2 * linux/include/linux/sunrpc/svc.h
4 * RPC server declarations.
6 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
13 #include <linux/sunrpc/types.h>
14 #include <linux/sunrpc/xdr.h>
15 #include <linux/sunrpc/svcauth.h>
20 * An RPC service is a ``daemon,'' possibly multithreaded, which
21 * receives and processes incoming RPC messages.
22 * It has one or more transport sockets associated with it, and maintains
23 * a list of idle threads waiting for input.
25 * We currently do not support more than one RPC program per daemon.
28 struct svc_rqst
* sv_threads
; /* idle server threads */
29 struct svc_sock
* sv_sockets
; /* pending sockets */
30 struct svc_program
* sv_program
; /* RPC program */
31 struct svc_stat
* sv_stats
; /* RPC statistics */
32 unsigned int sv_nrthreads
; /* # of server threads */
33 unsigned int sv_bufsz
; /* datagram buffer size */
34 unsigned int sv_xdrsize
; /* XDR buffer size */
36 struct svc_sock
* sv_allsocks
; /* all sockets */
38 char * sv_name
; /* service name */
42 * Maximum payload size supported by a kernel RPC server.
43 * This is use to determine the max number of pages nfsd is
44 * willing to return in a single READ operation.
46 #define RPCSVC_MAXPAYLOAD 16384u
49 * Buffer to store RPC requests or replies in.
50 * Each server thread has one of these beasts.
52 * Area points to the allocated memory chunk currently owned by the
53 * buffer. Base points to the buffer containing the request, which is
54 * different from area when directly reading from an sk_buff. buf is
55 * the current read/write position while processing an RPC request.
57 * The array of iovecs can hold additional data that the server process
58 * may not want to copy into the RPC reply buffer, but pass to the
59 * network sendmsg routines directly. The prime candidate for this
60 * will of course be NFS READ operations, but one might also want to
61 * do something about READLINK and READDIR. It might be worthwhile
62 * to implement some generic readdir cache in the VFS layer...
64 * On the receiving end of the RPC server, the iovec may be used to hold
65 * the list of IP fragments once we get to process fragmented UDP
68 #define RPCSVC_MAXIOV ((RPCSVC_MAXPAYLOAD+PAGE_SIZE-1)/PAGE_SIZE + 1)
70 u32
* area
; /* allocated memory */
71 u32
* base
; /* base of RPC datagram */
72 int buflen
; /* total length of buffer */
73 u32
* buf
; /* read/write pointer */
74 int len
; /* current end of buffer */
76 /* iovec for zero-copy NFS READs */
77 struct iovec iov
[RPCSVC_MAXIOV
];
80 #define svc_getlong(argp, val) { (val) = *(argp)->buf++; (argp)->len--; }
81 #define svc_putlong(resp, val) { *(resp)->buf++ = (val); (resp)->len++; }
84 * The context of a single thread, including the request currently being
86 * NOTE: First two items must be prev/next.
89 struct svc_rqst
* rq_prev
; /* idle list */
90 struct svc_rqst
* rq_next
;
91 struct svc_sock
* rq_sock
; /* socket */
92 struct sockaddr_in rq_addr
; /* peer address */
95 struct svc_serv
* rq_server
; /* RPC service definition */
96 struct svc_procedure
* rq_procinfo
; /* procedure info */
97 struct svc_cred rq_cred
; /* auth info */
98 struct sk_buff
* rq_skbuff
; /* fast recv inet buffer */
99 struct svc_buf rq_defbuf
; /* default buffer */
100 struct svc_buf rq_argbuf
; /* argument buffer */
101 struct svc_buf rq_resbuf
; /* result buffer */
102 u32 rq_xid
; /* transmission id */
103 u32 rq_prog
; /* program number */
104 u32 rq_vers
; /* program version */
105 u32 rq_proc
; /* procedure number */
106 u32 rq_prot
; /* IP protocol */
107 unsigned short rq_verfed
: 1, /* reply has verifier */
108 rq_userset
: 1, /* auth->setuser OK */
109 rq_secure
: 1, /* secure port */
110 rq_auth
: 1; /* check client */
112 void * rq_argp
; /* decoded arguments */
113 void * rq_resp
; /* xdr'd results */
115 /* Catering to nfsd */
116 struct svc_client
* rq_client
; /* RPC peer info */
117 struct svc_cacherep
* rq_cacherep
; /* cache info */
119 wait_queue_head_t rq_wait
; /* synchronozation */
126 u32 pg_prog
; /* program number */
127 unsigned int pg_lovers
; /* lowest version */
128 unsigned int pg_hivers
; /* lowest version */
129 unsigned int pg_nvers
; /* number of versions */
130 struct svc_version
** pg_vers
; /* version array */
131 char * pg_name
; /* service name */
132 struct svc_stat
* pg_stats
; /* rpc statistics */
136 * RPC program version
139 u32 vs_vers
; /* version number */
140 u32 vs_nproc
; /* number of procedures */
141 struct svc_procedure
* vs_proc
; /* per-procedure info */
143 /* Override dispatch function (e.g. when caching replies).
144 * A return value of 0 means drop the request.
145 * vs_dispatch == NULL means use default dispatcher.
147 int (*vs_dispatch
)(struct svc_rqst
*, u32
*);
153 typedef int (*svc_procfunc
)(struct svc_rqst
*, void *argp
, void *resp
);
154 struct svc_procedure
{
155 svc_procfunc pc_func
; /* process the request */
156 kxdrproc_t pc_decode
; /* XDR decode args */
157 kxdrproc_t pc_encode
; /* XDR encode result */
158 kxdrproc_t pc_release
; /* XDR free result */
159 unsigned int pc_argsize
; /* argument struct size */
160 unsigned int pc_ressize
; /* result struct size */
161 unsigned int pc_count
; /* call count */
162 unsigned int pc_cachetype
; /* cache info (NFS) */
166 * This is the RPC server thread function prototype
168 typedef void (*svc_thread_fn
)(struct svc_rqst
*);
171 * Function prototypes.
173 struct svc_serv
* svc_create(struct svc_program
*, unsigned int, unsigned int);
174 int svc_create_thread(svc_thread_fn
, struct svc_serv
*);
175 void svc_exit_thread(struct svc_rqst
*);
176 void svc_destroy(struct svc_serv
*);
177 int svc_process(struct svc_serv
*, struct svc_rqst
*);
178 int svc_register(struct svc_serv
*, int, unsigned short);
179 void svc_wake_up(struct svc_serv
*);
181 #endif /* SUNRPC_SVC_H */