Whamcloud - gitweb
LU-7902 osd: no need to set same [acm]time
[fs/lustre-release.git] / lnet / selftest / conrpc.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.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
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
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, 2013, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * /lnet/selftest/conrpc.h
37  *
38  * Console rpc
39  *
40  * Author: Liang Zhen <liang@whamcloud.com>
41  */
42
43 #ifndef __LST_CONRPC_H__
44 #define __LST_CONRPC_H__
45
46 #include <libcfs/libcfs.h>
47 #include <lnet/lnet.h>
48 #include <lnet/lib-types.h>
49 #include <lnet/lnetst.h>
50 #include "rpc.h"
51 #include "selftest.h"
52
53 /* Console rpc and rpc transaction */
54 #define LST_TRANS_TIMEOUT       30
55 #define LST_TRANS_MIN_TIMEOUT   3
56
57 #define LST_VALIDATE_TIMEOUT(t) MIN(MAX(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
58
59 #define LST_PING_INTERVAL       8
60
61 struct lstcon_rpc_trans;
62 struct lstcon_tsb_hdr;
63 struct lstcon_test;
64 struct lstcon_node;
65
66 typedef struct lstcon_rpc {
67         struct list_head         crp_link;      /* chain on rpc transaction */
68         srpc_client_rpc_t       *crp_rpc;       /* client rpc */
69         struct lstcon_node      *crp_node;      /* destination node */
70         struct lstcon_rpc_trans *crp_trans;     /* conrpc transaction */
71
72         unsigned int             crp_posted:1;   /* rpc is posted */
73         unsigned int             crp_finished:1; /* rpc is finished */
74         unsigned int             crp_unpacked:1; /* reply is unpacked */
75         /** RPC is embedded in other structure and can't free it */
76         unsigned int             crp_embedded:1;
77         int                      crp_status;     /* console rpc errors */
78         cfs_time_t               crp_stamp;      /* replied time stamp */
79 } lstcon_rpc_t;
80
81 typedef struct lstcon_rpc_trans {
82         /* link chain on owner list */
83         struct list_head        tas_olink;
84         /* link chain on global list */
85         struct list_head        tas_link;
86         /* operation code of transaction */
87         int                     tas_opc;
88         /* features mask is uptodate */
89         unsigned                tas_feats_updated;
90         /* test features mask */
91         unsigned                tas_features;
92         wait_queue_head_t       tas_waitq;      /* wait queue head */
93         atomic_t                tas_remaining;  /* # of un-scheduled rpcs */
94         struct list_head        tas_rpcs_list;  /* queued requests */
95 } lstcon_rpc_trans_t;
96
97 #define LST_TRANS_PRIVATE       0x1000
98
99 #define LST_TRANS_SESNEW        (LST_TRANS_PRIVATE | 0x01)
100 #define LST_TRANS_SESEND        (LST_TRANS_PRIVATE | 0x02)
101 #define LST_TRANS_SESQRY        0x03
102 #define LST_TRANS_SESPING       0x04
103
104 #define LST_TRANS_TSBCLIADD     (LST_TRANS_PRIVATE | 0x11)
105 #define LST_TRANS_TSBSRVADD     (LST_TRANS_PRIVATE | 0x12)
106 #define LST_TRANS_TSBRUN        (LST_TRANS_PRIVATE | 0x13)
107 #define LST_TRANS_TSBSTOP       (LST_TRANS_PRIVATE | 0x14)
108 #define LST_TRANS_TSBCLIQRY     0x15
109 #define LST_TRANS_TSBSRVQRY     0x16
110
111 #define LST_TRANS_STATQRY       0x21
112
113 typedef int (* lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
114 typedef int (*lstcon_rpc_readent_func_t)(int, srpc_msg_t *,
115                                          lstcon_rpc_ent_t __user *);
116
117 int  lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
118                         unsigned version, lstcon_rpc_t **crpc);
119 int  lstcon_dbgrpc_prep(struct lstcon_node *nd,
120                         unsigned version, lstcon_rpc_t **crpc);
121 int  lstcon_batrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
122                         struct lstcon_tsb_hdr *tsb, lstcon_rpc_t **crpc);
123 int  lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
124                          struct lstcon_test *test, lstcon_rpc_t **crpc);
125 int  lstcon_statrpc_prep(struct lstcon_node *nd, unsigned version,
126                          lstcon_rpc_t **crpc);
127 void lstcon_rpc_put(lstcon_rpc_t *crpc);
128 int  lstcon_rpc_trans_prep(struct list_head *translist,
129                            int transop, lstcon_rpc_trans_t **transpp);
130 int  lstcon_rpc_trans_ndlist(struct list_head *ndlist,
131                              struct list_head *translist, int transop,
132                              void *arg, lstcon_rpc_cond_func_t condition,
133                              lstcon_rpc_trans_t **transpp);
134 void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans,
135                            lstcon_trans_stat_t *stat);
136 int  lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
137                                   struct list_head __user *head_up,
138                                   lstcon_rpc_readent_func_t readent);
139 void lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error);
140 void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans);
141 void lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *req);
142 int  lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout);
143 int  lstcon_rpc_pinger_start(void);
144 void lstcon_rpc_pinger_stop(void);
145 void lstcon_rpc_cleanup_wait(void);
146 int  lstcon_rpc_module_init(void);
147 void lstcon_rpc_module_fini(void);
148
149
150 #endif