Whamcloud - gitweb
i=liangzhen
[fs/lustre-release.git] / lnet / selftest / rpc.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #ifndef __SELFTEST_RPC_H__
5 #define __SELFTEST_RPC_H__
6
7 #include <lnet/lnetst.h>
8
9 /*
10  * LST wired structures
11  * 
12  * XXX: *REPLY == *REQST + 1
13  */
14 typedef enum {
15         SRPC_MSG_MKSN_REQST     = 0,
16         SRPC_MSG_MKSN_REPLY     = 1,
17         SRPC_MSG_RMSN_REQST     = 2,
18         SRPC_MSG_RMSN_REPLY     = 3,
19         SRPC_MSG_BATCH_REQST    = 4,
20         SRPC_MSG_BATCH_REPLY    = 5,
21         SRPC_MSG_STAT_REQST     = 6,
22         SRPC_MSG_STAT_REPLY     = 7,
23         SRPC_MSG_TEST_REQST     = 8,
24         SRPC_MSG_TEST_REPLY     = 9,
25         SRPC_MSG_DEBUG_REQST    = 10,
26         SRPC_MSG_DEBUG_REPLY    = 11,
27         SRPC_MSG_BRW_REQST      = 12,
28         SRPC_MSG_BRW_REPLY      = 13,
29         SRPC_MSG_PING_REQST     = 14,
30         SRPC_MSG_PING_REPLY     = 15,
31         SRPC_MSG_JOIN_REQST     = 16,
32         SRPC_MSG_JOIN_REPLY     = 17,
33 } srpc_msg_type_t;
34
35 /* CAVEAT EMPTOR:
36  * All srpc_*_reqst_t's 1st field must be matchbits of reply buffer,
37  * and 2nd field matchbits of bulk buffer if any.
38  *
39  * All srpc_*_reply_t's 1st field must be a __u32 status, and 2nd field
40  * session id if needed.
41  */
42 typedef struct {
43         __u64                   rpyid;          /* reply buffer matchbits */
44         __u64                   bulkid;         /* bulk buffer matchbits */
45 } WIRE_ATTR srpc_generic_reqst_t;
46
47 typedef struct {
48         __u32                   status;
49         lst_sid_t               sid;
50 } WIRE_ATTR srpc_generic_reply_t;
51
52 /* FRAMEWORK RPCs */
53 typedef struct {
54         __u64                   mksn_rpyid;      /* reply buffer matchbits */
55         lst_sid_t               mksn_sid;        /* session id */
56         __u32                   mksn_force;      /* use brute force */
57         char                    mksn_name[LST_NAME_SIZE];
58 } WIRE_ATTR srpc_mksn_reqst_t;                  /* make session request */
59
60 typedef struct {
61         __u32                   mksn_status;      /* session status */
62         lst_sid_t               mksn_sid;         /* session id */
63         __u32                   mksn_timeout;     /* session timeout */
64         char                    mksn_name[LST_NAME_SIZE];
65 } WIRE_ATTR srpc_mksn_reply_t; /* make session reply */
66
67 typedef struct {
68         __u64                   rmsn_rpyid;      /* reply buffer matchbits */
69         lst_sid_t               rmsn_sid;        /* session id */
70 } WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */
71
72 typedef struct {
73         __u32                   rmsn_status;
74         lst_sid_t               rmsn_sid;        /* session id */
75 } WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */
76
77 typedef struct {
78         __u64                   join_rpyid;     /* reply buffer matchbits */
79         lst_sid_t               join_sid;       /* session id to join */
80         char                    join_group[LST_NAME_SIZE]; /* group name */
81 } WIRE_ATTR srpc_join_reqst_t;
82
83 typedef struct {
84         __u32                   join_status;    /* returned status */
85         lst_sid_t               join_sid;       /* session id */
86         __u32                   join_timeout;   /* # seconds' inactivity to expire */
87         char                    join_session[LST_NAME_SIZE]; /* session name */
88 } WIRE_ATTR srpc_join_reply_t;
89
90 typedef struct {
91         __u64                   dbg_rpyid;      /* reply buffer matchbits */ 
92         lst_sid_t               dbg_sid;        /* session id */
93         __u32                   dbg_flags;      /* bitmap of debug */
94 } WIRE_ATTR srpc_debug_reqst_t;
95
96 typedef struct {
97         __u32                   dbg_status;     /* returned code */
98         lst_sid_t               dbg_sid;        /* session id */
99         __u32                   dbg_timeout;    /* session timeout */
100         __u32                   dbg_nbatch;     /* # of batches in the node */
101         char                    dbg_name[LST_NAME_SIZE]; /* session name */
102 } WIRE_ATTR srpc_debug_reply_t;
103
104 #define SRPC_BATCH_OPC_RUN      1
105 #define SRPC_BATCH_OPC_STOP     2
106 #define SRPC_BATCH_OPC_QUERY    3
107
108 typedef struct {
109         __u64                   bar_rpyid;      /* reply buffer matchbits */ 
110         lst_sid_t               bar_sid;        /* session id */
111         lst_bid_t               bar_bid;        /* batch id */
112         __u32                   bar_opc;        /* create/start/stop batch */
113         __u32                   bar_testidx;    /* index of test */
114         __u32                   bar_arg;        /* parameters */
115 } WIRE_ATTR srpc_batch_reqst_t;
116
117 typedef struct {
118         __u32                   bar_status;     /* status of request */
119         lst_sid_t               bar_sid;        /* session id */
120         __u32                   bar_active;     /* # of active tests in batch/test */
121         __u32                   bar_time;       /* remained time */
122 } WIRE_ATTR srpc_batch_reply_t;
123
124 typedef struct {
125         __u64                   str_rpyid;      /* reply buffer matchbits */
126         lst_sid_t               str_sid;        /* session id */
127         __u32                   str_type;       /* type of stat */
128 } WIRE_ATTR srpc_stat_reqst_t;
129
130 typedef struct {
131         __u32                   str_status;
132         lst_sid_t               str_sid;
133         sfw_counters_t          str_fw;
134         srpc_counters_t         str_rpc;
135         lnet_counters_t         str_lnet;
136 } WIRE_ATTR srpc_stat_reply_t;
137
138 typedef struct {
139         __u32                   blk_opc;        /* bulk operation code */
140         __u32                   blk_npg;        /* # of pages */
141         __u32                   blk_flags;      /* reserved flags */
142 } WIRE_ATTR test_bulk_req_t;
143
144 typedef struct {
145         __u32                   png_size;       /* size of ping message */
146         __u32                   png_flags;      /* reserved flags */
147 } WIRE_ATTR test_ping_req_t;
148
149 typedef struct {
150         __u64                   tsr_rpyid;      /* reply buffer matchbits */
151         __u64                   tsr_bulkid;     /* bulk buffer matchbits */
152         lst_sid_t               tsr_sid;        /* session id */
153         lst_bid_t               tsr_bid;        /* batch id */
154         __u32                   tsr_service;    /* test type: bulk|ping|... */
155         /* test client loop count or # server buffers needed */
156         __u32                   tsr_loop;       
157         __u32                   tsr_concur;     /* concurrency of test */
158         __u8                    tsr_is_client;  /* is test client or not */
159         __u8                    tsr_stop_onerr; /* stop on error */
160         __u32                   tsr_ndest;      /* # of dest nodes */
161
162         union {
163                 test_bulk_req_t bulk;
164                 test_ping_req_t ping;
165         }                       tsr_u;
166 } WIRE_ATTR srpc_test_reqst_t;
167
168 typedef struct {
169         __u32                   tsr_status;     /* returned code */
170         lst_sid_t               tsr_sid;        
171 } WIRE_ATTR srpc_test_reply_t;
172
173 /* TEST RPCs */
174 typedef struct {
175         __u64                   pnr_rpyid;
176         __u32                   pnr_magic;
177         __u32                   pnr_seq;
178         __u64                   pnr_time_sec;
179         __u64                   pnr_time_usec;
180 } WIRE_ATTR srpc_ping_reqst_t;
181
182 typedef struct {
183         __u32                   pnr_status;
184         __u32                   pnr_magic;
185         __u32                   pnr_seq;
186 } WIRE_ATTR srpc_ping_reply_t;
187
188 typedef struct {
189         __u64                   brw_rpyid;      /* reply buffer matchbits */
190         __u64                   brw_bulkid;     /* bulk buffer matchbits */
191         __u32                   brw_rw;         /* read or write */
192         __u32                   brw_len;        /* bulk data len */
193         __u32                   brw_flags;      /* bulk data patterns */
194 } WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */
195
196 typedef struct {
197         __u32                   brw_status;
198 } WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */
199
200 #define SRPC_MSG_MAGIC                  0xeeb0f00d
201 #define SRPC_MSG_VERSION                1
202 typedef struct {
203         __u32   msg_magic;              /* magic */
204         __u32   msg_version;            /* # version */
205         __u32   msg_type;               /* what's in msg_body? srpc_msg_type_t */
206         __u32   msg_reserved0;          /* reserved seats */
207         __u32   msg_reserved1;
208         __u32   msg_reserved2;
209         union {
210                 srpc_generic_reqst_t reqst;
211                 srpc_generic_reply_t reply;
212
213                 srpc_mksn_reqst_t    mksn_reqst;
214                 srpc_mksn_reply_t    mksn_reply;
215                 srpc_rmsn_reqst_t    rmsn_reqst;
216                 srpc_rmsn_reply_t    rmsn_reply;
217                 srpc_debug_reqst_t   dbg_reqst;
218                 srpc_debug_reply_t   dbg_reply;
219                 srpc_batch_reqst_t   bat_reqst;
220                 srpc_batch_reply_t   bat_reply;
221                 srpc_stat_reqst_t    stat_reqst;
222                 srpc_stat_reply_t    stat_reply;
223                 srpc_test_reqst_t    tes_reqst;
224                 srpc_test_reply_t    tes_reply;
225                 srpc_join_reqst_t    join_reqst;
226                 srpc_join_reply_t    join_reply;
227
228                 srpc_ping_reqst_t    ping_reqst;
229                 srpc_ping_reply_t    ping_reply;
230                 srpc_brw_reqst_t     brw_reqst;
231                 srpc_brw_reply_t     brw_reply;
232         }     msg_body;
233 } WIRE_ATTR srpc_msg_t;
234
235 #endif /* __SELFTEST_RPC_H__ */