Skip to content

Commit 3dd411e

Browse files
mfijalkoborkmann
authored andcommitted
ice: Make Tx threshold dependent on ring length
XDP_TX workloads use a concept of Tx threshold that indicates the interval of setting RS bit on descriptors which in turn tells the HW to generate an interrupt to signal the completion of Tx on HW side. It is currently based on a constant value of 32 which might not work out well for various sizes of ring combined with for example batch size that can be set via SO_BUSY_POLL_BUDGET. Internal tests based on AF_XDP showed that most convenient setup of mentioned threshold is when it is equal to quarter of a ring length. Make use of recently introduced ICE_RING_QUARTER macro and use this value as a substitute for ICE_TX_THRESH. Align also ethtool -G callback so that next_dd/next_rs fields are up to date in terms of the ring size. 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> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20220125160446.78976-5-maciej.fijalkowski@intel.com
1 parent 3876ff5 commit 3dd411e

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

Diff for: drivers/net/ethernet/intel/ice/ice_ethtool.c

+2
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,8 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring,
28032803
/* clone ring and setup updated count */
28042804
xdp_rings[i] = *vsi->xdp_rings[i];
28052805
xdp_rings[i].count = new_tx_cnt;
2806+
xdp_rings[i].next_dd = ICE_RING_QUARTER(&xdp_rings[i]) - 1;
2807+
xdp_rings[i].next_rs = ICE_RING_QUARTER(&xdp_rings[i]) - 1;
28062808
xdp_rings[i].desc = NULL;
28072809
xdp_rings[i].tx_buf = NULL;
28082810
err = ice_setup_tx_ring(&xdp_rings[i]);

Diff for: drivers/net/ethernet/intel/ice/ice_main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2495,10 +2495,10 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)
24952495
xdp_ring->reg_idx = vsi->txq_map[xdp_q_idx];
24962496
xdp_ring->vsi = vsi;
24972497
xdp_ring->netdev = NULL;
2498-
xdp_ring->next_dd = ICE_TX_THRESH - 1;
2499-
xdp_ring->next_rs = ICE_TX_THRESH - 1;
25002498
xdp_ring->dev = dev;
25012499
xdp_ring->count = vsi->num_tx_desc;
2500+
xdp_ring->next_dd = ICE_RING_QUARTER(xdp_ring) - 1;
2501+
xdp_ring->next_rs = ICE_RING_QUARTER(xdp_ring) - 1;
25022502
WRITE_ONCE(vsi->xdp_rings[i], xdp_ring);
25032503
if (ice_setup_tx_ring(xdp_ring))
25042504
goto free_xdp_rings;

Diff for: drivers/net/ethernet/intel/ice/ice_txrx.h

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#define ICE_MAX_CHAINED_RX_BUFS 5
1414
#define ICE_MAX_BUF_TXD 8
1515
#define ICE_MIN_TX_LEN 17
16-
#define ICE_TX_THRESH 32
1716

1817
/* The size limit for a transmit buffer in a descriptor is (16K - 1).
1918
* In order to align with the read requests we will align the value to

Diff for: drivers/net/ethernet/intel/ice/ice_txrx_lib.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ ice_receive_skb(struct ice_rx_ring *rx_ring, struct sk_buff *skb, u16 vlan_tag)
222222
static void ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
223223
{
224224
unsigned int total_bytes = 0, total_pkts = 0;
225+
u16 tx_thresh = ICE_RING_QUARTER(xdp_ring);
225226
u16 ntc = xdp_ring->next_to_clean;
226227
struct ice_tx_desc *next_dd_desc;
227228
u16 next_dd = xdp_ring->next_dd;
@@ -233,7 +234,7 @@ static void ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
233234
cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE)))
234235
return;
235236

236-
for (i = 0; i < ICE_TX_THRESH; i++) {
237+
for (i = 0; i < tx_thresh; i++) {
237238
tx_buf = &xdp_ring->tx_buf[ntc];
238239

239240
total_bytes += tx_buf->bytecount;
@@ -254,9 +255,9 @@ static void ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
254255
}
255256

256257
next_dd_desc->cmd_type_offset_bsz = 0;
257-
xdp_ring->next_dd = xdp_ring->next_dd + ICE_TX_THRESH;
258+
xdp_ring->next_dd = xdp_ring->next_dd + tx_thresh;
258259
if (xdp_ring->next_dd > xdp_ring->count)
259-
xdp_ring->next_dd = ICE_TX_THRESH - 1;
260+
xdp_ring->next_dd = tx_thresh - 1;
260261
xdp_ring->next_to_clean = ntc;
261262
ice_update_tx_ring_stats(xdp_ring, total_pkts, total_bytes);
262263
}
@@ -269,12 +270,13 @@ static void ice_clean_xdp_irq(struct ice_tx_ring *xdp_ring)
269270
*/
270271
int ice_xmit_xdp_ring(void *data, u16 size, struct ice_tx_ring *xdp_ring)
271272
{
273+
u16 tx_thresh = ICE_RING_QUARTER(xdp_ring);
272274
u16 i = xdp_ring->next_to_use;
273275
struct ice_tx_desc *tx_desc;
274276
struct ice_tx_buf *tx_buf;
275277
dma_addr_t dma;
276278

277-
if (ICE_DESC_UNUSED(xdp_ring) < ICE_TX_THRESH)
279+
if (ICE_DESC_UNUSED(xdp_ring) < tx_thresh)
278280
ice_clean_xdp_irq(xdp_ring);
279281

280282
if (!unlikely(ICE_DESC_UNUSED(xdp_ring))) {
@@ -306,15 +308,15 @@ int ice_xmit_xdp_ring(void *data, u16 size, struct ice_tx_ring *xdp_ring)
306308
tx_desc = ICE_TX_DESC(xdp_ring, xdp_ring->next_rs);
307309
tx_desc->cmd_type_offset_bsz |=
308310
cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S);
309-
xdp_ring->next_rs = ICE_TX_THRESH - 1;
311+
xdp_ring->next_rs = tx_thresh - 1;
310312
}
311313
xdp_ring->next_to_use = i;
312314

313315
if (i > xdp_ring->next_rs) {
314316
tx_desc = ICE_TX_DESC(xdp_ring, xdp_ring->next_rs);
315317
tx_desc->cmd_type_offset_bsz |=
316318
cpu_to_le64(ICE_TX_DESC_CMD_RS << ICE_TXD_QW1_CMD_S);
317-
xdp_ring->next_rs += ICE_TX_THRESH;
319+
xdp_ring->next_rs += tx_thresh;
318320
}
319321

320322
return ICE_XDP_TX;

0 commit comments

Comments
 (0)