Skip to content

Commit 56b3c6b

Browse files
WeiFang-NXPPaolo Abeni
authored andcommitted
net: fec: increase the size of tx ring and update tx_wake_threshold
When the XDP feature is enabled and with heavy XDP frames to be transmitted, there is a considerable probability that available tx BDs are insufficient. This will lead to some XDP frames to be discarded and the "NOT enough BD for SG!" error log will appear in the console (as shown below). [ 160.013112] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.023116] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.028926] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.038946] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.044758] fec 30be0000.ethernet eth0: NOT enough BD for SG! In the case of heavy XDP traffic, sometimes the speed of recycling tx BDs may be slower than the speed of sending XDP frames. There may be several specific reasons, such as the interrupt is not responsed in time, the efficiency of the NAPI callback function is too low due to all the queues (tx queues and rx queues) share the same NAPI, and so on. After trying various methods, I think that increase the size of tx BD ring is simple and effective. Maybe the best resolution is that allocate NAPI for each queue to improve the efficiency of the NAPI callback, but this change is a bit big and I didn't try this method. Perheps this method will be implemented in a future patch. This patch also updates the tx_wake_threshold of tx ring which is related to the size of tx ring in the previous logic. Otherwise, the tx_wake_threshold will be too high (403 BDs), which is more likely to impact the slow path in the case of heavy XDP traffic, because XDP path and slow path share the tx BD rings. According to Jakub's suggestion, the tx_wake_threshold is at least equal to tx_stop_threshold + 2 * MAX_SKB_FRAGS, if a queue of hundreds of entries is overflowing, we should be able to apply a hysteresis of a few tens of entries. Fixes: 6d6b39f ("net: fec: add initial XDP support") Signed-off-by: Wei Fang <wei.fang@nxp.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 20f7973 commit 56b3c6b

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/net/ethernet/freescale/fec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ struct bufdesc_ex {
355355
#define RX_RING_SIZE (FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES)
356356
#define FEC_ENET_TX_FRSIZE 2048
357357
#define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE)
358-
#define TX_RING_SIZE 512 /* Must be power of two */
358+
#define TX_RING_SIZE 1024 /* Must be power of two */
359359
#define TX_RING_MOD_MASK 511 /* for this to work */
360360

361361
#define BD_ENET_RX_INT 0x00800000

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,8 +3349,7 @@ static int fec_enet_alloc_queue(struct net_device *ndev)
33493349
fep->total_tx_ring_size += fep->tx_queue[i]->bd.ring_size;
33503350

33513351
txq->tx_stop_threshold = FEC_MAX_SKB_DESCS;
3352-
txq->tx_wake_threshold =
3353-
(txq->bd.ring_size - txq->tx_stop_threshold) / 2;
3352+
txq->tx_wake_threshold = FEC_MAX_SKB_DESCS + 2 * MAX_SKB_FRAGS;
33543353

33553354
txq->tso_hdrs = dma_alloc_coherent(&fep->pdev->dev,
33563355
txq->bd.ring_size * TSO_HEADER_SIZE,

0 commit comments

Comments
 (0)