Commit | Line | Data |
---|---|---|
dd366728 SC |
1 | #ifndef CLIENT_H |
2 | #define CLIENT_H | |
3 | ||
0f92bd20 JA |
4 | #include <sys/socket.h> |
5 | #include <sys/un.h> | |
6 | #include <netinet/in.h> | |
7 | #include <arpa/inet.h> | |
8 | ||
67d2a9b8 | 9 | #include "lib/types.h" |
3e47bd25 JA |
10 | #include "stat.h" |
11 | ||
dd366728 | 12 | struct fio_net_cmd; |
a5276616 | 13 | struct client_ops; |
dd366728 | 14 | |
b9d2f30a JA |
15 | enum { |
16 | Client_created = 0, | |
17 | Client_connected = 1, | |
18 | Client_started = 2, | |
19 | Client_running = 3, | |
20 | Client_stopped = 4, | |
21 | Client_exited = 5, | |
22 | }; | |
23 | ||
323255cc JA |
24 | struct client_file { |
25 | char *file; | |
bb781643 | 26 | bool remote; |
323255cc JA |
27 | }; |
28 | ||
0f92bd20 JA |
29 | struct fio_client { |
30 | struct flist_head list; | |
31 | struct flist_head hash_list; | |
32 | struct flist_head arg_list; | |
33 | union { | |
34 | struct sockaddr_in addr; | |
35 | struct sockaddr_in6 addr6; | |
36 | struct sockaddr_un addr_un; | |
37 | }; | |
38 | char *hostname; | |
39 | int port; | |
40 | int fd; | |
5121a9aa | 41 | unsigned int refs; |
47714d68 | 42 | unsigned int last_cmd; |
0f92bd20 JA |
43 | |
44 | char *name; | |
45 | ||
0279b880 JA |
46 | struct flist_head *opt_lists; |
47 | ||
0f92bd20 JA |
48 | int state; |
49 | ||
67d2a9b8 JA |
50 | bool skip_newline; |
51 | bool is_sock; | |
52 | bool disk_stats_shown; | |
0f92bd20 | 53 | unsigned int jobs; |
a89d5319 | 54 | unsigned int nr_stat; |
0f92bd20 | 55 | int error; |
122c7725 | 56 | int signal; |
0f92bd20 | 57 | int ipv6; |
67d2a9b8 JA |
58 | bool sent_job; |
59 | bool did_stat; | |
46bcd498 | 60 | uint32_t type; |
0f92bd20 | 61 | |
40c60516 JA |
62 | uint32_t thread_number; |
63 | uint32_t groupid; | |
64 | ||
0f92bd20 JA |
65 | struct flist_head eta_list; |
66 | struct client_eta *eta_in_flight; | |
a64c13a4 | 67 | unsigned int eta_timeouts; |
0f92bd20 JA |
68 | |
69 | struct flist_head cmd_list; | |
70 | ||
71 | uint16_t argc; | |
72 | char **argv; | |
3ec62ec4 | 73 | |
a5276616 | 74 | struct client_ops *ops; |
3ec62ec4 | 75 | void *client_data; |
14ea90ed | 76 | |
323255cc JA |
77 | struct client_file *files; |
78 | unsigned int nr_files; | |
0f92bd20 JA |
79 | }; |
80 | ||
35c0ba7f JA |
81 | typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *); |
82 | typedef void (client_eta_op)(struct jobs_eta *je); | |
83 | typedef void (client_timed_out_op)(struct fio_client *); | |
84 | typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je); | |
3ec62ec4 | 85 | |
dd366728 | 86 | struct client_ops { |
35c0ba7f JA |
87 | client_cmd_op *text; |
88 | client_cmd_op *disk_util; | |
89 | client_cmd_op *thread_status; | |
90 | client_cmd_op *group_stats; | |
91 | client_jobs_eta_op *jobs_eta; | |
92 | client_eta_op *eta; | |
93 | client_cmd_op *probe; | |
94 | client_cmd_op *quit; | |
95 | client_cmd_op *add_job; | |
40c60516 | 96 | client_cmd_op *update_job; |
35c0ba7f JA |
97 | client_timed_out_op *timed_out; |
98 | client_cmd_op *stop; | |
99 | client_cmd_op *start; | |
100 | client_cmd_op *job_start; | |
0cf3ece0 | 101 | client_timed_out_op *removed; |
35c0ba7f | 102 | |
6433ee05 | 103 | unsigned int eta_msec; |
3ec62ec4 | 104 | int stay_connected; |
46bcd498 | 105 | uint32_t client_type; |
dd366728 SC |
106 | }; |
107 | ||
108 | extern struct client_ops fio_client_ops; | |
109 | ||
3e47bd25 | 110 | struct client_eta { |
3e47bd25 | 111 | unsigned int pending; |
166fb520 | 112 | struct jobs_eta eta; |
3e47bd25 JA |
113 | }; |
114 | ||
a5276616 | 115 | extern int fio_handle_client(struct fio_client *); |
3e47bd25 | 116 | extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); |
3e47bd25 | 117 | |
3ec62ec4 JA |
118 | enum { |
119 | Fio_client_ipv4 = 1, | |
120 | Fio_client_ipv6, | |
121 | Fio_client_socket, | |
122 | }; | |
123 | ||
2f99deb0 | 124 | extern int fio_client_connect(struct fio_client *); |
3ec62ec4 | 125 | extern int fio_clients_connect(void); |
b9d2f30a JA |
126 | extern int fio_start_client(struct fio_client *); |
127 | extern int fio_start_all_clients(void); | |
3ec62ec4 | 128 | extern int fio_clients_send_ini(const char *); |
bb781643 | 129 | extern int fio_client_send_ini(struct fio_client *, const char *, bool); |
a5276616 JA |
130 | extern int fio_handle_clients(struct client_ops *); |
131 | extern int fio_client_add(struct client_ops *, const char *, void **); | |
132 | extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int); | |
3ec62ec4 | 133 | extern void fio_client_add_cmd_option(void *, const char *); |
bb781643 | 134 | extern int fio_client_add_ini_file(void *, const char *, bool); |
0cf3ece0 | 135 | extern int fio_client_terminate(struct fio_client *); |
343cb4a9 JA |
136 | extern struct fio_client *fio_get_client(struct fio_client *); |
137 | extern void fio_put_client(struct fio_client *); | |
40c60516 JA |
138 | extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *); |
139 | extern int fio_client_wait_for_reply(struct fio_client *, uint64_t); | |
ca09be4b | 140 | extern int fio_clients_send_trigger(const char *); |
df06f220 | 141 | |
6433ee05 JA |
142 | #define FIO_CLIENT_DEF_ETA_MSEC 900 |
143 | ||
46bcd498 JA |
144 | enum { |
145 | FIO_CLIENT_TYPE_CLI = 1, | |
146 | FIO_CLIENT_TYPE_GUI = 2, | |
147 | }; | |
148 | ||
201ab643 JA |
149 | extern int sum_stat_clients; |
150 | extern struct thread_stat client_ts; | |
151 | extern struct group_run_stats client_gs; | |
152 | ||
dd366728 SC |
153 | #endif |
154 |