Skip to contentSkip to conversation

i40e: support XDP metadata ops (RX

PATCH In review Kohei Enju 4 participants 12 messages Mar 19 – Apr 14

Subsystems (3)
lore
Share & tools
lore

Kohei Enju

author
#0 lore raw

cover i40e: support XDP metadata ops (RX

This series adds support for XDP metadata ops. Since the i40e RX timestamps are not available from the RX descriptor in the XDP path, this series doesn't implement bpf_xdp_metadata_rx_timestamp().

Patch 1/3 prepares i40e_xdp_buff for subsequent patches. Patch 2/3 and 3/3 introduce bpf_xdp_metadata_rx_hash() and bpf_xdp_metadata_rx_vlan_tag() respectively.

Tested on Intel Corporation Ethernet Controller X710 for 10GbE SFP+ with ./tools/testing/selftests/bpf/xdp_hw_metadata.
Since i40e doesn't support HWTSTAMP_FILTER_ALL as an rx_filter, I locally changed the selftest to use HWTSTAMP_FILTER_NONE instead.

Kohei Enju (3):
i40e: prepare for XDP metadata ops support
i40e: add support for bpf_xdp_metadata_rx_hash()
i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

 drivers/net/ethernet/intel/i40e/i40e_main.c | 51 ++++++++++++++++++++-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.h |  7 ++-
 drivers/net/ethernet/intel/i40e/i40e_type.h |  5 ++
 drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 12 +++++
 5 files changed, 77 insertions(+), 3 deletions(-)
Signature · 1 line
2.51.0
author
#1 lore raw

PATCH 1/3 i40e: prepare for XDP metadata ops support

Prepare 'struct i40e_xdp_buff' that contains an xdp_buff and a pointer to i40e_rx_desc in order to pass the RX descriptor to the XDP kfuncs. Also in ZC path, use XSK_CHECK_PRIV_TYPE() to ensure i40e_xdp_buff doesn't exceed the offset of cb in xdp_buff_xsk.

No functional changes.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c |  2 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 ++++-
 drivers/net/ethernet/intel/i40e/i40e_txrx.h |  7 ++++++-
 drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 12 ++++++++++++
 4 files changed, 23 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 31a42ee18aa0..7966d9cb8009 100644
@@ -3619,7 +3619,7 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
 	}
 
 skip:
-	xdp_init_buff(&ring->xdp, xdp_frame_sz, &ring->xdp_rxq);
+	xdp_init_buff(&ring->xdp_ctx.xdp, xdp_frame_sz, &ring->xdp_rxq);
 
 	rx_ctx.dbuff = DIV_ROUND_UP(ring->rx_buf_len,
 				    BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
drivers/net/ethernet/intel/i40e/i40e_txrx.c +4 -1
index 4ffdb007c41a..cfaf724ee7ff 100644
@@ -2438,10 +2438,11 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget,
 			     unsigned int *rx_cleaned)
 {
 	unsigned int total_rx_bytes = 0, total_rx_packets = 0;
+	struct i40e_xdp_buff *xdp_ctx = &rx_ring->xdp_ctx;
 	u16 cleaned_count = I40E_DESC_UNUSED(rx_ring);
 	u16 clean_threshold = rx_ring->count / 2;
 	unsigned int offset = rx_ring->rx_offset;
-	struct xdp_buff *xdp = &rx_ring->xdp;
+	struct xdp_buff *xdp = &xdp_ctx->xdp;
 	unsigned int xdp_xmit = 0;
 	struct bpf_prog *xdp_prog;
 	bool failure = false;
@@ -2530,6 +2531,8 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget,
 		if (neop)
 			continue;
 
+		xdp_ctx->desc = rx_desc;
+
 		xdp_res = i40e_run_xdp(rx_ring, xdp, xdp_prog);
 
 		if (xdp_res) {
drivers/net/ethernet/intel/i40e/i40e_txrx.h +6 -1
index e630493e9139..6c6ba42ee00c 100644
@@ -283,6 +283,11 @@ struct i40e_rx_buffer {
 	__u32 page_count;
 };
 
+struct i40e_xdp_buff {
+	struct xdp_buff xdp;
+	const union i40e_rx_desc *desc;
+};
+
 struct i40e_queue_stats {
 	u64 packets;
 	u64 bytes;
@@ -345,7 +350,7 @@ struct i40e_ring {
 	 * and to resume packet building for this ring in the next call to
 	 * i40e_clean_rx_ring_irq().
 	 */
-	struct xdp_buff xdp;
+	struct i40e_xdp_buff xdp_ctx;
 
 	/* Next descriptor to be processed; next_to_clean is updated only on
 	 * processing EOP descriptor
drivers/net/ethernet/intel/i40e/i40e_xsk.c +12 -0
index 9f47388eaba5..51a05ce4c7ce 100644
@@ -246,6 +246,8 @@ bool i40e_alloc_rx_buffers_zc(struct i40e_ring *rx_ring, u16 count)
 	u32 nb_buffs, i;
 	dma_addr_t dma;
 
+	XSK_CHECK_PRIV_TYPE(struct i40e_xdp_buff);
+
 	rx_desc = I40E_RX_DESC(rx_ring, ntu);
 	xdp = i40e_rx_bi(rx_ring, ntu);
 
@@ -396,6 +398,14 @@ static void i40e_handle_xdp_result_zc(struct i40e_ring *rx_ring,
 	WARN_ON_ONCE(1);
 }
 
+static struct i40e_xdp_buff *xsk_buff_to_i40e_ctx(struct xdp_buff *xdp)
+{
+	/* xdp_buff pointer used by ZC code path is allocated as xdp_buff_xsk.
+	 * i40e_xdp_buff private fields overlap with xdp_buff_xsk->cb.
+	 */
+	return (struct i40e_xdp_buff *)xdp;
+}
+
 /**
  * i40e_clean_rx_irq_zc - Consumes Rx packets from the hardware ring
  * @rx_ring: Rx ring
@@ -472,6 +482,8 @@ int i40e_clean_rx_irq_zc(struct i40e_ring *rx_ring, int budget)
 		if (i40e_is_non_eop(rx_ring, rx_desc))
 			continue;
 
+		xsk_buff_to_i40e_ctx(first)->desc = rx_desc;
+
 		xdp_res = i40e_run_xdp_zc(rx_ring, first, xdp_prog);
 		i40e_handle_xdp_result_zc(rx_ring, first, rx_desc, &rx_packets,
 					  &rx_bytes, xdp_res, &failure);
Signature · 1 line
2.51.0
Reviewed-by on v1 1/3
#2 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 1/3] i40e: prepare for XDP metadata ops support

Quoted 57 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 1/3] i40e: prepare for XDP metadata ops support

Prepare 'struct i40e_xdp_buff' that contains an xdp_buff and a pointer to i40e_rx_desc in order to pass the RX descriptor to the XDP kfuncs. Also in ZC path, use XSK_CHECK_PRIV_TYPE() to ensure i40e_xdp_buff doesn't exceed the offset of cb in xdp_buff_xsk.

No functional changes.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c |  2 +-
drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 ++++-
drivers/net/ethernet/intel/i40e/i40e_txrx.h |  7 ++++++-
drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 12 ++++++++++++
 4 files changed, 23 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 31a42ee18aa0..7966d9cb8009 100644
@@ -3619,7 +3619,7 @@ static int i40e_configure_rx_ring(struct
 i40e_ring *ring)
 	}
 
 skip:
-	xdp_init_buff(&ring->xdp, xdp_frame_sz, &ring->xdp_rxq);
+	xdp_init_buff(&ring->xdp_ctx.xdp, xdp_frame_sz, &ring-
 >xdp_rxq);
 
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
 	rx_ctx.dbuff = DIV_ROUND_UP(ring->rx_buf_len,
 				    BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
drivers/net/ethernet/intel/i40e/i40e_txrx.c +0 -0
index 4ffdb007c41a..cfaf724ee7ff 100644
@@ -2438,10 +2438,11 @@ static int i40e_clean_rx_irq(struct i40e_ring
 *rx_ring, int budget,
 			     unsigned int *rx_cleaned)
 {
 	unsigned int total_rx_bytes = 0, total_rx_packets = 0;

...

Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_txrx.c +0 -0
 		xdp_res = i40e_run_xdp_zc(rx_ring, first, xdp_prog);
 		i40e_handle_xdp_result_zc(rx_ring, first, rx_desc,

&rx_packets,
&rx_bytes, xdp_res, &failure);
--
2.51.0

Tested-by
#3 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 1/3] i40e: prepare for XDP metadata ops support

Quoted 75 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Friday, March 20, 2026 7:57 AM
To: Kohei Enju <[email protected]>; [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1 1/3] i40e: prepare for XDP metadata ops support

Quoted 9 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>;

Paolo

Quoted 46 lines

Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 1/3] i40e: prepare for XDP metadata ops support

Prepare 'struct i40e_xdp_buff' that contains an xdp_buff and a pointer to i40e_rx_desc in order to pass the RX descriptor to the XDP kfuncs. Also in ZC path, use XSK_CHECK_PRIV_TYPE() to ensure i40e_xdp_buff doesn't exceed the offset of cb in xdp_buff_xsk.

No functional changes.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c |  2 +-
drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 ++++-
drivers/net/ethernet/intel/i40e/i40e_txrx.h |  7 ++++++-
drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 12 ++++++++++++
 4 files changed, 23 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -1
index 31a42ee18aa0..7966d9cb8009 100644
@@ -3619,7 +3619,7 @@ static int i40e_configure_rx_ring(struct
 i40e_ring *ring)
 	}
 
 skip:
-	xdp_init_buff(&ring->xdp, xdp_frame_sz, &ring->xdp_rxq);
+	xdp_init_buff(&ring->xdp_ctx.xdp, xdp_frame_sz, &ring-
 >xdp_rxq);
 
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
 	rx_ctx.dbuff = DIV_ROUND_UP(ring->rx_buf_len,
 				    BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
drivers/net/ethernet/intel/i40e/i40e_txrx.c +0 -0
index 4ffdb007c41a..cfaf724ee7ff 100644
@@ -2438,10 +2438,11 @@ static int i40e_clean_rx_irq(struct i40e_ring
 *rx_ring, int budget,
 			     unsigned int *rx_cleaned)
 {
 	unsigned int total_rx_bytes = 0, total_rx_packets = 0;

...

Quoted 8 lines

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Quoted 2 lines
drivers/net/ethernet/intel/i40e/i40e_txrx.c +0 -0
 		xdp_res = i40e_run_xdp_zc(rx_ring, first, xdp_prog);
 		i40e_handle_xdp_result_zc(rx_ring, first, rx_desc,

&rx_packets,

Quoted 3 lines

&rx_bytes, xdp_res, &failure);
--
2.51.0

author
#4 lore raw

PATCH 2/3 i40e: add support for bpf_xdp_metadata_rx_hash()

In reply to Kohei Enju

Introduce i40e_xdp_rx_hash() which takes the same approach as i40e_rx_hash() to extract the hash from RX descriptors.

Tested with X710 adapter using xdp_hw_metadata, and verified hash consistency between bpf_xdp_metadata_rx_hash() and skb->hash.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 30 +++++++++++++++++++++
 drivers/net/ethernet/intel/i40e/i40e_type.h |  5 ++++
 2 files changed, 35 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +30 -0
index 7966d9cb8009..6b7e34b16a8d 100644
@@ -4,6 +4,7 @@
 #include <generated/utsrelease.h>
 #include <linux/crash_dump.h>
 #include <linux/intel/libie/pctype.h>
+#include <linux/intel/libie/rx.h>
 #include <linux/if_bridge.h>
 #include <linux/if_macvlan.h>
 #include <linux/module.h>
@@ -13585,6 +13586,34 @@ static int i40e_xdp(struct net_device *dev,
 	}
 }
 
+static int i40e_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash,
+			    enum xdp_rss_hash_type *rss_type)
+{
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	struct libeth_rx_pt rx_ptype;
+	u8 raw_rx_ptype;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+	raw_rx_ptype = FIELD_GET(I40E_RXD_QW1_PTYPE_MASK, status);
+	rx_ptype = libie_rx_pt_parse(raw_rx_ptype);
+
+	if (!libeth_rx_pt_has_hash(ctx->xdp.rxq->dev, rx_ptype) ||
+	    FIELD_GET(I40E_RX_DESC_STATUS_FLTSTAT_MASK, status) !=
+		    I40E_RX_DESC_FLTSTAT_RSS_HASH)
+		return -ENODATA;
+
+	*hash = le32_to_cpu(desc->wb.qword0.hi_dword.rss);
+	*rss_type = rx_ptype.hash_type;
+
+	return 0;
+}
+
+static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
+	.xmo_rx_hash		= i40e_xdp_rx_hash,
+};
+
 static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_open		= i40e_open,
 	.ndo_stop		= i40e_close,
@@ -13788,6 +13817,7 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
 	i40e_vsi_config_netdev_tc(vsi, vsi->tc_config.enabled_tc);
 
 	netdev->netdev_ops = &i40e_netdev_ops;
+	netdev->xdp_metadata_ops = &i40e_xdp_metadata_ops;
 	netdev->watchdog_timeo = 5 * HZ;
 	i40e_set_ethtool_ops(netdev);
 
drivers/net/ethernet/intel/i40e/i40e_type.h +5 -0
index ed8bbdb586da..16a65c6e5153 100644
@@ -4,6 +4,7 @@
 #ifndef _I40E_TYPE_H_
 #define _I40E_TYPE_H_
 
+#include <linux/bits.h>
 #include <uapi/linux/if_ether.h>
 #include "i40e_adminq.h"
 #include "i40e_hmc.h"
@@ -699,6 +700,10 @@ enum i40e_rx_desc_status_bits {
 	I40E_RX_DESC_STATUS_LAST /* this entry must be last!!! */
 };
 
+#define I40E_RX_DESC_STATUS_FLTSTAT_MASK                   \
+	GENMASK_ULL(I40E_RX_DESC_STATUS_FLTSTAT_SHIFT + 1, \
+		    I40E_RX_DESC_STATUS_FLTSTAT_SHIFT)
+
 #define I40E_RXD_QW1_STATUS_SHIFT	0
 #define I40E_RXD_QW1_STATUS_MASK	((BIT(I40E_RX_DESC_STATUS_LAST) - 1) \
 					 << I40E_RXD_QW1_STATUS_SHIFT)
Signature · 1 line
2.51.0
Reviewed-by on v1 2/3
#5 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 2/3] i40e: add support for bpf_xdp_metadata_rx_hash()

Quoted 110 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 2/3] i40e: add support for bpf_xdp_metadata_rx_hash()

Introduce i40e_xdp_rx_hash() which takes the same approach as i40e_rx_hash() to extract the hash from RX descriptors.

Tested with X710 adapter using xdp_hw_metadata, and verified hash consistency between bpf_xdp_metadata_rx_hash() and skb->hash.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 30
+++++++++++++++++++++  drivers/net/ethernet/intel/i40e/i40e_type.h |
5 ++++
 2 files changed, 35 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +29 -0
index 7966d9cb8009..6b7e34b16a8d 100644
@@ -4,6 +4,7 @@
 #include <generated/utsrelease.h>
 #include <linux/crash_dump.h>
 #include <linux/intel/libie/pctype.h>
+#include <linux/intel/libie/rx.h>
 #include <linux/if_bridge.h>
 #include <linux/if_macvlan.h>
 #include <linux/module.h>
@@ -13585,6 +13586,34 @@ static int i40e_xdp(struct net_device *dev,
 	}
 }
 
