1 /* SPDX-License-Identifier: GPL-2.0 */
3 * RPC client multipathing definitions
5 * Copyright (c) 2015, 2016, Primary Data, Inc. All rights reserved.
7 * Trond Myklebust <trond.myklebust@primarydata.com>
9 #ifndef _NET_SUNRPC_XPRTMULTIPATH_H
10 #define _NET_SUNRPC_XPRTMULTIPATH_H
12 struct rpc_xprt_iter_ops
;
13 struct rpc_xprt_switch
{
17 unsigned int xps_nxprts
;
18 struct list_head xps_xprt_list
;
22 const struct rpc_xprt_iter_ops
*xps_iter_ops
;
24 struct rcu_head xps_rcu
;
27 struct rpc_xprt_iter
{
28 struct rpc_xprt_switch __rcu
*xpi_xpswitch
;
29 struct rpc_xprt
* xpi_cursor
;
31 const struct rpc_xprt_iter_ops
*xpi_ops
;
35 struct rpc_xprt_iter_ops
{
36 void (*xpi_rewind
)(struct rpc_xprt_iter
*);
37 struct rpc_xprt
*(*xpi_xprt
)(struct rpc_xprt_iter
*);
38 struct rpc_xprt
*(*xpi_next
)(struct rpc_xprt_iter
*);
41 extern struct rpc_xprt_switch
*xprt_switch_alloc(struct rpc_xprt
*xprt
,
44 extern struct rpc_xprt_switch
*xprt_switch_get(struct rpc_xprt_switch
*xps
);
45 extern void xprt_switch_put(struct rpc_xprt_switch
*xps
);
47 extern void rpc_xprt_switch_set_roundrobin(struct rpc_xprt_switch
*xps
);
49 extern void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch
*xps
,
50 struct rpc_xprt
*xprt
);
51 extern void rpc_xprt_switch_remove_xprt(struct rpc_xprt_switch
*xps
,
52 struct rpc_xprt
*xprt
);
54 extern void xprt_iter_init(struct rpc_xprt_iter
*xpi
,
55 struct rpc_xprt_switch
*xps
);
57 extern void xprt_iter_init_listall(struct rpc_xprt_iter
*xpi
,
58 struct rpc_xprt_switch
*xps
);
60 extern void xprt_iter_destroy(struct rpc_xprt_iter
*xpi
);
62 extern struct rpc_xprt_switch
*xprt_iter_xchg_switch(
63 struct rpc_xprt_iter
*xpi
,
64 struct rpc_xprt_switch
*newswitch
);
66 extern struct rpc_xprt
*xprt_iter_xprt(struct rpc_xprt_iter
*xpi
);
67 extern struct rpc_xprt
*xprt_iter_get_xprt(struct rpc_xprt_iter
*xpi
);
68 extern struct rpc_xprt
*xprt_iter_get_next(struct rpc_xprt_iter
*xpi
);
70 extern bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch
*xps
,
71 const struct sockaddr
*sap
);