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