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