Whamcloud - gitweb
LU-14487 lnet: remove references to Sun Trademark.
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnetst.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2016, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * Author: Liang Zhen <liangzhen@clusterfs.com>
32  */
33
34 #ifndef __UAPI_LNET_ST_H__
35 #define __UAPI_LNET_ST_H__
36
37 #include <linux/types.h>
38 #include <linux/lnet/lnet-types.h>
39 #include <linux/time.h>
40
41 #define LST_FEAT_NONE           (0)
42 #define LST_FEAT_BULK_LEN       (1 << 0)        /* enable variable page size */
43
44 #define LST_FEATS_EMPTY         (LST_FEAT_NONE)
45 #define LST_FEATS_MASK          (LST_FEAT_NONE | LST_FEAT_BULK_LEN)
46
47 #define LST_NAME_SIZE           32              /* max name buffer length */
48
49 #define LSTIO_DEBUG             0xC00           /* debug */
50 #define LSTIO_SESSION_NEW       0xC01           /* create session */
51 #define LSTIO_SESSION_END       0xC02           /* end session */
52 #define LSTIO_SESSION_INFO      0xC03           /* query session */
53 #define LSTIO_GROUP_ADD         0xC10           /* add group */
54 #define LSTIO_GROUP_LIST        0xC11           /* list all groups in session */
55 #define LSTIO_GROUP_INFO        0xC12           /* query defailt infomation of specified group */
56 #define LSTIO_GROUP_DEL         0xC13           /* delete group */
57 #define LSTIO_NODES_ADD         0xC14           /* add nodes to specified group */
58 #define LSTIO_GROUP_UPDATE      0xC15           /* update group */
59 #define LSTIO_BATCH_ADD         0xC20           /* add batch */
60 #define LSTIO_BATCH_START       0xC21           /* start batch */
61 #define LSTIO_BATCH_STOP        0xC22           /* stop batch */
62 #define LSTIO_BATCH_DEL         0xC23           /* delete batch */
63 #define LSTIO_BATCH_LIST        0xC24           /* show all batches in the session */
64 #define LSTIO_BATCH_INFO        0xC25           /* show defail of specified batch */
65 #define LSTIO_TEST_ADD          0xC26           /* add test (to batch) */
66 #define LSTIO_BATCH_QUERY       0xC27           /* query batch status */
67 #define LSTIO_STAT_QUERY        0xC30           /* get stats */
68
69 /*
70  * sparse kernel source annotations
71  */
72 #ifndef __user
73 #define __user
74 #endif
75
76 struct lst_sid {
77         lnet_nid_t      ses_nid;        /* nid of console node */
78         __s64           ses_stamp;      /* time stamp in milliseconds */
79 };                                      /*** session id */
80
81 extern struct lst_sid LST_INVALID_SID;
82
83 struct lst_bid {
84         __u64           bat_id;         /* unique id in session */
85 };
86
87 /* Status of test node */
88 #define LST_NODE_ACTIVE         0x1     /* node in this session */
89 #define LST_NODE_BUSY           0x2     /* node is taken by other session */
90 #define LST_NODE_DOWN           0x4     /* node is down */
91 #define LST_NODE_UNKNOWN        0x8     /* node not in session */
92
93 struct lstcon_node_ent {
94         struct lnet_process_id  nde_id;         /* id of node */
95         int                     nde_state;      /* state of node */
96 };                                              /*** node entry, for list_group command */
97
98 struct lstcon_ndlist_ent {
99         int     nle_nnode;      /* # of nodes */
100         int     nle_nactive;    /* # of active nodes */
101         int     nle_nbusy;      /* # of busy nodes */
102         int     nle_ndown;      /* # of down nodes */
103         int     nle_nunknown;   /* # of unknown nodes */
104 };                              /*** node_list entry, for list_batch command */
105
106 struct lstcon_test_ent {
107         int     tse_type;       /* test type */
108         int     tse_loop;       /* loop count */
109         int     tse_concur;     /* concurrency of test */
110 };                              /*** test summary entry, for list_batch command */
111
112 struct lstcon_batch_ent {
113         int     bae_state;      /* batch status */
114         int     bae_timeout;    /* batch timeout */
115         int     bae_ntest;      /* # of tests in the batch */
116 };                              /*** batch summary entry, for list_batch command */
117
118 struct lstcon_test_batch_ent {
119         struct lstcon_ndlist_ent        tbe_cli_nle;    /* client (group) node_list entry */
120         struct lstcon_ndlist_ent        tbe_srv_nle;    /* server (group) node_list entry */
121         union {
122                 struct lstcon_test_ent  tbe_test;       /* test entry */
123                 struct lstcon_batch_ent tbe_batch;      /* batch entry */
124         } u;
125 };                                                      /*** test/batch verbose information entry,
126                                                          *** for list_batch command */
127
128 /* This will go away once we move to netlink */
129 #if !defined(__KERNEL__) && !defined(__LIBCFS_UTIL_LIST_H__)
130 struct list_head {
131         struct list_head *next, *prev;
132 };
133 #endif
134
135 struct lstcon_rpc_ent {
136         struct list_head        rpe_link;               /* link chain */
137         struct lnet_process_id  rpe_peer;               /* peer's id */
138         /* This has not been used since Lustre 2.2 so its safe to use.
139          * Update to allow future use of timespec64
140          */
141         struct {
142                 __s64           tv_sec;
143                 __s64           tv_nsec;
144         } rpe_stamp;                                    /* time stamp of RPC */
145         int                     rpe_state;              /* peer's state */
146         int                     rpe_rpc_errno;          /* RPC errno */
147
148         struct lst_sid          rpe_sid;                /* peer's session id */
149         int                     rpe_fwk_errno;          /* framework errno */
150         int                     rpe_priv[4];            /* private data */
151         char                    rpe_payload[0];         /* private reply payload */
152 };
153
154 struct lstcon_trans_stat {
155         int     trs_rpc_stat[4];        /* RPCs stat (0: total, 1: failed, 2: finished, 4: reserved */
156         int     trs_rpc_errno;          /* RPC errno */
157         int     trs_fwk_stat[8];        /* framework stat */
158         int     trs_fwk_errno;          /* errno of the first remote error */
159         void   *trs_fwk_private;        /* private framework stat */
160 };
161
162 static inline int
163 lstcon_rpc_stat_total(struct lstcon_trans_stat *stat, int inc)
164 {
165         return inc ? ++stat->trs_rpc_stat[0] : stat->trs_rpc_stat[0];
166 }
167
168 static inline int
169 lstcon_rpc_stat_success(struct lstcon_trans_stat *stat, int inc)
170 {
171         return inc ? ++stat->trs_rpc_stat[1] : stat->trs_rpc_stat[1];
172 }
173
174 static inline int
175 lstcon_rpc_stat_failure(struct lstcon_trans_stat *stat, int inc)
176 {
177         return inc ? ++stat->trs_rpc_stat[2] : stat->trs_rpc_stat[2];
178 }
179
180 static inline int
181 lstcon_sesop_stat_success(struct lstcon_trans_stat *stat, int inc)
182 {
183         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
184 }
185
186 static inline int
187 lstcon_sesop_stat_failure(struct lstcon_trans_stat *stat, int inc)
188 {
189         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
190 }
191
192 static inline int
193 lstcon_sesqry_stat_active(struct lstcon_trans_stat *stat, int inc)
194 {
195         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
196 }
197
198 static inline int
199 lstcon_sesqry_stat_busy(struct lstcon_trans_stat *stat, int inc)
200 {
201         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
202 }
203
204 static inline int
205 lstcon_sesqry_stat_unknown(struct lstcon_trans_stat *stat, int inc)
206 {
207         return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2];
208 }
209
210 static inline int
211 lstcon_tsbop_stat_success(struct lstcon_trans_stat *stat, int inc)
212 {
213         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
214 }
215
216 static inline int
217 lstcon_tsbop_stat_failure(struct lstcon_trans_stat *stat, int inc)
218 {
219         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
220 }
221
222 static inline int
223 lstcon_tsbqry_stat_idle(struct lstcon_trans_stat *stat, int inc)
224 {
225         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
226 }
227
228 static inline int
229 lstcon_tsbqry_stat_run(struct lstcon_trans_stat *stat, int inc)
230 {
231         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
232 }
233
234 static inline int
235 lstcon_tsbqry_stat_failure(struct lstcon_trans_stat *stat, int inc)
236 {
237         return inc ? ++stat->trs_fwk_stat[2] : stat->trs_fwk_stat[2];
238 }
239
240 static inline int
241 lstcon_statqry_stat_success(struct lstcon_trans_stat *stat, int inc)
242 {
243         return inc ? ++stat->trs_fwk_stat[0] : stat->trs_fwk_stat[0];
244 }
245
246 static inline int
247 lstcon_statqry_stat_failure(struct lstcon_trans_stat *stat, int inc)
248 {
249         return inc ? ++stat->trs_fwk_stat[1] : stat->trs_fwk_stat[1];
250 }
251
252 /* create a session */
253 struct lstio_session_new_args {
254         int                     lstio_ses_key;          /* IN: local key */
255         int                     lstio_ses_timeout;      /* IN: session timeout */
256         int                     lstio_ses_force;        /* IN: force create ? */
257         /** IN: session features */
258         unsigned                lstio_ses_feats;
259         struct lst_sid __user  *lstio_ses_idp;          /* OUT: session id */
260         int                     lstio_ses_nmlen;        /* IN: name length */
261         char __user            *lstio_ses_namep;        /* IN: session name */
262 };
263
264 /* query current session */
265 struct lstio_session_info_args {
266         struct lst_sid __user   *lstio_ses_idp;         /* OUT: session id */
267         int __user              *lstio_ses_keyp;        /* OUT: local key */
268         /** OUT: session features */
269         unsigned __user         *lstio_ses_featp;
270         struct lstcon_ndlist_ent __user *lstio_ses_ndinfo; /* OUT: */
271         int                      lstio_ses_nmlen;       /* IN: name length */
272         char __user             *lstio_ses_namep;       /* OUT: session name */
273 };
274
275 /* delete a session */
276 struct lstio_session_end_args {
277         int                     lstio_ses_key;          /* IN: session key */
278 };
279
280 #define LST_OPC_SESSION         1
281 #define LST_OPC_GROUP           2
282 #define LST_OPC_NODES           3
283 #define LST_OPC_BATCHCLI        4
284 #define LST_OPC_BATCHSRV        5
285
286 struct lstio_debug_args {
287         int                     lstio_dbg_key;          /* IN: session key */
288         int                     lstio_dbg_type;         /* IN: debug sessin|batch|group|nodes list */
289         int                     lstio_dbg_flags;        /* IN: reserved debug flags */
290         int                     lstio_dbg_timeout;      /* IN: timeout of debug */
291
292         int                     lstio_dbg_nmlen;        /* IN: len of name */
293         char __user            *lstio_dbg_namep;        /* IN: name of group|batch */
294         int                     lstio_dbg_count;        /* IN: # of test nodes to debug */
295         struct lnet_process_id __user *lstio_dbg_idsp;  /* IN: id of test nodes */
296         /* OUT: list head of result buffer */
297         struct list_head __user *lstio_dbg_resultp;
298 };
299
300 struct lstio_group_add_args {
301         int                     lstio_grp_key;          /* IN: session key */
302         int                     lstio_grp_nmlen;        /* IN: name length */
303         char __user            *lstio_grp_namep;        /* IN: group name */
304 };
305
306 struct lstio_group_del_args {
307         int                     lstio_grp_key;          /* IN: session key */
308         int                     lstio_grp_nmlen;        /* IN: name length */
309         char __user            *lstio_grp_namep;        /* IN: group name */
310 };
311
312 #define LST_GROUP_CLEAN         1                       /* remove inactive nodes in the group */
313 #define LST_GROUP_REFRESH       2                       /* refresh inactive nodes in the group */
314 #define LST_GROUP_RMND          3                       /* delete nodes from the group */
315
316 struct lstio_group_update_args {
317         int                     lstio_grp_key;          /* IN: session key */
318         int                     lstio_grp_opc;          /* IN: OPC */
319         int                     lstio_grp_args;         /* IN: arguments */
320         int                     lstio_grp_nmlen;        /* IN: name length */
321         char __user            *lstio_grp_namep;        /* IN: group name */
322         int                     lstio_grp_count;        /* IN: # of nodes id */
323         struct lnet_process_id __user *lstio_grp_idsp;  /* IN: array of nodes */
324         /* OUT: list head of result buffer */
325         struct list_head __user *lstio_grp_resultp;
326 };
327
328 struct lstio_group_nodes_args {
329         int                      lstio_grp_key;         /* IN: session key */
330         int                      lstio_grp_nmlen;       /* IN: name length */
331         char __user             *lstio_grp_namep;       /* IN: group name */
332         int                      lstio_grp_count;       /* IN: # of nodes */
333         /** OUT: session features */
334         unsigned __user         *lstio_grp_featp;
335         struct lnet_process_id __user *lstio_grp_idsp;  /* IN: nodes */
336         /* OUT: list head of result buffer */
337         struct list_head __user *lstio_grp_resultp;
338 };
339
340 struct lstio_group_list_args {
341         int                     lstio_grp_key;          /* IN: session key */
342         int                     lstio_grp_idx;          /* IN: group idx */
343         int                     lstio_grp_nmlen;        /* IN: name len */
344         char __user            *lstio_grp_namep;        /* OUT: name */
345 };
346
347 struct lstio_group_info_args {
348         int                     lstio_grp_key;          /* IN: session key */
349         int                     lstio_grp_nmlen;        /* IN: name len */
350         char __user            *lstio_grp_namep;        /* IN: name */
351         struct lstcon_ndlist_ent __user *lstio_grp_entp;/* OUT: description of group */
352
353         int __user             *lstio_grp_idxp;         /* IN/OUT: node index */
354         int __user             *lstio_grp_ndentp;       /* IN/OUT: # of nodent */
355         struct lstcon_node_ent __user *lstio_grp_dentsp;/* OUT: nodent array */
356 };
357
358 #define LST_DEFAULT_BATCH       "batch"                 /* default batch name */
359
360 struct lstio_batch_add_args {
361         int                     lstio_bat_key;          /* IN: session key */
362         int                     lstio_bat_nmlen;        /* IN: name length */
363         char __user            *lstio_bat_namep;        /* IN: batch name */
364 };
365
366 struct lstio_batch_del_args {
367         int                     lstio_bat_key;          /* IN: session key */
368         int                     lstio_bat_nmlen;        /* IN: name length */
369         char __user            *lstio_bat_namep;        /* IN: batch name */
370 };
371
372 struct lstio_batch_run_args {
373         /* IN: session key */
374         int                      lstio_bat_key;
375         /* IN: timeout for the batch */
376         int                      lstio_bat_timeout;
377         /* IN: name length */
378         int                      lstio_bat_nmlen;
379         /* IN: batch name */
380         char __user             *lstio_bat_namep;
381         /* OUT: list head of result buffer */
382         struct list_head __user *lstio_bat_resultp;
383 };
384
385 struct lstio_batch_stop_args {
386         /* IN: session key */
387         int                      lstio_bat_key;
388         /* IN: abort unfinished test RPC */
389         int                      lstio_bat_force;
390         /* IN: name length */
391         int                      lstio_bat_nmlen;
392         /* IN: batch name */
393         char __user             *lstio_bat_namep;
394         /* OUT: list head of result buffer */
395         struct list_head __user *lstio_bat_resultp;
396 };
397
398 struct lstio_batch_query_args {
399         /* IN: session key */
400         int                     lstio_bat_key;
401         /* IN: test index */
402         int                     lstio_bat_testidx;
403         /* IN: is test client? */
404         int                     lstio_bat_client;
405         /* IN: timeout for waiting */
406         int                     lstio_bat_timeout;
407         /* IN: name length */
408         int                     lstio_bat_nmlen;
409         /* IN: batch name */
410         char __user             *lstio_bat_namep;
411         /* OUT: list head of result buffer */
412         struct list_head __user *lstio_bat_resultp;
413 };
414
415 struct lstio_batch_list_args {
416         int                     lstio_bat_key;          /* IN: session key */
417         int                     lstio_bat_idx;          /* IN: index */
418         int                     lstio_bat_nmlen;        /* IN: name length */
419         char __user            *lstio_bat_namep;        /* IN: batch name */
420 };
421
422 struct lstio_batch_info_args {
423         int                     lstio_bat_key;          /* IN: session key */
424         int                     lstio_bat_nmlen;        /* IN: name length */
425         char __user            *lstio_bat_namep;        /* IN: name */
426         int                     lstio_bat_server;       /* IN: query server or not */
427         int                     lstio_bat_testidx;      /* IN: test index */
428         struct lstcon_test_batch_ent __user *lstio_bat_entp;/* OUT: batch ent */
429
430         int __user             *lstio_bat_idxp;         /* IN/OUT: index of node */
431         int __user             *lstio_bat_ndentp;       /* IN/OUT: # of nodent */
432         struct lstcon_node_ent __user *lstio_bat_dentsp;/* array of nodent */
433 };
434
435 /* add stat in session */
436 struct lstio_stat_args {
437         /* IN: session key */
438         int                     lstio_sta_key;
439         /* IN: timeout for stat requst */
440         int                     lstio_sta_timeout;
441         /* IN: group name length */
442         int                     lstio_sta_nmlen;
443         /* IN: group name */
444         char __user            *lstio_sta_namep;
445         /* IN: # of pid */
446         int                     lstio_sta_count;
447         /* IN: pid */
448         struct lnet_process_id __user *lstio_sta_idsp;
449         /* OUT: list head of result buffer */
450         struct list_head __user *lstio_sta_resultp;
451 };
452
453 enum lst_test_type {
454         LST_TEST_BULK   = 1,
455         LST_TEST_PING   = 2
456 };
457
458 /* create a test in a batch */
459 #define LST_MAX_CONCUR          1024                    /* Max concurrency of test */
460
461 struct lstio_test_args {
462         int                     lstio_tes_key;          /* IN: session key */
463         int                     lstio_tes_bat_nmlen;    /* IN: batch name len */
464         char __user            *lstio_tes_bat_name;     /* IN: batch name */
465         int                     lstio_tes_type;         /* IN: test type */
466         int                     lstio_tes_oneside;      /* IN: one sided test */
467         int                     lstio_tes_loop;         /* IN: loop count */
468         int                     lstio_tes_concur;       /* IN: concurrency */
469
470         int                     lstio_tes_dist;         /* IN: node distribution in destination groups */
471         int                     lstio_tes_span;         /* IN: node span in destination groups */
472         int                     lstio_tes_sgrp_nmlen;   /* IN: source group name length */
473         char __user            *lstio_tes_sgrp_name;    /* IN: group name */
474         int                     lstio_tes_dgrp_nmlen;   /* IN: destination group name length */
475         char __user            *lstio_tes_dgrp_name;    /* IN: group name */
476
477         /* IN: param buffer len */
478         int                      lstio_tes_param_len;
479         /* IN: parameter for specified test:
480                lstio_bulk_param_t,
481                lstio_ping_param_t,
482                ... more */
483         void __user             *lstio_tes_param;
484         /* OUT: private returned value */
485         int __user              *lstio_tes_retp;
486         /* OUT: list head of result buffer */
487         struct list_head __user *lstio_tes_resultp;
488 };
489
490 enum lst_brw_type {
491         LST_BRW_READ    = 1,
492         LST_BRW_WRITE   = 2
493 };
494
495 enum lst_brw_flags {
496         LST_BRW_CHECK_NONE   = 1,
497         LST_BRW_CHECK_SIMPLE = 2,
498         LST_BRW_CHECK_FULL   = 3
499 };
500
501 struct lst_test_bulk_param {
502         int blk_opc;            /* bulk operation code */
503         int blk_size;           /* size (bytes) */
504         int blk_time;           /* time of running the test*/
505         int blk_flags;          /* reserved flags */
506         int blk_cli_off;        /* bulk offset on client */
507         int blk_srv_off;        /* reserved: bulk offset on server */
508 };
509
510 struct lst_test_ping_param {
511         int png_size;           /* size of ping message */
512         int png_time;           /* time */
513         int png_loop;           /* loop */
514         int png_flags;          /* reserved flags */
515 };
516
517 /* Both struct srpc_counters and struct sfw_counters are sent over the wire */
518 struct srpc_counters {
519         __u32 errors;
520         __u32 rpcs_sent;
521         __u32 rpcs_rcvd;
522         __u32 rpcs_dropped;
523         __u32 rpcs_expired;
524         __u64 bulk_get;
525         __u64 bulk_put;
526 } __attribute__((packed));
527
528 struct sfw_counters {
529         /** milliseconds since current session started */
530         __u32 running_ms;
531         __u32 active_batches;
532         __u32 zombie_sessions;
533         __u32 brw_errors;
534         __u32 ping_errors;
535 } __attribute__((packed));
536
537 #endif