Skip to content

Commit c5f57ce

Browse files
committed
Merge: ice: fixes for PAGE_SIZE over 8KB
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5130 JIRA: https://issues.redhat.com/browse/RHEL-37905 Fixes for PAGE_SIZE over 8KB Signed-off-by: Petr Oros <poros@redhat.com> Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com> Approved-by: Ivan Vecera <ivecera@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents b879ff7 + 811001a commit c5f57ce

File tree

2 files changed

+24
-44
lines changed

2 files changed

+24
-44
lines changed

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,25 @@ static void ice_xsk_pool_fill_cb(struct ice_rx_ring *ring)
512512
xsk_pool_fill_cb(ring->xsk_pool, &desc);
513513
}
514514

515+
/**
516+
* ice_get_frame_sz - calculate xdp_buff::frame_sz
517+
* @rx_ring: the ring being configured
518+
*
519+
* Return frame size based on underlying PAGE_SIZE
520+
*/
521+
static unsigned int ice_get_frame_sz(struct ice_rx_ring *rx_ring)
522+
{
523+
unsigned int frame_sz;
524+
525+
#if (PAGE_SIZE >= 8192)
526+
frame_sz = rx_ring->rx_buf_len;
527+
#else
528+
frame_sz = ice_rx_pg_size(rx_ring) / 2;
529+
#endif
530+
531+
return frame_sz;
532+
}
533+
515534
/**
516535
* ice_vsi_cfg_rxq - Configure an Rx queue
517536
* @ring: the ring being configured
@@ -576,7 +595,7 @@ static int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
576595
}
577596
}
578597

579-
xdp_init_buff(&ring->xdp, ice_rx_pg_size(ring) / 2, &ring->xdp_rxq);
598+
xdp_init_buff(&ring->xdp, ice_get_frame_sz(ring), &ring->xdp_rxq);
580599
ring->xdp.data = NULL;
581600
ring->xdp_ext.pkt_ctx = &ring->pkt_ctx;
582601
err = ice_setup_rx_ctx(ring);

drivers/net/ethernet/intel/ice/ice_txrx.c

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -521,30 +521,6 @@ int ice_setup_rx_ring(struct ice_rx_ring *rx_ring)
521521
return -ENOMEM;
522522
}
523523

524-
/**
525-
* ice_rx_frame_truesize
526-
* @rx_ring: ptr to Rx ring
527-
* @size: size
528-
*
529-
* calculate the truesize with taking into the account PAGE_SIZE of
530-
* underlying arch
531-
*/
532-
static unsigned int
533-
ice_rx_frame_truesize(struct ice_rx_ring *rx_ring, const unsigned int size)
534-
{
535-
unsigned int truesize;
536-
537-
#if (PAGE_SIZE < 8192)
538-
truesize = ice_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */
539-
#else
540-
truesize = rx_ring->rx_offset ?
541-
SKB_DATA_ALIGN(rx_ring->rx_offset + size) +
542-
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) :
543-
SKB_DATA_ALIGN(size);
544-
#endif
545-
return truesize;
546-
}
547-
548524
/**
549525
* ice_run_xdp - Executes an XDP program on initialized xdp_buff
550526
* @rx_ring: Rx ring
@@ -837,16 +813,15 @@ ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)
837813
if (!dev_page_is_reusable(page))
838814
return false;
839815

840-
#if (PAGE_SIZE < 8192)
841816
/* if we are only owner of page we can reuse it */
842817
if (unlikely(rx_buf->pgcnt - pagecnt_bias > 1))
843818
return false;
844-
#else
819+
#if (PAGE_SIZE >= 8192)
845820
#define ICE_LAST_OFFSET \
846-
(SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_2048)
821+
(SKB_WITH_OVERHEAD(PAGE_SIZE) - ICE_RXBUF_3072)
847822
if (rx_buf->page_offset > ICE_LAST_OFFSET)
848823
return false;
849-
#endif /* PAGE_SIZE < 8192) */
824+
#endif /* PAGE_SIZE >= 8192) */
850825

851826
/* If we have drained the page fragment pool we need to update
852827
* the pagecnt_bias and page count so that we fully restock the
@@ -949,12 +924,7 @@ ice_get_rx_buf(struct ice_rx_ring *rx_ring, const unsigned int size,
949924
struct ice_rx_buf *rx_buf;
950925

951926
rx_buf = &rx_ring->rx_buf[ntc];
952-
rx_buf->pgcnt =
953-
#if (PAGE_SIZE < 8192)
954-
page_count(rx_buf->page);
955-
#else
956-
0;
957-
#endif
927+
rx_buf->pgcnt = page_count(rx_buf->page);
958928
prefetchw(rx_buf->page);
959929

960930
if (!size)
@@ -1160,11 +1130,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
11601130
bool failure;
11611131
u32 first;
11621132

1163-
/* Frame size depend on rx_ring setup when PAGE_SIZE=4K */
1164-
#if (PAGE_SIZE < 8192)
1165-
xdp->frame_sz = ice_rx_frame_truesize(rx_ring, 0);
1166-
#endif
1167-
11681133
xdp_prog = READ_ONCE(rx_ring->xdp_prog);
11691134
if (xdp_prog) {
11701135
xdp_ring = rx_ring->xdp_ring;
@@ -1223,10 +1188,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
12231188
hard_start = page_address(rx_buf->page) + rx_buf->page_offset -
12241189
offset;
12251190
xdp_prepare_buff(xdp, hard_start, offset, size, !!offset);
1226-
#if (PAGE_SIZE > 4096)
1227-
/* At larger PAGE_SIZE, frame_sz depend on len size */
1228-
xdp->frame_sz = ice_rx_frame_truesize(rx_ring, size);
1229-
#endif
12301191
xdp_buff_clear_frags_flag(xdp);
12311192
} else if (ice_add_xdp_frag(rx_ring, xdp, rx_buf, size)) {
12321193
break;

0 commit comments

Comments
 (0)