blob: 0071484121c38136d457f367dc907cedd49fb171 [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;
12
Jens Axboe0f92bd22012-02-29 11:44:34 +010013struct fio_client {
14 struct flist_head list;
15 struct flist_head hash_list;
16 struct flist_head arg_list;
17 union {
18 struct sockaddr_in addr;
19 struct sockaddr_in6 addr6;
20 struct sockaddr_un addr_un;
21 };
22 char *hostname;
23 int port;
24 int fd;
25
26 char *name;
27
28 int state;
29
30 int skip_newline;
31 int is_sock;
32 int disk_stats_shown;
33 unsigned int jobs;
34 int error;
35 int ipv6;
36 int sent_job;
37
38 struct flist_head eta_list;
39 struct client_eta *eta_in_flight;
40
41 struct flist_head cmd_list;
42
43 uint16_t argc;
44 char **argv;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010045
46 void *client_data;
Jens Axboe0f92bd22012-02-29 11:44:34 +010047};
48
Stephen M. Camerondd366722012-02-24 08:17:30 +010049typedef void (*client_text_op_func)(struct fio_client *client,
50 FILE *f, __u16 pdu_len, const char *buf);
51
52typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd);
53
54typedef void (*client_thread_status_op)(struct fio_net_cmd *cmd);
55
56typedef void (*client_group_stats_op)(struct fio_net_cmd *cmd);
57
58typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd);
59
60typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd);
61
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +010062typedef void (*client_thread_status_display_op)(char *status_message, double perc);
Stephen M. Cameronba936c42012-02-24 08:17:31 +010063
Jens Axboe3ec62ec2012-03-01 12:01:29 +010064typedef void (*client_quit_op)(struct fio_client *);
65
Stephen M. Camerondd366722012-02-24 08:17:30 +010066struct client_ops {
67 client_text_op_func text_op;
68 client_disk_util_op_func disk_util;
69 client_thread_status_op thread_status;
70 client_group_stats_op group_stats;
Jens Axboe0420ba62012-02-29 11:16:52 +010071 client_eta_op eta;
Stephen M. Camerondd366722012-02-24 08:17:30 +010072 client_probe_op probe;
Jens Axboe3ec62ec2012-03-01 12:01:29 +010073 client_quit_op quit;
74 int stay_connected;
Stephen M. Camerondd366722012-02-24 08:17:30 +010075};
76
77extern struct client_ops fio_client_ops;
78
Jens Axboe3e47bd22012-02-29 13:45:02 +010079struct client_eta {
80 struct jobs_eta eta;
81 unsigned int pending;
82};
83
84extern int fio_handle_client(struct fio_client *, struct client_ops *ops);
85extern void fio_client_dec_jobs_eta(struct client_eta *eta, void (*fn)(struct jobs_eta *));
86extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je);
87extern void fio_client_convert_jobs_eta(struct jobs_eta *je);
88
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 *);
97extern int fio_handle_clients(struct client_ops *ops);
98extern int fio_client_add(const char *, void **);
99extern struct fio_client *fio_client_add_explicit(const char *, int, int);
100extern void fio_client_add_cmd_option(void *, const char *);
101
Stephen M. Camerondd366722012-02-24 08:17:30 +0100102#endif
103