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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lnet/selftest/console.h
38 * kernel structure for LST console
40 * Author: Liang Zhen <liangzhen@clusterfs.com>
43 #ifndef __LST_CONSOLE_H__
44 #define __LST_CONSOLE_H__
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"
55 lnet_process_id_t nd_id; /* id of the node */
56 int nd_ref; /* reference count */
57 int nd_state; /* state of the node */
58 int nd_timeout; /* session timeout */
59 unsigned long nd_stamp; /* timestamp of last replied RPC */
60 struct lstcon_rpc nd_ping; /* ping rpc */
63 /* node link descriptor */
64 struct lstcon_ndlink {
65 struct list_head ndl_link; /* chain on list */
66 struct list_head ndl_hlink; /* chain on hash */
67 struct lstcon_node *ndl_node; /* pointer to node */
70 /* (alias of nodes) group descriptor */
72 struct list_head grp_link; /* chain on global group list
74 int grp_ref; /* reference count */
75 int grp_userland; /* has userland nodes */
76 int grp_nnode; /* # of nodes */
77 char grp_name[LST_NAME_SIZE]; /* group name */
79 struct list_head grp_trans_list; /* transaction list */
80 struct list_head grp_ndl_list; /* nodes list */
81 struct list_head grp_ndl_hash[0]; /* hash table for nodes */
84 #define LST_BATCH_IDLE 0xB0 /* idle batch */
85 #define LST_BATCH_RUNNING 0xB1 /* running batch */
87 struct lstcon_tsb_hdr {
88 lst_bid_t tsb_id; /* batch ID */
89 int tsb_index; /* test index */
92 /* (tests ) batch descriptor */
94 struct lstcon_tsb_hdr bat_hdr; /* test_batch header */
95 struct list_head bat_link; /* chain on session's batches list */
96 int bat_ntest; /* # of test */
97 int bat_state; /* state of the batch */
98 int bat_arg; /* parameter for run|stop, timeout
99 * for run, force for stop */
100 char bat_name[LST_NAME_SIZE];/* name of batch */
102 struct list_head bat_test_list; /* list head of tests (struct lstcon_test)
104 struct list_head bat_trans_list; /* list head of transaction */
105 struct list_head bat_cli_list; /* list head of client nodes
106 * (struct lstcon_node) */
107 struct list_head *bat_cli_hash; /* hash table of client nodes */
108 struct list_head bat_srv_list; /* list head of server nodes */
109 struct list_head *bat_srv_hash; /* hash table of server nodes */
112 /* a single test descriptor */
114 struct lstcon_tsb_hdr tes_hdr; /* test batch header */
115 struct list_head tes_link; /* chain on batch's tests list */
116 struct lstcon_batch *tes_batch; /* pointer to batch */
118 int tes_type; /* type of the test, i.e: bulk, ping */
119 int tes_stop_onerr; /* stop on error */
120 int tes_oneside; /* one-sided test */
121 int tes_concur; /* concurrency */
122 int tes_loop; /* loop count */
123 int tes_dist; /* nodes distribution of target group */
124 int tes_span; /* nodes span of target group */
125 int tes_cliidx; /* client index, used for RPC creating */
127 struct list_head tes_trans_list; /* transaction list */
128 struct lstcon_group *tes_src_grp; /* group run the test */
129 struct lstcon_group *tes_dst_grp; /* target group */
131 int tes_paramlen; /* test parameter length */
132 char tes_param[0]; /* test parameter */
135 #define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
136 #define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
138 #define LST_SESSION_NONE 0x0 /* no session */
139 #define LST_SESSION_ACTIVE 0x1 /* working session */
141 #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
143 struct lstcon_session {
144 struct mutex ses_mutex; /* only 1 thread in session */
145 lst_sid_t ses_id; /* global session id */
146 int ses_key; /* local session key */
147 int ses_state; /* state of session */
148 int ses_timeout; /* timeout in seconds */
149 time64_t ses_laststamp; /* last operation stamp (seconds)
151 unsigned ses_features; /* tests features of the session
153 unsigned ses_feats_updated:1; /* features are synced with
154 * remote test nodes */
155 unsigned ses_force:1; /* force creating */
156 unsigned ses_shutdown:1; /* session is shutting down */
157 unsigned ses_expired:1; /* console is timedout */
158 __u64 ses_id_cookie; /* batch id cookie */
159 char ses_name[LST_NAME_SIZE];/* session name */
160 struct lstcon_rpc_trans *ses_ping; /* session pinger */
161 struct stt_timer ses_ping_timer; /* timer for pinger */
162 lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
164 struct list_head ses_trans_list; /* global list of transaction */
165 struct list_head ses_grp_list; /* global list of groups */
166 struct list_head ses_bat_list; /* global list of batches */
167 struct list_head ses_ndl_list; /* global list of nodes */
168 struct list_head *ses_ndl_hash; /* hash table of nodes */
170 spinlock_t ses_rpc_lock; /* serialize */
171 atomic_t ses_rpc_counter; /* # of initialized RPCs */
172 struct list_head ses_rpc_freelist; /* idle console rpc */
173 }; /* session descriptor */
175 extern struct lstcon_session console_session;
177 static inline lstcon_trans_stat_t *
178 lstcon_trans_stat(void)
180 return &console_session.ses_trans_stat;
183 static inline struct list_head *
184 lstcon_id2hash(lnet_process_id_t id, struct list_head *hash)
186 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
191 int lstcon_console_init(void);
192 int lstcon_console_fini(void);
193 int lstcon_session_match(lst_sid_t sid);
194 int lstcon_session_new(char *name, int key, unsigned version,
195 int timeout, int flags, lst_sid_t __user *sid_up);
196 int lstcon_session_info(lst_sid_t __user *sid_up, int __user *key,
197 unsigned __user *verp, lstcon_ndlist_ent_t __user *entp,
198 char __user *name_up, int len);
199 int lstcon_session_end(void);
200 int lstcon_session_debug(int timeout, struct list_head __user *result_up);
201 int lstcon_session_feats_check(unsigned feats);
202 int lstcon_batch_debug(int timeout, char *name,
203 int client, struct list_head __user *result_up);
204 int lstcon_group_debug(int timeout, char *name,
205 struct list_head __user *result_up);
206 int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t __user *nds_up,
207 struct list_head __user *result_up);
208 int lstcon_group_add(char *name);
209 int lstcon_group_del(char *name);
210 int lstcon_group_clean(char *name, int args);
211 int lstcon_group_refresh(char *name, struct list_head __user *result_up);
212 int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t __user *nds_up,
213 unsigned *featp, struct list_head __user *result_up);
214 int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t __user *nds_up,
215 struct list_head __user *result_up);
216 int lstcon_group_info(char *name, lstcon_ndlist_ent_t __user *gent_up,
217 int *index_p, int *ndent_p,
218 lstcon_node_ent_t __user *ndents_up);
219 int lstcon_group_list(int idx, int len, char __user *name_up);
220 int lstcon_batch_add(char *name);
221 int lstcon_batch_run(char *name, int timeout,
222 struct list_head __user *result_up);
223 int lstcon_batch_stop(char *name, int force,
224 struct list_head __user *result_up);
225 int lstcon_test_batch_query(char *name, int testidx,
226 int client, int timeout,
227 struct list_head __user *result_up);
228 int lstcon_batch_del(char *name);
229 int lstcon_batch_list(int idx, int namelen, char __user *name_up);
230 int lstcon_batch_info(char *name, lstcon_test_batch_ent_t __user *ent_up,
231 int server, int testidx, int *index_p,
232 int *ndent_p, lstcon_node_ent_t __user *dents_up);
233 int lstcon_group_stat(char *grp_name, int timeout,
234 struct list_head __user *result_up);
235 int lstcon_nodes_stat(int count, lnet_process_id_t __user *ids_up,
236 int timeout, struct list_head __user *result_up);
237 int lstcon_test_add(char *batch_name, int type, int loop,
238 int concur, int dist, int span,
239 char *src_name, char *dst_name,
240 void *param, int paramlen, int *retp,
241 struct list_head __user *result_up);