+static int i40e_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash,
+			    enum xdp_rss_hash_type *rss_type) {
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	struct libeth_rx_pt rx_ptype;
+	u8 raw_rx_ptype;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+	raw_rx_ptype = FIELD_GET(I40E_RXD_QW1_PTYPE_MASK, status);
+	rx_ptype = libie_rx_pt_parse(raw_rx_ptype);
+
+	if (!libeth_rx_pt_has_hash(ctx->xdp.rxq->dev, rx_ptype) ||
+	    FIELD_GET(I40E_RX_DESC_STATUS_FLTSTAT_MASK, status) !=
+		    I40E_RX_DESC_FLTSTAT_RSS_HASH)
+		return -ENODATA;
+
+	*hash = le32_to_cpu(desc->wb.qword0.hi_dword.rss);
+	*rss_type = rx_ptype.hash_type;
+
+	return 0;
+}
+
+static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
+	.xmo_rx_hash		= i40e_xdp_rx_hash,
+};
+
 static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_open		= i40e_open,
 	.ndo_stop		= i40e_close,
@@ -13788,6 +13817,7 @@ static int i40e_config_netdev(struct i40e_vsi
 *vsi)
 	i40e_vsi_config_netdev_tc(vsi, vsi->tc_config.enabled_tc);
 
 	netdev->netdev_ops = &i40e_netdev_ops;
