blob: fc9c19693a9ff0c60bfcee6429755344b72cdfdf [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 Axboe35899182014-10-07 20:56:28 -060023struct client_file {
24 char *file;
Elliott Hugheseda3a602017-05-19 18:53:02 -070025 bool remote;
Jens Axboe35899182014-10-07 20:56:28 -060026};
27
Jens Axboe0f92bd22012-02-29 11:44:34 +010028struct 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;
Jens Axboe5121a9a2012-03-05 13:32:47 +010040 unsigned int refs;
Jens Axboe0f92bd22012-02-29 11:44:34 +010041
42 char *name;
43
Elliott Hugheseda3a602017-05-19 18:53:02 -070044 struct flist_head *opt_lists;
45
Jens Axboe0f92bd22012-02-29 11:44:34 +010046 int state;
47
48 int skip_newline;
49 int is_sock;
50 int disk_stats_shown;
51 unsigned int jobs;
Jens Axboe30f8e312014-10-13 11:33:27 -060052 unsigned int nr_stat;
Jens Axboe0f92bd22012-02-29 11:44:34 +010053 int error;
Jens Axboe122c7722012-03-19 09:13:15 +010054 int signal;
Jens Axboe0f92bd22012-02-29 11:44:34 +010055 int ipv6;
56 int sent_job;
Jens Axboe1e5324e2012-11-14 14:25:31 -070057 int did_stat;
Jens Axboe46bcd492012-03-14 11:31:21 +010058 uint32_t type;
Jens Axboe0f92bd22012-02-29 11:44:34 +010059
Jens Axboe40c60512012-03-27 16:03:04 +020060 uint32_t thread_number;
61 uint32_t groupid;
62
Jens Axboe0f92bd22012-02-29 11:44:34 +010063 struct flist_head eta_list;
64 struct client_eta *eta_in_flight;
Elliott Hugheseda3a602017-05-19 18:53:02 -070065 unsigned int eta_timeouts;
Jens Axboe0f92bd22012-02-29 11:44:34 +010066
67 struct flist_head cmd_list;
68
69 uint16_t argc;
70 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010071
Jens Axboea5276612012-03-04 15:15:08 +010072 struct client_ops *ops;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010073 void *client_data;
Jens Axboe14ea90e2012-08-26 17:33:34 +020074
Jens Axboe35899182014-10-07 20:56:28 -060075 struct client_file *files;
76 unsigned int nr_files;
Jens Axboe0f92bd22012-02-29 11:44:34 +010077};
78
Jens Axboe35c0ba72012-03-14 10:56:40 +010079typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
80typedef void (client_eta_op)(struct jobs_eta *je);
81typedef void (client_timed_out_op)(struct fio_client *);
82typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010083
Stephen M. Camerondd366722012-02-24 08:17:30 +010084struct client_ops {
Jens Axboe35c0ba72012-03-14 10:56:40 +010085 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;
Jens Axboe40c60512012-03-27 16:03:04 +020094 client_cmd_op *update_job;
Jens Axboe35c0ba72012-03-14 10:56:40 +010095 client_timed_out_op *timed_out;
96 client_cmd_op *stop;
97 client_cmd_op *start;
98 client_cmd_op *job_start;
Jens Axboe0cf3ece2012-03-21 10:15:20 +010099 client_timed_out_op *removed;
Jens Axboe35c0ba72012-03-14 10:56:40 +0100100
Jens Axboe6433ee02012-03-09 20:10:51 +0100101 unsigned int eta_msec;
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100102 int stay_connected;
Jens Axboe46bcd492012-03-14 11:31:21 +0100103 uint32_t client_type;
Stephen M. Camerondd366722012-02-24 08:17:30 +0100104};
105
106extern struct client_ops fio_client_ops;
107
Jens Axboe3e47bd22012-02-29 13:45:02 +0100108struct client_eta {
Jens Axboe3e47bd22012-02-29 13:45:02 +0100109 unsigned int pending;
Jens Axboe166fb522013-04-11 13:45:51 +0200110 struct jobs_eta eta;
Jens Axboe3e47bd22012-02-29 13:45:02 +0100111};
112
Jens Axboea5276612012-03-04 15:15:08 +0100113extern int fio_handle_client(struct fio_client *);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100114extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100115
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100116enum {
117 Fio_client_ipv4 = 1,
118 Fio_client_ipv6,
119 Fio_client_socket,
120};
121
Jens Axboe2f99deb2012-03-09 14:37:29 +0100122extern int fio_client_connect(struct fio_client *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100123extern int fio_clients_connect(void);
Jens Axboeb9d2f302012-03-08 20:36:28 +0100124extern int fio_start_client(struct fio_client *);
125extern int fio_start_all_clients(void);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100126extern int fio_clients_send_ini(const char *);
Elliott Hugheseda3a602017-05-19 18:53:02 -0700127extern int fio_client_send_ini(struct fio_client *, const char *, bool);
Jens Axboea5276612012-03-04 15:15:08 +0100128extern int fio_handle_clients(struct client_ops *);
129extern int fio_client_add(struct client_ops *, const char *, void **);
130extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100131extern void fio_client_add_cmd_option(void *, const char *);
Elliott Hugheseda3a602017-05-19 18:53:02 -0700132extern int fio_client_add_ini_file(void *, const char *, bool);
Jens Axboe0cf3ece2012-03-21 10:15:20 +0100133extern int fio_client_terminate(struct fio_client *);
Jens Axboe343cb4a2012-03-09 17:16:51 +0100134extern struct fio_client *fio_get_client(struct fio_client *);
135extern void fio_put_client(struct fio_client *);
Jens Axboe40c60512012-03-27 16:03:04 +0200136extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *);
137extern int fio_client_wait_for_reply(struct fio_client *, uint64_t);
Jens Axboede54cfd2014-11-10 20:34:00 -0700138extern int fio_clients_send_trigger(const char *);
Jens Axboedf06f222012-03-02 13:32:04 +0100139
Jens Axboe6433ee02012-03-09 20:10:51 +0100140#define FIO_CLIENT_DEF_ETA_MSEC 900
141
Jens Axboe46bcd492012-03-14 11:31:21 +0100142enum {
143 FIO_CLIENT_TYPE_CLI = 1,
144 FIO_CLIENT_TYPE_GUI = 2,
145};
146
Elliott Hugheseda3a602017-05-19 18:53:02 -0700147extern int sum_stat_clients;
148extern struct thread_stat client_ts;
149extern struct group_run_stats client_gs;
150
Stephen M. Camerondd366722012-02-24 08:17:30 +0100151#endif
152