aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sunrpc/xprt.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sunrpc/xprt.h')
-rw-r--r--include/linux/sunrpc/xprt.h227
1 files changed, 148 insertions, 79 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index e618c1649814..3b8b6e823c70 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/include/linux/sunrpc/clnt_xprt.h 2 * linux/include/linux/sunrpc/xprt.h
3 * 3 *
4 * Declarations for the RPC transport interface. 4 * Declarations for the RPC transport interface.
5 * 5 *
@@ -15,20 +15,6 @@
15#include <linux/sunrpc/sched.h> 15#include <linux/sunrpc/sched.h>
16#include <linux/sunrpc/xdr.h> 16#include <linux/sunrpc/xdr.h>
17 17
18/*
19 * The transport code maintains an estimate on the maximum number of out-
20 * standing RPC requests, using a smoothed version of the congestion
21 * avoidance implemented in 44BSD. This is basically the Van Jacobson
22 * congestion algorithm: If a retransmit occurs, the congestion window is
23 * halved; otherwise, it is incremented by 1/cwnd when
24 *
25 * - a reply is received and
26 * - a full number of requests are outstanding and
27 * - the congestion window hasn't been updated recently.
28 *
29 * Upper procedures may check whether a request would block waiting for
30 * a free RPC slot by using the RPC_CONGESTED() macro.
31 */
32extern unsigned int xprt_udp_slot_table_entries; 18extern unsigned int xprt_udp_slot_table_entries;
33extern unsigned int xprt_tcp_slot_table_entries; 19extern unsigned int xprt_tcp_slot_table_entries;
34 20
@@ -36,34 +22,23 @@ extern unsigned int xprt_tcp_slot_table_entries;
36#define RPC_DEF_SLOT_TABLE (16U) 22#define RPC_DEF_SLOT_TABLE (16U)
37#define RPC_MAX_SLOT_TABLE (128U) 23#define RPC_MAX_SLOT_TABLE (128U)
38 24
39#define RPC_CWNDSHIFT (8U)
40#define RPC_CWNDSCALE (1U << RPC_CWNDSHIFT)
41#define RPC_INITCWND RPC_CWNDSCALE
42#define RPC_MAXCWND(xprt) ((xprt)->max_reqs << RPC_CWNDSHIFT)
43#define RPCXPRT_CONGESTED(xprt) ((xprt)->cong >= (xprt)->cwnd)
44
45/* Default timeout values */
46#define RPC_MAX_UDP_TIMEOUT (60*HZ)
47#define RPC_MAX_TCP_TIMEOUT (600*HZ)
48
49/* 25/*
50 * Wait duration for an RPC TCP connection to be established. Solaris 26 * RPC call and reply header size as number of 32bit words (verifier
51 * NFS over TCP uses 60 seconds, for example, which is in line with how 27 * size computed separately)
52 * long a server takes to reboot.
53 */ 28 */
54#define RPC_CONNECT_TIMEOUT (60*HZ) 29#define RPC_CALLHDRSIZE 6
30#define RPC_REPHDRSIZE 4
55 31
56/* 32/*
57 * Delay an arbitrary number of seconds before attempting to reconnect 33 * Parameters for choosing a free port
58 * after an error.
59 */ 34 */
60#define RPC_REESTABLISH_TIMEOUT (15*HZ) 35extern unsigned int xprt_min_resvport;
36extern unsigned int xprt_max_resvport;
61 37
62/* RPC call and reply header size as number of 32bit words (verifier 38#define RPC_MIN_RESVPORT (1U)
63 * size computed separately) 39#define RPC_MAX_RESVPORT (65535U)
64 */ 40#define RPC_DEF_MIN_RESVPORT (650U)
65#define RPC_CALLHDRSIZE 6 41#define RPC_DEF_MAX_RESVPORT (1023U)
66#define RPC_REPHDRSIZE 4
67 42
68/* 43/*
69 * This describes a timeout strategy 44 * This describes a timeout strategy
@@ -76,6 +51,9 @@ struct rpc_timeout {
76 unsigned char to_exponential; 51 unsigned char to_exponential;
77}; 52};
78 53
54struct rpc_task;
55struct rpc_xprt;
56
79/* 57/*
80 * This describes a complete RPC request 58 * This describes a complete RPC request
81 */ 59 */
@@ -95,7 +73,10 @@ struct rpc_rqst {
95 int rq_cong; /* has incremented xprt->cong */ 73 int rq_cong; /* has incremented xprt->cong */
96 int rq_received; /* receive completed */ 74 int rq_received; /* receive completed */
97 u32 rq_seqno; /* gss seq no. used on req. */ 75 u32 rq_seqno; /* gss seq no. used on req. */
98 76 int rq_enc_pages_num;
77 struct page **rq_enc_pages; /* scratch pages for use by
78 gss privacy code */
79 void (*rq_release_snd_buf)(struct rpc_rqst *); /* release rq_enc_pages */
99 struct list_head rq_list; 80 struct list_head rq_list;
100 81
101 struct xdr_buf rq_private_buf; /* The receive buffer 82 struct xdr_buf rq_private_buf; /* The receive buffer
@@ -121,12 +102,21 @@ struct rpc_rqst {
121#define rq_svec rq_snd_buf.head 102#define rq_svec rq_snd_buf.head
122#define rq_slen rq_snd_buf.len 103#define rq_slen rq_snd_buf.len
123 104
124#define XPRT_LAST_FRAG (1 << 0) 105struct rpc_xprt_ops {
125#define XPRT_COPY_RECM (1 << 1) 106 void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize);
126#define XPRT_COPY_XID (1 << 2) 107 int (*reserve_xprt)(struct rpc_task *task);
127#define XPRT_COPY_DATA (1 << 3) 108 void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
109 void (*connect)(struct rpc_task *task);
110 int (*send_request)(struct rpc_task *task);
111 void (*set_retrans_timeout)(struct rpc_task *task);
112 void (*timer)(struct rpc_task *task);
113 void (*release_request)(struct rpc_task *task);
114 void (*close)(struct rpc_xprt *xprt);
115 void (*destroy)(struct rpc_xprt *xprt);
116};
128 117
129struct rpc_xprt { 118struct rpc_xprt {
119 struct rpc_xprt_ops * ops; /* transport methods */
130 struct socket * sock; /* BSD socket layer */ 120 struct socket * sock; /* BSD socket layer */
131 struct sock * inet; /* INET layer */ 121 struct sock * inet; /* INET layer */
132 122
@@ -137,11 +127,13 @@ struct rpc_xprt {
137 unsigned long cong; /* current congestion */ 127 unsigned long cong; /* current congestion */
138 unsigned long cwnd; /* congestion window */ 128 unsigned long cwnd; /* congestion window */
139 129
140 unsigned int rcvsize, /* socket receive buffer size */ 130 size_t rcvsize, /* transport rcv buffer size */
141 sndsize; /* socket send buffer size */ 131 sndsize; /* transport send buffer size */
142 132
143 size_t max_payload; /* largest RPC payload size, 133 size_t max_payload; /* largest RPC payload size,
144 in bytes */ 134 in bytes */
135 unsigned int tsh_size; /* size of transport specific
136 header */
145 137
146 struct rpc_wait_queue sending; /* requests waiting to send */ 138 struct rpc_wait_queue sending; /* requests waiting to send */
147 struct rpc_wait_queue resend; /* requests waiting to resend */ 139 struct rpc_wait_queue resend; /* requests waiting to resend */
@@ -150,11 +142,9 @@ struct rpc_xprt {
150 struct list_head free; /* free slots */ 142 struct list_head free; /* free slots */
151 struct rpc_rqst * slot; /* slot table storage */ 143 struct rpc_rqst * slot; /* slot table storage */
152 unsigned int max_reqs; /* total slots */ 144 unsigned int max_reqs; /* total slots */
153 unsigned long sockstate; /* Socket state */ 145 unsigned long state; /* transport state */
154 unsigned char shutdown : 1, /* being shut down */ 146 unsigned char shutdown : 1, /* being shut down */
155 nocong : 1, /* no congestion control */ 147 resvport : 1; /* use a reserved port */
156 resvport : 1, /* use a reserved port */
157 stream : 1; /* TCP */
158 148
159 /* 149 /*
160 * XID 150 * XID
@@ -171,22 +161,27 @@ struct rpc_xprt {
171 unsigned long tcp_copied, /* copied to request */ 161 unsigned long tcp_copied, /* copied to request */
172 tcp_flags; 162 tcp_flags;
173 /* 163 /*
174 * Connection of sockets 164 * Connection of transports
175 */ 165 */
176 struct work_struct sock_connect; 166 unsigned long connect_timeout,
167 bind_timeout,
168 reestablish_timeout;
169 struct work_struct connect_worker;
177 unsigned short port; 170 unsigned short port;
171
178 /* 172 /*
179 * Disconnection of idle sockets 173 * Disconnection of idle transports
180 */ 174 */
181 struct work_struct task_cleanup; 175 struct work_struct task_cleanup;
182 struct timer_list timer; 176 struct timer_list timer;
183 unsigned long last_used; 177 unsigned long last_used,
178 idle_timeout;
184 179
185 /* 180 /*
186 * Send stuff 181 * Send stuff
187 */ 182 */
188 spinlock_t sock_lock; /* lock socket info */ 183 spinlock_t transport_lock; /* lock transport info */
189 spinlock_t xprt_lock; /* lock xprt info */ 184 spinlock_t reserve_lock; /* lock slot table */
190 struct rpc_task * snd_task; /* Task blocked in send */ 185 struct rpc_task * snd_task; /* Task blocked in send */
191 186
192 struct list_head recv; 187 struct list_head recv;
@@ -195,37 +190,111 @@ struct rpc_xprt {
195 void (*old_data_ready)(struct sock *, int); 190 void (*old_data_ready)(struct sock *, int);
196 void (*old_state_change)(struct sock *); 191 void (*old_state_change)(struct sock *);
197 void (*old_write_space)(struct sock *); 192 void (*old_write_space)(struct sock *);
198
199 wait_queue_head_t cong_wait;
200}; 193};
201 194
195#define XPRT_LAST_FRAG (1 << 0)
196#define XPRT_COPY_RECM (1 << 1)
197#define XPRT_COPY_XID (1 << 2)
198#define XPRT_COPY_DATA (1 << 3)
199
202#ifdef __KERNEL__ 200#ifdef __KERNEL__
203 201
204struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, 202/*
205 struct rpc_timeout *toparms); 203 * Transport operations used by ULPs
206int xprt_destroy(struct rpc_xprt *); 204 */
207void xprt_set_timeout(struct rpc_timeout *, unsigned int, 205struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, struct rpc_timeout *to);
208 unsigned long); 206void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr);
209 207
210void xprt_reserve(struct rpc_task *); 208/*
211int xprt_prepare_transmit(struct rpc_task *); 209 * Generic internal transport functions
212void xprt_transmit(struct rpc_task *); 210 */
213void xprt_receive(struct rpc_task *); 211void xprt_connect(struct rpc_task *task);
212void xprt_reserve(struct rpc_task *task);
213int xprt_reserve_xprt(struct rpc_task *task);
214int xprt_reserve_xprt_cong(struct rpc_task *task);
215int xprt_prepare_transmit(struct rpc_task *task);
216void xprt_transmit(struct rpc_task *task);
217void xprt_abort_transmit(struct rpc_task *task);
214int xprt_adjust_timeout(struct rpc_rqst *req); 218int xprt_adjust_timeout(struct rpc_rqst *req);
215void xprt_release(struct rpc_task *); 219void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
216void xprt_connect(struct rpc_task *); 220void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
217void xprt_sock_setbufsize(struct rpc_xprt *); 221void xprt_release(struct rpc_task *task);
218 222int xprt_destroy(struct rpc_xprt *xprt);
219#define XPRT_LOCKED 0 223
220#define XPRT_CONNECT 1 224static inline u32 *xprt_skip_transport_header(struct rpc_xprt *xprt, u32 *p)
221#define XPRT_CONNECTING 2 225{
222 226 return p + xprt->tsh_size;
223#define xprt_connected(xp) (test_bit(XPRT_CONNECT, &(xp)->sockstate)) 227}
224#define xprt_set_connected(xp) (set_bit(XPRT_CONNECT, &(xp)->sockstate)) 228
225#define xprt_test_and_set_connected(xp) (test_and_set_bit(XPRT_CONNECT, &(xp)->sockstate)) 229/*
226#define xprt_test_and_clear_connected(xp) \ 230 * Transport switch helper functions
227 (test_and_clear_bit(XPRT_CONNECT, &(xp)->sockstate)) 231 */
228#define xprt_clear_connected(xp) (clear_bit(XPRT_CONNECT, &(xp)->sockstate)) 232void xprt_set_retrans_timeout_def(struct rpc_task *task);
233void xprt_set_retrans_timeout_rtt(struct rpc_task *task);
234void xprt_wake_pending_tasks(struct rpc_xprt *xprt, int status);
235void xprt_wait_for_buffer_space(struct rpc_task *task);
236void xprt_write_space(struct rpc_xprt *xprt);
237void xprt_update_rtt(struct rpc_task *task);
238void xprt_adjust_cwnd(struct rpc_task *task, int result);
239struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid);
240void xprt_complete_rqst(struct rpc_task *task, int copied);
241void xprt_release_rqst_cong(struct rpc_task *task);
242void xprt_disconnect(struct rpc_xprt *xprt);
243
244/*
245 * Socket transport setup operations
246 */
247int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to);
248int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to);
249
250/*
251 * Reserved bit positions in xprt->state
252 */
253#define XPRT_LOCKED (0)
254#define XPRT_CONNECTED (1)
255#define XPRT_CONNECTING (2)
256
257static inline void xprt_set_connected(struct rpc_xprt *xprt)
258{
259 set_bit(XPRT_CONNECTED, &xprt->state);
260}
261
262static inline void xprt_clear_connected(struct rpc_xprt *xprt)
263{
264 clear_bit(XPRT_CONNECTED, &xprt->state);
265}
266
267static inline int xprt_connected(struct rpc_xprt *xprt)
268{
269 return test_bit(XPRT_CONNECTED, &xprt->state);
270}
271
272static inline int xprt_test_and_set_connected(struct rpc_xprt *xprt)
273{
274 return test_and_set_bit(XPRT_CONNECTED, &xprt->state);
275}
276
277static inline int xprt_test_and_clear_connected(struct rpc_xprt *xprt)
278{
279 return test_and_clear_bit(XPRT_CONNECTED, &xprt->state);
280}
281
282static inline void xprt_clear_connecting(struct rpc_xprt *xprt)
283{
284 smp_mb__before_clear_bit();
285 clear_bit(XPRT_CONNECTING, &xprt->state);
286 smp_mb__after_clear_bit();
287}
288
289static inline int xprt_connecting(struct rpc_xprt *xprt)
290{
291 return test_bit(XPRT_CONNECTING, &xprt->state);
292}
293
294static inline int xprt_test_and_set_connecting(struct rpc_xprt *xprt)
295{
296 return test_and_set_bit(XPRT_CONNECTING, &xprt->state);
297}
229 298
230#endif /* __KERNEL__*/ 299#endif /* __KERNEL__*/
231 300