linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
@ 2016-11-03 23:44 Adit Ranadive
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

This patch series adds the userspace library for our paravirtual RDMA device.
I have already sent out the patchset for the RDMA driver before [1]. I will
also send a pull request on github.

I have included the shared ABI file here based on the RDMA fix up stuff 
that Jason pointed me to.

The patch series was built on 28d918732cc4efb2185d91a500be1e41aeb149e7.

[1] http://marc.info/?l=linux-rdma&m=147546066322315&w=2

Adit Ranadive (8):
  libpvrdma: Add ABI and main header files
  libpvrdma: Add ring traversal
  libpvrdma: Add completion queue functions
  libpvrdma: Add queue pair functions
  libpvrdma: Add misc verbs functions
  libpvrdma: Add main library file
  libpvrdma: Add to consolidated rdma-core
  libpvrdma: Add fix up for ABI file

 CMakeLists.txt                           |   1 +
 MAINTAINERS                              |   6 +
 README.md                                |   1 +
 buildlib/RDMA_LinuxHeaders.cmake         |   1 +
 buildlib/fixup-include/rdma-pvrdma-abi.h | 297 ++++++++++++++++++
 providers/pvrdma/CMakeLists.txt          |   6 +
 providers/pvrdma/cq.c                    | 287 ++++++++++++++++++
 providers/pvrdma/pvrdma.h                | 347 +++++++++++++++++++++
 providers/pvrdma/pvrdma_main.c           | 214 +++++++++++++
 providers/pvrdma/pvrdma_ring.h           | 136 +++++++++
 providers/pvrdma/qp.c                    | 505 +++++++++++++++++++++++++++++++
 providers/pvrdma/verbs.c                 | 234 ++++++++++++++
 12 files changed, 2035 insertions(+)
 create mode 100644 buildlib/fixup-include/rdma-pvrdma-abi.h
 create mode 100644 providers/pvrdma/CMakeLists.txt
 create mode 100644 providers/pvrdma/cq.c
 create mode 100644 providers/pvrdma/pvrdma.h
 create mode 100644 providers/pvrdma/pvrdma_main.c
 create mode 100644 providers/pvrdma/pvrdma_ring.h
 create mode 100644 providers/pvrdma/qp.c
 create mode 100644 providers/pvrdma/verbs.c

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/8] libpvrdma: Add ABI and main header files
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 2/8] libpvrdma: Add ring traversal Adit Ranadive
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Add all the structures and types to interact with kernel driver.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/pvrdma-abi.h | 297 ++++++++++++++++++++++++++++++++++++
 providers/pvrdma/pvrdma.h     | 347 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 644 insertions(+)
 create mode 100644 providers/pvrdma/pvrdma-abi.h
 create mode 100644 providers/pvrdma/pvrdma.h

