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.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * lnet/selftest/console.h
36 * kernel structure for LST console
38 * Author: Liang Zhen <liangzhen@clusterfs.com>
41 #ifndef __LST_CONSOLE_H__
42 #define __LST_CONSOLE_H__
46 #include <libcfs/libcfs.h>
47 #include <lnet/lnet.h>
48 #include <lnet/lib-types.h>
49 #include <lnet/lnetst.h>
53 typedef struct lstcon_node {
54 lnet_process_id_t nd_id; /* id of the node */
55 int nd_ref; /* reference count */
56 int nd_state; /* state of the node */
57 int nd_timeout; /* session timeout */
58 cfs_time_t nd_stamp; /* timestamp of last replied RPC */
59 struct lstcon_rpc nd_ping; /* ping rpc */
60 } lstcon_node_t; /*** node descriptor */
63 cfs_list_t ndl_link; /* chain on list */
64 cfs_list_t ndl_hlink; /* chain on hash */
65 lstcon_node_t *ndl_node; /* pointer to node */
66 } lstcon_ndlink_t; /*** node link descriptor */
69 cfs_list_t grp_link; /* chain on global group list */
70 int grp_ref; /* reference count */
71 int grp_userland; /* has userland nodes */
72 int grp_nnode; /* # of nodes */
73 char grp_name[LST_NAME_SIZE]; /* group name */
75 cfs_list_t grp_trans_list; /* transaction list */
76 cfs_list_t grp_ndl_list; /* nodes list */
77 cfs_list_t grp_ndl_hash[0];/* hash table for nodes */
78 } lstcon_group_t; /*** (alias of nodes) group descriptor */
80 #define LST_BATCH_IDLE 0xB0 /* idle batch */
81 #define LST_BATCH_RUNNING 0xB1 /* running batch */
83 typedef struct lstcon_tsb_hdr {
84 lst_bid_t tsb_id; /* batch ID */
85 int tsb_index; /* test index */
89 lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
90 cfs_list_t bat_link; /* chain on session's batches list */
91 int bat_ntest; /* # of test */
92 int bat_state; /* state of the batch */
93 int bat_arg; /* parameter for run|stop, timeout for run, force for stop */
94 char bat_name[LST_NAME_SIZE]; /* name of batch */
96 cfs_list_t bat_test_list; /* list head of tests (lstcon_test_t) */
97 cfs_list_t bat_trans_list; /* list head of transaction */
98 cfs_list_t bat_cli_list; /* list head of client nodes (lstcon_node_t) */
99 cfs_list_t *bat_cli_hash; /* hash table of client nodes */
100 cfs_list_t bat_srv_list; /* list head of server nodes */
101 cfs_list_t *bat_srv_hash; /* hash table of server nodes */
102 } lstcon_batch_t; /*** (tests ) batch descritptor */
104 typedef struct lstcon_test {
105 lstcon_tsb_hdr_t tes_hdr; /* test batch header */
106 cfs_list_t tes_link; /* chain on batch's tests list */
107 lstcon_batch_t *tes_batch; /* pointer to batch */
109 int tes_type; /* type of the test, i.e: bulk, ping */
110 int tes_stop_onerr; /* stop on error */
111 int tes_oneside; /* one-sided test */
112 int tes_concur; /* concurrency */
113 int tes_loop; /* loop count */
114 int tes_dist; /* nodes distribution of target group */
115 int tes_span; /* nodes span of target group */
116 int tes_cliidx; /* client index, used for RPC creating */
118 cfs_list_t tes_trans_list; /* transaction list */
119 lstcon_group_t *tes_src_grp; /* group run the test */
120 lstcon_group_t *tes_dst_grp; /* target group */
122 int tes_paramlen; /* test parameter length */
123 char tes_param[0]; /* test parameter */
124 } lstcon_test_t; /*** a single test descriptor */
126 #define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
127 #define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
129 #define LST_SESSION_NONE 0x0 /* no session */
130 #define LST_SESSION_ACTIVE 0x1 /* working session */
132 #define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
135 cfs_mutex_t ses_mutex; /* lock for session, only one thread can enter session */
136 lst_sid_t ses_id; /* global session id */
137 int ses_key; /* local session key */
138 int ses_state; /* state of session */
139 int ses_timeout; /* timeout in seconds */
140 time_t ses_laststamp; /* last operation stamp (seconds) */
141 /** tests features of the session */
142 unsigned ses_features;
143 /** features are synced with remote test nodes */
144 unsigned ses_feats_updated:1;
145 /** force creating */
146 unsigned ses_force:1;
147 /** session is shutting down */
148 unsigned ses_shutdown:1;
149 /** console is timedout */
150 unsigned ses_expired:1;
151 __u64 ses_id_cookie; /* batch id cookie */
152 char ses_name[LST_NAME_SIZE]; /* session name */
153 lstcon_rpc_trans_t *ses_ping; /* session pinger */
154 stt_timer_t ses_ping_timer; /* timer for pinger */
155 lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
157 cfs_list_t ses_trans_list; /* global list of transaction */
158 cfs_list_t ses_grp_list; /* global list of groups */
159 cfs_list_t ses_bat_list; /* global list of batches */
160 cfs_list_t ses_ndl_list; /* global list of nodes */
161 cfs_list_t *ses_ndl_hash; /* hash table of nodes */
163 cfs_spinlock_t ses_rpc_lock; /* serialize */
164 cfs_atomic_t ses_rpc_counter;/* # of initialized RPCs */
165 cfs_list_t ses_rpc_freelist; /* idle console rpc */
166 } lstcon_session_t; /*** session descriptor */
168 extern lstcon_session_t console_session;
170 static inline lstcon_trans_stat_t *
171 lstcon_trans_stat(void)
173 return &console_session.ses_trans_stat;
176 static inline cfs_list_t *
177 lstcon_id2hash (lnet_process_id_t id, cfs_list_t *hash)
179 unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
184 extern int lstcon_session_match(lst_sid_t sid);
185 extern int lstcon_session_new(char *name, int key, unsigned version,
186 int timeout, int flags, lst_sid_t *sid_up);
187 extern int lstcon_session_info(lst_sid_t *sid_up, int *key, unsigned *verp,
188 lstcon_ndlist_ent_t *entp, char *name_up, int len);
189 extern int lstcon_session_end(void);
190 extern int lstcon_session_debug(int timeout, cfs_list_t *result_up);
191 extern int lstcon_session_feats_check(unsigned feats);
192 extern int lstcon_batch_debug(int timeout, char *name,
193 int client, cfs_list_t *result_up);
194 extern int lstcon_group_debug(int timeout, char *name,
195 cfs_list_t *result_up);
196 extern int lstcon_nodes_debug(int timeout, int nnd, lnet_process_id_t *nds_up,
197 cfs_list_t *result_up);
198 extern int lstcon_group_add(char *name);
199 extern int lstcon_group_del(char *name);
200 extern int lstcon_group_clean(char *name, int args);
201 extern int lstcon_group_refresh(char *name, cfs_list_t *result_up);
202 extern int lstcon_nodes_add(char *name, int nnd, lnet_process_id_t *nds_up,
203 unsigned *featp, cfs_list_t *result_up);
204 extern int lstcon_nodes_remove(char *name, int nnd, lnet_process_id_t *nds_up,
205 cfs_list_t *result_up);
206 extern int lstcon_group_info(char *name, lstcon_ndlist_ent_t *gent_up,
207 int *index_p, int *ndent_p, lstcon_node_ent_t *ndents_up);
208 extern int lstcon_group_list(int idx, int len, char *name_up);
209 extern int lstcon_batch_add(char *name);
210 extern int lstcon_batch_run(char *name, int timeout,
211 cfs_list_t *result_up);
212 extern int lstcon_batch_stop(char *name, int force,
213 cfs_list_t *result_up);
214 extern int lstcon_test_batch_query(char *name, int testidx,
215 int client, int timeout,
216 cfs_list_t *result_up);
217 extern int lstcon_batch_del(char *name);
218 extern int lstcon_batch_list(int idx, int namelen, char *name_up);
219 extern int lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up,
220 int server, int testidx, int *index_p,
221 int *ndent_p, lstcon_node_ent_t *dents_up);
222 extern int lstcon_group_stat(char *grp_name, int timeout,
223 cfs_list_t *result_up);
224 extern int lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
225 int timeout, cfs_list_t *result_up);
226 extern int lstcon_test_add(char *name, int type, int loop, int concur,
227 int dist, int span, char *src_name, char * dst_name,
228 void *param, int paramlen, int *retp,
229 cfs_list_t *result_up);