lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200727224444.2987641-7-jonathan.lemon@gmail.com>
Date:   Mon, 27 Jul 2020 15:44:29 -0700
From:   Jonathan Lemon <jonathan.lemon@...il.com>
To:     <netdev@...r.kernel.org>
CC:     <kernel-team@...com>
Subject: [RFC PATCH v2 06/21] include: add netgpu UAPI and kernel definitions

From: Jonathan Lemon <bsd@...com>

This provides the interface to the netgpu module.

Signed-off-by: Jonathan Lemon <jonathan.lemon@...il.com>
---
 include/net/netgpu.h       | 66 ++++++++++++++++++++++++++++++++++++
 include/uapi/misc/netgpu.h | 69 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)
 create mode 100644 include/net/netgpu.h
 create mode 100644 include/uapi/misc/netgpu.h

diff --git a/include/net/netgpu.h b/include/net/netgpu.h
new file mode 100644
index 000000000000..14bd19412c38
--- /dev/null
+++ b/include/net/netgpu.h
@@ -0,0 +1,66 @@
+#ifndef _NET_NETGPU_H
+#define _NET_NETGPU_H
+
+#include <uapi/misc/netgpu.h>		/* IOCTL defines */
+#include <uapi/misc/shqueue.h>
+
+enum {
+	NETGPU_MEMTYPE_HOST,
+	NETGPU_MEMTYPE_CUDA,
+
+	NETGPU_MEMTYPE_MAX,
+};
+
+struct netgpu_pgcache {
+	struct netgpu_pgcache *next;
+	struct page *page[];
+};
+
+struct netgpu_ifq {
+	struct shared_queue fill;
+	struct wait_queue_head fill_wait;
+	struct netgpu_ctx *ctx;
+	int queue_id;
+	spinlock_t pgcache_lock;
+	struct netgpu_pgcache *napi_cache;
+	struct netgpu_pgcache *spare_cache;
+	struct netgpu_pgcache *any_cache;
+	int napi_cache_count;
+	int any_cache_count;
+	struct list_head ifq_node;
+};
+
+struct netgpu_skq {
+	struct shared_queue rx;
+	struct shared_queue cq;		/* for requested completions */
+	struct netgpu_ctx *ctx;
+	void (*sk_destruct)(struct sock *sk);
+	void (*sk_data_ready)(struct sock *sk);
+};
+
+struct netgpu_ctx {
+	struct xarray xa;		/* contains dmamaps */
+	refcount_t ref;
+	struct net_device *dev;
+	struct list_head ifq_list;
+};
+
+struct net_device;
+struct netgpu_ops;
+struct socket;
+
+dma_addr_t netgpu_get_dma(struct netgpu_ctx *ctx, struct page *page);
+int netgpu_get_page(struct netgpu_ifq *ifq, struct page **page,
+		    dma_addr_t *dma);
+void netgpu_put_page(struct netgpu_ifq *ifq, struct page *page, bool napi);
+int netgpu_get_pages(struct sock *sk, struct page **pages, unsigned long addr,
+		     int count);
+
+int netgpu_socket_mmap(struct file *file, struct socket *sock,
+		       struct vm_area_struct *vma);
+int netgpu_attach_socket(struct sock *sk, void __user *arg);
+
+int netgpu_register(struct netgpu_ops *ops);
+void netgpu_unregister(int memtype);
+
+#endif /* _NET_NETGPU_H */
diff --git a/include/uapi/misc/netgpu.h b/include/uapi/misc/netgpu.h
new file mode 100644
index 000000000000..1fa8a1d719ee
--- /dev/null
+++ b/include/uapi/misc/netgpu.h
@@ -0,0 +1,69 @@
+#ifndef _UAPI_MISC_NETGPU_H
+#define _UAPI_MISC_NETGPU_H
+
+#include <linux/ioctl.h>
+
+#define NETGPU_OFF_FILL_ID	(0ULL << 12)
+#define NETGPU_OFF_RX_ID	(1ULL << 12)
+#define NETGPU_OFF_CQ_ID	(2ULL << 12)
+
+struct netgpu_queue_offsets {
+	unsigned prod;
+	unsigned cons;
+	unsigned data;
+	unsigned resv;
+};
+
+struct netgpu_user_queue {
+	unsigned elt_sz;
+	unsigned entries;
+	unsigned mask;
+	unsigned map_sz;
+	unsigned map_off;
+	struct netgpu_queue_offsets off;
+};
+
+enum netgpu_memtype {
+	MEMTYPE_HOST,
+	MEMTYPE_CUDA,
+
+	MEMTYPE_MAX,
+};
+
+/* VA memory provided by a specific PCI device. */
+struct netgpu_region_param {
+	struct iovec iov;
+	enum netgpu_memtype memtype;
+};
+
+struct netgpu_attach_param {
+	int mem_fd;
+	int mem_idx;
+};
+
+struct netgpu_socket_param {
+	unsigned resv;
+	int ctx_fd;
+	struct netgpu_user_queue rx;
+	struct netgpu_user_queue cq;
+};
+
+struct netgpu_ifq_param {
+	unsigned resv;
+	unsigned ifq_fd;		/* OUT parameter */
+	unsigned queue_id;		/* IN/OUT, IN: -1 if don't care */
+	struct netgpu_user_queue fill;
+};
+
+struct netgpu_ctx_param {
+	unsigned resv;
+	unsigned ifindex;
+};
+
+#define NETGPU_CTX_IOCTL_ATTACH_DEV	_IOR( 0, 1, int)
+#define NETGPU_CTX_IOCTL_BIND_QUEUE	_IOWR(0, 2, struct netgpu_ifq_param)
+#define NETGPU_CTX_IOCTL_ATTACH_REGION	_IOW( 0, 3, struct netgpu_attach_param)
+#define NETGPU_MEM_IOCTL_ADD_REGION	_IOR( 0, 4, struct netgpu_region_param)
+#define NETGPU_SOCK_IOCTL_ATTACH_QUEUES	(SIOCPROTOPRIVATE + 0)
+
+#endif /* _UAPI_MISC_NETGPU_H */
-- 
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