Whamcloud - gitweb
aab2629e7ba1d8bb37e175c284547e859f46952c
[fs/lustre-release.git] / lnet / selftest / rpc.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
33 #ifndef __SELFTEST_RPC_H__
34 #define __SELFTEST_RPC_H__
35
36 #include <lnet/lnetst.h>
37
38 /*
39  * LST wired structures
40  * 
41  * XXX: *REPLY == *REQST + 1
42  */
43 typedef enum {
44         SRPC_MSG_MKSN_REQST     = 0,
45         SRPC_MSG_MKSN_REPLY     = 1,
46         SRPC_MSG_RMSN_REQST     = 2,
47         SRPC_MSG_RMSN_REPLY     = 3,
48         SRPC_MSG_BATCH_REQST    = 4,
49         SRPC_MSG_BATCH_REPLY    = 5,
50         SRPC_MSG_STAT_REQST     = 6,
51         SRPC_MSG_STAT_REPLY     = 7,
52         SRPC_MSG_TEST_REQST     = 8,
53         SRPC_MSG_TEST_REPLY     = 9,
54         SRPC_MSG_DEBUG_REQST    = 10,
55         SRPC_MSG_DEBUG_REPLY    = 11,
56         SRPC_MSG_BRW_REQST      = 12,
57         SRPC_MSG_BRW_REPLY      = 13,
58         SRPC_MSG_PING_REQST     = 14,
59         SRPC_MSG_PING_REPLY     = 15,
60         SRPC_MSG_JOIN_REQST     = 16,
61         SRPC_MSG_JOIN_REPLY     = 17,
62 } srpc_msg_type_t;
63
64 /* CAVEAT EMPTOR:
65  * All srpc_*_reqst_t's 1st field must be matchbits of reply buffer,
66  * and 2nd field matchbits of bulk buffer if any.
67  *
68  * All srpc_*_reply_t's 1st field must be a __u32 status, and 2nd field
69  * session id if needed.
70  */
71 typedef struct {
72         __u64                   rpyid;          /* reply buffer matchbits */
73         __u64                   bulkid;         /* bulk buffer matchbits */
74 } WIRE_ATTR srpc_generic_reqst_t;
75
76 typedef struct {
77         __u32                   status;
78         struct lst_sid               sid;
79 } WIRE_ATTR srpc_generic_reply_t;
80
81 /* FRAMEWORK RPCs */
82 typedef struct {
83         __u64                   mksn_rpyid;      /* reply buffer matchbits */
84         struct lst_sid               mksn_sid;        /* session id */
85         __u32                   mksn_force;      /* use brute force */
86         char                    mksn_name[LST_NAME_SIZE];
87 } WIRE_ATTR srpc_mksn_reqst_t;                  /* make session request */
88
89 typedef struct {
90         __u32                   mksn_status;      /* session status */
91         struct lst_sid               mksn_sid;         /* session id */
92         __u32                   mksn_timeout;     /* session timeout */
93         char                    mksn_name[LST_NAME_SIZE];
94 } WIRE_ATTR srpc_mksn_reply_t; /* make session reply */
95
96 typedef struct {
97         __u64                   rmsn_rpyid;      /* reply buffer matchbits */
98         struct lst_sid          rmsn_sid;        /* session id */
99 } WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */
100
101 typedef struct {
102         __u32                   rmsn_status;
103         struct lst_sid          rmsn_sid;        /* session id */
104 } WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */
105
106 typedef struct {
107         __u64                   join_rpyid;     /* reply buffer matchbits */
108         struct lst_sid               join_sid;       /* session id to join */
109         char                    join_group[LST_NAME_SIZE]; /* group name */
110 } WIRE_ATTR srpc_join_reqst_t;
111
112 typedef struct {
113         __u32                   join_status;    /* returned status */
114         struct lst_sid               join_sid;       /* session id */
115         __u32                   join_timeout;   /* # seconds' inactivity to expire */
116         char                    join_session[LST_NAME_SIZE]; /* session name */
117 } WIRE_ATTR srpc_join_reply_t;
118
119 typedef struct {
120         __u64                   dbg_rpyid;      /* reply buffer matchbits */ 
121         struct lst_sid               dbg_sid;        /* session id */
122         __u32                   dbg_flags;      /* bitmap of debug */
123 } WIRE_ATTR srpc_debug_reqst_t;
124
125 typedef struct {
126         __u32                   dbg_status;     /* returned code */
127         struct lst_sid               dbg_sid;        /* session id */
128         __u32                   dbg_timeout;    /* session timeout */
129         __u32                   dbg_nbatch;     /* # of batches in the node */
130         char                    dbg_name[LST_NAME_SIZE]; /* session name */
131 } WIRE_ATTR srpc_debug_reply_t;
132
133 #define SRPC_BATCH_OPC_RUN      1
134 #define SRPC_BATCH_OPC_STOP     2
135 #define SRPC_BATCH_OPC_QUERY    3
136
137 typedef struct {
138         __u64                   bar_rpyid;      /* reply buffer matchbits */ 
139         struct lst_sid               bar_sid;        /* session id */
140         struct lst_bid               bar_bid;        /* batch id */
141         __u32                   bar_opc;        /* create/start/stop batch */
142         __u32                   bar_testidx;    /* index of test */
143         __u32                   bar_arg;        /* parameters */
144 } WIRE_ATTR srpc_batch_reqst_t;
145
146 typedef struct {
147         __u32                   bar_status;     /* status of request */
148         struct lst_sid          bar_sid;        /* session id */
149         __u32                   bar_active;     /* # of active tests in batch/test */
150         __u32                   bar_time;       /* remained time */
151 } WIRE_ATTR srpc_batch_reply_t;
152
153 typedef struct {
154         __u64                   str_rpyid;      /* reply buffer matchbits */
155         struct lst_sid          str_sid;        /* session id */
156         __u32                   str_type;       /* type of stat */
157 } WIRE_ATTR srpc_stat_reqst_t;
158
159 typedef struct {
160         __u32                   str_status;
161         struct lst_sid          str_sid;
162         struct sfw_counters     str_fw;
163         struct srpc_counters    str_rpc;
164         struct lnet_counters    str_lnet;
165 } WIRE_ATTR srpc_stat_reply_t;
166
167 typedef struct {
168         __u32                   blk_opc;        /* bulk operation code */
169         __u32                   blk_npg;        /* # of pages */
170         __u32                   blk_flags;      /* reserved flags */
171 } WIRE_ATTR test_bulk_req_t;
172
173 typedef struct {
174         /** bulk operation code */
175         __u16                   blk_opc;
176         /** data check flags */
177         __u16                   blk_flags;
178         /** data length */
179         __u32                   blk_len;
180         /** bulk offset */
181         __u32                   blk_offset;
182 } WIRE_ATTR test_bulk_req_v1_t;
183
184 typedef struct {
185         __u32                   png_size;       /* size of ping message */
186         __u32                   png_flags;      /* reserved flags */
187 } WIRE_ATTR test_ping_req_t;
188
189 typedef struct {
190         __u64                   tsr_rpyid;      /* reply buffer matchbits */
191         __u64                   tsr_bulkid;     /* bulk buffer matchbits */
192         struct lst_sid          tsr_sid;        /* session id */
193         struct lst_bid          tsr_bid;        /* batch id */
194         __u32                   tsr_service;    /* test type: bulk|ping|... */
195         /* test client loop count or # server buffers needed */
196         __u32                   tsr_loop;
197         __u32                   tsr_concur;     /* concurrency of test */
198         __u8                    tsr_is_client;  /* is test client or not */
199         __u8                    tsr_stop_onerr; /* stop on error */
200         __u32                   tsr_ndest;      /* # of dest nodes */
201
202         union {
203                 test_ping_req_t         ping;
204                 test_bulk_req_t         bulk_v0;
205                 test_bulk_req_v1_t      bulk_v1;
206         }               tsr_u;
207 } WIRE_ATTR srpc_test_reqst_t;
208
209 typedef struct {
210         __u32                   tsr_status;     /* returned code */
211         struct lst_sid          tsr_sid;
212 } WIRE_ATTR srpc_test_reply_t;
213
214 /* TEST RPCs */
215 typedef struct {
216         __u64                   pnr_rpyid;
217         __u32                   pnr_magic;
218         __u32                   pnr_seq;
219         __u64                   pnr_time_sec;
220         __u64                   pnr_time_nsec;
221 } WIRE_ATTR srpc_ping_reqst_t;
222
223 typedef struct {
224         __u32                   pnr_status;
225         __u32                   pnr_magic;
226         __u32                   pnr_seq;
227 } WIRE_ATTR srpc_ping_reply_t;
228
229 typedef struct {
230         __u64                   brw_rpyid;      /* reply buffer matchbits */
231         __u64                   brw_bulkid;     /* bulk buffer matchbits */
232         __u32                   brw_rw;         /* read or write */
233         __u32                   brw_len;        /* bulk data len */
234         __u32                   brw_flags;      /* bulk data patterns */
235 } WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */
236
237 typedef struct {
238         __u32                   brw_status;
239 } WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */
240
241 #define SRPC_MSG_MAGIC                  0xeeb0f00d
242 #define SRPC_MSG_VERSION                1
243
244 typedef struct srpc_msg {
245         /** magic number */
246         __u32   msg_magic;
247         /** message version number */
248         __u32   msg_version;
249         /** type of message body: srpc_msg_type_t */
250         __u32   msg_type;
251         __u32   msg_reserved0;
252         __u32   msg_reserved1;
253         /** test session features */
254         __u32   msg_ses_feats;
255         union {
256                 srpc_generic_reqst_t reqst;
257                 srpc_generic_reply_t reply;
258
259                 srpc_mksn_reqst_t    mksn_reqst;
260                 srpc_mksn_reply_t    mksn_reply;
261                 srpc_rmsn_reqst_t    rmsn_reqst;
262                 srpc_rmsn_reply_t    rmsn_reply;
263                 srpc_debug_reqst_t   dbg_reqst;
264                 srpc_debug_reply_t   dbg_reply;
265                 srpc_batch_reqst_t   bat_reqst;
266                 srpc_batch_reply_t   bat_reply;
267                 srpc_stat_reqst_t    stat_reqst;
268                 srpc_stat_reply_t    stat_reply;
269                 srpc_test_reqst_t    tes_reqst;
270                 srpc_test_reply_t    tes_reply;
271                 srpc_join_reqst_t    join_reqst;
272                 srpc_join_reply_t    join_reply;
273
274                 srpc_ping_reqst_t    ping_reqst;
275                 srpc_ping_reply_t    ping_reply;
276                 srpc_brw_reqst_t     brw_reqst;
277                 srpc_brw_reply_t     brw_reply;
278         }     msg_body;
279 } WIRE_ATTR srpc_msg_t;
280
281 static inline void
282 srpc_unpack_msg_hdr(srpc_msg_t *msg)
283 {
284         if (msg->msg_magic == SRPC_MSG_MAGIC)
285                 return; /* no flipping needed */
286
287         /* We do not swap the magic number here as it is needed to
288            determine whether the body needs to be swapped. */
289         /* __swab32s(&msg->msg_magic); */
290         __swab32s(&msg->msg_type);
291         __swab32s(&msg->msg_version);
292         __swab32s(&msg->msg_ses_feats);
293         __swab32s(&msg->msg_reserved0);
294         __swab32s(&msg->msg_reserved1);
295 }
296
297 #endif /* __SELFTEST_RPC_H__ */