diff --git a/providers/pvrdma/pvrdma-abi.h b/providers/pvrdma/pvrdma-abi.h
new file mode 100644
index 0000000..c7a38c5
--- /dev/null
+++ b/providers/pvrdma/pvrdma-abi.h
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#ifndef __PVRDMA_ABI_H__
+#define __PVRDMA_ABI_H__
+
+#include <infiniband/kern-abi.h>
+
+#define PVRDMA_UVERBS_ABI_VERSION	3
+#define PVRDMA_UAR_HANDLE_MASK		0x00FFFFFF	/* Bottom 24 bits. */
+#define PVRDMA_UAR_QP_OFFSET		0		/* QP doorbell offset. */
+#define PVRDMA_UAR_QP_SEND		BIT(30)		/* Send bit. */
+#define PVRDMA_UAR_QP_RECV		BIT(31)		/* Recv bit. */
+#define PVRDMA_UAR_CQ_OFFSET		4		/* CQ doorbell offset. */
+#define PVRDMA_UAR_CQ_ARM_SOL		BIT(29)		/* Arm solicited bit. */
+#define PVRDMA_UAR_CQ_ARM		BIT(30)		/* Arm bit. */
+#define PVRDMA_UAR_CQ_POLL		BIT(31)		/* Poll bit. */
+
+enum pvrdma_wr_opcode {
+	PVRDMA_WR_RDMA_WRITE,
+	PVRDMA_WR_RDMA_WRITE_WITH_IMM,
+	PVRDMA_WR_SEND,
+	PVRDMA_WR_SEND_WITH_IMM,
+	PVRDMA_WR_RDMA_READ,
+	PVRDMA_WR_ATOMIC_CMP_AND_SWP,
+	PVRDMA_WR_ATOMIC_FETCH_AND_ADD,
+	PVRDMA_WR_LSO,
+	PVRDMA_WR_SEND_WITH_INV,
+	PVRDMA_WR_RDMA_READ_WITH_INV,
+	PVRDMA_WR_LOCAL_INV,
+	PVRDMA_WR_FAST_REG_MR,
+	PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP,
+	PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
+	PVRDMA_WR_BIND_MW,
+	PVRDMA_WR_REG_SIG_MR,
+};
+
+enum pvrdma_wc_status {
+	PVRDMA_WC_SUCCESS,
+	PVRDMA_WC_LOC_LEN_ERR,
+	PVRDMA_WC_LOC_QP_OP_ERR,
+	PVRDMA_WC_LOC_EEC_OP_ERR,
+	PVRDMA_WC_LOC_PROT_ERR,
+	PVRDMA_WC_WR_FLUSH_ERR,
+	PVRDMA_WC_MW_BIND_ERR,
+	PVRDMA_WC_BAD_RESP_ERR,
+	PVRDMA_WC_LOC_ACCESS_ERR,
+	PVRDMA_WC_REM_INV_REQ_ERR,
+	PVRDMA_WC_REM_ACCESS_ERR,
+	PVRDMA_WC_REM_OP_ERR,
+	PVRDMA_WC_RETRY_EXC_ERR,
+	PVRDMA_WC_RNR_RETRY_EXC_ERR,
+	PVRDMA_WC_LOC_RDD_VIOL_ERR,
+	PVRDMA_WC_REM_INV_RD_REQ_ERR,
+	PVRDMA_WC_REM_ABORT_ERR,
+	PVRDMA_WC_INV_EECN_ERR,
+	PVRDMA_WC_INV_EEC_STATE_ERR,
+	PVRDMA_WC_FATAL_ERR,
+	PVRDMA_WC_RESP_TIMEOUT_ERR,
+	PVRDMA_WC_GENERAL_ERR,
+};
+
+enum pvrdma_wc_opcode {
+	PVRDMA_WC_SEND,
+	PVRDMA_WC_RDMA_WRITE,
+	PVRDMA_WC_RDMA_READ,
+	PVRDMA_WC_COMP_SWAP,
+	PVRDMA_WC_FETCH_ADD,
+	PVRDMA_WC_BIND_MW,
+	PVRDMA_WC_LSO,
+	PVRDMA_WC_LOCAL_INV,
+	PVRDMA_WC_FAST_REG_MR,
+	PVRDMA_WC_MASKED_COMP_SWAP,
+	PVRDMA_WC_MASKED_FETCH_ADD,
+	PVRDMA_WC_RECV = 1 << 7,
+	PVRDMA_WC_RECV_RDMA_WITH_IMM,
+};
+
+enum pvrdma_wc_flags {
+	PVRDMA_WC_GRH			= 1 << 0,
+	PVRDMA_WC_WITH_IMM		= 1 << 1,
+	PVRDMA_WC_WITH_INVALIDATE	= 1 << 2,
+	PVRDMA_WC_IP_CSUM_OK		= 1 << 3,
+	PVRDMA_WC_WITH_SMAC		= 1 << 4,
+	PVRDMA_WC_WITH_VLAN		= 1 << 5,
+	PVRDMA_WC_FLAGS_MAX		= PVRDMA_WC_WITH_VLAN,
+};
+
+struct pvrdma_alloc_ucontext_resp {
+	struct ibv_get_context_resp	ibv_resp;
+	__u32				qp_tab_size;
+	__u32				reserved;
+};
+
+struct pvrdma_alloc_pd_resp {
+	struct ibv_alloc_pd_resp	ibv_resp;
+	__u32				pdn;
+	__u32				reserved;
+};
+
+struct pvrdma_create_cq {
+	struct ibv_create_cq		ibv_cmd;
+	__u64				buf_addr;
+	__u32				buf_size;
+	__u32				reserved;
+};
+
+struct pvrdma_create_cq_resp {
+	struct ibv_create_cq_resp	ibv_resp;
+	__u32				cqn;
+	__u32				reserved;
+};
+
+struct pvrdma_resize_cq {
+	struct ibv_resize_cq		ibv_cmd;
+	__u64				buf_addr;
+	__u32				buf_size;
+	__u32				reserved;
+};
+
+struct pvrdma_create_srq {
+	struct ibv_create_srq		ibv_cmd;
+	__u64				buf_addr;
+};
+
+struct pvrdma_create_srq_resp {
+	struct ibv_create_srq_resp	ibv_resp;
+	__u32				srqn;
+	__u32				reserved;
+};
+
+struct pvrdma_create_qp {
+	struct ibv_create_qp		ibv_cmd;
+	__u64				rbuf_addr;
+	__u64				sbuf_addr;
+	__u32				rbuf_size;
+	__u32				sbuf_size;
+	__u64				qp_addr;
+};
+
+/* PVRDMA masked atomic compare and swap */
+struct pvrdma_ex_cmp_swap {
+	__u64 swap_val;
+	__u64 compare_val;
+	__u64 swap_mask;
+	__u64 compare_mask;
+};
+
+/* PVRDMA masked atomic fetch and add */
+struct pvrdma_ex_fetch_add {
+	__u64 add_val;
+	__u64 field_boundary;
+};
+
+/* PVRDMA address vector. */
+struct pvrdma_av {
+	__u32 port_pd;
+	__u32 sl_tclass_flowlabel;
+	__u8 dgid[16];
+	__u8 src_path_bits;
+	__u8 gid_index;
+	__u8 stat_rate;
+	__u8 hop_limit;
+	__u8 dmac[6];
+	__u8 reserved[6];
+};
+
+/* PVRDMA scatter/gather entry */
+struct pvrdma_sge {
+	__u64   addr;
+	__u32   length;
+	__u32   lkey;
+};
+
+/* PVRDMA receive queue work request */
+struct pvrdma_rq_wqe_hdr {
+	__u64 wr_id;		/* wr id */
+	__u32 num_sge;		/* size of s/g array */
+	__u32 total_len;	/* reserved */
+};
+/* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */
+
+/* PVRDMA send queue work request */
+struct pvrdma_sq_wqe_hdr {
+	__u64 wr_id;		/* wr id */
+	__u32 num_sge;		/* size of s/g array */
+	__u32 total_len;	/* reserved */
+	__u32 opcode;		/* operation type */
+	__u32 send_flags;	/* wr flags */
+	union {
+		__u32 imm_data;
+		__u32 invalidate_rkey;
+	} ex;
+	__u32 reserved;
+	union {
+		struct {
+			__u64 remote_addr;
+			__u32 rkey;
+			__u8 reserved[4];
+		} rdma;
+		struct {
+			__u64 remote_addr;
+			__u64 compare_add;
+			__u64 swap;
+			__u32 rkey;
+			__u32 reserved;
+		} atomic;
+		struct {
+			__u64 remote_addr;
+			__u32 log_arg_sz;
+			__u32 rkey;
+			union {
+				struct pvrdma_ex_cmp_swap  cmp_swap;
+				struct pvrdma_ex_fetch_add fetch_add;
+			} wr_data;
+		} masked_atomics;
+		struct {
+			__u64 iova_start;
+			__u64 pl_pdir_dma;
+			__u32 page_shift;
+			__u32 page_list_len;
+			__u32 length;
+			__u32 access_flags;
+			__u32 rkey;
+		} fast_reg;
+		struct {
+			__u32 remote_qpn;
+			__u32 remote_qkey;
+			struct pvrdma_av av;
+		} ud;
+	} wr;
+};
+/* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */
+
+/* Completion queue element. */
+struct pvrdma_cqe {
+	__u64 wr_id;
+	__u64 qp;
+	__u32 opcode;
+	__u32 status;
+	__u32 byte_len;
+	__u32 imm_data;
+	__u32 src_qp;
+	__u32 wc_flags;
+	__u32 vendor_err;
+	__u16 pkey_index;
+	__u16 slid;
+	__u8 sl;
+	__u8 dlid_path_bits;
+	__u8 port_num;
+	__u8 smac[6];
+	__u8 reserved2[7]; /* Pad to next power of 2 (64). */
+};
+
+#endif /* __PVRDMA_ABI_H__ */
diff --git a/providers/pvrdma/pvrdma.h b/providers/pvrdma/pvrdma.h
new file mode 100644
index 0000000..d3df07d
--- /dev/null
+++ b/providers/pvrdma/pvrdma.h
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#ifndef __PVRDMA_H__
+#define __PVRDMA_H__
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <sys/mman.h>
+#include <infiniband/driver.h>
+
+#define BIT(nr) (1UL << (nr))
+
+#include "pvrdma-abi.h"
+#include "pvrdma_ring.h"
+
+#ifndef rmb
+#  define rmb() mb()
+#endif
+
+#ifndef wmb
+#  define wmb() mb()
+#endif
+
+#ifndef likely
+#define likely(x)	__builtin_expect(!!(x), 1)
+#else
+#define likely(x)	(x)
+#endif
+
+#ifndef unlikely
+#define unlikely(x)	__builtin_expect(!!(x), 0)
+#else
+#define unlikely(x)	(x)
+#endif
+
+#ifndef max
+#define max(a, b) \
+	({ typeof (a) _a = (a); \
+	   typeof (b) _b = (b); \
+	   _a > _b ? _a : _b; })
+#endif
+
+#ifndef min
+#define min(a,b) \
+	({ typeof (a) _a = (a); \
+	   typeof (b) _b = (b); \
+	   _a < _b ? _a : _b; })
+#endif
+
+#define PFX "pvrdma: "
+
+enum {
+	PVRDMA_OPCODE_NOP			= 0x00,
+	PVRDMA_OPCODE_SEND_INVAL		= 0x01,
+	PVRDMA_OPCODE_RDMA_WRITE		= 0x08,
+	PVRDMA_OPCODE_RDMA_WRITE_IMM		= 0x09,
+	PVRDMA_OPCODE_SEND			= 0x0a,
+	PVRDMA_OPCODE_SEND_IMM			= 0x0b,
+	PVRDMA_OPCODE_LSO			= 0x0e,
+	PVRDMA_OPCODE_RDMA_READ			= 0x10,
+	PVRDMA_OPCODE_ATOMIC_CS			= 0x11,
+	PVRDMA_OPCODE_ATOMIC_FA			= 0x12,
+	PVRDMA_OPCODE_ATOMIC_MASK_CS		= 0x14,
+	PVRDMA_OPCODE_ATOMIC_MASK_FA		= 0x15,
+	PVRDMA_OPCODE_BIND_MW			= 0x18,
+	PVRDMA_OPCODE_FMR			= 0x19,
+	PVRDMA_OPCODE_LOCAL_INVAL		= 0x1b,
+	PVRDMA_OPCODE_CONFIG_CMD		= 0x1f,
+
+	PVRDMA_RECV_OPCODE_RDMA_WRITE_IMM	= 0x00,
+	PVRDMA_RECV_OPCODE_SEND			= 0x01,
+	PVRDMA_RECV_OPCODE_SEND_IMM		= 0x02,
+	PVRDMA_RECV_OPCODE_SEND_INVAL		= 0x03,
+
+	PVRDMA_CQE_OPCODE_ERROR			= 0x1e,
+	PVRDMA_CQE_OPCODE_RESIZE		= 0x16,
+};
+
+enum {
+	PVRDMA_WQE_CTRL_FENCE			= 1 << 6,
+	PVRDMA_WQE_CTRL_CQ_UPDATE		= 3 << 2,
+	PVRDMA_WQE_CTRL_SOLICIT			= 1 << 1,
+};
+
+struct pvrdma_device {
+	struct ibv_device		ibv_dev;
+	int				page_size;
+	int				abi_version;
+};
+
+struct pvrdma_context {
+	struct ibv_context		ibv_ctx;
+	void				*uar;
+	pthread_spinlock_t		uar_lock;
+	int				max_qp_wr;
+	int				max_sge;
+	int				max_cqe;
+	struct pvrdma_qp		**qp_tbl;
+};
+
+struct pvrdma_buf {
+	void				*buf;
+	size_t				length;
+};
+
+struct pvrdma_pd {
+	struct ibv_pd			ibv_pd;
+	uint32_t			pdn;
+};
+
+struct pvrdma_cq {
+	struct ibv_cq			ibv_cq;
+	struct pvrdma_buf		buf;
+	struct pvrdma_buf		resize_buf;
+	pthread_spinlock_t		lock;
+	struct pvrdma_ring_state	*ring_state;
+	uint32_t			cqe_cnt;
+	uint32_t			offset;
+	uint32_t			cqn;
+};
+
+struct pvrdma_wq {
+	uint64_t			*wrid;
+	pthread_spinlock_t		lock;
+	int				wqe_cnt;
+	int				wqe_size;
+	struct pvrdma_ring		*ring_state;
+	int				max_gs;
+	int				wqe_shift;
+	int				offset;
+};
+
+struct pvrdma_qp {
+	struct ibv_qp			ibv_qp;
+	struct pvrdma_buf		rbuf;
+	struct pvrdma_buf		sbuf;
+	int				max_inline_data;
+	int				buf_size;
+	uint32_t			sq_signal_bits;
+	int				sq_spare_wqes;
+	struct pvrdma_wq		sq;
+	struct pvrdma_wq		rq;
+};
+
+struct pvrdma_ah {
+	struct ibv_ah			ibv_ah;
+	struct pvrdma_av		av;
+};
+
+static inline unsigned long align(unsigned long val, unsigned long align)
+{
+	return (val + align - 1) & ~(align - 1);
+}
+
+static inline int align_next_power2(int size)
+{
+	int  val = 1;
+
+	while (val < size)
+		val <<= 1;
+
+	return val;
+}
+
+#define to_vxxx(xxx, type)						\
+	((struct pvrdma_##type *)					\
+	 ((void *) ib##xxx - offsetof(struct pvrdma_##type, ibv_##xxx)))
+
+static inline struct pvrdma_device *to_vdev(struct ibv_device *ibdev)
+{
+	return to_vxxx(dev, device);
+}
+
+static inline struct pvrdma_context *to_vctx(struct ibv_context *ibctx)
+{
+	return to_vxxx(ctx, context);
+}
+
+static inline struct pvrdma_pd *to_vpd(struct ibv_pd *ibpd)
+{
+	return to_vxxx(pd, pd);
+}
+
+static inline struct pvrdma_cq *to_vcq(struct ibv_cq *ibcq)
+{
+	return to_vxxx(cq, cq);
+}
+
+static inline struct pvrdma_qp *to_vqp(struct ibv_qp *ibqp)
+{
+	return to_vxxx(qp, qp);
+}
+
+static inline struct pvrdma_ah *to_vah(struct ibv_ah *ibah)
+{
+	return to_vxxx(ah, ah);
+}
+
+static inline void pvrdma_write_uar_qp(void *uar, unsigned value)
+{
+	*(uint32_t *)(uar + PVRDMA_UAR_QP_OFFSET) = htole32(value);
+}
+
+static inline void pvrdma_write_uar_cq(void *uar, unsigned value)
+{
+	*(uint32_t *)(uar + PVRDMA_UAR_CQ_OFFSET) = htole32(value);
+}
+
+static inline int ibv_send_flags_to_pvrdma(int flags)
+{
+	return flags;
+}
+
+static inline enum pvrdma_wr_opcode ibv_wr_opcode_to_pvrdma(
+						enum ibv_wr_opcode op)
+{
+	return (enum pvrdma_wr_opcode)op;
+}
+
+static inline enum ibv_wc_status pvrdma_wc_status_to_ibv(
+					enum pvrdma_wc_status status)
+{
+	return (enum ibv_wc_status)status;
+}
+
+static inline enum ibv_wc_opcode pvrdma_wc_opcode_to_ibv(
+					enum pvrdma_wc_opcode op)
+{
+	return (enum ibv_wc_opcode)op;
+}
+
+static inline int pvrdma_wc_flags_to_ibv(int flags)
+{
+	return flags;
+}
+
+int pvrdma_alloc_buf(struct pvrdma_buf *buf, size_t size, int page_size);
+void pvrdma_free_buf(struct pvrdma_buf *buf);
+
+int pvrdma_query_device(struct ibv_context *context,
+			struct ibv_device_attr *attr);
+int pvrdma_query_port(struct ibv_context *context, uint8_t port,
+		      struct ibv_port_attr *attr);
+
+struct ibv_pd *pvrdma_alloc_pd(struct ibv_context *context);
+int pvrdma_free_pd(struct ibv_pd *pd);
+
+struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr,
+			     size_t length, int access);
+int pvrdma_dereg_mr(struct ibv_mr *mr);
+
+struct ibv_cq *pvrdma_create_cq(struct ibv_context *context, int cqe,
+				struct ibv_comp_channel *channel,
+				int comp_vector);
+int pvrdma_alloc_cq_buf(struct pvrdma_device *dev, struct pvrdma_cq *cq,
+			struct pvrdma_buf *buf, int nent);
+int pvrdma_destroy_cq(struct ibv_cq *cq);
+int pvrdma_req_notify_cq(struct ibv_cq *cq, int solicited);
+int pvrdma_poll_cq(struct ibv_cq *cq, int ne, struct ibv_wc *wc);
+void pvrdma_cq_event(struct ibv_cq *cq);
+void __pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn);
+void pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn);
+int pvrdma_get_outstanding_cqes(struct pvrdma_cq *cq);
+void pvrdma_cq_resize_copy_cqes(struct pvrdma_cq *cq, void *buf,
+				int new_cqe);
+
+struct ibv_qp *pvrdma_create_qp(struct ibv_pd *pd,
+				struct ibv_qp_init_attr *attr);
+int pvrdma_query_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+		    int attr_mask, struct ibv_qp_init_attr *init_attr);
+int pvrdma_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+		     int attr_mask);
+int pvrdma_destroy_qp(struct ibv_qp *qp);
+void pvrdma_init_qp_indices(struct pvrdma_qp *qp);
+void pvrdma_qp_init_sq_ownership(struct pvrdma_qp *qp);
+int pvrdma_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+		     struct ibv_send_wr **bad_wr);
+int pvrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+		     struct ibv_recv_wr **bad_wr);
+void pvrdma_calc_sq_wqe_size(struct ibv_qp_cap *cap, enum ibv_qp_type type,
+			     struct pvrdma_qp *qp);
+int pvrdma_alloc_qp_buf(struct pvrdma_device *dev, struct ibv_qp_cap *cap,
+			enum ibv_qp_type type, struct pvrdma_qp *qp);
+void pvrdma_set_sq_sizes(struct pvrdma_qp *qp, struct ibv_qp_cap *cap,
+			 enum ibv_qp_type type);
+struct pvrdma_qp *pvrdma_find_qp(struct pvrdma_context *ctx,
+				 uint32_t qpn);
+int pvrdma_store_qp(struct pvrdma_context *ctx, uint32_t qpn,
+		    struct pvrdma_qp *qp);
+void pvrdma_clear_qp(struct pvrdma_context *ctx, uint32_t qpn);
+
+struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr);
+int pvrdma_destroy_ah(struct ibv_ah *ah);
+
+int pvrdma_alloc_av(struct pvrdma_pd *pd, struct ibv_ah_attr *attr,
+		    struct pvrdma_ah *ah);
+void pvrdma_free_av(struct pvrdma_ah *ah);
+
+#endif /* __PVRDMA_H__ */
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/8] libpvrdma: Add ring traversal
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  2016-11-03 23:44   ` [PATCH 1/8] libpvrdma: Add ABI and main header files Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 3/8] libpvrdma: Add completion queue functions Adit Ranadive
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

CQs and QPs use these structures to traverse the CQE/WQE rings.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/pvrdma_ring.h | 136 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)
 create mode 100644 providers/pvrdma/pvrdma_ring.h

diff --git a/providers/pvrdma/pvrdma_ring.h b/providers/pvrdma/pvrdma_ring.h
new file mode 100644
index 0000000..e99a551
--- /dev/null
+++ b/providers/pvrdma/pvrdma_ring.h
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program in the file COPYING. If not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#ifndef __PVRDMA_RING_H__
+#define __PVRDMA_RING_H__
+
+#include <linux/types.h>
+
+#define PVRDMA_INVALID_IDX	-1	/* Invalid index. */
+#define atomic_read(_x)		*(_x)
+#define atomic_set(_x, _y)	(*(_x) = (_y))
+
+typedef uint32_t atomic_t;
+
+struct pvrdma_ring {
+	atomic_t prod_tail;	/* Producer tail. */
+	atomic_t cons_head;	/* Consumer head. */
+};
+
+struct pvrdma_ring_state {
+	struct pvrdma_ring tx;	/* Tx ring. */
+	struct pvrdma_ring rx;	/* Rx ring. */
+};
+
+static inline int pvrdma_idx_valid(__u32 idx, __u32 max_elems)
+{
+	/* Generates fewer instructions than a less-than. */
+	return (idx & ~((max_elems << 1) - 1)) == 0;
+}
+
+static inline __s32 pvrdma_idx(atomic_t *var, __u32 max_elems)
+{
+	const unsigned idx = atomic_read(var);
+
+	if (pvrdma_idx_valid(idx, max_elems))
+		return idx & (max_elems - 1);
+	return PVRDMA_INVALID_IDX;
+}
+
+static inline void pvrdma_idx_ring_inc(atomic_t *var, __u32 max_elems)
+{
+	__u32 idx = atomic_read(var) + 1;	/* Increment. */
+
+	idx &= (max_elems << 1) - 1;		/* Modulo size, flip gen. */
+	atomic_set(var, idx);
+}
+
+static inline __s32 pvrdma_idx_ring_has_space(const struct pvrdma_ring *r,
+					      __u32 max_elems, __u32 *out_tail)
+{
+	const __u32 tail = atomic_read(&r->prod_tail);
+	const __u32 head = atomic_read(&r->cons_head);
+
+	if (pvrdma_idx_valid(tail, max_elems) &&
+	    pvrdma_idx_valid(head, max_elems)) {
+		*out_tail = tail & (max_elems - 1);
+		return tail != (head ^ max_elems);
+	}
+	return PVRDMA_INVALID_IDX;
+}
+
+static inline __s32 pvrdma_idx_ring_has_data(const struct pvrdma_ring *r,
+					     __u32 max_elems, __u32 *out_head)
+{
+	const __u32 tail = atomic_read(&r->prod_tail);
+	const __u32 head = atomic_read(&r->cons_head);
+
+	if (pvrdma_idx_valid(tail, max_elems) &&
+	    pvrdma_idx_valid(head, max_elems)) {
+		*out_head = head & (max_elems - 1);
+		return tail != head;
+	}
+	return PVRDMA_INVALID_IDX;
+}
+
+static inline __s32 pvrdma_idx_ring_is_valid_idx(const struct pvrdma_ring *r,
+						 __u32 max_elems, __u32 *idx)
+{
+	const __u32 tail = atomic_read(&r->prod_tail);
+	const __u32 head = atomic_read(&r->cons_head);
+
+	if (pvrdma_idx_valid(tail, max_elems) &&
+	    pvrdma_idx_valid(head, max_elems) &&
+	    pvrdma_idx_valid(*idx, max_elems)) {
+		if (tail > head && (*idx < tail && *idx >= head))
+			return 1;
+		else if (head > tail && (*idx >= head || *idx < tail))
+			return 1;
+	}
+	return 0;
+}
+
+#endif /* __PVRDMA_RING_H__ */
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/8] libpvrdma: Add completion queue functions
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  2016-11-03 23:44   ` [PATCH 1/8] libpvrdma: Add ABI and main header files Adit Ranadive
  2016-11-03 23:44   ` [PATCH 2/8] libpvrdma: Add ring traversal Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 4/8] libpvrdma: Add queue pair functions Adit Ranadive
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Add support for completion queue creation, destruction, polling and
events.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/cq.c | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 287 insertions(+)
 create mode 100644 providers/pvrdma/cq.c

diff --git a/providers/pvrdma/cq.c b/providers/pvrdma/cq.c
new file mode 100644
index 0000000..f99873c
--- /dev/null
+++ b/providers/pvrdma/cq.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#include <infiniband/arch.h>
+
+#include "pvrdma.h"
+
+enum {
+	CQ_OK =  0,
+	CQ_EMPTY = -1,
+	CQ_POLL_ERR = -2,
+};
+
+enum {
+	PVRDMA_CQE_IS_SEND_MASK = 0x40,
+	PVRDMA_CQE_OPCODE_MASK = 0x1f,
+};
+
+int pvrdma_alloc_cq_buf(struct pvrdma_device *dev, struct pvrdma_cq *cq,
+			struct pvrdma_buf *buf, int entries)
+{
+	if (pvrdma_alloc_buf(buf, cq->offset +
+			     entries * (sizeof(struct pvrdma_cqe)),
+			     dev->page_size))
+		return -1;
+	memset(buf->buf, 0, buf->length);
+
+	return 0;
+}
+
+static struct pvrdma_cqe *get_cqe(struct pvrdma_cq *cq, int entry)
+{
+	return cq->buf.buf + cq->offset +
+	       entry * (sizeof(struct pvrdma_cqe));
+}
+
+static int pvrdma_poll_one(struct pvrdma_cq *cq,
+			   struct pvrdma_qp **cur_qp,
+			   struct ibv_wc *wc)
+{
+	struct pvrdma_context *ctx = to_vctx(cq->ibv_cq.context);
+	int has_data;
+	unsigned int head;
+	int tried = 0;
+	struct pvrdma_cqe *cqe;
+
+retry:
+	has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					    cq->cqe_cnt, &head);
+	if (has_data == 0) {
+		unsigned int val;
+
+		if (tried)
+			return CQ_EMPTY;
+
+		/* Pass down POLL to give physical HCA a chance to poll. */
+		val = cq->cqn | PVRDMA_UAR_CQ_POLL;
+		pvrdma_write_uar_cq(ctx->uar, val);
+
+		tried = 1;
+		goto retry;
+	} else if (has_data == -1) {
+		return CQ_POLL_ERR;
+	}
+
+	cqe = get_cqe(cq, head);
+	if (!cqe)
+		return CQ_EMPTY;
+
+	rmb();
+
+	if (ctx->qp_tbl[cqe->qp & 0xFFFF])
+		*cur_qp = (struct pvrdma_qp *)ctx->qp_tbl[cqe->qp & 0xFFFF];
+	 else
+		return CQ_POLL_ERR;
+
+	wc->opcode = pvrdma_wc_opcode_to_ibv(cqe->opcode);
+	wc->status = pvrdma_wc_status_to_ibv(cqe->status);
+	wc->wr_id = cqe->wr_id;
+	wc->qp_num = (*cur_qp)->ibv_qp.qp_num;
+	wc->byte_len = cqe->byte_len;
+	wc->imm_data = cqe->imm_data;
+	wc->src_qp = cqe->src_qp;
+	wc->wc_flags = cqe->wc_flags;
+	wc->pkey_index = cqe->pkey_index;
+	wc->slid = cqe->slid;
+	wc->sl = cqe->sl;
+	wc->dlid_path_bits = cqe->dlid_path_bits;
+	wc->vendor_err = 0;
+
+	/* Update shared ring state. */
+	pvrdma_idx_ring_inc(&(cq->ring_state->rx.cons_head), cq->cqe_cnt);
+
+	return CQ_OK;
+}
+
+int pvrdma_poll_cq(struct ibv_cq *ibcq, int num_entries, struct ibv_wc *wc)
+{
+	struct pvrdma_cq *cq = to_vcq(ibcq);
+	struct pvrdma_qp *qp;
+	int npolled = 0;
+
+	if (num_entries < 1 || wc == NULL)
+		return 0;
+
+	pthread_spin_lock(&cq->lock);
+
+	for (npolled = 0; npolled < num_entries; ++npolled) {
+		if (pvrdma_poll_one(cq, &qp, wc + npolled) != CQ_OK)
+			break;
+	}
+
+	pthread_spin_unlock(&cq->lock);
+
+	return npolled;
+}
+
+void __pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn)
+{
+	/* Flush CQEs from specified QP */
+	int has_data;
+	unsigned int head;
+
+	/* Lock held */
+	has_data = pvrdma_idx_ring_has_data(&cq->ring_state->rx,
+					    cq->cqe_cnt, &head);
+
+	if (unlikely(has_data > 0)) {
+		int items;
+		int curr;
+		int tail = pvrdma_idx(&cq->ring_state->rx.prod_tail,
+				      cq->cqe_cnt);
+		struct pvrdma_cqe *cqe;
+		struct pvrdma_cqe *curr_cqe;
+
+		items = (tail > head) ? (tail - head) :
+			(cq->cqe_cnt - head + tail);
+		curr = --tail;
+		while (items-- > 0) {
+			if (curr < 0)
+				curr = cq->cqe_cnt - 1;
+			if (tail < 0)
+				tail = cq->cqe_cnt - 1;
+			curr_cqe = get_cqe(cq, curr);
+			rmb();
+			if ((curr_cqe->qp & 0xFFFF) != qpn) {
+				if (curr != tail) {
+					cqe = get_cqe(cq, tail);
+					rmb();
+					*cqe = *curr_cqe;
+				}
+				tail--;
+			} else {
+				pvrdma_idx_ring_inc(
+					&cq->ring_state->rx.cons_head,
+					cq->cqe_cnt);
+			}
+			curr--;
+		}
+	}
+}
+
+void pvrdma_cq_clean(struct pvrdma_cq *cq, uint32_t qpn)
+{
+	pthread_spin_lock(&cq->lock);
+	__pvrdma_cq_clean(cq, qpn);
+	pthread_spin_unlock(&cq->lock);
+}
+
+struct ibv_cq *pvrdma_create_cq(struct ibv_context *context, int cqe,
+				struct ibv_comp_channel *channel,
+				int comp_vector)
+{
+	struct pvrdma_device *dev = to_vdev(context->device);
+	struct pvrdma_create_cq cmd;
+	struct pvrdma_create_cq_resp resp;
+	struct pvrdma_cq *cq;
+	int ret;
+
+	if (cqe < 1)
+		return NULL;
+
+	cq = malloc(sizeof(*cq));
+	if (!cq)
+		return NULL;
+
+	/* Extra page for shared ring state */
+	cq->offset = dev->page_size;
+
+	if (pthread_spin_init(&cq->lock, PTHREAD_PROCESS_PRIVATE))
+		goto err;
+
+	cqe = align_next_power2(cqe);
+
+	if (pvrdma_alloc_cq_buf(dev, cq, &cq->buf, cqe))
+		goto err;
+
+	cq->ring_state = cq->buf.buf;
+
+	cmd.buf_addr = (uintptr_t) cq->buf.buf;
+	cmd.buf_size = cq->buf.length;
+	ret = ibv_cmd_create_cq(context, cqe, channel, comp_vector,
+				&cq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd),
+				&resp.ibv_resp, sizeof(resp));
+	if (ret)
+		goto err_buf;
+
+	cq->cqn = resp.cqn;
+	cq->cqe_cnt = cq->ibv_cq.cqe;
+
+	return &cq->ibv_cq;
+
+err_buf:
+	pvrdma_free_buf(&cq->buf);
+err:
+	free(cq);
+
+	return NULL;
+}
+
+int pvrdma_destroy_cq(struct ibv_cq *cq)
+{
+	int ret;
+
+	ret = ibv_cmd_destroy_cq(cq);
+	if (ret)
+		return ret;
+
+	pvrdma_free_buf(&to_vcq(cq)->buf);
+	free(to_vcq(cq));
+
+	return 0;
+}
+
+int pvrdma_req_notify_cq(struct ibv_cq *ibcq, int solicited)
+{
+	struct pvrdma_context *ctx = to_vctx(ibcq->context);
+	struct pvrdma_cq *cq = to_vcq(ibcq);
+	unsigned int val = cq->cqn;
+
+	val |= solicited ? PVRDMA_UAR_CQ_ARM_SOL : PVRDMA_UAR_CQ_ARM;
+	pvrdma_write_uar_cq(ctx->uar, val);
+
+	return 0;
+}
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/8] libpvrdma: Add queue pair functions
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 3/8] libpvrdma: Add completion queue functions Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 5/8] libpvrdma: Add misc verbs functions Adit Ranadive
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Added functions to create, destroy, post on queue pairs.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/qp.c | 505 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 505 insertions(+)
 create mode 100644 providers/pvrdma/qp.c

diff --git a/providers/pvrdma/qp.c b/providers/pvrdma/qp.c
new file mode 100644
index 0000000..46a0e32
--- /dev/null
+++ b/providers/pvrdma/qp.c
@@ -0,0 +1,505 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#include <infiniband/arch.h>
+
+#include "pvrdma.h"
+
+int pvrdma_alloc_qp_buf(struct pvrdma_device *dev, struct ibv_qp_cap *cap,
+			enum ibv_qp_type type, struct pvrdma_qp *qp)
+{
+	qp->sq.wrid = malloc(qp->sq.wqe_cnt * sizeof(uint64_t));
+	if (!qp->sq.wrid)
+		return -1;
+
+	qp->rq.wrid = malloc(qp->rq.wqe_cnt * sizeof(uint64_t));
+	if (!qp->rq.wrid) {
+		free(qp->sq.wrid);
+		return -1;
+	}
+
+	/* Align page size for [rq][sq] */
+	qp->rbuf.length = align(qp->rq.offset +
+				qp->rq.wqe_cnt * qp->rq.wqe_size,
+				dev->page_size);
+	qp->sbuf.length = align(qp->sq.offset +
+				qp->sq.wqe_cnt * qp->sq.wqe_size,
+				dev->page_size);
+	qp->buf_size = qp->rbuf.length + qp->sbuf.length;
+
+	if (pvrdma_alloc_buf(&qp->rbuf, qp->rbuf.length, dev->page_size)) {
+		free(qp->sq.wrid);
+		free(qp->rq.wrid);
+		return -1;
+	}
+
+	if (pvrdma_alloc_buf(&qp->sbuf, qp->sbuf.length, dev->page_size)) {
+		free(qp->sq.wrid);
+		free(qp->rq.wrid);
+		pvrdma_free_buf(&qp->rbuf);
+		return -1;
+	}
+
+	memset(qp->rbuf.buf, 0, qp->rbuf.length);
+	memset(qp->sbuf.buf, 0, qp->sbuf.length);
+
+	return 0;
+}
+
+static void pvrdma_init_qp_queue(struct pvrdma_qp *qp)
+{
+	atomic_set(&(qp->sq.ring_state->cons_head), 0);
+	atomic_set(&(qp->sq.ring_state->prod_tail), 0);
+	atomic_set(&(qp->rq.ring_state->cons_head), 0);
+	atomic_set(&(qp->rq.ring_state->prod_tail), 0);
+}
+
+struct ibv_qp *pvrdma_create_qp(struct ibv_pd *pd,
+				struct ibv_qp_init_attr *attr)
+{
+	struct pvrdma_device *dev = to_vdev(pd->context->device);
+	struct pvrdma_create_qp cmd;
+	struct ibv_create_qp_resp resp;
+	struct pvrdma_qp *qp;
+	int ret;
+
+	attr->cap.max_recv_sge =
+		align_next_power2(max(1U, attr->cap.max_recv_sge));
+	attr->cap.max_recv_wr =
+		align_next_power2(max(1U, attr->cap.max_recv_wr));
+	attr->cap.max_send_sge =
+		align_next_power2(max(1U, attr->cap.max_send_sge));
+	attr->cap.max_send_wr =
+		align_next_power2(max(1U, attr->cap.max_send_wr));
+
+	qp = calloc(1, sizeof(*qp));
+	if (!qp)
+		return NULL;
+
+	qp->rq.max_gs = attr->cap.max_recv_sge;
+	qp->rq.wqe_cnt = attr->cap.max_recv_wr;
+	qp->rq.offset = 0;
+	qp->rq.wqe_size = align_next_power2(sizeof(struct pvrdma_rq_wqe_hdr) +
+					    sizeof(struct ibv_sge) *
+					    qp->rq.max_gs);
+
+	qp->sq.max_gs = attr->cap.max_send_sge;
+	qp->sq.wqe_cnt = attr->cap.max_send_wr;
+	/* Extra page for shared ring state */
+	qp->sq.offset = dev->page_size;
+	qp->sq.wqe_size = align_next_power2(sizeof(struct pvrdma_sq_wqe_hdr) +
+					    sizeof(struct ibv_sge) *
+					    qp->sq.max_gs);
+
+	/* Reset attr.cap, no srq for now */
+	if (attr->srq) {
+		attr->cap.max_recv_wr = 0;
+		qp->rq.wqe_cnt = 0;
+	}
+
+	/* Allocate [rq][sq] memory */
+	if (pvrdma_alloc_qp_buf(dev, &attr->cap, attr->qp_type, qp))
+		goto err;
+
+	qp->sq.ring_state = qp->sbuf.buf;
+	qp->rq.ring_state = (struct pvrdma_ring *)&qp->sq.ring_state[1];
+	pvrdma_init_qp_queue(qp);
+
+	if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
+	    pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
+		goto err_free;
+
+	memset(&cmd, 0, sizeof(cmd));
+	cmd.rbuf_addr = (uintptr_t)qp->rbuf.buf;
+	cmd.rbuf_size = qp->rbuf.length;
+	cmd.sbuf_addr = (uintptr_t)qp->sbuf.buf;
+	cmd.sbuf_size = qp->sbuf.length;
+	cmd.qp_addr = (uintptr_t) qp;
+
+	ret = ibv_cmd_create_qp(pd, &qp->ibv_qp, attr,
+				&cmd.ibv_cmd, sizeof(cmd),
+				&resp, sizeof(resp));
+
+	if (ret)
+		goto err_free;
+
+	to_vctx(pd->context)->qp_tbl[qp->ibv_qp.qp_num & 0xFFFF] = qp;
+
+	/* If set, each WR submitted to the SQ generate a completion entry */
+	if (attr->sq_sig_all)
+		qp->sq_signal_bits = htonl(PVRDMA_WQE_CTRL_CQ_UPDATE);
+	else
+		qp->sq_signal_bits = 0;
+
+	return &qp->ibv_qp;
+
+err_free:
+	if (qp->sq.wqe_cnt)
+		free(qp->sq.wrid);
+	if (qp->rq.wqe_cnt)
+		free(qp->rq.wrid);
+	pvrdma_free_buf(&qp->rbuf);
+	pvrdma_free_buf(&qp->sbuf);
+err:
+	free(qp);
+
+	return NULL;
+}
+
+int pvrdma_query_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
+		      int attr_mask,
+		      struct ibv_qp_init_attr *init_attr)
+{
+	struct ibv_query_qp cmd;
+	struct pvrdma_qp *qp = to_vqp(ibqp);
+	int ret;
+
+	ret = ibv_cmd_query_qp(ibqp, attr, attr_mask, init_attr,
+			       &cmd, sizeof(cmd));
+	if (ret)
+		return ret;
+
+	/* Passing back */
+	init_attr->cap.max_send_wr     = qp->sq.wqe_cnt;
+	init_attr->cap.max_send_sge    = qp->sq.max_gs;
+	init_attr->cap.max_inline_data = qp->max_inline_data;
+
+	attr->cap = init_attr->cap;
+
+	return 0;
+}
+
+int pvrdma_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
+		       int attr_mask)
+{
+	struct ibv_modify_qp cmd;
+	int ret;
+
+	/* Sanity check */
+	if (!attr_mask)
+		return 0;
+
+	ret = ibv_cmd_modify_qp(qp, attr, attr_mask, &cmd, sizeof(cmd));
+
+	if (!ret &&
+	    (attr_mask & IBV_QP_STATE) &&
+	    attr->qp_state == IBV_QPS_RESET) {
+		pvrdma_cq_clean(to_vcq(qp->recv_cq), qp->qp_num);
+		if (qp->send_cq != qp->recv_cq)
+			pvrdma_cq_clean(to_vcq(qp->send_cq), qp->qp_num);
+		pvrdma_init_qp_queue(to_vqp(qp));
+	}
+
+	return ret;
+}
+
+static void pvrdma_lock_cqs(struct ibv_qp *qp)
+{
+	struct pvrdma_cq *send_cq = to_vcq(qp->send_cq);
+	struct pvrdma_cq *recv_cq = to_vcq(qp->recv_cq);
+
+	if (send_cq == recv_cq)
+		pthread_spin_lock(&send_cq->lock);
+	else if (send_cq->cqn < recv_cq->cqn) {
+		pthread_spin_lock(&send_cq->lock);
+		pthread_spin_lock(&recv_cq->lock);
+	} else {
+		pthread_spin_lock(&recv_cq->lock);
+		pthread_spin_lock(&send_cq->lock);
+	}
+}
+
+static void pvrdma_unlock_cqs(struct ibv_qp *qp)
+{
+	struct pvrdma_cq *send_cq = to_vcq(qp->send_cq);
+	struct pvrdma_cq *recv_cq = to_vcq(qp->recv_cq);
+
+	if (send_cq == recv_cq)
+		pthread_spin_unlock(&send_cq->lock);
+	else if (send_cq->cqn < recv_cq->cqn) {
+		pthread_spin_unlock(&recv_cq->lock);
+		pthread_spin_unlock(&send_cq->lock);
+	} else {
+		pthread_spin_unlock(&send_cq->lock);
+		pthread_spin_unlock(&recv_cq->lock);
+	}
+}
+
+int pvrdma_destroy_qp(struct ibv_qp *ibqp)
+{
+	struct pvrdma_context *ctx = to_vctx(ibqp->context);
+	struct pvrdma_qp *qp = to_vqp(ibqp);
+	int ret;
+
+	ret = ibv_cmd_destroy_qp(ibqp);
+	if (ret) {
+		return ret;
+	}
+
+	pvrdma_lock_cqs(ibqp);
+	/* Dump cqs */
+	__pvrdma_cq_clean(to_vcq(ibqp->recv_cq), ibqp->qp_num);
+
+	if (ibqp->send_cq != ibqp->recv_cq)
+		__pvrdma_cq_clean(to_vcq(ibqp->send_cq), ibqp->qp_num);
+	pvrdma_unlock_cqs(ibqp);
+
+	free(qp->sq.wrid);
+	free(qp->rq.wrid);
+	pvrdma_free_buf(&qp->rbuf);
+	pvrdma_free_buf(&qp->sbuf);
+	ctx->qp_tbl[ibqp->qp_num & 0xFFFF] = NULL;
+	free(qp);
+
+	return 0;
+}
+
+static void *get_rq_wqe(struct pvrdma_qp *qp, int n)
+{
+	return qp->rbuf.buf + qp->rq.offset + (n * qp->rq.wqe_size);
+}
+
+static void *get_sq_wqe(struct pvrdma_qp *qp, int n)
+{
+	return qp->sbuf.buf + qp->sq.offset + (n * qp->sq.wqe_size);
+}
+
+int pvrdma_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
+		     struct ibv_send_wr **bad_wr)
+{
+	struct pvrdma_context *ctx = to_vctx(ibqp->context);
+	struct pvrdma_qp *qp = to_vqp(ibqp);
+	int ind;
+	int nreq = 0;
+	struct pvrdma_sq_wqe_hdr *wqe_hdr;
+	struct ibv_sge *sge;
+	int ret = 0;
+	int i;
+
+	/*
+	 * In states lower than RTS, we can fail immediately. In other states,
+	 * just post and let the device figure it out.
+	 */
+	if (ibqp->state < IBV_QPS_RTS) {
+		*bad_wr = wr;
+		return EINVAL;
+	}
+
+	pthread_spin_lock(&qp->sq.lock);
+	ind = pvrdma_idx(&(qp->sq.ring_state->prod_tail), qp->sq.wqe_cnt);
+	if (ind < 0) {
+		pthread_spin_unlock(&qp->sq.lock);
+		ret = EINVAL;
+		goto out;
+	}
+
+	for (nreq = 0; wr; ++nreq, wr = wr->next) {
+		unsigned int tail;
+
+		if (pvrdma_idx_ring_has_space(qp->sq.ring_state,
+					      qp->sq.wqe_cnt, &tail) <= 0) {
+			ret = ENOMEM;
+			*bad_wr = wr;
+			goto out;
+		}
+
+		if (wr->num_sge > qp->sq.max_gs) {
+			ret = EINVAL;
+			*bad_wr = wr;
+			goto out;
+		}
+
+		wqe_hdr = (struct pvrdma_sq_wqe_hdr *)get_sq_wqe(qp, ind);
+		wqe_hdr->wr_id = wr->wr_id;
+		wqe_hdr->num_sge = wr->num_sge;
+		wqe_hdr->opcode = ibv_wr_opcode_to_pvrdma(wr->opcode);
+		wqe_hdr->send_flags = ibv_send_flags_to_pvrdma(wr->send_flags);
+		if (wr->opcode == IBV_WR_SEND_WITH_IMM ||
+		    wr->opcode == IBV_WR_RDMA_WRITE_WITH_IMM)
+			wqe_hdr->ex.imm_data = wr->imm_data;
+
+		switch (ibqp->qp_type) {
+		case IBV_QPT_UD:
+			wqe_hdr->wr.ud.remote_qpn = wr->wr.ud.remote_qpn;
+			wqe_hdr->wr.ud.remote_qkey = wr->wr.ud.remote_qkey;
+			wqe_hdr->wr.ud.av = to_vah(wr->wr.ud.ah)->av;
+			break;
+		case IBV_QPT_RC:
+			switch (wr->opcode) {
+			case IBV_WR_RDMA_READ:
+			case IBV_WR_RDMA_WRITE:
+			case IBV_WR_RDMA_WRITE_WITH_IMM:
+				wqe_hdr->wr.rdma.remote_addr =
+					wr->wr.rdma.remote_addr;
+				wqe_hdr->wr.rdma.rkey = wr->wr.rdma.rkey;
+				break;
+			case IBV_WR_ATOMIC_CMP_AND_SWP:
+			case IBV_WR_ATOMIC_FETCH_AND_ADD:
+				wqe_hdr->wr.atomic.remote_addr = wr->wr.atomic.remote_addr;
+				wqe_hdr->wr.atomic.rkey = wr->wr.atomic.rkey;
+				wqe_hdr->wr.atomic.compare_add = wr->wr.atomic.compare_add;
+				if (wr->opcode == IBV_WR_ATOMIC_CMP_AND_SWP)
+					wqe_hdr->wr.atomic.swap = wr->wr.atomic.swap;
+				break;
+			default:
+				/* No extra segments required for sends */
+				break;
+			}
+			break;
+		default:
+			fprintf(stderr, PFX "invalid post send opcode\n");
+			ret = EINVAL;
+			*bad_wr = wr;
+			goto out;
+		}
+
+		/* Write each segment */
+		sge = (struct ibv_sge *)&wqe_hdr[1];
+		for (i = 0; i < wr->num_sge; i++) {
+			sge->addr = wr->sg_list[i].addr;
+			sge->length = wr->sg_list[i].length;
+			sge->lkey = wr->sg_list[i].lkey;
+			sge++;
+		}
+
+		pvrdma_idx_ring_inc(&(qp->sq.ring_state->prod_tail),
+				    qp->sq.wqe_cnt);
+
+		wmb();
+
+		qp->sq.wrid[ind] = wr->wr_id;
+		++ind;
+		if (ind >= qp->sq.wqe_cnt)
+			ind = 0;
+	}
+
+out:
+	if (nreq)
+		pvrdma_write_uar_qp(ctx->uar,
+				    PVRDMA_UAR_QP_SEND | ibqp->qp_num);
+
+	wmb();
+	pthread_spin_unlock(&qp->sq.lock);
+
+	return ret;
+}
+
+int pvrdma_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
+		     struct ibv_recv_wr **bad_wr)
+{
+	struct pvrdma_context *ctx = to_vctx(ibqp->context);
+	struct pvrdma_qp *qp = to_vqp(ibqp);
+	struct pvrdma_rq_wqe_hdr *wqe_hdr;
+	struct ibv_sge *sge;
+	int nreq;
+	int ind;
+	int i;
+	int ret = 0;
+
+	if (!wr || !bad_wr)
+		return EINVAL;
+
+	/*
+	 * In the RESET state, we can fail immediately. For other states,
+	 * just post and let the device figure it out.
+	 */
+	if (ibqp->state == IBV_QPS_RESET) {
+		*bad_wr = wr;
+		return EINVAL;
+	}
+
+	pthread_spin_lock(&qp->rq.lock);
+
+	ind = pvrdma_idx(&(qp->rq.ring_state->prod_tail), qp->rq.wqe_cnt);
+	if (ind < 0) {
+		pthread_spin_unlock(&qp->rq.lock);
+		*bad_wr = wr;
+		return EINVAL;
+	}
+
+	for (nreq = 0; wr; ++nreq, wr = wr->next) {
+		unsigned int tail;
+
+		if (pvrdma_idx_ring_has_space(qp->rq.ring_state,
+					      qp->rq.wqe_cnt, &tail) <= 0) {
+			ret = ENOMEM;
+			*bad_wr = wr;
+			goto out;
+		}
+
+		if (wr->num_sge > qp->rq.max_gs) {
+			ret = EINVAL;
+			*bad_wr = wr;
+			goto out;
+		}
+
+		/* Fetch wqe */
+		wqe_hdr = (struct pvrdma_rq_wqe_hdr *)get_rq_wqe(qp, ind);
+		wqe_hdr->wr_id = wr->wr_id;
+		wqe_hdr->num_sge = wr->num_sge;
+
+		sge = (struct ibv_sge *)(wqe_hdr + 1);
+		for (i = 0; i < wr->num_sge; ++i) {
+			sge->addr = (uint64_t)wr->sg_list[i].addr;
+			sge->length = wr->sg_list[i].length;
+			sge->lkey = wr->sg_list[i].lkey;
+			sge++;
+		}
+
+		pvrdma_idx_ring_inc(&qp->rq.ring_state->prod_tail,
+				    qp->rq.wqe_cnt);
+
+		qp->rq.wrid[ind] = wr->wr_id;
+		ind = (ind + 1) & (qp->rq.wqe_cnt - 1);
+	}
+
+out:
+	if (nreq)
+		pvrdma_write_uar_qp(ctx->uar,
+				    PVRDMA_UAR_QP_RECV | ibqp->qp_num);
+
+	pthread_spin_unlock(&qp->rq.lock);
+	return ret;
+}
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/8] libpvrdma: Add misc verbs functions
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 4/8] libpvrdma: Add queue pair functions Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 6/8] libpvrdma: Add main library file Adit Ranadive
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

This includes other verbs functions that dont necessarily fit anywhere else.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/verbs.c | 234 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 234 insertions(+)
 create mode 100644 providers/pvrdma/verbs.c

diff --git a/providers/pvrdma/verbs.c b/providers/pvrdma/verbs.c
new file mode 100644
index 0000000..1646708
--- /dev/null
+++ b/providers/pvrdma/verbs.c
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#include "pvrdma.h"
+
+int pvrdma_query_device(struct ibv_context *context,
+			struct ibv_device_attr *attr)
+{
+	struct ibv_query_device cmd;
+	uint64_t raw_fw_ver;
+	unsigned major, minor, sub_minor;
+	int ret;
+
+	ret = ibv_cmd_query_device(context, attr, &raw_fw_ver,
+				   &cmd, sizeof(cmd));
+	if (ret)
+		return ret;
+
+	major = (raw_fw_ver >> 32) & 0xffff;
+	minor = (raw_fw_ver >> 16) & 0xffff;
+	sub_minor = raw_fw_ver & 0xffff;
+
+	snprintf(attr->fw_ver, sizeof(attr->fw_ver),
+		 "%d.%d.%03d", major, minor, sub_minor);
+
+	return 0;
+}
+
+int pvrdma_query_port(struct ibv_context *context, uint8_t port,
+		      struct ibv_port_attr *attr)
+{
+	struct ibv_query_port cmd;
+
+	return ibv_cmd_query_port(context, port, attr, &cmd, sizeof(cmd));
+}
+
+struct ibv_pd *pvrdma_alloc_pd(struct ibv_context *context)
+{
+	struct ibv_alloc_pd cmd;
+	struct pvrdma_alloc_pd_resp resp;
+	struct pvrdma_pd *pd;
+
+	pd = malloc(sizeof(*pd));
+	if (!pd)
+		return NULL;
+
+	if (ibv_cmd_alloc_pd(context, &pd->ibv_pd, &cmd, sizeof(cmd),
+			     &resp.ibv_resp, sizeof(resp))) {
+		free(pd);
+		return NULL;
+	}
+
+	pd->pdn = resp.pdn;
+
+	return &pd->ibv_pd;
+}
+
+int pvrdma_free_pd(struct ibv_pd *pd)
+{
+	int ret;
+
+	ret = ibv_cmd_dealloc_pd(pd);
+	if (ret)
+		return ret;
+
+	free(to_vpd(pd));
+
+	return 0;
+}
+
+struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
+			     int access)
+{
+	struct ibv_mr *mr;
+	struct ibv_reg_mr cmd;
+	struct ibv_reg_mr_resp resp;
+	int ret;
+
+	mr = malloc(sizeof(*mr));
+	if (!mr)
+		return NULL;
+
+	ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
+			     access, mr, &cmd, sizeof(cmd),
+			     &resp, sizeof(resp));
+	if (ret) {
+		free(mr);
+		return NULL;
+	}
+
+	return mr;
+}
+
+int pvrdma_dereg_mr(struct ibv_mr *mr)
+{
+	int ret;
+
+	ret = ibv_cmd_dereg_mr(mr);
+	if (ret)
+		return ret;
+
+	free(mr);
+
+	return 0;
+}
+
+static int is_multicast_gid(const union ibv_gid *gid)
+{
+	return gid->raw[0] == 0xff;
+}
+
+static int is_link_local_gid(const union ibv_gid *gid)
+{
+	uint32_t *hi = (uint32_t *)(gid->raw);
+	uint32_t *lo = (uint32_t *)(gid->raw + 4);
+	if (hi[0] == htonl(0xfe800000) && lo[0] == 0)
+		return 1;
+
+	return 0;
+}
+
+static int is_ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+	return ((a->s6_addr32[0] | a->s6_addr32[1]) |
+		(a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0UL ||
+		/* IPv4 encoded multicast addresses */
+		(a->s6_addr32[0] == htonl(0xff0e0000) &&
+		((a->s6_addr32[1] |
+			(a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0UL));
+}
+
+static void set_mac_from_gid(const union ibv_gid *gid,
+			     __u8 mac[6])
+{
+	if (is_link_local_gid(gid)) {
+		/*
+		 * The MAC is embedded in GID[8-10,13-15] with the
+		 * 7th most significant bit inverted.
+		 */
+		memcpy(mac, gid->raw + 8, 3);
+		memcpy(mac + 3, gid->raw + 13, 3);
+		mac[0] ^= 2;
+	}
+}
+
+struct ibv_ah *pvrdma_create_ah(struct ibv_pd *pd,
+				struct ibv_ah_attr *attr)
+{
+	struct pvrdma_ah *ah;
+	struct pvrdma_av *av;
+	struct ibv_port_attr port_attr;
+
+	if (!attr->is_global)
+		return NULL;
+
+	if (ibv_query_port(pd->context, attr->port_num, &port_attr))
+		return NULL;
+
+	if (port_attr.link_layer == IBV_LINK_LAYER_UNSPECIFIED ||
+	    port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND)
+		return NULL;
+
+	if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET &&
+	    (!is_link_local_gid(&attr->grh.dgid) &&
+	     !is_multicast_gid(&attr->grh.dgid)  &&
+	     !is_ipv6_addr_v4mapped((struct in6_addr *)attr->grh.dgid.raw)))
+		return NULL;
+
+	ah = calloc(1, sizeof(*ah));
+	if (!ah)
+		return NULL;
+
+	av = &ah->av;
+	av->port_pd = to_vpd(pd)->pdn | (attr->port_num << 24);
+	av->src_path_bits = attr->src_path_bits;
+	av->src_path_bits |= 0x80;
+	av->gid_index = attr->grh.sgid_index;
+	av->hop_limit = attr->grh.hop_limit;
+	av->sl_tclass_flowlabel = (attr->grh.traffic_class << 20) |
+				   attr->grh.flow_label;
+	memcpy(av->dgid, attr->grh.dgid.raw, 16);
+	set_mac_from_gid(&attr->grh.dgid, av->dmac);
+
+	return &ah->ibv_ah;
+}
+
+int pvrdma_destroy_ah(struct ibv_ah *ah)
+{
+	free(to_vah(ah));
+
+	return 0;
+}
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 6/8] libpvrdma: Add main library file
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 5/8] libpvrdma: Add misc verbs functions Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 7/8] libpvrdma: Add to consolidated rdma-core Adit Ranadive
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Registers the pvrdma library with libibverbs and allocates the user context.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 providers/pvrdma/pvrdma_main.c | 214 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 214 insertions(+)
 create mode 100644 providers/pvrdma/pvrdma_main.c

diff --git a/providers/pvrdma/pvrdma_main.c b/providers/pvrdma/pvrdma_main.c
new file mode 100644
index 0000000..909cf1e
--- /dev/null
+++ b/providers/pvrdma/pvrdma_main.c
@@ -0,0 +1,214 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#include "pvrdma.h"
+
+static struct ibv_context_ops pvrdma_ctx_ops = {
+	.query_device = pvrdma_query_device,
+	.query_port = pvrdma_query_port,
+	.alloc_pd = pvrdma_alloc_pd,
+	.dealloc_pd = pvrdma_free_pd,
+
+	.reg_mr = pvrdma_reg_mr,
+	.dereg_mr = pvrdma_dereg_mr,
+	.create_cq = pvrdma_create_cq,
+	.poll_cq = pvrdma_poll_cq,
+	.req_notify_cq = pvrdma_req_notify_cq,
+	.destroy_cq = pvrdma_destroy_cq,
+
+	.create_qp = pvrdma_create_qp,
+	.query_qp = pvrdma_query_qp,
+	.modify_qp = pvrdma_modify_qp,
+	.destroy_qp = pvrdma_destroy_qp,
+
+	.post_send = pvrdma_post_send,
+	.post_recv = pvrdma_post_recv,
+	.create_ah = pvrdma_create_ah,
+	.destroy_ah = pvrdma_destroy_ah,
+};
+
+int pvrdma_alloc_buf(struct pvrdma_buf *buf, size_t size, int page_size)
+{
+	int ret;
+
+	buf->length = align(size, page_size);
+	buf->buf = mmap(NULL, buf->length, PROT_READ | PROT_WRITE,
+			MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if (buf->buf == MAP_FAILED)
+		return errno;
+
+	ret = ibv_dontfork_range(buf->buf, size);
+	if (ret)
+		munmap(buf->buf, buf->length);
+
+	return ret;
+}
+
+void pvrdma_free_buf(struct pvrdma_buf *buf)
+{
+	ibv_dofork_range(buf->buf, buf->length);
+	munmap(buf->buf, buf->length);
+}
+
+static int pvrdma_init_context_shared(struct pvrdma_context *context,
+				      struct ibv_device *ibdev,
+				      int cmd_fd)
+{
+	struct ibv_get_context cmd;
+	struct pvrdma_alloc_ucontext_resp resp;
+
+	context->ibv_ctx.cmd_fd = cmd_fd;
+	if (ibv_cmd_get_context(&context->ibv_ctx, &cmd, sizeof(cmd),
+				&resp.ibv_resp, sizeof(resp)))
+		return errno;
+
+	context->qp_tbl = calloc(resp.qp_tab_size & 0xFFFF,
+				 sizeof(struct pvrdma_qp *));
+	if (!context->qp_tbl)
+		return -ENOMEM;
+
+	context->uar = mmap(NULL, to_vdev(ibdev)->page_size, PROT_WRITE,
+			    MAP_SHARED, cmd_fd, 0);
+	if (context->uar == MAP_FAILED) {
+		free(context->qp_tbl);
+		return errno;
+	}
+
+	pthread_spin_init(&context->uar_lock, PTHREAD_PROCESS_PRIVATE);
+	context->ibv_ctx.ops = pvrdma_ctx_ops;
+
+	return 0;
+}
+
+static void pvrdma_free_context_shared(struct pvrdma_context *context,
+				       struct pvrdma_device *dev)
+{
+	munmap(context->uar, dev->page_size);
+	free(context->qp_tbl);
+}
+
+static struct ibv_context *pvrdma_alloc_context(struct ibv_device *ibdev,
+						int cmd_fd)
+{
+	struct pvrdma_context *context;
+
+	context = malloc(sizeof(*context));
+	if (!context)
+		return NULL;
+
+	memset(context, 0, sizeof(*context));
+
+	if (pvrdma_init_context_shared(context, ibdev, cmd_fd)) {
+		free(context);
+		return NULL;
+	}
+
+	return &context->ibv_ctx;
+}
+
+static void pvrdma_free_context(struct ibv_context *ibctx)
+{
+	struct pvrdma_context *context = to_vctx(ibctx);
+
+	pvrdma_free_context_shared(context, to_vdev(ibctx->device));
+	free(context);
+}
+
+static struct ibv_device_ops pvrdma_dev_ops = {
+	.alloc_context = pvrdma_alloc_context,
+	.free_context  = pvrdma_free_context
+};
+
+static struct pvrdma_device *pvrdma_driver_init_shared(
+						const char *uverbs_sys_path,
+						int abi_version)
+{
+	struct pvrdma_device *dev;
+	char name[16];
+
+	/* We support only a single ABI version for now. */
+	if (abi_version != PVRDMA_UVERBS_ABI_VERSION) {
+		fprintf(stderr, PFX "ABI version %d of %s is not "
+			"supported (supported %d)\n",
+			abi_version, uverbs_sys_path,
+			PVRDMA_UVERBS_ABI_VERSION);
+		return NULL;
+	}
+
+	if (ibv_read_sysfs_file(uverbs_sys_path,
+				"ibdev", name, sizeof(name)) < 0) {
+		fprintf(stderr, PFX "not ib device\n");
+		return NULL;
+	}
+
+	dev = malloc(sizeof(*dev));
+	if (!dev) {
+		fprintf(stderr, PFX "couldn't allocate device for %s\n",
+			uverbs_sys_path);
+		return NULL;
+	}
+
+	dev->abi_version = abi_version;
+	dev->page_size   = sysconf(_SC_PAGESIZE);
+	dev->ibv_dev.ops = pvrdma_dev_ops;
+
+	return dev;
+}
+
+static struct ibv_device *pvrdma_driver_init(const char *uverbs_sys_path,
+					     int abi_version)
+{
+	struct pvrdma_device *dev = pvrdma_driver_init_shared(uverbs_sys_path,
+							      abi_version);
+	if (!dev)
+		return NULL;
+
+	return &dev->ibv_dev;
+}
+
+static __attribute__((constructor)) void pvrdma_register_driver(void)
+{
+	ibv_register_driver("pvrdma", pvrdma_driver_init);
+}
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 7/8] libpvrdma: Add to consolidated rdma-core
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (5 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 6/8] libpvrdma: Add main library file Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-03 23:44   ` [PATCH 8/8] libpvrdma: Add fix up for ABI file Adit Ranadive
  2016-11-04  0:46   ` [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA Jason Gunthorpe
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Update the build scripts and infrastructure for the pvrdma user library.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 CMakeLists.txt                  | 1 +
 MAINTAINERS                     | 6 ++++++
 README.md                       | 1 +
 providers/pvrdma/CMakeLists.txt | 6 ++++++
 4 files changed, 14 insertions(+)
 create mode 100644 providers/pvrdma/CMakeLists.txt

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b3b3ff1..2010265 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -335,6 +335,7 @@ add_subdirectory(providers/mlx5)
 add_subdirectory(providers/mthca)
 add_subdirectory(providers/nes)
 add_subdirectory(providers/ocrdma)
+add_subdirectory(providers/pvrdma)
 add_subdirectory(providers/qedr)
 add_subdirectory(providers/rxe)
 add_subdirectory(providers/rxe/man)
diff --git a/MAINTAINERS b/MAINTAINERS
index d83de10..69ab1f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -139,6 +139,12 @@ M:	Devesh Sharma <Devesh.sharma-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>
 S:	Supported
 F:	providers/ocrdma/
 
+PVRDMA USERSPACE PROVIDER (for pvrdma.ko)
+M:	Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
+L:	pv-drivers-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org
+S:	Supported
+F:	providers/pvrdma/
+
 QEDR USERSPACE PROVIDER (for qedr.ko)
 M:	Ram Amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
 M:	Ariel Elior <Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
diff --git a/README.md b/README.md
index 3a13042..fed8803 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,7 @@ is included:
  - ib_mthca.ko
  - iw_nes.ko
  - ocrdma.ko
+ - pvrdma.ko
  - qedr.ko
  - rdma_rxe.ko
 
diff --git a/providers/pvrdma/CMakeLists.txt b/providers/pvrdma/CMakeLists.txt
new file mode 100644
index 0000000..8ba9a45
--- /dev/null
+++ b/providers/pvrdma/CMakeLists.txt
@@ -0,0 +1,6 @@
+rdma_provider(pvrdma
+  cq.c
+  pvrdma_main.c
+  qp.c
+  verbs.c
+)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 8/8] libpvrdma: Add fix up for ABI file
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (6 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 7/8] libpvrdma: Add to consolidated rdma-core Adit Ranadive
@ 2016-11-03 23:44   ` Adit Ranadive
  2016-11-04  0:46   ` [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA Jason Gunthorpe
  8 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-03 23:44 UTC (permalink / raw)
  To: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA
  Cc: Adit Ranadive

Use the fix up added by Jason to use the kernel version of pvrdma-abi.h
if it exists.

Signed-off-by: Adit Ranadive <aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
---
 buildlib/RDMA_LinuxHeaders.cmake         |   1 +
 buildlib/fixup-include/rdma-pvrdma-abi.h | 297 +++++++++++++++++++++++++++++++
 providers/pvrdma/pvrdma-abi.h            | 297 -------------------------------
 providers/pvrdma/pvrdma.h                |   2 +-
 4 files changed, 299 insertions(+), 298 deletions(-)
 create mode 100644 buildlib/fixup-include/rdma-pvrdma-abi.h
 delete mode 100644 providers/pvrdma/pvrdma-abi.h

diff --git a/buildlib/RDMA_LinuxHeaders.cmake b/buildlib/RDMA_LinuxHeaders.cmake
index c67b0a6..4689cd1 100644
--- a/buildlib/RDMA_LinuxHeaders.cmake
+++ b/buildlib/RDMA_LinuxHeaders.cmake
@@ -83,3 +83,4 @@ rdma_check_kheader("rdma/ib_user_mad.h" "${DEFAULT_TEST}")
 rdma_check_kheader("rdma/rdma_netlink.h" "int main(int argc,const char *argv[]) { return RDMA_NL_IWPM_REMOTE_INFO && RDMA_NL_IWCM; }")
 rdma_check_kheader("rdma/rdma_user_cm.h" "${DEFAULT_TEST}")
 rdma_check_kheader("rdma/rdma_user_rxe.h" "${DEFAULT_TEST}")
+rdma_check_kheader("rdma/pvrdma-abi.h" "${DEFAULT_TEST}")
diff --git a/buildlib/fixup-include/rdma-pvrdma-abi.h b/buildlib/fixup-include/rdma-pvrdma-abi.h
new file mode 100644
index 0000000..c7a38c5
--- /dev/null
+++ b/buildlib/fixup-include/rdma-pvrdma-abi.h
@@ -0,0 +1,297 @@
+/*
+ * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of EITHER the GNU General Public License
+ * version 2 as published by the Free Software Foundation or the BSD
+ * 2-Clause License. This program is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License version 2 for more details at
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program available in the file COPYING in the main
+ * directory of this source tree.
+ *
+ * The BSD 2-Clause License
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - 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 THE COPYRIGHT HOLDERS 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 THE
+ * COPYRIGHT HOLDER 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.
+ */
+
+#ifndef __PVRDMA_ABI_H__
+#define __PVRDMA_ABI_H__
+
+#include <infiniband/kern-abi.h>
+
+#define PVRDMA_UVERBS_ABI_VERSION	3
+#define PVRDMA_UAR_HANDLE_MASK		0x00FFFFFF	/* Bottom 24 bits. */
+#define PVRDMA_UAR_QP_OFFSET		0		/* QP doorbell offset. */
+#define PVRDMA_UAR_QP_SEND		BIT(30)		/* Send bit. */
+#define PVRDMA_UAR_QP_RECV		BIT(31)		/* Recv bit. */
+#define PVRDMA_UAR_CQ_OFFSET		4		/* CQ doorbell offset. */
+#define PVRDMA_UAR_CQ_ARM_SOL		BIT(29)		/* Arm solicited bit. */
+#define PVRDMA_UAR_CQ_ARM		BIT(30)		/* Arm bit. */
+#define PVRDMA_UAR_CQ_POLL		BIT(31)		/* Poll bit. */
+
+enum pvrdma_wr_opcode {
+	PVRDMA_WR_RDMA_WRITE,
+	PVRDMA_WR_RDMA_WRITE_WITH_IMM,
+	PVRDMA_WR_SEND,
+	PVRDMA_WR_SEND_WITH_IMM,
+	PVRDMA_WR_RDMA_READ,
+	PVRDMA_WR_ATOMIC_CMP_AND_SWP,
+	PVRDMA_WR_ATOMIC_FETCH_AND_ADD,
+	PVRDMA_WR_LSO,
+	PVRDMA_WR_SEND_WITH_INV,
+	PVRDMA_WR_RDMA_READ_WITH_INV,
+	PVRDMA_WR_LOCAL_INV,
+	PVRDMA_WR_FAST_REG_MR,
+	PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP,
+	PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
+	PVRDMA_WR_BIND_MW,
+	PVRDMA_WR_REG_SIG_MR,
+};
+
+enum pvrdma_wc_status {
+	PVRDMA_WC_SUCCESS,
+	PVRDMA_WC_LOC_LEN_ERR,
+	PVRDMA_WC_LOC_QP_OP_ERR,
+	PVRDMA_WC_LOC_EEC_OP_ERR,
+	PVRDMA_WC_LOC_PROT_ERR,
+	PVRDMA_WC_WR_FLUSH_ERR,
+	PVRDMA_WC_MW_BIND_ERR,
+	PVRDMA_WC_BAD_RESP_ERR,
+	PVRDMA_WC_LOC_ACCESS_ERR,
+	PVRDMA_WC_REM_INV_REQ_ERR,
+	PVRDMA_WC_REM_ACCESS_ERR,
+	PVRDMA_WC_REM_OP_ERR,
+	PVRDMA_WC_RETRY_EXC_ERR,
+	PVRDMA_WC_RNR_RETRY_EXC_ERR,
+	PVRDMA_WC_LOC_RDD_VIOL_ERR,
+	PVRDMA_WC_REM_INV_RD_REQ_ERR,
+	PVRDMA_WC_REM_ABORT_ERR,
+	PVRDMA_WC_INV_EECN_ERR,
+	PVRDMA_WC_INV_EEC_STATE_ERR,
+	PVRDMA_WC_FATAL_ERR,
+	PVRDMA_WC_RESP_TIMEOUT_ERR,
+	PVRDMA_WC_GENERAL_ERR,
+};
+
+enum pvrdma_wc_opcode {
+	PVRDMA_WC_SEND,
+	PVRDMA_WC_RDMA_WRITE,
+	PVRDMA_WC_RDMA_READ,
+	PVRDMA_WC_COMP_SWAP,
+	PVRDMA_WC_FETCH_ADD,
+	PVRDMA_WC_BIND_MW,
+	PVRDMA_WC_LSO,
+	PVRDMA_WC_LOCAL_INV,
+	PVRDMA_WC_FAST_REG_MR,
+	PVRDMA_WC_MASKED_COMP_SWAP,
+	PVRDMA_WC_MASKED_FETCH_ADD,
+	PVRDMA_WC_RECV = 1 << 7,
+	PVRDMA_WC_RECV_RDMA_WITH_IMM,
+};
+
+enum pvrdma_wc_flags {
+	PVRDMA_WC_GRH			= 1 << 0,
+	PVRDMA_WC_WITH_IMM		= 1 << 1,
+	PVRDMA_WC_WITH_INVALIDATE	= 1 << 2,
+	PVRDMA_WC_IP_CSUM_OK		= 1 << 3,
+	PVRDMA_WC_WITH_SMAC		= 1 << 4,
+	PVRDMA_WC_WITH_VLAN		= 1 << 5,
+	PVRDMA_WC_FLAGS_MAX		= PVRDMA_WC_WITH_VLAN,
+};
+
+struct pvrdma_alloc_ucontext_resp {
+	struct ibv_get_context_resp	ibv_resp;
+	__u32				qp_tab_size;
+	__u32				reserved;
+};
+
+struct pvrdma_alloc_pd_resp {
+	struct ibv_alloc_pd_resp	ibv_resp;
+	__u32				pdn;
+	__u32				reserved;
+};
+
+struct pvrdma_create_cq {
+	struct ibv_create_cq		ibv_cmd;
+	__u64				buf_addr;
+	__u32				buf_size;
+	__u32				reserved;
+};
+
+struct pvrdma_create_cq_resp {
+	struct ibv_create_cq_resp	ibv_resp;
+	__u32				cqn;
+	__u32				reserved;
+};
+
+struct pvrdma_resize_cq {
+	struct ibv_resize_cq		ibv_cmd;
+	__u64				buf_addr;
+	__u32				buf_size;
+	__u32				reserved;
+};
+
+struct pvrdma_create_srq {
+	struct ibv_create_srq		ibv_cmd;
+	__u64				buf_addr;
+};
+
+struct pvrdma_create_srq_resp {
+	struct ibv_create_srq_resp	ibv_resp;
+	__u32				srqn;
+	__u32				reserved;
+};
+
+struct pvrdma_create_qp {
+	struct ibv_create_qp		ibv_cmd;
+	__u64				rbuf_addr;
+	__u64				sbuf_addr;
+	__u32				rbuf_size;
+	__u32				sbuf_size;
+	__u64				qp_addr;
+};
+
+/* PVRDMA masked atomic compare and swap */
+struct pvrdma_ex_cmp_swap {
+	__u64 swap_val;
+	__u64 compare_val;
+	__u64 swap_mask;
+	__u64 compare_mask;
+};
+
+/* PVRDMA masked atomic fetch and add */
+struct pvrdma_ex_fetch_add {
+	__u64 add_val;
+	__u64 field_boundary;
+};
+
+/* PVRDMA address vector. */
+struct pvrdma_av {
+	__u32 port_pd;
+	__u32 sl_tclass_flowlabel;
+	__u8 dgid[16];
+	__u8 src_path_bits;
+	__u8 gid_index;
+	__u8 stat_rate;
+	__u8 hop_limit;
+	__u8 dmac[6];
+	__u8 reserved[6];
+};
+
+/* PVRDMA scatter/gather entry */
+struct pvrdma_sge {
+	__u64   addr;
+	__u32   length;
+	__u32   lkey;
+};
+
+/* PVRDMA receive queue work request */
+struct pvrdma_rq_wqe_hdr {
+	__u64 wr_id;		/* wr id */
+	__u32 num_sge;		/* size of s/g array */
+	__u32 total_len;	/* reserved */
+};
+/* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */
+
+/* PVRDMA send queue work request */
+struct pvrdma_sq_wqe_hdr {
+	__u64 wr_id;		/* wr id */
+	__u32 num_sge;		/* size of s/g array */
+	__u32 total_len;	/* reserved */
+	__u32 opcode;		/* operation type */
+	__u32 send_flags;	/* wr flags */
+	union {
+		__u32 imm_data;
+		__u32 invalidate_rkey;
+	} ex;
+	__u32 reserved;
+	union {
+		struct {
+			__u64 remote_addr;
+			__u32 rkey;
+			__u8 reserved[4];
+		} rdma;
+		struct {
+			__u64 remote_addr;
+			__u64 compare_add;
+			__u64 swap;
+			__u32 rkey;
+			__u32 reserved;
+		} atomic;
+		struct {
+			__u64 remote_addr;
+			__u32 log_arg_sz;
+			__u32 rkey;
+			union {
+				struct pvrdma_ex_cmp_swap  cmp_swap;
+				struct pvrdma_ex_fetch_add fetch_add;
+			} wr_data;
+		} masked_atomics;
+		struct {
+			__u64 iova_start;
+			__u64 pl_pdir_dma;
+			__u32 page_shift;
+			__u32 page_list_len;
+			__u32 length;
+			__u32 access_flags;
+			__u32 rkey;
+		} fast_reg;
+		struct {
+			__u32 remote_qpn;
+			__u32 remote_qkey;
+			struct pvrdma_av av;
+		} ud;
+	} wr;
+};
+/* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */
+
+/* Completion queue element. */
+struct pvrdma_cqe {
+	__u64 wr_id;
+	__u64 qp;
+	__u32 opcode;
+	__u32 status;
+	__u32 byte_len;
+	__u32 imm_data;
+	__u32 src_qp;
+	__u32 wc_flags;
+	__u32 vendor_err;
+	__u16 pkey_index;
+	__u16 slid;
+	__u8 sl;
+	__u8 dlid_path_bits;
+	__u8 port_num;
+	__u8 smac[6];
+	__u8 reserved2[7]; /* Pad to next power of 2 (64). */
+};
+
+#endif /* __PVRDMA_ABI_H__ */
diff --git a/providers/pvrdma/pvrdma-abi.h b/providers/pvrdma/pvrdma-abi.h
deleted file mode 100644
index c7a38c5..0000000
--- a/providers/pvrdma/pvrdma-abi.h
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (c) 2012-2016 VMware, Inc.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of EITHER the GNU General Public License
- * version 2 as published by the Free Software Foundation or the BSD
- * 2-Clause License. This program is distributed in the hope that it
- * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License version 2 for more details at
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program available in the file COPYING in the main
- * directory of this source tree.
- *
- * The BSD 2-Clause License
- *
- *     Redistribution and use in source and binary forms, with or
- *     without modification, are permitted provided that the following
- *     conditions are met:
- *
- *      - Redistributions of source code must retain the above
- *        copyright notice, this list of conditions and the following
- *        disclaimer.
- *
- *      - 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 THE COPYRIGHT HOLDERS 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 THE
- * COPYRIGHT HOLDER 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.
- */
-
-#ifndef __PVRDMA_ABI_H__
-#define __PVRDMA_ABI_H__
-
-#include <infiniband/kern-abi.h>
-
-#define PVRDMA_UVERBS_ABI_VERSION	3
-#define PVRDMA_UAR_HANDLE_MASK		0x00FFFFFF	/* Bottom 24 bits. */
-#define PVRDMA_UAR_QP_OFFSET		0		/* QP doorbell offset. */
-#define PVRDMA_UAR_QP_SEND		BIT(30)		/* Send bit. */
-#define PVRDMA_UAR_QP_RECV		BIT(31)		/* Recv bit. */
-#define PVRDMA_UAR_CQ_OFFSET		4		/* CQ doorbell offset. */
-#define PVRDMA_UAR_CQ_ARM_SOL		BIT(29)		/* Arm solicited bit. */
-#define PVRDMA_UAR_CQ_ARM		BIT(30)		/* Arm bit. */
-#define PVRDMA_UAR_CQ_POLL		BIT(31)		/* Poll bit. */
-
-enum pvrdma_wr_opcode {
-	PVRDMA_WR_RDMA_WRITE,
-	PVRDMA_WR_RDMA_WRITE_WITH_IMM,
-	PVRDMA_WR_SEND,
-	PVRDMA_WR_SEND_WITH_IMM,
-	PVRDMA_WR_RDMA_READ,
-	PVRDMA_WR_ATOMIC_CMP_AND_SWP,
-	PVRDMA_WR_ATOMIC_FETCH_AND_ADD,
-	PVRDMA_WR_LSO,
-	PVRDMA_WR_SEND_WITH_INV,
-	PVRDMA_WR_RDMA_READ_WITH_INV,
-	PVRDMA_WR_LOCAL_INV,
-	PVRDMA_WR_FAST_REG_MR,
-	PVRDMA_WR_MASKED_ATOMIC_CMP_AND_SWP,
-	PVRDMA_WR_MASKED_ATOMIC_FETCH_AND_ADD,
-	PVRDMA_WR_BIND_MW,
-	PVRDMA_WR_REG_SIG_MR,
-};
-
-enum pvrdma_wc_status {
-	PVRDMA_WC_SUCCESS,
-	PVRDMA_WC_LOC_LEN_ERR,
-	PVRDMA_WC_LOC_QP_OP_ERR,
-	PVRDMA_WC_LOC_EEC_OP_ERR,
-	PVRDMA_WC_LOC_PROT_ERR,
-	PVRDMA_WC_WR_FLUSH_ERR,
-	PVRDMA_WC_MW_BIND_ERR,
-	PVRDMA_WC_BAD_RESP_ERR,
-	PVRDMA_WC_LOC_ACCESS_ERR,
-	PVRDMA_WC_REM_INV_REQ_ERR,
-	PVRDMA_WC_REM_ACCESS_ERR,
-	PVRDMA_WC_REM_OP_ERR,
-	PVRDMA_WC_RETRY_EXC_ERR,
-	PVRDMA_WC_RNR_RETRY_EXC_ERR,
-	PVRDMA_WC_LOC_RDD_VIOL_ERR,
-	PVRDMA_WC_REM_INV_RD_REQ_ERR,
-	PVRDMA_WC_REM_ABORT_ERR,
-	PVRDMA_WC_INV_EECN_ERR,
-	PVRDMA_WC_INV_EEC_STATE_ERR,
-	PVRDMA_WC_FATAL_ERR,
-	PVRDMA_WC_RESP_TIMEOUT_ERR,
-	PVRDMA_WC_GENERAL_ERR,
-};
-
-enum pvrdma_wc_opcode {
-	PVRDMA_WC_SEND,
-	PVRDMA_WC_RDMA_WRITE,
-	PVRDMA_WC_RDMA_READ,
-	PVRDMA_WC_COMP_SWAP,
-	PVRDMA_WC_FETCH_ADD,
-	PVRDMA_WC_BIND_MW,
-	PVRDMA_WC_LSO,
-	PVRDMA_WC_LOCAL_INV,
-	PVRDMA_WC_FAST_REG_MR,
-	PVRDMA_WC_MASKED_COMP_SWAP,
-	PVRDMA_WC_MASKED_FETCH_ADD,
-	PVRDMA_WC_RECV = 1 << 7,
-	PVRDMA_WC_RECV_RDMA_WITH_IMM,
-};
-
-enum pvrdma_wc_flags {
-	PVRDMA_WC_GRH			= 1 << 0,
-	PVRDMA_WC_WITH_IMM		= 1 << 1,
-	PVRDMA_WC_WITH_INVALIDATE	= 1 << 2,
-	PVRDMA_WC_IP_CSUM_OK		= 1 << 3,
-	PVRDMA_WC_WITH_SMAC		= 1 << 4,
-	PVRDMA_WC_WITH_VLAN		= 1 << 5,
-	PVRDMA_WC_FLAGS_MAX		= PVRDMA_WC_WITH_VLAN,
-};
-
-struct pvrdma_alloc_ucontext_resp {
-	struct ibv_get_context_resp	ibv_resp;
-	__u32				qp_tab_size;
-	__u32				reserved;
-};
-
-struct pvrdma_alloc_pd_resp {
-	struct ibv_alloc_pd_resp	ibv_resp;
-	__u32				pdn;
-	__u32				reserved;
-};
-
-struct pvrdma_create_cq {
-	struct ibv_create_cq		ibv_cmd;
-	__u64				buf_addr;
-	__u32				buf_size;
-	__u32				reserved;
-};
-
-struct pvrdma_create_cq_resp {
-	struct ibv_create_cq_resp	ibv_resp;
-	__u32				cqn;
-	__u32				reserved;
-};
-
-struct pvrdma_resize_cq {
-	struct ibv_resize_cq		ibv_cmd;
-	__u64				buf_addr;
-	__u32				buf_size;
-	__u32				reserved;
-};
-
-struct pvrdma_create_srq {
-	struct ibv_create_srq		ibv_cmd;
-	__u64				buf_addr;
-};
-
-struct pvrdma_create_srq_resp {
-	struct ibv_create_srq_resp	ibv_resp;
-	__u32				srqn;
-	__u32				reserved;
-};
-
-struct pvrdma_create_qp {
-	struct ibv_create_qp		ibv_cmd;
-	__u64				rbuf_addr;
-	__u64				sbuf_addr;
-	__u32				rbuf_size;
-	__u32				sbuf_size;
-	__u64				qp_addr;
-};
-
-/* PVRDMA masked atomic compare and swap */
-struct pvrdma_ex_cmp_swap {
-	__u64 swap_val;
-	__u64 compare_val;
-	__u64 swap_mask;
-	__u64 compare_mask;
-};
-
-/* PVRDMA masked atomic fetch and add */
-struct pvrdma_ex_fetch_add {
-	__u64 add_val;
-	__u64 field_boundary;
-};
-
-/* PVRDMA address vector. */
-struct pvrdma_av {
-	__u32 port_pd;
-	__u32 sl_tclass_flowlabel;
-	__u8 dgid[16];
-	__u8 src_path_bits;
-	__u8 gid_index;
-	__u8 stat_rate;
-	__u8 hop_limit;
-	__u8 dmac[6];
-	__u8 reserved[6];
-};
-
-/* PVRDMA scatter/gather entry */
-struct pvrdma_sge {
-	__u64   addr;
-	__u32   length;
-	__u32   lkey;
-};
-
-/* PVRDMA receive queue work request */
-struct pvrdma_rq_wqe_hdr {
-	__u64 wr_id;		/* wr id */
-	__u32 num_sge;		/* size of s/g array */
-	__u32 total_len;	/* reserved */
-};
-/* Use pvrdma_sge (ib_sge) for receive queue s/g array elements. */
-
-/* PVRDMA send queue work request */
-struct pvrdma_sq_wqe_hdr {
-	__u64 wr_id;		/* wr id */
-	__u32 num_sge;		/* size of s/g array */
-	__u32 total_len;	/* reserved */
-	__u32 opcode;		/* operation type */
-	__u32 send_flags;	/* wr flags */
-	union {
-		__u32 imm_data;
-		__u32 invalidate_rkey;
-	} ex;
-	__u32 reserved;
-	union {
-		struct {
-			__u64 remote_addr;
-			__u32 rkey;
-			__u8 reserved[4];
-		} rdma;
-		struct {
-			__u64 remote_addr;
-			__u64 compare_add;
-			__u64 swap;
-			__u32 rkey;
-			__u32 reserved;
-		} atomic;
-		struct {
-			__u64 remote_addr;
-			__u32 log_arg_sz;
-			__u32 rkey;
-			union {
-				struct pvrdma_ex_cmp_swap  cmp_swap;
-				struct pvrdma_ex_fetch_add fetch_add;
-			} wr_data;
-		} masked_atomics;
-		struct {
-			__u64 iova_start;
-			__u64 pl_pdir_dma;
-			__u32 page_shift;
-			__u32 page_list_len;
-			__u32 length;
-			__u32 access_flags;
-			__u32 rkey;
-		} fast_reg;
-		struct {
-			__u32 remote_qpn;
-			__u32 remote_qkey;
-			struct pvrdma_av av;
-		} ud;
-	} wr;
-};
-/* Use pvrdma_sge (ib_sge) for send queue s/g array elements. */
-
-/* Completion queue element. */
-struct pvrdma_cqe {
-	__u64 wr_id;
-	__u64 qp;
-	__u32 opcode;
-	__u32 status;
-	__u32 byte_len;
-	__u32 imm_data;
-	__u32 src_qp;
-	__u32 wc_flags;
-	__u32 vendor_err;
-	__u16 pkey_index;
-	__u16 slid;
-	__u8 sl;
-	__u8 dlid_path_bits;
-	__u8 port_num;
-	__u8 smac[6];
-	__u8 reserved2[7]; /* Pad to next power of 2 (64). */
-};
-
-#endif /* __PVRDMA_ABI_H__ */
diff --git a/providers/pvrdma/pvrdma.h b/providers/pvrdma/pvrdma.h
index d3df07d..703cb5f 100644
--- a/providers/pvrdma/pvrdma.h
+++ b/providers/pvrdma/pvrdma.h
@@ -55,10 +55,10 @@
 #include <netinet/in.h>
 #include <sys/mman.h>
 #include <infiniband/driver.h>
+#include <rdma/pvrdma-abi.h>
 
 #define BIT(nr) (1UL << (nr))
 
-#include "pvrdma-abi.h"
 #include "pvrdma_ring.h"
 
 #ifndef rmb
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
                     ` (7 preceding siblings ...)
  2016-11-03 23:44   ` [PATCH 8/8] libpvrdma: Add fix up for ABI file Adit Ranadive
@ 2016-11-04  0:46   ` Jason Gunthorpe
       [not found]     ` <20161104004620.GA30318-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  8 siblings, 1 reply; 23+ messages in thread
From: Jason Gunthorpe @ 2016-11-04  0:46 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	pv-drivers-pghWNbHTmq7QT0dZR+AlfA

On Thu, Nov 03, 2016 at 04:44:29PM -0700, Adit Ranadive wrote:
> 
> I have included the shared ABI file here based on the RDMA fix up stuff 
> that Jason pointed me to.

I left you some trivial notes on github.

The big item is that the shared ABI file must be byte for byte
identical to the kernel version, and it looks to me like it was
changed?

We still do not have a general solution to the need to add the header
struct in user space but not in kernel space, so you will need to
continue to get your enums from the kernel header but still have a
'copy' with the modified structs.

Does that make sense?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]     ` <20161104004620.GA30318-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-04 21:00       ` Adit Ranadive
       [not found]         ` <b88ad364-9d33-dd3e-a803-bb660de3b384-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Adit Ranadive @ 2016-11-04 21:00 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Thu, Nov 03, 2016 at 5:46:20PM -0700, Jason Gunthorpe wrote:
