Skip to content

Commit 743bbd9

Browse files
mfijalkoanguy11
authored andcommitted
ice: put Rx buffers after being done with current frame
Introduce a new helper ice_put_rx_mbuf() that will go through gathered frags from current frame and will call ice_put_rx_buf() on them. Current logic that was supposed to simplify and optimize the driver where we go through a batch of all buffers processed in current NAPI instance turned out to be broken for jumbo frames and very heavy load that was coming from both multi-thread iperf and nginx/wrk pair between server and client. The delay introduced by approach that we are dropping is simply too big and we need to take the decision regarding page recycling/releasing as quick as we can. While at it, address an error path of ice_add_xdp_frag() - we were missing buffer putting from day 1 there. As a nice side effect we get rid of annoying and repetitive three-liner: xdp->data = NULL; rx_ring->first_desc = ntc; rx_ring->nr_frags = 0; by embedding it within introduced routine. Fixes: 1dc1a7e ("ice: Centrallize Rx buffer recycling") Reported-and-tested-by: Xu Du <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Simon Horman <[email protected]> Co-developed-by: Jacob Keller <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: Maciej Fijalkowski <[email protected]> Tested-by: Chandan Kumar Rout <[email protected]> (A Contingent Worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent c2933b2 commit 743bbd9

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

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

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,49 @@ ice_put_rx_buf(struct ice_rx_ring *rx_ring, struct ice_rx_buf *rx_buf)
11031103
rx_buf->page = NULL;
11041104
}
11051105

1106+
/**
1107+
* ice_put_rx_mbuf - ice_put_rx_buf() caller, for all frame frags
1108+
* @rx_ring: Rx ring with all the auxiliary data
1109+
* @xdp: XDP buffer carrying linear + frags part
1110+
* @xdp_xmit: XDP_TX/XDP_REDIRECT verdict storage
1111+
* @ntc: a current next_to_clean value to be stored at rx_ring
1112+
*
1113+
* Walk through gathered fragments and satisfy internal page
1114+
* recycle mechanism; we take here an action related to verdict
1115+
* returned by XDP program;
1116+
*/
1117+
static void ice_put_rx_mbuf(struct ice_rx_ring *rx_ring, struct xdp_buff *xdp,
1118+
u32 *xdp_xmit, u32 ntc)
1119+
{
1120+
u32 nr_frags = rx_ring->nr_frags + 1;
1121+
u32 idx = rx_ring->first_desc;
1122+
u32 cnt = rx_ring->count;
1123+
struct ice_rx_buf *buf;
1124+
int i;
1125+
1126+
for (i = 0; i < nr_frags; i++) {
1127+
buf = &rx_ring->rx_buf[idx];
1128+
1129+
if (buf->act & (ICE_XDP_TX | ICE_XDP_REDIR)) {
1130+
ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz);
1131+
*xdp_xmit |= buf->act;
1132+
} else if (buf->act & ICE_XDP_CONSUMED) {
1133+
buf->pagecnt_bias++;
1134+
} else if (buf->act == ICE_XDP_PASS) {
1135+
ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz);
1136+
}
1137+
1138+
ice_put_rx_buf(rx_ring, buf);
1139+
1140+
if (++idx == cnt)
1141+
idx = 0;
1142+
}
1143+
1144+
xdp->data = NULL;
1145+
rx_ring->first_desc = ntc;
1146+
rx_ring->nr_frags = 0;
1147+
}
1148+
11061149
/**
11071150
* ice_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf
11081151
* @rx_ring: Rx descriptor ring to transact packets on
@@ -1120,15 +1163,13 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
11201163
unsigned int total_rx_bytes = 0, total_rx_pkts = 0;
11211164
unsigned int offset = rx_ring->rx_offset;
11221165
struct xdp_buff *xdp = &rx_ring->xdp;
1123-
u32 cached_ntc = rx_ring->first_desc;
11241166
struct ice_tx_ring *xdp_ring = NULL;
11251167
struct bpf_prog *xdp_prog = NULL;
11261168
u32 ntc = rx_ring->next_to_clean;
11271169
u32 cnt = rx_ring->count;
11281170
u32 xdp_xmit = 0;
11291171
u32 cached_ntu;
11301172
bool failure;
1131-
u32 first;
11321173

11331174
xdp_prog = READ_ONCE(rx_ring->xdp_prog);
11341175
if (xdp_prog) {
@@ -1190,6 +1231,7 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
11901231
xdp_prepare_buff(xdp, hard_start, offset, size, !!offset);
11911232
xdp_buff_clear_frags_flag(xdp);
11921233
} else if (ice_add_xdp_frag(rx_ring, xdp, rx_buf, size)) {
1234+
ice_put_rx_mbuf(rx_ring, xdp, NULL, ntc);
11931235
break;
11941236
}
11951237
if (++ntc == cnt)
@@ -1205,9 +1247,8 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
12051247
total_rx_bytes += xdp_get_buff_len(xdp);
12061248
total_rx_pkts++;
12071249

1208-
xdp->data = NULL;
1209-
rx_ring->first_desc = ntc;
1210-
rx_ring->nr_frags = 0;
1250+
ice_put_rx_mbuf(rx_ring, xdp, &xdp_xmit, ntc);
1251+
12111252
continue;
12121253
construct_skb:
12131254
if (likely(ice_ring_uses_build_skb(rx_ring)))
@@ -1221,14 +1262,11 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
12211262
if (unlikely(xdp_buff_has_frags(xdp)))
12221263
ice_set_rx_bufs_act(xdp, rx_ring,
12231264
ICE_XDP_CONSUMED);
1224-
xdp->data = NULL;
1225-
rx_ring->first_desc = ntc;
1226-
rx_ring->nr_frags = 0;
1227-
break;
12281265
}
1229-
xdp->data = NULL;
1230-
rx_ring->first_desc = ntc;
1231-
rx_ring->nr_frags = 0;
1266+
ice_put_rx_mbuf(rx_ring, xdp, &xdp_xmit, ntc);
1267+
1268+
if (!skb)
1269+
break;
12321270

12331271
stat_err_bits = BIT(ICE_RX_FLEX_DESC_STATUS0_RXE_S);
12341272
if (unlikely(ice_test_staterr(rx_desc->wb.status_error0,
@@ -1257,23 +1295,6 @@ int ice_clean_rx_irq(struct ice_rx_ring *rx_ring, int budget)
12571295
total_rx_pkts++;
12581296
}
12591297

1260-
first = rx_ring->first_desc;
1261-
while (cached_ntc != first) {
1262-
struct ice_rx_buf *buf = &rx_ring->rx_buf[cached_ntc];
1263-
1264-
if (buf->act & (ICE_XDP_TX | ICE_XDP_REDIR)) {
1265-
ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz);
1266-
xdp_xmit |= buf->act;
1267-
} else if (buf->act & ICE_XDP_CONSUMED) {
1268-
buf->pagecnt_bias++;
1269-
} else if (buf->act == ICE_XDP_PASS) {
1270-
ice_rx_buf_adjust_pg_offset(buf, xdp->frame_sz);
1271-
}
1272-
1273-
ice_put_rx_buf(rx_ring, buf);
1274-
if (++cached_ntc >= cnt)
1275-
cached_ntc = 0;
1276-
}
12771298
rx_ring->next_to_clean = ntc;
12781299
/* return up to cleaned_count buffers to hardware */
12791300
failure = ice_alloc_rx_bufs(rx_ring, ICE_RX_DESC_UNUSED(rx_ring));

0 commit comments

Comments
 (0)