root/include/linux/rpcsock.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


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

/* [previous][next][first][last][top][bottom][index][help] */