Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 1 | #ifndef CLIENT_H |
| 2 | #define CLIENT_H |
| 3 | |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 4 | #include <sys/socket.h> |
| 5 | #include <sys/un.h> |
| 6 | #include <netinet/in.h> |
| 7 | #include <arpa/inet.h> |
| 8 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 9 | #include "stat.h" |
| 10 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 11 | struct fio_net_cmd; |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 12 | struct client_ops; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 13 | |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 14 | struct 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 Axboe | 5121a9a | 2012-03-05 13:32:47 +0100 | [diff] [blame] | 26 | unsigned int refs; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 27 | |
| 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 Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 47 | |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 48 | struct client_ops *ops; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 49 | void *client_data; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
Jens Axboe | 084d1c6 | 2012-03-03 20:28:07 +0100 | [diff] [blame] | 52 | typedef void (*client_text_op_func)(struct fio_client *client, struct fio_net_cmd *cmd); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 53 | typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd); |
Jens Axboe | 89e5fad | 2012-03-05 09:21:12 +0100 | [diff] [blame] | 54 | typedef void (*client_thread_status_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 55 | typedef void (*client_group_stats_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 56 | typedef void (*client_eta_op)(struct jobs_eta *je); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 57 | typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 58 | typedef void (*client_thread_status_display_op)(char *status_message, double perc); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 59 | typedef void (*client_quit_op)(struct fio_client *); |
Jens Axboe | 807f997 | 2012-03-02 10:25:24 +0100 | [diff] [blame] | 60 | typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *); |
Jens Axboe | ed727a4 | 2012-03-02 12:14:40 +0100 | [diff] [blame] | 61 | typedef void (*client_timed_out)(struct fio_client *); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 62 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 63 | struct 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 Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 68 | client_eta_op eta; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 69 | client_probe_op probe; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 70 | client_quit_op quit; |
Jens Axboe | 807f997 | 2012-03-02 10:25:24 +0100 | [diff] [blame] | 71 | client_add_job_op add_job; |
Jens Axboe | ed727a4 | 2012-03-02 12:14:40 +0100 | [diff] [blame] | 72 | client_timed_out timed_out; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 73 | int stay_connected; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | extern struct client_ops fio_client_ops; |
| 77 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 78 | struct client_eta { |
| 79 | struct jobs_eta eta; |
| 80 | unsigned int pending; |
| 81 | }; |
| 82 | |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 83 | extern int fio_handle_client(struct fio_client *); |
| 84 | extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 85 | extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 86 | |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 87 | enum { |
| 88 | Fio_client_ipv4 = 1, |
| 89 | Fio_client_ipv6, |
| 90 | Fio_client_socket, |
| 91 | }; |
| 92 | |
| 93 | extern int fio_clients_connect(void); |
| 94 | extern int fio_clients_send_ini(const char *); |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 95 | extern int fio_handle_clients(struct client_ops *); |
| 96 | extern int fio_client_add(struct client_ops *, const char *, void **); |
| 97 | extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 98 | extern void fio_client_add_cmd_option(void *, const char *); |
Jens Axboe | df06f22 | 2012-03-02 13:32:04 +0100 | [diff] [blame] | 99 | extern void fio_clients_terminate(void); |
| 100 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 101 | #endif |
| 102 | |