bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next]  0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
@ 2020-08-28 15:20 Weqaar Janjua
  2020-08-28 16:14 ` Janjua, Weqaar A
  0 siblings, 1 reply; 2+ messages in thread
From: Weqaar Janjua @ 2020-08-28 15:20 UTC (permalink / raw)
  To: magnus.karlsson, bjorn.topel, ast, daniel, netdev, jonathan.lemon
  Cc: Weqaar Janjua, bpf

---
 ...to-xdpsock-to-avoid-recycling-frames.patch | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch

diff --git a/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch b/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
new file mode 100644
index 000000000000..ae3b99b335e2
--- /dev/null
+++ b/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
@@ -0,0 +1,62 @@
+From df0a23a79c9dca96c0059b4d766a613eba57200e Mon Sep 17 00:00:00 2001
+From: Weqaar Janjua <weqaar.a.janjua@intel.com>
+Date: Fri, 28 Aug 2020 13:36:32 +0100
+Subject: [PATCH bpf-next] samples/bpf: fix to xdpsock to avoid recycling
+ frames
+To: magnus.karlsson@intel.com
+
+The txpush program in the xdpsock sample application is supposed
+to send out all packets in the umem in a round-robin fashion.
+The problem is that it only cycled through the first BATCH_SIZE
+worth of packets. Fixed this so that it cycles through all buffers
+in the umem as intended.
+
+Fixes: 248c7f9c0e21 ("samples/bpf: convert xdpsock to use libbpf for AF_XDP access")
+Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com>
+---
+ samples/bpf/xdpsock_user.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
+index 19c679456a0e..c821e9867139 100644
+--- a/samples/bpf/xdpsock_user.c
++++ b/samples/bpf/xdpsock_user.c
+@@ -1004,7 +1004,7 @@ static void rx_drop_all(void)
+ 	}
+ }
+ 
+-static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
++static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
+ {
+ 	u32 idx;
+ 	unsigned int i;
+@@ -1017,14 +1017,14 @@ static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
+ 	for (i = 0; i < batch_size; i++) {
+ 		struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
+ 								  idx + i);
+-		tx_desc->addr = (frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
++		tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
+ 		tx_desc->len = PKT_SIZE;
+ 	}
+ 
+ 	xsk_ring_prod__submit(&xsk->tx, batch_size);
+ 	xsk->outstanding_tx += batch_size;
+-	frame_nb += batch_size;
+-	frame_nb %= NUM_FRAMES;
++	*frame_nb += batch_size;
++	*frame_nb %= NUM_FRAMES;
+ 	complete_tx_only(xsk, batch_size);
+ }
+ 
+@@ -1080,7 +1080,7 @@ static void tx_only_all(void)
+ 		}
+ 
+ 		for (i = 0; i < num_socks; i++)
+-			tx_only(xsks[i], frame_nb[i], batch_size);
++			tx_only(xsks[i], &frame_nb[i], batch_size);
+ 
+ 		pkt_cnt += batch_size;
+ 
+-- 
+2.20.1
+
-- 
2.20.1

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH bpf-next] 0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
  2020-08-28 15:20 [PATCH bpf-next] 0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch Weqaar Janjua
@ 2020-08-28 16:14 ` Janjua, Weqaar A
  0 siblings, 0 replies; 2+ messages in thread
From: Janjua, Weqaar A @ 2020-08-28 16:14 UTC (permalink / raw)
  To: Karlsson, Magnus, Topel, Bjorn, ast, daniel, netdev, jonathan.lemon; +Cc: bpf

