Whamcloud - gitweb
LU-445 lnet: Send timestamps with LNet counters
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36
37 #ifndef __SELFTEST_RPC_H__
38 #define __SELFTEST_RPC_H__
39
40 #include <lnet/lnetst.h>
41
42 /*
43  * LST wired structures
44  * 
45  * XXX: *REPLY == *REQST + 1
46  */
47 typedef enum {
48         SRPC_MSG_MKSN_REQST     = 0,
49         SRPC_MSG_MKSN_REPLY     = 1,
50         SRPC_MSG_RMSN_REQST     = 2,
51         SRPC_MSG_RMSN_REPLY     = 3,
52         SRPC_MSG_BATCH_REQST    = 4,
53         SRPC_MSG_BATCH_REPLY    = 5,
54         SRPC_MSG_STAT_REQST     = 6,
55         SRPC_MSG_STAT_REPLY     = 7,
56         SRPC_MSG_TEST_REQST     = 8,
57         SRPC_MSG_TEST_REPLY     = 9,
58         SRPC_MSG_DEBUG_REQST    = 10,
59         SRPC_MSG_DEBUG_REPLY    = 11,
60         SRPC_MSG_BRW_REQST      = 12,
61         SRPC_MSG_BRW_REPLY      = 13,
62         SRPC_MSG_PING_REQST     = 14,
63         SRPC_MSG_PING_REPLY     = 15,
64         SRPC_MSG_JOIN_REQST     = 16,
65         SRPC_MSG_JOIN_REPLY     = 17,
66 } srpc_msg_type_t;
67
68 #include <libcfs/libcfs_pack.h>
69
70 /* CAVEAT EMPTOR:
71  * All srpc_*_reqst_t's 1st field must be matchbits of reply buffer,
72  * and 2nd field matchbits of bulk buffer if any.
73  *
74  * All srpc_*_reply_t's 1st field must be a __u32 status, and 2nd field
75  * session id if needed.
76  */
77 typedef struct {
78         __u64                   rpyid;          /* reply buffer matchbits */
79         __u64                   bulkid;         /* bulk buffer matchbits */
80 } WIRE_ATTR srpc_generic_reqst_t;
81
82 typedef struct {
83         __u32                   status;
84         lst_sid_t               sid;
85 } WIRE_ATTR srpc_generic_reply_t;
86
87 /* FRAMEWORK RPCs */
88 typedef struct {
89         __u64                   mksn_rpyid;      /* reply buffer matchbits */
90         lst_sid_t               mksn_sid;        /* session id */
91         __u32                   mksn_force;      /* use brute force */
92         char                    mksn_name[LST_NAME_SIZE];
93 } WIRE_ATTR srpc_mksn_reqst_t;                  /* make session request */
94
95 typedef struct {
96         __u32                   mksn_status;      /* session status */
97         lst_sid_t               mksn_sid;         /* session id */
98         __u32                   mksn_timeout;     /* session timeout */
99         char                    mksn_name[LST_NAME_SIZE];
100 } WIRE_ATTR srpc_mksn_reply_t; /* make session reply */
101
102 typedef struct {
103         __u64                   rmsn_rpyid;      /* reply buffer matchbits */
104         lst_sid_t               rmsn_sid;        /* session id */
105 } WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */
106
107 typedef struct {
108         __u32                   rmsn_status;
109         lst_sid_t               rmsn_sid;        /* session id */
110 } WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */
111
112 typedef struct {
113         __u64                   join_rpyid;     /* reply buffer matchbits */
114         lst_sid_t               join_sid;       /* session id to join */
115         char                    join_group[LST_NAME_SIZE]; /* group name */
116 } WIRE_ATTR srpc_join_reqst_t;
117
118 typedef struct {
119         __u32                   join_status;    /* returned status */
120         lst_sid_t               join_sid;       /* session id */
121         __u32                   join_timeout;   /* # seconds' inactivity to expire */
122         char                    join_session[LST_NAME_SIZE]; /* session name */
123 } WIRE_ATTR srpc_join_reply_t;
124
125 typedef struct {
126         __u64                   dbg_rpyid;      /* reply buffer matchbits */ 
127         lst_sid_t               dbg_sid;        /* session id */
128         __u32                   dbg_flags;      /* bitmap of debug */
129 } WIRE_ATTR srpc_debug_reqst_t;
130
131 typedef struct {
132         __u32                   dbg_status;     /* returned code */
133         lst_sid_t               dbg_sid;        /* session id */
134         __u32                   dbg_timeout;    /* session timeout */
135         __u32                   dbg_nbatch;     /* # of batches in the node */
136         char                    dbg_name[LST_NAME_SIZE]; /* session name */
137 } WIRE_ATTR srpc_debug_reply_t;
138
139 #define SRPC_BATCH_OPC_RUN      1
140 #define SRPC_BATCH_OPC_STOP     2
141 #define SRPC_BATCH_OPC_QUERY    3
142
143 typedef struct {
144         __u64                   bar_rpyid;      /* reply buffer matchbits */ 
145         lst_sid_t               bar_sid;        /* session id */
146         lst_bid_t               bar_bid;        /* batch id */
147         __u32                   bar_opc;        /* create/start/stop batch */
148         __u32                   bar_testidx;    /* index of test */
149         __u32                   bar_arg;        /* parameters */
150 } WIRE_ATTR srpc_batch_reqst_t;
151
152 typedef struct {
153         __u32                   bar_status;     /* status of request */
154         lst_sid_t               bar_sid;        /* session id */
155         __u32                   bar_active;     /* # of active tests in batch/test */
156         __u32                   bar_time;       /* remained time */
157 } WIRE_ATTR srpc_batch_reply_t;
158
159 typedef struct {
160         __u64                   str_rpyid;      /* reply buffer matchbits */
161         lst_sid_t               str_sid;        /* session id */
162         __u32                   str_type;       /* type of stat */
163 } WIRE_ATTR srpc_stat_reqst_t;
164
165 typedef struct {
166         __u32                   str_status;
167         lst_sid_t               str_sid;
168         sfw_counters_t          str_fw;
169         srpc_counters_t         str_rpc;
170         lnet_counters_t         str_lnet;
171 } WIRE_ATTR srpc_stat_reply_t;
172
173 typedef struct {
174         __u32                   blk_opc;        /* bulk operation code */
175         __u32                   blk_npg;        /* # of pages */
176         __u32                   blk_flags;      /* reserved flags */
177 } WIRE_ATTR test_bulk_req_t;
178
179 typedef struct {
180         __u32                   png_size;       /* size of ping message */
181         __u32                   png_flags;      /* reserved flags */
182 } WIRE_ATTR test_ping_req_t;
183
184 typedef struct {
185         __u64                   tsr_rpyid;      /* reply buffer matchbits */
186         __u64                   tsr_bulkid;     /* bulk buffer matchbits */
187         lst_sid_t               tsr_sid;        /* session id */
188         lst_bid_t               tsr_bid;        /* batch id */
189         __u32                   tsr_service;    /* test type: bulk|ping|... */
190         /* test client loop count or # server buffers needed */
191         __u32                   tsr_loop;       
192         __u32                   tsr_concur;     /* concurrency of test */
193         __u8                    tsr_is_client;  /* is test client or not */
194         __u8                    tsr_stop_onerr; /* stop on error */
195         __u32                   tsr_ndest;      /* # of dest nodes */
196
197         union {
198                 test_bulk_req_t bulk;
199                 test_ping_req_t ping;
200         }                       tsr_u;
201 } WIRE_ATTR srpc_test_reqst_t;
202
203 typedef struct {
204         __u32                   tsr_status;     /* returned code */
205         lst_sid_t               tsr_sid;        
206 } WIRE_ATTR srpc_test_reply_t;
207
208 /* TEST RPCs */
209 typedef struct {
210         __u64                   pnr_rpyid;
211         __u32                   pnr_magic;
212         __u32                   pnr_seq;
213         __u64                   pnr_time_sec;
214         __u64                   pnr_time_usec;
215 } WIRE_ATTR srpc_ping_reqst_t;
216
217 typedef struct {
218         __u32                   pnr_status;
219         __u32                   pnr_magic;
220         __u32                   pnr_seq;
221 } WIRE_ATTR srpc_ping_reply_t;
222
223 typedef struct {
224         __u64                   brw_rpyid;      /* reply buffer matchbits */
225         __u64                   brw_bulkid;     /* bulk buffer matchbits */
226         __u32                   brw_rw;         /* read or write */
227         __u32                   brw_len;        /* bulk data len */
228         __u32                   brw_flags;      /* bulk data patterns */
229 } WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */
230
231 typedef struct {
232         __u32                   brw_status;
233 } WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */
234
235 #define SRPC_MSG_MAGIC                  0xeeb0f00d
236 #define SRPC_MSG_VERSION                1
237 typedef struct {
238         __u32   msg_magic;              /* magic */
239         __u32   msg_version;            /* # version */
240         __u32   msg_type;               /* what's in msg_body? srpc_msg_type_t */
241         __u32   msg_reserved0;          /* reserved seats */
242         __u32   msg_reserved1;
243         __u32   msg_reserved2;
244         union {
245                 srpc_generic_reqst_t reqst;
246                 srpc_generic_reply_t reply;
247
248                 srpc_mksn_reqst_t    mksn_reqst;
249                 srpc_mksn_reply_t    mksn_reply;
250                 srpc_rmsn_reqst_t    rmsn_reqst;
251                 srpc_rmsn_reply_t    rmsn_reply;
252                 srpc_debug_reqst_t   dbg_reqst;
253                 srpc_debug_reply_t   dbg_reply;
254                 srpc_batch_reqst_t   bat_reqst;
255                 srpc_batch_reply_t   bat_reply;
256                 srpc_stat_reqst_t    stat_reqst;
257                 srpc_stat_reply_t    stat_reply;
258                 srpc_test_reqst_t    tes_reqst;
259                 srpc_test_reply_t    tes_reply;
260                 srpc_join_reqst_t    join_reqst;
261                 srpc_join_reply_t    join_reply;
262
263                 srpc_ping_reqst_t    ping_reqst;
264                 srpc_ping_reply_t    ping_reply;
265                 srpc_brw_reqst_t     brw_reqst;
266                 srpc_brw_reply_t     brw_reply;
267         }     msg_body;
268 } WIRE_ATTR srpc_msg_t;
269
270 #include <libcfs/libcfs_unpack.h>
271
272 #endif /* __SELFTEST_RPC_H__ */