[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180131135356.19134-11-bjorn.topel@gmail.com>
Date: Wed, 31 Jan 2018 14:53:42 +0100
From: Björn Töpel <bjorn.topel@...il.com>
To: bjorn.topel@...il.com, magnus.karlsson@...el.com,
alexander.h.duyck@...el.com, alexander.duyck@...il.com,
john.fastabend@...il.com, ast@...com, brouer@...hat.com,
willemdebruijn.kernel@...il.com, daniel@...earbox.net,
netdev@...r.kernel.org
Cc: michael.lundkvist@...csson.com, jesse.brandeburg@...el.com,
anjali.singhai@...el.com, jeffrey.b.shaw@...el.com,
ferruh.yigit@...el.com, qi.z.zhang@...el.com
Subject: [RFC PATCH 10/24] netdevice: added XDP_{UN,}REGISTER_XSK command to ndo_bpf
From: Magnus Karlsson <magnus.karlsson@...el.com>
Here, ndo_bpf is extended with two sub-commands: XDP_REGISTER_XSK and
XDP_UNREGISTER_XSK. They are used to support zero copy allocators with
XDP sockets.
Signed-off-by: Magnus Karlsson <magnus.karlsson@...el.com>
---
include/linux/netdevice.h | 17 +++++++++++++++++
include/net/xdp_sock.h | 30 +++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 36cc7e92bd8e..a997649dd5cc 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -810,10 +810,18 @@ enum bpf_netdev_command {
BPF_OFFLOAD_DESTROY,
BPF_OFFLOAD_MAP_ALLOC,
BPF_OFFLOAD_MAP_FREE,
+ /* Registers callbacks with the driver that is used to support
+ * AF_XDP sockets in zero copy mode.
+ */
+ XDP_REGISTER_XSK,
+ /* Unregisters and AF_XDP socket in zero copy mode. */
+ XDP_UNREGISTER_XSK,
};
struct bpf_prog_offload_ops;
struct netlink_ext_ack;
+struct xsk_tx_parms;
+struct xsk_rx_parms;
struct netdev_bpf {
enum bpf_netdev_command command;
@@ -844,6 +852,15 @@ struct netdev_bpf {
struct {
struct bpf_offloaded_map *offmap;
};
+ /* XDP_REGISTER_XSK, XDP_UNREGISTER_XSK
+ * All fields used for XDP_REGISTER_XSK.
+ * queue_id the only field used for XDP_UNREGISTER_XSK.
+ */
+ struct {
+ struct xsk_tx_parms *tx_parms;
+ struct xsk_rx_parms *rx_parms;
+ u32 queue_id;
+ } xsk;
};
};
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h
index 132489fe0e70..866ea7191217 100644
--- a/include/net/xdp_sock.h
+++ b/include/net/xdp_sock.h
@@ -1,8 +1,36 @@
#ifndef _LINUX_AF_XDP_SOCK_H
#define _LINUX_AF_XDP_SOCK_H
-struct xdp_sock;
+#include <linux/dma-direction.h>
+
+struct buff_pool;
+struct net_device;
struct xdp_buff;
+struct xdp_sock;
+
+/* These two functions have to be called from the same serializing conext,
+ * for example the same NAPI context.
+ * They should not be called for the XDP_SKB path, only XDP_DRV.
+ */
+
+struct xsk_tx_parms {
+ void (*tx_completion)(u32 start, u32 npackets,
+ unsigned long ctx1, unsigned long ctx2);
+ unsigned long ctx1;
+ unsigned long ctx2;
+ int (*get_tx_packet)(struct net_device *dev, u32 queue_id,
+ dma_addr_t *dma, void **data, u32 *len,
+ u32 *offset);
+};
+
+struct xsk_rx_parms {
+ struct buff_pool *buff_pool;
+ int (*dma_map)(struct buff_pool *bp, struct device *dev,
+ enum dma_data_direction dir,
+ unsigned long attr);
+ void *error_report_ctx;
+ void (*error_report)(void *ctx, int errno);
+};
#ifdef CONFIG_XDP_SOCKETS
int xsk_generic_rcv(struct xdp_buff *xdp);
--
2.14.1
Powered by blists - more mailing lists