Whamcloud - gitweb
- fixed typo in a comment.
[fs/lustre-release.git] / lnet / selftest / conrpc.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  * 
4  * Author: Liang Zhen <liangzhen@clusterfs.com>
5  * 
6  * This file is part of Lustre, http://www.lustre.org
7  *
8  * Console rpc
9  */
10
11 #ifndef __LST_CONRPC_H__
12 #define __LST_CONRPC_H__
13
14 #ifdef __KERNEL__
15 #include <libcfs/kp30.h>
16 #include <lnet/lnet.h>
17 #include <lnet/lib-types.h>
18 #include <lnet/lnetst.h>
19 #include "rpc.h"
20 #include "selftest.h"
21
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
26
27 struct lstcon_rpc_trans;
28 struct lstcon_tsb_hdr;
29 struct lstcon_test;
30 struct lstcon_node;
31
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 */
37
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 */
44 } lstcon_rpc_t;
45
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 */
53 } lstcon_rpc_trans_t;
54
55 #define LST_TRANS_PRIVATE       0x1000
56
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
61
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
68
69 #define LST_TRANS_STATQRY       0x21
70
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 *);
73
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,
78                        int transop, struct lstcon_tsb_hdr *tsb, lstcon_rpc_t **crpc);
79 int lstcon_testrpc_prep(struct lstcon_node *nd,
80                         int transop, 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, struct list_head *translist,
86                             int transop, void *arg, lstcon_rpc_cond_func_t condition,
87                             lstcon_rpc_trans_t **transpp);
88 void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat);
89 int lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans, struct list_head *head_up,
90                                  lstcon_rpc_readent_func_t readent);
91 void lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error);
92 void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans);
93 void lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *req);
94 int lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout);
95 int lstcon_rpc_pinger_start(void);
96 void lstcon_rpc_pinger_stop(void);
97 void lstcon_rpc_cleanup_wait(void);
98 int lstcon_rpc_module_init(void);
99 void lstcon_rpc_module_fini(void);
100
101 #endif
102
103 #endif