7 #include <netinet/in.h>
12 #define FIO_NET_PORT 8765
15 unsigned int refs; /* frees sk_out when it drops to zero.
16 * protected by below ->lock */
19 HANDLE hProcess; /* process handle of handle_connection_process*/
21 int sk; /* socket fd to talk to client */
22 struct fio_sem lock; /* protects ref and below list */
23 struct flist_head list; /* list of pending transmit work */
24 struct fio_sem wait; /* wake backend when items added to list */
25 struct fio_sem xmit; /* held while sending data */
29 * On-wire encoding is little endian
32 uint16_t version; /* protocol version */
33 uint16_t opcode; /* command opcode */
34 uint32_t flags; /* modifier flags */
35 uint64_t tag; /* passed back on reply */
36 uint32_t pdu_len; /* length of post-cmd layload */
38 * These must be immediately before the payload, anything before
39 * these fields are checksummed.
41 uint16_t cmd_crc16; /* cmd checksum */
42 uint16_t pdu_crc16; /* payload checksum */
43 uint8_t payload[]; /* payload */
46 struct fio_net_cmd_reply {
47 struct flist_head list;
56 FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
57 FIO_SERVER_MAX_CMD_MB = 2048,
62 FIO_NET_CMD_JOBLINE = 4,
66 FIO_NET_CMD_SEND_ETA = 8,
68 FIO_NET_CMD_PROBE = 10,
69 FIO_NET_CMD_START = 11,
70 FIO_NET_CMD_STOP = 12,
72 FIO_NET_CMD_SERVER_START = 14,
73 FIO_NET_CMD_ADD_JOB = 15,
75 FIO_NET_CMD_IOLOG = 17,
76 FIO_NET_CMD_UPDATE_JOB = 18,
77 FIO_NET_CMD_LOAD_FILE = 19,
78 FIO_NET_CMD_VTRIGGER = 20,
79 FIO_NET_CMD_SENDFILE = 21,
80 FIO_NET_CMD_JOB_OPT = 22,
83 FIO_NET_CMD_F_MORE = 1UL << 0,
85 /* crc does not include the crc fields */
86 FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
89 FIO_NET_NAME_MAX = 256,
91 FIO_NET_CLIENT_TIMEOUT = 5000,
93 FIO_PROBE_FLAG_ZLIB = 1UL << 0,
97 uint8_t path[FIO_NET_NAME_MAX];
100 struct cmd_sendfile_reply {
107 * Client sends this to server on VTRIGGER, server sends back a full
108 * all_io_list structure.
110 struct cmd_vtrigger_pdu {
115 struct cmd_load_file_pdu {
117 uint16_t client_type;
122 struct thread_stat ts;
123 struct group_run_stats rs;
127 struct disk_util_stat dus;
128 struct disk_util_agg agg;
131 struct cmd_client_probe_pdu {
136 struct cmd_probe_reply_pdu {
137 uint8_t hostname[64];
139 uint8_t fio_version[32];
147 struct cmd_single_line_pdu {
152 struct cmd_line_pdu {
154 uint16_t client_type;
155 struct cmd_single_line_pdu options[];
160 uint32_t client_type;
164 struct cmd_start_pdu {
166 uint32_t stat_outputs;
174 struct cmd_add_job_pdu {
175 uint32_t thread_number;
177 struct thread_options_pack top;
180 struct cmd_text_pdu {
189 XMIT_COMPRESSED = 1U,
190 STORE_COMPRESSED = 2U,
193 struct cmd_iolog_pdu {
195 uint32_t thread_number;
200 uint32_t log_hist_coarseness;
201 uint8_t name[FIO_NET_NAME_MAX];
202 struct io_sample samples[0];
205 struct cmd_job_option {
213 extern int fio_start_server(char *);
214 extern int fio_server_text_output(int, const char *, size_t);
215 extern int fio_net_send_cmd(int, uint16_t, const void *, off_t, uint64_t *, struct flist_head *);
216 extern int fio_net_send_simple_cmd(int, uint16_t, uint64_t, struct flist_head *);
217 extern void fio_server_set_arg(const char *);
218 extern void fio_server_internal_set(const char *);
219 extern int fio_server_parse_string(const char *, char **, bool *, int *, struct in_addr *, struct in6_addr *, int *);
220 extern int fio_server_parse_host(const char *, int, struct in_addr *, struct in6_addr *);
221 extern const char *fio_server_op(unsigned int);
222 extern void fio_server_got_signal(int);
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 *);
226 extern void fio_server_send_du(void);
227 extern void fio_server_send_job_options(struct flist_head *, unsigned int);
228 extern int fio_server_get_verify_state(const char *, int, void **);
229 extern bool fio_server_poll_fd(int fd, short events, int timeout);
231 extern struct fio_net_cmd *fio_net_recv_cmd(int sk, bool wait);
233 extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *);
234 extern void fio_server_send_add_job(struct thread_data *);
235 extern void fio_server_send_start(struct thread_data *);
236 extern int fio_net_send_quit(int sk);
238 extern int fio_server_create_sk_key(void);
239 extern void fio_server_destroy_sk_key(void);
241 extern bool exit_backend;
242 extern int fio_net_port;