1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
5 * Use is subject to license terms.
7 * Copyright (c) 2012, 2013, Intel Corporation.
11 * This file is part of Lustre, http://www.lustre.org/
15 * Author: Liang Zhen <liang@whamcloud.com>
18 #ifndef __LST_CONRPC_H__
19 #define __LST_CONRPC_H__
21 #include <libcfs/libcfs.h>
22 #include <lnet/lib-types.h>
26 /* Console rpc and rpc transaction */
27 #define LST_TRANS_TIMEOUT 30
28 #define LST_TRANS_MIN_TIMEOUT 3
30 #define LST_VALIDATE_TIMEOUT(t) \
31 clamp_t(int, t, LST_TRANS_MIN_TIMEOUT, LST_TRANS_TIMEOUT)
33 #define LST_PING_INTERVAL 8
35 struct lstcon_rpc_trans;
36 struct lstcon_tsb_hdr;
41 struct list_head crp_link; /* chain on rpc transaction */
42 struct srpc_client_rpc *crp_rpc; /* client rpc */
43 struct lstcon_node *crp_node; /* destination node */
44 struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
46 unsigned int crp_posted:1; /* rpc is posted */
47 unsigned int crp_finished:1; /* rpc is finished */
48 unsigned int crp_unpacked:1; /* reply is unpacked */
49 /** RPC is embedded in other structure and can't free it */
50 unsigned int crp_embedded:1;
51 int crp_status; /* console rpc errors */
52 s64 crp_stamp_ns; /* replied time stamp */
55 struct lstcon_rpc_trans {
56 /* link chain on owner list */
57 struct list_head tas_olink;
58 /* link chain on global list */
59 struct list_head tas_link;
60 /* operation code of transaction */
62 /* features mask is uptodate */
63 unsigned tas_feats_updated;
64 /* test features mask */
65 unsigned tas_features;
66 wait_queue_head_t tas_waitq; /* wait queue head */
67 atomic_t tas_remaining; /* # of un-scheduled rpcs */
68 struct list_head tas_rpcs_list; /* queued requests */
71 #define LST_TRANS_PRIVATE 0x1000
73 #define LST_TRANS_SESNEW (LST_TRANS_PRIVATE | 0x01)
74 #define LST_TRANS_SESEND (LST_TRANS_PRIVATE | 0x02)
75 #define LST_TRANS_SESQRY 0x03
76 #define LST_TRANS_SESPING 0x04
78 #define LST_TRANS_TSBCLIADD (LST_TRANS_PRIVATE | 0x11)
79 #define LST_TRANS_TSBSRVADD (LST_TRANS_PRIVATE | 0x12)
80 #define LST_TRANS_TSBRUN (LST_TRANS_PRIVATE | 0x13)
81 #define LST_TRANS_TSBSTOP (LST_TRANS_PRIVATE | 0x14)
82 #define LST_TRANS_TSBCLIQRY 0x15
83 #define LST_TRANS_TSBSRVQRY 0x16
85 #define LST_TRANS_STATQRY 0x21
87 typedef int (*lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
88 typedef int (*lstcon_rpc_readent_func_t)(int, struct srpc_msg *,
89 struct lstcon_rpc_ent __user *);
91 int lstcon_sesrpc_prep(struct lstcon_node *nd, int transop,
92 unsigned int version, struct lstcon_rpc **crpc);
93 int lstcon_dbgrpc_prep(struct lstcon_node *nd,
94 unsigned int version, struct lstcon_rpc **crpc);
95 int lstcon_batrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
96 struct lstcon_tsb_hdr *tsb, struct lstcon_rpc **crpc);
97 int lstcon_testrpc_prep(struct lstcon_node *nd, int transop, unsigned version,
98 struct lstcon_test *test, struct lstcon_rpc **crpc);
99 int lstcon_statrpc_prep(struct lstcon_node *nd, unsigned version,
100 struct lstcon_rpc **crpc);
101 void lstcon_rpc_put(struct lstcon_rpc *crpc);
102 int lstcon_rpc_trans_prep(struct list_head *translist,
103 int transop, struct lstcon_rpc_trans **transpp);
104 int lstcon_rpc_trans_ndlist(struct list_head *ndlist,
105 struct list_head *translist, int transop,
106 void *arg, lstcon_rpc_cond_func_t condition,
107 struct lstcon_rpc_trans **transpp);
108 void lstcon_rpc_trans_stat(struct lstcon_rpc_trans *trans,
109 struct lstcon_trans_stat *stat);
110 int lstcon_rpc_trans_interpreter(struct lstcon_rpc_trans *trans,
111 struct list_head __user *head_up,
112 lstcon_rpc_readent_func_t readent);
113 void lstcon_rpc_trans_abort(struct lstcon_rpc_trans *trans, int error);
114 void lstcon_rpc_trans_destroy(struct lstcon_rpc_trans *trans);
115 void lstcon_rpc_trans_addreq(struct lstcon_rpc_trans *trans,
116 struct lstcon_rpc *req);
117 int lstcon_rpc_trans_postwait(struct lstcon_rpc_trans *trans, int timeout);
118 int lstcon_rpc_pinger_start(void);
119 void lstcon_rpc_pinger_stop(void);
120 void lstcon_rpc_cleanup_wait(void);
121 int lstcon_rpc_module_init(void);
122 void lstcon_rpc_module_fini(void);