[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190628221555.3009654-2-jonathan.lemon@gmail.com>
Date: Fri, 28 Jun 2019 15:15:53 -0700
From: Jonathan Lemon <jonathan.lemon@...il.com>
To: <netdev@...r.kernel.org>, <bjorn.topel@...el.com>,
<magnus.karlsson@...el.com>, <jakub.kicinski@...ronome.com>,
<jeffrey.t.kirsher@...el.com>
CC: <kernel-team@...com>
Subject: [PATCH 1/3 bpf-next] net: add convert_to_xdp_frame_keep_zc function
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@...il.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
Powered by blists - more mailing lists