+	netdev->xdp_metadata_ops = &i40e_xdp_metadata_ops;
 	netdev->watchdog_timeo = 5 * HZ;
 	i40e_set_ethtool_ops(netdev);
drivers/net/ethernet/intel/i40e/i40e_type.h +5 -1
index ed8bbdb586da..16a65c6e5153 100644
@@ -4,6 +4,7 @@
 #ifndef _I40E_TYPE_H_
 #define _I40E_TYPE_H_
 
+#include <linux/bits.h>
 #include <uapi/linux/if_ether.h>
 #include "i40e_adminq.h"
 #include "i40e_hmc.h"
@@ -699,6 +700,10 @@ enum i40e_rx_desc_status_bits {
 	I40E_RX_DESC_STATUS_LAST /* this entry must be last!!! */  };
 
+#define I40E_RX_DESC_STATUS_FLTSTAT_MASK                   \
+	GENMASK_ULL(I40E_RX_DESC_STATUS_FLTSTAT_SHIFT + 1, \
+		    I40E_RX_DESC_STATUS_FLTSTAT_SHIFT)
+
 #define I40E_RXD_QW1_STATUS_SHIFT	0
 #define I40E_RXD_QW1_STATUS_MASK	((BIT(I40E_RX_DESC_STATUS_LAST) - 1)
 \
 					 << I40E_RXD_QW1_STATUS_SHIFT)
