Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | /* |
3 | * linux/include/linux/sunrpc/clnt.h | |
4 | * | |
5 | * Declarations for the high-level RPC client interface | |
6 | * | |
7 | * Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de> | |
8 | */ | |
9 | ||
10 | #ifndef _LINUX_SUNRPC_CLNT_H | |
11 | #define _LINUX_SUNRPC_CLNT_H | |
12 | ||
d77385f2 | 13 | #include <linux/types.h> |
a02d6926 CL |
14 | #include <linux/socket.h> |
15 | #include <linux/in.h> | |
16 | #include <linux/in6.h> | |
17 | ||
1da177e4 LT |
18 | #include <linux/sunrpc/msg_prot.h> |
19 | #include <linux/sunrpc/sched.h> | |
20 | #include <linux/sunrpc/xprt.h> | |
21 | #include <linux/sunrpc/auth.h> | |
22 | #include <linux/sunrpc/stats.h> | |
23 | #include <linux/sunrpc/xdr.h> | |
24 | #include <linux/sunrpc/timer.h> | |
6739ffb7 | 25 | #include <linux/sunrpc/rpc_pipe_fs.h> |
1da177e4 | 26 | #include <asm/signal.h> |
7d217cac | 27 | #include <linux/path.h> |
4516fc04 | 28 | #include <net/ipv6.h> |
ad01b2c6 | 29 | #include <linux/sunrpc/xprtmultipath.h> |
1da177e4 | 30 | |
1da177e4 LT |
31 | struct rpc_inode; |
32 | ||
33 | /* | |
34 | * The high-level client handle | |
35 | */ | |
36 | struct rpc_clnt { | |
006abe88 | 37 | atomic_t cl_count; /* Number of references */ |
2f048db4 | 38 | unsigned int cl_clid; /* client id */ |
6529eba0 TM |
39 | struct list_head cl_clients; /* Global list of clients */ |
40 | struct list_head cl_tasks; /* List of tasks */ | |
4bef61ff | 41 | spinlock_t cl_lock; /* spinlock */ |
2446ab60 | 42 | struct rpc_xprt __rcu * cl_xprt; /* transport */ |
499b4988 | 43 | const struct rpc_procinfo *cl_procinfo; /* procedure info */ |
4a68179d CL |
44 | u32 cl_prog, /* RPC program number */ |
45 | cl_vers, /* RPC version number */ | |
46 | cl_maxproc; /* max procedure number */ | |
1da177e4 | 47 | |
1da177e4 | 48 | struct rpc_auth * cl_auth; /* authenticator */ |
11c556b3 CL |
49 | struct rpc_stat * cl_stats; /* per-program statistics */ |
50 | struct rpc_iostats * cl_metrics; /* per-client statistics */ | |
1da177e4 LT |
51 | |
52 | unsigned int cl_softrtry : 1,/* soft timeouts */ | |
43d78ef2 | 53 | cl_discrtry : 1,/* disconnect before retry */ |
8a19a0b6 | 54 | cl_noretranstimeo: 1,/* No retransmit timeouts */ |
b6b6152c OK |
55 | cl_autobind : 1,/* use getport() */ |
56 | cl_chatty : 1;/* be verbose */ | |
1da177e4 LT |
57 | |
58 | struct rpc_rtt * cl_rtt; /* RTO estimator data */ | |
ba7392bb | 59 | const struct rpc_timeout *cl_timeout; /* Timeout strategy */ |
1da177e4 | 60 | |
3c87ef6e | 61 | atomic_t cl_swapper; /* swapfile count */ |
1da177e4 | 62 | int cl_nodelen; /* nodename length */ |
03a9a42a | 63 | char cl_nodename[UNX_MAXNODENAME+1]; |
6739ffb7 | 64 | struct rpc_pipe_dir_head cl_pipedir_objects; |
1da177e4 LT |
65 | struct rpc_clnt * cl_parent; /* Points to parent of clones */ |
66 | struct rpc_rtt cl_rtt_default; | |
ba7392bb | 67 | struct rpc_timeout cl_timeout_default; |
a613fa16 | 68 | const struct rpc_program *cl_program; |
b4b9d2cc JL |
69 | #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) |
70 | struct dentry *cl_debugfs; /* debugfs directory */ | |
71 | #endif | |
ad01b2c6 | 72 | struct rpc_xprt_iter cl_xpi; |
1da177e4 | 73 | }; |
1da177e4 LT |
74 | |
75 | /* | |
76 | * General RPC program info | |
77 | */ | |
78 | #define RPC_MAXVERSION 4 | |
79 | struct rpc_program { | |
080b794c | 80 | const char * name; /* protocol name */ |
1da177e4 LT |
81 | u32 number; /* program number */ |
82 | unsigned int nrvers; /* number of versions */ | |
a613fa16 | 83 | const struct rpc_version ** version; /* version array */ |
1da177e4 | 84 | struct rpc_stat * stats; /* statistics */ |
080b794c | 85 | const char * pipe_dir_name; /* path to rpc_pipefs dir */ |
1da177e4 LT |
86 | }; |
87 | ||
88 | struct rpc_version { | |
89 | u32 number; /* version number */ | |
90 | unsigned int nrprocs; /* number of procs */ | |
499b4988 | 91 | const struct rpc_procinfo *procs; /* procedure array */ |
1c5876dd | 92 | unsigned int *counts; /* call counts */ |
1da177e4 LT |
93 | }; |
94 | ||
95 | /* | |
96 | * Procedure information | |
97 | */ | |
98 | struct rpc_procinfo { | |
99 | u32 p_proc; /* RPC procedure number */ | |
9f06c719 | 100 | kxdreproc_t p_encode; /* XDR encode function */ |
bf269551 | 101 | kxdrdproc_t p_decode; /* XDR decode function */ |
2bea90d4 CL |
102 | unsigned int p_arglen; /* argument hdr length (u32) */ |
103 | unsigned int p_replen; /* reply hdr length (u32) */ | |
1da177e4 | 104 | unsigned int p_timer; /* Which RTT timer to use */ |
cc0175c1 | 105 | u32 p_statidx; /* Which procedure to account */ |
6eac7d3f | 106 | const char * p_name; /* name of procedure */ |
1da177e4 LT |
107 | }; |
108 | ||
1da177e4 LT |
109 | #ifdef __KERNEL__ |
110 | ||
c2866763 | 111 | struct rpc_create_args { |
c653ce3f | 112 | struct net *net; |
c2866763 CL |
113 | int protocol; |
114 | struct sockaddr *address; | |
115 | size_t addrsize; | |
d3bc9a1d | 116 | struct sockaddr *saddress; |
ba7392bb | 117 | const struct rpc_timeout *timeout; |
6eac7d3f | 118 | const char *servername; |
03a9a42a | 119 | const char *nodename; |
a613fa16 | 120 | const struct rpc_program *program; |
d5b337b4 | 121 | u32 prognumber; /* overrides program->number */ |
c2866763 CL |
122 | u32 version; |
123 | rpc_authflavor_t authflavor; | |
124 | unsigned long flags; | |
608207e8 | 125 | char *client_name; |
f300baba | 126 | struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */ |
c2866763 CL |
127 | }; |
128 | ||
fda0ab41 AA |
129 | struct rpc_add_xprt_test { |
130 | int (*add_xprt_test)(struct rpc_clnt *, | |
131 | struct rpc_xprt *, | |
132 | void *calldata); | |
133 | void *data; | |
134 | }; | |
135 | ||
c2866763 CL |
136 | /* Values for "flags" field */ |
137 | #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0) | |
c2866763 | 138 | #define RPC_CLNT_CREATE_AUTOBIND (1UL << 2) |
90c5755f TM |
139 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) |
140 | #define RPC_CLNT_CREATE_NOPING (1UL << 4) | |
141 | #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5) | |
b6b6152c | 142 | #define RPC_CLNT_CREATE_QUIET (1UL << 6) |
b7993ceb | 143 | #define RPC_CLNT_CREATE_INFINITE_SLOTS (1UL << 7) |
33d90ac0 | 144 | #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8) |
8a19a0b6 | 145 | #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) |
c2866763 CL |
146 | |
147 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); | |
007e251f | 148 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
a613fa16 | 149 | const struct rpc_program *, u32); |
1da177e4 | 150 | struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); |
ba9b584c CL |
151 | struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *, |
152 | rpc_authflavor_t); | |
40b00b6b TM |
153 | int rpc_switch_client_transport(struct rpc_clnt *, |
154 | struct xprt_create *, | |
155 | const struct rpc_timeout *); | |
156 | ||
4c402b40 | 157 | void rpc_shutdown_client(struct rpc_clnt *); |
1da177e4 | 158 | void rpc_release_client(struct rpc_clnt *); |
58f9612c | 159 | void rpc_task_release_client(struct rpc_task *); |
cce63cd6 | 160 | |
f7a30c18 SK |
161 | int rpcb_create_local(struct net *); |
162 | void rpcb_put_local(struct net *); | |
977ac315 SK |
163 | int rpcb_register(struct net *, u32, u32, int, unsigned short); |
164 | int rpcb_v4_register(struct net *net, const u32 program, | |
165 | const u32 version, | |
c2e1b09f | 166 | const struct sockaddr *address, |
14aeb211 | 167 | const char *netid); |
45160d62 | 168 | void rpcb_getport_async(struct rpc_task *); |
1da177e4 | 169 | |
77de2c59 | 170 | void rpc_call_start(struct rpc_task *); |
cbc20059 TM |
171 | int rpc_call_async(struct rpc_clnt *clnt, |
172 | const struct rpc_message *msg, int flags, | |
173 | const struct rpc_call_ops *tk_ops, | |
963d8fe5 | 174 | void *calldata); |
cbc20059 TM |
175 | int rpc_call_sync(struct rpc_clnt *clnt, |
176 | const struct rpc_message *msg, int flags); | |
5e1550d6 TM |
177 | struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, |
178 | int flags); | |
f1f88fc7 TM |
179 | int rpc_restart_call_prepare(struct rpc_task *); |
180 | int rpc_restart_call(struct rpc_task *); | |
1da177e4 | 181 | void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); |
2446ab60 TM |
182 | int rpc_protocol(struct rpc_clnt *); |
183 | struct net * rpc_net_ns(struct rpc_clnt *); | |
1da177e4 | 184 | size_t rpc_max_payload(struct rpc_clnt *); |
6b26cc8c | 185 | size_t rpc_max_bc_payload(struct rpc_clnt *); |
35f5a422 | 186 | void rpc_force_rebind(struct rpc_clnt *); |
ed39440a | 187 | size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); |
b454ae90 | 188 | const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); |
2e738fdc | 189 | int rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t); |
1da177e4 | 190 | |
3227886c TM |
191 | int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt, |
192 | int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *), | |
193 | void *data); | |
194 | ||
7f554890 TM |
195 | int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, |
196 | struct rpc_xprt_switch *xps, | |
197 | struct rpc_xprt *xprt, | |
198 | void *dummy); | |
199 | int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *, | |
200 | int (*setup)(struct rpc_clnt *, | |
201 | struct rpc_xprt_switch *, | |
202 | struct rpc_xprt *, | |
203 | void *), | |
204 | void *data); | |
26ae102f TM |
205 | void rpc_set_connect_timeout(struct rpc_clnt *clnt, |
206 | unsigned long connect_timeout, | |
207 | unsigned long reconnect_timeout); | |
7f554890 | 208 | |
fda0ab41 AA |
209 | int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *, |
210 | struct rpc_xprt_switch *, | |
211 | struct rpc_xprt *, | |
212 | void *); | |
213 | ||
b4b9d2cc | 214 | const char *rpc_proc_name(const struct rpc_task *task); |
3b58a8a9 AA |
215 | |
216 | void rpc_clnt_xprt_switch_put(struct rpc_clnt *); | |
dd691717 | 217 | void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *, struct rpc_xprt *); |
39e5d2df AA |
218 | bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt, |
219 | const struct sockaddr *sap); | |
c929ea0b | 220 | void rpc_cleanup_clids(void); |
1da177e4 LT |
221 | #endif /* __KERNEL__ */ |
222 | #endif /* _LINUX_SUNRPC_CLNT_H */ |