blob: fd60b467461ce0a84027af880234acfc2f2a750f [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;
Jens Axboe122c7722012-03-19 09:13:15 +010046 int signal;
Jens Axboe0f92bd22012-02-29 11:44:34 +010047 int ipv6;
48 int sent_job;
Jens Axboe46bcd492012-03-14 11:31:21 +010049 uint32_t type;
Jens Axboe0f92bd22012-02-29 11:44:34 +010050
51 struct flist_head eta_list;
52 struct client_eta *eta_in_flight;
53
54 struct flist_head cmd_list;
55
56 uint16_t argc;
57 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010058
Jens Axboea5276612012-03-04 15:15:08 +010059 struct client_ops *ops;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010060 void *client_data;
Jens Axboe0f92bd22012-02-29 11:44:34 +010061};
62
Jens Axboe1b427252012-03-14 15:03:03 +010063struct cmd_iolog_pdu;
Jens Axboe35c0ba72012-03-14 10:56:40 +010064typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *);
65typedef void (client_eta_op)(struct jobs_eta *je);
66typedef void (client_timed_out_op)(struct fio_client *);
67typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je);
Jens Axboe1b427252012-03-14 15:03:03 +010068typedef void (client_iolog_op)(struct fio_client *client, struct cmd_iolog_pdu *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +010069
Stephen M. Camerondd366722012-02-24 08:17:30 +010070struct client_ops {
Jens Axboe35c0ba72012-03-14 10:56:40 +010071 client_cmd_op *text;
72 client_cmd_op *disk_util;
73 client_cmd_op *thread_status;
74 client_cmd_op *group_stats;
75 client_jobs_eta_op *jobs_eta;
76 client_eta_op *eta;
77 client_cmd_op *probe;
78 client_cmd_op *quit;
79 client_cmd_op *add_job;
80 client_timed_out_op *timed_out;
81 client_cmd_op *stop;
82 client_cmd_op *start;
83 client_cmd_op *job_start;
Jens Axboe1b427252012-03-14 15:03:03 +010084 client_iolog_op *iolog;
Jens Axboe35c0ba72012-03-14 10:56:40 +010085
Jens Axboe6433ee02012-03-09 20:10:51 +010086 unsigned int eta_msec;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010087 int stay_connected;
Jens Axboe46bcd492012-03-14 11:31:21 +010088 uint32_t client_type;
Stephen M. Camerondd366722012-02-24 08:17:30 +010089};
90
91extern struct client_ops fio_client_ops;
92
Jens Axboe3e47bd22012-02-29 13:45:02 +010093struct client_eta {
94 struct jobs_eta eta;
95 unsigned int pending;
96};
97
Jens Axboea5276612012-03-04 15:15:08 +010098extern int fio_handle_client(struct fio_client *);
99extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100100extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
Jens Axboe3e47bd22012-02-29 13:45:02 +0100101
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100102enum {
103 Fio_client_ipv4 = 1,
104 Fio_client_ipv6,
105 Fio_client_socket,
106};
107
Jens Axboe2f99deb2012-03-09 14:37:29 +0100108extern int fio_client_connect(struct fio_client *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100109extern int fio_clients_connect(void);
Jens Axboeb9d2f302012-03-08 20:36:28 +0100110extern int fio_start_client(struct fio_client *);
111extern int fio_start_all_clients(void);
Jens Axboe9988ca72012-03-09 15:14:06 +0100112extern int fio_client_send_ini(struct fio_client *, const char *);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100113extern int fio_clients_send_ini(const char *);
Jens Axboea5276612012-03-04 15:15:08 +0100114extern int fio_handle_clients(struct client_ops *);
115extern int fio_client_add(struct client_ops *, const char *, void **);
116extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int);
Jens Axboe3ec62ec2012-03-01 12:01:29 +0100117extern void fio_client_add_cmd_option(void *, const char *);
Jens Axboe2f99deb2012-03-09 14:37:29 +0100118extern void fio_client_terminate(struct fio_client *);
Jens Axboedf06f222012-03-02 13:32:04 +0100119extern void fio_clients_terminate(void);
Jens Axboe343cb4a2012-03-09 17:16:51 +0100120extern struct fio_client *fio_get_client(struct fio_client *);
121extern void fio_put_client(struct fio_client *);
Jens Axboedf06f222012-03-02 13:32:04 +0100122
Jens Axboe6433ee02012-03-09 20:10:51 +0100123#define FIO_CLIENT_DEF_ETA_MSEC 900
124
Jens Axboe46bcd492012-03-14 11:31:21 +0100125enum {
126 FIO_CLIENT_TYPE_CLI = 1,
127 FIO_CLIENT_TYPE_GUI = 2,
128};
129
Stephen M. Camerondd366722012-02-24 08:17:30 +0100130#endif
131