| 1 | #ifndef CLIENT_H |
| 2 | #define CLIENT_H |
| 3 | |
| 4 | #include <sys/socket.h> |
| 5 | #include <sys/un.h> |
| 6 | #include <netinet/in.h> |
| 7 | #include <arpa/inet.h> |
| 8 | |
| 9 | #include "stat.h" |
| 10 | |
| 11 | struct fio_net_cmd; |
| 12 | struct client_ops; |
| 13 | |
| 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 | |
| 23 | struct 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; |
| 35 | unsigned int refs; |
| 36 | |
| 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; |
| 46 | int ipv6; |
| 47 | int sent_job; |
| 48 | |
| 49 | struct flist_head eta_list; |
| 50 | struct client_eta *eta_in_flight; |
| 51 | |
| 52 | struct flist_head cmd_list; |
| 53 | |
| 54 | uint16_t argc; |
| 55 | char **argv; |
| 56 | |
| 57 | struct client_ops *ops; |
| 58 | void *client_data; |
| 59 | }; |
| 60 | |
| 61 | typedef void (*client_text_op_func)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 62 | typedef void (*client_disk_util_op_func)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 63 | typedef void (*client_thread_status_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 64 | typedef void (*client_group_stats_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 65 | typedef void (*client_eta_op)(struct jobs_eta *je); |
| 66 | typedef void (*client_jobs_eta_op)(struct fio_client *client, struct jobs_eta *je); |
| 67 | typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd); |
| 68 | typedef void (*client_thread_status_display_op)(char *status_message, double perc); |
| 69 | typedef void (*client_quit_op)(struct fio_client *); |
| 70 | typedef void (*client_add_job_op)(struct fio_client *, struct fio_net_cmd *); |
| 71 | typedef void (*client_timed_out)(struct fio_client *); |
| 72 | typedef void (*client_stop_op)(struct fio_client *, struct fio_net_cmd *); |
| 73 | |
| 74 | struct client_ops { |
| 75 | client_text_op_func text_op; |
| 76 | client_disk_util_op_func disk_util; |
| 77 | client_thread_status_op thread_status; |
| 78 | client_group_stats_op group_stats; |
| 79 | client_jobs_eta_op jobs_eta; |
| 80 | client_eta_op eta; |
| 81 | client_probe_op probe; |
| 82 | client_quit_op quit; |
| 83 | client_add_job_op add_job; |
| 84 | client_timed_out timed_out; |
| 85 | client_stop_op stop; |
| 86 | unsigned int eta_msec; |
| 87 | int stay_connected; |
| 88 | }; |
| 89 | |
| 90 | extern struct client_ops fio_client_ops; |
| 91 | |
| 92 | struct client_eta { |
| 93 | struct jobs_eta eta; |
| 94 | unsigned int pending; |
| 95 | }; |
| 96 | |
| 97 | extern int fio_handle_client(struct fio_client *); |
| 98 | extern void fio_client_dec_jobs_eta(struct client_eta *eta, client_eta_op fn); |
| 99 | extern void fio_client_sum_jobs_eta(struct jobs_eta *dst, struct jobs_eta *je); |
| 100 | |
| 101 | enum { |
| 102 | Fio_client_ipv4 = 1, |
| 103 | Fio_client_ipv6, |
| 104 | Fio_client_socket, |
| 105 | }; |
| 106 | |
| 107 | extern int fio_client_connect(struct fio_client *); |
| 108 | extern int fio_clients_connect(void); |
| 109 | extern int fio_start_client(struct fio_client *); |
| 110 | extern int fio_start_all_clients(void); |
| 111 | extern int fio_client_send_ini(struct fio_client *, const char *); |
| 112 | extern int fio_clients_send_ini(const char *); |
| 113 | extern int fio_handle_clients(struct client_ops *); |
| 114 | extern int fio_client_add(struct client_ops *, const char *, void **); |
| 115 | extern struct fio_client *fio_client_add_explicit(struct client_ops *, const char *, int, int); |
| 116 | extern void fio_client_add_cmd_option(void *, const char *); |
| 117 | extern void fio_client_terminate(struct fio_client *); |
| 118 | extern void fio_clients_terminate(void); |
| 119 | extern struct fio_client *fio_get_client(struct fio_client *); |
| 120 | extern void fio_put_client(struct fio_client *); |
| 121 | |
| 122 | #define FIO_CLIENT_DEF_ETA_MSEC 900 |
| 123 | |
| 124 | #endif |
| 125 | |