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, 2013, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * /lnet/selftest/conrpc.h
35 * Author: Liang Zhen <liang@whamcloud.com>
38 #ifndef __LST_CONRPC_H__
39 #define __LST_CONRPC_H__
41 #include <libcfs/libcfs.h>
42 #include <lnet/lib-types.h>
46 /* Console rpc and rpc transaction */
47 #define LST_TRANS_TIMEOUT 30
48 #define LST_TRANS_MIN_TIMEOUT 3
50 #define LST_VALIDATE_TIMEOUT(t) \
51 clamp_t(int, t, LST_TRANS_MIN_TIMEOUT, LST_TRANS_TIMEOUT)
53 #define LST_PING_INTERVAL 8
55 struct lstcon_rpc_trans;
56 struct lstcon_tsb_hdr;
61 struct list_head crp_link; /* chain on rpc transaction */
62 struct srpc_client_rpc *crp_rpc; /* client rpc */
63 struct lstcon_node *crp_node; /* destination node */
64 struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
66 unsigned int crp_posted:1; /* rpc is posted */
67 unsigned int crp_finished:1; /* rpc is finished */
68 unsigned int crp_unpacked:1; /* reply is unpacked */
69 /** RPC is embedded in other structure and can't free it */
70 unsigned int crp_embedded:1;
71 int crp_status; /* console rpc errors */
72 s64 crp_stamp_ns; /* replied time stamp */
75 struct lstcon_rpc_trans {
76 /* link chain on owner list */
77 struct list_head tas_olink;
78 /* link chain on global list */
79 struct list_head tas_link;
80 /* operation code of transaction */
82 /* features mask is uptodate */
83 unsigned tas_feats_updated;
84 /* test features mask */
85 unsigned tas_features;
86 wait_queue_head_t tas_waitq; /* wait queue head */
87 atomic_t tas_remaining; /* # of un-scheduled rpcs */
88 struct list_head tas_rpcs_list; /* queued requests */
91 #define LST_TRANS_PRIVATE 0x1000
93 #define LST_TRANS_SESNEW (LST_TRANS_PRIVATE | 0x01)
94 #define LST_TRANS_SESEND (LST_TRANS_PRIVATE | 0x02)
95 #define LST_TRANS_SESQRY 0x03
96 #define LST_TRANS_SESPING 0x04
98 #define LST_TRANS_TSBCLIADD (LST_TRANS_PRIVATE | 0x11)
99 #define LST_TRANS_TSBSRVADD (LST_TRANS_PRIVATE | 0x12)
100 #define LST_TRANS_TSBRUN (LST_TRANS_PRIVATE | 0x13)
101 #define LST_TRANS_TSBSTOP (LST_TRANS_PRIVATE | 0x14)
102 #define LST_TRANS_TSBCLIQRY 0x15
103 #define LST_TRANS_TSBSRVQRY 0x16
105 #define LST_TRANS_STATQRY 0x21
107 typedef int (*lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
108 typedef int (*lstcon_rpc_readent_func_t)(int, struct srpc_msg *,
109 struct lstcon_rpc_ent __user *);
111 int lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
112 unsigned int version, struct lstcon_rpc **crpc);
113 int lstcon_dbgrpc_prep(struct lstcon_node *nd,
114 unsigned int version, struct lstcon_rpc **crpc);
115 int lstcon_batrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
116 struct lstcon_tsb_hdr *tsb, struct lstcon_rpc **crpc);
117 int lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
118 struct lstcon_test *test, struct lstcon_rpc **crpc);
119 int lstcon_statrpc_prep(struct lstcon_node *nd, unsigned version,
120 struct lstcon_rpc **crpc);
121 void lstcon_rpc_put(struct lstcon_rpc *crpc);
122 int lstcon_rpc_trans_prep(struct list_head *translist,
123 int transop, struct lstcon_rpc_trans **transpp);
124 int lstcon_rpc_trans_ndlist(struct list_head *ndlist,
125 struct list_head *translist, int transop,
126 void *arg, lstcon_rpc_cond_func_t condition,
127 struct lstcon_rpc_trans **transpp);
128 void lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans,
129 struct lstcon_trans_stat *stat);
130 int lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
131 struct list_head __user *head_up,
132 lstcon_rpc_readent_func_t readent);
133 void lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error);
134 void lstcon_rpc_trans_destroy(struct lstcon_rpc_trans *trans);
135 void lstcon_rpc_trans_addreq(struct lstcon_rpc_trans *trans,
136 struct lstcon_rpc *req);
137 int lstcon_rpc_trans_postwait(struct lstcon_rpc_trans *trans, int timeout);
138 int lstcon_rpc_pinger_start(void);
139 void lstcon_rpc_pinger_stop(void);
140 void lstcon_rpc_cleanup_wait(void);
141 int lstcon_rpc_module_init(void);
142 void lstcon_rpc_module_fini(void);