> On Thu, Nov 03, 2016 at 04:44:29PM -0700, Adit Ranadive wrote:
> > 
> > I have included the shared ABI file here based on the RDMA fix up stuff 
> > that Jason pointed me to.
> 
> I left you some trivial notes on github.

Sorry, I didnt see this until now. It somehow ended up in my junk folder.
(I blame outlook).

Thanks for taking a look at the code!

I commented on most of the notes and I'll post a fix to address them.
Do I have re-issue the pull request or would it pick it automatically
after I push it?
 
> The big item is that the shared ABI file must be byte for byte
> identical to the kernel version, and it looks to me like it was
> changed?
> 
> We still do not have a general solution to the need to add the header
> struct in user space but not in kernel space, so you will need to
> continue to get your enums from the kernel header but still have a
> 'copy' with the modified structs.
> 
> Does that make sense?

Not entirely. You want me to keep the ABI file from the kernel in the
fix up folder and also keep a file with the modified structs in
providers/pvrdma?

Thanks,
Adit
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]         ` <b88ad364-9d33-dd3e-a803-bb660de3b384-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2016-11-05 15:01           ` Jason Gunthorpe
       [not found]             ` <20161105150136.GA23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  2016-11-05 15:03           ` Jason Gunthorpe
  1 sibling, 1 reply; 23+ messages in thread
