From: Andy Gospodarek <andrew.gospodarek@broadcom.com>
To: Chris J Arges <carges@cloudflare.com>
Cc: michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
joe@dama.to, kuba@kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
kernel-team@cloudflare.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/5] bnxt_en: Implement XDP RSS hash metadata extraction
Date: Thu, 12 Mar 2026 20:15:09 -0400 [thread overview]
Message-ID: <abNXDVPK42wLUPYv@JRM7P7Q02P> (raw)
In-Reply-To: <20260306230600.1628196-3-carges@cloudflare.com>
On Fri, Mar 06, 2026 at 05:00:17PM -0600, Chris J Arges wrote:
> Add 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.
>
> Signed-off-by: Chris J Arges <carges@cloudflare.com>
> Reviewed-by: Joe Damato <joe@dama.to>
Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
> ---
> 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(+)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index ab73aad40593..c06033cf9f82 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -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;
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 90fa3e93c8d6..34bb98709f2b 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -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
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
> index 85cbeb35681c..1f920464b426 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
> @@ -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_ext *rxcmp1 = xdp->rxcmp1;
> + const struct rx_cmp *rxcmp = xdp->rxcmp;
> + 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;
> + 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;
> + }
> + }
> +
> + *rss_type = hash_type;
> + return 0;
> +}
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h
> index 8c66698bde11..fb4f9143929f 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.h
> @@ -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
next prev parent reply other threads:[~2026-03-13 0:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 23:00 [PATCH net-next v3 0/5] bnxt_en: Add XDP RSS hash metadata support Chris J Arges
2026-03-06 23:00 ` [PATCH net-next v3 1/5] bnxt_en: use bnxt_xdp_buff for xdp context Chris J Arges
2026-03-10 0:52 ` Joe Damato
2026-03-13 0:14 ` Andy Gospodarek
2026-03-06 23:00 ` [PATCH net-next v3 2/5] bnxt_en: Implement XDP RSS hash metadata extraction Chris J Arges
2026-03-10 0:56 ` Joe Damato
2026-03-13 0:15 ` Andy Gospodarek [this message]
2026-03-06 23:00 ` [PATCH net-next v3 3/5] bnxt_en: Implement XDP RSS hash metadata extraction for V3_CMP Chris J Arges
2026-03-10 1:02 ` Joe Damato
2026-03-13 0:15 ` Andy Gospodarek
2026-03-06 23:00 ` [PATCH net-next v3 4/5] selftests: net: move common xdp.py functions into lib Chris J Arges
2026-03-10 0:54 ` Joe Damato
2026-03-06 23:00 ` [PATCH net-next v3 5/5] selftests: drv-net: xdp: Add rss_hash metadata tests Chris J Arges
2026-03-10 0:51 ` [PATCH net-next v3 0/5] bnxt_en: Add XDP RSS hash metadata support Joe Damato
2026-03-10 2:06 ` Chris Arges
2026-03-10 2:37 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abNXDVPK42wLUPYv@JRM7P7Q02P \
--to=andrew.gospodarek@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=carges@cloudflare.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=joe@dama.to \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=sdf@fomichev.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox