netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
	bjorn@kernel.org, tirthendu.sarkar@intel.com, toke@kernel.org,
	kuba@kernel.org, horms@kernel.org,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Subject: [PATCH v6 bpf-next 03/24] xsk: prepare both copy and zero-copy modes to co-exist
Date: Fri, 14 Jul 2023 13:36:19 +0200	[thread overview]
Message-ID: <20230714113640.556893-4-maciej.fijalkowski@intel.com> (raw)
In-Reply-To: <20230714113640.556893-1-maciej.fijalkowski@intel.com>

Currently, __xsk_rcv_zc() is a function that is responsible for
producing AF_XDP Rx descriptors. It is used by both copy and zero-copy
mode. Both of these modes are going to differ when multi-buffer support
is going to be added. ZC will work on a chain of xdp_buff_xsk structs
whereas copy-mode is going to utilize skb_shared_info contents. This
means that ZC-specific changes would affect the copy mode.

Let's modify __xsk_rcv_zc() to work directly on xdp_buff_xsk so the
callsites have to retrieve this from xdp_buff. Also, introduce
xsk_rcv_zc() which will carry all the needed later changes for
supporting multi-buffer on ZC side that do not apply to copy mode.

Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
 net/xdp/xsk.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index c8460927e5f3..c7f79920e8cc 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -135,9 +135,9 @@ int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,
 	return 0;
 }
 
-static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len, u32 flags)
+static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff_xsk *xskb, u32 len,
+			u32 flags)
 {
-	struct xdp_buff_xsk *xskb = container_of(xdp, struct xdp_buff_xsk, xdp);
 	u64 addr;
 	int err;
 
@@ -152,6 +152,13 @@ static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len, u32
 	return 0;
 }
 
+static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
+{
+	struct xdp_buff_xsk *xskb = container_of(xdp, struct xdp_buff_xsk, xdp);
+
+	return __xsk_rcv_zc(xs, xskb, len, 0);
+}
+
 static void xsk_copy_xdp(struct xdp_buff *to, struct xdp_buff *from, u32 len)
 {
 	void *from_buf, *to_buf;
@@ -172,6 +179,7 @@ static void xsk_copy_xdp(struct xdp_buff *to, struct xdp_buff *from, u32 len)
 
 static int __xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
 {
+	struct xdp_buff_xsk *xskb;
 	struct xdp_buff *xsk_xdp;
 	int err;
 	u32 len;
@@ -189,7 +197,8 @@ static int __xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
 	}
 
 	xsk_copy_xdp(xsk_xdp, xdp, len);
-	err = __xsk_rcv_zc(xs, xsk_xdp, len, 0);
+	xskb = container_of(xsk_xdp, struct xdp_buff_xsk, xdp);
+	err = __xsk_rcv_zc(xs, xskb, len, 0);
 	if (err) {
 		xsk_buff_free(xsk_xdp);
 		return err;
@@ -259,7 +268,7 @@ static int xsk_rcv(struct xdp_sock *xs, struct xdp_buff *xdp)
 
 	if (xdp->rxq->mem.type == MEM_TYPE_XSK_BUFF_POOL) {
 		len = xdp->data_end - xdp->data;
-		return __xsk_rcv_zc(xs, xdp, len, 0);
+		return xsk_rcv_zc(xs, xdp, len);
 	}
 
 	err = __xsk_rcv(xs, xdp);
-- 
2.34.1


  parent reply	other threads:[~2023-07-14 11:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 11:36 [PATCH v6 bpf-next 00/24] xsk: multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 01/24] xsk: prepare 'options' in xdp_desc for multi-buffer use Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 02/24] xsk: introduce XSK_USE_SG bind flag for xsk socket Maciej Fijalkowski
2023-07-14 11:36 ` Maciej Fijalkowski [this message]
2023-07-14 11:36 ` [PATCH v6 bpf-next 04/24] xsk: move xdp_buff's data length check to xsk_rcv_check Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 05/24] xsk: add support for AF_XDP multi-buffer on Rx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 06/24] xsk: introduce wrappers and helpers for supporting multi-buffer in Tx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 07/24] xsk: allow core/drivers to test EOP bit Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 08/24] xsk: add support for AF_XDP multi-buffer on Tx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 09/24] xsk: discard zero length descriptors in " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 10/24] xsk: add new netlink attribute dedicated for ZC max frags Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 11/24] xsk: support mbuf on ZC RX Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 12/24] ice: xsk: add RX multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 13/24] i40e: " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 14/24] xsk: support ZC Tx multi-buffer in batch API Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 15/24] ice: xsk: Tx multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 16/24] i40e: xsk: add TX " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 17/24] xsk: add multi-buffer documentation Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 18/24] selftests/xsk: transmit and receive multi-buffer packets Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 19/24] selftests/xsk: add basic multi-buffer test Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 20/24] selftests/xsk: add unaligned mode test for multi-buffer Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 21/24] selftests/xsk: add invalid descriptor " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 22/24] selftests/xsk: add metadata copy test for multi-buff Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 23/24] selftests/xsk: add test for too many frags Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 24/24] selftests/xsk: reset NIC settings to default after running test suite Maciej Fijalkowski
2023-07-14 15:34 ` [PATCH v6 bpf-next 00/24] xsk: multi-buffer support Alexei Starovoitov

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=20230714113640.556893-4-maciej.fijalkowski@intel.com \
    --to=maciej.fijalkowski@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=tirthendu.sarkar@intel.com \
    --cc=toke@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).