blob: 9668afa8dfc8a4a5e05fd465d3cd1f142dbc5564 [file] [log] [blame]
Stephen M. Camerondd366722012-02-24 08:17:30 +01001#ifndef CLIENT_H
2#define CLIENT_H
3
Jens Axboe0f92bd22012-02-29 11:44:34 +01004#include <sys/socket.h>
5#include <sys/un.h>
6#include <netinet/in.h>
7#include <arpa/inet.h>
8
Jens Axboe3e47bd22012-02-29 13:45:02 +01009#include "stat.h"
10
Stephen M. Camerondd366722012-02-24 08:17:30 +010011struct fio_net_cmd;
Jens Axboea5276612012-03-04 15:15:08 +010012struct client_ops;
Stephen M. Camerondd366722012-02-24 08:17:30 +010013
Jens Axboeb9d2f302012-03-08 20:36:28 +010014enum {
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
Jens Axboe0f92bd22012-02-29 11:44:34 +010023struct 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;
Jens Axboe5121a9a2012-03-05 13:32:47 +010035 unsigned int refs;
Jens Axboe0f92bd22012-02-29 11:44:34 +010036
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;
46 int ipv6;
47 int sent_job;
48
49 struct flist_head eta_list;
50 struct client_eta *eta_in_flight;
51
52 struct flist_head cmd_list;
53
54 uint16_t argc;
55 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010056
Jens Axboea5276612012-03-04 15:15:08 +010057 struct client_ops *ops;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010058 void *client_data;
Jens Axboe0f92bd22012-02-29 11:44:34 +010059};
60
Jens Axboe084d1c62012-03-03 20:28:07 +010061typedef void (*client_text_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
Stephen M. Camerondd366722012-02-24 08:17:30 +010062typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
Jens Axboe89e5fad2012-03-05 09:21:12 +010063typedef void (*client_thread_status_op)(struct fio_client *client, struct fio_net_cmd *cmd);
64typedef void (*client_group_stats_op)(struct fio_client *client, struct fio_net_cmd *cmd);
Jens Axboea5276612012-03-04 15:15:08 +010065typedef void (*client_eta_op)(struct jobs_eta *je);
Jens Axboe2f99deb2012-03-09 14:37:29 +010066typedef void (*client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
Stephen M. Camerondd366722012-02-24 08:17:30 +010067typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +010068typedef void (*client_thread_status_display_op)(char *status_message, double perc);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010069typedef void (*client_quit_op)(struct fio_client *);
Jens Axboe807f9972012-03-02 10:25:24 +010070typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *);
Jens Axboeed727a42012-03-02 12:14:40 +010071typedef void (*client_timed_out)(struct fio_client *);
Jens Axboe6b79c802012-03-08 10:51:36 +010072typedef void (*client_stop_op)(struct fio_client *, struct fio_net_cmd *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010073
Stephen M. Camerondd366722012-02-24 08:17:30 +010074struct client_ops {
75 client_text_op_func text_op;
76 client_disk_util_op_func disk_util;
77 client_thread_status_op thread_status;
78 client_group_stats_op group_stats;
Jens Axboe2f99deb2012-03-09 14:37:29 +010079 client_jobs_eta_op jobs_eta;
Jens Axboe0420ba62012-02-29 11:16:52 +010080 client_eta_op eta;
Stephen M. Camerondd366722012-02-24 08:17:30 +010081 client_probe_op probe;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010082 client_quit_op quit;
Jens Axboe807f9972012-03-02 10:25:24 +010083 client_add_job_op add_job;
Jens Axboeed727a42012-03-02 12:14:40 +010084 client_timed_out timed_out;
Jens Axboe6b79c802012-03-08 10:51:36 +010085 client_stop_op stop;
Jens Axboe6433ee02012-03-09 20:10:51 +010086 unsigned int eta_msec;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010087 int stay_connected;
Stephen M. Camerondd366722012-02-24 08:17:30 +010088};
89
90extern struct client_ops fio_client_ops;
91
Jens Axboe3e47bd22012-02-29 13:45:02 +010092struct client_eta {
93 struct jobs_eta eta;
94 unsigned int pending;
95};
96
Jens Axboea5276612012-03-04 15:15:08 +010097extern int fio_handle_client(struct fio_client *);
98extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
Jens Axboe3e47bd22012-02-29 13:45:02 +010099extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100100
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100101enum {
102 Fio_client_ipv4 = 1,
103 Fio_client_ipv6,
104 Fio_client_socket,
105};
106
Jens Axboe2f99deb2012-03-09 14:37:29 +0100107extern int fio_client_connect(struct fio_client *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100108extern int fio_clients_connect(void);
Jens Axboeb9d2f302012-03-08 20:36:28 +0100109extern int fio_start_client(struct fio_client *);
110extern int fio_start_all_clients(void);
Jens Axboe9988ca72012-03-09 15:14:06 +0100111extern int fio_client_send_ini(struct fio_client *, const char *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100112extern int fio_clients_send_ini(const char *);
Jens Axboea5276612012-03-04 15:15:08 +0100113extern int fio_handle_clients(struct client_ops *);
114extern int fio_client_add(struct client_ops *, const char *, void **);
115extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100116extern void fio_client_add_cmd_option(void *, const char *);
Jens Axboe2f99deb2012-03-09 14:37:29 +0100117extern void fio_client_terminate(struct fio_client *);
Jens Axboedf06f222012-03-02 13:32:04 +0100118extern void fio_clients_terminate(void);
Jens Axboe343cb4a2012-03-09 17:16:51 +0100119extern struct fio_client *fio_get_client(struct fio_client *);
120extern void fio_put_client(struct fio_client *);
Jens Axboedf06f222012-03-02 13:32:04 +0100121
Jens Axboe6433ee02012-03-09 20:10:51 +0100122#define FIO_CLIENT_DEF_ETA_MSEC 900
123
Stephen M. Camerondd366722012-02-24 08:17:30 +0100124#endif
125