client.h revision 89e5fad91bc33f1687cca6b1bf5aa3084c424650
1#ifndef CLIENT_H
2#define CLIENT_H
3
4#include <sys/socket.h>
5#include <sys/un.h>
6#include <netinet/in.h>
7#include <arpa/inet.h>
8
9#include "stat.h"
10
11struct fio_net_cmd;
12struct client_ops;
13
14struct fio_client {
15	struct flist_head list;
16	struct flist_head hash_list;
17	struct flist_head arg_list;
18	union {
19		struct sockaddr_in addr;
20		struct sockaddr_in6 addr6;
21		struct sockaddr_un addr_un;
22	};
23	char *hostname;
24	int port;
25	int fd;
26
27	char *name;
28
29	int state;
30
31	int skip_newline;
32	int is_sock;
33	int disk_stats_shown;
34	unsigned int jobs;
35	int error;
36	int ipv6;
37	int sent_job;
38
39	struct flist_head eta_list;
40	struct client_eta *eta_in_flight;
41
42	struct flist_head cmd_list;
43
44	uint16_t argc;
45	char **argv;
46
47	struct client_ops *ops;
48	void *client_data;
49};
50
51typedef void (*client_text_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
52typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
53typedef void (*client_thread_status_op)(struct fio_client *client, struct fio_net_cmd *cmd);
54typedef void (*client_group_stats_op)(struct fio_client *client, struct fio_net_cmd *cmd);
55typedef void (*client_eta_op)(struct jobs_eta *je);
56typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
57typedef void (*client_thread_status_display_op)(char *status_message, double perc);
58typedef void (*client_quit_op)(struct fio_client *);
59typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *);
60typedef void (*client_timed_out)(struct fio_client *);
61
62struct client_ops {
63	client_text_op_func text_op;
64	client_disk_util_op_func disk_util;
65	client_thread_status_op thread_status;
66	client_group_stats_op group_stats;
67	client_eta_op eta;
68	client_probe_op probe;
69	client_quit_op quit;
70	client_add_job_op add_job;
71	client_timed_out timed_out;
72	int stay_connected;
73};
74
75extern struct client_ops fio_client_ops;
76
77struct client_eta {
78	struct jobs_eta eta;
79	unsigned int pending;
80};
81
82extern int fio_handle_client(struct fio_client *);
83extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
84extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
85
86enum {
87	Fio_client_ipv4 = 1,
88	Fio_client_ipv6,
89	Fio_client_socket,
90};
91
92extern int fio_clients_connect(void);
93extern int fio_clients_send_ini(const char *);
94extern int fio_handle_clients(struct client_ops *);
95extern int fio_client_add(struct client_ops *, const char *, void **);
96extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
97extern void fio_client_add_cmd_option(void *, const char *);
98extern void fio_clients_terminate(void);
99
100#endif
101
102