Whamcloud - gitweb
- added rq_type field to ptlrpc_request
[fs/lustre-release.git] / lustre / include / linux / lustre_net.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef _LUSTRE_NET_H
24 #define _LUSTRE_NET_H
25
26 #include <linux/kp30.h>
27 #include <portals/p30.h>
28 #include <linux/lustre_idl.h>
29
30 /* FOO_REQUEST_PORTAL receives requests for the FOO subsystem.
31  * FOO_REPLY_PORTAL receives replies _from_ the FOO subsystem. */
32 #define OSC_REQUEST_PORTAL 1
33 #define OSC_REPLY_PORTAL   2
34 #define MDS_REQUEST_PORTAL 3
35 #define MDS_REPLY_PORTAL   4
36 #define OST_REQUEST_PORTAL 5
37 #define OST_REPLY_PORTAL   6
38 #define MDC_BULK_PORTAL    7
39 #define MDS_BULK_PORTAL    8
40 #define OSC_BULK_PORTAL    9
41 #define OST_BULK_PORTAL    10
42
43 /* default rpc ring length */
44 #define RPC_RING_LENGTH    2
45
46 /* generic wrappable next */
47 #define NEXT_INDEX(index, max)  (((index+1) >= max) ? 0 : (index+1))
48
49
50 struct ptlrpc_service {
51         char *srv_buf[RPC_RING_LENGTH];
52         __u32 srv_buf_size;
53         __u32 srv_me_active;
54         __u32 srv_me_tail;
55         __u32 srv_md_active;
56         __u32 srv_ring_length;
57         __u32 srv_portal;
58         __u32 srv_ref_count[RPC_RING_LENGTH];
59
60         struct lustre_peer srv_self;
61
62         /* FIXME: perhaps a list of EQs, if multiple NIs are used? */
63         ptl_handle_eq_t srv_eq_h;
64
65         ptl_handle_me_t srv_me_h[RPC_RING_LENGTH];
66         ptl_process_id_t srv_id;
67         ptl_md_t srv_md[RPC_RING_LENGTH];
68         ptl_handle_md_t srv_md_h[RPC_RING_LENGTH];
69         wait_queue_head_t *srv_wait_queue;
70         int (*srv_req_unpack)(char *buf, int len, struct ptlreq_hdr **, 
71                           union ptl_req *);
72         int (*srv_rep_pack)(char *buf1, int len1, char *buf2, int len2,
73                         struct ptlrep_hdr **, union ptl_rep*, 
74                         int *replen, char **repbuf); 
75 };
76
77 struct ptlrpc_request { 
78         int rq_type; /* one of PTLRPC_REQUEST, PTLRPC_REPLY, PTLRPC_BULK */
79         struct list_head rq_list;
80         struct mds_obd *rq_obd;
81         struct ost_obd *rq_ost;
82         int rq_status;
83         __u32 rq_xid;
84
85         char *rq_reqbuf;
86         int rq_reqlen;
87         struct ptlreq_hdr *rq_reqhdr;
88         union ptl_req rq_req;
89
90         char *rq_repbuf;
91         int rq_replen;
92         struct ptlrep_hdr *rq_rephdr;
93         union ptl_rep rq_rep;
94
95         char *rq_bulkbuf;
96         int rq_bulklen;
97         int (*rq_bulk_cb)(struct ptlrpc_request *, void *);
98
99         void *rq_reply_handle;
100         wait_queue_head_t rq_wait_for_rep;
101         wait_queue_head_t rq_wait_for_bulk;
102
103         ptl_md_t rq_reply_md;
104         ptl_handle_md_t rq_reply_md_h;
105         ptl_handle_me_t rq_reply_me_h;
106
107         ptl_md_t rq_req_md;
108         ptl_md_t rq_bulk_md;
109         ptl_handle_md_t rq_bulk_md_h;
110         ptl_handle_me_t rq_bulk_me_h;
111         __u32 rq_reply_portal;
112         __u32 rq_req_portal;
113         __u32 rq_bulk_portal;
114
115         struct lustre_peer rq_peer;
116 };
117
118 struct ptlrpc_client {
119         struct lustre_peer cli_server;
120         __u32 cli_request_portal;
121         __u32 cli_reply_portal;
122         __u32 cli_xid;
123         int (*cli_rep_unpack)(char *buf, int len, struct ptlrep_hdr **, 
124                           union ptl_rep *);
125         int (*cli_req_pack)(char *buf1, int len1, char *buf2, int len2,
126                         struct ptlreq_hdr **, union ptl_req*, 
127                         int *reqlen, char **reqbuf); 
128         int (*cli_enqueue)(struct ptlrpc_request *req);
129 };
130
131 /* rpc/rpc.c */
132 #define PTLRPC_REQUEST 1
133 #define PTLRPC_REPLY   2
134 #define PTLRPC_BULK    3
135
136 int ptl_send_buf(struct ptlrpc_request *request, struct lustre_peer *peer,
137                  int portal);
138 int ptl_send_rpc(struct ptlrpc_request *request, struct lustre_peer *peer);
139 int ptl_received_rpc(struct ptlrpc_service *service);
140 int rpc_register_service(struct ptlrpc_service *service, char *uuid);
141 int rpc_unregister_service(struct ptlrpc_service *service);
142 int ptlrpc_queue_wait(struct ptlrpc_request *req, 
143                       struct ptlrpc_client *cl);
144 struct ptlrpc_request *ptlrpc_prep_req(struct ptlrpc_client *cl, 
145                                        int opcode, int namelen, char *name,
146                                        int tgtlen, char *tgt);
147 void ptlrpc_free_req(struct ptlrpc_request *request);
148
149
150 /* FIXME */
151 #if 1
152 # define LUSTRE_NAL "ksocknal"
153 #else
154 # define LUSTRE_NAL "kqswnal"
155 #endif
156
157 #endif