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#include "../../include/linux/libcfs/libcfs.h"
47#include "../../include/linux/lnet/lnet.h"
48#include "../../include/linux/lnet/lib-types.h"
49#include "../../include/linux/lnet/lnetst.h"
50#include "selftest.h"
51#include "conrpc.h"
52
53typedef struct lstcon_node {
54 lnet_process_id_t nd_id;
55 int nd_ref;
56 int nd_state;
57 int nd_timeout;
58 unsigned long nd_stamp;
59 struct lstcon_rpc nd_ping;
60} lstcon_node_t;
61
62typedef struct {
63 struct list_head ndl_link;
64 struct list_head ndl_hlink;
65 lstcon_node_t *ndl_node;
66} lstcon_ndlink_t;
67
68typedef struct {
69 struct list_head grp_link;
70
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
96 char bat_name[LST_NAME_SIZE];
97
98 struct list_head bat_test_list;
99
100 struct list_head bat_trans_list;
101 struct list_head bat_cli_list;
102
103 struct list_head *bat_cli_hash;
104 struct list_head bat_srv_list;
105 struct list_head *bat_srv_hash;
106} lstcon_batch_t;
107
108typedef struct lstcon_test {
109 lstcon_tsb_hdr_t tes_hdr;
110 struct list_head tes_link;
111 lstcon_batch_t *tes_batch;
112
113 int tes_type;
114 int tes_stop_onerr;
115 int tes_oneside;
116 int tes_concur;
117 int tes_loop;
118 int tes_dist;
119 int tes_span;
120 int tes_cliidx;
121
122 struct list_head tes_trans_list;
123 lstcon_group_t *tes_src_grp;
124 lstcon_group_t *tes_dst_grp;
125
126 int tes_paramlen;
127 char tes_param[0];
128} lstcon_test_t;
129
130#define LST_GLOBAL_HASHSIZE 503
131#define LST_NODE_HASHSIZE 239
132
133#define LST_SESSION_NONE 0x0
134#define LST_SESSION_ACTIVE 0x1
135
136#define LST_CONSOLE_TIMEOUT 300
137
138struct lstcon_session {
139 struct mutex ses_mutex;
140 lst_sid_t ses_id;
141 int ses_key;
142 int ses_state;
143 int ses_timeout;
144 time64_t ses_laststamp;
145
146 unsigned ses_features;
147
148 unsigned ses_feats_updated:1;
149
150 unsigned ses_force:1;
151 unsigned ses_shutdown:1;
152 unsigned ses_expired:1;
153 __u64 ses_id_cookie;
154 char ses_name[LST_NAME_SIZE];
155 lstcon_rpc_trans_t *ses_ping;
156 struct stt_timer ses_ping_timer;
157 lstcon_trans_stat_t ses_trans_stat;
158
159 struct list_head ses_trans_list;
160 struct list_head ses_grp_list;
161 struct list_head ses_bat_list;
162 struct list_head ses_ndl_list;
163 struct list_head *ses_ndl_hash;
164
165 spinlock_t ses_rpc_lock;
166 atomic_t ses_rpc_counter;
167 struct list_head ses_rpc_freelist;
168};
169
170extern struct lstcon_session console_session;
171
172static inline lstcon_trans_stat_t *
173lstcon_trans_stat(void)
174{
175 return &console_session.ses_trans_stat;
176}
177
178static inline struct list_head *
179lstcon_id2hash(lnet_process_id_t id, struct list_head *hash)
180{
181 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
182
183 return &hash[idx];
184}
185
186int lstcon_console_init(void);
187int lstcon_console_fini(void);
188int lstcon_session_match(lst_sid_t sid);
189int lstcon_session_new(char *name, int key, unsigned version,
190 int timeout, int flags, lst_sid_t __user *sid_up);
191int lstcon_session_info(lst_sid_t __user *sid_up, int __user *key,
192 unsigned __user *verp, lstcon_ndlist_ent_t __user *entp,
193 char __user *name_up, int len);
194int lstcon_session_end(void);
195int lstcon_session_debug(int timeout, struct list_head __user *result_up);
196int lstcon_session_feats_check(unsigned feats);
197int lstcon_batch_debug(int timeout, char *name,
198 int client, struct list_head __user *result_up);
199int lstcon_group_debug(int timeout, char *name,
200 struct list_head __user *result_up);
201int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t __user *nds_up,
202 struct list_head __user *result_up);
203int lstcon_group_add(char *name);
204int lstcon_group_del(char *name);
205int lstcon_group_clean(char *name, int args);
206int lstcon_group_refresh(char *name, struct list_head __user *result_up);
207int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t __user *nds_up,
208 unsigned *featp, struct list_head __user *result_up);
209int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t __user *nds_up,
210 struct list_head __user *result_up);
211int lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gent_up,
212 int *index_p, int *ndent_p,
213 lstcon_node_ent_t __user *ndents_up);
214int lstcon_group_list(int idx, int len, char __user *name_up);
215int lstcon_batch_add(char *name);
216int lstcon_batch_run(char *name, int timeout,
217 struct list_head __user *result_up);
218int lstcon_batch_stop(char *name, int force,
219 struct list_head __user *result_up);
220int lstcon_test_batch_query(char *name, int testidx,
221 int client, int timeout,
222 struct list_head __user *result_up);
223int lstcon_batch_del(char *name);
224int lstcon_batch_list(int idx, int namelen, char __user *name_up);
225int lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up,
226 int server, int testidx, int *index_p,
227 int *ndent_p, lstcon_node_ent_t __user *dents_up);
228int lstcon_group_stat(char *grp_name, int timeout,
229 struct list_head __user *result_up);
230int lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up,
231 int timeout, struct list_head __user *result_up);
232int lstcon_test_add(char *batch_name, int type, int loop,
233 int concur, int dist, int span,
234 char *src_name, char *dst_name,
235 void *param, int paramlen, int *retp,
236 struct list_head __user *result_up);
237#endif
238