1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43#ifndef __LST_CONSOLE_H__
44#define __LST_CONSOLE_H__
45
46
47#include <linux/libcfs/libcfs.h>
48#include <linux/lnet/lnet.h>
49#include <linux/lnet/lib-types.h>
50#include <linux/lnet/lnetst.h>
51#include "selftest.h"
52#include "conrpc.h"
53
54typedef struct lstcon_node {
55 lnet_process_id_t nd_id;
56 int nd_ref;
57 int nd_state;
58 int nd_timeout;
59 cfs_time_t nd_stamp;
60 struct lstcon_rpc nd_ping;
61} lstcon_node_t;
62
63typedef struct {
64 struct list_head ndl_link;
65 struct list_head ndl_hlink;
66 lstcon_node_t *ndl_node;
67} lstcon_ndlink_t;
68
69typedef struct {
70 struct list_head grp_link;
71 int grp_ref;
72 int grp_userland;
73 int grp_nnode;
74 char grp_name[LST_NAME_SIZE];
75
76 struct list_head grp_trans_list;
77 struct list_head grp_ndl_list;
78 struct list_head grp_ndl_hash[0];
79} lstcon_group_t;
80
81#define LST_BATCH_IDLE 0xB0
82#define LST_BATCH_RUNNING 0xB1
83
84typedef struct lstcon_tsb_hdr {
85 lst_bid_t tsb_id;
86 int tsb_index;
87} lstcon_tsb_hdr_t;
88
89typedef struct {
90 lstcon_tsb_hdr_t bat_hdr;
91 struct list_head bat_link;
92 int bat_ntest;
93 int bat_state;
94 int bat_arg;
95 char bat_name[LST_NAME_SIZE];
96
97 struct list_head bat_test_list;
98 struct list_head bat_trans_list;
99 struct list_head bat_cli_list;
100 struct list_head *bat_cli_hash;
101 struct list_head bat_srv_list;
102 struct list_head *bat_srv_hash;
103} lstcon_batch_t;
104
105typedef struct lstcon_test {
106 lstcon_tsb_hdr_t tes_hdr;
107 struct list_head tes_link;
108 lstcon_batch_t *tes_batch;
109
110 int tes_type;
111 int tes_stop_onerr;
112 int tes_oneside;
113 int tes_concur;
114 int tes_loop;
115 int tes_dist;
116 int tes_span;
117 int tes_cliidx;
118
119 struct list_head tes_trans_list;
120 lstcon_group_t *tes_src_grp;
121 lstcon_group_t *tes_dst_grp;
122
123 int tes_paramlen;
124 char tes_param[0];
125} lstcon_test_t;
126
127#define LST_GLOBAL_HASHSIZE 503
128#define LST_NODE_HASHSIZE 239
129
130#define LST_SESSION_NONE 0x0
131#define LST_SESSION_ACTIVE 0x1
132
133#define LST_CONSOLE_TIMEOUT 300
134
135typedef struct {
136 struct mutex ses_mutex;
137 lst_sid_t ses_id;
138 int ses_key;
139 int ses_state;
140 int ses_timeout;
141 time_t ses_laststamp;
142
143 unsigned ses_features;
144
145 unsigned ses_feats_updated:1;
146
147 unsigned ses_force:1;
148
149 unsigned ses_shutdown:1;
150
151 unsigned ses_expired:1;
152 __u64 ses_id_cookie;
153 char ses_name[LST_NAME_SIZE];
154 lstcon_rpc_trans_t *ses_ping;
155 stt_timer_t ses_ping_timer;
156 lstcon_trans_stat_t ses_trans_stat;
157
158 struct list_head ses_trans_list;
159 struct list_head ses_grp_list;
160 struct list_head ses_bat_list;
161 struct list_head ses_ndl_list;
162 struct list_head *ses_ndl_hash;
163
164 spinlock_t ses_rpc_lock;
165 atomic_t ses_rpc_counter;
166 struct list_head ses_rpc_freelist;
167} lstcon_session_t;
168
169extern lstcon_session_t console_session;
170
171static inline lstcon_trans_stat_t *
172lstcon_trans_stat(void)
173{
174 return &console_session.ses_trans_stat;
175}
176
177static inline struct list_head *
178lstcon_id2hash (lnet_process_id_t id, struct list_head *hash)
179{
180 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
181
182 return &hash[idx];
183}
184
185extern int lstcon_session_match(lst_sid_t sid);
186extern int lstcon_session_new(char *name, int key, unsigned version,
187 int timeout, int flags, lst_sid_t *sid_up);
188extern int lstcon_session_info(lst_sid_t *sid_up, int *key, unsigned *verp,
189 lstcon_ndlist_ent_t *entp, char *name_up, int len);
190extern int lstcon_session_end(void);
191extern int lstcon_session_debug(int timeout, struct list_head *result_up);
192extern int lstcon_session_feats_check(unsigned feats);
193extern int lstcon_batch_debug(int timeout, char *name,
194 int client, struct list_head *result_up);
195extern int lstcon_group_debug(int timeout, char *name,
196 struct list_head *result_up);
197extern int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t *nds_up,
198 struct list_head *result_up);
199extern int lstcon_group_add(char *name);
200extern int lstcon_group_del(char *name);
201extern int lstcon_group_clean(char *name, int args);
202extern int lstcon_group_refresh(char *name, struct list_head *result_up);
203extern int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t *nds_up,
204 unsigned *featp, struct list_head *result_up);
205extern int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t *nds_up,
206 struct list_head *result_up);
207extern int lstcon_group_info(char *name, lstcon_ndlist_ent_t *gent_up,
208 int *index_p, int *ndent_p, lstcon_node_ent_t *ndents_up);
209extern int lstcon_group_list(int idx, int len, char *name_up);
210extern int lstcon_batch_add(char *name);
211extern int lstcon_batch_run(char *name, int timeout,
212 struct list_head *result_up);
213extern int lstcon_batch_stop(char *name, int force,
214 struct list_head *result_up);
215extern int lstcon_test_batch_query(char *name, int testidx,
216 int client, int timeout,
217 struct list_head *result_up);
218extern int lstcon_batch_del(char *name);
219extern int lstcon_batch_list(int idx, int namelen, char *name_up);
220extern int lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up,
221 int server, int testidx, int *index_p,
222 int *ndent_p, lstcon_node_ent_t *dents_up);
223extern int lstcon_group_stat(char *grp_name, int timeout,
224 struct list_head *result_up);
225extern int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
226 int timeout, struct list_head *result_up);
227extern int lstcon_test_add(char *name, int type, int loop, int concur,
228 int dist, int span, char *src_name, char * dst_name,
229 void *param, int paramlen, int *retp,
230 struct list_head *result_up);
231
232#endif
233