4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2013, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lnet/selftest/console.h
34 * kernel structure for LST console
36 * Author: Liang Zhen <liangzhen@clusterfs.com>
39 #ifndef __LST_CONSOLE_H__
40 #define __LST_CONSOLE_H__
43 #include <libcfs/libcfs.h>
44 #include <lnet/lnet.h>
45 #include <lnet/lib-types.h>
46 #include <lnet/lnetst.h>
50 typedef struct lstcon_node {
51 struct lnet_process_id nd_id; /* id of the node */
52 int nd_ref; /* reference count */
53 int nd_state; /* state of the node */
54 int nd_timeout; /* session timeout */
55 cfs_time_t nd_stamp; /* timestamp of last replied RPC */
56 struct lstcon_rpc nd_ping; /* ping rpc */
57 } lstcon_node_t; /*** node descriptor */
60 struct list_head ndl_link; /* chain on list */
61 struct list_head ndl_hlink; /* chain on hash */
62 lstcon_node_t *ndl_node; /* pointer to node */
63 } lstcon_ndlink_t; /*** node link descriptor */
66 struct list_head grp_link; /* chain on global group list */
67 int grp_ref; /* reference count */
68 int grp_userland; /* has userland nodes */
69 int grp_nnode; /* # of nodes */
70 char grp_name[LST_NAME_SIZE]; /* group name */
72 struct list_head grp_trans_list; /* transaction list */
73 struct list_head grp_ndl_list; /* nodes list */
74 struct list_head grp_ndl_hash[0];/* hash table for nodes */
75 } lstcon_group_t; /*** (alias of nodes) group descriptor */
77 #define LST_BATCH_IDLE 0xB0 /* idle batch */
78 #define LST_BATCH_RUNNING 0xB1 /* running batch */
80 typedef struct lstcon_tsb_hdr {
81 struct lst_bid tsb_id; /* batch ID */
82 int tsb_index; /* test index */
86 /* test_batch header */
87 lstcon_tsb_hdr_t bat_hdr;
88 /* chain on session's batches list */
89 struct list_head bat_link;
92 /* state of the batch */
94 /* parameter for run|stop, timeout for run, force for stop */
97 char bat_name[LST_NAME_SIZE];
99 /* list head of tests (lstcon_test_t) */
100 struct list_head bat_test_list;
101 /* list head of transaction */
102 struct list_head bat_trans_list;
103 /* list head of client nodes (lstcon_node_t) */
104 struct list_head bat_cli_list;
105 /* hash table of client nodes */
106 struct list_head *bat_cli_hash;
107 /* list head of server nodes */
108 struct list_head bat_srv_list;
109 /* hash table of server nodes */
110 struct list_head *bat_srv_hash;
111 } lstcon_batch_t; /*** (tests ) batch descritptor */
113 typedef struct lstcon_test {
114 /* test batch header */
115 lstcon_tsb_hdr_t tes_hdr;
116 /* chain on batch's tests list */
117 struct list_head tes_link;
118 /* pointer to batch */
119 lstcon_batch_t *tes_batch;
121 int tes_type; /* type of the test, i.e: bulk, ping */
122 int tes_stop_onerr; /* stop on error */
123 int tes_oneside; /* one-sided test */
124 int tes_concur; /* concurrency */
125 int tes_loop; /* loop count */
126 int tes_dist; /* nodes distribution of target group */
127 int tes_span; /* nodes span of target group */
128 int tes_cliidx; /* client index, used for RPC creating */
130 struct list_head tes_trans_list; /* transaction list */
131 lstcon_group_t *tes_src_grp; /* group run the test */
132 lstcon_group_t *tes_dst_grp; /* target group */
134 int tes_paramlen; /* test parameter length */
135 char tes_param[0]; /* test parameter */
136 } lstcon_test_t; /*** a single test descriptor */
138 #define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
139 #define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
141 #define LST_SESSION_NONE 0x0 /* no session */
142 #define LST_SESSION_ACTIVE 0x1 /* working session */
144 #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
147 struct mutex ses_mutex; /* only 1 thread in session */
148 struct lst_sid ses_id; /* global session id */
149 int ses_key; /* local session key */
150 int ses_state; /* state of session */
151 int ses_timeout; /* timeout in seconds */
152 time64_t ses_laststamp; /* last operation stamp (seconds) */
153 /** tests features of the session */
154 unsigned ses_features;
155 /** features are synced with remote test nodes */
156 unsigned ses_feats_updated:1;
157 /** force creating */
158 unsigned ses_force:1;
159 /** session is shutting down */
160 unsigned ses_shutdown:1;
161 /** console is timedout */
162 unsigned ses_expired:1;
163 __u64 ses_id_cookie; /* batch id cookie */
164 char ses_name[LST_NAME_SIZE]; /* session name */
165 lstcon_rpc_trans_t *ses_ping; /* session pinger */
166 stt_timer_t ses_ping_timer; /* timer for pinger */
167 struct lstcon_trans_stat ses_trans_stat; /* transaction stats */
169 struct list_head ses_trans_list; /* global list of transaction */
170 struct list_head ses_grp_list; /* global list of groups */
171 struct list_head ses_bat_list; /* global list of batches */
172 struct list_head ses_ndl_list; /* global list of nodes */
173 struct list_head *ses_ndl_hash; /* hash table of nodes */
175 spinlock_t ses_rpc_lock; /* serialize */
176 atomic_t ses_rpc_counter;/* # of initialized RPCs */
177 struct list_head ses_rpc_freelist;/* idle console rpc */
178 } lstcon_session_t; /*** session descriptor */
180 extern lstcon_session_t console_session;
182 static inline struct lstcon_trans_stat *
183 lstcon_trans_stat(void)
185 return &console_session.ses_trans_stat;
188 static inline struct list_head *
189 lstcon_id2hash(struct lnet_process_id id, struct list_head *hash)
191 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
196 extern int lstcon_session_match(struct lst_sid sid);
197 extern int lstcon_session_new(char *name, int key, unsigned version,
198 int timeout, int flags, struct lst_sid __user *sid_up);
199 extern int lstcon_session_info(struct lst_sid __user *sid_up, int __user *key,
200 unsigned __user *verp,
201 struct lstcon_ndlist_ent __user *entp,
202 char __user *name_up, int len);
203 extern int lstcon_session_end(void);
204 extern int lstcon_session_debug(int timeout,
205 struct list_head __user *result_up);
206 extern int lstcon_session_feats_check(unsigned feats);
207 extern int lstcon_batch_debug(int timeout, char *name,
208 int client, struct list_head __user *result_up);
209 extern int lstcon_group_debug(int timeout, char *name,
210 struct list_head __user *result_up);
211 extern int lstcon_nodes_debug(int timeout, int nnd,
212 struct lnet_process_id __user *nds_up,
213 struct list_head __user *result_up);
214 extern int lstcon_group_add(char *name);
215 extern int lstcon_group_del(char *name);
216 extern int lstcon_group_clean(char *name, int args);
217 extern int lstcon_group_refresh(char *name, struct list_head __user *result_up);
218 extern int lstcon_nodes_add(char *name, int nnd,
219 struct lnet_process_id __user *nds_up,
221 struct list_head __user *result_up);
222 extern int lstcon_nodes_remove(char *name, int nnd,
223 struct lnet_process_id __user *nds_up,
224 struct list_head __user *result_up);
225 extern int lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gent_up,
226 int *index_p, int *ndent_p,
227 struct lstcon_node_ent __user *ndents_up);
228 extern int lstcon_group_list(int idx, int len, char __user *name_up);
229 extern int lstcon_batch_add(char *name);
230 extern int lstcon_batch_run(char *name, int timeout,
231 struct list_head __user *result_up);
232 extern int lstcon_batch_stop(char *name, int force,
233 struct list_head __user *result_up);
234 extern int lstcon_test_batch_query(char *name, int testidx,
235 int client, int timeout,
236 struct list_head __user *result_up);
237 extern int lstcon_batch_del(char *name);
238 extern int lstcon_batch_list(int idx, int namelen, char __user *name_up);
239 extern int lstcon_batch_info(char *name,
240 struct lstcon_test_batch_ent __user *ent_up,
241 int server, int testidx, int *index_p,
243 struct lstcon_node_ent __user *dents_up);
244 extern int lstcon_group_stat(char *grp_name, int timeout,
245 struct list_head __user *result_up);
246 extern int lstcon_nodes_stat(int count, struct lnet_process_id __user *ids_up,
247 int timeout, struct list_head __user *result_up);
248 extern int lstcon_test_add(char *batch_name, int type, int loop,
249 int concur, int dist, int span,
250 char *src_name, char *dst_name,
251 void *param, int paramlen, int *retp,
252 struct list_head __user *result_up);
254 int lstcon_console_init(void);
255 int lstcon_console_fini(void);