Changeset View
Changeset View
Standalone View
Standalone View
contrib/ofed/libibverbs/include/infiniband/verbs.h
/* | /* | ||||
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. | * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. | ||||
* Copyright (c) 2004 Intel Corporation. All rights reserved. | * Copyright (c) 2004, 2011-2012 Intel Corporation. All rights reserved. | ||||
* Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. | * Copyright (c) 2005, 2006, 2007 Cisco Systems, Inc. All rights reserved. | ||||
* Copyright (c) 2005 PathScale, Inc. All rights reserved. | * Copyright (c) 2005 PathScale, Inc. All rights reserved. | ||||
* | * | ||||
* This software is available to you under a choice of one of two | * This software is available to you under a choice of one of two | ||||
* licenses. You may choose to be licensed under the terms of the GNU | * licenses. You may choose to be licensed under the terms of the GNU | ||||
* General Public License (GPL) Version 2, available from the file | * General Public License (GPL) Version 2, available from the file | ||||
* COPYING in the main directory of this source tree, or the | * COPYING in the main directory of this source tree, or the | ||||
* OpenIB.org BSD license below: | * OpenIB.org BSD license below: | ||||
Show All 21 Lines | |||||
* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#ifndef INFINIBAND_VERBS_H | #ifndef INFINIBAND_VERBS_H | ||||
#define INFINIBAND_VERBS_H | #define INFINIBAND_VERBS_H | ||||
#include <stdint.h> | #include <stdint.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <stddef.h> | |||||
#include <errno.h> | |||||
#include <infiniband/ofa_verbs.h> | |||||
#ifdef __cplusplus | #ifdef __cplusplus | ||||
# define BEGIN_C_DECLS extern "C" { | # define BEGIN_C_DECLS extern "C" { | ||||
# define END_C_DECLS } | # define END_C_DECLS } | ||||
#else /* !__cplusplus */ | #else /* !__cplusplus */ | ||||
# define BEGIN_C_DECLS | # define BEGIN_C_DECLS | ||||
# define END_C_DECLS | # define END_C_DECLS | ||||
#endif /* __cplusplus */ | #endif /* __cplusplus */ | ||||
Show All 9 Lines | |||||
union ibv_gid { | union ibv_gid { | ||||
uint8_t raw[16]; | uint8_t raw[16]; | ||||
struct { | struct { | ||||
uint64_t subnet_prefix; | uint64_t subnet_prefix; | ||||
uint64_t interface_id; | uint64_t interface_id; | ||||
} global; | } global; | ||||
}; | }; | ||||
#ifndef container_of | |||||
/** | |||||
* container_of - cast a member of a structure out to the containing structure | |||||
* @ptr: the pointer to the member. | |||||
* @type: the type of the container struct this is embedded in. | |||||
* @member: the name of the member within the struct. | |||||
* | |||||
*/ | |||||
#define container_of(ptr, type, member) \ | |||||
((type *) ((uint8_t *)(ptr) - offsetof(type, member))) | |||||
#endif | |||||
#define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz)) | |||||
static void *__VERBS_ABI_IS_EXTENDED = ((uint8_t *)NULL) - 1; | |||||
enum ibv_node_type { | enum ibv_node_type { | ||||
IBV_NODE_UNKNOWN = -1, | IBV_NODE_UNKNOWN = -1, | ||||
IBV_NODE_CA = 1, | IBV_NODE_CA = 1, | ||||
IBV_NODE_SWITCH, | IBV_NODE_SWITCH, | ||||
IBV_NODE_ROUTER, | IBV_NODE_ROUTER, | ||||
IBV_NODE_RNIC | IBV_NODE_RNIC, | ||||
/* Leave a gap for future node types before starting with | |||||
* experimental node types. | |||||
*/ | |||||
IBV_EXP_NODE_TYPE_START = 32, | |||||
IBV_EXP_NODE_MIC = IBV_EXP_NODE_TYPE_START | |||||
}; | }; | ||||
enum ibv_transport_type { | enum ibv_transport_type { | ||||
IBV_TRANSPORT_UNKNOWN = -1, | IBV_TRANSPORT_UNKNOWN = -1, | ||||
IBV_TRANSPORT_IB = 0, | IBV_TRANSPORT_IB = 0, | ||||
IBV_TRANSPORT_IWARP | IBV_TRANSPORT_IWARP, | ||||
/* Leave a gap for future transport types before starting with | |||||
* experimental transport types. | |||||
*/ | |||||
IBV_EXP_TRANSPORT_TYPE_START = 32, | |||||
IBV_EXP_TRANSPORT_SCIF = IBV_EXP_TRANSPORT_TYPE_START | |||||
}; | }; | ||||
enum ibv_device_cap_flags { | enum ibv_device_cap_flags { | ||||
IBV_DEVICE_RESIZE_MAX_WR = 1, | IBV_DEVICE_RESIZE_MAX_WR = 1, | ||||
IBV_DEVICE_BAD_PKEY_CNTR = 1 << 1, | IBV_DEVICE_BAD_PKEY_CNTR = 1 << 1, | ||||
IBV_DEVICE_BAD_QKEY_CNTR = 1 << 2, | IBV_DEVICE_BAD_QKEY_CNTR = 1 << 2, | ||||
IBV_DEVICE_RAW_MULTI = 1 << 3, | IBV_DEVICE_RAW_MULTI = 1 << 3, | ||||
IBV_DEVICE_AUTO_PATH_MIG = 1 << 4, | IBV_DEVICE_AUTO_PATH_MIG = 1 << 4, | ||||
IBV_DEVICE_CHANGE_PHY_PORT = 1 << 5, | IBV_DEVICE_CHANGE_PHY_PORT = 1 << 5, | ||||
IBV_DEVICE_UD_AV_PORT_ENFORCE = 1 << 6, | IBV_DEVICE_UD_AV_PORT_ENFORCE = 1 << 6, | ||||
IBV_DEVICE_CURR_QP_STATE_MOD = 1 << 7, | IBV_DEVICE_CURR_QP_STATE_MOD = 1 << 7, | ||||
IBV_DEVICE_SHUTDOWN_PORT = 1 << 8, | IBV_DEVICE_SHUTDOWN_PORT = 1 << 8, | ||||
IBV_DEVICE_INIT_TYPE = 1 << 9, | IBV_DEVICE_INIT_TYPE = 1 << 9, | ||||
IBV_DEVICE_PORT_ACTIVE_EVENT = 1 << 10, | IBV_DEVICE_PORT_ACTIVE_EVENT = 1 << 10, | ||||
IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11, | IBV_DEVICE_SYS_IMAGE_GUID = 1 << 11, | ||||
IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12, | IBV_DEVICE_RC_RNR_NAK_GEN = 1 << 12, | ||||
IBV_DEVICE_SRQ_RESIZE = 1 << 13, | IBV_DEVICE_SRQ_RESIZE = 1 << 13, | ||||
IBV_DEVICE_N_NOTIFY_CQ = 1 << 14, | IBV_DEVICE_N_NOTIFY_CQ = 1 << 14, | ||||
IBV_DEVICE_XRC = 1 << 20 | IBV_DEVICE_XRC = 1 << 20, | ||||
IBV_DEVICE_MANAGED_FLOW_STEERING = 1 << 29 | |||||
}; | }; | ||||
enum ibv_atomic_cap { | enum ibv_atomic_cap { | ||||
IBV_ATOMIC_NONE, | IBV_ATOMIC_NONE, | ||||
IBV_ATOMIC_HCA, | IBV_ATOMIC_HCA, | ||||
IBV_ATOMIC_GLOB | IBV_ATOMIC_GLOB | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | enum ibv_port_state { | ||||
IBV_PORT_ACTIVE = 4, | IBV_PORT_ACTIVE = 4, | ||||
IBV_PORT_ACTIVE_DEFER = 5 | IBV_PORT_ACTIVE_DEFER = 5 | ||||
}; | }; | ||||
enum { | enum { | ||||
IBV_LINK_LAYER_UNSPECIFIED, | IBV_LINK_LAYER_UNSPECIFIED, | ||||
IBV_LINK_LAYER_INFINIBAND, | IBV_LINK_LAYER_INFINIBAND, | ||||
IBV_LINK_LAYER_ETHERNET, | IBV_LINK_LAYER_ETHERNET, | ||||
/* Leave a gap for future link layer types before starting with | |||||
* experimental link layer. | |||||
*/ | |||||
IBV_EXP_LINK_LAYER_START = 32, | |||||
IBV_EXP_LINK_LAYER_SCIF = IBV_EXP_LINK_LAYER_START | |||||
}; | }; | ||||
enum ibv_port_cap_flags { | |||||
IBV_PORT_SM = 1 << 1, | |||||
IBV_PORT_NOTICE_SUP = 1 << 2, | |||||
IBV_PORT_TRAP_SUP = 1 << 3, | |||||
IBV_PORT_OPT_IPD_SUP = 1 << 4, | |||||
IBV_PORT_AUTO_MIGR_SUP = 1 << 5, | |||||
IBV_PORT_SL_MAP_SUP = 1 << 6, | |||||
IBV_PORT_MKEY_NVRAM = 1 << 7, | |||||
IBV_PORT_PKEY_NVRAM = 1 << 8, | |||||
IBV_PORT_LED_INFO_SUP = 1 << 9, | |||||
IBV_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, | |||||
IBV_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, | |||||
IBV_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, | |||||
IBV_PORT_CM_SUP = 1 << 16, | |||||
IBV_PORT_SNMP_TUNNEL_SUP = 1 << 17, | |||||
IBV_PORT_REINIT_SUP = 1 << 18, | |||||
IBV_PORT_DEVICE_MGMT_SUP = 1 << 19, | |||||
IBV_PORT_VENDOR_CLASS = 1 << 24, | |||||
IBV_PORT_CLIENT_REG_SUP = 1 << 25, | |||||
IBV_PORT_IP_BASED_GIDS = 1 << 26, | |||||
}; | |||||
struct ibv_port_attr { | struct ibv_port_attr { | ||||
enum ibv_port_state state; | enum ibv_port_state state; | ||||
enum ibv_mtu max_mtu; | enum ibv_mtu max_mtu; | ||||
enum ibv_mtu active_mtu; | enum ibv_mtu active_mtu; | ||||
int gid_tbl_len; | int gid_tbl_len; | ||||
uint32_t port_cap_flags; | uint32_t port_cap_flags; | ||||
uint32_t max_msg_sz; | uint32_t max_msg_sz; | ||||
uint32_t bad_pkey_cntr; | uint32_t bad_pkey_cntr; | ||||
uint32_t qkey_viol_cntr; | uint32_t qkey_viol_cntr; | ||||
uint16_t pkey_tbl_len; | uint16_t pkey_tbl_len; | ||||
uint16_t lid; | uint16_t lid; | ||||
uint16_t sm_lid; | uint16_t sm_lid; | ||||
uint8_t lmc; | uint8_t lmc; | ||||
uint8_t max_vl_num; | uint8_t max_vl_num; | ||||
uint8_t sm_sl; | uint8_t sm_sl; | ||||
uint8_t subnet_timeout; | uint8_t subnet_timeout; | ||||
uint8_t init_type_reply; | uint8_t init_type_reply; | ||||
uint8_t active_width; | uint8_t active_width; | ||||
uint8_t active_speed; | uint8_t active_speed; | ||||
uint8_t phys_state; | uint8_t phys_state; | ||||
uint8_t link_layer; | uint8_t link_layer; | ||||
uint8_t pad; | uint8_t reserved; | ||||
}; | }; | ||||
enum ibv_event_type { | enum ibv_event_type { | ||||
IBV_EVENT_CQ_ERR, | IBV_EVENT_CQ_ERR, | ||||
IBV_EVENT_QP_FATAL, | IBV_EVENT_QP_FATAL, | ||||
IBV_EVENT_QP_REQ_ERR, | IBV_EVENT_QP_REQ_ERR, | ||||
IBV_EVENT_QP_ACCESS_ERR, | IBV_EVENT_QP_ACCESS_ERR, | ||||
IBV_EVENT_COMM_EST, | IBV_EVENT_COMM_EST, | ||||
IBV_EVENT_SQ_DRAINED, | IBV_EVENT_SQ_DRAINED, | ||||
IBV_EVENT_PATH_MIG, | IBV_EVENT_PATH_MIG, | ||||
IBV_EVENT_PATH_MIG_ERR, | IBV_EVENT_PATH_MIG_ERR, | ||||
IBV_EVENT_DEVICE_FATAL, | IBV_EVENT_DEVICE_FATAL, | ||||
IBV_EVENT_PORT_ACTIVE, | IBV_EVENT_PORT_ACTIVE, | ||||
IBV_EVENT_PORT_ERR, | IBV_EVENT_PORT_ERR, | ||||
IBV_EVENT_LID_CHANGE, | IBV_EVENT_LID_CHANGE, | ||||
IBV_EVENT_PKEY_CHANGE, | IBV_EVENT_PKEY_CHANGE, | ||||
IBV_EVENT_SM_CHANGE, | IBV_EVENT_SM_CHANGE, | ||||
IBV_EVENT_SRQ_ERR, | IBV_EVENT_SRQ_ERR, | ||||
IBV_EVENT_SRQ_LIMIT_REACHED, | IBV_EVENT_SRQ_LIMIT_REACHED, | ||||
IBV_EVENT_QP_LAST_WQE_REACHED, | IBV_EVENT_QP_LAST_WQE_REACHED, | ||||
IBV_EVENT_CLIENT_REREGISTER, | IBV_EVENT_CLIENT_REREGISTER, | ||||
IBV_EVENT_GID_CHANGE, | IBV_EVENT_GID_CHANGE, | ||||
}; | |||||
enum ibv_event_flags { | /* new experimental events start here leaving enough | ||||
IBV_XRC_QP_EVENT_FLAG = 0x80000000, | * room for 14 events which should be enough | ||||
*/ | |||||
IBV_EXP_EVENT_DCT_KEY_VIOLATION = 32, | |||||
IBV_EXP_EVENT_DCT_ACCESS_ERR, | |||||
IBV_EXP_EVENT_DCT_REQ_ERR, | |||||
}; | }; | ||||
struct ibv_async_event { | struct ibv_async_event { | ||||
union { | union { | ||||
struct ibv_cq *cq; | struct ibv_cq *cq; | ||||
struct ibv_qp *qp; | struct ibv_qp *qp; | ||||
struct ibv_srq *srq; | struct ibv_srq *srq; | ||||
struct ibv_exp_dct *dct; | |||||
int port_num; | int port_num; | ||||
/* For source compatible with Legacy API */ | |||||
uint32_t xrc_qp_num; | uint32_t xrc_qp_num; | ||||
} element; | } element; | ||||
enum ibv_event_type event_type; | enum ibv_event_type event_type; | ||||
}; | }; | ||||
enum ibv_wc_status { | enum ibv_wc_status { | ||||
IBV_WC_SUCCESS, | IBV_WC_SUCCESS, | ||||
IBV_WC_LOC_LEN_ERR, | IBV_WC_LOC_LEN_ERR, | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | enum ibv_access_flags { | ||||
IBV_ACCESS_MW_BIND = (1<<4) | IBV_ACCESS_MW_BIND = (1<<4) | ||||
}; | }; | ||||
struct ibv_pd { | struct ibv_pd { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
uint32_t handle; | uint32_t handle; | ||||
}; | }; | ||||
enum ibv_xrcd_init_attr_mask { | |||||
IBV_XRCD_INIT_ATTR_FD = 1 << 0, | |||||
IBV_XRCD_INIT_ATTR_OFLAGS = 1 << 1, | |||||
IBV_XRCD_INIT_ATTR_RESERVED = 1 << 2 | |||||
}; | |||||
struct ibv_xrcd_init_attr { | |||||
uint32_t comp_mask; | |||||
int fd; | |||||
int oflags; | |||||
}; | |||||
struct ibv_xrcd { | |||||
struct ibv_context *context; | |||||
}; | |||||
enum ibv_rereg_mr_flags { | enum ibv_rereg_mr_flags { | ||||
IBV_REREG_MR_CHANGE_TRANSLATION = (1 << 0), | IBV_REREG_MR_CHANGE_TRANSLATION = (1 << 0), | ||||
IBV_REREG_MR_CHANGE_PD = (1 << 1), | IBV_REREG_MR_CHANGE_PD = (1 << 1), | ||||
IBV_REREG_MR_CHANGE_ACCESS = (1 << 2), | IBV_REREG_MR_CHANGE_ACCESS = (1 << 2), | ||||
IBV_REREG_MR_KEEP_VALID = (1 << 3) | IBV_REREG_MR_KEEP_VALID = (1 << 3) | ||||
}; | }; | ||||
struct ibv_mr { | struct ibv_mr { | ||||
Show All 39 Lines | enum ibv_rate { | ||||
IBV_RATE_2_5_GBPS = 2, | IBV_RATE_2_5_GBPS = 2, | ||||
IBV_RATE_5_GBPS = 5, | IBV_RATE_5_GBPS = 5, | ||||
IBV_RATE_10_GBPS = 3, | IBV_RATE_10_GBPS = 3, | ||||
IBV_RATE_20_GBPS = 6, | IBV_RATE_20_GBPS = 6, | ||||
IBV_RATE_30_GBPS = 4, | IBV_RATE_30_GBPS = 4, | ||||
IBV_RATE_40_GBPS = 7, | IBV_RATE_40_GBPS = 7, | ||||
IBV_RATE_60_GBPS = 8, | IBV_RATE_60_GBPS = 8, | ||||
IBV_RATE_80_GBPS = 9, | IBV_RATE_80_GBPS = 9, | ||||
IBV_RATE_120_GBPS = 10 | IBV_RATE_120_GBPS = 10, | ||||
IBV_RATE_14_GBPS = 11, | |||||
IBV_RATE_56_GBPS = 12, | |||||
IBV_RATE_112_GBPS = 13, | |||||
IBV_RATE_168_GBPS = 14, | |||||
IBV_RATE_25_GBPS = 15, | |||||
IBV_RATE_100_GBPS = 16, | |||||
IBV_RATE_200_GBPS = 17, | |||||
IBV_RATE_300_GBPS = 18 | |||||
}; | }; | ||||
/** | /** | ||||
* ibv_rate_to_mult - Convert the IB rate enum to a multiple of the | * ibv_rate_to_mult - Convert the IB rate enum to a multiple of the | ||||
* base rate of 2.5 Gbit/sec. For example, IBV_RATE_5_GBPS will be | * base rate of 2.5 Gbit/sec. For example, IBV_RATE_5_GBPS will be | ||||
* converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. | * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec. | ||||
* @rate: rate to convert. | * @rate: rate to convert. | ||||
*/ | */ | ||||
int ibv_rate_to_mult(enum ibv_rate rate) __attribute_const; | int ibv_rate_to_mult(enum ibv_rate rate) __attribute_const; | ||||
/** | /** | ||||
* mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate enum. | * mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate enum. | ||||
* @mult: multiple to convert. | * @mult: multiple to convert. | ||||
*/ | */ | ||||
enum ibv_rate mult_to_ibv_rate(int mult) __attribute_const; | enum ibv_rate mult_to_ibv_rate(int mult) __attribute_const; | ||||
/** | |||||
* ibv_rate_to_mbps - Convert the IB rate enum to Mbit/sec. | |||||
* For example, IBV_RATE_5_GBPS will return the value 5000. | |||||
* @rate: rate to convert. | |||||
*/ | |||||
int ibv_rate_to_mbps(enum ibv_rate rate) __attribute_const; | |||||
/** | |||||
* mbps_to_ibv_rate - Convert a Mbit/sec value to an IB rate enum. | |||||
* @mbps: value to convert. | |||||
*/ | |||||
enum ibv_rate mbps_to_ibv_rate(int mbps) __attribute_const; | |||||
struct ibv_ah_attr { | struct ibv_ah_attr { | ||||
struct ibv_global_route grh; | struct ibv_global_route grh; | ||||
uint16_t dlid; | uint16_t dlid; | ||||
uint8_t sl; | uint8_t sl; | ||||
uint8_t src_path_bits; | uint8_t src_path_bits; | ||||
uint8_t static_rate; | uint8_t static_rate; | ||||
uint8_t is_global; | uint8_t is_global; | ||||
uint8_t port_num; | uint8_t port_num; | ||||
}; | }; | ||||
struct ibv_xrc_domain { | |||||
struct ibv_context *context; | |||||
uint32_t handle; | |||||
}; | |||||
enum ibv_srq_attr_mask { | enum ibv_srq_attr_mask { | ||||
IBV_SRQ_MAX_WR = 1 << 0, | IBV_SRQ_MAX_WR = 1 << 0, | ||||
IBV_SRQ_LIMIT = 1 << 1 | IBV_SRQ_LIMIT = 1 << 1 | ||||
}; | }; | ||||
struct ibv_srq_attr { | struct ibv_srq_attr { | ||||
uint32_t max_wr; | uint32_t max_wr; | ||||
uint32_t max_sge; | uint32_t max_sge; | ||||
uint32_t srq_limit; | uint32_t srq_limit; | ||||
}; | }; | ||||
struct ibv_srq_init_attr { | struct ibv_srq_init_attr { | ||||
void *srq_context; | void *srq_context; | ||||
struct ibv_srq_attr attr; | struct ibv_srq_attr attr; | ||||
}; | }; | ||||
enum ibv_srq_type { | |||||
IBV_SRQT_BASIC, | |||||
IBV_SRQT_XRC | |||||
}; | |||||
enum ibv_srq_init_attr_mask { | |||||
IBV_SRQ_INIT_ATTR_TYPE = 1 << 0, | |||||
IBV_SRQ_INIT_ATTR_PD = 1 << 1, | |||||
IBV_SRQ_INIT_ATTR_XRCD = 1 << 2, | |||||
IBV_SRQ_INIT_ATTR_CQ = 1 << 3, | |||||
IBV_SRQ_INIT_ATTR_RESERVED = 1 << 4 | |||||
}; | |||||
struct ibv_srq_init_attr_ex { | |||||
void *srq_context; | |||||
struct ibv_srq_attr attr; | |||||
uint32_t comp_mask; | |||||
enum ibv_srq_type srq_type; | |||||
struct ibv_pd *pd; | |||||
struct ibv_xrcd *xrcd; | |||||
struct ibv_cq *cq; | |||||
}; | |||||
enum ibv_qp_type { | enum ibv_qp_type { | ||||
IBV_QPT_RC = 2, | IBV_QPT_RC = 2, | ||||
IBV_QPT_UC, | IBV_QPT_UC, | ||||
IBV_QPT_UD, | IBV_QPT_UD, | ||||
/* XRC compatible code */ | |||||
IBV_QPT_XRC, | IBV_QPT_XRC, | ||||
IBV_QPT_RAW_ETH = 8 | IBV_QPT_RAW_PACKET = 8, | ||||
IBV_QPT_RAW_ETH = 8, | |||||
IBV_QPT_XRC_SEND = 9, | |||||
IBV_QPT_XRC_RECV, | |||||
/* Leave a gap for future qp types before starting with | |||||
* experimental qp types. | |||||
*/ | |||||
IBV_EXP_QP_TYPE_START = 32, | |||||
IBV_EXP_QPT_DC_INI = IBV_EXP_QP_TYPE_START | |||||
}; | }; | ||||
struct ibv_qp_cap { | struct ibv_qp_cap { | ||||
uint32_t max_send_wr; | uint32_t max_send_wr; | ||||
uint32_t max_recv_wr; | uint32_t max_recv_wr; | ||||
uint32_t max_send_sge; | uint32_t max_send_sge; | ||||
uint32_t max_recv_sge; | uint32_t max_recv_sge; | ||||
uint32_t max_inline_data; | uint32_t max_inline_data; | ||||
}; | }; | ||||
struct ibv_qp_init_attr { | struct ibv_qp_init_attr { | ||||
void *qp_context; | void *qp_context; | ||||
struct ibv_cq *send_cq; | struct ibv_cq *send_cq; | ||||
struct ibv_cq *recv_cq; | struct ibv_cq *recv_cq; | ||||
struct ibv_srq *srq; | struct ibv_srq *srq; | ||||
struct ibv_qp_cap cap; | struct ibv_qp_cap cap; | ||||
enum ibv_qp_type qp_type; | enum ibv_qp_type qp_type; | ||||
int sq_sig_all; | int sq_sig_all; | ||||
/* Below is needed for backwards compatabile */ | |||||
struct ibv_xrc_domain *xrc_domain; | struct ibv_xrc_domain *xrc_domain; | ||||
}; | }; | ||||
enum ibv_qp_init_attr_mask { | |||||
IBV_QP_INIT_ATTR_PD = 1 << 0, | |||||
IBV_QP_INIT_ATTR_XRCD = 1 << 1, | |||||
IBV_QP_INIT_ATTR_RESERVED = 1 << 2 | |||||
}; | |||||
struct ibv_qp_init_attr_ex { | |||||
void *qp_context; | |||||
struct ibv_cq *send_cq; | |||||
struct ibv_cq *recv_cq; | |||||
struct ibv_srq *srq; | |||||
struct ibv_qp_cap cap; | |||||
enum ibv_qp_type qp_type; | |||||
int sq_sig_all; | |||||
uint32_t comp_mask; | |||||
struct ibv_pd *pd; | |||||
struct ibv_xrcd *xrcd; | |||||
}; | |||||
enum ibv_qp_open_attr_mask { | |||||
IBV_QP_OPEN_ATTR_NUM = 1 << 0, | |||||
IBV_QP_OPEN_ATTR_XRCD = 1 << 1, | |||||
IBV_QP_OPEN_ATTR_CONTEXT = 1 << 2, | |||||
IBV_QP_OPEN_ATTR_TYPE = 1 << 3, | |||||
IBV_QP_OPEN_ATTR_RESERVED = 1 << 4 | |||||
}; | |||||
struct ibv_qp_open_attr { | |||||
uint32_t comp_mask; | |||||
uint32_t qp_num; | |||||
struct ibv_xrcd *xrcd; | |||||
void *qp_context; | |||||
enum ibv_qp_type qp_type; | |||||
}; | |||||
enum ibv_qp_attr_mask { | enum ibv_qp_attr_mask { | ||||
IBV_QP_STATE = 1 << 0, | IBV_QP_STATE = 1 << 0, | ||||
IBV_QP_CUR_STATE = 1 << 1, | IBV_QP_CUR_STATE = 1 << 1, | ||||
IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2, | IBV_QP_EN_SQD_ASYNC_NOTIFY = 1 << 2, | ||||
IBV_QP_ACCESS_FLAGS = 1 << 3, | IBV_QP_ACCESS_FLAGS = 1 << 3, | ||||
IBV_QP_PKEY_INDEX = 1 << 4, | IBV_QP_PKEY_INDEX = 1 << 4, | ||||
IBV_QP_PORT = 1 << 5, | IBV_QP_PORT = 1 << 5, | ||||
IBV_QP_QKEY = 1 << 6, | IBV_QP_QKEY = 1 << 6, | ||||
Show All 15 Lines | |||||
enum ibv_qp_state { | enum ibv_qp_state { | ||||
IBV_QPS_RESET, | IBV_QPS_RESET, | ||||
IBV_QPS_INIT, | IBV_QPS_INIT, | ||||
IBV_QPS_RTR, | IBV_QPS_RTR, | ||||
IBV_QPS_RTS, | IBV_QPS_RTS, | ||||
IBV_QPS_SQD, | IBV_QPS_SQD, | ||||
IBV_QPS_SQE, | IBV_QPS_SQE, | ||||
IBV_QPS_ERR | IBV_QPS_ERR, | ||||
IBV_QPS_UNKNOWN | |||||
}; | }; | ||||
enum ibv_mig_state { | enum ibv_mig_state { | ||||
IBV_MIG_MIGRATED, | IBV_MIG_MIGRATED, | ||||
IBV_MIG_REARM, | IBV_MIG_REARM, | ||||
IBV_MIG_ARMED | IBV_MIG_ARMED | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | struct { | ||||
uint32_t rkey; | uint32_t rkey; | ||||
} atomic; | } atomic; | ||||
struct { | struct { | ||||
struct ibv_ah *ah; | struct ibv_ah *ah; | ||||
uint32_t remote_qpn; | uint32_t remote_qpn; | ||||
uint32_t remote_qkey; | uint32_t remote_qkey; | ||||
} ud; | } ud; | ||||
} wr; | } wr; | ||||
union { | |||||
union { | |||||
struct { | |||||
uint32_t remote_srqn; | |||||
} xrc; | |||||
} qp_type; | |||||
uint32_t xrc_remote_srq_num; | uint32_t xrc_remote_srq_num; | ||||
}; | }; | ||||
}; | |||||
struct ibv_recv_wr { | struct ibv_recv_wr { | ||||
uint64_t wr_id; | uint64_t wr_id; | ||||
struct ibv_recv_wr *next; | struct ibv_recv_wr *next; | ||||
struct ibv_sge *sg_list; | struct ibv_sge *sg_list; | ||||
int num_sge; | int num_sge; | ||||
}; | }; | ||||
struct ibv_mw_bind { | struct ibv_mw_bind { | ||||
uint64_t wr_id; | uint64_t wr_id; | ||||
struct ibv_mr *mr; | struct ibv_mr *mr; | ||||
void *addr; | void *addr; | ||||
size_t length; | size_t length; | ||||
int send_flags; | int send_flags; | ||||
int mw_access_flags; | int mw_access_flags; | ||||
}; | }; | ||||
struct ibv_srq { | struct ibv_srq { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
void *srq_context; | void *srq_context; | ||||
struct ibv_pd *pd; | struct ibv_pd *pd; | ||||
uint32_t handle; | uint32_t handle; | ||||
pthread_mutex_t mutex; | |||||
pthread_cond_t cond; | |||||
uint32_t events_completed; | uint32_t events_completed; | ||||
/* below are for source compatabilty with legacy XRC, | |||||
* padding based on ibv_srq_legacy. | |||||
*/ | |||||
uint32_t xrc_srq_num_bin_compat_padding; | |||||
struct ibv_xrc_domain *xrc_domain_bin_compat_padding; | |||||
struct ibv_cq *xrc_cq_bin_compat_padding; | |||||
void *ibv_srq_padding; | |||||
/* legacy fields */ | |||||
uint32_t xrc_srq_num; | uint32_t xrc_srq_num; | ||||
struct ibv_xrc_domain *xrc_domain; | struct ibv_xrc_domain *xrc_domain; | ||||
struct ibv_cq *xrc_cq; | struct ibv_cq *xrc_cq; | ||||
}; | |||||
pthread_mutex_t mutex; | /* Not in use in new API, needed for compilation as part of source compat layer */ | ||||
pthread_cond_t cond; | enum ibv_event_flags { | ||||
IBV_XRC_QP_EVENT_FLAG = 0x80000000, | |||||
}; | }; | ||||
struct ibv_qp { | struct ibv_qp { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
void *qp_context; | void *qp_context; | ||||
struct ibv_pd *pd; | struct ibv_pd *pd; | ||||
struct ibv_cq *send_cq; | struct ibv_cq *send_cq; | ||||
struct ibv_cq *recv_cq; | struct ibv_cq *recv_cq; | ||||
struct ibv_srq *srq; | struct ibv_srq *srq; | ||||
uint32_t handle; | uint32_t handle; | ||||
uint32_t qp_num; | uint32_t qp_num; | ||||
enum ibv_qp_state state; | enum ibv_qp_state state; | ||||
enum ibv_qp_type qp_type; | enum ibv_qp_type qp_type; | ||||
uint32_t events_completed; | |||||
struct ibv_xrc_domain *xrc_domain; | |||||
pthread_mutex_t mutex; | pthread_mutex_t mutex; | ||||
pthread_cond_t cond; | pthread_cond_t cond; | ||||
uint32_t events_completed; | |||||
}; | }; | ||||
struct ibv_comp_channel { | struct ibv_comp_channel { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
int fd; | int fd; | ||||
int refcnt; | int refcnt; | ||||
}; | }; | ||||
struct ibv_cq { | struct ibv_cq { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
struct ibv_comp_channel *channel; | struct ibv_comp_channel *channel; | ||||
void *cq_context; | void *cq_context; | ||||
uint32_t handle; | uint32_t handle; | ||||
int cqe; | int cqe; | ||||
uint32_t comp_events_completed; | |||||
uint32_t async_events_completed; | |||||
pthread_mutex_t mutex; | pthread_mutex_t mutex; | ||||
pthread_cond_t cond; | pthread_cond_t cond; | ||||
uint32_t comp_events_completed; | |||||
uint32_t async_events_completed; | |||||
}; | }; | ||||
struct ibv_ah { | struct ibv_ah { | ||||
struct ibv_context *context; | struct ibv_context *context; | ||||
struct ibv_pd *pd; | struct ibv_pd *pd; | ||||
uint32_t handle; | uint32_t handle; | ||||
}; | }; | ||||
enum ibv_flow_flags { | |||||
IBV_FLOW_ATTR_FLAGS_ALLOW_LOOP_BACK = 1, | |||||
}; | |||||
enum ibv_flow_attr_type { | |||||
/* steering according to rule specifications */ | |||||
IBV_FLOW_ATTR_NORMAL = 0x0, | |||||
/* default unicast and multicast rule - | |||||
* receive all Eth traffic which isn't steered to any QP | |||||
*/ | |||||
IBV_FLOW_ATTR_ALL_DEFAULT = 0x1, | |||||
/* default multicast rule - | |||||
* receive all Eth multicast traffic which isn't steered to any QP | |||||
*/ | |||||
IBV_FLOW_ATTR_MC_DEFAULT = 0x2, | |||||
}; | |||||
enum ibv_flow_spec_type { | |||||
IBV_FLOW_SPEC_ETH = 0x20, | |||||
IBV_FLOW_SPEC_IPV4 = 0x30, | |||||
IBV_FLOW_SPEC_TCP = 0x40, | |||||
IBV_FLOW_SPEC_UDP = 0x41, | |||||
}; | |||||
struct ibv_flow_eth_filter { | |||||
uint8_t dst_mac[6]; | |||||
uint8_t src_mac[6]; | |||||
uint16_t ether_type; | |||||
/* | |||||
* same layout as 802.1q: prio 3, cfi 1, vlan id 12 | |||||
*/ | |||||
uint16_t vlan_tag; | |||||
}; | |||||
struct ibv_flow_spec_eth { | |||||
enum ibv_flow_spec_type type; | |||||
uint16_t size; | |||||
struct ibv_flow_eth_filter val; | |||||
struct ibv_flow_eth_filter mask; | |||||
}; | |||||
struct ibv_flow_ipv4_filter { | |||||
uint32_t src_ip; | |||||
uint32_t dst_ip; | |||||
}; | |||||
struct ibv_flow_spec_ipv4 { | |||||
enum ibv_flow_spec_type type; | |||||
uint16_t size; | |||||
struct ibv_flow_ipv4_filter val; | |||||
struct ibv_flow_ipv4_filter mask; | |||||
}; | |||||
struct ibv_flow_tcp_udp_filter { | |||||
uint16_t dst_port; | |||||
uint16_t src_port; | |||||
}; | |||||
struct ibv_flow_spec_tcp_udp { | |||||
enum ibv_flow_spec_type type; | |||||
uint16_t size; | |||||
struct ibv_flow_tcp_udp_filter val; | |||||
struct ibv_flow_tcp_udp_filter mask; | |||||
}; | |||||
struct ibv_flow_spec { | |||||
union { | |||||
struct { | |||||
enum ibv_flow_spec_type type; | |||||
uint16_t size; | |||||
} hdr; | |||||
struct ibv_flow_spec_eth eth; | |||||
struct ibv_flow_spec_ipv4 ipv4; | |||||
struct ibv_flow_spec_tcp_udp tcp_udp; | |||||
}; | |||||
}; | |||||
struct ibv_flow_attr { | |||||
uint32_t comp_mask; | |||||
enum ibv_flow_attr_type type; | |||||
uint16_t size; | |||||
uint16_t priority; | |||||
uint8_t num_of_specs; | |||||
uint8_t port; | |||||
uint32_t flags; | |||||
/* Following are the optional layers according to user request | |||||
* struct ibv_flow_spec_xxx [L2] | |||||
* struct ibv_flow_spec_yyy [L3/L4] | |||||
*/ | |||||
}; | |||||
struct ibv_flow { | |||||
uint32_t comp_mask; | |||||
struct ibv_context *context; | |||||
uint32_t handle; | |||||
}; | |||||
struct ibv_device; | struct ibv_device; | ||||
struct ibv_context; | struct ibv_context; | ||||
struct ibv_device_ops { | struct ibv_device_ops { | ||||
struct ibv_context * (*alloc_context)(struct ibv_device *device, int cmd_fd); | struct ibv_context * (*alloc_context)(struct ibv_device *device, int cmd_fd); | ||||
void (*free_context)(struct ibv_context *context); | void (*free_context)(struct ibv_context *context); | ||||
}; | }; | ||||
Show All 11 Lines | struct ibv_device { | ||||
/* Name of uverbs device, eg "uverbs0" */ | /* Name of uverbs device, eg "uverbs0" */ | ||||
char dev_name[IBV_SYSFS_NAME_MAX]; | char dev_name[IBV_SYSFS_NAME_MAX]; | ||||
/* Path to infiniband_verbs class device in sysfs */ | /* Path to infiniband_verbs class device in sysfs */ | ||||
char dev_path[IBV_SYSFS_PATH_MAX]; | char dev_path[IBV_SYSFS_PATH_MAX]; | ||||
/* Path to infiniband class device in sysfs */ | /* Path to infiniband class device in sysfs */ | ||||
char ibdev_path[IBV_SYSFS_PATH_MAX]; | char ibdev_path[IBV_SYSFS_PATH_MAX]; | ||||
}; | }; | ||||
struct ibv_more_ops { | struct verbs_device { | ||||
struct ibv_srq * (*create_xrc_srq)(struct ibv_pd *pd, | struct ibv_device device; /* Must be first */ | ||||
struct ibv_xrc_domain *xrc_domain, | size_t sz; | ||||
struct ibv_cq *xrc_cq, | size_t size_of_context; | ||||
struct ibv_srq_init_attr *srq_init_attr); | int (*init_context)(struct verbs_device *device, | ||||
struct ibv_xrc_domain * (*open_xrc_domain)(struct ibv_context *context, | struct ibv_context *ctx, int cmd_fd); | ||||
int fd, int oflag); | void (*uninit_context)(struct verbs_device *device, | ||||
int (*close_xrc_domain)(struct ibv_xrc_domain *d); | struct ibv_context *ctx); | ||||
int (*create_xrc_rcv_qp)(struct ibv_qp_init_attr *init_attr, | /* future fields added here */ | ||||
uint32_t *xrc_qp_num); | |||||
int (*modify_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num, | |||||
struct ibv_qp_attr *attr, | |||||
int attr_mask); | |||||
int (*query_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num, | |||||
struct ibv_qp_attr *attr, | |||||
int attr_mask, | |||||
struct ibv_qp_init_attr *init_attr); | |||||
int (*reg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num); | |||||
int (*unreg_xrc_rcv_qp)(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num); | |||||
}; | }; | ||||
struct ibv_context_ops { | struct ibv_context_ops { | ||||
int (*query_device)(struct ibv_context *context, | int (*query_device)(struct ibv_context *context, | ||||
struct ibv_device_attr *device_attr); | struct ibv_device_attr *device_attr); | ||||
int (*query_port)(struct ibv_context *context, uint8_t port_num, | int (*query_port)(struct ibv_context *context, uint8_t port_num, | ||||
struct ibv_port_attr *port_attr); | struct ibv_port_attr *port_attr); | ||||
struct ibv_pd * (*alloc_pd)(struct ibv_context *context); | struct ibv_pd * (*alloc_pd)(struct ibv_context *context); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
struct ibv_context { | struct ibv_context { | ||||
struct ibv_device *device; | struct ibv_device *device; | ||||
struct ibv_context_ops ops; | struct ibv_context_ops ops; | ||||
int cmd_fd; | int cmd_fd; | ||||
int async_fd; | int async_fd; | ||||
int num_comp_vectors; | int num_comp_vectors; | ||||
pthread_mutex_t mutex; | pthread_mutex_t mutex; | ||||
void *abi_compat; | void *abi_compat; | ||||
struct ibv_more_ops *more_ops; | |||||
}; | }; | ||||
static inline int ___ibv_query_port(struct ibv_context *context, | enum verbs_context_mask { | ||||
uint8_t port_num, | VERBS_CONTEXT_XRCD = (uint64_t)1 << 0, | ||||
struct ibv_port_attr *port_attr) | VERBS_CONTEXT_SRQ = (uint64_t)1 << 1, | ||||
VERBS_CONTEXT_QP = (uint64_t)1 << 2, | |||||
VERBS_CONTEXT_RESERVED = (uint64_t)1 << 3, | |||||
VERBS_CONTEXT_EXP = (uint64_t)1 << 62 | |||||
}; | |||||
struct verbs_context { | |||||
/* "grows up" - new fields go here */ | |||||
int (*_reserved_2) (void); | |||||
int (*destroy_flow) (struct ibv_flow *flow); | |||||
int (*_reserved_1) (void); | |||||
struct ibv_flow * (*create_flow) (struct ibv_qp *qp, | |||||
struct ibv_flow_attr *flow_attr); | |||||
struct ibv_qp * (*open_qp)(struct ibv_context *context, | |||||
struct ibv_qp_open_attr *attr); | |||||
struct ibv_qp * (*create_qp_ex)(struct ibv_context *context, | |||||
struct ibv_qp_init_attr_ex *qp_init_attr_ex); | |||||
int (*get_srq_num)(struct ibv_srq *srq, uint32_t *srq_num); | |||||
struct ibv_srq * (*create_srq_ex)(struct ibv_context *context, | |||||
struct ibv_srq_init_attr_ex *srq_init_attr_ex); | |||||
struct ibv_xrcd * (*open_xrcd)(struct ibv_context *context, | |||||
struct ibv_xrcd_init_attr *xrcd_init_attr); | |||||
int (*close_xrcd)(struct ibv_xrcd *xrcd); | |||||
uint64_t has_comp_mask; | |||||
size_t sz; /* Must be immediately before struct ibv_context */ | |||||
struct ibv_context context;/* Must be last field in the struct */ | |||||
}; | |||||
static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx) | |||||
{ | { | ||||
port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; | return (!ctx || (ctx->abi_compat != __VERBS_ABI_IS_EXTENDED)) ? | ||||
port_attr->pad = 0; | NULL : container_of(ctx, struct verbs_context, context); | ||||
} | |||||
return context->ops.query_port(context, port_num, port_attr); | #define verbs_get_ctx_op(ctx, op) ({ \ | ||||
struct verbs_context *_vctx = verbs_get_ctx(ctx); \ | |||||
(!_vctx || (_vctx->sz < sizeof(*_vctx) - offsetof(struct verbs_context, op)) || \ | |||||
!_vctx->op) ? NULL : _vctx; }) | |||||
#define verbs_set_ctx_op(_vctx, op, ptr) ({ \ | |||||
struct verbs_context *vctx = _vctx; \ | |||||
if (vctx && (vctx->sz >= sizeof(*vctx) - offsetof(struct verbs_context, op))) \ | |||||
vctx->op = ptr; }) | |||||
static inline struct verbs_device *verbs_get_device( | |||||
const struct ibv_device *dev) | |||||
{ | |||||
return (dev->ops.alloc_context) ? | |||||
NULL : container_of(dev, struct verbs_device, device); | |||||
} | } | ||||
/** | /** | ||||
* ibv_get_device_list - Get list of IB devices currently available | * ibv_get_device_list - Get list of IB devices currently available | ||||
* @num_devices: optional. if non-NULL, set to the number of devices | * @num_devices: optional. if non-NULL, set to the number of devices | ||||
* returned in the array. | * returned in the array. | ||||
* | * | ||||
* Return a NULL-terminated array of IB devices. The array can be | * Return a NULL-terminated array of IB devices. The array can be | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | int ibv_query_device(struct ibv_context *context, | ||||
struct ibv_device_attr *device_attr); | struct ibv_device_attr *device_attr); | ||||
/** | /** | ||||
* ibv_query_port - Get port properties | * ibv_query_port - Get port properties | ||||
*/ | */ | ||||
int ibv_query_port(struct ibv_context *context, uint8_t port_num, | int ibv_query_port(struct ibv_context *context, uint8_t port_num, | ||||
struct ibv_port_attr *port_attr); | struct ibv_port_attr *port_attr); | ||||
static inline int ___ibv_query_port(struct ibv_context *context, | |||||
uint8_t port_num, | |||||
struct ibv_port_attr *port_attr) | |||||
{ | |||||
/* For compatibility when running with old libibverbs */ | |||||
port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; | |||||
port_attr->reserved = 0; | |||||
return ibv_query_port(context, port_num, port_attr); | |||||
} | |||||
#define ibv_query_port(context, port_num, port_attr) \ | |||||
___ibv_query_port(context, port_num, port_attr) | |||||
/** | /** | ||||
* ibv_query_gid - Get a GID table entry | * ibv_query_gid - Get a GID table entry | ||||
*/ | */ | ||||
int ibv_query_gid(struct ibv_context *context, uint8_t port_num, | int ibv_query_gid(struct ibv_context *context, uint8_t port_num, | ||||
int index, union ibv_gid *gid); | int index, union ibv_gid *gid); | ||||
/** | /** | ||||
* ibv_query_pkey - Get a P_Key table entry | * ibv_query_pkey - Get a P_Key table entry | ||||
*/ | */ | ||||
int ibv_query_pkey(struct ibv_context *context, uint8_t port_num, | int ibv_query_pkey(struct ibv_context *context, uint8_t port_num, | ||||
int index, uint16_t *pkey); | int index, uint16_t *pkey); | ||||
/** | /** | ||||
* ibv_alloc_pd - Allocate a protection domain | * ibv_alloc_pd - Allocate a protection domain | ||||
*/ | */ | ||||
struct ibv_pd *ibv_alloc_pd(struct ibv_context *context); | struct ibv_pd *ibv_alloc_pd(struct ibv_context *context); | ||||
/** | /** | ||||
* ibv_dealloc_pd - Free a protection domain | * ibv_dealloc_pd - Free a protection domain | ||||
*/ | */ | ||||
int ibv_dealloc_pd(struct ibv_pd *pd); | int ibv_dealloc_pd(struct ibv_pd *pd); | ||||
static inline struct ibv_flow *ibv_create_flow(struct ibv_qp *qp, | |||||
struct ibv_flow_attr *flow) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx_op(qp->context, | |||||
create_flow); | |||||
if (!vctx) | |||||
return NULL; | |||||
return vctx->create_flow(qp, flow); | |||||
} | |||||
static inline int ibv_destroy_flow(struct ibv_flow *flow_id) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx_op(flow_id->context, | |||||
destroy_flow); | |||||
if (!vctx) | |||||
return -ENOSYS; | |||||
return vctx->destroy_flow(flow_id); | |||||
} | |||||
/** | /** | ||||
* ibv_open_xrcd - Open an extended connection domain | |||||
*/ | |||||
static inline struct ibv_xrcd * | |||||
ibv_open_xrcd(struct ibv_context *context, struct ibv_xrcd_init_attr *xrcd_init_attr) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx_op(context, open_xrcd); | |||||
if (!vctx) { | |||||
errno = ENOSYS; | |||||
return NULL; | |||||
} | |||||
return vctx->open_xrcd(context, xrcd_init_attr); | |||||
} | |||||
/** | |||||
* ibv_close_xrcd - Close an extended connection domain | |||||
*/ | |||||
static inline int ibv_close_xrcd(struct ibv_xrcd *xrcd) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx(xrcd->context); | |||||
return vctx->close_xrcd(xrcd); | |||||
} | |||||
/** | |||||
* ibv_reg_mr - Register a memory region | * ibv_reg_mr - Register a memory region | ||||
*/ | */ | ||||
struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, | struct ibv_mr *ibv_reg_mr(struct ibv_pd *pd, void *addr, | ||||
size_t length, int access); | size_t length, int access); | ||||
/** | /** | ||||
* ibv_dereg_mr - Deregister a memory region | * ibv_dereg_mr - Deregister a memory region | ||||
*/ | */ | ||||
int ibv_dereg_mr(struct ibv_mr *mr); | int ibv_dereg_mr(struct ibv_mr *mr); | ||||
/** | /** | ||||
* ibv_alloc_mw - Allocate a memory window | |||||
*/ | |||||
static inline struct ibv_mw *ibv_alloc_mw(struct ibv_pd *pd, | |||||
enum ibv_mw_type type) | |||||
{ | |||||
if (!pd->context->ops.alloc_mw) { | |||||
errno = ENOSYS; | |||||
return NULL; | |||||
} | |||||
struct ibv_mw *mw = pd->context->ops.alloc_mw(pd, type); | |||||
if (mw) { | |||||
mw->context = pd->context; | |||||
mw->pd = pd; | |||||
} | |||||
return mw; | |||||
} | |||||
/** | |||||
* ibv_dealloc_mw - Free a memory window | |||||
*/ | |||||
static inline int ibv_dealloc_mw(struct ibv_mw *mw) | |||||
{ | |||||
return mw->context->ops.dealloc_mw(mw); | |||||
} | |||||
/** | |||||
* ibv_inc_rkey - increase the 8 lsb in the given rkey | |||||
*/ | |||||
static inline uint32_t ibv_inc_rkey(uint32_t rkey) | |||||
{ | |||||
const uint32_t mask = 0x000000ff; | |||||
uint8_t newtag = (uint8_t) ((rkey + 1) & mask); | |||||
return (rkey & ~mask) | newtag; | |||||
} | |||||
/** | |||||
* ibv_create_comp_channel - Create a completion event channel | * ibv_create_comp_channel - Create a completion event channel | ||||
*/ | */ | ||||
struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context); | struct ibv_comp_channel *ibv_create_comp_channel(struct ibv_context *context); | ||||
/** | /** | ||||
* ibv_destroy_comp_channel - Destroy a completion event channel | * ibv_destroy_comp_channel - Destroy a completion event channel | ||||
*/ | */ | ||||
int ibv_destroy_comp_channel(struct ibv_comp_channel *channel); | int ibv_destroy_comp_channel(struct ibv_comp_channel *channel); | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
* srq_attr->max_wr and srq_attr->max_sge are read the determine the | * srq_attr->max_wr and srq_attr->max_sge are read the determine the | ||||
* requested size of the SRQ, and set to the actual values allocated | * requested size of the SRQ, and set to the actual values allocated | ||||
* on return. If ibv_create_srq() succeeds, then max_wr and max_sge | * on return. If ibv_create_srq() succeeds, then max_wr and max_sge | ||||
* will always be at least as large as the requested values. | * will always be at least as large as the requested values. | ||||
*/ | */ | ||||
struct ibv_srq *ibv_create_srq(struct ibv_pd *pd, | struct ibv_srq *ibv_create_srq(struct ibv_pd *pd, | ||||
struct ibv_srq_init_attr *srq_init_attr); | struct ibv_srq_init_attr *srq_init_attr); | ||||
/** | static inline struct ibv_srq * | ||||
* ibv_create_xrc_srq - Creates a SRQ associated with the specified protection | ibv_create_srq_ex(struct ibv_context *context, | ||||
* domain and xrc domain. | struct ibv_srq_init_attr_ex *srq_init_attr_ex) | ||||
* @pd: The protection domain associated with the SRQ. | { | ||||
* @xrc_domain: The XRC domain associated with the SRQ. | struct verbs_context *vctx; | ||||
* @xrc_cq: CQ to report completions for XRC packets on. | uint32_t mask = srq_init_attr_ex->comp_mask; | ||||
* | |||||
* @srq_init_attr: A list of initial attributes required to create the SRQ. | |||||
* | |||||
* srq_attr->max_wr and srq_attr->max_sge are read the determine the | |||||
* requested size of the SRQ, and set to the actual values allocated | |||||
* on return. If ibv_create_srq() succeeds, then max_wr and max_sge | |||||
* will always be at least as large as the requested values. | |||||
*/ | |||||
struct ibv_srq *ibv_create_xrc_srq(struct ibv_pd *pd, | |||||
struct ibv_xrc_domain *xrc_domain, | |||||
struct ibv_cq *xrc_cq, | |||||
struct ibv_srq_init_attr *srq_init_attr); | |||||
if (!(mask & ~(IBV_SRQ_INIT_ATTR_PD | IBV_SRQ_INIT_ATTR_TYPE)) && | |||||
(mask & IBV_SRQ_INIT_ATTR_PD) && | |||||
(!(mask & IBV_SRQ_INIT_ATTR_TYPE) || | |||||
(srq_init_attr_ex->srq_type == IBV_SRQT_BASIC))) | |||||
return ibv_create_srq(srq_init_attr_ex->pd, | |||||
(struct ibv_srq_init_attr *) srq_init_attr_ex); | |||||
vctx = verbs_get_ctx_op(context, create_srq_ex); | |||||
if (!vctx) { | |||||
errno = ENOSYS; | |||||
return NULL; | |||||
} | |||||
return vctx->create_srq_ex(context, srq_init_attr_ex); | |||||
} | |||||
/** | /** | ||||
* ibv_modify_srq - Modifies the attributes for the specified SRQ. | * ibv_modify_srq - Modifies the attributes for the specified SRQ. | ||||
* @srq: The SRQ to modify. | * @srq: The SRQ to modify. | ||||
* @srq_attr: On input, specifies the SRQ attributes to modify. On output, | * @srq_attr: On input, specifies the SRQ attributes to modify. On output, | ||||
* the current values of selected SRQ attributes are returned. | * the current values of selected SRQ attributes are returned. | ||||
* @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ | * @srq_attr_mask: A bit-mask used to specify which attributes of the SRQ | ||||
* are being modified. | * are being modified. | ||||
* | * | ||||
* The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or | * The mask may contain IBV_SRQ_MAX_WR to resize the SRQ and/or | ||||
* IBV_SRQ_LIMIT to set the SRQ's limit and request notification when | * IBV_SRQ_LIMIT to set the SRQ's limit and request notification when | ||||
* the number of receives queued drops below the limit. | * the number of receives queued drops below the limit. | ||||
*/ | */ | ||||
int ibv_modify_srq(struct ibv_srq *srq, | int ibv_modify_srq(struct ibv_srq *srq, | ||||
struct ibv_srq_attr *srq_attr, | struct ibv_srq_attr *srq_attr, | ||||
int srq_attr_mask); | int srq_attr_mask); | ||||
/** | /** | ||||
* ibv_query_srq - Returns the attribute list and current values for the | * ibv_query_srq - Returns the attribute list and current values for the | ||||
* specified SRQ. | * specified SRQ. | ||||
* @srq: The SRQ to query. | * @srq: The SRQ to query. | ||||
* @srq_attr: The attributes of the specified SRQ. | * @srq_attr: The attributes of the specified SRQ. | ||||
*/ | */ | ||||
int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr); | int ibv_query_srq(struct ibv_srq *srq, struct ibv_srq_attr *srq_attr); | ||||
static inline int ibv_get_srq_num(struct ibv_srq *srq, uint32_t *srq_num) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx_op(srq->context, get_srq_num); | |||||
if (!vctx) | |||||
return ENOSYS; | |||||
return vctx->get_srq_num(srq, srq_num); | |||||
} | |||||
/** | /** | ||||
* ibv_destroy_srq - Destroys the specified SRQ. | * ibv_destroy_srq - Destroys the specified SRQ. | ||||
* @srq: The SRQ to destroy. | * @srq: The SRQ to destroy. | ||||
*/ | */ | ||||
int ibv_destroy_srq(struct ibv_srq *srq); | int ibv_destroy_srq(struct ibv_srq *srq); | ||||
/** | /** | ||||
* ibv_post_srq_recv - Posts a list of work requests to the specified SRQ. | * ibv_post_srq_recv - Posts a list of work requests to the specified SRQ. | ||||
Show All 10 Lines | |||||
} | } | ||||
/** | /** | ||||
* ibv_create_qp - Create a queue pair. | * ibv_create_qp - Create a queue pair. | ||||
*/ | */ | ||||
struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, | struct ibv_qp *ibv_create_qp(struct ibv_pd *pd, | ||||
struct ibv_qp_init_attr *qp_init_attr); | struct ibv_qp_init_attr *qp_init_attr); | ||||
static inline struct ibv_qp * | |||||
ibv_create_qp_ex(struct ibv_context *context, struct ibv_qp_init_attr_ex *qp_init_attr_ex) | |||||
{ | |||||
struct verbs_context *vctx; | |||||
uint32_t mask = qp_init_attr_ex->comp_mask; | |||||
if (mask == IBV_QP_INIT_ATTR_PD) | |||||
return ibv_create_qp(qp_init_attr_ex->pd, | |||||
(struct ibv_qp_init_attr *) qp_init_attr_ex); | |||||
vctx = verbs_get_ctx_op(context, create_qp_ex); | |||||
if (!vctx) { | |||||
errno = ENOSYS; | |||||
return NULL; | |||||
} | |||||
return vctx->create_qp_ex(context, qp_init_attr_ex); | |||||
} | |||||
/** | /** | ||||
* ibv_open_qp - Open a shareable queue pair. | |||||
*/ | |||||
static inline struct ibv_qp * | |||||
ibv_open_qp(struct ibv_context *context, struct ibv_qp_open_attr *qp_open_attr) | |||||
{ | |||||
struct verbs_context *vctx = verbs_get_ctx_op(context, open_qp); | |||||
if (!vctx) { | |||||
errno = ENOSYS; | |||||
return NULL; | |||||
} | |||||
return vctx->open_qp(context, qp_open_attr); | |||||
} | |||||
/** | |||||
* ibv_modify_qp - Modify a queue pair. | * ibv_modify_qp - Modify a queue pair. | ||||
*/ | */ | ||||
int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, | int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, | ||||
int attr_mask); | int attr_mask); | ||||
/** | /** | ||||
* ibv_query_qp - Returns the attribute list and current values for the | * ibv_query_qp - Returns the attribute list and current values for the | ||||
* specified QP. | * specified QP. | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
const char *ibv_port_state_str(enum ibv_port_state port_state); | const char *ibv_port_state_str(enum ibv_port_state port_state); | ||||
/** | /** | ||||
* ibv_event_type_str - Return string describing event_type enum value | * ibv_event_type_str - Return string describing event_type enum value | ||||
*/ | */ | ||||
const char *ibv_event_type_str(enum ibv_event_type event); | const char *ibv_event_type_str(enum ibv_event_type event); | ||||
/** | |||||
* ibv_open_xrc_domain - open an XRC domain | |||||
* Returns a reference to an XRC domain. | |||||
* | |||||
* @context: Device context | |||||
* @fd: descriptor for inode associated with the domain | |||||
* If fd == -1, no inode is associated with the domain; in this ca= se, | |||||
* the only legal value for oflag is O_CREAT | |||||
* | |||||
* @oflag: oflag values are constructed by OR-ing flags from the following list | |||||
* | |||||
* O_CREAT | |||||
* If a domain belonging to device named by context is already associated | |||||
* with the inode, this flag has no effect, except as noted under O_EXCL | |||||
* below. Otherwise, a new XRC domain is created and is associated with | |||||
* inode specified by fd. | |||||
* | |||||
* O_EXCL | |||||
* If O_EXCL and O_CREAT are set, open will fail if a domain associated with | |||||
* the inode exists. The check for the existence of the domain and creation | |||||
* of the domain if it does not exist is atomic with respect to other | |||||
* processes executing open with fd naming the same inode. | |||||
*/ | |||||
struct ibv_xrc_domain *ibv_open_xrc_domain(struct ibv_context *context, | |||||
int fd, int oflag); | |||||
/** | |||||
* ibv_close_xrc_domain - close an XRC domain | |||||
* If this is the last reference, destroys the domain. | |||||
* | |||||
* @d: reference to XRC domain to close | |||||
* | |||||
* close is implicitly performed at process exit. | |||||
*/ | |||||
int ibv_close_xrc_domain(struct ibv_xrc_domain *d); | |||||
/** | |||||
* ibv_create_xrc_rcv_qp - creates an XRC QP for serving as a receive-side-only QP, | |||||
* | |||||
* This QP is created in kernel space, and persists until the last process | |||||
* registered for the QP calls ibv_unreg_xrc_rcv_qp() (at which time the QP | |||||
* is destroyed). | |||||
* | |||||
* @init_attr: init attributes to use for QP. xrc domain MUST be included here. | |||||
* All other fields are ignored. | |||||
* | |||||
* @xrc_rcv_qpn: qp_num of created QP (if success). To be passed to the | |||||
* remote node (sender). The remote node will use xrc_rcv_qpn | |||||
* in ibv_post_send when sending to XRC SRQ's on this host | |||||
* in the same xrc domain. | |||||
* | |||||
* RETURNS: success (0), or a (negative) error value. | |||||
* | |||||
* NOTE: this verb also registers the calling user-process with the QP at its | |||||
* creation time (implicit call to ibv_reg_xrc_rcv_qp), to avoid race | |||||
* conditions. The creating process will need to call ibv_unreg_xrc_qp() | |||||
* for the QP to release it from this process. | |||||
*/ | |||||
int ibv_create_xrc_rcv_qp(struct ibv_qp_init_attr *init_attr, | |||||
uint32_t *xrc_rcv_qpn); | |||||
/** | |||||
* ibv_modify_xrc_rcv_qp - modifies an xrc_rcv qp. | |||||
* | |||||
* @xrc_domain: xrc domain the QP belongs to (for verification). | |||||
* @xrc_qp_num: The (24 bit) number of the XRC QP. | |||||
* @attr: modify-qp attributes. The following fields must be specified: | |||||
* for RESET_2_INIT: qp_state, pkey_index , port, qp_access_flags | |||||
* for INIT_2_RTR: qp_state, path_mtu, dest_qp_num, rq_psn, | |||||
* max_dest_rd_atomic, min_rnr_timer, ah_attr | |||||
* The QP need not be brought to RTS for the QP to operate as a | |||||
* receive-only QP. | |||||
* @attr_mask: bitmap indicating which attributes are provided in the attr | |||||
* struct. Used for validity checking. | |||||
* The following bits must be set: | |||||
* for RESET_2_INIT: IBV_QP_PKEY_INDEX, IBV_QP_PORT, | |||||
* IBV_QP_ACCESS_FLAGS, IBV_QP_STATE | |||||
* for INIT_2_RTR: IBV_QP_AV, IBV_QP_PATH_MTU, IBV_QP_DEST_QPN, | |||||
* IBV_QP_RQ_PSN, IBV_QP_MAX_DEST_RD_ATOMIC, | |||||
* IBV_QP_MIN_RNR_TIMER, IBV_QP_STATE | |||||
* | |||||
* RETURNS: success (0), or a (positive) error value. | |||||
* | |||||
*/ | |||||
int ibv_modify_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num, | |||||
struct ibv_qp_attr *attr, int attr_mask); | |||||
/** | |||||
* ibv_query_xrc_rcv_qp - queries an xrc_rcv qp. | |||||
* | |||||
* @xrc_domain: xrc domain the QP belongs to (for verification). | |||||
* @xrc_qp_num: The (24 bit) number of the XRC QP. | |||||
* @attr: for returning qp attributes. | |||||
* @attr_mask: bitmap indicating which attributes to return. | |||||
* @init_attr: for returning the init attributes | |||||
* | |||||
* RETURNS: success (0), or a (positive) error value. | |||||
* | |||||
*/ | |||||
int ibv_query_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num, | |||||
struct ibv_qp_attr *attr, int attr_mask, | |||||
struct ibv_qp_init_attr *init_attr); | |||||
/** | |||||
* ibv_reg_xrc_rcv_qp: registers a user process with an XRC QP which serves as | |||||
* a receive-side only QP. | |||||
* | |||||
* @xrc_domain: xrc domain the QP belongs to (for verification). | |||||
* @xrc_qp_num: The (24 bit) number of the XRC QP. | |||||
* | |||||
* RETURNS: success (0), | |||||
* or error (EINVAL), if: | |||||
* 1. There is no such QP_num allocated. | |||||
* 2. The QP is allocated, but is not an receive XRC QP | |||||
* 3. The XRC QP does not belong to the given domain. | |||||
*/ | |||||
int ibv_reg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, uint32_t xrc_qp_num); | |||||
/** | |||||
* ibv_unreg_xrc_rcv_qp: detaches a user process from an XRC QP serving as | |||||
* a receive-side only QP. If as a result, there are no remaining | |||||
* userspace processes registered for this XRC QP, it is destroyed. | |||||
* | |||||
* @xrc_domain: xrc domain the QP belongs to (for verification). | |||||
* @xrc_qp_num: The (24 bit) number of the XRC QP. | |||||
* | |||||
* RETURNS: success (0), | |||||
* or error (EINVAL), if: | |||||
* 1. There is no such QP_num allocated. | |||||
* 2. The QP is allocated, but is not an XRC QP | |||||
* 3. The XRC QP does not belong to the given domain. | |||||
* NOTE: There is no reason to return a special code if the QP is destroyed. | |||||
* The unregister simply succeeds. | |||||
*/ | |||||
int ibv_unreg_xrc_rcv_qp(struct ibv_xrc_domain *xrc_domain, | |||||
uint32_t xrc_qp_num); | |||||
END_C_DECLS | END_C_DECLS | ||||
# undef __attribute_const | # undef __attribute_const | ||||
#define ibv_query_port(context, port_num, port_attr) \ | #include <infiniband/verbs_exp.h> | ||||
___ibv_query_port(context, port_num, port_attr) | |||||
#endif /* INFINIBAND_VERBS_H */ | #endif /* INFINIBAND_VERBS_H */ |