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 | b9d2f30 | 2012-03-08 20:36:28 +0100 | [diff] [blame] | 14 | enum { |
| 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 Axboe | 3589918 | 2014-10-07 20:56:28 -0600 | [diff] [blame] | 23 | struct client_file { |
| 24 | char *file; |
| 25 | int remote; |
| 26 | }; |
| 27 | |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 28 | struct 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 Axboe | 5121a9a | 2012-03-05 13:32:47 +0100 | [diff] [blame] | 40 | unsigned int refs; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 41 | |
| 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 Axboe | 30f8e31 | 2014-10-13 11:33:27 -0600 | [diff] [blame] | 50 | unsigned int nr_stat; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 51 | int error; |
Jens Axboe | 122c772 | 2012-03-19 09:13:15 +0100 | [diff] [blame] | 52 | int signal; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 53 | int ipv6; |
| 54 | int sent_job; |
Jens Axboe | 1e5324e | 2012-11-14 14:25:31 -0700 | [diff] [blame] | 55 | int did_stat; |
Jens Axboe | 46bcd49 | 2012-03-14 11:31:21 +0100 | [diff] [blame] | 56 | uint32_t type; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 57 | |
Jens Axboe | 40c6051 | 2012-03-27 16:03:04 +0200 | [diff] [blame] | 58 | uint32_t thread_number; |
| 59 | uint32_t groupid; |
| 60 | |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 61 | 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 Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 68 | |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 69 | struct client_ops *ops; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 70 | void *client_data; |
Jens Axboe | 14ea90e | 2012-08-26 17:33:34 +0200 | [diff] [blame] | 71 | |
Jens Axboe | 3589918 | 2014-10-07 20:56:28 -0600 | [diff] [blame] | 72 | struct client_file *files; |
| 73 | unsigned int nr_files; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 74 | }; |
| 75 | |
Jens Axboe | 1b42725 | 2012-03-14 15:03:03 +0100 | [diff] [blame] | 76 | struct cmd_iolog_pdu; |
Jens Axboe | 35c0ba7 | 2012-03-14 10:56:40 +0100 | [diff] [blame] | 77 | typedef void (client_cmd_op)(struct fio_client *, struct fio_net_cmd *); |
| 78 | typedef void (client_eta_op)(struct jobs_eta *je); |
| 79 | typedef void (client_timed_out_op)(struct fio_client *); |
| 80 | typedef void (client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je); |
Jens Axboe | 1b42725 | 2012-03-14 15:03:03 +0100 | [diff] [blame] | 81 | typedef void (client_iolog_op)(struct fio_client *client, struct cmd_iolog_pdu *); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 82 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 83 | struct client_ops { |
Jens Axboe | 35c0ba7 | 2012-03-14 10:56:40 +0100 | [diff] [blame] | 84 | 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 Axboe | 40c6051 | 2012-03-27 16:03:04 +0200 | [diff] [blame] | 93 | client_cmd_op *update_job; |
Jens Axboe | 35c0ba7 | 2012-03-14 10:56:40 +0100 | [diff] [blame] | 94 | client_timed_out_op *timed_out; |
| 95 | client_cmd_op *stop; |
| 96 | client_cmd_op *start; |
| 97 | client_cmd_op *job_start; |
Jens Axboe | 1b42725 | 2012-03-14 15:03:03 +0100 | [diff] [blame] | 98 | client_iolog_op *iolog; |
Jens Axboe | 0cf3ece | 2012-03-21 10:15:20 +0100 | [diff] [blame] | 99 | client_timed_out_op *removed; |
Jens Axboe | 35c0ba7 | 2012-03-14 10:56:40 +0100 | [diff] [blame] | 100 | |
Jens Axboe | 6433ee0 | 2012-03-09 20:10:51 +0100 | [diff] [blame] | 101 | unsigned int eta_msec; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 102 | int stay_connected; |
Jens Axboe | 46bcd49 | 2012-03-14 11:31:21 +0100 | [diff] [blame] | 103 | uint32_t client_type; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | extern struct client_ops fio_client_ops; |
| 107 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 108 | struct client_eta { |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 109 | unsigned int pending; |
Jens Axboe | 166fb52 | 2013-04-11 13:45:51 +0200 | [diff] [blame] | 110 | struct jobs_eta eta; |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 111 | }; |
| 112 | |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 113 | extern int fio_handle_client(struct fio_client *); |
| 114 | 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] | 115 | 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] | 116 | |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 117 | enum { |
| 118 | Fio_client_ipv4 = 1, |
| 119 | Fio_client_ipv6, |
| 120 | Fio_client_socket, |
| 121 | }; |
| 122 | |
Jens Axboe | 2f99deb | 2012-03-09 14:37:29 +0100 | [diff] [blame] | 123 | extern int fio_client_connect(struct fio_client *); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 124 | extern int fio_clients_connect(void); |
Jens Axboe | b9d2f30 | 2012-03-08 20:36:28 +0100 | [diff] [blame] | 125 | extern int fio_start_client(struct fio_client *); |
| 126 | extern int fio_start_all_clients(void); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 127 | extern int fio_clients_send_ini(const char *); |
Jens Axboe | 3589918 | 2014-10-07 20:56:28 -0600 | [diff] [blame] | 128 | extern int fio_client_send_ini(struct fio_client *, const char *, int); |
Jens Axboe | a527661 | 2012-03-04 15:15:08 +0100 | [diff] [blame] | 129 | extern int fio_handle_clients(struct client_ops *); |
| 130 | extern int fio_client_add(struct client_ops *, const char *, void **); |
| 131 | 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] | 132 | extern void fio_client_add_cmd_option(void *, const char *); |
Jens Axboe | 3589918 | 2014-10-07 20:56:28 -0600 | [diff] [blame] | 133 | extern int fio_client_add_ini_file(void *, const char *, int); |
Jens Axboe | 0cf3ece | 2012-03-21 10:15:20 +0100 | [diff] [blame] | 134 | extern int fio_client_terminate(struct fio_client *); |
Jens Axboe | df06f22 | 2012-03-02 13:32:04 +0100 | [diff] [blame] | 135 | extern void fio_clients_terminate(void); |
Jens Axboe | 343cb4a | 2012-03-09 17:16:51 +0100 | [diff] [blame] | 136 | extern struct fio_client *fio_get_client(struct fio_client *); |
| 137 | extern void fio_put_client(struct fio_client *); |
Jens Axboe | 40c6051 | 2012-03-27 16:03:04 +0200 | [diff] [blame] | 138 | extern int fio_client_update_options(struct fio_client *, struct thread_options *, uint64_t *); |
| 139 | extern int fio_client_wait_for_reply(struct fio_client *, uint64_t); |
Jens Axboe | df06f22 | 2012-03-02 13:32:04 +0100 | [diff] [blame] | 140 | |
Jens Axboe | 6433ee0 | 2012-03-09 20:10:51 +0100 | [diff] [blame] | 141 | #define FIO_CLIENT_DEF_ETA_MSEC 900 |
| 142 | |
Jens Axboe | 46bcd49 | 2012-03-14 11:31:21 +0100 | [diff] [blame] | 143 | enum { |
| 144 | FIO_CLIENT_TYPE_CLI = 1, |
| 145 | FIO_CLIENT_TYPE_GUI = 2, |
| 146 | }; |
| 147 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 148 | #endif |
| 149 | |