• 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 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;
35 	unsigned int refs;
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 	unsigned int nr_stat;
46 	int error;
47 	int signal;
48 	int ipv6;
49 	int sent_job;
50 	int did_stat;
51 	uint32_t type;
52 
53 	uint32_t thread_number;
54 	uint32_t groupid;
55 
56 	struct flist_head eta_list;
57 	struct client_eta *eta_in_flight;
58 
59 	struct flist_head cmd_list;
60 
61 	uint16_t argc;
62 	char **argv;
63 
64 	struct client_ops *ops;
65 	void *client_data;
66 
67 	char **ini_file;
68 	unsigned int nr_ini_file;
69 };
70 
71 struct cmd_iolog_pdu;
72 typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
73 typedef void (client_eta_op)(struct jobs_eta *je);
74 typedef void (client_timed_out_op)(struct fio_client *);
75 typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
76 typedef void (client_iolog_op)(struct fio_client *client, struct cmd_iolog_pdu *);
77 
78 struct client_ops {
79 	client_cmd_op		*text;
80 	client_cmd_op		*disk_util;
81 	client_cmd_op		*thread_status;
82 	client_cmd_op		*group_stats;
83 	client_jobs_eta_op	*jobs_eta;
84 	client_eta_op		*eta;
85 	client_cmd_op		*probe;
86 	client_cmd_op		*quit;
87 	client_cmd_op		*add_job;
88 	client_cmd_op		*update_job;
89 	client_timed_out_op	*timed_out;
90 	client_cmd_op		*stop;
91 	client_cmd_op		*start;
92 	client_cmd_op		*job_start;
93 	client_iolog_op		*iolog;
94 	client_timed_out_op	*removed;
95 
96 	unsigned int eta_msec;
97 	int stay_connected;
98 	uint32_t client_type;
99 };
100 
101 extern struct client_ops fio_client_ops;
102 
103 struct client_eta {
104 	unsigned int pending;
105 	struct jobs_eta eta;
106 };
107 
108 extern int fio_handle_client(struct fio_client *);
109 extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
110 extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
111 
112 enum {
113 	Fio_client_ipv4 = 1,
114 	Fio_client_ipv6,
115 	Fio_client_socket,
116 };
117 
118 extern int fio_client_connect(struct fio_client *);
119 extern int fio_clients_connect(void);
120 extern int fio_start_client(struct fio_client *);
121 extern int fio_start_all_clients(void);
122 extern int fio_client_send_ini(struct fio_client *, const char *);
123 extern int fio_clients_send_ini(const char *);
124 extern int fio_handle_clients(struct client_ops *);
125 extern int fio_client_add(struct client_ops *, const char *, void **);
126 extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
127 extern void fio_client_add_cmd_option(void *, const char *);
128 extern void fio_client_add_ini_file(void *, const char *);
129 extern int fio_client_terminate(struct fio_client *);
130 extern void fio_clients_terminate(void);
131 extern struct fio_client *fio_get_client(struct fio_client *);
132 extern void fio_put_client(struct fio_client *);
133 extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *);
134 extern int fio_client_wait_for_reply(struct fio_client *, uint64_t);
135 
136 #define FIO_CLIENT_DEF_ETA_MSEC		900
137 
138 enum {
139 	FIO_CLIENT_TYPE_CLI		= 1,
140 	FIO_CLIENT_TYPE_GUI		= 2,
141 };
142 
143 #endif
144 
145