From: Jason Gunthorpe @ 2016-11-05 15:01 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Fri, Nov 04, 2016 at 02:00:37PM -0700, Adit Ranadive wrote:
> I commented on most of the notes and I'll post a fix to address them.
> Do I have re-issue the pull request or would it pick it automatically
> after I push it?

No just keep pushing, Doug can squash everything into one commit when
applying.

> > The big item is that the shared ABI file must be byte for byte
> > identical to the kernel version, and it looks to me like it was
> > changed?
> > 
> > We still do not have a general solution to the need to add the header
> > struct in user space but not in kernel space, so you will need to
> > continue to get your enums from the kernel header but still have a
> > 'copy' with the modified structs.
> > 
> > Does that make sense?
> 
> Not entirely. You want me to keep the ABI file from the kernel in the
> fix up folder and also keep a file with the modified structs in
> providers/pvrdma?

Yes, and the file with the modified structs should include the kernel
header and duplicate it minimally. This will make it simpler for us to
eventually get rid of it.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]         ` <b88ad364-9d33-dd3e-a803-bb660de3b384-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  2016-11-05 15:01           ` Jason Gunthorpe
@ 2016-11-05 15:03           ` Jason Gunthorpe
       [not found]             ` <20161105150307.GB23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  1 sibling, 1 reply; 23+ messages in thread
