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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
34 * /lnet/selftest/conrpc.h
38 * Author: Liang Zhen <liangzhen@clusterfs.com>
41 #ifndef __LST_CONRPC_H__
42 #define __LST_CONRPC_H__
45 #include <libcfs/libcfs.h>
46 #include <lnet/lnet.h>
47 #include <lnet/lib-types.h>
48 #include <lnet/lnetst.h>
52 /* Console rpc and rpc transaction */
53 #define LST_TRANS_TIMEOUT 30
54 #define LST_TRANS_MIN_TIMEOUT 3
56 #define LST_VALIDATE_TIMEOUT(t) MIN(MAX(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
58 #define LST_PING_INTERVAL 8
60 struct lstcon_rpc_trans;
61 struct lstcon_tsb_hdr;
65 typedef struct lstcon_rpc {
66 cfs_list_t crp_link; /* chain on rpc transaction */
67 srpc_client_rpc_t *crp_rpc; /* client rpc */
68 struct lstcon_node *crp_node; /* destination node */
69 struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
71 int crp_posted:1; /* rpc is posted */
72 int crp_finished:1; /* rpc is finished */
73 int crp_unpacked:1; /* reply is unpacked */
74 int crp_static:1; /* not from RPC buffer */
75 int crp_status; /* console rpc errors */
76 cfs_time_t crp_stamp; /* replied time stamp */
79 typedef struct lstcon_rpc_trans {
80 cfs_list_t tas_olink; /* link chain on owner list */
81 cfs_list_t tas_link; /* link chain on global list */
82 int tas_opc; /* operation code of transaction */
83 cfs_waitq_t tas_waitq; /* wait queue head */
84 cfs_atomic_t tas_remaining; /* # of un-scheduled rpcs */
85 cfs_list_t tas_rpcs_list; /* queued requests */
88 #define LST_TRANS_PRIVATE 0x1000
90 #define LST_TRANS_SESNEW (LST_TRANS_PRIVATE | 0x01)
91 #define LST_TRANS_SESEND (LST_TRANS_PRIVATE | 0x02)
92 #define LST_TRANS_SESQRY 0x03
93 #define LST_TRANS_SESPING 0x04
95 #define LST_TRANS_TSBCLIADD (LST_TRANS_PRIVATE | 0x11)
96 #define LST_TRANS_TSBSRVADD (LST_TRANS_PRIVATE | 0x12)
97 #define LST_TRANS_TSBRUN (LST_TRANS_PRIVATE | 0x13)
98 #define LST_TRANS_TSBSTOP (LST_TRANS_PRIVATE | 0x14)
99 #define LST_TRANS_TSBCLIQRY 0x15
100 #define LST_TRANS_TSBSRVQRY 0x16
102 #define LST_TRANS_STATQRY 0x21
104 typedef int (* lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
105 typedef int (* lstcon_rpc_readent_func_t)(int, srpc_msg_t *, lstcon_rpc_ent_t *);
107 int lstcon_sesrpc_prep(struct lstcon_node *nd,
108 int transop, lstcon_rpc_t **crpc);
109 int lstcon_dbgrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
110 int lstcon_batrpc_prep(struct lstcon_node *nd, int transop,
111 struct lstcon_tsb_hdr *tsb, lstcon_rpc_t **crpc);
112 int lstcon_testrpc_prep(struct lstcon_node *nd, int transop,
113 struct lstcon_test *test, lstcon_rpc_t **crpc);
114 int lstcon_statrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
115 void lstcon_rpc_put(lstcon_rpc_t *crpc);
116 int lstcon_rpc_trans_prep(cfs_list_t *translist,
117 int transop, lstcon_rpc_trans_t **transpp);
118 int lstcon_rpc_trans_ndlist(cfs_list_t *ndlist,
119 cfs_list_t *translist, int transop,
120 void *arg, lstcon_rpc_cond_func_t condition,
121 lstcon_rpc_trans_t **transpp);
122 void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans,
123 lstcon_trans_stat_t *stat);
124 int lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
126 lstcon_rpc_readent_func_t readent);
127 void lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error);
128 void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans);
129 void lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *req);
130 int lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout);
131 int lstcon_rpc_pinger_start(void);
132 void lstcon_rpc_pinger_stop(void);
133 void lstcon_rpc_cleanup_wait(void);
134 int lstcon_rpc_module_init(void);
135 void lstcon_rpc_module_fini(void);