From: Jonathan Lemon <jonathan.lemon@gmail.com>
To: <netdev@vger.kernel.org>, <bjorn.topel@intel.com>,
<magnus.karlsson@intel.com>, <jakub.kicinski@netronome.com>,
<jeffrey.t.kirsher@intel.com>
Cc: <kernel-team@fb.com>
Subject: [PATCH 1/3 bpf-next] net: add convert_to_xdp_frame_keep_zc function
Date: Fri, 28 Jun 2019 15:15:53 -0700 [thread overview]
Message-ID: <20190628221555.3009654-2-jonathan.lemon@gmail.com> (raw)
In-Reply-To: <20190628221555.3009654-1-jonathan.lemon@gmail.com>
Add a function which converts a ZC xdp_buff to a an xdp_frame, while
keeping the zc backing storage. This will be used to support TX of
received AF_XDP frames.
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
include/net/xdp.h | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/include/net/xdp.h b/include/net/xdp.h
index 40c6d3398458..abe5f47ff0a5 100644
--- a/include/net/xdp.h
+++ b/include/net/xdp.h
@@ -82,6 +82,7 @@ struct xdp_frame {
*/
struct xdp_mem_info mem;
struct net_device *dev_rx; /* used by cpumap */
+ unsigned long handle;
};
/* Clear kernel pointers in xdp_frame */
@@ -95,15 +96,12 @@ struct xdp_frame *xdp_convert_zc_to_xdp_frame(struct xdp_buff *xdp);
/* Convert xdp_buff to xdp_frame */
static inline
-struct xdp_frame *convert_to_xdp_frame(struct xdp_buff *xdp)
+struct xdp_frame *__convert_to_xdp_frame(struct xdp_buff *xdp)
{
struct xdp_frame *xdp_frame;
int metasize;
int headroom;
- if (xdp->rxq->mem.type == MEM_TYPE_ZERO_COPY)
- return xdp_convert_zc_to_xdp_frame(xdp);
-
/* Assure headroom is available for storing info */
headroom = xdp->data - xdp->data_hard_start;
metasize = xdp->data - xdp->data_meta;
@@ -125,6 +123,20 @@ struct xdp_frame *convert_to_xdp_frame(struct xdp_buff *xdp)
return xdp_frame;
}
+static inline
+struct xdp_frame *convert_to_xdp_frame(struct xdp_buff *xdp)
+{
+ if (xdp->rxq->mem.type == MEM_TYPE_ZERO_COPY)
+ return xdp_convert_zc_to_xdp_frame(xdp);
+ return __convert_to_xdp_frame(xdp);
+}
+
+static inline
+struct xdp_frame *convert_to_xdp_frame_keep_zc(struct xdp_buff *xdp)
+{
+ return __convert_to_xdp_frame(xdp);
+}
+
void xdp_return_frame(struct xdp_frame *xdpf);
void xdp_return_frame_rx_napi(struct xdp_frame *xdpf);
void xdp_return_buff(struct xdp_buff *xdp);
--
2.17.1
next prev parent reply other threads:[~2019-06-28 22:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-28 22:15 [PATCH 0/3 bpf-next] intel: AF_XDP support for TX of RX packets Jonathan Lemon
2019-06-28 22:15 ` Jonathan Lemon [this message]
2019-07-01 11:02 ` [PATCH 1/3 bpf-next] net: add convert_to_xdp_frame_keep_zc function Magnus Karlsson
2019-06-28 22:15 ` [PATCH 2/3 bpf-next] i40e: Support zero-copy XDP_TX on the RX path for AF_XDP sockets Jonathan Lemon
2019-07-01 11:04 ` Magnus Karlsson
2019-07-02 16:44 ` Jonathan Lemon
2019-07-02 7:07 ` Maxim Mikityanskiy
2019-07-02 16:31 ` Jonathan Lemon
2019-06-28 22:15 ` [PATCH 3/3 bpf-next] ixgbe: " Jonathan Lemon
2019-07-01 11:01 ` [PATCH 0/3 bpf-next] intel: AF_XDP support for TX of RX packets Magnus Karlsson
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=20190628221555.3009654-2-jonathan.lemon@gmail.com \
--to=jonathan.lemon@gmail.com \
--cc=bjorn.topel@intel.com \
--cc=jakub.kicinski@netronome.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=kernel-team@fb.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.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).