diff options
Diffstat (limited to 'include/linux/sunrpc/xprt.h')
| -rw-r--r-- | include/linux/sunrpc/xprt.h | 68 |
1 files changed, 57 insertions, 11 deletions
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index e8bbe8118de8..6cf626580752 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/uio.h> | 12 | #include <linux/uio.h> |
| 13 | #include <linux/socket.h> | 13 | #include <linux/socket.h> |
| 14 | #include <linux/in.h> | 14 | #include <linux/in.h> |
| 15 | #include <linux/kref.h> | ||
| 15 | #include <linux/sunrpc/sched.h> | 16 | #include <linux/sunrpc/sched.h> |
| 16 | #include <linux/sunrpc/xdr.h> | 17 | #include <linux/sunrpc/xdr.h> |
| 17 | 18 | ||
| @@ -37,7 +38,7 @@ extern unsigned int xprt_max_resvport; | |||
| 37 | 38 | ||
| 38 | #define RPC_MIN_RESVPORT (1U) | 39 | #define RPC_MIN_RESVPORT (1U) |
| 39 | #define RPC_MAX_RESVPORT (65535U) | 40 | #define RPC_MAX_RESVPORT (65535U) |
| 40 | #define RPC_DEF_MIN_RESVPORT (650U) | 41 | #define RPC_DEF_MIN_RESVPORT (665U) |
| 41 | #define RPC_DEF_MAX_RESVPORT (1023U) | 42 | #define RPC_DEF_MAX_RESVPORT (1023U) |
| 42 | 43 | ||
| 43 | /* | 44 | /* |
| @@ -51,6 +52,14 @@ struct rpc_timeout { | |||
| 51 | unsigned char to_exponential; | 52 | unsigned char to_exponential; |
| 52 | }; | 53 | }; |
| 53 | 54 | ||
| 55 | enum rpc_display_format_t { | ||
| 56 | RPC_DISPLAY_ADDR = 0, | ||
| 57 | RPC_DISPLAY_PORT, | ||
| 58 | RPC_DISPLAY_PROTO, | ||
| 59 | RPC_DISPLAY_ALL, | ||
| 60 | RPC_DISPLAY_MAX, | ||
| 61 | }; | ||
| 62 | |||
| 54 | struct rpc_task; | 63 | struct rpc_task; |
| 55 | struct rpc_xprt; | 64 | struct rpc_xprt; |
| 56 | struct seq_file; | 65 | struct seq_file; |
| @@ -70,7 +79,7 @@ struct rpc_rqst { | |||
| 70 | * This is the private part | 79 | * This is the private part |
| 71 | */ | 80 | */ |
| 72 | struct rpc_task * rq_task; /* RPC task data */ | 81 | struct rpc_task * rq_task; /* RPC task data */ |
| 73 | __u32 rq_xid; /* request XID */ | 82 | __be32 rq_xid; /* request XID */ |
| 74 | int rq_cong; /* has incremented xprt->cong */ | 83 | int rq_cong; /* has incremented xprt->cong */ |
| 75 | int rq_received; /* receive completed */ | 84 | int rq_received; /* receive completed */ |
| 76 | u32 rq_seqno; /* gss seq no. used on req. */ | 85 | u32 rq_seqno; /* gss seq no. used on req. */ |
| @@ -103,8 +112,10 @@ struct rpc_rqst { | |||
| 103 | 112 | ||
| 104 | struct rpc_xprt_ops { | 113 | struct rpc_xprt_ops { |
| 105 | void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize); | 114 | void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize); |
| 115 | char * (*print_addr)(struct rpc_xprt *xprt, enum rpc_display_format_t format); | ||
| 106 | int (*reserve_xprt)(struct rpc_task *task); | 116 | int (*reserve_xprt)(struct rpc_task *task); |
| 107 | void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); | 117 | void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); |
| 118 | void (*rpcbind)(struct rpc_task *task); | ||
| 108 | void (*set_port)(struct rpc_xprt *xprt, unsigned short port); | 119 | void (*set_port)(struct rpc_xprt *xprt, unsigned short port); |
| 109 | void (*connect)(struct rpc_task *task); | 120 | void (*connect)(struct rpc_task *task); |
| 110 | void * (*buf_alloc)(struct rpc_task *task, size_t size); | 121 | void * (*buf_alloc)(struct rpc_task *task, size_t size); |
| @@ -119,12 +130,14 @@ struct rpc_xprt_ops { | |||
| 119 | }; | 130 | }; |
| 120 | 131 | ||
| 121 | struct rpc_xprt { | 132 | struct rpc_xprt { |
| 133 | struct kref kref; /* Reference count */ | ||
| 122 | struct rpc_xprt_ops * ops; /* transport methods */ | 134 | struct rpc_xprt_ops * ops; /* transport methods */ |
| 123 | struct socket * sock; /* BSD socket layer */ | 135 | struct socket * sock; /* BSD socket layer */ |
| 124 | struct sock * inet; /* INET layer */ | 136 | struct sock * inet; /* INET layer */ |
| 125 | 137 | ||
| 126 | struct rpc_timeout timeout; /* timeout parms */ | 138 | struct rpc_timeout timeout; /* timeout parms */ |
| 127 | struct sockaddr_in addr; /* server address */ | 139 | struct sockaddr_storage addr; /* server address */ |
| 140 | size_t addrlen; /* size of server address */ | ||
| 128 | int prot; /* IP protocol */ | 141 | int prot; /* IP protocol */ |
| 129 | 142 | ||
| 130 | unsigned long cong; /* current congestion */ | 143 | unsigned long cong; /* current congestion */ |
| @@ -138,6 +151,7 @@ struct rpc_xprt { | |||
| 138 | unsigned int tsh_size; /* size of transport specific | 151 | unsigned int tsh_size; /* size of transport specific |
| 139 | header */ | 152 | header */ |
| 140 | 153 | ||
| 154 | struct rpc_wait_queue binding; /* requests waiting on rpcbind */ | ||
| 141 | struct rpc_wait_queue sending; /* requests waiting to send */ | 155 | struct rpc_wait_queue sending; /* requests waiting to send */ |
| 142 | struct rpc_wait_queue resend; /* requests waiting to resend */ | 156 | struct rpc_wait_queue resend; /* requests waiting to resend */ |
| 143 | struct rpc_wait_queue pending; /* requests in flight */ | 157 | struct rpc_wait_queue pending; /* requests in flight */ |
| @@ -157,9 +171,9 @@ struct rpc_xprt { | |||
| 157 | /* | 171 | /* |
| 158 | * State of TCP reply receive stuff | 172 | * State of TCP reply receive stuff |
| 159 | */ | 173 | */ |
| 160 | u32 tcp_recm, /* Fragment header */ | 174 | __be32 tcp_recm, /* Fragment header */ |
| 161 | tcp_xid, /* Current XID */ | 175 | tcp_xid; /* Current XID */ |
| 162 | tcp_reclen, /* fragment length */ | 176 | u32 tcp_reclen, /* fragment length */ |
| 163 | tcp_offset; /* fragment offset */ | 177 | tcp_offset; /* fragment offset */ |
| 164 | unsigned long tcp_copied, /* copied to request */ | 178 | unsigned long tcp_copied, /* copied to request */ |
| 165 | tcp_flags; | 179 | tcp_flags; |
| @@ -205,6 +219,8 @@ struct rpc_xprt { | |||
| 205 | void (*old_data_ready)(struct sock *, int); | 219 | void (*old_data_ready)(struct sock *, int); |
| 206 | void (*old_state_change)(struct sock *); | 220 | void (*old_state_change)(struct sock *); |
| 207 | void (*old_write_space)(struct sock *); | 221 | void (*old_write_space)(struct sock *); |
| 222 | |||
| 223 | char * address_strings[RPC_DISPLAY_MAX]; | ||
| 208 | }; | 224 | }; |
| 209 | 225 | ||
| 210 | #define XPRT_LAST_FRAG (1 << 0) | 226 | #define XPRT_LAST_FRAG (1 << 0) |
| @@ -217,26 +233,27 @@ struct rpc_xprt { | |||
| 217 | /* | 233 | /* |
| 218 | * Transport operations used by ULPs | 234 | * Transport operations used by ULPs |
| 219 | */ | 235 | */ |
| 220 | struct rpc_xprt * xprt_create_proto(int proto, struct sockaddr_in *addr, struct rpc_timeout *to); | ||
| 221 | void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr); | 236 | void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr); |
| 222 | 237 | ||
| 223 | /* | 238 | /* |
| 224 | * Generic internal transport functions | 239 | * Generic internal transport functions |
| 225 | */ | 240 | */ |
| 241 | struct rpc_xprt * xprt_create_transport(int proto, struct sockaddr *addr, size_t size, struct rpc_timeout *toparms); | ||
| 226 | void xprt_connect(struct rpc_task *task); | 242 | void xprt_connect(struct rpc_task *task); |
| 227 | void xprt_reserve(struct rpc_task *task); | 243 | void xprt_reserve(struct rpc_task *task); |
| 228 | int xprt_reserve_xprt(struct rpc_task *task); | 244 | int xprt_reserve_xprt(struct rpc_task *task); |
| 229 | int xprt_reserve_xprt_cong(struct rpc_task *task); | 245 | int xprt_reserve_xprt_cong(struct rpc_task *task); |
| 230 | int xprt_prepare_transmit(struct rpc_task *task); | 246 | int xprt_prepare_transmit(struct rpc_task *task); |
| 231 | void xprt_transmit(struct rpc_task *task); | 247 | void xprt_transmit(struct rpc_task *task); |
| 232 | void xprt_abort_transmit(struct rpc_task *task); | 248 | void xprt_end_transmit(struct rpc_task *task); |
| 233 | int xprt_adjust_timeout(struct rpc_rqst *req); | 249 | int xprt_adjust_timeout(struct rpc_rqst *req); |
| 234 | void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task); | 250 | void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task); |
| 235 | void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task); | 251 | void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task); |
| 236 | void xprt_release(struct rpc_task *task); | 252 | void xprt_release(struct rpc_task *task); |
| 237 | int xprt_destroy(struct rpc_xprt *xprt); | 253 | struct rpc_xprt * xprt_get(struct rpc_xprt *xprt); |
| 254 | void xprt_put(struct rpc_xprt *xprt); | ||
| 238 | 255 | ||
| 239 | static inline u32 *xprt_skip_transport_header(struct rpc_xprt *xprt, u32 *p) | 256 | static inline __be32 *xprt_skip_transport_header(struct rpc_xprt *xprt, __be32 *p) |
| 240 | { | 257 | { |
| 241 | return p + xprt->tsh_size; | 258 | return p + xprt->tsh_size; |
| 242 | } | 259 | } |
| @@ -251,7 +268,7 @@ void xprt_wait_for_buffer_space(struct rpc_task *task); | |||
| 251 | void xprt_write_space(struct rpc_xprt *xprt); | 268 | void xprt_write_space(struct rpc_xprt *xprt); |
| 252 | void xprt_update_rtt(struct rpc_task *task); | 269 | void xprt_update_rtt(struct rpc_task *task); |
| 253 | void xprt_adjust_cwnd(struct rpc_task *task, int result); | 270 | void xprt_adjust_cwnd(struct rpc_task *task, int result); |
| 254 | struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, u32 xid); | 271 | struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, __be32 xid); |
| 255 | void xprt_complete_rqst(struct rpc_task *task, int copied); | 272 | void xprt_complete_rqst(struct rpc_task *task, int copied); |
| 256 | void xprt_release_rqst_cong(struct rpc_task *task); | 273 | void xprt_release_rqst_cong(struct rpc_task *task); |
| 257 | void xprt_disconnect(struct rpc_xprt *xprt); | 274 | void xprt_disconnect(struct rpc_xprt *xprt); |
| @@ -269,6 +286,8 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to); | |||
| 269 | #define XPRT_CONNECTED (1) | 286 | #define XPRT_CONNECTED (1) |
| 270 | #define XPRT_CONNECTING (2) | 287 | #define XPRT_CONNECTING (2) |
| 271 | #define XPRT_CLOSE_WAIT (3) | 288 | #define XPRT_CLOSE_WAIT (3) |
| 289 | #define XPRT_BOUND (4) | ||
| 290 | #define XPRT_BINDING (5) | ||
| 272 | 291 | ||
| 273 | static inline void xprt_set_connected(struct rpc_xprt *xprt) | 292 | static inline void xprt_set_connected(struct rpc_xprt *xprt) |
| 274 | { | 293 | { |
| @@ -312,6 +331,33 @@ static inline int xprt_test_and_set_connecting(struct rpc_xprt *xprt) | |||
| 312 | return test_and_set_bit(XPRT_CONNECTING, &xprt->state); | 331 | return test_and_set_bit(XPRT_CONNECTING, &xprt->state); |
| 313 | } | 332 | } |
| 314 | 333 | ||
| 334 | static inline void xprt_set_bound(struct rpc_xprt *xprt) | ||
| 335 | { | ||
| 336 | test_and_set_bit(XPRT_BOUND, &xprt->state); | ||
| 337 | } | ||
| 338 | |||
| 339 | static inline int xprt_bound(struct rpc_xprt *xprt) | ||
| 340 | { | ||
| 341 | return test_bit(XPRT_BOUND, &xprt->state); | ||
| 342 | } | ||
| 343 | |||
| 344 | static inline void xprt_clear_bound(struct rpc_xprt *xprt) | ||
| 345 | { | ||
| 346 | clear_bit(XPRT_BOUND, &xprt->state); | ||
| 347 | } | ||
| 348 | |||
| 349 | static inline void xprt_clear_binding(struct rpc_xprt *xprt) | ||
| 350 | { | ||
| 351 | smp_mb__before_clear_bit(); | ||
| 352 | clear_bit(XPRT_BINDING, &xprt->state); | ||
| 353 | smp_mb__after_clear_bit(); | ||
| 354 | } | ||
| 355 | |||
| 356 | static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt) | ||
| 357 | { | ||
| 358 | return test_and_set_bit(XPRT_BINDING, &xprt->state); | ||
| 359 | } | ||
| 360 | |||
| 315 | #endif /* __KERNEL__*/ | 361 | #endif /* __KERNEL__*/ |
| 316 | 362 | ||
| 317 | #endif /* _LINUX_SUNRPC_XPRT_H */ | 363 | #endif /* _LINUX_SUNRPC_XPRT_H */ |
