7 #include <netinet/in.h>
13 #define FIO_NET_PORT 8765
16 unsigned int refs; /* frees sk_out when it drops to zero.
17 * protected by below ->lock */
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 */
27 * On-wire encoding is little endian
30 uint16_t version; /* protocol version */
31 uint16_t opcode; /* command opcode */
32 uint32_t flags; /* modifier flags */
33 uint64_t tag; /* passed back on reply */
34 uint32_t pdu_len; /* length of post-cmd layload */
36 * These must be immediately before the payload, anything before
37 * these fields are checksummed.
39 uint16_t cmd_crc16; /* cmd checksum */
40 uint16_t pdu_crc16; /* payload checksum */
41 uint8_t payload[]; /* payload */
44 struct fio_net_cmd_reply {
45 struct flist_head list;
54 FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
55 FIO_SERVER_MAX_CMD_MB = 2048,
60 FIO_NET_CMD_JOBLINE = 4,
64 FIO_NET_CMD_SEND_ETA = 8,
66 FIO_NET_CMD_PROBE = 10,
67 FIO_NET_CMD_START = 11,
68 FIO_NET_CMD_STOP = 12,
70 FIO_NET_CMD_SERVER_START = 14,
71 FIO_NET_CMD_ADD_JOB = 15,
73 FIO_NET_CMD_IOLOG = 17,
74 FIO_NET_CMD_UPDATE_JOB = 18,
75 FIO_NET_CMD_LOAD_FILE = 19,
76 FIO_NET_CMD_VTRIGGER = 20,
77 FIO_NET_CMD_SENDFILE = 21,
78 FIO_NET_CMD_JOB_OPT = 22,
81 FIO_NET_CMD_F_MORE = 1UL << 0,
83 /* crc does not include the crc fields */
84 FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
87 FIO_NET_NAME_MAX = 256,
89 FIO_NET_CLIENT_TIMEOUT = 5000,
91 FIO_PROBE_FLAG_ZLIB = 1UL << 0,
95 uint8_t path[FIO_NET_NAME_MAX];
98 struct cmd_sendfile_reply {
105 * Client sends this to server on VTRIGGER, server sends back a full
106 * all_io_list structure.
108 struct cmd_vtrigger_pdu {
113 struct cmd_load_file_pdu {
115 uint16_t client_type;
120 struct thread_stat ts;
121 struct group_run_stats rs;
125 struct disk_util_stat dus;
126 struct disk_util_agg agg;
129 struct cmd_client_probe_pdu {
134 struct cmd_probe_reply_pdu {
135 uint8_t hostname[64];
137 uint8_t fio_version[32];
145 struct cmd_single_line_pdu {
150 struct cmd_line_pdu {
152 uint16_t client_type;
153 struct cmd_single_line_pdu options[];
158 uint32_t client_type;
162 struct cmd_start_pdu {
164 uint32_t stat_outputs;
172 struct cmd_add_job_pdu {
173 uint32_t thread_number;
175 struct thread_options_pack top;
178 struct cmd_text_pdu {
187 XMIT_COMPRESSED = 1U,
188 STORE_COMPRESSED = 2U,
191 struct cmd_iolog_pdu {
193 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 **, int *, 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);
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 *);
224 extern void fio_server_send_du(void);
225 extern void fio_server_send_job_options(struct flist_head *, unsigned int);
226 extern int fio_server_get_verify_state(const char *, int, void **);
228 extern struct fio_net_cmd *fio_net_recv_cmd(int sk, bool wait);
230 extern int fio_send_iolog(struct thread_data *, struct io_log *, const char *);
231 extern void fio_server_send_add_job(struct thread_data *);
232 extern void fio_server_send_start(struct thread_data *);
233 extern int fio_net_send_quit(int sk);
235 extern int fio_server_create_sk_key(void);
236 extern void fio_server_destroy_sk_key(void);
238 extern int exit_backend;
239 extern int fio_net_port;