From: Jason Gunthorpe @ 2016-11-05 15:03 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Fri, Nov 04, 2016 at 02:00:37PM -0700, Adit Ranadive wrote:
> On Thu, Nov 03, 2016 at 5:46:20PM -0700, Jason Gunthorpe wrote:
> > On Thu, Nov 03, 2016 at 04:44:29PM -0700, Adit Ranadive wrote:
> > > 
> > > I have included the shared ABI file here based on the RDMA fix up stuff 
> > > that Jason pointed me to.
> > 
> > I left you some trivial notes on github.
> 
> Thanks for taking a look at the code!

Oh, I wanted to ask about the name - we have two 'pv' drivers now,
should this be called pvrdma_vmware or something? Is there a
convention for this in other parts of the kernel?

Same comment for the kernel patch set too.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]             ` <20161105150307.GB23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-05 17:38               ` Christoph Hellwig
       [not found]                 ` <20161105173815.GA28539-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-11-05 17:38 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Adit Ranadive, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Sat, Nov 05, 2016 at 09:03:07AM -0600, Jason Gunthorpe wrote:
> Oh, I wanted to ask about the name - we have two 'pv' drivers now,
> should this be called pvrdma_vmware or something? Is there a
> convention for this in other parts of the kernel?

Yes, it should, even if we have no exact convention.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                 ` <20161105173815.GA28539-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2016-11-05 21:24                   ` Doug Ledford
       [not found]                     ` <581E4E01.5020405-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Doug Ledford @ 2016-11-05 21:24 UTC (permalink / raw)
  To: Christoph Hellwig, Jason Gunthorpe
  Cc: Adit Ranadive, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	pv-drivers


