This adds the netgpu structure (which arguably should be private),
and some cruft to support using netgpu as a loadable module, which
should disappear.

Signed-off-by: Jonathan Lemon <jonathan.le...@gmail.com>
---
 include/net/netgpu.h | 65 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 include/net/netgpu.h

diff --git a/include/net/netgpu.h b/include/net/netgpu.h
new file mode 100644
index 000000000000..fee84ba3db78
--- /dev/null
+++ b/include/net/netgpu.h
@@ -0,0 +1,65 @@
+#pragma once
+
+struct net_device;
+#include <uapi/misc/shqueue.h>         /* XXX */
+
+struct netgpu_pgcache {
+       struct netgpu_pgcache *next;
+       struct page *page[];
+};
+
+struct netgpu_ctx {
+       struct xarray xa;               /* contains regions */
+       unsigned int index;
+       refcount_t ref;
+       struct shared_queue fill;
+       struct shared_queue rx;
+       struct net_device *dev;
+       struct netgpu_pgcache *napi_cache;
+       struct netgpu_pgcache *spare_cache;
+       struct netgpu_pgcache *any_cache;
+       spinlock_t pgcache_lock;
+       struct page *dummy_page;
+       unsigned page_extra_refc;
+       int queue_id;
+       int napi_cache_count;
+       int any_cache_count;
+       struct user_struct *user;
+       unsigned account_mem : 1;
+};
+
+int netgpu_get_page(struct netgpu_ctx *ctx, struct page **page,
+                   dma_addr_t *dma);
+void netgpu_put_page(struct netgpu_ctx *ctx, struct page *page, bool napi);
+int netgpu_get_pages(struct sock *sk, struct page **pages, unsigned long addr,
+                int count);
+
+/*---------------------------------------------------------------------------*/
+/* XXX temporary development support */
+
+extern int (*fn_netgpu_get_page)(struct netgpu_ctx *ctx,
+                         struct page **page, dma_addr_t *dma);
+extern void (*fn_netgpu_put_page)(struct netgpu_ctx *, struct page *, bool);
+extern int (*fn_netgpu_get_pages)(struct sock *, struct page **,
+                           unsigned long, int);
+extern struct netgpu_ctx *g_ctx;
+
+static inline int
+__netgpu_get_page(struct netgpu_ctx *ctx,
+                  struct page **page, dma_addr_t *dma)
+{
+        return fn_netgpu_get_page(ctx, page, dma);
+}
+
+static inline void
+__netgpu_put_page(struct netgpu_ctx *ctx, struct page *page, bool napi)
+{
+        return fn_netgpu_put_page(ctx, page, napi);
+}
+
+static inline int
+__netgpu_get_pages(struct sock *sk, struct page **pages,
+                   unsigned long addr, int count)
+{
+        return fn_netgpu_get_pages(sk, pages, addr, count);
+}
-- 
2.24.1

Reply via email to