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 | ||
3e47bd25 JA |
9 | #include "stat.h" |
10 | ||
dd366728 | 11 | struct fio_net_cmd; |
a5276616 | 12 | struct client_ops; |
dd366728 | 13 | |
b9d2f30a JA |
14 | enum { |
15 | Client_created = 0, | |
16 | Client_connected = 1, | |
17 | Client_started = 2, | |
18 | Client_running = 3, | |
19 | Client_stopped = 4, | |
20 | Client_exited = 5, | |
21 | }; | |
22 | ||
0f92bd20 JA |
23 | struct fio_client { |
24 | struct flist_head list; | |
25 | struct flist_head hash_list; | |
26 | struct flist_head arg_list; | |
27 | union { | |
28 | struct sockaddr_in addr; | |
29 | struct sockaddr_in6 addr6; | |
30 | struct sockaddr_un addr_un; | |
31 | }; | |
32 | char *hostname; | |
33 | int port; | |
34 | int fd; | |
5121a9aa | 35 | unsigned int refs; |
0f92bd20 JA |
36 | |
37 | char *name; | |
38 | ||
39 | int state; | |
40 | ||
41 | int skip_newline; | |
42 | int is_sock; | |
43 | int disk_stats_shown; | |
44 | unsigned int jobs; | |
45 | int error; | |
122c7725 | 46 | int signal; |
0f92bd20 JA |
47 | int ipv6; |
48 | int sent_job; | |
46bcd498 | 49 | uint32_t type; |
0f92bd20 | 50 | |
40c60516 JA |
51 | uint32_t thread_number; |
52 | uint32_t groupid; | |
53 | ||
0f92bd20 JA |
54 | struct flist_head eta_list; |
55 | struct client_eta *eta_in_flight; | |
56 | ||
57 | struct flist_head cmd_list; | |
58 | ||
59 | uint16_t argc; | |
60 | char **argv; | |
3ec62ec4 | 61 | |
a5276616 | 62 | struct client_ops *ops; |
3ec62ec4 | 63 | void *client_data; |
0f92bd20 JA |
64 | }; |
65 | ||
1b42725f | 66 | struct cmd_iolog_pdu; |
35c0ba7f JA |
67 | typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *); |
68 | typedef void (client_eta_op)(struct jobs_eta *je); | |
69 | typedef void (client_timed_out_op)(struct fio_client *); | |
70 | typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je); | |
1b42725f | 71 | typedef void (client_iolog_op)(struct fio_client *client, struct cmd_iolog_pdu *); |
3ec62ec4 | 72 | |
dd366728 | 73 | struct client_ops { |
35c0ba7f JA |
74 | client_cmd_op *text; |
75 | client_cmd_op *disk_util; | |
76 | client_cmd_op *thread_status; | |
77 | client_cmd_op *group_stats; | |
78 | client_jobs_eta_op *jobs_eta; | |
79 | client_eta_op *eta; | |
80 | client_cmd_op *probe; | |
81 | client_cmd_op *quit; | |
82 | client_cmd_op *add_job; | |
40c60516 | 83 | client_cmd_op *update_job; |
35c0ba7f JA |
84 | client_timed_out_op *timed_out; |
85 | client_cmd_op *stop; | |
86 | client_cmd_op *start; | |
87 | client_cmd_op *job_start; | |
1b42725f | 88 | client_iolog_op *iolog; |
0cf3ece0 | 89 | client_timed_out_op *removed; |
35c0ba7f | 90 | |
6433ee05 | 91 | unsigned int eta_msec; |
3ec62ec4 | 92 | int stay_connected; |
46bcd498 | 93 | uint32_t client_type; |
dd366728 SC |
94 | }; |
95 | ||
96 | extern struct client_ops fio_client_ops; | |
97 | ||
3e47bd25 JA |
98 | struct client_eta { |
99 | struct jobs_eta eta; | |
100 | unsigned int pending; | |
101 | }; | |
102 | ||
a5276616 JA |
103 | extern int fio_handle_client(struct fio_client *); |
104 | extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn); | |
3e47bd25 | 105 | extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); |
3e47bd25 | 106 | |
3ec62ec4 JA |
107 | enum { |
108 | Fio_client_ipv4 = 1, | |
109 | Fio_client_ipv6, | |
110 | Fio_client_socket, | |
111 | }; | |
112 | ||
2f99deb0 | 113 | extern int fio_client_connect(struct fio_client *); |
3ec62ec4 | 114 | extern int fio_clients_connect(void); |
b9d2f30a JA |
115 | extern int fio_start_client(struct fio_client *); |
116 | extern int fio_start_all_clients(void); | |
9988ca70 | 117 | extern int fio_client_send_ini(struct fio_client *, const char *); |
3ec62ec4 | 118 | extern int fio_clients_send_ini(const char *); |
a5276616 JA |
119 | extern int fio_handle_clients(struct client_ops *); |
120 | extern int fio_client_add(struct client_ops *, const char *, void **); | |
121 | extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int); | |
3ec62ec4 | 122 | extern void fio_client_add_cmd_option(void *, const char *); |
0cf3ece0 | 123 | extern int fio_client_terminate(struct fio_client *); |
df06f220 | 124 | extern void fio_clients_terminate(void); |
343cb4a9 JA |
125 | extern struct fio_client *fio_get_client(struct fio_client *); |
126 | extern void fio_put_client(struct fio_client *); | |
40c60516 JA |
127 | extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *); |
128 | extern int fio_client_wait_for_reply(struct fio_client *, uint64_t); | |
df06f220 | 129 | |
6433ee05 JA |
130 | #define FIO_CLIENT_DEF_ETA_MSEC 900 |
131 | ||
46bcd498 JA |
132 | enum { |
133 | FIO_CLIENT_TYPE_CLI = 1, | |
134 | FIO_CLIENT_TYPE_GUI = 2, | |
135 | }; | |
136 | ||
dd366728 SC |
137 | #endif |
138 |