-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.h
73 lines (58 loc) · 1.56 KB
/
server.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
68
69
70
71
72
73
/* SPDX-License-Identifier: BSD-3-Clause */
/* Copyright Meta Platforms, Inc. and affiliates */
#ifndef SERVER_H
#define SERVER_H 1
#include <netdb.h>
#include <net/if.h>
#include <sys/types.h>
#include <ccan/compiler/compiler.h>
#include <ccan/list/list.h>
#include <ynl-c/ynl.h>
#include "proto.h"
struct server_session {
int cfd;
pid_t pid;
struct list_node sessions;
};
#ifndef MSG_SOCK_DEVMEM
#define MSG_SOCK_DEVMEM 0x2000000
#define SO_DEVMEM_LINEAR 78
#define SO_DEVMEM_DMABUF 79
#define SO_DEVMEM_DONTNEED 80
struct dmabuf_cmsg {
__u64 frag_offset;
__u32 frag_size;
__u32 frag_token;
__u32 dmabuf_id;
__u32 flags;
};
struct dmabuf_token {
__u32 token_start;
__u32 token_count;
};
#endif
struct connection_devmem {
struct dmabuf_token rxtok[128];
int rxtok_len;
/* ncdevmem uses 80k, allocate 64k for recvmsg tokens */
char ctrl_data[64 * 1024];
};
struct session_state_devmem {
struct ynl_sock *ys;
char ifname[IFNAMSIZ];
int dmabuf_id;
int dmabuf_fd;
int udmabuf_devfd;
int udmabuf_memfd;
bool udmabuf_valid;
};
struct server_session *
server_session_spawn(int fd, struct sockaddr_in6 *addr, socklen_t *addrlen);
void NORETURN pworker_main(int fd, enum kpm_rx_mode rx_mode, enum kpm_tx_mode tx_mode);
int devmem_setup(struct session_state_devmem *devmem, int fd,
size_t udmabuf_size);
int devmem_teardown(struct session_state_devmem *devmem);
int devmem_release_tokens(int fd, struct connection_devmem *conn);
ssize_t devmem_recv(int fd, struct connection_devmem *conn,
unsigned char *rxbuf, size_t chunk, int rep);
#endif /* SERVER_H */