Skip to content

Commit be7ecbe

Browse files
WeiFang-NXPPaolo Abeni
authored andcommitted
net: fec: dynamically set the NETDEV_XDP_ACT_NDO_XMIT feature of XDP
When a XDP program is installed or uninstalled, fec_restart() will be invoked to reset MAC and buffer descriptor rings. It's reasonable not to transmit any packet during the process of reset. However, the NETDEV_XDP_ACT_NDO_XMIT bit of xdp_features is enabled by default, that is to say, it's possible that the fec_enet_xdp_xmit() will be invoked even if the process of reset is not finished. In this case, the redirected XDP frames might be dropped and available transmit BDs may be incorrectly deemed insufficient. So this patch disable the NETDEV_XDP_ACT_NDO_XMIT feature by default and dynamically configure this feature when the bpf program is installed or uninstalled. Fixes: e4ac7cc ("net: fec: turn on XDP features") Signed-off-by: Wei Fang <wei.fang@nxp.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 9d0aba9 commit be7ecbe

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,21 +3732,27 @@ static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf)
37323732
if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
37333733
return -EOPNOTSUPP;
37343734

3735+
if (!bpf->prog)
3736+
xdp_features_clear_redirect_target(dev);
3737+
37353738
if (is_run) {
37363739
napi_disable(&fep->napi);
37373740
netif_tx_disable(dev);
37383741
}
37393742

37403743
old_prog = xchg(&fep->xdp_prog, bpf->prog);
3744+
if (old_prog)
3745+
bpf_prog_put(old_prog);
3746+
37413747
fec_restart(dev);
37423748

37433749
if (is_run) {
37443750
napi_enable(&fep->napi);
37453751
netif_tx_start_all_queues(dev);
37463752
}
37473753

3748-
if (old_prog)
3749-
bpf_prog_put(old_prog);
3754+
if (bpf->prog)
3755+
xdp_features_set_redirect_target(dev, false);
37503756

37513757
return 0;
37523758

@@ -4016,8 +4022,7 @@ static int fec_enet_init(struct net_device *ndev)
40164022

40174023
if (!(fep->quirks & FEC_QUIRK_SWAP_FRAME))
40184024
ndev->xdp_features = NETDEV_XDP_ACT_BASIC |
4019-
NETDEV_XDP_ACT_REDIRECT |
4020-
NETDEV_XDP_ACT_NDO_XMIT;
4025+
NETDEV_XDP_ACT_REDIRECT;
40214026

40224027
fec_restart(ndev);
40234028

0 commit comments

Comments
 (0)