1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. 3219820Sjeff * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 4219820Sjeff * Copyright (c) 2004 Intel Corporation. All rights reserved. 5219820Sjeff * Copyright (c) 2004 Topspin Corporation. All rights reserved. 6219820Sjeff * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 7219820Sjeff * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 8219820Sjeff * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved. 9219820Sjeff * 10219820Sjeff * This software is available to you under a choice of one of two 11219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 12219820Sjeff * General Public License (GPL) Version 2, available from the file 13219820Sjeff * COPYING in the main directory of this source tree, or the 14219820Sjeff * OpenIB.org BSD license below: 15219820Sjeff * 16219820Sjeff * Redistribution and use in source and binary forms, with or 17219820Sjeff * without modification, are permitted provided that the following 18219820Sjeff * conditions are met: 19219820Sjeff * 20219820Sjeff * - Redistributions of source code must retain the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer. 23219820Sjeff * 24219820Sjeff * - Redistributions in binary form must reproduce the above 25219820Sjeff * copyright notice, this list of conditions and the following 26219820Sjeff * disclaimer in the documentation and/or other materials 27219820Sjeff * provided with the distribution. 28219820Sjeff * 29219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 30219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 31219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 32219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 33219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 34219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 35219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 36219820Sjeff * SOFTWARE. 37219820Sjeff */ 38219820Sjeff 39219820Sjeff#if !defined(IB_VERBS_H) 40219820Sjeff#define IB_VERBS_H 41219820Sjeff 42219820Sjeff#include <linux/types.h> 43219820Sjeff#include <linux/device.h> 44219820Sjeff#include <linux/mm.h> 45219820Sjeff#include <linux/dma-mapping.h> 46219820Sjeff#include <linux/kref.h> 47219820Sjeff#include <linux/list.h> 48219820Sjeff#include <linux/rwsem.h> 49219820Sjeff#include <linux/scatterlist.h> 50255932Salfred#include <linux/workqueue.h> 51219820Sjeff 52255932Salfred#include <linux/atomic.h> 53219820Sjeff#include <asm/uaccess.h> 54219820Sjeff#include <linux/rbtree.h> 55219820Sjeff#include <linux/mutex.h> 56219820Sjeff 57255932Salfredextern struct workqueue_struct *ib_wq; 58255932Salfred 59219820Sjeffunion ib_gid { 60219820Sjeff u8 raw[16]; 61219820Sjeff struct { 62219820Sjeff __be64 subnet_prefix; 63219820Sjeff __be64 interface_id; 64219820Sjeff } global; 65219820Sjeff}; 66219820Sjeff 67219820Sjeffenum rdma_node_type { 68219820Sjeff /* IB values map to NodeInfo:NodeType. */ 69219820Sjeff RDMA_NODE_IB_CA = 1, 70219820Sjeff RDMA_NODE_IB_SWITCH, 71219820Sjeff RDMA_NODE_IB_ROUTER, 72219820Sjeff RDMA_NODE_RNIC 73219820Sjeff}; 74219820Sjeff 75219820Sjeffenum rdma_transport_type { 76219820Sjeff RDMA_TRANSPORT_IB, 77219820Sjeff RDMA_TRANSPORT_IWARP 78219820Sjeff}; 79219820Sjeff 80219820Sjeffenum rdma_transport_type 81219820Sjeffrdma_node_get_transport(enum rdma_node_type node_type) __attribute_const__; 82219820Sjeff 83219820Sjeffenum rdma_link_layer { 84219820Sjeff IB_LINK_LAYER_UNSPECIFIED, 85219820Sjeff IB_LINK_LAYER_INFINIBAND, 86219820Sjeff IB_LINK_LAYER_ETHERNET, 87219820Sjeff}; 88219820Sjeff 89219820Sjeffenum ib_device_cap_flags { 90219820Sjeff IB_DEVICE_RESIZE_MAX_WR = 1, 91219820Sjeff IB_DEVICE_BAD_PKEY_CNTR = (1<<1), 92219820Sjeff IB_DEVICE_BAD_QKEY_CNTR = (1<<2), 93219820Sjeff IB_DEVICE_RAW_MULTI = (1<<3), 94219820Sjeff IB_DEVICE_AUTO_PATH_MIG = (1<<4), 95219820Sjeff IB_DEVICE_CHANGE_PHY_PORT = (1<<5), 96219820Sjeff IB_DEVICE_UD_AV_PORT_ENFORCE = (1<<6), 97219820Sjeff IB_DEVICE_CURR_QP_STATE_MOD = (1<<7), 98219820Sjeff IB_DEVICE_SHUTDOWN_PORT = (1<<8), 99219820Sjeff IB_DEVICE_INIT_TYPE = (1<<9), 100219820Sjeff IB_DEVICE_PORT_ACTIVE_EVENT = (1<<10), 101219820Sjeff IB_DEVICE_SYS_IMAGE_GUID = (1<<11), 102219820Sjeff IB_DEVICE_RC_RNR_NAK_GEN = (1<<12), 103219820Sjeff IB_DEVICE_SRQ_RESIZE = (1<<13), 104219820Sjeff IB_DEVICE_N_NOTIFY_CQ = (1<<14), 105219820Sjeff IB_DEVICE_LOCAL_DMA_LKEY = (1<<15), 106219820Sjeff IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */ 107219820Sjeff IB_DEVICE_MEM_WINDOW = (1<<17), 108219820Sjeff /* 109219820Sjeff * Devices should set IB_DEVICE_UD_IP_SUM if they support 110219820Sjeff * insertion of UDP and TCP checksum on outgoing UD IPoIB 111219820Sjeff * messages and can verify the validity of checksum for 112219820Sjeff * incoming messages. Setting this flag implies that the 113219820Sjeff * IPoIB driver may set NETIF_F_IP_CSUM for datagram mode. 114219820Sjeff */ 115219820Sjeff IB_DEVICE_UD_IP_CSUM = (1<<18), 116219820Sjeff IB_DEVICE_UD_TSO = (1<<19), 117219820Sjeff IB_DEVICE_XRC = (1<<20), 118219820Sjeff IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21), 119219820Sjeff IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22), 120255932Salfred IB_DEVICE_MR_ALLOCATE = (1<<23), 121255932Salfred IB_DEVICE_SHARED_MR = (1<<24), 122255932Salfred IB_DEVICE_QPG = (1<<25), 123255932Salfred IB_DEVICE_UD_RSS = (1<<26), 124255932Salfred IB_DEVICE_UD_TSS = (1<<27) 125219820Sjeff}; 126219820Sjeff 127219820Sjeffenum ib_atomic_cap { 128219820Sjeff IB_ATOMIC_NONE, 129219820Sjeff IB_ATOMIC_HCA, 130219820Sjeff IB_ATOMIC_GLOB 131219820Sjeff}; 132219820Sjeff 133219820Sjeffstruct ib_device_attr { 134219820Sjeff u64 fw_ver; 135219820Sjeff __be64 sys_image_guid; 136219820Sjeff u64 max_mr_size; 137219820Sjeff u64 page_size_cap; 138219820Sjeff u32 vendor_id; 139219820Sjeff u32 vendor_part_id; 140219820Sjeff u32 hw_ver; 141219820Sjeff int max_qp; 142219820Sjeff int max_qp_wr; 143219820Sjeff int device_cap_flags; 144219820Sjeff int max_sge; 145219820Sjeff int max_sge_rd; 146219820Sjeff int max_cq; 147219820Sjeff int max_cqe; 148219820Sjeff int max_mr; 149219820Sjeff int max_pd; 150219820Sjeff int max_qp_rd_atom; 151219820Sjeff int max_ee_rd_atom; 152219820Sjeff int max_res_rd_atom; 153219820Sjeff int max_qp_init_rd_atom; 154219820Sjeff int max_ee_init_rd_atom; 155219820Sjeff enum ib_atomic_cap atomic_cap; 156219820Sjeff enum ib_atomic_cap masked_atomic_cap; 157219820Sjeff int max_ee; 158219820Sjeff int max_rdd; 159219820Sjeff int max_mw; 160219820Sjeff int max_raw_ipv6_qp; 161219820Sjeff int max_raw_ethy_qp; 162219820Sjeff int max_mcast_grp; 163219820Sjeff int max_mcast_qp_attach; 164219820Sjeff int max_total_mcast_qp_attach; 165219820Sjeff int max_ah; 166219820Sjeff int max_fmr; 167219820Sjeff int max_map_per_fmr; 168219820Sjeff int max_srq; 169219820Sjeff int max_srq_wr; 170219820Sjeff int max_srq_sge; 171219820Sjeff unsigned int max_fast_reg_page_list_len; 172255932Salfred int max_rss_tbl_sz; 173219820Sjeff u16 max_pkeys; 174219820Sjeff u8 local_ca_ack_delay; 175219820Sjeff}; 176219820Sjeff 177219820Sjeffenum ib_mtu { 178219820Sjeff IB_MTU_256 = 1, 179219820Sjeff IB_MTU_512 = 2, 180219820Sjeff IB_MTU_1024 = 3, 181219820Sjeff IB_MTU_2048 = 4, 182219820Sjeff IB_MTU_4096 = 5 183219820Sjeff}; 184219820Sjeff 185219820Sjeffstatic inline int ib_mtu_enum_to_int(enum ib_mtu mtu) 186219820Sjeff{ 187219820Sjeff switch (mtu) { 188219820Sjeff case IB_MTU_256: return 256; 189219820Sjeff case IB_MTU_512: return 512; 190219820Sjeff case IB_MTU_1024: return 1024; 191219820Sjeff case IB_MTU_2048: return 2048; 192219820Sjeff case IB_MTU_4096: return 4096; 193219820Sjeff default: return -1; 194219820Sjeff } 195219820Sjeff} 196219820Sjeff 197219820Sjeffenum ib_port_state { 198219820Sjeff IB_PORT_NOP = 0, 199219820Sjeff IB_PORT_DOWN = 1, 200219820Sjeff IB_PORT_INIT = 2, 201219820Sjeff IB_PORT_ARMED = 3, 202219820Sjeff IB_PORT_ACTIVE = 4, 203219820Sjeff IB_PORT_ACTIVE_DEFER = 5 204219820Sjeff}; 205219820Sjeff 206219820Sjeffenum ib_port_cap_flags { 207219820Sjeff IB_PORT_SM = 1 << 1, 208219820Sjeff IB_PORT_NOTICE_SUP = 1 << 2, 209219820Sjeff IB_PORT_TRAP_SUP = 1 << 3, 210219820Sjeff IB_PORT_OPT_IPD_SUP = 1 << 4, 211219820Sjeff IB_PORT_AUTO_MIGR_SUP = 1 << 5, 212219820Sjeff IB_PORT_SL_MAP_SUP = 1 << 6, 213219820Sjeff IB_PORT_MKEY_NVRAM = 1 << 7, 214219820Sjeff IB_PORT_PKEY_NVRAM = 1 << 8, 215219820Sjeff IB_PORT_LED_INFO_SUP = 1 << 9, 216219820Sjeff IB_PORT_SM_DISABLED = 1 << 10, 217219820Sjeff IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, 218219820Sjeff IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, 219255932Salfred IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, 220219820Sjeff IB_PORT_CM_SUP = 1 << 16, 221219820Sjeff IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, 222219820Sjeff IB_PORT_REINIT_SUP = 1 << 18, 223219820Sjeff IB_PORT_DEVICE_MGMT_SUP = 1 << 19, 224219820Sjeff IB_PORT_VENDOR_CLASS_SUP = 1 << 20, 225219820Sjeff IB_PORT_DR_NOTICE_SUP = 1 << 21, 226219820Sjeff IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, 227219820Sjeff IB_PORT_BOOT_MGMT_SUP = 1 << 23, 228219820Sjeff IB_PORT_LINK_LATENCY_SUP = 1 << 24, 229219820Sjeff IB_PORT_CLIENT_REG_SUP = 1 << 25 230219820Sjeff}; 231219820Sjeff 232219820Sjeffenum ib_port_width { 233219820Sjeff IB_WIDTH_1X = 1, 234219820Sjeff IB_WIDTH_4X = 2, 235219820Sjeff IB_WIDTH_8X = 4, 236219820Sjeff IB_WIDTH_12X = 8 237219820Sjeff}; 238219820Sjeff 239219820Sjeffstatic inline int ib_width_enum_to_int(enum ib_port_width width) 240219820Sjeff{ 241219820Sjeff switch (width) { 242219820Sjeff case IB_WIDTH_1X: return 1; 243219820Sjeff case IB_WIDTH_4X: return 4; 244219820Sjeff case IB_WIDTH_8X: return 8; 245219820Sjeff case IB_WIDTH_12X: return 12; 246219820Sjeff default: return -1; 247219820Sjeff } 248219820Sjeff} 249219820Sjeff 250255932Salfredenum ib_port_speed { 251255932Salfred IB_SPEED_SDR = 1, 252255932Salfred IB_SPEED_DDR = 2, 253255932Salfred IB_SPEED_QDR = 4, 254255932Salfred IB_SPEED_FDR10 = 8, 255255932Salfred IB_SPEED_FDR = 16, 256255932Salfred IB_SPEED_EDR = 32 257255932Salfred}; 258255932Salfred 259219820Sjeffstruct ib_protocol_stats { 260219820Sjeff /* TBD... */ 261219820Sjeff}; 262219820Sjeff 263219820Sjeffstruct iw_protocol_stats { 264219820Sjeff u64 ipInReceives; 265219820Sjeff u64 ipInHdrErrors; 266219820Sjeff u64 ipInTooBigErrors; 267219820Sjeff u64 ipInNoRoutes; 268219820Sjeff u64 ipInAddrErrors; 269219820Sjeff u64 ipInUnknownProtos; 270219820Sjeff u64 ipInTruncatedPkts; 271219820Sjeff u64 ipInDiscards; 272219820Sjeff u64 ipInDelivers; 273219820Sjeff u64 ipOutForwDatagrams; 274219820Sjeff u64 ipOutRequests; 275219820Sjeff u64 ipOutDiscards; 276219820Sjeff u64 ipOutNoRoutes; 277219820Sjeff u64 ipReasmTimeout; 278219820Sjeff u64 ipReasmReqds; 279219820Sjeff u64 ipReasmOKs; 280219820Sjeff u64 ipReasmFails; 281219820Sjeff u64 ipFragOKs; 282219820Sjeff u64 ipFragFails; 283219820Sjeff u64 ipFragCreates; 284219820Sjeff u64 ipInMcastPkts; 285219820Sjeff u64 ipOutMcastPkts; 286219820Sjeff u64 ipInBcastPkts; 287219820Sjeff u64 ipOutBcastPkts; 288219820Sjeff 289219820Sjeff u64 tcpRtoAlgorithm; 290219820Sjeff u64 tcpRtoMin; 291219820Sjeff u64 tcpRtoMax; 292219820Sjeff u64 tcpMaxConn; 293219820Sjeff u64 tcpActiveOpens; 294219820Sjeff u64 tcpPassiveOpens; 295219820Sjeff u64 tcpAttemptFails; 296219820Sjeff u64 tcpEstabResets; 297219820Sjeff u64 tcpCurrEstab; 298219820Sjeff u64 tcpInSegs; 299219820Sjeff u64 tcpOutSegs; 300219820Sjeff u64 tcpRetransSegs; 301219820Sjeff u64 tcpInErrs; 302219820Sjeff u64 tcpOutRsts; 303219820Sjeff}; 304219820Sjeff 305219820Sjeffunion rdma_protocol_stats { 306219820Sjeff struct ib_protocol_stats ib; 307219820Sjeff struct iw_protocol_stats iw; 308219820Sjeff}; 309219820Sjeff 310219820Sjeffstruct ib_port_attr { 311219820Sjeff enum ib_port_state state; 312219820Sjeff enum ib_mtu max_mtu; 313219820Sjeff enum ib_mtu active_mtu; 314219820Sjeff int gid_tbl_len; 315219820Sjeff u32 port_cap_flags; 316219820Sjeff u32 max_msg_sz; 317219820Sjeff u32 bad_pkey_cntr; 318219820Sjeff u32 qkey_viol_cntr; 319219820Sjeff u16 pkey_tbl_len; 320219820Sjeff u16 lid; 321219820Sjeff u16 sm_lid; 322219820Sjeff u8 lmc; 323219820Sjeff u8 max_vl_num; 324219820Sjeff u8 sm_sl; 325219820Sjeff u8 subnet_timeout; 326219820Sjeff u8 init_type_reply; 327219820Sjeff u8 active_width; 328219820Sjeff u8 active_speed; 329219820Sjeff u8 phys_state; 330219820Sjeff enum rdma_link_layer link_layer; 331219820Sjeff}; 332219820Sjeff 333219820Sjeffenum ib_device_modify_flags { 334219820Sjeff IB_DEVICE_MODIFY_SYS_IMAGE_GUID = 1 << 0, 335219820Sjeff IB_DEVICE_MODIFY_NODE_DESC = 1 << 1 336219820Sjeff}; 337219820Sjeff 338219820Sjeffstruct ib_device_modify { 339219820Sjeff u64 sys_image_guid; 340219820Sjeff char node_desc[64]; 341219820Sjeff}; 342219820Sjeff 343219820Sjeffenum ib_port_modify_flags { 344219820Sjeff IB_PORT_SHUTDOWN = 1, 345219820Sjeff IB_PORT_INIT_TYPE = (1<<2), 346219820Sjeff IB_PORT_RESET_QKEY_CNTR = (1<<3) 347219820Sjeff}; 348219820Sjeff 349219820Sjeffstruct ib_port_modify { 350219820Sjeff u32 set_port_cap_mask; 351219820Sjeff u32 clr_port_cap_mask; 352219820Sjeff u8 init_type; 353219820Sjeff}; 354219820Sjeff 355219820Sjeffenum ib_event_type { 356219820Sjeff IB_EVENT_CQ_ERR, 357219820Sjeff IB_EVENT_QP_FATAL, 358219820Sjeff IB_EVENT_QP_REQ_ERR, 359219820Sjeff IB_EVENT_QP_ACCESS_ERR, 360219820Sjeff IB_EVENT_COMM_EST, 361219820Sjeff IB_EVENT_SQ_DRAINED, 362219820Sjeff IB_EVENT_PATH_MIG, 363219820Sjeff IB_EVENT_PATH_MIG_ERR, 364219820Sjeff IB_EVENT_DEVICE_FATAL, 365219820Sjeff IB_EVENT_PORT_ACTIVE, 366219820Sjeff IB_EVENT_PORT_ERR, 367219820Sjeff IB_EVENT_LID_CHANGE, 368219820Sjeff IB_EVENT_PKEY_CHANGE, 369219820Sjeff IB_EVENT_SM_CHANGE, 370219820Sjeff IB_EVENT_SRQ_ERR, 371219820Sjeff IB_EVENT_SRQ_LIMIT_REACHED, 372219820Sjeff IB_EVENT_QP_LAST_WQE_REACHED, 373219820Sjeff IB_EVENT_CLIENT_REREGISTER, 374219820Sjeff IB_EVENT_GID_CHANGE, 375219820Sjeff}; 376219820Sjeff 377219820Sjeffenum ib_event_flags { 378219820Sjeff IB_XRC_QP_EVENT_FLAG = 0x80000000, 379219820Sjeff}; 380219820Sjeff 381219820Sjeffstruct ib_event { 382219820Sjeff struct ib_device *device; 383219820Sjeff union { 384219820Sjeff struct ib_cq *cq; 385219820Sjeff struct ib_qp *qp; 386219820Sjeff struct ib_srq *srq; 387219820Sjeff u8 port_num; 388219820Sjeff u32 xrc_qp_num; 389219820Sjeff } element; 390219820Sjeff enum ib_event_type event; 391219820Sjeff}; 392219820Sjeff 393219820Sjeffstruct ib_event_handler { 394219820Sjeff struct ib_device *device; 395219820Sjeff void (*handler)(struct ib_event_handler *, struct ib_event *); 396219820Sjeff struct list_head list; 397219820Sjeff}; 398219820Sjeff 399219820Sjeff#define INIT_IB_EVENT_HANDLER(_ptr, _device, _handler) \ 400219820Sjeff do { \ 401219820Sjeff (_ptr)->device = _device; \ 402219820Sjeff (_ptr)->handler = _handler; \ 403219820Sjeff INIT_LIST_HEAD(&(_ptr)->list); \ 404219820Sjeff } while (0) 405219820Sjeff 406219820Sjeffstruct ib_global_route { 407219820Sjeff union ib_gid dgid; 408219820Sjeff u32 flow_label; 409219820Sjeff u8 sgid_index; 410219820Sjeff u8 hop_limit; 411219820Sjeff u8 traffic_class; 412219820Sjeff}; 413219820Sjeff 414219820Sjeffstruct ib_grh { 415219820Sjeff __be32 version_tclass_flow; 416219820Sjeff __be16 paylen; 417219820Sjeff u8 next_hdr; 418219820Sjeff u8 hop_limit; 419219820Sjeff union ib_gid sgid; 420219820Sjeff union ib_gid dgid; 421219820Sjeff}; 422219820Sjeff 423219820Sjeffenum { 424219820Sjeff IB_MULTICAST_QPN = 0xffffff 425219820Sjeff}; 426219820Sjeff 427219820Sjeff#define IB_LID_PERMISSIVE cpu_to_be16(0xFFFF) 428219820Sjeff 429219820Sjeffenum ib_ah_flags { 430219820Sjeff IB_AH_GRH = 1 431219820Sjeff}; 432219820Sjeff 433219820Sjeffenum ib_rate { 434219820Sjeff IB_RATE_PORT_CURRENT = 0, 435219820Sjeff IB_RATE_2_5_GBPS = 2, 436219820Sjeff IB_RATE_5_GBPS = 5, 437219820Sjeff IB_RATE_10_GBPS = 3, 438219820Sjeff IB_RATE_20_GBPS = 6, 439219820Sjeff IB_RATE_30_GBPS = 4, 440219820Sjeff IB_RATE_40_GBPS = 7, 441219820Sjeff IB_RATE_60_GBPS = 8, 442219820Sjeff IB_RATE_80_GBPS = 9, 443255932Salfred IB_RATE_120_GBPS = 10, 444255932Salfred IB_RATE_14_GBPS = 11, 445255932Salfred IB_RATE_56_GBPS = 12, 446255932Salfred IB_RATE_112_GBPS = 13, 447255932Salfred IB_RATE_168_GBPS = 14, 448255932Salfred IB_RATE_25_GBPS = 15, 449255932Salfred IB_RATE_100_GBPS = 16, 450255932Salfred IB_RATE_200_GBPS = 17, 451255932Salfred IB_RATE_300_GBPS = 18 452219820Sjeff}; 453219820Sjeff 454219820Sjeff/** 455219820Sjeff * ib_rate_to_mult - Convert the IB rate enum to a multiple of the 456219820Sjeff * base rate of 2.5 Gbit/sec. For example, IB_RATE_5_GBPS will be 457219820Sjeff * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. 458219820Sjeff * @rate: rate to convert. 459219820Sjeff */ 460219820Sjeffint ib_rate_to_mult(enum ib_rate rate) __attribute_const__; 461219820Sjeff 462219820Sjeff/** 463255932Salfred * ib_rate_to_mbps - Convert the IB rate enum to Mbps. 464255932Salfred * For example, IB_RATE_2_5_GBPS will be converted to 2500. 465255932Salfred * @rate: rate to convert. 466255932Salfred */ 467255932Salfredint ib_rate_to_mbps(enum ib_rate rate) __attribute_const__; 468255932Salfred 469255932Salfred/** 470219820Sjeff * mult_to_ib_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate 471219820Sjeff * enum. 472219820Sjeff * @mult: multiple to convert. 473219820Sjeff */ 474219820Sjeffenum ib_rate mult_to_ib_rate(int mult) __attribute_const__; 475219820Sjeff 476219820Sjeffstruct ib_ah_attr { 477219820Sjeff struct ib_global_route grh; 478219820Sjeff u16 dlid; 479219820Sjeff u8 sl; 480219820Sjeff u8 src_path_bits; 481219820Sjeff u8 static_rate; 482219820Sjeff u8 ah_flags; 483219820Sjeff u8 port_num; 484219820Sjeff}; 485219820Sjeff 486219820Sjeffenum ib_wc_status { 487219820Sjeff IB_WC_SUCCESS, 488219820Sjeff IB_WC_LOC_LEN_ERR, 489219820Sjeff IB_WC_LOC_QP_OP_ERR, 490219820Sjeff IB_WC_LOC_EEC_OP_ERR, 491219820Sjeff IB_WC_LOC_PROT_ERR, 492219820Sjeff IB_WC_WR_FLUSH_ERR, 493219820Sjeff IB_WC_MW_BIND_ERR, 494219820Sjeff IB_WC_BAD_RESP_ERR, 495219820Sjeff IB_WC_LOC_ACCESS_ERR, 496219820Sjeff IB_WC_REM_INV_REQ_ERR, 497219820Sjeff IB_WC_REM_ACCESS_ERR, 498219820Sjeff IB_WC_REM_OP_ERR, 499219820Sjeff IB_WC_RETRY_EXC_ERR, 500219820Sjeff IB_WC_RNR_RETRY_EXC_ERR, 501219820Sjeff IB_WC_LOC_RDD_VIOL_ERR, 502219820Sjeff IB_WC_REM_INV_RD_REQ_ERR, 503219820Sjeff IB_WC_REM_ABORT_ERR, 504219820Sjeff IB_WC_INV_EECN_ERR, 505219820Sjeff IB_WC_INV_EEC_STATE_ERR, 506219820Sjeff IB_WC_FATAL_ERR, 507219820Sjeff IB_WC_RESP_TIMEOUT_ERR, 508219820Sjeff IB_WC_GENERAL_ERR 509219820Sjeff}; 510219820Sjeff 511219820Sjeffenum ib_wc_opcode { 512219820Sjeff IB_WC_SEND, 513219820Sjeff IB_WC_RDMA_WRITE, 514219820Sjeff IB_WC_RDMA_READ, 515219820Sjeff IB_WC_COMP_SWAP, 516219820Sjeff IB_WC_FETCH_ADD, 517219820Sjeff IB_WC_BIND_MW, 518219820Sjeff IB_WC_LSO, 519219820Sjeff IB_WC_LOCAL_INV, 520219820Sjeff IB_WC_FAST_REG_MR, 521219820Sjeff IB_WC_MASKED_COMP_SWAP, 522219820Sjeff IB_WC_MASKED_FETCH_ADD, 523219820Sjeff/* 524219820Sjeff * Set value of IB_WC_RECV so consumers can test if a completion is a 525219820Sjeff * receive by testing (opcode & IB_WC_RECV). 526219820Sjeff */ 527219820Sjeff IB_WC_RECV = 1 << 7, 528219820Sjeff IB_WC_RECV_RDMA_WITH_IMM 529219820Sjeff}; 530219820Sjeff 531219820Sjeffenum ib_wc_flags { 532219820Sjeff IB_WC_GRH = 1, 533219820Sjeff IB_WC_WITH_IMM = (1<<1), 534219820Sjeff IB_WC_WITH_INVALIDATE = (1<<2), 535255932Salfred IB_WC_IP_CSUM_OK = (1<<3), 536219820Sjeff}; 537219820Sjeff 538219820Sjeffstruct ib_wc { 539219820Sjeff u64 wr_id; 540219820Sjeff enum ib_wc_status status; 541219820Sjeff enum ib_wc_opcode opcode; 542219820Sjeff u32 vendor_err; 543219820Sjeff u32 byte_len; 544219820Sjeff struct ib_qp *qp; 545219820Sjeff union { 546219820Sjeff __be32 imm_data; 547219820Sjeff u32 invalidate_rkey; 548219820Sjeff } ex; 549219820Sjeff u32 src_qp; 550219820Sjeff int wc_flags; 551219820Sjeff u16 pkey_index; 552219820Sjeff u16 slid; 553219820Sjeff u8 sl; 554219820Sjeff u8 dlid_path_bits; 555219820Sjeff u8 port_num; /* valid only for DR SMPs on switches */ 556219820Sjeff int csum_ok; 557219820Sjeff}; 558219820Sjeff 559219820Sjeffenum ib_cq_notify_flags { 560219820Sjeff IB_CQ_SOLICITED = 1 << 0, 561219820Sjeff IB_CQ_NEXT_COMP = 1 << 1, 562219820Sjeff IB_CQ_SOLICITED_MASK = IB_CQ_SOLICITED | IB_CQ_NEXT_COMP, 563219820Sjeff IB_CQ_REPORT_MISSED_EVENTS = 1 << 2, 564219820Sjeff}; 565219820Sjeff 566255932Salfredenum ib_srq_type { 567255932Salfred IB_SRQT_BASIC, 568255932Salfred IB_SRQT_XRC 569255932Salfred}; 570255932Salfred 571219820Sjeffenum ib_srq_attr_mask { 572219820Sjeff IB_SRQ_MAX_WR = 1 << 0, 573219820Sjeff IB_SRQ_LIMIT = 1 << 1, 574219820Sjeff}; 575219820Sjeff 576219820Sjeffstruct ib_srq_attr { 577219820Sjeff u32 max_wr; 578219820Sjeff u32 max_sge; 579219820Sjeff u32 srq_limit; 580219820Sjeff}; 581219820Sjeff 582219820Sjeffstruct ib_srq_init_attr { 583219820Sjeff void (*event_handler)(struct ib_event *, void *); 584219820Sjeff void *srq_context; 585219820Sjeff struct ib_srq_attr attr; 586255932Salfred enum ib_srq_type srq_type; 587255932Salfred 588255932Salfred union { 589255932Salfred struct { 590255932Salfred struct ib_xrcd *xrcd; 591255932Salfred struct ib_cq *cq; 592255932Salfred } xrc; 593255932Salfred } ext; 594219820Sjeff}; 595219820Sjeff 596219820Sjeffstruct ib_qp_cap { 597219820Sjeff u32 max_send_wr; 598219820Sjeff u32 max_recv_wr; 599219820Sjeff u32 max_send_sge; 600219820Sjeff u32 max_recv_sge; 601219820Sjeff u32 max_inline_data; 602255932Salfred u32 qpg_tss_mask_sz; 603219820Sjeff}; 604219820Sjeff 605219820Sjeffenum ib_sig_type { 606219820Sjeff IB_SIGNAL_ALL_WR, 607219820Sjeff IB_SIGNAL_REQ_WR 608219820Sjeff}; 609219820Sjeff 610219820Sjeffenum ib_qp_type { 611219820Sjeff /* 612219820Sjeff * IB_QPT_SMI and IB_QPT_GSI have to be the first two entries 613219820Sjeff * here (and in that order) since the MAD layer uses them as 614219820Sjeff * indices into a 2-entry table. 615219820Sjeff */ 616219820Sjeff IB_QPT_SMI, 617219820Sjeff IB_QPT_GSI, 618219820Sjeff 619219820Sjeff IB_QPT_RC, 620219820Sjeff IB_QPT_UC, 621219820Sjeff IB_QPT_UD, 622219820Sjeff IB_QPT_XRC, 623219820Sjeff IB_QPT_RAW_IPV6, 624255932Salfred IB_QPT_RAW_ETHERTYPE, 625255932Salfred IB_QPT_RAW_PACKET = 8, 626255932Salfred IB_QPT_XRC_INI = 9, 627255932Salfred IB_QPT_XRC_TGT, 628255932Salfred IB_QPT_MAX, 629219820Sjeff}; 630219820Sjeff 631219820Sjeffenum ib_qp_create_flags { 632219820Sjeff IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, 633219820Sjeff IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1, 634255932Salfred IB_QP_CREATE_NETIF_QP = 1 << 2, 635255932Salfred /* reserve bits 26-31 for low level drivers' internal use */ 636255932Salfred IB_QP_CREATE_RESERVED_START = 1 << 26, 637255932Salfred IB_QP_CREATE_RESERVED_END = 1 << 31, 638219820Sjeff}; 639219820Sjeff 640255932Salfredenum ib_qpg_type { 641255932Salfred IB_QPG_NONE = 0, 642255932Salfred IB_QPG_PARENT = (1<<0), 643255932Salfred IB_QPG_CHILD_RX = (1<<1), 644255932Salfred IB_QPG_CHILD_TX = (1<<2) 645255932Salfred}; 646255932Salfred 647255932Salfredstruct ib_qpg_init_attrib { 648255932Salfred u32 tss_child_count; 649255932Salfred u32 rss_child_count; 650255932Salfred}; 651255932Salfred 652219820Sjeffstruct ib_qp_init_attr { 653219820Sjeff void (*event_handler)(struct ib_event *, void *); 654219820Sjeff void *qp_context; 655219820Sjeff struct ib_cq *send_cq; 656219820Sjeff struct ib_cq *recv_cq; 657219820Sjeff struct ib_srq *srq; 658255932Salfred struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 659219820Sjeff struct ib_qp_cap cap; 660255932Salfred union { 661255932Salfred struct ib_qp *qpg_parent; /* see qpg_type */ 662255932Salfred struct ib_qpg_init_attrib parent_attrib; 663256116Sdim } pp; 664219820Sjeff enum ib_sig_type sq_sig_type; 665219820Sjeff enum ib_qp_type qp_type; 666219820Sjeff enum ib_qp_create_flags create_flags; 667255932Salfred enum ib_qpg_type qpg_type; 668219820Sjeff u8 port_num; /* special QP types only */ 669219820Sjeff}; 670219820Sjeff 671255932Salfredstruct ib_qp_open_attr { 672255932Salfred void (*event_handler)(struct ib_event *, void *); 673255932Salfred void *qp_context; 674255932Salfred u32 qp_num; 675255932Salfred enum ib_qp_type qp_type; 676255932Salfred}; 677255932Salfred 678219820Sjeffenum ib_rnr_timeout { 679219820Sjeff IB_RNR_TIMER_655_36 = 0, 680219820Sjeff IB_RNR_TIMER_000_01 = 1, 681219820Sjeff IB_RNR_TIMER_000_02 = 2, 682219820Sjeff IB_RNR_TIMER_000_03 = 3, 683219820Sjeff IB_RNR_TIMER_000_04 = 4, 684219820Sjeff IB_RNR_TIMER_000_06 = 5, 685219820Sjeff IB_RNR_TIMER_000_08 = 6, 686219820Sjeff IB_RNR_TIMER_000_12 = 7, 687219820Sjeff IB_RNR_TIMER_000_16 = 8, 688219820Sjeff IB_RNR_TIMER_000_24 = 9, 689219820Sjeff IB_RNR_TIMER_000_32 = 10, 690219820Sjeff IB_RNR_TIMER_000_48 = 11, 691219820Sjeff IB_RNR_TIMER_000_64 = 12, 692219820Sjeff IB_RNR_TIMER_000_96 = 13, 693219820Sjeff IB_RNR_TIMER_001_28 = 14, 694219820Sjeff IB_RNR_TIMER_001_92 = 15, 695219820Sjeff IB_RNR_TIMER_002_56 = 16, 696219820Sjeff IB_RNR_TIMER_003_84 = 17, 697219820Sjeff IB_RNR_TIMER_005_12 = 18, 698219820Sjeff IB_RNR_TIMER_007_68 = 19, 699219820Sjeff IB_RNR_TIMER_010_24 = 20, 700219820Sjeff IB_RNR_TIMER_015_36 = 21, 701219820Sjeff IB_RNR_TIMER_020_48 = 22, 702219820Sjeff IB_RNR_TIMER_030_72 = 23, 703219820Sjeff IB_RNR_TIMER_040_96 = 24, 704219820Sjeff IB_RNR_TIMER_061_44 = 25, 705219820Sjeff IB_RNR_TIMER_081_92 = 26, 706219820Sjeff IB_RNR_TIMER_122_88 = 27, 707219820Sjeff IB_RNR_TIMER_163_84 = 28, 708219820Sjeff IB_RNR_TIMER_245_76 = 29, 709219820Sjeff IB_RNR_TIMER_327_68 = 30, 710219820Sjeff IB_RNR_TIMER_491_52 = 31 711219820Sjeff}; 712219820Sjeff 713219820Sjeffenum ib_qp_attr_mask { 714219820Sjeff IB_QP_STATE = 1, 715219820Sjeff IB_QP_CUR_STATE = (1<<1), 716219820Sjeff IB_QP_EN_SQD_ASYNC_NOTIFY = (1<<2), 717219820Sjeff IB_QP_ACCESS_FLAGS = (1<<3), 718219820Sjeff IB_QP_PKEY_INDEX = (1<<4), 719219820Sjeff IB_QP_PORT = (1<<5), 720219820Sjeff IB_QP_QKEY = (1<<6), 721219820Sjeff IB_QP_AV = (1<<7), 722219820Sjeff IB_QP_PATH_MTU = (1<<8), 723219820Sjeff IB_QP_TIMEOUT = (1<<9), 724219820Sjeff IB_QP_RETRY_CNT = (1<<10), 725219820Sjeff IB_QP_RNR_RETRY = (1<<11), 726219820Sjeff IB_QP_RQ_PSN = (1<<12), 727219820Sjeff IB_QP_MAX_QP_RD_ATOMIC = (1<<13), 728219820Sjeff IB_QP_ALT_PATH = (1<<14), 729219820Sjeff IB_QP_MIN_RNR_TIMER = (1<<15), 730219820Sjeff IB_QP_SQ_PSN = (1<<16), 731219820Sjeff IB_QP_MAX_DEST_RD_ATOMIC = (1<<17), 732219820Sjeff IB_QP_PATH_MIG_STATE = (1<<18), 733219820Sjeff IB_QP_CAP = (1<<19), 734255932Salfred IB_QP_DEST_QPN = (1<<20), 735255932Salfred IB_QP_GROUP_RSS = (1<<21) 736219820Sjeff}; 737219820Sjeff 738219820Sjeffenum ib_qp_state { 739219820Sjeff IB_QPS_RESET, 740219820Sjeff IB_QPS_INIT, 741219820Sjeff IB_QPS_RTR, 742219820Sjeff IB_QPS_RTS, 743219820Sjeff IB_QPS_SQD, 744219820Sjeff IB_QPS_SQE, 745219820Sjeff IB_QPS_ERR 746219820Sjeff}; 747219820Sjeff 748219820Sjeffenum ib_mig_state { 749219820Sjeff IB_MIG_MIGRATED, 750219820Sjeff IB_MIG_REARM, 751219820Sjeff IB_MIG_ARMED 752219820Sjeff}; 753219820Sjeff 754219820Sjeffstruct ib_qp_attr { 755219820Sjeff enum ib_qp_state qp_state; 756219820Sjeff enum ib_qp_state cur_qp_state; 757219820Sjeff enum ib_mtu path_mtu; 758219820Sjeff enum ib_mig_state path_mig_state; 759219820Sjeff u32 qkey; 760219820Sjeff u32 rq_psn; 761219820Sjeff u32 sq_psn; 762219820Sjeff u32 dest_qp_num; 763219820Sjeff int qp_access_flags; 764219820Sjeff struct ib_qp_cap cap; 765219820Sjeff struct ib_ah_attr ah_attr; 766219820Sjeff struct ib_ah_attr alt_ah_attr; 767219820Sjeff u16 pkey_index; 768219820Sjeff u16 alt_pkey_index; 769219820Sjeff u8 en_sqd_async_notify; 770219820Sjeff u8 sq_draining; 771219820Sjeff u8 max_rd_atomic; 772219820Sjeff u8 max_dest_rd_atomic; 773219820Sjeff u8 min_rnr_timer; 774219820Sjeff u8 port_num; 775219820Sjeff u8 timeout; 776219820Sjeff u8 retry_cnt; 777219820Sjeff u8 rnr_retry; 778219820Sjeff u8 alt_port_num; 779219820Sjeff u8 alt_timeout; 780219820Sjeff}; 781219820Sjeff 782219820Sjeffenum ib_wr_opcode { 783219820Sjeff IB_WR_RDMA_WRITE, 784219820Sjeff IB_WR_RDMA_WRITE_WITH_IMM, 785219820Sjeff IB_WR_SEND, 786219820Sjeff IB_WR_SEND_WITH_IMM, 787219820Sjeff IB_WR_RDMA_READ, 788219820Sjeff IB_WR_ATOMIC_CMP_AND_SWP, 789219820Sjeff IB_WR_ATOMIC_FETCH_AND_ADD, 790219820Sjeff IB_WR_LSO, 791219820Sjeff IB_WR_BIG_LSO, 792219820Sjeff IB_WR_SEND_WITH_INV, 793219820Sjeff IB_WR_RDMA_READ_WITH_INV, 794219820Sjeff IB_WR_LOCAL_INV, 795219820Sjeff IB_WR_FAST_REG_MR, 796219820Sjeff IB_WR_MASKED_ATOMIC_CMP_AND_SWP, 797219820Sjeff IB_WR_MASKED_ATOMIC_FETCH_AND_ADD, 798219820Sjeff}; 799219820Sjeff 800219820Sjeffenum ib_send_flags { 801219820Sjeff IB_SEND_FENCE = 1, 802219820Sjeff IB_SEND_SIGNALED = (1<<1), 803219820Sjeff IB_SEND_SOLICITED = (1<<2), 804219820Sjeff IB_SEND_INLINE = (1<<3), 805219820Sjeff IB_SEND_IP_CSUM = (1<<4) 806219820Sjeff}; 807219820Sjeff 808255932Salfredenum ib_flow_types { 809255932Salfred IB_FLOW_ETH = 0, 810255932Salfred IB_FLOW_IB_UC = 1, 811255932Salfred IB_FLOW_IB_MC_IPV4 = 2, 812255932Salfred IB_FLOW_IB_MC_IPV6 = 3 813255932Salfred}; 814255932Salfred 815255932Salfredenum { 816255932Salfred IB_FLOW_L4_NONE = 0, 817255932Salfred IB_FLOW_L4_OTHER = 3, 818255932Salfred IB_FLOW_L4_UDP = 5, 819255932Salfred IB_FLOW_L4_TCP = 6 820255932Salfred}; 821255932Salfred 822219820Sjeffstruct ib_sge { 823219820Sjeff u64 addr; 824219820Sjeff u32 length; 825219820Sjeff u32 lkey; 826219820Sjeff}; 827219820Sjeff 828219820Sjeffstruct ib_fast_reg_page_list { 829219820Sjeff struct ib_device *device; 830219820Sjeff u64 *page_list; 831219820Sjeff unsigned int max_page_list_len; 832219820Sjeff}; 833219820Sjeff 834219820Sjeffstruct ib_send_wr { 835219820Sjeff struct ib_send_wr *next; 836219820Sjeff u64 wr_id; 837219820Sjeff struct ib_sge *sg_list; 838219820Sjeff int num_sge; 839219820Sjeff enum ib_wr_opcode opcode; 840219820Sjeff int send_flags; 841219820Sjeff union { 842219820Sjeff __be32 imm_data; 843219820Sjeff u32 invalidate_rkey; 844219820Sjeff } ex; 845219820Sjeff union { 846219820Sjeff struct { 847219820Sjeff u64 remote_addr; 848219820Sjeff u32 rkey; 849219820Sjeff } rdma; 850219820Sjeff struct { 851219820Sjeff u64 remote_addr; 852219820Sjeff u64 compare_add; 853219820Sjeff u64 swap; 854219820Sjeff u64 compare_add_mask; 855219820Sjeff u64 swap_mask; 856219820Sjeff u32 rkey; 857219820Sjeff } atomic; 858219820Sjeff struct { 859219820Sjeff struct ib_ah *ah; 860219820Sjeff void *header; 861219820Sjeff int hlen; 862219820Sjeff int mss; 863219820Sjeff u32 remote_qpn; 864219820Sjeff u32 remote_qkey; 865219820Sjeff u16 pkey_index; /* valid for GSI only */ 866219820Sjeff u8 port_num; /* valid for DR SMPs on switch only */ 867219820Sjeff } ud; 868219820Sjeff struct { 869219820Sjeff u64 iova_start; 870219820Sjeff struct ib_fast_reg_page_list *page_list; 871219820Sjeff unsigned int page_shift; 872219820Sjeff unsigned int page_list_len; 873219820Sjeff u32 length; 874219820Sjeff int access_flags; 875219820Sjeff u32 rkey; 876219820Sjeff } fast_reg; 877219820Sjeff struct { 878219820Sjeff struct ib_unpacked_lrh *lrh; 879219820Sjeff u32 eth_type; 880219820Sjeff u8 static_rate; 881219820Sjeff } raw_ety; 882219820Sjeff } wr; 883255932Salfred u32 xrc_remote_srq_num; /* XRC TGT QPs only */ 884219820Sjeff}; 885219820Sjeff 886219820Sjeffstruct ib_recv_wr { 887219820Sjeff struct ib_recv_wr *next; 888219820Sjeff u64 wr_id; 889219820Sjeff struct ib_sge *sg_list; 890219820Sjeff int num_sge; 891219820Sjeff}; 892219820Sjeff 893219820Sjeffenum ib_access_flags { 894219820Sjeff IB_ACCESS_LOCAL_WRITE = 1, 895219820Sjeff IB_ACCESS_REMOTE_WRITE = (1<<1), 896219820Sjeff IB_ACCESS_REMOTE_READ = (1<<2), 897219820Sjeff IB_ACCESS_REMOTE_ATOMIC = (1<<3), 898255932Salfred IB_ACCESS_MW_BIND = (1<<4), 899255932Salfred IB_ACCESS_ALLOCATE_MR = (1<<5), 900255932Salfred IB_ACCESS_SHARED_MR_USER_READ = (1<<6), 901255932Salfred IB_ACCESS_SHARED_MR_USER_WRITE = (1<<7), 902255932Salfred IB_ACCESS_SHARED_MR_GROUP_READ = (1<<8), 903255932Salfred IB_ACCESS_SHARED_MR_GROUP_WRITE = (1<<9), 904255932Salfred IB_ACCESS_SHARED_MR_OTHER_READ = (1<<10), 905255932Salfred IB_ACCESS_SHARED_MR_OTHER_WRITE = (1<<11) 906255932Salfred 907219820Sjeff}; 908219820Sjeff 909219820Sjeffstruct ib_phys_buf { 910219820Sjeff u64 addr; 911219820Sjeff u64 size; 912219820Sjeff}; 913219820Sjeff 914219820Sjeffstruct ib_mr_attr { 915219820Sjeff struct ib_pd *pd; 916219820Sjeff u64 device_virt_addr; 917219820Sjeff u64 size; 918219820Sjeff int mr_access_flags; 919219820Sjeff u32 lkey; 920219820Sjeff u32 rkey; 921219820Sjeff}; 922219820Sjeff 923219820Sjeffenum ib_mr_rereg_flags { 924219820Sjeff IB_MR_REREG_TRANS = 1, 925219820Sjeff IB_MR_REREG_PD = (1<<1), 926219820Sjeff IB_MR_REREG_ACCESS = (1<<2) 927219820Sjeff}; 928219820Sjeff 929219820Sjeffstruct ib_mw_bind { 930219820Sjeff struct ib_mr *mr; 931219820Sjeff u64 wr_id; 932219820Sjeff u64 addr; 933219820Sjeff u32 length; 934219820Sjeff int send_flags; 935219820Sjeff int mw_access_flags; 936219820Sjeff}; 937219820Sjeff 938219820Sjeffstruct ib_fmr_attr { 939219820Sjeff int max_pages; 940219820Sjeff int max_maps; 941219820Sjeff u8 page_shift; 942219820Sjeff}; 943219820Sjeff 944219820Sjeffstruct ib_ucontext { 945219820Sjeff struct ib_device *device; 946219820Sjeff struct list_head pd_list; 947219820Sjeff struct list_head mr_list; 948219820Sjeff struct list_head mw_list; 949219820Sjeff struct list_head cq_list; 950219820Sjeff struct list_head qp_list; 951219820Sjeff struct list_head srq_list; 952219820Sjeff struct list_head ah_list; 953255932Salfred struct list_head xrcd_list; 954219820Sjeff int closing; 955219820Sjeff}; 956219820Sjeff 957219820Sjeffstruct ib_uobject { 958219820Sjeff u64 user_handle; /* handle given to us by userspace */ 959219820Sjeff struct ib_ucontext *context; /* associated user context */ 960219820Sjeff void *object; /* containing object */ 961219820Sjeff struct list_head list; /* link to context's list */ 962219820Sjeff int id; /* index into kernel idr */ 963219820Sjeff struct kref ref; 964219820Sjeff struct rw_semaphore mutex; /* protects .live */ 965219820Sjeff int live; 966219820Sjeff}; 967219820Sjeff 968219820Sjeffstruct ib_udata { 969219820Sjeff void __user *inbuf; 970219820Sjeff void __user *outbuf; 971219820Sjeff size_t inlen; 972219820Sjeff size_t outlen; 973219820Sjeff}; 974219820Sjeff 975219820Sjeffstruct ib_uxrc_rcv_object { 976219820Sjeff struct list_head list; /* link to context's list */ 977219820Sjeff u32 qp_num; 978219820Sjeff u32 domain_handle; 979219820Sjeff}; 980219820Sjeff 981219820Sjeffstruct ib_pd { 982219820Sjeff struct ib_device *device; 983219820Sjeff struct ib_uobject *uobject; 984219820Sjeff atomic_t usecnt; /* count all resources */ 985219820Sjeff}; 986219820Sjeff 987219820Sjeffstruct ib_xrcd { 988219820Sjeff struct ib_device *device; 989219820Sjeff struct ib_uobject *uobject; 990255932Salfred atomic_t usecnt; /* count all exposed resources */ 991219820Sjeff struct inode *inode; 992219820Sjeff struct rb_node node; 993255932Salfred 994255932Salfred struct mutex tgt_qp_mutex; 995255932Salfred struct list_head tgt_qp_list; 996219820Sjeff}; 997219820Sjeff 998219820Sjeffstruct ib_ah { 999219820Sjeff struct ib_device *device; 1000219820Sjeff struct ib_pd *pd; 1001219820Sjeff struct ib_uobject *uobject; 1002219820Sjeff}; 1003219820Sjeff 1004219820Sjefftypedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context); 1005219820Sjeff 1006219820Sjeffstruct ib_cq { 1007219820Sjeff struct ib_device *device; 1008219820Sjeff struct ib_uobject *uobject; 1009219820Sjeff ib_comp_handler comp_handler; 1010219820Sjeff void (*event_handler)(struct ib_event *, void *); 1011219820Sjeff void *cq_context; 1012219820Sjeff int cqe; 1013219820Sjeff atomic_t usecnt; /* count number of work queues */ 1014219820Sjeff}; 1015219820Sjeff 1016219820Sjeffstruct ib_srq { 1017219820Sjeff struct ib_device *device; 1018219820Sjeff struct ib_pd *pd; 1019219820Sjeff struct ib_uobject *uobject; 1020219820Sjeff void (*event_handler)(struct ib_event *, void *); 1021219820Sjeff void *srq_context; 1022255932Salfred enum ib_srq_type srq_type; 1023219820Sjeff atomic_t usecnt; 1024255932Salfred 1025255932Salfred union { 1026255932Salfred struct { 1027255932Salfred struct ib_xrcd *xrcd; 1028255932Salfred struct ib_cq *cq; 1029255932Salfred u32 srq_num; 1030255932Salfred } xrc; 1031255932Salfred } ext; 1032219820Sjeff}; 1033219820Sjeff 1034219820Sjeffstruct ib_qp { 1035219820Sjeff struct ib_device *device; 1036219820Sjeff struct ib_pd *pd; 1037219820Sjeff struct ib_cq *send_cq; 1038219820Sjeff struct ib_cq *recv_cq; 1039219820Sjeff struct ib_srq *srq; 1040255932Salfred struct ib_xrcd *xrcd; /* XRC TGT QPs only */ 1041255932Salfred struct list_head xrcd_list; 1042255932Salfred atomic_t usecnt; /* count times opened, mcast attaches */ 1043255932Salfred struct list_head open_list; 1044255932Salfred struct ib_qp *real_qp; 1045219820Sjeff struct ib_uobject *uobject; 1046219820Sjeff void (*event_handler)(struct ib_event *, void *); 1047219820Sjeff void *qp_context; 1048219820Sjeff u32 qp_num; 1049219820Sjeff enum ib_qp_type qp_type; 1050255932Salfred enum ib_qpg_type qpg_type; 1051219820Sjeff}; 1052219820Sjeff 1053219820Sjeffstruct ib_mr { 1054219820Sjeff struct ib_device *device; 1055219820Sjeff struct ib_pd *pd; 1056219820Sjeff struct ib_uobject *uobject; 1057219820Sjeff u32 lkey; 1058219820Sjeff u32 rkey; 1059219820Sjeff atomic_t usecnt; /* count number of MWs */ 1060219820Sjeff}; 1061219820Sjeff 1062219820Sjeffstruct ib_mw { 1063219820Sjeff struct ib_device *device; 1064219820Sjeff struct ib_pd *pd; 1065219820Sjeff struct ib_uobject *uobject; 1066219820Sjeff u32 rkey; 1067219820Sjeff}; 1068219820Sjeff 1069219820Sjeffstruct ib_fmr { 1070219820Sjeff struct ib_device *device; 1071219820Sjeff struct ib_pd *pd; 1072219820Sjeff struct list_head list; 1073219820Sjeff u32 lkey; 1074219820Sjeff u32 rkey; 1075219820Sjeff}; 1076219820Sjeff 1077255932Salfredstruct ib_flow_spec { 1078255932Salfred enum ib_flow_types type; 1079255932Salfred union { 1080255932Salfred struct { 1081255932Salfred __be16 ethertype; 1082255932Salfred __be16 vlan; 1083255932Salfred u8 vlan_present; 1084255932Salfred u8 mac[6]; 1085255932Salfred u8 port; 1086255932Salfred } eth; 1087255932Salfred struct { 1088255932Salfred __be32 qpn; 1089255932Salfred } ib_uc; 1090255932Salfred struct { 1091255932Salfred u8 mgid[16]; 1092255932Salfred } ib_mc; 1093255932Salfred } l2_id; 1094255932Salfred __be32 src_ip; 1095255932Salfred __be32 dst_ip; 1096255932Salfred __be16 src_port; 1097255932Salfred __be16 dst_port; 1098255932Salfred u8 l4_protocol; 1099255932Salfred u8 block_mc_loopback; 1100255932Salfred u8 rule_type; 1101255932Salfred}; 1102255932Salfred 1103219820Sjeffstruct ib_mad; 1104219820Sjeffstruct ib_grh; 1105219820Sjeff 1106219820Sjeffenum ib_process_mad_flags { 1107219820Sjeff IB_MAD_IGNORE_MKEY = 1, 1108219820Sjeff IB_MAD_IGNORE_BKEY = 2, 1109219820Sjeff IB_MAD_IGNORE_ALL = IB_MAD_IGNORE_MKEY | IB_MAD_IGNORE_BKEY 1110219820Sjeff}; 1111219820Sjeff 1112219820Sjeffenum ib_mad_result { 1113219820Sjeff IB_MAD_RESULT_FAILURE = 0, /* (!SUCCESS is the important flag) */ 1114219820Sjeff IB_MAD_RESULT_SUCCESS = 1 << 0, /* MAD was successfully processed */ 1115219820Sjeff IB_MAD_RESULT_REPLY = 1 << 1, /* Reply packet needs to be sent */ 1116219820Sjeff IB_MAD_RESULT_CONSUMED = 1 << 2 /* Packet consumed: stop processing */ 1117219820Sjeff}; 1118219820Sjeff 1119219820Sjeff#define IB_DEVICE_NAME_MAX 64 1120219820Sjeff 1121219820Sjeffstruct ib_cache { 1122219820Sjeff rwlock_t lock; 1123219820Sjeff struct ib_event_handler event_handler; 1124219820Sjeff struct ib_pkey_cache **pkey_cache; 1125219820Sjeff struct ib_gid_cache **gid_cache; 1126219820Sjeff u8 *lmc_cache; 1127219820Sjeff}; 1128219820Sjeff 1129219820Sjeffstruct ib_dma_mapping_ops { 1130219820Sjeff int (*mapping_error)(struct ib_device *dev, 1131219820Sjeff u64 dma_addr); 1132219820Sjeff u64 (*map_single)(struct ib_device *dev, 1133219820Sjeff void *ptr, size_t size, 1134219820Sjeff enum dma_data_direction direction); 1135219820Sjeff void (*unmap_single)(struct ib_device *dev, 1136219820Sjeff u64 addr, size_t size, 1137219820Sjeff enum dma_data_direction direction); 1138219820Sjeff u64 (*map_page)(struct ib_device *dev, 1139219820Sjeff struct page *page, unsigned long offset, 1140219820Sjeff size_t size, 1141219820Sjeff enum dma_data_direction direction); 1142219820Sjeff void (*unmap_page)(struct ib_device *dev, 1143219820Sjeff u64 addr, size_t size, 1144219820Sjeff enum dma_data_direction direction); 1145219820Sjeff int (*map_sg)(struct ib_device *dev, 1146219820Sjeff struct scatterlist *sg, int nents, 1147219820Sjeff enum dma_data_direction direction); 1148219820Sjeff void (*unmap_sg)(struct ib_device *dev, 1149219820Sjeff struct scatterlist *sg, int nents, 1150219820Sjeff enum dma_data_direction direction); 1151219820Sjeff u64 (*dma_address)(struct ib_device *dev, 1152219820Sjeff struct scatterlist *sg); 1153219820Sjeff unsigned int (*dma_len)(struct ib_device *dev, 1154219820Sjeff struct scatterlist *sg); 1155219820Sjeff void (*sync_single_for_cpu)(struct ib_device *dev, 1156219820Sjeff u64 dma_handle, 1157219820Sjeff size_t size, 1158219820Sjeff enum dma_data_direction dir); 1159219820Sjeff void (*sync_single_for_device)(struct ib_device *dev, 1160219820Sjeff u64 dma_handle, 1161219820Sjeff size_t size, 1162219820Sjeff enum dma_data_direction dir); 1163219820Sjeff void *(*alloc_coherent)(struct ib_device *dev, 1164219820Sjeff size_t size, 1165219820Sjeff u64 *dma_handle, 1166219820Sjeff gfp_t flag); 1167219820Sjeff void (*free_coherent)(struct ib_device *dev, 1168219820Sjeff size_t size, void *cpu_addr, 1169219820Sjeff u64 dma_handle); 1170219820Sjeff}; 1171219820Sjeff 1172219820Sjeffstruct iw_cm_verbs; 1173219820Sjeff 1174219820Sjeffstruct ib_device { 1175219820Sjeff struct device *dma_device; 1176219820Sjeff 1177219820Sjeff char name[IB_DEVICE_NAME_MAX]; 1178219820Sjeff 1179219820Sjeff struct list_head event_handler_list; 1180219820Sjeff spinlock_t event_handler_lock; 1181219820Sjeff 1182255932Salfred spinlock_t client_data_lock; 1183219820Sjeff struct list_head core_list; 1184219820Sjeff struct list_head client_data_list; 1185219820Sjeff 1186219820Sjeff struct ib_cache cache; 1187219820Sjeff int *pkey_tbl_len; 1188219820Sjeff int *gid_tbl_len; 1189219820Sjeff 1190219820Sjeff int num_comp_vectors; 1191219820Sjeff 1192219820Sjeff struct iw_cm_verbs *iwcm; 1193219820Sjeff 1194219820Sjeff int (*get_protocol_stats)(struct ib_device *device, 1195219820Sjeff union rdma_protocol_stats *stats); 1196219820Sjeff int (*query_device)(struct ib_device *device, 1197219820Sjeff struct ib_device_attr *device_attr); 1198219820Sjeff int (*query_port)(struct ib_device *device, 1199219820Sjeff u8 port_num, 1200219820Sjeff struct ib_port_attr *port_attr); 1201219820Sjeff enum rdma_link_layer (*get_link_layer)(struct ib_device *device, 1202219820Sjeff u8 port_num); 1203219820Sjeff int (*query_gid)(struct ib_device *device, 1204219820Sjeff u8 port_num, int index, 1205219820Sjeff union ib_gid *gid); 1206219820Sjeff int (*query_pkey)(struct ib_device *device, 1207219820Sjeff u8 port_num, u16 index, u16 *pkey); 1208219820Sjeff int (*modify_device)(struct ib_device *device, 1209219820Sjeff int device_modify_mask, 1210219820Sjeff struct ib_device_modify *device_modify); 1211219820Sjeff int (*modify_port)(struct ib_device *device, 1212219820Sjeff u8 port_num, int port_modify_mask, 1213219820Sjeff struct ib_port_modify *port_modify); 1214219820Sjeff struct ib_ucontext * (*alloc_ucontext)(struct ib_device *device, 1215219820Sjeff struct ib_udata *udata); 1216219820Sjeff int (*dealloc_ucontext)(struct ib_ucontext *context); 1217219820Sjeff int (*mmap)(struct ib_ucontext *context, 1218219820Sjeff struct vm_area_struct *vma); 1219219820Sjeff struct ib_pd * (*alloc_pd)(struct ib_device *device, 1220219820Sjeff struct ib_ucontext *context, 1221219820Sjeff struct ib_udata *udata); 1222219820Sjeff int (*dealloc_pd)(struct ib_pd *pd); 1223219820Sjeff struct ib_ah * (*create_ah)(struct ib_pd *pd, 1224219820Sjeff struct ib_ah_attr *ah_attr); 1225219820Sjeff int (*modify_ah)(struct ib_ah *ah, 1226219820Sjeff struct ib_ah_attr *ah_attr); 1227219820Sjeff int (*query_ah)(struct ib_ah *ah, 1228219820Sjeff struct ib_ah_attr *ah_attr); 1229219820Sjeff int (*destroy_ah)(struct ib_ah *ah); 1230219820Sjeff struct ib_srq * (*create_srq)(struct ib_pd *pd, 1231219820Sjeff struct ib_srq_init_attr *srq_init_attr, 1232219820Sjeff struct ib_udata *udata); 1233219820Sjeff int (*modify_srq)(struct ib_srq *srq, 1234219820Sjeff struct ib_srq_attr *srq_attr, 1235219820Sjeff enum ib_srq_attr_mask srq_attr_mask, 1236219820Sjeff struct ib_udata *udata); 1237219820Sjeff int (*query_srq)(struct ib_srq *srq, 1238219820Sjeff struct ib_srq_attr *srq_attr); 1239219820Sjeff int (*destroy_srq)(struct ib_srq *srq); 1240219820Sjeff int (*post_srq_recv)(struct ib_srq *srq, 1241219820Sjeff struct ib_recv_wr *recv_wr, 1242219820Sjeff struct ib_recv_wr **bad_recv_wr); 1243219820Sjeff struct ib_qp * (*create_qp)(struct ib_pd *pd, 1244219820Sjeff struct ib_qp_init_attr *qp_init_attr, 1245219820Sjeff struct ib_udata *udata); 1246219820Sjeff int (*modify_qp)(struct ib_qp *qp, 1247219820Sjeff struct ib_qp_attr *qp_attr, 1248219820Sjeff int qp_attr_mask, 1249219820Sjeff struct ib_udata *udata); 1250219820Sjeff int (*query_qp)(struct ib_qp *qp, 1251219820Sjeff struct ib_qp_attr *qp_attr, 1252219820Sjeff int qp_attr_mask, 1253219820Sjeff struct ib_qp_init_attr *qp_init_attr); 1254219820Sjeff int (*destroy_qp)(struct ib_qp *qp); 1255219820Sjeff int (*post_send)(struct ib_qp *qp, 1256219820Sjeff struct ib_send_wr *send_wr, 1257219820Sjeff struct ib_send_wr **bad_send_wr); 1258219820Sjeff int (*post_recv)(struct ib_qp *qp, 1259219820Sjeff struct ib_recv_wr *recv_wr, 1260219820Sjeff struct ib_recv_wr **bad_recv_wr); 1261219820Sjeff struct ib_cq * (*create_cq)(struct ib_device *device, int cqe, 1262219820Sjeff int comp_vector, 1263219820Sjeff struct ib_ucontext *context, 1264219820Sjeff struct ib_udata *udata); 1265219820Sjeff int (*modify_cq)(struct ib_cq *cq, u16 cq_count, 1266219820Sjeff u16 cq_period); 1267219820Sjeff int (*destroy_cq)(struct ib_cq *cq); 1268219820Sjeff int (*resize_cq)(struct ib_cq *cq, int cqe, 1269219820Sjeff struct ib_udata *udata); 1270219820Sjeff int (*poll_cq)(struct ib_cq *cq, int num_entries, 1271219820Sjeff struct ib_wc *wc); 1272219820Sjeff int (*peek_cq)(struct ib_cq *cq, int wc_cnt); 1273219820Sjeff int (*req_notify_cq)(struct ib_cq *cq, 1274219820Sjeff enum ib_cq_notify_flags flags); 1275219820Sjeff int (*req_ncomp_notif)(struct ib_cq *cq, 1276219820Sjeff int wc_cnt); 1277219820Sjeff struct ib_mr * (*get_dma_mr)(struct ib_pd *pd, 1278219820Sjeff int mr_access_flags); 1279219820Sjeff struct ib_mr * (*reg_phys_mr)(struct ib_pd *pd, 1280219820Sjeff struct ib_phys_buf *phys_buf_array, 1281219820Sjeff int num_phys_buf, 1282219820Sjeff int mr_access_flags, 1283219820Sjeff u64 *iova_start); 1284219820Sjeff struct ib_mr * (*reg_user_mr)(struct ib_pd *pd, 1285219820Sjeff u64 start, u64 length, 1286219820Sjeff u64 virt_addr, 1287219820Sjeff int mr_access_flags, 1288255932Salfred struct ib_udata *udata, 1289255932Salfred int mr_id); 1290219820Sjeff int (*query_mr)(struct ib_mr *mr, 1291219820Sjeff struct ib_mr_attr *mr_attr); 1292219820Sjeff int (*dereg_mr)(struct ib_mr *mr); 1293219820Sjeff struct ib_mr * (*alloc_fast_reg_mr)(struct ib_pd *pd, 1294219820Sjeff int max_page_list_len); 1295219820Sjeff struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device, 1296219820Sjeff int page_list_len); 1297219820Sjeff void (*free_fast_reg_page_list)(struct ib_fast_reg_page_list *page_list); 1298219820Sjeff int (*rereg_phys_mr)(struct ib_mr *mr, 1299219820Sjeff int mr_rereg_mask, 1300219820Sjeff struct ib_pd *pd, 1301219820Sjeff struct ib_phys_buf *phys_buf_array, 1302219820Sjeff int num_phys_buf, 1303219820Sjeff int mr_access_flags, 1304219820Sjeff u64 *iova_start); 1305219820Sjeff struct ib_mw * (*alloc_mw)(struct ib_pd *pd); 1306219820Sjeff int (*bind_mw)(struct ib_qp *qp, 1307219820Sjeff struct ib_mw *mw, 1308219820Sjeff struct ib_mw_bind *mw_bind); 1309219820Sjeff int (*dealloc_mw)(struct ib_mw *mw); 1310219820Sjeff struct ib_fmr * (*alloc_fmr)(struct ib_pd *pd, 1311219820Sjeff int mr_access_flags, 1312219820Sjeff struct ib_fmr_attr *fmr_attr); 1313219820Sjeff int (*map_phys_fmr)(struct ib_fmr *fmr, 1314219820Sjeff u64 *page_list, int list_len, 1315219820Sjeff u64 iova); 1316219820Sjeff int (*unmap_fmr)(struct list_head *fmr_list); 1317219820Sjeff int (*dealloc_fmr)(struct ib_fmr *fmr); 1318219820Sjeff int (*attach_mcast)(struct ib_qp *qp, 1319219820Sjeff union ib_gid *gid, 1320219820Sjeff u16 lid); 1321219820Sjeff int (*detach_mcast)(struct ib_qp *qp, 1322219820Sjeff union ib_gid *gid, 1323219820Sjeff u16 lid); 1324219820Sjeff int (*process_mad)(struct ib_device *device, 1325219820Sjeff int process_mad_flags, 1326219820Sjeff u8 port_num, 1327219820Sjeff struct ib_wc *in_wc, 1328219820Sjeff struct ib_grh *in_grh, 1329219820Sjeff struct ib_mad *in_mad, 1330219820Sjeff struct ib_mad *out_mad); 1331219820Sjeff struct ib_srq * (*create_xrc_srq)(struct ib_pd *pd, 1332219820Sjeff struct ib_cq *xrc_cq, 1333219820Sjeff struct ib_xrcd *xrcd, 1334219820Sjeff struct ib_srq_init_attr *srq_init_attr, 1335219820Sjeff struct ib_udata *udata); 1336219820Sjeff struct ib_xrcd * (*alloc_xrcd)(struct ib_device *device, 1337255932Salfred struct ib_ucontext *ucontext, 1338219820Sjeff struct ib_udata *udata); 1339219820Sjeff int (*dealloc_xrcd)(struct ib_xrcd *xrcd); 1340219820Sjeff int (*create_xrc_rcv_qp)(struct ib_qp_init_attr *init_attr, 1341219820Sjeff u32 *qp_num); 1342219820Sjeff int (*modify_xrc_rcv_qp)(struct ib_xrcd *xrcd, 1343219820Sjeff u32 qp_num, 1344219820Sjeff struct ib_qp_attr *attr, 1345219820Sjeff int attr_mask); 1346219820Sjeff int (*query_xrc_rcv_qp)(struct ib_xrcd *xrcd, 1347219820Sjeff u32 qp_num, 1348219820Sjeff struct ib_qp_attr *attr, 1349219820Sjeff int attr_mask, 1350219820Sjeff struct ib_qp_init_attr *init_attr); 1351219820Sjeff int (*reg_xrc_rcv_qp)(struct ib_xrcd *xrcd, 1352219820Sjeff void *context, 1353219820Sjeff u32 qp_num); 1354219820Sjeff int (*unreg_xrc_rcv_qp)(struct ib_xrcd *xrcd, 1355219820Sjeff void *context, 1356219820Sjeff u32 qp_num); 1357255932Salfred int (*attach_flow)(struct ib_qp *qp, 1358255932Salfred struct ib_flow_spec *spec, 1359255932Salfred int priority); 1360255932Salfred int (*detach_flow)(struct ib_qp *qp, 1361255932Salfred struct ib_flow_spec *spec, 1362255932Salfred int priority); 1363219820Sjeff 1364255932Salfred unsigned long (*get_unmapped_area)(struct file *file, 1365255932Salfred unsigned long addr, 1366255932Salfred unsigned long len, unsigned long pgoff, 1367255932Salfred unsigned long flags); 1368219820Sjeff struct ib_dma_mapping_ops *dma_ops; 1369219820Sjeff 1370219820Sjeff struct module *owner; 1371219820Sjeff struct device dev; 1372219820Sjeff struct kobject *ports_parent; 1373219820Sjeff struct list_head port_list; 1374219820Sjeff 1375219820Sjeff enum { 1376219820Sjeff IB_DEV_UNINITIALIZED, 1377219820Sjeff IB_DEV_REGISTERED, 1378219820Sjeff IB_DEV_UNREGISTERED 1379219820Sjeff } reg_state; 1380219820Sjeff 1381255932Salfred int uverbs_abi_ver; 1382219820Sjeff u64 uverbs_cmd_mask; 1383219820Sjeff 1384219820Sjeff char node_desc[64]; 1385219820Sjeff __be64 node_guid; 1386219820Sjeff u32 local_dma_lkey; 1387219820Sjeff u8 node_type; 1388219820Sjeff u8 phys_port_cnt; 1389219820Sjeff struct rb_root ib_uverbs_xrcd_table; 1390219820Sjeff struct mutex xrcd_table_mutex; 1391219820Sjeff}; 1392219820Sjeff 1393219820Sjeffstruct ib_client { 1394219820Sjeff char *name; 1395219820Sjeff void (*add) (struct ib_device *); 1396219820Sjeff void (*remove)(struct ib_device *); 1397219820Sjeff 1398219820Sjeff struct list_head list; 1399219820Sjeff}; 1400219820Sjeff 1401219820Sjeffstruct ib_device *ib_alloc_device(size_t size); 1402219820Sjeffvoid ib_dealloc_device(struct ib_device *device); 1403219820Sjeff 1404255932Salfredint ib_register_device(struct ib_device *device, 1405255932Salfred int (*port_callback)(struct ib_device *, 1406255932Salfred u8, struct kobject *)); 1407219820Sjeffvoid ib_unregister_device(struct ib_device *device); 1408219820Sjeff 1409219820Sjeffint ib_register_client (struct ib_client *client); 1410219820Sjeffvoid ib_unregister_client(struct ib_client *client); 1411219820Sjeff 1412219820Sjeffvoid *ib_get_client_data(struct ib_device *device, struct ib_client *client); 1413219820Sjeffvoid ib_set_client_data(struct ib_device *device, struct ib_client *client, 1414219820Sjeff void *data); 1415219820Sjeff 1416219820Sjeffstatic inline int ib_copy_from_udata(void *dest, struct ib_udata *udata, size_t len) 1417219820Sjeff{ 1418219820Sjeff return copy_from_user(dest, udata->inbuf, len) ? -EFAULT : 0; 1419219820Sjeff} 1420219820Sjeff 1421219820Sjeffstatic inline int ib_copy_to_udata(struct ib_udata *udata, void *src, size_t len) 1422219820Sjeff{ 1423219820Sjeff return copy_to_user(udata->outbuf, src, len) ? -EFAULT : 0; 1424219820Sjeff} 1425219820Sjeff 1426219820Sjeff/** 1427219820Sjeff * ib_modify_qp_is_ok - Check that the supplied attribute mask 1428219820Sjeff * contains all required attributes and no attributes not allowed for 1429219820Sjeff * the given QP state transition. 1430219820Sjeff * @cur_state: Current QP state 1431219820Sjeff * @next_state: Next QP state 1432219820Sjeff * @type: QP type 1433219820Sjeff * @mask: Mask of supplied QP attributes 1434219820Sjeff * 1435219820Sjeff * This function is a helper function that a low-level driver's 1436219820Sjeff * modify_qp method can use to validate the consumer's input. It 1437219820Sjeff * checks that cur_state and next_state are valid QP states, that a 1438219820Sjeff * transition from cur_state to next_state is allowed by the IB spec, 1439219820Sjeff * and that the attribute mask supplied is allowed for the transition. 1440219820Sjeff */ 1441219820Sjeffint ib_modify_qp_is_ok(enum ib_qp_state cur_state, enum ib_qp_state next_state, 1442219820Sjeff enum ib_qp_type type, enum ib_qp_attr_mask mask); 1443219820Sjeff 1444219820Sjeffint ib_register_event_handler (struct ib_event_handler *event_handler); 1445219820Sjeffint ib_unregister_event_handler(struct ib_event_handler *event_handler); 1446219820Sjeffvoid ib_dispatch_event(struct ib_event *event); 1447219820Sjeff 1448219820Sjeffint ib_query_device(struct ib_device *device, 1449219820Sjeff struct ib_device_attr *device_attr); 1450219820Sjeff 1451219820Sjeffint ib_query_port(struct ib_device *device, 1452219820Sjeff u8 port_num, struct ib_port_attr *port_attr); 1453219820Sjeff 1454219820Sjeffenum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device, 1455219820Sjeff u8 port_num); 1456219820Sjeff 1457219820Sjeffint ib_query_gid(struct ib_device *device, 1458219820Sjeff u8 port_num, int index, union ib_gid *gid); 1459219820Sjeff 1460219820Sjeffint ib_query_pkey(struct ib_device *device, 1461219820Sjeff u8 port_num, u16 index, u16 *pkey); 1462219820Sjeff 1463219820Sjeffint ib_modify_device(struct ib_device *device, 1464219820Sjeff int device_modify_mask, 1465219820Sjeff struct ib_device_modify *device_modify); 1466219820Sjeff 1467219820Sjeffint ib_modify_port(struct ib_device *device, 1468219820Sjeff u8 port_num, int port_modify_mask, 1469219820Sjeff struct ib_port_modify *port_modify); 1470219820Sjeff 1471219820Sjeffint ib_find_gid(struct ib_device *device, union ib_gid *gid, 1472219820Sjeff u8 *port_num, u16 *index); 1473219820Sjeff 1474219820Sjeffint ib_find_pkey(struct ib_device *device, 1475219820Sjeff u8 port_num, u16 pkey, u16 *index); 1476219820Sjeff 1477219820Sjeff/** 1478219820Sjeff * ib_alloc_pd - Allocates an unused protection domain. 1479219820Sjeff * @device: The device on which to allocate the protection domain. 1480219820Sjeff * 1481219820Sjeff * A protection domain object provides an association between QPs, shared 1482219820Sjeff * receive queues, address handles, memory regions, and memory windows. 1483219820Sjeff */ 1484219820Sjeffstruct ib_pd *ib_alloc_pd(struct ib_device *device); 1485219820Sjeff 1486219820Sjeff/** 1487219820Sjeff * ib_dealloc_pd - Deallocates a protection domain. 1488219820Sjeff * @pd: The protection domain to deallocate. 1489219820Sjeff */ 1490219820Sjeffint ib_dealloc_pd(struct ib_pd *pd); 1491219820Sjeff 1492219820Sjeff/** 1493219820Sjeff * ib_create_ah - Creates an address handle for the given address vector. 1494219820Sjeff * @pd: The protection domain associated with the address handle. 1495219820Sjeff * @ah_attr: The attributes of the address vector. 1496219820Sjeff * 1497219820Sjeff * The address handle is used to reference a local or global destination 1498219820Sjeff * in all UD QP post sends. 1499219820Sjeff */ 1500219820Sjeffstruct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr); 1501219820Sjeff 1502219820Sjeff/** 1503219820Sjeff * ib_init_ah_from_wc - Initializes address handle attributes from a 1504219820Sjeff * work completion. 1505219820Sjeff * @device: Device on which the received message arrived. 1506219820Sjeff * @port_num: Port on which the received message arrived. 1507219820Sjeff * @wc: Work completion associated with the received message. 1508219820Sjeff * @grh: References the received global route header. This parameter is 1509219820Sjeff * ignored unless the work completion indicates that the GRH is valid. 1510219820Sjeff * @ah_attr: Returned attributes that can be used when creating an address 1511219820Sjeff * handle for replying to the message. 1512219820Sjeff */ 1513219820Sjeffint ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc, 1514219820Sjeff struct ib_grh *grh, struct ib_ah_attr *ah_attr); 1515219820Sjeff 1516219820Sjeff/** 1517219820Sjeff * ib_create_ah_from_wc - Creates an address handle associated with the 1518219820Sjeff * sender of the specified work completion. 1519219820Sjeff * @pd: The protection domain associated with the address handle. 1520219820Sjeff * @wc: Work completion information associated with a received message. 1521219820Sjeff * @grh: References the received global route header. This parameter is 1522219820Sjeff * ignored unless the work completion indicates that the GRH is valid. 1523219820Sjeff * @port_num: The outbound port number to associate with the address. 1524219820Sjeff * 1525219820Sjeff * The address handle is used to reference a local or global destination 1526219820Sjeff * in all UD QP post sends. 1527219820Sjeff */ 1528219820Sjeffstruct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc, 1529219820Sjeff struct ib_grh *grh, u8 port_num); 1530219820Sjeff 1531219820Sjeff/** 1532219820Sjeff * ib_modify_ah - Modifies the address vector associated with an address 1533219820Sjeff * handle. 1534219820Sjeff * @ah: The address handle to modify. 1535219820Sjeff * @ah_attr: The new address vector attributes to associate with the 1536219820Sjeff * address handle. 1537219820Sjeff */ 1538219820Sjeffint ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 1539219820Sjeff 1540219820Sjeff/** 1541219820Sjeff * ib_query_ah - Queries the address vector associated with an address 1542219820Sjeff * handle. 1543219820Sjeff * @ah: The address handle to query. 1544219820Sjeff * @ah_attr: The address vector attributes associated with the address 1545219820Sjeff * handle. 1546219820Sjeff */ 1547219820Sjeffint ib_query_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr); 1548219820Sjeff 1549219820Sjeff/** 1550219820Sjeff * ib_destroy_ah - Destroys an address handle. 1551219820Sjeff * @ah: The address handle to destroy. 1552219820Sjeff */ 1553219820Sjeffint ib_destroy_ah(struct ib_ah *ah); 1554219820Sjeff 1555219820Sjeff/** 1556219820Sjeff * ib_create_xrc_srq - Creates an XRC SRQ associated with the specified 1557219820Sjeff * protection domain, cq, and xrc domain. 1558219820Sjeff * @pd: The protection domain associated with the SRQ. 1559219820Sjeff * @xrc_cq: The cq to be associated with the XRC SRQ. 1560219820Sjeff * @xrcd: The XRC domain to be associated with the XRC SRQ. 1561219820Sjeff * @srq_init_attr: A list of initial attributes required to create the 1562219820Sjeff * XRC SRQ. If XRC SRQ creation succeeds, then the attributes are updated 1563219820Sjeff * to the actual capabilities of the created XRC SRQ. 1564219820Sjeff * 1565219820Sjeff * srq_attr->max_wr and srq_attr->max_sge are read the determine the 1566219820Sjeff * requested size of the XRC SRQ, and set to the actual values allocated 1567219820Sjeff * on return. If ib_create_xrc_srq() succeeds, then max_wr and max_sge 1568219820Sjeff * will always be at least as large as the requested values. 1569219820Sjeff */ 1570219820Sjeffstruct ib_srq *ib_create_xrc_srq(struct ib_pd *pd, 1571219820Sjeff struct ib_cq *xrc_cq, 1572219820Sjeff struct ib_xrcd *xrcd, 1573219820Sjeff struct ib_srq_init_attr *srq_init_attr); 1574219820Sjeff 1575219820Sjeff/** 1576255932Salfred * ib_create_srq - Creates a SRQ associated with the specified protection 1577255932Salfred * domain. 1578219820Sjeff * @pd: The protection domain associated with the SRQ. 1579219820Sjeff * @srq_init_attr: A list of initial attributes required to create the 1580219820Sjeff * SRQ. If SRQ creation succeeds, then the attributes are updated to 1581219820Sjeff * the actual capabilities of the created SRQ. 1582219820Sjeff * 1583219820Sjeff * srq_attr->max_wr and srq_attr->max_sge are read the determine the 1584219820Sjeff * requested size of the SRQ, and set to the actual values allocated 1585219820Sjeff * on return. If ib_create_srq() succeeds, then max_wr and max_sge 1586219820Sjeff * will always be at least as large as the requested values. 1587219820Sjeff */ 1588219820Sjeffstruct ib_srq *ib_create_srq(struct ib_pd *pd, 1589219820Sjeff struct ib_srq_init_attr *srq_init_attr); 1590219820Sjeff 1591219820Sjeff/** 1592219820Sjeff * ib_modify_srq - Modifies the attributes for the specified SRQ. 1593219820Sjeff * @srq: The SRQ to modify. 1594219820Sjeff * @srq_attr: On input, specifies the SRQ attributes to modify. On output, 1595219820Sjeff * the current values of selected SRQ attributes are returned. 1596219820Sjeff * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ 1597219820Sjeff * are being modified. 1598219820Sjeff * 1599219820Sjeff * The mask may contain IB_SRQ_MAX_WR to resize the SRQ and/or 1600219820Sjeff * IB_SRQ_LIMIT to set the SRQ's limit and request notification when 1601219820Sjeff * the number of receives queued drops below the limit. 1602219820Sjeff */ 1603219820Sjeffint ib_modify_srq(struct ib_srq *srq, 1604219820Sjeff struct ib_srq_attr *srq_attr, 1605219820Sjeff enum ib_srq_attr_mask srq_attr_mask); 1606219820Sjeff 1607219820Sjeff/** 1608219820Sjeff * ib_query_srq - Returns the attribute list and current values for the 1609219820Sjeff * specified SRQ. 1610219820Sjeff * @srq: The SRQ to query. 1611219820Sjeff * @srq_attr: The attributes of the specified SRQ. 1612219820Sjeff */ 1613219820Sjeffint ib_query_srq(struct ib_srq *srq, 1614219820Sjeff struct ib_srq_attr *srq_attr); 1615219820Sjeff 1616219820Sjeff/** 1617219820Sjeff * ib_destroy_srq - Destroys the specified SRQ. 1618219820Sjeff * @srq: The SRQ to destroy. 1619219820Sjeff */ 1620219820Sjeffint ib_destroy_srq(struct ib_srq *srq); 1621219820Sjeff 1622219820Sjeff/** 1623219820Sjeff * ib_post_srq_recv - Posts a list of work requests to the specified SRQ. 1624219820Sjeff * @srq: The SRQ to post the work request on. 1625219820Sjeff * @recv_wr: A list of work requests to post on the receive queue. 1626219820Sjeff * @bad_recv_wr: On an immediate failure, this parameter will reference 1627219820Sjeff * the work request that failed to be posted on the QP. 1628219820Sjeff */ 1629219820Sjeffstatic inline int ib_post_srq_recv(struct ib_srq *srq, 1630219820Sjeff struct ib_recv_wr *recv_wr, 1631219820Sjeff struct ib_recv_wr **bad_recv_wr) 1632219820Sjeff{ 1633219820Sjeff return srq->device->post_srq_recv(srq, recv_wr, bad_recv_wr); 1634219820Sjeff} 1635219820Sjeff 1636219820Sjeff/** 1637219820Sjeff * ib_create_qp - Creates a QP associated with the specified protection 1638219820Sjeff * domain. 1639219820Sjeff * @pd: The protection domain associated with the QP. 1640219820Sjeff * @qp_init_attr: A list of initial attributes required to create the 1641219820Sjeff * QP. If QP creation succeeds, then the attributes are updated to 1642219820Sjeff * the actual capabilities of the created QP. 1643219820Sjeff */ 1644219820Sjeffstruct ib_qp *ib_create_qp(struct ib_pd *pd, 1645219820Sjeff struct ib_qp_init_attr *qp_init_attr); 1646219820Sjeff 1647219820Sjeff/** 1648219820Sjeff * ib_modify_qp - Modifies the attributes for the specified QP and then 1649219820Sjeff * transitions the QP to the given state. 1650219820Sjeff * @qp: The QP to modify. 1651219820Sjeff * @qp_attr: On input, specifies the QP attributes to modify. On output, 1652219820Sjeff * the current values of selected QP attributes are returned. 1653219820Sjeff * @qp_attr_mask: A bit-mask used to specify which attributes of the QP 1654219820Sjeff * are being modified. 1655219820Sjeff */ 1656219820Sjeffint ib_modify_qp(struct ib_qp *qp, 1657219820Sjeff struct ib_qp_attr *qp_attr, 1658219820Sjeff int qp_attr_mask); 1659219820Sjeff 1660219820Sjeff/** 1661219820Sjeff * ib_query_qp - Returns the attribute list and current values for the 1662219820Sjeff * specified QP. 1663219820Sjeff * @qp: The QP to query. 1664219820Sjeff * @qp_attr: The attributes of the specified QP. 1665219820Sjeff * @qp_attr_mask: A bit-mask used to select specific attributes to query. 1666219820Sjeff * @qp_init_attr: Additional attributes of the selected QP. 1667219820Sjeff * 1668219820Sjeff * The qp_attr_mask may be used to limit the query to gathering only the 1669219820Sjeff * selected attributes. 1670219820Sjeff */ 1671219820Sjeffint ib_query_qp(struct ib_qp *qp, 1672219820Sjeff struct ib_qp_attr *qp_attr, 1673219820Sjeff int qp_attr_mask, 1674219820Sjeff struct ib_qp_init_attr *qp_init_attr); 1675219820Sjeff 1676219820Sjeff/** 1677219820Sjeff * ib_destroy_qp - Destroys the specified QP. 1678219820Sjeff * @qp: The QP to destroy. 1679219820Sjeff */ 1680219820Sjeffint ib_destroy_qp(struct ib_qp *qp); 1681219820Sjeff 1682219820Sjeff/** 1683255932Salfred * ib_open_qp - Obtain a reference to an existing sharable QP. 1684255932Salfred * @xrcd - XRC domain 1685255932Salfred * @qp_open_attr: Attributes identifying the QP to open. 1686255932Salfred * 1687255932Salfred * Returns a reference to a sharable QP. 1688255932Salfred */ 1689255932Salfredstruct ib_qp *ib_open_qp(struct ib_xrcd *xrcd, 1690255932Salfred struct ib_qp_open_attr *qp_open_attr); 1691255932Salfred 1692255932Salfred/** 1693255932Salfred * ib_close_qp - Release an external reference to a QP. 1694255932Salfred * @qp: The QP handle to release 1695255932Salfred * 1696255932Salfred * The opened QP handle is released by the caller. The underlying 1697255932Salfred * shared QP is not destroyed until all internal references are released. 1698255932Salfred */ 1699255932Salfredint ib_close_qp(struct ib_qp *qp); 1700255932Salfred 1701255932Salfred/** 1702219820Sjeff * ib_post_send - Posts a list of work requests to the send queue of 1703219820Sjeff * the specified QP. 1704219820Sjeff * @qp: The QP to post the work request on. 1705219820Sjeff * @send_wr: A list of work requests to post on the send queue. 1706219820Sjeff * @bad_send_wr: On an immediate failure, this parameter will reference 1707219820Sjeff * the work request that failed to be posted on the QP. 1708255932Salfred * 1709255932Salfred * While IBA Vol. 1 section 11.4.1.1 specifies that if an immediate 1710255932Salfred * error is returned, the QP state shall not be affected, 1711255932Salfred * ib_post_send() will return an immediate error after queueing any 1712255932Salfred * earlier work requests in the list. 1713219820Sjeff */ 1714219820Sjeffstatic inline int ib_post_send(struct ib_qp *qp, 1715219820Sjeff struct ib_send_wr *send_wr, 1716219820Sjeff struct ib_send_wr **bad_send_wr) 1717219820Sjeff{ 1718219820Sjeff return qp->device->post_send(qp, send_wr, bad_send_wr); 1719219820Sjeff} 1720219820Sjeff 1721219820Sjeff/** 1722219820Sjeff * ib_post_recv - Posts a list of work requests to the receive queue of 1723219820Sjeff * the specified QP. 1724219820Sjeff * @qp: The QP to post the work request on. 1725219820Sjeff * @recv_wr: A list of work requests to post on the receive queue. 1726219820Sjeff * @bad_recv_wr: On an immediate failure, this parameter will reference 1727219820Sjeff * the work request that failed to be posted on the QP. 1728219820Sjeff */ 1729219820Sjeffstatic inline int ib_post_recv(struct ib_qp *qp, 1730219820Sjeff struct ib_recv_wr *recv_wr, 1731219820Sjeff struct ib_recv_wr **bad_recv_wr) 1732219820Sjeff{ 1733219820Sjeff return qp->device->post_recv(qp, recv_wr, bad_recv_wr); 1734219820Sjeff} 1735219820Sjeff 1736219820Sjeff/* 1737219820Sjeff * IB_CQ_VECTOR_LEAST_ATTACHED: The constant specifies that 1738219820Sjeff * the CQ will be attached to the completion vector that has 1739219820Sjeff * the least number of CQs already attached to it. 1740219820Sjeff */ 1741219820Sjeff#define IB_CQ_VECTOR_LEAST_ATTACHED 0xffffffff 1742219820Sjeff 1743219820Sjeff/** 1744219820Sjeff * ib_create_cq - Creates a CQ on the specified device. 1745219820Sjeff * @device: The device on which to create the CQ. 1746219820Sjeff * @comp_handler: A user-specified callback that is invoked when a 1747219820Sjeff * completion event occurs on the CQ. 1748219820Sjeff * @event_handler: A user-specified callback that is invoked when an 1749219820Sjeff * asynchronous event not associated with a completion occurs on the CQ. 1750219820Sjeff * @cq_context: Context associated with the CQ returned to the user via 1751219820Sjeff * the associated completion and event handlers. 1752219820Sjeff * @cqe: The minimum size of the CQ. 1753219820Sjeff * @comp_vector - Completion vector used to signal completion events. 1754255932Salfred * Must be >= 0 and < context->num_comp_vectors. 1755219820Sjeff * 1756219820Sjeff * Users can examine the cq structure to determine the actual CQ size. 1757219820Sjeff */ 1758219820Sjeffstruct ib_cq *ib_create_cq(struct ib_device *device, 1759219820Sjeff ib_comp_handler comp_handler, 1760219820Sjeff void (*event_handler)(struct ib_event *, void *), 1761219820Sjeff void *cq_context, int cqe, int comp_vector); 1762219820Sjeff 1763219820Sjeff/** 1764219820Sjeff * ib_resize_cq - Modifies the capacity of the CQ. 1765219820Sjeff * @cq: The CQ to resize. 1766219820Sjeff * @cqe: The minimum size of the CQ. 1767219820Sjeff * 1768219820Sjeff * Users can examine the cq structure to determine the actual CQ size. 1769219820Sjeff */ 1770219820Sjeffint ib_resize_cq(struct ib_cq *cq, int cqe); 1771219820Sjeff 1772219820Sjeff/** 1773219820Sjeff * ib_modify_cq - Modifies moderation params of the CQ 1774219820Sjeff * @cq: The CQ to modify. 1775219820Sjeff * @cq_count: number of CQEs that will trigger an event 1776219820Sjeff * @cq_period: max period of time in usec before triggering an event 1777219820Sjeff * 1778219820Sjeff */ 1779219820Sjeffint ib_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period); 1780219820Sjeff 1781219820Sjeff/** 1782219820Sjeff * ib_destroy_cq - Destroys the specified CQ. 1783219820Sjeff * @cq: The CQ to destroy. 1784219820Sjeff */ 1785219820Sjeffint ib_destroy_cq(struct ib_cq *cq); 1786219820Sjeff 1787219820Sjeff/** 1788219820Sjeff * ib_poll_cq - poll a CQ for completion(s) 1789219820Sjeff * @cq:the CQ being polled 1790219820Sjeff * @num_entries:maximum number of completions to return 1791219820Sjeff * @wc:array of at least @num_entries &struct ib_wc where completions 1792219820Sjeff * will be returned 1793219820Sjeff * 1794219820Sjeff * Poll a CQ for (possibly multiple) completions. If the return value 1795219820Sjeff * is < 0, an error occurred. If the return value is >= 0, it is the 1796219820Sjeff * number of completions returned. If the return value is 1797219820Sjeff * non-negative and < num_entries, then the CQ was emptied. 1798219820Sjeff */ 1799219820Sjeffstatic inline int ib_poll_cq(struct ib_cq *cq, int num_entries, 1800219820Sjeff struct ib_wc *wc) 1801219820Sjeff{ 1802219820Sjeff return cq->device->poll_cq(cq, num_entries, wc); 1803219820Sjeff} 1804219820Sjeff 1805219820Sjeff/** 1806219820Sjeff * ib_peek_cq - Returns the number of unreaped completions currently 1807219820Sjeff * on the specified CQ. 1808219820Sjeff * @cq: The CQ to peek. 1809219820Sjeff * @wc_cnt: A minimum number of unreaped completions to check for. 1810219820Sjeff * 1811219820Sjeff * If the number of unreaped completions is greater than or equal to wc_cnt, 1812219820Sjeff * this function returns wc_cnt, otherwise, it returns the actual number of 1813219820Sjeff * unreaped completions. 1814219820Sjeff */ 1815219820Sjeffint ib_peek_cq(struct ib_cq *cq, int wc_cnt); 1816219820Sjeff 1817219820Sjeff/** 1818219820Sjeff * ib_req_notify_cq - Request completion notification on a CQ. 1819219820Sjeff * @cq: The CQ to generate an event for. 1820219820Sjeff * @flags: 1821219820Sjeff * Must contain exactly one of %IB_CQ_SOLICITED or %IB_CQ_NEXT_COMP 1822219820Sjeff * to request an event on the next solicited event or next work 1823219820Sjeff * completion at any type, respectively. %IB_CQ_REPORT_MISSED_EVENTS 1824219820Sjeff * may also be |ed in to request a hint about missed events, as 1825219820Sjeff * described below. 1826219820Sjeff * 1827219820Sjeff * Return Value: 1828219820Sjeff * < 0 means an error occurred while requesting notification 1829219820Sjeff * == 0 means notification was requested successfully, and if 1830219820Sjeff * IB_CQ_REPORT_MISSED_EVENTS was passed in, then no events 1831219820Sjeff * were missed and it is safe to wait for another event. In 1832219820Sjeff * this case is it guaranteed that any work completions added 1833219820Sjeff * to the CQ since the last CQ poll will trigger a completion 1834219820Sjeff * notification event. 1835219820Sjeff * > 0 is only returned if IB_CQ_REPORT_MISSED_EVENTS was passed 1836219820Sjeff * in. It means that the consumer must poll the CQ again to 1837219820Sjeff * make sure it is empty to avoid missing an event because of a 1838219820Sjeff * race between requesting notification and an entry being 1839219820Sjeff * added to the CQ. This return value means it is possible 1840219820Sjeff * (but not guaranteed) that a work completion has been added 1841219820Sjeff * to the CQ since the last poll without triggering a 1842219820Sjeff * completion notification event. 1843219820Sjeff */ 1844219820Sjeffstatic inline int ib_req_notify_cq(struct ib_cq *cq, 1845219820Sjeff enum ib_cq_notify_flags flags) 1846219820Sjeff{ 1847219820Sjeff return cq->device->req_notify_cq(cq, flags); 1848219820Sjeff} 1849219820Sjeff 1850219820Sjeff/** 1851219820Sjeff * ib_req_ncomp_notif - Request completion notification when there are 1852219820Sjeff * at least the specified number of unreaped completions on the CQ. 1853219820Sjeff * @cq: The CQ to generate an event for. 1854219820Sjeff * @wc_cnt: The number of unreaped completions that should be on the 1855219820Sjeff * CQ before an event is generated. 1856219820Sjeff */ 1857219820Sjeffstatic inline int ib_req_ncomp_notif(struct ib_cq *cq, int wc_cnt) 1858219820Sjeff{ 1859219820Sjeff return cq->device->req_ncomp_notif ? 1860219820Sjeff cq->device->req_ncomp_notif(cq, wc_cnt) : 1861219820Sjeff -ENOSYS; 1862219820Sjeff} 1863219820Sjeff 1864219820Sjeff/** 1865219820Sjeff * ib_get_dma_mr - Returns a memory region for system memory that is 1866219820Sjeff * usable for DMA. 1867219820Sjeff * @pd: The protection domain associated with the memory region. 1868219820Sjeff * @mr_access_flags: Specifies the memory access rights. 1869219820Sjeff * 1870219820Sjeff * Note that the ib_dma_*() functions defined below must be used 1871219820Sjeff * to create/destroy addresses used with the Lkey or Rkey returned 1872219820Sjeff * by ib_get_dma_mr(). 1873219820Sjeff */ 1874219820Sjeffstruct ib_mr *ib_get_dma_mr(struct ib_pd *pd, int mr_access_flags); 1875219820Sjeff 1876219820Sjeff/** 1877219820Sjeff * ib_dma_mapping_error - check a DMA addr for error 1878219820Sjeff * @dev: The device for which the dma_addr was created 1879219820Sjeff * @dma_addr: The DMA address to check 1880219820Sjeff */ 1881219820Sjeffstatic inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr) 1882219820Sjeff{ 1883219820Sjeff if (dev->dma_ops) 1884219820Sjeff return dev->dma_ops->mapping_error(dev, dma_addr); 1885219820Sjeff return dma_mapping_error(dev->dma_device, dma_addr); 1886219820Sjeff} 1887219820Sjeff 1888219820Sjeff/** 1889219820Sjeff * ib_dma_map_single - Map a kernel virtual address to DMA address 1890219820Sjeff * @dev: The device for which the dma_addr is to be created 1891219820Sjeff * @cpu_addr: The kernel virtual address 1892219820Sjeff * @size: The size of the region in bytes 1893219820Sjeff * @direction: The direction of the DMA 1894219820Sjeff */ 1895219820Sjeffstatic inline u64 ib_dma_map_single(struct ib_device *dev, 1896219820Sjeff void *cpu_addr, size_t size, 1897219820Sjeff enum dma_data_direction direction) 1898219820Sjeff{ 1899219820Sjeff if (dev->dma_ops) 1900219820Sjeff return dev->dma_ops->map_single(dev, cpu_addr, size, direction); 1901219820Sjeff return dma_map_single(dev->dma_device, cpu_addr, size, direction); 1902219820Sjeff} 1903219820Sjeff 1904219820Sjeff/** 1905219820Sjeff * ib_dma_unmap_single - Destroy a mapping created by ib_dma_map_single() 1906219820Sjeff * @dev: The device for which the DMA address was created 1907219820Sjeff * @addr: The DMA address 1908219820Sjeff * @size: The size of the region in bytes 1909219820Sjeff * @direction: The direction of the DMA 1910219820Sjeff */ 1911219820Sjeffstatic inline void ib_dma_unmap_single(struct ib_device *dev, 1912219820Sjeff u64 addr, size_t size, 1913219820Sjeff enum dma_data_direction direction) 1914219820Sjeff{ 1915219820Sjeff if (dev->dma_ops) 1916219820Sjeff dev->dma_ops->unmap_single(dev, addr, size, direction); 1917219820Sjeff else 1918219820Sjeff dma_unmap_single(dev->dma_device, addr, size, direction); 1919219820Sjeff} 1920219820Sjeff 1921219820Sjeffstatic inline u64 ib_dma_map_single_attrs(struct ib_device *dev, 1922219820Sjeff void *cpu_addr, size_t size, 1923219820Sjeff enum dma_data_direction direction, 1924219820Sjeff struct dma_attrs *attrs) 1925219820Sjeff{ 1926219820Sjeff return dma_map_single_attrs(dev->dma_device, cpu_addr, size, 1927219820Sjeff direction, attrs); 1928219820Sjeff} 1929219820Sjeff 1930219820Sjeffstatic inline void ib_dma_unmap_single_attrs(struct ib_device *dev, 1931219820Sjeff u64 addr, size_t size, 1932219820Sjeff enum dma_data_direction direction, 1933219820Sjeff struct dma_attrs *attrs) 1934219820Sjeff{ 1935219820Sjeff return dma_unmap_single_attrs(dev->dma_device, addr, size, 1936219820Sjeff direction, attrs); 1937219820Sjeff} 1938219820Sjeff 1939219820Sjeff/** 1940219820Sjeff * ib_dma_map_page - Map a physical page to DMA address 1941219820Sjeff * @dev: The device for which the dma_addr is to be created 1942219820Sjeff * @page: The page to be mapped 1943219820Sjeff * @offset: The offset within the page 1944219820Sjeff * @size: The size of the region in bytes 1945219820Sjeff * @direction: The direction of the DMA 1946219820Sjeff */ 1947219820Sjeffstatic inline u64 ib_dma_map_page(struct ib_device *dev, 1948219820Sjeff struct page *page, 1949219820Sjeff unsigned long offset, 1950219820Sjeff size_t size, 1951219820Sjeff enum dma_data_direction direction) 1952219820Sjeff{ 1953219820Sjeff if (dev->dma_ops) 1954219820Sjeff return dev->dma_ops->map_page(dev, page, offset, size, direction); 1955219820Sjeff return dma_map_page(dev->dma_device, page, offset, size, direction); 1956219820Sjeff} 1957219820Sjeff 1958219820Sjeff/** 1959219820Sjeff * ib_dma_unmap_page - Destroy a mapping created by ib_dma_map_page() 1960219820Sjeff * @dev: The device for which the DMA address was created 1961219820Sjeff * @addr: The DMA address 1962219820Sjeff * @size: The size of the region in bytes 1963219820Sjeff * @direction: The direction of the DMA 1964219820Sjeff */ 1965219820Sjeffstatic inline void ib_dma_unmap_page(struct ib_device *dev, 1966219820Sjeff u64 addr, size_t size, 1967219820Sjeff enum dma_data_direction direction) 1968219820Sjeff{ 1969219820Sjeff if (dev->dma_ops) 1970219820Sjeff dev->dma_ops->unmap_page(dev, addr, size, direction); 1971219820Sjeff else 1972219820Sjeff dma_unmap_page(dev->dma_device, addr, size, direction); 1973219820Sjeff} 1974219820Sjeff 1975219820Sjeff/** 1976219820Sjeff * ib_dma_map_sg - Map a scatter/gather list to DMA addresses 1977219820Sjeff * @dev: The device for which the DMA addresses are to be created 1978219820Sjeff * @sg: The array of scatter/gather entries 1979219820Sjeff * @nents: The number of scatter/gather entries 1980219820Sjeff * @direction: The direction of the DMA 1981219820Sjeff */ 1982219820Sjeffstatic inline int ib_dma_map_sg(struct ib_device *dev, 1983219820Sjeff struct scatterlist *sg, int nents, 1984219820Sjeff enum dma_data_direction direction) 1985219820Sjeff{ 1986219820Sjeff if (dev->dma_ops) 1987219820Sjeff return dev->dma_ops->map_sg(dev, sg, nents, direction); 1988219820Sjeff return dma_map_sg(dev->dma_device, sg, nents, direction); 1989219820Sjeff} 1990219820Sjeff 1991219820Sjeff/** 1992219820Sjeff * ib_dma_unmap_sg - Unmap a scatter/gather list of DMA addresses 1993219820Sjeff * @dev: The device for which the DMA addresses were created 1994219820Sjeff * @sg: The array of scatter/gather entries 1995219820Sjeff * @nents: The number of scatter/gather entries 1996219820Sjeff * @direction: The direction of the DMA 1997219820Sjeff */ 1998219820Sjeffstatic inline void ib_dma_unmap_sg(struct ib_device *dev, 1999219820Sjeff struct scatterlist *sg, int nents, 2000219820Sjeff enum dma_data_direction direction) 2001219820Sjeff{ 2002219820Sjeff if (dev->dma_ops) 2003219820Sjeff dev->dma_ops->unmap_sg(dev, sg, nents, direction); 2004219820Sjeff else 2005219820Sjeff dma_unmap_sg(dev->dma_device, sg, nents, direction); 2006219820Sjeff} 2007219820Sjeff 2008219820Sjeffstatic inline int ib_dma_map_sg_attrs(struct ib_device *dev, 2009219820Sjeff struct scatterlist *sg, int nents, 2010219820Sjeff enum dma_data_direction direction, 2011219820Sjeff struct dma_attrs *attrs) 2012219820Sjeff{ 2013219820Sjeff return dma_map_sg_attrs(dev->dma_device, sg, nents, direction, attrs); 2014219820Sjeff} 2015219820Sjeff 2016219820Sjeffstatic inline void ib_dma_unmap_sg_attrs(struct ib_device *dev, 2017219820Sjeff struct scatterlist *sg, int nents, 2018219820Sjeff enum dma_data_direction direction, 2019219820Sjeff struct dma_attrs *attrs) 2020219820Sjeff{ 2021219820Sjeff dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, attrs); 2022219820Sjeff} 2023219820Sjeff/** 2024219820Sjeff * ib_sg_dma_address - Return the DMA address from a scatter/gather entry 2025219820Sjeff * @dev: The device for which the DMA addresses were created 2026219820Sjeff * @sg: The scatter/gather entry 2027219820Sjeff */ 2028219820Sjeffstatic inline u64 ib_sg_dma_address(struct ib_device *dev, 2029219820Sjeff struct scatterlist *sg) 2030219820Sjeff{ 2031219820Sjeff if (dev->dma_ops) 2032219820Sjeff return dev->dma_ops->dma_address(dev, sg); 2033219820Sjeff return sg_dma_address(sg); 2034219820Sjeff} 2035219820Sjeff 2036219820Sjeff/** 2037219820Sjeff * ib_sg_dma_len - Return the DMA length from a scatter/gather entry 2038219820Sjeff * @dev: The device for which the DMA addresses were created 2039219820Sjeff * @sg: The scatter/gather entry 2040219820Sjeff */ 2041219820Sjeffstatic inline unsigned int ib_sg_dma_len(struct ib_device *dev, 2042219820Sjeff struct scatterlist *sg) 2043219820Sjeff{ 2044219820Sjeff if (dev->dma_ops) 2045219820Sjeff return dev->dma_ops->dma_len(dev, sg); 2046219820Sjeff return sg_dma_len(sg); 2047219820Sjeff} 2048219820Sjeff 2049219820Sjeff/** 2050219820Sjeff * ib_dma_sync_single_for_cpu - Prepare DMA region to be accessed by CPU 2051219820Sjeff * @dev: The device for which the DMA address was created 2052219820Sjeff * @addr: The DMA address 2053219820Sjeff * @size: The size of the region in bytes 2054219820Sjeff * @dir: The direction of the DMA 2055219820Sjeff */ 2056219820Sjeffstatic inline void ib_dma_sync_single_for_cpu(struct ib_device *dev, 2057219820Sjeff u64 addr, 2058219820Sjeff size_t size, 2059219820Sjeff enum dma_data_direction dir) 2060219820Sjeff{ 2061219820Sjeff if (dev->dma_ops) 2062219820Sjeff dev->dma_ops->sync_single_for_cpu(dev, addr, size, dir); 2063219820Sjeff else 2064219820Sjeff dma_sync_single_for_cpu(dev->dma_device, addr, size, dir); 2065219820Sjeff} 2066219820Sjeff 2067219820Sjeff/** 2068219820Sjeff * ib_dma_sync_single_for_device - Prepare DMA region to be accessed by device 2069219820Sjeff * @dev: The device for which the DMA address was created 2070219820Sjeff * @addr: The DMA address 2071219820Sjeff * @size: The size of the region in bytes 2072219820Sjeff * @dir: The direction of the DMA 2073219820Sjeff */ 2074219820Sjeffstatic inline void ib_dma_sync_single_for_device(struct ib_device *dev, 2075219820Sjeff u64 addr, 2076219820Sjeff size_t size, 2077219820Sjeff enum dma_data_direction dir) 2078219820Sjeff{ 2079219820Sjeff if (dev->dma_ops) 2080219820Sjeff dev->dma_ops->sync_single_for_device(dev, addr, size, dir); 2081219820Sjeff else 2082219820Sjeff dma_sync_single_for_device(dev->dma_device, addr, size, dir); 2083219820Sjeff} 2084219820Sjeff 2085219820Sjeff/** 2086219820Sjeff * ib_dma_alloc_coherent - Allocate memory and map it for DMA 2087219820Sjeff * @dev: The device for which the DMA address is requested 2088219820Sjeff * @size: The size of the region to allocate in bytes 2089219820Sjeff * @dma_handle: A pointer for returning the DMA address of the region 2090219820Sjeff * @flag: memory allocator flags 2091219820Sjeff */ 2092219820Sjeffstatic inline void *ib_dma_alloc_coherent(struct ib_device *dev, 2093219820Sjeff size_t size, 2094219820Sjeff u64 *dma_handle, 2095219820Sjeff gfp_t flag) 2096219820Sjeff{ 2097219820Sjeff if (dev->dma_ops) 2098219820Sjeff return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag); 2099219820Sjeff else { 2100219820Sjeff dma_addr_t handle; 2101219820Sjeff void *ret; 2102219820Sjeff 2103219820Sjeff ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag); 2104219820Sjeff *dma_handle = handle; 2105219820Sjeff return ret; 2106219820Sjeff } 2107219820Sjeff} 2108219820Sjeff 2109219820Sjeff/** 2110219820Sjeff * ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent() 2111219820Sjeff * @dev: The device for which the DMA addresses were allocated 2112219820Sjeff * @size: The size of the region 2113219820Sjeff * @cpu_addr: the address returned by ib_dma_alloc_coherent() 2114219820Sjeff * @dma_handle: the DMA address returned by ib_dma_alloc_coherent() 2115219820Sjeff */ 2116219820Sjeffstatic inline void ib_dma_free_coherent(struct ib_device *dev, 2117219820Sjeff size_t size, void *cpu_addr, 2118219820Sjeff u64 dma_handle) 2119219820Sjeff{ 2120219820Sjeff if (dev->dma_ops) 2121219820Sjeff dev->dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 2122219820Sjeff else 2123219820Sjeff dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle); 2124219820Sjeff} 2125219820Sjeff 2126219820Sjeff/** 2127219820Sjeff * ib_reg_phys_mr - Prepares a virtually addressed memory region for use 2128219820Sjeff * by an HCA. 2129219820Sjeff * @pd: The protection domain associated assigned to the registered region. 2130219820Sjeff * @phys_buf_array: Specifies a list of physical buffers to use in the 2131219820Sjeff * memory region. 2132219820Sjeff * @num_phys_buf: Specifies the size of the phys_buf_array. 2133219820Sjeff * @mr_access_flags: Specifies the memory access rights. 2134219820Sjeff * @iova_start: The offset of the region's starting I/O virtual address. 2135219820Sjeff */ 2136219820Sjeffstruct ib_mr *ib_reg_phys_mr(struct ib_pd *pd, 2137219820Sjeff struct ib_phys_buf *phys_buf_array, 2138219820Sjeff int num_phys_buf, 2139219820Sjeff int mr_access_flags, 2140219820Sjeff u64 *iova_start); 2141219820Sjeff 2142219820Sjeff/** 2143219820Sjeff * ib_rereg_phys_mr - Modifies the attributes of an existing memory region. 2144219820Sjeff * Conceptually, this call performs the functions deregister memory region 2145219820Sjeff * followed by register physical memory region. Where possible, 2146219820Sjeff * resources are reused instead of deallocated and reallocated. 2147219820Sjeff * @mr: The memory region to modify. 2148219820Sjeff * @mr_rereg_mask: A bit-mask used to indicate which of the following 2149219820Sjeff * properties of the memory region are being modified. 2150219820Sjeff * @pd: If %IB_MR_REREG_PD is set in mr_rereg_mask, this field specifies 2151219820Sjeff * the new protection domain to associated with the memory region, 2152219820Sjeff * otherwise, this parameter is ignored. 2153219820Sjeff * @phys_buf_array: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this 2154219820Sjeff * field specifies a list of physical buffers to use in the new 2155219820Sjeff * translation, otherwise, this parameter is ignored. 2156219820Sjeff * @num_phys_buf: If %IB_MR_REREG_TRANS is set in mr_rereg_mask, this 2157219820Sjeff * field specifies the size of the phys_buf_array, otherwise, this 2158219820Sjeff * parameter is ignored. 2159219820Sjeff * @mr_access_flags: If %IB_MR_REREG_ACCESS is set in mr_rereg_mask, this 2160219820Sjeff * field specifies the new memory access rights, otherwise, this 2161219820Sjeff * parameter is ignored. 2162219820Sjeff * @iova_start: The offset of the region's starting I/O virtual address. 2163219820Sjeff */ 2164219820Sjeffint ib_rereg_phys_mr(struct ib_mr *mr, 2165219820Sjeff int mr_rereg_mask, 2166219820Sjeff struct ib_pd *pd, 2167219820Sjeff struct ib_phys_buf *phys_buf_array, 2168219820Sjeff int num_phys_buf, 2169219820Sjeff int mr_access_flags, 2170219820Sjeff u64 *iova_start); 2171219820Sjeff 2172219820Sjeff/** 2173219820Sjeff * ib_query_mr - Retrieves information about a specific memory region. 2174219820Sjeff * @mr: The memory region to retrieve information about. 2175219820Sjeff * @mr_attr: The attributes of the specified memory region. 2176219820Sjeff */ 2177219820Sjeffint ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr); 2178219820Sjeff 2179219820Sjeff/** 2180219820Sjeff * ib_dereg_mr - Deregisters a memory region and removes it from the 2181219820Sjeff * HCA translation table. 2182219820Sjeff * @mr: The memory region to deregister. 2183219820Sjeff */ 2184219820Sjeffint ib_dereg_mr(struct ib_mr *mr); 2185219820Sjeff 2186219820Sjeff/** 2187219820Sjeff * ib_alloc_fast_reg_mr - Allocates memory region usable with the 2188219820Sjeff * IB_WR_FAST_REG_MR send work request. 2189219820Sjeff * @pd: The protection domain associated with the region. 2190219820Sjeff * @max_page_list_len: requested max physical buffer list length to be 2191219820Sjeff * used with fast register work requests for this MR. 2192219820Sjeff */ 2193219820Sjeffstruct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); 2194219820Sjeff 2195219820Sjeff/** 2196219820Sjeff * ib_alloc_fast_reg_page_list - Allocates a page list array 2197219820Sjeff * @device - ib device pointer. 2198219820Sjeff * @page_list_len - size of the page list array to be allocated. 2199219820Sjeff * 2200219820Sjeff * This allocates and returns a struct ib_fast_reg_page_list * and a 2201219820Sjeff * page_list array that is at least page_list_len in size. The actual 2202219820Sjeff * size is returned in max_page_list_len. The caller is responsible 2203219820Sjeff * for initializing the contents of the page_list array before posting 2204219820Sjeff * a send work request with the IB_WC_FAST_REG_MR opcode. 2205219820Sjeff * 2206219820Sjeff * The page_list array entries must be translated using one of the 2207219820Sjeff * ib_dma_*() functions just like the addresses passed to 2208219820Sjeff * ib_map_phys_fmr(). Once the ib_post_send() is issued, the struct 2209219820Sjeff * ib_fast_reg_page_list must not be modified by the caller until the 2210219820Sjeff * IB_WC_FAST_REG_MR work request completes. 2211219820Sjeff */ 2212219820Sjeffstruct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list( 2213219820Sjeff struct ib_device *device, int page_list_len); 2214219820Sjeff 2215219820Sjeff/** 2216219820Sjeff * ib_free_fast_reg_page_list - Deallocates a previously allocated 2217219820Sjeff * page list array. 2218219820Sjeff * @page_list - struct ib_fast_reg_page_list pointer to be deallocated. 2219219820Sjeff */ 2220219820Sjeffvoid ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list); 2221219820Sjeff 2222219820Sjeff/** 2223219820Sjeff * ib_update_fast_reg_key - updates the key portion of the fast_reg MR 2224219820Sjeff * R_Key and L_Key. 2225219820Sjeff * @mr - struct ib_mr pointer to be updated. 2226219820Sjeff * @newkey - new key to be used. 2227219820Sjeff */ 2228219820Sjeffstatic inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey) 2229219820Sjeff{ 2230219820Sjeff mr->lkey = (mr->lkey & 0xffffff00) | newkey; 2231219820Sjeff mr->rkey = (mr->rkey & 0xffffff00) | newkey; 2232219820Sjeff} 2233219820Sjeff 2234219820Sjeff/** 2235219820Sjeff * ib_alloc_mw - Allocates a memory window. 2236219820Sjeff * @pd: The protection domain associated with the memory window. 2237219820Sjeff */ 2238219820Sjeffstruct ib_mw *ib_alloc_mw(struct ib_pd *pd); 2239219820Sjeff 2240219820Sjeff/** 2241219820Sjeff * ib_bind_mw - Posts a work request to the send queue of the specified 2242219820Sjeff * QP, which binds the memory window to the given address range and 2243219820Sjeff * remote access attributes. 2244219820Sjeff * @qp: QP to post the bind work request on. 2245219820Sjeff * @mw: The memory window to bind. 2246219820Sjeff * @mw_bind: Specifies information about the memory window, including 2247219820Sjeff * its address range, remote access rights, and associated memory region. 2248219820Sjeff */ 2249219820Sjeffstatic inline int ib_bind_mw(struct ib_qp *qp, 2250219820Sjeff struct ib_mw *mw, 2251219820Sjeff struct ib_mw_bind *mw_bind) 2252219820Sjeff{ 2253219820Sjeff /* XXX reference counting in corresponding MR? */ 2254219820Sjeff return mw->device->bind_mw ? 2255219820Sjeff mw->device->bind_mw(qp, mw, mw_bind) : 2256219820Sjeff -ENOSYS; 2257219820Sjeff} 2258219820Sjeff 2259219820Sjeff/** 2260219820Sjeff * ib_dealloc_mw - Deallocates a memory window. 2261219820Sjeff * @mw: The memory window to deallocate. 2262219820Sjeff */ 2263219820Sjeffint ib_dealloc_mw(struct ib_mw *mw); 2264219820Sjeff 2265219820Sjeff/** 2266219820Sjeff * ib_alloc_fmr - Allocates a unmapped fast memory region. 2267219820Sjeff * @pd: The protection domain associated with the unmapped region. 2268219820Sjeff * @mr_access_flags: Specifies the memory access rights. 2269219820Sjeff * @fmr_attr: Attributes of the unmapped region. 2270219820Sjeff * 2271219820Sjeff * A fast memory region must be mapped before it can be used as part of 2272219820Sjeff * a work request. 2273219820Sjeff */ 2274219820Sjeffstruct ib_fmr *ib_alloc_fmr(struct ib_pd *pd, 2275219820Sjeff int mr_access_flags, 2276219820Sjeff struct ib_fmr_attr *fmr_attr); 2277219820Sjeff 2278219820Sjeff/** 2279219820Sjeff * ib_map_phys_fmr - Maps a list of physical pages to a fast memory region. 2280219820Sjeff * @fmr: The fast memory region to associate with the pages. 2281219820Sjeff * @page_list: An array of physical pages to map to the fast memory region. 2282219820Sjeff * @list_len: The number of pages in page_list. 2283219820Sjeff * @iova: The I/O virtual address to use with the mapped region. 2284219820Sjeff */ 2285219820Sjeffstatic inline int ib_map_phys_fmr(struct ib_fmr *fmr, 2286219820Sjeff u64 *page_list, int list_len, 2287219820Sjeff u64 iova) 2288219820Sjeff{ 2289219820Sjeff return fmr->device->map_phys_fmr(fmr, page_list, list_len, iova); 2290219820Sjeff} 2291219820Sjeff 2292219820Sjeff/** 2293219820Sjeff * ib_unmap_fmr - Removes the mapping from a list of fast memory regions. 2294219820Sjeff * @fmr_list: A linked list of fast memory regions to unmap. 2295219820Sjeff */ 2296219820Sjeffint ib_unmap_fmr(struct list_head *fmr_list); 2297219820Sjeff 2298219820Sjeff/** 2299219820Sjeff * ib_dealloc_fmr - Deallocates a fast memory region. 2300219820Sjeff * @fmr: The fast memory region to deallocate. 2301219820Sjeff */ 2302219820Sjeffint ib_dealloc_fmr(struct ib_fmr *fmr); 2303219820Sjeff 2304219820Sjeff/** 2305219820Sjeff * ib_attach_mcast - Attaches the specified QP to a multicast group. 2306219820Sjeff * @qp: QP to attach to the multicast group. The QP must be type 2307219820Sjeff * IB_QPT_UD. 2308219820Sjeff * @gid: Multicast group GID. 2309219820Sjeff * @lid: Multicast group LID in host byte order. 2310219820Sjeff * 2311219820Sjeff * In order to send and receive multicast packets, subnet 2312219820Sjeff * administration must have created the multicast group and configured 2313219820Sjeff * the fabric appropriately. The port associated with the specified 2314219820Sjeff * QP must also be a member of the multicast group. 2315219820Sjeff */ 2316219820Sjeffint ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 2317219820Sjeff 2318219820Sjeff/** 2319219820Sjeff * ib_detach_mcast - Detaches the specified QP from a multicast group. 2320219820Sjeff * @qp: QP to detach from the multicast group. 2321219820Sjeff * @gid: Multicast group GID. 2322219820Sjeff * @lid: Multicast group LID in host byte order. 2323219820Sjeff */ 2324219820Sjeffint ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid); 2325219820Sjeff 2326219820Sjeff/** 2327255932Salfred * ib_alloc_xrcd - Allocates an XRC domain. 2328255932Salfred * @device: The device on which to allocate the XRC domain. 2329219820Sjeff */ 2330255932Salfredstruct ib_xrcd *ib_alloc_xrcd(struct ib_device *device); 2331219820Sjeff 2332219820Sjeff/** 2333255932Salfred * ib_dealloc_xrcd - Deallocates an XRC domain. 2334255932Salfred * @xrcd: The XRC domain to deallocate. 2335219820Sjeff */ 2336255932Salfredint ib_dealloc_xrcd(struct ib_xrcd *xrcd); 2337219820Sjeff 2338255932Salfredint ib_attach_flow(struct ib_qp *qp, struct ib_flow_spec *spec, int priority); 2339255932Salfredint ib_detach_flow(struct ib_qp *qp, struct ib_flow_spec *spec, int priority); 2340255932Salfred 2341219820Sjeff#endif /* IB_VERBS_H */ 2342