Add new mlx5ib(4) driver to the kernel source tree which supports
Remote DMA over Converged Ethernet, RoCE, for the ConnectX-4 series of PCI express network cards. There is currently no user-space support and this driver only supports kernel side non-routable RoCE V1. The krping kernel module can be used to test this driver. Full user-space support including RoCE V2 will be added as part of the ongoing upgrade to ibcore from Linux 4.9. Otherwise this driver is feature equivalent to mlx4ib(4). The mlx5ib(4) kernel module will only be built when WITH_OFED=YES is specified. MFC after: 2 weeks Sponsored by: Mellanox Technologies
This commit is contained in:
parent
8e7cd863dd
commit
1251590741
@ -888,6 +888,7 @@ MAN+= iser.4
|
||||
|
||||
.if ${MK_OFED} != "no"
|
||||
MAN+= mlx4ib.4
|
||||
MAN+= mlx5ib.4
|
||||
.endif
|
||||
|
||||
.if ${MK_TESTS} != "no"
|
||||
|
124
share/man/man4/mlx5ib.4
Normal file
124
share/man/man4/mlx5ib.4
Normal file
@ -0,0 +1,124 @@
|
||||
.\" Copyright (c) 2017 Mellanox Technologies
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd August 23, 2017
|
||||
.Dt MLX5IB 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mlx5ib
|
||||
.Nd "Mellanox ConnectX-4 and ConnectX-4 LX based 100Gb, 50Gb, 40Gb, 25Gb and 10Gb network adapter driver"
|
||||
.Sh SYNOPSIS
|
||||
To compile this driver into the kernel,
|
||||
place these lines in your kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "options COMPAT_LINUXKPI"
|
||||
.Cd "device mlx5"
|
||||
.Cd "device mlx5ib"
|
||||
.Ed
|
||||
.Pp
|
||||
To load the driver as a module at run-time,
|
||||
run this command as root:
|
||||
.Bd -literal -offset indent
|
||||
kldload mlx5ib
|
||||
.Ed
|
||||
.Pp
|
||||
To load the driver as a
|
||||
module at boot time, place this line in
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
mlx5ib_load="YES"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for infiniband and Remote DMA over Converged Ethernet,
|
||||
RoCE, for PCI Express network adapters based on ConnectX-4 and ConnectX-4 LX.
|
||||
.br
|
||||
For further hardware information and questions related to hardware
|
||||
requirements, see
|
||||
.Pa http://www.mellanox.com/ .
|
||||
.Pp
|
||||
For more information on configuring this device, see
|
||||
.Xr ifconfig 8 .
|
||||
.Sh HARDWARE
|
||||
The
|
||||
.Nm
|
||||
driver supports 100Gb, 50Gb, 40Gb, 25Gb and 10Gb network adapters.
|
||||
ConnectX-4 supports: 10/20/25/40/50/56/100Gb/s speeds.
|
||||
ConnectX-4 LX supports: 10/25/40/50Gb/s speeds (and reduced power consumption):
|
||||
.Pp
|
||||
.Bl -bullet -compact
|
||||
.It
|
||||
Mellanox MCX455A-ECAT
|
||||
.It
|
||||
Mellanox MCX456A-ECAT
|
||||
.It
|
||||
Mellanox MCX415A-CCAT
|
||||
.It
|
||||
Mellanox MCX416A-CCAT
|
||||
.It
|
||||
Mellanox MCX455A-FCAT
|
||||
.It
|
||||
Mellanox MCX456A-FCAT
|
||||
.It
|
||||
Mellanox MCX415A-BCAT
|
||||
.It
|
||||
Mellanox MCX416A-BCAT
|
||||
.It
|
||||
Mellanox MCX4131A-GCAT
|
||||
.It
|
||||
Mellanox MCX4131A-BCAT
|
||||
.It
|
||||
Mellanox MCX4121A-ACAT
|
||||
.It
|
||||
Mellanox MCX4111A-ACAT
|
||||
.It
|
||||
Mellanox MCX4121A-XCAT
|
||||
.It
|
||||
Mellanox MCX4111A-XCAT
|
||||
.El
|
||||
.Sh SUPPORT
|
||||
For general information and support,
|
||||
go to the Mellanox support website at:
|
||||
.Pa http://www.mellanox.com/ .
|
||||
.Pp
|
||||
If an issue is identified with this driver with a supported adapter,
|
||||
email all the specific information related to the issue to
|
||||
.Aq Mt freebsd-drivers@mellanox.com .
|
||||
.Sh SEE ALSO
|
||||
.Xr mlx5en 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 12.x .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Mellanox Technologies <freebsd-drivers@mellanox.com> .
|
@ -4508,6 +4508,27 @@ dev/mlx4/mlx4_en/mlx4_en_rx.c optional mlx4en pci inet inet6 \
|
||||
dev/mlx4/mlx4_en/mlx4_en_tx.c optional mlx4en pci inet inet6 \
|
||||
compile-with "${OFED_C}"
|
||||
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_ah.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_cq.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_mad.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_main.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_mem.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_mr.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_qp.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_roce.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_ib/mlx5_ib_srq.c optional mlx5ib pci ofed \
|
||||
compile-with "${OFED_C}"
|
||||
|
||||
dev/mlx5/mlx5_core/mlx5_alloc.c optional mlx5 pci \
|
||||
compile-with "${OFED_C}"
|
||||
dev/mlx5/mlx5_core/mlx5_cmd.c optional mlx5 pci \
|
||||
|
790
sys/dev/mlx5/mlx5_ib/mlx5_ib.h
Normal file
790
sys/dev/mlx5/mlx5_ib/mlx5_ib.h
Normal file
@ -0,0 +1,790 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef MLX5_IB_H
|
||||
#define MLX5_IB_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/sched.h>
|
||||
#include <rdma/ib_verbs.h>
|
||||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <dev/mlx5/device.h>
|
||||
#include <dev/mlx5/driver.h>
|
||||
#include <dev/mlx5/cq.h>
|
||||
#include <dev/mlx5/qp.h>
|
||||
#include <dev/mlx5/srq.h>
|
||||
#include <linux/types.h>
|
||||
#include <dev/mlx5/mlx5_core/transobj.h>
|
||||
|
||||
#define mlx5_ib_dbg(dev, format, arg...) \
|
||||
pr_debug("mlx5_dbg:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
|
||||
__LINE__, curthread->td_proc->p_pid, ##arg)
|
||||
|
||||
#define mlx5_ib_err(dev, format, arg...) \
|
||||
printf("mlx5_ib: ERR: ""mlx5_err:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
|
||||
__LINE__, curthread->td_proc->p_pid, ##arg)
|
||||
|
||||
#define mlx5_ib_warn(dev, format, arg...) \
|
||||
printf("mlx5_ib: WARN: ""mlx5_warn:%s:%s:%d:(pid %d): " format, (dev)->ib_dev.name, __func__, \
|
||||
__LINE__, curthread->td_proc->p_pid, ##arg)
|
||||
#define BF_ENABLE 0
|
||||
|
||||
extern struct workqueue_struct *mlx5_ib_wq;
|
||||
|
||||
enum {
|
||||
MLX5_IB_MMAP_CMD_SHIFT = 8,
|
||||
MLX5_IB_MMAP_CMD_MASK = 0xff,
|
||||
};
|
||||
|
||||
enum mlx5_ib_mmap_cmd {
|
||||
MLX5_IB_MMAP_REGULAR_PAGE = 0,
|
||||
MLX5_IB_MMAP_GET_CONTIGUOUS_PAGES = 1,
|
||||
MLX5_IB_MMAP_WC_PAGE = 2,
|
||||
MLX5_IB_MMAP_NC_PAGE = 3,
|
||||
MLX5_IB_MMAP_MAP_DC_INFO_PAGE = 4,
|
||||
|
||||
/* Use EXP mmap commands until it is pushed to upstream */
|
||||
MLX5_IB_EXP_MMAP_CORE_CLOCK = 0xFB,
|
||||
MLX5_IB_EXP_MMAP_GET_CONTIGUOUS_PAGES_CPU_NUMA = 0xFC,
|
||||
MLX5_IB_EXP_MMAP_GET_CONTIGUOUS_PAGES_DEV_NUMA = 0xFD,
|
||||
MLX5_IB_EXP_ALLOC_N_MMAP_WC = 0xFE,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_RES_SCAT_DATA32_CQE = 0x1,
|
||||
MLX5_RES_SCAT_DATA64_CQE = 0x2,
|
||||
MLX5_REQ_SCAT_DATA32_CQE = 0x11,
|
||||
MLX5_REQ_SCAT_DATA64_CQE = 0x22,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_DCT_CS_RES_64 = 2,
|
||||
MLX5_CNAK_RX_POLL_CQ_QUOTA = 256,
|
||||
};
|
||||
|
||||
enum mlx5_ib_latency_class {
|
||||
MLX5_IB_LATENCY_CLASS_LOW,
|
||||
MLX5_IB_LATENCY_CLASS_MEDIUM,
|
||||
MLX5_IB_LATENCY_CLASS_HIGH,
|
||||
MLX5_IB_LATENCY_CLASS_FAST_PATH
|
||||
};
|
||||
|
||||
enum mlx5_ib_mad_ifc_flags {
|
||||
MLX5_MAD_IFC_IGNORE_MKEY = 1,
|
||||
MLX5_MAD_IFC_IGNORE_BKEY = 2,
|
||||
MLX5_MAD_IFC_NET_VIEW = 4,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_CROSS_CHANNEL_UUAR = 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_IB_MAX_CTX_DYNAMIC_UARS = 256,
|
||||
MLX5_IB_INVALID_UAR_INDEX = -1U
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_MAX_SINGLE_STRIDE_LOG_NUM_BYTES = 13,
|
||||
MLX5_MIN_SINGLE_STRIDE_LOG_NUM_BYTES = 6,
|
||||
MLX5_MAX_SINGLE_WQE_LOG_NUM_STRIDES = 16,
|
||||
MLX5_MIN_SINGLE_WQE_LOG_NUM_STRIDES = 9,
|
||||
};
|
||||
|
||||
struct mlx5_ib_ucontext {
|
||||
struct ib_ucontext ibucontext;
|
||||
struct list_head db_page_list;
|
||||
|
||||
/* protect doorbell record alloc/free
|
||||
*/
|
||||
struct mutex db_page_mutex;
|
||||
struct mlx5_uuar_info uuari;
|
||||
u32 dynamic_wc_uar_index[MLX5_IB_MAX_CTX_DYNAMIC_UARS];
|
||||
/* Transport Domain number */
|
||||
u32 tdn;
|
||||
};
|
||||
|
||||
static inline struct mlx5_ib_ucontext *to_mucontext(struct ib_ucontext *ibucontext)
|
||||
{
|
||||
return container_of(ibucontext, struct mlx5_ib_ucontext, ibucontext);
|
||||
}
|
||||
|
||||
struct mlx5_ib_pd {
|
||||
struct ib_pd ibpd;
|
||||
u32 pdn;
|
||||
u32 pa_lkey;
|
||||
};
|
||||
|
||||
struct wr_list {
|
||||
u16 opcode;
|
||||
u16 next;
|
||||
};
|
||||
|
||||
struct mlx5_swr_ctx {
|
||||
u64 wrid;
|
||||
u32 wr_data;
|
||||
struct wr_list w_list;
|
||||
u32 wqe_head;
|
||||
u8 sig_piped;
|
||||
u8 rsvd[11];
|
||||
};
|
||||
|
||||
struct mlx5_rwr_ctx {
|
||||
u64 wrid;
|
||||
};
|
||||
|
||||
struct mlx5_ib_wq {
|
||||
union {
|
||||
struct mlx5_swr_ctx *swr_ctx;
|
||||
struct mlx5_rwr_ctx *rwr_ctx;
|
||||
};
|
||||
u16 unsig_count;
|
||||
|
||||
/* serialize post to the work queue
|
||||
*/
|
||||
spinlock_t lock;
|
||||
int wqe_cnt;
|
||||
int max_post;
|
||||
int max_gs;
|
||||
int offset;
|
||||
int wqe_shift;
|
||||
unsigned head;
|
||||
unsigned tail;
|
||||
u16 cur_post;
|
||||
u16 last_poll;
|
||||
void *qend;
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_QP_USER,
|
||||
MLX5_QP_KERNEL,
|
||||
MLX5_QP_EMPTY
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_WQ_USER,
|
||||
MLX5_WQ_KERNEL
|
||||
};
|
||||
|
||||
struct mlx5_ib_sqd {
|
||||
struct mlx5_ib_qp *qp;
|
||||
struct work_struct work;
|
||||
};
|
||||
|
||||
struct mlx5_ib_mc_flows_list {
|
||||
struct list_head flows_list;
|
||||
/*Protect the flows_list*/
|
||||
struct mutex lock;
|
||||
};
|
||||
|
||||
struct mlx5_ib_qp {
|
||||
struct ib_qp ibqp;
|
||||
struct mlx5_core_qp mqp;
|
||||
struct mlx5_core_qp mrq;
|
||||
struct mlx5_core_qp msq;
|
||||
u32 tisn;
|
||||
u32 tirn;
|
||||
struct mlx5_buf buf;
|
||||
|
||||
struct mlx5_db db;
|
||||
struct mlx5_ib_wq rq;
|
||||
|
||||
u32 doorbell_qpn;
|
||||
u8 sq_signal_bits;
|
||||
u8 fm_cache;
|
||||
int sq_max_wqes_per_wr;
|
||||
int sq_spare_wqes;
|
||||
struct mlx5_ib_wq sq;
|
||||
|
||||
struct ib_umem *umem;
|
||||
int buf_size;
|
||||
/* Raw Ethernet QP's SQ is allocated seperately
|
||||
* from the RQ's buffer in user-space.
|
||||
*/
|
||||
struct ib_umem *sq_umem;
|
||||
int sq_buf_size;
|
||||
u64 sq_buf_addr;
|
||||
int allow_mp_wqe;
|
||||
|
||||
/* serialize qp state modifications
|
||||
*/
|
||||
struct mutex mutex;
|
||||
u16 xrcdn;
|
||||
u32 flags;
|
||||
u8 port;
|
||||
u8 alt_port;
|
||||
u8 atomic_rd_en;
|
||||
u8 resp_depth;
|
||||
u8 state;
|
||||
/* Raw Ethernet QP's SQ and RQ states */
|
||||
u8 rq_state;
|
||||
u8 sq_state;
|
||||
int mlx_type;
|
||||
int wq_sig;
|
||||
int scat_cqe;
|
||||
int max_inline_data;
|
||||
struct mlx5_bf *bf;
|
||||
int has_rq;
|
||||
|
||||
/* only for user space QPs. For kernel
|
||||
* we have it from the bf object
|
||||
*/
|
||||
int uuarn;
|
||||
|
||||
int create_type;
|
||||
u32 pa_lkey;
|
||||
|
||||
/* Store signature errors */
|
||||
bool signature_en;
|
||||
|
||||
struct list_head qps_list;
|
||||
struct list_head cq_recv_list;
|
||||
struct list_head cq_send_list;
|
||||
|
||||
struct mlx5_ib_mc_flows_list mc_flows_list;
|
||||
};
|
||||
|
||||
struct mlx5_ib_cq_buf {
|
||||
struct mlx5_buf buf;
|
||||
struct ib_umem *umem;
|
||||
int cqe_size;
|
||||
int nent;
|
||||
};
|
||||
|
||||
enum mlx5_ib_qp_flags {
|
||||
MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 0,
|
||||
MLX5_IB_QP_SIGNATURE_HANDLING = 1 << 1,
|
||||
MLX5_IB_QP_CAP_RX_END_PADDING = 1 << 5,
|
||||
};
|
||||
|
||||
struct mlx5_umr_wr {
|
||||
union {
|
||||
u64 virt_addr;
|
||||
u64 offset;
|
||||
} target;
|
||||
struct ib_pd *pd;
|
||||
unsigned int page_shift;
|
||||
unsigned int npages;
|
||||
u64 length;
|
||||
int access_flags;
|
||||
u32 mkey;
|
||||
};
|
||||
|
||||
struct mlx5_shared_mr_info {
|
||||
int mr_id;
|
||||
struct ib_umem *umem;
|
||||
};
|
||||
|
||||
struct mlx5_ib_cq {
|
||||
struct ib_cq ibcq;
|
||||
struct mlx5_core_cq mcq;
|
||||
struct mlx5_ib_cq_buf buf;
|
||||
struct mlx5_db db;
|
||||
|
||||
/* serialize access to the CQ
|
||||
*/
|
||||
spinlock_t lock;
|
||||
|
||||
/* protect resize cq
|
||||
*/
|
||||
struct mutex resize_mutex;
|
||||
struct mlx5_ib_cq_buf *resize_buf;
|
||||
struct ib_umem *resize_umem;
|
||||
int cqe_size;
|
||||
struct list_head list_send_qp;
|
||||
struct list_head list_recv_qp;
|
||||
};
|
||||
|
||||
struct mlx5_ib_srq {
|
||||
struct ib_srq ibsrq;
|
||||
struct mlx5_core_srq msrq;
|
||||
struct mlx5_buf buf;
|
||||
struct mlx5_db db;
|
||||
u64 *wrid;
|
||||
/* protect SRQ hanlding
|
||||
*/
|
||||
spinlock_t lock;
|
||||
int head;
|
||||
int tail;
|
||||
u16 wqe_ctr;
|
||||
struct ib_umem *umem;
|
||||
/* serialize arming a SRQ
|
||||
*/
|
||||
struct mutex mutex;
|
||||
int wq_sig;
|
||||
};
|
||||
|
||||
struct mlx5_ib_xrcd {
|
||||
struct ib_xrcd ibxrcd;
|
||||
u32 xrcdn;
|
||||
};
|
||||
|
||||
enum mlx5_ib_mtt_access_flags {
|
||||
MLX5_IB_MTT_READ = (1 << 0),
|
||||
MLX5_IB_MTT_WRITE = (1 << 1),
|
||||
};
|
||||
|
||||
#define MLX5_IB_MTT_PRESENT (MLX5_IB_MTT_READ | MLX5_IB_MTT_WRITE)
|
||||
|
||||
struct mlx5_ib_mr {
|
||||
struct ib_mr ibmr;
|
||||
struct mlx5_core_mr mmr;
|
||||
struct ib_umem *umem;
|
||||
struct mlx5_shared_mr_info *smr_info;
|
||||
struct list_head list;
|
||||
int order;
|
||||
int umred;
|
||||
dma_addr_t dma;
|
||||
int npages;
|
||||
struct mlx5_ib_dev *dev;
|
||||
struct mlx5_create_mkey_mbox_out out;
|
||||
struct mlx5_core_sig_ctx *sig;
|
||||
u32 max_reg_descriptors;
|
||||
u64 size;
|
||||
u64 page_count;
|
||||
struct mlx5_ib_mr **children;
|
||||
int nchild;
|
||||
};
|
||||
|
||||
struct mlx5_ib_fast_reg_page_list {
|
||||
struct ib_fast_reg_page_list ibfrpl;
|
||||
__be64 *mapped_page_list;
|
||||
dma_addr_t map;
|
||||
};
|
||||
|
||||
struct mlx5_ib_umr_context {
|
||||
enum ib_wc_status status;
|
||||
struct completion done;
|
||||
};
|
||||
|
||||
static inline void mlx5_ib_init_umr_context(struct mlx5_ib_umr_context *context)
|
||||
{
|
||||
context->status = -1;
|
||||
init_completion(&context->done);
|
||||
}
|
||||
|
||||
struct umr_common {
|
||||
struct ib_pd *pd;
|
||||
struct ib_mr *mr;
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_FMR_INVALID,
|
||||
MLX5_FMR_VALID,
|
||||
MLX5_FMR_BUSY,
|
||||
};
|
||||
|
||||
struct mlx5_ib_fmr {
|
||||
struct ib_fmr ibfmr;
|
||||
struct mlx5_core_mr mr;
|
||||
int access_flags;
|
||||
int state;
|
||||
/* protect fmr state
|
||||
*/
|
||||
spinlock_t lock;
|
||||
u64 wrid;
|
||||
struct ib_send_wr wr[2];
|
||||
u8 page_shift;
|
||||
struct ib_fast_reg_page_list page_list;
|
||||
};
|
||||
|
||||
struct cache_order {
|
||||
struct kobject kobj;
|
||||
int order;
|
||||
int index;
|
||||
struct mlx5_ib_dev *dev;
|
||||
};
|
||||
|
||||
struct mlx5_cache_ent {
|
||||
struct list_head head;
|
||||
/* sync access to the cahce entry
|
||||
*/
|
||||
spinlock_t lock;
|
||||
|
||||
|
||||
u32 order;
|
||||
u32 size;
|
||||
u32 cur;
|
||||
u32 miss;
|
||||
u32 limit;
|
||||
|
||||
struct mlx5_ib_dev *dev;
|
||||
struct work_struct work;
|
||||
struct delayed_work dwork;
|
||||
int pending;
|
||||
struct cache_order co;
|
||||
};
|
||||
|
||||
struct mlx5_mr_cache {
|
||||
struct workqueue_struct *wq;
|
||||
struct mlx5_cache_ent ent[MAX_MR_CACHE_ENTRIES];
|
||||
int stopped;
|
||||
struct dentry *root;
|
||||
int last_add;
|
||||
int rel_timeout;
|
||||
int rel_imm;
|
||||
};
|
||||
|
||||
struct mlx5_ib_resources {
|
||||
struct ib_cq *c0;
|
||||
struct ib_xrcd *x0;
|
||||
struct ib_xrcd *x1;
|
||||
struct ib_pd *p0;
|
||||
struct ib_srq *s0;
|
||||
struct ib_srq *s1;
|
||||
};
|
||||
|
||||
struct mlx5_dc_tracer {
|
||||
struct page *pg;
|
||||
dma_addr_t dma;
|
||||
int size;
|
||||
int order;
|
||||
};
|
||||
|
||||
struct mlx5_dc_desc {
|
||||
dma_addr_t dma;
|
||||
void *buf;
|
||||
};
|
||||
|
||||
enum mlx5_op {
|
||||
MLX5_WR_OP_MLX = 1,
|
||||
};
|
||||
|
||||
struct mlx5_mlx_wr {
|
||||
u8 sl;
|
||||
u16 dlid;
|
||||
int icrc;
|
||||
};
|
||||
|
||||
struct mlx5_send_wr {
|
||||
struct ib_send_wr wr;
|
||||
union {
|
||||
struct mlx5_mlx_wr mlx;
|
||||
} sel;
|
||||
};
|
||||
|
||||
struct mlx5_dc_data {
|
||||
struct ib_mr *mr;
|
||||
struct ib_qp *dcqp;
|
||||
struct ib_cq *rcq;
|
||||
struct ib_cq *scq;
|
||||
unsigned int rx_npages;
|
||||
unsigned int tx_npages;
|
||||
struct mlx5_dc_desc *rxdesc;
|
||||
struct mlx5_dc_desc *txdesc;
|
||||
unsigned int max_wqes;
|
||||
unsigned int cur_send;
|
||||
unsigned int last_send_completed;
|
||||
int tx_pending;
|
||||
struct mlx5_ib_dev *dev;
|
||||
int port;
|
||||
int initialized;
|
||||
struct kobject kobj;
|
||||
unsigned long connects;
|
||||
unsigned long cnaks;
|
||||
unsigned long discards;
|
||||
struct ib_wc wc_tbl[MLX5_CNAK_RX_POLL_CQ_QUOTA];
|
||||
};
|
||||
|
||||
struct mlx5_ib_port_sysfs_group {
|
||||
struct kobject kobj;
|
||||
bool enabled;
|
||||
struct attribute_group counters;
|
||||
};
|
||||
|
||||
#define MLX5_IB_GID_MAX 16
|
||||
|
||||
struct mlx5_ib_port {
|
||||
struct mlx5_ib_dev *dev;
|
||||
u8 port_num; /* 0 based */
|
||||
u8 port_gone; /* set when gone */
|
||||
u16 q_cnt_id;
|
||||
struct mlx5_ib_port_sysfs_group group;
|
||||
union ib_gid gid_table[MLX5_IB_GID_MAX];
|
||||
};
|
||||
|
||||
struct mlx5_ib_dev {
|
||||
struct ib_device ib_dev;
|
||||
struct mlx5_core_dev *mdev;
|
||||
MLX5_DECLARE_DOORBELL_LOCK(uar_lock);
|
||||
int num_ports;
|
||||
/* serialize update of capability mask
|
||||
*/
|
||||
struct mutex cap_mask_mutex;
|
||||
bool ib_active;
|
||||
struct umr_common umrc;
|
||||
/* sync used page count stats
|
||||
*/
|
||||
struct mlx5_ib_resources devr;
|
||||
struct mutex slow_path_mutex;
|
||||
int enable_atomic_resp;
|
||||
enum ib_atomic_cap atomic_cap;
|
||||
struct mlx5_mr_cache cache;
|
||||
struct kobject mr_cache;
|
||||
/* protect resources needed as part of reset flow */
|
||||
spinlock_t reset_flow_resource_lock;
|
||||
struct list_head qp_list;
|
||||
struct timer_list delay_timer;
|
||||
int fill_delay;
|
||||
struct mlx5_dc_tracer dctr;
|
||||
struct mlx5_dc_data dcd[MLX5_MAX_PORTS];
|
||||
struct kobject *dc_kobj;
|
||||
/* Array with num_ports elements */
|
||||
struct mlx5_ib_port *port;
|
||||
struct kobject *ports_parent;
|
||||
};
|
||||
|
||||
static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
|
||||
{
|
||||
return container_of(mcq, struct mlx5_ib_cq, mcq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_xrcd *to_mxrcd(struct ib_xrcd *ibxrcd)
|
||||
{
|
||||
return container_of(ibxrcd, struct mlx5_ib_xrcd, ibxrcd);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_dev *to_mdev(struct ib_device *ibdev)
|
||||
{
|
||||
return container_of(ibdev, struct mlx5_ib_dev, ib_dev);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_fmr *to_mfmr(struct ib_fmr *ibfmr)
|
||||
{
|
||||
return container_of(ibfmr, struct mlx5_ib_fmr, ibfmr);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_cq *to_mcq(struct ib_cq *ibcq)
|
||||
{
|
||||
return container_of(ibcq, struct mlx5_ib_cq, ibcq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_qp *to_mibqp(struct mlx5_core_qp *mqp)
|
||||
{
|
||||
return container_of(mqp, struct mlx5_ib_qp, mqp);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_qp *sq_to_mibqp(struct mlx5_core_qp *msq)
|
||||
{
|
||||
return container_of(msq, struct mlx5_ib_qp, msq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_qp *rq_to_mibqp(struct mlx5_core_qp *mrq)
|
||||
{
|
||||
return container_of(mrq, struct mlx5_ib_qp, mrq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_mr *to_mibmr(struct mlx5_core_mr *mmr)
|
||||
{
|
||||
return container_of(mmr, struct mlx5_ib_mr, mmr);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_pd *to_mpd(struct ib_pd *ibpd)
|
||||
{
|
||||
return container_of(ibpd, struct mlx5_ib_pd, ibpd);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_srq *to_msrq(struct ib_srq *ibsrq)
|
||||
{
|
||||
return container_of(ibsrq, struct mlx5_ib_srq, ibsrq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_qp *to_mqp(struct ib_qp *ibqp)
|
||||
{
|
||||
return container_of(ibqp, struct mlx5_ib_qp, ibqp);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_srq *to_mibsrq(struct mlx5_core_srq *msrq)
|
||||
{
|
||||
return container_of(msrq, struct mlx5_ib_srq, msrq);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_mr *to_mmr(struct ib_mr *ibmr)
|
||||
{
|
||||
return container_of(ibmr, struct mlx5_ib_mr, ibmr);
|
||||
}
|
||||
|
||||
static inline struct mlx5_ib_fast_reg_page_list *to_mfrpl(struct ib_fast_reg_page_list *ibfrpl)
|
||||
{
|
||||
return container_of(ibfrpl, struct mlx5_ib_fast_reg_page_list, ibfrpl);
|
||||
}
|
||||
|
||||
struct mlx5_ib_ah {
|
||||
struct ib_ah ibah;
|
||||
struct mlx5_av av;
|
||||
};
|
||||
|
||||
static inline struct mlx5_ib_ah *to_mah(struct ib_ah *ibah)
|
||||
{
|
||||
return container_of(ibah, struct mlx5_ib_ah, ibah);
|
||||
}
|
||||
|
||||
int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, uintptr_t virt,
|
||||
struct mlx5_db *db);
|
||||
void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db);
|
||||
void __mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
|
||||
void mlx5_ib_cq_clean(struct mlx5_ib_cq *cq, u32 qpn, struct mlx5_ib_srq *srq);
|
||||
void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index);
|
||||
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
|
||||
u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh,
|
||||
void *in_mad, void *response_mad);
|
||||
struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev, struct ib_ah_attr *ah_attr,
|
||||
struct mlx5_ib_ah *ah, enum rdma_link_layer ll);
|
||||
struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
|
||||
int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr);
|
||||
int mlx5_ib_destroy_ah(struct ib_ah *ah);
|
||||
struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
|
||||
struct ib_srq_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
|
||||
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata);
|
||||
int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr);
|
||||
int mlx5_ib_destroy_srq(struct ib_srq *srq);
|
||||
int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
|
||||
struct ib_recv_wr **bad_wr);
|
||||
struct ib_qp *mlx5_ib_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
int attr_mask, struct ib_udata *udata);
|
||||
int mlx5_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask,
|
||||
struct ib_qp_init_attr *qp_init_attr);
|
||||
int mlx5_ib_destroy_qp(struct ib_qp *qp);
|
||||
int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
|
||||
struct ib_send_wr **bad_wr);
|
||||
int mlx5_ib_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr,
|
||||
struct ib_recv_wr **bad_wr);
|
||||
void *mlx5_get_send_wqe(struct mlx5_ib_qp *qp, int n);
|
||||
struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev,
|
||||
struct ib_cq_init_attr *attr,
|
||||
struct ib_ucontext *context,
|
||||
struct ib_udata *udata);
|
||||
int mlx5_ib_destroy_cq(struct ib_cq *cq);
|
||||
int mlx5_ib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
|
||||
int mlx5_ib_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags);
|
||||
int mlx5_ib_modify_cq(struct ib_cq *cq, struct ib_cq_attr *attr, int cq_attr_mask);
|
||||
int mlx5_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata);
|
||||
struct ib_mr *mlx5_ib_get_dma_mr(struct ib_pd *pd, int acc);
|
||||
struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
|
||||
u64 virt_addr, int access_flags,
|
||||
struct ib_udata *udata, int mr_id);
|
||||
struct ib_mr *mlx5_ib_reg_phys_mr(struct ib_pd *pd,
|
||||
struct ib_phys_buf *buffer_list,
|
||||
int num_phys_buf,
|
||||
int access_flags,
|
||||
u64 *virt_addr);
|
||||
int mlx5_ib_dereg_mr(struct ib_mr *ibmr);
|
||||
int mlx5_ib_destroy_mr(struct ib_mr *ibmr);
|
||||
struct ib_mr *mlx5_ib_alloc_fast_reg_mr(struct ib_pd *pd,
|
||||
int max_page_list_len);
|
||||
struct ib_fast_reg_page_list *mlx5_ib_alloc_fast_reg_page_list(struct ib_device *ibdev,
|
||||
int page_list_len);
|
||||
void mlx5_ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
|
||||
|
||||
struct ib_fmr *mlx5_ib_fmr_alloc(struct ib_pd *pd, int acc,
|
||||
struct ib_fmr_attr *fmr_attr);
|
||||
int mlx5_ib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
|
||||
int npages, u64 iova);
|
||||
int mlx5_ib_unmap_fmr(struct list_head *fmr_list);
|
||||
int mlx5_ib_fmr_dealloc(struct ib_fmr *ibfmr);
|
||||
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
|
||||
struct ib_wc *in_wc, struct ib_grh *in_grh,
|
||||
struct ib_mad *in_mad, struct ib_mad *out_mad);
|
||||
struct ib_xrcd *mlx5_ib_alloc_xrcd(struct ib_device *ibdev,
|
||||
struct ib_ucontext *context,
|
||||
struct ib_udata *udata);
|
||||
int mlx5_ib_dealloc_xrcd(struct ib_xrcd *xrcd);
|
||||
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset);
|
||||
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port);
|
||||
int mlx5_query_smp_attr_node_info_mad_ifc(struct ib_device *ibdev,
|
||||
struct ib_smp *out_mad);
|
||||
int mlx5_query_system_image_guid_mad_ifc(struct ib_device *ibdev,
|
||||
__be64 *sys_image_guid);
|
||||
int mlx5_query_max_pkeys_mad_ifc(struct ib_device *ibdev,
|
||||
u16 *max_pkeys);
|
||||
int mlx5_query_vendor_id_mad_ifc(struct ib_device *ibdev,
|
||||
u32 *vendor_id);
|
||||
int mlx5_query_pkey_mad_ifc(struct ib_device *ibdev, u8 port, u16 index,
|
||||
u16 *pkey);
|
||||
int mlx5_query_node_desc_mad_ifc(struct mlx5_ib_dev *dev, char *node_desc);
|
||||
int mlx5_query_node_guid_mad_ifc(struct mlx5_ib_dev *dev, u64 *node_guid);
|
||||
int mlx5_query_gids_mad_ifc(struct ib_device *ibdev, u8 port, int index,
|
||||
union ib_gid *gid);
|
||||
int mlx5_query_port_mad_ifc(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
int mlx5_ib_query_port(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
int mlx5_ib_init_fmr(struct mlx5_ib_dev *dev);
|
||||
void mlx5_ib_cleanup_fmr(struct mlx5_ib_dev *dev);
|
||||
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
|
||||
int *ncont, int *order);
|
||||
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, __be64 *pas, int umr);
|
||||
void mlx5_ib_copy_pas(u64 *old, u64 *new, int step, int num);
|
||||
int mlx5_ib_get_cqe_size(struct mlx5_ib_dev *dev, struct ib_cq *ibcq);
|
||||
int mlx5_mr_cache_init(struct mlx5_ib_dev *dev);
|
||||
int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev);
|
||||
int mlx5_mr_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift);
|
||||
void mlx5_umr_cq_handler(struct ib_cq *cq, void *cq_context);
|
||||
int mlx5_query_port_roce(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port, int index,
|
||||
__be16 ah_udp_s_port);
|
||||
int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port,
|
||||
int index, int *gid_type);
|
||||
struct net_device *mlx5_ib_get_netdev(struct ib_device *ib_dev, u8 port);
|
||||
int modify_gid_roce(struct ib_device *ib_dev, u8 port, unsigned int index,
|
||||
const union ib_gid *gid, struct net_device *ndev);
|
||||
int query_gid_roce(struct ib_device *ib_dev, u8 port, int index,
|
||||
union ib_gid *gid);
|
||||
int mlx5_process_mad_mad_ifc(struct ib_device *ibdev, int mad_flags,
|
||||
u8 port_num, struct ib_wc *in_wc,
|
||||
struct ib_grh *in_grh, struct ib_mad *in_mad,
|
||||
struct ib_mad *out_mad);
|
||||
|
||||
static inline void init_query_mad(struct ib_smp *mad)
|
||||
{
|
||||
mad->base_version = 1;
|
||||
mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
|
||||
mad->class_version = 1;
|
||||
mad->method = IB_MGMT_METHOD_GET;
|
||||
}
|
||||
|
||||
static inline u8 convert_access(int acc)
|
||||
{
|
||||
return (acc & IB_ACCESS_REMOTE_ATOMIC ? MLX5_PERM_ATOMIC : 0) |
|
||||
(acc & IB_ACCESS_REMOTE_WRITE ? MLX5_PERM_REMOTE_WRITE : 0) |
|
||||
(acc & IB_ACCESS_REMOTE_READ ? MLX5_PERM_REMOTE_READ : 0) |
|
||||
(acc & IB_ACCESS_LOCAL_WRITE ? MLX5_PERM_LOCAL_WRITE : 0) |
|
||||
MLX5_PERM_LOCAL_READ;
|
||||
}
|
||||
|
||||
#define MLX5_MAX_UMR_SHIFT 16
|
||||
#define MLX5_MAX_UMR_PAGES (1 << MLX5_MAX_UMR_SHIFT)
|
||||
|
||||
#endif /* MLX5_IB_H */
|
125
sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
Normal file
125
sys/dev/mlx5/mlx5_ib/mlx5_ib_ah.c
Normal file
@ -0,0 +1,125 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include "mlx5_ib.h"
|
||||
|
||||
#define IPV6_DEFAULT_HOPLIMIT 64
|
||||
|
||||
struct ib_ah *create_ib_ah(struct mlx5_ib_dev *dev,
|
||||
struct ib_ah_attr *ah_attr,
|
||||
struct mlx5_ib_ah *ah, enum rdma_link_layer ll)
|
||||
{
|
||||
int err;
|
||||
int gid_type;
|
||||
|
||||
if (ah_attr->ah_flags & IB_AH_GRH) {
|
||||
memcpy(ah->av.rgid, &ah_attr->grh.dgid, 16);
|
||||
ah->av.grh_gid_fl = cpu_to_be32(ah_attr->grh.flow_label |
|
||||
(1 << 30) |
|
||||
ah_attr->grh.sgid_index << 20);
|
||||
ah->av.hop_limit = ah_attr->grh.hop_limit;
|
||||
ah->av.tclass = ah_attr->grh.traffic_class;
|
||||
}
|
||||
|
||||
ah->av.stat_rate_sl = (ah_attr->static_rate << 4);
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET) {
|
||||
err = mlx5_get_roce_gid_type(dev, ah_attr->port_num,
|
||||
ah_attr->grh.sgid_index,
|
||||
&gid_type);
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
memcpy(ah->av.rmac, ah_attr->dmac, sizeof(ah_attr->dmac));
|
||||
ah->av.udp_sport = mlx5_get_roce_udp_sport(
|
||||
dev,
|
||||
ah_attr->port_num,
|
||||
ah_attr->grh.sgid_index,
|
||||
0);
|
||||
ah->av.stat_rate_sl |= (ah_attr->sl & 0x7) << 1;
|
||||
ah->av.hop_limit = ah_attr->grh.hop_limit;
|
||||
/* TODO: initialize other eth fields */
|
||||
} else {
|
||||
ah->av.rlid = cpu_to_be16(ah_attr->dlid);
|
||||
ah->av.fl_mlid = ah_attr->src_path_bits & 0x7f;
|
||||
ah->av.stat_rate_sl |= (ah_attr->sl & 0xf);
|
||||
}
|
||||
|
||||
return &ah->ibah;
|
||||
}
|
||||
|
||||
struct ib_ah *mlx5_ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
|
||||
{
|
||||
struct mlx5_ib_ah *ah;
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
enum rdma_link_layer ll;
|
||||
struct ib_ah *ret = ERR_PTR(-EINVAL);
|
||||
|
||||
ah = kzalloc(sizeof(*ah), GFP_ATOMIC);
|
||||
if (!ah)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ll = pd->device->get_link_layer(pd->device, ah_attr->port_num);
|
||||
|
||||
if (ll == IB_LINK_LAYER_ETHERNET && !(ah_attr->ah_flags & IB_AH_GRH))
|
||||
goto err_kfree_ah;
|
||||
|
||||
return create_ib_ah(dev, ah_attr, ah, ll); /* never fails */
|
||||
|
||||
err_kfree_ah:
|
||||
kfree(ah);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mlx5_ib_query_ah(struct ib_ah *ibah, struct ib_ah_attr *ah_attr)
|
||||
{
|
||||
struct mlx5_ib_ah *ah = to_mah(ibah);
|
||||
u32 tmp;
|
||||
|
||||
memset(ah_attr, 0, sizeof(*ah_attr));
|
||||
|
||||
tmp = be32_to_cpu(ah->av.grh_gid_fl);
|
||||
if (tmp & (1 << 30)) {
|
||||
ah_attr->ah_flags = IB_AH_GRH;
|
||||
ah_attr->grh.sgid_index = (tmp >> 20) & 0xff;
|
||||
ah_attr->grh.flow_label = tmp & 0xfffff;
|
||||
memcpy(&ah_attr->grh.dgid, ah->av.rgid, 16);
|
||||
ah_attr->grh.hop_limit = ah->av.hop_limit;
|
||||
ah_attr->grh.traffic_class = ah->av.tclass;
|
||||
}
|
||||
ah_attr->dlid = be16_to_cpu(ah->av.rlid);
|
||||
ah_attr->static_rate = ah->av.stat_rate_sl >> 4;
|
||||
ah_attr->sl = ah->av.stat_rate_sl & 0xf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx5_ib_destroy_ah(struct ib_ah *ah)
|
||||
{
|
||||
kfree(to_mah(ah));
|
||||
return 0;
|
||||
}
|
1303
sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c
Normal file
1303
sys/dev/mlx5/mlx5_ib/mlx5_ib_cq.c
Normal file
File diff suppressed because it is too large
Load Diff
93
sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c
Normal file
93
sys/dev/mlx5/mlx5_ib/mlx5_ib_doorbell.c
Normal file
@ -0,0 +1,93 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <linux/kref.h>
|
||||
#include <linux/slab.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
|
||||
#include "mlx5_ib.h"
|
||||
|
||||
struct mlx5_ib_user_db_page {
|
||||
struct list_head list;
|
||||
struct ib_umem *umem;
|
||||
uintptr_t user_virt;
|
||||
int refcnt;
|
||||
};
|
||||
|
||||
int mlx5_ib_db_map_user(struct mlx5_ib_ucontext *context, uintptr_t virt,
|
||||
struct mlx5_db *db)
|
||||
{
|
||||
struct mlx5_ib_user_db_page *page;
|
||||
int err = 0;
|
||||
|
||||
mutex_lock(&context->db_page_mutex);
|
||||
|
||||
list_for_each_entry(page, &context->db_page_list, list)
|
||||
if (page->user_virt == (virt & PAGE_MASK))
|
||||
goto found;
|
||||
|
||||
page = kmalloc(sizeof(*page), GFP_KERNEL);
|
||||
if (!page) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
page->user_virt = (virt & PAGE_MASK);
|
||||
page->refcnt = 0;
|
||||
page->umem = ib_umem_get(&context->ibucontext, virt & PAGE_MASK,
|
||||
PAGE_SIZE, 0, 0);
|
||||
if (IS_ERR(page->umem)) {
|
||||
err = PTR_ERR(page->umem);
|
||||
kfree(page);
|
||||
goto out;
|
||||
}
|
||||
|
||||
list_add(&page->list, &context->db_page_list);
|
||||
|
||||
found:
|
||||
db->dma = sg_dma_address(page->umem->sg_head.sgl) + (virt & ~PAGE_MASK);
|
||||
db->u.user_page = page;
|
||||
++page->refcnt;
|
||||
|
||||
out:
|
||||
mutex_unlock(&context->db_page_mutex);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void mlx5_ib_db_unmap_user(struct mlx5_ib_ucontext *context, struct mlx5_db *db)
|
||||
{
|
||||
mutex_lock(&context->db_page_mutex);
|
||||
|
||||
if (!--db->u.user_page->refcnt) {
|
||||
list_del(&db->u.user_page->list);
|
||||
ib_umem_release(db->u.user_page->umem);
|
||||
kfree(db->u.user_page);
|
||||
}
|
||||
|
||||
mutex_unlock(&context->db_page_mutex);
|
||||
}
|
523
sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
Normal file
523
sys/dev/mlx5/mlx5_ib/mlx5_ib_mad.c
Normal file
@ -0,0 +1,523 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <rdma/ib_mad.h>
|
||||
#include <rdma/ib_smi.h>
|
||||
#include <rdma/ib_pma.h>
|
||||
#include "mlx5_ib.h"
|
||||
#include <dev/mlx5/vport.h>
|
||||
|
||||
enum {
|
||||
MLX5_IB_VENDOR_CLASS1 = 0x9,
|
||||
MLX5_IB_VENDOR_CLASS2 = 0xa
|
||||
};
|
||||
|
||||
int mlx5_MAD_IFC(struct mlx5_ib_dev *dev, int ignore_mkey, int ignore_bkey,
|
||||
u8 port, struct ib_wc *in_wc, struct ib_grh *in_grh,
|
||||
void *in_mad, void *response_mad)
|
||||
{
|
||||
u8 op_modifier = 0;
|
||||
|
||||
/* Key check traps can't be generated unless we have in_wc to
|
||||
* tell us where to send the trap.
|
||||
*/
|
||||
if (ignore_mkey || !in_wc)
|
||||
op_modifier |= 0x1;
|
||||
if (ignore_bkey || !in_wc)
|
||||
op_modifier |= 0x2;
|
||||
|
||||
return mlx5_core_mad_ifc(dev->mdev, in_mad, response_mad, op_modifier, port);
|
||||
}
|
||||
|
||||
static int process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
|
||||
struct ib_wc *in_wc, struct ib_grh *in_grh,
|
||||
struct ib_mad *in_mad, struct ib_mad *out_mad)
|
||||
{
|
||||
u16 slid;
|
||||
int err;
|
||||
|
||||
slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
|
||||
|
||||
if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && slid == 0)
|
||||
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
|
||||
|
||||
if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
|
||||
in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
|
||||
if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
|
||||
in_mad->mad_hdr.method != IB_MGMT_METHOD_SET &&
|
||||
in_mad->mad_hdr.method != IB_MGMT_METHOD_TRAP_REPRESS)
|
||||
return IB_MAD_RESULT_SUCCESS;
|
||||
|
||||
/* Don't process SMInfo queries -- the SMA can't handle them.
|
||||
*/
|
||||
if (in_mad->mad_hdr.attr_id == IB_SMP_ATTR_SM_INFO)
|
||||
return IB_MAD_RESULT_SUCCESS;
|
||||
} else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
|
||||
in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS1 ||
|
||||
in_mad->mad_hdr.mgmt_class == MLX5_IB_VENDOR_CLASS2 ||
|
||||
in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_CONG_MGMT) {
|
||||
if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
|
||||
in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
|
||||
return IB_MAD_RESULT_SUCCESS;
|
||||
} else {
|
||||
return IB_MAD_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
err = mlx5_MAD_IFC(to_mdev(ibdev),
|
||||
mad_flags & IB_MAD_IGNORE_MKEY,
|
||||
mad_flags & IB_MAD_IGNORE_BKEY,
|
||||
port_num, in_wc, in_grh, in_mad, out_mad);
|
||||
if (err)
|
||||
return IB_MAD_RESULT_FAILURE;
|
||||
|
||||
/* set return bit in status of directed route responses */
|
||||
if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
|
||||
out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
|
||||
|
||||
if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
|
||||
/* no response for trap repress */
|
||||
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_CONSUMED;
|
||||
|
||||
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
|
||||
}
|
||||
|
||||
static void pma_cnt_ext_assign(struct ib_pma_portcounters_ext *pma_cnt_ext,
|
||||
struct mlx5_vport_counters *vc)
|
||||
{
|
||||
pma_cnt_ext->port_xmit_data = cpu_to_be64((vc->transmitted_ib_unicast.octets +
|
||||
vc->transmitted_ib_multicast.octets) >> 2);
|
||||
pma_cnt_ext->port_rcv_data = cpu_to_be64((vc->received_ib_unicast.octets +
|
||||
vc->received_ib_multicast.octets) >> 2);
|
||||
pma_cnt_ext->port_xmit_packets = cpu_to_be64(vc->transmitted_ib_unicast.packets +
|
||||
vc->transmitted_ib_multicast.packets);
|
||||
pma_cnt_ext->port_rcv_packets = cpu_to_be64(vc->received_ib_unicast.packets +
|
||||
vc->received_ib_multicast.packets);
|
||||
pma_cnt_ext->port_unicast_xmit_packets = cpu_to_be64(vc->transmitted_ib_unicast.packets);
|
||||
pma_cnt_ext->port_unicast_rcv_packets = cpu_to_be64(vc->received_ib_unicast.packets);
|
||||
pma_cnt_ext->port_multicast_xmit_packets = cpu_to_be64(vc->transmitted_ib_multicast.packets);
|
||||
pma_cnt_ext->port_multicast_rcv_packets = cpu_to_be64(vc->received_ib_multicast.packets);
|
||||
}
|
||||
|
||||
static void pma_cnt_assign(struct ib_pma_portcounters *pma_cnt,
|
||||
struct mlx5_vport_counters *vc)
|
||||
{
|
||||
ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
|
||||
(vc->transmitted_ib_unicast.octets +
|
||||
vc->transmitted_ib_multicast.octets) >> 2);
|
||||
ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
|
||||
(vc->received_ib_unicast.octets +
|
||||
vc->received_ib_multicast.octets) >> 2);
|
||||
ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
|
||||
vc->transmitted_ib_unicast.packets +
|
||||
vc->transmitted_ib_multicast.packets);
|
||||
ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
|
||||
vc->received_ib_unicast.packets +
|
||||
vc->received_ib_multicast.packets);
|
||||
}
|
||||
|
||||
static int process_pma_cmd(struct ib_device *ibdev, u8 port_num,
|
||||
struct ib_mad *in_mad, struct ib_mad *out_mad)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibdev);
|
||||
struct mlx5_vport_counters *vc;
|
||||
int err;
|
||||
int ext;
|
||||
|
||||
vc = kzalloc(sizeof(*vc), GFP_KERNEL);
|
||||
if (!vc)
|
||||
return -ENOMEM;
|
||||
|
||||
ext = in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT;
|
||||
|
||||
err = mlx5_get_vport_counters(dev->mdev, port_num, vc);
|
||||
if (!err) {
|
||||
if (ext) {
|
||||
struct ib_pma_portcounters_ext *pma_cnt_ext =
|
||||
(struct ib_pma_portcounters_ext *)(out_mad->data + 40);
|
||||
|
||||
pma_cnt_ext_assign(pma_cnt_ext, vc);
|
||||
} else {
|
||||
struct ib_pma_portcounters *pma_cnt =
|
||||
(struct ib_pma_portcounters *)(out_mad->data + 40);
|
||||
|
||||
ASSIGN_16BIT_COUNTER(pma_cnt->port_rcv_errors,
|
||||
(u16)vc->received_errors.packets);
|
||||
|
||||
pma_cnt_assign(pma_cnt, vc);
|
||||
}
|
||||
err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
|
||||
}
|
||||
|
||||
kfree(vc);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
|
||||
struct ib_wc *in_wc, struct ib_grh *in_grh,
|
||||
struct ib_mad *in_mad, struct ib_mad *out_mad)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibdev);
|
||||
struct mlx5_core_dev *mdev = dev->mdev;
|
||||
|
||||
memset(out_mad->data, 0, sizeof(out_mad->data));
|
||||
|
||||
if (MLX5_CAP_GEN(mdev, vport_counters) &&
|
||||
in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
|
||||
in_mad->mad_hdr.method == IB_MGMT_METHOD_GET) {
|
||||
/* TBD: read error counters from the PPCNT */
|
||||
return process_pma_cmd(ibdev, port_num, in_mad, out_mad);
|
||||
} else {
|
||||
return process_mad(ibdev, mad_flags, port_num, in_wc, in_grh,
|
||||
in_mad, out_mad);
|
||||
}
|
||||
}
|
||||
|
||||
int mlx5_query_ext_port_caps(struct mlx5_ib_dev *dev, u8 port)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
u16 packet_error;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO;
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);
|
||||
|
||||
packet_error = be16_to_cpu(out_mad->status);
|
||||
|
||||
dev->mdev->port_caps[port - 1].ext_port_cap = (!err && !packet_error) ?
|
||||
MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO : 0;
|
||||
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_smp_attr_node_info_mad_ifc(struct ib_device *ibdev,
|
||||
struct ib_smp *out_mad)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
if (!in_mad)
|
||||
return -ENOMEM;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
|
||||
|
||||
err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, 1, NULL, NULL, in_mad,
|
||||
out_mad);
|
||||
|
||||
kfree(in_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_system_image_guid_mad_ifc(struct ib_device *ibdev,
|
||||
__be64 *sys_image_guid)
|
||||
{
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!out_mad)
|
||||
return -ENOMEM;
|
||||
|
||||
err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
memcpy(sys_image_guid, out_mad->data + 4, 8);
|
||||
|
||||
out:
|
||||
kfree(out_mad);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_max_pkeys_mad_ifc(struct ib_device *ibdev,
|
||||
u16 *max_pkeys)
|
||||
{
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!out_mad)
|
||||
return -ENOMEM;
|
||||
|
||||
err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
*max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28));
|
||||
|
||||
out:
|
||||
kfree(out_mad);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_vendor_id_mad_ifc(struct ib_device *ibdev,
|
||||
u32 *vendor_id)
|
||||
{
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!out_mad)
|
||||
return -ENOMEM;
|
||||
|
||||
err = mlx5_query_smp_attr_node_info_mad_ifc(ibdev, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
*vendor_id = be32_to_cpup((__be32 *)(out_mad->data + 36)) & 0xffff;
|
||||
|
||||
out:
|
||||
kfree(out_mad);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_node_desc_mad_ifc(struct mlx5_ib_dev *dev, char *node_desc)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_DESC;
|
||||
|
||||
err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
memcpy(node_desc, out_mad->data, 64);
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_node_guid_mad_ifc(struct mlx5_ib_dev *dev, u64 *node_guid)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;
|
||||
|
||||
err = mlx5_MAD_IFC(dev, 1, 1, 1, NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_pkey_mad_ifc(struct ib_device *ibdev, u8 port, u16 index,
|
||||
u16 *pkey)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_PKEY_TABLE;
|
||||
in_mad->attr_mod = cpu_to_be32(index / 32);
|
||||
|
||||
err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad,
|
||||
out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
*pkey = be16_to_cpu(((__be16 *)out_mad->data)[index % 32]);
|
||||
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_gids_mad_ifc(struct ib_device *ibdev, u8 port, int index,
|
||||
union ib_gid *gid)
|
||||
{
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int err = -ENOMEM;
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad,
|
||||
out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
memcpy(gid->raw, out_mad->data + 8, 8);
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_GUID_INFO;
|
||||
in_mad->attr_mod = cpu_to_be32(index / 8);
|
||||
|
||||
err = mlx5_MAD_IFC(to_mdev(ibdev), 1, 1, port, NULL, NULL, in_mad,
|
||||
out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8);
|
||||
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_port_mad_ifc(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibdev);
|
||||
struct mlx5_core_dev *mdev = dev->mdev;
|
||||
struct ib_smp *in_mad = NULL;
|
||||
struct ib_smp *out_mad = NULL;
|
||||
int ext_active_speed;
|
||||
int err = -ENOMEM;
|
||||
|
||||
if (port < 1 || port > MLX5_CAP_GEN(mdev, num_ports)) {
|
||||
mlx5_ib_warn(dev, "invalid port number %d\n", port);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
in_mad = kzalloc(sizeof(*in_mad), GFP_KERNEL);
|
||||
out_mad = kmalloc(sizeof(*out_mad), GFP_KERNEL);
|
||||
if (!in_mad || !out_mad)
|
||||
goto out;
|
||||
|
||||
memset(props, 0, sizeof(*props));
|
||||
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = IB_SMP_ATTR_PORT_INFO;
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mlx5_MAD_IFC(dev, 1, 1, port, NULL, NULL, in_mad, out_mad);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "err %d\n", err);
|
||||
goto out;
|
||||
}
|
||||
|
||||
props->lid = be16_to_cpup((__be16 *)(out_mad->data + 16));
|
||||
props->lmc = out_mad->data[34] & 0x7;
|
||||
props->sm_lid = be16_to_cpup((__be16 *)(out_mad->data + 18));
|
||||
props->sm_sl = out_mad->data[36] & 0xf;
|
||||
props->state = out_mad->data[32] & 0xf;
|
||||
props->phys_state = out_mad->data[33] >> 4;
|
||||
props->port_cap_flags = be32_to_cpup((__be32 *)(out_mad->data + 20));
|
||||
props->gid_tbl_len = out_mad->data[50];
|
||||
props->max_msg_sz = 1 << MLX5_CAP_GEN(mdev, log_max_msg);
|
||||
props->pkey_tbl_len = mdev->port_caps[port - 1].pkey_table_len;
|
||||
props->bad_pkey_cntr = be16_to_cpup((__be16 *)(out_mad->data + 46));
|
||||
props->qkey_viol_cntr = be16_to_cpup((__be16 *)(out_mad->data + 48));
|
||||
props->active_width = out_mad->data[31] & 0xf;
|
||||
props->active_speed = out_mad->data[35] >> 4;
|
||||
props->max_mtu = out_mad->data[41] & 0xf;
|
||||
props->active_mtu = out_mad->data[36] >> 4;
|
||||
props->subnet_timeout = out_mad->data[51] & 0x1f;
|
||||
props->max_vl_num = out_mad->data[37] >> 4;
|
||||
props->init_type_reply = out_mad->data[41] >> 4;
|
||||
|
||||
/* Check if extended speeds (EDR/FDR/...) are supported */
|
||||
if (props->port_cap_flags & IB_PORT_EXTENDED_SPEEDS_SUP) {
|
||||
ext_active_speed = out_mad->data[62] >> 4;
|
||||
|
||||
switch (ext_active_speed) {
|
||||
case 1:
|
||||
props->active_speed = 16; /* FDR */
|
||||
break;
|
||||
case 2:
|
||||
props->active_speed = 32; /* EDR */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If reported active speed is QDR, check if is FDR-10 */
|
||||
if (props->active_speed == 4) {
|
||||
if (mdev->port_caps[port - 1].ext_port_cap &
|
||||
MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO) {
|
||||
init_query_mad(in_mad);
|
||||
in_mad->attr_id = MLX5_ATTR_EXTENDED_PORT_INFO;
|
||||
in_mad->attr_mod = cpu_to_be32(port);
|
||||
|
||||
err = mlx5_MAD_IFC(dev, 1, 1, port,
|
||||
NULL, NULL, in_mad, out_mad);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
/* Checking LinkSpeedActive for FDR-10 */
|
||||
if (out_mad->data[15] & 0x1)
|
||||
props->active_speed = 8;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
kfree(in_mad);
|
||||
kfree(out_mad);
|
||||
|
||||
return err;
|
||||
}
|
2310
sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
Normal file
2310
sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
Normal file
File diff suppressed because it is too large
Load Diff
185
sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c
Normal file
185
sys/dev/mlx5/mlx5_ib/mlx5_ib_mem.c
Normal file
@ -0,0 +1,185 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
#include "mlx5_ib.h"
|
||||
|
||||
/* @umem: umem object to scan
|
||||
* @addr: ib virtual address requested by the user
|
||||
* @count: number of PAGE_SIZE pages covered by umem
|
||||
* @shift: page shift for the compound pages found in the region
|
||||
* @ncont: number of compund pages
|
||||
* @order: log2 of the number of compound pages
|
||||
*/
|
||||
|
||||
void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
|
||||
int *ncont, int *order)
|
||||
{
|
||||
uintptr_t tmp;
|
||||
unsigned long m;
|
||||
int i, k;
|
||||
u64 base = 0;
|
||||
int p = 0;
|
||||
int skip;
|
||||
int mask;
|
||||
u64 len;
|
||||
u64 pfn;
|
||||
struct scatterlist *sg;
|
||||
int entry;
|
||||
unsigned long page_shift = ilog2(umem->page_size);
|
||||
|
||||
addr = addr >> page_shift;
|
||||
tmp = (uintptr_t)addr;
|
||||
m = find_first_bit(&tmp, 8 * sizeof(tmp));
|
||||
skip = 1 << m;
|
||||
mask = skip - 1;
|
||||
i = 0;
|
||||
|
||||
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
|
||||
len = sg_dma_len(sg) >> page_shift;
|
||||
pfn = sg_dma_address(sg) >> page_shift;
|
||||
for (k = 0; k < len; k++) {
|
||||
if (!(i & mask)) {
|
||||
tmp = (uintptr_t)pfn;
|
||||
m = min_t(unsigned long, m,
|
||||
find_first_bit(&tmp, 8 * sizeof(tmp)));
|
||||
skip = 1 << m;
|
||||
mask = skip - 1;
|
||||
base = pfn;
|
||||
p = 0;
|
||||
} else {
|
||||
if (base + p != pfn) {
|
||||
tmp = (uintptr_t)p;
|
||||
m = find_first_bit(&tmp, 8 * sizeof(tmp));
|
||||
skip = 1 << m;
|
||||
mask = skip - 1;
|
||||
base = pfn;
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
p++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (i) {
|
||||
m = min_t(unsigned long, ilog2(roundup_pow_of_two(i)), m);
|
||||
|
||||
if (order)
|
||||
*order = ilog2(roundup_pow_of_two(i) >> m);
|
||||
|
||||
*ncont = DIV_ROUND_UP(i, (1 << m));
|
||||
} else {
|
||||
m = 0;
|
||||
|
||||
if (order)
|
||||
*order = 0;
|
||||
|
||||
*ncont = 0;
|
||||
}
|
||||
*shift = page_shift + m;
|
||||
*count = i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Populate the given array with bus addresses from the umem.
|
||||
*
|
||||
* dev - mlx5_ib device
|
||||
* umem - umem to use to fill the pages
|
||||
* page_shift - determines the page size used in the resulting array
|
||||
* offset - offset into the umem to start from,
|
||||
* only implemented for ODP umems
|
||||
* num_pages - total number of pages to fill
|
||||
* pas - bus addresses array to fill
|
||||
* access_flags - access flags to set on all present pages.
|
||||
use enum mlx5_ib_mtt_access_flags for this.
|
||||
*/
|
||||
static void __mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, size_t offset,
|
||||
__be64 *pas, int access_flags)
|
||||
{
|
||||
unsigned long umem_page_shift = ilog2(umem->page_size);
|
||||
int shift = page_shift - umem_page_shift;
|
||||
int mask = (1 << shift) - 1;
|
||||
int i, k;
|
||||
u64 cur = 0;
|
||||
u64 base;
|
||||
int len;
|
||||
struct scatterlist *sg;
|
||||
int entry;
|
||||
|
||||
i = 0;
|
||||
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
|
||||
len = sg_dma_len(sg) >> umem_page_shift;
|
||||
base = sg_dma_address(sg);
|
||||
for (k = 0; k < len; k++) {
|
||||
if (!(i & mask)) {
|
||||
cur = base + (k << umem_page_shift);
|
||||
cur |= access_flags;
|
||||
|
||||
pas[i >> shift] = cpu_to_be64(cur);
|
||||
mlx5_ib_dbg(dev, "pas[%d] 0x%llx\n",
|
||||
i >> shift, (unsigned long long)
|
||||
be64_to_cpu(pas[i >> shift]));
|
||||
} else
|
||||
mlx5_ib_dbg(dev, "=====> 0x%llx\n",
|
||||
(unsigned long long)
|
||||
(base + (k << umem_page_shift)));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mlx5_ib_populate_pas(struct mlx5_ib_dev *dev, struct ib_umem *umem,
|
||||
int page_shift, __be64 *pas, int access_flags)
|
||||
{
|
||||
return __mlx5_ib_populate_pas(dev, umem, page_shift, 0,
|
||||
pas,
|
||||
access_flags);
|
||||
}
|
||||
|
||||
int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset)
|
||||
{
|
||||
u64 page_size;
|
||||
u64 page_mask;
|
||||
u64 off_size;
|
||||
u64 off_mask;
|
||||
u64 buf_off;
|
||||
|
||||
page_size = (u64)1 << page_shift;
|
||||
page_mask = page_size - 1;
|
||||
buf_off = addr & page_mask;
|
||||
off_size = page_size >> 6;
|
||||
off_mask = off_size - 1;
|
||||
|
||||
if (buf_off & off_mask)
|
||||
return -EINVAL;
|
||||
|
||||
*offset = (u32)(buf_off >> ilog2(off_size));
|
||||
return 0;
|
||||
}
|
1310
sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
Normal file
1310
sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
Normal file
File diff suppressed because it is too large
Load Diff
2995
sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
Normal file
2995
sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
Normal file
File diff suppressed because it is too large
Load Diff
252
sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c
Normal file
252
sys/dev/mlx5/mlx5_ib/mlx5_ib_roce.c
Normal file
@ -0,0 +1,252 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/inetdevice.h>
|
||||
#include <dev/mlx5/vport.h>
|
||||
#include <net/ipv6.h>
|
||||
#include <rdma/ib_addr.h>
|
||||
#include <rdma/ib_cache.h>
|
||||
#include "mlx5_ib.h"
|
||||
|
||||
struct net_device *mlx5_ib_get_netdev(struct ib_device *ib_dev, u8 port)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ib_dev);
|
||||
|
||||
return mlx5_get_protocol_dev(dev->mdev, MLX5_INTERFACE_PROTOCOL_ETH);
|
||||
}
|
||||
|
||||
|
||||
static void ib_gid_to_mlx5_roce_addr(const union ib_gid *gid,
|
||||
struct net_device *ndev,
|
||||
void *mlx5_addr)
|
||||
{
|
||||
#define MLX5_SET_RA(p, f, v) MLX5_SET(roce_addr_layout, p, f, v)
|
||||
char *mlx5_addr_l3_addr = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
|
||||
source_l3_address);
|
||||
void *mlx5_addr_mac = MLX5_ADDR_OF(roce_addr_layout, mlx5_addr,
|
||||
source_mac_47_32);
|
||||
union ib_gid zgid;
|
||||
u16 vtag;
|
||||
|
||||
memset(&zgid, 0, sizeof(zgid));
|
||||
if (0 == memcmp(gid, &zgid, sizeof(zgid)))
|
||||
return;
|
||||
|
||||
ether_addr_copy(mlx5_addr_mac, IF_LLADDR(ndev));
|
||||
|
||||
if (VLAN_TAG(ndev, &vtag) == 0) {
|
||||
MLX5_SET_RA(mlx5_addr, vlan_valid, 1);
|
||||
MLX5_SET_RA(mlx5_addr, vlan_id, vtag);
|
||||
}
|
||||
|
||||
#ifndef MLX5_USE_ROCE_VERSION_2
|
||||
MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_1);
|
||||
|
||||
memcpy(mlx5_addr_l3_addr, gid, sizeof(*gid));
|
||||
#else
|
||||
MLX5_SET_RA(mlx5_addr, roce_version, MLX5_ROCE_VERSION_2);
|
||||
|
||||
if (ipv6_addr_v4mapped((void *)gid)) {
|
||||
MLX5_SET_RA(mlx5_addr, roce_l3_type,
|
||||
MLX5_ROCE_L3_TYPE_IPV4);
|
||||
memcpy(&mlx5_addr_l3_addr[12], &gid->raw[12], 4);
|
||||
} else {
|
||||
MLX5_SET_RA(mlx5_addr, roce_l3_type,
|
||||
MLX5_ROCE_L3_TYPE_IPV6);
|
||||
memcpy(mlx5_addr_l3_addr, gid, sizeof(*gid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int modify_gid_roce(struct ib_device *ib_dev, u8 port, unsigned int index,
|
||||
const union ib_gid *gid, struct net_device *ndev)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ib_dev);
|
||||
u32 in[MLX5_ST_SZ_DW(set_roce_address_in)];
|
||||
u32 out[MLX5_ST_SZ_DW(set_roce_address_out)];
|
||||
void *in_addr = MLX5_ADDR_OF(set_roce_address_in, in, roce_address);
|
||||
|
||||
memset(in, 0, sizeof(in));
|
||||
|
||||
ib_gid_to_mlx5_roce_addr(gid, ndev, in_addr);
|
||||
|
||||
MLX5_SET(set_roce_address_in, in, roce_address_index, index);
|
||||
MLX5_SET(set_roce_address_in, in, opcode, MLX5_CMD_OP_SET_ROCE_ADDRESS);
|
||||
|
||||
memset(out, 0, sizeof(out));
|
||||
return mlx5_cmd_exec(dev->mdev, in, sizeof(in), out, sizeof(out));
|
||||
}
|
||||
|
||||
static int translate_eth_proto_oper(u32 eth_proto_oper, u8 *active_speed,
|
||||
u8 *active_width)
|
||||
{
|
||||
switch (eth_proto_oper) {
|
||||
case MLX5_PROT_MASK(MLX5_1000BASE_CX_SGMII):
|
||||
case MLX5_PROT_MASK(MLX5_1000BASE_KX):
|
||||
case MLX5_PROT_MASK(MLX5_100BASE_TX):
|
||||
case MLX5_PROT_MASK(MLX5_1000BASE_T):
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_SDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_T):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_CX4):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_KX4):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_KR):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_CR):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_SR):
|
||||
case MLX5_PROT_MASK(MLX5_10GBASE_ER):
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_QDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_25GBASE_CR):
|
||||
case MLX5_PROT_MASK(MLX5_25GBASE_KR):
|
||||
case MLX5_PROT_MASK(MLX5_25GBASE_SR):
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_EDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_40GBASE_CR4):
|
||||
case MLX5_PROT_MASK(MLX5_40GBASE_KR4):
|
||||
case MLX5_PROT_MASK(MLX5_40GBASE_SR4):
|
||||
case MLX5_PROT_MASK(MLX5_40GBASE_LR4):
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_QDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_50GBASE_CR2):
|
||||
case MLX5_PROT_MASK(MLX5_50GBASE_KR2):
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_FDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_56GBASE_R4):
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_FDR;
|
||||
break;
|
||||
case MLX5_PROT_MASK(MLX5_100GBASE_CR4):
|
||||
case MLX5_PROT_MASK(MLX5_100GBASE_SR4):
|
||||
case MLX5_PROT_MASK(MLX5_100GBASE_KR4):
|
||||
case MLX5_PROT_MASK(MLX5_100GBASE_LR4):
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_EDR;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlx5_query_roce_port_ptys(struct ib_device *ib_dev,
|
||||
struct ib_port_attr *props, u8 port)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ib_dev);
|
||||
struct mlx5_core_dev *mdev = dev->mdev;
|
||||
struct mlx5_ptys_reg *ptys;
|
||||
int err;
|
||||
|
||||
ptys = kzalloc(sizeof(*ptys), GFP_KERNEL);
|
||||
if (!ptys)
|
||||
return -ENOMEM;
|
||||
|
||||
ptys->proto_mask |= MLX5_PTYS_EN;
|
||||
ptys->local_port = port;
|
||||
|
||||
err = mlx5_core_access_ptys(mdev, ptys, 0);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = translate_eth_proto_oper(ptys->eth_proto_oper,
|
||||
&props->active_speed,
|
||||
&props->active_width);
|
||||
out:
|
||||
kfree(ptys);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mlx5_query_port_roce(struct ib_device *ib_dev, u8 port,
|
||||
struct ib_port_attr *props)
|
||||
{
|
||||
struct net_device *netdev = mlx5_ib_get_netdev(ib_dev, port);
|
||||
struct mlx5_ib_dev *dev = to_mdev(ib_dev);
|
||||
enum ib_mtu netdev_ib_mtu;
|
||||
|
||||
memset(props, 0, sizeof(*props));
|
||||
|
||||
props->port_cap_flags |= IB_PORT_CM_SUP;
|
||||
|
||||
props->gid_tbl_len = MLX5_CAP_ROCE(dev->mdev,
|
||||
roce_address_table_size);
|
||||
props->max_mtu = IB_MTU_4096;
|
||||
props->max_msg_sz = 1 << MLX5_CAP_GEN(dev->mdev, log_max_msg);
|
||||
props->pkey_tbl_len = 1;
|
||||
props->state = IB_PORT_DOWN;
|
||||
props->phys_state = 3;
|
||||
|
||||
if (mlx5_query_nic_vport_qkey_viol_cntr(dev->mdev,
|
||||
(u16 *)&props->qkey_viol_cntr))
|
||||
printf("mlx5_ib: WARN: ""%s failed to query qkey violations counter\n", __func__);
|
||||
|
||||
|
||||
if (!netdev)
|
||||
return 0;
|
||||
|
||||
if (netif_running(netdev) && netif_carrier_ok(netdev)) {
|
||||
props->state = IB_PORT_ACTIVE;
|
||||
props->phys_state = 5;
|
||||
}
|
||||
|
||||
netdev_ib_mtu = iboe_get_mtu(netdev->if_mtu);
|
||||
props->active_mtu = min(props->max_mtu, netdev_ib_mtu);
|
||||
|
||||
mlx5_query_roce_port_ptys(ib_dev, props, port);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
__be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port,
|
||||
int index, __be16 ah_s_udp_port)
|
||||
{
|
||||
#ifndef MLX5_USE_ROCE_VERSION_2
|
||||
return 0;
|
||||
#else
|
||||
return cpu_to_be16(MLX5_CAP_ROCE(dev->mdev, r_roce_min_src_udp_port));
|
||||
#endif
|
||||
}
|
||||
|
||||
int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port,
|
||||
int index, int *gid_type)
|
||||
{
|
||||
union ib_gid gid;
|
||||
int ret;
|
||||
|
||||
ret = ib_get_cached_gid(&dev->ib_dev, port, index, &gid);
|
||||
|
||||
if (!ret)
|
||||
*gid_type = -1;
|
||||
|
||||
return ret;
|
||||
}
|
503
sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c
Normal file
503
sys/dev/mlx5/mlx5_ib/mlx5_ib_srq.c
Normal file
@ -0,0 +1,503 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <dev/mlx5/qp.h>
|
||||
#include <dev/mlx5/srq.h>
|
||||
#include <linux/slab.h>
|
||||
#include <rdma/ib_umem.h>
|
||||
#include <rdma/ib_user_verbs.h>
|
||||
|
||||
#include "mlx5_ib.h"
|
||||
#include "user.h"
|
||||
|
||||
/* not supported currently */
|
||||
static int srq_signature;
|
||||
|
||||
static void *get_wqe(struct mlx5_ib_srq *srq, int n)
|
||||
{
|
||||
return mlx5_buf_offset(&srq->buf, n << srq->msrq.wqe_shift);
|
||||
}
|
||||
|
||||
static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, int type)
|
||||
{
|
||||
struct ib_event event;
|
||||
struct ib_srq *ibsrq = &to_mibsrq(srq)->ibsrq;
|
||||
|
||||
if (ibsrq->event_handler) {
|
||||
event.device = ibsrq->device;
|
||||
event.element.srq = ibsrq;
|
||||
switch (type) {
|
||||
case MLX5_EVENT_TYPE_SRQ_RQ_LIMIT:
|
||||
event.event = IB_EVENT_SRQ_LIMIT_REACHED;
|
||||
break;
|
||||
case MLX5_EVENT_TYPE_SRQ_CATAS_ERROR:
|
||||
event.event = IB_EVENT_SRQ_ERR;
|
||||
break;
|
||||
default:
|
||||
printf("mlx5_ib: WARN: ""mlx5_ib: Unexpected event type %d on SRQ %06x\n", type, srq->srqn);
|
||||
return;
|
||||
}
|
||||
|
||||
ibsrq->event_handler(&event, ibsrq->srq_context);
|
||||
}
|
||||
}
|
||||
|
||||
static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
|
||||
struct mlx5_create_srq_mbox_in **in,
|
||||
struct ib_udata *udata, int buf_size, int *inlen)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
struct mlx5_ib_create_srq ucmd;
|
||||
size_t ucmdlen;
|
||||
void *xsrqc;
|
||||
int err;
|
||||
int npages;
|
||||
int page_shift;
|
||||
int ncont;
|
||||
int drv_data = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr);
|
||||
u32 offset;
|
||||
|
||||
ucmdlen = (drv_data < sizeof(ucmd)) ?
|
||||
drv_data : sizeof(ucmd);
|
||||
|
||||
if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) {
|
||||
mlx5_ib_err(dev, "failed copy udata\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (ucmdlen == sizeof(ucmd) &&
|
||||
ucmd.reserved1 != 0) {
|
||||
mlx5_ib_warn(dev, "corrupted ucmd\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
srq->wq_sig = !!(ucmd.flags & MLX5_SRQ_FLAG_SIGNATURE);
|
||||
|
||||
srq->umem = ib_umem_get(pd->uobject->context, ucmd.buf_addr, buf_size,
|
||||
0, 0);
|
||||
if (IS_ERR(srq->umem)) {
|
||||
mlx5_ib_warn(dev, "failed umem get, size %d\n", buf_size);
|
||||
err = PTR_ERR(srq->umem);
|
||||
return err;
|
||||
}
|
||||
|
||||
mlx5_ib_cont_pages(srq->umem, ucmd.buf_addr, &npages,
|
||||
&page_shift, &ncont, NULL);
|
||||
err = mlx5_ib_get_buf_offset(ucmd.buf_addr, page_shift,
|
||||
&offset);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "bad offset\n");
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
*inlen = sizeof(**in) + sizeof(*(*in)->pas) * ncont;
|
||||
*in = mlx5_vzalloc(*inlen);
|
||||
if (!(*in)) {
|
||||
mlx5_ib_err(dev, "failed allocate mbox\n");
|
||||
err = -ENOMEM;
|
||||
goto err_umem;
|
||||
}
|
||||
|
||||
mlx5_ib_populate_pas(dev, srq->umem, page_shift, (*in)->pas, 0);
|
||||
|
||||
err = mlx5_ib_db_map_user(to_mucontext(pd->uobject->context),
|
||||
ucmd.db_addr, &srq->db);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "map doorbell failed\n");
|
||||
goto err_in;
|
||||
}
|
||||
|
||||
(*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
(*in)->ctx.pgoff_cqn = cpu_to_be32(offset << 26);
|
||||
|
||||
if (MLX5_CAP_GEN(dev->mdev, cqe_version)) {
|
||||
xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
|
||||
xrc_srq_context_entry);
|
||||
/* 0xffffff means we ask to work with cqe version 0 */
|
||||
if (drv_data > offsetof(struct mlx5_ib_create_srq, uidx))
|
||||
MLX5_SET(xrc_srqc, xsrqc, user_index, ucmd.uidx);
|
||||
else
|
||||
MLX5_SET(xrc_srqc, xsrqc, user_index, 0xffffff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_in:
|
||||
kvfree(*in);
|
||||
|
||||
err_umem:
|
||||
ib_umem_release(srq->umem);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
|
||||
struct mlx5_create_srq_mbox_in **in, int buf_size,
|
||||
int *inlen)
|
||||
{
|
||||
int err;
|
||||
int i;
|
||||
struct mlx5_wqe_srq_next_seg *next;
|
||||
int page_shift;
|
||||
void *xsrqc;
|
||||
|
||||
err = mlx5_db_alloc(dev->mdev, &srq->db);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "alloc dbell rec failed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
if (mlx5_buf_alloc(dev->mdev, buf_size, PAGE_SIZE * 2, &srq->buf)) {
|
||||
mlx5_ib_err(dev, "buf alloc failed\n");
|
||||
err = -ENOMEM;
|
||||
goto err_db;
|
||||
}
|
||||
page_shift = srq->buf.page_shift;
|
||||
|
||||
srq->head = 0;
|
||||
srq->tail = srq->msrq.max - 1;
|
||||
srq->wqe_ctr = 0;
|
||||
|
||||
for (i = 0; i < srq->msrq.max; i++) {
|
||||
next = get_wqe(srq, i);
|
||||
next->next_wqe_index =
|
||||
cpu_to_be16((i + 1) & (srq->msrq.max - 1));
|
||||
}
|
||||
|
||||
*inlen = sizeof(**in) + sizeof(*(*in)->pas) * srq->buf.npages;
|
||||
*in = mlx5_vzalloc(*inlen);
|
||||
if (!*in) {
|
||||
mlx5_ib_err(dev, "failed allocate mbox\n");
|
||||
err = -ENOMEM;
|
||||
goto err_buf;
|
||||
}
|
||||
mlx5_fill_page_array(&srq->buf, (*in)->pas);
|
||||
|
||||
srq->wrid = kmalloc(srq->msrq.max * sizeof(u64), GFP_KERNEL);
|
||||
if (!srq->wrid) {
|
||||
err = -ENOMEM;
|
||||
goto err_in;
|
||||
}
|
||||
srq->wq_sig = !!srq_signature;
|
||||
|
||||
(*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
|
||||
|
||||
if (MLX5_CAP_GEN(dev->mdev, cqe_version)) {
|
||||
xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
|
||||
xrc_srq_context_entry);
|
||||
/* 0xffffff means we ask to work with cqe version 0 */
|
||||
MLX5_SET(xrc_srqc, xsrqc, user_index, 0xffffff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_in:
|
||||
kvfree(*in);
|
||||
|
||||
err_buf:
|
||||
mlx5_buf_free(dev->mdev, &srq->buf);
|
||||
|
||||
err_db:
|
||||
mlx5_db_free(dev->mdev, &srq->db);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void destroy_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq)
|
||||
{
|
||||
mlx5_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db);
|
||||
ib_umem_release(srq->umem);
|
||||
}
|
||||
|
||||
|
||||
static void destroy_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq)
|
||||
{
|
||||
kfree(srq->wrid);
|
||||
mlx5_buf_free(dev->mdev, &srq->buf);
|
||||
mlx5_db_free(dev->mdev, &srq->db);
|
||||
}
|
||||
|
||||
struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
|
||||
struct ib_srq_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(pd->device);
|
||||
struct mlx5_ib_srq *srq;
|
||||
int desc_size;
|
||||
int buf_size;
|
||||
int err;
|
||||
struct mlx5_create_srq_mbox_in *uninitialized_var(in);
|
||||
int uninitialized_var(inlen);
|
||||
int is_xrc;
|
||||
u32 flgs, xrcdn;
|
||||
__u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz);
|
||||
|
||||
/* Sanity check SRQ size before proceeding */
|
||||
if (init_attr->attr.max_wr >= max_srq_wqes) {
|
||||
mlx5_ib_warn(dev, "max_wr %d, cap %d\n",
|
||||
init_attr->attr.max_wr,
|
||||
max_srq_wqes);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
srq = kmalloc(sizeof(*srq), GFP_KERNEL);
|
||||
if (!srq)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mutex_init(&srq->mutex);
|
||||
spin_lock_init(&srq->lock);
|
||||
srq->msrq.max = roundup_pow_of_two(init_attr->attr.max_wr + 1);
|
||||
srq->msrq.max_gs = init_attr->attr.max_sge;
|
||||
|
||||
desc_size = sizeof(struct mlx5_wqe_srq_next_seg) +
|
||||
srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg);
|
||||
desc_size = roundup_pow_of_two(desc_size);
|
||||
desc_size = max_t(int, 32, desc_size);
|
||||
srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) /
|
||||
sizeof(struct mlx5_wqe_data_seg);
|
||||
srq->msrq.wqe_shift = ilog2(desc_size);
|
||||
buf_size = srq->msrq.max * desc_size;
|
||||
mlx5_ib_dbg(dev, "desc_size 0x%x, req wr 0x%x, srq size 0x%x, max_gs 0x%x, max_avail_gather 0x%x\n",
|
||||
desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs,
|
||||
srq->msrq.max_avail_gather);
|
||||
|
||||
if (pd->uobject)
|
||||
err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen);
|
||||
else
|
||||
err = create_srq_kernel(dev, srq, &in, buf_size, &inlen);
|
||||
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "create srq %s failed, err %d\n",
|
||||
pd->uobject ? "user" : "kernel", err);
|
||||
goto err_srq;
|
||||
}
|
||||
|
||||
is_xrc = (init_attr->srq_type == IB_SRQT_XRC);
|
||||
in->ctx.state_log_sz = ilog2(srq->msrq.max);
|
||||
flgs = ((srq->msrq.wqe_shift - 4) | (is_xrc << 5) | (srq->wq_sig << 7)) << 24;
|
||||
xrcdn = 0;
|
||||
if (is_xrc) {
|
||||
xrcdn = to_mxrcd(init_attr->ext.xrc.xrcd)->xrcdn;
|
||||
in->ctx.pgoff_cqn |= cpu_to_be32(to_mcq(init_attr->ext.xrc.cq)->mcq.cqn);
|
||||
} else if (init_attr->srq_type == IB_SRQT_BASIC) {
|
||||
xrcdn = to_mxrcd(dev->devr.x0)->xrcdn;
|
||||
in->ctx.pgoff_cqn |= cpu_to_be32(to_mcq(dev->devr.c0)->mcq.cqn);
|
||||
}
|
||||
|
||||
in->ctx.flags_xrcd = cpu_to_be32((flgs & 0xFF000000) | (xrcdn & 0xFFFFFF));
|
||||
|
||||
in->ctx.pd = cpu_to_be32(to_mpd(pd)->pdn);
|
||||
in->ctx.db_record = cpu_to_be64(srq->db.dma);
|
||||
err = mlx5_core_create_srq(dev->mdev, &srq->msrq, in, inlen, is_xrc);
|
||||
kvfree(in);
|
||||
if (err) {
|
||||
mlx5_ib_warn(dev, "create SRQ failed, err %d\n", err);
|
||||
goto err_usr_kern_srq;
|
||||
}
|
||||
|
||||
mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn);
|
||||
|
||||
srq->msrq.event = mlx5_ib_srq_event;
|
||||
srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn;
|
||||
|
||||
if (pd->uobject)
|
||||
if (ib_copy_to_udata(udata, &srq->msrq.srqn, sizeof(__u32))) {
|
||||
mlx5_ib_err(dev, "copy to user failed\n");
|
||||
err = -EFAULT;
|
||||
goto err_core;
|
||||
}
|
||||
|
||||
init_attr->attr.max_wr = srq->msrq.max - 1;
|
||||
|
||||
return &srq->ibsrq;
|
||||
|
||||
err_core:
|
||||
mlx5_core_destroy_srq(dev->mdev, &srq->msrq);
|
||||
|
||||
err_usr_kern_srq:
|
||||
if (pd->uobject)
|
||||
destroy_srq_user(pd, srq);
|
||||
else
|
||||
destroy_srq_kernel(dev, srq);
|
||||
|
||||
err_srq:
|
||||
kfree(srq);
|
||||
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
int mlx5_ib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
|
||||
enum ib_srq_attr_mask attr_mask, struct ib_udata *udata)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibsrq->device);
|
||||
struct mlx5_ib_srq *srq = to_msrq(ibsrq);
|
||||
int ret;
|
||||
|
||||
/* We don't support resizing SRQs yet */
|
||||
if (attr_mask & IB_SRQ_MAX_WR)
|
||||
return -EINVAL;
|
||||
|
||||
if (attr_mask & IB_SRQ_LIMIT) {
|
||||
if (attr->srq_limit >= srq->msrq.max)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&srq->mutex);
|
||||
ret = mlx5_core_arm_srq(dev->mdev, &srq->msrq, attr->srq_limit, 1);
|
||||
mutex_unlock(&srq->mutex);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx5_ib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *srq_attr)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibsrq->device);
|
||||
struct mlx5_ib_srq *srq = to_msrq(ibsrq);
|
||||
int ret;
|
||||
struct mlx5_query_srq_mbox_out *out;
|
||||
|
||||
out = kzalloc(sizeof(*out), GFP_KERNEL);
|
||||
if (!out)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = mlx5_core_query_srq(dev->mdev, &srq->msrq, out);
|
||||
if (ret)
|
||||
goto out_box;
|
||||
|
||||
srq_attr->srq_limit = be16_to_cpu(out->ctx.lwm);
|
||||
srq_attr->max_wr = srq->msrq.max - 1;
|
||||
srq_attr->max_sge = srq->msrq.max_gs;
|
||||
|
||||
out_box:
|
||||
kfree(out);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mlx5_ib_destroy_srq(struct ib_srq *srq)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(srq->device);
|
||||
struct mlx5_ib_srq *msrq = to_msrq(srq);
|
||||
|
||||
mlx5_core_destroy_srq(dev->mdev, &msrq->msrq);
|
||||
|
||||
if (srq->uobject) {
|
||||
mlx5_ib_db_unmap_user(to_mucontext(srq->uobject->context), &msrq->db);
|
||||
ib_umem_release(msrq->umem);
|
||||
} else {
|
||||
destroy_srq_kernel(dev, msrq);
|
||||
}
|
||||
|
||||
kfree(srq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mlx5_ib_free_srq_wqe(struct mlx5_ib_srq *srq, int wqe_index)
|
||||
{
|
||||
struct mlx5_wqe_srq_next_seg *next;
|
||||
|
||||
/* always called with interrupts disabled. */
|
||||
spin_lock(&srq->lock);
|
||||
|
||||
next = get_wqe(srq, srq->tail);
|
||||
next->next_wqe_index = cpu_to_be16(wqe_index);
|
||||
srq->tail = wqe_index;
|
||||
|
||||
spin_unlock(&srq->lock);
|
||||
}
|
||||
|
||||
int mlx5_ib_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
|
||||
struct ib_recv_wr **bad_wr)
|
||||
{
|
||||
struct mlx5_ib_srq *srq = to_msrq(ibsrq);
|
||||
struct mlx5_wqe_srq_next_seg *next;
|
||||
struct mlx5_wqe_data_seg *scat;
|
||||
struct mlx5_ib_dev *dev = to_mdev(ibsrq->device);
|
||||
struct mlx5_core_dev *mdev = dev->mdev;
|
||||
unsigned long flags;
|
||||
int err = 0;
|
||||
int nreq;
|
||||
int i;
|
||||
|
||||
spin_lock_irqsave(&srq->lock, flags);
|
||||
|
||||
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
|
||||
err = -EIO;
|
||||
*bad_wr = wr;
|
||||
nreq = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (nreq = 0; wr; nreq++, wr = wr->next) {
|
||||
if (unlikely(wr->num_sge > srq->msrq.max_gs)) {
|
||||
err = -EINVAL;
|
||||
*bad_wr = wr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (unlikely(srq->head == srq->tail)) {
|
||||
err = -ENOMEM;
|
||||
*bad_wr = wr;
|
||||
break;
|
||||
}
|
||||
|
||||
srq->wrid[srq->head] = wr->wr_id;
|
||||
|
||||
next = get_wqe(srq, srq->head);
|
||||
srq->head = be16_to_cpu(next->next_wqe_index);
|
||||
scat = (struct mlx5_wqe_data_seg *)(next + 1);
|
||||
|
||||
for (i = 0; i < wr->num_sge; i++) {
|
||||
scat[i].byte_count = cpu_to_be32(wr->sg_list[i].length);
|
||||
scat[i].lkey = cpu_to_be32(wr->sg_list[i].lkey);
|
||||
scat[i].addr = cpu_to_be64(wr->sg_list[i].addr);
|
||||
}
|
||||
|
||||
if (i < srq->msrq.max_avail_gather) {
|
||||
scat[i].byte_count = 0;
|
||||
scat[i].lkey = cpu_to_be32(MLX5_INVALID_LKEY);
|
||||
scat[i].addr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (likely(nreq)) {
|
||||
srq->wqe_ctr += nreq;
|
||||
|
||||
/* Make sure that descriptors are written before
|
||||
* doorbell record.
|
||||
*/
|
||||
wmb();
|
||||
|
||||
*srq->db.db = cpu_to_be32(srq->wqe_ctr);
|
||||
}
|
||||
out:
|
||||
spin_unlock_irqrestore(&srq->lock, flags);
|
||||
|
||||
return err;
|
||||
}
|
318
sys/dev/mlx5/mlx5_ib/user.h
Normal file
318
sys/dev/mlx5/mlx5_ib/user.h
Normal file
@ -0,0 +1,318 @@
|
||||
/*-
|
||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef MLX5_IB_USER_H
|
||||
#define MLX5_IB_USER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
enum {
|
||||
MLX5_QP_FLAG_SIGNATURE = 1 << 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_SRQ_FLAG_SIGNATURE = 1 << 0,
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_WQ_FLAG_SIGNATURE = 1 << 0,
|
||||
};
|
||||
|
||||
|
||||
/* Increment this value if any changes that break userspace ABI
|
||||
* compatibility are made.
|
||||
*/
|
||||
#define MLX5_IB_UVERBS_ABI_VERSION 1
|
||||
|
||||
/* Make sure that all structs defined in this file remain laid out so
|
||||
* that they pack the same way on 32-bit and 64-bit architectures (to
|
||||
* avoid incompatibility between 32-bit userspace and 64-bit kernels).
|
||||
* In particular do not use pointer types -- pass pointers in __u64
|
||||
* instead.
|
||||
*/
|
||||
|
||||
struct mlx5_ib_alloc_ucontext_req {
|
||||
__u32 total_num_uuars;
|
||||
__u32 num_low_latency_uuars;
|
||||
};
|
||||
|
||||
struct mlx5_ib_alloc_ucontext_req_v2 {
|
||||
__u32 total_num_uuars;
|
||||
__u32 num_low_latency_uuars;
|
||||
__u32 flags;
|
||||
__u32 reserved;
|
||||
};
|
||||
|
||||
struct mlx5_ib_alloc_ucontext_resp {
|
||||
__u32 qp_tab_size;
|
||||
__u32 bf_reg_size;
|
||||
__u32 tot_uuars;
|
||||
__u32 cache_line_size;
|
||||
__u16 max_sq_desc_sz;
|
||||
__u16 max_rq_desc_sz;
|
||||
__u32 max_send_wqebb;
|
||||
__u32 max_recv_wr;
|
||||
__u32 max_srq_recv_wr;
|
||||
__u16 num_ports;
|
||||
__u16 reserved;
|
||||
__u32 max_desc_sz_sq_dc;
|
||||
__u32 atomic_arg_sizes_dc;
|
||||
__u32 reserved1;
|
||||
__u32 flags;
|
||||
__u32 reserved2[5];
|
||||
};
|
||||
|
||||
enum mlx5_exp_ib_alloc_ucontext_data_resp_mask {
|
||||
MLX5_EXP_ALLOC_CTX_RESP_MASK_CQE_COMP_MAX_NUM = 1 << 0,
|
||||
MLX5_EXP_ALLOC_CTX_RESP_MASK_CQE_VERSION = 1 << 1,
|
||||
MLX5_EXP_ALLOC_CTX_RESP_MASK_RROCE_UDP_SPORT_MIN = 1 << 2,
|
||||
MLX5_EXP_ALLOC_CTX_RESP_MASK_RROCE_UDP_SPORT_MAX = 1 << 3,
|
||||
MLX5_EXP_ALLOC_CTX_RESP_MASK_HCA_CORE_CLOCK_OFFSET = 1 << 4,
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_alloc_ucontext_data_resp {
|
||||
__u32 comp_mask; /* use mlx5_ib_exp_alloc_ucontext_data_resp_mask */
|
||||
__u16 cqe_comp_max_num;
|
||||
__u8 cqe_version;
|
||||
__u8 reserved;
|
||||
__u16 rroce_udp_sport_min;
|
||||
__u16 rroce_udp_sport_max;
|
||||
__u32 hca_core_clock_offset;
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_alloc_ucontext_resp {
|
||||
__u32 qp_tab_size;
|
||||
__u32 bf_reg_size;
|
||||
__u32 tot_uuars;
|
||||
__u32 cache_line_size;
|
||||
__u16 max_sq_desc_sz;
|
||||
__u16 max_rq_desc_sz;
|
||||
__u32 max_send_wqebb;
|
||||
__u32 max_recv_wr;
|
||||
__u32 max_srq_recv_wr;
|
||||
__u16 num_ports;
|
||||
__u16 reserved;
|
||||
__u32 max_desc_sz_sq_dc;
|
||||
__u32 atomic_arg_sizes_dc;
|
||||
__u32 reserved1;
|
||||
__u32 flags;
|
||||
__u32 reserved2[5];
|
||||
/* Some more reserved fields for
|
||||
* future growth of mlx5_ib_alloc_ucontext_resp */
|
||||
__u64 prefix_reserved[8];
|
||||
struct mlx5_exp_ib_alloc_ucontext_data_resp exp_data;
|
||||
};
|
||||
|
||||
struct mlx5_ib_alloc_pd_resp {
|
||||
__u32 pdn;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_cq {
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 cqe_size;
|
||||
__u32 reserved; /* explicit padding (optional on i386) */
|
||||
};
|
||||
|
||||
enum mlx5_exp_ib_create_cq_mask {
|
||||
MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_EN = 1 << 0,
|
||||
MLX5_EXP_CREATE_CQ_MASK_CQE_COMP_RECV_TYPE = 1 << 1,
|
||||
MLX5_EXP_CREATE_CQ_MASK_RESERVED = 1 << 2,
|
||||
};
|
||||
|
||||
enum mlx5_exp_cqe_comp_recv_type {
|
||||
MLX5_IB_CQE_FORMAT_HASH,
|
||||
MLX5_IB_CQE_FORMAT_CSUM,
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_cq_data {
|
||||
__u32 comp_mask; /* use mlx5_exp_ib_creaet_cq_mask */
|
||||
__u8 cqe_comp_en;
|
||||
__u8 cqe_comp_recv_type; /* use mlx5_exp_cqe_comp_recv_type */
|
||||
__u16 reserved;
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_cq {
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 cqe_size;
|
||||
__u32 reserved; /* explicit padding (optional on i386) */
|
||||
|
||||
/* Some more reserved fields for future growth of mlx5_ib_create_cq */
|
||||
__u64 prefix_reserved[8];
|
||||
|
||||
/* sizeof prefix aligned with mlx5_ib_create_cq */
|
||||
__u64 size_of_prefix;
|
||||
struct mlx5_exp_ib_create_cq_data exp_data;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_cq_resp {
|
||||
__u32 cqn;
|
||||
__u32 reserved;
|
||||
};
|
||||
|
||||
struct mlx5_ib_resize_cq {
|
||||
__u64 buf_addr;
|
||||
__u16 cqe_size;
|
||||
__u16 reserved0;
|
||||
__u32 reserved1;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_srq {
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 flags;
|
||||
__u32 reserved; /* explicit padding (optional on i386) */
|
||||
__u32 uidx;
|
||||
__u32 reserved1;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_srq_resp {
|
||||
__u32 srqn;
|
||||
__u32 reserved;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_qp {
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 sq_wqe_count;
|
||||
__u32 rq_wqe_count;
|
||||
__u32 rq_wqe_shift;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
enum mlx5_exp_ib_create_qp_mask {
|
||||
MLX5_EXP_CREATE_QP_MASK_UIDX = 1 << 0,
|
||||
MLX5_EXP_CREATE_QP_MASK_SQ_BUFF_ADD = 1 << 1,
|
||||
MLX5_EXP_CREATE_QP_MASK_WC_UAR_IDX = 1 << 2,
|
||||
MLX5_EXP_CREATE_QP_MASK_FLAGS_IDX = 1 << 3,
|
||||
MLX5_EXP_CREATE_QP_MASK_RESERVED = 1 << 4,
|
||||
};
|
||||
|
||||
enum mlx5_exp_create_qp_flags {
|
||||
MLX5_EXP_CREATE_QP_MULTI_PACKET_WQE_REQ_FLAG = 1 << 0,
|
||||
};
|
||||
|
||||
enum mlx5_exp_drv_create_qp_uar_idx {
|
||||
MLX5_EXP_CREATE_QP_DB_ONLY_UUAR = -1
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_qp_data {
|
||||
__u32 comp_mask; /* use mlx5_exp_ib_create_qp_mask */
|
||||
__u32 uidx;
|
||||
__u64 sq_buf_addr;
|
||||
__u32 wc_uar_index;
|
||||
__u32 flags; /* use mlx5_exp_create_qp_flags */
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_qp {
|
||||
/* To allow casting to mlx5_ib_create_qp the prefix is the same as
|
||||
* struct mlx5_ib_create_qp prefix
|
||||
*/
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 sq_wqe_count;
|
||||
__u32 rq_wqe_count;
|
||||
__u32 rq_wqe_shift;
|
||||
__u32 flags;
|
||||
|
||||
/* Some more reserved fields for future growth of mlx5_ib_create_qp */
|
||||
__u64 prefix_reserved[8];
|
||||
|
||||
/* sizeof prefix aligned with mlx5_ib_create_qp */
|
||||
__u64 size_of_prefix;
|
||||
|
||||
/* Experimental data
|
||||
* Add new experimental data only inside the exp struct
|
||||
*/
|
||||
struct mlx5_exp_ib_create_qp_data exp;
|
||||
};
|
||||
|
||||
enum {
|
||||
MLX5_EXP_INVALID_UUAR = -1,
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_qp_resp {
|
||||
__u32 uuar_index;
|
||||
__u32 rsvd;
|
||||
};
|
||||
|
||||
enum mlx5_exp_ib_create_qp_resp_mask {
|
||||
MLX5_EXP_CREATE_QP_RESP_MASK_FLAGS_IDX = 1 << 0,
|
||||
MLX5_EXP_CREATE_QP_RESP_MASK_RESERVED = 1 << 1,
|
||||
};
|
||||
|
||||
enum mlx5_exp_create_qp_resp_flags {
|
||||
MLX5_EXP_CREATE_QP_RESP_MULTI_PACKET_WQE_FLAG = 1 << 0,
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_qp_resp_data {
|
||||
__u32 comp_mask; /* use mlx5_exp_ib_create_qp_resp_mask */
|
||||
__u32 flags; /* use mlx5_exp_create_qp_resp_flags */
|
||||
};
|
||||
|
||||
struct mlx5_exp_ib_create_qp_resp {
|
||||
__u32 uuar_index;
|
||||
__u32 rsvd;
|
||||
|
||||
/* Some more reserved fields for future growth of mlx5_ib_create_qp_resp */
|
||||
__u64 prefix_reserved[8];
|
||||
|
||||
/* sizeof prefix aligned with mlx5_ib_create_qp_resp */
|
||||
__u64 size_of_prefix;
|
||||
|
||||
/* Experimental data
|
||||
* Add new experimental data only inside the exp struct
|
||||
*/
|
||||
struct mlx5_exp_ib_create_qp_resp_data exp;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_dct {
|
||||
__u32 uidx;
|
||||
__u32 reserved;
|
||||
};
|
||||
|
||||
struct mlx5_ib_arm_dct {
|
||||
__u64 reserved0;
|
||||
__u64 reserved1;
|
||||
};
|
||||
|
||||
struct mlx5_ib_arm_dct_resp {
|
||||
__u64 reserved0;
|
||||
__u64 reserved1;
|
||||
};
|
||||
|
||||
struct mlx5_ib_create_wq {
|
||||
__u64 buf_addr;
|
||||
__u64 db_addr;
|
||||
__u32 rq_wqe_count;
|
||||
__u32 rq_wqe_shift;
|
||||
__u32 user_index;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
#endif /* MLX5_IB_USER_H */
|
@ -250,6 +250,7 @@ SUBDIR= \
|
||||
${_mlx4en} \
|
||||
${_mlx5} \
|
||||
${_mlx5en} \
|
||||
${_mlx5ib} \
|
||||
${_mly} \
|
||||
mmc \
|
||||
mmcsd \
|
||||
@ -670,6 +671,7 @@ _mlx5en= mlx5en
|
||||
.endif
|
||||
.if ${MK_OFED} != "no" || defined(ALL_MODULES)
|
||||
_mlx4ib= mlx4ib
|
||||
_mlx5ib= mlx5ib
|
||||
.endif
|
||||
_mly= mly
|
||||
.if ${MK_OFED} != "no" || defined(ALL_MODULES)
|
||||
|
24
sys/modules/mlx5ib/Makefile
Normal file
24
sys/modules/mlx5ib/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
# $FreeBSD$
|
||||
.PATH: ${SRCTOP}/sys/dev/mlx5/mlx5_ib
|
||||
|
||||
KMOD=mlx5ib
|
||||
SRCS= \
|
||||
mlx5_ib_ah.c \
|
||||
mlx5_ib_cq.c \
|
||||
mlx5_ib_doorbell.c \
|
||||
mlx5_ib_mad.c \
|
||||
mlx5_ib_main.c \
|
||||
mlx5_ib_mem.c \
|
||||
mlx5_ib_mr.c \
|
||||
mlx5_ib_qp.c \
|
||||
mlx5_ib_roce.c \
|
||||
mlx5_ib_srq.c \
|
||||
device_if.h bus_if.h vnode_if.h pci_if.h \
|
||||
opt_inet.h opt_inet6.h
|
||||
|
||||
CFLAGS+= -I${SRCTOP}/sys/ofed/include
|
||||
CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/include
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
|
||||
CFLAGS+= -Wno-cast-qual -Wno-pointer-arith ${GCC_MS_EXTENSIONS}
|
Loading…
Reference in New Issue
Block a user