blob: 213987ca4511df538ca383082ed6e0b33eea34eb [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 Axboe3ec62ec2012-03-01 12:01:29 +010062
Stephen M. Camerondd366722012-02-24 08:17:30 +010063struct client_ops {
64 client_text_op_func text_op;
65 client_disk_util_op_func disk_util;
66 client_thread_status_op thread_status;
67 client_group_stats_op group_stats;
Jens Axboe0420ba62012-02-29 11:16:52 +010068 client_eta_op eta;
Stephen M. Camerondd366722012-02-24 08:17:30 +010069 client_probe_op probe;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010070 client_quit_op quit;
Jens Axboe807f9972012-03-02 10:25:24 +010071 client_add_job_op add_job;
Jens Axboeed727a42012-03-02 12:14:40 +010072 client_timed_out timed_out;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010073 int stay_connected;
Stephen M. Camerondd366722012-02-24 08:17:30 +010074};
75
76extern struct client_ops fio_client_ops;
77
Jens Axboe3e47bd22012-02-29 13:45:02 +010078struct client_eta {
79 struct jobs_eta eta;
80 unsigned int pending;
81};
82
Jens Axboea5276612012-03-04 15:15:08 +010083extern int fio_handle_client(struct fio_client *);
84extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
Jens Axboe3e47bd22012-02-29 13:45:02 +010085extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +010086
Jens Axboe3ec62ec2012-03-01 12:01:29 +010087enum {
88 Fio_client_ipv4 = 1,
89 Fio_client_ipv6,
90 Fio_client_socket,
91};
92
93extern int fio_clients_connect(void);
94extern int fio_clients_send_ini(const char *);
Jens Axboea5276612012-03-04 15:15:08 +010095extern int fio_handle_clients(struct client_ops *);
96extern int fio_client_add(struct client_ops *, const char *, void **);
97extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010098extern void fio_client_add_cmd_option(void *, const char *);
Jens Axboedf06f222012-03-02 13:32:04 +010099extern void fio_clients_terminate(void);
100
Stephen M. Camerondd366722012-02-24 08:17:30 +0100101#endif
102