bnxt_en: Add XDP RSS hash metadata
Subsystems (6)
cover bnxt_en: Add XDP RSS hash metadata
This patchset adds the ability to use an XDP program to extract the RSS hash of a given an xdp_md context.
For example this XDP program extracts hash and rss_type:
```
ret = bpf_xdp_metadata_rx_hash(ctx, &hash, &rss_type);
if (ret == 0) {
bpf_printk("XDP: RX hash=0x%x type=%02x", hash, rss_type);
}
```I was able to test this with a Broadcom BCM57414 NIC and verify that the rss_type and hash were correct for IPv4/6 TCP/UDP and ICMP traffic.
Chris J Arges (2):
bnxt_en: use bnxt_xdp_buff for xdp context
bnxt_en: Implement XDP RSS hash metadata extraction
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 29 ++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 9 ++++ 4 files changed, 77 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 bnxt_en: use bnxt_xdp_buff for xdp context
This adds bnxt_xdp_buff which embeds the xdp_buff struct and stores pointers to hardware RX completion descriptors (rx_cmp and rx_cmp_ext) along with the completion type.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 24 +++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 7 ++++++ 2 files changed, 21 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +14 -10
@@ -2115,7 +2115,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bool xdp_active = false;dma_addr_t dma_addr;struct sk_buff *skb; -struct xdp_buff xdp; +struct bnxt_xdp_buff bnxt_xdp;u32 flags, misc;u32 cmpl_ts;void *data;
@@ -2228,9 +2228,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, dma_addr = rx_buf->mapping;if (bnxt_xdp_attached (bp, rxr)) { -bnxt_xdp_buff_init (bp, rxr, cons, data_ptr, len, &xdp); + bnxt_xdp.rxcmp = rxcmp; + bnxt_xdp.rxcmp1 = rxcmp1; + bnxt_xdp.cmp_type = cmp_type; + +bnxt_xdp_buff_init (bp, rxr, cons, data_ptr, len, &bnxt_xdp.xdp);if (agg_bufs) { -u32 frag_len =bnxt_rx_agg_netmems_xdp (bp, cpr, &xdp, +u32 frag_len =bnxt_rx_agg_netmems_xdp (bp, cpr, &bnxt_xdp.xdp, cp_cons, agg_bufs, false);
@@ -2242,12 +2246,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, }if (xdp_active) { -if (bnxt_rx_xdp (bp, rxr, cons, &xdp, data, &data_ptr, &len, event)) { +if (bnxt_rx_xdp (bp, rxr, cons, &bnxt_xdp.xdp, data, &data_ptr, &len, event)) { rc =1 ; goto next_rx; } -if (xdp_buff_has_frags (&xdp)) { - sinfo =xdp_get_shared_info_from_buff (&xdp); +if (xdp_buff_has_frags (&bnxt_xdp.xdp)) { + sinfo =xdp_get_shared_info_from_buff (&bnxt_xdp.xdp); agg_bufs = sinfo->nr_frags; }else { agg_bufs =0 ;
@@ -2258,7 +2262,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,if (!xdp_active) skb =bnxt_copy_skb (bnapi, data_ptr, len, dma_addr);else - skb =bnxt_copy_xdp (bnapi, &xdp, len, dma_addr); + skb =bnxt_copy_xdp (bnapi, &bnxt_xdp.xdp, len, dma_addr);bnxt_reuse_rx_data (rxr, cons, data);if (!skb) {if (agg_bufs) {
@@ -2266,7 +2270,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bnxt_reuse_rx_agg_bufs (cpr, cp_cons,0 , agg_bufs, false); else - bnxt_xdp_buff_frags_free(rxr, &xdp); + bnxt_xdp_buff_frags_free(rxr, &bnxt_xdp.xdp); } goto oom_next_rx; }
@@ -2291,10 +2295,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, goto oom_next_rx; }else { skb =bnxt_xdp_build_skb (bp, skb, agg_bufs, - rxr->page_pool, &xdp); + rxr->page_pool, &bnxt_xdp.xdp);if (!skb) {/* we should be able to free the old skb here */ -bnxt_xdp_buff_frags_free (rxr, &xdp); +bnxt_xdp_buff_frags_free (rxr, &bnxt_xdp.xdp); goto oom_next_rx; } }
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +7 -0
@@ -12,6 +12,13 @@DECLARE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_xdp_buff { +struct xdp_buff xdp; +struct rx_cmp *rxcmp; +struct rx_cmp_ext *rxcmp1; +u8 cmp_type; +}; + struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, dma_addr_t mapping, u32 len,
Signature · 1 line
2.43.0
PATCH 2/2 bnxt_en: Implement XDP RSS hash metadata extraction
In reply to Chris J ArgesAdd support for extracting RSS hash values and hash types from hardware completion descriptors in XDP programs for bnxt_en.
Add IP_TYPE definition for determining if completion is ipv4 or ipv6. In addition add ITYPE_ICMP flag for identifying ICMP completions.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 2 + 4 files changed, 56 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -0
@@ -15845,6 +15845,10 @@ static const struct net_device_ops bnxt_netdev_ops = { .ndo_hwtstamp_set = bnxt_hwtstamp_set, }; +static const struct xdp_metadata_ops bnxt_xdp_metadata_ops = { + .xmo_rx_hash = bnxt_xdp_rx_hash, +}; +static void bnxt_get_queue_stats_rx (struct net_device *dev,int i,struct netdev_queue_stats_rx *stats) {
@@ -16684,6 +16688,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto init_err_free; dev->netdev_ops = &bnxt_netdev_ops; + dev->xdp_metadata_ops = &bnxt_xdp_metadata_ops; dev->stat_ops = &bnxt_stat_ops; dev->watchdog_timeo =BNXT_TX_TIMEOUT ; dev->ethtool_ops = &bnxt_ethtool_ops;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -232,6 +232,7 @@ struct rx_cmp {#define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)#define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)#define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) +#define RX_CMP_FLAGS_ITYPE_ICMP (7 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)#define RX_CMP_LEN (0xffff << 16)
@@ -311,6 +312,7 @@ struct rx_cmp_ext {#define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)#define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)#define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) +#define RX_CMP_FLAGS2_IP_TYPE (0x1 << 8)__le32 rx_cmp_meta_data;#define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff#define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +47 -0
50 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +2 -0
@@ -41,4 +41,6 @@ void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr,struct sk_buff *bnxt_xdp_build_skb (struct bnxt *bp,struct sk_buff *skb,u8 num_frags,struct page_pool *pool,struct xdp_buff *xdp); +int bnxt_xdp_rx_hash (const struct xdp_md *ctx,u32 *hash, +enum xdp_rss_hash_type *rss_type);#endif
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH 2/2] bnxt_en: Implement XDP RSS hash metadata extraction
kernel test robot noticed the following build errors:
Hi Chris,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.19]
[cannot apply to linus/master next-20260213]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chris-J-Arges/bnxt_en-use-bnxt_xdp_buff-for-xdp-context/20260214-032849 base: v6.19 patch link: https://lore.kernel.org/r/20260213192449.1294830-3-carges%40cloudflare.com patch subject: [PATCH 2/2] bnxt_en: Implement XDP RSS hash metadata extraction config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260214/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260214/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
>> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:476:12: error: static declaration of 'bnxt_xdp_rx_hash' follows non-static declaration
476 | static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:22:
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h:44:5: note: previous declaration of 'bnxt_xdp_rx_hash' with type 'int(const struct xdp_md *, u32 *, enum xdp_rss_hash_type *)' {aka 'int(const struct xdp_md *, unsigned int *, enum xdp_rss_hash_type *)'}
44 | int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:476:12: warning: 'bnxt_xdp_rx_hash' defined but not used [-Wunused-function] 476 | static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
vim +/bnxt_xdp_rx_hash +476 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
475
> 476 static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/2] bnxt_en: Implement XDP RSS hash metadata extraction
In reply to Chris J Argeskernel test robot noticed the following build errors:
Hi Chris,
kernel test robot noticed the following build errors:
[auto build test ERROR on v6.19]
[cannot apply to linus/master next-20260213]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chris-J-Arges/bnxt_en-use-bnxt_xdp_buff-for-xdp-context/20260214-032849 base: v6.19 patch link: https://lore.kernel.org/r/20260213192449.1294830-3-carges%40cloudflare.com patch subject: [PATCH 2/2] bnxt_en: Implement XDP RSS hash metadata extraction config: openrisc-allmodconfig (https://download.01.org/0day-ci/archive/20260215/[email protected]/config) compiler: or1k-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260215/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
>> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:476:12: error: static declaration of 'bnxt_xdp_rx_hash' follows non-static declaration
476 | static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
In file included from drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:22:
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h:44:5: note: previous declaration of 'bnxt_xdp_rx_hash' with type 'int(const struct xdp_md *, u32 *, enum xdp_rss_hash_type *)' {aka 'int(const struct xdp_md *, unsigned int *, enum xdp_rss_hash_type *)'}
44 | int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
>> drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c:476:12: warning: 'bnxt_xdp_rx_hash' defined but not used [-Wunused-function] 476 | static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
| ^~~~~~~~~~~~~~~~
vim +/bnxt_xdp_rx_hash +476 drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
475
> 476 static int bnxt_xdp_rx_hash(const struct xdp_md *ctx, u32 *hash,
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 3 lines · Chris J Arges
This patchset adds the ability to use an XDP program to extract the RSS hash of a given an
xdp_mdcontext.
I see net-next is closed: https://netdev.bots.linux.dev/net-next.html
I'll re-send with proper target after Feb 23rd.
--chris
Quoted 23 lines
For example this XDP program extracts hash and
rss_type:``` ret = bpf_xdp_metadata_rx_hash(ctx, &hash, &rss_type); if (ret == 0) { bpf_printk("XDP: RX hash=0x%x type=%02x", hash, rss_type); } ```I was able to test this with a Broadcom BCM57414 NIC and verify that the
rss_typeand hash were correct for IPv4/6 TCP/UDP and ICMP traffic.Chris J Arges (2):
bnxt_en: usebnxt_xdp_bufffor xdp context
bnxt_en: Implement XDP RSS hash metadata extractiondrivers/net/ethernet/broadcom/bnxt/bnxt.c | 29 ++++++++---- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 9 ++++ 4 files changed, 77 insertions(+), 10 deletions(-)Signature · 1 line
2.43.0
Jakub Kicinski
maintainerQuoted 6 lines · On Fri, 13 Feb 2026 13:37:58 -0600 Chris Arges wrote:
Quoted 2 lines · Chris J Arges
This patchset adds the ability to use an XDP program to extract the RSS hash of a given an
xdp_mdcontext.I see net-next is closed: https://netdev.bots.linux.dev/net-next.html
I'll re-send with proper target after Feb 23rd.
Would you be willing to add a test as well?
https://github.com/linux-netdev/nipa/wiki/Running-driver-tests
existing tests in tools/testing/selftests/drivers/net/
Quoted 5 lines · Jakub Kicinski
Quoted 4 lines · On Fri, 13 Feb 2026 13:37:58 -0600 Chris Arges wrote:
Quoted 2 lines · Chris J Arges
This patchset adds the ability to use an XDP program to extract the RSS hash of a given an
xdp_mdcontext.
Quoted 7 lines
Quoted 2 lines
I see net-next is closed: https://netdev.bots.linux.dev/net-next.html
I'll re-send with proper target after Feb 23rd.Would you be willing to add a test as well?
https://github.com/linux-netdev/nipa/wiki/Running-driver-tests
existing tests intools/testing/selftests/drivers/net/
Sure, I'll add this and kbot test fixes when I re-submit the patches. Thanks,
--chris
v2 cover bnxt_en: add XDP RSS hash metadata support
In reply to Chris J ArgesThis series adds XDP RSS hash metadata extraction support for the bnxt_en driver and includes selftests to validate the functionality. I was able to test this on a BCM57414 NIC.
The driver changes introduce a bnxt_xdp_buff wrapper that carries hardware RX completion descriptors alongside the xdp_buff, then use it to implement bpf_xdp_metadata_rx_hash().
The selftest changes refactor common XDP/BPF helpers into a shared library and add a new xdp_metadata test that verifies RSS hash extraction for TCP and UDP traffic via device-bound XDP programs.
Changes from v1:
- selftests: moved tests into net/hw
- selftests: fix pylinter errors
- selftests: add check for no error count
- bnxt_xdp: followed RCT for variable declaration
- rebased on net-next
Chris J Arges (4):
bnxt_en: use bnxt_xdp_buff for xdp context
bnxt_en: Implement XDP RSS hash metadata extraction
selftests: net: move common xdp.py functions into lib
selftests: drv-net: xdp: Add rss_hash metadata tests
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 30 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 10 ++ .../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/lib/py/__init__.py | 2 + .../selftests/drivers/net/hw/xdp_metadata.py | 146 ++++++++++++++++ .../selftests/drivers/net/lib/py/__init__.py | 2 + tools/testing/selftests/drivers/net/xdp.py | 95 +++------- .../testing/selftests/net/lib/py/__init__.py | 2 + tools/testing/selftests/net/lib/py/bpf.py | 68 ++++++++ .../selftests/net/lib/xdp_metadata.bpf.c | 163 ++++++++++++++++++ 12 files changed, 486 insertions(+), 82 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/hw/xdp_metadata.py create mode 100644 tools/testing/selftests/net/lib/py/bpf.py create mode 100644 tools/testing/selftests/net/lib/xdp_metadata.bpf.c
Signature · 1 line
2.43.0
PATCH v2 1/4 bnxt_en: use bnxt_xdp_buff for xdp context
This adds bnxt_xdp_buff which embeds the xdp_buff struct and stores pointers to hardware RX completion descriptors (rx_cmp and rx_cmp_ext) along with the completion type.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 25 +++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 7 ++++++ 2 files changed, 22 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +15 -10
@@ -2118,7 +2118,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bool xdp_active = false;dma_addr_t dma_addr;struct sk_buff *skb; -struct xdp_buff xdp; +struct bnxt_xdp_buff bnxt_xdp;u32 flags, misc;u32 cmpl_ts;void *data;
@@ -2231,9 +2231,13 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, dma_addr = rx_buf->mapping;if (bnxt_xdp_attached (bp, rxr)) { -bnxt_xdp_buff_init (bp, rxr, cons, data_ptr, len, &xdp); + bnxt_xdp.rxcmp = rxcmp; + bnxt_xdp.rxcmp1 = rxcmp1; + bnxt_xdp.cmp_type = cmp_type; + +bnxt_xdp_buff_init (bp, rxr, cons, data_ptr, len, &bnxt_xdp.xdp);if (agg_bufs) { -u32 frag_len =bnxt_rx_agg_netmems_xdp (bp, cpr, &xdp, +u32 frag_len =bnxt_rx_agg_netmems_xdp (bp, cpr, &bnxt_xdp.xdp, cp_cons, agg_bufs, false);
@@ -2245,12 +2249,12 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, }if (xdp_active) { -if (bnxt_rx_xdp (bp, rxr, cons, &xdp, data, &data_ptr, &len, event)) { +if (bnxt_rx_xdp (bp, rxr, cons, &bnxt_xdp.xdp, data, &data_ptr, &len, event)) { rc =1 ; goto next_rx; } -if (xdp_buff_has_frags (&xdp)) { - sinfo =xdp_get_shared_info_from_buff (&xdp); +if (xdp_buff_has_frags (&bnxt_xdp.xdp)) { + sinfo =xdp_get_shared_info_from_buff (&bnxt_xdp.xdp); agg_bufs = sinfo->nr_frags; }else { agg_bufs =0 ;
@@ -2261,7 +2265,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,if (!xdp_active) skb =bnxt_copy_skb (bnapi, data_ptr, len, dma_addr);else - skb =bnxt_copy_xdp (bnapi, &xdp, len, dma_addr); + skb =bnxt_copy_xdp (bnapi, &bnxt_xdp.xdp, len, dma_addr);bnxt_reuse_rx_data (rxr, cons, data);if (!skb) {if (agg_bufs) {
@@ -2269,7 +2273,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bnxt_reuse_rx_agg_bufs (cpr, cp_cons,0 , agg_bufs, false); else - bnxt_xdp_buff_frags_free(rxr, &xdp); + bnxt_xdp_buff_frags_free(rxr, &bnxt_xdp.xdp); } goto oom_next_rx; }
@@ -2293,10 +2297,11 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,if (!skb) goto oom_next_rx; }else { - skb =bnxt_xdp_build_skb (bp, skb, agg_bufs, rxr, &xdp); + skb =bnxt_xdp_build_skb (bp, skb, agg_bufs, + rxr, &bnxt_xdp.xdp);if (!skb) {/* we should be able to free the old skb here */ -bnxt_xdp_buff_frags_free (rxr, &xdp); +bnxt_xdp_buff_frags_free (rxr, &bnxt_xdp.xdp); goto oom_next_rx; } }
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +7 -0
@@ -12,6 +12,13 @@DECLARE_STATIC_KEY_FALSE (bnxt_xdp_locking_key); +struct bnxt_xdp_buff { +struct xdp_buff xdp; +struct rx_cmp *rxcmp; +struct rx_cmp_ext *rxcmp1; +u8 cmp_type; +}; + struct bnxt_sw_tx_bd *bnxt_xmit_bd(struct bnxt *bp, struct bnxt_tx_ring_info *txr, dma_addr_t mapping, u32 len,
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 1/4] bnxt_en: use bnxt_xdp_buff for xdp context
Quoted 15 lines · Chris J Arges
This adds
bnxt_xdp_buffwhich embeds thexdp_buffstruct and stores pointers to hardware RX completion descriptors (rx_cmpandrx_cmp_ext) along with the completion type.Signed-off-by Chris J Arges <[email protected]>--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 25 +++++++++++-------- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 7 ++++++ 2 files changed, 22 insertions(+), 10 deletions(-)drivers/net/ethernet/broadcom/bnxt/bnxt.c +0
-0
drivers/net/ethernet/broadcom/bnxt/bnxt.c static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, · line 2121
Quoted 5 lines
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1
-1@@ -2118,7 +2118,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,bool xdp_active = false;dma_addr_t dma_addr;struct sk_buff *skb; -struct xdp_buff xdp; +struct bnxt_xdp_buff bnxt_xdp;
Not sure if it matters but similar RCT issue here.
Otherwise the rest of the implementation looks OK to me, you can retain my Reviewed-by if you are respinning to fix a cosmetic thing:
PATCH v2 2/4 bnxt_en: Implement XDP RSS hash metadata extraction
In reply to Chris J ArgesAdd support for extracting RSS hash values and hash types from hardware completion descriptors in XDP programs for bnxt_en.
Add IP_TYPE definition for determining if completion is ipv4 or ipv6. In addition add ITYPE_ICMP flag for identifying ICMP completions.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 3 ++ 4 files changed, 57 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -0
@@ -15906,6 +15906,10 @@ static const struct net_device_ops bnxt_netdev_ops = { .ndo_hwtstamp_set = bnxt_hwtstamp_set, }; +static const struct xdp_metadata_ops bnxt_xdp_metadata_ops = { + .xmo_rx_hash = bnxt_xdp_rx_hash, +}; +static void bnxt_get_queue_stats_rx (struct net_device *dev,int i,struct netdev_queue_stats_rx *stats) {
@@ -16790,6 +16794,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto init_err_free; dev->netdev_ops = &bnxt_netdev_ops; + dev->xdp_metadata_ops = &bnxt_xdp_metadata_ops; dev->stat_ops = &bnxt_stat_ops; dev->watchdog_timeo =BNXT_TX_TIMEOUT ; dev->ethtool_ops = &bnxt_ethtool_ops;
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -232,6 +232,7 @@ struct rx_cmp {#define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)#define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)#define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) +#define RX_CMP_FLAGS_ITYPE_ICMP (7 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)#define RX_CMP_LEN (0xffff << 16)
@@ -311,6 +312,7 @@ struct rx_cmp_ext {#define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)#define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)#define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) +#define RX_CMP_FLAGS2_IP_TYPE (0x1 << 8)__le32 rx_cmp_meta_data;#define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff#define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +47 -0
50 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h +3 -0
@@ -41,4 +41,7 @@ void bnxt_xdp_buff_frags_free(struct bnxt_rx_ring_info *rxr,struct sk_buff *bnxt_xdp_build_skb (struct bnxt *bp,struct sk_buff *skb,u8 num_frags,struct bnxt_rx_ring_info *rxr,struct xdp_buff *xdp); +int bnxt_xdp_rx_hash (const struct xdp_md *ctx,u32 *hash, +enum xdp_rss_hash_type *rss_type); +#endif
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 2/4] bnxt_en: Implement XDP RSS hash metadata extraction
Quoted 64 lines · Chris J Arges
Add support for extracting RSS hash values and hash types from hardware completion descriptors in XDP programs for
bnxt_en.Add
IP_TYPEdefinition for determining if completion is ipv4 or ipv6. In addition addITYPE_ICMPflag for identifying ICMP completions.Signed-off-by Chris J Arges <[email protected]>--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 ++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 47 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h | 3 ++ 4 files changed, 57 insertions(+)drivers/net/ethernet/broadcom/bnxt/bnxt.c +5
-0@@ -15906,6 +15906,10 @@ static const struct net_device_ops bnxt_netdev_ops = { .ndo_hwtstamp_set = bnxt_hwtstamp_set, }; +static const struct xdp_metadata_ops bnxt_xdp_metadata_ops = { + .xmo_rx_hash = bnxt_xdp_rx_hash, +}; +static void bnxt_get_queue_stats_rx (struct net_device *dev,int i,struct netdev_queue_stats_rx *stats) {@@ -16790,6 +16794,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto init_err_free; dev->netdev_ops = &bnxt_netdev_ops; + dev->xdp_metadata_ops = &bnxt_xdp_metadata_ops; dev->stat_ops = &bnxt_stat_ops; dev->watchdog_timeo =BNXT_TX_TIMEOUT ; dev->ethtool_ops = &bnxt_ethtool_ops;drivers/net/ethernet/broadcom/bnxt/bnxt.h +2
-0@@ -232,6 +232,7 @@ struct rx_cmp {#define RX_CMP_FLAGS_ITYPE_UDP (3 << 12)#define RX_CMP_FLAGS_ITYPE_FCOE (4 << 12)#define RX_CMP_FLAGS_ITYPE_ROCE (5 << 12) +#define RX_CMP_FLAGS_ITYPE_ICMP (7 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_WO_TS (8 << 12)#define RX_CMP_FLAGS_ITYPE_PTP_W_TS (9 << 12)#define RX_CMP_LEN (0xffff << 16)@@ -311,6 +312,7 @@ struct rx_cmp_ext {#define RX_CMP_FLAGS2_T_IP_CS_CALC (0x1 << 2)#define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3)#define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) +#define RX_CMP_FLAGS2_IP_TYPE (0x1 << 8)__le32 rx_cmp_meta_data;#define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff#define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfffdrivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +0
-0@@ -472,3 +472,50 @@ bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, u8 num_frags, xdp_buff_get_skb_flags(xdp));return skb;
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, u8 num_frags, · line 483
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +9
-0} + +int bnxt_xdp_rx_hash (const struct xdp_md *ctx,u32 *hash, +enum xdp_rss_hash_type *rss_type) +{ +const struct bnxt_xdp_buff *xdp = (void *)ctx; +const struct rx_cmp *rxcmp = xdp->rxcmp; +const struct rx_cmp_ext *rxcmp1 = xdp->rxcmp1; +enum xdp_rss_hash_type hash_type =0 ; +u32 itypes;
Sorry don't mean to nitpick (also: I'm just a random subscriber to the list so maybe the maintainers don't mind), but I think rx_cmp_ext needs to be moved up to preserve RCT ?
You can retain my Reviewed-by (if you respin) because the rest seems OK to me:
Jakub Kicinski
maintainerRe: [net-next,v2,2/4] bnxt_en: Implement XDP RSS hash metadata extraction
In reply to Chris J ArgesThis is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---bnxt_en: Implement XDP RSS hash metadata extraction
This commit adds support for extracting RSS hash values and hash types from hardware completion descriptors in XDP programs for the bnxt_en driver.
Quoted 4 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +0
-0
[ ... ]
Quoted 37 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +33
-0@@ -472,3 +472,50 @@ bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, u8 num_frags, xdp_buff_get_skb_flags(xdp));return skb; } + +int bnxt_xdp_rx_hash (const struct xdp_md *ctx,u32 *hash, +enum xdp_rss_hash_type *rss_type) +{ +const struct bnxt_xdp_buff *xdp = (void *)ctx; +const struct rx_cmp *rxcmp = xdp->rxcmp; +const struct rx_cmp_ext *rxcmp1 = xdp->rxcmp1; +enum xdp_rss_hash_type hash_type =0 ; +u32 itypes; + +if (!rxcmp || !RX_CMP_HASH_VALID (rxcmp)) +return -ENODATA ; + + *hash =le32_to_cpu (rxcmp->rx_cmp_rss_hash); + +if (!rxcmp1) { + *rss_type =XDP_RSS_TYPE_L2 ; +return 0 ; + } + +if (xdp->cmp_type ==CMP_TYPE_RX_L2_CMP ) { + itypes =RX_CMP_ITYPES (rxcmp); +if (rxcmp1->rx_cmp_flags2 & +cpu_to_le32 (RX_CMP_FLAGS2_IP_TYPE )) { + hash_type |=XDP_RSS_TYPE_L3_IPV6 ; + }else { + hash_type |=XDP_RSS_TYPE_L3_IPV4 ; + } + +switch (itypes) { +case RX_CMP_FLAGS_ITYPE_TCP : + hash_type |=XDP_RSS_L4 |XDP_RSS_L4_TCP ; +break ;
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c bnxt_xdp_build_skb(struct bnxt *bp, struct sk_buff *skb, u8 num_frags, · line 517
Quoted 10 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +10
-0+case RX_CMP_FLAGS_ITYPE_UDP : + hash_type |=XDP_RSS_L4 |XDP_RSS_L4_UDP ; +break ; +case RX_CMP_FLAGS_ITYPE_ICMP : + hash_type |=XDP_RSS_L4 |XDP_RSS_L4_ICMP ; +break ; +default : +break ; + } + }
What happens when xdp->cmp_type is CMP_TYPE_RX_L2_V3_CMP instead of CMP_TYPE_RX_L2_CMP? Looking at bnxt_rx_pkt() in bnxt.c, when XDP is attached, the cmp_type field can be set to CMP_TYPE_RX_L2_V3_CMP on P5+ hardware:
drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_rx_pkt() {
...
cmp_type = RX_CMP_TYPE(rxcmp);
...
if (bp->xdp_prog) {
...
bnxt_xdp.cmp_type = cmp_type;
...
}
}In the V3 case, this function returns success with *hash set correctly but leaves *rss_type as 0 (XDP_RSS_TYPE_L2/XDP_RSS_TYPE_NONE) because the type classification logic is skipped.
The existing SKB path handles V3 completions differently:
drivers/net/ethernet/broadcom/bnxt/bnxt.c:bnxt_rx_pkt() {
...
if (cmp_type == CMP_TYPE_RX_L2_V3_CMP) {
bnxt_rss_ext_op(bp, rxcmp1, skb);
} else {
skb_set_hash(skb, ...);
}
}Where bnxt_rss_ext_op() uses RX_CMP_V3_HASH_TYPE() for proper L3/L4 classification.
Should bnxt_xdp_rx_hash() handle CMP_TYPE_RX_L2_V3_CMP completions with equivalent V3 hash type decoding, or return -ENODATA for V3 completions to avoid returning success with misleading type information?
Quoted 4 lines
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +4
-0+ + *rss_type = hash_type; +return 0 ; +}
Signature · 1 line
pw-bot: cr
PATCH v2 3/4 selftests: net: move common xdp.py functions into lib
In reply to Chris J ArgesThis moves a few functions which can be useful to other python programs that manipulate XDP programs. This also refactors xdp.py to use the refactored functions.
--- .../selftests/drivers/net/lib/py/__init__.py | 2 + tools/testing/selftests/drivers/net/xdp.py | 95 +++++-------------- .../testing/selftests/net/lib/py/__init__.py | 2 + tools/testing/selftests/net/lib/py/bpf.py | 68 +++++++++++++ 4 files changed, 95 insertions(+), 72 deletions(-) create mode 100644 tools/testing/selftests/net/lib/py/bpf.py
tools/testing/selftests/drivers/net/lib/py/__init__.py +2 -0
@@ -23,6 +23,7 @@ try: from net.lib.py import CmdExitFailure from net.lib.py import bkg, cmd, bpftool, bpftrace, defer, ethtool, \ fd_read_timeout, ip, rand_port, rand_ports, wait_port_listen, wait_file + from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \ ksft_setup, ksft_variants, KsftNamedVariant
@@ -36,6 +37,7 @@ try: "bkg", "cmd", "bpftool", "bpftrace", "defer", "ethtool", "fd_read_timeout", "ip", "rand_port", "rand_ports", "wait_port_listen", "wait_file", + "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids", "KsftSkipEx", "KsftFailEx", "KsftXfailEx", "ksft_disruptive", "ksft_exit", "ksft_pr", "ksft_run", "ksft_setup", "ksft_variants", "KsftNamedVariant",
tools/testing/selftests/drivers/net/xdp.py +23 -72
168 lines not on this page · raw message
tools/testing/selftests/net/lib/py/__init__.py +2 -0
@@ -15,6 +15,7 @@ from .nsim import NetdevSim, NetdevSimDev from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \ bpftool, ip, ethtool, bpftrace, rand_port, rand_ports, wait_port_listen, \ wait_file, tool +from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids from .ynl import NlError, YnlFamily, EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily
@@ -28,6 +29,7 @@ __all__ = ["KSRC", "CmdExitFailure", "fd_read_timeout", "cmd", "bkg", "defer", "bpftool", "ip", "ethtool", "bpftrace", "rand_port", "rand_ports", "wait_port_listen", "wait_file", "tool", + "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids", "NetdevSim", "NetdevSimDev", "NetshaperFamily", "DevlinkFamily", "PSPFamily", "NlError", "YnlFamily", "EthtoolFamily", "NetdevFamily", "RtnlFamily",
tools/testing/selftests/net/lib/py/bpf.py new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 3/4] selftests: net: move common xdp.py functions into lib
Quoted 4 lines · Chris J Arges
This moves a few functions which can be useful to other python programs that manipulate XDP programs. This also refactors
xdp.pyto use the refactored functions.
Quoted 8 lines
Signed-off-by Chris J Arges <[email protected]>--- .../selftests/drivers/net/lib/py/__init__.py | 2 + tools/testing/selftests/drivers/net/xdp.py | 95 +++++-------------- .../testing/selftests/net/lib/py/__init__.py | 2 + tools/testing/selftests/net/lib/py/bpf.py | 68 +++++++++++++ 4 files changed, 95 insertions(+), 72 deletions(-) create mode 100644 tools/testing/selftests/net/lib/py/bpf.py
Took a quick look and it didn't seem like anything changed in this patch from the last revision I reviewed:
PATCH v2 4/4 selftests: drv-net: xdp: Add rss_hash metadata tests
In reply to Chris J ArgesThis test loads xdp_metadata.bpf which calls bpf_xdp_metadata_rx_hash() on incoming packets. The metadata from that packet is then sent to a BPF map for validation. It borrows structure from xdp.py, reusing common functions.
The test checks the device's xdp-rx-metadata-features via netlink before running and skips on devices that do not advertise hash support. This can be run on veth devices as well as real hardware.
The test is fairly simple and just verifies that a TCP or UDP packet can be identified as an L4 flow. This minimal test also passes if run on a veth device.
--- .../testing/selftests/drivers/net/hw/Makefile | 1 + .../drivers/net/hw/lib/py/__init__.py | 2 + .../selftests/drivers/net/hw/xdp_metadata.py | 146 ++++++++++++++++ .../selftests/net/lib/xdp_metadata.bpf.c | 163 ++++++++++++++++++ 4 files changed, 312 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/hw/xdp_metadata.py create mode 100644 tools/testing/selftests/net/lib/xdp_metadata.bpf.c
tools/testing/selftests/drivers/net/hw/Makefile +1 -0
@@ -40,6 +40,7 @@ TEST_PROGS = \ rss_input_xfrm.py \ toeplitz.py \ tso.py \ + xdp_metadata.py \ xsk_reconfig.py \ #
tools/testing/selftests/drivers/net/hw/lib/py/__init__.py +2 -0
@@ -24,6 +24,7 @@ try: from net.lib.py import bkg, cmd, bpftool, bpftrace, defer, ethtool, \ fd_read_timeout, ip, rand_port, rand_ports, wait_port_listen, \ wait_file, tool + from net.lib.py import bpf_map_set, bpf_map_dump, bpf_prog_map_ids from net.lib.py import KsftSkipEx, KsftFailEx, KsftXfailEx from net.lib.py import ksft_disruptive, ksft_exit, ksft_pr, ksft_run, \ ksft_setup, ksft_variants, KsftNamedVariant
@@ -39,6 +40,7 @@ try: "bkg", "cmd", "bpftool", "bpftrace", "defer", "ethtool", "fd_read_timeout", "ip", "rand_port", "rand_ports", "wait_port_listen", "wait_file", "tool", + "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids", "KsftSkipEx", "KsftFailEx", "KsftXfailEx", "ksft_disruptive", "ksft_exit", "ksft_pr", "ksft_run", "ksft_setup", "ksft_variants", "KsftNamedVariant",
tools/testing/selftests/drivers/net/hw/xdp_metadata.py new file +146 -0
146 lines not on this page · raw message
tools/testing/selftests/net/lib/xdp_metadata.bpf.c new file +163 -0
163 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next v2 0/4] bnxt_en: add XDP RSS hash metadata support
In reply to Chris J ArgesQuoted 12 lines · Chris J Arges
This series adds XDP RSS hash metadata extraction support for the
bnxt_endriver and includes selftests to validate the functionality. I was able to test this on a BCM57414 NIC.The driver changes introduce a
bnxt_xdp_buffwrapper that carries hardware RX completion descriptors alongside thexdp_buff, then use it to implementbpf_xdp_metadata_rx_hash().The selftest changes refactor common XDP/BPF helpers into a shared library and add a new
xdp_metadatatest that verifies RSS hash extraction for TCP and UDP traffic via device-bound XDP programs.
Quoted 6 lines
Changes from v1:
- selftests: moved tests into net/hw
- selftests: fix pylinter errors
- selftests: add check for no error count
-bnxt_xdp: followed RCT for variable declaration
- rebased on net-next
Thanks for putting the summary in the cover letter.
In the future, you might consider including a summary in the patches themselves to make it more clear what changed in each patch.
As an example of how you might do it in the future, check out this recent patch [1].