1aa0a1e58SJeff Roberson /* 2aa0a1e58SJeff Roberson * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. 3aa0a1e58SJeff Roberson * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 4aa0a1e58SJeff Roberson * Copyright (c) 2004 Intel Corporation. All rights reserved. 5aa0a1e58SJeff Roberson * Copyright (c) 2004 Topspin Corporation. All rights reserved. 6aa0a1e58SJeff Roberson * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 7aa0a1e58SJeff Roberson * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 8aa0a1e58SJeff Roberson * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. 9aa0a1e58SJeff Roberson * 10aa0a1e58SJeff Roberson * This software is available to you under a choice of one of two 11aa0a1e58SJeff Roberson * licenses. You may choose to be licensed under the terms of the GNU 12aa0a1e58SJeff Roberson * General Public License (GPL) Version 2, available from the file 13aa0a1e58SJeff Roberson * COPYING in the main directory of this source tree, or the 14aa0a1e58SJeff Roberson * OpenIB.org BSD license below: 15aa0a1e58SJeff Roberson * 16aa0a1e58SJeff Roberson * Redistribution and use in source and binary forms, with or 17aa0a1e58SJeff Roberson * without modification, are permitted provided that the following 18aa0a1e58SJeff Roberson * conditions are met: 19aa0a1e58SJeff Roberson * 20aa0a1e58SJeff Roberson * - Redistributions of source code must retain the above 21aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 22aa0a1e58SJeff Roberson * disclaimer. 23aa0a1e58SJeff Roberson * 24aa0a1e58SJeff Roberson * - Redistributions in binary form must reproduce the above 25aa0a1e58SJeff Roberson * copyright notice, this list of conditions and the following 26aa0a1e58SJeff Roberson * disclaimer in the documentation and/or other materials 27aa0a1e58SJeff Roberson * provided with the distribution. 28aa0a1e58SJeff Roberson * 29aa0a1e58SJeff Roberson * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30aa0a1e58SJeff Roberson * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31aa0a1e58SJeff Roberson * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 32aa0a1e58SJeff Roberson * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 33aa0a1e58SJeff Roberson * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 34aa0a1e58SJeff Roberson * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 35aa0a1e58SJeff Roberson * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36aa0a1e58SJeff Roberson * SOFTWARE. 37aa0a1e58SJeff Roberson */ 38aa0a1e58SJeff Roberson 39aa0a1e58SJeff Roberson #if !defined(IB_VERBS_H) 40aa0a1e58SJeff Roberson #define IB_VERBS_H 41aa0a1e58SJeff Roberson 42aa0a1e58SJeff Roberson #include <linux/types.h> 43aa0a1e58SJeff Roberson #include <linux/device.h> 44aa0a1e58SJeff Roberson #include <linux/mm.h> 45aa0a1e58SJeff Roberson #include <linux/dma-mapping.h> 46aa0a1e58SJeff Roberson #include <linux/kref.h> 47aa0a1e58SJeff Roberson #include <linux/list.h> 48aa0a1e58SJeff Roberson #include <linux/rwsem.h> 49aa0a1e58SJeff Roberson #include <linux/scatterlist.h> 50c9f432b7SAlfred Perlstein #include <linux/workqueue.h> 51*478d3005SHans Petter Selasky #include <linux/socket.h> 52b5c1e0cbSHans Petter Selasky #include <linux/if_ether.h> 53*478d3005SHans Petter Selasky #include <net/ipv6.h> 54*478d3005SHans Petter Selasky #include <net/ip.h> 55*478d3005SHans Petter Selasky #include <linux/string.h> 56*478d3005SHans Petter Selasky #include <linux/slab.h> 57*478d3005SHans Petter Selasky #include <linux/rcupdate.h> 58*478d3005SHans Petter Selasky #include <linux/netdevice.h> 59*478d3005SHans Petter Selasky #include <netinet/ip.h> 60aa0a1e58SJeff Roberson 61*478d3005SHans Petter Selasky #include <asm/atomic.h> 62aa0a1e58SJeff Roberson #include <asm/uaccess.h> 63aa0a1e58SJeff Roberson 64*478d3005SHans Petter Selasky struct ifla_vf_info; 65*478d3005SHans Petter Selasky struct ifla_vf_stats; 66*478d3005SHans Petter Selasky 67c9f432b7SAlfred Perlstein extern struct workqueue_struct *ib_wq; 68*478d3005SHans Petter Selasky extern struct workqueue_struct *ib_comp_wq; 69c9f432b7SAlfred Perlstein 70aa0a1e58SJeff Roberson union ib_gid { 71aa0a1e58SJeff Roberson u8 raw[16]; 72aa0a1e58SJeff Roberson struct { 73aa0a1e58SJeff Roberson __be64 subnet_prefix; 74aa0a1e58SJeff Roberson __be64 interface_id; 75aa0a1e58SJeff Roberson } global; 76aa0a1e58SJeff Roberson }; 77aa0a1e58SJeff Roberson 78*478d3005SHans Petter Selasky extern union ib_gid zgid; 79*478d3005SHans Petter Selasky 80*478d3005SHans Petter Selasky enum ib_gid_type { 81*478d3005SHans Petter Selasky /* If link layer is Ethernet, this is RoCE V1 */ 82*478d3005SHans Petter Selasky IB_GID_TYPE_IB = 0, 83*478d3005SHans Petter Selasky IB_GID_TYPE_ROCE = 0, 84*478d3005SHans Petter Selasky IB_GID_TYPE_ROCE_UDP_ENCAP = 1, 85*478d3005SHans Petter Selasky IB_GID_TYPE_SIZE 86*478d3005SHans Petter Selasky }; 87*478d3005SHans Petter Selasky 88*478d3005SHans Petter Selasky #define ROCE_V2_UDP_DPORT 4791 89*478d3005SHans Petter Selasky struct ib_gid_attr { 90*478d3005SHans Petter Selasky enum ib_gid_type gid_type; 91*478d3005SHans Petter Selasky struct net_device *ndev; 92*478d3005SHans Petter Selasky }; 93*478d3005SHans Petter Selasky 94aa0a1e58SJeff Roberson enum rdma_node_type { 95aa0a1e58SJeff Roberson /* IB values map to NodeInfo:NodeType. */ 96aa0a1e58SJeff Roberson RDMA_NODE_IB_CA = 1, 97aa0a1e58SJeff Roberson RDMA_NODE_IB_SWITCH, 98aa0a1e58SJeff Roberson RDMA_NODE_IB_ROUTER, 99b5c1e0cbSHans Petter Selasky RDMA_NODE_RNIC, 100*478d3005SHans Petter Selasky RDMA_NODE_USNIC, 101*478d3005SHans Petter Selasky RDMA_NODE_USNIC_UDP, 102*478d3005SHans Petter Selasky }; 103*478d3005SHans Petter Selasky 104*478d3005SHans Petter Selasky enum { 105*478d3005SHans Petter Selasky /* set the local administered indication */ 106*478d3005SHans Petter Selasky IB_SA_WELL_KNOWN_GUID = BIT_ULL(57) | 2, 107aa0a1e58SJeff Roberson }; 108aa0a1e58SJeff Roberson 109aa0a1e58SJeff Roberson enum rdma_transport_type { 110aa0a1e58SJeff Roberson RDMA_TRANSPORT_IB, 111b5c1e0cbSHans Petter Selasky RDMA_TRANSPORT_IWARP, 112*478d3005SHans Petter Selasky RDMA_TRANSPORT_USNIC, 113*478d3005SHans Petter Selasky RDMA_TRANSPORT_USNIC_UDP 114aa0a1e58SJeff Roberson }; 115aa0a1e58SJeff Roberson 116*478d3005SHans Petter Selasky enum rdma_protocol_type { 117*478d3005SHans Petter Selasky RDMA_PROTOCOL_IB, 118*478d3005SHans Petter Selasky RDMA_PROTOCOL_IBOE, 119*478d3005SHans Petter Selasky RDMA_PROTOCOL_IWARP, 120*478d3005SHans Petter Selasky RDMA_PROTOCOL_USNIC_UDP 121*478d3005SHans Petter Selasky }; 122*478d3005SHans Petter Selasky 123*478d3005SHans Petter Selasky __attribute_const__ enum rdma_transport_type 124*478d3005SHans Petter Selasky rdma_node_get_transport(enum rdma_node_type node_type); 125*478d3005SHans Petter Selasky 126*478d3005SHans Petter Selasky enum rdma_network_type { 127*478d3005SHans Petter Selasky RDMA_NETWORK_IB, 128*478d3005SHans Petter Selasky RDMA_NETWORK_ROCE_V1 = RDMA_NETWORK_IB, 129*478d3005SHans Petter Selasky RDMA_NETWORK_IPV4, 130*478d3005SHans Petter Selasky RDMA_NETWORK_IPV6 131*478d3005SHans Petter Selasky }; 132*478d3005SHans Petter Selasky 133*478d3005SHans Petter Selasky static inline enum ib_gid_type ib_network_to_gid_type(enum rdma_network_type network_type) 134*478d3005SHans Petter Selasky { 135*478d3005SHans Petter Selasky if (network_type == RDMA_NETWORK_IPV4 || 136*478d3005SHans Petter Selasky network_type == RDMA_NETWORK_IPV6) 137*478d3005SHans Petter Selasky return IB_GID_TYPE_ROCE_UDP_ENCAP; 138*478d3005SHans Petter Selasky 139*478d3005SHans Petter Selasky /* IB_GID_TYPE_IB same as RDMA_NETWORK_ROCE_V1 */ 140*478d3005SHans Petter Selasky return IB_GID_TYPE_IB; 141*478d3005SHans Petter Selasky } 142*478d3005SHans Petter Selasky 143*478d3005SHans Petter Selasky static inline enum rdma_network_type ib_gid_to_network_type(enum ib_gid_type gid_type, 144*478d3005SHans Petter Selasky union ib_gid *gid) 145*478d3005SHans Petter Selasky { 146*478d3005SHans Petter Selasky if (gid_type == IB_GID_TYPE_IB) 147*478d3005SHans Petter Selasky return RDMA_NETWORK_IB; 148*478d3005SHans Petter Selasky 149*478d3005SHans Petter Selasky if (ipv6_addr_v4mapped((struct in6_addr *)gid)) 150*478d3005SHans Petter Selasky return RDMA_NETWORK_IPV4; 151*478d3005SHans Petter Selasky else 152*478d3005SHans Petter Selasky return RDMA_NETWORK_IPV6; 153*478d3005SHans Petter Selasky } 154aa0a1e58SJeff Roberson 155aa0a1e58SJeff Roberson enum rdma_link_layer { 156aa0a1e58SJeff Roberson IB_LINK_LAYER_UNSPECIFIED, 157aa0a1e58SJeff Roberson IB_LINK_LAYER_INFINIBAND, 158aa0a1e58SJeff Roberson IB_LINK_LAYER_ETHERNET, 159aa0a1e58SJeff Roberson }; 160aa0a1e58SJeff Roberson 161aa0a1e58SJeff Roberson enum ib_device_cap_flags { 162*478d3005SHans Petter Selasky IB_DEVICE_RESIZE_MAX_WR = (1 << 0), 163aa0a1e58SJeff Roberson IB_DEVICE_BAD_PKEY_CNTR = (1 << 1), 164aa0a1e58SJeff Roberson IB_DEVICE_BAD_QKEY_CNTR = (1 << 2), 165aa0a1e58SJeff Roberson IB_DEVICE_RAW_MULTI = (1 << 3), 166aa0a1e58SJeff Roberson IB_DEVICE_AUTO_PATH_MIG = (1 << 4), 167aa0a1e58SJeff Roberson IB_DEVICE_CHANGE_PHY_PORT = (1 << 5), 168aa0a1e58SJeff Roberson IB_DEVICE_UD_AV_PORT_ENFORCE = (1 << 6), 169aa0a1e58SJeff Roberson IB_DEVICE_CURR_QP_STATE_MOD = (1 << 7), 170aa0a1e58SJeff Roberson IB_DEVICE_SHUTDOWN_PORT = (1 << 8), 171aa0a1e58SJeff Roberson IB_DEVICE_INIT_TYPE = (1 << 9), 172aa0a1e58SJeff Roberson IB_DEVICE_PORT_ACTIVE_EVENT = (1 << 10), 173aa0a1e58SJeff Roberson IB_DEVICE_SYS_IMAGE_GUID = (1 << 11), 174aa0a1e58SJeff Roberson IB_DEVICE_RC_RNR_NAK_GEN = (1 << 12), 175aa0a1e58SJeff Roberson IB_DEVICE_SRQ_RESIZE = (1 << 13), 176aa0a1e58SJeff Roberson IB_DEVICE_N_NOTIFY_CQ = (1 << 14), 177*478d3005SHans Petter Selasky 178*478d3005SHans Petter Selasky /* 179*478d3005SHans Petter Selasky * This device supports a per-device lkey or stag that can be 180*478d3005SHans Petter Selasky * used without performing a memory registration for the local 181*478d3005SHans Petter Selasky * memory. Note that ULPs should never check this flag, but 182*478d3005SHans Petter Selasky * instead of use the local_dma_lkey flag in the ib_pd structure, 183*478d3005SHans Petter Selasky * which will always contain a usable lkey. 184*478d3005SHans Petter Selasky */ 185aa0a1e58SJeff Roberson IB_DEVICE_LOCAL_DMA_LKEY = (1 << 15), 186*478d3005SHans Petter Selasky IB_DEVICE_RESERVED /* old SEND_W_INV */ = (1 << 16), 187aa0a1e58SJeff Roberson IB_DEVICE_MEM_WINDOW = (1 << 17), 188aa0a1e58SJeff Roberson /* 189aa0a1e58SJeff Roberson * Devices should set IB_DEVICE_UD_IP_SUM if they support 190aa0a1e58SJeff Roberson * insertion of UDP and TCP checksum on outgoing UD IPoIB 191aa0a1e58SJeff Roberson * messages and can verify the validity of checksum for 192aa0a1e58SJeff Roberson * incoming messages. Setting this flag implies that the 193aa0a1e58SJeff Roberson * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode. 194aa0a1e58SJeff Roberson */ 195aa0a1e58SJeff Roberson IB_DEVICE_UD_IP_CSUM = (1 << 18), 196aa0a1e58SJeff Roberson IB_DEVICE_UD_TSO = (1 << 19), 197aa0a1e58SJeff Roberson IB_DEVICE_XRC = (1 << 20), 198*478d3005SHans Petter Selasky 199*478d3005SHans Petter Selasky /* 200*478d3005SHans Petter Selasky * This device supports the IB "base memory management extension", 201*478d3005SHans Petter Selasky * which includes support for fast registrations (IB_WR_REG_MR, 202*478d3005SHans Petter Selasky * IB_WR_LOCAL_INV and IB_WR_SEND_WITH_INV verbs). This flag should 203*478d3005SHans Petter Selasky * also be set by any iWarp device which must support FRs to comply 204*478d3005SHans Petter Selasky * to the iWarp verbs spec. iWarp devices also support the 205*478d3005SHans Petter Selasky * IB_WR_RDMA_READ_WITH_INV verb for RDMA READs that invalidate the 206*478d3005SHans Petter Selasky * stag. 207*478d3005SHans Petter Selasky */ 208aa0a1e58SJeff Roberson IB_DEVICE_MEM_MGT_EXTENSIONS = (1 << 21), 209aa0a1e58SJeff Roberson IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1 << 22), 210*478d3005SHans Petter Selasky IB_DEVICE_MEM_WINDOW_TYPE_2A = (1 << 23), 211*478d3005SHans Petter Selasky IB_DEVICE_MEM_WINDOW_TYPE_2B = (1 << 24), 212*478d3005SHans Petter Selasky IB_DEVICE_RC_IP_CSUM = (1 << 25), 213*478d3005SHans Petter Selasky IB_DEVICE_RAW_IP_CSUM = (1 << 26), 214b5c1e0cbSHans Petter Selasky /* 215*478d3005SHans Petter Selasky * Devices should set IB_DEVICE_CROSS_CHANNEL if they 216*478d3005SHans Petter Selasky * support execution of WQEs that involve synchronization 217*478d3005SHans Petter Selasky * of I/O operations with single completion queue managed 218*478d3005SHans Petter Selasky * by hardware. 219b5c1e0cbSHans Petter Selasky */ 220*478d3005SHans Petter Selasky IB_DEVICE_CROSS_CHANNEL = (1 << 27), 221*478d3005SHans Petter Selasky IB_DEVICE_MANAGED_FLOW_STEERING = (1 << 29), 222*478d3005SHans Petter Selasky IB_DEVICE_SIGNATURE_HANDOVER = (1 << 30), 223*478d3005SHans Petter Selasky IB_DEVICE_ON_DEMAND_PAGING = (1ULL << 31), 224*478d3005SHans Petter Selasky IB_DEVICE_SG_GAPS_REG = (1ULL << 32), 225*478d3005SHans Petter Selasky IB_DEVICE_VIRTUAL_FUNCTION = (1ULL << 33), 226*478d3005SHans Petter Selasky IB_DEVICE_RAW_SCATTER_FCS = (1ULL << 34), 227b5c1e0cbSHans Petter Selasky }; 228b5c1e0cbSHans Petter Selasky 229b5c1e0cbSHans Petter Selasky enum ib_signature_prot_cap { 230b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_1 = 1, 231b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_2 = 1 << 1, 232b5c1e0cbSHans Petter Selasky IB_PROT_T10DIF_TYPE_3 = 1 << 2, 233b5c1e0cbSHans Petter Selasky }; 234b5c1e0cbSHans Petter Selasky 235b5c1e0cbSHans Petter Selasky enum ib_signature_guard_cap { 236b5c1e0cbSHans Petter Selasky IB_GUARD_T10DIF_CRC = 1, 237b5c1e0cbSHans Petter Selasky IB_GUARD_T10DIF_CSUM = 1 << 1, 238aa0a1e58SJeff Roberson }; 239aa0a1e58SJeff Roberson 240aa0a1e58SJeff Roberson enum ib_atomic_cap { 241aa0a1e58SJeff Roberson IB_ATOMIC_NONE, 242aa0a1e58SJeff Roberson IB_ATOMIC_HCA, 243aa0a1e58SJeff Roberson IB_ATOMIC_GLOB 244aa0a1e58SJeff Roberson }; 245aa0a1e58SJeff Roberson 246*478d3005SHans Petter Selasky enum ib_odp_general_cap_bits { 247*478d3005SHans Petter Selasky IB_ODP_SUPPORT = 1 << 0, 248*478d3005SHans Petter Selasky }; 249*478d3005SHans Petter Selasky 250*478d3005SHans Petter Selasky enum ib_odp_transport_cap_bits { 251*478d3005SHans Petter Selasky IB_ODP_SUPPORT_SEND = 1 << 0, 252*478d3005SHans Petter Selasky IB_ODP_SUPPORT_RECV = 1 << 1, 253*478d3005SHans Petter Selasky IB_ODP_SUPPORT_WRITE = 1 << 2, 254*478d3005SHans Petter Selasky IB_ODP_SUPPORT_READ = 1 << 3, 255*478d3005SHans Petter Selasky IB_ODP_SUPPORT_ATOMIC = 1 << 4, 256*478d3005SHans Petter Selasky }; 257*478d3005SHans Petter Selasky 258*478d3005SHans Petter Selasky struct ib_odp_caps { 259*478d3005SHans Petter Selasky uint64_t general_caps; 260*478d3005SHans Petter Selasky struct { 261*478d3005SHans Petter Selasky uint32_t rc_odp_caps; 262*478d3005SHans Petter Selasky uint32_t uc_odp_caps; 263*478d3005SHans Petter Selasky uint32_t ud_odp_caps; 264*478d3005SHans Petter Selasky } per_transport_caps; 265*478d3005SHans Petter Selasky }; 266*478d3005SHans Petter Selasky 267*478d3005SHans Petter Selasky struct ib_rss_caps { 268*478d3005SHans Petter Selasky /* Corresponding bit will be set if qp type from 269*478d3005SHans Petter Selasky * 'enum ib_qp_type' is supported, e.g. 270*478d3005SHans Petter Selasky * supported_qpts |= 1 << IB_QPT_UD 271*478d3005SHans Petter Selasky */ 272*478d3005SHans Petter Selasky u32 supported_qpts; 273*478d3005SHans Petter Selasky u32 max_rwq_indirection_tables; 274*478d3005SHans Petter Selasky u32 max_rwq_indirection_table_size; 275*478d3005SHans Petter Selasky }; 276*478d3005SHans Petter Selasky 277*478d3005SHans Petter Selasky enum ib_cq_creation_flags { 278*478d3005SHans Petter Selasky IB_CQ_FLAGS_TIMESTAMP_COMPLETION = 1 << 0, 279*478d3005SHans Petter Selasky IB_CQ_FLAGS_IGNORE_OVERRUN = 1 << 1, 280*478d3005SHans Petter Selasky }; 281*478d3005SHans Petter Selasky 282*478d3005SHans Petter Selasky struct ib_cq_init_attr { 283*478d3005SHans Petter Selasky unsigned int cqe; 284*478d3005SHans Petter Selasky int comp_vector; 285*478d3005SHans Petter Selasky u32 flags; 286b5c1e0cbSHans Petter Selasky }; 287b5c1e0cbSHans Petter Selasky 288aa0a1e58SJeff Roberson struct ib_device_attr { 289aa0a1e58SJeff Roberson u64 fw_ver; 290aa0a1e58SJeff Roberson __be64 sys_image_guid; 291aa0a1e58SJeff Roberson u64 max_mr_size; 292aa0a1e58SJeff Roberson u64 page_size_cap; 293aa0a1e58SJeff Roberson u32 vendor_id; 294aa0a1e58SJeff Roberson u32 vendor_part_id; 295aa0a1e58SJeff Roberson u32 hw_ver; 296aa0a1e58SJeff Roberson int max_qp; 297aa0a1e58SJeff Roberson int max_qp_wr; 298b5c1e0cbSHans Petter Selasky u64 device_cap_flags; 299aa0a1e58SJeff Roberson int max_sge; 300aa0a1e58SJeff Roberson int max_sge_rd; 301aa0a1e58SJeff Roberson int max_cq; 302aa0a1e58SJeff Roberson int max_cqe; 303aa0a1e58SJeff Roberson int max_mr; 304aa0a1e58SJeff Roberson int max_pd; 305aa0a1e58SJeff Roberson int max_qp_rd_atom; 306aa0a1e58SJeff Roberson int max_ee_rd_atom; 307aa0a1e58SJeff Roberson int max_res_rd_atom; 308aa0a1e58SJeff Roberson int max_qp_init_rd_atom; 309aa0a1e58SJeff Roberson int max_ee_init_rd_atom; 310aa0a1e58SJeff Roberson enum ib_atomic_cap atomic_cap; 311aa0a1e58SJeff Roberson enum ib_atomic_cap masked_atomic_cap; 312aa0a1e58SJeff Roberson int max_ee; 313aa0a1e58SJeff Roberson int max_rdd; 314aa0a1e58SJeff Roberson int max_mw; 315aa0a1e58SJeff Roberson int max_raw_ipv6_qp; 316aa0a1e58SJeff Roberson int max_raw_ethy_qp; 317aa0a1e58SJeff Roberson int max_mcast_grp; 318aa0a1e58SJeff Roberson int max_mcast_qp_attach; 319aa0a1e58SJeff Roberson int max_total_mcast_qp_attach; 320aa0a1e58SJeff Roberson int max_ah; 321aa0a1e58SJeff Roberson int max_fmr; 322aa0a1e58SJeff Roberson int max_map_per_fmr; 323aa0a1e58SJeff Roberson int max_srq; 324aa0a1e58SJeff Roberson int max_srq_wr; 325aa0a1e58SJeff Roberson int max_srq_sge; 326aa0a1e58SJeff Roberson unsigned int max_fast_reg_page_list_len; 327aa0a1e58SJeff Roberson u16 max_pkeys; 328aa0a1e58SJeff Roberson u8 local_ca_ack_delay; 329*478d3005SHans Petter Selasky int sig_prot_cap; 330*478d3005SHans Petter Selasky int sig_guard_cap; 331*478d3005SHans Petter Selasky struct ib_odp_caps odp_caps; 332b5c1e0cbSHans Petter Selasky uint64_t timestamp_mask; 333*478d3005SHans Petter Selasky uint64_t hca_core_clock; /* in KHZ */ 334*478d3005SHans Petter Selasky struct ib_rss_caps rss_caps; 335*478d3005SHans Petter Selasky u32 max_wq_type_rq; 336aa0a1e58SJeff Roberson }; 337aa0a1e58SJeff Roberson 338aa0a1e58SJeff Roberson enum ib_mtu { 339aa0a1e58SJeff Roberson IB_MTU_256 = 1, 340aa0a1e58SJeff Roberson IB_MTU_512 = 2, 341aa0a1e58SJeff Roberson IB_MTU_1024 = 3, 342aa0a1e58SJeff Roberson IB_MTU_2048 = 4, 343aa0a1e58SJeff Roberson IB_MTU_4096 = 5 344aa0a1e58SJeff Roberson }; 345aa0a1e58SJeff Roberson 346aa0a1e58SJeff Roberson static inline int ib_mtu_enum_to_int(enum ib_mtu mtu) 347aa0a1e58SJeff Roberson { 348aa0a1e58SJeff Roberson switch (mtu) { 349aa0a1e58SJeff Roberson case IB_MTU_256: return 256; 350aa0a1e58SJeff Roberson case IB_MTU_512: return 512; 351aa0a1e58SJeff Roberson case IB_MTU_1024: return 1024; 352aa0a1e58SJeff Roberson case IB_MTU_2048: return 2048; 353aa0a1e58SJeff Roberson case IB_MTU_4096: return 4096; 354aa0a1e58SJeff Roberson default: return -1; 355aa0a1e58SJeff Roberson } 356aa0a1e58SJeff Roberson } 357aa0a1e58SJeff Roberson 358aa0a1e58SJeff Roberson enum ib_port_state { 359aa0a1e58SJeff Roberson IB_PORT_NOP = 0, 360aa0a1e58SJeff Roberson IB_PORT_DOWN = 1, 361aa0a1e58SJeff Roberson IB_PORT_INIT = 2, 362aa0a1e58SJeff Roberson IB_PORT_ARMED = 3, 363aa0a1e58SJeff Roberson IB_PORT_ACTIVE = 4, 364b5c1e0cbSHans Petter Selasky IB_PORT_ACTIVE_DEFER = 5, 365*478d3005SHans Petter Selasky IB_PORT_DUMMY = -1, /* force enum signed */ 366aa0a1e58SJeff Roberson }; 367aa0a1e58SJeff Roberson 368aa0a1e58SJeff Roberson enum ib_port_cap_flags { 369aa0a1e58SJeff Roberson IB_PORT_SM = 1 << 1, 370aa0a1e58SJeff Roberson IB_PORT_NOTICE_SUP = 1 << 2, 371aa0a1e58SJeff Roberson IB_PORT_TRAP_SUP = 1 << 3, 372aa0a1e58SJeff Roberson IB_PORT_OPT_IPD_SUP = 1 << 4, 373aa0a1e58SJeff Roberson IB_PORT_AUTO_MIGR_SUP = 1 << 5, 374aa0a1e58SJeff Roberson IB_PORT_SL_MAP_SUP = 1 << 6, 375aa0a1e58SJeff Roberson IB_PORT_MKEY_NVRAM = 1 << 7, 376aa0a1e58SJeff Roberson IB_PORT_PKEY_NVRAM = 1 << 8, 377aa0a1e58SJeff Roberson IB_PORT_LED_INFO_SUP = 1 << 9, 378aa0a1e58SJeff Roberson IB_PORT_SM_DISABLED = 1 << 10, 379aa0a1e58SJeff Roberson IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, 380aa0a1e58SJeff Roberson IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, 381c9f432b7SAlfred Perlstein IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, 382aa0a1e58SJeff Roberson IB_PORT_CM_SUP = 1 << 16, 383aa0a1e58SJeff Roberson IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, 384aa0a1e58SJeff Roberson IB_PORT_REINIT_SUP = 1 << 18, 385aa0a1e58SJeff Roberson IB_PORT_DEVICE_MGMT_SUP = 1 << 19, 386aa0a1e58SJeff Roberson IB_PORT_VENDOR_CLASS_SUP = 1 << 20, 387aa0a1e58SJeff Roberson IB_PORT_DR_NOTICE_SUP = 1 << 21, 388aa0a1e58SJeff Roberson IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, 389aa0a1e58SJeff Roberson IB_PORT_BOOT_MGMT_SUP = 1 << 23, 390aa0a1e58SJeff Roberson IB_PORT_LINK_LATENCY_SUP = 1 << 24, 391*478d3005SHans Petter Selasky IB_PORT_CLIENT_REG_SUP = 1 << 25, 392*478d3005SHans Petter Selasky IB_PORT_IP_BASED_GIDS = 1 << 26, 393aa0a1e58SJeff Roberson }; 394aa0a1e58SJeff Roberson 395aa0a1e58SJeff Roberson enum ib_port_width { 396aa0a1e58SJeff Roberson IB_WIDTH_1X = 1, 397aa0a1e58SJeff Roberson IB_WIDTH_4X = 2, 398aa0a1e58SJeff Roberson IB_WIDTH_8X = 4, 399aa0a1e58SJeff Roberson IB_WIDTH_12X = 8 400aa0a1e58SJeff Roberson }; 401aa0a1e58SJeff Roberson 402aa0a1e58SJeff Roberson static inline int ib_width_enum_to_int(enum ib_port_width width) 403aa0a1e58SJeff Roberson { 404aa0a1e58SJeff Roberson switch (width) { 405aa0a1e58SJeff Roberson case IB_WIDTH_1X: return 1; 406aa0a1e58SJeff Roberson case IB_WIDTH_4X: return 4; 407aa0a1e58SJeff Roberson case IB_WIDTH_8X: return 8; 408aa0a1e58SJeff Roberson case IB_WIDTH_12X: return 12; 409aa0a1e58SJeff Roberson default: return -1; 410aa0a1e58SJeff Roberson } 411aa0a1e58SJeff Roberson } 412aa0a1e58SJeff Roberson 413c9f432b7SAlfred Perlstein enum ib_port_speed { 414c9f432b7SAlfred Perlstein IB_SPEED_SDR = 1, 415c9f432b7SAlfred Perlstein IB_SPEED_DDR = 2, 416c9f432b7SAlfred Perlstein IB_SPEED_QDR = 4, 417c9f432b7SAlfred Perlstein IB_SPEED_FDR10 = 8, 418c9f432b7SAlfred Perlstein IB_SPEED_FDR = 16, 419c9f432b7SAlfred Perlstein IB_SPEED_EDR = 32 420c9f432b7SAlfred Perlstein }; 421c9f432b7SAlfred Perlstein 422*478d3005SHans Petter Selasky /** 423*478d3005SHans Petter Selasky * struct rdma_hw_stats 424*478d3005SHans Petter Selasky * @timestamp - Used by the core code to track when the last update was 425*478d3005SHans Petter Selasky * @lifespan - Used by the core code to determine how old the counters 426*478d3005SHans Petter Selasky * should be before being updated again. Stored in jiffies, defaults 427*478d3005SHans Petter Selasky * to 10 milliseconds, drivers can override the default be specifying 428*478d3005SHans Petter Selasky * their own value during their allocation routine. 429*478d3005SHans Petter Selasky * @name - Array of pointers to static names used for the counters in 430*478d3005SHans Petter Selasky * directory. 431*478d3005SHans Petter Selasky * @num_counters - How many hardware counters there are. If name is 432*478d3005SHans Petter Selasky * shorter than this number, a kernel oops will result. Driver authors 433*478d3005SHans Petter Selasky * are encouraged to leave BUILD_BUG_ON(ARRAY_SIZE(@name) < num_counters) 434*478d3005SHans Petter Selasky * in their code to prevent this. 435*478d3005SHans Petter Selasky * @value - Array of u64 counters that are accessed by the sysfs code and 436*478d3005SHans Petter Selasky * filled in by the drivers get_stats routine 437*478d3005SHans Petter Selasky */ 438*478d3005SHans Petter Selasky struct rdma_hw_stats { 439*478d3005SHans Petter Selasky unsigned long timestamp; 440*478d3005SHans Petter Selasky unsigned long lifespan; 441*478d3005SHans Petter Selasky const char * const *names; 442*478d3005SHans Petter Selasky int num_counters; 443*478d3005SHans Petter Selasky u64 value[]; 444aa0a1e58SJeff Roberson }; 445aa0a1e58SJeff Roberson 446*478d3005SHans Petter Selasky #define RDMA_HW_STATS_DEFAULT_LIFESPAN 10 447*478d3005SHans Petter Selasky /** 448*478d3005SHans Petter Selasky * rdma_alloc_hw_stats_struct - Helper function to allocate dynamic struct 449*478d3005SHans Petter Selasky * for drivers. 450*478d3005SHans Petter Selasky * @names - Array of static const char * 451*478d3005SHans Petter Selasky * @num_counters - How many elements in array 452*478d3005SHans Petter Selasky * @lifespan - How many milliseconds between updates 453*478d3005SHans Petter Selasky */ 454*478d3005SHans Petter Selasky static inline struct rdma_hw_stats *rdma_alloc_hw_stats_struct( 455*478d3005SHans Petter Selasky const char * const *names, int num_counters, 456*478d3005SHans Petter Selasky unsigned long lifespan) 457*478d3005SHans Petter Selasky { 458*478d3005SHans Petter Selasky struct rdma_hw_stats *stats; 459aa0a1e58SJeff Roberson 460*478d3005SHans Petter Selasky stats = kzalloc(sizeof(*stats) + num_counters * sizeof(u64), 461*478d3005SHans Petter Selasky GFP_KERNEL); 462*478d3005SHans Petter Selasky if (!stats) 463*478d3005SHans Petter Selasky return NULL; 464*478d3005SHans Petter Selasky stats->names = names; 465*478d3005SHans Petter Selasky stats->num_counters = num_counters; 466*478d3005SHans Petter Selasky stats->lifespan = msecs_to_jiffies(lifespan); 467aa0a1e58SJeff Roberson 468*478d3005SHans Petter Selasky return stats; 469*478d3005SHans Petter Selasky } 470*478d3005SHans Petter Selasky 471*478d3005SHans Petter Selasky 472*478d3005SHans Petter Selasky /* Define bits for the various functionality this port needs to be supported by 473*478d3005SHans Petter Selasky * the core. 474*478d3005SHans Petter Selasky */ 475*478d3005SHans Petter Selasky /* Management 0x00000FFF */ 476*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_MAD 0x00000001 477*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_SMI 0x00000002 478*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_CM 0x00000004 479*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IW_CM 0x00000008 480*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_IB_SA 0x00000010 481*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_OPA_MAD 0x00000020 482*478d3005SHans Petter Selasky 483*478d3005SHans Petter Selasky /* Address format 0x000FF000 */ 484*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_AF_IB 0x00001000 485*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_ETH_AH 0x00002000 486*478d3005SHans Petter Selasky 487*478d3005SHans Petter Selasky /* Protocol 0xFFF00000 */ 488*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_IB 0x00100000 489*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_ROCE 0x00200000 490*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_IWARP 0x00400000 491*478d3005SHans Petter Selasky #define RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP 0x00800000 492*478d3005SHans Petter Selasky 493*478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_IB (RDMA_CORE_CAP_PROT_IB \ 494*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 495*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_SMI \ 496*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 497*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_SA \ 498*478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB) 499*478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_ROCE (RDMA_CORE_CAP_PROT_ROCE \ 500*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 501*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 502*478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB \ 503*478d3005SHans Petter Selasky | RDMA_CORE_CAP_ETH_AH) 504*478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP \ 505*478d3005SHans Petter Selasky (RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP \ 506*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_MAD \ 507*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IB_CM \ 508*478d3005SHans Petter Selasky | RDMA_CORE_CAP_AF_IB \ 509*478d3005SHans Petter Selasky | RDMA_CORE_CAP_ETH_AH) 510*478d3005SHans Petter Selasky #define RDMA_CORE_PORT_IWARP (RDMA_CORE_CAP_PROT_IWARP \ 511*478d3005SHans Petter Selasky | RDMA_CORE_CAP_IW_CM) 512*478d3005SHans Petter Selasky #define RDMA_CORE_PORT_INTEL_OPA (RDMA_CORE_PORT_IBA_IB \ 513*478d3005SHans Petter Selasky | RDMA_CORE_CAP_OPA_MAD) 514aa0a1e58SJeff Roberson 515aa0a1e58SJeff Roberson struct ib_port_attr { 516*478d3005SHans Petter Selasky u64 subnet_prefix; 517aa0a1e58SJeff Roberson enum ib_port_state state; 518aa0a1e58SJeff Roberson enum ib_mtu max_mtu; 519aa0a1e58SJeff Roberson enum ib_mtu active_mtu; 520aa0a1e58SJeff Roberson int gid_tbl_len; 521aa0a1e58SJeff Roberson u32 port_cap_flags; 522aa0a1e58SJeff Roberson u32 max_msg_sz; 523aa0a1e58SJeff Roberson u32 bad_pkey_cntr; 524aa0a1e58SJeff Roberson u32 qkey_viol_cntr; 525aa0a1e58SJeff Roberson u16 pkey_tbl_len; 526aa0a1e58SJeff Roberson u16 lid; 527aa0a1e58SJeff Roberson u16 sm_lid; 528aa0a1e58SJeff Roberson u8 lmc; 529aa0a1e58SJeff Roberson u8 max_vl_num; 530aa0a1e58SJeff Roberson u8 sm_sl; 531aa0a1e58SJeff Roberson u8 subnet_timeout; 532aa0a1e58SJeff Roberson u8 init_type_reply; 533aa0a1e58SJeff Roberson u8 active_width; 534aa0a1e58SJeff Roberson u8 active_speed; 535aa0a1e58SJeff Roberson u8 phys_state; 536*478d3005SHans Petter Selasky bool grh_required; 537aa0a1e58SJeff Roberson }; 538aa0a1e58SJeff Roberson 539aa0a1e58SJeff Roberson enum ib_device_modify_flags { 540aa0a1e58SJeff Roberson IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0, 541aa0a1e58SJeff Roberson IB_DEVICE_MODIFY_NODE_DESC = 1 << 1 542aa0a1e58SJeff Roberson }; 543aa0a1e58SJeff Roberson 544*478d3005SHans Petter Selasky #define IB_DEVICE_NODE_DESC_MAX 64 545*478d3005SHans Petter Selasky 546aa0a1e58SJeff Roberson struct ib_device_modify { 547aa0a1e58SJeff Roberson u64 sys_image_guid; 548*478d3005SHans Petter Selasky char node_desc[IB_DEVICE_NODE_DESC_MAX]; 549aa0a1e58SJeff Roberson }; 550aa0a1e58SJeff Roberson 551aa0a1e58SJeff Roberson enum ib_port_modify_flags { 552aa0a1e58SJeff Roberson IB_PORT_SHUTDOWN = 1, 553aa0a1e58SJeff Roberson IB_PORT_INIT_TYPE = (1<<2), 554aa0a1e58SJeff Roberson IB_PORT_RESET_QKEY_CNTR = (1<<3) 555aa0a1e58SJeff Roberson }; 556aa0a1e58SJeff Roberson 557aa0a1e58SJeff Roberson struct ib_port_modify { 558aa0a1e58SJeff Roberson u32 set_port_cap_mask; 559aa0a1e58SJeff Roberson u32 clr_port_cap_mask; 560aa0a1e58SJeff Roberson u8 init_type; 561aa0a1e58SJeff Roberson }; 562aa0a1e58SJeff Roberson 563aa0a1e58SJeff Roberson enum ib_event_type { 564aa0a1e58SJeff Roberson IB_EVENT_CQ_ERR, 565aa0a1e58SJeff Roberson IB_EVENT_QP_FATAL, 566aa0a1e58SJeff Roberson IB_EVENT_QP_REQ_ERR, 567aa0a1e58SJeff Roberson IB_EVENT_QP_ACCESS_ERR, 568aa0a1e58SJeff Roberson IB_EVENT_COMM_EST, 569aa0a1e58SJeff Roberson IB_EVENT_SQ_DRAINED, 570aa0a1e58SJeff Roberson IB_EVENT_PATH_MIG, 571aa0a1e58SJeff Roberson IB_EVENT_PATH_MIG_ERR, 572aa0a1e58SJeff Roberson IB_EVENT_DEVICE_FATAL, 573aa0a1e58SJeff Roberson IB_EVENT_PORT_ACTIVE, 574aa0a1e58SJeff Roberson IB_EVENT_PORT_ERR, 575aa0a1e58SJeff Roberson IB_EVENT_LID_CHANGE, 576aa0a1e58SJeff Roberson IB_EVENT_PKEY_CHANGE, 577aa0a1e58SJeff Roberson IB_EVENT_SM_CHANGE, 578aa0a1e58SJeff Roberson IB_EVENT_SRQ_ERR, 579aa0a1e58SJeff Roberson IB_EVENT_SRQ_LIMIT_REACHED, 580aa0a1e58SJeff Roberson IB_EVENT_QP_LAST_WQE_REACHED, 581aa0a1e58SJeff Roberson IB_EVENT_CLIENT_REREGISTER, 582aa0a1e58SJeff Roberson IB_EVENT_GID_CHANGE, 583*478d3005SHans Petter Selasky IB_EVENT_WQ_FATAL, 584aa0a1e58SJeff Roberson }; 585aa0a1e58SJeff Roberson 586*478d3005SHans Petter Selasky const char *__attribute_const__ ib_event_msg(enum ib_event_type event); 587*478d3005SHans Petter Selasky 588aa0a1e58SJeff Roberson struct ib_event { 589aa0a1e58SJeff Roberson struct ib_device *device; 590aa0a1e58SJeff Roberson union { 591aa0a1e58SJeff Roberson struct ib_cq *cq; 592aa0a1e58SJeff Roberson struct ib_qp *qp; 593aa0a1e58SJeff Roberson struct ib_srq *srq; 594*478d3005SHans Petter Selasky struct ib_wq *wq; 595aa0a1e58SJeff Roberson u8 port_num; 596aa0a1e58SJeff Roberson } element; 597aa0a1e58SJeff Roberson enum ib_event_type event; 598aa0a1e58SJeff Roberson }; 599aa0a1e58SJeff Roberson 600aa0a1e58SJeff Roberson struct ib_event_handler { 601aa0a1e58SJeff Roberson struct ib_device *device; 602aa0a1e58SJeff Roberson void (*handler)(struct ib_event_handler *, struct ib_event *); 603aa0a1e58SJeff Roberson struct list_head list; 604aa0a1e58SJeff Roberson }; 605aa0a1e58SJeff Roberson 606aa0a1e58SJeff Roberson #define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \ 607aa0a1e58SJeff Roberson do { \ 608aa0a1e58SJeff Roberson (_ptr)->device = _device; \ 609aa0a1e58SJeff Roberson (_ptr)->handler = _handler; \ 610aa0a1e58SJeff Roberson INIT_LIST_HEAD(&(_ptr)->list); \ 611aa0a1e58SJeff Roberson } while (0) 612aa0a1e58SJeff Roberson 613aa0a1e58SJeff Roberson struct ib_global_route { 614aa0a1e58SJeff Roberson union ib_gid dgid; 615aa0a1e58SJeff Roberson u32 flow_label; 616aa0a1e58SJeff Roberson u8 sgid_index; 617aa0a1e58SJeff Roberson u8 hop_limit; 618aa0a1e58SJeff Roberson u8 traffic_class; 619aa0a1e58SJeff Roberson }; 620aa0a1e58SJeff Roberson 621aa0a1e58SJeff Roberson struct ib_grh { 622aa0a1e58SJeff Roberson __be32 version_tclass_flow; 623aa0a1e58SJeff Roberson __be16 paylen; 624aa0a1e58SJeff Roberson u8 next_hdr; 625aa0a1e58SJeff Roberson u8 hop_limit; 626aa0a1e58SJeff Roberson union ib_gid sgid; 627aa0a1e58SJeff Roberson union ib_gid dgid; 628aa0a1e58SJeff Roberson }; 629aa0a1e58SJeff Roberson 630*478d3005SHans Petter Selasky union rdma_network_hdr { 631*478d3005SHans Petter Selasky struct ib_grh ibgrh; 632*478d3005SHans Petter Selasky struct { 633*478d3005SHans Petter Selasky /* The IB spec states that if it's IPv4, the header 634*478d3005SHans Petter Selasky * is located in the last 20 bytes of the header. 635*478d3005SHans Petter Selasky */ 636*478d3005SHans Petter Selasky u8 reserved[20]; 637*478d3005SHans Petter Selasky struct ip roce4grh; 638*478d3005SHans Petter Selasky }; 639*478d3005SHans Petter Selasky }; 640*478d3005SHans Petter Selasky 641aa0a1e58SJeff Roberson enum { 642aa0a1e58SJeff Roberson IB_MULTICAST_QPN = 0xffffff 643aa0a1e58SJeff Roberson }; 644aa0a1e58SJeff Roberson 645aa0a1e58SJeff Roberson #define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF) 646*478d3005SHans Petter Selasky #define IB_MULTICAST_LID_BASE cpu_to_be16(0xC000) 647aa0a1e58SJeff Roberson 648aa0a1e58SJeff Roberson enum ib_ah_flags { 649aa0a1e58SJeff Roberson IB_AH_GRH = 1 650aa0a1e58SJeff Roberson }; 651aa0a1e58SJeff Roberson 652aa0a1e58SJeff Roberson enum ib_rate { 653aa0a1e58SJeff Roberson IB_RATE_PORT_CURRENT = 0, 654aa0a1e58SJeff Roberson IB_RATE_2_5_GBPS = 2, 655aa0a1e58SJeff Roberson IB_RATE_5_GBPS = 5, 656aa0a1e58SJeff Roberson IB_RATE_10_GBPS = 3, 657aa0a1e58SJeff Roberson IB_RATE_20_GBPS = 6, 658aa0a1e58SJeff Roberson IB_RATE_30_GBPS = 4, 659aa0a1e58SJeff Roberson IB_RATE_40_GBPS = 7, 660aa0a1e58SJeff Roberson IB_RATE_60_GBPS = 8, 661aa0a1e58SJeff Roberson IB_RATE_80_GBPS = 9, 662c9f432b7SAlfred Perlstein IB_RATE_120_GBPS = 10, 663c9f432b7SAlfred Perlstein IB_RATE_14_GBPS = 11, 664c9f432b7SAlfred Perlstein IB_RATE_56_GBPS = 12, 665c9f432b7SAlfred Perlstein IB_RATE_112_GBPS = 13, 666c9f432b7SAlfred Perlstein IB_RATE_168_GBPS = 14, 667c9f432b7SAlfred Perlstein IB_RATE_25_GBPS = 15, 668c9f432b7SAlfred Perlstein IB_RATE_100_GBPS = 16, 669c9f432b7SAlfred Perlstein IB_RATE_200_GBPS = 17, 670c9f432b7SAlfred Perlstein IB_RATE_300_GBPS = 18 671aa0a1e58SJeff Roberson }; 672aa0a1e58SJeff Roberson 673aa0a1e58SJeff Roberson /** 674aa0a1e58SJeff Roberson * ib_rate_to_mult - Convert the IB rate enum to a multiple of the 675aa0a1e58SJeff Roberson * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be 676aa0a1e58SJeff Roberson * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. 677aa0a1e58SJeff Roberson * @rate: rate to convert. 678aa0a1e58SJeff Roberson */ 679*478d3005SHans Petter Selasky __attribute_const__ int ib_rate_to_mult(enum ib_rate rate); 680aa0a1e58SJeff Roberson 681aa0a1e58SJeff Roberson /** 682c9f432b7SAlfred Perlstein * ib_rate_to_mbps - Convert the IB rate enum to Mbps. 683c9f432b7SAlfred Perlstein * For example, IB_RATE_2_5_GBPS will be converted to 2500. 684c9f432b7SAlfred Perlstein * @rate: rate to convert. 685c9f432b7SAlfred Perlstein */ 686*478d3005SHans Petter Selasky __attribute_const__ int ib_rate_to_mbps(enum ib_rate rate); 687c9f432b7SAlfred Perlstein 688b5c1e0cbSHans Petter Selasky 689*478d3005SHans Petter Selasky /** 690*478d3005SHans Petter Selasky * enum ib_mr_type - memory region type 691*478d3005SHans Petter Selasky * @IB_MR_TYPE_MEM_REG: memory region that is used for 692*478d3005SHans Petter Selasky * normal registration 693*478d3005SHans Petter Selasky * @IB_MR_TYPE_SIGNATURE: memory region that is used for 694*478d3005SHans Petter Selasky * signature operations (data-integrity 695*478d3005SHans Petter Selasky * capable regions) 696*478d3005SHans Petter Selasky * @IB_MR_TYPE_SG_GAPS: memory region that is capable to 697*478d3005SHans Petter Selasky * register any arbitrary sg lists (without 698*478d3005SHans Petter Selasky * the normal mr constraints - see 699*478d3005SHans Petter Selasky * ib_map_mr_sg) 700*478d3005SHans Petter Selasky */ 701*478d3005SHans Petter Selasky enum ib_mr_type { 702*478d3005SHans Petter Selasky IB_MR_TYPE_MEM_REG, 703*478d3005SHans Petter Selasky IB_MR_TYPE_SIGNATURE, 704*478d3005SHans Petter Selasky IB_MR_TYPE_SG_GAPS, 705b5c1e0cbSHans Petter Selasky }; 706b5c1e0cbSHans Petter Selasky 707b5c1e0cbSHans Petter Selasky /** 708*478d3005SHans Petter Selasky * Signature types 709*478d3005SHans Petter Selasky * IB_SIG_TYPE_NONE: Unprotected. 710*478d3005SHans Petter Selasky * IB_SIG_TYPE_T10_DIF: Type T10-DIF 711b5c1e0cbSHans Petter Selasky */ 712*478d3005SHans Petter Selasky enum ib_signature_type { 713*478d3005SHans Petter Selasky IB_SIG_TYPE_NONE, 714*478d3005SHans Petter Selasky IB_SIG_TYPE_T10_DIF, 715b5c1e0cbSHans Petter Selasky }; 716b5c1e0cbSHans Petter Selasky 717b5c1e0cbSHans Petter Selasky /** 718b5c1e0cbSHans Petter Selasky * Signature T10-DIF block-guard types 719b5c1e0cbSHans Petter Selasky * IB_T10DIF_CRC: Corresponds to T10-PI mandated CRC checksum rules. 720b5c1e0cbSHans Petter Selasky * IB_T10DIF_CSUM: Corresponds to IP checksum rules. 721b5c1e0cbSHans Petter Selasky */ 722b5c1e0cbSHans Petter Selasky enum ib_t10_dif_bg_type { 723b5c1e0cbSHans Petter Selasky IB_T10DIF_CRC, 724b5c1e0cbSHans Petter Selasky IB_T10DIF_CSUM 725b5c1e0cbSHans Petter Selasky }; 726b5c1e0cbSHans Petter Selasky 727b5c1e0cbSHans Petter Selasky /** 728b5c1e0cbSHans Petter Selasky * struct ib_t10_dif_domain - Parameters specific for T10-DIF 729b5c1e0cbSHans Petter Selasky * domain. 730b5c1e0cbSHans Petter Selasky * @bg_type: T10-DIF block guard type (CRC|CSUM) 731b5c1e0cbSHans Petter Selasky * @pi_interval: protection information interval. 732b5c1e0cbSHans Petter Selasky * @bg: seed of guard computation. 733b5c1e0cbSHans Petter Selasky * @app_tag: application tag of guard block 734b5c1e0cbSHans Petter Selasky * @ref_tag: initial guard block reference tag. 735*478d3005SHans Petter Selasky * @ref_remap: Indicate wethear the reftag increments each block 736*478d3005SHans Petter Selasky * @app_escape: Indicate to skip block check if apptag=0xffff 737*478d3005SHans Petter Selasky * @ref_escape: Indicate to skip block check if reftag=0xffffffff 738*478d3005SHans Petter Selasky * @apptag_check_mask: check bitmask of application tag. 739b5c1e0cbSHans Petter Selasky */ 740b5c1e0cbSHans Petter Selasky struct ib_t10_dif_domain { 741b5c1e0cbSHans Petter Selasky enum ib_t10_dif_bg_type bg_type; 742*478d3005SHans Petter Selasky u16 pi_interval; 743b5c1e0cbSHans Petter Selasky u16 bg; 744b5c1e0cbSHans Petter Selasky u16 app_tag; 745b5c1e0cbSHans Petter Selasky u32 ref_tag; 746*478d3005SHans Petter Selasky bool ref_remap; 747*478d3005SHans Petter Selasky bool app_escape; 748*478d3005SHans Petter Selasky bool ref_escape; 749*478d3005SHans Petter Selasky u16 apptag_check_mask; 750b5c1e0cbSHans Petter Selasky }; 751b5c1e0cbSHans Petter Selasky 752b5c1e0cbSHans Petter Selasky /** 753b5c1e0cbSHans Petter Selasky * struct ib_sig_domain - Parameters for signature domain 754b5c1e0cbSHans Petter Selasky * @sig_type: specific signauture type 755b5c1e0cbSHans Petter Selasky * @sig: union of all signature domain attributes that may 756b5c1e0cbSHans Petter Selasky * be used to set domain layout. 757b5c1e0cbSHans Petter Selasky */ 758b5c1e0cbSHans Petter Selasky struct ib_sig_domain { 759b5c1e0cbSHans Petter Selasky enum ib_signature_type sig_type; 760b5c1e0cbSHans Petter Selasky union { 761b5c1e0cbSHans Petter Selasky struct ib_t10_dif_domain dif; 762b5c1e0cbSHans Petter Selasky } sig; 763b5c1e0cbSHans Petter Selasky }; 764b5c1e0cbSHans Petter Selasky 765b5c1e0cbSHans Petter Selasky /** 766b5c1e0cbSHans Petter Selasky * struct ib_sig_attrs - Parameters for signature handover operation 767b5c1e0cbSHans Petter Selasky * @check_mask: bitmask for signature byte check (8 bytes) 768b5c1e0cbSHans Petter Selasky * @mem: memory domain layout desciptor. 769b5c1e0cbSHans Petter Selasky * @wire: wire domain layout desciptor. 770b5c1e0cbSHans Petter Selasky */ 771b5c1e0cbSHans Petter Selasky struct ib_sig_attrs { 772b5c1e0cbSHans Petter Selasky u8 check_mask; 773b5c1e0cbSHans Petter Selasky struct ib_sig_domain mem; 774b5c1e0cbSHans Petter Selasky struct ib_sig_domain wire; 775b5c1e0cbSHans Petter Selasky }; 776b5c1e0cbSHans Petter Selasky 777b5c1e0cbSHans Petter Selasky enum ib_sig_err_type { 778b5c1e0cbSHans Petter Selasky IB_SIG_BAD_GUARD, 779b5c1e0cbSHans Petter Selasky IB_SIG_BAD_REFTAG, 780b5c1e0cbSHans Petter Selasky IB_SIG_BAD_APPTAG, 781b5c1e0cbSHans Petter Selasky }; 782b5c1e0cbSHans Petter Selasky 783b5c1e0cbSHans Petter Selasky /** 784b5c1e0cbSHans Petter Selasky * struct ib_sig_err - signature error descriptor 785b5c1e0cbSHans Petter Selasky */ 786b5c1e0cbSHans Petter Selasky struct ib_sig_err { 787b5c1e0cbSHans Petter Selasky enum ib_sig_err_type err_type; 788b5c1e0cbSHans Petter Selasky u32 expected; 789b5c1e0cbSHans Petter Selasky u32 actual; 790b5c1e0cbSHans Petter Selasky u64 sig_err_offset; 791b5c1e0cbSHans Petter Selasky u32 key; 792b5c1e0cbSHans Petter Selasky }; 793b5c1e0cbSHans Petter Selasky 794b5c1e0cbSHans Petter Selasky enum ib_mr_status_check { 795b5c1e0cbSHans Petter Selasky IB_MR_CHECK_SIG_STATUS = 1, 796b5c1e0cbSHans Petter Selasky }; 797b5c1e0cbSHans Petter Selasky 798b5c1e0cbSHans Petter Selasky /** 799b5c1e0cbSHans Petter Selasky * struct ib_mr_status - Memory region status container 800b5c1e0cbSHans Petter Selasky * 801b5c1e0cbSHans Petter Selasky * @fail_status: Bitmask of MR checks status. For each 802b5c1e0cbSHans Petter Selasky * failed check a corresponding status bit is set. 803b5c1e0cbSHans Petter Selasky * @sig_err: Additional info for IB_MR_CEHCK_SIG_STATUS 804b5c1e0cbSHans Petter Selasky * failure. 805b5c1e0cbSHans Petter Selasky */ 806b5c1e0cbSHans Petter Selasky struct ib_mr_status { 807b5c1e0cbSHans Petter Selasky u32 fail_status; 808b5c1e0cbSHans Petter Selasky struct ib_sig_err sig_err; 809b5c1e0cbSHans Petter Selasky }; 810b5c1e0cbSHans Petter Selasky 811c9f432b7SAlfred Perlstein /** 812aa0a1e58SJeff Roberson * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate 813aa0a1e58SJeff Roberson * enum. 814aa0a1e58SJeff Roberson * @mult: multiple to convert. 815aa0a1e58SJeff Roberson */ 816*478d3005SHans Petter Selasky __attribute_const__ enum ib_rate mult_to_ib_rate(int mult); 817aa0a1e58SJeff Roberson 818aa0a1e58SJeff Roberson struct ib_ah_attr { 819aa0a1e58SJeff Roberson struct ib_global_route grh; 820aa0a1e58SJeff Roberson u16 dlid; 821aa0a1e58SJeff Roberson u8 sl; 822aa0a1e58SJeff Roberson u8 src_path_bits; 823aa0a1e58SJeff Roberson u8 static_rate; 824aa0a1e58SJeff Roberson u8 ah_flags; 825aa0a1e58SJeff Roberson u8 port_num; 826*478d3005SHans Petter Selasky u8 dmac[ETH_ALEN]; 827aa0a1e58SJeff Roberson }; 828aa0a1e58SJeff Roberson 829aa0a1e58SJeff Roberson enum ib_wc_status { 830aa0a1e58SJeff Roberson IB_WC_SUCCESS, 831aa0a1e58SJeff Roberson IB_WC_LOC_LEN_ERR, 832aa0a1e58SJeff Roberson IB_WC_LOC_QP_OP_ERR, 833aa0a1e58SJeff Roberson IB_WC_LOC_EEC_OP_ERR, 834aa0a1e58SJeff Roberson IB_WC_LOC_PROT_ERR, 835aa0a1e58SJeff Roberson IB_WC_WR_FLUSH_ERR, 836aa0a1e58SJeff Roberson IB_WC_MW_BIND_ERR, 837aa0a1e58SJeff Roberson IB_WC_BAD_RESP_ERR, 838aa0a1e58SJeff Roberson IB_WC_LOC_ACCESS_ERR, 839aa0a1e58SJeff Roberson IB_WC_REM_INV_REQ_ERR, 840aa0a1e58SJeff Roberson IB_WC_REM_ACCESS_ERR, 841aa0a1e58SJeff Roberson IB_WC_REM_OP_ERR, 842aa0a1e58SJeff Roberson IB_WC_RETRY_EXC_ERR, 843aa0a1e58SJeff Roberson IB_WC_RNR_RETRY_EXC_ERR, 844aa0a1e58SJeff Roberson IB_WC_LOC_RDD_VIOL_ERR, 845aa0a1e58SJeff Roberson IB_WC_REM_INV_RD_REQ_ERR, 846aa0a1e58SJeff Roberson IB_WC_REM_ABORT_ERR, 847aa0a1e58SJeff Roberson IB_WC_INV_EECN_ERR, 848aa0a1e58SJeff Roberson IB_WC_INV_EEC_STATE_ERR, 849aa0a1e58SJeff Roberson IB_WC_FATAL_ERR, 850aa0a1e58SJeff Roberson IB_WC_RESP_TIMEOUT_ERR, 851aa0a1e58SJeff Roberson IB_WC_GENERAL_ERR 852aa0a1e58SJeff Roberson }; 853aa0a1e58SJeff Roberson 854*478d3005SHans Petter Selasky const char *__attribute_const__ ib_wc_status_msg(enum ib_wc_status status); 855*478d3005SHans Petter Selasky 856aa0a1e58SJeff Roberson enum ib_wc_opcode { 857aa0a1e58SJeff Roberson IB_WC_SEND, 858aa0a1e58SJeff Roberson IB_WC_RDMA_WRITE, 859aa0a1e58SJeff Roberson IB_WC_RDMA_READ, 860aa0a1e58SJeff Roberson IB_WC_COMP_SWAP, 861aa0a1e58SJeff Roberson IB_WC_FETCH_ADD, 862aa0a1e58SJeff Roberson IB_WC_LSO, 863aa0a1e58SJeff Roberson IB_WC_LOCAL_INV, 864*478d3005SHans Petter Selasky IB_WC_REG_MR, 865aa0a1e58SJeff Roberson IB_WC_MASKED_COMP_SWAP, 866aa0a1e58SJeff Roberson IB_WC_MASKED_FETCH_ADD, 867aa0a1e58SJeff Roberson /* 868aa0a1e58SJeff Roberson * Set value of IB_WC_RECV so consumers can test if a completion is a 869aa0a1e58SJeff Roberson * receive by testing (opcode & IB_WC_RECV). 870aa0a1e58SJeff Roberson */ 871aa0a1e58SJeff Roberson IB_WC_RECV = 1 << 7, 872*478d3005SHans Petter Selasky IB_WC_RECV_RDMA_WITH_IMM, 873*478d3005SHans Petter Selasky IB_WC_DUMMY = -1, /* force enum signed */ 874aa0a1e58SJeff Roberson }; 875aa0a1e58SJeff Roberson 876aa0a1e58SJeff Roberson enum ib_wc_flags { 877aa0a1e58SJeff Roberson IB_WC_GRH = 1, 878aa0a1e58SJeff Roberson IB_WC_WITH_IMM = (1<<1), 879aa0a1e58SJeff Roberson IB_WC_WITH_INVALIDATE = (1<<2), 880c9f432b7SAlfred Perlstein IB_WC_IP_CSUM_OK = (1<<3), 881*478d3005SHans Petter Selasky IB_WC_WITH_SMAC = (1<<4), 882*478d3005SHans Petter Selasky IB_WC_WITH_VLAN = (1<<5), 883*478d3005SHans Petter Selasky IB_WC_WITH_NETWORK_HDR_TYPE = (1<<6), 884aa0a1e58SJeff Roberson }; 885aa0a1e58SJeff Roberson 886aa0a1e58SJeff Roberson struct ib_wc { 887*478d3005SHans Petter Selasky union { 888aa0a1e58SJeff Roberson u64 wr_id; 889*478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 890*478d3005SHans Petter Selasky }; 891aa0a1e58SJeff Roberson enum ib_wc_status status; 892aa0a1e58SJeff Roberson enum ib_wc_opcode opcode; 893aa0a1e58SJeff Roberson u32 vendor_err; 894aa0a1e58SJeff Roberson u32 byte_len; 895aa0a1e58SJeff Roberson struct ib_qp *qp; 896aa0a1e58SJeff Roberson union { 897aa0a1e58SJeff Roberson __be32 imm_data; 898aa0a1e58SJeff Roberson u32 invalidate_rkey; 899aa0a1e58SJeff Roberson } ex; 900aa0a1e58SJeff Roberson u32 src_qp; 901aa0a1e58SJeff Roberson int wc_flags; 902aa0a1e58SJeff Roberson u16 pkey_index; 903aa0a1e58SJeff Roberson u16 slid; 904aa0a1e58SJeff Roberson u8 sl; 905aa0a1e58SJeff Roberson u8 dlid_path_bits; 906aa0a1e58SJeff Roberson u8 port_num; /* valid only for DR SMPs on switches */ 907*478d3005SHans Petter Selasky u8 smac[ETH_ALEN]; 908b5c1e0cbSHans Petter Selasky u16 vlan_id; 909*478d3005SHans Petter Selasky u8 network_hdr_type; 910aa0a1e58SJeff Roberson }; 911aa0a1e58SJeff Roberson 912aa0a1e58SJeff Roberson enum ib_cq_notify_flags { 913aa0a1e58SJeff Roberson IB_CQ_SOLICITED = 1 << 0, 914aa0a1e58SJeff Roberson IB_CQ_NEXT_COMP = 1 << 1, 915aa0a1e58SJeff Roberson IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP, 916aa0a1e58SJeff Roberson IB_CQ_REPORT_MISSED_EVENTS = 1 << 2, 917aa0a1e58SJeff Roberson }; 918aa0a1e58SJeff Roberson 919c9f432b7SAlfred Perlstein enum ib_srq_type { 920c9f432b7SAlfred Perlstein IB_SRQT_BASIC, 921c9f432b7SAlfred Perlstein IB_SRQT_XRC 922c9f432b7SAlfred Perlstein }; 923c9f432b7SAlfred Perlstein 924aa0a1e58SJeff Roberson enum ib_srq_attr_mask { 925aa0a1e58SJeff Roberson IB_SRQ_MAX_WR = 1 << 0, 926aa0a1e58SJeff Roberson IB_SRQ_LIMIT = 1 << 1, 927aa0a1e58SJeff Roberson }; 928aa0a1e58SJeff Roberson 929aa0a1e58SJeff Roberson struct ib_srq_attr { 930aa0a1e58SJeff Roberson u32 max_wr; 931aa0a1e58SJeff Roberson u32 max_sge; 932aa0a1e58SJeff Roberson u32 srq_limit; 933aa0a1e58SJeff Roberson }; 934aa0a1e58SJeff Roberson 935aa0a1e58SJeff Roberson struct ib_srq_init_attr { 936aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 937aa0a1e58SJeff Roberson void *srq_context; 938aa0a1e58SJeff Roberson struct ib_srq_attr attr; 939c9f432b7SAlfred Perlstein enum ib_srq_type srq_type; 940c9f432b7SAlfred Perlstein 941c9f432b7SAlfred Perlstein union { 942c9f432b7SAlfred Perlstein struct { 943c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; 944c9f432b7SAlfred Perlstein struct ib_cq *cq; 945c9f432b7SAlfred Perlstein } xrc; 946c9f432b7SAlfred Perlstein } ext; 947aa0a1e58SJeff Roberson }; 948aa0a1e58SJeff Roberson 949aa0a1e58SJeff Roberson struct ib_qp_cap { 950aa0a1e58SJeff Roberson u32 max_send_wr; 951aa0a1e58SJeff Roberson u32 max_recv_wr; 952aa0a1e58SJeff Roberson u32 max_send_sge; 953aa0a1e58SJeff Roberson u32 max_recv_sge; 954aa0a1e58SJeff Roberson u32 max_inline_data; 955*478d3005SHans Petter Selasky 956*478d3005SHans Petter Selasky /* 957*478d3005SHans Petter Selasky * Maximum number of rdma_rw_ctx structures in flight at a time. 958*478d3005SHans Petter Selasky * ib_create_qp() will calculate the right amount of neededed WRs 959*478d3005SHans Petter Selasky * and MRs based on this. 960*478d3005SHans Petter Selasky */ 961*478d3005SHans Petter Selasky u32 max_rdma_ctxs; 962aa0a1e58SJeff Roberson }; 963aa0a1e58SJeff Roberson 964aa0a1e58SJeff Roberson enum ib_sig_type { 965aa0a1e58SJeff Roberson IB_SIGNAL_ALL_WR, 966aa0a1e58SJeff Roberson IB_SIGNAL_REQ_WR 967aa0a1e58SJeff Roberson }; 968aa0a1e58SJeff Roberson 969aa0a1e58SJeff Roberson enum ib_qp_type { 970aa0a1e58SJeff Roberson /* 971aa0a1e58SJeff Roberson * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries 972aa0a1e58SJeff Roberson * here (and in that order) since the MAD layer uses them as 973aa0a1e58SJeff Roberson * indices into a 2-entry table. 974aa0a1e58SJeff Roberson */ 975aa0a1e58SJeff Roberson IB_QPT_SMI, 976aa0a1e58SJeff Roberson IB_QPT_GSI, 977aa0a1e58SJeff Roberson 978aa0a1e58SJeff Roberson IB_QPT_RC, 979aa0a1e58SJeff Roberson IB_QPT_UC, 980aa0a1e58SJeff Roberson IB_QPT_UD, 981aa0a1e58SJeff Roberson IB_QPT_RAW_IPV6, 982c9f432b7SAlfred Perlstein IB_QPT_RAW_ETHERTYPE, 983c9f432b7SAlfred Perlstein IB_QPT_RAW_PACKET = 8, 984c9f432b7SAlfred Perlstein IB_QPT_XRC_INI = 9, 985c9f432b7SAlfred Perlstein IB_QPT_XRC_TGT, 986c9f432b7SAlfred Perlstein IB_QPT_MAX, 987b5c1e0cbSHans Petter Selasky /* Reserve a range for qp types internal to the low level driver. 988b5c1e0cbSHans Petter Selasky * These qp types will not be visible at the IB core layer, so the 989b5c1e0cbSHans Petter Selasky * IB_QPT_MAX usages should not be affected in the core layer 990b5c1e0cbSHans Petter Selasky */ 991b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED1 = 0x1000, 992b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED2, 993b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED3, 994b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED4, 995b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED5, 996b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED6, 997b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED7, 998b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED8, 999b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED9, 1000b5c1e0cbSHans Petter Selasky IB_QPT_RESERVED10, 1001aa0a1e58SJeff Roberson }; 1002aa0a1e58SJeff Roberson 1003aa0a1e58SJeff Roberson enum ib_qp_create_flags { 1004aa0a1e58SJeff Roberson IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, 1005aa0a1e58SJeff Roberson IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1, 1006b5c1e0cbSHans Petter Selasky IB_QP_CREATE_CROSS_CHANNEL = 1 << 2, 1007b5c1e0cbSHans Petter Selasky IB_QP_CREATE_MANAGED_SEND = 1 << 3, 1008b5c1e0cbSHans Petter Selasky IB_QP_CREATE_MANAGED_RECV = 1 << 4, 1009b5c1e0cbSHans Petter Selasky IB_QP_CREATE_NETIF_QP = 1 << 5, 1010b5c1e0cbSHans Petter Selasky IB_QP_CREATE_SIGNATURE_EN = 1 << 6, 1011*478d3005SHans Petter Selasky IB_QP_CREATE_USE_GFP_NOIO = 1 << 7, 1012*478d3005SHans Petter Selasky IB_QP_CREATE_SCATTER_FCS = 1 << 8, 1013c9f432b7SAlfred Perlstein /* reserve bits 26-31 for low level drivers' internal use */ 1014c9f432b7SAlfred Perlstein IB_QP_CREATE_RESERVED_START = 1 << 26, 1015c9f432b7SAlfred Perlstein IB_QP_CREATE_RESERVED_END = 1 << 31, 1016c9f432b7SAlfred Perlstein }; 1017c9f432b7SAlfred Perlstein 1018*478d3005SHans Petter Selasky /* 1019*478d3005SHans Petter Selasky * Note: users may not call ib_close_qp or ib_destroy_qp from the event_handler 1020*478d3005SHans Petter Selasky * callback to destroy the passed in QP. 1021*478d3005SHans Petter Selasky */ 1022aa0a1e58SJeff Roberson 1023aa0a1e58SJeff Roberson struct ib_qp_init_attr { 1024aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1025aa0a1e58SJeff Roberson void *qp_context; 1026aa0a1e58SJeff Roberson struct ib_cq *send_cq; 1027aa0a1e58SJeff Roberson struct ib_cq *recv_cq; 1028aa0a1e58SJeff Roberson struct ib_srq *srq; 1029c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 1030aa0a1e58SJeff Roberson struct ib_qp_cap cap; 1031aa0a1e58SJeff Roberson enum ib_sig_type sq_sig_type; 1032aa0a1e58SJeff Roberson enum ib_qp_type qp_type; 1033aa0a1e58SJeff Roberson enum ib_qp_create_flags create_flags; 1034aa0a1e58SJeff Roberson 1035*478d3005SHans Petter Selasky /* 1036*478d3005SHans Petter Selasky * Only needed for special QP types, or when using the RW API. 1037*478d3005SHans Petter Selasky */ 1038*478d3005SHans Petter Selasky u8 port_num; 1039*478d3005SHans Petter Selasky struct ib_rwq_ind_table *rwq_ind_tbl; 1040b5c1e0cbSHans Petter Selasky }; 1041b5c1e0cbSHans Petter Selasky 1042c9f432b7SAlfred Perlstein struct ib_qp_open_attr { 1043c9f432b7SAlfred Perlstein void (*event_handler)(struct ib_event *, void *); 1044c9f432b7SAlfred Perlstein void *qp_context; 1045c9f432b7SAlfred Perlstein u32 qp_num; 1046c9f432b7SAlfred Perlstein enum ib_qp_type qp_type; 1047c9f432b7SAlfred Perlstein }; 1048c9f432b7SAlfred Perlstein 1049aa0a1e58SJeff Roberson enum ib_rnr_timeout { 1050aa0a1e58SJeff Roberson IB_RNR_TIMER_655_36 = 0, 1051aa0a1e58SJeff Roberson IB_RNR_TIMER_000_01 = 1, 1052aa0a1e58SJeff Roberson IB_RNR_TIMER_000_02 = 2, 1053aa0a1e58SJeff Roberson IB_RNR_TIMER_000_03 = 3, 1054aa0a1e58SJeff Roberson IB_RNR_TIMER_000_04 = 4, 1055aa0a1e58SJeff Roberson IB_RNR_TIMER_000_06 = 5, 1056aa0a1e58SJeff Roberson IB_RNR_TIMER_000_08 = 6, 1057aa0a1e58SJeff Roberson IB_RNR_TIMER_000_12 = 7, 1058aa0a1e58SJeff Roberson IB_RNR_TIMER_000_16 = 8, 1059aa0a1e58SJeff Roberson IB_RNR_TIMER_000_24 = 9, 1060aa0a1e58SJeff Roberson IB_RNR_TIMER_000_32 = 10, 1061aa0a1e58SJeff Roberson IB_RNR_TIMER_000_48 = 11, 1062aa0a1e58SJeff Roberson IB_RNR_TIMER_000_64 = 12, 1063aa0a1e58SJeff Roberson IB_RNR_TIMER_000_96 = 13, 1064aa0a1e58SJeff Roberson IB_RNR_TIMER_001_28 = 14, 1065aa0a1e58SJeff Roberson IB_RNR_TIMER_001_92 = 15, 1066aa0a1e58SJeff Roberson IB_RNR_TIMER_002_56 = 16, 1067aa0a1e58SJeff Roberson IB_RNR_TIMER_003_84 = 17, 1068aa0a1e58SJeff Roberson IB_RNR_TIMER_005_12 = 18, 1069aa0a1e58SJeff Roberson IB_RNR_TIMER_007_68 = 19, 1070aa0a1e58SJeff Roberson IB_RNR_TIMER_010_24 = 20, 1071aa0a1e58SJeff Roberson IB_RNR_TIMER_015_36 = 21, 1072aa0a1e58SJeff Roberson IB_RNR_TIMER_020_48 = 22, 1073aa0a1e58SJeff Roberson IB_RNR_TIMER_030_72 = 23, 1074aa0a1e58SJeff Roberson IB_RNR_TIMER_040_96 = 24, 1075aa0a1e58SJeff Roberson IB_RNR_TIMER_061_44 = 25, 1076aa0a1e58SJeff Roberson IB_RNR_TIMER_081_92 = 26, 1077aa0a1e58SJeff Roberson IB_RNR_TIMER_122_88 = 27, 1078aa0a1e58SJeff Roberson IB_RNR_TIMER_163_84 = 28, 1079aa0a1e58SJeff Roberson IB_RNR_TIMER_245_76 = 29, 1080aa0a1e58SJeff Roberson IB_RNR_TIMER_327_68 = 30, 1081aa0a1e58SJeff Roberson IB_RNR_TIMER_491_52 = 31 1082aa0a1e58SJeff Roberson }; 1083aa0a1e58SJeff Roberson 1084aa0a1e58SJeff Roberson enum ib_qp_attr_mask { 1085aa0a1e58SJeff Roberson IB_QP_STATE = 1, 1086aa0a1e58SJeff Roberson IB_QP_CUR_STATE = (1<<1), 1087aa0a1e58SJeff Roberson IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), 1088aa0a1e58SJeff Roberson IB_QP_ACCESS_FLAGS = (1<<3), 1089aa0a1e58SJeff Roberson IB_QP_PKEY_INDEX = (1<<4), 1090aa0a1e58SJeff Roberson IB_QP_PORT = (1<<5), 1091aa0a1e58SJeff Roberson IB_QP_QKEY = (1<<6), 1092aa0a1e58SJeff Roberson IB_QP_AV = (1<<7), 1093aa0a1e58SJeff Roberson IB_QP_PATH_MTU = (1<<8), 1094aa0a1e58SJeff Roberson IB_QP_TIMEOUT = (1<<9), 1095aa0a1e58SJeff Roberson IB_QP_RETRY_CNT = (1<<10), 1096aa0a1e58SJeff Roberson IB_QP_RNR_RETRY = (1<<11), 1097aa0a1e58SJeff Roberson IB_QP_RQ_PSN = (1<<12), 1098aa0a1e58SJeff Roberson IB_QP_MAX_QP_RD_ATOMIC = (1<<13), 1099aa0a1e58SJeff Roberson IB_QP_ALT_PATH = (1<<14), 1100aa0a1e58SJeff Roberson IB_QP_MIN_RNR_TIMER = (1<<15), 1101aa0a1e58SJeff Roberson IB_QP_SQ_PSN = (1<<16), 1102aa0a1e58SJeff Roberson IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), 1103aa0a1e58SJeff Roberson IB_QP_PATH_MIG_STATE = (1<<18), 1104aa0a1e58SJeff Roberson IB_QP_CAP = (1<<19), 1105c9f432b7SAlfred Perlstein IB_QP_DEST_QPN = (1<<20), 1106*478d3005SHans Petter Selasky IB_QP_RESERVED1 = (1<<21), 1107*478d3005SHans Petter Selasky IB_QP_RESERVED2 = (1<<22), 1108*478d3005SHans Petter Selasky IB_QP_RESERVED3 = (1<<23), 1109*478d3005SHans Petter Selasky IB_QP_RESERVED4 = (1<<24), 1110aa0a1e58SJeff Roberson }; 1111aa0a1e58SJeff Roberson 1112aa0a1e58SJeff Roberson enum ib_qp_state { 1113aa0a1e58SJeff Roberson IB_QPS_RESET, 1114aa0a1e58SJeff Roberson IB_QPS_INIT, 1115aa0a1e58SJeff Roberson IB_QPS_RTR, 1116aa0a1e58SJeff Roberson IB_QPS_RTS, 1117aa0a1e58SJeff Roberson IB_QPS_SQD, 1118aa0a1e58SJeff Roberson IB_QPS_SQE, 1119b5c1e0cbSHans Petter Selasky IB_QPS_ERR, 1120*478d3005SHans Petter Selasky IB_QPS_DUMMY = -1, /* force enum signed */ 1121aa0a1e58SJeff Roberson }; 1122aa0a1e58SJeff Roberson 1123aa0a1e58SJeff Roberson enum ib_mig_state { 1124aa0a1e58SJeff Roberson IB_MIG_MIGRATED, 1125aa0a1e58SJeff Roberson IB_MIG_REARM, 1126aa0a1e58SJeff Roberson IB_MIG_ARMED 1127aa0a1e58SJeff Roberson }; 1128aa0a1e58SJeff Roberson 1129b5c1e0cbSHans Petter Selasky enum ib_mw_type { 1130b5c1e0cbSHans Petter Selasky IB_MW_TYPE_1 = 1, 1131b5c1e0cbSHans Petter Selasky IB_MW_TYPE_2 = 2 1132b5c1e0cbSHans Petter Selasky }; 1133b5c1e0cbSHans Petter Selasky 1134aa0a1e58SJeff Roberson struct ib_qp_attr { 1135aa0a1e58SJeff Roberson enum ib_qp_state qp_state; 1136aa0a1e58SJeff Roberson enum ib_qp_state cur_qp_state; 1137aa0a1e58SJeff Roberson enum ib_mtu path_mtu; 1138aa0a1e58SJeff Roberson enum ib_mig_state path_mig_state; 1139aa0a1e58SJeff Roberson u32 qkey; 1140aa0a1e58SJeff Roberson u32 rq_psn; 1141aa0a1e58SJeff Roberson u32 sq_psn; 1142aa0a1e58SJeff Roberson u32 dest_qp_num; 1143aa0a1e58SJeff Roberson int qp_access_flags; 1144aa0a1e58SJeff Roberson struct ib_qp_cap cap; 1145aa0a1e58SJeff Roberson struct ib_ah_attr ah_attr; 1146aa0a1e58SJeff Roberson struct ib_ah_attr alt_ah_attr; 1147aa0a1e58SJeff Roberson u16 pkey_index; 1148aa0a1e58SJeff Roberson u16 alt_pkey_index; 1149aa0a1e58SJeff Roberson u8 en_sqd_async_notify; 1150aa0a1e58SJeff Roberson u8 sq_draining; 1151aa0a1e58SJeff Roberson u8 max_rd_atomic; 1152aa0a1e58SJeff Roberson u8 max_dest_rd_atomic; 1153aa0a1e58SJeff Roberson u8 min_rnr_timer; 1154aa0a1e58SJeff Roberson u8 port_num; 1155aa0a1e58SJeff Roberson u8 timeout; 1156aa0a1e58SJeff Roberson u8 retry_cnt; 1157aa0a1e58SJeff Roberson u8 rnr_retry; 1158aa0a1e58SJeff Roberson u8 alt_port_num; 1159aa0a1e58SJeff Roberson u8 alt_timeout; 1160aa0a1e58SJeff Roberson }; 1161aa0a1e58SJeff Roberson 1162aa0a1e58SJeff Roberson enum ib_wr_opcode { 1163aa0a1e58SJeff Roberson IB_WR_RDMA_WRITE, 1164aa0a1e58SJeff Roberson IB_WR_RDMA_WRITE_WITH_IMM, 1165aa0a1e58SJeff Roberson IB_WR_SEND, 1166aa0a1e58SJeff Roberson IB_WR_SEND_WITH_IMM, 1167aa0a1e58SJeff Roberson IB_WR_RDMA_READ, 1168aa0a1e58SJeff Roberson IB_WR_ATOMIC_CMP_AND_SWP, 1169aa0a1e58SJeff Roberson IB_WR_ATOMIC_FETCH_AND_ADD, 1170aa0a1e58SJeff Roberson IB_WR_LSO, 1171aa0a1e58SJeff Roberson IB_WR_SEND_WITH_INV, 1172aa0a1e58SJeff Roberson IB_WR_RDMA_READ_WITH_INV, 1173aa0a1e58SJeff Roberson IB_WR_LOCAL_INV, 1174*478d3005SHans Petter Selasky IB_WR_REG_MR, 1175aa0a1e58SJeff Roberson IB_WR_MASKED_ATOMIC_CMP_AND_SWP, 1176aa0a1e58SJeff Roberson IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, 1177b5c1e0cbSHans Petter Selasky IB_WR_REG_SIG_MR, 1178b5c1e0cbSHans Petter Selasky /* reserve values for low level drivers' internal use. 1179b5c1e0cbSHans Petter Selasky * These values will not be used at all in the ib core layer. 1180b5c1e0cbSHans Petter Selasky */ 1181b5c1e0cbSHans Petter Selasky IB_WR_RESERVED1 = 0xf0, 1182b5c1e0cbSHans Petter Selasky IB_WR_RESERVED2, 1183b5c1e0cbSHans Petter Selasky IB_WR_RESERVED3, 1184b5c1e0cbSHans Petter Selasky IB_WR_RESERVED4, 1185b5c1e0cbSHans Petter Selasky IB_WR_RESERVED5, 1186b5c1e0cbSHans Petter Selasky IB_WR_RESERVED6, 1187b5c1e0cbSHans Petter Selasky IB_WR_RESERVED7, 1188b5c1e0cbSHans Petter Selasky IB_WR_RESERVED8, 1189b5c1e0cbSHans Petter Selasky IB_WR_RESERVED9, 1190b5c1e0cbSHans Petter Selasky IB_WR_RESERVED10, 1191*478d3005SHans Petter Selasky IB_WR_DUMMY = -1, /* force enum signed */ 1192aa0a1e58SJeff Roberson }; 1193aa0a1e58SJeff Roberson 1194aa0a1e58SJeff Roberson enum ib_send_flags { 1195aa0a1e58SJeff Roberson IB_SEND_FENCE = 1, 1196aa0a1e58SJeff Roberson IB_SEND_SIGNALED = (1<<1), 1197aa0a1e58SJeff Roberson IB_SEND_SOLICITED = (1<<2), 1198aa0a1e58SJeff Roberson IB_SEND_INLINE = (1<<3), 1199b5c1e0cbSHans Petter Selasky IB_SEND_IP_CSUM = (1<<4), 1200aa0a1e58SJeff Roberson 1201b5c1e0cbSHans Petter Selasky /* reserve bits 26-31 for low level drivers' internal use */ 1202b5c1e0cbSHans Petter Selasky IB_SEND_RESERVED_START = (1 << 26), 1203b5c1e0cbSHans Petter Selasky IB_SEND_RESERVED_END = (1 << 31), 1204c9f432b7SAlfred Perlstein }; 1205c9f432b7SAlfred Perlstein 1206aa0a1e58SJeff Roberson struct ib_sge { 1207aa0a1e58SJeff Roberson u64 addr; 1208aa0a1e58SJeff Roberson u32 length; 1209aa0a1e58SJeff Roberson u32 lkey; 1210aa0a1e58SJeff Roberson }; 1211aa0a1e58SJeff Roberson 1212*478d3005SHans Petter Selasky struct ib_cqe { 1213*478d3005SHans Petter Selasky void (*done)(struct ib_cq *cq, struct ib_wc *wc); 1214b5c1e0cbSHans Petter Selasky }; 1215b5c1e0cbSHans Petter Selasky 1216aa0a1e58SJeff Roberson struct ib_send_wr { 1217aa0a1e58SJeff Roberson struct ib_send_wr *next; 1218*478d3005SHans Petter Selasky union { 1219aa0a1e58SJeff Roberson u64 wr_id; 1220*478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 1221*478d3005SHans Petter Selasky }; 1222aa0a1e58SJeff Roberson struct ib_sge *sg_list; 1223aa0a1e58SJeff Roberson int num_sge; 1224aa0a1e58SJeff Roberson enum ib_wr_opcode opcode; 1225aa0a1e58SJeff Roberson int send_flags; 1226aa0a1e58SJeff Roberson union { 1227aa0a1e58SJeff Roberson __be32 imm_data; 1228aa0a1e58SJeff Roberson u32 invalidate_rkey; 1229aa0a1e58SJeff Roberson } ex; 1230*478d3005SHans Petter Selasky }; 1231*478d3005SHans Petter Selasky 1232*478d3005SHans Petter Selasky struct ib_rdma_wr { 1233*478d3005SHans Petter Selasky struct ib_send_wr wr; 1234aa0a1e58SJeff Roberson u64 remote_addr; 1235aa0a1e58SJeff Roberson u32 rkey; 1236*478d3005SHans Petter Selasky }; 1237*478d3005SHans Petter Selasky 1238*478d3005SHans Petter Selasky static inline struct ib_rdma_wr *rdma_wr(struct ib_send_wr *wr) 1239*478d3005SHans Petter Selasky { 1240*478d3005SHans Petter Selasky return container_of(wr, struct ib_rdma_wr, wr); 1241*478d3005SHans Petter Selasky } 1242*478d3005SHans Petter Selasky 1243*478d3005SHans Petter Selasky struct ib_atomic_wr { 1244*478d3005SHans Petter Selasky struct ib_send_wr wr; 1245aa0a1e58SJeff Roberson u64 remote_addr; 1246aa0a1e58SJeff Roberson u64 compare_add; 1247aa0a1e58SJeff Roberson u64 swap; 1248aa0a1e58SJeff Roberson u64 compare_add_mask; 1249aa0a1e58SJeff Roberson u64 swap_mask; 1250aa0a1e58SJeff Roberson u32 rkey; 1251*478d3005SHans Petter Selasky }; 1252*478d3005SHans Petter Selasky 1253*478d3005SHans Petter Selasky static inline struct ib_atomic_wr *atomic_wr(struct ib_send_wr *wr) 1254*478d3005SHans Petter Selasky { 1255*478d3005SHans Petter Selasky return container_of(wr, struct ib_atomic_wr, wr); 1256*478d3005SHans Petter Selasky } 1257*478d3005SHans Petter Selasky 1258*478d3005SHans Petter Selasky struct ib_ud_wr { 1259*478d3005SHans Petter Selasky struct ib_send_wr wr; 1260aa0a1e58SJeff Roberson struct ib_ah *ah; 1261aa0a1e58SJeff Roberson void *header; 1262aa0a1e58SJeff Roberson int hlen; 1263aa0a1e58SJeff Roberson int mss; 1264aa0a1e58SJeff Roberson u32 remote_qpn; 1265aa0a1e58SJeff Roberson u32 remote_qkey; 1266aa0a1e58SJeff Roberson u16 pkey_index; /* valid for GSI only */ 1267aa0a1e58SJeff Roberson u8 port_num; /* valid for DR SMPs on switch only */ 1268*478d3005SHans Petter Selasky }; 1269*478d3005SHans Petter Selasky 1270*478d3005SHans Petter Selasky static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr) 1271*478d3005SHans Petter Selasky { 1272*478d3005SHans Petter Selasky return container_of(wr, struct ib_ud_wr, wr); 1273*478d3005SHans Petter Selasky } 1274*478d3005SHans Petter Selasky 1275*478d3005SHans Petter Selasky struct ib_reg_wr { 1276*478d3005SHans Petter Selasky struct ib_send_wr wr; 1277*478d3005SHans Petter Selasky struct ib_mr *mr; 1278*478d3005SHans Petter Selasky u32 key; 1279*478d3005SHans Petter Selasky int access; 1280*478d3005SHans Petter Selasky }; 1281*478d3005SHans Petter Selasky 1282*478d3005SHans Petter Selasky static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr) 1283*478d3005SHans Petter Selasky { 1284*478d3005SHans Petter Selasky return container_of(wr, struct ib_reg_wr, wr); 1285*478d3005SHans Petter Selasky } 1286*478d3005SHans Petter Selasky 1287*478d3005SHans Petter Selasky struct ib_sig_handover_wr { 1288*478d3005SHans Petter Selasky struct ib_send_wr wr; 1289b5c1e0cbSHans Petter Selasky struct ib_sig_attrs *sig_attrs; 1290b5c1e0cbSHans Petter Selasky struct ib_mr *sig_mr; 1291b5c1e0cbSHans Petter Selasky int access_flags; 1292b5c1e0cbSHans Petter Selasky struct ib_sge *prot; 1293aa0a1e58SJeff Roberson }; 1294aa0a1e58SJeff Roberson 1295*478d3005SHans Petter Selasky static inline struct ib_sig_handover_wr *sig_handover_wr(struct ib_send_wr *wr) 1296*478d3005SHans Petter Selasky { 1297*478d3005SHans Petter Selasky return container_of(wr, struct ib_sig_handover_wr, wr); 1298*478d3005SHans Petter Selasky } 1299*478d3005SHans Petter Selasky 1300aa0a1e58SJeff Roberson struct ib_recv_wr { 1301aa0a1e58SJeff Roberson struct ib_recv_wr *next; 1302*478d3005SHans Petter Selasky union { 1303aa0a1e58SJeff Roberson u64 wr_id; 1304*478d3005SHans Petter Selasky struct ib_cqe *wr_cqe; 1305*478d3005SHans Petter Selasky }; 1306aa0a1e58SJeff Roberson struct ib_sge *sg_list; 1307aa0a1e58SJeff Roberson int num_sge; 1308aa0a1e58SJeff Roberson }; 1309aa0a1e58SJeff Roberson 1310aa0a1e58SJeff Roberson enum ib_access_flags { 1311aa0a1e58SJeff Roberson IB_ACCESS_LOCAL_WRITE = 1, 1312aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_WRITE = (1<<1), 1313aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_READ = (1<<2), 1314aa0a1e58SJeff Roberson IB_ACCESS_REMOTE_ATOMIC = (1<<3), 1315c9f432b7SAlfred Perlstein IB_ACCESS_MW_BIND = (1<<4), 1316*478d3005SHans Petter Selasky IB_ZERO_BASED = (1<<5), 1317*478d3005SHans Petter Selasky IB_ACCESS_ON_DEMAND = (1<<6), 1318aa0a1e58SJeff Roberson }; 1319aa0a1e58SJeff Roberson 1320*478d3005SHans Petter Selasky /* 1321*478d3005SHans Petter Selasky * XXX: these are apparently used for ->rereg_user_mr, no idea why they 1322*478d3005SHans Petter Selasky * are hidden here instead of a uapi header! 1323*478d3005SHans Petter Selasky */ 1324aa0a1e58SJeff Roberson enum ib_mr_rereg_flags { 1325aa0a1e58SJeff Roberson IB_MR_REREG_TRANS = 1, 1326aa0a1e58SJeff Roberson IB_MR_REREG_PD = (1<<1), 1327*478d3005SHans Petter Selasky IB_MR_REREG_ACCESS = (1<<2), 1328*478d3005SHans Petter Selasky IB_MR_REREG_SUPPORTED = ((IB_MR_REREG_ACCESS << 1) - 1) 1329aa0a1e58SJeff Roberson }; 1330aa0a1e58SJeff Roberson 1331aa0a1e58SJeff Roberson struct ib_fmr_attr { 1332aa0a1e58SJeff Roberson int max_pages; 1333aa0a1e58SJeff Roberson int max_maps; 1334aa0a1e58SJeff Roberson u8 page_shift; 1335aa0a1e58SJeff Roberson }; 1336aa0a1e58SJeff Roberson 1337*478d3005SHans Petter Selasky struct ib_umem; 1338*478d3005SHans Petter Selasky 1339aa0a1e58SJeff Roberson struct ib_ucontext { 1340aa0a1e58SJeff Roberson struct ib_device *device; 1341aa0a1e58SJeff Roberson struct list_head pd_list; 1342aa0a1e58SJeff Roberson struct list_head mr_list; 1343aa0a1e58SJeff Roberson struct list_head mw_list; 1344aa0a1e58SJeff Roberson struct list_head cq_list; 1345aa0a1e58SJeff Roberson struct list_head qp_list; 1346aa0a1e58SJeff Roberson struct list_head srq_list; 1347aa0a1e58SJeff Roberson struct list_head ah_list; 1348c9f432b7SAlfred Perlstein struct list_head xrcd_list; 1349b5c1e0cbSHans Petter Selasky struct list_head rule_list; 1350*478d3005SHans Petter Selasky struct list_head wq_list; 1351*478d3005SHans Petter Selasky struct list_head rwq_ind_tbl_list; 1352aa0a1e58SJeff Roberson int closing; 1353*478d3005SHans Petter Selasky 1354*478d3005SHans Petter Selasky pid_t tgid; 1355*478d3005SHans Petter Selasky #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING 1356*478d3005SHans Petter Selasky struct rb_root umem_tree; 1357*478d3005SHans Petter Selasky /* 1358*478d3005SHans Petter Selasky * Protects .umem_rbroot and tree, as well as odp_mrs_count and 1359*478d3005SHans Petter Selasky * mmu notifiers registration. 1360*478d3005SHans Petter Selasky */ 1361*478d3005SHans Petter Selasky struct rw_semaphore umem_rwsem; 1362*478d3005SHans Petter Selasky void (*invalidate_range)(struct ib_umem *umem, 1363*478d3005SHans Petter Selasky unsigned long start, unsigned long end); 1364*478d3005SHans Petter Selasky 1365*478d3005SHans Petter Selasky struct mmu_notifier mn; 1366*478d3005SHans Petter Selasky atomic_t notifier_count; 1367*478d3005SHans Petter Selasky /* A list of umems that don't have private mmu notifier counters yet. */ 1368*478d3005SHans Petter Selasky struct list_head no_private_counters; 1369*478d3005SHans Petter Selasky int odp_mrs_count; 1370*478d3005SHans Petter Selasky #endif 1371aa0a1e58SJeff Roberson }; 1372aa0a1e58SJeff Roberson 1373aa0a1e58SJeff Roberson struct ib_uobject { 1374aa0a1e58SJeff Roberson u64 user_handle; /* handle given to us by userspace */ 1375aa0a1e58SJeff Roberson struct ib_ucontext *context; /* associated user context */ 1376aa0a1e58SJeff Roberson void *object; /* containing object */ 1377aa0a1e58SJeff Roberson struct list_head list; /* link to context's list */ 1378aa0a1e58SJeff Roberson int id; /* index into kernel idr */ 1379aa0a1e58SJeff Roberson struct kref ref; 1380aa0a1e58SJeff Roberson struct rw_semaphore mutex; /* protects .live */ 1381*478d3005SHans Petter Selasky struct rcu_head rcu; /* kfree_rcu() overhead */ 1382aa0a1e58SJeff Roberson int live; 1383aa0a1e58SJeff Roberson }; 1384aa0a1e58SJeff Roberson 1385aa0a1e58SJeff Roberson struct ib_udata { 1386*478d3005SHans Petter Selasky const void __user *inbuf; 1387aa0a1e58SJeff Roberson void __user *outbuf; 1388aa0a1e58SJeff Roberson size_t inlen; 1389aa0a1e58SJeff Roberson size_t outlen; 1390aa0a1e58SJeff Roberson }; 1391aa0a1e58SJeff Roberson 1392aa0a1e58SJeff Roberson struct ib_pd { 1393*478d3005SHans Petter Selasky u32 local_dma_lkey; 1394*478d3005SHans Petter Selasky u32 flags; 1395aa0a1e58SJeff Roberson struct ib_device *device; 1396aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1397aa0a1e58SJeff Roberson atomic_t usecnt; /* count all resources */ 1398*478d3005SHans Petter Selasky 1399*478d3005SHans Petter Selasky u32 unsafe_global_rkey; 1400*478d3005SHans Petter Selasky 1401*478d3005SHans Petter Selasky /* 1402*478d3005SHans Petter Selasky * Implementation details of the RDMA core, don't use in drivers: 1403*478d3005SHans Petter Selasky */ 1404*478d3005SHans Petter Selasky struct ib_mr *__internal_mr; 1405aa0a1e58SJeff Roberson }; 1406aa0a1e58SJeff Roberson 1407aa0a1e58SJeff Roberson struct ib_xrcd { 1408aa0a1e58SJeff Roberson struct ib_device *device; 1409c9f432b7SAlfred Perlstein atomic_t usecnt; /* count all exposed resources */ 1410aa0a1e58SJeff Roberson struct inode *inode; 1411aa0a1e58SJeff Roberson 1412c9f432b7SAlfred Perlstein struct mutex tgt_qp_mutex; 1413c9f432b7SAlfred Perlstein struct list_head tgt_qp_list; 1414c9f432b7SAlfred Perlstein }; 1415aa0a1e58SJeff Roberson 1416aa0a1e58SJeff Roberson struct ib_ah { 1417aa0a1e58SJeff Roberson struct ib_device *device; 1418aa0a1e58SJeff Roberson struct ib_pd *pd; 1419aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1420aa0a1e58SJeff Roberson }; 1421aa0a1e58SJeff Roberson 1422aa0a1e58SJeff Roberson typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); 1423aa0a1e58SJeff Roberson 1424*478d3005SHans Petter Selasky enum ib_poll_context { 1425*478d3005SHans Petter Selasky IB_POLL_DIRECT, /* caller context, no hw completions */ 1426*478d3005SHans Petter Selasky IB_POLL_SOFTIRQ, /* poll from softirq context */ 1427*478d3005SHans Petter Selasky IB_POLL_WORKQUEUE, /* poll from workqueue */ 1428*478d3005SHans Petter Selasky }; 1429*478d3005SHans Petter Selasky 1430aa0a1e58SJeff Roberson struct ib_cq { 1431aa0a1e58SJeff Roberson struct ib_device *device; 1432aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1433aa0a1e58SJeff Roberson ib_comp_handler comp_handler; 1434aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1435aa0a1e58SJeff Roberson void *cq_context; 1436aa0a1e58SJeff Roberson int cqe; 1437aa0a1e58SJeff Roberson atomic_t usecnt; /* count number of work queues */ 1438*478d3005SHans Petter Selasky enum ib_poll_context poll_ctx; 1439*478d3005SHans Petter Selasky struct work_struct work; 1440aa0a1e58SJeff Roberson }; 1441aa0a1e58SJeff Roberson 1442aa0a1e58SJeff Roberson struct ib_srq { 1443aa0a1e58SJeff Roberson struct ib_device *device; 1444aa0a1e58SJeff Roberson struct ib_pd *pd; 1445aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1446aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1447aa0a1e58SJeff Roberson void *srq_context; 1448c9f432b7SAlfred Perlstein enum ib_srq_type srq_type; 1449aa0a1e58SJeff Roberson atomic_t usecnt; 1450c9f432b7SAlfred Perlstein 1451c9f432b7SAlfred Perlstein union { 1452c9f432b7SAlfred Perlstein struct { 1453c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; 1454c9f432b7SAlfred Perlstein struct ib_cq *cq; 1455c9f432b7SAlfred Perlstein u32 srq_num; 1456c9f432b7SAlfred Perlstein } xrc; 1457c9f432b7SAlfred Perlstein } ext; 1458aa0a1e58SJeff Roberson }; 1459aa0a1e58SJeff Roberson 1460*478d3005SHans Petter Selasky enum ib_wq_type { 1461*478d3005SHans Petter Selasky IB_WQT_RQ 1462*478d3005SHans Petter Selasky }; 1463*478d3005SHans Petter Selasky 1464*478d3005SHans Petter Selasky enum ib_wq_state { 1465*478d3005SHans Petter Selasky IB_WQS_RESET, 1466*478d3005SHans Petter Selasky IB_WQS_RDY, 1467*478d3005SHans Petter Selasky IB_WQS_ERR 1468*478d3005SHans Petter Selasky }; 1469*478d3005SHans Petter Selasky 1470*478d3005SHans Petter Selasky struct ib_wq { 1471*478d3005SHans Petter Selasky struct ib_device *device; 1472*478d3005SHans Petter Selasky struct ib_uobject *uobject; 1473*478d3005SHans Petter Selasky void *wq_context; 1474*478d3005SHans Petter Selasky void (*event_handler)(struct ib_event *, void *); 1475*478d3005SHans Petter Selasky struct ib_pd *pd; 1476*478d3005SHans Petter Selasky struct ib_cq *cq; 1477*478d3005SHans Petter Selasky u32 wq_num; 1478*478d3005SHans Petter Selasky enum ib_wq_state state; 1479*478d3005SHans Petter Selasky enum ib_wq_type wq_type; 1480*478d3005SHans Petter Selasky atomic_t usecnt; 1481*478d3005SHans Petter Selasky }; 1482*478d3005SHans Petter Selasky 1483*478d3005SHans Petter Selasky struct ib_wq_init_attr { 1484*478d3005SHans Petter Selasky void *wq_context; 1485*478d3005SHans Petter Selasky enum ib_wq_type wq_type; 1486*478d3005SHans Petter Selasky u32 max_wr; 1487*478d3005SHans Petter Selasky u32 max_sge; 1488*478d3005SHans Petter Selasky struct ib_cq *cq; 1489*478d3005SHans Petter Selasky void (*event_handler)(struct ib_event *, void *); 1490*478d3005SHans Petter Selasky }; 1491*478d3005SHans Petter Selasky 1492*478d3005SHans Petter Selasky enum ib_wq_attr_mask { 1493*478d3005SHans Petter Selasky IB_WQ_STATE = 1 << 0, 1494*478d3005SHans Petter Selasky IB_WQ_CUR_STATE = 1 << 1, 1495*478d3005SHans Petter Selasky }; 1496*478d3005SHans Petter Selasky 1497*478d3005SHans Petter Selasky struct ib_wq_attr { 1498*478d3005SHans Petter Selasky enum ib_wq_state wq_state; 1499*478d3005SHans Petter Selasky enum ib_wq_state curr_wq_state; 1500*478d3005SHans Petter Selasky }; 1501*478d3005SHans Petter Selasky 1502*478d3005SHans Petter Selasky struct ib_rwq_ind_table { 1503*478d3005SHans Petter Selasky struct ib_device *device; 1504*478d3005SHans Petter Selasky struct ib_uobject *uobject; 1505*478d3005SHans Petter Selasky atomic_t usecnt; 1506*478d3005SHans Petter Selasky u32 ind_tbl_num; 1507*478d3005SHans Petter Selasky u32 log_ind_tbl_size; 1508*478d3005SHans Petter Selasky struct ib_wq **ind_tbl; 1509*478d3005SHans Petter Selasky }; 1510*478d3005SHans Petter Selasky 1511*478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr { 1512*478d3005SHans Petter Selasky u32 log_ind_tbl_size; 1513*478d3005SHans Petter Selasky /* Each entry is a pointer to Receive Work Queue */ 1514*478d3005SHans Petter Selasky struct ib_wq **ind_tbl; 1515*478d3005SHans Petter Selasky }; 1516*478d3005SHans Petter Selasky 1517*478d3005SHans Petter Selasky /* 1518*478d3005SHans Petter Selasky * @max_write_sge: Maximum SGE elements per RDMA WRITE request. 1519*478d3005SHans Petter Selasky * @max_read_sge: Maximum SGE elements per RDMA READ request. 1520*478d3005SHans Petter Selasky */ 1521aa0a1e58SJeff Roberson struct ib_qp { 1522aa0a1e58SJeff Roberson struct ib_device *device; 1523aa0a1e58SJeff Roberson struct ib_pd *pd; 1524aa0a1e58SJeff Roberson struct ib_cq *send_cq; 1525aa0a1e58SJeff Roberson struct ib_cq *recv_cq; 1526*478d3005SHans Petter Selasky spinlock_t mr_lock; 1527aa0a1e58SJeff Roberson struct ib_srq *srq; 1528c9f432b7SAlfred Perlstein struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 1529c9f432b7SAlfred Perlstein struct list_head xrcd_list; 1530*478d3005SHans Petter Selasky 1531b5c1e0cbSHans Petter Selasky /* count times opened, mcast attaches, flow attaches */ 1532b5c1e0cbSHans Petter Selasky atomic_t usecnt; 1533c9f432b7SAlfred Perlstein struct list_head open_list; 1534c9f432b7SAlfred Perlstein struct ib_qp *real_qp; 1535aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1536aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *); 1537aa0a1e58SJeff Roberson void *qp_context; 1538aa0a1e58SJeff Roberson u32 qp_num; 1539*478d3005SHans Petter Selasky u32 max_write_sge; 1540*478d3005SHans Petter Selasky u32 max_read_sge; 1541aa0a1e58SJeff Roberson enum ib_qp_type qp_type; 1542*478d3005SHans Petter Selasky struct ib_rwq_ind_table *rwq_ind_tbl; 1543aa0a1e58SJeff Roberson }; 1544aa0a1e58SJeff Roberson 1545aa0a1e58SJeff Roberson struct ib_mr { 1546aa0a1e58SJeff Roberson struct ib_device *device; 1547aa0a1e58SJeff Roberson struct ib_pd *pd; 1548aa0a1e58SJeff Roberson u32 lkey; 1549aa0a1e58SJeff Roberson u32 rkey; 1550*478d3005SHans Petter Selasky u64 iova; 1551*478d3005SHans Petter Selasky u32 length; 1552*478d3005SHans Petter Selasky unsigned int page_size; 1553*478d3005SHans Petter Selasky bool need_inval; 1554*478d3005SHans Petter Selasky union { 1555*478d3005SHans Petter Selasky struct ib_uobject *uobject; /* user */ 1556*478d3005SHans Petter Selasky struct list_head qp_entry; /* FR */ 1557*478d3005SHans Petter Selasky }; 1558aa0a1e58SJeff Roberson }; 1559aa0a1e58SJeff Roberson 1560aa0a1e58SJeff Roberson struct ib_mw { 1561aa0a1e58SJeff Roberson struct ib_device *device; 1562aa0a1e58SJeff Roberson struct ib_pd *pd; 1563aa0a1e58SJeff Roberson struct ib_uobject *uobject; 1564aa0a1e58SJeff Roberson u32 rkey; 1565b5c1e0cbSHans Petter Selasky enum ib_mw_type type; 1566aa0a1e58SJeff Roberson }; 1567aa0a1e58SJeff Roberson 1568aa0a1e58SJeff Roberson struct ib_fmr { 1569aa0a1e58SJeff Roberson struct ib_device *device; 1570aa0a1e58SJeff Roberson struct ib_pd *pd; 1571aa0a1e58SJeff Roberson struct list_head list; 1572aa0a1e58SJeff Roberson u32 lkey; 1573aa0a1e58SJeff Roberson u32 rkey; 1574aa0a1e58SJeff Roberson }; 1575aa0a1e58SJeff Roberson 1576b5c1e0cbSHans Petter Selasky /* Supported steering options */ 1577b5c1e0cbSHans Petter Selasky enum ib_flow_attr_type { 1578b5c1e0cbSHans Petter Selasky /* steering according to rule specifications */ 1579b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_NORMAL = 0x0, 1580b5c1e0cbSHans Petter Selasky /* default unicast and multicast rule - 1581b5c1e0cbSHans Petter Selasky * receive all Eth traffic which isn't steered to any QP 1582b5c1e0cbSHans Petter Selasky */ 1583b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_ALL_DEFAULT = 0x1, 1584b5c1e0cbSHans Petter Selasky /* default multicast rule - 1585b5c1e0cbSHans Petter Selasky * receive all Eth multicast traffic which isn't steered to any QP 1586b5c1e0cbSHans Petter Selasky */ 1587b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_MC_DEFAULT = 0x2, 1588b5c1e0cbSHans Petter Selasky /* sniffer rule - receive all port traffic */ 1589b5c1e0cbSHans Petter Selasky IB_FLOW_ATTR_SNIFFER = 0x3 1590b5c1e0cbSHans Petter Selasky }; 1591b5c1e0cbSHans Petter Selasky 1592b5c1e0cbSHans Petter Selasky /* Supported steering header types */ 1593b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type { 1594b5c1e0cbSHans Petter Selasky /* L2 headers*/ 1595b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_ETH = 0x20, 1596*478d3005SHans Petter Selasky IB_FLOW_SPEC_IB = 0x22, 1597b5c1e0cbSHans Petter Selasky /* L3 header*/ 1598b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_IPV4 = 0x30, 1599*478d3005SHans Petter Selasky IB_FLOW_SPEC_IPV6 = 0x31, 1600b5c1e0cbSHans Petter Selasky /* L4 headers*/ 1601b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_TCP = 0x40, 1602b5c1e0cbSHans Petter Selasky IB_FLOW_SPEC_UDP = 0x41 1603b5c1e0cbSHans Petter Selasky }; 1604*478d3005SHans Petter Selasky #define IB_FLOW_SPEC_LAYER_MASK 0xF0 1605b5c1e0cbSHans Petter Selasky #define IB_FLOW_SPEC_SUPPORT_LAYERS 4 1606b5c1e0cbSHans Petter Selasky 1607b5c1e0cbSHans Petter Selasky /* Flow steering rule priority is set according to it's domain. 1608b5c1e0cbSHans Petter Selasky * Lower domain value means higher priority. 1609b5c1e0cbSHans Petter Selasky */ 1610b5c1e0cbSHans Petter Selasky enum ib_flow_domain { 1611b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_USER, 1612b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_ETHTOOL, 1613b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_RFS, 1614b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_NIC, 1615b5c1e0cbSHans Petter Selasky IB_FLOW_DOMAIN_NUM /* Must be last */ 1616b5c1e0cbSHans Petter Selasky }; 1617b5c1e0cbSHans Petter Selasky 1618b5c1e0cbSHans Petter Selasky enum ib_flow_flags { 1619*478d3005SHans Petter Selasky IB_FLOW_ATTR_FLAGS_DONT_TRAP = 1UL << 1, /* Continue match, no steal */ 1620*478d3005SHans Petter Selasky IB_FLOW_ATTR_FLAGS_RESERVED = 1UL << 2 /* Must be last */ 1621b5c1e0cbSHans Petter Selasky }; 1622b5c1e0cbSHans Petter Selasky 1623b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter { 1624b5c1e0cbSHans Petter Selasky u8 dst_mac[6]; 1625b5c1e0cbSHans Petter Selasky u8 src_mac[6]; 1626b5c1e0cbSHans Petter Selasky __be16 ether_type; 1627b5c1e0cbSHans Petter Selasky __be16 vlan_tag; 1628*478d3005SHans Petter Selasky /* Must be last */ 1629*478d3005SHans Petter Selasky u8 real_sz[0]; 1630b5c1e0cbSHans Petter Selasky }; 1631b5c1e0cbSHans Petter Selasky 1632b5c1e0cbSHans Petter Selasky struct ib_flow_spec_eth { 1633b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1634b5c1e0cbSHans Petter Selasky u16 size; 1635b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter val; 1636b5c1e0cbSHans Petter Selasky struct ib_flow_eth_filter mask; 1637b5c1e0cbSHans Petter Selasky }; 1638b5c1e0cbSHans Petter Selasky 1639b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter { 1640*478d3005SHans Petter Selasky __be16 dlid; 1641*478d3005SHans Petter Selasky __u8 sl; 1642*478d3005SHans Petter Selasky /* Must be last */ 1643*478d3005SHans Petter Selasky u8 real_sz[0]; 1644b5c1e0cbSHans Petter Selasky }; 1645b5c1e0cbSHans Petter Selasky 1646b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ib { 1647b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1648b5c1e0cbSHans Petter Selasky u16 size; 1649b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter val; 1650b5c1e0cbSHans Petter Selasky struct ib_flow_ib_filter mask; 1651b5c1e0cbSHans Petter Selasky }; 1652b5c1e0cbSHans Petter Selasky 1653*478d3005SHans Petter Selasky /* IPv4 header flags */ 1654*478d3005SHans Petter Selasky enum ib_ipv4_flags { 1655*478d3005SHans Petter Selasky IB_IPV4_DONT_FRAG = 0x2, /* Don't enable packet fragmentation */ 1656*478d3005SHans Petter Selasky IB_IPV4_MORE_FRAG = 0X4 /* For All fragmented packets except the 1657*478d3005SHans Petter Selasky last have this flag set */ 1658*478d3005SHans Petter Selasky }; 1659*478d3005SHans Petter Selasky 1660b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter { 1661c9f432b7SAlfred Perlstein __be32 src_ip; 1662c9f432b7SAlfred Perlstein __be32 dst_ip; 1663*478d3005SHans Petter Selasky u8 proto; 1664*478d3005SHans Petter Selasky u8 tos; 1665*478d3005SHans Petter Selasky u8 ttl; 1666*478d3005SHans Petter Selasky u8 flags; 1667*478d3005SHans Petter Selasky /* Must be last */ 1668*478d3005SHans Petter Selasky u8 real_sz[0]; 1669b5c1e0cbSHans Petter Selasky }; 1670b5c1e0cbSHans Petter Selasky 1671b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ipv4 { 1672b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1673b5c1e0cbSHans Petter Selasky u16 size; 1674b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter val; 1675b5c1e0cbSHans Petter Selasky struct ib_flow_ipv4_filter mask; 1676b5c1e0cbSHans Petter Selasky }; 1677b5c1e0cbSHans Petter Selasky 1678*478d3005SHans Petter Selasky struct ib_flow_ipv6_filter { 1679*478d3005SHans Petter Selasky u8 src_ip[16]; 1680*478d3005SHans Petter Selasky u8 dst_ip[16]; 1681*478d3005SHans Petter Selasky __be32 flow_label; 1682*478d3005SHans Petter Selasky u8 next_hdr; 1683*478d3005SHans Petter Selasky u8 traffic_class; 1684*478d3005SHans Petter Selasky u8 hop_limit; 1685*478d3005SHans Petter Selasky /* Must be last */ 1686*478d3005SHans Petter Selasky u8 real_sz[0]; 1687*478d3005SHans Petter Selasky }; 1688*478d3005SHans Petter Selasky 1689*478d3005SHans Petter Selasky struct ib_flow_spec_ipv6 { 1690*478d3005SHans Petter Selasky enum ib_flow_spec_type type; 1691*478d3005SHans Petter Selasky u16 size; 1692*478d3005SHans Petter Selasky struct ib_flow_ipv6_filter val; 1693*478d3005SHans Petter Selasky struct ib_flow_ipv6_filter mask; 1694*478d3005SHans Petter Selasky }; 1695*478d3005SHans Petter Selasky 1696b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter { 1697c9f432b7SAlfred Perlstein __be16 dst_port; 1698b5c1e0cbSHans Petter Selasky __be16 src_port; 1699*478d3005SHans Petter Selasky /* Must be last */ 1700*478d3005SHans Petter Selasky u8 real_sz[0]; 1701b5c1e0cbSHans Petter Selasky }; 1702b5c1e0cbSHans Petter Selasky 1703b5c1e0cbSHans Petter Selasky struct ib_flow_spec_tcp_udp { 1704b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1705b5c1e0cbSHans Petter Selasky u16 size; 1706b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter val; 1707b5c1e0cbSHans Petter Selasky struct ib_flow_tcp_udp_filter mask; 1708b5c1e0cbSHans Petter Selasky }; 1709b5c1e0cbSHans Petter Selasky 1710b5c1e0cbSHans Petter Selasky union ib_flow_spec { 1711b5c1e0cbSHans Petter Selasky struct { 1712b5c1e0cbSHans Petter Selasky enum ib_flow_spec_type type; 1713b5c1e0cbSHans Petter Selasky u16 size; 1714b5c1e0cbSHans Petter Selasky }; 1715b5c1e0cbSHans Petter Selasky struct ib_flow_spec_eth eth; 1716*478d3005SHans Petter Selasky struct ib_flow_spec_ib ib; 1717b5c1e0cbSHans Petter Selasky struct ib_flow_spec_ipv4 ipv4; 1718b5c1e0cbSHans Petter Selasky struct ib_flow_spec_tcp_udp tcp_udp; 1719*478d3005SHans Petter Selasky struct ib_flow_spec_ipv6 ipv6; 1720b5c1e0cbSHans Petter Selasky }; 1721b5c1e0cbSHans Petter Selasky 1722b5c1e0cbSHans Petter Selasky struct ib_flow_attr { 1723b5c1e0cbSHans Petter Selasky enum ib_flow_attr_type type; 1724b5c1e0cbSHans Petter Selasky u16 size; 1725b5c1e0cbSHans Petter Selasky u16 priority; 1726*478d3005SHans Petter Selasky u32 flags; 1727b5c1e0cbSHans Petter Selasky u8 num_of_specs; 1728b5c1e0cbSHans Petter Selasky u8 port; 1729b5c1e0cbSHans Petter Selasky /* Following are the optional layers according to user request 1730b5c1e0cbSHans Petter Selasky * struct ib_flow_spec_xxx 1731b5c1e0cbSHans Petter Selasky * struct ib_flow_spec_yyy 1732b5c1e0cbSHans Petter Selasky */ 1733b5c1e0cbSHans Petter Selasky }; 1734b5c1e0cbSHans Petter Selasky 1735b5c1e0cbSHans Petter Selasky struct ib_flow { 1736b5c1e0cbSHans Petter Selasky struct ib_qp *qp; 1737b5c1e0cbSHans Petter Selasky struct ib_uobject *uobject; 1738c9f432b7SAlfred Perlstein }; 1739c9f432b7SAlfred Perlstein 1740*478d3005SHans Petter Selasky struct ib_mad_hdr; 1741aa0a1e58SJeff Roberson struct ib_grh; 1742aa0a1e58SJeff Roberson 1743aa0a1e58SJeff Roberson enum ib_process_mad_flags { 1744aa0a1e58SJeff Roberson IB_MAD_IGNORE_MKEY = 1, 1745aa0a1e58SJeff Roberson IB_MAD_IGNORE_BKEY = 2, 1746aa0a1e58SJeff Roberson IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY 1747aa0a1e58SJeff Roberson }; 1748aa0a1e58SJeff Roberson 1749aa0a1e58SJeff Roberson enum ib_mad_result { 1750aa0a1e58SJeff Roberson IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */ 1751aa0a1e58SJeff Roberson IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */ 1752aa0a1e58SJeff Roberson IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */ 1753aa0a1e58SJeff Roberson IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */ 1754aa0a1e58SJeff Roberson }; 1755aa0a1e58SJeff Roberson 1756aa0a1e58SJeff Roberson #define IB_DEVICE_NAME_MAX 64 1757aa0a1e58SJeff Roberson 1758aa0a1e58SJeff Roberson struct ib_cache { 1759aa0a1e58SJeff Roberson rwlock_t lock; 1760aa0a1e58SJeff Roberson struct ib_event_handler event_handler; 1761aa0a1e58SJeff Roberson struct ib_pkey_cache **pkey_cache; 1762*478d3005SHans Petter Selasky struct ib_gid_table **gid_cache; 1763aa0a1e58SJeff Roberson u8 *lmc_cache; 1764aa0a1e58SJeff Roberson }; 1765aa0a1e58SJeff Roberson 1766aa0a1e58SJeff Roberson struct ib_dma_mapping_ops { 1767aa0a1e58SJeff Roberson int (*mapping_error)(struct ib_device *dev, 1768aa0a1e58SJeff Roberson u64 dma_addr); 1769aa0a1e58SJeff Roberson u64 (*map_single)(struct ib_device *dev, 1770aa0a1e58SJeff Roberson void *ptr, size_t size, 1771aa0a1e58SJeff Roberson enum dma_data_direction direction); 1772aa0a1e58SJeff Roberson void (*unmap_single)(struct ib_device *dev, 1773aa0a1e58SJeff Roberson u64 addr, size_t size, 1774aa0a1e58SJeff Roberson enum dma_data_direction direction); 1775aa0a1e58SJeff Roberson u64 (*map_page)(struct ib_device *dev, 1776aa0a1e58SJeff Roberson struct page *page, unsigned long offset, 1777aa0a1e58SJeff Roberson size_t size, 1778aa0a1e58SJeff Roberson enum dma_data_direction direction); 1779aa0a1e58SJeff Roberson void (*unmap_page)(struct ib_device *dev, 1780aa0a1e58SJeff Roberson u64 addr, size_t size, 1781aa0a1e58SJeff Roberson enum dma_data_direction direction); 1782aa0a1e58SJeff Roberson int (*map_sg)(struct ib_device *dev, 1783aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 1784aa0a1e58SJeff Roberson enum dma_data_direction direction); 1785aa0a1e58SJeff Roberson void (*unmap_sg)(struct ib_device *dev, 1786aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 1787aa0a1e58SJeff Roberson enum dma_data_direction direction); 1788*478d3005SHans Petter Selasky int (*map_sg_attrs)(struct ib_device *dev, 1789*478d3005SHans Petter Selasky struct scatterlist *sg, int nents, 1790*478d3005SHans Petter Selasky enum dma_data_direction direction, 1791*478d3005SHans Petter Selasky struct dma_attrs *attrs); 1792*478d3005SHans Petter Selasky void (*unmap_sg_attrs)(struct ib_device *dev, 1793*478d3005SHans Petter Selasky struct scatterlist *sg, int nents, 1794*478d3005SHans Petter Selasky enum dma_data_direction direction, 1795*478d3005SHans Petter Selasky struct dma_attrs *attrs); 1796aa0a1e58SJeff Roberson void (*sync_single_for_cpu)(struct ib_device *dev, 1797aa0a1e58SJeff Roberson u64 dma_handle, 1798aa0a1e58SJeff Roberson size_t size, 1799aa0a1e58SJeff Roberson enum dma_data_direction dir); 1800aa0a1e58SJeff Roberson void (*sync_single_for_device)(struct ib_device *dev, 1801aa0a1e58SJeff Roberson u64 dma_handle, 1802aa0a1e58SJeff Roberson size_t size, 1803aa0a1e58SJeff Roberson enum dma_data_direction dir); 1804aa0a1e58SJeff Roberson void *(*alloc_coherent)(struct ib_device *dev, 1805aa0a1e58SJeff Roberson size_t size, 1806aa0a1e58SJeff Roberson u64 *dma_handle, 1807aa0a1e58SJeff Roberson gfp_t flag); 1808aa0a1e58SJeff Roberson void (*free_coherent)(struct ib_device *dev, 1809aa0a1e58SJeff Roberson size_t size, void *cpu_addr, 1810aa0a1e58SJeff Roberson u64 dma_handle); 1811aa0a1e58SJeff Roberson }; 1812aa0a1e58SJeff Roberson 1813aa0a1e58SJeff Roberson struct iw_cm_verbs; 1814*478d3005SHans Petter Selasky 1815*478d3005SHans Petter Selasky struct ib_port_immutable { 1816*478d3005SHans Petter Selasky int pkey_tbl_len; 1817*478d3005SHans Petter Selasky int gid_tbl_len; 1818*478d3005SHans Petter Selasky u32 core_cap_flags; 1819*478d3005SHans Petter Selasky u32 max_mad_size; 1820*478d3005SHans Petter Selasky }; 1821aa0a1e58SJeff Roberson 1822aa0a1e58SJeff Roberson struct ib_device { 1823aa0a1e58SJeff Roberson struct device *dma_device; 1824aa0a1e58SJeff Roberson 1825aa0a1e58SJeff Roberson char name[IB_DEVICE_NAME_MAX]; 1826aa0a1e58SJeff Roberson 1827aa0a1e58SJeff Roberson struct list_head event_handler_list; 1828aa0a1e58SJeff Roberson spinlock_t event_handler_lock; 1829aa0a1e58SJeff Roberson 1830c9f432b7SAlfred Perlstein spinlock_t client_data_lock; 1831aa0a1e58SJeff Roberson struct list_head core_list; 1832*478d3005SHans Petter Selasky /* Access to the client_data_list is protected by the client_data_lock 1833*478d3005SHans Petter Selasky * spinlock and the lists_rwsem read-write semaphore */ 1834aa0a1e58SJeff Roberson struct list_head client_data_list; 1835aa0a1e58SJeff Roberson 1836aa0a1e58SJeff Roberson struct ib_cache cache; 1837*478d3005SHans Petter Selasky /** 1838*478d3005SHans Petter Selasky * port_immutable is indexed by port number 1839*478d3005SHans Petter Selasky */ 1840*478d3005SHans Petter Selasky struct ib_port_immutable *port_immutable; 1841aa0a1e58SJeff Roberson 1842aa0a1e58SJeff Roberson int num_comp_vectors; 1843aa0a1e58SJeff Roberson 1844aa0a1e58SJeff Roberson struct iw_cm_verbs *iwcm; 1845aa0a1e58SJeff Roberson 1846*478d3005SHans Petter Selasky /** 1847*478d3005SHans Petter Selasky * alloc_hw_stats - Allocate a struct rdma_hw_stats and fill in the 1848*478d3005SHans Petter Selasky * driver initialized data. The struct is kfree()'ed by the sysfs 1849*478d3005SHans Petter Selasky * core when the device is removed. A lifespan of -1 in the return 1850*478d3005SHans Petter Selasky * struct tells the core to set a default lifespan. 1851*478d3005SHans Petter Selasky */ 1852*478d3005SHans Petter Selasky struct rdma_hw_stats *(*alloc_hw_stats)(struct ib_device *device, 1853*478d3005SHans Petter Selasky u8 port_num); 1854*478d3005SHans Petter Selasky /** 1855*478d3005SHans Petter Selasky * get_hw_stats - Fill in the counter value(s) in the stats struct. 1856*478d3005SHans Petter Selasky * @index - The index in the value array we wish to have updated, or 1857*478d3005SHans Petter Selasky * num_counters if we want all stats updated 1858*478d3005SHans Petter Selasky * Return codes - 1859*478d3005SHans Petter Selasky * < 0 - Error, no counters updated 1860*478d3005SHans Petter Selasky * index - Updated the single counter pointed to by index 1861*478d3005SHans Petter Selasky * num_counters - Updated all counters (will reset the timestamp 1862*478d3005SHans Petter Selasky * and prevent further calls for lifespan milliseconds) 1863*478d3005SHans Petter Selasky * Drivers are allowed to update all counters in leiu of just the 1864*478d3005SHans Petter Selasky * one given in index at their option 1865*478d3005SHans Petter Selasky */ 1866*478d3005SHans Petter Selasky int (*get_hw_stats)(struct ib_device *device, 1867*478d3005SHans Petter Selasky struct rdma_hw_stats *stats, 1868*478d3005SHans Petter Selasky u8 port, int index); 1869aa0a1e58SJeff Roberson int (*query_device)(struct ib_device *device, 1870*478d3005SHans Petter Selasky struct ib_device_attr *device_attr, 1871*478d3005SHans Petter Selasky struct ib_udata *udata); 1872aa0a1e58SJeff Roberson int (*query_port)(struct ib_device *device, 1873aa0a1e58SJeff Roberson u8 port_num, 1874aa0a1e58SJeff Roberson struct ib_port_attr *port_attr); 1875aa0a1e58SJeff Roberson enum rdma_link_layer (*get_link_layer)(struct ib_device *device, 1876aa0a1e58SJeff Roberson u8 port_num); 18770bab509bSHans Petter Selasky /* When calling get_netdev, the HW vendor's driver should return the 1878*478d3005SHans Petter Selasky * net device of device @device at port @port_num or NULL if such 1879*478d3005SHans Petter Selasky * a net device doesn't exist. The vendor driver should call dev_hold 1880*478d3005SHans Petter Selasky * on this net device. The HW vendor's device driver must guarantee 1881*478d3005SHans Petter Selasky * that this function returns NULL before the net device reaches 18820bab509bSHans Petter Selasky * NETDEV_UNREGISTER_FINAL state. 18830bab509bSHans Petter Selasky */ 18840bab509bSHans Petter Selasky struct net_device *(*get_netdev)(struct ib_device *device, 18850bab509bSHans Petter Selasky u8 port_num); 1886aa0a1e58SJeff Roberson int (*query_gid)(struct ib_device *device, 1887aa0a1e58SJeff Roberson u8 port_num, int index, 1888aa0a1e58SJeff Roberson union ib_gid *gid); 1889*478d3005SHans Petter Selasky /* When calling add_gid, the HW vendor's driver should 1890*478d3005SHans Petter Selasky * add the gid of device @device at gid index @index of 1891*478d3005SHans Petter Selasky * port @port_num to be @gid. Meta-info of that gid (for example, 1892*478d3005SHans Petter Selasky * the network device related to this gid is available 1893*478d3005SHans Petter Selasky * at @attr. @context allows the HW vendor driver to store extra 1894*478d3005SHans Petter Selasky * information together with a GID entry. The HW vendor may allocate 1895*478d3005SHans Petter Selasky * memory to contain this information and store it in @context when a 1896*478d3005SHans Petter Selasky * new GID entry is written to. Params are consistent until the next 1897*478d3005SHans Petter Selasky * call of add_gid or delete_gid. The function should return 0 on 1898*478d3005SHans Petter Selasky * success or error otherwise. The function could be called 1899*478d3005SHans Petter Selasky * concurrently for different ports. This function is only called 1900*478d3005SHans Petter Selasky * when roce_gid_table is used. 1901*478d3005SHans Petter Selasky */ 1902*478d3005SHans Petter Selasky int (*add_gid)(struct ib_device *device, 1903*478d3005SHans Petter Selasky u8 port_num, 1904*478d3005SHans Petter Selasky unsigned int index, 1905*478d3005SHans Petter Selasky const union ib_gid *gid, 1906*478d3005SHans Petter Selasky const struct ib_gid_attr *attr, 1907*478d3005SHans Petter Selasky void **context); 1908*478d3005SHans Petter Selasky /* When calling del_gid, the HW vendor's driver should delete the 1909*478d3005SHans Petter Selasky * gid of device @device at gid index @index of port @port_num. 1910*478d3005SHans Petter Selasky * Upon the deletion of a GID entry, the HW vendor must free any 1911*478d3005SHans Petter Selasky * allocated memory. The caller will clear @context afterwards. 1912*478d3005SHans Petter Selasky * This function is only called when roce_gid_table is used. 1913*478d3005SHans Petter Selasky */ 1914*478d3005SHans Petter Selasky int (*del_gid)(struct ib_device *device, 1915*478d3005SHans Petter Selasky u8 port_num, 1916*478d3005SHans Petter Selasky unsigned int index, 1917*478d3005SHans Petter Selasky void **context); 1918aa0a1e58SJeff Roberson int (*query_pkey)(struct ib_device *device, 1919aa0a1e58SJeff Roberson u8 port_num, u16 index, u16 *pkey); 1920aa0a1e58SJeff Roberson int (*modify_device)(struct ib_device *device, 1921aa0a1e58SJeff Roberson int device_modify_mask, 1922aa0a1e58SJeff Roberson struct ib_device_modify *device_modify); 1923aa0a1e58SJeff Roberson int (*modify_port)(struct ib_device *device, 1924aa0a1e58SJeff Roberson u8 port_num, int port_modify_mask, 1925aa0a1e58SJeff Roberson struct ib_port_modify *port_modify); 1926aa0a1e58SJeff Roberson struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, 1927aa0a1e58SJeff Roberson struct ib_udata *udata); 1928aa0a1e58SJeff Roberson int (*dealloc_ucontext)(struct ib_ucontext *context); 1929aa0a1e58SJeff Roberson int (*mmap)(struct ib_ucontext *context, 1930aa0a1e58SJeff Roberson struct vm_area_struct *vma); 1931aa0a1e58SJeff Roberson struct ib_pd * (*alloc_pd)(struct ib_device *device, 1932aa0a1e58SJeff Roberson struct ib_ucontext *context, 1933aa0a1e58SJeff Roberson struct ib_udata *udata); 1934aa0a1e58SJeff Roberson int (*dealloc_pd)(struct ib_pd *pd); 1935aa0a1e58SJeff Roberson struct ib_ah * (*create_ah)(struct ib_pd *pd, 1936aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 1937aa0a1e58SJeff Roberson int (*modify_ah)(struct ib_ah *ah, 1938aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 1939aa0a1e58SJeff Roberson int (*query_ah)(struct ib_ah *ah, 1940aa0a1e58SJeff Roberson struct ib_ah_attr *ah_attr); 1941aa0a1e58SJeff Roberson int (*destroy_ah)(struct ib_ah *ah); 1942aa0a1e58SJeff Roberson struct ib_srq * (*create_srq)(struct ib_pd *pd, 1943aa0a1e58SJeff Roberson struct ib_srq_init_attr *srq_init_attr, 1944aa0a1e58SJeff Roberson struct ib_udata *udata); 1945aa0a1e58SJeff Roberson int (*modify_srq)(struct ib_srq *srq, 1946aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr, 1947aa0a1e58SJeff Roberson enum ib_srq_attr_mask srq_attr_mask, 1948aa0a1e58SJeff Roberson struct ib_udata *udata); 1949aa0a1e58SJeff Roberson int (*query_srq)(struct ib_srq *srq, 1950aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr); 1951aa0a1e58SJeff Roberson int (*destroy_srq)(struct ib_srq *srq); 1952aa0a1e58SJeff Roberson int (*post_srq_recv)(struct ib_srq *srq, 1953aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 1954aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr); 1955aa0a1e58SJeff Roberson struct ib_qp * (*create_qp)(struct ib_pd *pd, 1956aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr, 1957aa0a1e58SJeff Roberson struct ib_udata *udata); 1958aa0a1e58SJeff Roberson int (*modify_qp)(struct ib_qp *qp, 1959aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 1960aa0a1e58SJeff Roberson int qp_attr_mask, 1961aa0a1e58SJeff Roberson struct ib_udata *udata); 1962aa0a1e58SJeff Roberson int (*query_qp)(struct ib_qp *qp, 1963aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 1964aa0a1e58SJeff Roberson int qp_attr_mask, 1965aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 1966aa0a1e58SJeff Roberson int (*destroy_qp)(struct ib_qp *qp); 1967aa0a1e58SJeff Roberson int (*post_send)(struct ib_qp *qp, 1968aa0a1e58SJeff Roberson struct ib_send_wr *send_wr, 1969aa0a1e58SJeff Roberson struct ib_send_wr **bad_send_wr); 1970aa0a1e58SJeff Roberson int (*post_recv)(struct ib_qp *qp, 1971aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 1972aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr); 1973b5c1e0cbSHans Petter Selasky struct ib_cq * (*create_cq)(struct ib_device *device, 1974*478d3005SHans Petter Selasky const struct ib_cq_init_attr *attr, 1975aa0a1e58SJeff Roberson struct ib_ucontext *context, 1976aa0a1e58SJeff Roberson struct ib_udata *udata); 1977*478d3005SHans Petter Selasky int (*modify_cq)(struct ib_cq *cq, u16 cq_count, 1978*478d3005SHans Petter Selasky u16 cq_period); 1979aa0a1e58SJeff Roberson int (*destroy_cq)(struct ib_cq *cq); 1980aa0a1e58SJeff Roberson int (*resize_cq)(struct ib_cq *cq, int cqe, 1981aa0a1e58SJeff Roberson struct ib_udata *udata); 1982aa0a1e58SJeff Roberson int (*poll_cq)(struct ib_cq *cq, int num_entries, 1983aa0a1e58SJeff Roberson struct ib_wc *wc); 1984aa0a1e58SJeff Roberson int (*peek_cq)(struct ib_cq *cq, int wc_cnt); 1985aa0a1e58SJeff Roberson int (*req_notify_cq)(struct ib_cq *cq, 1986aa0a1e58SJeff Roberson enum ib_cq_notify_flags flags); 1987aa0a1e58SJeff Roberson int (*req_ncomp_notif)(struct ib_cq *cq, 1988aa0a1e58SJeff Roberson int wc_cnt); 1989aa0a1e58SJeff Roberson struct ib_mr * (*get_dma_mr)(struct ib_pd *pd, 1990aa0a1e58SJeff Roberson int mr_access_flags); 1991aa0a1e58SJeff Roberson struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, 1992aa0a1e58SJeff Roberson u64 start, u64 length, 1993aa0a1e58SJeff Roberson u64 virt_addr, 1994aa0a1e58SJeff Roberson int mr_access_flags, 1995*478d3005SHans Petter Selasky struct ib_udata *udata); 1996*478d3005SHans Petter Selasky int (*rereg_user_mr)(struct ib_mr *mr, 1997*478d3005SHans Petter Selasky int flags, 1998*478d3005SHans Petter Selasky u64 start, u64 length, 1999*478d3005SHans Petter Selasky u64 virt_addr, 2000aa0a1e58SJeff Roberson int mr_access_flags, 2001*478d3005SHans Petter Selasky struct ib_pd *pd, 2002*478d3005SHans Petter Selasky struct ib_udata *udata); 2003*478d3005SHans Petter Selasky int (*dereg_mr)(struct ib_mr *mr); 2004*478d3005SHans Petter Selasky struct ib_mr * (*alloc_mr)(struct ib_pd *pd, 2005*478d3005SHans Petter Selasky enum ib_mr_type mr_type, 2006*478d3005SHans Petter Selasky u32 max_num_sg); 2007*478d3005SHans Petter Selasky int (*map_mr_sg)(struct ib_mr *mr, 2008*478d3005SHans Petter Selasky struct scatterlist *sg, 2009*478d3005SHans Petter Selasky int sg_nents, 2010*478d3005SHans Petter Selasky unsigned int *sg_offset); 2011b5c1e0cbSHans Petter Selasky struct ib_mw * (*alloc_mw)(struct ib_pd *pd, 2012*478d3005SHans Petter Selasky enum ib_mw_type type, 2013*478d3005SHans Petter Selasky struct ib_udata *udata); 2014aa0a1e58SJeff Roberson int (*dealloc_mw)(struct ib_mw *mw); 2015aa0a1e58SJeff Roberson struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd, 2016aa0a1e58SJeff Roberson int mr_access_flags, 2017aa0a1e58SJeff Roberson struct ib_fmr_attr *fmr_attr); 2018aa0a1e58SJeff Roberson int (*map_phys_fmr)(struct ib_fmr *fmr, 2019aa0a1e58SJeff Roberson u64 *page_list, int list_len, 2020aa0a1e58SJeff Roberson u64 iova); 2021aa0a1e58SJeff Roberson int (*unmap_fmr)(struct list_head *fmr_list); 2022aa0a1e58SJeff Roberson int (*dealloc_fmr)(struct ib_fmr *fmr); 2023aa0a1e58SJeff Roberson int (*attach_mcast)(struct ib_qp *qp, 2024aa0a1e58SJeff Roberson union ib_gid *gid, 2025aa0a1e58SJeff Roberson u16 lid); 2026aa0a1e58SJeff Roberson int (*detach_mcast)(struct ib_qp *qp, 2027aa0a1e58SJeff Roberson union ib_gid *gid, 2028aa0a1e58SJeff Roberson u16 lid); 2029aa0a1e58SJeff Roberson int (*process_mad)(struct ib_device *device, 2030aa0a1e58SJeff Roberson int process_mad_flags, 2031aa0a1e58SJeff Roberson u8 port_num, 2032*478d3005SHans Petter Selasky const struct ib_wc *in_wc, 2033*478d3005SHans Petter Selasky const struct ib_grh *in_grh, 2034*478d3005SHans Petter Selasky const struct ib_mad_hdr *in_mad, 2035*478d3005SHans Petter Selasky size_t in_mad_size, 2036*478d3005SHans Petter Selasky struct ib_mad_hdr *out_mad, 2037*478d3005SHans Petter Selasky size_t *out_mad_size, 2038*478d3005SHans Petter Selasky u16 *out_mad_pkey_index); 2039aa0a1e58SJeff Roberson struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device, 2040c9f432b7SAlfred Perlstein struct ib_ucontext *ucontext, 2041aa0a1e58SJeff Roberson struct ib_udata *udata); 2042aa0a1e58SJeff Roberson int (*dealloc_xrcd)(struct ib_xrcd *xrcd); 2043b5c1e0cbSHans Petter Selasky struct ib_flow * (*create_flow)(struct ib_qp *qp, 2044b5c1e0cbSHans Petter Selasky struct ib_flow_attr 2045b5c1e0cbSHans Petter Selasky *flow_attr, 2046b5c1e0cbSHans Petter Selasky int domain); 2047b5c1e0cbSHans Petter Selasky int (*destroy_flow)(struct ib_flow *flow_id); 2048b5c1e0cbSHans Petter Selasky int (*check_mr_status)(struct ib_mr *mr, u32 check_mask, 2049b5c1e0cbSHans Petter Selasky struct ib_mr_status *mr_status); 2050*478d3005SHans Petter Selasky void (*disassociate_ucontext)(struct ib_ucontext *ibcontext); 2051*478d3005SHans Petter Selasky void (*drain_rq)(struct ib_qp *qp); 2052*478d3005SHans Petter Selasky void (*drain_sq)(struct ib_qp *qp); 2053*478d3005SHans Petter Selasky int (*set_vf_link_state)(struct ib_device *device, int vf, u8 port, 2054*478d3005SHans Petter Selasky int state); 2055*478d3005SHans Petter Selasky int (*get_vf_config)(struct ib_device *device, int vf, u8 port, 2056*478d3005SHans Petter Selasky struct ifla_vf_info *ivf); 2057*478d3005SHans Petter Selasky int (*get_vf_stats)(struct ib_device *device, int vf, u8 port, 2058*478d3005SHans Petter Selasky struct ifla_vf_stats *stats); 2059*478d3005SHans Petter Selasky int (*set_vf_guid)(struct ib_device *device, int vf, u8 port, u64 guid, 2060*478d3005SHans Petter Selasky int type); 2061*478d3005SHans Petter Selasky struct ib_wq * (*create_wq)(struct ib_pd *pd, 2062*478d3005SHans Petter Selasky struct ib_wq_init_attr *init_attr, 2063*478d3005SHans Petter Selasky struct ib_udata *udata); 2064*478d3005SHans Petter Selasky int (*destroy_wq)(struct ib_wq *wq); 2065*478d3005SHans Petter Selasky int (*modify_wq)(struct ib_wq *wq, 2066*478d3005SHans Petter Selasky struct ib_wq_attr *attr, 2067*478d3005SHans Petter Selasky u32 wq_attr_mask, 2068*478d3005SHans Petter Selasky struct ib_udata *udata); 2069*478d3005SHans Petter Selasky struct ib_rwq_ind_table * (*create_rwq_ind_table)(struct ib_device *device, 2070*478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr *init_attr, 2071*478d3005SHans Petter Selasky struct ib_udata *udata); 2072*478d3005SHans Petter Selasky int (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table); 2073aa0a1e58SJeff Roberson struct ib_dma_mapping_ops *dma_ops; 2074aa0a1e58SJeff Roberson 2075aa0a1e58SJeff Roberson struct module *owner; 2076aa0a1e58SJeff Roberson struct device dev; 2077aa0a1e58SJeff Roberson struct kobject *ports_parent; 2078aa0a1e58SJeff Roberson struct list_head port_list; 2079aa0a1e58SJeff Roberson 2080aa0a1e58SJeff Roberson enum { 2081aa0a1e58SJeff Roberson IB_DEV_UNINITIALIZED, 2082aa0a1e58SJeff Roberson IB_DEV_REGISTERED, 2083aa0a1e58SJeff Roberson IB_DEV_UNREGISTERED 2084aa0a1e58SJeff Roberson } reg_state; 2085aa0a1e58SJeff Roberson 2086aa0a1e58SJeff Roberson int uverbs_abi_ver; 2087c9f432b7SAlfred Perlstein u64 uverbs_cmd_mask; 2088b5c1e0cbSHans Petter Selasky u64 uverbs_ex_cmd_mask; 2089aa0a1e58SJeff Roberson 2090*478d3005SHans Petter Selasky char node_desc[IB_DEVICE_NODE_DESC_MAX]; 2091aa0a1e58SJeff Roberson __be64 node_guid; 2092aa0a1e58SJeff Roberson u32 local_dma_lkey; 2093*478d3005SHans Petter Selasky u16 is_switch:1; 2094aa0a1e58SJeff Roberson u8 node_type; 2095aa0a1e58SJeff Roberson u8 phys_port_cnt; 2096*478d3005SHans Petter Selasky struct ib_device_attr attrs; 2097*478d3005SHans Petter Selasky struct attribute_group *hw_stats_ag; 2098*478d3005SHans Petter Selasky struct rdma_hw_stats *hw_stats; 2099b5c1e0cbSHans Petter Selasky 2100*478d3005SHans Petter Selasky /** 2101*478d3005SHans Petter Selasky * The following mandatory functions are used only at device 2102*478d3005SHans Petter Selasky * registration. Keep functions such as these at the end of this 2103*478d3005SHans Petter Selasky * structure to avoid cache line misses when accessing struct ib_device 2104*478d3005SHans Petter Selasky * in fast paths. 2105b5c1e0cbSHans Petter Selasky */ 2106*478d3005SHans Petter Selasky int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *); 2107*478d3005SHans Petter Selasky void (*get_dev_fw_str)(struct ib_device *, char *str, size_t str_len); 2108aa0a1e58SJeff Roberson }; 2109aa0a1e58SJeff Roberson 2110aa0a1e58SJeff Roberson struct ib_client { 2111aa0a1e58SJeff Roberson char *name; 2112aa0a1e58SJeff Roberson void (*add) (struct ib_device *); 2113*478d3005SHans Petter Selasky void (*remove)(struct ib_device *, void *client_data); 2114aa0a1e58SJeff Roberson 2115*478d3005SHans Petter Selasky /* Returns the net_dev belonging to this ib_client and matching the 2116*478d3005SHans Petter Selasky * given parameters. 2117*478d3005SHans Petter Selasky * @dev: An RDMA device that the net_dev use for communication. 2118*478d3005SHans Petter Selasky * @port: A physical port number on the RDMA device. 2119*478d3005SHans Petter Selasky * @pkey: P_Key that the net_dev uses if applicable. 2120*478d3005SHans Petter Selasky * @gid: A GID that the net_dev uses to communicate. 2121*478d3005SHans Petter Selasky * @addr: An IP address the net_dev is configured with. 2122*478d3005SHans Petter Selasky * @client_data: The device's client data set by ib_set_client_data(). 2123*478d3005SHans Petter Selasky * 2124*478d3005SHans Petter Selasky * An ib_client that implements a net_dev on top of RDMA devices 2125*478d3005SHans Petter Selasky * (such as IP over IB) should implement this callback, allowing the 2126*478d3005SHans Petter Selasky * rdma_cm module to find the right net_dev for a given request. 2127*478d3005SHans Petter Selasky * 2128*478d3005SHans Petter Selasky * The caller is responsible for calling dev_put on the returned 2129*478d3005SHans Petter Selasky * netdev. */ 2130*478d3005SHans Petter Selasky struct net_device *(*get_net_dev_by_params)( 2131*478d3005SHans Petter Selasky struct ib_device *dev, 2132*478d3005SHans Petter Selasky u8 port, 2133*478d3005SHans Petter Selasky u16 pkey, 2134*478d3005SHans Petter Selasky const union ib_gid *gid, 2135*478d3005SHans Petter Selasky const struct sockaddr *addr, 2136*478d3005SHans Petter Selasky void *client_data); 2137aa0a1e58SJeff Roberson struct list_head list; 2138aa0a1e58SJeff Roberson }; 2139aa0a1e58SJeff Roberson 2140aa0a1e58SJeff Roberson struct ib_device *ib_alloc_device(size_t size); 2141aa0a1e58SJeff Roberson void ib_dealloc_device(struct ib_device *device); 2142aa0a1e58SJeff Roberson 2143*478d3005SHans Petter Selasky void ib_get_device_fw_str(struct ib_device *device, char *str, size_t str_len); 2144*478d3005SHans Petter Selasky 2145c9f432b7SAlfred Perlstein int ib_register_device(struct ib_device *device, 2146c9f432b7SAlfred Perlstein int (*port_callback)(struct ib_device *, 2147c9f432b7SAlfred Perlstein u8, struct kobject *)); 2148aa0a1e58SJeff Roberson void ib_unregister_device(struct ib_device *device); 2149aa0a1e58SJeff Roberson 2150aa0a1e58SJeff Roberson int ib_register_client (struct ib_client *client); 2151aa0a1e58SJeff Roberson void ib_unregister_client(struct ib_client *client); 2152aa0a1e58SJeff Roberson 2153aa0a1e58SJeff Roberson void *ib_get_client_data(struct ib_device *device, struct ib_client *client); 2154aa0a1e58SJeff Roberson void ib_set_client_data(struct ib_device *device, struct ib_client *client, 2155aa0a1e58SJeff Roberson void *data); 2156aa0a1e58SJeff Roberson 2157aa0a1e58SJeff Roberson static inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) 2158aa0a1e58SJeff Roberson { 2159*478d3005SHans Petter Selasky return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; 2160aa0a1e58SJeff Roberson } 2161aa0a1e58SJeff Roberson 2162aa0a1e58SJeff Roberson static inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) 2163aa0a1e58SJeff Roberson { 2164*478d3005SHans Petter Selasky return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; 2165*478d3005SHans Petter Selasky } 2166*478d3005SHans Petter Selasky 2167*478d3005SHans Petter Selasky static inline bool ib_is_udata_cleared(struct ib_udata *udata, 2168*478d3005SHans Petter Selasky size_t offset, 2169*478d3005SHans Petter Selasky size_t len) 2170*478d3005SHans Petter Selasky { 2171*478d3005SHans Petter Selasky const void __user *p = (const char __user *)udata->inbuf + offset; 2172*478d3005SHans Petter Selasky bool ret; 2173*478d3005SHans Petter Selasky u8 *buf; 2174*478d3005SHans Petter Selasky 2175*478d3005SHans Petter Selasky if (len > USHRT_MAX) 2176*478d3005SHans Petter Selasky return false; 2177*478d3005SHans Petter Selasky 2178*478d3005SHans Petter Selasky buf = memdup_user(p, len); 2179*478d3005SHans Petter Selasky if (IS_ERR(buf)) 2180*478d3005SHans Petter Selasky return false; 2181*478d3005SHans Petter Selasky 2182*478d3005SHans Petter Selasky ret = !memchr_inv(buf, 0, len); 2183*478d3005SHans Petter Selasky kfree(buf); 2184*478d3005SHans Petter Selasky return ret; 2185aa0a1e58SJeff Roberson } 2186aa0a1e58SJeff Roberson 2187aa0a1e58SJeff Roberson /** 2188aa0a1e58SJeff Roberson * ib_modify_qp_is_ok - Check that the supplied attribute mask 2189aa0a1e58SJeff Roberson * contains all required attributes and no attributes not allowed for 2190aa0a1e58SJeff Roberson * the given QP state transition. 2191aa0a1e58SJeff Roberson * @cur_state: Current QP state 2192aa0a1e58SJeff Roberson * @next_state: Next QP state 2193aa0a1e58SJeff Roberson * @type: QP type 2194aa0a1e58SJeff Roberson * @mask: Mask of supplied QP attributes 2195b5c1e0cbSHans Petter Selasky * @ll : link layer of port 2196aa0a1e58SJeff Roberson * 2197aa0a1e58SJeff Roberson * This function is a helper function that a low-level driver's 2198aa0a1e58SJeff Roberson * modify_qp method can use to validate the consumer's input. It 2199aa0a1e58SJeff Roberson * checks that cur_state and next_state are valid QP states, that a 2200aa0a1e58SJeff Roberson * transition from cur_state to next_state is allowed by the IB spec, 2201aa0a1e58SJeff Roberson * and that the attribute mask supplied is allowed for the transition. 2202aa0a1e58SJeff Roberson */ 2203aa0a1e58SJeff Roberson int ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, 2204b5c1e0cbSHans Petter Selasky enum ib_qp_type type, enum ib_qp_attr_mask mask, 2205b5c1e0cbSHans Petter Selasky enum rdma_link_layer ll); 2206aa0a1e58SJeff Roberson 2207aa0a1e58SJeff Roberson int ib_register_event_handler (struct ib_event_handler *event_handler); 2208aa0a1e58SJeff Roberson int ib_unregister_event_handler(struct ib_event_handler *event_handler); 2209aa0a1e58SJeff Roberson void ib_dispatch_event(struct ib_event *event); 2210aa0a1e58SJeff Roberson 2211aa0a1e58SJeff Roberson int ib_query_port(struct ib_device *device, 2212aa0a1e58SJeff Roberson u8 port_num, struct ib_port_attr *port_attr); 2213aa0a1e58SJeff Roberson 2214aa0a1e58SJeff Roberson enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, 2215aa0a1e58SJeff Roberson u8 port_num); 2216aa0a1e58SJeff Roberson 2217*478d3005SHans Petter Selasky /** 2218*478d3005SHans Petter Selasky * rdma_cap_ib_switch - Check if the device is IB switch 2219*478d3005SHans Petter Selasky * @device: Device to check 2220*478d3005SHans Petter Selasky * 2221*478d3005SHans Petter Selasky * Device driver is responsible for setting is_switch bit on 2222*478d3005SHans Petter Selasky * in ib_device structure at init time. 2223*478d3005SHans Petter Selasky * 2224*478d3005SHans Petter Selasky * Return: true if the device is IB switch. 2225*478d3005SHans Petter Selasky */ 2226*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_switch(const struct ib_device *device) 2227*478d3005SHans Petter Selasky { 2228*478d3005SHans Petter Selasky return device->is_switch; 2229*478d3005SHans Petter Selasky } 2230*478d3005SHans Petter Selasky 2231*478d3005SHans Petter Selasky /** 2232*478d3005SHans Petter Selasky * rdma_start_port - Return the first valid port number for the device 2233*478d3005SHans Petter Selasky * specified 2234*478d3005SHans Petter Selasky * 2235*478d3005SHans Petter Selasky * @device: Device to be checked 2236*478d3005SHans Petter Selasky * 2237*478d3005SHans Petter Selasky * Return start port number 2238*478d3005SHans Petter Selasky */ 2239*478d3005SHans Petter Selasky static inline u8 rdma_start_port(const struct ib_device *device) 2240*478d3005SHans Petter Selasky { 2241*478d3005SHans Petter Selasky return rdma_cap_ib_switch(device) ? 0 : 1; 2242*478d3005SHans Petter Selasky } 2243*478d3005SHans Petter Selasky 2244*478d3005SHans Petter Selasky /** 2245*478d3005SHans Petter Selasky * rdma_end_port - Return the last valid port number for the device 2246*478d3005SHans Petter Selasky * specified 2247*478d3005SHans Petter Selasky * 2248*478d3005SHans Petter Selasky * @device: Device to be checked 2249*478d3005SHans Petter Selasky * 2250*478d3005SHans Petter Selasky * Return last port number 2251*478d3005SHans Petter Selasky */ 2252*478d3005SHans Petter Selasky static inline u8 rdma_end_port(const struct ib_device *device) 2253*478d3005SHans Petter Selasky { 2254*478d3005SHans Petter Selasky return rdma_cap_ib_switch(device) ? 0 : device->phys_port_cnt; 2255*478d3005SHans Petter Selasky } 2256*478d3005SHans Petter Selasky 2257*478d3005SHans Petter Selasky static inline bool rdma_protocol_ib(const struct ib_device *device, u8 port_num) 2258*478d3005SHans Petter Selasky { 2259*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB; 2260*478d3005SHans Petter Selasky } 2261*478d3005SHans Petter Selasky 2262*478d3005SHans Petter Selasky static inline bool rdma_protocol_roce(const struct ib_device *device, u8 port_num) 2263*478d3005SHans Petter Selasky { 2264*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & 2265*478d3005SHans Petter Selasky (RDMA_CORE_CAP_PROT_ROCE | RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP); 2266*478d3005SHans Petter Selasky } 2267*478d3005SHans Petter Selasky 2268*478d3005SHans Petter Selasky static inline bool rdma_protocol_roce_udp_encap(const struct ib_device *device, u8 port_num) 2269*478d3005SHans Petter Selasky { 2270*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE_UDP_ENCAP; 2271*478d3005SHans Petter Selasky } 2272*478d3005SHans Petter Selasky 2273*478d3005SHans Petter Selasky static inline bool rdma_protocol_roce_eth_encap(const struct ib_device *device, u8 port_num) 2274*478d3005SHans Petter Selasky { 2275*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_ROCE; 2276*478d3005SHans Petter Selasky } 2277*478d3005SHans Petter Selasky 2278*478d3005SHans Petter Selasky static inline bool rdma_protocol_iwarp(const struct ib_device *device, u8 port_num) 2279*478d3005SHans Petter Selasky { 2280*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IWARP; 2281*478d3005SHans Petter Selasky } 2282*478d3005SHans Petter Selasky 2283*478d3005SHans Petter Selasky static inline bool rdma_ib_or_roce(const struct ib_device *device, u8 port_num) 2284*478d3005SHans Petter Selasky { 2285*478d3005SHans Petter Selasky return rdma_protocol_ib(device, port_num) || 2286*478d3005SHans Petter Selasky rdma_protocol_roce(device, port_num); 2287*478d3005SHans Petter Selasky } 2288*478d3005SHans Petter Selasky 2289*478d3005SHans Petter Selasky /** 2290*478d3005SHans Petter Selasky * rdma_cap_ib_mad - Check if the port of a device supports Infiniband 2291*478d3005SHans Petter Selasky * Management Datagrams. 2292*478d3005SHans Petter Selasky * @device: Device to check 2293*478d3005SHans Petter Selasky * @port_num: Port number to check 2294*478d3005SHans Petter Selasky * 2295*478d3005SHans Petter Selasky * Management Datagrams (MAD) are a required part of the InfiniBand 2296*478d3005SHans Petter Selasky * specification and are supported on all InfiniBand devices. A slightly 2297*478d3005SHans Petter Selasky * extended version are also supported on OPA interfaces. 2298*478d3005SHans Petter Selasky * 2299*478d3005SHans Petter Selasky * Return: true if the port supports sending/receiving of MAD packets. 2300*478d3005SHans Petter Selasky */ 2301*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_mad(const struct ib_device *device, u8 port_num) 2302*478d3005SHans Petter Selasky { 2303*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_MAD; 2304*478d3005SHans Petter Selasky } 2305*478d3005SHans Petter Selasky 2306*478d3005SHans Petter Selasky /** 2307*478d3005SHans Petter Selasky * rdma_cap_opa_mad - Check if the port of device provides support for OPA 2308*478d3005SHans Petter Selasky * Management Datagrams. 2309*478d3005SHans Petter Selasky * @device: Device to check 2310*478d3005SHans Petter Selasky * @port_num: Port number to check 2311*478d3005SHans Petter Selasky * 2312*478d3005SHans Petter Selasky * Intel OmniPath devices extend and/or replace the InfiniBand Management 2313*478d3005SHans Petter Selasky * datagrams with their own versions. These OPA MADs share many but not all of 2314*478d3005SHans Petter Selasky * the characteristics of InfiniBand MADs. 2315*478d3005SHans Petter Selasky * 2316*478d3005SHans Petter Selasky * OPA MADs differ in the following ways: 2317*478d3005SHans Petter Selasky * 2318*478d3005SHans Petter Selasky * 1) MADs are variable size up to 2K 2319*478d3005SHans Petter Selasky * IBTA defined MADs remain fixed at 256 bytes 2320*478d3005SHans Petter Selasky * 2) OPA SMPs must carry valid PKeys 2321*478d3005SHans Petter Selasky * 3) OPA SMP packets are a different format 2322*478d3005SHans Petter Selasky * 2323*478d3005SHans Petter Selasky * Return: true if the port supports OPA MAD packet formats. 2324*478d3005SHans Petter Selasky */ 2325*478d3005SHans Petter Selasky static inline bool rdma_cap_opa_mad(struct ib_device *device, u8 port_num) 2326*478d3005SHans Petter Selasky { 2327*478d3005SHans Petter Selasky return (device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_OPA_MAD) 2328*478d3005SHans Petter Selasky == RDMA_CORE_CAP_OPA_MAD; 2329*478d3005SHans Petter Selasky } 2330*478d3005SHans Petter Selasky 2331*478d3005SHans Petter Selasky /** 2332*478d3005SHans Petter Selasky * rdma_cap_ib_smi - Check if the port of a device provides an Infiniband 2333*478d3005SHans Petter Selasky * Subnet Management Agent (SMA) on the Subnet Management Interface (SMI). 2334*478d3005SHans Petter Selasky * @device: Device to check 2335*478d3005SHans Petter Selasky * @port_num: Port number to check 2336*478d3005SHans Petter Selasky * 2337*478d3005SHans Petter Selasky * Each InfiniBand node is required to provide a Subnet Management Agent 2338*478d3005SHans Petter Selasky * that the subnet manager can access. Prior to the fabric being fully 2339*478d3005SHans Petter Selasky * configured by the subnet manager, the SMA is accessed via a well known 2340*478d3005SHans Petter Selasky * interface called the Subnet Management Interface (SMI). This interface 2341*478d3005SHans Petter Selasky * uses directed route packets to communicate with the SM to get around the 2342*478d3005SHans Petter Selasky * chicken and egg problem of the SM needing to know what's on the fabric 2343*478d3005SHans Petter Selasky * in order to configure the fabric, and needing to configure the fabric in 2344*478d3005SHans Petter Selasky * order to send packets to the devices on the fabric. These directed 2345*478d3005SHans Petter Selasky * route packets do not need the fabric fully configured in order to reach 2346*478d3005SHans Petter Selasky * their destination. The SMI is the only method allowed to send 2347*478d3005SHans Petter Selasky * directed route packets on an InfiniBand fabric. 2348*478d3005SHans Petter Selasky * 2349*478d3005SHans Petter Selasky * Return: true if the port provides an SMI. 2350*478d3005SHans Petter Selasky */ 2351*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_smi(const struct ib_device *device, u8 port_num) 2352*478d3005SHans Petter Selasky { 2353*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SMI; 2354*478d3005SHans Petter Selasky } 2355*478d3005SHans Petter Selasky 2356*478d3005SHans Petter Selasky /** 2357*478d3005SHans Petter Selasky * rdma_cap_ib_cm - Check if the port of device has the capability Infiniband 2358*478d3005SHans Petter Selasky * Communication Manager. 2359*478d3005SHans Petter Selasky * @device: Device to check 2360*478d3005SHans Petter Selasky * @port_num: Port number to check 2361*478d3005SHans Petter Selasky * 2362*478d3005SHans Petter Selasky * The InfiniBand Communication Manager is one of many pre-defined General 2363*478d3005SHans Petter Selasky * Service Agents (GSA) that are accessed via the General Service 2364*478d3005SHans Petter Selasky * Interface (GSI). It's role is to facilitate establishment of connections 2365*478d3005SHans Petter Selasky * between nodes as well as other management related tasks for established 2366*478d3005SHans Petter Selasky * connections. 2367*478d3005SHans Petter Selasky * 2368*478d3005SHans Petter Selasky * Return: true if the port supports an IB CM (this does not guarantee that 2369*478d3005SHans Petter Selasky * a CM is actually running however). 2370*478d3005SHans Petter Selasky */ 2371*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_cm(const struct ib_device *device, u8 port_num) 2372*478d3005SHans Petter Selasky { 2373*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_CM; 2374*478d3005SHans Petter Selasky } 2375*478d3005SHans Petter Selasky 2376*478d3005SHans Petter Selasky /** 2377*478d3005SHans Petter Selasky * rdma_cap_iw_cm - Check if the port of device has the capability IWARP 2378*478d3005SHans Petter Selasky * Communication Manager. 2379*478d3005SHans Petter Selasky * @device: Device to check 2380*478d3005SHans Petter Selasky * @port_num: Port number to check 2381*478d3005SHans Petter Selasky * 2382*478d3005SHans Petter Selasky * Similar to above, but specific to iWARP connections which have a different 2383*478d3005SHans Petter Selasky * managment protocol than InfiniBand. 2384*478d3005SHans Petter Selasky * 2385*478d3005SHans Petter Selasky * Return: true if the port supports an iWARP CM (this does not guarantee that 2386*478d3005SHans Petter Selasky * a CM is actually running however). 2387*478d3005SHans Petter Selasky */ 2388*478d3005SHans Petter Selasky static inline bool rdma_cap_iw_cm(const struct ib_device *device, u8 port_num) 2389*478d3005SHans Petter Selasky { 2390*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IW_CM; 2391*478d3005SHans Petter Selasky } 2392*478d3005SHans Petter Selasky 2393*478d3005SHans Petter Selasky /** 2394*478d3005SHans Petter Selasky * rdma_cap_ib_sa - Check if the port of device has the capability Infiniband 2395*478d3005SHans Petter Selasky * Subnet Administration. 2396*478d3005SHans Petter Selasky * @device: Device to check 2397*478d3005SHans Petter Selasky * @port_num: Port number to check 2398*478d3005SHans Petter Selasky * 2399*478d3005SHans Petter Selasky * An InfiniBand Subnet Administration (SA) service is a pre-defined General 2400*478d3005SHans Petter Selasky * Service Agent (GSA) provided by the Subnet Manager (SM). On InfiniBand 2401*478d3005SHans Petter Selasky * fabrics, devices should resolve routes to other hosts by contacting the 2402*478d3005SHans Petter Selasky * SA to query the proper route. 2403*478d3005SHans Petter Selasky * 2404*478d3005SHans Petter Selasky * Return: true if the port should act as a client to the fabric Subnet 2405*478d3005SHans Petter Selasky * Administration interface. This does not imply that the SA service is 2406*478d3005SHans Petter Selasky * running locally. 2407*478d3005SHans Petter Selasky */ 2408*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_sa(const struct ib_device *device, u8 port_num) 2409*478d3005SHans Petter Selasky { 2410*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_IB_SA; 2411*478d3005SHans Petter Selasky } 2412*478d3005SHans Petter Selasky 2413*478d3005SHans Petter Selasky /** 2414*478d3005SHans Petter Selasky * rdma_cap_ib_mcast - Check if the port of device has the capability Infiniband 2415*478d3005SHans Petter Selasky * Multicast. 2416*478d3005SHans Petter Selasky * @device: Device to check 2417*478d3005SHans Petter Selasky * @port_num: Port number to check 2418*478d3005SHans Petter Selasky * 2419*478d3005SHans Petter Selasky * InfiniBand multicast registration is more complex than normal IPv4 or 2420*478d3005SHans Petter Selasky * IPv6 multicast registration. Each Host Channel Adapter must register 2421*478d3005SHans Petter Selasky * with the Subnet Manager when it wishes to join a multicast group. It 2422*478d3005SHans Petter Selasky * should do so only once regardless of how many queue pairs it subscribes 2423*478d3005SHans Petter Selasky * to this group. And it should leave the group only after all queue pairs 2424*478d3005SHans Petter Selasky * attached to the group have been detached. 2425*478d3005SHans Petter Selasky * 2426*478d3005SHans Petter Selasky * Return: true if the port must undertake the additional adminstrative 2427*478d3005SHans Petter Selasky * overhead of registering/unregistering with the SM and tracking of the 2428*478d3005SHans Petter Selasky * total number of queue pairs attached to the multicast group. 2429*478d3005SHans Petter Selasky */ 2430*478d3005SHans Petter Selasky static inline bool rdma_cap_ib_mcast(const struct ib_device *device, u8 port_num) 2431*478d3005SHans Petter Selasky { 2432*478d3005SHans Petter Selasky return rdma_cap_ib_sa(device, port_num); 2433*478d3005SHans Petter Selasky } 2434*478d3005SHans Petter Selasky 2435*478d3005SHans Petter Selasky /** 2436*478d3005SHans Petter Selasky * rdma_cap_af_ib - Check if the port of device has the capability 2437*478d3005SHans Petter Selasky * Native Infiniband Address. 2438*478d3005SHans Petter Selasky * @device: Device to check 2439*478d3005SHans Petter Selasky * @port_num: Port number to check 2440*478d3005SHans Petter Selasky * 2441*478d3005SHans Petter Selasky * InfiniBand addressing uses a port's GUID + Subnet Prefix to make a default 2442*478d3005SHans Petter Selasky * GID. RoCE uses a different mechanism, but still generates a GID via 2443*478d3005SHans Petter Selasky * a prescribed mechanism and port specific data. 2444*478d3005SHans Petter Selasky * 2445*478d3005SHans Petter Selasky * Return: true if the port uses a GID address to identify devices on the 2446*478d3005SHans Petter Selasky * network. 2447*478d3005SHans Petter Selasky */ 2448*478d3005SHans Petter Selasky static inline bool rdma_cap_af_ib(const struct ib_device *device, u8 port_num) 2449*478d3005SHans Petter Selasky { 2450*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_AF_IB; 2451*478d3005SHans Petter Selasky } 2452*478d3005SHans Petter Selasky 2453*478d3005SHans Petter Selasky /** 2454*478d3005SHans Petter Selasky * rdma_cap_eth_ah - Check if the port of device has the capability 2455*478d3005SHans Petter Selasky * Ethernet Address Handle. 2456*478d3005SHans Petter Selasky * @device: Device to check 2457*478d3005SHans Petter Selasky * @port_num: Port number to check 2458*478d3005SHans Petter Selasky * 2459*478d3005SHans Petter Selasky * RoCE is InfiniBand over Ethernet, and it uses a well defined technique 2460*478d3005SHans Petter Selasky * to fabricate GIDs over Ethernet/IP specific addresses native to the 2461*478d3005SHans Petter Selasky * port. Normally, packet headers are generated by the sending host 2462*478d3005SHans Petter Selasky * adapter, but when sending connectionless datagrams, we must manually 2463*478d3005SHans Petter Selasky * inject the proper headers for the fabric we are communicating over. 2464*478d3005SHans Petter Selasky * 2465*478d3005SHans Petter Selasky * Return: true if we are running as a RoCE port and must force the 2466*478d3005SHans Petter Selasky * addition of a Global Route Header built from our Ethernet Address 2467*478d3005SHans Petter Selasky * Handle into our header list for connectionless packets. 2468*478d3005SHans Petter Selasky */ 2469*478d3005SHans Petter Selasky static inline bool rdma_cap_eth_ah(const struct ib_device *device, u8 port_num) 2470*478d3005SHans Petter Selasky { 2471*478d3005SHans Petter Selasky return device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_ETH_AH; 2472*478d3005SHans Petter Selasky } 2473*478d3005SHans Petter Selasky 2474*478d3005SHans Petter Selasky /** 2475*478d3005SHans Petter Selasky * rdma_max_mad_size - Return the max MAD size required by this RDMA Port. 2476*478d3005SHans Petter Selasky * 2477*478d3005SHans Petter Selasky * @device: Device 2478*478d3005SHans Petter Selasky * @port_num: Port number 2479*478d3005SHans Petter Selasky * 2480*478d3005SHans Petter Selasky * This MAD size includes the MAD headers and MAD payload. No other headers 2481*478d3005SHans Petter Selasky * are included. 2482*478d3005SHans Petter Selasky * 2483*478d3005SHans Petter Selasky * Return the max MAD size required by the Port. Will return 0 if the port 2484*478d3005SHans Petter Selasky * does not support MADs 2485*478d3005SHans Petter Selasky */ 2486*478d3005SHans Petter Selasky static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_num) 2487*478d3005SHans Petter Selasky { 2488*478d3005SHans Petter Selasky return device->port_immutable[port_num].max_mad_size; 2489*478d3005SHans Petter Selasky } 2490*478d3005SHans Petter Selasky 2491*478d3005SHans Petter Selasky /** 2492*478d3005SHans Petter Selasky * rdma_cap_roce_gid_table - Check if the port of device uses roce_gid_table 2493*478d3005SHans Petter Selasky * @device: Device to check 2494*478d3005SHans Petter Selasky * @port_num: Port number to check 2495*478d3005SHans Petter Selasky * 2496*478d3005SHans Petter Selasky * RoCE GID table mechanism manages the various GIDs for a device. 2497*478d3005SHans Petter Selasky * 2498*478d3005SHans Petter Selasky * NOTE: if allocating the port's GID table has failed, this call will still 2499*478d3005SHans Petter Selasky * return true, but any RoCE GID table API will fail. 2500*478d3005SHans Petter Selasky * 2501*478d3005SHans Petter Selasky * Return: true if the port uses RoCE GID table mechanism in order to manage 2502*478d3005SHans Petter Selasky * its GIDs. 2503*478d3005SHans Petter Selasky */ 2504*478d3005SHans Petter Selasky static inline bool rdma_cap_roce_gid_table(const struct ib_device *device, 2505*478d3005SHans Petter Selasky u8 port_num) 2506*478d3005SHans Petter Selasky { 2507*478d3005SHans Petter Selasky return rdma_protocol_roce(device, port_num) && 2508*478d3005SHans Petter Selasky device->add_gid && device->del_gid; 2509*478d3005SHans Petter Selasky } 2510*478d3005SHans Petter Selasky 2511*478d3005SHans Petter Selasky /* 2512*478d3005SHans Petter Selasky * Check if the device supports READ W/ INVALIDATE. 2513*478d3005SHans Petter Selasky */ 2514*478d3005SHans Petter Selasky static inline bool rdma_cap_read_inv(struct ib_device *dev, u32 port_num) 2515*478d3005SHans Petter Selasky { 2516*478d3005SHans Petter Selasky /* 2517*478d3005SHans Petter Selasky * iWarp drivers must support READ W/ INVALIDATE. No other protocol 2518*478d3005SHans Petter Selasky * has support for it yet. 2519*478d3005SHans Petter Selasky */ 2520*478d3005SHans Petter Selasky return rdma_protocol_iwarp(dev, port_num); 2521*478d3005SHans Petter Selasky } 2522*478d3005SHans Petter Selasky 2523aa0a1e58SJeff Roberson int ib_query_gid(struct ib_device *device, 2524*478d3005SHans Petter Selasky u8 port_num, int index, union ib_gid *gid, 2525*478d3005SHans Petter Selasky struct ib_gid_attr *attr); 2526*478d3005SHans Petter Selasky 2527*478d3005SHans Petter Selasky int ib_set_vf_link_state(struct ib_device *device, int vf, u8 port, 2528*478d3005SHans Petter Selasky int state); 2529*478d3005SHans Petter Selasky int ib_get_vf_config(struct ib_device *device, int vf, u8 port, 2530*478d3005SHans Petter Selasky struct ifla_vf_info *info); 2531*478d3005SHans Petter Selasky int ib_get_vf_stats(struct ib_device *device, int vf, u8 port, 2532*478d3005SHans Petter Selasky struct ifla_vf_stats *stats); 2533*478d3005SHans Petter Selasky int ib_set_vf_guid(struct ib_device *device, int vf, u8 port, u64 guid, 2534*478d3005SHans Petter Selasky int type); 2535aa0a1e58SJeff Roberson 2536aa0a1e58SJeff Roberson int ib_query_pkey(struct ib_device *device, 2537aa0a1e58SJeff Roberson u8 port_num, u16 index, u16 *pkey); 2538aa0a1e58SJeff Roberson 2539aa0a1e58SJeff Roberson int ib_modify_device(struct ib_device *device, 2540aa0a1e58SJeff Roberson int device_modify_mask, 2541aa0a1e58SJeff Roberson struct ib_device_modify *device_modify); 2542aa0a1e58SJeff Roberson 2543aa0a1e58SJeff Roberson int ib_modify_port(struct ib_device *device, 2544aa0a1e58SJeff Roberson u8 port_num, int port_modify_mask, 2545aa0a1e58SJeff Roberson struct ib_port_modify *port_modify); 2546aa0a1e58SJeff Roberson 2547aa0a1e58SJeff Roberson int ib_find_gid(struct ib_device *device, union ib_gid *gid, 2548*478d3005SHans Petter Selasky enum ib_gid_type gid_type, struct net_device *ndev, 2549aa0a1e58SJeff Roberson u8 *port_num, u16 *index); 2550aa0a1e58SJeff Roberson 2551aa0a1e58SJeff Roberson int ib_find_pkey(struct ib_device *device, 2552aa0a1e58SJeff Roberson u8 port_num, u16 pkey, u16 *index); 2553aa0a1e58SJeff Roberson 2554*478d3005SHans Petter Selasky enum ib_pd_flags { 2555*478d3005SHans Petter Selasky /* 2556*478d3005SHans Petter Selasky * Create a memory registration for all memory in the system and place 2557*478d3005SHans Petter Selasky * the rkey for it into pd->unsafe_global_rkey. This can be used by 2558*478d3005SHans Petter Selasky * ULPs to avoid the overhead of dynamic MRs. 2559aa0a1e58SJeff Roberson * 2560*478d3005SHans Petter Selasky * This flag is generally considered unsafe and must only be used in 2561*478d3005SHans Petter Selasky * extremly trusted environments. Every use of it will log a warning 2562*478d3005SHans Petter Selasky * in the kernel log. 2563aa0a1e58SJeff Roberson */ 2564*478d3005SHans Petter Selasky IB_PD_UNSAFE_GLOBAL_RKEY = 0x01, 2565*478d3005SHans Petter Selasky }; 2566aa0a1e58SJeff Roberson 2567*478d3005SHans Petter Selasky struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, 2568*478d3005SHans Petter Selasky const char *caller); 2569*478d3005SHans Petter Selasky #define ib_alloc_pd(device, flags) \ 2570*478d3005SHans Petter Selasky __ib_alloc_pd((device), (flags), __func__) 2571*478d3005SHans Petter Selasky void ib_dealloc_pd(struct ib_pd *pd); 2572aa0a1e58SJeff Roberson 2573aa0a1e58SJeff Roberson /** 2574aa0a1e58SJeff Roberson * ib_create_ah - Creates an address handle for the given address vector. 2575aa0a1e58SJeff Roberson * @pd: The protection domain associated with the address handle. 2576aa0a1e58SJeff Roberson * @ah_attr: The attributes of the address vector. 2577aa0a1e58SJeff Roberson * 2578aa0a1e58SJeff Roberson * The address handle is used to reference a local or global destination 2579aa0a1e58SJeff Roberson * in all UD QP post sends. 2580aa0a1e58SJeff Roberson */ 2581aa0a1e58SJeff Roberson struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); 2582aa0a1e58SJeff Roberson 2583aa0a1e58SJeff Roberson /** 2584aa0a1e58SJeff Roberson * ib_init_ah_from_wc - Initializes address handle attributes from a 2585aa0a1e58SJeff Roberson * work completion. 2586aa0a1e58SJeff Roberson * @device: Device on which the received message arrived. 2587aa0a1e58SJeff Roberson * @port_num: Port on which the received message arrived. 2588aa0a1e58SJeff Roberson * @wc: Work completion associated with the received message. 2589aa0a1e58SJeff Roberson * @grh: References the received global route header. This parameter is 2590aa0a1e58SJeff Roberson * ignored unless the work completion indicates that the GRH is valid. 2591aa0a1e58SJeff Roberson * @ah_attr: Returned attributes that can be used when creating an address 2592aa0a1e58SJeff Roberson * handle for replying to the message. 2593aa0a1e58SJeff Roberson */ 2594*478d3005SHans Petter Selasky int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, 2595*478d3005SHans Petter Selasky const struct ib_wc *wc, const struct ib_grh *grh, 2596*478d3005SHans Petter Selasky struct ib_ah_attr *ah_attr); 2597aa0a1e58SJeff Roberson 2598aa0a1e58SJeff Roberson /** 2599aa0a1e58SJeff Roberson * ib_create_ah_from_wc - Creates an address handle associated with the 2600aa0a1e58SJeff Roberson * sender of the specified work completion. 2601aa0a1e58SJeff Roberson * @pd: The protection domain associated with the address handle. 2602aa0a1e58SJeff Roberson * @wc: Work completion information associated with a received message. 2603aa0a1e58SJeff Roberson * @grh: References the received global route header. This parameter is 2604aa0a1e58SJeff Roberson * ignored unless the work completion indicates that the GRH is valid. 2605aa0a1e58SJeff Roberson * @port_num: The outbound port number to associate with the address. 2606aa0a1e58SJeff Roberson * 2607aa0a1e58SJeff Roberson * The address handle is used to reference a local or global destination 2608aa0a1e58SJeff Roberson * in all UD QP post sends. 2609aa0a1e58SJeff Roberson */ 2610*478d3005SHans Petter Selasky struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, const struct ib_wc *wc, 2611*478d3005SHans Petter Selasky const struct ib_grh *grh, u8 port_num); 2612aa0a1e58SJeff Roberson 2613aa0a1e58SJeff Roberson /** 2614aa0a1e58SJeff Roberson * ib_modify_ah - Modifies the address vector associated with an address 2615aa0a1e58SJeff Roberson * handle. 2616aa0a1e58SJeff Roberson * @ah: The address handle to modify. 2617aa0a1e58SJeff Roberson * @ah_attr: The new address vector attributes to associate with the 2618aa0a1e58SJeff Roberson * address handle. 2619aa0a1e58SJeff Roberson */ 2620aa0a1e58SJeff Roberson int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 2621aa0a1e58SJeff Roberson 2622aa0a1e58SJeff Roberson /** 2623aa0a1e58SJeff Roberson * ib_query_ah - Queries the address vector associated with an address 2624aa0a1e58SJeff Roberson * handle. 2625aa0a1e58SJeff Roberson * @ah: The address handle to query. 2626aa0a1e58SJeff Roberson * @ah_attr: The address vector attributes associated with the address 2627aa0a1e58SJeff Roberson * handle. 2628aa0a1e58SJeff Roberson */ 2629aa0a1e58SJeff Roberson int ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 2630aa0a1e58SJeff Roberson 2631aa0a1e58SJeff Roberson /** 2632aa0a1e58SJeff Roberson * ib_destroy_ah - Destroys an address handle. 2633aa0a1e58SJeff Roberson * @ah: The address handle to destroy. 2634aa0a1e58SJeff Roberson */ 2635aa0a1e58SJeff Roberson int ib_destroy_ah(struct ib_ah *ah); 2636aa0a1e58SJeff Roberson 2637aa0a1e58SJeff Roberson /** 2638c9f432b7SAlfred Perlstein * ib_create_srq - Creates a SRQ associated with the specified protection 2639c9f432b7SAlfred Perlstein * domain. 2640aa0a1e58SJeff Roberson * @pd: The protection domain associated with the SRQ. 2641aa0a1e58SJeff Roberson * @srq_init_attr: A list of initial attributes required to create the 2642aa0a1e58SJeff Roberson * SRQ. If SRQ creation succeeds, then the attributes are updated to 2643aa0a1e58SJeff Roberson * the actual capabilities of the created SRQ. 2644aa0a1e58SJeff Roberson * 2645aa0a1e58SJeff Roberson * srq_attr->max_wr and srq_attr->max_sge are read the determine the 2646aa0a1e58SJeff Roberson * requested size of the SRQ, and set to the actual values allocated 2647aa0a1e58SJeff Roberson * on return. If ib_create_srq() succeeds, then max_wr and max_sge 2648aa0a1e58SJeff Roberson * will always be at least as large as the requested values. 2649aa0a1e58SJeff Roberson */ 2650aa0a1e58SJeff Roberson struct ib_srq *ib_create_srq(struct ib_pd *pd, 2651aa0a1e58SJeff Roberson struct ib_srq_init_attr *srq_init_attr); 2652aa0a1e58SJeff Roberson 2653aa0a1e58SJeff Roberson /** 2654aa0a1e58SJeff Roberson * ib_modify_srq - Modifies the attributes for the specified SRQ. 2655aa0a1e58SJeff Roberson * @srq: The SRQ to modify. 2656aa0a1e58SJeff Roberson * @srq_attr: On input, specifies the SRQ attributes to modify. On output, 2657aa0a1e58SJeff Roberson * the current values of selected SRQ attributes are returned. 2658aa0a1e58SJeff Roberson * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ 2659aa0a1e58SJeff Roberson * are being modified. 2660aa0a1e58SJeff Roberson * 2661aa0a1e58SJeff Roberson * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or 2662aa0a1e58SJeff Roberson * IB_SRQ_LIMIT to set the SRQ's limit and request notification when 2663aa0a1e58SJeff Roberson * the number of receives queued drops below the limit. 2664aa0a1e58SJeff Roberson */ 2665aa0a1e58SJeff Roberson int ib_modify_srq(struct ib_srq *srq, 2666aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr, 2667aa0a1e58SJeff Roberson enum ib_srq_attr_mask srq_attr_mask); 2668aa0a1e58SJeff Roberson 2669aa0a1e58SJeff Roberson /** 2670aa0a1e58SJeff Roberson * ib_query_srq - Returns the attribute list and current values for the 2671aa0a1e58SJeff Roberson * specified SRQ. 2672aa0a1e58SJeff Roberson * @srq: The SRQ to query. 2673aa0a1e58SJeff Roberson * @srq_attr: The attributes of the specified SRQ. 2674aa0a1e58SJeff Roberson */ 2675aa0a1e58SJeff Roberson int ib_query_srq(struct ib_srq *srq, 2676aa0a1e58SJeff Roberson struct ib_srq_attr *srq_attr); 2677aa0a1e58SJeff Roberson 2678aa0a1e58SJeff Roberson /** 2679aa0a1e58SJeff Roberson * ib_destroy_srq - Destroys the specified SRQ. 2680aa0a1e58SJeff Roberson * @srq: The SRQ to destroy. 2681aa0a1e58SJeff Roberson */ 2682aa0a1e58SJeff Roberson int ib_destroy_srq(struct ib_srq *srq); 2683aa0a1e58SJeff Roberson 2684aa0a1e58SJeff Roberson /** 2685aa0a1e58SJeff Roberson * ib_post_srq_recv - Posts a list of work requests to the specified SRQ. 2686aa0a1e58SJeff Roberson * @srq: The SRQ to post the work request on. 2687aa0a1e58SJeff Roberson * @recv_wr: A list of work requests to post on the receive queue. 2688aa0a1e58SJeff Roberson * @bad_recv_wr: On an immediate failure, this parameter will reference 2689aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2690aa0a1e58SJeff Roberson */ 2691aa0a1e58SJeff Roberson static inline int ib_post_srq_recv(struct ib_srq *srq, 2692aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 2693aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr) 2694aa0a1e58SJeff Roberson { 2695aa0a1e58SJeff Roberson return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr); 2696aa0a1e58SJeff Roberson } 2697aa0a1e58SJeff Roberson 2698aa0a1e58SJeff Roberson /** 2699aa0a1e58SJeff Roberson * ib_create_qp - Creates a QP associated with the specified protection 2700aa0a1e58SJeff Roberson * domain. 2701aa0a1e58SJeff Roberson * @pd: The protection domain associated with the QP. 2702aa0a1e58SJeff Roberson * @qp_init_attr: A list of initial attributes required to create the 2703aa0a1e58SJeff Roberson * QP. If QP creation succeeds, then the attributes are updated to 2704aa0a1e58SJeff Roberson * the actual capabilities of the created QP. 2705aa0a1e58SJeff Roberson */ 2706aa0a1e58SJeff Roberson struct ib_qp *ib_create_qp(struct ib_pd *pd, 2707aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 2708aa0a1e58SJeff Roberson 2709aa0a1e58SJeff Roberson /** 2710aa0a1e58SJeff Roberson * ib_modify_qp - Modifies the attributes for the specified QP and then 2711aa0a1e58SJeff Roberson * transitions the QP to the given state. 2712aa0a1e58SJeff Roberson * @qp: The QP to modify. 2713aa0a1e58SJeff Roberson * @qp_attr: On input, specifies the QP attributes to modify. On output, 2714aa0a1e58SJeff Roberson * the current values of selected QP attributes are returned. 2715aa0a1e58SJeff Roberson * @qp_attr_mask: A bit-mask used to specify which attributes of the QP 2716aa0a1e58SJeff Roberson * are being modified. 2717aa0a1e58SJeff Roberson */ 2718aa0a1e58SJeff Roberson int ib_modify_qp(struct ib_qp *qp, 2719aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 2720aa0a1e58SJeff Roberson int qp_attr_mask); 2721aa0a1e58SJeff Roberson 2722aa0a1e58SJeff Roberson /** 2723aa0a1e58SJeff Roberson * ib_query_qp - Returns the attribute list and current values for the 2724aa0a1e58SJeff Roberson * specified QP. 2725aa0a1e58SJeff Roberson * @qp: The QP to query. 2726aa0a1e58SJeff Roberson * @qp_attr: The attributes of the specified QP. 2727aa0a1e58SJeff Roberson * @qp_attr_mask: A bit-mask used to select specific attributes to query. 2728aa0a1e58SJeff Roberson * @qp_init_attr: Additional attributes of the selected QP. 2729aa0a1e58SJeff Roberson * 2730aa0a1e58SJeff Roberson * The qp_attr_mask may be used to limit the query to gathering only the 2731aa0a1e58SJeff Roberson * selected attributes. 2732aa0a1e58SJeff Roberson */ 2733aa0a1e58SJeff Roberson int ib_query_qp(struct ib_qp *qp, 2734aa0a1e58SJeff Roberson struct ib_qp_attr *qp_attr, 2735aa0a1e58SJeff Roberson int qp_attr_mask, 2736aa0a1e58SJeff Roberson struct ib_qp_init_attr *qp_init_attr); 2737aa0a1e58SJeff Roberson 2738aa0a1e58SJeff Roberson /** 2739aa0a1e58SJeff Roberson * ib_destroy_qp - Destroys the specified QP. 2740aa0a1e58SJeff Roberson * @qp: The QP to destroy. 2741aa0a1e58SJeff Roberson */ 2742aa0a1e58SJeff Roberson int ib_destroy_qp(struct ib_qp *qp); 2743aa0a1e58SJeff Roberson 2744aa0a1e58SJeff Roberson /** 2745c9f432b7SAlfred Perlstein * ib_open_qp - Obtain a reference to an existing sharable QP. 2746c9f432b7SAlfred Perlstein * @xrcd - XRC domain 2747c9f432b7SAlfred Perlstein * @qp_open_attr: Attributes identifying the QP to open. 2748c9f432b7SAlfred Perlstein * 2749c9f432b7SAlfred Perlstein * Returns a reference to a sharable QP. 2750c9f432b7SAlfred Perlstein */ 2751c9f432b7SAlfred Perlstein struct ib_qp *ib_open_qp(struct ib_xrcd *xrcd, 2752c9f432b7SAlfred Perlstein struct ib_qp_open_attr *qp_open_attr); 2753c9f432b7SAlfred Perlstein 2754c9f432b7SAlfred Perlstein /** 2755c9f432b7SAlfred Perlstein * ib_close_qp - Release an external reference to a QP. 2756c9f432b7SAlfred Perlstein * @qp: The QP handle to release 2757c9f432b7SAlfred Perlstein * 2758c9f432b7SAlfred Perlstein * The opened QP handle is released by the caller. The underlying 2759c9f432b7SAlfred Perlstein * shared QP is not destroyed until all internal references are released. 2760c9f432b7SAlfred Perlstein */ 2761c9f432b7SAlfred Perlstein int ib_close_qp(struct ib_qp *qp); 2762c9f432b7SAlfred Perlstein 2763c9f432b7SAlfred Perlstein /** 2764aa0a1e58SJeff Roberson * ib_post_send - Posts a list of work requests to the send queue of 2765aa0a1e58SJeff Roberson * the specified QP. 2766aa0a1e58SJeff Roberson * @qp: The QP to post the work request on. 2767aa0a1e58SJeff Roberson * @send_wr: A list of work requests to post on the send queue. 2768aa0a1e58SJeff Roberson * @bad_send_wr: On an immediate failure, this parameter will reference 2769aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2770c9f432b7SAlfred Perlstein * 2771c9f432b7SAlfred Perlstein * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate 2772c9f432b7SAlfred Perlstein * error is returned, the QP state shall not be affected, 2773c9f432b7SAlfred Perlstein * ib_post_send() will return an immediate error after queueing any 2774c9f432b7SAlfred Perlstein * earlier work requests in the list. 2775aa0a1e58SJeff Roberson */ 2776aa0a1e58SJeff Roberson static inline int ib_post_send(struct ib_qp *qp, 2777aa0a1e58SJeff Roberson struct ib_send_wr *send_wr, 2778aa0a1e58SJeff Roberson struct ib_send_wr **bad_send_wr) 2779aa0a1e58SJeff Roberson { 2780aa0a1e58SJeff Roberson return qp->device->post_send(qp, send_wr, bad_send_wr); 2781aa0a1e58SJeff Roberson } 2782aa0a1e58SJeff Roberson 2783aa0a1e58SJeff Roberson /** 2784aa0a1e58SJeff Roberson * ib_post_recv - Posts a list of work requests to the receive queue of 2785aa0a1e58SJeff Roberson * the specified QP. 2786aa0a1e58SJeff Roberson * @qp: The QP to post the work request on. 2787aa0a1e58SJeff Roberson * @recv_wr: A list of work requests to post on the receive queue. 2788aa0a1e58SJeff Roberson * @bad_recv_wr: On an immediate failure, this parameter will reference 2789aa0a1e58SJeff Roberson * the work request that failed to be posted on the QP. 2790aa0a1e58SJeff Roberson */ 2791aa0a1e58SJeff Roberson static inline int ib_post_recv(struct ib_qp *qp, 2792aa0a1e58SJeff Roberson struct ib_recv_wr *recv_wr, 2793aa0a1e58SJeff Roberson struct ib_recv_wr **bad_recv_wr) 2794aa0a1e58SJeff Roberson { 2795aa0a1e58SJeff Roberson return qp->device->post_recv(qp, recv_wr, bad_recv_wr); 2796aa0a1e58SJeff Roberson } 2797aa0a1e58SJeff Roberson 2798*478d3005SHans Petter Selasky struct ib_cq *ib_alloc_cq(struct ib_device *dev, void *private, 2799*478d3005SHans Petter Selasky int nr_cqe, int comp_vector, enum ib_poll_context poll_ctx); 2800*478d3005SHans Petter Selasky void ib_free_cq(struct ib_cq *cq); 2801*478d3005SHans Petter Selasky 2802aa0a1e58SJeff Roberson /** 2803aa0a1e58SJeff Roberson * ib_create_cq - Creates a CQ on the specified device. 2804aa0a1e58SJeff Roberson * @device: The device on which to create the CQ. 2805aa0a1e58SJeff Roberson * @comp_handler: A user-specified callback that is invoked when a 2806aa0a1e58SJeff Roberson * completion event occurs on the CQ. 2807aa0a1e58SJeff Roberson * @event_handler: A user-specified callback that is invoked when an 2808aa0a1e58SJeff Roberson * asynchronous event not associated with a completion occurs on the CQ. 2809aa0a1e58SJeff Roberson * @cq_context: Context associated with the CQ returned to the user via 2810aa0a1e58SJeff Roberson * the associated completion and event handlers. 2811*478d3005SHans Petter Selasky * @cq_attr: The attributes the CQ should be created upon. 2812aa0a1e58SJeff Roberson * 2813aa0a1e58SJeff Roberson * Users can examine the cq structure to determine the actual CQ size. 2814aa0a1e58SJeff Roberson */ 2815aa0a1e58SJeff Roberson struct ib_cq *ib_create_cq(struct ib_device *device, 2816aa0a1e58SJeff Roberson ib_comp_handler comp_handler, 2817aa0a1e58SJeff Roberson void (*event_handler)(struct ib_event *, void *), 2818*478d3005SHans Petter Selasky void *cq_context, 2819*478d3005SHans Petter Selasky const struct ib_cq_init_attr *cq_attr); 2820aa0a1e58SJeff Roberson 2821aa0a1e58SJeff Roberson /** 2822aa0a1e58SJeff Roberson * ib_resize_cq - Modifies the capacity of the CQ. 2823aa0a1e58SJeff Roberson * @cq: The CQ to resize. 2824aa0a1e58SJeff Roberson * @cqe: The minimum size of the CQ. 2825aa0a1e58SJeff Roberson * 2826aa0a1e58SJeff Roberson * Users can examine the cq structure to determine the actual CQ size. 2827aa0a1e58SJeff Roberson */ 2828aa0a1e58SJeff Roberson int ib_resize_cq(struct ib_cq *cq, int cqe); 2829aa0a1e58SJeff Roberson 2830aa0a1e58SJeff Roberson /** 2831*478d3005SHans Petter Selasky * ib_modify_cq - Modifies moderation params of the CQ 2832aa0a1e58SJeff Roberson * @cq: The CQ to modify. 2833*478d3005SHans Petter Selasky * @cq_count: number of CQEs that will trigger an event 2834*478d3005SHans Petter Selasky * @cq_period: max period of time in usec before triggering an event 2835*478d3005SHans Petter Selasky * 2836aa0a1e58SJeff Roberson */ 2837*478d3005SHans Petter Selasky int ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 2838aa0a1e58SJeff Roberson 2839aa0a1e58SJeff Roberson /** 2840aa0a1e58SJeff Roberson * ib_destroy_cq - Destroys the specified CQ. 2841aa0a1e58SJeff Roberson * @cq: The CQ to destroy. 2842aa0a1e58SJeff Roberson */ 2843aa0a1e58SJeff Roberson int ib_destroy_cq(struct ib_cq *cq); 2844aa0a1e58SJeff Roberson 2845aa0a1e58SJeff Roberson /** 2846aa0a1e58SJeff Roberson * ib_poll_cq - poll a CQ for completion(s) 2847aa0a1e58SJeff Roberson * @cq:the CQ being polled 2848aa0a1e58SJeff Roberson * @num_entries:maximum number of completions to return 2849aa0a1e58SJeff Roberson * @wc:array of at least @num_entries &struct ib_wc where completions 2850aa0a1e58SJeff Roberson * will be returned 2851aa0a1e58SJeff Roberson * 2852aa0a1e58SJeff Roberson * Poll a CQ for (possibly multiple) completions. If the return value 2853aa0a1e58SJeff Roberson * is < 0, an error occurred. If the return value is >= 0, it is the 2854aa0a1e58SJeff Roberson * number of completions returned. If the return value is 2855aa0a1e58SJeff Roberson * non-negative and < num_entries, then the CQ was emptied. 2856aa0a1e58SJeff Roberson */ 2857aa0a1e58SJeff Roberson static inline int ib_poll_cq(struct ib_cq *cq, int num_entries, 2858aa0a1e58SJeff Roberson struct ib_wc *wc) 2859aa0a1e58SJeff Roberson { 2860aa0a1e58SJeff Roberson return cq->device->poll_cq(cq, num_entries, wc); 2861aa0a1e58SJeff Roberson } 2862aa0a1e58SJeff Roberson 2863aa0a1e58SJeff Roberson /** 2864aa0a1e58SJeff Roberson * ib_peek_cq - Returns the number of unreaped completions currently 2865aa0a1e58SJeff Roberson * on the specified CQ. 2866aa0a1e58SJeff Roberson * @cq: The CQ to peek. 2867aa0a1e58SJeff Roberson * @wc_cnt: A minimum number of unreaped completions to check for. 2868aa0a1e58SJeff Roberson * 2869aa0a1e58SJeff Roberson * If the number of unreaped completions is greater than or equal to wc_cnt, 2870aa0a1e58SJeff Roberson * this function returns wc_cnt, otherwise, it returns the actual number of 2871aa0a1e58SJeff Roberson * unreaped completions. 2872aa0a1e58SJeff Roberson */ 2873aa0a1e58SJeff Roberson int ib_peek_cq(struct ib_cq *cq, int wc_cnt); 2874aa0a1e58SJeff Roberson 2875aa0a1e58SJeff Roberson /** 2876aa0a1e58SJeff Roberson * ib_req_notify_cq - Request completion notification on a CQ. 2877aa0a1e58SJeff Roberson * @cq: The CQ to generate an event for. 2878aa0a1e58SJeff Roberson * @flags: 2879aa0a1e58SJeff Roberson * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP 2880aa0a1e58SJeff Roberson * to request an event on the next solicited event or next work 2881aa0a1e58SJeff Roberson * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS 2882aa0a1e58SJeff Roberson * may also be |ed in to request a hint about missed events, as 2883aa0a1e58SJeff Roberson * described below. 2884aa0a1e58SJeff Roberson * 2885aa0a1e58SJeff Roberson * Return Value: 2886aa0a1e58SJeff Roberson * < 0 means an error occurred while requesting notification 2887aa0a1e58SJeff Roberson * == 0 means notification was requested successfully, and if 2888aa0a1e58SJeff Roberson * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events 2889aa0a1e58SJeff Roberson * were missed and it is safe to wait for another event. In 2890aa0a1e58SJeff Roberson * this case is it guaranteed that any work completions added 2891aa0a1e58SJeff Roberson * to the CQ since the last CQ poll will trigger a completion 2892aa0a1e58SJeff Roberson * notification event. 2893aa0a1e58SJeff Roberson * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed 2894aa0a1e58SJeff Roberson * in. It means that the consumer must poll the CQ again to 2895aa0a1e58SJeff Roberson * make sure it is empty to avoid missing an event because of a 2896aa0a1e58SJeff Roberson * race between requesting notification and an entry being 2897aa0a1e58SJeff Roberson * added to the CQ. This return value means it is possible 2898aa0a1e58SJeff Roberson * (but not guaranteed) that a work completion has been added 2899aa0a1e58SJeff Roberson * to the CQ since the last poll without triggering a 2900aa0a1e58SJeff Roberson * completion notification event. 2901aa0a1e58SJeff Roberson */ 2902aa0a1e58SJeff Roberson static inline int ib_req_notify_cq(struct ib_cq *cq, 2903aa0a1e58SJeff Roberson enum ib_cq_notify_flags flags) 2904aa0a1e58SJeff Roberson { 2905aa0a1e58SJeff Roberson return cq->device->req_notify_cq(cq, flags); 2906aa0a1e58SJeff Roberson } 2907aa0a1e58SJeff Roberson 2908aa0a1e58SJeff Roberson /** 2909aa0a1e58SJeff Roberson * ib_req_ncomp_notif - Request completion notification when there are 2910aa0a1e58SJeff Roberson * at least the specified number of unreaped completions on the CQ. 2911aa0a1e58SJeff Roberson * @cq: The CQ to generate an event for. 2912aa0a1e58SJeff Roberson * @wc_cnt: The number of unreaped completions that should be on the 2913aa0a1e58SJeff Roberson * CQ before an event is generated. 2914aa0a1e58SJeff Roberson */ 2915aa0a1e58SJeff Roberson static inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt) 2916aa0a1e58SJeff Roberson { 2917aa0a1e58SJeff Roberson return cq->device->req_ncomp_notif ? 2918aa0a1e58SJeff Roberson cq->device->req_ncomp_notif(cq, wc_cnt) : 2919aa0a1e58SJeff Roberson -ENOSYS; 2920aa0a1e58SJeff Roberson } 2921aa0a1e58SJeff Roberson 2922aa0a1e58SJeff Roberson /** 2923aa0a1e58SJeff Roberson * ib_dma_mapping_error - check a DMA addr for error 2924aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr was created 2925aa0a1e58SJeff Roberson * @dma_addr: The DMA address to check 2926aa0a1e58SJeff Roberson */ 2927aa0a1e58SJeff Roberson static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) 2928aa0a1e58SJeff Roberson { 2929aa0a1e58SJeff Roberson if (dev->dma_ops) 2930aa0a1e58SJeff Roberson return dev->dma_ops->mapping_error(dev, dma_addr); 2931aa0a1e58SJeff Roberson return dma_mapping_error(dev->dma_device, dma_addr); 2932aa0a1e58SJeff Roberson } 2933aa0a1e58SJeff Roberson 2934aa0a1e58SJeff Roberson /** 2935aa0a1e58SJeff Roberson * ib_dma_map_single - Map a kernel virtual address to DMA address 2936aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr is to be created 2937aa0a1e58SJeff Roberson * @cpu_addr: The kernel virtual address 2938aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2939aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2940aa0a1e58SJeff Roberson */ 2941aa0a1e58SJeff Roberson static inline u64 ib_dma_map_single(struct ib_device *dev, 2942aa0a1e58SJeff Roberson void *cpu_addr, size_t size, 2943aa0a1e58SJeff Roberson enum dma_data_direction direction) 2944aa0a1e58SJeff Roberson { 2945aa0a1e58SJeff Roberson if (dev->dma_ops) 2946aa0a1e58SJeff Roberson return dev->dma_ops->map_single(dev, cpu_addr, size, direction); 2947aa0a1e58SJeff Roberson return dma_map_single(dev->dma_device, cpu_addr, size, direction); 2948aa0a1e58SJeff Roberson } 2949aa0a1e58SJeff Roberson 2950aa0a1e58SJeff Roberson /** 2951aa0a1e58SJeff Roberson * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single() 2952aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 2953aa0a1e58SJeff Roberson * @addr: The DMA address 2954aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2955aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2956aa0a1e58SJeff Roberson */ 2957aa0a1e58SJeff Roberson static inline void ib_dma_unmap_single(struct ib_device *dev, 2958aa0a1e58SJeff Roberson u64 addr, size_t size, 2959aa0a1e58SJeff Roberson enum dma_data_direction direction) 2960aa0a1e58SJeff Roberson { 2961aa0a1e58SJeff Roberson if (dev->dma_ops) 2962aa0a1e58SJeff Roberson dev->dma_ops->unmap_single(dev, addr, size, direction); 2963aa0a1e58SJeff Roberson else 2964aa0a1e58SJeff Roberson dma_unmap_single(dev->dma_device, addr, size, direction); 2965aa0a1e58SJeff Roberson } 2966aa0a1e58SJeff Roberson 2967aa0a1e58SJeff Roberson static inline u64 ib_dma_map_single_attrs(struct ib_device *dev, 2968aa0a1e58SJeff Roberson void *cpu_addr, size_t size, 2969aa0a1e58SJeff Roberson enum dma_data_direction direction, 2970*478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 2971aa0a1e58SJeff Roberson { 2972aa0a1e58SJeff Roberson return dma_map_single_attrs(dev->dma_device, cpu_addr, size, 2973*478d3005SHans Petter Selasky direction, dma_attrs); 2974aa0a1e58SJeff Roberson } 2975aa0a1e58SJeff Roberson 2976aa0a1e58SJeff Roberson static inline void ib_dma_unmap_single_attrs(struct ib_device *dev, 2977aa0a1e58SJeff Roberson u64 addr, size_t size, 2978aa0a1e58SJeff Roberson enum dma_data_direction direction, 2979*478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 2980aa0a1e58SJeff Roberson { 2981aa0a1e58SJeff Roberson return dma_unmap_single_attrs(dev->dma_device, addr, size, 2982*478d3005SHans Petter Selasky direction, dma_attrs); 2983aa0a1e58SJeff Roberson } 2984aa0a1e58SJeff Roberson 2985aa0a1e58SJeff Roberson /** 2986aa0a1e58SJeff Roberson * ib_dma_map_page - Map a physical page to DMA address 2987aa0a1e58SJeff Roberson * @dev: The device for which the dma_addr is to be created 2988aa0a1e58SJeff Roberson * @page: The page to be mapped 2989aa0a1e58SJeff Roberson * @offset: The offset within the page 2990aa0a1e58SJeff Roberson * @size: The size of the region in bytes 2991aa0a1e58SJeff Roberson * @direction: The direction of the DMA 2992aa0a1e58SJeff Roberson */ 2993aa0a1e58SJeff Roberson static inline u64 ib_dma_map_page(struct ib_device *dev, 2994aa0a1e58SJeff Roberson struct page *page, 2995aa0a1e58SJeff Roberson unsigned long offset, 2996aa0a1e58SJeff Roberson size_t size, 2997aa0a1e58SJeff Roberson enum dma_data_direction direction) 2998aa0a1e58SJeff Roberson { 2999aa0a1e58SJeff Roberson if (dev->dma_ops) 3000aa0a1e58SJeff Roberson return dev->dma_ops->map_page(dev, page, offset, size, direction); 3001aa0a1e58SJeff Roberson return dma_map_page(dev->dma_device, page, offset, size, direction); 3002aa0a1e58SJeff Roberson } 3003aa0a1e58SJeff Roberson 3004aa0a1e58SJeff Roberson /** 3005aa0a1e58SJeff Roberson * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page() 3006aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3007aa0a1e58SJeff Roberson * @addr: The DMA address 3008aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3009aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3010aa0a1e58SJeff Roberson */ 3011aa0a1e58SJeff Roberson static inline void ib_dma_unmap_page(struct ib_device *dev, 3012aa0a1e58SJeff Roberson u64 addr, size_t size, 3013aa0a1e58SJeff Roberson enum dma_data_direction direction) 3014aa0a1e58SJeff Roberson { 3015aa0a1e58SJeff Roberson if (dev->dma_ops) 3016aa0a1e58SJeff Roberson dev->dma_ops->unmap_page(dev, addr, size, direction); 3017aa0a1e58SJeff Roberson else 3018aa0a1e58SJeff Roberson dma_unmap_page(dev->dma_device, addr, size, direction); 3019aa0a1e58SJeff Roberson } 3020aa0a1e58SJeff Roberson 3021aa0a1e58SJeff Roberson /** 3022aa0a1e58SJeff Roberson * ib_dma_map_sg - Map a scatter/gather list to DMA addresses 3023aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses are to be created 3024aa0a1e58SJeff Roberson * @sg: The array of scatter/gather entries 3025aa0a1e58SJeff Roberson * @nents: The number of scatter/gather entries 3026aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3027aa0a1e58SJeff Roberson */ 3028aa0a1e58SJeff Roberson static inline int ib_dma_map_sg(struct ib_device *dev, 3029aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3030aa0a1e58SJeff Roberson enum dma_data_direction direction) 3031aa0a1e58SJeff Roberson { 3032aa0a1e58SJeff Roberson if (dev->dma_ops) 3033aa0a1e58SJeff Roberson return dev->dma_ops->map_sg(dev, sg, nents, direction); 3034aa0a1e58SJeff Roberson return dma_map_sg(dev->dma_device, sg, nents, direction); 3035aa0a1e58SJeff Roberson } 3036aa0a1e58SJeff Roberson 3037aa0a1e58SJeff Roberson /** 3038aa0a1e58SJeff Roberson * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses 3039aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3040aa0a1e58SJeff Roberson * @sg: The array of scatter/gather entries 3041aa0a1e58SJeff Roberson * @nents: The number of scatter/gather entries 3042aa0a1e58SJeff Roberson * @direction: The direction of the DMA 3043aa0a1e58SJeff Roberson */ 3044aa0a1e58SJeff Roberson static inline void ib_dma_unmap_sg(struct ib_device *dev, 3045aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3046aa0a1e58SJeff Roberson enum dma_data_direction direction) 3047aa0a1e58SJeff Roberson { 3048aa0a1e58SJeff Roberson if (dev->dma_ops) 3049aa0a1e58SJeff Roberson dev->dma_ops->unmap_sg(dev, sg, nents, direction); 3050aa0a1e58SJeff Roberson else 3051aa0a1e58SJeff Roberson dma_unmap_sg(dev->dma_device, sg, nents, direction); 3052aa0a1e58SJeff Roberson } 3053aa0a1e58SJeff Roberson 3054aa0a1e58SJeff Roberson static inline int ib_dma_map_sg_attrs(struct ib_device *dev, 3055aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3056aa0a1e58SJeff Roberson enum dma_data_direction direction, 3057*478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 3058aa0a1e58SJeff Roberson { 3059*478d3005SHans Petter Selasky if (dev->dma_ops) 3060*478d3005SHans Petter Selasky return dev->dma_ops->map_sg_attrs(dev, sg, nents, direction, 3061*478d3005SHans Petter Selasky dma_attrs); 3062*478d3005SHans Petter Selasky else 3063*478d3005SHans Petter Selasky return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, 3064*478d3005SHans Petter Selasky dma_attrs); 3065aa0a1e58SJeff Roberson } 3066aa0a1e58SJeff Roberson 3067aa0a1e58SJeff Roberson static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, 3068aa0a1e58SJeff Roberson struct scatterlist *sg, int nents, 3069aa0a1e58SJeff Roberson enum dma_data_direction direction, 3070*478d3005SHans Petter Selasky struct dma_attrs *dma_attrs) 3071aa0a1e58SJeff Roberson { 3072*478d3005SHans Petter Selasky if (dev->dma_ops) 3073*478d3005SHans Petter Selasky return dev->dma_ops->unmap_sg_attrs(dev, sg, nents, direction, 3074*478d3005SHans Petter Selasky dma_attrs); 3075*478d3005SHans Petter Selasky else 3076*478d3005SHans Petter Selasky dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, 3077*478d3005SHans Petter Selasky dma_attrs); 3078aa0a1e58SJeff Roberson } 3079aa0a1e58SJeff Roberson /** 3080aa0a1e58SJeff Roberson * ib_sg_dma_address - Return the DMA address from a scatter/gather entry 3081aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3082aa0a1e58SJeff Roberson * @sg: The scatter/gather entry 3083*478d3005SHans Petter Selasky * 3084*478d3005SHans Petter Selasky * Note: this function is obsolete. To do: change all occurrences of 3085*478d3005SHans Petter Selasky * ib_sg_dma_address() into sg_dma_address(). 3086aa0a1e58SJeff Roberson */ 3087aa0a1e58SJeff Roberson static inline u64 ib_sg_dma_address(struct ib_device *dev, 3088aa0a1e58SJeff Roberson struct scatterlist *sg) 3089aa0a1e58SJeff Roberson { 3090aa0a1e58SJeff Roberson return sg_dma_address(sg); 3091aa0a1e58SJeff Roberson } 3092aa0a1e58SJeff Roberson 3093aa0a1e58SJeff Roberson /** 3094aa0a1e58SJeff Roberson * ib_sg_dma_len - Return the DMA length from a scatter/gather entry 3095aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were created 3096aa0a1e58SJeff Roberson * @sg: The scatter/gather entry 3097*478d3005SHans Petter Selasky * 3098*478d3005SHans Petter Selasky * Note: this function is obsolete. To do: change all occurrences of 3099*478d3005SHans Petter Selasky * ib_sg_dma_len() into sg_dma_len(). 3100aa0a1e58SJeff Roberson */ 3101aa0a1e58SJeff Roberson static inline unsigned int ib_sg_dma_len(struct ib_device *dev, 3102aa0a1e58SJeff Roberson struct scatterlist *sg) 3103aa0a1e58SJeff Roberson { 3104aa0a1e58SJeff Roberson return sg_dma_len(sg); 3105aa0a1e58SJeff Roberson } 3106aa0a1e58SJeff Roberson 3107aa0a1e58SJeff Roberson /** 3108aa0a1e58SJeff Roberson * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU 3109aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3110aa0a1e58SJeff Roberson * @addr: The DMA address 3111aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3112aa0a1e58SJeff Roberson * @dir: The direction of the DMA 3113aa0a1e58SJeff Roberson */ 3114aa0a1e58SJeff Roberson static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev, 3115aa0a1e58SJeff Roberson u64 addr, 3116aa0a1e58SJeff Roberson size_t size, 3117aa0a1e58SJeff Roberson enum dma_data_direction dir) 3118aa0a1e58SJeff Roberson { 3119aa0a1e58SJeff Roberson if (dev->dma_ops) 3120aa0a1e58SJeff Roberson dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir); 3121aa0a1e58SJeff Roberson else 3122aa0a1e58SJeff Roberson dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); 3123aa0a1e58SJeff Roberson } 3124aa0a1e58SJeff Roberson 3125aa0a1e58SJeff Roberson /** 3126aa0a1e58SJeff Roberson * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device 3127aa0a1e58SJeff Roberson * @dev: The device for which the DMA address was created 3128aa0a1e58SJeff Roberson * @addr: The DMA address 3129aa0a1e58SJeff Roberson * @size: The size of the region in bytes 3130aa0a1e58SJeff Roberson * @dir: The direction of the DMA 3131aa0a1e58SJeff Roberson */ 3132aa0a1e58SJeff Roberson static inline void ib_dma_sync_single_for_device(struct ib_device *dev, 3133aa0a1e58SJeff Roberson u64 addr, 3134aa0a1e58SJeff Roberson size_t size, 3135aa0a1e58SJeff Roberson enum dma_data_direction dir) 3136aa0a1e58SJeff Roberson { 3137aa0a1e58SJeff Roberson if (dev->dma_ops) 3138aa0a1e58SJeff Roberson dev->dma_ops->sync_single_for_device(dev, addr, size, dir); 3139aa0a1e58SJeff Roberson else 3140aa0a1e58SJeff Roberson dma_sync_single_for_device(dev->dma_device, addr, size, dir); 3141aa0a1e58SJeff Roberson } 3142aa0a1e58SJeff Roberson 3143aa0a1e58SJeff Roberson /** 3144aa0a1e58SJeff Roberson * ib_dma_alloc_coherent - Allocate memory and map it for DMA 3145aa0a1e58SJeff Roberson * @dev: The device for which the DMA address is requested 3146aa0a1e58SJeff Roberson * @size: The size of the region to allocate in bytes 3147aa0a1e58SJeff Roberson * @dma_handle: A pointer for returning the DMA address of the region 3148aa0a1e58SJeff Roberson * @flag: memory allocator flags 3149aa0a1e58SJeff Roberson */ 3150aa0a1e58SJeff Roberson static inline void *ib_dma_alloc_coherent(struct ib_device *dev, 3151aa0a1e58SJeff Roberson size_t size, 3152aa0a1e58SJeff Roberson u64 *dma_handle, 3153aa0a1e58SJeff Roberson gfp_t flag) 3154aa0a1e58SJeff Roberson { 3155aa0a1e58SJeff Roberson if (dev->dma_ops) 3156aa0a1e58SJeff Roberson return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag); 3157aa0a1e58SJeff Roberson else { 3158aa0a1e58SJeff Roberson dma_addr_t handle; 3159aa0a1e58SJeff Roberson void *ret; 3160aa0a1e58SJeff Roberson 3161aa0a1e58SJeff Roberson ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag); 3162aa0a1e58SJeff Roberson *dma_handle = handle; 3163aa0a1e58SJeff Roberson return ret; 3164aa0a1e58SJeff Roberson } 3165aa0a1e58SJeff Roberson } 3166aa0a1e58SJeff Roberson 3167aa0a1e58SJeff Roberson /** 3168aa0a1e58SJeff Roberson * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent() 3169aa0a1e58SJeff Roberson * @dev: The device for which the DMA addresses were allocated 3170aa0a1e58SJeff Roberson * @size: The size of the region 3171aa0a1e58SJeff Roberson * @cpu_addr: the address returned by ib_dma_alloc_coherent() 3172aa0a1e58SJeff Roberson * @dma_handle: the DMA address returned by ib_dma_alloc_coherent() 3173aa0a1e58SJeff Roberson */ 3174aa0a1e58SJeff Roberson static inline void ib_dma_free_coherent(struct ib_device *dev, 3175aa0a1e58SJeff Roberson size_t size, void *cpu_addr, 3176aa0a1e58SJeff Roberson u64 dma_handle) 3177aa0a1e58SJeff Roberson { 3178aa0a1e58SJeff Roberson if (dev->dma_ops) 3179aa0a1e58SJeff Roberson dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 3180aa0a1e58SJeff Roberson else 3181aa0a1e58SJeff Roberson dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle); 3182aa0a1e58SJeff Roberson } 3183aa0a1e58SJeff Roberson 3184aa0a1e58SJeff Roberson /** 3185aa0a1e58SJeff Roberson * ib_dereg_mr - Deregisters a memory region and removes it from the 3186aa0a1e58SJeff Roberson * HCA translation table. 3187aa0a1e58SJeff Roberson * @mr: The memory region to deregister. 3188b5c1e0cbSHans Petter Selasky * 3189b5c1e0cbSHans Petter Selasky * This function can fail, if the memory region has memory windows bound to it. 3190aa0a1e58SJeff Roberson */ 3191aa0a1e58SJeff Roberson int ib_dereg_mr(struct ib_mr *mr); 3192aa0a1e58SJeff Roberson 3193*478d3005SHans Petter Selasky struct ib_mr *ib_alloc_mr(struct ib_pd *pd, 3194*478d3005SHans Petter Selasky enum ib_mr_type mr_type, 3195*478d3005SHans Petter Selasky u32 max_num_sg); 3196aa0a1e58SJeff Roberson 3197aa0a1e58SJeff Roberson /** 3198aa0a1e58SJeff Roberson * ib_update_fast_reg_key - updates the key portion of the fast_reg MR 3199aa0a1e58SJeff Roberson * R_Key and L_Key. 3200aa0a1e58SJeff Roberson * @mr - struct ib_mr pointer to be updated. 3201aa0a1e58SJeff Roberson * @newkey - new key to be used. 3202aa0a1e58SJeff Roberson */ 3203aa0a1e58SJeff Roberson static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey) 3204aa0a1e58SJeff Roberson { 3205aa0a1e58SJeff Roberson mr->lkey = (mr->lkey & 0xffffff00) | newkey; 3206aa0a1e58SJeff Roberson mr->rkey = (mr->rkey & 0xffffff00) | newkey; 3207aa0a1e58SJeff Roberson } 3208aa0a1e58SJeff Roberson 3209aa0a1e58SJeff Roberson /** 3210b5c1e0cbSHans Petter Selasky * ib_inc_rkey - increments the key portion of the given rkey. Can be used 3211b5c1e0cbSHans Petter Selasky * for calculating a new rkey for type 2 memory windows. 3212b5c1e0cbSHans Petter Selasky * @rkey - the rkey to increment. 3213b5c1e0cbSHans Petter Selasky */ 3214b5c1e0cbSHans Petter Selasky static inline u32 ib_inc_rkey(u32 rkey) 3215b5c1e0cbSHans Petter Selasky { 3216b5c1e0cbSHans Petter Selasky const u32 mask = 0x000000ff; 3217b5c1e0cbSHans Petter Selasky return ((rkey + 1) & mask) | (rkey & ~mask); 3218b5c1e0cbSHans Petter Selasky } 3219b5c1e0cbSHans Petter Selasky 3220b5c1e0cbSHans Petter Selasky /** 3221aa0a1e58SJeff Roberson * ib_alloc_fmr - Allocates a unmapped fast memory region. 3222aa0a1e58SJeff Roberson * @pd: The protection domain associated with the unmapped region. 3223aa0a1e58SJeff Roberson * @mr_access_flags: Specifies the memory access rights. 3224aa0a1e58SJeff Roberson * @fmr_attr: Attributes of the unmapped region. 3225aa0a1e58SJeff Roberson * 3226aa0a1e58SJeff Roberson * A fast memory region must be mapped before it can be used as part of 3227aa0a1e58SJeff Roberson * a work request. 3228aa0a1e58SJeff Roberson */ 3229aa0a1e58SJeff Roberson struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd, 3230aa0a1e58SJeff Roberson int mr_access_flags, 3231aa0a1e58SJeff Roberson struct ib_fmr_attr *fmr_attr); 3232aa0a1e58SJeff Roberson 3233aa0a1e58SJeff Roberson /** 3234aa0a1e58SJeff Roberson * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region. 3235aa0a1e58SJeff Roberson * @fmr: The fast memory region to associate with the pages. 3236aa0a1e58SJeff Roberson * @page_list: An array of physical pages to map to the fast memory region. 3237aa0a1e58SJeff Roberson * @list_len: The number of pages in page_list. 3238aa0a1e58SJeff Roberson * @iova: The I/O virtual address to use with the mapped region. 3239aa0a1e58SJeff Roberson */ 3240aa0a1e58SJeff Roberson static inline int ib_map_phys_fmr(struct ib_fmr *fmr, 3241aa0a1e58SJeff Roberson u64 *page_list, int list_len, 3242aa0a1e58SJeff Roberson u64 iova) 3243aa0a1e58SJeff Roberson { 3244aa0a1e58SJeff Roberson return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova); 3245aa0a1e58SJeff Roberson } 3246aa0a1e58SJeff Roberson 3247aa0a1e58SJeff Roberson /** 3248aa0a1e58SJeff Roberson * ib_unmap_fmr - Removes the mapping from a list of fast memory regions. 3249aa0a1e58SJeff Roberson * @fmr_list: A linked list of fast memory regions to unmap. 3250aa0a1e58SJeff Roberson */ 3251aa0a1e58SJeff Roberson int ib_unmap_fmr(struct list_head *fmr_list); 3252aa0a1e58SJeff Roberson 3253aa0a1e58SJeff Roberson /** 3254aa0a1e58SJeff Roberson * ib_dealloc_fmr - Deallocates a fast memory region. 3255aa0a1e58SJeff Roberson * @fmr: The fast memory region to deallocate. 3256aa0a1e58SJeff Roberson */ 3257aa0a1e58SJeff Roberson int ib_dealloc_fmr(struct ib_fmr *fmr); 3258aa0a1e58SJeff Roberson 3259aa0a1e58SJeff Roberson /** 3260aa0a1e58SJeff Roberson * ib_attach_mcast - Attaches the specified QP to a multicast group. 3261aa0a1e58SJeff Roberson * @qp: QP to attach to the multicast group. The QP must be type 3262aa0a1e58SJeff Roberson * IB_QPT_UD. 3263aa0a1e58SJeff Roberson * @gid: Multicast group GID. 3264aa0a1e58SJeff Roberson * @lid: Multicast group LID in host byte order. 3265aa0a1e58SJeff Roberson * 3266aa0a1e58SJeff Roberson * In order to send and receive multicast packets, subnet 3267aa0a1e58SJeff Roberson * administration must have created the multicast group and configured 3268aa0a1e58SJeff Roberson * the fabric appropriately. The port associated with the specified 3269aa0a1e58SJeff Roberson * QP must also be a member of the multicast group. 3270aa0a1e58SJeff Roberson */ 3271aa0a1e58SJeff Roberson int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 3272aa0a1e58SJeff Roberson 3273aa0a1e58SJeff Roberson /** 3274aa0a1e58SJeff Roberson * ib_detach_mcast - Detaches the specified QP from a multicast group. 3275aa0a1e58SJeff Roberson * @qp: QP to detach from the multicast group. 3276aa0a1e58SJeff Roberson * @gid: Multicast group GID. 3277aa0a1e58SJeff Roberson * @lid: Multicast group LID in host byte order. 3278aa0a1e58SJeff Roberson */ 3279aa0a1e58SJeff Roberson int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 3280aa0a1e58SJeff Roberson 3281c9f432b7SAlfred Perlstein /** 3282c9f432b7SAlfred Perlstein * ib_alloc_xrcd - Allocates an XRC domain. 3283c9f432b7SAlfred Perlstein * @device: The device on which to allocate the XRC domain. 3284c9f432b7SAlfred Perlstein */ 3285c9f432b7SAlfred Perlstein struct ib_xrcd *ib_alloc_xrcd(struct ib_device *device); 3286aa0a1e58SJeff Roberson 3287aa0a1e58SJeff Roberson /** 3288c9f432b7SAlfred Perlstein * ib_dealloc_xrcd - Deallocates an XRC domain. 3289c9f432b7SAlfred Perlstein * @xrcd: The XRC domain to deallocate. 3290aa0a1e58SJeff Roberson */ 3291aa0a1e58SJeff Roberson int ib_dealloc_xrcd(struct ib_xrcd *xrcd); 3292aa0a1e58SJeff Roberson 3293b5c1e0cbSHans Petter Selasky struct ib_flow *ib_create_flow(struct ib_qp *qp, 3294b5c1e0cbSHans Petter Selasky struct ib_flow_attr *flow_attr, int domain); 3295b5c1e0cbSHans Petter Selasky int ib_destroy_flow(struct ib_flow *flow_id); 3296b5c1e0cbSHans Petter Selasky 3297b5c1e0cbSHans Petter Selasky static inline int ib_check_mr_access(int flags) 3298b5c1e0cbSHans Petter Selasky { 3299b5c1e0cbSHans Petter Selasky /* 3300b5c1e0cbSHans Petter Selasky * Local write permission is required if remote write or 3301b5c1e0cbSHans Petter Selasky * remote atomic permission is also requested. 3302b5c1e0cbSHans Petter Selasky */ 3303b5c1e0cbSHans Petter Selasky if (flags & (IB_ACCESS_REMOTE_ATOMIC | IB_ACCESS_REMOTE_WRITE) && 3304b5c1e0cbSHans Petter Selasky !(flags & IB_ACCESS_LOCAL_WRITE)) 3305b5c1e0cbSHans Petter Selasky return -EINVAL; 3306b5c1e0cbSHans Petter Selasky 3307b5c1e0cbSHans Petter Selasky return 0; 3308b5c1e0cbSHans Petter Selasky } 3309b5c1e0cbSHans Petter Selasky 3310b5c1e0cbSHans Petter Selasky /** 3311b5c1e0cbSHans Petter Selasky * ib_check_mr_status: lightweight check of MR status. 3312b5c1e0cbSHans Petter Selasky * This routine may provide status checks on a selected 3313b5c1e0cbSHans Petter Selasky * ib_mr. first use is for signature status check. 3314b5c1e0cbSHans Petter Selasky * 3315b5c1e0cbSHans Petter Selasky * @mr: A memory region. 3316b5c1e0cbSHans Petter Selasky * @check_mask: Bitmask of which checks to perform from 3317b5c1e0cbSHans Petter Selasky * ib_mr_status_check enumeration. 3318b5c1e0cbSHans Petter Selasky * @mr_status: The container of relevant status checks. 3319b5c1e0cbSHans Petter Selasky * failed checks will be indicated in the status bitmask 3320b5c1e0cbSHans Petter Selasky * and the relevant info shall be in the error item. 3321b5c1e0cbSHans Petter Selasky */ 3322b5c1e0cbSHans Petter Selasky int ib_check_mr_status(struct ib_mr *mr, u32 check_mask, 3323b5c1e0cbSHans Petter Selasky struct ib_mr_status *mr_status); 3324aa0a1e58SJeff Roberson 3325*478d3005SHans Petter Selasky struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u8 port, 3326*478d3005SHans Petter Selasky u16 pkey, const union ib_gid *gid, 3327*478d3005SHans Petter Selasky const struct sockaddr *addr); 3328*478d3005SHans Petter Selasky struct ib_wq *ib_create_wq(struct ib_pd *pd, 3329*478d3005SHans Petter Selasky struct ib_wq_init_attr *init_attr); 3330*478d3005SHans Petter Selasky int ib_destroy_wq(struct ib_wq *wq); 3331*478d3005SHans Petter Selasky int ib_modify_wq(struct ib_wq *wq, struct ib_wq_attr *attr, 3332*478d3005SHans Petter Selasky u32 wq_attr_mask); 3333*478d3005SHans Petter Selasky struct ib_rwq_ind_table *ib_create_rwq_ind_table(struct ib_device *device, 3334*478d3005SHans Petter Selasky struct ib_rwq_ind_table_init_attr* 3335*478d3005SHans Petter Selasky wq_ind_table_init_attr); 3336*478d3005SHans Petter Selasky int ib_destroy_rwq_ind_table(struct ib_rwq_ind_table *wq_ind_table); 3337*478d3005SHans Petter Selasky 3338*478d3005SHans Petter Selasky int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, 3339*478d3005SHans Petter Selasky unsigned int *sg_offset, unsigned int page_size); 3340*478d3005SHans Petter Selasky 3341*478d3005SHans Petter Selasky static inline int 3342*478d3005SHans Petter Selasky ib_map_mr_sg_zbva(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, 3343*478d3005SHans Petter Selasky unsigned int *sg_offset, unsigned int page_size) 3344*478d3005SHans Petter Selasky { 3345*478d3005SHans Petter Selasky int n; 3346*478d3005SHans Petter Selasky 3347*478d3005SHans Petter Selasky n = ib_map_mr_sg(mr, sg, sg_nents, sg_offset, page_size); 3348*478d3005SHans Petter Selasky mr->iova = 0; 3349*478d3005SHans Petter Selasky 3350*478d3005SHans Petter Selasky return n; 3351*478d3005SHans Petter Selasky } 3352*478d3005SHans Petter Selasky 3353*478d3005SHans Petter Selasky int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents, 3354*478d3005SHans Petter Selasky unsigned int *sg_offset, int (*set_page)(struct ib_mr *, u64)); 3355*478d3005SHans Petter Selasky 3356*478d3005SHans Petter Selasky void ib_drain_rq(struct ib_qp *qp); 3357*478d3005SHans Petter Selasky void ib_drain_sq(struct ib_qp *qp); 3358*478d3005SHans Petter Selasky void ib_drain_qp(struct ib_qp *qp); 3359aa0a1e58SJeff Roberson #endif /* IB_VERBS_H */ 3360