-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
96 lines (83 loc) · 1.55 KB
/
util.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef _UTIL_H
#define _UTIL_H
#define err_with(rc, ...) do { \
errno = -rc; \
err(1, __VA_ARGS__); \
} while (0)
extern long read_count;
extern long write_count;
extern long read_partial;
extern long write_partial;
struct node {
int fd;
int rank;
int family;
int socktype;
int protocol;
socklen_t addrlen;
struct sockaddr_storage addr;
// struct ether_addr mac_addr;
};
enum rw_type {
RW_BASIC,
RW_MSG,
RW_FIXED,
};
enum transport_type {
TRANSPORT_TCP,
TRANSPORT_UDP,
TRANSPORT_XDP,
TRANSPORT_IOU,
};
struct opt {
const char *iface;
bool poll;
bool nonblock;
bool dual;
bool end_summary;
int timeout;
int port;
int rank;
enum transport_type transport;
const char *driver;
bool zerocopy;
/* test parameters */
struct {
int iterations;
int elements;
int chunk_size;
int chunk_count;
};
/* mpi/mesh parameters */
struct {
int size; /* mesh size */
bool root;
int rootport; /* control port */
const char *roothost;
};
/* iou parameters */
struct {
enum rw_type rw_api;
int entries;
} iou;
/* xdp parameters */
struct {
bool use_wakeup;
unsigned xdp_flags;
unsigned bind_flags;
unsigned mmap_flags;
unsigned umem_flags;
int frame_size;
int num_frames;
int num_xsks;
int queue;
int ifindex;
} xsk;
};
extern struct opt opt;
void set_blocking_mode(int fd, bool on);
bool fd_read_ready(int fd);
const char *show_node_addr(struct node *node);
void setup_node(struct node *node, int socktype, const char *selfname);
void set_port(struct node *node, int port);
#endif /* _UTIL_H */