1fe267a55SPedro F. Giffuni /*- 2fe267a55SPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3fe267a55SPedro F. Giffuni * 4aa0a1e58SJeff Roberson * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. 5aa0a1e58SJeff Roberson * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 6aa0a1e58SJeff Roberson * Copyright (c) 2004 Intel Corporation. All rights reserved. 7aa0a1e58SJeff Roberson * Copyright (c) 2004 Topspin Corporation. All rights reserved. 8aa0a1e58SJeff Roberson * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 9aa0a1e58SJeff Roberson * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 10aa0a1e58SJeff Roberson * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. 11aa0a1e58SJeff Roberson * 12aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two 13aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU 14aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file 15aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the 16aa0a1e58SJeff Roberson * OpenIB.org BSD license below: 17aa0a1e58SJeff Roberson * 18aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or 19aa0a1e58SJeff Roberson * without modification, are permitted provided that the following 20aa0a1e58SJeff Roberson * conditions are met: 21aa0a1e58SJeff Roberson * 22aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above 23aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 24aa0a1e58SJeff Roberson * disclaimer. 25aa0a1e58SJeff Roberson * 26aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above 27aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 28aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials 29aa0a1e58SJeff Roberson * provided with the distribution. 30aa0a1e58SJeff Roberson * 31aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 32aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 33aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 34aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 35aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 36aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 37aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 38aa0a1e58SJeff Roberson * SOFTWARE. 3909938b21SHans Petter Selasky * 4009938b21SHans Petter Selasky * $FreeBSD$ 41aa0a1e58SJeff Roberson */ 42aa0a1e58SJeff Roberson 43aa0a1e58SJeff Roberson #if !defined(IB_VERBS_H) 44aa0a1e58SJeff Roberson #define IB_VERBS_H 45aa0a1e58SJeff Roberson 46aa0a1e58SJeff Roberson #include <linux/types.h> 47aa0a1e58SJeff Roberson #include <linux/device.h> 48aa0a1e58SJeff Roberson #include <linux/mm.h> 49aa0a1e58SJeff Roberson #include <linux/dma-mapping.h> 50aa0a1e58SJeff Roberson #include <linux/kref.h> 51aa0a1e58SJeff Roberson #include <linux/list.h> 52aa0a1e58SJeff Roberson #include <linux/rwsem.h> 53aa0a1e58SJeff Roberson #include <linux/scatterlist.h> 54c9f432b7SAlfred Perlstein #include <linux/workqueue.h> 55478d3005SHans Petter Selasky #include <linux/socket.h> 56b5c1e0cbSHans Petter Selasky #include <linux/if_ether.h> 57478d3005SHans Petter Selasky #include <net/ipv6.h> 58478d3005SHans Petter Selasky #include <net/ip.h> 59478d3005SHans Petter Selasky #include <linux/string.h> 60478d3005SHans Petter Selasky #include <linux/slab.h> 61478d3005SHans Petter Selasky #include <linux/rcupdate.h> 62478d3005SHans Petter Selasky #include <linux/netdevice.h> 63478d3005SHans Petter Selasky #include <netinet/ip.h> 64aa0a1e58SJeff Roberson 65478d3005SHans Petter Selasky #include <asm/atomic.h> 66aa0a1e58SJeff Roberson #include <asm/uaccess.h> 67aa0a1e58SJeff Roberson 68478d3005SHans Petter Selasky struct ifla_vf_info; 69478d3005SHans Petter Selasky struct ifla_vf_stats; 70478d3005SHans Petter Selasky 71c9f432b7SAlfred Perlstein extern struct workqueue_struct *ib_wq; 72478d3005SHans Petter Selasky extern struct workqueue_struct *ib_comp_wq; 73c9f432b7SAlfred Perlstein 74aa0a1e58SJeff Roberson union ib_gid { 75aa0a1e58SJeff Roberson u8 raw[16]; 76aa0a1e58SJeff Roberson struct { 77aa0a1e58SJeff Roberson __be64 subnet_prefix; 78aa0a1e58SJeff Roberson __be64 interface_id; 79aa0a1e58SJeff Roberson } global; 80aa0a1e58SJeff Roberson }; 81aa0a1e58SJeff Roberson 82478d3005SHans Petter Selasky extern union ib_gid zgid; 83478d3005SHans Petter Selasky 84478d3005SHans Petter Selasky enum ib_gid_type { 85478d3005SHans Petter Selasky /* If link layer is Ethernet, this is RoCE V1 */ 86478d3005SHans Petter Selasky IB_GID_TYPE_IB = 0, 87478d3005SHans Petter Selasky IB_GID_TYPE_ROCE = 0, 88478d3005SHans Petter Selasky IB_GID_TYPE_ROCE_UDP_ENCAP = 1, 89478d3005SHans Petter Selasky IB_GID_TYPE_SIZE 90478d3005SHans Petter Selasky }; 91478d3005SHans Petter Selasky 92478d3005SHans Petter Selasky #define ROCE_V2_UDP_DPORT 4791 93478d3005SHans Petter Selasky struct ib_gid_attr { 94478d3005SHans Petter Selasky enum ib_gid_type gid_type; 95478d3005SHans Petter Selasky struct net_device *ndev; 96478d3005SHans Petter Selasky }; 97478d3005SHans Petter Selasky 98aa0a1e58SJeff Roberson enum rdma_node_type { 99aa0a1e58SJeff Roberson /* IB values map to NodeInfo:NodeType. */ 100aa0a1e58SJeff Roberson RDMA_NODE_IB_CA = 1, 101aa0a1e58SJeff Roberson RDMA_NODE_IB_SWITCH, 102aa0a1e58SJeff Roberson RDMA_NODE_IB_ROUTER, 103b5c1e0cbSHans Petter Selasky RDMA_NODE_RNIC, 104478d3005SHans Petter Selasky RDMA_NODE_USNIC, 105478d3005SHans Petter Selasky RDMA_NODE_USNIC_UDP, 106478d3005SHans Petter Selasky }; 107478d3005SHans Petter Selasky 108478d3005SHans Petter Selasky enum { 109478d3005SHans Petter Selasky /* set the local administered indication */ 110478d3005SHans Petter Selasky IB_SA_WELL_KNOWN_GUID = BIT_ULL(57) | 2, 111aa0a1e58SJeff Roberson }; 112aa0a1e58SJeff Roberson 113aa0a1e58SJeff Roberson enum rdma_transport_type { 114aa0a1e58SJeff Roberson RDMA_TRANSPORT_IB, 115b5c1e0cbSHans Petter Selasky RDMA_TRANSPORT_IWARP, 116478d3005SHans Petter Selasky RDMA_TRANSPORT_USNIC, 117478d3005SHans Petter Selasky RDMA_TRANSPORT_USNIC_UDP 118aa0a1e58SJeff Roberson }; 119aa0a1e58SJeff Roberson 120478d3005SHans Petter Selasky enum rdma_protocol_type { 121478d3005SHans Petter Selasky RDMA_PROTOCOL_IB, 122478d3005SHans Petter Selasky RDMA_PROTOCOL_IBOE, 123478d3005SHans Petter Selasky RDMA_PROTOCOL_IWARP, 124478d3005SHans Petter Selasky RDMA_PROTOCOL_USNIC_UDP 125478d3005SHans Petter Selasky }; 126478d3005SHans Petter Selasky 127478d3005SHans Petter Selasky __attribute_const__ enum rdma_transport_type 128478d3005SHans Petter Selasky rdma_node_get_transport(enum rdma_node_type node_type); 129478d3005SHans Petter Selasky 130478d3005SHans Petter Selasky enum rdma_network_type { 131478d3005SHans Petter Selasky RDMA_NETWORK_IB, 132478d3005SHans Petter Selasky RDMA_NETWORK_ROCE_V1 = RDMA_NETWORK_IB, 133478d3005SHans Petter Selasky RDMA_NETWORK_IPV4, 134478d3005SHans Petter Selasky RDMA_NETWORK_IPV6 135478d3005SHans Petter Selasky }; 136478d3005SHans Petter Selasky 137478d3005SHans Petter Selasky static inline enum ib_gid_type ib_network_to_gid_type(enum rdma_network_type network_type) 138478d3005SHans Petter Selasky { 139478d3005SHans Petter Selasky if (network_type == RDMA_NETWORK_IPV4 || 140478d3005SHans Petter Selasky network_type == RDMA_NETWORK_IPV6) 141478d3005SHans Petter Selasky return IB_GID_TYPE_ROCE_UDP_ENCAP; 142478d3005SHans Petter Selasky 143478d3005SHans Petter Selasky /* IB_GID_TYPE_IB same as RDMA_NETWORK_ROCE_V1 */ 144478d3005SHans Petter Selasky return IB_GID_TYPE_IB; 145478d3005SHans Petter Selasky } 146478d3005SHans Petter Selasky 147478d3005SHans Petter Selasky static inline enum rdma_network_type ib_gid_to_network_type(enum ib_gid_type gid_type, 148478d3005SHans Petter Selasky union ib_gid *gid) 149478d3005SHans Petter Selasky { 150478d3005SHans Petter Selasky if (gid_type == IB_GID_TYPE_IB) 151478d3005SHans Petter Selasky return RDMA_NETWORK_IB; 152478d3005SHans Petter Selasky 153478d3005SHans Petter Selasky if (ipv6_addr_v4mapped((struct in6_addr *)gid)) 154478d3005SHans Petter Selasky return RDMA_NETWORK_IPV4; 155478d3005SHans Petter Selasky else 156478d3005SHans Petter Selasky return RDMA_NETWORK_IPV6; 157478d3005SHans Petter Selasky } 158aa0a1e58SJeff Roberson 159aa0a1e58SJeff Roberson enum rdma_link_layer { 160aa0a1e58SJeff Roberson IB_LINK_LAYER_UNSPECIFIED, 161aa0a1e58SJeff Roberson IB_LINK_LAYER_INFINIBAND, 162aa0a1e58SJeff Roberson IB_LINK_LAYER_ETHERNET, 163aa0a1e58SJeff Roberson }; 164aa0a1e58SJeff Roberson 165aa0a1e58SJeff Roberson enum ib_device_cap_flags { 166478d3005SHans Petter Selasky IB_DEVICE_RESIZE_MAX_WR = (1 << 0), 167aa0a1e58SJeff Roberson IB_DEVICE_BAD_PKEY_CNTR = (1 << 1), 168aa0a1e58SJeff Roberson IB_DEVICE_BAD_QKEY_CNTR = (1 << 2), 169aa0a1e58SJeff Roberson IB_DEVICE_RAW_MULTI = (1 << 3), 170aa0a1e58SJeff Roberson IB_DEVICE_AUTO_PATH_MIG = (1 << 4), 171aa0a1e58SJeff Roberson IB_DEVICE_CHANGE_PHY_PORT = (1 << 5), 172aa0a1e58SJeff Roberson IB_DEVICE_UD_AV_PORT_ENFORCE = (1 << 6), 173aa0a1e58SJeff Roberson IB_DEVICE_CURR_QP_STATE_MOD = (1 << 7), 174aa0a1e58SJeff Roberson IB_DEVICE_SHUTDOWN_PORT = (1 << 8), 175aa0a1e58SJeff Roberson IB_DEVICE_INIT_TYPE = (1 << 9), 176aa0a1e58SJeff Roberson IB_DEVICE_PORT_ACTIVE_EVENT = (1 << 10), 177aa0a1e58SJeff Roberson IB_DEVICE_SYS_IMAGE_GUID = (1 << 11), 178aa0a1e58SJeff Roberson IB_DEVICE_RC_RNR_NAK_GEN = (1 << 12), 179aa0a1e58SJeff Roberson IB_DEVICE_SRQ_RESIZE = (1 << 13), 180aa0a1e58SJeff Roberson IB_DEVICE_N_NOTIFY_CQ = (1 << 14), 181478d3005SHans Petter Selasky 182478d3005SHans Petter Selasky /* 183478d3005SHans Petter Selasky * This device supports a per-device lkey or stag that can be 184478d3005SHans Petter Selasky * used without performing a memory registration for the local 185478d3005SHans Petter Selasky * memory. Note that ULPs should never check this flag, but 186478d3005SHans Petter Selasky * instead of use the local_dma_lkey flag in the ib_pd structure, 187478d3005SHans Petter Selasky * which will always contain a usable lkey. 188478d3005SHans Petter Selasky */ 189aa0a1e58SJeff Roberson IB_DEVICE_LOCAL_DMA_LKEY = (1 << 15), 190478d3005SHans Petter Selasky IB_DEVICE_RESERVED /* old SEND_W_INV */ = (1 << 16), 191aa0a1e58SJeff Roberson IB_DEVICE_MEM_WINDOW = (1 << 17), 192aa0a1e58SJeff Roberson /* 193aa0a1e58SJeff Roberson * Devices should set IB_DEVICE_UD_IP_SUM if they support 194aa0a1e58SJeff Roberson * insertion of UDP and TCP checksum on outgoing UD IPoIB 195aa0a1e58SJeff Roberson * messages and can verify the validity of checksum for 196aa0a1e58SJeff Roberson * incoming messages. Setting this flag implies that the 197aa0a1e58SJeff Roberson * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode. 198aa0a1e58SJeff Roberson */ 199aa0a1e58SJeff Roberson IB_DEVICE_UD_IP_CSUM = (1 << 18), 200aa0a1e58SJeff Roberson IB_DEVICE_UD_TSO = (1 << 19), 201aa0a1e58SJeff Roberson IB_DEVICE_XRC = (1 << 20), 202478d3005SHans Petter Selasky 203478d3005SHans Petter Selasky /* 204478d3005SHans Petter Selasky * This device supports the IB "base memory management extension", 205478d3005SHans Petter Selasky * which includes support for fast registrations (IB_WR_REG_MR, 206478d3005SHans Petter Selasky * IB_WR_LOCAL_INV and IB_WR_SEND_WITH_INV verbs). This flag should 207478d3005SHans Petter Selasky * also be set by any iWarp device which must support FRs to comply 208478d3005SHans Petter Selasky * to the iWarp verbs spec. iWarp devices also support the 209478d3005SHans Petter Selasky * IB_WR_RDMA_READ_WITH_INV verb for RDMA READs that invalidate the 210478d3005SHans Petter Selasky * stag. 211478d3005SHans Petter Selasky */ 212aa0a1e58SJeff Roberson IB_DEVICE_MEM_MGT_EXTENSIONS = (1 << 21), 213aa0a1e58SJeff Roberson IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1 << 22), 214478d3005SHans Petter Selasky IB_DEVICE_MEM_WINDOW_TYPE_2A = (1 << 23), 215478d3005SHans Petter Selasky IB_DEVICE_MEM_WINDOW_TYPE_2B = (1 << 24), 216478d3005SHans Petter Selasky IB_DEVICE_RC_IP_CSUM = (1 << 25), 217478d3005SHans Petter Selasky IB_DEVICE_RAW_IP_CSUM = (1 << 26), 218b5c1e0cbSHans Petter Selasky /* 219478d3005SHans Petter Selasky * Devices should set IB_DEVICE_CROSS_CHANNEL if they 220478d3005SHans Petter Selasky * support execution of WQEs that involve synchronization 221478d3005SHans Petter Selasky * of I/O operations with single completion queue managed 222478d3005SHans Petter Selasky * by hardware. 223b5c1e0cbSHans Petter Selasky */ 224478d3005SHans Petter Selasky IB_DEVICE_CROSS_CHANNEL = (1 << 27), 225478d3005SHans Petter Selasky IB_DEVICE_MANAGED_FLOW_STEERING = (1 << 29), 226478d3005SHans Petter Selasky IB_DEVICE_SIGNATURE_HANDOVER = (1 << 30), 227478d3005SHans Petter Selasky IB_DEVICE_ON_DEMAND_PAGING = (1ULL << 31), 228478d3005SHans Petter Selasky IB_DEVICE_SG_GAPS_REG = (1ULL << 32), 229478d3005SHans Petter Selasky IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33), 230478d3005SHans Petter Selasky IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34), 231b5c1e0cbSHans Petter Selasky }; 232b5c1e0cbSHans Petter Selasky 233b5c1e0cbSHans Petter Selasky enum ib_signature_prot_cap { 234b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_1 = 1, 235b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_2 = 1 << 1, 236b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_3 = 1 << 2, 237b5c1e0cbSHans Petter Selasky }; 238b5c1e0cbSHans Petter Selasky 239b5c1e0cbSHans Petter Selasky enum ib_signature_guard_cap { 240b5c1e0cbSHans Petter Selasky IB_GUARD_T10DIF_CRC = 1, 241b5c1e0cbSHans Petter Selasky IB_GUARD_T10DIF_CSUM = 1 << 1, 242aa0a1e58SJeff Roberson }; 243aa0a1e58SJeff Roberson 244aa0a1e58SJeff Roberson enum ib_atomic_cap { 245aa0a1e58SJeff Roberson IB_ATOMIC_NONE, 246aa0a1e58SJeff Roberson IB_ATOMIC_HCA, 247aa0a1e58SJeff Roberson IB_ATOMIC_GLOB 248aa0a1e58SJeff Roberson }; 249aa0a1e58SJeff Roberson 250478d3005SHans Petter Selasky enum ib_odp_general_cap_bits { 251478d3005SHans Petter Selasky IB_ODP_SUPPORT = 1 << 0, 252478d3005SHans Petter Selasky }; 253478d3005SHans Petter Selasky 254478d3005SHans Petter Selasky enum ib_odp_transport_cap_bits { 255478d3005SHans Petter Selasky IB_ODP_SUPPORT_SEND = 1 << 0, 256478d3005SHans Petter Selasky IB_ODP_SUPPORT_RECV = 1 << 1, 257478d3005SHans Petter Selasky IB_ODP_SUPPORT_WRITE = 1 << 2, 258478d3005SHans Petter Selasky IB_ODP_SUPPORT_READ = 1 << 3, 259478d3005SHans Petter Selasky IB_ODP_SUPPORT_ATOMIC = 1 << 4, 260478d3005SHans Petter Selasky }; 261478d3005SHans Petter Selasky 262478d3005SHans Petter Selasky struct ib_odp_caps { 263478d3005SHans Petter Selasky uint64_t general_caps; 264478d3005SHans Petter Selasky struct { 265478d3005SHans Petter Selasky uint32_t rc_odp_caps; 266478d3005SHans Petter Selasky uint32_t uc_odp_caps; 267478d3005SHans Petter Selasky uint32_t ud_odp_caps; 268478d3005SHans Petter Selasky } per_transport_caps; 269478d3005SHans Petter Selasky }; 270478d3005SHans Petter Selasky 271478d3005SHans Petter Selasky struct ib_rss_caps { 272478d3005SHans Petter Selasky /* Corresponding bit will be set if qp type from 273478d3005SHans Petter Selasky * 'enum ib_qp_type' is supported, e.g. 274478d3005SHans Petter Selasky * supported_qpts |= 1 << IB_QPT_UD 275478d3005SHans Petter Selasky */ 276478d3005SHans Petter Selasky u32 supported_qpts; 277478d3005SHans Petter Selasky u32 max_rwq_indirection_tables; 278478d3005SHans Petter Selasky u32 max_rwq_indirection_table_size; 279478d3005SHans Petter Selasky }; 280478d3005SHans Petter Selasky 281478d3005SHans Petter Selasky enum ib_cq_creation_flags { 282478d3005SHans Petter Selasky IB_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0, 283478d3005SHans Petter Selasky IB_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1, 284478d3005SHans Petter Selasky }; 285478d3005SHans Petter Selasky 286478d3005SHans Petter Selasky struct ib_cq_init_attr { 287478d3005SHans Petter Selasky unsigned int cqe; 288478d3005SHans Petter Selasky int comp_vector; 289478d3005SHans Petter Selasky u32 flags; 290b5c1e0cbSHans Petter Selasky }; 291b5c1e0cbSHans Petter Selasky 292aa0a1e58SJeff Roberson struct ib_device_attr { 293aa0a1e58SJeff Roberson u64 fw_ver; 294aa0a1e58SJeff Roberson __be64 sys_image_guid; 295aa0a1e58SJeff Roberson u64 max_mr_size; 296aa0a1e58SJeff Roberson u64 page_size_cap; 297aa0a1e58SJeff Roberson u32 vendor_id; 298aa0a1e58SJeff Roberson u32 vendor_part_id; 299aa0a1e58SJeff Roberson u32 hw_ver; 300aa0a1e58SJeff Roberson int max_qp; 301aa0a1e58SJeff Roberson int max_qp_wr; 302b5c1e0cbSHans Petter Selasky u64 device_cap_flags; 303aa0a1e58SJeff Roberson int max_sge; 304aa0a1e58SJeff Roberson int max_sge_rd; 305aa0a1e58SJeff Roberson int max_cq; 306aa0a1e58SJeff Roberson int max_cqe; 307aa0a1e58SJeff Roberson int max_mr; 308aa0a1e58SJeff Roberson int max_pd; 309aa0a1e58SJeff Roberson int max_qp_rd_atom; 310aa0a1e58SJeff Roberson int max_ee_rd_atom; 311aa0a1e58SJeff Roberson int max_res_rd_atom; 312aa0a1e58SJeff Roberson int max_qp_init_rd_atom; 313aa0a1e58SJeff Roberson int max_ee_init_rd_atom; 314aa0a1e58SJeff Roberson enum ib_atomic_cap atomic_cap; 315aa0a1e58SJeff Roberson enum ib_atomic_cap masked_atomic_cap; 316aa0a1e58SJeff Roberson int max_ee; 317aa0a1e58SJeff Roberson int max_rdd; 318aa0a1e58SJeff Roberson int max_mw; 319aa0a1e58SJeff Roberson int max_raw_ipv6_qp; 320aa0a1e58SJeff Roberson int max_raw_ethy_qp; 321aa0a1e58SJeff Roberson int max_mcast_grp; 322aa0a1e58SJeff Roberson int max_mcast_qp_attach; 323aa0a1e58SJeff Roberson int max_total_mcast_qp_attach; 324aa0a1e58SJeff Roberson int max_ah; 325aa0a1e58SJeff Roberson int max_fmr; 326aa0a1e58SJeff Roberson int max_map_per_fmr; 327aa0a1e58SJeff Roberson int max_srq; 328aa0a1e58SJeff Roberson int max_srq_wr; 329aa0a1e58SJeff Roberson int max_srq_sge; 330aa0a1e58SJeff Roberson unsigned int max_fast_reg_page_list_len; 331aa0a1e58SJeff Roberson u16 max_pkeys; 332aa0a1e58SJeff Roberson u8 local_ca_ack_delay; 333478d3005SHans Petter Selasky int sig_prot_cap; 334478d3005SHans Petter Selasky int sig_guard_cap; 335478d3005SHans Petter Selasky struct ib_odp_caps odp_caps; 336b5c1e0cbSHans Petter Selasky uint64_t timestamp_mask; 337478d3005SHans Petter Selasky uint64_t hca_core_clock; /* in KHZ */ 338478d3005SHans Petter Selasky struct ib_rss_caps rss_caps; 339478d3005SHans Petter Selasky u32 max_wq_type_rq; 340aa0a1e58SJeff Roberson }; 341aa0a1e58SJeff Roberson 342aa0a1e58SJeff Roberson enum ib_mtu { 343aa0a1e58SJeff Roberson IB_MTU_256 = 1, 344aa0a1e58SJeff Roberson IB_MTU_512 = 2, 345aa0a1e58SJeff Roberson IB_MTU_1024 = 3, 346aa0a1e58SJeff Roberson IB_MTU_2048 = 4, 347aa0a1e58SJeff Roberson IB_MTU_4096 = 5 348aa0a1e58SJeff Roberson }; 349aa0a1e58SJeff Roberson 350aa0a1e58SJeff Roberson static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) 351aa0a1e58SJeff Roberson { 352aa0a1e58SJeff Roberson switch (mtu) { 353aa0a1e58SJeff Roberson case IB_MTU_256: return 256; 354aa0a1e58SJeff Roberson case IB_MTU_512: return 512; 355aa0a1e58SJeff Roberson case IB_MTU_1024: return 1024; 356aa0a1e58SJeff Roberson case IB_MTU_2048: return 2048; 357aa0a1e58SJeff Roberson case IB_MTU_4096: return 4096; 358aa0a1e58SJeff Roberson default: return -1; 359aa0a1e58SJeff Roberson } 360aa0a1e58SJeff Roberson } 361aa0a1e58SJeff Roberson 362aa0a1e58SJeff Roberson enum ib_port_state { 363aa0a1e58SJeff Roberson IB_PORT_NOP = 0, 364aa0a1e58SJeff Roberson IB_PORT_DOWN = 1, 365aa0a1e58SJeff Roberson IB_PORT_INIT = 2, 366aa0a1e58SJeff Roberson IB_PORT_ARMED = 3, 367aa0a1e58SJeff Roberson IB_PORT_ACTIVE = 4, 368b5c1e0cbSHans Petter Selasky IB_PORT_ACTIVE_DEFER = 5, 369478d3005SHans Petter Selasky IB_PORT_DUMMY = -1, /* force enum signed */ 370aa0a1e58SJeff Roberson }; 371aa0a1e58SJeff Roberson 372aa0a1e58SJeff Roberson enum ib_port_cap_flags { 373aa0a1e58SJeff Roberson IB_PORT_SM = 1 << 1, 374aa0a1e58SJeff Roberson IB_PORT_NOTICE_SUP = 1 << 2, 375aa0a1e58SJeff Roberson IB_PORT_TRAP_SUP = 1 << 3, 376aa0a1e58SJeff Roberson IB_PORT_OPT_IPD_SUP = 1 << 4, 377aa0a1e58SJeff Roberson IB_PORT_AUTO_MIGR_SUP = 1 << 5, 378aa0a1e58SJeff Roberson IB_PORT_SL_MAP_SUP = 1 << 6, 379aa0a1e58SJeff Roberson IB_PORT_MKEY_NVRAM = 1 << 7, 380aa0a1e58SJeff Roberson IB_PORT_PKEY_NVRAM = 1 << 8, 381aa0a1e58SJeff Roberson IB_PORT_LED_INFO_SUP = 1 << 9, 382aa0a1e58SJeff Roberson IB_PORT_SM_DISABLED = 1 << 10, 383aa0a1e58SJeff Roberson IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, 384aa0a1e58SJeff Roberson IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, 385c9f432b7SAlfred Perlstein IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, 386aa0a1e58SJeff Roberson IB_PORT_CM_SUP = 1 << 16, 387aa0a1e58SJeff Roberson IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, 388aa0a1e58SJeff Roberson IB_PORT_REINIT_SUP = 1 << 18, 389aa0a1e58SJeff Roberson IB_PORT_DEVICE_MGMT_SUP = 1 << 19, 390aa0a1e58SJeff Roberson IB_PORT_VENDOR_CLASS_SUP = 1 << 20, 391aa0a1e58SJeff Roberson IB_PORT_DR_NOTICE_SUP = 1 << 21, 392aa0a1e58SJeff Roberson IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, 393aa0a1e58SJeff Roberson IB_PORT_BOOT_MGMT_SUP = 1 << 23, 394aa0a1e58SJeff Roberson IB_PORT_LINK_LATENCY_SUP = 1 << 24, 395478d3005SHans Petter Selasky IB_PORT_CLIENT_REG_SUP = 1 << 25, 396478d3005SHans Petter Selasky IB_PORT_IP_BASED_GIDS = 1 << 26, 397aa0a1e58SJeff Roberson }; 398aa0a1e58SJeff Roberson 399aa0a1e58SJeff Roberson enum ib_port_width { 400aa0a1e58SJeff Roberson IB_WIDTH_1X = 1, 401aa0a1e58SJeff Roberson IB_WIDTH_4X = 2, 402aa0a1e58SJeff Roberson IB_WIDTH_8X = 4, 403aa0a1e58SJeff Roberson IB_WIDTH_12X = 8 404aa0a1e58SJeff Roberson }; 405aa0a1e58SJeff Roberson 406aa0a1e58SJeff Roberson static inline int ib_width_enum_to_int(enum ib_port_width width) 407aa0a1e58SJeff Roberson { 408aa0a1e58SJeff Roberson switch (width) { 409aa0a1e58SJeff Roberson case IB_WIDTH_1X: return 1; 410aa0a1e58SJeff Roberson case IB_WIDTH_4X: return 4; 411aa0a1e58SJeff Roberson case IB_WIDTH_8X: return 8; 412aa0a1e58SJeff Roberson case IB_WIDTH_12X: return 12; 413aa0a1e58SJeff Roberson default: return -1; 414aa0a1e58SJeff Roberson } 415aa0a1e58SJeff Roberson } 416aa0a1e58SJeff Roberson 417c9f432b7SAlfred Perlstein enum ib_port_speed { 418c9f432b7SAlfred Perlstein IB_SPEED_SDR = 1, 419c9f432b7SAlfred Perlstein IB_SPEED_DDR = 2, 420c9f432b7SAlfred Perlstein IB_SPEED_QDR = 4, 421c9f432b7SAlfred Perlstein IB_SPEED_FDR10 = 8, 422c9f432b7SAlfred Perlstein IB_SPEED_FDR = 16, 423*d0a82c24SHans Petter Selasky IB_SPEED_EDR = 32, 424*d0a82c24SHans Petter Selasky IB_SPEED_HDR = 64 425c9f432b7SAlfred Perlstein }; 426c9f432b7SAlfred Perlstein 427478d3005SHans Petter Selasky /** 428478d3005SHans Petter Selasky * struct rdma_hw_stats 429478d3005SHans Petter Selasky * @timestamp - Used by the core code to track when the last update was 430478d3005SHans Petter Selasky * @lifespan - Used by the core code to determine how old the counters 431478d3005SHans Petter Selasky * should be before being updated again. Stored in jiffies, defaults 432478d3005SHans Petter Selasky * to 10 milliseconds, drivers can override the default be specifying 433478d3005SHans Petter Selasky * their own value during their allocation routine. 434478d3005SHans Petter Selasky * @name - Array of pointers to static names used for the counters in 435478d3005SHans Petter Selasky * directory. 436478d3005SHans Petter Selasky * @num_counters - How many hardware counters there are. If name is 437478d3005SHans Petter Selasky * shorter than this number, a kernel oops will result. Driver authors 438478d3005SHans Petter Selasky * are encouraged to leave BUILD_BUG_ON(ARRAY_SIZE(@name) < num_counters) 439478d3005SHans Petter Selasky * in their code to prevent this. 440478d3005SHans Petter Selasky * @value - Array of u64 counters that are accessed by the sysfs code and 441478d3005SHans Petter Selasky * filled in by the drivers get_stats routine 442478d3005SHans Petter Selasky */ 443478d3005SHans Petter Selasky struct rdma_hw_stats { 444478d3005SHans Petter Selasky unsigned long timestamp; 445478d3005SHans Petter Selasky unsigned long lifespan; 446478d3005SHans Petter Selasky const char * const *names; 447478d3005SHans Petter Selasky int num_counters; 448478d3005SHans Petter Selasky u64 value[]; 449aa0a1e58SJeff Roberson }; 450aa0a1e58SJeff Roberson 451478d3005SHans Petter Selasky #define RDMA_HW_STATS_DEFAULT_LIFESPAN 10 452478d3005SHans Petter Selasky /** 453478d3005SHans Petter Selasky * rdma_alloc_hw_stats_struct - Helper function to allocate dynamic struct 454478d3005SHans Petter Selasky * for drivers. 455478d3005SHans Petter Selasky * @names - Array of static const char * 456478d3005SHans Petter Selasky * @num_counters - How many elements in array 457478d3005SHans Petter Selasky * @lifespan - How many milliseconds between updates 458478d3005SHans Petter Selasky */ 459478d3005SHans Petter Selasky static inline struct rdma_hw_stats *rdma_alloc_hw_stats_struct( 460478d3005SHans Petter Selasky const char * const *names, int num_counters, 461478d3005SHans Petter Selasky unsigned long lifespan) 462478d3005SHans Petter Selasky { 463478d3005SHans Petter Selasky struct rdma_hw_stats *stats; 464aa0a1e58SJeff Roberson 465478d3005SHans Petter Selasky stats = kzalloc(sizeof(*stats) + num_counters * sizeof(u64), 466478d3005SHans Petter Selasky GFP_KERNEL); 467478d3005SHans Petter Selasky if (!stats) 468478d3005SHans Petter Selasky return NULL; 469478d3005SHans Petter Selasky stats->names = names; 470478d3005SHans Petter Selasky stats->num_counters = num_counters; 471478d3005SHans Petter Selasky stats->lifespan = msecs_to_jiffies(lifespan); 472aa0a1e58SJeff Roberson 473478d3005SHans Petter Selasky return stats; 474478d3005SHans Petter Selasky } 475478d3005SHans Petter Selasky 476478d3005SHans Petter Selasky 477478d3005SHans Petter Selasky /* Define bits for the various functionality this port needs to be supported by 478478d3005SHans Petter Selasky * the core. 479478d3005SHans Petter Selasky */ 480478d3005SHans Petter Selasky /* Management 0x00000FFF */ 481478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_MAD 0x00000001 482478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_SMI 0x00000002 483478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_CM 0x00000004 484478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IW_CM 0x00000008 485478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_SA 0x00000010 486478d3005SHans Petter Selasky #define RDMA_CORE_CAP_OPA_MAD 0x00000020 487478d3005SHans Petter Selasky 488478d3005SHans Petter Selasky /* Address format 0x000FF000 */ 489478d3005SHans Petter Selasky #define RDMA_CORE_CAP_AF_IB 0x00001000 490478d3005SHans Petter Selasky #define RDMA_CORE_CAP_ETH_AH 0x00002000 491478d3005SHans Petter Selasky 492478d3005SHans Petter Selasky /* Protocol 0xFFF00000 */ 493478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_IB 0x00100000 494478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_ROCE 0x00200000 495478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_IWARP 0x00400000 496478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP 0x00800000 497478d3005SHans Petter Selasky 498478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_IB (RDMA_CORE_CAP_PROT_IB \ 499478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 500478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_SMI \ 501478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 502478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_SA \ 503478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB) 504478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_ROCE (RDMA_CORE_CAP_PROT_ROCE \ 505478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 506478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 507478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB \ 508478d3005SHans Petter Selasky | RDMA_CORE_CAP_ETH_AH) 509478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP \ 510478d3005SHans Petter Selasky (RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP \ 511478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 512478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 513478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB \ 514478d3005SHans Petter Selasky | RDMA_CORE_CAP_ETH_AH) 515478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IWARP (RDMA_CORE_CAP_PROT_IWARP \ 516478d3005SHans Petter Selasky | RDMA_CORE_CAP_IW_CM) 517478d3005SHans Petter Selasky #define RDMA_CORE_PORT_INTEL_OPA (RDMA_CORE_PORT_IBA_IB \ 518478d3005SHans Petter Selasky | RDMA_CORE_CAP_OPA_MAD) 519aa0a1e58SJeff Roberson 520aa0a1e58SJeff Roberson struct ib_port_attr { 521478d3005SHans Petter Selasky u64 subnet_prefix; 522aa0a1e58SJeff Roberson enum ib_port_state state; 523aa0a1e58SJeff Roberson enum ib_mtu max_mtu; 524aa0a1e58SJeff Roberson enum ib_mtu active_mtu; 525aa0a1e58SJeff Roberson int gid_tbl_len; 526aa0a1e58SJeff Roberson u32 port_cap_flags; 527aa0a1e58SJeff Roberson u32 max_msg_sz; 528aa0a1e58SJeff Roberson u32 bad_pkey_cntr; 529aa0a1e58SJeff Roberson u32 qkey_viol_cntr; 530aa0a1e58SJeff Roberson u16 pkey_tbl_len; 531aa0a1e58SJeff Roberson u16 lid; 532aa0a1e58SJeff Roberson u16 sm_lid; 533aa0a1e58SJeff Roberson u8 lmc; 534aa0a1e58SJeff Roberson u8 max_vl_num; 535aa0a1e58SJeff Roberson u8 sm_sl; 536aa0a1e58SJeff Roberson u8 subnet_timeout; 537aa0a1e58SJeff Roberson u8 init_type_reply; 538aa0a1e58SJeff Roberson u8 active_width; 539aa0a1e58SJeff Roberson u8 active_speed; 540aa0a1e58SJeff Roberson u8 phys_state; 541478d3005SHans Petter Selasky bool grh_required; 542aa0a1e58SJeff Roberson }; 543aa0a1e58SJeff Roberson 544aa0a1e58SJeff Roberson enum ib_device_modify_flags { 545aa0a1e58SJeff Roberson IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0, 546aa0a1e58SJeff Roberson IB_DEVICE_MODIFY_NODE_DESC = 1 << 1 547aa0a1e58SJeff Roberson }; 548aa0a1e58SJeff Roberson 549478d3005SHans Petter Selasky #define IB_DEVICE_NODE_DESC_MAX 64 550478d3005SHans Petter Selasky 551aa0a1e58SJeff Roberson struct ib_device_modify { 552aa0a1e58SJeff Roberson u64 sys_image_guid; 553478d3005SHans Petter Selasky char node_desc[IB_DEVICE_NODE_DESC_MAX]; 554aa0a1e58SJeff Roberson }; 555aa0a1e58SJeff Roberson 556aa0a1e58SJeff Roberson enum ib_port_modify_flags { 557aa0a1e58SJeff Roberson IB_PORT_SHUTDOWN = 1, 558aa0a1e58SJeff Roberson IB_PORT_INIT_TYPE = (1<<2), 559aa0a1e58SJeff Roberson IB_PORT_RESET_QKEY_CNTR = (1<<3) 560aa0a1e58SJeff Roberson }; 561aa0a1e58SJeff Roberson 562aa0a1e58SJeff Roberson struct ib_port_modify { 563aa0a1e58SJeff Roberson u32 set_port_cap_mask; 564aa0a1e58SJeff Roberson u32 clr_port_cap_mask; 565aa0a1e58SJeff Roberson u8 init_type; 566aa0a1e58SJeff Roberson }; 567aa0a1e58SJeff Roberson 568aa0a1e58SJeff Roberson enum ib_event_type { 569aa0a1e58SJeff Roberson IB_EVENT_CQ_ERR, 570aa0a1e58SJeff Roberson IB_EVENT_QP_FATAL, 571aa0a1e58SJeff Roberson IB_EVENT_QP_REQ_ERR, 572aa0a1e58SJeff Roberson IB_EVENT_QP_ACCESS_ERR, 573aa0a1e58SJeff Roberson IB_EVENT_COMM_EST, 574aa0a1e58SJeff Roberson IB_EVENT_SQ_DRAINED, 575aa0a1e58SJeff Roberson IB_EVENT_PATH_MIG, 576aa0a1e58SJeff Roberson IB_EVENT_PATH_MIG_ERR, 577aa0a1e58SJeff Roberson IB_EVENT_DEVICE_FATAL, 578aa0a1e58SJeff Roberson IB_EVENT_PORT_ACTIVE, 579aa0a1e58SJeff Roberson IB_EVENT_PORT_ERR, 580aa0a1e58SJeff Roberson IB_EVENT_LID_CHANGE, 581aa0a1e58SJeff Roberson IB_EVENT_PKEY_CHANGE, 582aa0a1e58SJeff Roberson IB_EVENT_SM_CHANGE, 583aa0a1e58SJeff Roberson IB_EVENT_SRQ_ERR, 584aa0a1e58SJeff Roberson IB_EVENT_SRQ_LIMIT_REACHED, 585aa0a1e58SJeff Roberson IB_EVENT_QP_LAST_WQE_REACHED, 586aa0a1e58SJeff Roberson IB_EVENT_CLIENT_REREGISTER, 587aa0a1e58SJeff Roberson IB_EVENT_GID_CHANGE, 588478d3005SHans Petter Selasky IB_EVENT_WQ_FATAL, 589aa0a1e58SJeff Roberson }; 590aa0a1e58SJeff Roberson 591478d3005SHans Petter Selasky const char *__attribute_const__ ib_event_msg(enum ib_event_type event); 592478d3005SHans Petter Selasky 593aa0a1e58SJeff Roberson struct ib_event { 594aa0a1e58SJeff Roberson struct ib_device *device; 595aa0a1e58SJeff Roberson union { 596aa0a1e58SJeff Roberson struct ib_cq *cq; 597aa0a1e58SJeff Roberson struct ib_qp *qp; 598aa0a1e58SJeff Roberson struct ib_srq *srq; 599478d3005SHans Petter Selasky struct ib_wq *wq; 600aa0a1e58SJeff Roberson u8 port_num; 601aa0a1e58SJeff Roberson } element; 602aa0a1e58SJeff Roberson enum ib_event_type event; 603aa0a1e58SJeff Roberson }; 604aa0a1e58SJeff Roberson 605aa0a1e58SJeff Roberson struct ib_event_handler { 606aa0a1e58SJeff Roberson struct ib_device *device; 607aa0a1e58SJeff Roberson void (*handler)(struct ib_event_handler *, struct ib_event *); 608aa0a1e58SJeff Roberson struct list_head list; 609aa0a1e58SJeff Roberson }; 610aa0a1e58SJeff Roberson 611aa0a1e58SJeff Roberson #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \ 612aa0a1e58SJeff Roberson do { \ 613aa0a1e58SJeff Roberson (_ptr)->device = _device; \ 614aa0a1e58SJeff Roberson (_ptr)->handler = _handler; \ 615aa0a1e58SJeff Roberson INIT_LIST_HEAD(&(_ptr)->list); \ 616aa0a1e58SJeff Roberson } while (0) 617aa0a1e58SJeff Roberson 618aa0a1e58SJeff Roberson struct ib_global_route { 619aa0a1e58SJeff Roberson union ib_gid dgid; 620aa0a1e58SJeff Roberson u32 flow_label; 621aa0a1e58SJeff Roberson u8 sgid_index; 622aa0a1e58SJeff Roberson u8 hop_limit; 623aa0a1e58SJeff Roberson u8 traffic_class; 624aa0a1e58SJeff Roberson }; 625aa0a1e58SJeff Roberson 626aa0a1e58SJeff Roberson struct ib_grh { 627aa0a1e58SJeff Roberson __be32 version_tclass_flow; 628aa0a1e58SJeff Roberson __be16 paylen; 629aa0a1e58SJeff Roberson u8 next_hdr; 630aa0a1e58SJeff Roberson u8 hop_limit; 631aa0a1e58SJeff Roberson union ib_gid sgid; 632aa0a1e58SJeff Roberson union ib_gid dgid; 633aa0a1e58SJeff Roberson }; 634aa0a1e58SJeff Roberson 635478d3005SHans Petter Selasky union rdma_network_hdr { 636478d3005SHans Petter Selasky struct ib_grh ibgrh; 637478d3005SHans Petter Selasky struct { 638478d3005SHans Petter Selasky /* The IB spec states that if it's IPv4, the header 639478d3005SHans Petter Selasky * is located in the last 20 bytes of the header. 640478d3005SHans Petter Selasky */ 641478d3005SHans Petter Selasky u8 reserved[20]; 642478d3005SHans Petter Selasky struct ip roce4grh; 643478d3005SHans Petter Selasky }; 644478d3005SHans Petter Selasky }; 645478d3005SHans Petter Selasky 646aa0a1e58SJeff Roberson enum { 647aa0a1e58SJeff Roberson IB_MULTICAST_QPN = 0xffffff 648aa0a1e58SJeff Roberson }; 649aa0a1e58SJeff Roberson 650aa0a1e58SJeff Roberson #define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF) 651478d3005SHans Petter Selasky #define IB_MULTICAST_LID_BASE cpu_to_be16(0xC000) 652aa0a1e58SJeff Roberson 653aa0a1e58SJeff Roberson enum ib_ah_flags { 654aa0a1e58SJeff Roberson IB_AH_GRH = 1 655aa0a1e58SJeff Roberson }; 656aa0a1e58SJeff Roberson 657aa0a1e58SJeff Roberson enum ib_rate { 658aa0a1e58SJeff Roberson IB_RATE_PORT_CURRENT = 0, 659aa0a1e58SJeff Roberson IB_RATE_2_5_GBPS = 2, 660aa0a1e58SJeff Roberson IB_RATE_5_GBPS = 5, 661aa0a1e58SJeff Roberson IB_RATE_10_GBPS = 3, 662aa0a1e58SJeff Roberson IB_RATE_20_GBPS = 6, 663aa0a1e58SJeff Roberson IB_RATE_30_GBPS = 4, 664aa0a1e58SJeff Roberson IB_RATE_40_GBPS = 7, 665aa0a1e58SJeff Roberson IB_RATE_60_GBPS = 8, 666aa0a1e58SJeff Roberson IB_RATE_80_GBPS = 9, 667c9f432b7SAlfred Perlstein IB_RATE_120_GBPS = 10, 668c9f432b7SAlfred Perlstein IB_RATE_14_GBPS = 11, 669c9f432b7SAlfred Perlstein IB_RATE_56_GBPS = 12, 670c9f432b7SAlfred Perlstein IB_RATE_112_GBPS = 13, 671c9f432b7SAlfred Perlstein IB_RATE_168_GBPS = 14, 672c9f432b7SAlfred Perlstein IB_RATE_25_GBPS = 15, 673c9f432b7SAlfred Perlstein IB_RATE_100_GBPS = 16, 674c9f432b7SAlfred Perlstein IB_RATE_200_GBPS = 17, 675c9f432b7SAlfred Perlstein IB_RATE_300_GBPS = 18 676aa0a1e58SJeff Roberson }; 677aa0a1e58SJeff Roberson 678aa0a1e58SJeff Roberson /** 679aa0a1e58SJeff Roberson * ib_rate_to_mult - Convert the IB rate enum to a multiple of the 680aa0a1e58SJeff Roberson * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be 681aa0a1e58SJeff Roberson * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. 682aa0a1e58SJeff Roberson * @rate: rate to convert. 683aa0a1e58SJeff Roberson */ 684478d3005SHans Petter Selasky __attribute_const__ int ib_rate_to_mult(enum ib_rate rate); 685aa0a1e58SJeff Roberson 686aa0a1e58SJeff Roberson /** 687c9f432b7SAlfred Perlstein * ib_rate_to_mbps - Convert the IB rate enum to Mbps. 688c9f432b7SAlfred Perlstein * For example, IB_RATE_2_5_GBPS will be converted to 2500. 689c9f432b7SAlfred Perlstein * @rate: rate to convert. 690c9f432b7SAlfred Perlstein */ 691478d3005SHans Petter Selasky __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate); 692c9f432b7SAlfred Perlstein 693b5c1e0cbSHans Petter Selasky 694478d3005SHans Petter Selasky /** 695478d3005SHans Petter Selasky * enum ib_mr_type - memory region type 696478d3005SHans Petter Selasky * @IB_MR_TYPE_MEM_REG: memory region that is used for 697478d3005SHans Petter Selasky * normal registration 698478d3005SHans Petter Selasky * @IB_MR_TYPE_SIGNATURE: memory region that is used for 699478d3005SHans Petter Selasky * signature operations (data-integrity 700478d3005SHans Petter Selasky * capable regions) 701478d3005SHans Petter Selasky * @IB_MR_TYPE_SG_GAPS: memory region that is capable to 702478d3005SHans Petter Selasky * register any arbitrary sg lists (without 703478d3005SHans Petter Selasky * the normal mr constraints - see 704478d3005SHans Petter Selasky * ib_map_mr_sg) 705478d3005SHans Petter Selasky */ 706478d3005SHans Petter Selasky enum ib_mr_type { 707478d3005SHans Petter Selasky IB_MR_TYPE_MEM_REG, 708478d3005SHans Petter Selasky IB_MR_TYPE_SIGNATURE, 709478d3005SHans Petter Selasky IB_MR_TYPE_SG_GAPS, 710b5c1e0cbSHans Petter Selasky }; 711b5c1e0cbSHans Petter Selasky 712b5c1e0cbSHans Petter Selasky /** 713478d3005SHans Petter Selasky * Signature types 714478d3005SHans Petter Selasky * IB_SIG_TYPE_NONE: Unprotected. 715478d3005SHans Petter Selasky * IB_SIG_TYPE_T10_DIF: Type T10-DIF 716b5c1e0cbSHans Petter Selasky */ 717478d3005SHans Petter Selasky enum ib_signature_type { 718478d3005SHans Petter Selasky IB_SIG_TYPE_NONE, 719478d3005SHans Petter Selasky IB_SIG_TYPE_T10_DIF, 720b5c1e0cbSHans Petter Selasky }; 721b5c1e0cbSHans Petter Selasky 722b5c1e0cbSHans Petter Selasky /** 723b5c1e0cbSHans Petter Selasky * Signature T10-DIF block-guard types 724b5c1e0cbSHans Petter Selasky * IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. 725b5c1e0cbSHans Petter Selasky * IB_T10DIF_CSUM: Corresponds to IP checksum rules. 726b5c1e0cbSHans Petter Selasky */ 727b5c1e0cbSHans Petter Selasky enum ib_t10_dif_bg_type { 728b5c1e0cbSHans Petter Selasky IB_T10DIF_CRC, 729b5c1e0cbSHans Petter Selasky IB_T10DIF_CSUM 730b5c1e0cbSHans Petter Selasky }; 731b5c1e0cbSHans Petter Selasky 732b5c1e0cbSHans Petter Selasky /** 733b5c1e0cbSHans Petter Selasky * struct ib_t10_dif_domain - Parameters specific for T10-DIF 734b5c1e0cbSHans Petter Selasky * domain. 735b5c1e0cbSHans Petter Selasky * @bg_type: T10-DIF block guard type (CRC|CSUM) 736b5c1e0cbSHans Petter Selasky * @pi_interval: protection information interval. 737b5c1e0cbSHans Petter Selasky * @bg: seed of guard computation. 738b5c1e0cbSHans Petter Selasky * @app_tag: application tag of guard block 739b5c1e0cbSHans Petter Selasky * @ref_tag: initial guard block reference tag. 740478d3005SHans Petter Selasky * @ref_remap: Indicate wethear the reftag increments each block 741478d3005SHans Petter Selasky * @app_escape: Indicate to skip block check if apptag=0xffff 742478d3005SHans Petter Selasky * @ref_escape: Indicate to skip block check if reftag=0xffffffff 743478d3005SHans Petter Selasky * @apptag_check_mask: check bitmask of application tag. 744b5c1e0cbSHans Petter Selasky */ 745b5c1e0cbSHans Petter Selasky struct ib_t10_dif_domain { 746b5c1e0cbSHans Petter Selasky enum ib_t10_dif_bg_type bg_type; 747478d3005SHans Petter Selasky u16 pi_interval; 748b5c1e0cbSHans Petter Selasky u16 bg; 749b5c1e0cbSHans Petter Selasky u16 app_tag; 750b5c1e0cbSHans Petter Selasky u32 ref_tag; 751478d3005SHans Petter Selasky bool ref_remap; 752478d3005SHans Petter Selasky bool app_escape; 753478d3005SHans Petter Selasky bool ref_escape; 754478d3005SHans Petter Selasky u16 apptag_check_mask; 755b5c1e0cbSHans Petter Selasky }; 756b5c1e0cbSHans Petter Selasky 757b5c1e0cbSHans Petter Selasky /** 758b5c1e0cbSHans Petter Selasky * struct ib_sig_domain - Parameters for signature domain 759b5c1e0cbSHans Petter Selasky * @sig_type: specific signauture type 760b5c1e0cbSHans Petter Selasky * @sig: union of all signature domain attributes that may 761b5c1e0cbSHans Petter Selasky * be used to set domain layout. 762b5c1e0cbSHans Petter Selasky */ 763b5c1e0cbSHans Petter Selasky struct ib_sig_domain { 764b5c1e0cbSHans Petter Selasky enum ib_signature_type sig_type; 765b5c1e0cbSHans Petter Selasky union { 766b5c1e0cbSHans Petter Selasky struct ib_t10_dif_domain dif; 767b5c1e0cbSHans Petter Selasky } sig; 768b5c1e0cbSHans Petter Selasky }; 769b5c1e0cbSHans Petter Selasky 770b5c1e0cbSHans Petter Selasky /** 771b5c1e0cbSHans Petter Selasky * struct ib_sig_attrs - Parameters for signature handover operation 772b5c1e0cbSHans Petter Selasky * @check_mask: bitmask for signature byte check (8 bytes) 773b5c1e0cbSHans Petter Selasky * @mem: memory domain layout desciptor. 774b5c1e0cbSHans Petter Selasky * @wire: wire domain layout desciptor. 775b5c1e0cbSHans Petter Selasky */ 776b5c1e0cbSHans Petter Selasky struct ib_sig_attrs { 777b5c1e0cbSHans Petter Selasky u8 check_mask; 778b5c1e0cbSHans Petter Selasky struct ib_sig_domain mem; 779b5c1e0cbSHans Petter Selasky struct ib_sig_domain wire; 780b5c1e0cbSHans Petter Selasky }; 781b5c1e0cbSHans Petter Selasky 782b5c1e0cbSHans Petter Selasky enum ib_sig_err_type { 783b5c1e0cbSHans Petter Selasky IB_SIG_BAD_GUARD, 784b5c1e0cbSHans Petter Selasky IB_SIG_BAD_REFTAG, 785b5c1e0cbSHans Petter Selasky IB_SIG_BAD_APPTAG, 786b5c1e0cbSHans Petter Selasky }; 787b5c1e0cbSHans Petter Selasky 788b5c1e0cbSHans Petter Selasky /** 789b5c1e0cbSHans Petter Selasky * struct ib_sig_err - signature error descriptor 790b5c1e0cbSHans Petter Selasky */ 791b5c1e0cbSHans Petter Selasky struct ib_sig_err { 792b5c1e0cbSHans Petter Selasky enum ib_sig_err_type err_type; 793b5c1e0cbSHans Petter Selasky u32 expected; 794b5c1e0cbSHans Petter Selasky u32 actual; 795b5c1e0cbSHans Petter Selasky u64 sig_err_offset; 796b5c1e0cbSHans Petter Selasky u32 key; 797b5c1e0cbSHans Petter Selasky }; 798b5c1e0cbSHans Petter Selasky 799b5c1e0cbSHans Petter Selasky enum ib_mr_status_check { 800b5c1e0cbSHans Petter Selasky IB_MR_CHECK_SIG_STATUS = 1, 801b5c1e0cbSHans Petter Selasky }; 802b5c1e0cbSHans Petter Selasky 803b5c1e0cbSHans Petter Selasky /** 804b5c1e0cbSHans Petter Selasky * struct ib_mr_status - Memory region status container 805b5c1e0cbSHans Petter Selasky * 806b5c1e0cbSHans Petter Selasky * @fail_status: Bitmask of MR checks status. For each 807b5c1e0cbSHans Petter Selasky * failed check a corresponding status bit is set. 808b5c1e0cbSHans Petter Selasky * @sig_err: Additional info for IB_MR_CEHCK_SIG_STATUS 809b5c1e0cbSHans Petter Selasky * failure. 810b5c1e0cbSHans Petter Selasky */ 811b5c1e0cbSHans Petter Selasky struct ib_mr_status { 812b5c1e0cbSHans Petter Selasky u32 fail_status; 813b5c1e0cbSHans Petter Selasky struct ib_sig_err sig_err; 814b5c1e0cbSHans Petter Selasky }; 815b5c1e0cbSHans Petter Selasky 816c9f432b7SAlfred Perlstein /** 817aa0a1e58SJeff Roberson * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate 818aa0a1e58SJeff Roberson * enum. 819aa0a1e58SJeff Roberson * @mult: multiple to convert. 820aa0a1e58SJeff Roberson */ 821478d3005SHans Petter Selasky __attribute_const__ enum ib_rate mult_to_ib_rate(int mult); 822aa0a1e58SJeff Roberson 823aa0a1e58SJeff Roberson struct ib_ah_attr { 824aa0a1e58SJeff Roberson struct ib_global_route grh; 825aa0a1e58SJeff Roberson u16 dlid; 826aa0a1e58SJeff Roberson u8 sl; 827aa0a1e58SJeff Roberson u8 src_path_bits; 828aa0a1e58SJeff Roberson u8 static_rate; 829aa0a1e58SJeff Roberson u8 ah_flags; 830aa0a1e58SJeff Roberson u8 port_num; 831478d3005SHans Petter Selasky u8 dmac[ETH_ALEN]; 832aa0a1e58SJeff Roberson }; 833aa0a1e58SJeff Roberson 834aa0a1e58SJeff Roberson enum ib_wc_status { 835aa0a1e58SJeff Roberson IB_WC_SUCCESS, 836aa0a1e58SJeff Roberson IB_WC_LOC_LEN_ERR, 837aa0a1e58SJeff Roberson IB_WC_LOC_QP_OP_ERR, 838aa0a1e58SJeff Roberson IB_WC_LOC_EEC_OP_ERR, 839aa0a1e58SJeff Roberson IB_WC_LOC_PROT_ERR, 840aa0a1e58SJeff Roberson IB_WC_WR_FLUSH_ERR, 841aa0a1e58SJeff Roberson IB_WC_MW_BIND_ERR, 842aa0a1e58SJeff Roberson IB_WC_BAD_RESP_ERR, 843aa0a1e58SJeff Roberson IB_WC_LOC_ACCESS_ERR, 844aa0a1e58SJeff Roberson IB_WC_REM_INV_REQ_ERR, 845aa0a1e58SJeff Roberson IB_WC_REM_ACCESS_ERR, 846aa0a1e58SJeff Roberson IB_WC_REM_OP_ERR, 847aa0a1e58SJeff Roberson IB_WC_RETRY_EXC_ERR, 848aa0a1e58SJeff Roberson IB_WC_RNR_RETRY_EXC_ERR, 849aa0a1e58SJeff Roberson IB_WC_LOC_RDD_VIOL_ERR, 850aa0a1e58SJeff Roberson IB_WC_REM_INV_RD_REQ_ERR, 851aa0a1e58SJeff Roberson IB_WC_REM_ABORT_ERR, 852aa0a1e58SJeff Roberson IB_WC_INV_EECN_ERR, 853aa0a1e58SJeff Roberson IB_WC_INV_EEC_STATE_ERR, 854aa0a1e58SJeff Roberson IB_WC_FATAL_ERR, 855aa0a1e58SJeff Roberson IB_WC_RESP_TIMEOUT_ERR, 856aa0a1e58SJeff Roberson IB_WC_GENERAL_ERR 857aa0a1e58SJeff Roberson }; 858aa0a1e58SJeff Roberson 859478d3005SHans Petter Selasky const char *__attribute_const__ ib_wc_status_msg(enum ib_wc_status status); 860478d3005SHans Petter Selasky 861aa0a1e58SJeff Roberson enum ib_wc_opcode { 862aa0a1e58SJeff Roberson IB_WC_SEND, 863aa0a1e58SJeff Roberson IB_WC_RDMA_WRITE, 864aa0a1e58SJeff Roberson IB_WC_RDMA_READ, 865aa0a1e58SJeff Roberson IB_WC_COMP_SWAP, 866aa0a1e58SJeff Roberson IB_WC_FETCH_ADD, 867aa0a1e58SJeff Roberson IB_WC_LSO, 868aa0a1e58SJeff Roberson IB_WC_LOCAL_INV, 869478d3005SHans Petter Selasky IB_WC_REG_MR, 870aa0a1e58SJeff Roberson IB_WC_MASKED_COMP_SWAP, 871aa0a1e58SJeff Roberson IB_WC_MASKED_FETCH_ADD, 872aa0a1e58SJeff Roberson /* 873aa0a1e58SJeff Roberson * Set value of IB_WC_RECV so consumers can test if a completion is a 874aa0a1e58SJeff Roberson * receive by testing (opcode & IB_WC_RECV). 875aa0a1e58SJeff Roberson */ 876aa0a1e58SJeff Roberson IB_WC_RECV = 1 << 7, 877478d3005SHans Petter Selasky IB_WC_RECV_RDMA_WITH_IMM, 878478d3005SHans Petter Selasky IB_WC_DUMMY = -1, /* force enum signed */ 879aa0a1e58SJeff Roberson }; 880aa0a1e58SJeff Roberson 881aa0a1e58SJeff Roberson enum ib_wc_flags { 882aa0a1e58SJeff Roberson IB_WC_GRH = 1, 883aa0a1e58SJeff Roberson IB_WC_WITH_IMM = (1<<1), 884aa0a1e58SJeff Roberson IB_WC_WITH_INVALIDATE = (1<<2), 885c9f432b7SAlfred Perlstein IB_WC_IP_CSUM_OK = (1<<3), 886478d3005SHans Petter Selasky IB_WC_WITH_SMAC = (1<<4), 887478d3005SHans Petter Selasky IB_WC_WITH_VLAN = (1<<5), 888478d3005SHans Petter Selasky IB_WC_WITH_NETWORK_HDR_TYPE = (1<<6), 889aa0a1e58SJeff Roberson }; 890aa0a1e58SJeff Roberson 891aa0a1e58SJeff Roberson struct ib_wc { 892478d3005SHans Petter Selasky union { 893aa0a1e58SJeff Roberson u64 wr_id; 894478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 895478d3005SHans Petter Selasky }; 896aa0a1e58SJeff Roberson enum ib_wc_status status; 897aa0a1e58SJeff Roberson enum ib_wc_opcode opcode; 898aa0a1e58SJeff Roberson u32 vendor_err; 899aa0a1e58SJeff Roberson u32 byte_len; 900aa0a1e58SJeff Roberson struct ib_qp *qp; 901aa0a1e58SJeff Roberson union { 902aa0a1e58SJeff Roberson __be32 imm_data; 903aa0a1e58SJeff Roberson u32 invalidate_rkey; 904aa0a1e58SJeff Roberson } ex; 905aa0a1e58SJeff Roberson u32 src_qp; 906aa0a1e58SJeff Roberson int wc_flags; 907aa0a1e58SJeff Roberson u16 pkey_index; 908aa0a1e58SJeff Roberson u16 slid; 909aa0a1e58SJeff Roberson u8 sl; 910aa0a1e58SJeff Roberson u8 dlid_path_bits; 911aa0a1e58SJeff Roberson u8 port_num; /* valid only for DR SMPs on switches */ 912478d3005SHans Petter Selasky u8 smac[ETH_ALEN]; 913b5c1e0cbSHans Petter Selasky u16 vlan_id; 914478d3005SHans Petter Selasky u8 network_hdr_type; 915aa0a1e58SJeff Roberson }; 916aa0a1e58SJeff Roberson 917aa0a1e58SJeff Roberson enum ib_cq_notify_flags { 918aa0a1e58SJeff Roberson IB_CQ_SOLICITED = 1 << 0, 919aa0a1e58SJeff Roberson IB_CQ_NEXT_COMP = 1 << 1, 920aa0a1e58SJeff Roberson IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP, 921aa0a1e58SJeff Roberson IB_CQ_REPORT_MISSED_EVENTS = 1 << 2, 922aa0a1e58SJeff Roberson }; 923aa0a1e58SJeff Roberson 924c9f432b7SAlfred Perlstein enum ib_srq_type { 925c9f432b7SAlfred Perlstein IB_SRQT_BASIC, 926c9f432b7SAlfred Perlstein IB_SRQT_XRC 927c9f432b7SAlfred Perlstein }; 928c9f432b7SAlfred Perlstein 929aa0a1e58SJeff Roberson enum ib_srq_attr_mask { 930aa0a1e58SJeff Roberson IB_SRQ_MAX_WR = 1 << 0, 931aa0a1e58SJeff Roberson IB_SRQ_LIMIT = 1 << 1, 932aa0a1e58SJeff Roberson }; 933aa0a1e58SJeff Roberson 934aa0a1e58SJeff Roberson struct ib_srq_attr { 935aa0a1e58SJeff Roberson u32 max_wr; 936aa0a1e58SJeff Roberson u32 max_sge; 937aa0a1e58SJeff Roberson u32 srq_limit; 938aa0a1e58SJeff Roberson }; 939aa0a1e58SJeff Roberson 940aa0a1e58SJeff Roberson struct ib_srq_init_attr { 941aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 942aa0a1e58SJeff Roberson void *srq_context; 943aa0a1e58SJeff Roberson struct ib_srq_attr attr; 944c9f432b7SAlfred Perlstein enum ib_srq_type srq_type; 945c9f432b7SAlfred Perlstein 946c9f432b7SAlfred Perlstein union { 947c9f432b7SAlfred Perlstein struct { 948c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; 949c9f432b7SAlfred Perlstein struct ib_cq *cq; 950c9f432b7SAlfred Perlstein } xrc; 951c9f432b7SAlfred Perlstein } ext; 952aa0a1e58SJeff Roberson }; 953aa0a1e58SJeff Roberson 954aa0a1e58SJeff Roberson struct ib_qp_cap { 955aa0a1e58SJeff Roberson u32 max_send_wr; 956aa0a1e58SJeff Roberson u32 max_recv_wr; 957aa0a1e58SJeff Roberson u32 max_send_sge; 958aa0a1e58SJeff Roberson u32 max_recv_sge; 959aa0a1e58SJeff Roberson u32 max_inline_data; 960478d3005SHans Petter Selasky 961478d3005SHans Petter Selasky /* 962478d3005SHans Petter Selasky * Maximum number of rdma_rw_ctx structures in flight at a time. 963478d3005SHans Petter Selasky * ib_create_qp() will calculate the right amount of neededed WRs 964478d3005SHans Petter Selasky * and MRs based on this. 965478d3005SHans Petter Selasky */ 966478d3005SHans Petter Selasky u32 max_rdma_ctxs; 967aa0a1e58SJeff Roberson }; 968aa0a1e58SJeff Roberson 969aa0a1e58SJeff Roberson enum ib_sig_type { 970aa0a1e58SJeff Roberson IB_SIGNAL_ALL_WR, 971aa0a1e58SJeff Roberson IB_SIGNAL_REQ_WR 972aa0a1e58SJeff Roberson }; 973aa0a1e58SJeff Roberson 974aa0a1e58SJeff Roberson enum ib_qp_type { 975aa0a1e58SJeff Roberson /* 976aa0a1e58SJeff Roberson * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries 977aa0a1e58SJeff Roberson * here (and in that order) since the MAD layer uses them as 978aa0a1e58SJeff Roberson * indices into a 2-entry table. 979aa0a1e58SJeff Roberson */ 980aa0a1e58SJeff Roberson IB_QPT_SMI, 981aa0a1e58SJeff Roberson IB_QPT_GSI, 982aa0a1e58SJeff Roberson 983aa0a1e58SJeff Roberson IB_QPT_RC, 984aa0a1e58SJeff Roberson IB_QPT_UC, 985aa0a1e58SJeff Roberson IB_QPT_UD, 986aa0a1e58SJeff Roberson IB_QPT_RAW_IPV6, 987c9f432b7SAlfred Perlstein IB_QPT_RAW_ETHERTYPE, 988c9f432b7SAlfred Perlstein IB_QPT_RAW_PACKET = 8, 989c9f432b7SAlfred Perlstein IB_QPT_XRC_INI = 9, 990c9f432b7SAlfred Perlstein IB_QPT_XRC_TGT, 991c9f432b7SAlfred Perlstein IB_QPT_MAX, 992b5c1e0cbSHans Petter Selasky /* Reserve a range for qp types internal to the low level driver. 993b5c1e0cbSHans Petter Selasky * These qp types will not be visible at the IB core layer, so the 994b5c1e0cbSHans Petter Selasky * IB_QPT_MAX usages should not be affected in the core layer 995b5c1e0cbSHans Petter Selasky */ 996b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED1 = 0x1000, 997b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED2, 998b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED3, 999b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED4, 1000b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED5, 1001b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED6, 1002b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED7, 1003b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED8, 1004b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED9, 1005b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED10, 1006aa0a1e58SJeff Roberson }; 1007aa0a1e58SJeff Roberson 1008aa0a1e58SJeff Roberson enum ib_qp_create_flags { 1009aa0a1e58SJeff Roberson IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, 1010aa0a1e58SJeff Roberson IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1, 1011b5c1e0cbSHans Petter Selasky IB_QP_CREATE_CROSS_CHANNEL = 1 << 2, 1012b5c1e0cbSHans Petter Selasky IB_QP_CREATE_MANAGED_SEND = 1 << 3, 1013b5c1e0cbSHans Petter Selasky IB_QP_CREATE_MANAGED_RECV = 1 << 4, 1014b5c1e0cbSHans Petter Selasky IB_QP_CREATE_NETIF_QP = 1 << 5, 1015b5c1e0cbSHans Petter Selasky IB_QP_CREATE_SIGNATURE_EN = 1 << 6, 1016478d3005SHans Petter Selasky IB_QP_CREATE_USE_GFP_NOIO = 1 << 7, 1017478d3005SHans Petter Selasky IB_QP_CREATE_SCATTER_FCS = 1 << 8, 1018c9f432b7SAlfred Perlstein /* reserve bits 26-31 for low level drivers' internal use */ 1019c9f432b7SAlfred Perlstein IB_QP_CREATE_RESERVED_START = 1 << 26, 1020c9f432b7SAlfred Perlstein IB_QP_CREATE_RESERVED_END = 1 << 31, 1021c9f432b7SAlfred Perlstein }; 1022c9f432b7SAlfred Perlstein 1023478d3005SHans Petter Selasky /* 1024478d3005SHans Petter Selasky * Note: users may not call ib_close_qp or ib_destroy_qp from the event_handler 1025478d3005SHans Petter Selasky * callback to destroy the passed in QP. 1026478d3005SHans Petter Selasky */ 1027aa0a1e58SJeff Roberson 1028aa0a1e58SJeff Roberson struct ib_qp_init_attr { 1029aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1030aa0a1e58SJeff Roberson void *qp_context; 1031aa0a1e58SJeff Roberson struct ib_cq *send_cq; 1032aa0a1e58SJeff Roberson struct ib_cq *recv_cq; 1033aa0a1e58SJeff Roberson struct ib_srq *srq; 1034c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 1035aa0a1e58SJeff Roberson struct ib_qp_cap cap; 1036aa0a1e58SJeff Roberson enum ib_sig_type sq_sig_type; 1037aa0a1e58SJeff Roberson enum ib_qp_type qp_type; 1038aa0a1e58SJeff Roberson enum ib_qp_create_flags create_flags; 1039aa0a1e58SJeff Roberson 1040478d3005SHans Petter Selasky /* 1041478d3005SHans Petter Selasky * Only needed for special QP types, or when using the RW API. 1042478d3005SHans Petter Selasky */ 1043478d3005SHans Petter Selasky u8 port_num; 1044478d3005SHans Petter Selasky struct ib_rwq_ind_table *rwq_ind_tbl; 1045b5c1e0cbSHans Petter Selasky }; 1046b5c1e0cbSHans Petter Selasky 1047c9f432b7SAlfred Perlstein struct ib_qp_open_attr { 1048c9f432b7SAlfred Perlstein void (*event_handler)(struct ib_event *, void *); 1049c9f432b7SAlfred Perlstein void *qp_context; 1050c9f432b7SAlfred Perlstein u32 qp_num; 1051c9f432b7SAlfred Perlstein enum ib_qp_type qp_type; 1052c9f432b7SAlfred Perlstein }; 1053c9f432b7SAlfred Perlstein 1054aa0a1e58SJeff Roberson enum ib_rnr_timeout { 1055aa0a1e58SJeff Roberson IB_RNR_TIMER_655_36 = 0, 1056aa0a1e58SJeff Roberson IB_RNR_TIMER_000_01 = 1, 1057aa0a1e58SJeff Roberson IB_RNR_TIMER_000_02 = 2, 1058aa0a1e58SJeff Roberson IB_RNR_TIMER_000_03 = 3, 1059aa0a1e58SJeff Roberson IB_RNR_TIMER_000_04 = 4, 1060aa0a1e58SJeff Roberson IB_RNR_TIMER_000_06 = 5, 1061aa0a1e58SJeff Roberson IB_RNR_TIMER_000_08 = 6, 1062aa0a1e58SJeff Roberson IB_RNR_TIMER_000_12 = 7, 1063aa0a1e58SJeff Roberson IB_RNR_TIMER_000_16 = 8, 1064aa0a1e58SJeff Roberson IB_RNR_TIMER_000_24 = 9, 1065aa0a1e58SJeff Roberson IB_RNR_TIMER_000_32 = 10, 1066aa0a1e58SJeff Roberson IB_RNR_TIMER_000_48 = 11, 1067aa0a1e58SJeff Roberson IB_RNR_TIMER_000_64 = 12, 1068aa0a1e58SJeff Roberson IB_RNR_TIMER_000_96 = 13, 1069aa0a1e58SJeff Roberson IB_RNR_TIMER_001_28 = 14, 1070aa0a1e58SJeff Roberson IB_RNR_TIMER_001_92 = 15, 1071aa0a1e58SJeff Roberson IB_RNR_TIMER_002_56 = 16, 1072aa0a1e58SJeff Roberson IB_RNR_TIMER_003_84 = 17, 1073aa0a1e58SJeff Roberson IB_RNR_TIMER_005_12 = 18, 1074aa0a1e58SJeff Roberson IB_RNR_TIMER_007_68 = 19, 1075aa0a1e58SJeff Roberson IB_RNR_TIMER_010_24 = 20, 1076aa0a1e58SJeff Roberson IB_RNR_TIMER_015_36 = 21, 1077aa0a1e58SJeff Roberson IB_RNR_TIMER_020_48 = 22, 1078aa0a1e58SJeff Roberson IB_RNR_TIMER_030_72 = 23, 1079aa0a1e58SJeff Roberson IB_RNR_TIMER_040_96 = 24, 1080aa0a1e58SJeff Roberson IB_RNR_TIMER_061_44 = 25, 1081aa0a1e58SJeff Roberson IB_RNR_TIMER_081_92 = 26, 1082aa0a1e58SJeff Roberson IB_RNR_TIMER_122_88 = 27, 1083aa0a1e58SJeff Roberson IB_RNR_TIMER_163_84 = 28, 1084aa0a1e58SJeff Roberson IB_RNR_TIMER_245_76 = 29, 1085aa0a1e58SJeff Roberson IB_RNR_TIMER_327_68 = 30, 1086aa0a1e58SJeff Roberson IB_RNR_TIMER_491_52 = 31 1087aa0a1e58SJeff Roberson }; 1088aa0a1e58SJeff Roberson 1089aa0a1e58SJeff Roberson enum ib_qp_attr_mask { 1090aa0a1e58SJeff Roberson IB_QP_STATE = 1, 1091aa0a1e58SJeff Roberson IB_QP_CUR_STATE = (1<<1), 1092aa0a1e58SJeff Roberson IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), 1093aa0a1e58SJeff Roberson IB_QP_ACCESS_FLAGS = (1<<3), 1094aa0a1e58SJeff Roberson IB_QP_PKEY_INDEX = (1<<4), 1095aa0a1e58SJeff Roberson IB_QP_PORT = (1<<5), 1096aa0a1e58SJeff Roberson IB_QP_QKEY = (1<<6), 1097aa0a1e58SJeff Roberson IB_QP_AV = (1<<7), 1098aa0a1e58SJeff Roberson IB_QP_PATH_MTU = (1<<8), 1099aa0a1e58SJeff Roberson IB_QP_TIMEOUT = (1<<9), 1100aa0a1e58SJeff Roberson IB_QP_RETRY_CNT = (1<<10), 1101aa0a1e58SJeff Roberson IB_QP_RNR_RETRY = (1<<11), 1102aa0a1e58SJeff Roberson IB_QP_RQ_PSN = (1<<12), 1103aa0a1e58SJeff Roberson IB_QP_MAX_QP_RD_ATOMIC = (1<<13), 1104aa0a1e58SJeff Roberson IB_QP_ALT_PATH = (1<<14), 1105aa0a1e58SJeff Roberson IB_QP_MIN_RNR_TIMER = (1<<15), 1106aa0a1e58SJeff Roberson IB_QP_SQ_PSN = (1<<16), 1107aa0a1e58SJeff Roberson IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), 1108aa0a1e58SJeff Roberson IB_QP_PATH_MIG_STATE = (1<<18), 1109aa0a1e58SJeff Roberson IB_QP_CAP = (1<<19), 1110c9f432b7SAlfred Perlstein IB_QP_DEST_QPN = (1<<20), 1111478d3005SHans Petter Selasky IB_QP_RESERVED1 = (1<<21), 1112478d3005SHans Petter Selasky IB_QP_RESERVED2 = (1<<22), 1113478d3005SHans Petter Selasky IB_QP_RESERVED3 = (1<<23), 1114478d3005SHans Petter Selasky IB_QP_RESERVED4 = (1<<24), 1115aa0a1e58SJeff Roberson }; 1116aa0a1e58SJeff Roberson 1117aa0a1e58SJeff Roberson enum ib_qp_state { 1118aa0a1e58SJeff Roberson IB_QPS_RESET, 1119aa0a1e58SJeff Roberson IB_QPS_INIT, 1120aa0a1e58SJeff Roberson IB_QPS_RTR, 1121aa0a1e58SJeff Roberson IB_QPS_RTS, 1122aa0a1e58SJeff Roberson IB_QPS_SQD, 1123aa0a1e58SJeff Roberson IB_QPS_SQE, 1124b5c1e0cbSHans Petter Selasky IB_QPS_ERR, 1125478d3005SHans Petter Selasky IB_QPS_DUMMY = -1, /* force enum signed */ 1126aa0a1e58SJeff Roberson }; 1127aa0a1e58SJeff Roberson 1128aa0a1e58SJeff Roberson enum ib_mig_state { 1129aa0a1e58SJeff Roberson IB_MIG_MIGRATED, 1130aa0a1e58SJeff Roberson IB_MIG_REARM, 1131aa0a1e58SJeff Roberson IB_MIG_ARMED 1132aa0a1e58SJeff Roberson }; 1133aa0a1e58SJeff Roberson 1134b5c1e0cbSHans Petter Selasky enum ib_mw_type { 1135b5c1e0cbSHans Petter Selasky IB_MW_TYPE_1 = 1, 1136b5c1e0cbSHans Petter Selasky IB_MW_TYPE_2 = 2 1137b5c1e0cbSHans Petter Selasky }; 1138b5c1e0cbSHans Petter Selasky 1139aa0a1e58SJeff Roberson struct ib_qp_attr { 1140aa0a1e58SJeff Roberson enum ib_qp_state qp_state; 1141aa0a1e58SJeff Roberson enum ib_qp_state cur_qp_state; 1142aa0a1e58SJeff Roberson enum ib_mtu path_mtu; 1143aa0a1e58SJeff Roberson enum ib_mig_state path_mig_state; 1144aa0a1e58SJeff Roberson u32 qkey; 1145aa0a1e58SJeff Roberson u32 rq_psn; 1146aa0a1e58SJeff Roberson u32 sq_psn; 1147aa0a1e58SJeff Roberson u32 dest_qp_num; 1148aa0a1e58SJeff Roberson int qp_access_flags; 1149aa0a1e58SJeff Roberson struct ib_qp_cap cap; 1150aa0a1e58SJeff Roberson struct ib_ah_attr ah_attr; 1151aa0a1e58SJeff Roberson struct ib_ah_attr alt_ah_attr; 1152aa0a1e58SJeff Roberson u16 pkey_index; 1153aa0a1e58SJeff Roberson u16 alt_pkey_index; 1154aa0a1e58SJeff Roberson u8 en_sqd_async_notify; 1155aa0a1e58SJeff Roberson u8 sq_draining; 1156aa0a1e58SJeff Roberson u8 max_rd_atomic; 1157aa0a1e58SJeff Roberson u8 max_dest_rd_atomic; 1158aa0a1e58SJeff Roberson u8 min_rnr_timer; 1159aa0a1e58SJeff Roberson u8 port_num; 1160aa0a1e58SJeff Roberson u8 timeout; 1161aa0a1e58SJeff Roberson u8 retry_cnt; 1162aa0a1e58SJeff Roberson u8 rnr_retry; 1163aa0a1e58SJeff Roberson u8 alt_port_num; 1164aa0a1e58SJeff Roberson u8 alt_timeout; 1165aa0a1e58SJeff Roberson }; 1166aa0a1e58SJeff Roberson 1167aa0a1e58SJeff Roberson enum ib_wr_opcode { 1168aa0a1e58SJeff Roberson IB_WR_RDMA_WRITE, 1169aa0a1e58SJeff Roberson IB_WR_RDMA_WRITE_WITH_IMM, 1170aa0a1e58SJeff Roberson IB_WR_SEND, 1171aa0a1e58SJeff Roberson IB_WR_SEND_WITH_IMM, 1172aa0a1e58SJeff Roberson IB_WR_RDMA_READ, 1173aa0a1e58SJeff Roberson IB_WR_ATOMIC_CMP_AND_SWP, 1174aa0a1e58SJeff Roberson IB_WR_ATOMIC_FETCH_AND_ADD, 1175aa0a1e58SJeff Roberson IB_WR_LSO, 1176aa0a1e58SJeff Roberson IB_WR_SEND_WITH_INV, 1177aa0a1e58SJeff Roberson IB_WR_RDMA_READ_WITH_INV, 1178aa0a1e58SJeff Roberson IB_WR_LOCAL_INV, 1179478d3005SHans Petter Selasky IB_WR_REG_MR, 1180aa0a1e58SJeff Roberson IB_WR_MASKED_ATOMIC_CMP_AND_SWP, 1181aa0a1e58SJeff Roberson IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, 1182b5c1e0cbSHans Petter Selasky IB_WR_REG_SIG_MR, 1183b5c1e0cbSHans Petter Selasky /* reserve values for low level drivers' internal use. 1184b5c1e0cbSHans Petter Selasky * These values will not be used at all in the ib core layer. 1185b5c1e0cbSHans Petter Selasky */ 1186b5c1e0cbSHans Petter Selasky IB_WR_RESERVED1 = 0xf0, 1187b5c1e0cbSHans Petter Selasky IB_WR_RESERVED2, 1188b5c1e0cbSHans Petter Selasky IB_WR_RESERVED3, 1189b5c1e0cbSHans Petter Selasky IB_WR_RESERVED4, 1190b5c1e0cbSHans Petter Selasky IB_WR_RESERVED5, 1191b5c1e0cbSHans Petter Selasky IB_WR_RESERVED6, 1192b5c1e0cbSHans Petter Selasky IB_WR_RESERVED7, 1193b5c1e0cbSHans Petter Selasky IB_WR_RESERVED8, 1194b5c1e0cbSHans Petter Selasky IB_WR_RESERVED9, 1195b5c1e0cbSHans Petter Selasky IB_WR_RESERVED10, 1196478d3005SHans Petter Selasky IB_WR_DUMMY = -1, /* force enum signed */ 1197aa0a1e58SJeff Roberson }; 1198aa0a1e58SJeff Roberson 1199aa0a1e58SJeff Roberson enum ib_send_flags { 1200aa0a1e58SJeff Roberson IB_SEND_FENCE = 1, 1201aa0a1e58SJeff Roberson IB_SEND_SIGNALED = (1<<1), 1202aa0a1e58SJeff Roberson IB_SEND_SOLICITED = (1<<2), 1203aa0a1e58SJeff Roberson IB_SEND_INLINE = (1<<3), 1204b5c1e0cbSHans Petter Selasky IB_SEND_IP_CSUM = (1<<4), 1205aa0a1e58SJeff Roberson 1206b5c1e0cbSHans Petter Selasky /* reserve bits 26-31 for low level drivers' internal use */ 1207b5c1e0cbSHans Petter Selasky IB_SEND_RESERVED_START = (1 << 26), 1208b5c1e0cbSHans Petter Selasky IB_SEND_RESERVED_END = (1 << 31), 1209c9f432b7SAlfred Perlstein }; 1210c9f432b7SAlfred Perlstein 1211aa0a1e58SJeff Roberson struct ib_sge { 1212aa0a1e58SJeff Roberson u64 addr; 1213aa0a1e58SJeff Roberson u32 length; 1214aa0a1e58SJeff Roberson u32 lkey; 1215aa0a1e58SJeff Roberson }; 1216aa0a1e58SJeff Roberson 1217478d3005SHans Petter Selasky struct ib_cqe { 1218478d3005SHans Petter Selasky void (*done)(struct ib_cq *cq, struct ib_wc *wc); 1219b5c1e0cbSHans Petter Selasky }; 1220b5c1e0cbSHans Petter Selasky 1221aa0a1e58SJeff Roberson struct ib_send_wr { 1222aa0a1e58SJeff Roberson struct ib_send_wr *next; 1223478d3005SHans Petter Selasky union { 1224aa0a1e58SJeff Roberson u64 wr_id; 1225478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 1226478d3005SHans Petter Selasky }; 1227aa0a1e58SJeff Roberson struct ib_sge *sg_list; 1228aa0a1e58SJeff Roberson int num_sge; 1229aa0a1e58SJeff Roberson enum ib_wr_opcode opcode; 1230aa0a1e58SJeff Roberson int send_flags; 1231aa0a1e58SJeff Roberson union { 1232aa0a1e58SJeff Roberson __be32 imm_data; 1233aa0a1e58SJeff Roberson u32 invalidate_rkey; 1234aa0a1e58SJeff Roberson } ex; 1235478d3005SHans Petter Selasky }; 1236478d3005SHans Petter Selasky 1237478d3005SHans Petter Selasky struct ib_rdma_wr { 1238478d3005SHans Petter Selasky struct ib_send_wr wr; 1239aa0a1e58SJeff Roberson u64 remote_addr; 1240aa0a1e58SJeff Roberson u32 rkey; 1241478d3005SHans Petter Selasky }; 1242478d3005SHans Petter Selasky 1243478d3005SHans Petter Selasky static inline struct ib_rdma_wr *rdma_wr(struct ib_send_wr *wr) 1244478d3005SHans Petter Selasky { 1245478d3005SHans Petter Selasky return container_of(wr, struct ib_rdma_wr, wr); 1246478d3005SHans Petter Selasky } 1247478d3005SHans Petter Selasky 1248478d3005SHans Petter Selasky struct ib_atomic_wr { 1249478d3005SHans Petter Selasky struct ib_send_wr wr; 1250aa0a1e58SJeff Roberson u64 remote_addr; 1251aa0a1e58SJeff Roberson u64 compare_add; 1252aa0a1e58SJeff Roberson u64 swap; 1253aa0a1e58SJeff Roberson u64 compare_add_mask; 1254aa0a1e58SJeff Roberson u64 swap_mask; 1255aa0a1e58SJeff Roberson u32 rkey; 1256478d3005SHans Petter Selasky }; 1257478d3005SHans Petter Selasky 1258478d3005SHans Petter Selasky static inline struct ib_atomic_wr *atomic_wr(struct ib_send_wr *wr) 1259478d3005SHans Petter Selasky { 1260478d3005SHans Petter Selasky return container_of(wr, struct ib_atomic_wr, wr); 1261478d3005SHans Petter Selasky } 1262478d3005SHans Petter Selasky 1263478d3005SHans Petter Selasky struct ib_ud_wr { 1264478d3005SHans Petter Selasky struct ib_send_wr wr; 1265aa0a1e58SJeff Roberson struct ib_ah *ah; 1266aa0a1e58SJeff Roberson void *header; 1267aa0a1e58SJeff Roberson int hlen; 1268aa0a1e58SJeff Roberson int mss; 1269aa0a1e58SJeff Roberson u32 remote_qpn; 1270aa0a1e58SJeff Roberson u32 remote_qkey; 1271aa0a1e58SJeff Roberson u16 pkey_index; /* valid for GSI only */ 1272aa0a1e58SJeff Roberson u8 port_num; /* valid for DR SMPs on switch only */ 1273478d3005SHans Petter Selasky }; 1274478d3005SHans Petter Selasky 1275478d3005SHans Petter Selasky static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr) 1276478d3005SHans Petter Selasky { 1277478d3005SHans Petter Selasky return container_of(wr, struct ib_ud_wr, wr); 1278478d3005SHans Petter Selasky } 1279478d3005SHans Petter Selasky 1280478d3005SHans Petter Selasky struct ib_reg_wr { 1281478d3005SHans Petter Selasky struct ib_send_wr wr; 1282478d3005SHans Petter Selasky struct ib_mr *mr; 1283478d3005SHans Petter Selasky u32 key; 1284478d3005SHans Petter Selasky int access; 1285478d3005SHans Petter Selasky }; 1286478d3005SHans Petter Selasky 1287478d3005SHans Petter Selasky static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr) 1288478d3005SHans Petter Selasky { 1289478d3005SHans Petter Selasky return container_of(wr, struct ib_reg_wr, wr); 1290478d3005SHans Petter Selasky } 1291478d3005SHans Petter Selasky 1292478d3005SHans Petter Selasky struct ib_sig_handover_wr { 1293478d3005SHans Petter Selasky struct ib_send_wr wr; 1294b5c1e0cbSHans Petter Selasky struct ib_sig_attrs *sig_attrs; 1295b5c1e0cbSHans Petter Selasky struct ib_mr *sig_mr; 1296b5c1e0cbSHans Petter Selasky int access_flags; 1297b5c1e0cbSHans Petter Selasky struct ib_sge *prot; 1298aa0a1e58SJeff Roberson }; 1299aa0a1e58SJeff Roberson 1300478d3005SHans Petter Selasky static inline struct ib_sig_handover_wr *sig_handover_wr(struct ib_send_wr *wr) 1301478d3005SHans Petter Selasky { 1302478d3005SHans Petter Selasky return container_of(wr, struct ib_sig_handover_wr, wr); 1303478d3005SHans Petter Selasky } 1304478d3005SHans Petter Selasky 1305aa0a1e58SJeff Roberson struct ib_recv_wr { 1306aa0a1e58SJeff Roberson struct ib_recv_wr *next; 1307478d3005SHans Petter Selasky union { 1308aa0a1e58SJeff Roberson u64 wr_id; 1309478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 1310478d3005SHans Petter Selasky }; 1311aa0a1e58SJeff Roberson struct ib_sge *sg_list; 1312aa0a1e58SJeff Roberson int num_sge; 1313aa0a1e58SJeff Roberson }; 1314aa0a1e58SJeff Roberson 1315aa0a1e58SJeff Roberson enum ib_access_flags { 1316aa0a1e58SJeff Roberson IB_ACCESS_LOCAL_WRITE = 1, 1317aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_WRITE = (1<<1), 1318aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_READ = (1<<2), 1319aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_ATOMIC = (1<<3), 1320c9f432b7SAlfred Perlstein IB_ACCESS_MW_BIND = (1<<4), 1321478d3005SHans Petter Selasky IB_ZERO_BASED = (1<<5), 1322478d3005SHans Petter Selasky IB_ACCESS_ON_DEMAND = (1<<6), 1323aa0a1e58SJeff Roberson }; 1324aa0a1e58SJeff Roberson 1325478d3005SHans Petter Selasky /* 1326478d3005SHans Petter Selasky * XXX: these are apparently used for ->rereg_user_mr, no idea why they 1327478d3005SHans Petter Selasky * are hidden here instead of a uapi header! 1328478d3005SHans Petter Selasky */ 1329aa0a1e58SJeff Roberson enum ib_mr_rereg_flags { 1330aa0a1e58SJeff Roberson IB_MR_REREG_TRANS = 1, 1331aa0a1e58SJeff Roberson IB_MR_REREG_PD = (1<<1), 1332478d3005SHans Petter Selasky IB_MR_REREG_ACCESS = (1<<2), 1333478d3005SHans Petter Selasky IB_MR_REREG_SUPPORTED = ((IB_MR_REREG_ACCESS << 1) - 1) 1334aa0a1e58SJeff Roberson }; 1335aa0a1e58SJeff Roberson 1336aa0a1e58SJeff Roberson struct ib_fmr_attr { 1337aa0a1e58SJeff Roberson int max_pages; 1338aa0a1e58SJeff Roberson int max_maps; 1339aa0a1e58SJeff Roberson u8 page_shift; 1340aa0a1e58SJeff Roberson }; 1341aa0a1e58SJeff Roberson 1342478d3005SHans Petter Selasky struct ib_umem; 1343478d3005SHans Petter Selasky 1344aa0a1e58SJeff Roberson struct ib_ucontext { 1345aa0a1e58SJeff Roberson struct ib_device *device; 1346aa0a1e58SJeff Roberson struct list_head pd_list; 1347aa0a1e58SJeff Roberson struct list_head mr_list; 1348aa0a1e58SJeff Roberson struct list_head mw_list; 1349aa0a1e58SJeff Roberson struct list_head cq_list; 1350aa0a1e58SJeff Roberson struct list_head qp_list; 1351aa0a1e58SJeff Roberson struct list_head srq_list; 1352aa0a1e58SJeff Roberson struct list_head ah_list; 1353c9f432b7SAlfred Perlstein struct list_head xrcd_list; 1354b5c1e0cbSHans Petter Selasky struct list_head rule_list; 1355478d3005SHans Petter Selasky struct list_head wq_list; 1356478d3005SHans Petter Selasky struct list_head rwq_ind_tbl_list; 1357aa0a1e58SJeff Roberson int closing; 1358478d3005SHans Petter Selasky 1359478d3005SHans Petter Selasky pid_t tgid; 1360478d3005SHans Petter Selasky #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING 1361478d3005SHans Petter Selasky struct rb_root umem_tree; 1362478d3005SHans Petter Selasky /* 1363478d3005SHans Petter Selasky * Protects .umem_rbroot and tree, as well as odp_mrs_count and 1364478d3005SHans Petter Selasky * mmu notifiers registration. 1365478d3005SHans Petter Selasky */ 1366478d3005SHans Petter Selasky struct rw_semaphore umem_rwsem; 1367478d3005SHans Petter Selasky void (*invalidate_range)(struct ib_umem *umem, 1368478d3005SHans Petter Selasky unsigned long start, unsigned long end); 1369478d3005SHans Petter Selasky 1370478d3005SHans Petter Selasky struct mmu_notifier mn; 1371478d3005SHans Petter Selasky atomic_t notifier_count; 1372478d3005SHans Petter Selasky /* A list of umems that don't have private mmu notifier counters yet. */ 1373478d3005SHans Petter Selasky struct list_head no_private_counters; 1374478d3005SHans Petter Selasky int odp_mrs_count; 1375478d3005SHans Petter Selasky #endif 1376aa0a1e58SJeff Roberson }; 1377aa0a1e58SJeff Roberson 1378aa0a1e58SJeff Roberson struct ib_uobject { 1379aa0a1e58SJeff Roberson u64 user_handle; /* handle given to us by userspace */ 1380aa0a1e58SJeff Roberson struct ib_ucontext *context; /* associated user context */ 1381aa0a1e58SJeff Roberson void *object; /* containing object */ 1382aa0a1e58SJeff Roberson struct list_head list; /* link to context's list */ 1383aa0a1e58SJeff Roberson int id; /* index into kernel idr */ 1384aa0a1e58SJeff Roberson struct kref ref; 1385aa0a1e58SJeff Roberson struct rw_semaphore mutex; /* protects .live */ 1386478d3005SHans Petter Selasky struct rcu_head rcu; /* kfree_rcu() overhead */ 1387aa0a1e58SJeff Roberson int live; 1388aa0a1e58SJeff Roberson }; 1389aa0a1e58SJeff Roberson 1390aa0a1e58SJeff Roberson struct ib_udata { 1391478d3005SHans Petter Selasky const void __user *inbuf; 1392aa0a1e58SJeff Roberson void __user *outbuf; 1393aa0a1e58SJeff Roberson size_t inlen; 1394aa0a1e58SJeff Roberson size_t outlen; 1395aa0a1e58SJeff Roberson }; 1396aa0a1e58SJeff Roberson 1397aa0a1e58SJeff Roberson struct ib_pd { 1398478d3005SHans Petter Selasky u32 local_dma_lkey; 1399478d3005SHans Petter Selasky u32 flags; 1400aa0a1e58SJeff Roberson struct ib_device *device; 1401aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1402aa0a1e58SJeff Roberson atomic_t usecnt; /* count all resources */ 1403478d3005SHans Petter Selasky 1404478d3005SHans Petter Selasky u32 unsafe_global_rkey; 1405478d3005SHans Petter Selasky 1406478d3005SHans Petter Selasky /* 1407478d3005SHans Petter Selasky * Implementation details of the RDMA core, don't use in drivers: 1408478d3005SHans Petter Selasky */ 1409478d3005SHans Petter Selasky struct ib_mr *__internal_mr; 1410aa0a1e58SJeff Roberson }; 1411aa0a1e58SJeff Roberson 1412aa0a1e58SJeff Roberson struct ib_xrcd { 1413aa0a1e58SJeff Roberson struct ib_device *device; 1414c9f432b7SAlfred Perlstein atomic_t usecnt; /* count all exposed resources */ 1415aa0a1e58SJeff Roberson struct inode *inode; 1416aa0a1e58SJeff Roberson 1417c9f432b7SAlfred Perlstein struct mutex tgt_qp_mutex; 1418c9f432b7SAlfred Perlstein struct list_head tgt_qp_list; 1419c9f432b7SAlfred Perlstein }; 1420aa0a1e58SJeff Roberson 1421aa0a1e58SJeff Roberson struct ib_ah { 1422aa0a1e58SJeff Roberson struct ib_device *device; 1423aa0a1e58SJeff Roberson struct ib_pd *pd; 1424aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1425aa0a1e58SJeff Roberson }; 1426aa0a1e58SJeff Roberson 1427aa0a1e58SJeff Roberson typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); 1428aa0a1e58SJeff Roberson 1429478d3005SHans Petter Selasky enum ib_poll_context { 1430478d3005SHans Petter Selasky IB_POLL_DIRECT, /* caller context, no hw completions */ 1431478d3005SHans Petter Selasky IB_POLL_SOFTIRQ, /* poll from softirq context */ 1432478d3005SHans Petter Selasky IB_POLL_WORKQUEUE, /* poll from workqueue */ 1433478d3005SHans Petter Selasky }; 1434478d3005SHans Petter Selasky 1435aa0a1e58SJeff Roberson struct ib_cq { 1436aa0a1e58SJeff Roberson struct ib_device *device; 1437aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1438aa0a1e58SJeff Roberson ib_comp_handler comp_handler; 1439aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1440aa0a1e58SJeff Roberson void *cq_context; 1441aa0a1e58SJeff Roberson int cqe; 1442aa0a1e58SJeff Roberson atomic_t usecnt; /* count number of work queues */ 1443478d3005SHans Petter Selasky enum ib_poll_context poll_ctx; 1444478d3005SHans Petter Selasky struct work_struct work; 1445aa0a1e58SJeff Roberson }; 1446aa0a1e58SJeff Roberson 1447aa0a1e58SJeff Roberson struct ib_srq { 1448aa0a1e58SJeff Roberson struct ib_device *device; 1449aa0a1e58SJeff Roberson struct ib_pd *pd; 1450aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1451aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1452aa0a1e58SJeff Roberson void *srq_context; 1453c9f432b7SAlfred Perlstein enum ib_srq_type srq_type; 1454aa0a1e58SJeff Roberson atomic_t usecnt; 1455c9f432b7SAlfred Perlstein 1456c9f432b7SAlfred Perlstein union { 1457c9f432b7SAlfred Perlstein struct { 1458c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; 1459c9f432b7SAlfred Perlstein struct ib_cq *cq; 1460c9f432b7SAlfred Perlstein u32 srq_num; 1461c9f432b7SAlfred Perlstein } xrc; 1462c9f432b7SAlfred Perlstein } ext; 1463aa0a1e58SJeff Roberson }; 1464aa0a1e58SJeff Roberson 1465478d3005SHans Petter Selasky enum ib_wq_type { 1466478d3005SHans Petter Selasky IB_WQT_RQ 1467478d3005SHans Petter Selasky }; 1468478d3005SHans Petter Selasky 1469478d3005SHans Petter Selasky enum ib_wq_state { 1470478d3005SHans Petter Selasky IB_WQS_RESET, 1471478d3005SHans Petter Selasky IB_WQS_RDY, 1472478d3005SHans Petter Selasky IB_WQS_ERR 1473478d3005SHans Petter Selasky }; 1474478d3005SHans Petter Selasky 1475478d3005SHans Petter Selasky struct ib_wq { 1476478d3005SHans Petter Selasky struct ib_device *device; 1477478d3005SHans Petter Selasky struct ib_uobject *uobject; 1478478d3005SHans Petter Selasky void *wq_context; 1479478d3005SHans Petter Selasky void (*event_handler)(struct ib_event *, void *); 1480478d3005SHans Petter Selasky struct ib_pd *pd; 1481478d3005SHans Petter Selasky struct ib_cq *cq; 1482478d3005SHans Petter Selasky u32 wq_num; 1483478d3005SHans Petter Selasky enum ib_wq_state state; 1484478d3005SHans Petter Selasky enum ib_wq_type wq_type; 1485478d3005SHans Petter Selasky atomic_t usecnt; 1486478d3005SHans Petter Selasky }; 1487478d3005SHans Petter Selasky 1488478d3005SHans Petter Selasky struct ib_wq_init_attr { 1489478d3005SHans Petter Selasky void *wq_context; 1490478d3005SHans Petter Selasky enum ib_wq_type wq_type; 1491478d3005SHans Petter Selasky u32 max_wr; 1492478d3005SHans Petter Selasky u32 max_sge; 1493478d3005SHans Petter Selasky struct ib_cq *cq; 1494478d3005SHans Petter Selasky void (*event_handler)(struct ib_event *, void *); 1495478d3005SHans Petter Selasky }; 1496478d3005SHans Petter Selasky 1497478d3005SHans Petter Selasky enum ib_wq_attr_mask { 1498478d3005SHans Petter Selasky IB_WQ_STATE = 1 << 0, 1499478d3005SHans Petter Selasky IB_WQ_CUR_STATE = 1 << 1, 1500478d3005SHans Petter Selasky }; 1501478d3005SHans Petter Selasky 1502478d3005SHans Petter Selasky struct ib_wq_attr { 1503478d3005SHans Petter Selasky enum ib_wq_state wq_state; 1504478d3005SHans Petter Selasky enum ib_wq_state curr_wq_state; 1505478d3005SHans Petter Selasky }; 1506478d3005SHans Petter Selasky 1507478d3005SHans Petter Selasky struct ib_rwq_ind_table { 1508478d3005SHans Petter Selasky struct ib_device *device; 1509478d3005SHans Petter Selasky struct ib_uobject *uobject; 1510478d3005SHans Petter Selasky atomic_t usecnt; 1511478d3005SHans Petter Selasky u32 ind_tbl_num; 1512478d3005SHans Petter Selasky u32 log_ind_tbl_size; 1513478d3005SHans Petter Selasky struct ib_wq **ind_tbl; 1514478d3005SHans Petter Selasky }; 1515478d3005SHans Petter Selasky 1516478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr { 1517478d3005SHans Petter Selasky u32 log_ind_tbl_size; 1518478d3005SHans Petter Selasky /* Each entry is a pointer to Receive Work Queue */ 1519478d3005SHans Petter Selasky struct ib_wq **ind_tbl; 1520478d3005SHans Petter Selasky }; 1521478d3005SHans Petter Selasky 1522478d3005SHans Petter Selasky /* 1523478d3005SHans Petter Selasky * @max_write_sge: Maximum SGE elements per RDMA WRITE request. 1524478d3005SHans Petter Selasky * @max_read_sge: Maximum SGE elements per RDMA READ request. 1525478d3005SHans Petter Selasky */ 1526aa0a1e58SJeff Roberson struct ib_qp { 1527aa0a1e58SJeff Roberson struct ib_device *device; 1528aa0a1e58SJeff Roberson struct ib_pd *pd; 1529aa0a1e58SJeff Roberson struct ib_cq *send_cq; 1530aa0a1e58SJeff Roberson struct ib_cq *recv_cq; 1531478d3005SHans Petter Selasky spinlock_t mr_lock; 1532aa0a1e58SJeff Roberson struct ib_srq *srq; 1533c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 1534c9f432b7SAlfred Perlstein struct list_head xrcd_list; 1535478d3005SHans Petter Selasky 1536b5c1e0cbSHans Petter Selasky /* count times opened, mcast attaches, flow attaches */ 1537b5c1e0cbSHans Petter Selasky atomic_t usecnt; 1538c9f432b7SAlfred Perlstein struct list_head open_list; 1539c9f432b7SAlfred Perlstein struct ib_qp *real_qp; 1540aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1541aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1542aa0a1e58SJeff Roberson void *qp_context; 1543aa0a1e58SJeff Roberson u32 qp_num; 1544478d3005SHans Petter Selasky u32 max_write_sge; 1545478d3005SHans Petter Selasky u32 max_read_sge; 1546aa0a1e58SJeff Roberson enum ib_qp_type qp_type; 1547478d3005SHans Petter Selasky struct ib_rwq_ind_table *rwq_ind_tbl; 1548aa0a1e58SJeff Roberson }; 1549aa0a1e58SJeff Roberson 1550aa0a1e58SJeff Roberson struct ib_mr { 1551aa0a1e58SJeff Roberson struct ib_device *device; 1552aa0a1e58SJeff Roberson struct ib_pd *pd; 1553aa0a1e58SJeff Roberson u32 lkey; 1554aa0a1e58SJeff Roberson u32 rkey; 1555478d3005SHans Petter Selasky u64 iova; 1556478d3005SHans Petter Selasky u32 length; 1557478d3005SHans Petter Selasky unsigned int page_size; 1558478d3005SHans Petter Selasky bool need_inval; 1559478d3005SHans Petter Selasky union { 1560478d3005SHans Petter Selasky struct ib_uobject *uobject; /* user */ 1561478d3005SHans Petter Selasky struct list_head qp_entry; /* FR */ 1562478d3005SHans Petter Selasky }; 1563aa0a1e58SJeff Roberson }; 1564aa0a1e58SJeff Roberson 1565aa0a1e58SJeff Roberson struct ib_mw { 1566aa0a1e58SJeff Roberson struct ib_device *device; 1567aa0a1e58SJeff Roberson struct ib_pd *pd; 1568aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1569aa0a1e58SJeff Roberson u32 rkey; 1570b5c1e0cbSHans Petter Selasky enum ib_mw_type type; 1571aa0a1e58SJeff Roberson }; 1572aa0a1e58SJeff Roberson 1573aa0a1e58SJeff Roberson struct ib_fmr { 1574aa0a1e58SJeff Roberson struct ib_device *device; 1575aa0a1e58SJeff Roberson struct ib_pd *pd; 1576aa0a1e58SJeff Roberson struct list_head list; 1577aa0a1e58SJeff Roberson u32 lkey; 1578aa0a1e58SJeff Roberson u32 rkey; 1579aa0a1e58SJeff Roberson }; 1580aa0a1e58SJeff Roberson 1581b5c1e0cbSHans Petter Selasky /* Supported steering options */ 1582b5c1e0cbSHans Petter Selasky enum ib_flow_attr_type { 1583b5c1e0cbSHans Petter Selasky /* steering according to rule specifications */ 1584b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_NORMAL = 0x0, 1585b5c1e0cbSHans Petter Selasky /* default unicast and multicast rule - 1586b5c1e0cbSHans Petter Selasky * receive all Eth traffic which isn't steered to any QP 1587b5c1e0cbSHans Petter Selasky */ 1588b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_ALL_DEFAULT = 0x1, 1589b5c1e0cbSHans Petter Selasky /* default multicast rule - 1590b5c1e0cbSHans Petter Selasky * receive all Eth multicast traffic which isn't steered to any QP 1591b5c1e0cbSHans Petter Selasky */ 1592b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_MC_DEFAULT = 0x2, 1593b5c1e0cbSHans Petter Selasky /* sniffer rule - receive all port traffic */ 1594b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_SNIFFER = 0x3 1595b5c1e0cbSHans Petter Selasky }; 1596b5c1e0cbSHans Petter Selasky 1597b5c1e0cbSHans Petter Selasky /* Supported steering header types */ 1598b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type { 1599b5c1e0cbSHans Petter Selasky /* L2 headers*/ 1600b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_ETH = 0x20, 1601478d3005SHans Petter Selasky IB_FLOW_SPEC_IB = 0x22, 1602b5c1e0cbSHans Petter Selasky /* L3 header*/ 1603b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_IPV4 = 0x30, 1604478d3005SHans Petter Selasky IB_FLOW_SPEC_IPV6 = 0x31, 1605b5c1e0cbSHans Petter Selasky /* L4 headers*/ 1606b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_TCP = 0x40, 1607b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_UDP = 0x41 1608b5c1e0cbSHans Petter Selasky }; 1609478d3005SHans Petter Selasky #define IB_FLOW_SPEC_LAYER_MASK 0xF0 1610b5c1e0cbSHans Petter Selasky #define IB_FLOW_SPEC_SUPPORT_LAYERS 4 1611b5c1e0cbSHans Petter Selasky 1612b5c1e0cbSHans Petter Selasky /* Flow steering rule priority is set according to it's domain. 1613b5c1e0cbSHans Petter Selasky * Lower domain value means higher priority. 1614b5c1e0cbSHans Petter Selasky */ 1615b5c1e0cbSHans Petter Selasky enum ib_flow_domain { 1616b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_USER, 1617b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_ETHTOOL, 1618b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_RFS, 1619b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_NIC, 1620b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_NUM /* Must be last */ 1621b5c1e0cbSHans Petter Selasky }; 1622b5c1e0cbSHans Petter Selasky 1623b5c1e0cbSHans Petter Selasky enum ib_flow_flags { 1624478d3005SHans Petter Selasky IB_FLOW_ATTR_FLAGS_DONT_TRAP = 1UL << 1, /* Continue match, no steal */ 1625478d3005SHans Petter Selasky IB_FLOW_ATTR_FLAGS_RESERVED = 1UL << 2 /* Must be last */ 1626b5c1e0cbSHans Petter Selasky }; 1627b5c1e0cbSHans Petter Selasky 1628b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter { 1629b5c1e0cbSHans Petter Selasky u8 dst_mac[6]; 1630b5c1e0cbSHans Petter Selasky u8 src_mac[6]; 1631b5c1e0cbSHans Petter Selasky __be16 ether_type; 1632b5c1e0cbSHans Petter Selasky __be16 vlan_tag; 1633478d3005SHans Petter Selasky /* Must be last */ 1634478d3005SHans Petter Selasky u8 real_sz[0]; 1635b5c1e0cbSHans Petter Selasky }; 1636b5c1e0cbSHans Petter Selasky 1637b5c1e0cbSHans Petter Selasky struct ib_flow_spec_eth { 1638b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1639b5c1e0cbSHans Petter Selasky u16 size; 1640b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter val; 1641b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter mask; 1642b5c1e0cbSHans Petter Selasky }; 1643b5c1e0cbSHans Petter Selasky 1644b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter { 1645478d3005SHans Petter Selasky __be16 dlid; 1646478d3005SHans Petter Selasky __u8 sl; 1647478d3005SHans Petter Selasky /* Must be last */ 1648478d3005SHans Petter Selasky u8 real_sz[0]; 1649b5c1e0cbSHans Petter Selasky }; 1650b5c1e0cbSHans Petter Selasky 1651b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ib { 1652b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1653b5c1e0cbSHans Petter Selasky u16 size; 1654b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter val; 1655b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter mask; 1656b5c1e0cbSHans Petter Selasky }; 1657b5c1e0cbSHans Petter Selasky 1658478d3005SHans Petter Selasky /* IPv4 header flags */ 1659478d3005SHans Petter Selasky enum ib_ipv4_flags { 1660478d3005SHans Petter Selasky IB_IPV4_DONT_FRAG = 0x2, /* Don't enable packet fragmentation */ 1661478d3005SHans Petter Selasky IB_IPV4_MORE_FRAG = 0X4 /* For All fragmented packets except the 1662478d3005SHans Petter Selasky last have this flag set */ 1663478d3005SHans Petter Selasky }; 1664478d3005SHans Petter Selasky 1665b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter { 1666c9f432b7SAlfred Perlstein __be32 src_ip; 1667c9f432b7SAlfred Perlstein __be32 dst_ip; 1668478d3005SHans Petter Selasky u8 proto; 1669478d3005SHans Petter Selasky u8 tos; 1670478d3005SHans Petter Selasky u8 ttl; 1671478d3005SHans Petter Selasky u8 flags; 1672478d3005SHans Petter Selasky /* Must be last */ 1673478d3005SHans Petter Selasky u8 real_sz[0]; 1674b5c1e0cbSHans Petter Selasky }; 1675b5c1e0cbSHans Petter Selasky 1676b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ipv4 { 1677b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1678b5c1e0cbSHans Petter Selasky u16 size; 1679b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter val; 1680b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter mask; 1681b5c1e0cbSHans Petter Selasky }; 1682b5c1e0cbSHans Petter Selasky 1683478d3005SHans Petter Selasky struct ib_flow_ipv6_filter { 1684478d3005SHans Petter Selasky u8 src_ip[16]; 1685478d3005SHans Petter Selasky u8 dst_ip[16]; 1686478d3005SHans Petter Selasky __be32 flow_label; 1687478d3005SHans Petter Selasky u8 next_hdr; 1688478d3005SHans Petter Selasky u8 traffic_class; 1689478d3005SHans Petter Selasky u8 hop_limit; 1690478d3005SHans Petter Selasky /* Must be last */ 1691478d3005SHans Petter Selasky u8 real_sz[0]; 1692478d3005SHans Petter Selasky }; 1693478d3005SHans Petter Selasky 1694478d3005SHans Petter Selasky struct ib_flow_spec_ipv6 { 1695478d3005SHans Petter Selasky enum ib_flow_spec_type type; 1696478d3005SHans Petter Selasky u16 size; 1697478d3005SHans Petter Selasky struct ib_flow_ipv6_filter val; 1698478d3005SHans Petter Selasky struct ib_flow_ipv6_filter mask; 1699478d3005SHans Petter Selasky }; 1700478d3005SHans Petter Selasky 1701b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter { 1702c9f432b7SAlfred Perlstein __be16 dst_port; 1703b5c1e0cbSHans Petter Selasky __be16 src_port; 1704478d3005SHans Petter Selasky /* Must be last */ 1705478d3005SHans Petter Selasky u8 real_sz[0]; 1706b5c1e0cbSHans Petter Selasky }; 1707b5c1e0cbSHans Petter Selasky 1708b5c1e0cbSHans Petter Selasky struct ib_flow_spec_tcp_udp { 1709b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1710b5c1e0cbSHans Petter Selasky u16 size; 1711b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter val; 1712b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter mask; 1713b5c1e0cbSHans Petter Selasky }; 1714b5c1e0cbSHans Petter Selasky 1715b5c1e0cbSHans Petter Selasky union ib_flow_spec { 1716b5c1e0cbSHans Petter Selasky struct { 1717b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1718b5c1e0cbSHans Petter Selasky u16 size; 1719b5c1e0cbSHans Petter Selasky }; 1720b5c1e0cbSHans Petter Selasky struct ib_flow_spec_eth eth; 1721478d3005SHans Petter Selasky struct ib_flow_spec_ib ib; 1722b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ipv4 ipv4; 1723b5c1e0cbSHans Petter Selasky struct ib_flow_spec_tcp_udp tcp_udp; 1724478d3005SHans Petter Selasky struct ib_flow_spec_ipv6 ipv6; 1725b5c1e0cbSHans Petter Selasky }; 1726b5c1e0cbSHans Petter Selasky 1727b5c1e0cbSHans Petter Selasky struct ib_flow_attr { 1728b5c1e0cbSHans Petter Selasky enum ib_flow_attr_type type; 1729b5c1e0cbSHans Petter Selasky u16 size; 1730b5c1e0cbSHans Petter Selasky u16 priority; 1731478d3005SHans Petter Selasky u32 flags; 1732b5c1e0cbSHans Petter Selasky u8 num_of_specs; 1733b5c1e0cbSHans Petter Selasky u8 port; 1734b5c1e0cbSHans Petter Selasky /* Following are the optional layers according to user request 1735b5c1e0cbSHans Petter Selasky * struct ib_flow_spec_xxx 1736b5c1e0cbSHans Petter Selasky * struct ib_flow_spec_yyy 1737b5c1e0cbSHans Petter Selasky */ 1738b5c1e0cbSHans Petter Selasky }; 1739b5c1e0cbSHans Petter Selasky 1740b5c1e0cbSHans Petter Selasky struct ib_flow { 1741b5c1e0cbSHans Petter Selasky struct ib_qp *qp; 1742b5c1e0cbSHans Petter Selasky struct ib_uobject *uobject; 1743c9f432b7SAlfred Perlstein }; 1744c9f432b7SAlfred Perlstein 1745478d3005SHans Petter Selasky struct ib_mad_hdr; 1746aa0a1e58SJeff Roberson struct ib_grh; 1747aa0a1e58SJeff Roberson 1748aa0a1e58SJeff Roberson enum ib_process_mad_flags { 1749aa0a1e58SJeff Roberson IB_MAD_IGNORE_MKEY = 1, 1750aa0a1e58SJeff Roberson IB_MAD_IGNORE_BKEY = 2, 1751aa0a1e58SJeff Roberson IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY 1752aa0a1e58SJeff Roberson }; 1753aa0a1e58SJeff Roberson 1754aa0a1e58SJeff Roberson enum ib_mad_result { 1755aa0a1e58SJeff Roberson IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */ 1756aa0a1e58SJeff Roberson IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */ 1757aa0a1e58SJeff Roberson IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */ 1758aa0a1e58SJeff Roberson IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */ 1759aa0a1e58SJeff Roberson }; 1760aa0a1e58SJeff Roberson 1761aa0a1e58SJeff Roberson #define IB_DEVICE_NAME_MAX 64 1762aa0a1e58SJeff Roberson 1763aa0a1e58SJeff Roberson struct ib_cache { 1764aa0a1e58SJeff Roberson rwlock_t lock; 1765aa0a1e58SJeff Roberson struct ib_event_handler event_handler; 1766aa0a1e58SJeff Roberson struct ib_pkey_cache **pkey_cache; 1767478d3005SHans Petter Selasky struct ib_gid_table **gid_cache; 1768aa0a1e58SJeff Roberson u8 *lmc_cache; 1769aa0a1e58SJeff Roberson }; 1770aa0a1e58SJeff Roberson 1771aa0a1e58SJeff Roberson struct ib_dma_mapping_ops { 1772aa0a1e58SJeff Roberson int (*mapping_error)(struct ib_device *dev, 1773aa0a1e58SJeff Roberson u64 dma_addr); 1774aa0a1e58SJeff Roberson u64 (*map_single)(struct ib_device *dev, 1775aa0a1e58SJeff Roberson void *ptr, size_t size, 1776aa0a1e58SJeff Roberson enum dma_data_direction direction); 1777aa0a1e58SJeff Roberson void (*unmap_single)(struct ib_device *dev, 1778aa0a1e58SJeff Roberson u64 addr, size_t size, 1779aa0a1e58SJeff Roberson enum dma_data_direction direction); 1780aa0a1e58SJeff Roberson u64 (*map_page)(struct ib_device *dev, 1781aa0a1e58SJeff Roberson struct page *page, unsigned long offset, 1782aa0a1e58SJeff Roberson size_t size, 1783aa0a1e58SJeff Roberson enum dma_data_direction direction); 1784aa0a1e58SJeff Roberson void (*unmap_page)(struct ib_device *dev, 1785aa0a1e58SJeff Roberson u64 addr, size_t size, 1786aa0a1e58SJeff Roberson enum dma_data_direction direction); 1787aa0a1e58SJeff Roberson int (*map_sg)(struct ib_device *dev, 1788aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 1789aa0a1e58SJeff Roberson enum dma_data_direction direction); 1790aa0a1e58SJeff Roberson void (*unmap_sg)(struct ib_device *dev, 1791aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 1792aa0a1e58SJeff Roberson enum dma_data_direction direction); 1793478d3005SHans Petter Selasky int (*map_sg_attrs)(struct ib_device *dev, 1794478d3005SHans Petter Selasky struct scatterlist *sg, int nents, 1795478d3005SHans Petter Selasky enum dma_data_direction direction, 1796478d3005SHans Petter Selasky struct dma_attrs *attrs); 1797478d3005SHans Petter Selasky void (*unmap_sg_attrs)(struct ib_device *dev, 1798478d3005SHans Petter Selasky struct scatterlist *sg, int nents, 1799478d3005SHans Petter Selasky enum dma_data_direction direction, 1800478d3005SHans Petter Selasky struct dma_attrs *attrs); 1801aa0a1e58SJeff Roberson void (*sync_single_for_cpu)(struct ib_device *dev, 1802aa0a1e58SJeff Roberson u64 dma_handle, 1803aa0a1e58SJeff Roberson size_t size, 1804aa0a1e58SJeff Roberson enum dma_data_direction dir); 1805aa0a1e58SJeff Roberson void (*sync_single_for_device)(struct ib_device *dev, 1806aa0a1e58SJeff Roberson u64 dma_handle, 1807aa0a1e58SJeff Roberson size_t size, 1808aa0a1e58SJeff Roberson enum dma_data_direction dir); 1809aa0a1e58SJeff Roberson void *(*alloc_coherent)(struct ib_device *dev, 1810aa0a1e58SJeff Roberson size_t size, 1811aa0a1e58SJeff Roberson u64 *dma_handle, 1812aa0a1e58SJeff Roberson gfp_t flag); 1813aa0a1e58SJeff Roberson void (*free_coherent)(struct ib_device *dev, 1814aa0a1e58SJeff Roberson size_t size, void *cpu_addr, 1815aa0a1e58SJeff Roberson u64 dma_handle); 1816aa0a1e58SJeff Roberson }; 1817aa0a1e58SJeff Roberson 1818aa0a1e58SJeff Roberson struct iw_cm_verbs; 1819478d3005SHans Petter Selasky 1820478d3005SHans Petter Selasky struct ib_port_immutable { 1821478d3005SHans Petter Selasky int pkey_tbl_len; 1822478d3005SHans Petter Selasky int gid_tbl_len; 1823478d3005SHans Petter Selasky u32 core_cap_flags; 1824478d3005SHans Petter Selasky u32 max_mad_size; 1825478d3005SHans Petter Selasky }; 1826aa0a1e58SJeff Roberson 1827aa0a1e58SJeff Roberson struct ib_device { 1828aa0a1e58SJeff Roberson struct device *dma_device; 1829aa0a1e58SJeff Roberson 1830aa0a1e58SJeff Roberson char name[IB_DEVICE_NAME_MAX]; 1831aa0a1e58SJeff Roberson 1832aa0a1e58SJeff Roberson struct list_head event_handler_list; 1833aa0a1e58SJeff Roberson spinlock_t event_handler_lock; 1834aa0a1e58SJeff Roberson 1835c9f432b7SAlfred Perlstein spinlock_t client_data_lock; 1836aa0a1e58SJeff Roberson struct list_head core_list; 1837478d3005SHans Petter Selasky /* Access to the client_data_list is protected by the client_data_lock 1838478d3005SHans Petter Selasky * spinlock and the lists_rwsem read-write semaphore */ 1839aa0a1e58SJeff Roberson struct list_head client_data_list; 1840aa0a1e58SJeff Roberson 1841aa0a1e58SJeff Roberson struct ib_cache cache; 1842478d3005SHans Petter Selasky /** 1843478d3005SHans Petter Selasky * port_immutable is indexed by port number 1844478d3005SHans Petter Selasky */ 1845478d3005SHans Petter Selasky struct ib_port_immutable *port_immutable; 1846aa0a1e58SJeff Roberson 1847aa0a1e58SJeff Roberson int num_comp_vectors; 1848aa0a1e58SJeff Roberson 1849aa0a1e58SJeff Roberson struct iw_cm_verbs *iwcm; 1850aa0a1e58SJeff Roberson 1851478d3005SHans Petter Selasky /** 1852478d3005SHans Petter Selasky * alloc_hw_stats - Allocate a struct rdma_hw_stats and fill in the 1853478d3005SHans Petter Selasky * driver initialized data. The struct is kfree()'ed by the sysfs 1854478d3005SHans Petter Selasky * core when the device is removed. A lifespan of -1 in the return 1855478d3005SHans Petter Selasky * struct tells the core to set a default lifespan. 1856478d3005SHans Petter Selasky */ 1857478d3005SHans Petter Selasky struct rdma_hw_stats *(*alloc_hw_stats)(struct ib_device *device, 1858478d3005SHans Petter Selasky u8 port_num); 1859478d3005SHans Petter Selasky /** 1860478d3005SHans Petter Selasky * get_hw_stats - Fill in the counter value(s) in the stats struct. 1861478d3005SHans Petter Selasky * @index - The index in the value array we wish to have updated, or 1862478d3005SHans Petter Selasky * num_counters if we want all stats updated 1863478d3005SHans Petter Selasky * Return codes - 1864478d3005SHans Petter Selasky * < 0 - Error, no counters updated 1865478d3005SHans Petter Selasky * index - Updated the single counter pointed to by index 1866478d3005SHans Petter Selasky * num_counters - Updated all counters (will reset the timestamp 1867478d3005SHans Petter Selasky * and prevent further calls for lifespan milliseconds) 1868478d3005SHans Petter Selasky * Drivers are allowed to update all counters in leiu of just the 1869478d3005SHans Petter Selasky * one given in index at their option 1870478d3005SHans Petter Selasky */ 1871478d3005SHans Petter Selasky int (*get_hw_stats)(struct ib_device *device, 1872478d3005SHans Petter Selasky struct rdma_hw_stats *stats, 1873478d3005SHans Petter Selasky u8 port, int index); 1874aa0a1e58SJeff Roberson int (*query_device)(struct ib_device *device, 1875478d3005SHans Petter Selasky struct ib_device_attr *device_attr, 1876478d3005SHans Petter Selasky struct ib_udata *udata); 1877aa0a1e58SJeff Roberson int (*query_port)(struct ib_device *device, 1878aa0a1e58SJeff Roberson u8 port_num, 1879aa0a1e58SJeff Roberson struct ib_port_attr *port_attr); 1880aa0a1e58SJeff Roberson enum rdma_link_layer (*get_link_layer)(struct ib_device *device, 1881aa0a1e58SJeff Roberson u8 port_num); 18820bab509bSHans Petter Selasky /* When calling get_netdev, the HW vendor's driver should return the 1883478d3005SHans Petter Selasky * net device of device @device at port @port_num or NULL if such 1884478d3005SHans Petter Selasky * a net device doesn't exist. The vendor driver should call dev_hold 1885478d3005SHans Petter Selasky * on this net device. The HW vendor's device driver must guarantee 1886478d3005SHans Petter Selasky * that this function returns NULL before the net device reaches 18870bab509bSHans Petter Selasky * NETDEV_UNREGISTER_FINAL state. 18880bab509bSHans Petter Selasky */ 18890bab509bSHans Petter Selasky struct net_device *(*get_netdev)(struct ib_device *device, 18900bab509bSHans Petter Selasky u8 port_num); 1891aa0a1e58SJeff Roberson int (*query_gid)(struct ib_device *device, 1892aa0a1e58SJeff Roberson u8 port_num, int index, 1893aa0a1e58SJeff Roberson union ib_gid *gid); 1894478d3005SHans Petter Selasky /* When calling add_gid, the HW vendor's driver should 1895478d3005SHans Petter Selasky * add the gid of device @device at gid index @index of 1896478d3005SHans Petter Selasky * port @port_num to be @gid. Meta-info of that gid (for example, 1897478d3005SHans Petter Selasky * the network device related to this gid is available 1898478d3005SHans Petter Selasky * at @attr. @context allows the HW vendor driver to store extra 1899478d3005SHans Petter Selasky * information together with a GID entry. The HW vendor may allocate 1900478d3005SHans Petter Selasky * memory to contain this information and store it in @context when a 1901478d3005SHans Petter Selasky * new GID entry is written to. Params are consistent until the next 1902478d3005SHans Petter Selasky * call of add_gid or delete_gid. The function should return 0 on 1903478d3005SHans Petter Selasky * success or error otherwise. The function could be called 1904478d3005SHans Petter Selasky * concurrently for different ports. This function is only called 1905478d3005SHans Petter Selasky * when roce_gid_table is used. 1906478d3005SHans Petter Selasky */ 1907478d3005SHans Petter Selasky int (*add_gid)(struct ib_device *device, 1908478d3005SHans Petter Selasky u8 port_num, 1909478d3005SHans Petter Selasky unsigned int index, 1910478d3005SHans Petter Selasky const union ib_gid *gid, 1911478d3005SHans Petter Selasky const struct ib_gid_attr *attr, 1912478d3005SHans Petter Selasky void **context); 1913478d3005SHans Petter Selasky /* When calling del_gid, the HW vendor's driver should delete the 1914478d3005SHans Petter Selasky * gid of device @device at gid index @index of port @port_num. 1915478d3005SHans Petter Selasky * Upon the deletion of a GID entry, the HW vendor must free any 1916478d3005SHans Petter Selasky * allocated memory. The caller will clear @context afterwards. 1917478d3005SHans Petter Selasky * This function is only called when roce_gid_table is used. 1918478d3005SHans Petter Selasky */ 1919478d3005SHans Petter Selasky int (*del_gid)(struct ib_device *device, 1920478d3005SHans Petter Selasky u8 port_num, 1921478d3005SHans Petter Selasky unsigned int index, 1922478d3005SHans Petter Selasky void **context); 1923aa0a1e58SJeff Roberson int (*query_pkey)(struct ib_device *device, 1924aa0a1e58SJeff Roberson u8 port_num, u16 index, u16 *pkey); 1925aa0a1e58SJeff Roberson int (*modify_device)(struct ib_device *device, 1926aa0a1e58SJeff Roberson int device_modify_mask, 1927aa0a1e58SJeff Roberson struct ib_device_modify *device_modify); 1928aa0a1e58SJeff Roberson int (*modify_port)(struct ib_device *device, 1929aa0a1e58SJeff Roberson u8 port_num, int port_modify_mask, 1930aa0a1e58SJeff Roberson struct ib_port_modify *port_modify); 1931aa0a1e58SJeff Roberson struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, 1932aa0a1e58SJeff Roberson struct ib_udata *udata); 1933aa0a1e58SJeff Roberson int (*dealloc_ucontext)(struct ib_ucontext *context); 1934aa0a1e58SJeff Roberson int (*mmap)(struct ib_ucontext *context, 1935aa0a1e58SJeff Roberson struct vm_area_struct *vma); 1936aa0a1e58SJeff Roberson struct ib_pd * (*alloc_pd)(struct ib_device *device, 1937aa0a1e58SJeff Roberson struct ib_ucontext *context, 1938aa0a1e58SJeff Roberson struct ib_udata *udata); 1939aa0a1e58SJeff Roberson int (*dealloc_pd)(struct ib_pd *pd); 1940aa0a1e58SJeff Roberson struct ib_ah * (*create_ah)(struct ib_pd *pd, 19411456d97cSHans Petter Selasky struct ib_ah_attr *ah_attr, 19421456d97cSHans Petter Selasky struct ib_udata *udata); 1943aa0a1e58SJeff Roberson int (*modify_ah)(struct ib_ah *ah, 1944aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 1945aa0a1e58SJeff Roberson int (*query_ah)(struct ib_ah *ah, 1946aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 1947aa0a1e58SJeff Roberson int (*destroy_ah)(struct ib_ah *ah); 1948aa0a1e58SJeff Roberson struct ib_srq * (*create_srq)(struct ib_pd *pd, 1949aa0a1e58SJeff Roberson struct ib_srq_init_attr *srq_init_attr, 1950aa0a1e58SJeff Roberson struct ib_udata *udata); 1951aa0a1e58SJeff Roberson int (*modify_srq)(struct ib_srq *srq, 1952aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr, 1953aa0a1e58SJeff Roberson enum ib_srq_attr_mask srq_attr_mask, 1954aa0a1e58SJeff Roberson struct ib_udata *udata); 1955aa0a1e58SJeff Roberson int (*query_srq)(struct ib_srq *srq, 1956aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr); 1957aa0a1e58SJeff Roberson int (*destroy_srq)(struct ib_srq *srq); 1958aa0a1e58SJeff Roberson int (*post_srq_recv)(struct ib_srq *srq, 1959aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 1960aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr); 1961aa0a1e58SJeff Roberson struct ib_qp * (*create_qp)(struct ib_pd *pd, 1962aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr, 1963aa0a1e58SJeff Roberson struct ib_udata *udata); 1964aa0a1e58SJeff Roberson int (*modify_qp)(struct ib_qp *qp, 1965aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 1966aa0a1e58SJeff Roberson int qp_attr_mask, 1967aa0a1e58SJeff Roberson struct ib_udata *udata); 1968aa0a1e58SJeff Roberson int (*query_qp)(struct ib_qp *qp, 1969aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 1970aa0a1e58SJeff Roberson int qp_attr_mask, 1971aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 1972aa0a1e58SJeff Roberson int (*destroy_qp)(struct ib_qp *qp); 1973aa0a1e58SJeff Roberson int (*post_send)(struct ib_qp *qp, 1974aa0a1e58SJeff Roberson struct ib_send_wr *send_wr, 1975aa0a1e58SJeff Roberson struct ib_send_wr **bad_send_wr); 1976aa0a1e58SJeff Roberson int (*post_recv)(struct ib_qp *qp, 1977aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 1978aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr); 1979b5c1e0cbSHans Petter Selasky struct ib_cq * (*create_cq)(struct ib_device *device, 1980478d3005SHans Petter Selasky const struct ib_cq_init_attr *attr, 1981aa0a1e58SJeff Roberson struct ib_ucontext *context, 1982aa0a1e58SJeff Roberson struct ib_udata *udata); 1983478d3005SHans Petter Selasky int (*modify_cq)(struct ib_cq *cq, u16 cq_count, 1984478d3005SHans Petter Selasky u16 cq_period); 1985aa0a1e58SJeff Roberson int (*destroy_cq)(struct ib_cq *cq); 1986aa0a1e58SJeff Roberson int (*resize_cq)(struct ib_cq *cq, int cqe, 1987aa0a1e58SJeff Roberson struct ib_udata *udata); 1988aa0a1e58SJeff Roberson int (*poll_cq)(struct ib_cq *cq, int num_entries, 1989aa0a1e58SJeff Roberson struct ib_wc *wc); 1990aa0a1e58SJeff Roberson int (*peek_cq)(struct ib_cq *cq, int wc_cnt); 1991aa0a1e58SJeff Roberson int (*req_notify_cq)(struct ib_cq *cq, 1992aa0a1e58SJeff Roberson enum ib_cq_notify_flags flags); 1993aa0a1e58SJeff Roberson int (*req_ncomp_notif)(struct ib_cq *cq, 1994aa0a1e58SJeff Roberson int wc_cnt); 1995aa0a1e58SJeff Roberson struct ib_mr * (*get_dma_mr)(struct ib_pd *pd, 1996aa0a1e58SJeff Roberson int mr_access_flags); 1997aa0a1e58SJeff Roberson struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, 1998aa0a1e58SJeff Roberson u64 start, u64 length, 1999aa0a1e58SJeff Roberson u64 virt_addr, 2000aa0a1e58SJeff Roberson int mr_access_flags, 2001478d3005SHans Petter Selasky struct ib_udata *udata); 2002478d3005SHans Petter Selasky int (*rereg_user_mr)(struct ib_mr *mr, 2003478d3005SHans Petter Selasky int flags, 2004478d3005SHans Petter Selasky u64 start, u64 length, 2005478d3005SHans Petter Selasky u64 virt_addr, 2006aa0a1e58SJeff Roberson int mr_access_flags, 2007478d3005SHans Petter Selasky struct ib_pd *pd, 2008478d3005SHans Petter Selasky struct ib_udata *udata); 2009478d3005SHans Petter Selasky int (*dereg_mr)(struct ib_mr *mr); 2010478d3005SHans Petter Selasky struct ib_mr * (*alloc_mr)(struct ib_pd *pd, 2011478d3005SHans Petter Selasky enum ib_mr_type mr_type, 2012478d3005SHans Petter Selasky u32 max_num_sg); 2013478d3005SHans Petter Selasky int (*map_mr_sg)(struct ib_mr *mr, 2014478d3005SHans Petter Selasky struct scatterlist *sg, 2015478d3005SHans Petter Selasky int sg_nents, 2016478d3005SHans Petter Selasky unsigned int *sg_offset); 2017b5c1e0cbSHans Petter Selasky struct ib_mw * (*alloc_mw)(struct ib_pd *pd, 2018478d3005SHans Petter Selasky enum ib_mw_type type, 2019478d3005SHans Petter Selasky struct ib_udata *udata); 2020aa0a1e58SJeff Roberson int (*dealloc_mw)(struct ib_mw *mw); 2021aa0a1e58SJeff Roberson struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd, 2022aa0a1e58SJeff Roberson int mr_access_flags, 2023aa0a1e58SJeff Roberson struct ib_fmr_attr *fmr_attr); 2024aa0a1e58SJeff Roberson int (*map_phys_fmr)(struct ib_fmr *fmr, 2025aa0a1e58SJeff Roberson u64 *page_list, int list_len, 2026aa0a1e58SJeff Roberson u64 iova); 2027aa0a1e58SJeff Roberson int (*unmap_fmr)(struct list_head *fmr_list); 2028aa0a1e58SJeff Roberson int (*dealloc_fmr)(struct ib_fmr *fmr); 2029aa0a1e58SJeff Roberson int (*attach_mcast)(struct ib_qp *qp, 2030aa0a1e58SJeff Roberson union ib_gid *gid, 2031aa0a1e58SJeff Roberson u16 lid); 2032aa0a1e58SJeff Roberson int (*detach_mcast)(struct ib_qp *qp, 2033aa0a1e58SJeff Roberson union ib_gid *gid, 2034aa0a1e58SJeff Roberson u16 lid); 2035aa0a1e58SJeff Roberson int (*process_mad)(struct ib_device *device, 2036aa0a1e58SJeff Roberson int process_mad_flags, 2037aa0a1e58SJeff Roberson u8 port_num, 2038478d3005SHans Petter Selasky const struct ib_wc *in_wc, 2039478d3005SHans Petter Selasky const struct ib_grh *in_grh, 2040478d3005SHans Petter Selasky const struct ib_mad_hdr *in_mad, 2041478d3005SHans Petter Selasky size_t in_mad_size, 2042478d3005SHans Petter Selasky struct ib_mad_hdr *out_mad, 2043478d3005SHans Petter Selasky size_t *out_mad_size, 2044478d3005SHans Petter Selasky u16 *out_mad_pkey_index); 2045aa0a1e58SJeff Roberson struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device, 2046c9f432b7SAlfred Perlstein struct ib_ucontext *ucontext, 2047aa0a1e58SJeff Roberson struct ib_udata *udata); 2048aa0a1e58SJeff Roberson int (*dealloc_xrcd)(struct ib_xrcd *xrcd); 2049b5c1e0cbSHans Petter Selasky struct ib_flow * (*create_flow)(struct ib_qp *qp, 2050b5c1e0cbSHans Petter Selasky struct ib_flow_attr 2051b5c1e0cbSHans Petter Selasky *flow_attr, 2052b5c1e0cbSHans Petter Selasky int domain); 2053b5c1e0cbSHans Petter Selasky int (*destroy_flow)(struct ib_flow *flow_id); 2054b5c1e0cbSHans Petter Selasky int (*check_mr_status)(struct ib_mr *mr, u32 check_mask, 2055b5c1e0cbSHans Petter Selasky struct ib_mr_status *mr_status); 2056478d3005SHans Petter Selasky void (*disassociate_ucontext)(struct ib_ucontext *ibcontext); 2057478d3005SHans Petter Selasky void (*drain_rq)(struct ib_qp *qp); 2058478d3005SHans Petter Selasky void (*drain_sq)(struct ib_qp *qp); 2059478d3005SHans Petter Selasky int (*set_vf_link_state)(struct ib_device *device, int vf, u8 port, 2060478d3005SHans Petter Selasky int state); 2061478d3005SHans Petter Selasky int (*get_vf_config)(struct ib_device *device, int vf, u8 port, 2062478d3005SHans Petter Selasky struct ifla_vf_info *ivf); 2063478d3005SHans Petter Selasky int (*get_vf_stats)(struct ib_device *device, int vf, u8 port, 2064478d3005SHans Petter Selasky struct ifla_vf_stats *stats); 2065478d3005SHans Petter Selasky int (*set_vf_guid)(struct ib_device *device, int vf, u8 port, u64 guid, 2066478d3005SHans Petter Selasky int type); 2067478d3005SHans Petter Selasky struct ib_wq * (*create_wq)(struct ib_pd *pd, 2068478d3005SHans Petter Selasky struct ib_wq_init_attr *init_attr, 2069478d3005SHans Petter Selasky struct ib_udata *udata); 2070478d3005SHans Petter Selasky int (*destroy_wq)(struct ib_wq *wq); 2071478d3005SHans Petter Selasky int (*modify_wq)(struct ib_wq *wq, 2072478d3005SHans Petter Selasky struct ib_wq_attr *attr, 2073478d3005SHans Petter Selasky u32 wq_attr_mask, 2074478d3005SHans Petter Selasky struct ib_udata *udata); 2075478d3005SHans Petter Selasky struct ib_rwq_ind_table * (*create_rwq_ind_table)(struct ib_device *device, 2076478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr *init_attr, 2077478d3005SHans Petter Selasky struct ib_udata *udata); 2078478d3005SHans Petter Selasky int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table); 2079aa0a1e58SJeff Roberson struct ib_dma_mapping_ops *dma_ops; 2080aa0a1e58SJeff Roberson 2081aa0a1e58SJeff Roberson struct module *owner; 2082aa0a1e58SJeff Roberson struct device dev; 2083aa0a1e58SJeff Roberson struct kobject *ports_parent; 2084aa0a1e58SJeff Roberson struct list_head port_list; 2085aa0a1e58SJeff Roberson 2086aa0a1e58SJeff Roberson enum { 2087aa0a1e58SJeff Roberson IB_DEV_UNINITIALIZED, 2088aa0a1e58SJeff Roberson IB_DEV_REGISTERED, 2089aa0a1e58SJeff Roberson IB_DEV_UNREGISTERED 2090aa0a1e58SJeff Roberson } reg_state; 2091aa0a1e58SJeff Roberson 2092aa0a1e58SJeff Roberson int uverbs_abi_ver; 2093c9f432b7SAlfred Perlstein u64 uverbs_cmd_mask; 2094b5c1e0cbSHans Petter Selasky u64 uverbs_ex_cmd_mask; 2095aa0a1e58SJeff Roberson 2096478d3005SHans Petter Selasky char node_desc[IB_DEVICE_NODE_DESC_MAX]; 2097aa0a1e58SJeff Roberson __be64 node_guid; 2098aa0a1e58SJeff Roberson u32 local_dma_lkey; 2099478d3005SHans Petter Selasky u16 is_switch:1; 2100aa0a1e58SJeff Roberson u8 node_type; 2101aa0a1e58SJeff Roberson u8 phys_port_cnt; 2102478d3005SHans Petter Selasky struct ib_device_attr attrs; 2103478d3005SHans Petter Selasky struct attribute_group *hw_stats_ag; 2104478d3005SHans Petter Selasky struct rdma_hw_stats *hw_stats; 2105b5c1e0cbSHans Petter Selasky 2106478d3005SHans Petter Selasky /** 2107478d3005SHans Petter Selasky * The following mandatory functions are used only at device 2108478d3005SHans Petter Selasky * registration. Keep functions such as these at the end of this 2109478d3005SHans Petter Selasky * structure to avoid cache line misses when accessing struct ib_device 2110478d3005SHans Petter Selasky * in fast paths. 2111b5c1e0cbSHans Petter Selasky */ 2112478d3005SHans Petter Selasky int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *); 2113478d3005SHans Petter Selasky void (*get_dev_fw_str)(struct ib_device *, char *str, size_t str_len); 2114aa0a1e58SJeff Roberson }; 2115aa0a1e58SJeff Roberson 2116aa0a1e58SJeff Roberson struct ib_client { 2117aa0a1e58SJeff Roberson char *name; 2118aa0a1e58SJeff Roberson void (*add) (struct ib_device *); 2119478d3005SHans Petter Selasky void (*remove)(struct ib_device *, void *client_data); 2120aa0a1e58SJeff Roberson 2121478d3005SHans Petter Selasky /* Returns the net_dev belonging to this ib_client and matching the 2122478d3005SHans Petter Selasky * given parameters. 2123478d3005SHans Petter Selasky * @dev: An RDMA device that the net_dev use for communication. 2124478d3005SHans Petter Selasky * @port: A physical port number on the RDMA device. 2125478d3005SHans Petter Selasky * @pkey: P_Key that the net_dev uses if applicable. 2126478d3005SHans Petter Selasky * @gid: A GID that the net_dev uses to communicate. 2127478d3005SHans Petter Selasky * @addr: An IP address the net_dev is configured with. 2128478d3005SHans Petter Selasky * @client_data: The device's client data set by ib_set_client_data(). 2129478d3005SHans Petter Selasky * 2130478d3005SHans Petter Selasky * An ib_client that implements a net_dev on top of RDMA devices 2131478d3005SHans Petter Selasky * (such as IP over IB) should implement this callback, allowing the 2132478d3005SHans Petter Selasky * rdma_cm module to find the right net_dev for a given request. 2133478d3005SHans Petter Selasky * 2134478d3005SHans Petter Selasky * The caller is responsible for calling dev_put on the returned 2135478d3005SHans Petter Selasky * netdev. */ 2136478d3005SHans Petter Selasky struct net_device *(*get_net_dev_by_params)( 2137478d3005SHans Petter Selasky struct ib_device *dev, 2138478d3005SHans Petter Selasky u8 port, 2139478d3005SHans Petter Selasky u16 pkey, 2140478d3005SHans Petter Selasky const union ib_gid *gid, 2141478d3005SHans Petter Selasky const struct sockaddr *addr, 2142478d3005SHans Petter Selasky void *client_data); 2143aa0a1e58SJeff Roberson struct list_head list; 2144aa0a1e58SJeff Roberson }; 2145aa0a1e58SJeff Roberson 2146aa0a1e58SJeff Roberson struct ib_device *ib_alloc_device(size_t size); 2147aa0a1e58SJeff Roberson void ib_dealloc_device(struct ib_device *device); 2148aa0a1e58SJeff Roberson 2149478d3005SHans Petter Selasky void ib_get_device_fw_str(struct ib_device *device, char *str, size_t str_len); 2150478d3005SHans Petter Selasky 2151c9f432b7SAlfred Perlstein int ib_register_device(struct ib_device *device, 2152c9f432b7SAlfred Perlstein int (*port_callback)(struct ib_device *, 2153c9f432b7SAlfred Perlstein u8, struct kobject *)); 2154aa0a1e58SJeff Roberson void ib_unregister_device(struct ib_device *device); 2155aa0a1e58SJeff Roberson 2156aa0a1e58SJeff Roberson int ib_register_client (struct ib_client *client); 2157aa0a1e58SJeff Roberson void ib_unregister_client(struct ib_client *client); 2158aa0a1e58SJeff Roberson 2159aa0a1e58SJeff Roberson void *ib_get_client_data(struct ib_device *device, struct ib_client *client); 2160aa0a1e58SJeff Roberson void ib_set_client_data(struct ib_device *device, struct ib_client *client, 2161aa0a1e58SJeff Roberson void *data); 2162aa0a1e58SJeff Roberson 2163aa0a1e58SJeff Roberson static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) 2164aa0a1e58SJeff Roberson { 2165478d3005SHans Petter Selasky return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; 2166aa0a1e58SJeff Roberson } 2167aa0a1e58SJeff Roberson 2168aa0a1e58SJeff Roberson static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) 2169aa0a1e58SJeff Roberson { 2170478d3005SHans Petter Selasky return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; 2171478d3005SHans Petter Selasky } 2172478d3005SHans Petter Selasky 2173478d3005SHans Petter Selasky static inline bool ib_is_udata_cleared(struct ib_udata *udata, 2174478d3005SHans Petter Selasky size_t offset, 2175478d3005SHans Petter Selasky size_t len) 2176478d3005SHans Petter Selasky { 2177478d3005SHans Petter Selasky const void __user *p = (const char __user *)udata->inbuf + offset; 2178478d3005SHans Petter Selasky bool ret; 2179478d3005SHans Petter Selasky u8 *buf; 2180478d3005SHans Petter Selasky 2181478d3005SHans Petter Selasky if (len > USHRT_MAX) 2182478d3005SHans Petter Selasky return false; 2183478d3005SHans Petter Selasky 2184478d3005SHans Petter Selasky buf = memdup_user(p, len); 2185478d3005SHans Petter Selasky if (IS_ERR(buf)) 2186478d3005SHans Petter Selasky return false; 2187478d3005SHans Petter Selasky 2188478d3005SHans Petter Selasky ret = !memchr_inv(buf, 0, len); 2189478d3005SHans Petter Selasky kfree(buf); 2190478d3005SHans Petter Selasky return ret; 2191aa0a1e58SJeff Roberson } 2192aa0a1e58SJeff Roberson 2193aa0a1e58SJeff Roberson /** 2194aa0a1e58SJeff Roberson * ib_modify_qp_is_ok - Check that the supplied attribute mask 2195aa0a1e58SJeff Roberson * contains all required attributes and no attributes not allowed for 2196aa0a1e58SJeff Roberson * the given QP state transition. 2197aa0a1e58SJeff Roberson * @cur_state: Current QP state 2198aa0a1e58SJeff Roberson * @next_state: Next QP state 2199aa0a1e58SJeff Roberson * @type: QP type 2200aa0a1e58SJeff Roberson * @mask: Mask of supplied QP attributes 2201b5c1e0cbSHans Petter Selasky * @ll : link layer of port 2202aa0a1e58SJeff Roberson * 2203aa0a1e58SJeff Roberson * This function is a helper function that a low-level driver's 2204aa0a1e58SJeff Roberson * modify_qp method can use to validate the consumer's input. It 2205aa0a1e58SJeff Roberson * checks that cur_state and next_state are valid QP states, that a 2206aa0a1e58SJeff Roberson * transition from cur_state to next_state is allowed by the IB spec, 2207aa0a1e58SJeff Roberson * and that the attribute mask supplied is allowed for the transition. 2208aa0a1e58SJeff Roberson */ 2209aa0a1e58SJeff Roberson int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, 2210b5c1e0cbSHans Petter Selasky enum ib_qp_type type, enum ib_qp_attr_mask mask, 2211b5c1e0cbSHans Petter Selasky enum rdma_link_layer ll); 2212aa0a1e58SJeff Roberson 2213aa0a1e58SJeff Roberson int ib_register_event_handler (struct ib_event_handler *event_handler); 2214aa0a1e58SJeff Roberson int ib_unregister_event_handler(struct ib_event_handler *event_handler); 2215aa0a1e58SJeff Roberson void ib_dispatch_event(struct ib_event *event); 2216aa0a1e58SJeff Roberson 2217aa0a1e58SJeff Roberson int ib_query_port(struct ib_device *device, 2218aa0a1e58SJeff Roberson u8 port_num, struct ib_port_attr *port_attr); 2219aa0a1e58SJeff Roberson 2220aa0a1e58SJeff Roberson enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, 2221aa0a1e58SJeff Roberson u8 port_num); 2222aa0a1e58SJeff Roberson 2223478d3005SHans Petter Selasky /** 2224478d3005SHans Petter Selasky * rdma_cap_ib_switch - Check if the device is IB switch 2225478d3005SHans Petter Selasky * @device: Device to check 2226478d3005SHans Petter Selasky * 2227478d3005SHans Petter Selasky * Device driver is responsible for setting is_switch bit on 2228478d3005SHans Petter Selasky * in ib_device structure at init time. 2229478d3005SHans Petter Selasky * 2230478d3005SHans Petter Selasky * Return: true if the device is IB switch. 2231478d3005SHans Petter Selasky */ 2232478d3005SHans Petter Selasky static inline bool rdma_cap_ib_switch(const struct ib_device *device) 2233478d3005SHans Petter Selasky { 2234478d3005SHans Petter Selasky return device->is_switch; 2235478d3005SHans Petter Selasky } 2236478d3005SHans Petter Selasky 2237478d3005SHans Petter Selasky /** 2238478d3005SHans Petter Selasky * rdma_start_port - Return the first valid port number for the device 2239478d3005SHans Petter Selasky * specified 2240478d3005SHans Petter Selasky * 2241478d3005SHans Petter Selasky * @device: Device to be checked 2242478d3005SHans Petter Selasky * 2243478d3005SHans Petter Selasky * Return start port number 2244478d3005SHans Petter Selasky */ 2245478d3005SHans Petter Selasky static inline u8 rdma_start_port(const struct ib_device *device) 2246478d3005SHans Petter Selasky { 2247478d3005SHans Petter Selasky return rdma_cap_ib_switch(device) ? 0 : 1; 2248478d3005SHans Petter Selasky } 2249478d3005SHans Petter Selasky 2250478d3005SHans Petter Selasky /** 2251478d3005SHans Petter Selasky * rdma_end_port - Return the last valid port number for the device 2252478d3005SHans Petter Selasky * specified 2253478d3005SHans Petter Selasky * 2254478d3005SHans Petter Selasky * @device: Device to be checked 2255478d3005SHans Petter Selasky * 2256478d3005SHans Petter Selasky * Return last port number 2257478d3005SHans Petter Selasky */ 2258478d3005SHans Petter Selasky static inline u8 rdma_end_port(const struct ib_device *device) 2259478d3005SHans Petter Selasky { 2260478d3005SHans Petter Selasky return rdma_cap_ib_switch(device) ? 0 : device->phys_port_cnt; 2261478d3005SHans Petter Selasky } 2262478d3005SHans Petter Selasky 2263478d3005SHans Petter Selasky static inline bool rdma_protocol_ib(const struct ib_device *device, u8 port_num) 2264478d3005SHans Petter Selasky { 2265478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB; 2266478d3005SHans Petter Selasky } 2267478d3005SHans Petter Selasky 2268478d3005SHans Petter Selasky static inline bool rdma_protocol_roce(const struct ib_device *device, u8 port_num) 2269478d3005SHans Petter Selasky { 2270478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & 2271478d3005SHans Petter Selasky (RDMA_CORE_CAP_PROT_ROCE | RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP); 2272478d3005SHans Petter Selasky } 2273478d3005SHans Petter Selasky 2274478d3005SHans Petter Selasky static inline bool rdma_protocol_roce_udp_encap(const struct ib_device *device, u8 port_num) 2275478d3005SHans Petter Selasky { 2276478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP; 2277478d3005SHans Petter Selasky } 2278478d3005SHans Petter Selasky 2279478d3005SHans Petter Selasky static inline bool rdma_protocol_roce_eth_encap(const struct ib_device *device, u8 port_num) 2280478d3005SHans Petter Selasky { 2281478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE; 2282478d3005SHans Petter Selasky } 2283478d3005SHans Petter Selasky 2284478d3005SHans Petter Selasky static inline bool rdma_protocol_iwarp(const struct ib_device *device, u8 port_num) 2285478d3005SHans Petter Selasky { 2286478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP; 2287478d3005SHans Petter Selasky } 2288478d3005SHans Petter Selasky 2289478d3005SHans Petter Selasky static inline bool rdma_ib_or_roce(const struct ib_device *device, u8 port_num) 2290478d3005SHans Petter Selasky { 2291478d3005SHans Petter Selasky return rdma_protocol_ib(device, port_num) || 2292478d3005SHans Petter Selasky rdma_protocol_roce(device, port_num); 2293478d3005SHans Petter Selasky } 2294478d3005SHans Petter Selasky 2295478d3005SHans Petter Selasky /** 2296478d3005SHans Petter Selasky * rdma_cap_ib_mad - Check if the port of a device supports Infiniband 2297478d3005SHans Petter Selasky * Management Datagrams. 2298478d3005SHans Petter Selasky * @device: Device to check 2299478d3005SHans Petter Selasky * @port_num: Port number to check 2300478d3005SHans Petter Selasky * 2301478d3005SHans Petter Selasky * Management Datagrams (MAD) are a required part of the InfiniBand 2302478d3005SHans Petter Selasky * specification and are supported on all InfiniBand devices. A slightly 2303478d3005SHans Petter Selasky * extended version are also supported on OPA interfaces. 2304478d3005SHans Petter Selasky * 2305478d3005SHans Petter Selasky * Return: true if the port supports sending/receiving of MAD packets. 2306478d3005SHans Petter Selasky */ 2307478d3005SHans Petter Selasky static inline bool rdma_cap_ib_mad(const struct ib_device *device, u8 port_num) 2308478d3005SHans Petter Selasky { 2309478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_MAD; 2310478d3005SHans Petter Selasky } 2311478d3005SHans Petter Selasky 2312478d3005SHans Petter Selasky /** 2313478d3005SHans Petter Selasky * rdma_cap_opa_mad - Check if the port of device provides support for OPA 2314478d3005SHans Petter Selasky * Management Datagrams. 2315478d3005SHans Petter Selasky * @device: Device to check 2316478d3005SHans Petter Selasky * @port_num: Port number to check 2317478d3005SHans Petter Selasky * 2318478d3005SHans Petter Selasky * Intel OmniPath devices extend and/or replace the InfiniBand Management 2319478d3005SHans Petter Selasky * datagrams with their own versions. These OPA MADs share many but not all of 2320478d3005SHans Petter Selasky * the characteristics of InfiniBand MADs. 2321478d3005SHans Petter Selasky * 2322478d3005SHans Petter Selasky * OPA MADs differ in the following ways: 2323478d3005SHans Petter Selasky * 2324478d3005SHans Petter Selasky * 1) MADs are variable size up to 2K 2325478d3005SHans Petter Selasky * IBTA defined MADs remain fixed at 256 bytes 2326478d3005SHans Petter Selasky * 2) OPA SMPs must carry valid PKeys 2327478d3005SHans Petter Selasky * 3) OPA SMP packets are a different format 2328478d3005SHans Petter Selasky * 2329478d3005SHans Petter Selasky * Return: true if the port supports OPA MAD packet formats. 2330478d3005SHans Petter Selasky */ 2331478d3005SHans Petter Selasky static inline bool rdma_cap_opa_mad(struct ib_device *device, u8 port_num) 2332478d3005SHans Petter Selasky { 2333478d3005SHans Petter Selasky return (device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_OPA_MAD) 2334478d3005SHans Petter Selasky == RDMA_CORE_CAP_OPA_MAD; 2335478d3005SHans Petter Selasky } 2336478d3005SHans Petter Selasky 2337478d3005SHans Petter Selasky /** 2338478d3005SHans Petter Selasky * rdma_cap_ib_smi - Check if the port of a device provides an Infiniband 2339478d3005SHans Petter Selasky * Subnet Management Agent (SMA) on the Subnet Management Interface (SMI). 2340478d3005SHans Petter Selasky * @device: Device to check 2341478d3005SHans Petter Selasky * @port_num: Port number to check 2342478d3005SHans Petter Selasky * 2343478d3005SHans Petter Selasky * Each InfiniBand node is required to provide a Subnet Management Agent 2344478d3005SHans Petter Selasky * that the subnet manager can access. Prior to the fabric being fully 2345478d3005SHans Petter Selasky * configured by the subnet manager, the SMA is accessed via a well known 2346478d3005SHans Petter Selasky * interface called the Subnet Management Interface (SMI). This interface 2347478d3005SHans Petter Selasky * uses directed route packets to communicate with the SM to get around the 2348478d3005SHans Petter Selasky * chicken and egg problem of the SM needing to know what's on the fabric 2349478d3005SHans Petter Selasky * in order to configure the fabric, and needing to configure the fabric in 2350478d3005SHans Petter Selasky * order to send packets to the devices on the fabric. These directed 2351478d3005SHans Petter Selasky * route packets do not need the fabric fully configured in order to reach 2352478d3005SHans Petter Selasky * their destination. The SMI is the only method allowed to send 2353478d3005SHans Petter Selasky * directed route packets on an InfiniBand fabric. 2354478d3005SHans Petter Selasky * 2355478d3005SHans Petter Selasky * Return: true if the port provides an SMI. 2356478d3005SHans Petter Selasky */ 2357478d3005SHans Petter Selasky static inline bool rdma_cap_ib_smi(const struct ib_device *device, u8 port_num) 2358478d3005SHans Petter Selasky { 2359478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SMI; 2360478d3005SHans Petter Selasky } 2361478d3005SHans Petter Selasky 2362478d3005SHans Petter Selasky /** 2363478d3005SHans Petter Selasky * rdma_cap_ib_cm - Check if the port of device has the capability Infiniband 2364478d3005SHans Petter Selasky * Communication Manager. 2365478d3005SHans Petter Selasky * @device: Device to check 2366478d3005SHans Petter Selasky * @port_num: Port number to check 2367478d3005SHans Petter Selasky * 2368478d3005SHans Petter Selasky * The InfiniBand Communication Manager is one of many pre-defined General 2369478d3005SHans Petter Selasky * Service Agents (GSA) that are accessed via the General Service 2370478d3005SHans Petter Selasky * Interface (GSI). It's role is to facilitate establishment of connections 2371478d3005SHans Petter Selasky * between nodes as well as other management related tasks for established 2372478d3005SHans Petter Selasky * connections. 2373478d3005SHans Petter Selasky * 2374478d3005SHans Petter Selasky * Return: true if the port supports an IB CM (this does not guarantee that 2375478d3005SHans Petter Selasky * a CM is actually running however). 2376478d3005SHans Petter Selasky */ 2377478d3005SHans Petter Selasky static inline bool rdma_cap_ib_cm(const struct ib_device *device, u8 port_num) 2378478d3005SHans Petter Selasky { 2379478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_CM; 2380478d3005SHans Petter Selasky } 2381478d3005SHans Petter Selasky 2382478d3005SHans Petter Selasky /** 2383478d3005SHans Petter Selasky * rdma_cap_iw_cm - Check if the port of device has the capability IWARP 2384478d3005SHans Petter Selasky * Communication Manager. 2385478d3005SHans Petter Selasky * @device: Device to check 2386478d3005SHans Petter Selasky * @port_num: Port number to check 2387478d3005SHans Petter Selasky * 2388478d3005SHans Petter Selasky * Similar to above, but specific to iWARP connections which have a different 2389478d3005SHans Petter Selasky * managment protocol than InfiniBand. 2390478d3005SHans Petter Selasky * 2391478d3005SHans Petter Selasky * Return: true if the port supports an iWARP CM (this does not guarantee that 2392478d3005SHans Petter Selasky * a CM is actually running however). 2393478d3005SHans Petter Selasky */ 2394478d3005SHans Petter Selasky static inline bool rdma_cap_iw_cm(const struct ib_device *device, u8 port_num) 2395478d3005SHans Petter Selasky { 2396478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IW_CM; 2397478d3005SHans Petter Selasky } 2398478d3005SHans Petter Selasky 2399478d3005SHans Petter Selasky /** 2400478d3005SHans Petter Selasky * rdma_cap_ib_sa - Check if the port of device has the capability Infiniband 2401478d3005SHans Petter Selasky * Subnet Administration. 2402478d3005SHans Petter Selasky * @device: Device to check 2403478d3005SHans Petter Selasky * @port_num: Port number to check 2404478d3005SHans Petter Selasky * 2405478d3005SHans Petter Selasky * An InfiniBand Subnet Administration (SA) service is a pre-defined General 2406478d3005SHans Petter Selasky * Service Agent (GSA) provided by the Subnet Manager (SM). On InfiniBand 2407478d3005SHans Petter Selasky * fabrics, devices should resolve routes to other hosts by contacting the 2408478d3005SHans Petter Selasky * SA to query the proper route. 2409478d3005SHans Petter Selasky * 2410478d3005SHans Petter Selasky * Return: true if the port should act as a client to the fabric Subnet 2411478d3005SHans Petter Selasky * Administration interface. This does not imply that the SA service is 2412478d3005SHans Petter Selasky * running locally. 2413478d3005SHans Petter Selasky */ 2414478d3005SHans Petter Selasky static inline bool rdma_cap_ib_sa(const struct ib_device *device, u8 port_num) 2415478d3005SHans Petter Selasky { 2416478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SA; 2417478d3005SHans Petter Selasky } 2418478d3005SHans Petter Selasky 2419478d3005SHans Petter Selasky /** 2420478d3005SHans Petter Selasky * rdma_cap_ib_mcast - Check if the port of device has the capability Infiniband 2421478d3005SHans Petter Selasky * Multicast. 2422478d3005SHans Petter Selasky * @device: Device to check 2423478d3005SHans Petter Selasky * @port_num: Port number to check 2424478d3005SHans Petter Selasky * 2425478d3005SHans Petter Selasky * InfiniBand multicast registration is more complex than normal IPv4 or 2426478d3005SHans Petter Selasky * IPv6 multicast registration. Each Host Channel Adapter must register 2427478d3005SHans Petter Selasky * with the Subnet Manager when it wishes to join a multicast group. It 2428478d3005SHans Petter Selasky * should do so only once regardless of how many queue pairs it subscribes 2429478d3005SHans Petter Selasky * to this group. And it should leave the group only after all queue pairs 2430478d3005SHans Petter Selasky * attached to the group have been detached. 2431478d3005SHans Petter Selasky * 2432478d3005SHans Petter Selasky * Return: true if the port must undertake the additional adminstrative 2433478d3005SHans Petter Selasky * overhead of registering/unregistering with the SM and tracking of the 2434478d3005SHans Petter Selasky * total number of queue pairs attached to the multicast group. 2435478d3005SHans Petter Selasky */ 2436478d3005SHans Petter Selasky static inline bool rdma_cap_ib_mcast(const struct ib_device *device, u8 port_num) 2437478d3005SHans Petter Selasky { 2438478d3005SHans Petter Selasky return rdma_cap_ib_sa(device, port_num); 2439478d3005SHans Petter Selasky } 2440478d3005SHans Petter Selasky 2441478d3005SHans Petter Selasky /** 2442478d3005SHans Petter Selasky * rdma_cap_af_ib - Check if the port of device has the capability 2443478d3005SHans Petter Selasky * Native Infiniband Address. 2444478d3005SHans Petter Selasky * @device: Device to check 2445478d3005SHans Petter Selasky * @port_num: Port number to check 2446478d3005SHans Petter Selasky * 2447478d3005SHans Petter Selasky * InfiniBand addressing uses a port's GUID + Subnet Prefix to make a default 2448478d3005SHans Petter Selasky * GID. RoCE uses a different mechanism, but still generates a GID via 2449478d3005SHans Petter Selasky * a prescribed mechanism and port specific data. 2450478d3005SHans Petter Selasky * 2451478d3005SHans Petter Selasky * Return: true if the port uses a GID address to identify devices on the 2452478d3005SHans Petter Selasky * network. 2453478d3005SHans Petter Selasky */ 2454478d3005SHans Petter Selasky static inline bool rdma_cap_af_ib(const struct ib_device *device, u8 port_num) 2455478d3005SHans Petter Selasky { 2456478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_AF_IB; 2457478d3005SHans Petter Selasky } 2458478d3005SHans Petter Selasky 2459478d3005SHans Petter Selasky /** 2460478d3005SHans Petter Selasky * rdma_cap_eth_ah - Check if the port of device has the capability 2461478d3005SHans Petter Selasky * Ethernet Address Handle. 2462478d3005SHans Petter Selasky * @device: Device to check 2463478d3005SHans Petter Selasky * @port_num: Port number to check 2464478d3005SHans Petter Selasky * 2465478d3005SHans Petter Selasky * RoCE is InfiniBand over Ethernet, and it uses a well defined technique 2466478d3005SHans Petter Selasky * to fabricate GIDs over Ethernet/IP specific addresses native to the 2467478d3005SHans Petter Selasky * port. Normally, packet headers are generated by the sending host 2468478d3005SHans Petter Selasky * adapter, but when sending connectionless datagrams, we must manually 2469478d3005SHans Petter Selasky * inject the proper headers for the fabric we are communicating over. 2470478d3005SHans Petter Selasky * 2471478d3005SHans Petter Selasky * Return: true if we are running as a RoCE port and must force the 2472478d3005SHans Petter Selasky * addition of a Global Route Header built from our Ethernet Address 2473478d3005SHans Petter Selasky * Handle into our header list for connectionless packets. 2474478d3005SHans Petter Selasky */ 2475478d3005SHans Petter Selasky static inline bool rdma_cap_eth_ah(const struct ib_device *device, u8 port_num) 2476478d3005SHans Petter Selasky { 2477478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_ETH_AH; 2478478d3005SHans Petter Selasky } 2479478d3005SHans Petter Selasky 2480478d3005SHans Petter Selasky /** 2481478d3005SHans Petter Selasky * rdma_max_mad_size - Return the max MAD size required by this RDMA Port. 2482478d3005SHans Petter Selasky * 2483478d3005SHans Petter Selasky * @device: Device 2484478d3005SHans Petter Selasky * @port_num: Port number 2485478d3005SHans Petter Selasky * 2486478d3005SHans Petter Selasky * This MAD size includes the MAD headers and MAD payload. No other headers 2487478d3005SHans Petter Selasky * are included. 2488478d3005SHans Petter Selasky * 2489478d3005SHans Petter Selasky * Return the max MAD size required by the Port. Will return 0 if the port 2490478d3005SHans Petter Selasky * does not support MADs 2491478d3005SHans Petter Selasky */ 2492478d3005SHans Petter Selasky static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_num) 2493478d3005SHans Petter Selasky { 2494478d3005SHans Petter Selasky return device->port_immutable[port_num].max_mad_size; 2495478d3005SHans Petter Selasky } 2496478d3005SHans Petter Selasky 2497478d3005SHans Petter Selasky /** 2498478d3005SHans Petter Selasky * rdma_cap_roce_gid_table - Check if the port of device uses roce_gid_table 2499478d3005SHans Petter Selasky * @device: Device to check 2500478d3005SHans Petter Selasky * @port_num: Port number to check 2501478d3005SHans Petter Selasky * 2502478d3005SHans Petter Selasky * RoCE GID table mechanism manages the various GIDs for a device. 2503478d3005SHans Petter Selasky * 2504478d3005SHans Petter Selasky * NOTE: if allocating the port's GID table has failed, this call will still 2505478d3005SHans Petter Selasky * return true, but any RoCE GID table API will fail. 2506478d3005SHans Petter Selasky * 2507478d3005SHans Petter Selasky * Return: true if the port uses RoCE GID table mechanism in order to manage 2508478d3005SHans Petter Selasky * its GIDs. 2509478d3005SHans Petter Selasky */ 2510478d3005SHans Petter Selasky static inline bool rdma_cap_roce_gid_table(const struct ib_device *device, 2511478d3005SHans Petter Selasky u8 port_num) 2512478d3005SHans Petter Selasky { 2513478d3005SHans Petter Selasky return rdma_protocol_roce(device, port_num) && 2514478d3005SHans Petter Selasky device->add_gid && device->del_gid; 2515478d3005SHans Petter Selasky } 2516478d3005SHans Petter Selasky 2517478d3005SHans Petter Selasky /* 2518478d3005SHans Petter Selasky * Check if the device supports READ W/ INVALIDATE. 2519478d3005SHans Petter Selasky */ 2520478d3005SHans Petter Selasky static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num) 2521478d3005SHans Petter Selasky { 2522478d3005SHans Petter Selasky /* 2523478d3005SHans Petter Selasky * iWarp drivers must support READ W/ INVALIDATE. No other protocol 2524478d3005SHans Petter Selasky * has support for it yet. 2525478d3005SHans Petter Selasky */ 2526478d3005SHans Petter Selasky return rdma_protocol_iwarp(dev, port_num); 2527478d3005SHans Petter Selasky } 2528478d3005SHans Petter Selasky 2529aa0a1e58SJeff Roberson int ib_query_gid(struct ib_device *device, 2530478d3005SHans Petter Selasky u8 port_num, int index, union ib_gid *gid, 2531478d3005SHans Petter Selasky struct ib_gid_attr *attr); 2532478d3005SHans Petter Selasky 2533478d3005SHans Petter Selasky int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port, 2534478d3005SHans Petter Selasky int state); 2535478d3005SHans Petter Selasky int ib_get_vf_config(struct ib_device *device, int vf, u8 port, 2536478d3005SHans Petter Selasky struct ifla_vf_info *info); 2537478d3005SHans Petter Selasky int ib_get_vf_stats(struct ib_device *device, int vf, u8 port, 2538478d3005SHans Petter Selasky struct ifla_vf_stats *stats); 2539478d3005SHans Petter Selasky int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid, 2540478d3005SHans Petter Selasky int type); 2541aa0a1e58SJeff Roberson 2542aa0a1e58SJeff Roberson int ib_query_pkey(struct ib_device *device, 2543aa0a1e58SJeff Roberson u8 port_num, u16 index, u16 *pkey); 2544aa0a1e58SJeff Roberson 2545aa0a1e58SJeff Roberson int ib_modify_device(struct ib_device *device, 2546aa0a1e58SJeff Roberson int device_modify_mask, 2547aa0a1e58SJeff Roberson struct ib_device_modify *device_modify); 2548aa0a1e58SJeff Roberson 2549aa0a1e58SJeff Roberson int ib_modify_port(struct ib_device *device, 2550aa0a1e58SJeff Roberson u8 port_num, int port_modify_mask, 2551aa0a1e58SJeff Roberson struct ib_port_modify *port_modify); 2552aa0a1e58SJeff Roberson 2553aa0a1e58SJeff Roberson int ib_find_gid(struct ib_device *device, union ib_gid *gid, 2554478d3005SHans Petter Selasky enum ib_gid_type gid_type, struct net_device *ndev, 2555aa0a1e58SJeff Roberson u8 *port_num, u16 *index); 2556aa0a1e58SJeff Roberson 2557aa0a1e58SJeff Roberson int ib_find_pkey(struct ib_device *device, 2558aa0a1e58SJeff Roberson u8 port_num, u16 pkey, u16 *index); 2559aa0a1e58SJeff Roberson 2560478d3005SHans Petter Selasky enum ib_pd_flags { 2561478d3005SHans Petter Selasky /* 2562478d3005SHans Petter Selasky * Create a memory registration for all memory in the system and place 2563478d3005SHans Petter Selasky * the rkey for it into pd->unsafe_global_rkey. This can be used by 2564478d3005SHans Petter Selasky * ULPs to avoid the overhead of dynamic MRs. 2565aa0a1e58SJeff Roberson * 2566478d3005SHans Petter Selasky * This flag is generally considered unsafe and must only be used in 2567478d3005SHans Petter Selasky * extremly trusted environments. Every use of it will log a warning 2568478d3005SHans Petter Selasky * in the kernel log. 2569aa0a1e58SJeff Roberson */ 2570478d3005SHans Petter Selasky IB_PD_UNSAFE_GLOBAL_RKEY = 0x01, 2571478d3005SHans Petter Selasky }; 2572aa0a1e58SJeff Roberson 2573478d3005SHans Petter Selasky struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, 2574478d3005SHans Petter Selasky const char *caller); 2575478d3005SHans Petter Selasky #define ib_alloc_pd(device, flags) \ 2576478d3005SHans Petter Selasky __ib_alloc_pd((device), (flags), __func__) 2577478d3005SHans Petter Selasky void ib_dealloc_pd(struct ib_pd *pd); 2578aa0a1e58SJeff Roberson 2579aa0a1e58SJeff Roberson /** 2580aa0a1e58SJeff Roberson * ib_create_ah - Creates an address handle for the given address vector. 2581aa0a1e58SJeff Roberson * @pd: The protection domain associated with the address handle. 2582aa0a1e58SJeff Roberson * @ah_attr: The attributes of the address vector. 2583aa0a1e58SJeff Roberson * 2584aa0a1e58SJeff Roberson * The address handle is used to reference a local or global destination 2585aa0a1e58SJeff Roberson * in all UD QP post sends. 2586aa0a1e58SJeff Roberson */ 2587aa0a1e58SJeff Roberson struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); 2588aa0a1e58SJeff Roberson 2589aa0a1e58SJeff Roberson /** 2590aa0a1e58SJeff Roberson * ib_init_ah_from_wc - Initializes address handle attributes from a 2591aa0a1e58SJeff Roberson * work completion. 2592aa0a1e58SJeff Roberson * @device: Device on which the received message arrived. 2593aa0a1e58SJeff Roberson * @port_num: Port on which the received message arrived. 2594aa0a1e58SJeff Roberson * @wc: Work completion associated with the received message. 2595aa0a1e58SJeff Roberson * @grh: References the received global route header. This parameter is 2596aa0a1e58SJeff Roberson * ignored unless the work completion indicates that the GRH is valid. 2597aa0a1e58SJeff Roberson * @ah_attr: Returned attributes that can be used when creating an address 2598aa0a1e58SJeff Roberson * handle for replying to the message. 2599aa0a1e58SJeff Roberson */ 2600478d3005SHans Petter Selasky int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, 2601478d3005SHans Petter Selasky const struct ib_wc *wc, const struct ib_grh *grh, 2602478d3005SHans Petter Selasky struct ib_ah_attr *ah_attr); 2603aa0a1e58SJeff Roberson 2604aa0a1e58SJeff Roberson /** 2605aa0a1e58SJeff Roberson * ib_create_ah_from_wc - Creates an address handle associated with the 2606aa0a1e58SJeff Roberson * sender of the specified work completion. 2607aa0a1e58SJeff Roberson * @pd: The protection domain associated with the address handle. 2608aa0a1e58SJeff Roberson * @wc: Work completion information associated with a received message. 2609aa0a1e58SJeff Roberson * @grh: References the received global route header. This parameter is 2610aa0a1e58SJeff Roberson * ignored unless the work completion indicates that the GRH is valid. 2611aa0a1e58SJeff Roberson * @port_num: The outbound port number to associate with the address. 2612aa0a1e58SJeff Roberson * 2613aa0a1e58SJeff Roberson * The address handle is used to reference a local or global destination 2614aa0a1e58SJeff Roberson * in all UD QP post sends. 2615aa0a1e58SJeff Roberson */ 2616478d3005SHans Petter Selasky struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc, 2617478d3005SHans Petter Selasky const struct ib_grh *grh, u8 port_num); 2618aa0a1e58SJeff Roberson 2619aa0a1e58SJeff Roberson /** 2620aa0a1e58SJeff Roberson * ib_modify_ah - Modifies the address vector associated with an address 2621aa0a1e58SJeff Roberson * handle. 2622aa0a1e58SJeff Roberson * @ah: The address handle to modify. 2623aa0a1e58SJeff Roberson * @ah_attr: The new address vector attributes to associate with the 2624aa0a1e58SJeff Roberson * address handle. 2625aa0a1e58SJeff Roberson */ 2626aa0a1e58SJeff Roberson int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 2627aa0a1e58SJeff Roberson 2628aa0a1e58SJeff Roberson /** 2629aa0a1e58SJeff Roberson * ib_query_ah - Queries the address vector associated with an address 2630aa0a1e58SJeff Roberson * handle. 2631aa0a1e58SJeff Roberson * @ah: The address handle to query. 2632aa0a1e58SJeff Roberson * @ah_attr: The address vector attributes associated with the address 2633aa0a1e58SJeff Roberson * handle. 2634aa0a1e58SJeff Roberson */ 2635aa0a1e58SJeff Roberson int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 2636aa0a1e58SJeff Roberson 2637aa0a1e58SJeff Roberson /** 2638aa0a1e58SJeff Roberson * ib_destroy_ah - Destroys an address handle. 2639aa0a1e58SJeff Roberson * @ah: The address handle to destroy. 2640aa0a1e58SJeff Roberson */ 2641aa0a1e58SJeff Roberson int ib_destroy_ah(struct ib_ah *ah); 2642aa0a1e58SJeff Roberson 2643aa0a1e58SJeff Roberson /** 2644c9f432b7SAlfred Perlstein * ib_create_srq - Creates a SRQ associated with the specified protection 2645c9f432b7SAlfred Perlstein * domain. 2646aa0a1e58SJeff Roberson * @pd: The protection domain associated with the SRQ. 2647aa0a1e58SJeff Roberson * @srq_init_attr: A list of initial attributes required to create the 2648aa0a1e58SJeff Roberson * SRQ. If SRQ creation succeeds, then the attributes are updated to 2649aa0a1e58SJeff Roberson * the actual capabilities of the created SRQ. 2650aa0a1e58SJeff Roberson * 2651aa0a1e58SJeff Roberson * srq_attr->max_wr and srq_attr->max_sge are read the determine the 2652aa0a1e58SJeff Roberson * requested size of the SRQ, and set to the actual values allocated 2653aa0a1e58SJeff Roberson * on return. If ib_create_srq() succeeds, then max_wr and max_sge 2654aa0a1e58SJeff Roberson * will always be at least as large as the requested values. 2655aa0a1e58SJeff Roberson */ 2656aa0a1e58SJeff Roberson struct ib_srq *ib_create_srq(struct ib_pd *pd, 2657aa0a1e58SJeff Roberson struct ib_srq_init_attr *srq_init_attr); 2658aa0a1e58SJeff Roberson 2659aa0a1e58SJeff Roberson /** 2660aa0a1e58SJeff Roberson * ib_modify_srq - Modifies the attributes for the specified SRQ. 2661aa0a1e58SJeff Roberson * @srq: The SRQ to modify. 2662aa0a1e58SJeff Roberson * @srq_attr: On input, specifies the SRQ attributes to modify. On output, 2663aa0a1e58SJeff Roberson * the current values of selected SRQ attributes are returned. 2664aa0a1e58SJeff Roberson * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ 2665aa0a1e58SJeff Roberson * are being modified. 2666aa0a1e58SJeff Roberson * 2667aa0a1e58SJeff Roberson * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or 2668aa0a1e58SJeff Roberson * IB_SRQ_LIMIT to set the SRQ's limit and request notification when 2669aa0a1e58SJeff Roberson * the number of receives queued drops below the limit. 2670aa0a1e58SJeff Roberson */ 2671aa0a1e58SJeff Roberson int ib_modify_srq(struct ib_srq *srq, 2672aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr, 2673aa0a1e58SJeff Roberson enum ib_srq_attr_mask srq_attr_mask); 2674aa0a1e58SJeff Roberson 2675aa0a1e58SJeff Roberson /** 2676aa0a1e58SJeff Roberson * ib_query_srq - Returns the attribute list and current values for the 2677aa0a1e58SJeff Roberson * specified SRQ. 2678aa0a1e58SJeff Roberson * @srq: The SRQ to query. 2679aa0a1e58SJeff Roberson * @srq_attr: The attributes of the specified SRQ. 2680aa0a1e58SJeff Roberson */ 2681aa0a1e58SJeff Roberson int ib_query_srq(struct ib_srq *srq, 2682aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr); 2683aa0a1e58SJeff Roberson 2684aa0a1e58SJeff Roberson /** 2685aa0a1e58SJeff Roberson * ib_destroy_srq - Destroys the specified SRQ. 2686aa0a1e58SJeff Roberson * @srq: The SRQ to destroy. 2687aa0a1e58SJeff Roberson */ 2688aa0a1e58SJeff Roberson int ib_destroy_srq(struct ib_srq *srq); 2689aa0a1e58SJeff Roberson 2690aa0a1e58SJeff Roberson /** 2691aa0a1e58SJeff Roberson * ib_post_srq_recv - Posts a list of work requests to the specified SRQ. 2692aa0a1e58SJeff Roberson * @srq: The SRQ to post the work request on. 2693aa0a1e58SJeff Roberson * @recv_wr: A list of work requests to post on the receive queue. 2694aa0a1e58SJeff Roberson * @bad_recv_wr: On an immediate failure, this parameter will reference 2695aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2696aa0a1e58SJeff Roberson */ 2697aa0a1e58SJeff Roberson static inline int ib_post_srq_recv(struct ib_srq *srq, 2698aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 2699aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr) 2700aa0a1e58SJeff Roberson { 2701aa0a1e58SJeff Roberson return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr); 2702aa0a1e58SJeff Roberson } 2703aa0a1e58SJeff Roberson 2704aa0a1e58SJeff Roberson /** 2705aa0a1e58SJeff Roberson * ib_create_qp - Creates a QP associated with the specified protection 2706aa0a1e58SJeff Roberson * domain. 2707aa0a1e58SJeff Roberson * @pd: The protection domain associated with the QP. 2708aa0a1e58SJeff Roberson * @qp_init_attr: A list of initial attributes required to create the 2709aa0a1e58SJeff Roberson * QP. If QP creation succeeds, then the attributes are updated to 2710aa0a1e58SJeff Roberson * the actual capabilities of the created QP. 2711aa0a1e58SJeff Roberson */ 2712aa0a1e58SJeff Roberson struct ib_qp *ib_create_qp(struct ib_pd *pd, 2713aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 2714aa0a1e58SJeff Roberson 2715aa0a1e58SJeff Roberson /** 2716aa0a1e58SJeff Roberson * ib_modify_qp - Modifies the attributes for the specified QP and then 2717aa0a1e58SJeff Roberson * transitions the QP to the given state. 2718aa0a1e58SJeff Roberson * @qp: The QP to modify. 2719aa0a1e58SJeff Roberson * @qp_attr: On input, specifies the QP attributes to modify. On output, 2720aa0a1e58SJeff Roberson * the current values of selected QP attributes are returned. 2721aa0a1e58SJeff Roberson * @qp_attr_mask: A bit-mask used to specify which attributes of the QP 2722aa0a1e58SJeff Roberson * are being modified. 2723aa0a1e58SJeff Roberson */ 2724aa0a1e58SJeff Roberson int ib_modify_qp(struct ib_qp *qp, 2725aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 2726aa0a1e58SJeff Roberson int qp_attr_mask); 2727aa0a1e58SJeff Roberson 2728aa0a1e58SJeff Roberson /** 2729aa0a1e58SJeff Roberson * ib_query_qp - Returns the attribute list and current values for the 2730aa0a1e58SJeff Roberson * specified QP. 2731aa0a1e58SJeff Roberson * @qp: The QP to query. 2732aa0a1e58SJeff Roberson * @qp_attr: The attributes of the specified QP. 2733aa0a1e58SJeff Roberson * @qp_attr_mask: A bit-mask used to select specific attributes to query. 2734aa0a1e58SJeff Roberson * @qp_init_attr: Additional attributes of the selected QP. 2735aa0a1e58SJeff Roberson * 2736aa0a1e58SJeff Roberson * The qp_attr_mask may be used to limit the query to gathering only the 2737aa0a1e58SJeff Roberson * selected attributes. 2738aa0a1e58SJeff Roberson */ 2739aa0a1e58SJeff Roberson int ib_query_qp(struct ib_qp *qp, 2740aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 2741aa0a1e58SJeff Roberson int qp_attr_mask, 2742aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 2743aa0a1e58SJeff Roberson 2744aa0a1e58SJeff Roberson /** 2745aa0a1e58SJeff Roberson * ib_destroy_qp - Destroys the specified QP. 2746aa0a1e58SJeff Roberson * @qp: The QP to destroy. 2747aa0a1e58SJeff Roberson */ 2748aa0a1e58SJeff Roberson int ib_destroy_qp(struct ib_qp *qp); 2749aa0a1e58SJeff Roberson 2750aa0a1e58SJeff Roberson /** 2751c9f432b7SAlfred Perlstein * ib_open_qp - Obtain a reference to an existing sharable QP. 2752c9f432b7SAlfred Perlstein * @xrcd - XRC domain 2753c9f432b7SAlfred Perlstein * @qp_open_attr: Attributes identifying the QP to open. 2754c9f432b7SAlfred Perlstein * 2755c9f432b7SAlfred Perlstein * Returns a reference to a sharable QP. 2756c9f432b7SAlfred Perlstein */ 2757c9f432b7SAlfred Perlstein struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd, 2758c9f432b7SAlfred Perlstein struct ib_qp_open_attr *qp_open_attr); 2759c9f432b7SAlfred Perlstein 2760c9f432b7SAlfred Perlstein /** 2761c9f432b7SAlfred Perlstein * ib_close_qp - Release an external reference to a QP. 2762c9f432b7SAlfred Perlstein * @qp: The QP handle to release 2763c9f432b7SAlfred Perlstein * 2764c9f432b7SAlfred Perlstein * The opened QP handle is released by the caller. The underlying 2765c9f432b7SAlfred Perlstein * shared QP is not destroyed until all internal references are released. 2766c9f432b7SAlfred Perlstein */ 2767c9f432b7SAlfred Perlstein int ib_close_qp(struct ib_qp *qp); 2768c9f432b7SAlfred Perlstein 2769c9f432b7SAlfred Perlstein /** 2770aa0a1e58SJeff Roberson * ib_post_send - Posts a list of work requests to the send queue of 2771aa0a1e58SJeff Roberson * the specified QP. 2772aa0a1e58SJeff Roberson * @qp: The QP to post the work request on. 2773aa0a1e58SJeff Roberson * @send_wr: A list of work requests to post on the send queue. 2774aa0a1e58SJeff Roberson * @bad_send_wr: On an immediate failure, this parameter will reference 2775aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2776c9f432b7SAlfred Perlstein * 2777c9f432b7SAlfred Perlstein * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate 2778c9f432b7SAlfred Perlstein * error is returned, the QP state shall not be affected, 2779c9f432b7SAlfred Perlstein * ib_post_send() will return an immediate error after queueing any 2780c9f432b7SAlfred Perlstein * earlier work requests in the list. 2781aa0a1e58SJeff Roberson */ 2782aa0a1e58SJeff Roberson static inline int ib_post_send(struct ib_qp *qp, 2783aa0a1e58SJeff Roberson struct ib_send_wr *send_wr, 2784aa0a1e58SJeff Roberson struct ib_send_wr **bad_send_wr) 2785aa0a1e58SJeff Roberson { 2786aa0a1e58SJeff Roberson return qp->device->post_send(qp, send_wr, bad_send_wr); 2787aa0a1e58SJeff Roberson } 2788aa0a1e58SJeff Roberson 2789aa0a1e58SJeff Roberson /** 2790aa0a1e58SJeff Roberson * ib_post_recv - Posts a list of work requests to the receive queue of 2791aa0a1e58SJeff Roberson * the specified QP. 2792aa0a1e58SJeff Roberson * @qp: The QP to post the work request on. 2793aa0a1e58SJeff Roberson * @recv_wr: A list of work requests to post on the receive queue. 2794aa0a1e58SJeff Roberson * @bad_recv_wr: On an immediate failure, this parameter will reference 2795aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2796aa0a1e58SJeff Roberson */ 2797aa0a1e58SJeff Roberson static inline int ib_post_recv(struct ib_qp *qp, 2798aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 2799aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr) 2800aa0a1e58SJeff Roberson { 2801aa0a1e58SJeff Roberson return qp->device->post_recv(qp, recv_wr, bad_recv_wr); 2802aa0a1e58SJeff Roberson } 2803aa0a1e58SJeff Roberson 2804478d3005SHans Petter Selasky struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, 2805478d3005SHans Petter Selasky int nr_cqe, int comp_vector, enum ib_poll_context poll_ctx); 2806478d3005SHans Petter Selasky void ib_free_cq(struct ib_cq *cq); 2807478d3005SHans Petter Selasky 2808aa0a1e58SJeff Roberson /** 2809aa0a1e58SJeff Roberson * ib_create_cq - Creates a CQ on the specified device. 2810aa0a1e58SJeff Roberson * @device: The device on which to create the CQ. 2811aa0a1e58SJeff Roberson * @comp_handler: A user-specified callback that is invoked when a 2812aa0a1e58SJeff Roberson * completion event occurs on the CQ. 2813aa0a1e58SJeff Roberson * @event_handler: A user-specified callback that is invoked when an 2814aa0a1e58SJeff Roberson * asynchronous event not associated with a completion occurs on the CQ. 2815aa0a1e58SJeff Roberson * @cq_context: Context associated with the CQ returned to the user via 2816aa0a1e58SJeff Roberson * the associated completion and event handlers. 2817478d3005SHans Petter Selasky * @cq_attr: The attributes the CQ should be created upon. 2818aa0a1e58SJeff Roberson * 2819aa0a1e58SJeff Roberson * Users can examine the cq structure to determine the actual CQ size. 2820aa0a1e58SJeff Roberson */ 2821aa0a1e58SJeff Roberson struct ib_cq *ib_create_cq(struct ib_device *device, 2822aa0a1e58SJeff Roberson ib_comp_handler comp_handler, 2823aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *), 2824478d3005SHans Petter Selasky void *cq_context, 2825478d3005SHans Petter Selasky const struct ib_cq_init_attr *cq_attr); 2826aa0a1e58SJeff Roberson 2827aa0a1e58SJeff Roberson /** 2828aa0a1e58SJeff Roberson * ib_resize_cq - Modifies the capacity of the CQ. 2829aa0a1e58SJeff Roberson * @cq: The CQ to resize. 2830aa0a1e58SJeff Roberson * @cqe: The minimum size of the CQ. 2831aa0a1e58SJeff Roberson * 2832aa0a1e58SJeff Roberson * Users can examine the cq structure to determine the actual CQ size. 2833aa0a1e58SJeff Roberson */ 2834aa0a1e58SJeff Roberson int ib_resize_cq(struct ib_cq *cq, int cqe); 2835aa0a1e58SJeff Roberson 2836aa0a1e58SJeff Roberson /** 2837478d3005SHans Petter Selasky * ib_modify_cq - Modifies moderation params of the CQ 2838aa0a1e58SJeff Roberson * @cq: The CQ to modify. 2839478d3005SHans Petter Selasky * @cq_count: number of CQEs that will trigger an event 2840478d3005SHans Petter Selasky * @cq_period: max period of time in usec before triggering an event 2841478d3005SHans Petter Selasky * 2842aa0a1e58SJeff Roberson */ 2843478d3005SHans Petter Selasky int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 2844aa0a1e58SJeff Roberson 2845aa0a1e58SJeff Roberson /** 2846aa0a1e58SJeff Roberson * ib_destroy_cq - Destroys the specified CQ. 2847aa0a1e58SJeff Roberson * @cq: The CQ to destroy. 2848aa0a1e58SJeff Roberson */ 2849aa0a1e58SJeff Roberson int ib_destroy_cq(struct ib_cq *cq); 2850aa0a1e58SJeff Roberson 2851aa0a1e58SJeff Roberson /** 2852aa0a1e58SJeff Roberson * ib_poll_cq - poll a CQ for completion(s) 2853aa0a1e58SJeff Roberson * @cq:the CQ being polled 2854aa0a1e58SJeff Roberson * @num_entries:maximum number of completions to return 2855aa0a1e58SJeff Roberson * @wc:array of at least @num_entries &struct ib_wc where completions 2856aa0a1e58SJeff Roberson * will be returned 2857aa0a1e58SJeff Roberson * 2858aa0a1e58SJeff Roberson * Poll a CQ for (possibly multiple) completions. If the return value 2859aa0a1e58SJeff Roberson * is < 0, an error occurred. If the return value is >= 0, it is the 2860aa0a1e58SJeff Roberson * number of completions returned. If the return value is 2861aa0a1e58SJeff Roberson * non-negative and < num_entries, then the CQ was emptied. 2862aa0a1e58SJeff Roberson */ 2863aa0a1e58SJeff Roberson static inline int ib_poll_cq(struct ib_cq *cq, int num_entries, 2864aa0a1e58SJeff Roberson struct ib_wc *wc) 2865aa0a1e58SJeff Roberson { 2866aa0a1e58SJeff Roberson return cq->device->poll_cq(cq, num_entries, wc); 2867aa0a1e58SJeff Roberson } 2868aa0a1e58SJeff Roberson 2869aa0a1e58SJeff Roberson /** 2870aa0a1e58SJeff Roberson * ib_peek_cq - Returns the number of unreaped completions currently 2871aa0a1e58SJeff Roberson * on the specified CQ. 2872aa0a1e58SJeff Roberson * @cq: The CQ to peek. 2873aa0a1e58SJeff Roberson * @wc_cnt: A minimum number of unreaped completions to check for. 2874aa0a1e58SJeff Roberson * 2875aa0a1e58SJeff Roberson * If the number of unreaped completions is greater than or equal to wc_cnt, 2876aa0a1e58SJeff Roberson * this function returns wc_cnt, otherwise, it returns the actual number of 2877aa0a1e58SJeff Roberson * unreaped completions. 2878aa0a1e58SJeff Roberson */ 2879aa0a1e58SJeff Roberson int ib_peek_cq(struct ib_cq *cq, int wc_cnt); 2880aa0a1e58SJeff Roberson 2881aa0a1e58SJeff Roberson /** 2882aa0a1e58SJeff Roberson * ib_req_notify_cq - Request completion notification on a CQ. 2883aa0a1e58SJeff Roberson * @cq: The CQ to generate an event for. 2884aa0a1e58SJeff Roberson * @flags: 2885aa0a1e58SJeff Roberson * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP 2886aa0a1e58SJeff Roberson * to request an event on the next solicited event or next work 2887aa0a1e58SJeff Roberson * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS 2888aa0a1e58SJeff Roberson * may also be |ed in to request a hint about missed events, as 2889aa0a1e58SJeff Roberson * described below. 2890aa0a1e58SJeff Roberson * 2891aa0a1e58SJeff Roberson * Return Value: 2892aa0a1e58SJeff Roberson * < 0 means an error occurred while requesting notification 2893aa0a1e58SJeff Roberson * == 0 means notification was requested successfully, and if 2894aa0a1e58SJeff Roberson * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events 2895aa0a1e58SJeff Roberson * were missed and it is safe to wait for another event. In 2896aa0a1e58SJeff Roberson * this case is it guaranteed that any work completions added 2897aa0a1e58SJeff Roberson * to the CQ since the last CQ poll will trigger a completion 2898aa0a1e58SJeff Roberson * notification event. 2899aa0a1e58SJeff Roberson * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed 2900aa0a1e58SJeff Roberson * in. It means that the consumer must poll the CQ again to 2901aa0a1e58SJeff Roberson * make sure it is empty to avoid missing an event because of a 2902aa0a1e58SJeff Roberson * race between requesting notification and an entry being 2903aa0a1e58SJeff Roberson * added to the CQ. This return value means it is possible 2904aa0a1e58SJeff Roberson * (but not guaranteed) that a work completion has been added 2905aa0a1e58SJeff Roberson * to the CQ since the last poll without triggering a 2906aa0a1e58SJeff Roberson * completion notification event. 2907aa0a1e58SJeff Roberson */ 2908aa0a1e58SJeff Roberson static inline int ib_req_notify_cq(struct ib_cq *cq, 2909aa0a1e58SJeff Roberson enum ib_cq_notify_flags flags) 2910aa0a1e58SJeff Roberson { 2911aa0a1e58SJeff Roberson return cq->device->req_notify_cq(cq, flags); 2912aa0a1e58SJeff Roberson } 2913aa0a1e58SJeff Roberson 2914aa0a1e58SJeff Roberson /** 2915aa0a1e58SJeff Roberson * ib_req_ncomp_notif - Request completion notification when there are 2916aa0a1e58SJeff Roberson * at least the specified number of unreaped completions on the CQ. 2917aa0a1e58SJeff Roberson * @cq: The CQ to generate an event for. 2918aa0a1e58SJeff Roberson * @wc_cnt: The number of unreaped completions that should be on the 2919aa0a1e58SJeff Roberson * CQ before an event is generated. 2920aa0a1e58SJeff Roberson */ 2921aa0a1e58SJeff Roberson static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt) 2922aa0a1e58SJeff Roberson { 2923aa0a1e58SJeff Roberson return cq->device->req_ncomp_notif ? 2924aa0a1e58SJeff Roberson cq->device->req_ncomp_notif(cq, wc_cnt) : 2925aa0a1e58SJeff Roberson -ENOSYS; 2926aa0a1e58SJeff Roberson } 2927aa0a1e58SJeff Roberson 2928aa0a1e58SJeff Roberson /** 2929aa0a1e58SJeff Roberson * ib_dma_mapping_error - check a DMA addr for error 2930aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr was created 2931aa0a1e58SJeff Roberson * @dma_addr: The DMA address to check 2932aa0a1e58SJeff Roberson */ 2933aa0a1e58SJeff Roberson static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) 2934aa0a1e58SJeff Roberson { 2935aa0a1e58SJeff Roberson if (dev->dma_ops) 2936aa0a1e58SJeff Roberson return dev->dma_ops->mapping_error(dev, dma_addr); 2937aa0a1e58SJeff Roberson return dma_mapping_error(dev->dma_device, dma_addr); 2938aa0a1e58SJeff Roberson } 2939aa0a1e58SJeff Roberson 2940aa0a1e58SJeff Roberson /** 2941aa0a1e58SJeff Roberson * ib_dma_map_single - Map a kernel virtual address to DMA address 2942aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr is to be created 2943aa0a1e58SJeff Roberson * @cpu_addr: The kernel virtual address 2944aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2945aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2946aa0a1e58SJeff Roberson */ 2947aa0a1e58SJeff Roberson static inline u64 ib_dma_map_single(struct ib_device *dev, 2948aa0a1e58SJeff Roberson void *cpu_addr, size_t size, 2949aa0a1e58SJeff Roberson enum dma_data_direction direction) 2950aa0a1e58SJeff Roberson { 2951aa0a1e58SJeff Roberson if (dev->dma_ops) 2952aa0a1e58SJeff Roberson return dev->dma_ops->map_single(dev, cpu_addr, size, direction); 2953aa0a1e58SJeff Roberson return dma_map_single(dev->dma_device, cpu_addr, size, direction); 2954aa0a1e58SJeff Roberson } 2955aa0a1e58SJeff Roberson 2956aa0a1e58SJeff Roberson /** 2957aa0a1e58SJeff Roberson * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single() 2958aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 2959aa0a1e58SJeff Roberson * @addr: The DMA address 2960aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2961aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2962aa0a1e58SJeff Roberson */ 2963aa0a1e58SJeff Roberson static inline void ib_dma_unmap_single(struct ib_device *dev, 2964aa0a1e58SJeff Roberson u64 addr, size_t size, 2965aa0a1e58SJeff Roberson enum dma_data_direction direction) 2966aa0a1e58SJeff Roberson { 2967aa0a1e58SJeff Roberson if (dev->dma_ops) 2968aa0a1e58SJeff Roberson dev->dma_ops->unmap_single(dev, addr, size, direction); 2969aa0a1e58SJeff Roberson else 2970aa0a1e58SJeff Roberson dma_unmap_single(dev->dma_device, addr, size, direction); 2971aa0a1e58SJeff Roberson } 2972aa0a1e58SJeff Roberson 2973aa0a1e58SJeff Roberson static inline u64 ib_dma_map_single_attrs(struct ib_device *dev, 2974aa0a1e58SJeff Roberson void *cpu_addr, size_t size, 2975aa0a1e58SJeff Roberson enum dma_data_direction direction, 2976478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 2977aa0a1e58SJeff Roberson { 2978aa0a1e58SJeff Roberson return dma_map_single_attrs(dev->dma_device, cpu_addr, size, 2979478d3005SHans Petter Selasky direction, dma_attrs); 2980aa0a1e58SJeff Roberson } 2981aa0a1e58SJeff Roberson 2982aa0a1e58SJeff Roberson static inline void ib_dma_unmap_single_attrs(struct ib_device *dev, 2983aa0a1e58SJeff Roberson u64 addr, size_t size, 2984aa0a1e58SJeff Roberson enum dma_data_direction direction, 2985478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 2986aa0a1e58SJeff Roberson { 2987aa0a1e58SJeff Roberson return dma_unmap_single_attrs(dev->dma_device, addr, size, 2988478d3005SHans Petter Selasky direction, dma_attrs); 2989aa0a1e58SJeff Roberson } 2990aa0a1e58SJeff Roberson 2991aa0a1e58SJeff Roberson /** 2992aa0a1e58SJeff Roberson * ib_dma_map_page - Map a physical page to DMA address 2993aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr is to be created 2994aa0a1e58SJeff Roberson * @page: The page to be mapped 2995aa0a1e58SJeff Roberson * @offset: The offset within the page 2996aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2997aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2998aa0a1e58SJeff Roberson */ 2999aa0a1e58SJeff Roberson static inline u64 ib_dma_map_page(struct ib_device *dev, 3000aa0a1e58SJeff Roberson struct page *page, 3001aa0a1e58SJeff Roberson unsigned long offset, 3002aa0a1e58SJeff Roberson size_t size, 3003aa0a1e58SJeff Roberson enum dma_data_direction direction) 3004aa0a1e58SJeff Roberson { 3005aa0a1e58SJeff Roberson if (dev->dma_ops) 3006aa0a1e58SJeff Roberson return dev->dma_ops->map_page(dev, page, offset, size, direction); 3007aa0a1e58SJeff Roberson return dma_map_page(dev->dma_device, page, offset, size, direction); 3008aa0a1e58SJeff Roberson } 3009aa0a1e58SJeff Roberson 3010aa0a1e58SJeff Roberson /** 3011aa0a1e58SJeff Roberson * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page() 3012aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3013aa0a1e58SJeff Roberson * @addr: The DMA address 3014aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3015aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3016aa0a1e58SJeff Roberson */ 3017aa0a1e58SJeff Roberson static inline void ib_dma_unmap_page(struct ib_device *dev, 3018aa0a1e58SJeff Roberson u64 addr, size_t size, 3019aa0a1e58SJeff Roberson enum dma_data_direction direction) 3020aa0a1e58SJeff Roberson { 3021aa0a1e58SJeff Roberson if (dev->dma_ops) 3022aa0a1e58SJeff Roberson dev->dma_ops->unmap_page(dev, addr, size, direction); 3023aa0a1e58SJeff Roberson else 3024aa0a1e58SJeff Roberson dma_unmap_page(dev->dma_device, addr, size, direction); 3025aa0a1e58SJeff Roberson } 3026aa0a1e58SJeff Roberson 3027aa0a1e58SJeff Roberson /** 3028aa0a1e58SJeff Roberson * ib_dma_map_sg - Map a scatter/gather list to DMA addresses 3029aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses are to be created 3030aa0a1e58SJeff Roberson * @sg: The array of scatter/gather entries 3031aa0a1e58SJeff Roberson * @nents: The number of scatter/gather entries 3032aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3033aa0a1e58SJeff Roberson */ 3034aa0a1e58SJeff Roberson static inline int ib_dma_map_sg(struct ib_device *dev, 3035aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3036aa0a1e58SJeff Roberson enum dma_data_direction direction) 3037aa0a1e58SJeff Roberson { 3038aa0a1e58SJeff Roberson if (dev->dma_ops) 3039aa0a1e58SJeff Roberson return dev->dma_ops->map_sg(dev, sg, nents, direction); 3040aa0a1e58SJeff Roberson return dma_map_sg(dev->dma_device, sg, nents, direction); 3041aa0a1e58SJeff Roberson } 3042aa0a1e58SJeff Roberson 3043aa0a1e58SJeff Roberson /** 3044aa0a1e58SJeff Roberson * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses 3045aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3046aa0a1e58SJeff Roberson * @sg: The array of scatter/gather entries 3047aa0a1e58SJeff Roberson * @nents: The number of scatter/gather entries 3048aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3049aa0a1e58SJeff Roberson */ 3050aa0a1e58SJeff Roberson static inline void ib_dma_unmap_sg(struct ib_device *dev, 3051aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3052aa0a1e58SJeff Roberson enum dma_data_direction direction) 3053aa0a1e58SJeff Roberson { 3054aa0a1e58SJeff Roberson if (dev->dma_ops) 3055aa0a1e58SJeff Roberson dev->dma_ops->unmap_sg(dev, sg, nents, direction); 3056aa0a1e58SJeff Roberson else 3057aa0a1e58SJeff Roberson dma_unmap_sg(dev->dma_device, sg, nents, direction); 3058aa0a1e58SJeff Roberson } 3059aa0a1e58SJeff Roberson 3060aa0a1e58SJeff Roberson static inline int ib_dma_map_sg_attrs(struct ib_device *dev, 3061aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3062aa0a1e58SJeff Roberson enum dma_data_direction direction, 3063478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 3064aa0a1e58SJeff Roberson { 3065478d3005SHans Petter Selasky if (dev->dma_ops) 3066478d3005SHans Petter Selasky return dev->dma_ops->map_sg_attrs(dev, sg, nents, direction, 3067478d3005SHans Petter Selasky dma_attrs); 3068478d3005SHans Petter Selasky else 3069478d3005SHans Petter Selasky return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, 3070478d3005SHans Petter Selasky dma_attrs); 3071aa0a1e58SJeff Roberson } 3072aa0a1e58SJeff Roberson 3073aa0a1e58SJeff Roberson static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, 3074aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3075aa0a1e58SJeff Roberson enum dma_data_direction direction, 3076478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 3077aa0a1e58SJeff Roberson { 3078478d3005SHans Petter Selasky if (dev->dma_ops) 3079478d3005SHans Petter Selasky return dev->dma_ops->unmap_sg_attrs(dev, sg, nents, direction, 3080478d3005SHans Petter Selasky dma_attrs); 3081478d3005SHans Petter Selasky else 3082478d3005SHans Petter Selasky dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, 3083478d3005SHans Petter Selasky dma_attrs); 3084aa0a1e58SJeff Roberson } 3085aa0a1e58SJeff Roberson /** 3086aa0a1e58SJeff Roberson * ib_sg_dma_address - Return the DMA address from a scatter/gather entry 3087aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3088aa0a1e58SJeff Roberson * @sg: The scatter/gather entry 3089478d3005SHans Petter Selasky * 3090478d3005SHans Petter Selasky * Note: this function is obsolete. To do: change all occurrences of 3091478d3005SHans Petter Selasky * ib_sg_dma_address() into sg_dma_address(). 3092aa0a1e58SJeff Roberson */ 3093aa0a1e58SJeff Roberson static inline u64 ib_sg_dma_address(struct ib_device *dev, 3094aa0a1e58SJeff Roberson struct scatterlist *sg) 3095aa0a1e58SJeff Roberson { 3096aa0a1e58SJeff Roberson return sg_dma_address(sg); 3097aa0a1e58SJeff Roberson } 3098aa0a1e58SJeff Roberson 3099aa0a1e58SJeff Roberson /** 3100aa0a1e58SJeff Roberson * ib_sg_dma_len - Return the DMA length from a scatter/gather entry 3101aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3102aa0a1e58SJeff Roberson * @sg: The scatter/gather entry 3103478d3005SHans Petter Selasky * 3104478d3005SHans Petter Selasky * Note: this function is obsolete. To do: change all occurrences of 3105478d3005SHans Petter Selasky * ib_sg_dma_len() into sg_dma_len(). 3106aa0a1e58SJeff Roberson */ 3107aa0a1e58SJeff Roberson static inline unsigned int ib_sg_dma_len(struct ib_device *dev, 3108aa0a1e58SJeff Roberson struct scatterlist *sg) 3109aa0a1e58SJeff Roberson { 3110aa0a1e58SJeff Roberson return sg_dma_len(sg); 3111aa0a1e58SJeff Roberson } 3112aa0a1e58SJeff Roberson 3113aa0a1e58SJeff Roberson /** 3114aa0a1e58SJeff Roberson * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU 3115aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3116aa0a1e58SJeff Roberson * @addr: The DMA address 3117aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3118aa0a1e58SJeff Roberson * @dir: The direction of the DMA 3119aa0a1e58SJeff Roberson */ 3120aa0a1e58SJeff Roberson static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev, 3121aa0a1e58SJeff Roberson u64 addr, 3122aa0a1e58SJeff Roberson size_t size, 3123aa0a1e58SJeff Roberson enum dma_data_direction dir) 3124aa0a1e58SJeff Roberson { 3125aa0a1e58SJeff Roberson if (dev->dma_ops) 3126aa0a1e58SJeff Roberson dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir); 3127aa0a1e58SJeff Roberson else 3128aa0a1e58SJeff Roberson dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); 3129aa0a1e58SJeff Roberson } 3130aa0a1e58SJeff Roberson 3131aa0a1e58SJeff Roberson /** 3132aa0a1e58SJeff Roberson * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device 3133aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3134aa0a1e58SJeff Roberson * @addr: The DMA address 3135aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3136aa0a1e58SJeff Roberson * @dir: The direction of the DMA 3137aa0a1e58SJeff Roberson */ 3138aa0a1e58SJeff Roberson static inline void ib_dma_sync_single_for_device(struct ib_device *dev, 3139aa0a1e58SJeff Roberson u64 addr, 3140aa0a1e58SJeff Roberson size_t size, 3141aa0a1e58SJeff Roberson enum dma_data_direction dir) 3142aa0a1e58SJeff Roberson { 3143aa0a1e58SJeff Roberson if (dev->dma_ops) 3144aa0a1e58SJeff Roberson dev->dma_ops->sync_single_for_device(dev, addr, size, dir); 3145aa0a1e58SJeff Roberson else 3146aa0a1e58SJeff Roberson dma_sync_single_for_device(dev->dma_device, addr, size, dir); 3147aa0a1e58SJeff Roberson } 3148aa0a1e58SJeff Roberson 3149aa0a1e58SJeff Roberson /** 3150aa0a1e58SJeff Roberson * ib_dma_alloc_coherent - Allocate memory and map it for DMA 3151aa0a1e58SJeff Roberson * @dev: The device for which the DMA address is requested 3152aa0a1e58SJeff Roberson * @size: The size of the region to allocate in bytes 3153aa0a1e58SJeff Roberson * @dma_handle: A pointer for returning the DMA address of the region 3154aa0a1e58SJeff Roberson * @flag: memory allocator flags 3155aa0a1e58SJeff Roberson */ 3156aa0a1e58SJeff Roberson static inline void *ib_dma_alloc_coherent(struct ib_device *dev, 3157aa0a1e58SJeff Roberson size_t size, 3158aa0a1e58SJeff Roberson u64 *dma_handle, 3159aa0a1e58SJeff Roberson gfp_t flag) 3160aa0a1e58SJeff Roberson { 3161aa0a1e58SJeff Roberson if (dev->dma_ops) 3162aa0a1e58SJeff Roberson return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag); 3163aa0a1e58SJeff Roberson else { 3164aa0a1e58SJeff Roberson dma_addr_t handle; 3165aa0a1e58SJeff Roberson void *ret; 3166aa0a1e58SJeff Roberson 3167aa0a1e58SJeff Roberson ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag); 3168aa0a1e58SJeff Roberson *dma_handle = handle; 3169aa0a1e58SJeff Roberson return ret; 3170aa0a1e58SJeff Roberson } 3171aa0a1e58SJeff Roberson } 3172aa0a1e58SJeff Roberson 3173aa0a1e58SJeff Roberson /** 3174aa0a1e58SJeff Roberson * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent() 3175aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were allocated 3176aa0a1e58SJeff Roberson * @size: The size of the region 3177aa0a1e58SJeff Roberson * @cpu_addr: the address returned by ib_dma_alloc_coherent() 3178aa0a1e58SJeff Roberson * @dma_handle: the DMA address returned by ib_dma_alloc_coherent() 3179aa0a1e58SJeff Roberson */ 3180aa0a1e58SJeff Roberson static inline void ib_dma_free_coherent(struct ib_device *dev, 3181aa0a1e58SJeff Roberson size_t size, void *cpu_addr, 3182aa0a1e58SJeff Roberson u64 dma_handle) 3183aa0a1e58SJeff Roberson { 3184aa0a1e58SJeff Roberson if (dev->dma_ops) 3185aa0a1e58SJeff Roberson dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 3186aa0a1e58SJeff Roberson else 3187aa0a1e58SJeff Roberson dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle); 3188aa0a1e58SJeff Roberson } 3189aa0a1e58SJeff Roberson 3190aa0a1e58SJeff Roberson /** 3191aa0a1e58SJeff Roberson * ib_dereg_mr - Deregisters a memory region and removes it from the 3192aa0a1e58SJeff Roberson * HCA translation table. 3193aa0a1e58SJeff Roberson * @mr: The memory region to deregister. 3194b5c1e0cbSHans Petter Selasky * 3195b5c1e0cbSHans Petter Selasky * This function can fail, if the memory region has memory windows bound to it. 3196aa0a1e58SJeff Roberson */ 3197aa0a1e58SJeff Roberson int ib_dereg_mr(struct ib_mr *mr); 3198aa0a1e58SJeff Roberson 3199478d3005SHans Petter Selasky struct ib_mr *ib_alloc_mr(struct ib_pd *pd, 3200478d3005SHans Petter Selasky enum ib_mr_type mr_type, 3201478d3005SHans Petter Selasky u32 max_num_sg); 3202aa0a1e58SJeff Roberson 3203aa0a1e58SJeff Roberson /** 3204aa0a1e58SJeff Roberson * ib_update_fast_reg_key - updates the key portion of the fast_reg MR 3205aa0a1e58SJeff Roberson * R_Key and L_Key. 3206aa0a1e58SJeff Roberson * @mr - struct ib_mr pointer to be updated. 3207aa0a1e58SJeff Roberson * @newkey - new key to be used. 3208aa0a1e58SJeff Roberson */ 3209aa0a1e58SJeff Roberson static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey) 3210aa0a1e58SJeff Roberson { 3211aa0a1e58SJeff Roberson mr->lkey = (mr->lkey & 0xffffff00) | newkey; 3212aa0a1e58SJeff Roberson mr->rkey = (mr->rkey & 0xffffff00) | newkey; 3213aa0a1e58SJeff Roberson } 3214aa0a1e58SJeff Roberson 3215aa0a1e58SJeff Roberson /** 3216b5c1e0cbSHans Petter Selasky * ib_inc_rkey - increments the key portion of the given rkey. Can be used 3217b5c1e0cbSHans Petter Selasky * for calculating a new rkey for type 2 memory windows. 3218b5c1e0cbSHans Petter Selasky * @rkey - the rkey to increment. 3219b5c1e0cbSHans Petter Selasky */ 3220b5c1e0cbSHans Petter Selasky static inline u32 ib_inc_rkey(u32 rkey) 3221b5c1e0cbSHans Petter Selasky { 3222b5c1e0cbSHans Petter Selasky const u32 mask = 0x000000ff; 3223b5c1e0cbSHans Petter Selasky return ((rkey + 1) & mask) | (rkey & ~mask); 3224b5c1e0cbSHans Petter Selasky } 3225b5c1e0cbSHans Petter Selasky 3226b5c1e0cbSHans Petter Selasky /** 3227aa0a1e58SJeff Roberson * ib_alloc_fmr - Allocates a unmapped fast memory region. 3228aa0a1e58SJeff Roberson * @pd: The protection domain associated with the unmapped region. 3229aa0a1e58SJeff Roberson * @mr_access_flags: Specifies the memory access rights. 3230aa0a1e58SJeff Roberson * @fmr_attr: Attributes of the unmapped region. 3231aa0a1e58SJeff Roberson * 3232aa0a1e58SJeff Roberson * A fast memory region must be mapped before it can be used as part of 3233aa0a1e58SJeff Roberson * a work request. 3234aa0a1e58SJeff Roberson */ 3235aa0a1e58SJeff Roberson struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd, 3236aa0a1e58SJeff Roberson int mr_access_flags, 3237aa0a1e58SJeff Roberson struct ib_fmr_attr *fmr_attr); 3238aa0a1e58SJeff Roberson 3239aa0a1e58SJeff Roberson /** 3240aa0a1e58SJeff Roberson * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region. 3241aa0a1e58SJeff Roberson * @fmr: The fast memory region to associate with the pages. 3242aa0a1e58SJeff Roberson * @page_list: An array of physical pages to map to the fast memory region. 3243aa0a1e58SJeff Roberson * @list_len: The number of pages in page_list. 3244aa0a1e58SJeff Roberson * @iova: The I/O virtual address to use with the mapped region. 3245aa0a1e58SJeff Roberson */ 3246aa0a1e58SJeff Roberson static inline int ib_map_phys_fmr(struct ib_fmr *fmr, 3247aa0a1e58SJeff Roberson u64 *page_list, int list_len, 3248aa0a1e58SJeff Roberson u64 iova) 3249aa0a1e58SJeff Roberson { 3250aa0a1e58SJeff Roberson return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova); 3251aa0a1e58SJeff Roberson } 3252aa0a1e58SJeff Roberson 3253aa0a1e58SJeff Roberson /** 3254aa0a1e58SJeff Roberson * ib_unmap_fmr - Removes the mapping from a list of fast memory regions. 3255aa0a1e58SJeff Roberson * @fmr_list: A linked list of fast memory regions to unmap. 3256aa0a1e58SJeff Roberson */ 3257aa0a1e58SJeff Roberson int ib_unmap_fmr(struct list_head *fmr_list); 3258aa0a1e58SJeff Roberson 3259aa0a1e58SJeff Roberson /** 3260aa0a1e58SJeff Roberson * ib_dealloc_fmr - Deallocates a fast memory region. 3261aa0a1e58SJeff Roberson * @fmr: The fast memory region to deallocate. 3262aa0a1e58SJeff Roberson */ 3263aa0a1e58SJeff Roberson int ib_dealloc_fmr(struct ib_fmr *fmr); 3264aa0a1e58SJeff Roberson 3265aa0a1e58SJeff Roberson /** 3266aa0a1e58SJeff Roberson * ib_attach_mcast - Attaches the specified QP to a multicast group. 3267aa0a1e58SJeff Roberson * @qp: QP to attach to the multicast group. The QP must be type 3268aa0a1e58SJeff Roberson * IB_QPT_UD. 3269aa0a1e58SJeff Roberson * @gid: Multicast group GID. 3270aa0a1e58SJeff Roberson * @lid: Multicast group LID in host byte order. 3271aa0a1e58SJeff Roberson * 3272aa0a1e58SJeff Roberson * In order to send and receive multicast packets, subnet 3273aa0a1e58SJeff Roberson * administration must have created the multicast group and configured 3274aa0a1e58SJeff Roberson * the fabric appropriately. The port associated with the specified 3275aa0a1e58SJeff Roberson * QP must also be a member of the multicast group. 3276aa0a1e58SJeff Roberson */ 3277aa0a1e58SJeff Roberson int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 3278aa0a1e58SJeff Roberson 3279aa0a1e58SJeff Roberson /** 3280aa0a1e58SJeff Roberson * ib_detach_mcast - Detaches the specified QP from a multicast group. 3281aa0a1e58SJeff Roberson * @qp: QP to detach from the multicast group. 3282aa0a1e58SJeff Roberson * @gid: Multicast group GID. 3283aa0a1e58SJeff Roberson * @lid: Multicast group LID in host byte order. 3284aa0a1e58SJeff Roberson */ 3285aa0a1e58SJeff Roberson int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 3286aa0a1e58SJeff Roberson 3287c9f432b7SAlfred Perlstein /** 3288c9f432b7SAlfred Perlstein * ib_alloc_xrcd - Allocates an XRC domain. 3289c9f432b7SAlfred Perlstein * @device: The device on which to allocate the XRC domain. 3290c9f432b7SAlfred Perlstein */ 3291c9f432b7SAlfred Perlstein struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device); 3292aa0a1e58SJeff Roberson 3293aa0a1e58SJeff Roberson /** 3294c9f432b7SAlfred Perlstein * ib_dealloc_xrcd - Deallocates an XRC domain. 3295c9f432b7SAlfred Perlstein * @xrcd: The XRC domain to deallocate. 3296aa0a1e58SJeff Roberson */ 3297aa0a1e58SJeff Roberson int ib_dealloc_xrcd(struct ib_xrcd *xrcd); 3298aa0a1e58SJeff Roberson 3299b5c1e0cbSHans Petter Selasky struct ib_flow *ib_create_flow(struct ib_qp *qp, 3300b5c1e0cbSHans Petter Selasky struct ib_flow_attr *flow_attr, int domain); 3301b5c1e0cbSHans Petter Selasky int ib_destroy_flow(struct ib_flow *flow_id); 3302b5c1e0cbSHans Petter Selasky 3303b5c1e0cbSHans Petter Selasky static inline int ib_check_mr_access(int flags) 3304b5c1e0cbSHans Petter Selasky { 3305b5c1e0cbSHans Petter Selasky /* 3306b5c1e0cbSHans Petter Selasky * Local write permission is required if remote write or 3307b5c1e0cbSHans Petter Selasky * remote atomic permission is also requested. 3308b5c1e0cbSHans Petter Selasky */ 3309b5c1e0cbSHans Petter Selasky if (flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) && 3310b5c1e0cbSHans Petter Selasky !(flags & IB_ACCESS_LOCAL_WRITE)) 3311b5c1e0cbSHans Petter Selasky return -EINVAL; 3312b5c1e0cbSHans Petter Selasky 3313b5c1e0cbSHans Petter Selasky return 0; 3314b5c1e0cbSHans Petter Selasky } 3315b5c1e0cbSHans Petter Selasky 3316b5c1e0cbSHans Petter Selasky /** 3317b5c1e0cbSHans Petter Selasky * ib_check_mr_status: lightweight check of MR status. 3318b5c1e0cbSHans Petter Selasky * This routine may provide status checks on a selected 3319b5c1e0cbSHans Petter Selasky * ib_mr. first use is for signature status check. 3320b5c1e0cbSHans Petter Selasky * 3321b5c1e0cbSHans Petter Selasky * @mr: A memory region. 3322b5c1e0cbSHans Petter Selasky * @check_mask: Bitmask of which checks to perform from 3323b5c1e0cbSHans Petter Selasky * ib_mr_status_check enumeration. 3324b5c1e0cbSHans Petter Selasky * @mr_status: The container of relevant status checks. 3325b5c1e0cbSHans Petter Selasky * failed checks will be indicated in the status bitmask 3326b5c1e0cbSHans Petter Selasky * and the relevant info shall be in the error item. 3327b5c1e0cbSHans Petter Selasky */ 3328b5c1e0cbSHans Petter Selasky int ib_check_mr_status(struct ib_mr *mr, u32 check_mask, 3329b5c1e0cbSHans Petter Selasky struct ib_mr_status *mr_status); 3330aa0a1e58SJeff Roberson 3331478d3005SHans Petter Selasky struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u8 port, 3332478d3005SHans Petter Selasky u16 pkey, const union ib_gid *gid, 3333478d3005SHans Petter Selasky const struct sockaddr *addr); 3334478d3005SHans Petter Selasky struct ib_wq *ib_create_wq(struct ib_pd *pd, 3335478d3005SHans Petter Selasky struct ib_wq_init_attr *init_attr); 3336478d3005SHans Petter Selasky int ib_destroy_wq(struct ib_wq *wq); 3337478d3005SHans Petter Selasky int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *attr, 3338478d3005SHans Petter Selasky u32 wq_attr_mask); 3339478d3005SHans Petter Selasky struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device, 3340478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr* 3341478d3005SHans Petter Selasky wq_ind_table_init_attr); 3342478d3005SHans Petter Selasky int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table); 3343478d3005SHans Petter Selasky 3344478d3005SHans Petter Selasky int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, 3345478d3005SHans Petter Selasky unsigned int *sg_offset, unsigned int page_size); 3346478d3005SHans Petter Selasky 3347478d3005SHans Petter Selasky static inline int 3348478d3005SHans Petter Selasky ib_map_mr_sg_zbva(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, 3349478d3005SHans Petter Selasky unsigned int *sg_offset, unsigned int page_size) 3350478d3005SHans Petter Selasky { 3351478d3005SHans Petter Selasky int n; 3352478d3005SHans Petter Selasky 3353478d3005SHans Petter Selasky n = ib_map_mr_sg(mr, sg, sg_nents, sg_offset, page_size); 3354478d3005SHans Petter Selasky mr->iova = 0; 3355478d3005SHans Petter Selasky 3356478d3005SHans Petter Selasky return n; 3357478d3005SHans Petter Selasky } 3358478d3005SHans Petter Selasky 3359478d3005SHans Petter Selasky int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents, 3360478d3005SHans Petter Selasky unsigned int *sg_offset, int (*set_page)(struct ib_mr *, u64)); 3361478d3005SHans Petter Selasky 3362478d3005SHans Petter Selasky void ib_drain_rq(struct ib_qp *qp); 3363478d3005SHans Petter Selasky void ib_drain_sq(struct ib_qp *qp); 3364478d3005SHans Petter Selasky void ib_drain_qp(struct ib_qp *qp); 33651456d97cSHans Petter Selasky 33661456d97cSHans Petter Selasky int ib_resolve_eth_dmac(struct ib_device *device, 33671456d97cSHans Petter Selasky struct ib_ah_attr *ah_attr); 3368aa0a1e58SJeff Roberson #endif /* IB_VERBS_H */ 3369