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; |
| 12 | |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 13 | struct 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 Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 45 | |
| 46 | void *client_data; |
Jens Axboe | 0f92bd2 | 2012-02-29 11:44:34 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 49 | typedef void (*client_text_op_func)(struct fio_client *client, |
| 50 | FILE *f, __u16 pdu_len, const char *buf); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 51 | typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 52 | typedef void (*client_thread_status_op)(struct fio_net_cmd *cmd); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 53 | typedef void (*client_group_stats_op)(struct fio_net_cmd *cmd); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 54 | typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 55 | 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] | 56 | typedef void (*client_thread_status_display_op)(char *status_message, double perc); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 57 | typedef void (*client_quit_op)(struct fio_client *); |
Jens Axboe | 807f997 | 2012-03-02 10:25:24 +0100 | [diff] [blame^] | 58 | typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *); |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 59 | |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 60 | struct client_ops { |
| 61 | client_text_op_func text_op; |
| 62 | client_disk_util_op_func disk_util; |
| 63 | client_thread_status_op thread_status; |
| 64 | client_group_stats_op group_stats; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 65 | client_eta_op eta; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 66 | client_probe_op probe; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 67 | client_quit_op quit; |
Jens Axboe | 807f997 | 2012-03-02 10:25:24 +0100 | [diff] [blame^] | 68 | client_add_job_op add_job; |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 69 | int stay_connected; |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | extern struct client_ops fio_client_ops; |
| 73 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame] | 74 | struct client_eta { |
| 75 | struct jobs_eta eta; |
| 76 | unsigned int pending; |
| 77 | }; |
| 78 | |
| 79 | extern int fio_handle_client(struct fio_client *, struct client_ops *ops); |
| 80 | extern void fio_client_dec_jobs_eta(struct client_eta *eta, void (*fn)(struct jobs_eta *)); |
| 81 | extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); |
| 82 | extern void fio_client_convert_jobs_eta(struct jobs_eta *je); |
| 83 | |
Jens Axboe | 3ec62ec | 2012-03-01 12:01:29 +0100 | [diff] [blame] | 84 | enum { |
| 85 | Fio_client_ipv4 = 1, |
| 86 | Fio_client_ipv6, |
| 87 | Fio_client_socket, |
| 88 | }; |
| 89 | |
| 90 | extern int fio_clients_connect(void); |
| 91 | extern int fio_clients_send_ini(const char *); |
| 92 | extern int fio_handle_clients(struct client_ops *ops); |
| 93 | extern int fio_client_add(const char *, void **); |
| 94 | extern struct fio_client *fio_client_add_explicit(const char *, int, int); |
| 95 | extern void fio_client_add_cmd_option(void *, const char *); |
Stephen M. Cameron | dd36672 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 96 | #endif |
| 97 | |