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