[-- Attachment #1.1: Type: text/plain, Size: 636 bytes --]

On 11/5/16 11:38 AM, Christoph Hellwig wrote:
> On Sat, Nov 05, 2016 at 09:03:07AM -0600, Jason Gunthorpe wrote:
>> Oh, I wanted to ask about the name - we have two 'pv' drivers now,
>> should this be called pvrdma_vmware or something? Is there a
>> convention for this in other parts of the kernel?
> 
> Yes, it should, even if we have no exact convention.
> 

Agreed.  I hate how long the driver name will end up being, but pvrdma_
as a prefix sounds appropriate.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>    GPG Key ID: 0E572FDD
  Red Hat, Inc.
  100 E. Davie St
  Raleigh, NC 27601 USA


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 907 bytes --]

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                     ` <581E4E01.5020405-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2016-11-06  1:31                       ` Adit Ranadive
       [not found]                         ` <f67c81ff-d358-7242-dc52-e32dff252904-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Adit Ranadive @ 2016-11-06  1:31 UTC (permalink / raw)
  To: Doug Ledford, Christoph Hellwig, Jason Gunthorpe
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Sat Nov 05 2016 14:24:17 GMT-0700 (PDT), Doug Ledford wrote:
> On 11/5/16 11:38 AM, Christoph Hellwig wrote:
> > On Sat, Nov 05, 2016 at 09:03:07AM -0600, Jason Gunthorpe wrote:
> > > Oh, I wanted to ask about the name - we have two 'pv' drivers now,
> > > should this be called pvrdma_vmware or something? Is there a
> > > convention for this in other parts of the kernel?
> > 
> > Yes, it should, even if we have no exact convention.
> > 
> 
> Agreed.  I hate how long the driver name will end up being, but pvrdma_
> as a prefix sounds appropriate.
> 

Hi Jason/Doug,

I wasn't aware that there was another paravirtual RDMA driver being upstreamed.
Maybe I missed it in the linux-rdma list?

Shouldn't this be a vendor choice since it would depend on how they want
to name their driver as long as it doesn't clash with any existing ones?

Thanks,
Adit
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                         ` <f67c81ff-d358-7242-dc52-e32dff252904-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2016-11-09  1:17                           ` Christoph Hellwig
       [not found]                             ` <20161109011715.GA29310-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-11-09  1:17 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: Doug Ledford, Christoph Hellwig, Jason Gunthorpe,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

