Import 2.2.0pre6
[davej-history.git] / include / linux / sunrpc / xprt.h
blob032293ea354861648f8c87180c94b1259018bee0
1 /*
2 * linux/include/linux/sunrpc/clnt_xprt.h
4 * Declarations for the RPC transport interface.
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
7 */
9 #ifndef _LINUX_SUNRPC_XPRT_H
10 #define _LINUX_SUNRPC_XPRT_H
12 #include <linux/uio.h>
13 #include <linux/socket.h>
14 #include <linux/in.h>
15 #include <linux/sunrpc/sched.h>
18 * Maximum number of iov's we use.
20 #define MAX_IOVEC 8
23 * The transport code maintains an estimate on the maximum number of out-
24 * standing RPC requests, using a smoothed version of the congestion
25 * avoidance implemented in 44BSD. This is basically the Van Jacobson
26 * slow start algorithm: If a retransmit occurs, the congestion window is
27 * halved; otherwise, it is incremented by 1/cwnd when
29 * - a reply is received and
30 * - a full number of requests are outstanding and
31 * - the congestion window hasn't been updated recently.
33 * Upper procedures may check whether a request would block waiting for
34 * a free RPC slot by using the RPC_CONGESTED() macro.
36 * Note: on machines with low memory we should probably use a smaller
37 * MAXREQS value: At 32 outstanding reqs with 8 megs of RAM, fragment
38 * reassembly will frequently run out of memory.
39 * Come Linux 2.3, we'll handle fragments directly.
41 #define RPC_MAXCONG 16
42 #define RPC_MAXREQS (RPC_MAXCONG + 1)
43 #define RPC_CWNDSCALE 256
44 #define RPC_MAXCWND (RPC_MAXCONG * RPC_CWNDSCALE)
45 #define RPC_INITCWND RPC_CWNDSCALE
46 #define RPCXPRT_CONGESTED(xprt) \
47 ((xprt)->cong >= ((xprt)->nocong? RPC_MAXCWND : (xprt)->cwnd))
49 /* Default timeout values */
50 #define RPC_MAX_UDP_TIMEOUT (6*HZ)
51 #define RPC_MAX_TCP_TIMEOUT (600*HZ)
53 /* RPC call and reply header size as number of 32bit words (verifier
54 * size computed separately)
56 #define RPC_CALLHDRSIZE 6
57 #define RPC_REPHDRSIZE 4
60 * This describes a timeout strategy
62 struct rpc_timeout {
63 unsigned long to_current, /* current timeout */
64 to_initval, /* initial timeout */
65 to_maxval, /* max timeout */
66 to_increment, /* if !exponential */
67 to_resrvval; /* reserve timeout */
68 short to_retries; /* max # of retries */
69 unsigned char to_exponential;
73 * This is the RPC buffer
75 struct rpc_iov {
76 struct iovec io_vec[MAX_IOVEC];
77 unsigned int io_nr;
78 unsigned int io_len;
82 * This describes a complete RPC request
84 struct rpc_rqst {
86 * This is the user-visible part
88 struct rpc_xprt * rq_xprt; /* RPC client */
89 struct rpc_timeout rq_timeout; /* timeout parms */
90 struct rpc_iov rq_snd_buf; /* send buffer */
91 struct rpc_iov rq_rcv_buf; /* recv buffer */
94 * This is the private part
96 struct rpc_task * rq_task; /* RPC task data */
97 __u32 rq_xid; /* request XID */
98 struct rpc_rqst * rq_next; /* free list */
99 unsigned char rq_gotit; /* reply received */
100 unsigned char rq_damaged; /* being received */
103 * For authentication (e.g. auth_des)
105 u32 rq_creddata[2];
108 * Partial send handling
111 u32 rq_bytes_sent; /* Bytes we have sent */
113 #ifdef RPC_PROFILE
114 unsigned long rq_xtime; /* when transmitted */
115 #endif
117 #define rq_svec rq_snd_buf.io_vec
118 #define rq_snr rq_snd_buf.io_nr
119 #define rq_slen rq_snd_buf.io_len
120 #define rq_rvec rq_rcv_buf.io_vec
121 #define rq_rnr rq_rcv_buf.io_nr
122 #define rq_rlen rq_rcv_buf.io_len
124 struct rpc_xprt {
125 struct rpc_xprt * link; /* list of all clients */
126 struct rpc_xprt * rx_pending; /* receive pending list */
128 int rx_pending_flag;/* are we on the pending list ? */
130 struct file * file; /* VFS layer */
131 struct socket * sock; /* BSD socket layer */
132 struct sock * inet; /* INET layer */
134 struct rpc_timeout timeout; /* timeout parms */
135 struct sockaddr_in addr; /* server address */
136 int prot; /* IP protocol */
138 unsigned long cong; /* current congestion */
139 unsigned long cwnd; /* congestion window */
140 unsigned long congtime; /* hold cwnd until then */
142 struct rpc_wait_queue sending; /* requests waiting to send */
143 struct rpc_wait_queue pending; /* requests in flight */
144 struct rpc_wait_queue backlog; /* waiting for slot */
145 struct rpc_wait_queue reconn; /* waiting for reconnect */
146 struct rpc_rqst * free; /* free slots */
147 struct rpc_rqst slot[RPC_MAXREQS];
148 unsigned char connected; /* TCP: connected */
149 unsigned char write_space; /* TCP: can send */
150 unsigned int shutdown : 1, /* being shut down */
151 nocong : 1, /* no congestion control */
152 stream : 1, /* TCP */
153 tcp_more : 1, /* more record fragments */
154 connecting : 1; /* being reconnected */
157 * State of TCP reply receive stuff
159 union { /* record marker & XID */
160 u32 header[2];
161 u8 data[8];
162 } tcp_recm;
163 struct rpc_rqst * tcp_rqstp;
164 struct iovec tcp_iovec[MAX_IOVEC];
165 u32 tcp_total; /* overall record length */
166 u32 tcp_reclen; /* fragment length */
167 u32 tcp_offset; /* fragment offset */
168 u32 tcp_copied; /* copied to request */
171 * TCP send stuff
173 struct rpc_iov snd_buf; /* send buffer */
174 struct rpc_task * snd_task; /* Task blocked in send */
175 u32 snd_sent; /* Bytes we have sent */
178 void (*old_data_ready)(struct sock *, int);
179 void (*old_state_change)(struct sock *);
180 void (*old_write_space)(struct sock *);
182 #define tcp_reclen tcp_recm.header[0]
183 #define tcp_xid tcp_recm.header[1]
185 #ifdef __KERNEL__
187 struct rpc_xprt * xprt_create(struct file *socket,
188 struct sockaddr_in *addr,
189 struct rpc_timeout *toparms);
190 struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr,
191 struct rpc_timeout *toparms);
192 int xprt_destroy(struct rpc_xprt *);
193 void xprt_default_timeout(struct rpc_timeout *, int);
194 void xprt_set_timeout(struct rpc_timeout *, unsigned int,
195 unsigned long);
197 int xprt_reserve(struct rpc_task *);
198 void xprt_transmit(struct rpc_task *);
199 void xprt_receive(struct rpc_task *);
200 int xprt_adjust_timeout(struct rpc_timeout *);
201 void xprt_release(struct rpc_task *);
202 void xprt_reconnect(struct rpc_task *);
204 #endif /* __KERNEL__*/
206 #endif /* _LINUX_SUNRPC_XPRT_H */