--
Quoted 1 line

2.51.0

Tested-by
#6 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 2/3] i40e: add support for bpf_xdp_metadata_rx_hash()

Quoted 123 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Friday, March 20, 2026 7:57 AM
To: Kohei Enju <[email protected]>; [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1 2/3] i40e: add support for bpf_xdp_metadata_rx_hash()

Quoted 9 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>;

Paolo

Quoted 88 lines

Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 2/3] i40e: add support for bpf_xdp_metadata_rx_hash()

Introduce i40e_xdp_rx_hash() which takes the same approach as i40e_rx_hash() to extract the hash from RX descriptors.

Tested with X710 adapter using xdp_hw_metadata, and verified hash consistency between bpf_xdp_metadata_rx_hash() and skb->hash.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 30
+++++++++++++++++++++  drivers/net/ethernet/intel/i40e/i40e_type.h |
5 ++++
 2 files changed, 35 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +29 -0
index 7966d9cb8009..6b7e34b16a8d 100644
@@ -4,6 +4,7 @@
 #include <generated/utsrelease.h>
 #include <linux/crash_dump.h>
 #include <linux/intel/libie/pctype.h>
+#include <linux/intel/libie/rx.h>
 #include <linux/if_bridge.h>
 #include <linux/if_macvlan.h>
 #include <linux/module.h>
