blob: eccac9228849b81161700ce193dbe84e31ceb1ae [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 Axboe0f92bd22012-02-29 11:44:34 +010014struct fio_client {
15 struct flist_head list;
16 struct flist_head hash_list;
17 struct flist_head arg_list;
18 union {
19 struct sockaddr_in addr;
20 struct sockaddr_in6 addr6;
21 struct sockaddr_un addr_un;
22 };
23 char *hostname;
24 int port;
25 int fd;
Jens Axboe5121a9a2012-03-05 13:32:47 +010026 unsigned int refs;
Jens Axboe0f92bd22012-02-29 11:44:34 +010027
28 char *name;
29
30 int state;
31
32 int skip_newline;
33 int is_sock;
34 int disk_stats_shown;
35 unsigned int jobs;
36 int error;
37 int ipv6;
38 int sent_job;
39
40 struct flist_head eta_list;
41 struct client_eta *eta_in_flight;
42
43 struct flist_head cmd_list;
44
45 uint16_t argc;
46 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010047
Jens Axboea5276612012-03-04 15:15:08 +010048 struct client_ops *ops;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010049 void *client_data;
Jens Axboe0f92bd22012-02-29 11:44:34 +010050};
51
Jens Axboe084d1c62012-03-03 20:28:07 +010052typedef void (*client_text_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
Stephen M. Camerondd366722012-02-24 08:17:30 +010053typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
Jens Axboe89e5fad2012-03-05 09:21:12 +010054typedef void (*client_thread_status_op)(struct fio_client *client, struct fio_net_cmd *cmd);
55typedef void (*client_group_stats_op)(struct fio_client *client, struct fio_net_cmd *cmd);
Jens Axboea5276612012-03-04 15:15:08 +010056typedef void (*client_eta_op)(struct jobs_eta *je);
Stephen M. Camerondd366722012-02-24 08:17:30 +010057typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +010058typedef void (*client_thread_status_display_op)(char *status_message, double perc);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010059typedef void (*client_quit_op)(struct fio_client *);
Jens Axboe807f9972012-03-02 10:25:24 +010060typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *);
Jens Axboeed727a42012-03-02 12:14:40 +010061typedef void (*client_timed_out)(struct fio_client *);
Jens Axboe6b79c802012-03-08 10:51:36 +010062typedef void (*client_stop_op)(struct fio_client *, struct fio_net_cmd *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010063
Stephen M. Camerondd366722012-02-24 08:17:30 +010064struct client_ops {
65 client_text_op_func text_op;
66 client_disk_util_op_func disk_util;
67 client_thread_status_op thread_status;
68 client_group_stats_op group_stats;
Jens Axboe0420ba62012-02-29 11:16:52 +010069 client_eta_op eta;
Stephen M. Camerondd366722012-02-24 08:17:30 +010070 client_probe_op probe;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010071 client_quit_op quit;
Jens Axboe807f9972012-03-02 10:25:24 +010072 client_add_job_op add_job;
Jens Axboeed727a42012-03-02 12:14:40 +010073 client_timed_out timed_out;
Jens Axboe6b79c802012-03-08 10:51:36 +010074 client_stop_op stop;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010075 int stay_connected;
Stephen M. Camerondd366722012-02-24 08:17:30 +010076};
77
78extern struct client_ops fio_client_ops;
79
Jens Axboe3e47bd22012-02-29 13:45:02 +010080struct client_eta {
81 struct jobs_eta eta;
82 unsigned int pending;
83};
84
Jens Axboea5276612012-03-04 15:15:08 +010085extern int fio_handle_client(struct fio_client *);
86extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
Jens Axboe3e47bd22012-02-29 13:45:02 +010087extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +010088
Jens Axboe3ec62ec2012-03-01 12:01:29 +010089enum {
90 Fio_client_ipv4 = 1,
91 Fio_client_ipv6,
92 Fio_client_socket,
93};
94
95extern int fio_clients_connect(void);
96extern int fio_clients_send_ini(const char *);
Jens Axboea5276612012-03-04 15:15:08 +010097extern int fio_handle_clients(struct client_ops *);
98extern int fio_client_add(struct client_ops *, const char *, void **);
99extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100100extern void fio_client_add_cmd_option(void *, const char *);
Jens Axboedf06f222012-03-02 13:32:04 +0100101extern void fio_clients_terminate(void);
102
Stephen M. Camerondd366722012-02-24 08:17:30 +0100103#endif
104