Skip to content

Commit c728a95

Browse files
Wei Fangkuba-moo
Wei Fang
authored andcommitted
net: enetc: block concurrent XDP transmissions during ring reconfiguration
When testing the XDP_REDIRECT function on the LS1028A platform, we found a very reproducible issue that the Tx frames can no longer be sent out even if XDP_REDIRECT is turned off. Specifically, if there is a lot of traffic on Rx direction, when XDP_REDIRECT is turned on, the console may display some warnings like "timeout for tx ring #6 clear", and all redirected frames will be dropped, the detailed log is as follows. root@ls1028ardb:~# ./xdp-bench redirect eno0 eno2 Redirecting from eno0 (ifindex 3; driver fsl_enetc) to eno2 (ifindex 4; driver fsl_enetc) [203.849809] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #5 clear [204.006051] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #6 clear [204.161944] fsl_enetc 0000:00:00.2 eno2: timeout for tx ring #7 clear eno0->eno2 1420505 rx/s 1420590 err,drop/s 0 xmit/s xmit eno0->eno2 0 xmit/s 1420590 drop/s 0 drv_err/s 15.71 bulk-avg eno0->eno2 1420484 rx/s 1420485 err,drop/s 0 xmit/s xmit eno0->eno2 0 xmit/s 1420485 drop/s 0 drv_err/s 15.71 bulk-avg By analyzing the XDP_REDIRECT implementation of enetc driver, the driver will reconfigure Tx and Rx BD rings when a bpf program is installed or uninstalled, but there is no mechanisms to block the redirected frames when enetc driver reconfigures rings. Similarly, XDP_TX verdicts on received frames can also lead to frames being enqueued in the Tx rings. Because XDP ignores the state set by the netif_tx_wake_queue() API, so introduce the ENETC_TX_DOWN flag to suppress transmission of XDP frames. Fixes: c33bfaf ("net: enetc: set up XDP program under enetc_reconfigure()") Cc: [email protected] Signed-off-by: Wei Fang <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 412950d commit c728a95

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

+14
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget)
902902

903903
if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) &&
904904
__netif_subqueue_stopped(ndev, tx_ring->index) &&
905+
!test_bit(ENETC_TX_DOWN, &priv->flags) &&
905906
(enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) {
906907
netif_wake_subqueue(ndev, tx_ring->index);
907908
}
@@ -1377,6 +1378,9 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames,
13771378
int xdp_tx_bd_cnt, i, k;
13781379
int xdp_tx_frm_cnt = 0;
13791380

1381+
if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags)))
1382+
return -ENETDOWN;
1383+
13801384
enetc_lock_mdio();
13811385

13821386
tx_ring = priv->xdp_tx_ring[smp_processor_id()];
@@ -1602,6 +1606,12 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
16021606
break;
16031607
case XDP_TX:
16041608
tx_ring = priv->xdp_tx_ring[rx_ring->index];
1609+
if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags))) {
1610+
enetc_xdp_drop(rx_ring, orig_i, i);
1611+
tx_ring->stats.xdp_tx_drops++;
1612+
break;
1613+
}
1614+
16051615
xdp_tx_bd_cnt = enetc_rx_swbd_to_xdp_tx_swbd(xdp_tx_arr,
16061616
rx_ring,
16071617
orig_i, i);
@@ -2463,6 +2473,8 @@ void enetc_start(struct net_device *ndev)
24632473
enetc_enable_bdrs(priv);
24642474

24652475
netif_tx_start_all_queues(ndev);
2476+
2477+
clear_bit(ENETC_TX_DOWN, &priv->flags);
24662478
}
24672479
EXPORT_SYMBOL_GPL(enetc_start);
24682480

@@ -2520,6 +2532,8 @@ void enetc_stop(struct net_device *ndev)
25202532
struct enetc_ndev_priv *priv = netdev_priv(ndev);
25212533
int i;
25222534

2535+
set_bit(ENETC_TX_DOWN, &priv->flags);
2536+
25232537
netif_tx_stop_all_queues(ndev);
25242538

25252539
enetc_disable_bdrs(priv);

drivers/net/ethernet/freescale/enetc/enetc.h

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ enum enetc_active_offloads {
325325

326326
enum enetc_flags_bit {
327327
ENETC_TX_ONESTEP_TSTAMP_IN_PROGRESS = 0,
328+
ENETC_TX_DOWN,
328329
};
329330

330331
/* interrupt coalescing modes */

0 commit comments

Comments
 (0)