@@ -13585,6 +13586,34 @@ static int i40e_xdp(struct net_device *dev,
 	}
 }
 
+static int i40e_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash,
+			    enum xdp_rss_hash_type *rss_type) {
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	struct libeth_rx_pt rx_ptype;
+	u8 raw_rx_ptype;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+	raw_rx_ptype = FIELD_GET(I40E_RXD_QW1_PTYPE_MASK, status);
+	rx_ptype = libie_rx_pt_parse(raw_rx_ptype);
+
+	if (!libeth_rx_pt_has_hash(ctx->xdp.rxq->dev, rx_ptype) ||
+	    FIELD_GET(I40E_RX_DESC_STATUS_FLTSTAT_MASK, status) !=
+		    I40E_RX_DESC_FLTSTAT_RSS_HASH)
+		return -ENODATA;
+
+	*hash = le32_to_cpu(desc->wb.qword0.hi_dword.rss);
+	*rss_type = rx_ptype.hash_type;
+
+	return 0;
+}
+
+static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
+	.xmo_rx_hash		= i40e_xdp_rx_hash,
+};
+
 static const struct net_device_ops i40e_netdev_ops = {
 	.ndo_open		= i40e_open,
 	.ndo_stop		= i40e_close,
@@ -13788,6 +13817,7 @@ static int i40e_config_netdev(struct i40e_vsi
 *vsi)
 	i40e_vsi_config_netdev_tc(vsi, vsi->tc_config.enabled_tc);
 
 	netdev->netdev_ops = &i40e_netdev_ops;
+	netdev->xdp_metadata_ops = &i40e_xdp_metadata_ops;
 	netdev->watchdog_timeo = 5 * HZ;
 	i40e_set_ethtool_ops(netdev);
drivers/net/ethernet/intel/i40e/i40e_type.h +1 -0
index ed8bbdb586da..16a65c6e5153 100644
@@ -4,6 +4,7 @@
 #ifndef _I40E_TYPE_H_
 #define _I40E_TYPE_H_
 
+#include <linux/bits.h>
 #include <uapi/linux/if_ether.h>
 #include "i40e_adminq.h"
 #include "i40e_hmc.h"

drivers/net/ethernet/intel/i40e/i40e_type.h enum i40e_rx_desc_status_bits { · line 707

Quoted 8 lines
drivers/net/ethernet/intel/i40e/i40e_type.h +4 -0
@@ -699,6 +700,10 @@ enum i40e_rx_desc_status_bits {
 	I40E_RX_DESC_STATUS_LAST /* this entry must be last!!! */  };
 
+#define I40E_RX_DESC_STATUS_FLTSTAT_MASK                   \
+	GENMASK_ULL(I40E_RX_DESC_STATUS_FLTSTAT_SHIFT + 1, \
+		    I40E_RX_DESC_STATUS_FLTSTAT_SHIFT)
+
 #define I40E_RXD_QW1_STATUS_SHIFT	0
 #define I40E_RXD_QW1_STATUS_MASK
	((BIT(I40E_RX_DESC_STATUS_LAST) - 1)
Quoted 6 lines
Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_type.h +0 -1
 \
 					 << I40E_RXD_QW1_STATUS_SHIFT)
--

2.51.0

author
#7 lore raw

PATCH 3/3 i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

In reply to Kohei Enju

Introduce i40e_xdp_rx_vlan_tag() which takes the same approach as i40e_process_skb_fields() to extract the VLAN tag from the RX descriptor.

Tested with X710 adapter using xdp_hw_metadata, and confirmed that VLAN tags match between bpf_xdp_metadata_rx_vlan_tag() and skb->vlan_proto/vlan_tci.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +19 -0
index 6b7e34b16a8d..3749f32ef95a 100644
@@ -13610,8 +13610,27 @@ static int i40e_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash,
 	return 0;
 }
 
+static int i40e_xdp_rx_vlan_tag(const struct xdp_md *_ctx, __be16 *vlan_proto,
+				u16 *vlan_tci)
+{
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+
+	if (!(status & BIT(I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)))
+		return -ENODATA;
+
+	*vlan_proto = cpu_to_be16(ETH_P_8021Q);
+	*vlan_tci = le16_to_cpu(desc->wb.qword0.lo_dword.l2tag1);
+
+	return 0;
+}
+
 static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
 	.xmo_rx_hash		= i40e_xdp_rx_hash,
+	.xmo_rx_vlan_tag	= i40e_xdp_rx_vlan_tag,
 };
 
 static const struct net_device_ops i40e_netdev_ops = {
Signature · 1 line
2.51.0
Reviewed-by on v1 3/3
#8 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 3/3] i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Quoted 63 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 3/3] i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Introduce i40e_xdp_rx_vlan_tag() which takes the same approach as i40e_process_skb_fields() to extract the VLAN tag from the RX descriptor.

Tested with X710 adapter using xdp_hw_metadata, and confirmed that VLAN tags match between bpf_xdp_metadata_rx_vlan_tag() and skb->vlan_proto/vlan_tci.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +19 -0
index 6b7e34b16a8d..3749f32ef95a 100644
@@ -13610,8 +13610,27 @@ static int i40e_xdp_rx_hash(const struct
 xdp_md *_ctx, u32 *hash,
 	return 0;
 }
 
+static int i40e_xdp_rx_vlan_tag(const struct xdp_md *_ctx, __be16
 *vlan_proto,
+				u16 *vlan_tci)
+{
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+
+	if (!(status & BIT(I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)))
+		return -ENODATA;
+
+	*vlan_proto = cpu_to_be16(ETH_P_8021Q);
+	*vlan_tci = le16_to_cpu(desc->wb.qword0.lo_dword.l2tag1);
+
+	return 0;
+}
+
 static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
 	.xmo_rx_hash		= i40e_xdp_rx_hash,
+	.xmo_rx_vlan_tag	= i40e_xdp_rx_vlan_tag,
 };
