bnxt: don't reject XDP installation when HDS isn't forced on
Subsystems (5)
Jakub Kicinski
maintainerPATCH 1/2 bnxt: don't reject XDP installation when HDS isn't forced on
HDS flag is often set because GRO-HW is enabled. But we call bnxt_set_rx_skb_mode() later, which will clear it. So make sure we reject XDP when user asked for HDS, not when it's enabled for other reasons.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +3 -1
@@ -11,10 +11,12 @@#include <linux/pci.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/ethtool_netlink.h> #include <linux/if_vlan.h> #include <linux/bpf.h> #include <linux/bpf_trace.h> #include <linux/filter.h> +#include <net/netdev_queues.h> #include <net/page_pool/helpers.h> #include "bnxt_hsi.h" #include "bnxt.h"
@@ -395,7 +397,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU);return -EOPNOTSUPP ; } -if (prog && bp->flags &BNXT_FLAG_HDS ) { +if (prog && dev->cfg->hds_config ==ETHTOOL_TCP_DATA_SPLIT_ENABLED ) {netdev_warn (dev,"XDP is disallowed when HDS is enabled.\n" );return -EOPNOTSUPP ; }
Signature · 1 line
2.48.1
Jakub Kicinski
maintainerPATCH 2/2 selftests: drv-net: test installing XDP with HDS set to auto
Testing bnxt:
# NETIF=eth0 ./ksft-net-drv/drivers/net/hds.py
KTAP version 1
1..9
ok 1 hds.get_hds
ok 2 hds.get_hds_thresh
ok 3 hds.set_hds_disable # SKIP disabling of HDS not supported by the device ok 4 hds.set_hds_enable
ok 5 hds.set_hds_thresh_zero
ok 6 hds.set_hds_thresh_max
ok 7 hds.set_hds_thresh_gt
ok 8 hds.set_xdp
ok 9 hds.set_xdp_enabled
# Totals: pass:8 fail:0 xfail:0 xpass:0 skip:1 error:0
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- tools/testing/selftests/net/lib/Makefile | 3 + .../testing/selftests/net/lib/xdp_dummy.bpf.c | 13 +++++ tools/testing/selftests/drivers/net/hds.py | 55 ++++++++++++++++++- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/net/lib/xdp_dummy.bpf.c
tools/testing/selftests/net/lib/Makefile +3 -0
@@ -9,7 +9,10 @@ TEST_FILES := ../../../../../Documentation/netlink/specs TEST_FILES += ../../../../net/ynl TEST_GEN_FILES += csum +TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c)) TEST_INCLUDES := $(wildcard py/*.py sh/*.sh) include ../../lib.mk + +include ../bpf.mk
tools/testing/selftests/net/lib/xdp_dummy.bpf.c new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +#define KBUILD_MODNAME "xdp_dummy" +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> + +SEC("xdp") +int xdp_dummy_prog (struct xdp_md *ctx) +{ +return XDP_PASS ; +} + +char _license[] SEC("license") = "GPL";
tools/testing/selftests/drivers/net/hds.py +52 -3
82 lines not on this page · raw message
Signature · 1 line
2.48.1
Quoted 47 lines · Jakub Kicinski
HDS flag is often set because GRO-HW is enabled. But we call
bnxt_set_rx_skb_mode()later, which will clear it. So make sure we reject XDP when user asked for HDS, not when it's enabled for other reasons.Fixes 87c8f8496a05 ("bnxt_en: add support for tcp-data-split ethtool command")Signed-off-by Jakub Kicinski <[email protected]>---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +3
-1@@ -11,10 +11,12 @@#include <linux/pci.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/ethtool_netlink.h> #include <linux/if_vlan.h> #include <linux/bpf.h> #include <linux/bpf_trace.h> #include <linux/filter.h> +#include <net/netdev_queues.h> #include <net/page_pool/helpers.h> #include "bnxt_hsi.h" #include "bnxt.h" @@ -395,7 +397,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU);return -EOPNOTSUPP ; } -if (prog && bp->flags &BNXT_FLAG_HDS ) { +if (prog && dev->cfg->hds_config ==ETHTOOL_TCP_DATA_SPLIT_ENABLED ) {netdev_warn (dev,"XDP is disallowed when HDS is enabled.\n" );return -EOPNOTSUPP ; }Signature · 1 line
2.48.1
Nice, that fixed it.
Jakub Kicinski
maintainerQuoted 15 lines · On Wed, 19 Feb 2025 18:58:02 -0700 Daniel Xu wrote:
Quoted 12 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +1
-1@@ -395,7 +397,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU);return -EOPNOTSUPP ; } -if (prog && bp->flags &BNXT_FLAG_HDS ) { +if (prog && dev->cfg->hds_config ==ETHTOOL_TCP_DATA_SPLIT_ENABLED ) {netdev_warn (dev,"XDP is disallowed when HDS is enabled.\n" );return -EOPNOTSUPP ; }Signature · 1 line
2.48.1Nice, that fixed it.
Quoted 1 line
Tested-by Daniel Xu <[email protected]>
I looked again after sending because it wasn't sitting 100% well with me. As the commit message says this will work, because it forces all flags to off. But the driver is also only setting its internal flag when user requested. So why does it get set in the first place..
I think the real fix may be:
@@ -2071,6 +2072,8 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
dev->ethtool_ops->get_ringparam(dev, &max, &kernel_ringparam, NULL);
+ kernel_ringparam.tcp_data_split = dev->cfg->hds_config;
+
/* ensure new ring parameters are within the maximums */
if (ringparam.rx_pending > max.rx_max_pending ||
ringparam.rx_mini_pending > max.rx_mini_max_pending ||This is the legacy / ioctl path. We don't hit it in testing, but you probably hit it via systemd.
At least that's my current theory, waiting for the test kernel to deploy. Sorry for the flip flop..
On Thu, Feb 20, 2025 at 11:14 AM Jakub Kicinski <[email protected]> wrote:
Hi Jakub, Thank you so much for this fix!
Quoted 36 lines · On Wed, 19 Feb 2025 18:58:02 -0700 Daniel Xu wrote:
Quoted 15 lines
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +1
-2@@ -395,7 +397,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog) bp->dev->mtu, BNXT_MAX_PAGE_MODE_MTU);return -EOPNOTSUPP ; } -if (prog && bp->flags &BNXT_FLAG_HDS ) { +if (prog && dev->cfg->hds_config ==ETHTOOL_TCP_DATA_SPLIT_ENABLED ) {netdev_warn (dev,"XDP is disallowed when HDS is enabled.\n" );return -EOPNOTSUPP ; } --Quoted 2 lines
2.48.1
Nice, that fixed it.
Quoted 1 line
Tested-by Daniel Xu <[email protected]>I looked again after sending because it wasn't sitting 100% well with me. As the commit message says this will work, because it forces all flags to off. But the driver is also only setting its internal flag when user requested. So why does it get set in the first place..
I think the real fix may be:
(quoted diff) +2
-0@@ -2071,6 +2072,8 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr) dev->ethtool_ops->get_ringparam(dev, &max, &kernel_ringparam, NULL); + kernel_ringparam.tcp_data_split = dev->cfg->hds_config; + /* ensure new ring parameters are within the maximums */ if (ringparam.rx_pending > max.rx_max_pending || ringparam.rx_mini_pending > max.rx_mini_max_pending ||
Quoted 5 lines
This is the legacy / ioctl path. We don't hit it in testing, but you probably hit it via systemd.
At least that's my current theory, waiting for the test kernel to deploy. Sorry for the flip flop..
As you mentioned, I tested it with legacy/ioctl path.
How to reproduce:
ethtool -K eth0 lro on gro on
ethtool --disable-netlink -G eth0 rx 512
ip link set eth0 xdp obj xdp.o
With this change, I can't see this bug anymore.
Thanks a lot!
Taehee Yoo