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 */
18 int sk; /* socket fd to talk to client */
19 struct fio_sem lock; /* protects ref and below list */
20 struct flist_head list; /* list of pending transmit work */
21 struct fio_sem wait; /* wake backend when items added to list */
22 struct fio_sem xmit; /* held while sending data */
26 * On-wire encoding is little endian
29 uint16_t version; /* protocol version */
30 uint16_t opcode; /* command opcode */
31 uint32_t flags; /* modifier flags */
32 uint64_t tag; /* passed back on reply */
33 uint32_t pdu_len; /* length of post-cmd layload */
35 * These must be immediately before the payload, anything before
36 * these fields are checksummed.
38 uint16_t cmd_crc16; /* cmd checksum */
39 uint16_t pdu_crc16; /* payload checksum */
40 uint8_t payload[]; /* payload */
43 struct fio_net_cmd_reply {
44 struct flist_head list;
53 FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
54 FIO_SERVER_MAX_CMD_MB = 2048,
59 FIO_NET_CMD_JOBLINE = 4,
63 FIO_NET_CMD_SEND_ETA = 8,
65 FIO_NET_CMD_PROBE = 10,
66 FIO_NET_CMD_START = 11,
67 FIO_NET_CMD_STOP = 12,
69 FIO_NET_CMD_SERVER_START = 14,
70 FIO_NET_CMD_ADD_JOB = 15,
72 FIO_NET_CMD_IOLOG = 17,
73 FIO_NET_CMD_UPDATE_JOB = 18,
74 FIO_NET_CMD_LOAD_FILE = 19,
75 FIO_NET_CMD_VTRIGGER = 20,
76 FIO_NET_CMD_SENDFILE = 21,
77 FIO_NET_CMD_JOB_OPT = 22,
80 FIO_NET_CMD_F_MORE = 1UL << 0,
82 /* crc does not include the crc fields */
83 FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
86 FIO_NET_NAME_MAX = 256,
88 FIO_NET_CLIENT_TIMEOUT = 5000,
90 FIO_PROBE_FLAG_ZLIB = 1UL << 0,
94 uint8_t path[FIO_NET_NAME_MAX];
97 struct cmd_sendfile_reply {
104 * Client sends this to server on VTRIGGER, server sends back a full
105 * all_io_list structure.
107 struct cmd_vtrigger_pdu {
112 struct cmd_load_file_pdu {
114 uint16_t client_type;
119 struct thread_stat ts;
120 struct group_run_stats rs;
124 struct disk_util_stat dus;
125 struct disk_util_agg agg;
128 struct cmd_client_probe_pdu {
133 struct cmd_probe_reply_pdu {
134 uint8_t hostname[64];
136 uint8_t fio_version[32];
144 struct cmd_single_line_pdu {
149 struct cmd_line_pdu {
151 uint16_t client_type;
152 struct cmd_single_line_pdu options[];
157 uint32_t client_type;
161 struct cmd_start_pdu {
163 uint32_t stat_outputs;
171 struct cmd_add_job_pdu {
172 uint32_t thread_number;
174 struct thread_options_pack top;
177 struct cmd_text_pdu {
186 XMIT_COMPRESSED = 1U,
187 STORE_COMPRESSED = 2U,
190 struct cmd_iolog_pdu {
192 uint32_t thread_number;
197 uint32_t log_hist_coarseness;
198 uint8_t name[FIO_NET_NAME_MAX];
199 struct io_sample samples[0];
202 struct cmd_job_option {
210 extern int fio_start_server(char *);
211 extern int fio_server_text_output(int, const char *, size_t);
212 extern int fio_net_send_cmd(int, uint16_t, const void *, off_t, uint64_t *, struct flist_head *);
213 extern int fio_net_send_simple_cmd(int, uint16_t, uint64_t, struct flist_head *);
214 extern void fio_server_set_arg(const char *);
215 extern int fio_server_parse_string(const char *, char **, bool *, int *, struct in_addr *, struct in6_addr *, int *);
216 extern int fio_server_parse_host(const char *, int, struct in_addr *, struct in6_addr *);
217 extern const char *fio_server_op(unsigned int);
218 extern void fio_server_got_signal(int);
220 extern void fio_server_send_ts(struct thread_stat *, struct group_run_stats *);
221 extern void fio_server_send_gs(struct group_run_stats *);
222 extern void fio_server_send_du(void);
223 extern void fio_server_send_job_options(struct flist_head *, unsigned int);
224 extern int fio_server_get_verify_state(const char *, int, void **);
226 extern struct fio_net_cmd *fio_net_recv_cmd(int sk, bool wait);
228 extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *);
229 extern void fio_server_send_add_job(struct thread_data *);
230 extern void fio_server_send_start(struct thread_data *);
231 extern int fio_net_send_quit(int sk);
233 extern int fio_server_create_sk_key(void);
234 extern void fio_server_destroy_sk_key(void);
236 extern bool exit_backend;
237 extern int fio_net_port;