Skip to contentSkip to conversation

AF_XDP fixes for i40e, ixgbe and xdpsock

PATCH Applied Ciara Loftus 3 participants 6 messages Sep 13, 2019 – Sep 16, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover AF_XDP fixes for i40e, ixgbe and xdpsock

This patch set contains some fixes for AF_XDP zero copy in the i40e and ixgbe drivers as well as a fix for the 'xdpsock' sample application when running in unaligned mode.

Patches 1 and 2 fix a regression for the i40e and ixgbe drivers which caused the umem headroom to be added to the xdp handle twice, resulting in an incorrect value being received by the user for the case where the umem headroom is non-zero.

Patch 3 fixes an issue with the xdpsock sample application whereby the start of the tx packet data (offset) was not being set correctly when the application was being run in unaligned mode.

This patch set has been applied against commit a2c11b034142 ("kcm: use BPF_PROG_RUN")

---
v2:
- Rearranged local variable order in i40e_run_xdp_zc and ixgbe_run_xdp_zc to comply with coding standards.

Ciara Loftus (3):
i40e: fix xdp handle calculations
ixgbe: fix xdp handle calculations samples/bpf: fix xdpsock l2fwd tx for unaligned mode

 drivers/net/ethernet/intel/i40e/i40e_xsk.c   | 4 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 ++--
 samples/bpf/xdpsock_user.c                   | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/3 i40e: fix xdp handle calculations

Commit 4c5d9a7fa149 ("i40e: fix xdp handle calculations") reintroduced the addition of the umem headroom to the xdp handle in the i40e_zca_free, i40e_alloc_buffer_slow_zc and i40e_alloc_buffer_zc functions. However, the headroom is already added to the handle in the function i40_run_xdp_zc. This commit removes the latter addition and fixes the case where the headroom is non-zero.

Fixes 4c5d9a7fa149 ("i40e: fix xdp handle calculations")
---
 drivers/net/ethernet/intel/i40e/i40e_xsk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_xsk.c +2 -2