Quoted 3 lines

static const struct net_device_ops i40e_netdev_ops = {
--
2.51.0

Tested-by
#9 lore raw

RE: [Intel-wired-lan] [PATCH iwl-next v1 3/3] i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Quoted 78 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Loktionov, Aleksandr
Sent: Friday, March 20, 2026 7:58 AM
To: Kohei Enju <[email protected]>; [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1 3/3] i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Quoted 9 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Kohei Enju
Sent: Thursday, March 19, 2026 6:17 PM
To: [email protected]; [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>;

Paolo

Quoted 52 lines

Abeni <[email protected]>; [email protected]; Kohei Enju <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v1 3/3] i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Introduce i40e_xdp_rx_vlan_tag() which takes the same approach as i40e_process_skb_fields() to extract the VLAN tag from the RX descriptor.

Tested with X710 adapter using xdp_hw_metadata, and confirmed that VLAN tags match between bpf_xdp_metadata_rx_vlan_tag() and skb->vlan_proto/vlan_tci.

---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +19 -0
index 6b7e34b16a8d..3749f32ef95a 100644
@@ -13610,8 +13610,27 @@ static int i40e_xdp_rx_hash(const struct
 xdp_md *_ctx, u32 *hash,
 	return 0;
 }
 
+static int i40e_xdp_rx_vlan_tag(const struct xdp_md *_ctx, __be16
 *vlan_proto,
+				u16 *vlan_tci)
+{
+	const struct i40e_xdp_buff *ctx = (const void *)_ctx;
+	const union i40e_rx_desc *desc = ctx->desc;
+	u64 status;
+
+	status = le64_to_cpu(desc->wb.qword1.status_error_len);
+
+	if (!(status & BIT(I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)))
+		return -ENODATA;
+
+	*vlan_proto = cpu_to_be16(ETH_P_8021Q);
+	*vlan_tci = le16_to_cpu(desc->wb.qword0.lo_dword.l2tag1);
+
+	return 0;
+}
+
 static const struct xdp_metadata_ops i40e_xdp_metadata_ops = {
 	.xmo_rx_hash		= i40e_xdp_rx_hash,
+	.xmo_rx_vlan_tag	= i40e_xdp_rx_vlan_tag,
 };
Quoted 5 lines
Quoted 3 lines

static const struct net_device_ops i40e_netdev_ops = {
--
2.51.0

Reviewed-by on the v1 series
#10 lore raw
In reply to Kohei Enju
Quoted 18 lines · Kohei Enju

This series adds support for XDP metadata ops. Since the i40e RX timestamps are not available from the RX descriptor in the XDP path, this series doesn't implement bpf_xdp_metadata_rx_timestamp().

Patch 1/3 prepares i40e_xdp_buff for subsequent patches. Patch 2/3 and 3/3 introduce bpf_xdp_metadata_rx_hash() and bpf_xdp_metadata_rx_vlan_tag() respectively.

Tested on Intel Corporation Ethernet Controller X710 for 10GbE SFP+ with ./tools/testing/selftests/bpf/xdp_hw_metadata.
Since i40e doesn't support HWTSTAMP_FILTER_ALL as an rx_filter, I locally changed the selftest to use HWTSTAMP_FILTER_NONE instead.

Kohei Enju (3):
i40e: prepare for XDP metadata ops support
i40e: add support for bpf_xdp_metadata_rx_hash()
i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Quoted 6 lines
 drivers/net/ethernet/intel/i40e/i40e_main.c | 51 ++++++++++++++++++++-
 drivers/net/ethernet/intel/i40e/i40e_txrx.c |  5 +-
 drivers/net/ethernet/intel/i40e/i40e_txrx.h |  7 ++-
 drivers/net/ethernet/intel/i40e/i40e_type.h |  5 ++
 drivers/net/ethernet/intel/i40e/i40e_xsk.c  | 12 +++++
 5 files changed, 77 insertions(+), 3 deletions(-)

For the series:

Tested-by
#11 lore raw
Quoted 40 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Joe Damato
Sent: Saturday, March 21, 2026 12:10 AM
To: Kohei Enju <[email protected]>
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v1 0/3] i40e: support XDP metadata ops (RX

Quoted 18 lines · Kohei Enju

This series adds support for XDP metadata ops. Since the i40e RX timestamps are not available from the RX descriptor in the XDP path, this series doesn't implement bpf_xdp_metadata_rx_timestamp().

Patch 1/3 prepares i40e_xdp_buff for subsequent patches. Patch 2/3 and 3/3 introduce bpf_xdp_metadata_rx_hash() and bpf_xdp_metadata_rx_vlan_tag() respectively.

Tested on Intel Corporation Ethernet Controller X710 for 10GbE SFP+ with ./tools/testing/selftests/bpf/xdp_hw_metadata. Since i40e doesn't support HWTSTAMP_FILTER_ALL as an rx_filter, I locally changed the selftest to use HWTSTAMP_FILTER_NONE instead.

Kohei Enju (3):
i40e: prepare for XDP metadata ops support
i40e: add support for bpf_xdp_metadata_rx_hash()
i40e: add support for bpf_xdp_metadata_rx_vlan_tag()

Quoted 6 lines
 drivers/net/ethernet/intel/i40e/i40e_main.c | 51

++++++++++++++++++++- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 5 +- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 7 ++- drivers/net/ethernet/intel/i40e/i40e_type.h | 5 ++ drivers/net/ethernet/intel/i40e/i40e_xsk.c | 12 +++++

 5 files changed, 77 insertions(+), 3 deletions(-)
Quoted 3 lines

For the series: