transport.c revision 43cedbf0e8dfb9c5610eb7985d5f21263e313802
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>
525a0e3ad6af8660be21ca98a971cd00f331318c05Tejun Heo#include <linux/slab.h>
53f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include <linux/seq_file.h>
54f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
55f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#include "xprt_rdma.h"
56f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
57f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
58f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\# define RPCDBG_FACILITY	RPCDBG_TRANS
59f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
60f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
61f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_LICENSE("Dual BSD/GPL");
62f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
63f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_DESCRIPTION("RPC/RDMA Transport for Linux kernel NFS");
64f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\MODULE_AUTHOR("Network Appliance, Inc.");
65f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
66f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
67f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * tunables
68f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
69f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
70f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_slot_table_entries = RPCRDMA_DEF_SLOT_TABLE;
71f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
72f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
73f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int xprt_rdma_inline_write_padding;
743197d309f5fb042499b2c4c8f2fcb67372df5201Tom Talpeystatic unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRMR;
759191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey                int xprt_rdma_pad_optimize = 0;
76f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
77f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
78f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
79f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int min_slot_table_size = RPCRDMA_MIN_SLOT_TABLE;
80f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_slot_table_size = RPCRDMA_MAX_SLOT_TABLE;
81f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int zero;
82f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_padding = PAGE_SIZE;
83f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int min_memreg = RPCRDMA_BOUNCEBUFFERS;
84f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static unsigned int max_memreg = RPCRDMA_LAST - 1;
85f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
86f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct ctl_table_header *sunrpc_table_header;
87f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
88f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static ctl_table xr_tunables_table[] = {
89f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
90f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_slot_table_entries",
91f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_slot_table_entries,
92f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
93f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
946d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec_minmax,
95f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &min_slot_table_size,
96f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_slot_table_size
97f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
98f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
99f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_max_inline_read",
100f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_max_inline_read,
101f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
102f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
1036d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec,
104f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
105f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
106f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_max_inline_write",
107f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_max_inline_write,
108f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
109f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
1106d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec,
111f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
112f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
113f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_inline_write_padding",
114f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_inline_write_padding,
115f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
116f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
1176d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec_minmax,
118f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &zero,
119f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_padding,
120f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
121f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
122f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "rdma_memreg_strategy",
123f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.data		= &xprt_rdma_memreg_strategy,
124f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.maxlen		= sizeof(unsigned int),
125f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0644,
1266d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec_minmax,
127f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra1		= &min_memreg,
128f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.extra2		= &max_memreg,
129f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
130f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
1319191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey		.procname	= "rdma_pad_optimize",
1329191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey		.data		= &xprt_rdma_pad_optimize,
1339191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey		.maxlen		= sizeof(unsigned int),
1349191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey		.mode		= 0644,
1356d4561110a3e9fa742aeec6717248a491dfb1878Eric W. Biederman		.proc_handler	= proc_dointvec,
1369191ca3b381b15b9a88785a8ae2fa4db8e553b0cTom Talpey	},
137f8572d8f2a2ba75408b97dc24ef47c83671795d7Eric W. Biederman	{ },
138f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
139f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
140f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static ctl_table sunrpc_table[] = {
141f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	{
142f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.procname	= "sunrpc",
143f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.mode		= 0555,
144f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		.child		= xr_tunables_table
145f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	},
146f8572d8f2a2ba75408b97dc24ef47c83671795d7Eric W. Biederman	{ },
147f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
148f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
149f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
150f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
151f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt_ops xprt_rdma_procs;	/* forward reference */
152f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
153f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
154f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_format_addresses(struct rpc_xprt *xprt)
155f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
156c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	struct sockaddr *sap = (struct sockaddr *)
157f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					&rpcx_to_rdmad(xprt).addr;
158c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	struct sockaddr_in *sin = (struct sockaddr_in *)sap;
159c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	char buf[64];
160f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
161c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	(void)rpc_ntop(sap, buf, sizeof(buf));
162c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	xprt->address_strings[RPC_DISPLAY_ADDR] = kstrdup(buf, GFP_KERNEL);
163f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
16481160e66cca3d3a16b7d88e0e2dccfc5c76f36f9Joe Perches	snprintf(buf, sizeof(buf), "%u", rpc_get_port(sap));
165c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	xprt->address_strings[RPC_DISPLAY_PORT] = kstrdup(buf, GFP_KERNEL);
166f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
167f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma";
168f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
16981160e66cca3d3a16b7d88e0e2dccfc5c76f36f9Joe Perches	snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr));
170c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL);
171c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever
17281160e66cca3d3a16b7d88e0e2dccfc5c76f36f9Joe Perches	snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap));
173c877b849d302d1275452af80b7221a2555dc02e1Chuck Lever	xprt->address_strings[RPC_DISPLAY_HEX_PORT] = kstrdup(buf, GFP_KERNEL);
174f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
175f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* netid */
176f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->address_strings[RPC_DISPLAY_NETID] = "rdma";
177f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
178f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
179f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
180f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_free_addresses(struct rpc_xprt *xprt)
181f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
18233e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever	unsigned int i;
18333e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever
18433e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever	for (i = 0; i < RPC_DISPLAY_MAX; i++)
18533e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever		switch (i) {
18633e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever		case RPC_DISPLAY_PROTO:
18733e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever		case RPC_DISPLAY_NETID:
18833e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever			continue;
18933e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever		default:
19033e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever			kfree(xprt->address_strings[i]);
19133e01dc7f578813cda074ceaeaf68b0f3ffcc393Chuck Lever		}
192f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
193f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
194f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
195f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_connect_worker(struct work_struct *work)
196f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
197f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt =
198f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		container_of(work, struct rpcrdma_xprt, rdma_connect.work);
199f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = &r_xprt->xprt;
200f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc = 0;
201f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
202f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!xprt->shutdown) {
203f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_clear_connected(xprt);
204f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
205f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: %sconnect\n", __func__,
206f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				r_xprt->rx_ep.rep_connected != 0 ? "re" : "");
207f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rc = rpcrdma_ep_connect(&r_xprt->rx_ep, &r_xprt->rx_ia);
208f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rc)
209f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto out;
210f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
211f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	goto out_clear;
212f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
213f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out:
214f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_wake_pending_tasks(xprt, rc);
215f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
216f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out_clear:
217f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: exit\n", __func__);
218f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_clear_connecting(xprt);
219f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
220f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
221f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
222f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * xprt_rdma_destroy
223f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
224f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Destroy the xprt.
225f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Free all memory associated with the object, including its own.
226f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * NOTE: none of the *destroy methods free memory for their top-level
227f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * objects, even though they may have allocated it (they do free
228f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * private memory). It's up to the caller to handle it. In this
229f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * case (RDMA transport), all structure memory is inlined with the
230f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * struct rpcrdma_xprt.
231f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
232f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
233f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_destroy(struct rpc_xprt *xprt)
234f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
235f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
236f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
237f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
238f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: called\n", __func__);
239f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
240a25e758c5fa1137e1bbc440194e55f7c59177145Tejun Heo	cancel_delayed_work_sync(&r_xprt->rdma_connect);
241f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
242f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_clear_connected(xprt);
243f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
244f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_destroy(&r_xprt->rx_buf);
245f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ep_destroy(&r_xprt->rx_ep, &r_xprt->rx_ia);
246f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
247f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: rpcrdma_ep_destroy returned %i\n",
248f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, rc);
249f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_ia_close(&r_xprt->rx_ia);
250f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
251f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_free_addresses(xprt);
252f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
253e204e621b4160c802315bc2d0fa335337c0d62e8Pavel Emelyanov	xprt_free(xprt);
254f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
255f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: returning\n", __func__);
256f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
257f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	module_put(THIS_MODULE);
258f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
259f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
2602881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebuststatic const struct rpc_timeout xprt_rdma_default_timeout = {
2612881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust	.to_initval = 60 * HZ,
2622881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust	.to_maxval = 60 * HZ,
2632881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust};
2642881ae74e68ecfe3b32a90936e5d93a9ba598c3aTrond Myklebust
265f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/**
266f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * xprt_setup_rdma - Set up transport to use RDMA
267f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *
268f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * @args: rpc transport arguments
269f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
270f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt *
271f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_setup_rdma(struct xprt_create *args)
272f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
273f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_create_data_internal cdata;
274f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt;
275f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *new_xprt;
276f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_ep *new_ep;
277f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct sockaddr_in *sin;
278f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
279f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
280f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (args->addrlen > sizeof(xprt->addr)) {
281f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: address too large\n", __func__);
282f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return ERR_PTR(-EBADF);
283f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
284f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
28537aa2133731d9231eb834f700119f0d3f1ed2664Pavel Emelyanov	xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt),
286bd1722d4316e42a12fe6337ebe34d7e1e2c088b2Pavel Emelyanov			xprt_rdma_slot_table_entries);
287f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (xprt == NULL) {
288f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: couldn't allocate rpcrdma_xprt\n",
289f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__);
290f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return ERR_PTR(-ENOMEM);
291f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
292f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
293f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* 60 second timeout, no retries */
294ba7392bb37cb12781890f45d7ddee1618e33a036Trond Myklebust	xprt->timeout = &xprt_rdma_default_timeout;
295f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->bind_timeout = (60U * HZ);
296f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->reestablish_timeout = (5U * HZ);
297f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->idle_timeout = (5U * 60 * HZ);
298f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
299f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->resvport = 0;		/* privileged port not needed */
300f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->tsh_size = 0;		/* RPC-RDMA handles framing */
301f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->max_payload = RPCRDMA_MAX_DATA_SEGS * PAGE_SIZE;
302f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->ops = &xprt_rdma_procs;
303f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
304f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
305f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Set up RDMA-specific connect data.
306f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
307f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
308f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Put server RDMA address in local cdata */
309f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	memcpy(&cdata.addr, args->dstaddr, args->addrlen);
310f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
311f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Ensure xprt->addr holds valid server TCP (not RDMA)
312f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * address, for any side protocols which peek at it */
313f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->prot = IPPROTO_TCP;
314f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->addrlen = args->addrlen;
315f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	memcpy(&xprt->addr, &cdata.addr, xprt->addrlen);
316f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
317f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sin = (struct sockaddr_in *)&cdata.addr;
318f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (ntohs(sin->sin_port) != 0)
319f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_set_bound(xprt);
320f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
32121454aaad30651ba0dcc16fe5271bc12ee21f132Harvey Harrison	dprintk("RPC:       %s: %pI4:%u\n",
32221454aaad30651ba0dcc16fe5271bc12ee21f132Harvey Harrison		__func__, &sin->sin_addr.s_addr, ntohs(sin->sin_port));
323f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
324f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Set max requests */
325f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.max_requests = xprt->max_reqs;
326f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
327f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Set some length limits */
328f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.rsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA write max */
329f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.wsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA read max */
330f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
331f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.inline_wsize = xprt_rdma_max_inline_write;
332f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (cdata.inline_wsize > cdata.wsize)
333f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		cdata.inline_wsize = cdata.wsize;
334f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
335f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.inline_rsize = xprt_rdma_max_inline_read;
336f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (cdata.inline_rsize > cdata.rsize)
337f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		cdata.inline_rsize = cdata.rsize;
338f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
339f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	cdata.padding = xprt_rdma_inline_write_padding;
340f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
341f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
342f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Create new transport instance, which includes initialized
343f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o ia
344f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o endpoint
345f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 *  o buffers
346f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
347f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
348f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_xprt = rpcx_to_rdmax(xprt);
349f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
350f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ia_open(new_xprt, (struct sockaddr *) &cdata.addr,
351f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				xprt_rdma_memreg_strategy);
352f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
353f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out1;
354f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
355f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
356f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * initialize and create ep
357f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
358f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_xprt->rx_data = cdata;
359f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep = &new_xprt->rx_ep;
360f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_remote_addr = cdata.addr;
361f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
362f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_ep_create(&new_xprt->rx_ep,
363f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&new_xprt->rx_ia, &new_xprt->rx_data);
364f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
365f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out2;
366f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
367f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
368f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Allocate pre-registered send and receive buffers for headers and
369f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * any inline data. Also specify any padding which will be provided
370f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * from a preregistered zero buffer.
371f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
372f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = rpcrdma_buffer_create(&new_xprt->rx_buf, new_ep, &new_xprt->rx_ia,
373f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&new_xprt->rx_data);
374f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
375f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out3;
376f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
377f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
378f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Register a callback for connection events. This is necessary because
379f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * connection loss notification is async. We also catch connection loss
380f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * when reaping receives.
381f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
382f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	INIT_DELAYED_WORK(&new_xprt->rdma_connect, xprt_rdma_connect_worker);
383f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_func = rpcrdma_conn_func;
384f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	new_ep->rep_xprt = xprt;
385f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
386f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_format_addresses(xprt);
387f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
388f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!try_module_get(THIS_MODULE))
389f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		goto out4;
390f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
391f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return xprt;
392f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
393f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out4:
394f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt_rdma_free_addresses(xprt);
395f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = -EINVAL;
396f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out3:
397f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	(void) rpcrdma_ep_destroy(new_ep, &new_xprt->rx_ia);
398f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out2:
399f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_ia_close(&new_xprt->rx_ia);
400f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out1:
401e204e621b4160c802315bc2d0fa335337c0d62e8Pavel Emelyanov	xprt_free(xprt);
402f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return ERR_PTR(rc);
403f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
404f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
405f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
406f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Close a connection, during shutdown or timeout/reconnect
407f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
408f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
409f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_close(struct rpc_xprt *xprt)
410f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
411f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
412f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
413f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: closing\n", __func__);
41408ca0dce1eafa419059ac4cad9ed522af7052526Tom Talpey	if (r_xprt->rx_ep.rep_connected > 0)
41508ca0dce1eafa419059ac4cad9ed522af7052526Tom Talpey		xprt->reestablish_timeout = 0;
41662da3b24880bccd4ffc32cf8d9a7e23fab475bddTrond Myklebust	xprt_disconnect_done(xprt);
417f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	(void) rpcrdma_ep_disconnect(&r_xprt->rx_ep, &r_xprt->rx_ia);
418f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
419f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
420f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
421f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_set_port(struct rpc_xprt *xprt, u16 port)
422f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
423f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct sockaddr_in *sap;
424f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
425f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap = (struct sockaddr_in *)&xprt->addr;
426f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap->sin_port = htons(port);
427f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap = (struct sockaddr_in *)&rpcx_to_rdmad(xprt).addr;
428f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	sap->sin_port = htons(port);
429f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: %u\n", __func__, port);
430f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
431f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
432f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
433f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_connect(struct rpc_task *task)
434f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
435f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = (struct rpc_xprt *)task->tk_xprt;
436f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
437f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
4380b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust	if (r_xprt->rx_ep.rep_connected != 0) {
4390b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		/* Reconnect */
4400b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		schedule_delayed_work(&r_xprt->rdma_connect,
4410b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust			xprt->reestablish_timeout);
4420b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		xprt->reestablish_timeout <<= 1;
4430b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		if (xprt->reestablish_timeout > (30 * HZ))
4440b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust			xprt->reestablish_timeout = (30 * HZ);
4450b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		else if (xprt->reestablish_timeout < (5 * HZ))
4460b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust			xprt->reestablish_timeout = (5 * HZ);
4470b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust	} else {
4480b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		schedule_delayed_work(&r_xprt->rdma_connect, 0);
4490b9e79431377df452348e78262dd5a3dc359eeefTrond Myklebust		if (!RPC_IS_ASYNC(task))
450a25e758c5fa1137e1bbc440194e55f7c59177145Tejun Heo			flush_delayed_work(&r_xprt->rdma_connect);
451f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
452f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
453f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
454f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int
45543cedbf0e8dfb9c5610eb7985d5f21263e313802Trond Myklebustxprt_rdma_reserve_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
456f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
457f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
458f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int credits = atomic_read(&r_xprt->rx_buf.rb_credits);
459f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
460f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* == RPC_CWNDSCALE @ init, but *after* setup */
461f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (r_xprt->rx_buf.rb_cwndscale == 0UL) {
462f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		r_xprt->rx_buf.rb_cwndscale = xprt->cwnd;
463f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: cwndscale %lu\n", __func__,
464f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			r_xprt->rx_buf.rb_cwndscale);
465f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		BUG_ON(r_xprt->rx_buf.rb_cwndscale <= 0);
466f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
467f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	xprt->cwnd = credits * r_xprt->rx_buf.rb_cwndscale;
46843cedbf0e8dfb9c5610eb7985d5f21263e313802Trond Myklebust	return xprt_reserve_xprt_cong(xprt, task);
469f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
470f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
471f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
472f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * The RDMA allocate/free functions need the task structure as a place
473f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * to hide the struct rpcrdma_req, which is necessary for the actual send/recv
474f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * sequence. For this reason, the recv buffers are attached to send
475f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * buffers for portions of the RPC. Note that the RPC layer allocates
476f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * both send and receive buffers in the same call. We may register
477f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * the receive buffer portion when using reply chunks.
478f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
479f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void *
480f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_allocate(struct rpc_task *task, size_t size)
481f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
482f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = task->tk_xprt;
483f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req, *nreq;
484f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
485f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	req = rpcrdma_buffer_get(&rpcx_to_rdmax(xprt)->rx_buf);
486f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	BUG_ON(NULL == req);
487f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
488f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (size > req->rl_size) {
489f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: size %zd too large for buffer[%zd]: "
490f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			"prog %d vers %d proc %d\n",
491f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, size, req->rl_size,
492f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			task->tk_client->cl_prog, task->tk_client->cl_vers,
493f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			task->tk_msg.rpc_proc->p_proc);
494f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/*
495f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * Outgoing length shortage. Our inline write max must have
496f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * been configured to perform direct i/o.
497f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 *
498f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * This is therefore a large metadata operation, and the
499f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * allocate call was made on the maximum possible message,
500f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * e.g. containing long filename(s) or symlink data. In
501f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * fact, while these metadata operations *might* carry
502f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * large outgoing payloads, they rarely *do*. However, we
503f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * have to commit to the request here, so reallocate and
504f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * register it now. The data path will never require this
505f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * reallocation.
506f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 *
507f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * If the allocation or registration fails, the RPC framework
508f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 * will (doggedly) retry.
509f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		 */
510f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rpcx_to_rdmax(xprt)->rx_ia.ri_memreg_strategy ==
511f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				RPCRDMA_BOUNCEBUFFERS) {
512f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			/* forced to "pure inline" */
513f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			dprintk("RPC:       %s: too much data (%zd) for inline "
514f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					"(r/w max %d/%d)\n", __func__, size,
515f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					rpcx_to_rdmad(xprt).inline_rsize,
516f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\					rpcx_to_rdmad(xprt).inline_wsize);
517f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			size = req->rl_size;
518f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			rpc_exit(task, -EIO);		/* fail the operation */
519f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			rpcx_to_rdmax(xprt)->rx_stats.failed_marshal_count++;
520f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto out;
521f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		}
522f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (task->tk_flags & RPC_TASK_SWAPPER)
523f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			nreq = kmalloc(sizeof *req + size, GFP_ATOMIC);
524f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		else
525f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			nreq = kmalloc(sizeof *req + size, GFP_NOFS);
526f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (nreq == NULL)
527f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto outfail;
528f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
529f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		if (rpcrdma_register_internal(&rpcx_to_rdmax(xprt)->rx_ia,
530f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				nreq->rl_base, size + sizeof(struct rpcrdma_req)
531f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				- offsetof(struct rpcrdma_req, rl_base),
532f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\				&nreq->rl_handle, &nreq->rl_iov)) {
533f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			kfree(nreq);
534f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			goto outfail;
535f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		}
536f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rpcx_to_rdmax(xprt)->rx_stats.hardway_register_count += size;
537f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_size = size;
538f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_niovs = 0;
539f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_nchunks = 0;
540f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_buffer = (struct rpcrdma_buffer *)req;
541f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_reply = req->rl_reply;
542f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		memcpy(nreq->rl_segments,
543f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			req->rl_segments, sizeof nreq->rl_segments);
544f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/* flag the swap with an unused field */
545f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		nreq->rl_iov.length = 0;
546f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply = NULL;
547f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req = nreq;
548f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
549f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: size %zd, request 0x%p\n", __func__, size, req);
550f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\out:
551575448bd36208f99fe0dd554a43518d798966740Tom Talpey	req->rl_connect_cookie = 0;	/* our reserved value */
552f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return req->rl_xdr_buf;
553f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
554f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\outfail:
555f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_put(req);
556f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcx_to_rdmax(xprt)->rx_stats.failed_marshal_count++;
557f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return NULL;
558f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
559f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
560f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
561f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * This function returns all RDMA resources to the pool.
562f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
563f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void
564f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_free(void *buffer)
565f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
566f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req;
567f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt;
568f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_rep *rep;
569f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int i;
570f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
571f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (buffer == NULL)
572f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return;
573f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
574f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	req = container_of(buffer, struct rpcrdma_req, rl_xdr_buf[0]);
575ee1a2c564f67407947e89f1dac75ac0af0ba88c7Tom Talpey	if (req->rl_iov.length == 0) {	/* see allocate above */
576ee1a2c564f67407947e89f1dac75ac0af0ba88c7Tom Talpey		r_xprt = container_of(((struct rpcrdma_req *) req->rl_buffer)->rl_buffer,
577ee1a2c564f67407947e89f1dac75ac0af0ba88c7Tom Talpey				      struct rpcrdma_xprt, rx_buf);
578ee1a2c564f67407947e89f1dac75ac0af0ba88c7Tom Talpey	} else
579ee1a2c564f67407947e89f1dac75ac0af0ba88c7Tom Talpey		r_xprt = container_of(req->rl_buffer, struct rpcrdma_xprt, rx_buf);
580f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rep = req->rl_reply;
581f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
582f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk("RPC:       %s: called on 0x%p%s\n",
583f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		__func__, rep, (rep && rep->rr_func) ? " (with waiter)" : "");
584f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
585f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/*
586f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * Finish the deregistration. When using mw bind, this was
587f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * begun in rpcrdma_reply_handler(). In all other modes, we
588f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * do it here, in thread context. The process is considered
589f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * complete when the rr_func vector becomes NULL - this
590f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * was put in place during rpcrdma_reply_handler() - the wait
591f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * call below will not block if the dereg is "done". If
592f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 * interrupted, our framework will clean up.
593f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	 */
594f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	for (i = 0; req->rl_nchunks;) {
595f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		--req->rl_nchunks;
596f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		i += rpcrdma_deregister_external(
597f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			&req->rl_segments[i], r_xprt, NULL);
598f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
599f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
600f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rep && wait_event_interruptible(rep->rr_unbind, !rep->rr_func)) {
601f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rep->rr_func = NULL;	/* abandon the callback */
602f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply = NULL;
603f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
604f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
605f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_iov.length == 0) {	/* see allocate above */
606f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		struct rpcrdma_req *oreq = (struct rpcrdma_req *)req->rl_buffer;
607f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		oreq->rl_reply = req->rl_reply;
608f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		(void) rpcrdma_deregister_internal(&r_xprt->rx_ia,
609f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\						   req->rl_handle,
610f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\						   &req->rl_iov);
611f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		kfree(req);
612f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req = oreq;
613f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
614f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
615f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* Put back request+reply buffers */
616f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rpcrdma_buffer_put(req);
617f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
618f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
619f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
620f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * send_request invokes the meat of RPC RDMA. It must do the following:
621f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  1.  Marshal the RPC request into an RPC RDMA request, which means
622f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	putting a header in front of data, and creating IOVs for RDMA
623f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	from those in the request.
624f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  2.  In marshaling, detect opportunities for RDMA, and use them.
625f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  3.  Post a recv message to set up asynch completion, then send
626f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *	the request (rpcrdma_ep_post).
627f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ *  4.  No partial sends are possible in the RPC-RDMA protocol (as in UDP).
628f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
629f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
630f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int
631f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\xprt_rdma_send_request(struct rpc_task *task)
632f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
633f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_rqst *rqst = task->tk_rqstp;
634f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpc_xprt *xprt = task->tk_xprt;
635f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
636f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
637f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
638f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	/* marshal the send itself */
639f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_niovs == 0 && rpcrdma_marshal_req(rqst) != 0) {
640f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		r_xprt->rx_stats.failed_marshal_count++;
641f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: rpcrdma_marshal_req failed\n",
642f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__);
643f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return -EIO;
644f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
645f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
646f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_reply == NULL) 		/* e.g. reconnection */
647f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		rpcrdma_recv_buffer_get(req);
648f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
649f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (req->rl_reply) {
650f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply->rr_func = rpcrdma_reply_handler;
651f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		/* this need only be done once, but... */
652f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		req->rl_reply->rr_xprt = xprt;
653f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
654f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
655575448bd36208f99fe0dd554a43518d798966740Tom Talpey	/* Must suppress retransmit to maintain credits */
656575448bd36208f99fe0dd554a43518d798966740Tom Talpey	if (req->rl_connect_cookie == xprt->connect_cookie)
657575448bd36208f99fe0dd554a43518d798966740Tom Talpey		goto drop_connection;
658575448bd36208f99fe0dd554a43518d798966740Tom Talpey	req->rl_connect_cookie = xprt->connect_cookie;
659575448bd36208f99fe0dd554a43518d798966740Tom Talpey
660575448bd36208f99fe0dd554a43518d798966740Tom Talpey	if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req))
661575448bd36208f99fe0dd554a43518d798966740Tom Talpey		goto drop_connection;
662f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
663d60dbb20a74c2cfa142be0a34dac3c6547ea086cTrond Myklebust	rqst->rq_xmit_bytes_sent += rqst->rq_snd_buf.len;
664f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rqst->rq_bytes_sent = 0;
665f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return 0;
666575448bd36208f99fe0dd554a43518d798966740Tom Talpey
667575448bd36208f99fe0dd554a43518d798966740Tom Talpeydrop_connection:
668575448bd36208f99fe0dd554a43518d798966740Tom Talpey	xprt_disconnect_done(xprt);
669575448bd36208f99fe0dd554a43518d798966740Tom Talpey	return -ENOTCONN;	/* implies disconnect */
670f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
671f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
672f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void xprt_rdma_print_stats(struct rpc_xprt *xprt, struct seq_file *seq)
673f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
674f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
675f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	long idle_time = 0;
676f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
677f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (xprt_connected(xprt))
678f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		idle_time = (long)(jiffies - xprt->last_used) / HZ;
679f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
680f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	seq_printf(seq,
681f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	  "\txprt:\trdma %u %lu %lu %lu %ld %lu %lu %lu %Lu %Lu "
682f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	  "%lu %lu %lu %Lu %Lu %Lu %Lu %lu %lu %lu\n",
683f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
684f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   0,	/* need a local port? */
685f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bind_count,
686f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.connect_count,
687f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.connect_time,
688f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   idle_time,
689f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.sends,
690f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.recvs,
691f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bad_xids,
692f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.req_u,
693f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   xprt->stat.bklog_u,
694f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
695f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.read_chunk_count,
696f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.write_chunk_count,
697f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.reply_chunk_count,
698f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.total_rdma_request,
699f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.total_rdma_reply,
700f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.pullup_copy_count,
701f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.fixup_copy_count,
702f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.hardway_register_count,
703f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.failed_marshal_count,
704f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	   r_xprt->rx_stats.bad_reply_count);
705f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
706f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
707f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\/*
708f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ * Plumbing for rpc transport switch and kernel module
709f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\ */
710f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
711f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct rpc_xprt_ops xprt_rdma_procs = {
712f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.reserve_xprt		= xprt_rdma_reserve_xprt,
713f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.release_xprt		= xprt_release_xprt_cong, /* sunrpc/xprt.c */
714f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.release_request	= xprt_release_rqst_cong,       /* ditto */
715f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.set_retrans_timeout	= xprt_set_retrans_timeout_def, /* ditto */
716f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.rpcbind		= rpcb_getport_async,	/* sunrpc/rpcb_clnt.c */
717f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.set_port		= xprt_rdma_set_port,
718f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.connect		= xprt_rdma_connect,
719f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.buf_alloc		= xprt_rdma_allocate,
720f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.buf_free		= xprt_rdma_free,
721f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.send_request		= xprt_rdma_send_request,
722f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.close			= xprt_rdma_close,
723f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.destroy		= xprt_rdma_destroy,
724f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.print_stats		= xprt_rdma_print_stats
725f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
726f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
727f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static struct xprt_class xprt_rdma = {
728f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.list			= LIST_HEAD_INIT(xprt_rdma.list),
729f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.name			= "rdma",
730f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.owner			= THIS_MODULE,
731f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.ident			= XPRT_TRANSPORT_RDMA,
732f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	.setup			= xprt_setup_rdma,
733f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\};
734f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
735f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static void __exit xprt_rdma_cleanup(void)
736f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
737f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
738f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
739b3cd8d45a764e6edb06e7bd386faf99a879569b8Tom Talpey	dprintk(KERN_INFO "RPCRDMA Module Removed, deregister RPC RDMA transport\n");
740f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
741f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (sunrpc_table_header) {
742f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		unregister_sysctl_table(sunrpc_table_header);
743f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		sunrpc_table_header = NULL;
744f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	}
745f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
746f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = xprt_unregister_transport(&xprt_rdma);
747f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
748f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		dprintk("RPC:       %s: xprt_unregister returned %i\n",
749f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\			__func__, rc);
750f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
751f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
752f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\static int __init xprt_rdma_init(void)
753f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\{
754f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	int rc;
755f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
756f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	rc = xprt_register_transport(&xprt_rdma);
757f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
758f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (rc)
759f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		return rc;
760f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
761f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "RPCRDMA Module Init, register RPC RDMA transport\n");
762f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
763f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "Defaults:\n");
764f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "\tSlots %d\n"
765f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		"\tMaxInlineRead %d\n\tMaxInlineWrite %d\n",
766f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_slot_table_entries,
767f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_max_inline_read, xprt_rdma_max_inline_write);
768f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	dprintk(KERN_INFO "\tPadding %d\n\tMemreg %d\n",
769f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		xprt_rdma_inline_write_padding, xprt_rdma_memreg_strategy);
770f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
771f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#ifdef RPC_DEBUG
772f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	if (!sunrpc_table_header)
773f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\		sunrpc_table_header = register_sysctl_table(sunrpc_table);
774f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\#endif
775f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\	return 0;
776f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\}
777f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\
778f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\module_init(xprt_rdma_init);
779f58851e6b0f148fb4b2a1c6f70beb2f125863c0f\"Talpey, Thomas\module_exit(xprt_rdma_cleanup);
780