index 0373bc6c7e61..a05dfecdd9b4 100644
@@ -192,9 +192,9 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp)
 {
 	struct xdp_umem *umem = rx_ring->xsk_umem;
 	int err, result = I40E_XDP_PASS;
-	u64 offset = umem->headroom;
 	struct i40e_ring *xdp_ring;
 	struct bpf_prog *xdp_prog;
+	u64 offset;
 	u32 act;
 
 	rcu_read_lock();
@@ -203,7 +203,7 @@ static int i40e_run_xdp_zc(struct i40e_ring *rx_ring, struct xdp_buff *xdp)
 	 */
 	xdp_prog = READ_ONCE(rx_ring->xdp_prog);
 	act = bpf_prog_run_xdp(xdp_prog, xdp);
-	offset += xdp->data - xdp->data_hard_start;
+	offset = xdp->data - xdp->data_hard_start;
 
 	xdp->handle = xsk_umem_adjust_offset(umem, xdp->handle, offset);
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/3 ixgbe: fix xdp handle calculations

In reply to Ciara Loftus

Commit 7cbbf9f1fa23 ("ixgbe: fix xdp handle calculations") reintroduced the addition of the umem headroom to the xdp handle in the ixgbe_zca_free, ixgbe_alloc_buffer_slow_zc and ixgbe_alloc_buffer_zc functions. However, the headroom is already added to the handle in the function ixgbe_run_xdp_zc. This commit removes the latter addition and fixes the case where the headroom is non-zero.

Fixes 7cbbf9f1fa23 ("ixgbe: fix xdp handle calculations")
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c +2 -2
index ad802a8909e0..fd45d12b5a98 100644
@@ -145,15 +145,15 @@ static int ixgbe_run_xdp_zc(struct ixgbe_adapter *adapter,
 {
 	struct xdp_umem *umem = rx_ring->xsk_umem;
 	int err, result = IXGBE_XDP_PASS;
-	u64 offset = umem->headroom;
 	struct bpf_prog *xdp_prog;
 	struct xdp_frame *xdpf;
+	u64 offset;
 	u32 act;
 
 	rcu_read_lock();
 	xdp_prog = READ_ONCE(rx_ring->xdp_prog);
 	act = bpf_prog_run_xdp(xdp_prog, xdp);
-	offset += xdp->data - xdp->data_hard_start;
+	offset = xdp->data - xdp->data_hard_start;
 
 	xdp->handle = xsk_umem_adjust_offset(umem, xdp->handle, offset);
 
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/3 samples/bpf: fix xdpsock l2fwd tx for unaligned mode

In reply to Ciara Loftus

Preserve the offset of the address of the received descriptor, and include it in the address set for the tx descriptor, so the kernel can correctly locate the start of the packet data.

Fixes 03895e63ff97 ("samples/bpf: add buffer recycling for unaligned chunks to xdpsock")
---
 samples/bpf/xdpsock_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/xdpsock_user.c +1 -1
index 102eace22956..df011ac33402 100644
@@ -685,7 +685,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds)
 	for (i = 0; i < rcvd; i++) {
 		u64 addr = xsk_ring_cons__rx_desc(&xsk->rx, idx_rx)->addr;
 		u32 len = xsk_ring_cons__rx_desc(&xsk->rx, idx_rx++)->len;
-		u64 orig = xsk_umem__extract_addr(addr);
+		u64 orig = addr;
 
 		addr = xsk_umem__add_offset_to_addr(addr);
 		char *pkt = xsk_umem__get_data(xsk->umem->buffer, addr);
Signature · 1 line
2.17.1
Acked-by on the v2 series
#4 lore raw
In reply to Ciara Loftus
Quoted 13 lines · Ciara Loftus

This patch set contains some fixes for AF_XDP zero copy in the i40e and ixgbe drivers as well as a fix for the 'xdpsock' sample application when running in unaligned mode.

Patches 1 and 2 fix a regression for the i40e and ixgbe drivers which caused the umem headroom to be added to the xdp handle twice, resulting in an incorrect value being received by the user for the case where the umem headroom is non-zero.

Patch 3 fixes an issue with the xdpsock sample application whereby the start of the tx packet data (offset) was not being set correctly when the application was being run in unaligned mode.

Quoted 8 lines

This patch set has been applied against commit a2c11b034142 ("kcm: use BPF_PROG_RUN")

---
v2:
- Rearranged local variable order in i40e_run_xdp_zc and ixgbe_run_xdp_zc to comply with coding standards.

Thanks Ciara!

Quoted 10 lines

Ciara Loftus (3):
i40e: fix xdp handle calculations
ixgbe: fix xdp handle calculations samples/bpf: fix xdpsock l2fwd tx for unaligned mode

  drivers/net/ethernet/intel/i40e/i40e_xsk.c   | 4 ++--
  drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 ++--
  samples/bpf/xdpsock_user.c                   | 2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)
maintainer Applied
#5 lore raw
In reply to Ciara Loftus
Quoted 26 lines · Ciara Loftus

This patch set contains some fixes for AF_XDP zero copy in the i40e and ixgbe drivers as well as a fix for the 'xdpsock' sample application when running in unaligned mode.

Patches 1 and 2 fix a regression for the i40e and ixgbe drivers which caused the umem headroom to be added to the xdp handle twice, resulting in an incorrect value being received by the user for the case where the umem headroom is non-zero.

Patch 3 fixes an issue with the xdpsock sample application whereby the start of the tx packet data (offset) was not being set correctly when the application was being run in unaligned mode.

This patch set has been applied against commit a2c11b034142 ("kcm: use BPF_PROG_RUN")

---
v2:
- Rearranged local variable order in i40e_run_xdp_zc and ixgbe_run_xdp_zc to comply with coding standards.

Ciara Loftus (3):
i40e: fix xdp handle calculations
ixgbe: fix xdp handle calculations samples/bpf: fix xdpsock l2fwd tx for unaligned mode

Quoted 5 lines
  drivers/net/ethernet/intel/i40e/i40e_xsk.c   | 4 ++--
  drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 ++--
  samples/bpf/xdpsock_user.c                   | 2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)

Applied, thanks!