1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Author: Liang Zhen <liangzhen@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org
11 #ifndef __LST_CONRPC_H__
12 #define __LST_CONRPC_H__
15 #include <libcfs/kp30.h>
16 #include <lnet/lnet.h>
17 #include <lnet/lib-types.h>
18 #include <lnet/lnetst.h>
22 /* Console rpc and rpc transaction */
23 #define LST_TRANS_TIMEOUT 30
24 #define LST_TRANS_MIN_TIMEOUT 3
25 #define LST_PING_INTERVAL 8
27 struct lstcon_rpc_trans;
28 struct lstcon_tsb_hdr;
32 typedef struct lstcon_rpc {
33 struct list_head crp_link; /* chain on rpc transaction */
34 srpc_client_rpc_t *crp_rpc; /* client rpc */
35 struct lstcon_node *crp_node; /* destination node */
36 struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
38 int crp_posted:1; /* rpc is posted */
39 int crp_finished:1; /* rpc is finished */
40 int crp_unpacked:1; /* reply is unpacked */
41 int crp_static:1; /* not from RPC buffer */
42 int crp_status; /* console rpc errors */
43 cfs_time_t crp_stamp; /* replied time stamp */
46 typedef struct lstcon_rpc_trans {
47 struct list_head tas_olink; /* link chain on owner list */
48 struct list_head tas_link; /* link chain on global list */
49 int tas_opc; /* operation code of transaction */
50 cfs_waitq_t tas_waitq; /* wait queue head */
51 atomic_t tas_remaining; /* # of un-scheduled rpcs */
52 struct list_head tas_rpcs_list; /* queued requests */
55 #define LST_TRANS_PRIVATE 0x1000
57 #define LST_TRANS_SESNEW (LST_TRANS_PRIVATE | 0x01)
58 #define LST_TRANS_SESEND (LST_TRANS_PRIVATE | 0x02)
59 #define LST_TRANS_SESQRY 0x03
60 #define LST_TRANS_SESPING 0x04
62 #define LST_TRANS_TSBCLIADD (LST_TRANS_PRIVATE | 0x11)
63 #define LST_TRANS_TSBSRVADD (LST_TRANS_PRIVATE | 0x12)
64 #define LST_TRANS_TSBRUN (LST_TRANS_PRIVATE | 0x13)
65 #define LST_TRANS_TSBSTOP (LST_TRANS_PRIVATE | 0x14)
66 #define LST_TRANS_TSBCLIQRY 0x15
67 #define LST_TRANS_TSBSRVQRY 0x16
69 #define LST_TRANS_STATQRY 0x21
71 typedef int (* lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
72 typedef int (* lstcon_rpc_readent_func_t)(int, srpc_msg_t *, lstcon_rpc_ent_t *);
74 int lstcon_sesrpc_prep(struct lstcon_node *nd,
75 int transop, lstcon_rpc_t **crpc);
76 int lstcon_dbgrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
77 int lstcon_batrpc_prep(struct lstcon_node *nd, int transop,
78 struct lstcon_tsb_hdr *tsb, lstcon_rpc_t **crpc);
79 int lstcon_testrpc_prep(struct lstcon_node *nd, int transop,
80 struct lstcon_test *test, lstcon_rpc_t **crpc);
81 int lstcon_statrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
82 void lstcon_rpc_put(lstcon_rpc_t *crpc);
83 int lstcon_rpc_trans_prep(struct list_head *translist,
84 int transop, lstcon_rpc_trans_t **transpp);
85 int lstcon_rpc_trans_ndlist(struct list_head *ndlist,
86 struct list_head *translist, int transop,
87 void *arg, lstcon_rpc_cond_func_t condition,
88 lstcon_rpc_trans_t **transpp);
89 void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans,
90 lstcon_trans_stat_t *stat);
91 int lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
92 struct list_head *head_up,
93 lstcon_rpc_readent_func_t readent);
94 void lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error);
95 void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans);
96 void lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *req);
97 int lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout);
98 int lstcon_rpc_pinger_start(void);
99 void lstcon_rpc_pinger_stop(void);
100 void lstcon_rpc_cleanup_wait(void);
101 int lstcon_rpc_module_init(void);
102 void lstcon_rpc_module_fini(void);