9 * On-wire encoding is little endian
12 uint16_t version; /* protocol version */
13 uint16_t opcode; /* command opcode */
14 uint32_t flags; /* modifier flags */
15 uint64_t serial; /* serial number */
16 uint32_t pdu_len; /* length of post-cmd layload */
17 uint16_t cmd_crc16; /* cmd checksum */
18 uint16_t pdu_crc16; /* payload checksum */
19 uint8_t payload[0]; /* payload */
26 FIO_SERVER_MAX_PDU = 4096,
30 FIO_NET_CMD_JOB_END = 3,
35 /* crc does not include the crc fields */
36 FIO_NET_CMD_CRC_SZ = sizeof(struct fio_net_cmd) -
40 extern int fio_server(void);
41 extern int fio_server_text_output(const char *, unsigned int len);
42 extern int fio_server_log(const char *format, ...);
44 extern int fio_client_connect(const char *);
45 extern int fio_client_send_ini(const char *);
46 extern int fio_handle_clients(void);
48 extern int fio_recv_data(int sk, void *p, unsigned int len);
49 extern int fio_send_data(int sk, const void *p, unsigned int len);
50 extern void fio_net_cmd_crc(struct fio_net_cmd *);
51 extern struct fio_net_cmd *fio_net_cmd_read(int sk);
53 extern int exit_backend;
54 extern int fio_net_port;
56 #if __BYTE_ORDER == __LITTLE_ENDIAN
57 #define le16_to_cpu(x) (x)
58 #define le32_to_cpu(x) (x)
59 #define le64_to_cpu(x) (x)
60 #define cpu_to_le16(x) (x)
61 #define cpu_to_le32(x) (x)
62 #define cpu_to_le64(x) (x)
63 #elif __BYTE_ORDER == __BIG_ENDIAN
64 #define le16_to_cpu(x) __bswap_16(x)
65 #define le32_to_cpu(x) __bswap_32(x)
66 #define le64_to_cpu(x) __bswap_64(x)
67 #define cpu_to_le16(x) __bswap_16(x)
68 #define cpu_to_le32(x) __bswap_32(x)
69 #define cpu_to_le64(x) __bswap_64(x)
71 #error "Endianness not detected"
74 static inline void fio_init_net_cmd(struct fio_net_cmd *cmd, uint16_t opcode,
75 const void *pdu, uint32_t pdu_len)
77 memset(cmd, 0, sizeof(*cmd));
79 cmd->version = cpu_to_le16(FIO_SERVER_VER1);
80 cmd->opcode = cpu_to_le16(opcode);
83 cmd->pdu_len = cpu_to_le32(pdu_len);
84 memcpy(&cmd->payload, pdu, pdu_len);