4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * lnet/selftest/selftest.h
33 * Author: Isaac Huang <isaac@clusterfs.com>
35 #ifndef __SELFTEST_SELFTEST_H__
36 #define __SELFTEST_SELFTEST_H__
40 #include <libcfs/libcfs.h>
42 #include <lnet/lib-lnet.h>
43 #include <lnet/lib-types.h>
44 #include <uapi/linux/lnet/lnetst.h>
49 #ifndef MADE_WITHOUT_COMPROMISE
50 #define MADE_WITHOUT_COMPROMISE
53 /* enum lnet_selftest_session_attrs - LNet selftest session Netlink
56 * @LNET_SELFTEST_SESSION_UNSPEC: unspecified attribute to catch errors
57 * @LNET_SELFTEST_SESSION_PAD: padding for 64-bit attributes, ignore
59 * @LENT_SELFTEST_SESSION_HDR: Netlink group this data is for
61 * @LNET_SELFTEST_SESSION_NAME: name of this session (NLA_STRING)
62 * @LNET_SELFTEST_SESSION_KEY: key used to represent the session
64 * @LNET_SELFTEST_SESSION_TIMESTAMP: timestamp when the session was created
66 * @LNET_SELFTEST_SESSION_NID: NID of the node selftest ran on
68 * @LNET_SELFTEST_SESSION_NODE_COUNT: Number of nodes in use (NLA_U16)
70 enum lnet_selftest_session_attrs {
71 LNET_SELFTEST_SESSION_UNSPEC = 0,
72 LNET_SELFTEST_SESSION_PAD = LNET_SELFTEST_SESSION_UNSPEC,
74 LNET_SELFTEST_SESSION_HDR,
75 LNET_SELFTEST_SESSION_NAME,
76 LNET_SELFTEST_SESSION_KEY,
77 LNET_SELFTEST_SESSION_TIMESTAMP,
78 LNET_SELFTEST_SESSION_NID,
79 LNET_SELFTEST_SESSION_NODE_COUNT,
81 __LNET_SELFTEST_SESSION_MAX_PLUS_ONE,
84 #define LNET_SELFTEST_SESSION_MAX (__LNET_SELFTEST_SESSION_MAX_PLUS_ONE - 1)
86 /* enum lnet_selftest_group_attrs - LNet selftest group Netlink attributes
88 * @LNET_SELFTEST_GROUP_ATTR_UNSPEC: unspecified attribute to catch errors
90 * @LENT_SELFTEST_GROUP_ATTR_HDR: Netlink group this data is for
92 * @LNET_SELFTEST_GROUP_ATTR_NAME: name of this group (NLA_STRING)
93 * @LNET_SELFTEST_GROUP_ATTR_NODELIST: List of nodes belonging to the group
96 enum lnet_selftest_group_attrs {
97 LNET_SELFTEST_GROUP_ATTR_UNSPEC = 0,
99 LNET_SELFTEST_GROUP_ATTR_HDR,
100 LNET_SELFTEST_GROUP_ATTR_NAME,
101 LNET_SELFTEST_GROUP_ATTR_NODELIST,
103 __LNET_SELFTEST_GROUP_MAX_PLUS_ONE,
106 #define LNET_SELFTEST_GROUP_MAX (__LNET_SELFTEST_GROUP_MAX_PLUS_ONE - 1)
108 /* enum lnet_selftest_group_nodelist_prop_attrs - Netlink attributes for
109 * the properties of the
110 * nodes that belong to a
113 * @LNET_SELFTEST_GROUP_NODELIST_PROP_ATTR_UNSPEC: unspecified attribute
116 * @LENT_SELFTEST_GROUP_NODELIST_PROP_ATTR_NID: Nodes's NID (NLA_STRING)
117 * @LNET_SELFTEST_GROUP_NODELIST_PROP_ATTR_STATUS: Status of the node
120 enum lnet_selftest_group_nodelist_prop_attrs {
121 LNET_SELFTEST_GROUP_NODELIST_PROP_ATTR_UNSPEC = 0,
123 LNET_SELFTEST_GROUP_NODELIST_PROP_ATTR_NID,
124 LNET_SELFTEST_GROUP_NODELIST_PROP_ATTR_STATUS,
125 __LNET_SELFTEST_GROUP_NODELIST_PROP_MAX_PLUS_ONE,
128 #define LNET_SELFTEST_GROUP_NODELIST_PROP_MAX (__LNET_SELFTEST_GROUP_NODELIST_PROP_MAX_PLUS_ONE - 1)
133 SWI_STATE_REPLY_SUBMITTED,
134 SWI_STATE_REPLY_SENT,
135 SWI_STATE_REQUEST_SUBMITTED,
136 SWI_STATE_REQUEST_SENT,
137 SWI_STATE_REPLY_RECEIVED,
138 SWI_STATE_BULK_STARTED,
145 struct srpc_service_cd;
146 struct sfw_test_unit;
147 struct sfw_test_instance;
149 /* services below SRPC_FRAMEWORK_SERVICE_MAX_ID are framework
150 * services, e.g. create/modify session.
152 #define SRPC_SERVICE_DEBUG 0
153 #define SRPC_SERVICE_MAKE_SESSION 1
154 #define SRPC_SERVICE_REMOVE_SESSION 2
155 #define SRPC_SERVICE_BATCH 3
156 #define SRPC_SERVICE_TEST 4
157 #define SRPC_SERVICE_QUERY_STAT 5
158 #define SRPC_SERVICE_JOIN 6
159 #define SRPC_FRAMEWORK_SERVICE_MAX_ID 10
160 /* other services start from SRPC_FRAMEWORK_SERVICE_MAX_ID+1 */
161 #define SRPC_SERVICE_BRW 11
162 #define SRPC_SERVICE_PING 12
163 #define SRPC_SERVICE_MAX_ID 12
165 #define SRPC_REQUEST_PORTAL 50
166 /* a lazy portal for framework RPC requests */
167 #define SRPC_FRAMEWORK_REQUEST_PORTAL 51
168 /* all reply/bulk RDMAs go to this portal */
169 #define SRPC_RDMA_PORTAL 52
171 static inline enum srpc_msg_type
172 srpc_service2request (int service)
177 case SRPC_SERVICE_DEBUG:
178 return SRPC_MSG_DEBUG_REQST;
180 case SRPC_SERVICE_MAKE_SESSION:
181 return SRPC_MSG_MKSN_REQST;
183 case SRPC_SERVICE_REMOVE_SESSION:
184 return SRPC_MSG_RMSN_REQST;
186 case SRPC_SERVICE_BATCH:
187 return SRPC_MSG_BATCH_REQST;
189 case SRPC_SERVICE_TEST:
190 return SRPC_MSG_TEST_REQST;
192 case SRPC_SERVICE_QUERY_STAT:
193 return SRPC_MSG_STAT_REQST;
195 case SRPC_SERVICE_BRW:
196 return SRPC_MSG_BRW_REQST;
198 case SRPC_SERVICE_PING:
199 return SRPC_MSG_PING_REQST;
201 case SRPC_SERVICE_JOIN:
202 return SRPC_MSG_JOIN_REQST;
206 static inline enum srpc_msg_type
207 srpc_service2reply (int service)
209 return srpc_service2request(service) + 1;
212 enum srpc_event_type {
213 SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source) received */
214 SRPC_BULK_PUT_SENT = 2, /* active bulk PUT sent (source) */
215 SRPC_BULK_GET_RPLD = 3, /* active bulk GET replied (sink) */
216 SRPC_REPLY_RCVD = 4, /* incoming reply received */
217 SRPC_REPLY_SENT = 5, /* outgoing reply sent */
218 SRPC_REQUEST_RCVD = 6, /* incoming request received */
219 SRPC_REQUEST_SENT = 7, /* outgoing request sent */
224 enum srpc_event_type ev_type; /* what's up */
225 enum lnet_event_kind ev_lnet; /* LNet event type */
226 int ev_fired; /* LNet event fired? */
227 int ev_status; /* LNet event status */
228 void *ev_data; /* owning server/client RPC */
231 /* bulk descriptor */
233 int bk_len; /* len of bulk data */
234 struct lnet_handle_md bk_mdh;
235 int bk_sink; /* sink/source */
236 int bk_niov; /* # iov in bk_iovs */
237 struct bio_vec bk_iovs[0];
240 /* message buffer descriptor */
242 struct list_head buf_list; /* chain on srpc_service::*_msgq */
243 struct srpc_msg buf_msg;
244 struct lnet_handle_md buf_mdh;
246 struct lnet_process_id buf_peer;
250 typedef void (*swi_action_t)(struct swi_workitem *);
252 struct swi_workitem {
253 struct workqueue_struct *swi_wq;
254 struct work_struct swi_work;
255 swi_action_t swi_action;
256 enum lsr_swi_state swi_state;
259 /* server-side state of a RPC */
260 struct srpc_server_rpc {
261 /* chain on srpc_service::*_rpcq */
262 struct list_head srpc_list;
263 struct srpc_service_cd *srpc_scd;
264 struct swi_workitem srpc_wi;
265 struct srpc_event srpc_ev; /* bulk/reply event */
266 lnet_nid_t srpc_self;
267 struct lnet_process_id srpc_peer;
268 struct srpc_msg srpc_replymsg;
269 struct lnet_handle_md srpc_replymdh;
270 struct srpc_buffer *srpc_reqstbuf;
271 struct srpc_bulk *srpc_bulk;
273 unsigned int srpc_aborted; /* being given up */
275 void (*srpc_done)(struct srpc_server_rpc *);
278 /* client-side state of a RPC */
279 struct srpc_client_rpc {
280 struct list_head crpc_list; /* chain on user's lists */
281 spinlock_t crpc_lock; /* serialize */
283 atomic_t crpc_refcount;
284 /* # seconds to wait for reply */
286 struct stt_timer crpc_timer;
287 struct swi_workitem crpc_wi;
288 struct lnet_process_id crpc_dest;
290 void (*crpc_done)(struct srpc_client_rpc *);
291 void (*crpc_fini)(struct srpc_client_rpc *);
292 int crpc_status; /* completion status */
293 void *crpc_priv; /* caller data */
296 unsigned int crpc_aborted:1; /* being given up */
297 unsigned int crpc_closed:1; /* completed */
300 struct srpc_event crpc_bulkev; /* bulk event */
301 struct srpc_event crpc_reqstev; /* request event */
302 struct srpc_event crpc_replyev; /* reply event */
304 /* bulk, request(reqst), and reply exchanged on wire */
305 struct srpc_msg crpc_reqstmsg;
306 struct srpc_msg crpc_replymsg;
307 struct lnet_handle_md crpc_reqstmdh;
308 struct lnet_handle_md crpc_replymdh;
309 struct srpc_bulk crpc_bulk;
312 #define srpc_client_rpc_size(rpc) \
313 offsetof(struct srpc_client_rpc, crpc_bulk.bk_iovs[(rpc)->crpc_bulk.bk_niov])
315 #define srpc_client_rpc_addref(rpc) \
317 CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \
318 (rpc), libcfs_id2str((rpc)->crpc_dest), \
319 atomic_read(&(rpc)->crpc_refcount)); \
320 LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
321 atomic_inc(&(rpc)->crpc_refcount); \
324 #define srpc_client_rpc_decref(rpc) \
326 CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \
327 (rpc), libcfs_id2str((rpc)->crpc_dest), \
328 atomic_read(&(rpc)->crpc_refcount)); \
329 LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
330 if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \
331 srpc_destroy_client_rpc(rpc); \
334 #define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \
335 (rpc)->crpc_reqstev.ev_fired == 0 || \
336 (rpc)->crpc_replyev.ev_fired == 0)
338 /* CPU partition data of srpc service */
339 struct srpc_service_cd {
342 /** backref to service */
343 struct srpc_service *scd_svc;
345 struct srpc_event scd_ev;
346 /** free RPC descriptors */
347 struct list_head scd_rpc_free;
348 /** in-flight RPCs */
349 struct list_head scd_rpc_active;
350 /** workitem for posting buffer */
351 struct swi_workitem scd_buf_wi;
354 /** error code for scd_buf_wi */
356 /** timestamp for scd_buf_err */
357 time64_t scd_buf_err_stamp;
358 /** total # request buffers */
360 /** # posted request buffers */
362 /** in progress of buffer posting */
364 /** allocate more buffers if scd_buf_nposted < scd_buf_low */
366 /** increase/decrease some buffers */
368 /** posted message buffers */
369 struct list_head scd_buf_posted;
370 /** blocked for RPC descriptor */
371 struct list_head scd_buf_blocked;
374 /* number of server workitems (mini-thread) for testing service */
375 #define SFW_TEST_WI_MIN 256
376 #define SFW_TEST_WI_MAX 2048
377 /* extra buffers for tolerating buggy peers, or unbalanced number
378 * of peers between partitions */
379 #define SFW_TEST_WI_EXTRA 64
381 /* number of server workitems (mini-thread) for framework service */
382 #define SFW_FRWK_WI_MIN 16
383 #define SFW_FRWK_WI_MAX 256
385 struct srpc_service {
386 int sv_id; /* service id */
387 const char *sv_name; /* human readable name */
388 int sv_wi_total; /* total server workitems */
391 /* percpt data for srpc_service */
392 struct srpc_service_cd **sv_cpt_data;
393 /* Service callbacks:
394 * - sv_handler: process incoming RPC request
395 * - sv_bulk_ready: notify bulk data
397 int (*sv_handler)(struct srpc_server_rpc *);
398 int (*sv_bulk_ready)(struct srpc_server_rpc *, int);
401 struct lst_session_id {
402 s64 ses_stamp; /* time stamp in milliseconds */
403 struct lnet_nid ses_nid; /* nid of console node */
404 }; /*** session id (large addr) */
406 extern struct lst_session_id LST_INVALID_SID;
409 /* chain on fw_zombie_sessions */
410 struct list_head sn_list;
411 struct lst_session_id sn_id; /* unique identifier */
412 /* # seconds' inactivity to expire */
413 unsigned int sn_timeout;
415 unsigned int sn_features;
416 struct stt_timer sn_timer;
417 struct list_head sn_batches; /* list of batches */
418 char sn_name[LST_NAME_SIZE];
419 atomic_t sn_refcount;
420 atomic_t sn_brw_errors;
421 atomic_t sn_ping_errors;
425 static inline int sfw_sid_equal(struct lst_sid sid0,
426 struct lst_session_id sid1)
428 struct lnet_nid ses_nid;
430 lnet_nid4_to_nid(sid0.ses_nid, &ses_nid);
432 return ((sid0.ses_stamp == sid1.ses_stamp) &&
433 nid_same(&ses_nid, &sid1.ses_nid));
437 struct list_head bat_list; /* chain on sn_batches */
438 struct lst_bid bat_id; /* batch id */
439 int bat_error; /* error code of batch */
440 struct sfw_session *bat_session; /* batch's session */
441 atomic_t bat_nactive; /* # of active tests */
442 struct list_head bat_tests; /* test instances */
445 struct sfw_test_client_ops {
446 int (*tso_init)(struct sfw_test_instance *tsi); /* intailize test client */
447 void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test client */
448 int (*tso_prep_rpc)(struct sfw_test_unit *tsu,
449 struct lnet_process_id dest,
450 struct srpc_client_rpc **rpc); /* prep a tests rpc */
451 void (*tso_done_rpc)(struct sfw_test_unit *tsu,
452 struct srpc_client_rpc *rpc); /* done a test rpc */
455 struct sfw_test_instance {
456 struct list_head tsi_list; /* chain on batch */
457 int tsi_service; /* test type */
458 struct sfw_batch *tsi_batch; /* batch */
459 struct sfw_test_client_ops *tsi_ops; /* test client operations */
461 /* public parameter for all test units */
462 unsigned int tsi_is_client:1; /* is test client */
463 unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */
464 int tsi_concur; /* concurrency */
465 int tsi_loop; /* loop count */
467 /* status of test instance */
468 spinlock_t tsi_lock; /* serialize */
469 unsigned int tsi_stopping:1; /* test is stopping */
470 atomic_t tsi_nactive; /* # of active test unit */
471 struct list_head tsi_units; /* test units */
472 struct list_head tsi_free_rpcs; /* free rpcs */
473 struct list_head tsi_active_rpcs;/* active rpcs */
476 struct test_ping_req ping; /* ping parameter */
477 struct test_bulk_req bulk_v0; /* bulk parameter */
478 struct test_bulk_req_v1 bulk_v1; /* bulk v1 parameter */
482 /* XXX: trailing (PAGE_SIZE % sizeof(struct lnet_process_id)) bytes at
483 * the end of pages are not used */
484 #define SFW_MAX_CONCUR LST_MAX_CONCUR
485 #define SFW_ID_PER_PAGE (PAGE_SIZE / sizeof(struct lnet_process_id_packed))
486 #define SFW_MAX_NDESTS (LNET_MAX_IOV * SFW_ID_PER_PAGE)
487 #define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE)
489 struct sfw_test_unit {
490 struct list_head tsu_list; /* chain on lst_test_instance */
491 struct lnet_process_id tsu_dest; /* id of dest node */
492 int tsu_loop; /* loop count of the test */
493 struct sfw_test_instance *tsu_instance; /* pointer to test instance */
494 void *tsu_private; /* private data */
495 struct swi_workitem tsu_worker; /* workitem of the test unit */
498 struct sfw_test_case {
499 struct list_head tsc_list; /* chain on fw_tests */
500 struct srpc_service *tsc_srv_service; /* test service */
501 struct sfw_test_client_ops *tsc_cli_ops; /* ops of test client */
504 struct srpc_client_rpc *
505 sfw_create_rpc(struct lnet_process_id peer, int service,
506 unsigned features, int nbulkiov, int bulklen,
507 void (*done)(struct srpc_client_rpc *), void *priv);
508 int sfw_create_test_rpc(struct sfw_test_unit *tsu,
509 struct lnet_process_id peer, unsigned int features,
510 int nblk, int blklen, struct srpc_client_rpc **rpc);
511 void sfw_abort_rpc(struct srpc_client_rpc *rpc);
512 void sfw_post_rpc(struct srpc_client_rpc *rpc);
513 void sfw_client_rpc_done(struct srpc_client_rpc *rpc);
514 void sfw_unpack_message(struct srpc_msg *msg);
515 void sfw_free_pages(struct srpc_server_rpc *rpc);
516 void sfw_add_bulk_page(struct srpc_bulk *bk, struct page *pg, int i);
517 int sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
519 int sfw_make_session(struct srpc_mksn_reqst *request,
520 struct srpc_mksn_reply *reply);
522 struct srpc_client_rpc *
523 srpc_create_client_rpc(struct lnet_process_id peer, int service,
524 int nbulkiov, int bulklen,
525 void (*rpc_done)(struct srpc_client_rpc *),
526 void (*rpc_fini)(struct srpc_client_rpc *), void *priv);
527 void srpc_post_rpc(struct srpc_client_rpc *rpc);
528 void srpc_abort_rpc(struct srpc_client_rpc *rpc, int why);
529 void srpc_free_bulk(struct srpc_bulk *bk);
530 struct srpc_bulk *srpc_alloc_bulk(int cpt, unsigned int off,
531 unsigned int bulk_npg, unsigned int bulk_len,
533 void srpc_send_rpc(struct swi_workitem *wi);
534 int srpc_send_reply(struct srpc_server_rpc *rpc);
535 int srpc_add_service(struct srpc_service *sv);
536 int srpc_remove_service(struct srpc_service *sv);
537 void srpc_shutdown_service(struct srpc_service *sv);
538 void srpc_abort_service(struct srpc_service *sv);
539 int srpc_finish_service(struct srpc_service *sv);
540 int srpc_service_add_buffers(struct srpc_service *sv, int nbuffer);
541 void srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer);
542 void srpc_get_counters(struct srpc_counters *cnt);
544 extern struct workqueue_struct *lst_serial_wq;
545 extern struct workqueue_struct **lst_test_wq;
548 srpc_serv_is_framework(struct srpc_service *svc)
550 return svc->sv_id < SRPC_FRAMEWORK_SERVICE_MAX_ID;
554 swi_wi_action(struct work_struct *wi)
556 struct swi_workitem *swi;
558 swi = container_of(wi, struct swi_workitem, swi_work);
559 swi->swi_action(swi);
563 swi_init_workitem(struct swi_workitem *swi,
564 swi_action_t action, struct workqueue_struct *wq)
567 swi->swi_action = action;
568 swi->swi_state = SWI_STATE_NEWBORN;
569 INIT_WORK(&swi->swi_work, swi_wi_action);
573 swi_schedule_workitem(struct swi_workitem *wi)
575 queue_work(wi->swi_wq, &wi->swi_work);
579 swi_cancel_workitem(struct swi_workitem *swi)
581 swi->swi_state = SWI_STATE_DONE;
582 return cancel_work_sync(&swi->swi_work);
585 int sfw_startup(void);
586 int srpc_startup(void);
587 void sfw_shutdown(void);
588 void srpc_shutdown(void);
591 srpc_destroy_client_rpc(struct srpc_client_rpc *rpc)
593 LASSERT (rpc != NULL);
594 LASSERT (!srpc_event_pending(rpc));
595 LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
597 if (rpc->crpc_fini == NULL) {
598 LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
600 (*rpc->crpc_fini) (rpc);
605 srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer,
606 int service, int nbulkiov, int bulklen,
607 void (*rpc_done)(struct srpc_client_rpc *),
608 void (*rpc_fini)(struct srpc_client_rpc *), void *priv)
610 LASSERT(nbulkiov <= LNET_MAX_IOV);
612 memset(rpc, 0, offsetof(struct srpc_client_rpc,
613 crpc_bulk.bk_iovs[nbulkiov]));
615 INIT_LIST_HEAD(&rpc->crpc_list);
616 swi_init_workitem(&rpc->crpc_wi, srpc_send_rpc,
617 lst_test_wq[lnet_cpt_of_nid(peer.nid, NULL)]);
618 spin_lock_init(&rpc->crpc_lock);
619 atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
621 rpc->crpc_dest = peer;
622 rpc->crpc_priv = priv;
623 rpc->crpc_service = service;
624 rpc->crpc_bulk.bk_len = bulklen;
625 rpc->crpc_bulk.bk_niov = nbulkiov;
626 rpc->crpc_done = rpc_done;
627 rpc->crpc_fini = rpc_fini;
628 LNetInvalidateMDHandle(&rpc->crpc_reqstmdh);
629 LNetInvalidateMDHandle(&rpc->crpc_replymdh);
630 LNetInvalidateMDHandle(&rpc->crpc_bulk.bk_mdh);
632 /* no event is expected at this point */
633 rpc->crpc_bulkev.ev_fired =
634 rpc->crpc_reqstev.ev_fired =
635 rpc->crpc_replyev.ev_fired = 1;
637 rpc->crpc_reqstmsg.msg_magic = SRPC_MSG_MAGIC;
638 rpc->crpc_reqstmsg.msg_version = SRPC_MSG_VERSION;
639 rpc->crpc_reqstmsg.msg_type = srpc_service2request(service);
642 static inline const char *
643 swi_state2str (int state)
645 #define STATE2STR(x) case x: return #x
649 STATE2STR(SWI_STATE_NEWBORN);
650 STATE2STR(SWI_STATE_REPLY_SUBMITTED);
651 STATE2STR(SWI_STATE_REPLY_SENT);
652 STATE2STR(SWI_STATE_REQUEST_SUBMITTED);
653 STATE2STR(SWI_STATE_REQUEST_SENT);
654 STATE2STR(SWI_STATE_REPLY_RECEIVED);
655 STATE2STR(SWI_STATE_BULK_STARTED);
656 STATE2STR(SWI_STATE_DONE);
661 #define lst_wait_until(cond, lock, fmt, ...) \
665 CDEBUG(is_power_of_2(++__I) ? D_WARNING : D_NET, \
666 fmt, ## __VA_ARGS__); \
667 spin_unlock(&(lock)); \
669 schedule_timeout_uninterruptible( \
670 cfs_time_seconds(1) / 10); \
672 spin_lock(&(lock)); \
677 srpc_wait_service_shutdown(struct srpc_service *sv)
681 LASSERT(sv->sv_shuttingdown);
683 while (srpc_finish_service(sv) == 0) {
685 CDEBUG(((i & -i) == i) ? D_WARNING : D_NET,
686 "Waiting for %s service to shutdown...\n",
688 schedule_timeout_uninterruptible(cfs_time_seconds(1) / 10);
692 extern struct sfw_test_client_ops ping_test_client;
693 extern struct srpc_service ping_test_service;
694 void ping_init_test_client(void);
695 void ping_init_test_service(void);
697 extern struct sfw_test_client_ops brw_test_client;
698 extern struct srpc_service brw_test_service;
699 void brw_init_test_client(void);
700 void brw_init_test_service(void);
702 #endif /* __SELFTEST_SELFTEST_H__ */