> -----Original Message-----
> From: Janjua, Weqaar A <weqaar.a.janjua@intel.com>
> Sent: Friday, August 28, 2020 4:20 PM
> To: Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn
> <bjorn.topel@intel.com>; ast@kernel.org; daniel@iogearbox.net;
> netdev@vger.kernel.org; jonathan.lemon@gmail.com
> Cc: Janjua, Weqaar A <weqaar.a.janjua@intel.com>; bpf@vger.kernel.org
> Subject: [PATCH bpf-next] 0001-samples-bpf-fix-to-xdpsock-to-avoid-
> recycling-frames.patch
> 
> ---
>  ...to-xdpsock-to-avoid-recycling-frames.patch | 62 +++++++++++++++++++
>  1 file changed, 62 insertions(+)
>  create mode 100644 0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-
> frames.patch
> 
> diff --git a/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
> b/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
> new file mode 100644
> index 000000000000..ae3b99b335e2
> --- /dev/null
> +++ b/0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch
> @@ -0,0 +1,62 @@
> +From df0a23a79c9dca96c0059b4d766a613eba57200e Mon Sep 17
> 00:00:00 2001
> +From: Weqaar Janjua <weqaar.a.janjua@intel.com>
> +Date: Fri, 28 Aug 2020 13:36:32 +0100
> +Subject: [PATCH bpf-next] samples/bpf: fix to xdpsock to avoid
> +recycling  frames
> +To: magnus.karlsson@intel.com
> +
> +The txpush program in the xdpsock sample application is supposed to
> +send out all packets in the umem in a round-robin fashion.
> +The problem is that it only cycled through the first BATCH_SIZE worth
> +of packets. Fixed this so that it cycles through all buffers in the
> +umem as intended.
> +
> +Fixes: 248c7f9c0e21 ("samples/bpf: convert xdpsock to use libbpf for
> +AF_XDP access")
> +Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com>
> +---
> + samples/bpf/xdpsock_user.c | 10 +++++-----
> + 1 file changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> +index 19c679456a0e..c821e9867139 100644
> +--- a/samples/bpf/xdpsock_user.c
> ++++ b/samples/bpf/xdpsock_user.c
> +@@ -1004,7 +1004,7 @@ static void rx_drop_all(void)
> + 	}
> + }
> +
> +-static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int
> +batch_size)
> ++static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int
> ++batch_size)
> + {
> + 	u32 idx;
> + 	unsigned int i;
> +@@ -1017,14 +1017,14 @@ static void tx_only(struct xsk_socket_info
> *xsk, u32 frame_nb, int batch_size)
> + 	for (i = 0; i < batch_size; i++) {
> + 		struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk-
> >tx,
> + 								  idx + i);
> +-		tx_desc->addr = (frame_nb + i) <<
> XSK_UMEM__DEFAULT_FRAME_SHIFT;
> ++		tx_desc->addr = (*frame_nb + i) <<
> XSK_UMEM__DEFAULT_FRAME_SHIFT;
> + 		tx_desc->len = PKT_SIZE;
> + 	}
> +
> + 	xsk_ring_prod__submit(&xsk->tx, batch_size);
> + 	xsk->outstanding_tx += batch_size;
> +-	frame_nb += batch_size;
> +-	frame_nb %= NUM_FRAMES;
> ++	*frame_nb += batch_size;
> ++	*frame_nb %= NUM_FRAMES;
> + 	complete_tx_only(xsk, batch_size);
> + }
> +
> +@@ -1080,7 +1080,7 @@ static void tx_only_all(void)
> + 		}
> +
> + 		for (i = 0; i < num_socks; i++)
> +-			tx_only(xsks[i], frame_nb[i], batch_size);
> ++			tx_only(xsks[i], &frame_nb[i], batch_size);
> +
> + 		pkt_cnt += batch_size;
> +
> +--
> +2.20.1
> +
> --
> 2.20.1

[Janjua, Weqaar A] Apologies, please discard this patch, will resubmit.
--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-28 16:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 15:20 [PATCH bpf-next] 0001-samples-bpf-fix-to-xdpsock-to-avoid-recycling-frames.patch Weqaar Janjua
2020-08-28 16:14 ` Janjua, Weqaar A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).