blob: d86acc63b25fa1220ecd1bd1a4b237dd2b3689d2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/linux/sunrpc/clnt.h
3 *
4 * Declarations for the high-level RPC client interface
5 *
6 * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#ifndef _LINUX_SUNRPC_CLNT_H
10#define _LINUX_SUNRPC_CLNT_H
11
Trond Myklebustd77385f2011-10-17 16:08:10 -070012#include <linux/types.h>
Chuck Levera02d6922009-08-09 15:09:34 -040013#include <linux/socket.h>
14#include <linux/in.h>
15#include <linux/in6.h>
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/sunrpc/msg_prot.h>
18#include <linux/sunrpc/sched.h>
19#include <linux/sunrpc/xprt.h>
20#include <linux/sunrpc/auth.h>
21#include <linux/sunrpc/stats.h>
22#include <linux/sunrpc/xdr.h>
23#include <linux/sunrpc/timer.h>
Trond Myklebust6739ffb2013-08-26 15:38:11 -040024#include <linux/sunrpc/rpc_pipe_fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <asm/signal.h>
Trond Myklebust7d217ca2009-08-09 15:14:24 -040026#include <linux/path.h>
Jeff Layton4516fc02009-08-14 12:57:54 -040027#include <net/ipv6.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Linus Torvalds1da177e2005-04-16 15:20:36 -070029struct rpc_inode;
30
31/*
32 * The high-level client handle
33 */
34struct rpc_clnt {
Trond Myklebust006abe82010-09-12 19:55:25 -040035 atomic_t cl_count; /* Number of references */
Trond Myklebust2f048db2013-09-04 21:51:44 -040036 unsigned int cl_clid; /* client id */
Trond Myklebust6529eba2007-06-14 16:40:14 -040037 struct list_head cl_clients; /* Global list of clients */
38 struct list_head cl_tasks; /* List of tasks */
Trond Myklebust4bef61f2007-06-16 14:17:01 -040039 spinlock_t cl_lock; /* spinlock */
Trond Myklebust2446ab62012-03-01 17:00:56 -050040 struct rpc_xprt __rcu * cl_xprt; /* transport */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 struct rpc_procinfo * cl_procinfo; /* procedure info */
Chuck Lever4a681792006-08-22 20:06:15 -040042 u32 cl_prog, /* RPC program number */
43 cl_vers, /* RPC version number */
44 cl_maxproc; /* max procedure number */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 struct rpc_auth * cl_auth; /* authenticator */
Chuck Lever11c556b2006-03-20 13:44:22 -050047 struct rpc_stat * cl_stats; /* per-program statistics */
48 struct rpc_iostats * cl_metrics; /* per-client statistics */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 unsigned int cl_softrtry : 1,/* soft timeouts */
Chuck Lever43d78ef2007-02-06 18:26:11 -050051 cl_discrtry : 1,/* disconnect before retry */
Trond Myklebust8a19a0b2013-09-24 12:00:27 -040052 cl_noretranstimeo: 1,/* No retransmit timeouts */
Olga Kornievskaiab6b61522008-06-09 16:51:31 -040053 cl_autobind : 1,/* use getport() */
54 cl_chatty : 1;/* be verbose */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56 struct rpc_rtt * cl_rtt; /* RTO estimator data */
Trond Myklebustba7392b2007-12-20 16:03:55 -050057 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59 int cl_nodelen; /* nodename length */
60 char cl_nodename[UNX_MAXNODENAME];
Trond Myklebust6739ffb2013-08-26 15:38:11 -040061 struct rpc_pipe_dir_head cl_pipedir_objects;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 struct rpc_clnt * cl_parent; /* Points to parent of clones */
63 struct rpc_rtt cl_rtt_default;
Trond Myklebustba7392b2007-12-20 16:03:55 -050064 struct rpc_timeout cl_timeout_default;
Trond Myklebusta613fa12012-01-20 13:53:56 -050065 const struct rpc_program *cl_program;
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -050066#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
67 struct dentry *cl_debugfs; /* debugfs directory */
68#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070069};
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71/*
72 * General RPC program info
73 */
74#define RPC_MAXVERSION 4
75struct rpc_program {
Trond Myklebust080b7942012-01-20 13:53:56 -050076 const char * name; /* protocol name */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 u32 number; /* program number */
78 unsigned int nrvers; /* number of versions */
Trond Myklebusta613fa12012-01-20 13:53:56 -050079 const struct rpc_version ** version; /* version array */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct rpc_stat * stats; /* statistics */
Trond Myklebust080b7942012-01-20 13:53:56 -050081 const char * pipe_dir_name; /* path to rpc_pipefs dir */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
84struct rpc_version {
85 u32 number; /* version number */
86 unsigned int nrprocs; /* number of procs */
87 struct rpc_procinfo * procs; /* procedure array */
88};
89
90/*
91 * Procedure information
92 */
93struct rpc_procinfo {
94 u32 p_proc; /* RPC procedure number */
Chuck Lever9f06c712010-12-14 14:59:18 +000095 kxdreproc_t p_encode; /* XDR encode function */
Chuck Leverbf269552010-12-14 14:59:29 +000096 kxdrdproc_t p_decode; /* XDR decode function */
Chuck Lever2bea90d2007-03-29 16:47:53 -040097 unsigned int p_arglen; /* argument hdr length (u32) */
98 unsigned int p_replen; /* reply hdr length (u32) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 unsigned int p_count; /* call count */
100 unsigned int p_timer; /* Which RTT timer to use */
Chuck Levercc0175c2006-03-20 13:44:22 -0500101 u32 p_statidx; /* Which procedure to account */
Trond Myklebust6eac7d32012-01-20 13:53:37 -0500102 const char * p_name; /* name of procedure */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103};
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105#ifdef __KERNEL__
106
Chuck Leverc2866762006-08-22 20:06:20 -0400107struct rpc_create_args {
Pavel Emelyanovc653ce32010-09-29 16:04:45 +0400108 struct net *net;
Chuck Leverc2866762006-08-22 20:06:20 -0400109 int protocol;
110 struct sockaddr *address;
111 size_t addrsize;
Frank van Maarseveend3bc9a12007-07-09 22:23:35 +0200112 struct sockaddr *saddress;
Trond Myklebustba7392b2007-12-20 16:03:55 -0500113 const struct rpc_timeout *timeout;
Trond Myklebust6eac7d32012-01-20 13:53:37 -0500114 const char *servername;
Trond Myklebusta613fa12012-01-20 13:53:56 -0500115 const struct rpc_program *program;
Benny Halevyd5b337b2008-09-28 09:21:26 +0300116 u32 prognumber; /* overrides program->number */
Chuck Leverc2866762006-08-22 20:06:20 -0400117 u32 version;
118 rpc_authflavor_t authflavor;
119 unsigned long flags;
Olga Kornievskaia608207e2008-12-23 16:17:40 -0500120 char *client_name;
Alexandros Batsakisf300bab2009-09-10 17:33:30 +0300121 struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */
Chuck Leverc2866762006-08-22 20:06:20 -0400122};
123
124/* Values for "flags" field */
125#define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
Chuck Leverc2866762006-08-22 20:06:20 -0400126#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
Trond Myklebust90c57552007-06-09 19:49:36 -0400127#define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
128#define RPC_CLNT_CREATE_NOPING (1UL << 4)
129#define RPC_CLNT_CREATE_DISCRTRY (1UL << 5)
Olga Kornievskaiab6b61522008-06-09 16:51:31 -0400130#define RPC_CLNT_CREATE_QUIET (1UL << 6)
Trond Myklebustb7993ce2013-04-14 11:42:00 -0400131#define RPC_CLNT_CREATE_INFINITE_SLOTS (1UL << 7)
J. Bruce Fields33d90ac2013-04-11 15:06:36 -0400132#define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)
Trond Myklebust8a19a0b2013-09-24 12:00:27 -0400133#define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
Chuck Leverc2866762006-08-22 20:06:20 -0400134
135struct rpc_clnt *rpc_create(struct rpc_create_args *args);
Kinglong Mee83ddfeb2014-03-24 11:58:59 +0800136struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
137 struct rpc_xprt *xprt);
Andreas Gruenbacher007e2512005-06-22 17:16:23 +0000138struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
Trond Myklebusta613fa12012-01-20 13:53:56 -0500139 const struct rpc_program *, u32);
Andy Adamsoncbdabc7f2011-03-01 01:34:20 +0000140void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
Chuck Leverba9b5842012-09-14 17:24:02 -0400142struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
143 rpc_authflavor_t);
Trond Myklebust40b00b6b2013-10-17 14:12:23 -0400144int rpc_switch_client_transport(struct rpc_clnt *,
145 struct xprt_create *,
146 const struct rpc_timeout *);
147
Trond Myklebust4c402b42007-06-14 16:40:32 -0400148void rpc_shutdown_client(struct rpc_clnt *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149void rpc_release_client(struct rpc_clnt *);
Trond Myklebust58f96122010-07-31 14:29:08 -0400150void rpc_task_release_client(struct rpc_task *);
Chuck Levercce63cd2007-07-01 12:13:12 -0400151
Stanislav Kinsburskyf7a30c12012-01-13 12:52:51 +0400152int rpcb_create_local(struct net *);
153void rpcb_put_local(struct net *);
Stanislav Kinsbursky977ac312012-01-13 12:52:43 +0400154int rpcb_register(struct net *, u32, u32, int, unsigned short);
155int rpcb_v4_register(struct net *net, const u32 program,
156 const u32 version,
Chuck Leverc2e1b092008-07-14 16:03:30 -0400157 const struct sockaddr *address,
Chuck Lever14aeb212008-08-18 19:34:00 -0400158 const char *netid);
Chuck Lever45160d62007-07-01 12:13:17 -0400159void rpcb_getport_async(struct rpc_task *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
Trond Myklebust77de2c52007-10-25 18:40:21 -0400161void rpc_call_start(struct rpc_task *);
Trond Myklebustcbc20052008-02-14 11:11:30 -0500162int rpc_call_async(struct rpc_clnt *clnt,
163 const struct rpc_message *msg, int flags,
164 const struct rpc_call_ops *tk_ops,
Trond Myklebust963d8fe2006-01-03 09:55:04 +0100165 void *calldata);
Trond Myklebustcbc20052008-02-14 11:11:30 -0500166int rpc_call_sync(struct rpc_clnt *clnt,
167 const struct rpc_message *msg, int flags);
Trond Myklebust5e1550d2007-06-23 10:17:16 -0400168struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
169 int flags);
Trond Myklebustf1f88fc2010-07-31 14:29:07 -0400170int rpc_restart_call_prepare(struct rpc_task *);
171int rpc_restart_call(struct rpc_task *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
Trond Myklebust2446ab62012-03-01 17:00:56 -0500173int rpc_protocol(struct rpc_clnt *);
174struct net * rpc_net_ns(struct rpc_clnt *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175size_t rpc_max_payload(struct rpc_clnt *);
Weston Andros Adamsonedddbb12013-02-28 20:30:09 -0500176unsigned long rpc_get_timeout(struct rpc_clnt *clnt);
Chuck Lever35f5a422006-01-03 09:55:50 +0100177void rpc_force_rebind(struct rpc_clnt *);
Chuck Levered394402006-08-22 20:06:17 -0400178size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
Chuck Leverb454ae92008-01-07 18:34:48 -0500179const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
Chuck Lever2e738fd2012-03-01 17:01:14 -0500180int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Jeff Laytonb4b9d2c2014-11-26 14:44:43 -0500182const char *rpc_proc_name(const struct rpc_task *task);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183#endif /* __KERNEL__ */
184#endif /* _LINUX_SUNRPC_CLNT_H */