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__
42 #include <linux/uaccess.h>
44 #include <libcfs/libcfs.h>
45 #include <lnet/lib-types.h>
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 ktime_t nd_stamp; /* last RPC reply timestamp */
56 struct lstcon_rpc nd_ping; /* ping rpc */
59 /* node link descriptor */
60 struct lstcon_ndlink {
61 struct list_head ndl_link; /* chain on list */
62 struct list_head ndl_hlink; /* chain on hash */
63 struct lstcon_node *ndl_node; /* pointer to node */
66 /* (alias of nodes) group descriptor */
68 struct list_head grp_link; /* chain on global group list */
69 int grp_ref; /* reference count */
70 int grp_userland; /* has userland nodes */
71 int grp_nnode; /* # of nodes */
72 char grp_name[LST_NAME_SIZE]; /* group name */
74 struct list_head grp_trans_list; /* transaction list */
75 struct list_head grp_ndl_list; /* nodes list */
76 struct list_head grp_ndl_hash[0];/* hash table for nodes */
79 #define LST_BATCH_IDLE 0xB0 /* idle batch */
80 #define LST_BATCH_RUNNING 0xB1 /* running batch */
82 struct lstcon_tsb_hdr {
83 struct lst_bid tsb_id; /* batch ID */
84 int tsb_index; /* test index */
87 /* (tests ) batch descriptor */
89 /* test_batch header */
90 struct lstcon_tsb_hdr bat_hdr;
91 /* chain on session's batches list */
92 struct list_head bat_link;
95 /* state of the batch */
97 /* parameter for run|stop, timeout for run, force for stop */
100 char bat_name[LST_NAME_SIZE];
102 /* list head of tests (lstcon_test_t) */
103 struct list_head bat_test_list;
104 /* list head of transaction */
105 struct list_head bat_trans_list;
106 /* list head of client nodes (struct lstcon_node) */
107 struct list_head bat_cli_list;
108 /* hash table of client nodes */
109 struct list_head *bat_cli_hash;
110 /* list head of server nodes */
111 struct list_head bat_srv_list;
112 /* hash table of server nodes */
113 struct list_head *bat_srv_hash;
116 /* a single test descriptor */
118 /* test batch header */
119 struct lstcon_tsb_hdr tes_hdr;
120 /* chain on batch's tests list */
121 struct list_head tes_link;
122 /* pointer to batch */
123 struct lstcon_batch *tes_batch;
125 int tes_type; /* type of the test, i.e: bulk, ping */
126 int tes_stop_onerr; /* stop on error */
127 int tes_oneside; /* one-sided test */
128 int tes_concur; /* concurrency */
129 int tes_loop; /* loop count */
130 int tes_dist; /* nodes distribution of target group */
131 int tes_span; /* nodes span of target group */
132 int tes_cliidx; /* client index, used for RPC creating */
134 struct list_head tes_trans_list; /* transaction list */
135 struct lstcon_group *tes_src_grp; /* group run the test */
136 struct lstcon_group *tes_dst_grp; /* target group */
138 int tes_paramlen; /* test parameter length */
139 char tes_param[0]; /* test parameter */
142 #define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
143 #define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
145 #define LST_SESSION_NONE 0x0 /* no session */
146 #define LST_SESSION_ACTIVE 0x1 /* working session */
148 #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
150 struct lstcon_session {
151 struct mutex ses_mutex; /* only 1 thread in session */
152 struct lst_sid ses_id; /* global session id */
153 int ses_key; /* local session key */
154 int ses_state; /* state of session */
155 int ses_timeout; /* timeout in seconds */
156 time64_t ses_laststamp; /* last operation stamp (seconds) */
157 /** tests features of the session */
158 unsigned ses_features;
159 /** features are synced with remote test nodes */
160 unsigned ses_feats_updated:1;
161 /** force creating */
162 unsigned ses_force:1;
163 /** session is shutting down */
164 unsigned ses_shutdown:1;
165 /** console is timedout */
166 unsigned ses_expired:1;
167 __u64 ses_id_cookie; /* batch id cookie */
168 char ses_name[LST_NAME_SIZE]; /* session name */
169 struct lstcon_rpc_trans *ses_ping; /* session pinger */
170 struct stt_timer ses_ping_timer; /* timer for pinger */
171 struct lstcon_trans_stat ses_trans_stat;/* transaction stats */
173 struct list_head ses_trans_list; /* global list of transaction */
174 struct list_head ses_grp_list; /* global list of groups */
175 struct list_head ses_bat_list; /* global list of batches */
176 struct list_head ses_ndl_list; /* global list of nodes */
177 struct list_head *ses_ndl_hash; /* hash table of nodes */
179 spinlock_t ses_rpc_lock; /* serialize */
180 atomic_t ses_rpc_counter;/* # of initialized RPCs */
181 struct list_head ses_rpc_freelist;/* idle console rpc */
182 }; /* session descriptor */
184 extern struct lstcon_session console_session;
186 static inline struct lstcon_trans_stat *
187 lstcon_trans_stat(void)
189 return &console_session.ses_trans_stat;
192 static inline struct list_head *
193 lstcon_id2hash(struct lnet_process_id id, struct list_head *hash)
195 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
200 extern int lstcon_session_match(struct lst_sid sid);
201 extern int lstcon_session_new(char *name, int key, unsigned version,
202 int timeout, int flags, struct lst_sid __user *sid_up);
203 extern int lstcon_session_info(struct lst_sid __user *sid_up, int __user *key,
204 unsigned __user *verp,
205 struct lstcon_ndlist_ent __user *entp,
206 char __user *name_up, int len);
207 extern int lstcon_session_end(void);
208 extern int lstcon_session_debug(int timeout,
209 struct list_head __user *result_up);
210 extern int lstcon_session_feats_check(unsigned feats);
211 extern int lstcon_batch_debug(int timeout, char *name,
212 int client, struct list_head __user *result_up);
213 extern int lstcon_group_debug(int timeout, char *name,
214 struct list_head __user *result_up);
215 extern int lstcon_nodes_debug(int timeout, int nnd,
216 struct lnet_process_id __user *nds_up,
217 struct list_head __user *result_up);
218 extern int lstcon_group_add(char *name);
219 extern int lstcon_group_del(char *name);
220 extern int lstcon_group_clean(char *name, int args);
221 extern int lstcon_group_refresh(char *name, struct list_head __user *result_up);
222 extern int lstcon_nodes_add(char *name, int nnd,
223 struct lnet_process_id __user *nds_up,
225 struct list_head __user *result_up);
226 extern int lstcon_nodes_remove(char *name, int nnd,
227 struct lnet_process_id __user *nds_up,
228 struct list_head __user *result_up);
229 extern int lstcon_group_info(char *name, struct lstcon_ndlist_ent __user *gent_up,
230 int *index_p, int *ndent_p,
231 struct lstcon_node_ent __user *ndents_up);
232 extern int lstcon_group_list(int idx, int len, char __user *name_up);
233 extern int lstcon_batch_add(char *name);
234 extern int lstcon_batch_run(char *name, int timeout,
235 struct list_head __user *result_up);
236 extern int lstcon_batch_stop(char *name, int force,
237 struct list_head __user *result_up);
238 extern int lstcon_test_batch_query(char *name, int testidx,
239 int client, int timeout,
240 struct list_head __user *result_up);
241 extern int lstcon_batch_del(char *name);
242 extern int lstcon_batch_list(int idx, int namelen, char __user *name_up);
243 extern int lstcon_batch_info(char *name,
244 struct lstcon_test_batch_ent __user *ent_up,
245 int server, int testidx, int *index_p,
247 struct lstcon_node_ent __user *dents_up);
248 extern int lstcon_group_stat(char *grp_name, int timeout,
249 struct list_head __user *result_up);
250 extern int lstcon_nodes_stat(int count, struct lnet_process_id __user *ids_up,
251 int timeout, struct list_head __user *result_up);
252 extern int lstcon_test_add(char *batch_name, int type, int loop,
253 int concur, int dist, int span,
254 char *src_name, char *dst_name,
255 void *param, int paramlen, int *retp,
256 struct list_head __user *result_up);
258 int lstcon_ioctl_entry(struct notifier_block *nb,
259 unsigned long cmd, void *vdata);
260 int lstcon_console_init(void);
261 int lstcon_console_fini(void);