transport.c revision ba7392bb37cb12781890f45d7ddee1618e33a036
1f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
2f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
3f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
4f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * This software is available to you under a choice of one of two
5f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * licenses.  You may choose to be licensed under the terms of the GNU
6f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * General Public License (GPL) Version 2, available from the file
7f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * COPYING in the main directory of this source tree, or the BSD-type
8f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * license below:
9f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
10f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Redistribution and use in source and binary forms, with or without
11f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * modification, are permitted provided that the following conditions
12f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * are met:
13f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
14f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      Redistributions of source code must retain the above copyright
15f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      notice, this list of conditions and the following disclaimer.
16f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
17f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      Redistributions in binary form must reproduce the above
18f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      copyright notice, this list of conditions and the following
19f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      disclaimer in the documentation and/or other materials provided
20f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      with the distribution.
21f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
22f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      Neither the name of the Network Appliance, Inc. nor the names of
23f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      its contributors may be used to endorse or promote products
24f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      derived from this software without specific prior written
25f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *      permission.
26f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
27f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
39f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
40f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
41f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * transport.c
42f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
43f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * This file contains the top-level implementation of an RPC RDMA
44f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * transport.
45f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
46f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Naming convention: functions beginning with xprt_ are part of the
47f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * transport switch. All others are RPC RDMA internal.
48f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
49f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
50f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include <linux/module.h>
51f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include <linux/init.h>
52f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include <linux/seq_file.h>
53f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
54f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include "xprt_rdma.h"
55f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
56f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
57f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\# define RPCDBG_FACILITY	RPCDBG_TRANS
58f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
59f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
60f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_LICENSE("Dual BSD/GPL");
61f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
62f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_DESCRIPTION("RPC/RDMA Transport for Linux kernel NFS");
63f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_AUTHOR("Network Appliance, Inc.");
64f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
65f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
66f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * tunables
67f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
68f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
69f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_slot_table_entries = RPCRDMA_DEF_SLOT_TABLE;
70f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
71f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
72f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_inline_write_padding;
73f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#if !RPCRDMA_PERSISTENT_REGISTRATION
74f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_REGISTER; /* FMR? */
75f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#else
76f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_ALLPHYSICAL;
77f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
78f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
79f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
80f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
81f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int min_slot_table_size = RPCRDMA_MIN_SLOT_TABLE;
82f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_slot_table_size = RPCRDMA_MAX_SLOT_TABLE;
83f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int zero;
84f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_padding = PAGE_SIZE;
85f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int min_memreg = RPCRDMA_BOUNCEBUFFERS;
86f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_memreg = RPCRDMA_LAST - 1;
87f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
88f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct ctl_table_header *sunrpc_table_header;
89f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
90f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static ctl_table xr_tunables_table[] = {
91f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
92cfcb43ff7ce28f347a39e1a7519e01850b588718James Lentini		.ctl_name       = CTL_UNNUMBERED,
93f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_slot_table_entries",
94f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_slot_table_entries,
95f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
96f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
97f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.proc_handler	= &proc_dointvec_minmax,
98f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.strategy	= &sysctl_intvec,
99f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &min_slot_table_size,
100f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_slot_table_size
101f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
102f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
103cfcb43ff7ce28f347a39e1a7519e01850b588718James Lentini		.ctl_name       = CTL_UNNUMBERED,
104f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_max_inline_read",
105f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_max_inline_read,
106f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
107f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
108f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.proc_handler	= &proc_dointvec,
109f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.strategy	= &sysctl_intvec,
110f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
111f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
112cfcb43ff7ce28f347a39e1a7519e01850b588718James Lentini		.ctl_name       = CTL_UNNUMBERED,
113f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_max_inline_write",
114f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_max_inline_write,
115f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
116f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
117f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.proc_handler	= &proc_dointvec,
118f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.strategy	= &sysctl_intvec,
119f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
120f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
121cfcb43ff7ce28f347a39e1a7519e01850b588718James Lentini		.ctl_name       = CTL_UNNUMBERED,
122f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_inline_write_padding",
123f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_inline_write_padding,
124f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
125f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
126f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.proc_handler	= &proc_dointvec_minmax,
127f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.strategy	= &sysctl_intvec,
128f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &zero,
129f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_padding,
130f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
131f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
132cfcb43ff7ce28f347a39e1a7519e01850b588718James Lentini		.ctl_name       = CTL_UNNUMBERED,
133f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_memreg_strategy",
134f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_memreg_strategy,
135f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
136f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
137f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.proc_handler	= &proc_dointvec_minmax,
138f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.strategy	= &sysctl_intvec,
139f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &min_memreg,
140f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_memreg,
141f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
142f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
143f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.ctl_name = 0,
144f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
145f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
146f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
147f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static ctl_table sunrpc_table[] = {
148f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
149f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.ctl_name	= CTL_SUNRPC,
150f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "sunrpc",
151f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0555,
152f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.child		= xr_tunables_table
153f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
154f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
155f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.ctl_name = 0,
156f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
157f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
158f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
159f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
160f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
161f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt_ops xprt_rdma_procs;	/* forward reference */
162f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
163f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
164f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_format_addresses(struct rpc_xprt *xprt)
165f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
166f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct sockaddr_in *addr = (struct sockaddr_in *)
167f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					&rpcx_to_rdmad(xprt).addr;
168f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	char *buf;
169f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
170f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(20, GFP_KERNEL);
171f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
172f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 20, NIPQUAD_FMT, NIPQUAD(addr->sin_addr.s_addr));
173f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_ADDR] = buf;
174f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
175f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(8, GFP_KERNEL);
176f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
177f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 8, "%u", ntohs(addr->sin_port));
178f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_PORT] = buf;
179f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
180f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma";
181f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
182f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(48, GFP_KERNEL);
183f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
184f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 48, "addr="NIPQUAD_FMT" port=%u proto=%s",
185f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			NIPQUAD(addr->sin_addr.s_addr),
186f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			ntohs(addr->sin_port), "rdma");
187f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_ALL] = buf;
188f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
189f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(10, GFP_KERNEL);
190f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
191f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 10, "%02x%02x%02x%02x",
192f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			NIPQUAD(addr->sin_addr.s_addr));
193f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = buf;
194f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
195f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(8, GFP_KERNEL);
196f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
197f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 8, "%4hx", ntohs(addr->sin_port));
198f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_HEX_PORT] = buf;
199f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
200f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	buf = kzalloc(30, GFP_KERNEL);
201f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buf)
202f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		snprintf(buf, 30, NIPQUAD_FMT".%u.%u",
203f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			NIPQUAD(addr->sin_addr.s_addr),
204f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			ntohs(addr->sin_port) >> 8,
205f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			ntohs(addr->sin_port) & 0xff);
206f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR] = buf;
207f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
208f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* netid */
209f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_NETID] = "rdma";
210f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
211f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
212f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
213f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_free_addresses(struct rpc_xprt *xprt)
214f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
215f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_ADDR]);
216f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_PORT]);
217f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_ALL]);
218f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_HEX_ADDR]);
219f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]);
220f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR]);
221f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
222f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
223f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
224f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_connect_worker(struct work_struct *work)
225f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
226f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt =
227f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		container_of(work, struct rpcrdma_xprt, rdma_connect.work);
228f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = &r_xprt->xprt;
229f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc = 0;
230f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
231f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!xprt->shutdown) {
232f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_clear_connected(xprt);
233f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
234f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: %sconnect\n", __func__,
235f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				r_xprt->rx_ep.rep_connected != 0 ? "re" : "");
236f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rc = rpcrdma_ep_connect(&r_xprt->rx_ep, &r_xprt->rx_ia);
237f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rc)
238f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto out;
239f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
240f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	goto out_clear;
241f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
242f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out:
243f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_wake_pending_tasks(xprt, rc);
244f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
245f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out_clear:
246f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: exit\n", __func__);
247f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_clear_connecting(xprt);
248f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
249f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
250f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
251f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * xprt_rdma_destroy
252f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
253f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Destroy the xprt.
254f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Free all memory associated with the object, including its own.
255f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * NOTE: none of the *destroy methods free memory for their top-level
256f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * objects, even though they may have allocated it (they do free
257f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * private memory). It's up to the caller to handle it. In this
258f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * case (RDMA transport), all structure memory is inlined with the
259f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * struct rpcrdma_xprt.
260f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
261f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
262f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_destroy(struct rpc_xprt *xprt)
263f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
264f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
265f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
266f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
267f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: called\n", __func__);
268f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
269f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cancel_delayed_work(&r_xprt->rdma_connect);
270f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	flush_scheduled_work();
271f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
272f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_clear_connected(xprt);
273f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
274f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_destroy(&r_xprt->rx_buf);
275f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ep_destroy(&r_xprt->rx_ep, &r_xprt->rx_ia);
276f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
277f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: rpcrdma_ep_destroy returned %i\n",
278f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, rc);
279f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_ia_close(&r_xprt->rx_ia);
280f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
281f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_free_addresses(xprt);
282f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
283f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->slot);
284f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->slot = NULL;
285f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt);
286f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
287f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: returning\n", __func__);
288f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
289f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	module_put(THIS_MODULE);
290f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
291f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
2922881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebuststatic const struct rpc_timeout xprt_rdma_default_timeout = {
2932881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust	.to_initval = 60 * HZ,
2942881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust	.to_maxval = 60 * HZ,
2952881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust};
2962881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust
297f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/**
298f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * xprt_setup_rdma - Set up transport to use RDMA
299f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
300f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * @args: rpc transport arguments
301f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
302f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt *
303f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_setup_rdma(struct xprt_create *args)
304f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
305f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_create_data_internal cdata;
306f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt;
307f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *new_xprt;
308f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_ep *new_ep;
309f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct sockaddr_in *sin;
310f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
311f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
312f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (args->addrlen > sizeof(xprt->addr)) {
313f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: address too large\n", __func__);
314f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return ERR_PTR(-EBADF);
315f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
316f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
317f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt = kzalloc(sizeof(struct rpcrdma_xprt), GFP_KERNEL);
318f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (xprt == NULL) {
319f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: couldn't allocate rpcrdma_xprt\n",
320f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__);
321f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return ERR_PTR(-ENOMEM);
322f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
323f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
324f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->max_reqs = xprt_rdma_slot_table_entries;
325f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->slot = kcalloc(xprt->max_reqs,
326f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				sizeof(struct rpc_rqst), GFP_KERNEL);
327f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (xprt->slot == NULL) {
328f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: couldn't allocate %d slots\n",
329f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, xprt->max_reqs);
330d5cd97872dca9b79c31224ca014bcea7ca01f5f1Adrian Bunk		kfree(xprt);
331f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return ERR_PTR(-ENOMEM);
332f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
333f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
334f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* 60 second timeout, no retries */
335ba7392bb37cb12781890f45d7ddee1618e33a036Trond Myklebust	xprt->timeout = &xprt_rdma_default_timeout;
336f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->bind_timeout = (60U * HZ);
337f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->connect_timeout = (60U * HZ);
338f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->reestablish_timeout = (5U * HZ);
339f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->idle_timeout = (5U * 60 * HZ);
340f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
341f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->resvport = 0;		/* privileged port not needed */
342f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->tsh_size = 0;		/* RPC-RDMA handles framing */
343f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->max_payload = RPCRDMA_MAX_DATA_SEGS * PAGE_SIZE;
344f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->ops = &xprt_rdma_procs;
345f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
346f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
347f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Set up RDMA-specific connect data.
348f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
349f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
350f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Put server RDMA address in local cdata */
351f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	memcpy(&cdata.addr, args->dstaddr, args->addrlen);
352f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
353f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Ensure xprt->addr holds valid server TCP (not RDMA)
354f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * address, for any side protocols which peek at it */
355f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->prot = IPPROTO_TCP;
356f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->addrlen = args->addrlen;
357f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	memcpy(&xprt->addr, &cdata.addr, xprt->addrlen);
358f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
359f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sin = (struct sockaddr_in *)&cdata.addr;
360f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (ntohs(sin->sin_port) != 0)
361f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_set_bound(xprt);
362f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
363f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: %u.%u.%u.%u:%u\n", __func__,
364f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
365f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
366f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Set max requests */
367f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.max_requests = xprt->max_reqs;
368f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
369f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Set some length limits */
370f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.rsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA write max */
371f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.wsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA read max */
372f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
373f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.inline_wsize = xprt_rdma_max_inline_write;
374f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (cdata.inline_wsize > cdata.wsize)
375f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		cdata.inline_wsize = cdata.wsize;
376f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
377f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.inline_rsize = xprt_rdma_max_inline_read;
378f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (cdata.inline_rsize > cdata.rsize)
379f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		cdata.inline_rsize = cdata.rsize;
380f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
381f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.padding = xprt_rdma_inline_write_padding;
382f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
383f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
384f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Create new transport instance, which includes initialized
385f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o ia
386f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o endpoint
387f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o buffers
388f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
389f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
390f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_xprt = rpcx_to_rdmax(xprt);
391f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
392f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ia_open(new_xprt, (struct sockaddr *) &cdata.addr,
393f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				xprt_rdma_memreg_strategy);
394f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
395f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out1;
396f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
397f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
398f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * initialize and create ep
399f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
400f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_xprt->rx_data = cdata;
401f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep = &new_xprt->rx_ep;
402f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_remote_addr = cdata.addr;
403f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
404f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ep_create(&new_xprt->rx_ep,
405f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&new_xprt->rx_ia, &new_xprt->rx_data);
406f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
407f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out2;
408f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
409f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
410f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Allocate pre-registered send and receive buffers for headers and
411f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * any inline data. Also specify any padding which will be provided
412f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * from a preregistered zero buffer.
413f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
414f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_buffer_create(&new_xprt->rx_buf, new_ep, &new_xprt->rx_ia,
415f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&new_xprt->rx_data);
416f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
417f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out3;
418f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
419f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
420f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Register a callback for connection events. This is necessary because
421f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * connection loss notification is async. We also catch connection loss
422f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * when reaping receives.
423f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
424f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	INIT_DELAYED_WORK(&new_xprt->rdma_connect, xprt_rdma_connect_worker);
425f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_func = rpcrdma_conn_func;
426f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_xprt = xprt;
427f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
428f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_format_addresses(xprt);
429f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
430f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!try_module_get(THIS_MODULE))
431f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out4;
432f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
433f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return xprt;
434f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
435f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out4:
436f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_free_addresses(xprt);
437f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = -EINVAL;
438f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out3:
439f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	(void) rpcrdma_ep_destroy(new_ep, &new_xprt->rx_ia);
440f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out2:
441f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_ia_close(&new_xprt->rx_ia);
442f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out1:
443f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt->slot);
444f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	kfree(xprt);
445f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return ERR_PTR(rc);
446f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
447f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
448f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
449f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Close a connection, during shutdown or timeout/reconnect
450f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
451f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
452f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_close(struct rpc_xprt *xprt)
453f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
454f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
455f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
456f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: closing\n", __func__);
45762da3b24880bccd4ffc32cf8d9a7e23fab475bddTrond Myklebust	xprt_disconnect_done(xprt);
458f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	(void) rpcrdma_ep_disconnect(&r_xprt->rx_ep, &r_xprt->rx_ia);
459f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
460f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
461f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
462f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_set_port(struct rpc_xprt *xprt, u16 port)
463f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
464f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct sockaddr_in *sap;
465f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
466f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap = (struct sockaddr_in *)&xprt->addr;
467f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap->sin_port = htons(port);
468f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap = (struct sockaddr_in *)&rpcx_to_rdmad(xprt).addr;
469f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap->sin_port = htons(port);
470f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: %u\n", __func__, port);
471f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
472f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
473f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
474f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_connect(struct rpc_task *task)
475f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
476f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = (struct rpc_xprt *)task->tk_xprt;
477f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
478f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
479f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!xprt_test_and_set_connecting(xprt)) {
480f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (r_xprt->rx_ep.rep_connected != 0) {
481f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			/* Reconnect */
482f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			schedule_delayed_work(&r_xprt->rdma_connect,
483f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				xprt->reestablish_timeout);
484f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		} else {
485f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			schedule_delayed_work(&r_xprt->rdma_connect, 0);
486f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			if (!RPC_IS_ASYNC(task))
487f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				flush_scheduled_work();
488f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		}
489f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
490f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
491f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
492f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int
493f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_reserve_xprt(struct rpc_task *task)
494f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
495f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = task->tk_xprt;
496f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
497f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int credits = atomic_read(&r_xprt->rx_buf.rb_credits);
498f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
499f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* == RPC_CWNDSCALE @ init, but *after* setup */
500f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (r_xprt->rx_buf.rb_cwndscale == 0UL) {
501f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		r_xprt->rx_buf.rb_cwndscale = xprt->cwnd;
502f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: cwndscale %lu\n", __func__,
503f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			r_xprt->rx_buf.rb_cwndscale);
504f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		BUG_ON(r_xprt->rx_buf.rb_cwndscale <= 0);
505f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
506f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->cwnd = credits * r_xprt->rx_buf.rb_cwndscale;
507f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return xprt_reserve_xprt_cong(task);
508f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
509f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
510f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
511f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * The RDMA allocate/free functions need the task structure as a place
512f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * to hide the struct rpcrdma_req, which is necessary for the actual send/recv
513f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * sequence. For this reason, the recv buffers are attached to send
514f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * buffers for portions of the RPC. Note that the RPC layer allocates
515f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * both send and receive buffers in the same call. We may register
516f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * the receive buffer portion when using reply chunks.
517f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
518f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void *
519f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_allocate(struct rpc_task *task, size_t size)
520f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
521f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = task->tk_xprt;
522f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req, *nreq;
523f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
524f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	req = rpcrdma_buffer_get(&rpcx_to_rdmax(xprt)->rx_buf);
525f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	BUG_ON(NULL == req);
526f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
527f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (size > req->rl_size) {
528f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: size %zd too large for buffer[%zd]: "
529f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			"prog %d vers %d proc %d\n",
530f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, size, req->rl_size,
531f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			task->tk_client->cl_prog, task->tk_client->cl_vers,
532f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			task->tk_msg.rpc_proc->p_proc);
533f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/*
534f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * Outgoing length shortage. Our inline write max must have
535f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * been configured to perform direct i/o.
536f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 *
537f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * This is therefore a large metadata operation, and the
538f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * allocate call was made on the maximum possible message,
539f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * e.g. containing long filename(s) or symlink data. In
540f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * fact, while these metadata operations *might* carry
541f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * large outgoing payloads, they rarely *do*. However, we
542f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * have to commit to the request here, so reallocate and
543f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * register it now. The data path will never require this
544f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * reallocation.
545f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 *
546f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * If the allocation or registration fails, the RPC framework
547f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * will (doggedly) retry.
548f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 */
549f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rpcx_to_rdmax(xprt)->rx_ia.ri_memreg_strategy ==
550f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				RPCRDMA_BOUNCEBUFFERS) {
551f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			/* forced to "pure inline" */
552f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			dprintk("RPC:       %s: too much data (%zd) for inline "
553f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					"(r/w max %d/%d)\n", __func__, size,
554f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					rpcx_to_rdmad(xprt).inline_rsize,
555f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					rpcx_to_rdmad(xprt).inline_wsize);
556f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			size = req->rl_size;
557f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			rpc_exit(task, -EIO);		/* fail the operation */
558f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			rpcx_to_rdmax(xprt)->rx_stats.failed_marshal_count++;
559f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto out;
560f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		}
561f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (task->tk_flags & RPC_TASK_SWAPPER)
562f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			nreq = kmalloc(sizeof *req + size, GFP_ATOMIC);
563f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		else
564f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			nreq = kmalloc(sizeof *req + size, GFP_NOFS);
565f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (nreq == NULL)
566f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto outfail;
567f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
568f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rpcrdma_register_internal(&rpcx_to_rdmax(xprt)->rx_ia,
569f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				nreq->rl_base, size + sizeof(struct rpcrdma_req)
570f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				- offsetof(struct rpcrdma_req, rl_base),
571f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&nreq->rl_handle, &nreq->rl_iov)) {
572f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			kfree(nreq);
573f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto outfail;
574f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		}
575f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rpcx_to_rdmax(xprt)->rx_stats.hardway_register_count += size;
576f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_size = size;
577f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_niovs = 0;
578f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_nchunks = 0;
579f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_buffer = (struct rpcrdma_buffer *)req;
580f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_reply = req->rl_reply;
581f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		memcpy(nreq->rl_segments,
582f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			req->rl_segments, sizeof nreq->rl_segments);
583f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/* flag the swap with an unused field */
584f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_iov.length = 0;
585f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply = NULL;
586f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req = nreq;
587f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
588f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: size %zd, request 0x%p\n", __func__, size, req);
589f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out:
590f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return req->rl_xdr_buf;
591f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
592f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\outfail:
593f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_put(req);
594f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcx_to_rdmax(xprt)->rx_stats.failed_marshal_count++;
595f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return NULL;
596f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
597f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
598f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
599f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * This function returns all RDMA resources to the pool.
600f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
601f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
602f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_free(void *buffer)
603f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
604f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req;
605f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt;
606f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_rep *rep;
607f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int i;
608f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
609f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buffer == NULL)
610f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return;
611f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
612f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	req = container_of(buffer, struct rpcrdma_req, rl_xdr_buf[0]);
613f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	r_xprt = container_of(req->rl_buffer, struct rpcrdma_xprt, rx_buf);
614f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rep = req->rl_reply;
615f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
616f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: called on 0x%p%s\n",
617f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		__func__, rep, (rep && rep->rr_func) ? " (with waiter)" : "");
618f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
619f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
620f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Finish the deregistration. When using mw bind, this was
621f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * begun in rpcrdma_reply_handler(). In all other modes, we
622f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * do it here, in thread context. The process is considered
623f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * complete when the rr_func vector becomes NULL - this
624f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * was put in place during rpcrdma_reply_handler() - the wait
625f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * call below will not block if the dereg is "done". If
626f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * interrupted, our framework will clean up.
627f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
628f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	for (i = 0; req->rl_nchunks;) {
629f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		--req->rl_nchunks;
630f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		i += rpcrdma_deregister_external(
631f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			&req->rl_segments[i], r_xprt, NULL);
632f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
633f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
634f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rep && wait_event_interruptible(rep->rr_unbind, !rep->rr_func)) {
635f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rep->rr_func = NULL;	/* abandon the callback */
636f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply = NULL;
637f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
638f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
639f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_iov.length == 0) {	/* see allocate above */
640f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		struct rpcrdma_req *oreq = (struct rpcrdma_req *)req->rl_buffer;
641f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		oreq->rl_reply = req->rl_reply;
642f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		(void) rpcrdma_deregister_internal(&r_xprt->rx_ia,
643f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\						   req->rl_handle,
644f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\						   &req->rl_iov);
645f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		kfree(req);
646f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req = oreq;
647f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
648f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
649f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Put back request+reply buffers */
650f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_put(req);
651f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
652f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
653f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
654f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * send_request invokes the meat of RPC RDMA. It must do the following:
655f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  1.  Marshal the RPC request into an RPC RDMA request, which means
656f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	putting a header in front of data, and creating IOVs for RDMA
657f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	from those in the request.
658f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  2.  In marshaling, detect opportunities for RDMA, and use them.
659f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  3.  Post a recv message to set up asynch completion, then send
660f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	the request (rpcrdma_ep_post).
661f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  4.  No partial sends are possible in the RPC-RDMA protocol (as in UDP).
662f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
663f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
664f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int
665f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_send_request(struct rpc_task *task)
666f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
667f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_rqst *rqst = task->tk_rqstp;
668f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = task->tk_xprt;
669f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
670f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
671f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
672f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* marshal the send itself */
673f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_niovs == 0 && rpcrdma_marshal_req(rqst) != 0) {
674f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		r_xprt->rx_stats.failed_marshal_count++;
675f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: rpcrdma_marshal_req failed\n",
676f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__);
677f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return -EIO;
678f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
679f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
680f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_reply == NULL) 		/* e.g. reconnection */
681f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rpcrdma_recv_buffer_get(req);
682f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
683f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_reply) {
684f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply->rr_func = rpcrdma_reply_handler;
685f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/* this need only be done once, but... */
686f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply->rr_xprt = xprt;
687f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
688f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
689f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req)) {
69062da3b24880bccd4ffc32cf8d9a7e23fab475bddTrond Myklebust		xprt_disconnect_done(xprt);
691f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return -ENOTCONN;	/* implies disconnect */
692f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
693f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
694f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rqst->rq_bytes_sent = 0;
695f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return 0;
696f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
697f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
698f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
699f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
700f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
701f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	long idle_time = 0;
702f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
703f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (xprt_connected(xprt))
704f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		idle_time = (long)(jiffies - xprt->last_used) / HZ;
705f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
706f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	seq_printf(seq,
707f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	  "\txprt:\trdma %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu "
708f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	  "%lu %lu %lu %Lu %Lu %Lu %Lu %lu %lu %lu\n",
709f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
710f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   0,	/* need a local port? */
711f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bind_count,
712f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.connect_count,
713f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.connect_time,
714f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   idle_time,
715f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.sends,
716f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.recvs,
717f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bad_xids,
718f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.req_u,
719f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bklog_u,
720f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
721f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.read_chunk_count,
722f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.write_chunk_count,
723f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.reply_chunk_count,
724f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.total_rdma_request,
725f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.total_rdma_reply,
726f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.pullup_copy_count,
727f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.fixup_copy_count,
728f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.hardway_register_count,
729f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.failed_marshal_count,
730f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.bad_reply_count);
731f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
732f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
733f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
734f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Plumbing for rpc transport switch and kernel module
735f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
736f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
737f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt_ops xprt_rdma_procs = {
738f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.reserve_xprt		= xprt_rdma_reserve_xprt,
739f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.release_xprt		= xprt_release_xprt_cong, /* sunrpc/xprt.c */
740f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.release_request	= xprt_release_rqst_cong,       /* ditto */
741f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.set_retrans_timeout	= xprt_set_retrans_timeout_def, /* ditto */
742f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.rpcbind		= rpcb_getport_async,	/* sunrpc/rpcb_clnt.c */
743f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.set_port		= xprt_rdma_set_port,
744f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.connect		= xprt_rdma_connect,
745f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.buf_alloc		= xprt_rdma_allocate,
746f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.buf_free		= xprt_rdma_free,
747f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.send_request		= xprt_rdma_send_request,
748f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.close			= xprt_rdma_close,
749f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.destroy		= xprt_rdma_destroy,
750f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.print_stats		= xprt_rdma_print_stats
751f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
752f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
753f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct xprt_class xprt_rdma = {
754f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.list			= LIST_HEAD_INIT(xprt_rdma.list),
755f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.name			= "rdma",
756f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.owner			= THIS_MODULE,
757f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.ident			= XPRT_TRANSPORT_RDMA,
758f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.setup			= xprt_setup_rdma,
759f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
760f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
761f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void __exit xprt_rdma_cleanup(void)
762f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
763f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
764f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
765f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPCRDMA Module Removed, deregister RPC RDMA transport\n");
766f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
767f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (sunrpc_table_header) {
768f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		unregister_sysctl_table(sunrpc_table_header);
769f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		sunrpc_table_header = NULL;
770f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
771f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
772f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = xprt_unregister_transport(&xprt_rdma);
773f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
774f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: xprt_unregister returned %i\n",
775f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, rc);
776f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
777f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
778f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int __init xprt_rdma_init(void)
779f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
780f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
781f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
782f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = xprt_register_transport(&xprt_rdma);
783f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
784f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
785f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return rc;
786f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
787f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "RPCRDMA Module Init, register RPC RDMA transport\n");
788f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
789f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "Defaults:\n");
790f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "\tSlots %d\n"
791f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		"\tMaxInlineRead %d\n\tMaxInlineWrite %d\n",
792f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_slot_table_entries,
793f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_max_inline_read, xprt_rdma_max_inline_write);
794f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "\tPadding %d\n\tMemreg %d\n",
795f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_inline_write_padding, xprt_rdma_memreg_strategy);
796f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
797f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
798f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!sunrpc_table_header)
799f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		sunrpc_table_header = register_sysctl_table(sunrpc_table);
800f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
801f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return 0;
802f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
803f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
804f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\module_init(xprt_rdma_init);
805f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\module_exit(xprt_rdma_cleanup);
806