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