@@ -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;
};
};
@@ -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);