• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, 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 "../../include/linux/lnet/lnetst.h"
37 
38 /*
39  * LST wired structures
40  *
41  * XXX: *REPLY == *REQST + 1
42  */
43 enum srpc_msg_type {
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 };
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 struct srpc_generic_reqst {
72 	__u64			rpyid;		/* reply buffer matchbits */
73 	__u64			bulkid;		/* bulk buffer matchbits */
74 } WIRE_ATTR;
75 
76 struct srpc_generic_reply {
77 	__u32			status;
78 	lst_sid_t		sid;
79 } WIRE_ATTR;
80 
81 /* FRAMEWORK RPCs */
82 struct srpc_mksn_reqst {
83 	__u64			mksn_rpyid;	/* reply buffer matchbits */
84 	lst_sid_t		mksn_sid;	/* session id */
85 	__u32			mksn_force;	/* use brute force */
86 	char			mksn_name[LST_NAME_SIZE];
87 } WIRE_ATTR; /* make session request */
88 
89 struct srpc_mksn_reply {
90 	__u32			mksn_status;	/* session status */
91 	lst_sid_t		mksn_sid;	/* session id */
92 	__u32			mksn_timeout;	/* session timeout */
93 	char			mksn_name[LST_NAME_SIZE];
94 } WIRE_ATTR; /* make session reply */
95 
96 struct srpc_rmsn_reqst {
97 	__u64			rmsn_rpyid;	/* reply buffer matchbits */
98 	lst_sid_t		rmsn_sid;	/* session id */
99 } WIRE_ATTR; /* remove session request */
100 
101 struct srpc_rmsn_reply {
102 	__u32			rmsn_status;
103 	lst_sid_t		rmsn_sid;	/* session id */
104 } WIRE_ATTR; /* remove session reply */
105 
106 struct srpc_join_reqst {
107 	__u64			join_rpyid;	/* reply buffer matchbits */
108 	lst_sid_t		join_sid;	/* session id to join */
109 	char			join_group[LST_NAME_SIZE]; /* group name */
110 } WIRE_ATTR;
111 
112 struct srpc_join_reply {
113 	__u32			join_status;	/* returned status */
114 	lst_sid_t		join_sid;	/* session id */
115 	__u32			join_timeout;	/* # seconds' inactivity to
116 						 * expire */
117 	char			join_session[LST_NAME_SIZE]; /* session name */
118 } WIRE_ATTR;
119 
120 struct srpc_debug_reqst {
121 	__u64			dbg_rpyid;	/* reply buffer matchbits */
122 	lst_sid_t		dbg_sid;	/* session id */
123 	__u32			dbg_flags;	/* bitmap of debug */
124 } WIRE_ATTR;
125 
126 struct srpc_debug_reply {
127 	__u32			dbg_status;	/* returned code */
128 	lst_sid_t		dbg_sid;	/* session id */
129 	__u32			dbg_timeout;	/* session timeout */
130 	__u32			dbg_nbatch;	/* # of batches in the node */
131 	char			dbg_name[LST_NAME_SIZE]; /* session name */
132 } WIRE_ATTR;
133 
134 #define SRPC_BATCH_OPC_RUN	1
135 #define SRPC_BATCH_OPC_STOP	2
136 #define SRPC_BATCH_OPC_QUERY	3
137 
138 struct srpc_batch_reqst {
139 	__u64		   bar_rpyid;	   /* reply buffer matchbits */
140 	lst_sid_t	   bar_sid;	   /* session id */
141 	lst_bid_t	   bar_bid;	   /* batch id */
142 	__u32		   bar_opc;	   /* create/start/stop batch */
143 	__u32		   bar_testidx;    /* index of test */
144 	__u32		   bar_arg;	   /* parameters */
145 } WIRE_ATTR;
146 
147 struct srpc_batch_reply {
148 	__u32		   bar_status;	   /* status of request */
149 	lst_sid_t	   bar_sid;	   /* session id */
150 	__u32		   bar_active;	   /* # of active tests in batch/test */
151 	__u32		   bar_time;	   /* remained time */
152 } WIRE_ATTR;
153 
154 struct srpc_stat_reqst {
155 	__u64		   str_rpyid;	   /* reply buffer matchbits */
156 	lst_sid_t	   str_sid;	   /* session id */
157 	__u32		   str_type;	   /* type of stat */
158 } WIRE_ATTR;
159 
160 struct srpc_stat_reply {
161 	__u32		   str_status;
162 	lst_sid_t	   str_sid;
163 	sfw_counters_t	   str_fw;
164 	srpc_counters_t    str_rpc;
165 	lnet_counters_t    str_lnet;
166 } WIRE_ATTR;
167 
168 struct test_bulk_req {
169 	__u32		   blk_opc;	   /* bulk operation code */
170 	__u32		   blk_npg;	   /* # of pages */
171 	__u32		   blk_flags;	   /* reserved flags */
172 } WIRE_ATTR;
173 
174 struct test_bulk_req_v1 {
175 	__u16		   blk_opc;	   /* bulk operation code */
176 	__u16		   blk_flags;	   /* data check flags */
177 	__u32		   blk_len;	   /* data length */
178 	__u32		   blk_offset;	   /* reserved: offset */
179 } WIRE_ATTR;
180 
181 struct test_ping_req {
182 	__u32		   png_size;	   /* size of ping message */
183 	__u32		   png_flags;	   /* reserved flags */
184 } WIRE_ATTR;
185 
186 struct srpc_test_reqst {
187 	__u64			tsr_rpyid;	/* reply buffer matchbits */
188 	__u64			tsr_bulkid;	/* bulk buffer matchbits */
189 	lst_sid_t		tsr_sid;	/* session id */
190 	lst_bid_t		tsr_bid;	/* batch id */
191 	__u32			tsr_service;	/* test type: bulk|ping|... */
192 	__u32			tsr_loop;	/* test client loop count or
193 						 * # server buffers needed */
194 	__u32			tsr_concur;	/* concurrency of test */
195 	__u8			tsr_is_client;	/* is test client or not */
196 	__u8			tsr_stop_onerr; /* stop on error */
197 	__u32			tsr_ndest;	/* # of dest nodes */
198 
199 	union {
200 		struct test_ping_req	ping;
201 		struct test_bulk_req	bulk_v0;
202 		struct test_bulk_req_v1	bulk_v1;
203 	} tsr_u;
204 } WIRE_ATTR;
205 
206 struct srpc_test_reply {
207 	__u32			tsr_status;	/* returned code */
208 	lst_sid_t		tsr_sid;
209 } WIRE_ATTR;
210 
211 /* TEST RPCs */
212 struct srpc_ping_reqst {
213 	__u64		   pnr_rpyid;
214 	__u32		   pnr_magic;
215 	__u32		   pnr_seq;
216 	__u64		   pnr_time_sec;
217 	__u64		   pnr_time_usec;
218 } WIRE_ATTR;
219 
220 struct srpc_ping_reply {
221 	__u32		   pnr_status;
222 	__u32		   pnr_magic;
223 	__u32		   pnr_seq;
224 } WIRE_ATTR;
225 
226 struct srpc_brw_reqst {
227 	__u64		   brw_rpyid;	   /* reply buffer matchbits */
228 	__u64		   brw_bulkid;	   /* bulk buffer matchbits */
229 	__u32		   brw_rw;	   /* read or write */
230 	__u32		   brw_len;	   /* bulk data len */
231 	__u32		   brw_flags;	   /* bulk data patterns */
232 } WIRE_ATTR; /* bulk r/w request */
233 
234 struct srpc_brw_reply {
235 	__u32		   brw_status;
236 } WIRE_ATTR; /* bulk r/w reply */
237 
238 #define SRPC_MSG_MAGIC		0xeeb0f00d
239 #define SRPC_MSG_VERSION	1
240 
241 struct srpc_msg {
242 	__u32	msg_magic;     /* magic number */
243 	__u32	msg_version;   /* message version number */
244 	__u32	msg_type;      /* type of message body: srpc_msg_type */
245 	__u32	msg_reserved0;
246 	__u32	msg_reserved1;
247 	__u32	msg_ses_feats; /* test session features */
248 	union {
249 		struct srpc_generic_reqst	reqst;
250 		struct srpc_generic_reply	reply;
251 
252 		struct srpc_mksn_reqst		mksn_reqst;
253 		struct srpc_mksn_reply		mksn_reply;
254 		struct srpc_rmsn_reqst		rmsn_reqst;
255 		struct srpc_rmsn_reply		rmsn_reply;
256 		struct srpc_debug_reqst		dbg_reqst;
257 		struct srpc_debug_reply		dbg_reply;
258 		struct srpc_batch_reqst		bat_reqst;
259 		struct srpc_batch_reply		bat_reply;
260 		struct srpc_stat_reqst		stat_reqst;
261 		struct srpc_stat_reply		stat_reply;
262 		struct srpc_test_reqst		tes_reqst;
263 		struct srpc_test_reply		tes_reply;
264 		struct srpc_join_reqst		join_reqst;
265 		struct srpc_join_reply		join_reply;
266 
267 		struct srpc_ping_reqst		ping_reqst;
268 		struct srpc_ping_reply		ping_reply;
269 		struct srpc_brw_reqst		brw_reqst;
270 		struct srpc_brw_reply		brw_reply;
271 	}     msg_body;
272 } WIRE_ATTR;
273 
274 static inline void
srpc_unpack_msg_hdr(struct srpc_msg * msg)275 srpc_unpack_msg_hdr(struct srpc_msg *msg)
276 {
277 	if (msg->msg_magic == SRPC_MSG_MAGIC)
278 		return; /* no flipping needed */
279 
280 	/*
281 	 * We do not swap the magic number here as it is needed to
282 	 * determine whether the body needs to be swapped.
283 	 */
284 	/* __swab32s(&msg->msg_magic); */
285 	__swab32s(&msg->msg_type);
286 	__swab32s(&msg->msg_version);
287 	__swab32s(&msg->msg_ses_feats);
288 	__swab32s(&msg->msg_reserved0);
289 	__swab32s(&msg->msg_reserved1);
290 }
291 
292 #endif /* __SELFTEST_RPC_H__ */
293