Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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 Myklebust | d77385f | 2011-10-17 16:08:10 -0700 | [diff] [blame] | 12 | #include <linux/types.h> |
Chuck Lever | a02d692 | 2009-08-09 15:09:34 -0400 | [diff] [blame] | 13 | #include <linux/socket.h> |
| 14 | #include <linux/in.h> |
| 15 | #include <linux/in6.h> |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #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 Myklebust | 6739ffb | 2013-08-26 15:38:11 -0400 | [diff] [blame] | 24 | #include <linux/sunrpc/rpc_pipe_fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/signal.h> |
Trond Myklebust | 7d217ca | 2009-08-09 15:14:24 -0400 | [diff] [blame] | 26 | #include <linux/path.h> |
Jeff Layton | 4516fc0 | 2009-08-14 12:57:54 -0400 | [diff] [blame] | 27 | #include <net/ipv6.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | struct rpc_inode; |
| 30 | |
| 31 | /* |
| 32 | * The high-level client handle |
| 33 | */ |
| 34 | struct rpc_clnt { |
Trond Myklebust | 006abe8 | 2010-09-12 19:55:25 -0400 | [diff] [blame] | 35 | atomic_t cl_count; /* Number of references */ |
Trond Myklebust | 2f048db | 2013-09-04 21:51:44 -0400 | [diff] [blame] | 36 | unsigned int cl_clid; /* client id */ |
Trond Myklebust | 6529eba | 2007-06-14 16:40:14 -0400 | [diff] [blame] | 37 | struct list_head cl_clients; /* Global list of clients */ |
| 38 | struct list_head cl_tasks; /* List of tasks */ |
Trond Myklebust | 4bef61f | 2007-06-16 14:17:01 -0400 | [diff] [blame] | 39 | spinlock_t cl_lock; /* spinlock */ |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 40 | struct rpc_xprt __rcu * cl_xprt; /* transport */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | struct rpc_procinfo * cl_procinfo; /* procedure info */ |
Chuck Lever | 4a68179 | 2006-08-22 20:06:15 -0400 | [diff] [blame] | 42 | u32 cl_prog, /* RPC program number */ |
| 43 | cl_vers, /* RPC version number */ |
| 44 | cl_maxproc; /* max procedure number */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | struct rpc_auth * cl_auth; /* authenticator */ |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 47 | struct rpc_stat * cl_stats; /* per-program statistics */ |
| 48 | struct rpc_iostats * cl_metrics; /* per-client statistics */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | unsigned int cl_softrtry : 1,/* soft timeouts */ |
Chuck Lever | 43d78ef | 2007-02-06 18:26:11 -0500 | [diff] [blame] | 51 | cl_discrtry : 1,/* disconnect before retry */ |
Trond Myklebust | 8a19a0b | 2013-09-24 12:00:27 -0400 | [diff] [blame] | 52 | cl_noretranstimeo: 1,/* No retransmit timeouts */ |
Olga Kornievskaia | b6b6152 | 2008-06-09 16:51:31 -0400 | [diff] [blame] | 53 | cl_autobind : 1,/* use getport() */ |
| 54 | cl_chatty : 1;/* be verbose */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | struct rpc_rtt * cl_rtt; /* RTO estimator data */ |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 57 | const struct rpc_timeout *cl_timeout; /* Timeout strategy */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | int cl_nodelen; /* nodename length */ |
| 60 | char cl_nodename[UNX_MAXNODENAME]; |
Trond Myklebust | 6739ffb | 2013-08-26 15:38:11 -0400 | [diff] [blame] | 61 | struct rpc_pipe_dir_head cl_pipedir_objects; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | struct rpc_clnt * cl_parent; /* Points to parent of clones */ |
| 63 | struct rpc_rtt cl_rtt_default; |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 64 | struct rpc_timeout cl_timeout_default; |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 65 | const struct rpc_program *cl_program; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * General RPC program info |
| 70 | */ |
| 71 | #define RPC_MAXVERSION 4 |
| 72 | struct rpc_program { |
Trond Myklebust | 080b794 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 73 | const char * name; /* protocol name */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | u32 number; /* program number */ |
| 75 | unsigned int nrvers; /* number of versions */ |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 76 | const struct rpc_version ** version; /* version array */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | struct rpc_stat * stats; /* statistics */ |
Trond Myklebust | 080b794 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 78 | const char * pipe_dir_name; /* path to rpc_pipefs dir */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | struct rpc_version { |
| 82 | u32 number; /* version number */ |
| 83 | unsigned int nrprocs; /* number of procs */ |
| 84 | struct rpc_procinfo * procs; /* procedure array */ |
| 85 | }; |
| 86 | |
| 87 | /* |
| 88 | * Procedure information |
| 89 | */ |
| 90 | struct rpc_procinfo { |
| 91 | u32 p_proc; /* RPC procedure number */ |
Chuck Lever | 9f06c71 | 2010-12-14 14:59:18 +0000 | [diff] [blame] | 92 | kxdreproc_t p_encode; /* XDR encode function */ |
Chuck Lever | bf26955 | 2010-12-14 14:59:29 +0000 | [diff] [blame] | 93 | kxdrdproc_t p_decode; /* XDR decode function */ |
Chuck Lever | 2bea90d | 2007-03-29 16:47:53 -0400 | [diff] [blame] | 94 | unsigned int p_arglen; /* argument hdr length (u32) */ |
| 95 | unsigned int p_replen; /* reply hdr length (u32) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | unsigned int p_count; /* call count */ |
| 97 | unsigned int p_timer; /* Which RTT timer to use */ |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 98 | u32 p_statidx; /* Which procedure to account */ |
Trond Myklebust | 6eac7d3 | 2012-01-20 13:53:37 -0500 | [diff] [blame] | 99 | const char * p_name; /* name of procedure */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | #ifdef __KERNEL__ |
| 103 | |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 104 | struct rpc_create_args { |
Pavel Emelyanov | c653ce3 | 2010-09-29 16:04:45 +0400 | [diff] [blame] | 105 | struct net *net; |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 106 | int protocol; |
| 107 | struct sockaddr *address; |
| 108 | size_t addrsize; |
Frank van Maarseveen | d3bc9a1 | 2007-07-09 22:23:35 +0200 | [diff] [blame] | 109 | struct sockaddr *saddress; |
Trond Myklebust | ba7392b | 2007-12-20 16:03:55 -0500 | [diff] [blame] | 110 | const struct rpc_timeout *timeout; |
Trond Myklebust | 6eac7d3 | 2012-01-20 13:53:37 -0500 | [diff] [blame] | 111 | const char *servername; |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 112 | const struct rpc_program *program; |
Benny Halevy | d5b337b | 2008-09-28 09:21:26 +0300 | [diff] [blame] | 113 | u32 prognumber; /* overrides program->number */ |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 114 | u32 version; |
| 115 | rpc_authflavor_t authflavor; |
| 116 | unsigned long flags; |
Olga Kornievskaia | 608207e | 2008-12-23 16:17:40 -0500 | [diff] [blame] | 117 | char *client_name; |
Alexandros Batsakis | f300bab | 2009-09-10 17:33:30 +0300 | [diff] [blame] | 118 | struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */ |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /* Values for "flags" field */ |
| 122 | #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0) |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 123 | #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2) |
Trond Myklebust | 90c5755 | 2007-06-09 19:49:36 -0400 | [diff] [blame] | 124 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) |
| 125 | #define RPC_CLNT_CREATE_NOPING (1UL << 4) |
| 126 | #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5) |
Olga Kornievskaia | b6b6152 | 2008-06-09 16:51:31 -0400 | [diff] [blame] | 127 | #define RPC_CLNT_CREATE_QUIET (1UL << 6) |
Trond Myklebust | b7993ce | 2013-04-14 11:42:00 -0400 | [diff] [blame] | 128 | #define RPC_CLNT_CREATE_INFINITE_SLOTS (1UL << 7) |
J. Bruce Fields | 33d90ac | 2013-04-11 15:06:36 -0400 | [diff] [blame] | 129 | #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8) |
Trond Myklebust | 8a19a0b | 2013-09-24 12:00:27 -0400 | [diff] [blame] | 130 | #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) |
Chuck Lever | c286676 | 2006-08-22 20:06:20 -0400 | [diff] [blame] | 131 | |
| 132 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); |
Andreas Gruenbacher | 007e251 | 2005-06-22 17:16:23 +0000 | [diff] [blame] | 133 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
Trond Myklebust | a613fa1 | 2012-01-20 13:53:56 -0500 | [diff] [blame] | 134 | const struct rpc_program *, u32); |
Andy Adamson | cbdabc7 | 2011-03-01 01:34:20 +0000 | [diff] [blame] | 135 | void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); |
Chuck Lever | ba9b584 | 2012-09-14 17:24:02 -0400 | [diff] [blame] | 137 | struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *, |
| 138 | rpc_authflavor_t); |
Trond Myklebust | 40b00b6b | 2013-10-17 14:12:23 -0400 | [diff] [blame] | 139 | int rpc_switch_client_transport(struct rpc_clnt *, |
| 140 | struct xprt_create *, |
| 141 | const struct rpc_timeout *); |
| 142 | |
Trond Myklebust | 4c402b4 | 2007-06-14 16:40:32 -0400 | [diff] [blame] | 143 | void rpc_shutdown_client(struct rpc_clnt *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | void rpc_release_client(struct rpc_clnt *); |
Trond Myklebust | 58f9612 | 2010-07-31 14:29:08 -0400 | [diff] [blame] | 145 | void rpc_task_release_client(struct rpc_task *); |
Chuck Lever | cce63cd | 2007-07-01 12:13:12 -0400 | [diff] [blame] | 146 | |
Stanislav Kinsbursky | f7a30c1 | 2012-01-13 12:52:51 +0400 | [diff] [blame] | 147 | int rpcb_create_local(struct net *); |
| 148 | void rpcb_put_local(struct net *); |
Stanislav Kinsbursky | 977ac31 | 2012-01-13 12:52:43 +0400 | [diff] [blame] | 149 | int rpcb_register(struct net *, u32, u32, int, unsigned short); |
| 150 | int rpcb_v4_register(struct net *net, const u32 program, |
| 151 | const u32 version, |
Chuck Lever | c2e1b09 | 2008-07-14 16:03:30 -0400 | [diff] [blame] | 152 | const struct sockaddr *address, |
Chuck Lever | 14aeb21 | 2008-08-18 19:34:00 -0400 | [diff] [blame] | 153 | const char *netid); |
Chuck Lever | 45160d6 | 2007-07-01 12:13:17 -0400 | [diff] [blame] | 154 | void rpcb_getport_async(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Trond Myklebust | 77de2c5 | 2007-10-25 18:40:21 -0400 | [diff] [blame] | 156 | void rpc_call_start(struct rpc_task *); |
Trond Myklebust | cbc2005 | 2008-02-14 11:11:30 -0500 | [diff] [blame] | 157 | int rpc_call_async(struct rpc_clnt *clnt, |
| 158 | const struct rpc_message *msg, int flags, |
| 159 | const struct rpc_call_ops *tk_ops, |
Trond Myklebust | 963d8fe | 2006-01-03 09:55:04 +0100 | [diff] [blame] | 160 | void *calldata); |
Trond Myklebust | cbc2005 | 2008-02-14 11:11:30 -0500 | [diff] [blame] | 161 | int rpc_call_sync(struct rpc_clnt *clnt, |
| 162 | const struct rpc_message *msg, int flags); |
Trond Myklebust | 5e1550d | 2007-06-23 10:17:16 -0400 | [diff] [blame] | 163 | struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, |
| 164 | int flags); |
Trond Myklebust | f1f88fc | 2010-07-31 14:29:07 -0400 | [diff] [blame] | 165 | int rpc_restart_call_prepare(struct rpc_task *); |
| 166 | int rpc_restart_call(struct rpc_task *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 168 | int rpc_protocol(struct rpc_clnt *); |
| 169 | struct net * rpc_net_ns(struct rpc_clnt *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | size_t rpc_max_payload(struct rpc_clnt *); |
Weston Andros Adamson | edddbb1 | 2013-02-28 20:30:09 -0500 | [diff] [blame] | 171 | unsigned long rpc_get_timeout(struct rpc_clnt *clnt); |
Chuck Lever | 35f5a42 | 2006-01-03 09:55:50 +0100 | [diff] [blame] | 172 | void rpc_force_rebind(struct rpc_clnt *); |
Chuck Lever | ed39440 | 2006-08-22 20:06:17 -0400 | [diff] [blame] | 173 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); |
Chuck Lever | b454ae9 | 2008-01-07 18:34:48 -0500 | [diff] [blame] | 174 | const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); |
Chuck Lever | 2e738fd | 2012-03-01 17:01:14 -0500 | [diff] [blame] | 175 | int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | #endif /* __KERNEL__ */ |
| 178 | #endif /* _LINUX_SUNRPC_CLNT_H */ |