FYI, the convention used in scsi is vmw_pvscsi.c, so naming the
RDMA equivalent vmw_pvrdma would make a lot of sense and still
be reasonably short.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]             ` <20161105150136.GA23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-09  1:23               ` Christoph Hellwig
       [not found]                 ` <20161109012335.GA29658-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2016-11-09  1:23 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Adit Ranadive, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Sat, Nov 05, 2016 at 09:01:36AM -0600, Jason Gunthorpe wrote:
> > Not entirely. You want me to keep the ABI file from the kernel in the
> > fix up folder and also keep a file with the modified structs in
> > providers/pvrdma?
> 
> Yes, and the file with the modified structs should include the kernel
> header and duplicate it minimally. This will make it simpler for us to
> eventually get rid of it.

Can we just automate generating the user header, e.g. have a sed script
that recognized a magic comments ala

	/* LIBIBVERBS PREAMBLE (DO NOT REMOVE) */

and just insers the needed fields?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                             ` <20161109011715.GA29310-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2016-11-09 17:39                               ` Adit Ranadive
       [not found]                                 ` <b49161b1-75f6-6902-fced-355804b885bb-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Adit Ranadive @ 2016-11-09 17:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Doug Ledford, Jason Gunthorpe,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Tue, Nov 08, 2016 at 5:17:15PM -0800, Christoph Hellwig wrote:
