-
Notifications
You must be signed in to change notification settings - Fork 0
/
netgpu_lib.h
67 lines (50 loc) · 2.16 KB
/
netgpu_lib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <sys/uio.h>
#include "netgpu_util.h"
#include "bpf/libbpf_util.h"
#include "uapi/misc/netgpu.h"
#include "uapi/misc/shqueue.h"
#include "netgpu_lib.h"
#ifndef MSG_ZEROCOPY
#define MSG_ZEROCOPY 0x4000000
#endif
#define MSG_NETDMA 0x8000000
struct netgpu_skq;
struct netgpu_ifq;
struct netgpu_ctx;
struct netgpu_mem;
void netgpu_populate_ring(struct netgpu_ifq *ifq, uint64_t addr, int count);
int netgpu_get_rx_batch(struct netgpu_skq *skq, struct iovec *iov[], int count);
int netgpu_get_cq_batch(struct netgpu_skq *skq, uint64_t *notify[], int count);
void netgpu_recycle_buffer(struct netgpu_ifq *ifq, void *ptr);
bool netgpu_recycle_batch(struct netgpu_ifq *ifq, struct iovec **iov,
int count);
void netgpu_recycle_complete(struct netgpu_ifq *ifq);
void netgpu_populate_meta(struct netgpu_skq *skq, uint64_t addr, int count,
int size);
void netgpu_recycle_meta(struct netgpu_skq *skq, void *ptr);
void netgpu_submit_meta(struct netgpu_skq *skq);
int netgpu_add_meta(struct netgpu_skq *skq, int fd, void *addr, size_t len,
int nentries, int meta_len);
int netgpu_attach_socket(struct netgpu_skq **skqp, struct netgpu_ctx *ctx,
int fd, int nentries);
void netgpu_detach_socket(struct netgpu_skq **skqp);
int netgpu_ifq_id(struct netgpu_ifq *ifq);
int netgpu_open_ifq(struct netgpu_ifq **ifqp, struct netgpu_ctx *ctx,
int queue_id, int fill_entries);
void netgpu_close_ifq(struct netgpu_ifq **ifqp);
int netgpu_attach_region(struct netgpu_ctx *ctx, struct netgpu_mem *mem,
int idx);
int netgpu_open_ctx(struct netgpu_ctx **ctxp, const char *ifname);
void netgpu_close_ctx(struct netgpu_ctx **ctxp);
int netgpu_open_memarea(struct netgpu_mem **memp);
void netgpu_close_memarea(struct netgpu_mem **memp);
int netgpu_add_memarea(struct netgpu_mem *mem, void *va, size_t size,
enum netgpu_memtype memtype);
void *netgpu_alloc_memory(size_t size, enum netgpu_memtype memtype);
void netgpu_free_memory(void *area, size_t size, enum netgpu_memtype memtype);
/* convenience functions */
int netgpu_register_memory(struct netgpu_ctx *ctx, void *va, size_t size,
enum netgpu_memtype memtype);