rpcsock.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:3k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  rpcsock.h Declarations for the RPC call interface.
  3.  *
  4.  *  Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  5.  */
  6. #ifndef _LINUX_RPCSOCK_H
  7. #define _LINUX_RPCSOCK_H
  8. /*
  9.  * The rpcsock code maintains an estimate on the maximum number of out-
  10.  * standing RPC requests, using the congestion avoidance implemented in
  11.  * 44BSD. This is basically the Van Jacobson slow start algorithm: If a
  12.  * retransmit occurs, the congestion window is halved; otherwise, it is
  13.  * incremented by 1/cwnd when a reply is received and a full number of
  14.  * requests are outstanding.
  15.  *
  16.  * Upper procedures may check whether a request would block waiting for
  17.  * a free RPC slot by using the RPC_CONGESTED() macro.
  18.  *
  19.  * Note: on machines with low memory we should probably use a smaller
  20.  * MAXREQS value: At 32 outstanding reqs with 8 megs of RAM, fragment
  21.  * reassembly will frequently run out of memory.
  22.  */
  23. #define RPC_MAXREQS 32
  24. #define RPC_CWNDSCALE 256
  25. #define RPC_MAXCWND (RPC_MAXREQS * RPC_CWNDSCALE)
  26. /* #define RPC_INITCWND (RPC_MAXCWND / 2) */
  27. #define RPC_INITCWND RPC_CWNDSCALE
  28. #define RPC_CONGESTED(rsock) ((rsock)->cong >= (rsock)->cwnd)
  29. /* RPC reply header size: xid, direction, status, accept_status (verifier
  30.  * size computed separately)
  31.  */
  32. #define RPC_HDRSIZE (4 * 4)
  33. /*
  34.  * This describes a timeout strategy
  35.  */
  36. struct rpc_timeout {
  37. unsigned long to_initval,
  38. to_maxval,
  39. to_increment;
  40. int to_retries;
  41. char to_exponential;
  42. };
  43. /*
  44.  * This describes a complete RPC request
  45.  */
  46. struct rpc_ioreq {
  47. struct rpc_wait * rq_slot;
  48. struct sockaddr * rq_addr;
  49. int rq_alen;
  50. struct iovec rq_svec[UIO_FASTIOV];
  51. unsigned int rq_snr;
  52. unsigned long rq_slen;
  53. struct iovec rq_rvec[UIO_FASTIOV];
  54. unsigned int rq_rnr;
  55. unsigned long rq_rlen;
  56. };
  57. /*
  58.  * This is the callback handler for async RPC.
  59.  */
  60. struct rpc_wait;
  61. typedef void (*rpc_callback_fn_t)(int, struct rpc_wait *, void *);
  62. /*
  63.  * Wait information. This struct defines all the state of an RPC
  64.  * request currently in flight.
  65.  */
  66. struct rpc_wait {
  67. struct rpc_sock * w_sock;
  68. struct rpc_wait * w_prev;
  69. struct rpc_wait * w_next;
  70. struct rpc_ioreq * w_req;
  71. int w_result;
  72. wait_queue_head_t  w_wait;
  73. rpc_callback_fn_t w_handler;
  74. void * w_cdata;
  75. char w_queued;
  76. char w_gotit;
  77. __u32 w_xid;
  78. };
  79. struct rpc_sock {
  80. struct file * file;
  81. struct socket * sock;
  82. struct sock * inet;
  83. struct rpc_wait waiting[RPC_MAXREQS];
  84. unsigned long cong;
  85. unsigned long cwnd;
  86. struct rpc_wait * pending;
  87. struct rpc_wait * free;
  88. wait_queue_head_t backlog;
  89. wait_queue_head_t shutwait;
  90. int shutdown;
  91. };
  92. #ifdef __KERNEL__
  93. /* rpc_call: Call synchronously */
  94. int rpc_call(struct rpc_sock *, struct rpc_ioreq *,
  95.  struct rpc_timeout *);
  96. /* These implement asynch calls for nfsiod: Process calls rpc_reserve and
  97.  * rpc_transmits, then passes the request to nfsiod, which collects the
  98.  * results via rpc_doio
  99.  */
  100. int rpc_reserve(struct rpc_sock *, struct rpc_ioreq *, int);
  101. void rpc_release(struct rpc_sock *, struct rpc_ioreq *);
  102. int rpc_transmit(struct rpc_sock *, struct rpc_ioreq *);
  103. int rpc_doio(struct rpc_sock *, struct rpc_ioreq *,
  104.  struct rpc_timeout *, int);
  105. struct rpc_sock * rpc_makesock(struct file *);
  106. int rpc_closesock(struct rpc_sock *);
  107. #endif /* __KERNEL__*/
  108. #endif /* _LINUX_RPCSOCK_H */