> FYI, the convention used in scsi is vmw_pvscsi.c, so naming the
> RDMA equivalent vmw_pvrdma would make a lot of sense and still
> be reasonably short.

Thanks Christoph. We agree with that as well. Then the driver path
(drivers/infiniband/hw/vmw_pvrdma/...) and the module name would
reflect vmw_pvrdma.
What about the user library? libpvrdma -> libvmwpvrdma?

Thanks,
Adit

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                                 ` <b49161b1-75f6-6902-fced-355804b885bb-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
@ 2016-11-09 17:51                                   ` Jason Gunthorpe
       [not found]                                     ` <20161109175142.GA13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Jason Gunthorpe @ 2016-11-09 17:51 UTC (permalink / raw)
  To: Adit Ranadive
  Cc: Christoph Hellwig, Doug Ledford,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Wed, Nov 09, 2016 at 09:39:49AM -0800, Adit Ranadive wrote:
> On Tue, Nov 08, 2016 at 5:17:15PM -0800, Christoph Hellwig wrote:
> > FYI, the convention used in scsi is vmw_pvscsi.c, so naming the
> > RDMA equivalent vmw_pvrdma would make a lot of sense and still
> > be reasonably short.
> 
> Thanks Christoph. We agree with that as well. Then the driver path
> (drivers/infiniband/hw/vmw_pvrdma/...) and the module name would
> reflect vmw_pvrdma.
> What about the user library? libpvrdma -> libvmwpvrdma?

I am encouraging people to match the name of the module in the
library.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                 ` <20161109012335.GA29658-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
@ 2016-11-09 17:56                   ` Jason Gunthorpe
       [not found]                     ` <20161109175606.GB13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 23+ messages in thread
From: Jason Gunthorpe @ 2016-11-09 17:56 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Adit Ranadive, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Tue, Nov 08, 2016 at 05:23:35PM -0800, Christoph Hellwig wrote:
> On Sat, Nov 05, 2016 at 09:01:36AM -0600, Jason Gunthorpe wrote:
> > > Not entirely. You want me to keep the ABI file from the kernel in the
> > > fix up folder and also keep a file with the modified structs in
> > > providers/pvrdma?
> > 
> > Yes, and the file with the modified structs should include the kernel
> > header and duplicate it minimally. This will make it simpler for us to
> > eventually get rid of it.
> 
> Can we just automate generating the user header, e.g. have a sed script
> that recognized a magic comments ala
> 
> 	/* LIBIBVERBS PREAMBLE (DO NOT REMOVE) */
> 
> and just insers the needed fields?

Yah, something like that is a maybe, but if the drivers are going to
be small like pvrdma, I think we are OK with this approach.. I haven't
had time to audit what is needed beyond knowing that the uverbs header
is actually quite big.

Adit, make sure you push your patch to github too..

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                     ` <20161109175606.GB13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-09 17:58                       ` Adit Ranadive
  0 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-09 17:58 UTC (permalink / raw)
  To: Jason Gunthorpe, Christoph Hellwig
  Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Wed, Nov 09, 2016 at 10:56:06AM -0700, Jason Gunthorpe wrote:
> 
> Adit, make sure you push your patch to github too..
> 
> Jason

Wasnt sure if other folks wanted to take a look at it but I will push it.

Thanks,
Adit 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA
       [not found]                                     ` <20161109175142.GA13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
@ 2016-11-11 19:07                                       ` Adit Ranadive
  0 siblings, 0 replies; 23+ messages in thread
From: Adit Ranadive @ 2016-11-11 19:07 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Christoph Hellwig, Doug Ledford,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers

On Wed, Nov 09, 2016 at 10:51:42AM -0700, Jason Gunthorpe wrote:
> On Wed, Nov 09, 2016 at 09:39:49AM -0800, Adit Ranadive wrote:
> > On Tue, Nov 08, 2016 at 5:17:15PM -0800, Christoph Hellwig wrote:
> > > FYI, the convention used in scsi is vmw_pvscsi.c, so naming the
> > > RDMA equivalent vmw_pvrdma would make a lot of sense and still
> > > be reasonably short.
> > 
> > Thanks Christoph. We agree with that as well. Then the driver path
> > (drivers/infiniband/hw/vmw_pvrdma/...) and the module name would
> > reflect vmw_pvrdma.
> > What about the user library? libpvrdma -> libvmwpvrdma?
> 
> I am encouraging people to match the name of the module in the
> library.
>
> Jason
> 

Hi Doug,

We would like to get the driver in 4.10 if its possible. I can 
respin the patches (with the new driver name/location) based on your
for-4.10 branch or another branch if you prefer.

Thanks,
Adit
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2016-11-11 19:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 23:44 [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA Adit Ranadive
     [not found] ` <1478216677-6150-1-git-send-email-aditr-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-11-03 23:44   ` [PATCH 1/8] libpvrdma: Add ABI and main header files Adit Ranadive
2016-11-03 23:44   ` [PATCH 2/8] libpvrdma: Add ring traversal Adit Ranadive
2016-11-03 23:44   ` [PATCH 3/8] libpvrdma: Add completion queue functions Adit Ranadive
2016-11-03 23:44   ` [PATCH 4/8] libpvrdma: Add queue pair functions Adit Ranadive
2016-11-03 23:44   ` [PATCH 5/8] libpvrdma: Add misc verbs functions Adit Ranadive
2016-11-03 23:44   ` [PATCH 6/8] libpvrdma: Add main library file Adit Ranadive
2016-11-03 23:44   ` [PATCH 7/8] libpvrdma: Add to consolidated rdma-core Adit Ranadive
2016-11-03 23:44   ` [PATCH 8/8] libpvrdma: Add fix up for ABI file Adit Ranadive
2016-11-04  0:46   ` [PATCH rdma-core 0/8] libpvrdma: userspace library for PVRDMA Jason Gunthorpe
     [not found]     ` <20161104004620.GA30318-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-04 21:00       ` Adit Ranadive
     [not found]         ` <b88ad364-9d33-dd3e-a803-bb660de3b384-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-11-05 15:01           ` Jason Gunthorpe
     [not found]             ` <20161105150136.GA23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-09  1:23               ` Christoph Hellwig
     [not found]                 ` <20161109012335.GA29658-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-11-09 17:56                   ` Jason Gunthorpe
     [not found]                     ` <20161109175606.GB13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-09 17:58                       ` Adit Ranadive
2016-11-05 15:03           ` Jason Gunthorpe
     [not found]             ` <20161105150307.GB23803-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-05 17:38               ` Christoph Hellwig
     [not found]                 ` <20161105173815.GA28539-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-11-05 21:24                   ` Doug Ledford
     [not found]                     ` <581E4E01.5020405-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-11-06  1:31                       ` Adit Ranadive
     [not found]                         ` <f67c81ff-d358-7242-dc52-e32dff252904-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-11-09  1:17                           ` Christoph Hellwig
     [not found]                             ` <20161109011715.GA29310-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-11-09 17:39                               ` Adit Ranadive
     [not found]                                 ` <b49161b1-75f6-6902-fced-355804b885bb-pghWNbHTmq7QT0dZR+AlfA@public.gmane.org>
2016-11-09 17:51                                   ` Jason Gunthorpe
     [not found]                                     ` <20161109175142.GA13467-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-11-11 19:07                                       ` Adit Ranadive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).