Commit | Line | Data |
---|---|---|
50d16976 JA |
1 | #ifndef FIO_SERVER_H |
2 | #define FIO_SERVER_H | |
3 | ||
132159a5 | 4 | #include <inttypes.h> |
142575e6 | 5 | #include <string.h> |
89c1707c | 6 | #include <sys/time.h> |
811826be | 7 | #include <netinet/in.h> |
132159a5 | 8 | |
a64e88da | 9 | #include "stat.h" |
610a730c | 10 | #include "os/os.h" |
d09a64a0 | 11 | #include "diskutil.h" |
a64e88da | 12 | |
5adc2447 SC |
13 | #define FIO_NET_PORT 8765 |
14 | ||
0cf59b52 TK |
15 | struct sk_out { |
16 | unsigned int refs; /* frees sk_out when it drops to zero. | |
17 | * protected by below ->lock */ | |
18 | ||
19 | int sk; /* socket fd to talk to client */ | |
20 | struct fio_mutex lock; /* protects ref and below list */ | |
21 | struct flist_head list; /* list of pending transmit work */ | |
22 | struct fio_mutex wait; /* wake backend when items added to list */ | |
23 | struct fio_mutex xmit; /* held while sending data */ | |
24 | }; | |
25 | ||
132159a5 JA |
26 | /* |
27 | * On-wire encoding is little endian | |
28 | */ | |
29 | struct fio_net_cmd { | |
30 | uint16_t version; /* protocol version */ | |
31 | uint16_t opcode; /* command opcode */ | |
32 | uint32_t flags; /* modifier flags */ | |
af9c9fb3 | 33 | uint64_t tag; /* passed back on reply */ |
132159a5 | 34 | uint32_t pdu_len; /* length of post-cmd layload */ |
a64e88da JA |
35 | /* |
36 | * These must be immediately before the payload, anything before | |
37 | * these fields are checksummed. | |
38 | */ | |
fcee5ff6 JA |
39 | uint16_t cmd_crc16; /* cmd checksum */ |
40 | uint16_t pdu_crc16; /* payload checksum */ | |
372aecb9 | 41 | uint8_t payload[]; /* payload */ |
132159a5 JA |
42 | }; |
43 | ||
40c60516 | 44 | struct fio_net_cmd_reply { |
89c1707c | 45 | struct flist_head list; |
8b6a404c | 46 | struct timespec ts; |
89c1707c | 47 | uint64_t saved_tag; |
40c60516 | 48 | uint16_t opcode; |
89c1707c JA |
49 | }; |
50 | ||
132159a5 | 51 | enum { |
188b6016 | 52 | FIO_SERVER_VER = 65, |
132159a5 | 53 | |
b9d2f30a | 54 | FIO_SERVER_MAX_FRAGMENT_PDU = 1024, |
dfbf1f6f | 55 | FIO_SERVER_MAX_CMD_MB = 2048, |
132159a5 | 56 | |
5d7793aa JA |
57 | FIO_NET_CMD_QUIT = 1, |
58 | FIO_NET_CMD_EXIT = 2, | |
59 | FIO_NET_CMD_JOB = 3, | |
60 | FIO_NET_CMD_JOBLINE = 4, | |
61 | FIO_NET_CMD_TEXT = 5, | |
62 | FIO_NET_CMD_TS = 6, | |
63 | FIO_NET_CMD_GS = 7, | |
64 | FIO_NET_CMD_SEND_ETA = 8, | |
65 | FIO_NET_CMD_ETA = 9, | |
66 | FIO_NET_CMD_PROBE = 10, | |
67 | FIO_NET_CMD_START = 11, | |
68 | FIO_NET_CMD_STOP = 12, | |
69 | FIO_NET_CMD_DU = 13, | |
70 | FIO_NET_CMD_SERVER_START = 14, | |
71 | FIO_NET_CMD_ADD_JOB = 15, | |
b9d2f30a | 72 | FIO_NET_CMD_RUN = 16, |
1b42725f | 73 | FIO_NET_CMD_IOLOG = 17, |
f58bd2a4 | 74 | FIO_NET_CMD_UPDATE_JOB = 18, |
323255cc | 75 | FIO_NET_CMD_LOAD_FILE = 19, |
ca09be4b JA |
76 | FIO_NET_CMD_VTRIGGER = 20, |
77 | FIO_NET_CMD_SENDFILE = 21, | |
0279b880 JA |
78 | FIO_NET_CMD_JOB_OPT = 22, |
79 | FIO_NET_CMD_NR = 23, | |
794d69ca | 80 | |
5d7793aa | 81 | FIO_NET_CMD_F_MORE = 1UL << 0, |
fcee5ff6 JA |
82 | |
83 | /* crc does not include the crc fields */ | |
5d7793aa JA |
84 | FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) - |
85 | 2 * sizeof(uint16_t), | |
89c1707c | 86 | |
1b42725f JA |
87 | FIO_NET_NAME_MAX = 256, |
88 | ||
a64c13a4 | 89 | FIO_NET_CLIENT_TIMEOUT = 5000, |
3989b143 JA |
90 | |
91 | FIO_PROBE_FLAG_ZLIB = 1UL << 0, | |
132159a5 JA |
92 | }; |
93 | ||
ca09be4b JA |
94 | struct cmd_sendfile { |
95 | uint8_t path[FIO_NET_NAME_MAX]; | |
96 | }; | |
97 | ||
98 | struct cmd_sendfile_reply { | |
99 | uint32_t size; | |
100 | uint32_t error; | |
101 | uint8_t data[0]; | |
102 | }; | |
103 | ||
104 | /* | |
105 | * Client sends this to server on VTRIGGER, server sends back a full | |
106 | * all_io_list structure. | |
107 | */ | |
108 | struct cmd_vtrigger_pdu { | |
109 | uint16_t len; | |
110 | uint8_t cmd[]; | |
111 | }; | |
112 | ||
323255cc JA |
113 | struct cmd_load_file_pdu { |
114 | uint16_t name_len; | |
115 | uint16_t client_type; | |
116 | uint8_t file[]; | |
117 | }; | |
118 | ||
a64e88da JA |
119 | struct cmd_ts_pdu { |
120 | struct thread_stat ts; | |
121 | struct group_run_stats rs; | |
122 | }; | |
123 | ||
d09a64a0 JA |
124 | struct cmd_du_pdu { |
125 | struct disk_util_stat dus; | |
126 | struct disk_util_agg agg; | |
127 | }; | |
128 | ||
3989b143 JA |
129 | struct cmd_client_probe_pdu { |
130 | uint64_t flags; | |
ca09be4b | 131 | uint8_t server[128]; |
3989b143 JA |
132 | }; |
133 | ||
134 | struct cmd_probe_reply_pdu { | |
c28e8e8c | 135 | uint8_t hostname[64]; |
6eb24791 | 136 | uint8_t bigendian; |
750db473 | 137 | uint8_t fio_version[32]; |
cca84643 JA |
138 | uint8_t os; |
139 | uint8_t arch; | |
38fdef22 | 140 | uint8_t bpp; |
d31e26d0 JA |
141 | uint32_t cpus; |
142 | uint64_t flags; | |
c28e8e8c JA |
143 | }; |
144 | ||
fa2ea806 JA |
145 | struct cmd_single_line_pdu { |
146 | uint16_t len; | |
372aecb9 | 147 | uint8_t text[]; |
fa2ea806 JA |
148 | }; |
149 | ||
81179eec | 150 | struct cmd_line_pdu { |
fa2ea806 | 151 | uint16_t lines; |
46bcd498 | 152 | uint16_t client_type; |
372aecb9 | 153 | struct cmd_single_line_pdu options[]; |
81179eec JA |
154 | }; |
155 | ||
46bcd498 JA |
156 | struct cmd_job_pdu { |
157 | uint32_t buf_len; | |
158 | uint32_t client_type; | |
159 | uint8_t buf[0]; | |
160 | }; | |
161 | ||
11e950bd JA |
162 | struct cmd_start_pdu { |
163 | uint32_t jobs; | |
108fea77 | 164 | uint32_t stat_outputs; |
11e950bd JA |
165 | }; |
166 | ||
167 | struct cmd_end_pdu { | |
168 | uint32_t error; | |
122c7725 | 169 | uint32_t signal; |
11e950bd JA |
170 | }; |
171 | ||
807f9971 | 172 | struct cmd_add_job_pdu { |
2f122b13 JA |
173 | uint32_t thread_number; |
174 | uint32_t groupid; | |
dcaeb606 | 175 | struct thread_options_pack top; |
807f9971 JA |
176 | }; |
177 | ||
084d1c6f JA |
178 | struct cmd_text_pdu { |
179 | uint32_t level; | |
180 | uint32_t buf_len; | |
181 | uint64_t log_sec; | |
182 | uint64_t log_usec; | |
183 | uint8_t buf[0]; | |
184 | }; | |
185 | ||
0cba0f91 JA |
186 | enum { |
187 | XMIT_COMPRESSED = 1U, | |
188 | STORE_COMPRESSED = 2U, | |
189 | }; | |
190 | ||
1b42725f | 191 | struct cmd_iolog_pdu { |
ae588852 | 192 | uint64_t nr_samples; |
2f122b13 | 193 | uint32_t thread_number; |
1b42725f | 194 | uint32_t log_type; |
3989b143 | 195 | uint32_t compressed; |
ae588852 | 196 | uint32_t log_offset; |
868f6f03 | 197 | uint32_t log_hist_coarseness; |
1b42725f JA |
198 | uint8_t name[FIO_NET_NAME_MAX]; |
199 | struct io_sample samples[0]; | |
200 | }; | |
201 | ||
0279b880 JA |
202 | struct cmd_job_option { |
203 | uint16_t global; | |
bc0fec0e JA |
204 | uint16_t truncated; |
205 | uint32_t groupid; | |
0279b880 JA |
206 | uint8_t name[64]; |
207 | uint8_t value[128]; | |
208 | }; | |
209 | ||
402668f3 | 210 | extern int fio_start_server(char *); |
084d1c6f | 211 | extern int fio_server_text_output(int, const char *, size_t); |
40c60516 | 212 | extern int fio_net_send_cmd(int, uint16_t, const void *, off_t, uint64_t *, struct flist_head *); |
89c1707c | 213 | extern int fio_net_send_simple_cmd(int, uint16_t, uint64_t, struct flist_head *); |
bebe6398 | 214 | extern void fio_server_set_arg(const char *); |
67d2a9b8 | 215 | extern int fio_server_parse_string(const char *, char **, bool *, int *, struct in_addr *, struct in6_addr *, int *); |
3aa3ceeb | 216 | extern int fio_server_parse_host(const char *, int, struct in_addr *, struct in6_addr *); |
89c1707c | 217 | extern const char *fio_server_op(unsigned int); |
7b821684 | 218 | extern void fio_server_got_signal(int); |
a64e88da JA |
219 | |
220 | struct thread_stat; | |
221 | struct group_run_stats; | |
222 | extern void fio_server_send_ts(struct thread_stat *, struct group_run_stats *); | |
223 | extern void fio_server_send_gs(struct group_run_stats *); | |
d09a64a0 | 224 | extern void fio_server_send_du(void); |
0279b880 | 225 | extern void fio_server_send_job_options(struct flist_head *, unsigned int); |
94a6e1bb | 226 | extern int fio_server_get_verify_state(const char *, int, void **); |
132159a5 | 227 | |
54e62ad4 | 228 | extern struct fio_net_cmd *fio_net_recv_cmd(int sk, bool wait); |
132159a5 | 229 | |
1b42725f | 230 | extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *); |
2f122b13 | 231 | extern void fio_server_send_add_job(struct thread_data *); |
122c7725 | 232 | extern void fio_server_send_start(struct thread_data *); |
122c7725 | 233 | extern int fio_net_send_quit(int sk); |
807f9971 | 234 | |
3d80c735 | 235 | extern int fio_server_create_sk_key(void); |
518a1cf0 | 236 | extern void fio_server_destroy_sk_key(void); |
3d80c735 | 237 | |
009b1be4 | 238 | extern int exit_backend; |
132159a5 JA |
239 | extern int fio_net_port; |
240 | ||
50d16976 | 241 | #endif |