blob: 8818de2b82119e4787cbb6fd6d63b4941fb5afd9 [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;
25 int remote;
26};
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
44 int state;
45
46 int skip_newline;
47 int is_sock;
48 int disk_stats_shown;
49 unsigned int jobs;
Jens Axboe30f8e312014-10-13 11:33:27 -060050 unsigned int nr_stat;
Jens Axboe0f92bd22012-02-29 11:44:34 +010051 int error;
Jens Axboe122c7722012-03-19 09:13:15 +010052 int signal;
Jens Axboe0f92bd22012-02-29 11:44:34 +010053 int ipv6;
54 int sent_job;
Jens Axboe1e5324e2012-11-14 14:25:31 -070055 int did_stat;
Jens Axboe46bcd492012-03-14 11:31:21 +010056 uint32_t type;
Jens Axboe0f92bd22012-02-29 11:44:34 +010057
Jens Axboe40c60512012-03-27 16:03:04 +020058 uint32_t thread_number;
59 uint32_t groupid;
60
Jens Axboe0f92bd22012-02-29 11:44:34 +010061 struct flist_head eta_list;
62 struct client_eta *eta_in_flight;
63
64 struct flist_head cmd_list;
65
66 uint16_t argc;
67 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010068
Jens Axboea5276612012-03-04 15:15:08 +010069 struct client_ops *ops;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010070 void *client_data;
Jens Axboe14ea90e2012-08-26 17:33:34 +020071
Jens Axboe35899182014-10-07 20:56:28 -060072 struct client_file *files;
73 unsigned int nr_files;
Jens Axboe0f92bd22012-02-29 11:44:34 +010074};
75
Jens Axboe1b427252012-03-14 15:03:03 +010076struct cmd_iolog_pdu;
Jens Axboe35c0ba72012-03-14 10:56:40 +010077typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
78typedef void (client_eta_op)(struct jobs_eta *je);
79typedef void (client_timed_out_op)(struct fio_client *);
80typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
Jens Axboe1b427252012-03-14 15:03:03 +010081typedef void (client_iolog_op)(struct fio_client *client, struct cmd_iolog_pdu *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010082
Stephen M. Camerondd366722012-02-24 08:17:30 +010083struct client_ops {
Jens Axboe35c0ba72012-03-14 10:56:40 +010084 client_cmd_op *text;
85 client_cmd_op *disk_util;
86 client_cmd_op *thread_status;
87 client_cmd_op *group_stats;
88 client_jobs_eta_op *jobs_eta;
89 client_eta_op *eta;
90 client_cmd_op *probe;
91 client_cmd_op *quit;
92 client_cmd_op *add_job;
Jens Axboe40c60512012-03-27 16:03:04 +020093 client_cmd_op *update_job;
Jens Axboe35c0ba72012-03-14 10:56:40 +010094 client_timed_out_op *timed_out;
95 client_cmd_op *stop;
96 client_cmd_op *start;
97 client_cmd_op *job_start;
Jens Axboe1b427252012-03-14 15:03:03 +010098 client_iolog_op *iolog;
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 *);
114extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100115extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100116
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100117enum {
118 Fio_client_ipv4 = 1,
119 Fio_client_ipv6,
120 Fio_client_socket,
121};
122
Jens Axboe2f99deb2012-03-09 14:37:29 +0100123extern int fio_client_connect(struct fio_client *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100124extern int fio_clients_connect(void);
Jens Axboeb9d2f302012-03-08 20:36:28 +0100125extern int fio_start_client(struct fio_client *);
126extern int fio_start_all_clients(void);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100127extern int fio_clients_send_ini(const char *);
Jens Axboe35899182014-10-07 20:56:28 -0600128extern int fio_client_send_ini(struct fio_client *, const char *, int);
Jens Axboea5276612012-03-04 15:15:08 +0100129extern int fio_handle_clients(struct client_ops *);
130extern int fio_client_add(struct client_ops *, const char *, void **);
131extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100132extern void fio_client_add_cmd_option(void *, const char *);
Jens Axboe35899182014-10-07 20:56:28 -0600133extern int fio_client_add_ini_file(void *, const char *, int);
Jens Axboe0cf3ece2012-03-21 10:15:20 +0100134extern int fio_client_terminate(struct fio_client *);
Jens Axboedf06f222012-03-02 13:32:04 +0100135extern void fio_clients_terminate(void);
Jens Axboe343cb4a2012-03-09 17:16:51 +0100136extern struct fio_client *fio_get_client(struct fio_client *);
137extern void fio_put_client(struct fio_client *);
Jens Axboe40c60512012-03-27 16:03:04 +0200138extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *);
139extern int fio_client_wait_for_reply(struct fio_client *, uint64_t);
Jens Axboede54cfd2014-11-10 20:34:00 -0700140extern int fio_clients_send_trigger(const char *);
Jens Axboedf06f222012-03-02 13:32:04 +0100141
Jens Axboe6433ee02012-03-09 20:10:51 +0100142#define FIO_CLIENT_DEF_ETA_MSEC 900
143
Jens Axboe46bcd492012-03-14 11:31:21 +0100144enum {
145 FIO_CLIENT_TYPE_CLI = 1,
146 FIO_CLIENT_TYPE_GUI = 2,
147};
148
Stephen M. Camerondd366722012-02-24 08:17:30 +0100149#endif
150