Whamcloud - gitweb
ba2a72c226ed773434252c814e72b7441b171466
[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  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * /lnet/selftest/conrpc.h
37  *
38  * Console rpc
39  *
40  * Author: Liang Zhen <liangzhen@clusterfs.com>
41  */
42
43 #ifndef __LST_CONRPC_H__
44 #define __LST_CONRPC_H__
45
46 #ifdef __KERNEL__
47 #include <libcfs/libcfs.h>
48 #include <lnet/lnet.h>
49 #include <lnet/lib-types.h>
50 #include <lnet/lnetst.h>
51 #include "rpc.h"
52 #include "selftest.h"
53
54 /* Console rpc and rpc transaction */
55 #define LST_TRANS_TIMEOUT       30
56 #define LST_TRANS_MIN_TIMEOUT   3
57 #define LST_PING_INTERVAL       8
58
59 struct lstcon_rpc_trans;
60 struct lstcon_tsb_hdr;
61 struct lstcon_test;
62 struct lstcon_node;
63
64 typedef struct lstcon_rpc {
65         struct list_head        crp_link;       /* chain on rpc transaction */
66         srpc_client_rpc_t      *crp_rpc;        /* client rpc */
67         struct lstcon_node     *crp_node;       /* destination node */
68         struct lstcon_rpc_trans *crp_trans;     /* conrpc transaction */
69
70         int                     crp_posted:1;   /* rpc is posted */
71         int                     crp_finished:1; /* rpc is finished */
72         int                     crp_unpacked:1; /* reply is unpacked */
73         int                     crp_static:1;   /* not from RPC buffer */
74         int                     crp_status;     /* console rpc errors */
75         cfs_time_t              crp_stamp;      /* replied time stamp */
76 } lstcon_rpc_t;
77
78 typedef struct lstcon_rpc_trans {
79         struct list_head        tas_olink;      /* link chain on owner list */
80         struct list_head        tas_link;       /* link chain on global list */
81         int                     tas_opc;        /* operation code of transaction */
82         cfs_waitq_t             tas_waitq;      /* wait queue head */
83         atomic_t                tas_remaining;  /* # of un-scheduled rpcs */
84         struct list_head        tas_rpcs_list;  /* queued requests */
85 } lstcon_rpc_trans_t;
86
87 #define LST_TRANS_PRIVATE       0x1000
88
89 #define LST_TRANS_SESNEW        (LST_TRANS_PRIVATE | 0x01)
90 #define LST_TRANS_SESEND        (LST_TRANS_PRIVATE | 0x02)
91 #define LST_TRANS_SESQRY        0x03
92 #define LST_TRANS_SESPING       0x04
93
94 #define LST_TRANS_TSBCLIADD     (LST_TRANS_PRIVATE | 0x11)
95 #define LST_TRANS_TSBSRVADD     (LST_TRANS_PRIVATE | 0x12)
96 #define LST_TRANS_TSBRUN        (LST_TRANS_PRIVATE | 0x13)
97 #define LST_TRANS_TSBSTOP       (LST_TRANS_PRIVATE | 0x14)
98 #define LST_TRANS_TSBCLIQRY     0x15
99 #define LST_TRANS_TSBSRVQRY     0x16
100
101 #define LST_TRANS_STATQRY       0x21
102
103 typedef int (* lstcon_rpc_cond_func_t)(int, struct lstcon_node *, void *);
104 typedef int (* lstcon_rpc_readent_func_t)(int, srpc_msg_t *, lstcon_rpc_ent_t *);
105
106 int  lstcon_sesrpc_prep(struct lstcon_node *nd, 
107                         int transop, lstcon_rpc_t **crpc);
108 int  lstcon_dbgrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
109 int  lstcon_batrpc_prep(struct lstcon_node *nd, int transop,
110                         struct lstcon_tsb_hdr *tsb, lstcon_rpc_t **crpc);
111 int  lstcon_testrpc_prep(struct lstcon_node *nd, int transop,
112                          struct lstcon_test *test, lstcon_rpc_t **crpc);
113 int  lstcon_statrpc_prep(struct lstcon_node *nd, lstcon_rpc_t **crpc);
114 void lstcon_rpc_put(lstcon_rpc_t *crpc);
115 int  lstcon_rpc_trans_prep(struct list_head *translist,
116                            int transop, lstcon_rpc_trans_t **transpp);
117 int  lstcon_rpc_trans_ndlist(struct list_head *ndlist,
118                              struct list_head *translist, int transop,
119                              void *arg, lstcon_rpc_cond_func_t condition,
120                              lstcon_rpc_trans_t **transpp);
121 void lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans,
122                            lstcon_trans_stat_t *stat);
123 int  lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
124                                   struct list_head *head_up,
125                                   lstcon_rpc_readent_func_t readent);
126 void lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error);
127 void lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans);
128 void lstcon_rpc_trans_addreq(lstcon_rpc_trans_t *trans, lstcon_rpc_t *req);
129 int  lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout);
130 int  lstcon_rpc_pinger_start(void);
131 void lstcon_rpc_pinger_stop(void);
132 void lstcon_rpc_cleanup_wait(void);
133 int  lstcon_rpc_module_init(void);
134 void lstcon_rpc_module_fini(void);
135
136 #endif
137
138 #endif