Skip to content

Commit cb0473e

Browse files
mfijalkoborkmann
authored andcommitted
ice: Add xdp_buff to ice_rx_ring struct
In preparation for XDP multi-buffer support, let's store xdp_buff on Rx ring struct. This will allow us to combine fragmented frames across separate NAPI cycles in the same way as currently skb fragments are handled. This means that skb pointer on Rx ring will become redundant and will be removed. For now it is kept and layout of Rx ring struct was not inspected, some member movement will be needed later on so that will be the time to take care of it. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com> Link: https://lore.kernel.org/bpf/20230131204506.219292-3-maciej.fijalkowski@intel.com
1 parent c61bceb commit cb0473e

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ int ice_vsi_cfg_rxq(struct ice_rx_ring *ring)
533533
}
534534
}
535535

536+
xdp_init_buff(&ring->xdp, ice_rx_pg_size(ring) / 2, &ring->xdp_rxq);
536537
err = ice_setup_rx_ctx(ring);
537538
if (err) {
538539
dev_err(dev, "ice_setup_rx_ctx failed for RxQ %d, err %d\n",

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

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,16 @@ int ice_setup_rx_ring(struct ice_rx_ring *rx_ring)
523523
return -ENOMEM;
524524
}
525525

526+
/**
527+
* ice_rx_frame_truesize
528+
* @rx_ring: ptr to Rx ring
529+
* @size: size
530+
*
531+
* calculate the truesize with taking into the account PAGE_SIZE of
532+
* underlying arch
533+
*/
526534
static unsigned int
527-
ice_rx_frame_truesize(struct ice_rx_ring *rx_ring, unsigned int __maybe_unused size)
535+
ice_rx_frame_truesize(struct ice_rx_ring *rx_ring, const unsigned int size)
528536
{
529537
unsigned int truesize;
530538

@@ -1103,21 +1111,20 @@ ice_is_non_eop(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc)
11031111
*/
11041112
int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
11051113
{
1106-
unsigned int total_rx_bytes = 0, total_rx_pkts = 0, frame_sz = 0;
1114+
unsigned int total_rx_bytes = 0, total_rx_pkts = 0;
11071115
u16 cleaned_count = ICE_DESC_UNUSED(rx_ring);
11081116
unsigned int offset = rx_ring->rx_offset;
1117+
struct xdp_buff *xdp = &rx_ring->xdp;
11091118
struct ice_tx_ring *xdp_ring = NULL;
11101119
unsigned int xdp_res, xdp_xmit = 0;
11111120
struct sk_buff *skb = rx_ring->skb;
11121121
struct bpf_prog *xdp_prog = NULL;
1113-
struct xdp_buff xdp;
11141122
bool failure;
11151123

11161124
/* Frame size depend on rx_ring setup when PAGE_SIZE=4K */
11171125
#if (PAGE_SIZE < 8192)
1118-
frame_sz = ice_rx_frame_truesize(rx_ring, 0);
1126+
xdp->frame_sz = ice_rx_frame_truesize(rx_ring, 0);
11191127
#endif
1120-
xdp_init_buff(&xdp, frame_sz, &rx_ring->xdp_rxq);
11211128

11221129
xdp_prog = READ_ONCE(rx_ring->xdp_prog);
11231130
if (xdp_prog)
@@ -1171,30 +1178,30 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
11711178
rx_buf = ice_get_rx_buf(rx_ring, size, &rx_buf_pgcnt);
11721179

11731180
if (!size) {
1174-
xdp.data = NULL;
1175-
xdp.data_end = NULL;
1176-
xdp.data_hard_start = NULL;
1177-
xdp.data_meta = NULL;
1181+
xdp->data = NULL;
1182+
xdp->data_end = NULL;
1183+
xdp->data_hard_start = NULL;
1184+
xdp->data_meta = NULL;
11781185
goto construct_skb;
11791186
}
11801187

11811188
hard_start = page_address(rx_buf->page) + rx_buf->page_offset -
11821189
offset;
1183-
xdp_prepare_buff(&xdp, hard_start, offset, size, !!offset);
1190+
xdp_prepare_buff(xdp, hard_start, offset, size, !!offset);
11841191
#if (PAGE_SIZE > 4096)
11851192
/* At larger PAGE_SIZE, frame_sz depend on len size */
1186-
xdp.frame_sz = ice_rx_frame_truesize(rx_ring, size);
1193+
xdp->frame_sz = ice_rx_frame_truesize(rx_ring, size);
11871194
#endif
11881195

11891196
if (!xdp_prog)
11901197
goto construct_skb;
11911198

1192-
xdp_res = ice_run_xdp(rx_ring, &xdp, xdp_prog, xdp_ring);
1199+
xdp_res = ice_run_xdp(rx_ring, xdp, xdp_prog, xdp_ring);
11931200
if (!xdp_res)
11941201
goto construct_skb;
11951202
if (xdp_res & (ICE_XDP_TX | ICE_XDP_REDIR)) {
11961203
xdp_xmit |= xdp_res;
1197-
ice_rx_buf_adjust_pg_offset(rx_buf, xdp.frame_sz);
1204+
ice_rx_buf_adjust_pg_offset(rx_buf, xdp->frame_sz);
11981205
} else {
11991206
rx_buf->pagecnt_bias++;
12001207
}
@@ -1207,11 +1214,11 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
12071214
construct_skb:
12081215
if (skb) {
12091216
ice_add_rx_frag(rx_ring, rx_buf, skb, size);
1210-
} else if (likely(xdp.data)) {
1217+
} else if (likely(xdp->data)) {
12111218
if (ice_ring_uses_build_skb(rx_ring))
1212-
skb = ice_build_skb(rx_ring, rx_buf, &xdp);
1219+
skb = ice_build_skb(rx_ring, rx_buf, xdp);
12131220
else
1214-
skb = ice_construct_skb(rx_ring, rx_buf, &xdp);
1221+
skb = ice_construct_skb(rx_ring, rx_buf, xdp);
12151222
}
12161223
/* exit if we failed to retrieve a buffer */
12171224
if (!skb) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ struct ice_rx_ring {
303303
struct bpf_prog *xdp_prog;
304304
struct ice_tx_ring *xdp_ring;
305305
struct xsk_buff_pool *xsk_pool;
306+
struct xdp_buff xdp;
306307
struct sk_buff *skb;
307308
dma_addr_t dma; /* physical address of ring */
308309
u64 cached_phctime;

0 commit comments

Comments
 (0)