• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 struct fio_net_cmd;
12 struct client_ops;
13 
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 
23 struct client_file {
24 	char *file;
25 	bool remote;
26 };
27 
28 struct fio_client {
29 	struct flist_head list;
30 	struct flist_head hash_list;
31 	struct flist_head arg_list;
32 	union {
33 		struct sockaddr_in addr;
34 		struct sockaddr_in6 addr6;
35 		struct sockaddr_un addr_un;
36 	};
37 	char *hostname;
38 	int port;
39 	int fd;
40 	unsigned int refs;
41 
42 	char *name;
43 
44 	struct flist_head *opt_lists;
45 
46 	int state;
47 
48 	int skip_newline;
49 	int is_sock;
50 	int disk_stats_shown;
51 	unsigned int jobs;
52 	unsigned int nr_stat;
53 	int error;
54 	int signal;
55 	int ipv6;
56 	int sent_job;
57 	int did_stat;
58 	uint32_t type;
59 
60 	uint32_t thread_number;
61 	uint32_t groupid;
62 
63 	struct flist_head eta_list;
64 	struct client_eta *eta_in_flight;
65 	unsigned int eta_timeouts;
66 
67 	struct flist_head cmd_list;
68 
69 	uint16_t argc;
70 	char **argv;
71 
72 	struct client_ops *ops;
73 	void *client_data;
74 
75 	struct client_file *files;
76 	unsigned int nr_files;
77 };
78 
79 typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
80 typedef void (client_eta_op)(struct jobs_eta *je);
81 typedef void (client_timed_out_op)(struct fio_client *);
82 typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
83 
84 struct client_ops {
85 	client_cmd_op		*text;
86 	client_cmd_op		*disk_util;
87 	client_cmd_op		*thread_status;
88 	client_cmd_op		*group_stats;
89 	client_jobs_eta_op	*jobs_eta;
90 	client_eta_op		*eta;
91 	client_cmd_op		*probe;
92 	client_cmd_op		*quit;
93 	client_cmd_op		*add_job;
94 	client_cmd_op		*update_job;
95 	client_timed_out_op	*timed_out;
96 	client_cmd_op		*stop;
97 	client_cmd_op		*start;
98 	client_cmd_op		*job_start;
99 	client_timed_out_op	*removed;
100 
101 	unsigned int eta_msec;
102 	int stay_connected;
103 	uint32_t client_type;
104 };
105 
106 extern struct client_ops fio_client_ops;
107 
108 struct client_eta {
109 	unsigned int pending;
110 	struct jobs_eta eta;
111 };
112 
113 extern int fio_handle_client(struct fio_client *);
114 extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
115 
116 enum {
117 	Fio_client_ipv4 = 1,
118 	Fio_client_ipv6,
119 	Fio_client_socket,
120 };
121 
122 extern int fio_client_connect(struct fio_client *);
123 extern int fio_clients_connect(void);
124 extern int fio_start_client(struct fio_client *);
125 extern int fio_start_all_clients(void);
126 extern int fio_clients_send_ini(const char *);
127 extern int fio_client_send_ini(struct fio_client *, const char *, bool);
128 extern int fio_handle_clients(struct client_ops *);
129 extern int fio_client_add(struct client_ops *, const char *, void **);
130 extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
131 extern void fio_client_add_cmd_option(void *, const char *);
132 extern int fio_client_add_ini_file(void *, const char *, bool);
133 extern int fio_client_terminate(struct fio_client *);
134 extern struct fio_client *fio_get_client(struct fio_client *);
135 extern void fio_put_client(struct fio_client *);
136 extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *);
137 extern int fio_client_wait_for_reply(struct fio_client *, uint64_t);
138 extern int fio_clients_send_trigger(const char *);
139 
140 #define FIO_CLIENT_DEF_ETA_MSEC		900
141 
142 enum {
143 	FIO_CLIENT_TYPE_CLI		= 1,
144 	FIO_CLIENT_TYPE_GUI		= 2,
145 };
146 
147 extern int sum_stat_clients;
148 extern struct thread_stat client_ts;
149 extern struct group_run_stats client_gs;
150 
151 #endif
152 
153