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