Skip to contentSkip to conversation

Broadcom User Space RoCE Driver

PATCH Superseded Devesh Sharma 4 participants 30 messages Jan 28, 2017 – Feb 8, 2017 11 messages not in the archive InfiniBand

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Broadcom User Space RoCE Driver

This series introduces the user space RoCE driver for the Broadcom NetXtreme-E 10/25/40/50 RDMA Ethernet Controller. This driver is dependent on the bnxt_re driver posted earlier to linux-rdma community and is under reveiw.

This patch series is based on the latest master of rdma-core repository hosted at https://github.com/linux-rdma/rdma-core.git

The GIT for this library is hosted at following URL on github
https://github.com/dsharma283/bnxtre-rdma-core.git
branch: bnxtre-v0

Please review and give your feedback.

Devesh Sharma (11):
libbnxtre: introduce bnxtre user space RDMA provider
libbnxtre: Add support for user memory regions
libbnxtre: Add support for CQ and QP management
libbnxtre: Add support for posting and polling
libbnxtre: Allow apps to poll for flushed completions
libbnxtre: convert cpu to le all over the place
libbnxtre: Enable UD control path and wqe posting
libbnxtre: Enable polling for UD completions
libbnxtre: Add support for atomic operations
libbnxtre: Add support for SRQ in user lib
libbnxtre: Add versioning support

 CMakeLists.txt                  |    1 +
 MAINTAINERS                     |    5 +
 providers/bnxtre/CMakeLists.txt |    6 +
 providers/bnxtre/abi.h          |  418 ++++++++++
 providers/bnxtre/bnxtre.driver  |    1 +
 providers/bnxtre/db.c           |  110 +++
 providers/bnxtre/list.h         |  135 ++++
 providers/bnxtre/main.c         |  220 ++++++
 providers/bnxtre/main.h         |  358 +++++++++
 providers/bnxtre/memory.c       |   77 ++
 providers/bnxtre/memory.h       |  160 ++++
 providers/bnxtre/verbs.c        | 1597 +++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.h        |  106 +++
 providers/bnxtre/version.h      |   53 ++
 14 files changed, 3247 insertions(+)
 create mode 100644 providers/bnxtre/CMakeLists.txt
 create mode 100644 providers/bnxtre/abi.h
 create mode 100644 providers/bnxtre/bnxtre.driver
 create mode 100644 providers/bnxtre/db.c
 create mode 100644 providers/bnxtre/list.h
 create mode 100644 providers/bnxtre/main.c
 create mode 100644 providers/bnxtre/main.h
 create mode 100644 providers/bnxtre/memory.c
 create mode 100644 providers/bnxtre/memory.h
 create mode 100644 providers/bnxtre/verbs.c
 create mode 100644 providers/bnxtre/verbs.h
 create mode 100644 providers/bnxtre/version.h
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-1-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#2 lore raw

PATCH 1/11 libbnxtre: introduce bnxtre user space RDMA provider

libnxtre is a user-space driver which provides RDMA capability to user applications. The current framework has following parts working:

-Basic Cmake framework to build and install the library. -Register and unregister user-space driver with uverbs
interface.
-List all available bnxt_re devices using "ibv_devinfo"
admin command.
-List all the device and port attributes using
"ibv_devinfo" admin command.
-Support allocate/free of protection domains. -Check ABI version between library and kernel module. -Update MAINTAINERS file

---
 CMakeLists.txt                  |   1 +
 MAINTAINERS                     |   5 +
 providers/bnxtre/CMakeLists.txt |   4 +
 providers/bnxtre/abi.h          |  59 ++++++++++
 providers/bnxtre/bnxtre.driver  |   1 +
 providers/bnxtre/main.c         | 192 +++++++++++++++++++++++++++++++
 providers/bnxtre/main.h         | 108 ++++++++++++++++++
 providers/bnxtre/verbs.c        | 247 ++++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.h        | 106 +++++++++++++++++
 9 files changed, 723 insertions(+)
 create mode 100644 providers/bnxtre/CMakeLists.txt
 create mode 100644 providers/bnxtre/abi.h
 create mode 100644 providers/bnxtre/bnxtre.driver
 create mode 100644 providers/bnxtre/main.c
 create mode 100644 providers/bnxtre/main.h
 create mode 100644 providers/bnxtre/verbs.c
 create mode 100644 providers/bnxtre/verbs.h
CMakeLists.txt +1 -0
index 8f7a475..b6f96c0 100644
@@ -382,6 +382,7 @@ add_subdirectory(providers/nes)
 add_subdirectory(providers/ocrdma)
 add_subdirectory(providers/qedr)
 add_subdirectory(providers/vmw_pvrdma)
+add_subdirectory(providers/bnxtre)
 endif()
 
 add_subdirectory(providers/hfi1verbs)
MAINTAINERS +5 -0
index 2ae504c..f52da1c 100644
@@ -166,3 +166,8 @@ M:	Adit Ranadive <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	providers/vmw_pvrdma/
+
+BNXTRE USERSPACE PROVIDER (for bnxtre.ko)
+M:	Devesh Sharma  <Devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]>
+S:	Supported
+F:	providers/bnxtre
providers/bnxtre/CMakeLists.txt new file +4 -0
new file mode 100644
index 0000000..4c61355
@@ -0,0 +1,4 @@
+rdma_provider(bnxtre
+	main.c
+	verbs.c
+)
providers/bnxtre/abi.h new file +59 -0

59 lines not on this page · raw message

providers/bnxtre/bnxtre.driver new file +1 -0
new file mode 100644
index 0000000..5ce796f
@@ -0,0 +1 @@
+driver	bnxtre
providers/bnxtre/main.c new file +192 -0

192 lines not on this page · raw message

providers/bnxtre/main.h new file +108 -0

108 lines not on this page · raw message

providers/bnxtre/verbs.c new file +247 -0

247 lines not on this page · raw message

providers/bnxtre/verbs.h new file +106 -0

106 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-2-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#4 lore raw

Re: [PATCH rdma-core 01/11] libbnxtre: introduce bnxtre user space RDMA provider

Quoted 55 lines · Devesh Sharma

libnxtre is a user-space driver which provides RDMA capability to user applications. The current framework has following parts working:

-Basic Cmake framework to build and install the library. -Register and unregister user-space driver with uverbs
interface.
-List all available bnxt_re devices using "ibv_devinfo"
admin command.
-List all the device and port attributes using
"ibv_devinfo" admin command.
-Support allocate/free of protection domains. -Check ABI version between library and kernel module. -Update MAINTAINERS file

---
 CMakeLists.txt                  |   1 +
 MAINTAINERS                     |   5 +
 providers/bnxtre/CMakeLists.txt |   4 +
 providers/bnxtre/abi.h          |  59 ++++++++++
 providers/bnxtre/bnxtre.driver  |   1 +
 providers/bnxtre/main.c         | 192 +++++++++++++++++++++++++++++++
 providers/bnxtre/main.h         | 108 ++++++++++++++++++
 providers/bnxtre/verbs.c        | 247 ++++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.h        | 106 +++++++++++++++++
 9 files changed, 723 insertions(+)
 create mode 100644 providers/bnxtre/CMakeLists.txt
 create mode 100644 providers/bnxtre/abi.h
 create mode 100644 providers/bnxtre/bnxtre.driver
 create mode 100644 providers/bnxtre/main.c
 create mode 100644 providers/bnxtre/main.h
 create mode 100644 providers/bnxtre/verbs.c
 create mode 100644 providers/bnxtre/verbs.h
CMakeLists.txt +1 -0
index 8f7a475..b6f96c0 100644
@@ -382,6 +382,7 @@ add_subdirectory(providers/nes)
 add_subdirectory(providers/ocrdma)
 add_subdirectory(providers/qedr)
 add_subdirectory(providers/vmw_pvrdma)
+add_subdirectory(providers/bnxtre)
 endif()
 
 add_subdirectory(providers/hfi1verbs)
MAINTAINERS +0 -0
index 2ae504c..f52da1c 100644

MAINTAINERS M: Adit Ranadive <[email protected]> · line 173

Quoted 8 lines
MAINTAINERS +5 -0
@@ -166,3 +166,8 @@ M:	Adit Ranadive <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	providers/vmw_pvrdma/
+
+BNXTRE USERSPACE PROVIDER (for bnxtre.ko)
+M:	Devesh Sharma  <Devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]>
+S:	Supported
+F:	providers/bnxtre

It should have "/" at the end of line.

Quoted 120 lines
providers/bnxtre/CMakeLists.txt new file +4 -0
new file mode 100644
index 0000000..4c61355
@@ -0,0 +1,4 @@
+rdma_provider(bnxtre
+	main.c
+	verbs.c
+)
providers/bnxtre/abi.h new file +59 -0
new file mode 100644
index 0000000..653ac71
@@ -0,0 +1,59 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: ABI data structure definition
+ */
+
+#ifndef __BNXT_RE_ABI_H__
+#define __BNXT_RE_ABI_H__
+
+#include <infiniband/kern-abi.h>
+
+#define BNXT_RE_ABI_VERSION 1
+
+struct bnxt_re_cntx_resp {
+	struct ibv_get_context_resp resp;
+	__u32 dev_id;
+	__u32 max_qp; /* To allocate qp-table */
+};
+
+struct bnxt_re_pd_resp {
+	struct ibv_alloc_pd_resp resp;
+	__u32 pdid;
+	__u32 dpi;
+	__u64 dbr;
+};
+
+#endif
providers/bnxtre/bnxtre.driver new file +1 -0
new file mode 100644
index 0000000..5ce796f
@@ -0,0 +1 @@
+driver	bnxtre
providers/bnxtre/main.c new file +32 -0
new file mode 100644
index 0000000..0c26c8b
@@ -0,0 +1,192 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE

providers/bnxtre/main.c line 42

Quoted 10 lines
providers/bnxtre/main.c new file +10 -0
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Device detection and initializatoin
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif                          /* HAVE_CONFIG_H */
+

There is no need to guard config.h

Quoted 1 line
providers/bnxtre/main.c new file +1 -0
+#include <stdio.h>
#5 lore raw

Re: [PATCH rdma-core 01/11] libbnxtre: introduce bnxtre user space RDMA provider

In reply to a message not in the archive
Quoted 5 lines · Devesh Sharma

add_subdirectory(providers/ocrdma)
add_subdirectory(providers/qedr)
add_subdirectory(providers/vmw_pvrdma)
+add_subdirectory(providers/bnxtre)
endif()

Keep list sorted

Quoted 6 lines

add_subdirectory(providers/hfi1verbs)

MAINTAINERS +1 -0
index 2ae504c..f52da1c 100644
+++ b/MAINTAINERS

MAINTAINERS M: Adit Ranadive <[email protected]> · line 173

Quoted 8 lines
MAINTAINERS +5 -0
@@ -166,3 +166,8 @@ M:	Adit Ranadive <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	providers/vmw_pvrdma/
+
+BNXTRE USERSPACE PROVIDER (for bnxtre.ko)
+M:	Devesh Sharma  <Devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]>
+S:	Supported
+F:	providers/bnxtre

Keep list sorted

providers/bnxtre/bnxtre.driver line 1

Quoted 6 lines
providers/bnxtre/bnxtre.driver new file +2 -0
new file mode 100644
index 0000000..5ce796f
+++ b/providers/bnxtre/bnxtre.driver
@@ -0,0 +1 @@
+driver	bnxtre

No, delete this file

providers/bnxtre/bnxtre.driver

Quoted 3 lines
providers/bnxtre/bnxtre.driver new file +3 -0
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif                          /* HAVE_CONFIG_H */

HAVE_CONFIG_H is not defined in our builds, do not use config.h if we don't need it. Ditto everywhere

providers/bnxtre/bnxtre.driver

Quoted 4 lines
providers/bnxtre/bnxtre.driver new file +4 -0
+struct {
+	unsigned int vendor;
+	unsigned int device;
+} cna_table[] = {

static const?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

PATCH 2/11 libbnxtre: Add support for user memory regions

In reply to a message not in the archive

This patch adds code to allow user applications to register and unregister memory buffers with the HCA. Following functions are now supported:
- ibv_reg_mr()
- ibv_dereg_mr()

---
 providers/bnxtre/abi.h   |  4 ++++
 providers/bnxtre/verbs.c | 26 ++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)
providers/bnxtre/abi.h +4 -0
index 653ac71..0568d67 100644
@@ -56,4 +56,8 @@ struct bnxt_re_pd_resp {
 	__u64 dbr;
 };
 
+struct bnxt_re_mr_resp {
+	struct ibv_reg_mr_resp resp;
+};
+
 #endif
providers/bnxtre/verbs.c +24 -2
index ab1a453..9813db8 100644
@@ -134,12 +134,34 @@ int bnxt_re_free_pd(struct ibv_pd *ibvpd)
 struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len,
 			      int access)
 {
-	return NULL;
+	struct bnxt_re_mr *mr;
+	struct ibv_reg_mr cmd;
+	struct bnxt_re_mr_resp resp;
+
+	mr = calloc(1, sizeof(*mr));
+	if (!mr)
+		return NULL;
+
+	if (ibv_cmd_reg_mr(ibvpd, sva, len, (uint64_t)sva, access, &mr->ibvmr,
+			   &cmd, sizeof(cmd), &resp.resp, sizeof(resp))) {
+		free(mr);
+		return NULL;
+	}
+
+	return &mr->ibvmr;
 }
 
 int bnxt_re_dereg_mr(struct ibv_mr *ibvmr)
 {
-	return -ENOSYS;
+	struct bnxt_re_mr *mr = (struct bnxt_re_mr *)ibvmr;
+	int status;
+
+	status = ibv_cmd_dereg_mr(ibvmr);
+	if (status)
+		return status;
+	free(mr);
+
+	return 0;
 }
 
 struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

PATCH 3/11 libbnxtre: Add support for CQ and QP management

In reply to a message not in the archive

This patch adds support for completion queue creation and destruction following are the changes:

- Added User/Kernel ABI to communicate CQ specific parameters.
- Added a function in a new file to allocate Page-Aligned address space.
- Added a function to free page-aligned address space.
- Added function to create and destroy completion queue.
- Add ABI to for QP creation and WQE/RQE format.
- Add functions to allocate SQ, RQ and Search PSN address space.
- Add functions to store/clean qp-handles in the form of a linear table. There is table maintained in every instance of ucontext.
- CQ and QP contexts now hold a pointer to the DPI mapped during PD allocation.
- Removed hard-coding of page size during mapping DB page.
- Renamed a variable in PD code.
- Add support for create-qp.
- Add support for destroy-qp.
- Add support for modify-qp.
- Add support for query-qp.

---
 providers/bnxtre/CMakeLists.txt |   1 +
 providers/bnxtre/abi.h          | 127 +++++++++++++++++++++
 providers/bnxtre/main.c         |   5 +
 providers/bnxtre/main.h         |  61 +++++++++--
 providers/bnxtre/memory.c       |  73 +++++++++++++
 providers/bnxtre/memory.h       |  76 +++++++++++++
 providers/bnxtre/verbs.c        | 236 +++++++++++++++++++++++++++++++++++++++-
 7 files changed, 561 insertions(+), 18 deletions(-)
 create mode 100644 providers/bnxtre/memory.c
 create mode 100644 providers/bnxtre/memory.h
providers/bnxtre/CMakeLists.txt +1 -0
index 4c61355..93bdf1a 100644
@@ -1,4 +1,5 @@
 rdma_provider(bnxtre
+	memory.c
 	main.c
 	verbs.c
 )
providers/bnxtre/abi.h +127 -0

137 lines not on this page · raw message

providers/bnxtre/main.c +5 -0
index 0c26c8b..3cb3827 100644
@@ -115,8 +115,10 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 {
 	struct ibv_get_context cmd;
 	struct bnxt_re_cntx_resp resp;
+	struct bnxt_re_dev *dev;
 	struct bnxt_re_context *cntx;
 
+	dev = to_bnxt_re_dev(&vdev->device);
 	cntx = to_bnxt_re_context(ibvctx);
 
 	memset(&resp, 0, sizeof(resp));
@@ -127,6 +129,9 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 
 	cntx->dev_id = resp.dev_id;
 	cntx->max_qp = resp.max_qp;
+	dev->pg_size = resp.pg_size;
+	dev->cqe_size = resp.cqe_size;
+	dev->max_cq_depth = resp.max_cqd;
 	ibvctx->ops = bnxt_re_cntx_ops;
 
 	return 0;
providers/bnxtre/main.h +49 -12

90 lines not on this page · raw message

providers/bnxtre/memory.c new file +73 -0

73 lines not on this page · raw message

providers/bnxtre/memory.h new file +76 -0

76 lines not on this page · raw message

providers/bnxtre/verbs.c +230 -6

296 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-4-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#9 lore raw

Re: [PATCH rdma-core 03/11] libbnxtre: Add support for CQ and QP management

providers/bnxtre/CMakeLists.txt line 4

Quoted 8 lines · Devesh Sharma
providers/bnxtre/CMakeLists.txt +2 -0
index 4c61355..93bdf1a 100644
+++ b/providers/bnxtre/CMakeLists.txt
@@ -1,4 +1,5 @@
 rdma_provider(bnxtre
+	memory.c
 	main.c
 	verbs.c

Keep list sorted

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [PATCH rdma-core 03/11] libbnxtre: Add support for CQ and QP management

In reply to a message not in the archive
Quoted 180 lines · Devesh Sharma

This patch adds support for completion queue creation and destruction following are the changes:

- Added User/Kernel ABI to communicate CQ specific parameters.
- Added a function in a new file to allocate Page-Aligned address space.
- Added a function to free page-aligned address space.
- Added function to create and destroy completion queue.
- Add ABI to for QP creation and WQE/RQE format.
- Add functions to allocate SQ, RQ and Search PSN address space.
- Add functions to store/clean qp-handles in the form of a linear table. There is table maintained in every instance of ucontext.
- CQ and QP contexts now hold a pointer to the DPI mapped during PD allocation.
- Removed hard-coding of page size during mapping DB page.
- Renamed a variable in PD code.
- Add support for create-qp.
- Add support for destroy-qp.
- Add support for modify-qp.
- Add support for query-qp.

---
 providers/bnxtre/CMakeLists.txt |   1 +
 providers/bnxtre/abi.h          | 127 +++++++++++++++++++++
 providers/bnxtre/main.c         |   5 +
 providers/bnxtre/main.h         |  61 +++++++++--
 providers/bnxtre/memory.c       |  73 +++++++++++++
 providers/bnxtre/memory.h       |  76 +++++++++++++
 providers/bnxtre/verbs.c        | 236 +++++++++++++++++++++++++++++++++++++++-
 7 files changed, 561 insertions(+), 18 deletions(-)
 create mode 100644 providers/bnxtre/memory.c
 create mode 100644 providers/bnxtre/memory.h
providers/bnxtre/CMakeLists.txt +1 -0
index 4c61355..93bdf1a 100644
@@ -1,4 +1,5 @@
 rdma_provider(bnxtre
+	memory.c
 	main.c
 	verbs.c
 )
providers/bnxtre/abi.h +116 -0
index 0568d67..81d7585 100644
@@ -47,6 +47,10 @@ struct bnxt_re_cntx_resp {
 	struct ibv_get_context_resp resp;
 	__u32 dev_id;
 	__u32 max_qp; /* To allocate qp-table */
+	__u32 pg_size;
+	__u32 cqe_size;
+	__u32 max_cqd;
+	__u32 rsvd;
 };
 
 struct bnxt_re_pd_resp {
@@ -60,4 +64,127 @@ struct bnxt_re_mr_resp {
 	struct ibv_reg_mr_resp resp;
 };
 
+struct bnxt_re_cq_req {
+	struct ibv_create_cq cmd;
+	__u64 cq_va;
+	__u64 cq_handle;
+};
+
+struct bnxt_re_cq_resp {
+	struct ibv_create_cq_resp resp;
+	__u32 cqid;
+	__u32 tail;
+	__u32 phase;
+	__u32 rsvd;
+};
+
+struct bnxt_re_qp_req {
+	struct ibv_create_qp cmd;
+	__u64 qpsva;
+	__u64 qprva;
+	__u64 qp_handle;
+};
+
+struct bnxt_re_qp_resp {
+	struct ibv_create_qp_resp resp;
+	__u32 qpid;
+	__u32 rsvd;
+};
+
+struct bnxt_re_bsqe {
+	__u32 rsv_ws_fl_wt;
+	__u32 key_immd;
+};
+
+struct bnxt_re_psns {
+	__u32 opc_spsn;
+	__u32 flg_npsn;
+};
+
+struct bnxt_re_sge {
+	__u32 pa_lo;
+	__u32 pa_hi;
+	__u32 lkey;
+	__u32 length;
+};
+
+/*  Cu+ max inline data */
+#define BNXT_RE_MAX_INLINE_SIZE		0x60
+
+struct bnxt_re_send {
+	__u32 length;
+	__u32 qkey;
+	__u32 dst_qp;
+	__u32 avid;
+	__u64 rsvd;
+};
+
+struct bnxt_re_raw {
+	__u32 length;
+	__u32 rsvd1;
+	__u32 cfa_meta;
+	__u32 rsvd2;
+	__u64 rsvd3;
+};
+
+struct bnxt_re_rdma {
+	__u32 length;
+	__u32 rsvd1;
+	__u32 rva_lo;
+	__u32 rva_hi;
+	__u32 rkey;
+	__u32 rsvd2;
+};
+
+struct bnxt_re_atomic {
+	__u32 rva_lo;
+	__u32 rva_hi;
+	__u32 swp_dt_lo;
+	__u32 swp_dt_hi;
+	__u32 cmp_dt_lo;
+	__u32 cmp_dt_hi;
+};
+
+struct bnxt_re_inval {
+	__u64 rsvd[3];
+};
+
+struct bnxt_re_bind {
+	__u32 plkey;
+	__u32 lkey;
+	__u32 va_lo;
+	__u32 va_hi;
+	__u32 len_lo;
+	__u32 len_hi; /* only 40 bits are valid */
+};
+
+struct bnxt_re_brqe {
+	__u32 rsv_ws_fl_wt;
+	__u32 rsvd;
+};
+
+struct bnxt_re_rqe {
+	__u64 rsvd[3];
+};
+
+struct bnxt_re_srqe {
+	__u32 srq_tag; /* 20 bits are valid */
+	__u32 rsvd1;
+	__u64 rsvd[2];
+};
+
+static inline uint32_t bnxt_re_get_sqe_sz(void)
+{
+	return sizeof(struct bnxt_re_bsqe) +

providers/bnxtre/abi.h struct bnxt_re_mr_resp { · line 188

Quoted 10 lines
providers/bnxtre/abi.h +10 -0
+	       sizeof(struct bnxt_re_send) +
+	       BNXT_RE_MAX_INLINE_SIZE;
+}
+
+static inline uint32_t bnxt_re_get_rqe_sz(void)
+{
+	return sizeof(struct bnxt_re_brqe) +
+	       sizeof(struct bnxt_re_rqe) +
+	       BNXT_RE_MAX_INLINE_SIZE;
+}

I afraid that you misuse this abi.h file. Our intention is to keep it as close as possible to kernel version, so no functions please.

Quoted 169 lines
providers/bnxtre/abi.h +1 -0
+
 #endif
providers/bnxtre/main.c +5 -0
index 0c26c8b..3cb3827 100644
@@ -115,8 +115,10 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 {
 	struct ibv_get_context cmd;
 	struct bnxt_re_cntx_resp resp;
+	struct bnxt_re_dev *dev;
 	struct bnxt_re_context *cntx;
 
+	dev = to_bnxt_re_dev(&vdev->device);
 	cntx = to_bnxt_re_context(ibvctx);
 
 	memset(&resp, 0, sizeof(resp));
@@ -127,6 +129,9 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 
 	cntx->dev_id = resp.dev_id;
 	cntx->max_qp = resp.max_qp;
+	dev->pg_size = resp.pg_size;
+	dev->cqe_size = resp.cqe_size;
+	dev->max_cq_depth = resp.max_cqd;
 	ibvctx->ops = bnxt_re_cntx_ops;
 
 	return 0;
providers/bnxtre/main.h +49 -12
index 700dcb8..954ac47 100644
@@ -47,6 +47,16 @@
 #include <infiniband/driver.h>
 #include <infiniband/arch.h>
 
+#include "memory.h"
+
+#define DEV	"bnxtre : "
+
+struct bnxt_re_dpi {
+	__u32 dpindx;
+	__u64 *dbpage;
+	pthread_spinlock_t db_lock;
+};
+
 struct bnxt_re_pd {
 	struct ibv_pd ibvpd;
 	uint32_t pdid;
@@ -54,31 +64,48 @@ struct bnxt_re_pd {
 
 struct bnxt_re_cq {
 	struct ibv_cq ibvcq;
-};
-
-struct bnxt_re_qp {
-	struct ibv_qp ibvqp;
+	uint32_t cqid;
+	struct bnxt_re_queue cqq;
+	struct bnxt_re_dpi *udpi;
+	uint32_t cqe_size;
+	uint8_t  phase;
 };
 
 struct bnxt_re_srq {
 	struct ibv_srq ibvsrq;
 };
 
-struct bnxt_re_mr {
-	struct ibv_mr ibvmr;
+struct bnxt_re_qp {
+	struct ibv_qp ibvqp;
+	struct bnxt_re_queue *sqq;
+	struct bnxt_re_psns *psns; /* start ptr. */
+	struct bnxt_re_queue *rqq;
+	struct bnxt_re_srq *srq;
+	struct bnxt_re_cq *scq;
+	struct bnxt_re_cq *rcq;
+	struct bnxt_re_dpi *udpi;
+	uint64_t *swrid;
+	uint64_t *rwrid;
+	uint32_t qpid;
+	uint32_t tbl_indx;
+	uint16_t mtu;
+	uint16_t qpst;
+	uint8_t qptyp;
+	/* wrid? */
+	/* irdord? */
 };
 
-#define DEV	"bnxtre : "
-
-struct bnxt_re_dpi {
-	__u32 dpindx;
-	__u64 *dbpage;
-	pthread_spinlock_t db_lock;
+struct bnxt_re_mr {
+	struct ibv_mr ibvmr;
 };
 
 struct bnxt_re_dev {
 	struct verbs_device vdev;
 	uint8_t abi_version;
+	uint32_t pg_size;
+
+	uint32_t cqe_size;
+	uint32_t max_cq_depth;
 };
 
 struct bnxt_re_context {
@@ -105,4 +132,14 @@ static inline struct bnxt_re_pd *to_bnxt_re_pd(struct ibv_pd *ibvpd)
 	return container_of(ibvpd, struct bnxt_re_pd, ibvpd);
 }
 
+static inline struct bnxt_re_cq *to_bnxt_re_cq(struct ibv_cq *ibvcq)
+{
+	return container_of(ibvcq, struct bnxt_re_cq, ibvcq);
+}
+
+static inline struct bnxt_re_qp *to_bnxt_re_qp(struct ibv_qp *ibvqp)
+{
+	return container_of(ibvqp, struct bnxt_re_qp, ibvqp);
+}
+
 #endif
providers/bnxtre/memory.c new file +39 -0
new file mode 100644
index 0000000..c96641e
@@ -0,0 +1,73 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Implements method to allocate page-aligned memory
+ *              buffers.
+ */
+

providers/bnxtre/memory.c line 49

Quoted 10 lines
providers/bnxtre/memory.c new file +10 -0
+#include <sys/mman.h>
+
+#include "main.h"
+
+int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size)
+{
+	int ret, bytes;
+
+	bytes = (que->depth * que->stride);
+	que->bytes = get_aligned(bytes, pg_size);

There is the same function align(..) which many providers implemented it. Please move it to common code to all providers and use it from there.

Quoted 91 lines
providers/bnxtre/memory.c new file +24 -0
+	que->va = mmap(NULL, que->bytes, PROT_READ | PROT_WRITE,
+		       MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if (que->va == MAP_FAILED) {
+		que->bytes = 0;
+		return errno;
+	}
+
+	ret = ibv_dontfork_range(que->va, que->bytes);
+	if (ret) {
+		munmap(que->va, que->bytes);
+		que->bytes = 0;
+	}
+
+	return ret;
+}
+
+void bnxt_re_free_aligned(struct bnxt_re_queue *que)
+{
+	if (que->bytes) {
+		ibv_dofork_range(que->va, que->bytes);
+		munmap(que->va, que->bytes);
+		que->bytes = 0;
+	}
+}
providers/bnxtre/memory.h new file +61 -0
new file mode 100644
index 0000000..6c4ebaa
@@ -0,0 +1,76 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Implements data-struture to allocate page-aligned
+ *              memory buffer.
+ */
+
+#ifndef __BNXT_RE_MEMORY_H__
+#define __BNXT_RE_MEMORY_H__
+
+#include <pthread.h>
+
+struct bnxt_re_queue {
+	void *va;
+	uint32_t bytes; /* for munmap */
+	uint32_t depth; /* no. of entries */
+	uint32_t head;
+	uint32_t tail;
+	uint32_t stride;
+	pthread_spinlock_t qlock;
+};
+
+static inline unsigned long get_aligned(uint32_t size, uint32_t al_size)
+{
+	return (unsigned long)(size + al_size - 1) & ~(al_size - 1);
+}
+
+static inline unsigned long roundup_pow_of_two(unsigned long val)
+{

providers/bnxtre/memory.h line 71

Quoted 10 lines
providers/bnxtre/memory.h new file +10 -0
+	unsigned long roundup = 1;
+
+	if (val == 1)
+		return (roundup << 1);
+
+	while (roundup < val)
+		roundup <<= 1;
+
+	return roundup;
+}

Please move to common code.

Quoted 319 lines
providers/bnxtre/memory.h new file +5 -0
+
+int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size);
+void bnxt_re_free_aligned(struct bnxt_re_queue *que);
+
+#endif
providers/bnxtre/verbs.c +230 -7
index 9813db8..3cad358 100644
@@ -84,6 +84,7 @@ struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *ibvctx)
 	struct ibv_alloc_pd cmd;
 	struct bnxt_re_pd_resp resp;
 	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx);
+	struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device);
 	struct bnxt_re_pd *pd;
 
 	pd = calloc(1, sizeof(*pd));
@@ -99,7 +100,7 @@ struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *ibvctx)
 
 	/* Map DB page now. */
 	cntx->udpi.dpindx = resp.dpi;
-	cntx->udpi.dbpage = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED,
+	cntx->udpi.dbpage = mmap(NULL, dev->pg_size, PROT_WRITE, MAP_SHARED,
 				 ibvctx->cmd_fd, resp.dbr);
 	if (cntx->udpi.dbpage == MAP_FAILED) {
 		(void)ibv_cmd_dealloc_pd(&pd->ibvpd);
@@ -117,6 +118,7 @@ int bnxt_re_free_pd(struct ibv_pd *ibvpd)
 {
 	struct bnxt_re_pd *pd = to_bnxt_re_pd(ibvpd);
 	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvpd->context);
+	struct bnxt_re_dev *dev = to_bnxt_re_dev(cntx->ibvctx.device);
 	int status;
 
 	status = ibv_cmd_dealloc_pd(ibvpd);
@@ -125,7 +127,8 @@ int bnxt_re_free_pd(struct ibv_pd *ibvpd)
 
 	pthread_spin_destroy(&cntx->udpi.db_lock);
 	if (cntx->udpi.dbpage && (cntx->udpi.dbpage != MAP_FAILED))
-		munmap(cntx->udpi.dbpage, 4096);
+		munmap(cntx->udpi.dbpage, dev->pg_size);
+
 	free(pd);
 
 	return 0;
@@ -167,6 +170,48 @@ int bnxt_re_dereg_mr(struct ibv_mr *ibvmr)
 struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
 				 struct ibv_comp_channel *channel, int vec)
 {
+	struct bnxt_re_cq *cq;
+	struct bnxt_re_cq_req cmd;
+	struct bnxt_re_cq_resp resp;
+
+	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx);
+	struct bnxt_re_dev *dev = to_bnxt_re_dev(ibvctx->device);
+
+	if (ncqe > dev->max_cq_depth)
+		return NULL;
+
+	cq = calloc(1, sizeof(*cq));
+	if (!cq)
+		return NULL;
+
+	cq->cqq.depth = roundup_pow_of_two(ncqe + 1);
+	if (cq->cqq.depth > dev->max_cq_depth + 1)
+		cq->cqq.depth = dev->max_cq_depth + 1;
+	cq->cqq.stride = dev->cqe_size;
+	if (bnxt_re_alloc_aligned(&cq->cqq, dev->pg_size))
+		goto fail;
+
+	pthread_spin_init(&cq->cqq.qlock, PTHREAD_PROCESS_PRIVATE);
+
+	cmd.cq_va = (uint64_t)cq->cqq.va;
+	cmd.cq_handle = (uint64_t)cq;
+
+	memset(&resp, 0, sizeof(resp));
+	if (ibv_cmd_create_cq(ibvctx, ncqe, channel, vec,
+			      &cq->ibvcq, &cmd.cmd, sizeof(cmd),
+			      &resp.resp, sizeof(resp)))
+		goto cmdfail;
+
+	cq->cqid = resp.cqid;
+	cq->phase = resp.phase;
+	cq->cqq.tail = resp.tail;
+	cq->udpi = &cntx->udpi;
+
+	return &cq->ibvcq;
+cmdfail:
+	bnxt_re_free_aligned(&cq->cqq);
+fail:
+	free(cq);
 	return NULL;
 }
 
@@ -177,7 +222,17 @@ int bnxt_re_resize_cq(struct ibv_cq *ibvcq, int ncqe)
 
 int bnxt_re_destroy_cq(struct ibv_cq *ibvcq)
 {
-	return -ENOSYS;
+	int status;
+	struct bnxt_re_cq *cq = to_bnxt_re_cq(ibvcq);
+
+	status = ibv_cmd_destroy_cq(ibvcq);
+	if (status)
+		return status;
+
+	bnxt_re_free_aligned(&cq->cqq);
+	free(cq);
+
+	return 0;
 }
 
 int bnxt_re_poll_cq(struct ibv_cq *ibvcq, int nwc, struct ibv_wc *wc)
@@ -195,27 +250,196 @@ int bnxt_re_arm_cq(struct ibv_cq *ibvcq, int flags)
 	return -ENOSYS;
 }
 
+static int bnxt_re_check_qp_limits(struct ibv_qp_init_attr *attr)
+{
+	return 0;
+}
+
+static void bnxt_re_free_queue_ptr(struct bnxt_re_qp *qp)
+{
+	if (qp->rqq)
+		free(qp->rqq);
+	if (qp->sqq)
+		free(qp->sqq);
+}
+
+static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp,
+				   struct ibv_qp_init_attr *attr)
+{
+	qp->sqq = calloc(1, sizeof(struct bnxt_re_queue));
+	if (!qp->sqq)
+		return -ENOMEM;
+	if (attr->srq)
+		qp->srq = NULL;/*TODO: to_bnxt_re_srq(attr->srq);*/
+	else {
+		qp->rqq = calloc(1, sizeof(struct bnxt_re_queue));
+		if (!qp->rqq) {
+			free(qp->sqq);
+			return -ENOMEM;
+		}
+	}
+
+	return 0;
+}
+
+static void bnxt_re_free_queues(struct bnxt_re_qp *qp)
+{
+	if (qp->rwrid)
+		free(qp->rwrid);
+	pthread_spin_destroy(&qp->rqq->qlock);
+	bnxt_re_free_aligned(qp->rqq);
+
+	if (qp->swrid)
+		free(qp->swrid);
+	pthread_spin_destroy(&qp->sqq->qlock);
+	bnxt_re_free_aligned(qp->sqq);
+}
+
+static int bnxt_re_alloc_queues(struct bnxt_re_qp *qp,
+				struct ibv_qp_init_attr *attr,
+				uint32_t pg_size) {
+	struct bnxt_re_queue *que;
+	uint32_t psn_depth;
+	int ret;
+
+	if (attr->cap.max_send_wr) {
+		que = qp->sqq;
+		que->stride = bnxt_re_get_sqe_sz();
+		que->depth = roundup_pow_of_two(attr->cap.max_send_wr);
+		/* psn_depth extra entries of size que->stride */
+		psn_depth = (que->depth * sizeof(struct bnxt_re_psns)) /
+			     que->stride;
+		que->depth += psn_depth;
+		ret = bnxt_re_alloc_aligned(qp->sqq, pg_size);
+		if (ret)
+			return ret;
+		/* exclude psns depth*/
+		que->depth -= psn_depth;
+		/* start of spsn space sizeof(struct bnxt_re_psns) each. */
+		qp->psns = (que->va + que->stride * que->depth);
+		pthread_spin_init(&que->qlock, PTHREAD_PROCESS_PRIVATE);
+		qp->swrid = calloc(que->depth, sizeof(uint64_t));
+		if (!qp->swrid) {
+			ret = -ENOMEM;
+			goto fail;
+		}
+	}
+
+	if (attr->cap.max_recv_wr && qp->rqq) {
+		que = qp->rqq;
+		que->stride = bnxt_re_get_rqe_sz();
+		que->depth = roundup_pow_of_two(attr->cap.max_recv_wr);
+		ret = bnxt_re_alloc_aligned(qp->rqq, pg_size);
+		if (ret)
+			goto fail;
+		pthread_spin_init(&que->qlock, PTHREAD_PROCESS_PRIVATE);
+		qp->rwrid = calloc(que->depth, sizeof(uint64_t));
+		if (!qp->rwrid) {
+			ret = -ENOMEM;
+			goto fail;
+		}
+	}
+
+	return 0;
+
+fail:
+	bnxt_re_free_queues(qp);
+	return ret;
+}
+
 struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd,
 				 struct ibv_qp_init_attr *attr)
 {
+	struct bnxt_re_qp *qp;
+	struct bnxt_re_qp_req req;
+	struct bnxt_re_qp_resp resp;
+
+	struct bnxt_re_context *cntx = to_bnxt_re_context(ibvpd->context);
+	struct bnxt_re_dev *dev = to_bnxt_re_dev(cntx->ibvctx.device);
+
+	if (bnxt_re_check_qp_limits(attr))
+		return NULL;
+
+	qp = calloc(1, sizeof(*qp));
+	if (!qp)
+		return NULL;
+	/* alloc queue pointers */
+	if (bnxt_re_alloc_queue_ptr(qp, attr))
+		goto fail;
+	/* alloc queues */
+	if (bnxt_re_alloc_queues(qp, attr, dev->pg_size))
+		goto failq;
+	/* Fill ibv_cmd */
+	req.qpsva = (uint64_t)qp->sqq->va;
+	req.qprva = qp->rqq ? (uint64_t)qp->rqq->va : 0;
+	req.qp_handle = (uint64_t)qp;
+
+	if (ibv_cmd_create_qp(ibvpd, &qp->ibvqp, attr, &req.cmd, sizeof(req),
+			      &resp.resp, sizeof(resp))) {
+		goto failcmd;
+	}
+
+	qp->qpid = resp.qpid;
+	qp->qptyp = attr->qp_type;
+	qp->qpst = IBV_QPS_RESET;
+	qp->scq = to_bnxt_re_cq(attr->send_cq);
+	qp->rcq = to_bnxt_re_cq(attr->recv_cq);
+	qp->udpi = &cntx->udpi;
+
+	return &qp->ibvqp;
+failcmd:
+	bnxt_re_free_queues(qp);
+failq:
+	bnxt_re_free_queue_ptr(qp);
+fail:
+	free(qp);
+
 	return NULL;
 }
 
 int bnxt_re_modify_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr,
 		      int attr_mask)
 {
-	return -ENOSYS;
+	struct ibv_modify_qp cmd = {};
+	struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp);
+	int rc;
+
+	rc = ibv_cmd_modify_qp(ibvqp, attr, attr_mask, &cmd, sizeof(cmd));
+	if (!rc)
+		qp->qpst = ibvqp->state;
+
+	return rc;
 }
 
 int bnxt_re_query_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr,
 		     int attr_mask, struct ibv_qp_init_attr *init_attr)
 {
-	return -ENOSYS;
+	struct ibv_query_qp cmd;
+	struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp);
+	int rc;
+
+	rc = ibv_cmd_query_qp(ibvqp, attr, attr_mask, init_attr,
+			      &cmd, sizeof(cmd));
+	if (!rc)
+		qp->qpst = ibvqp->state;
+
+	return rc;
 }
 
 int bnxt_re_destroy_qp(struct ibv_qp *ibvqp)
 {
-	return -ENOSYS;
+	struct bnxt_re_qp *qp = to_bnxt_re_qp(ibvqp);
+	int status;
+
+	status = ibv_cmd_destroy_qp(ibvqp);
+	if (status)
+		return status;
+
+	bnxt_re_free_queues(qp);
+	bnxt_re_free_queue_ptr(qp);
+	free(qp);
+
+	return 0;
 }
 
 int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

PATCH 4/11 libbnxtre: Add support for posting and polling

In reply to a message not in the archive

This patch adds code to support ibv_post_recv(), ibv_post_send(), ibv_poll_cq() and ibv_arm_cq() routines. With this patch applications are able to enqueue RQE or WQE ring doorbells and poll for completions from CQ. Currently, this code do not support SRQ, UD service and and flush completions. Following are the major changes:

- Added most of the enums to handle device specific opcodes, masks, shifts and data structures.
- Added a new file to define DB related routines.
- Added routines to handle circular queue operations.
- Added enums and few utility functions.
- Added bnxt_re_post_recv().
- Add code to build and post SQEs for RDMA-WRITE, RDMA-READ, SEND through bnxt_re_post_send() routine.
- Fixed couple of bugs in create-qp and modify-qp.
- bnxt_re_create_qp() now check the limits.
- Add polling support for RC send completions.
- Add polling support for RC Recv completions.
- Add support to ARM completion queue.
- Cleanup CQ while QP is being destroyed.
- Add utility functions to convert chip specific completion codes to IB stack specific codes.

---
 providers/bnxtre/CMakeLists.txt |   1 +
 providers/bnxtre/abi.h          | 189 +++++++++++-
 providers/bnxtre/db.c           |  92 ++++++
 providers/bnxtre/main.c         |   1 +
 providers/bnxtre/main.h         | 184 ++++++++++-
 providers/bnxtre/memory.c       |   4 +
 providers/bnxtre/memory.h       |  31 ++
 providers/bnxtre/verbs.c        | 663 +++++++++++++++++++++++++++++++++++++---
 8 files changed, 1124 insertions(+), 41 deletions(-)
 create mode 100644 providers/bnxtre/db.c
providers/bnxtre/CMakeLists.txt +1 -0
index 93bdf1a..bad462a 100644
@@ -1,5 +1,6 @@
 rdma_provider(bnxtre
 	memory.c
+	db.c
 	main.c
 	verbs.c
 )
providers/bnxtre/abi.h +188 -1

219 lines not on this page · raw message

providers/bnxtre/db.c new file +92 -0

92 lines not on this page · raw message

providers/bnxtre/main.c +1 -0
index 3cb3827..962f460 100644
@@ -110,6 +110,7 @@ static struct ibv_context_ops bnxt_re_cntx_ops = {
 	.destroy_ah    = bnxt_re_destroy_ah
 };
 
+/* Context Init functions */
 static int bnxt_re_init_context(struct verbs_device *vdev,
 				struct ibv_context *ibvctx, int cmd_fd)
 {
providers/bnxtre/main.h +180 -4

219 lines not on this page · raw message

providers/bnxtre/memory.c +4 -0
index c96641e..109c98d 100644
@@ -37,6 +37,7 @@
  *              buffers.
  */
 
+#include <string.h>
 #include <sys/mman.h>
 
 #include "main.h"
@@ -54,6 +55,9 @@ int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size)
 		return errno;
 	}
 
+	/* Touch pages before proceeding. */
+	memset(que->va, 0, que->bytes);
+
 	ret = ibv_dontfork_range(que->va, que->bytes);
 	if (ret) {
 		munmap(que->va, que->bytes);
providers/bnxtre/memory.h +31 -0
index 6c4ebaa..44648ab 100644
@@ -73,4 +73,35 @@ static inline unsigned long roundup_pow_of_two(unsigned long val)
 int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size);
 void bnxt_re_free_aligned(struct bnxt_re_queue *que);
 
+static inline void iowrite64(__u64 *dst, uint64_t *src)
+{
+	*(volatile __u64 *)dst = *src;
+}
+
+static inline void iowrite32(__u32 *dst, uint32_t *src)
+{
+	*(volatile __u32 *)dst = *src;
+}
+
+/* Basic queue operation */
+static inline uint32_t bnxt_re_is_que_full(struct bnxt_re_queue *que)
+{
+	return (((que->tail + 1) & (que->depth - 1)) == que->head);
+}
+
+static inline uint32_t bnxt_re_incr(uint32_t val, uint32_t max)
+{
+	return (++val & (max - 1));
+}
+
+static inline void bnxt_re_incr_tail(struct bnxt_re_queue *que)
+{
+	que->tail = bnxt_re_incr(que->tail, que->depth);
+}
+
+static inline void bnxt_re_incr_head(struct bnxt_re_queue *que)
+{
+	que->head = bnxt_re_incr(que->head, que->depth);
+}
+
 #endif
providers/bnxtre/verbs.c +627 -36

756 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-5-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#13 lore raw

Re: [PATCH rdma-core 04/11] libbnxtre: Add support for posting and polling

providers/bnxtre/abi.h line 45

Quoted 2 lines · Devesh Sharma
providers/bnxtre/abi.h +2 -0
+#define true           1
+#define false          0

Nope, delete.

providers/bnxtre/db.c line 51

Quoted 12 lines
providers/bnxtre/db.c new file +12 -0
+
+static void bnxt_re_ring_db(struct bnxt_re_dpi *dpi,
+			    struct bnxt_re_db_hdr *hdr)
+{
+	uint64_t *dbval = (uint64_t *)&hdr->indx;
+
+	/*TODO: cpu_to_le64 */
+	pthread_spin_lock(&dpi->db_lock);
+	iowrite64(dpi->dbpage, dbval);
+	/* write barrier */
+	wmb();
+	pthread_spin_unlock(&dpi->db_lock);

That wmb sure looks like it is in the wrong place. Better check them all..

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170129234338.GG24051-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#15 lore raw

Re: [PATCH rdma-core 04/11] libbnxtre: Add support for posting and polling

Quoted 6 lines · Jason Gunthorpe

providers/bnxtre/abi.h line 45

Quoted 2 lines · Devesh Sharma
providers/bnxtre/abi.h +2 -0
+#define true           1
+#define false          0

Nope, delete.

Yeah, It made me puzzled for a long time. Why on the earth do they need to reinvent standard declaration available in C99?

#16 lore raw

Re: [PATCH rdma-core 04/11] libbnxtre: Add support for posting and polling

In reply to a message not in the archive
Quoted 25 lines · Devesh Sharma

This patch adds code to support ibv_post_recv(), ibv_post_send(), ibv_poll_cq() and ibv_arm_cq() routines. With this patch applications are able to enqueue RQE or WQE ring doorbells and poll for completions from CQ. Currently, this code do not support SRQ, UD service and and flush completions. Following are the major changes:

- Added most of the enums to handle device specific opcodes, masks, shifts and data structures.
- Added a new file to define DB related routines.
- Added routines to handle circular queue operations.
- Added enums and few utility functions.
- Added bnxt_re_post_recv().
- Add code to build and post SQEs for RDMA-WRITE, RDMA-READ, SEND through bnxt_re_post_send() routine.
- Fixed couple of bugs in create-qp and modify-qp.
- bnxt_re_create_qp() now check the limits.
- Add polling support for RC send completions.
- Add polling support for RC Recv completions.
- Add support to ARM completion queue.
- Cleanup CQ while QP is being destroyed.
- Add utility functions to convert chip specific completion codes to IB stack specific codes.

Quoted 7 lines
---
 providers/bnxtre/CMakeLists.txt |   1 +
 providers/bnxtre/abi.h          | 189 +++++++++++-

Please use standard name for this file., there is long standing goal to reuse kernel headers for this file.

It should be providername-abi.h (the same as in the kernel).

Quoted 8 lines
 providers/bnxtre/db.c           |  92 ++++++
 providers/bnxtre/main.c         |   1 +
 providers/bnxtre/main.h         | 184 ++++++++++-
 providers/bnxtre/memory.c       |   4 +
 providers/bnxtre/memory.h       |  31 ++
 providers/bnxtre/verbs.c        | 663 +++++++++++++++++++++++++++++++++++++---
 8 files changed, 1124 insertions(+), 41 deletions(-)
 create mode 100644 providers/bnxtre/db.c

<snip>

providers/bnxtre/verbs.c int bnxt_re_destroy_qp(struct ibv_qp *ibvqp) · line 872

Quoted 7 lines
providers/bnxtre/verbs.c +7 -0
+	qesize += (bnxt_re_get_sqe_hdr_sz() >> 4);
+	hdr->rsv_ws_fl_wt |= (qesize & BNXT_RE_HDR_WS_MASK) <<
+			      BNXT_RE_HDR_WS_SHIFT;
+#if 0
+	if (qp_typ == IBV_QPT_UD) {
+	}
+#endif

Please don't add dead code.

Quoted 5 lines
providers/bnxtre/verbs.c +5 -0
+	return len;
+}
+
+static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe,
+				  struct ibv_send_wr *wr, uint8_t is_inline)

providers/bnxtre/verbs.c int bnxt_re_destroy_qp(struct ibv_qp *ibvqp) · line 887

Quoted 10 lines
providers/bnxtre/verbs.c +10 -0
+{
+	struct bnxt_re_rdma *sqe = ((void *)wqe + sizeof(struct bnxt_re_bsqe));
+	uint32_t len;
+
+	len = bnxt_re_build_send_sqe(qp, wqe, wr, is_inline);
+	sqe->rva_lo = wr->wr.rdma.remote_addr & 0xFFFFFFFFUL;
+	sqe->rva_hi = (wr->wr.rdma.remote_addr >> 32);
+	sqe->rkey = wr->wr.rdma.rkey;
+
+	return len;

Return type mismatch.

Quoted 2 lines
(quoted diff) +2 -0
+}
+
#17 lore raw

PATCH 5/11 libbnxtre: Allow apps to poll for flushed completions

In reply to a message not in the archive

This patch adds support for reporting flush completions. following is the overview of the algorithm used.

Step-1: Poll a completion from h/w CQ.
Step-2: check the status, if it is error goto step3 else report
completion to user based on the con_idx reported.
Step-3: Report the completion with actual error to consumer, and
without bothering about the con_idx reported in the completion do following:
3a. Add this QP to the CQ flush list if it was not there
already. If this is req-error, add the QP to send-flush list, else add it to recv-flush-list.
3b. Change QP-soft-state to ERROR if it was not in error
already.

Step-4: If next CQE is TERM CQE, extract this CQE. make sure this CQE
is not reported to the consumer. Do the following steps as further processing:
4a. Add this QP to both send-flush-list and recv-flush-list
if QP is absent from any of the flush lists.
4b. Change QP-soft-state to ERROR if it was not in error
already.
Step5: Continue polling from both h/w CQ and flush-lists until
all the queues are empty.

The QP is removed from the flush list during destroy-qp.

Further, it adds network to host format conversion on the received immediate data.

This patch also takes care of Hardware specific requirement to skip reporting h/w flush error CQEs to consumer but ring the CQ-DB for them.

---
 providers/bnxtre/list.h   | 135 ++++++++++++++++++++++++++
 providers/bnxtre/main.c   |   5 +
 providers/bnxtre/main.h   |   6 ++
 providers/bnxtre/memory.h |   5 +
 providers/bnxtre/verbs.c  | 242 +++++++++++++++++++++++++++++++++++++++++-----
 5 files changed, 369 insertions(+), 24 deletions(-)
 create mode 100644 providers/bnxtre/list.h
providers/bnxtre/list.h new file +135 -0
new file mode 100644
index 0000000..b4cb7e7
@@ -0,0 +1,135 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: Basic link list operations and data structures
+ */
+
+#ifndef __BNXT_RE_LIST_H__
+#define __BNXT_RE_LIST_H__
+
+struct bnxt_re_list_node {
+	uint8_t valid;
+	struct bnxt_re_list_node *next, *prev;
+};
+
+struct bnxt_re_list_head {
+	struct bnxt_re_list_node node;
+	pthread_mutex_t lock;
+};
+
+#define DBLY_LIST_HEAD_INIT(name) {{true, &name.node, &name.node},\
+				    PTHREAD_MUTEX_INITIALIZER}
+
+#define DBLY_LIST_HEAD(name) \
+	struct bnxt_re_list_head name = DBLY_LIST_HEAD_INIT(name) \
+
+#define INIT_DBLY_LIST_NODE(ptr) do {	\
+	(ptr)->next = (ptr); (ptr)->prev = (ptr); (ptr)->valid = false;	\
+} while (0)
+
+#define INIT_DBLY_LIST_HEAD(ptr) INIT_DBLY_LIST_NODE(ptr.node)
+
+static inline void __list_add_node(struct bnxt_re_list_node *new,
+				   struct bnxt_re_list_node *prev,
+				   struct bnxt_re_list_node *next)
+{
+	next->prev = new;
+	new->next = next;
+	new->prev = prev;
+	prev->next = new;
+}
+
+static inline void list_add_node_tail(struct bnxt_re_list_node *new,
+				      struct bnxt_re_list_head *head)
+{
+	__list_add_node(new, head->node.prev, &head->node);
+	new->valid = true;
+}
+
+static inline void __list_del_node(struct bnxt_re_list_node *prev,
+				   struct bnxt_re_list_node *next)
+{
+	next->prev = prev;
+	prev->next = next;
+}
+
+static inline void list_del_node(struct bnxt_re_list_node *entry)
+{
+	__list_del_node(entry->prev, entry->next);
+	entry->next = 0;
+	entry->prev = 0;
+	entry->valid = false;
+}
+
+static inline uint8_t list_empty(struct bnxt_re_list_head *head)
+{
+	struct bnxt_re_list_node *node = &head->node;
+	return (head->node.next == node) && (head->node.prev == node);
+}
+
+#define list_lock(head) pthread_mutex_lock(&((head)->lock))
+#define list_unlock(head) pthread_mutex_unlock(&((head)->lock))
+
+#define list_node(ptr, type, member)	\
+	((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))
+
+#define list_node_valid(node)	((node)->valid)
+
+/*
+ * list_for_each_node_safe - iterate over a list safe against removal of list
+ * entry
+ * @pos:	the &struct bnxt_re_list_head to use as a loop counter.
+ * @n:		another &struct bnxt_re_list_head to use as temporary storage
+ * @head:	the head for your list.
+ */
+#define list_for_each_node_safe(pos, n, head) \
+	for (pos = (head)->node.next, n = pos->next; pos != &((head)->node); \
+		pos = n, n = pos->next)
+
+static inline void bnxt_re_list_add_node(struct bnxt_re_list_node *node,
+					 struct bnxt_re_list_head *head)
+{
+	if (!list_node_valid(node))
+		list_add_node_tail(node, head);
+}
+
+static inline void bnxt_re_list_del_node(struct bnxt_re_list_node *node,
+					 struct bnxt_re_list_head *head)
+{
+	if (list_node_valid(node))
+		list_del_node(node);
+}
+
+#endif	/* __bnxt_re_LIST_H__ */
providers/bnxtre/main.c +5 -0
index 962f460..effb3b6 100644
@@ -133,6 +133,7 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 	dev->pg_size = resp.pg_size;
 	dev->cqe_size = resp.cqe_size;
 	dev->max_cq_depth = resp.max_cqd;
+	pthread_spin_init(&cntx->fqlock, PTHREAD_PROCESS_PRIVATE);
 	ibvctx->ops = bnxt_re_cntx_ops;
 
 	return 0;
@@ -141,7 +142,11 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 static void bnxt_re_uninit_context(struct verbs_device *vdev,
 				   struct ibv_context *ibvctx)
 {
+	struct bnxt_re_context *cntx;
+
+	cntx = to_bnxt_re_context(ibvctx);
 	/* Unmap if anything device specific was mapped in init_context. */
+	pthread_spin_destroy(&cntx->fqlock);
 }
 
 static struct verbs_device *bnxt_re_driver_init(const char *uverbs_sys_path,
providers/bnxtre/main.h +6 -0
index e39be26..5526bc6 100644
@@ -49,6 +49,7 @@
 
 #include "abi.h"
 #include "memory.h"
+#include "list.h"
 
 #define DEV	"bnxtre : "
 
@@ -68,6 +69,8 @@ struct bnxt_re_cq {
 	uint32_t cqid;
 	struct bnxt_re_queue cqq;
 	struct bnxt_re_dpi *udpi;
+	struct bnxt_re_list_head sfhead;
+	struct bnxt_re_list_head rfhead;
 	uint32_t cqe_size;
 	uint8_t  phase;
 };
@@ -103,6 +106,8 @@ struct bnxt_re_qp {
 	struct bnxt_re_cq *rcq;
 	struct bnxt_re_dpi *udpi;
 	struct bnxt_re_qpcap cap;
+	struct bnxt_re_list_node snode;
+	struct bnxt_re_list_node rnode;
 	uint32_t qpid;
 	uint32_t tbl_indx;
 	uint32_t sq_psn;
@@ -132,6 +137,7 @@ struct bnxt_re_context {
 	uint32_t max_qp;
 	uint32_t max_srq;
 	struct bnxt_re_dpi udpi;
+	pthread_spinlock_t fqlock;
 };
 
 /* DB ring functions used internally*/
providers/bnxtre/memory.h +5 -0
index 44648ab..a7a7d90 100644
@@ -89,6 +89,11 @@ static inline uint32_t bnxt_re_is_que_full(struct bnxt_re_queue *que)
 	return (((que->tail + 1) & (que->depth - 1)) == que->head);
 }
 
+static inline uint32_t bnxt_re_is_que_empty(struct bnxt_re_queue *que)
+{
+	return que->tail == que->head;
+}
+
 static inline uint32_t bnxt_re_incr(uint32_t val, uint32_t max)
 {
 	return (++val & (max - 1));
providers/bnxtre/verbs.c +218 -24

315 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-6-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#19 lore raw

Re: [PATCH rdma-core 05/11] libbnxtre: Allow apps to poll for flushed completions

Quoted 24 lines · Devesh Sharma
providers/bnxtre/list.h new file +24 -0
+#ifndef __BNXT_RE_LIST_H__
+#define __BNXT_RE_LIST_H__
+
+struct bnxt_re_list_node {
+	uint8_t valid;
+	struct bnxt_re_list_node *next, *prev;
+};
+
+struct bnxt_re_list_head {
+	struct bnxt_re_list_node node;
+	pthread_mutex_t lock;
+};
+
+#define DBLY_LIST_HEAD_INIT(name) {{true, &name.node, &name.node},\
+				    PTHREAD_MUTEX_INITIALIZER}
+
+#define DBLY_LIST_HEAD(name) \
+	struct bnxt_re_list_head name = DBLY_LIST_HEAD_INIT(name) \
+
+#define INIT_DBLY_LIST_NODE(ptr) do {	\
+	(ptr)->next = (ptr); (ptr)->prev = (ptr); (ptr)->valid = false;	\
+} while (0)
+
+#define INIT_DBLY_LIST_HEAD(ptr) INIT_DBLY_LIST_NODE(ptr.node)

providers/bnxtre/list.h line 72

Quoted 10 lines
providers/bnxtre/list.h new file +10 -0
+
+static inline void __list_add_node(struct bnxt_re_list_node *new,
+				   struct bnxt_re_list_node *prev,
+				   struct bnxt_re_list_node *next)
+{
+	next->prev = new;
+	new->next = next;
+	new->prev = prev;
+	prev->next = new;
+}

Nope on this entire file, use ccan/list.h

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#20 lore raw

PATCH 6/11 libbnxtre: convert cpu to le all over the place

In reply to a message not in the archive

User library should take care of endian-ness when reading or writing data to the device.
This patch also adds a warning message and fails the call if access to any unsupported object is attempted.

---
 providers/bnxtre/db.c     |  2 +-
 providers/bnxtre/memory.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.c  | 24 ++++++++++++++++--------
 3 files changed, 62 insertions(+), 9 deletions(-)
providers/bnxtre/db.c +1 -1
index b705c8b..fc22e0d 100644
@@ -43,8 +43,8 @@ static void bnxt_re_ring_db(struct bnxt_re_dpi *dpi,
 {
 	uint64_t *dbval = (uint64_t *)&hdr->indx;
 
-	/*TODO: cpu_to_le64 */
 	pthread_spin_lock(&dpi->db_lock);
+	*dbval = htole64(*dbval);
 	iowrite64(dpi->dbpage, dbval);
 	/* write barrier */
 	wmb();
providers/bnxtre/memory.h +45 -0

49 lines not on this page · raw message

providers/bnxtre/verbs.c +16 -8
index c2340af..adb9b23 100644
@@ -262,8 +262,9 @@ static uint8_t bnxt_re_poll_err_scqe(struct bnxt_re_qp *qp,
 	ibvwc->wc_flags = 0;
 	ibvwc->wr_id = swrid->wrid;
 	ibvwc->qp_num = qp->qpid;
-	ibvwc->opcode = (spsn->opc_spsn >> BNXT_RE_PSNS_OPCD_SHIFT) &
-			 BNXT_RE_PSNS_OPCD_MASK;
+	ibvwc->opcode = (le32toh(spsn->opc_spsn) >>
+			BNXT_RE_PSNS_OPCD_SHIFT) &
+			BNXT_RE_PSNS_OPCD_MASK;
 	ibvwc->byte_len = 0;
 
 	bnxt_re_incr_head(qp->sqq);
@@ -301,8 +302,9 @@ static uint8_t bnxt_re_poll_success_scqe(struct bnxt_re_qp *qp,
 		ibvwc->wc_flags = 0;
 		ibvwc->qp_num = qp->qpid;
 		ibvwc->wr_id = swrid->wrid;
-		ibvwc->opcode = (spsn->opc_spsn >> BNXT_RE_PSNS_OPCD_SHIFT) &
-				 BNXT_RE_PSNS_OPCD_MASK;
+		ibvwc->opcode = (le32toh(spsn->opc_spsn) >>
+				BNXT_RE_PSNS_OPCD_SHIFT) &
+				BNXT_RE_PSNS_OPCD_MASK;
 		if (ibvwc->opcode == IBV_WC_RDMA_READ ||
 		    ibvwc->opcode == IBV_WC_COMP_SWAP ||
 		    ibvwc->opcode == IBV_WC_FETCH_ADD)
@@ -473,8 +475,8 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc)
 
 	while (nwc) {
 		cqe = cqq->va + cqq->head * bnxt_re_get_cqe_sz();
+		bnxt_re_le64_to_host((uint64_t *)cqe, cqq->stride);
 		hdr = cqe + sizeof(struct bnxt_re_req_cqe);
-		/* TODO: LE to CPU cqe & hdr */
 		if (!bnxt_re_is_cqe_valid(cq, hdr))
 			break;
 		type = (hdr->flg_st_typ_ph >> BNXT_RE_BCQE_TYPE_SHIFT) &
@@ -708,6 +710,9 @@ static int bnxt_re_check_qp_limits(struct bnxt_re_context *cntx,
 	struct ibv_device_attr devattr;
 	int ret;
 
+	if (attr->qp_type == IBV_QPT_UD)
+		return -ENOSYS;
+
 	ret = bnxt_re_query_device(&cntx->ibvctx, &devattr);
 	if (ret)
 		return ret;
@@ -1019,7 +1024,8 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns,
 	nxt_psn = ((qp->sq_psn + pkt_cnt) & BNXT_RE_PSNS_NPSN_MASK);
 	psns->flg_npsn = nxt_psn;
 	qp->sq_psn = nxt_psn;
-	/* TODO: cpu_to_le64(psns) */
+
+	*(uint64_t *)psns = htole64(*(uint64_t *)psns);
 }
 
 static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr,
@@ -1154,9 +1160,9 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
 			break;
 		}
 
-		/* TODO: cpu_to_le64(wqe) */
 		bnxt_re_fill_wrid(wrid, wr, bytes, qp->cap.sqsig);
 		bnxt_re_fill_psns(qp, psns, wr->opcode, bytes);
+		bnxt_re_host_to_le64((uint64_t *)sqe, sq->stride);
 		bnxt_re_incr_tail(sq);
 		wr = wr->next;
 		wmb(); /* write barrier */
@@ -1188,6 +1194,7 @@ static int bnxt_re_build_rqe(struct bnxt_re_qp *qp, struct ibv_recv_wr *wr,
 			       BNXT_RE_HDR_WS_SHIFT);
 	rwr->wrid = qp->rqq->tail;
 
+	/* Fill wrid */
 	wrid->wrid = wr->wr_id;
 	wrid->bytes = len; /* N.A. for RQE */
 	wrid->sig = 0; /* N.A. for RQE */
@@ -1227,7 +1234,8 @@ int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
 			*bad = wr;
 			return ENOMEM;
 		}
-		/* TODO: cpu_to_le64(rqe)*/
+
+		bnxt_re_host_to_le64((uint64_t *)rqe, rq->stride);
 		bnxt_re_incr_tail(rq);
 		wr = wr->next;
 
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-7-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#22 lore raw

Re: [PATCH rdma-core 06/11] libbnxtre: convert cpu to le all over the place

Quoted 9 lines · Devesh Sharma

User library should take care of endian-ness when reading or writing data to the device.
This patch also adds a warning message and fails the call if access to any unsupported object is attempted.

Quoted 5 lines
---
 providers/bnxtre/db.c     |  2 +-
 providers/bnxtre/memory.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.c  | 24 ++++++++++++++++--------
 3 files changed, 62 insertions(+), 9 deletions(-)

I have two questions regarding this patch.
1. Why don't you introduce the proper ordering immediately and don't defer such conversion to patch #6?
2. Why does bnxt_re_le64_to_host return values while you are not checking it anywhere?

Thanks

Quoted 163 lines
providers/bnxtre/db.c +1 -1
index b705c8b..fc22e0d 100644
@@ -43,8 +43,8 @@ static void bnxt_re_ring_db(struct bnxt_re_dpi *dpi,
 {
 	uint64_t *dbval = (uint64_t *)&hdr->indx;
 
-	/*TODO: cpu_to_le64 */
 	pthread_spin_lock(&dpi->db_lock);
+	*dbval = htole64(*dbval);
 	iowrite64(dpi->dbpage, dbval);
 	/* write barrier */
 	wmb();
providers/bnxtre/memory.h +45 -0
index a7a7d90..4360914 100644
@@ -109,4 +109,49 @@ static inline void bnxt_re_incr_head(struct bnxt_re_queue *que)
 	que->head = bnxt_re_incr(que->head, que->depth);
 }
 
+/* Memory byte order conversion functions. */
+#if __BYTE_ORDER == __BIG_ENDIAN
+static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
+{
+	int qwords, indx;
+
+	if (!bytes || bytes < 8)
+		return -EINVAL;
+
+	qwords = bytes / sizeof(uint64_t);
+	for (indx = 0; indx < qwords; indx++) {
+		if (*(src + indx))
+			*(src + indx) = htole64(*(src + indx));
+	}
+
+	return qwords;
+}
+
+static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
+{
+	int qwords, indx;
+
+	if (!bytes || bytes < 8)
+		return -EINVAL;
+
+	qwords = bytes / sizeof(uint64_t);
+	for (indx = 0; indx < qwords; indx++) {
+		if (*(src + indx))
+			*(src + indx) = le64toh(*(src + indx));
+	}
+
+	return qwords;
+}
+#else
+static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
+{
+	return 0;
+}
+
+static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
+{
+	return 0;
+}
+#endif
+
 #endif
providers/bnxtre/verbs.c +16 -9
index c2340af..adb9b23 100644
@@ -262,8 +262,9 @@ static uint8_t bnxt_re_poll_err_scqe(struct bnxt_re_qp *qp,
 	ibvwc->wc_flags = 0;
 	ibvwc->wr_id = swrid->wrid;
 	ibvwc->qp_num = qp->qpid;
-	ibvwc->opcode = (spsn->opc_spsn >> BNXT_RE_PSNS_OPCD_SHIFT) &
-			 BNXT_RE_PSNS_OPCD_MASK;
+	ibvwc->opcode = (le32toh(spsn->opc_spsn) >>
+			BNXT_RE_PSNS_OPCD_SHIFT) &
+			BNXT_RE_PSNS_OPCD_MASK;
 	ibvwc->byte_len = 0;
 
 	bnxt_re_incr_head(qp->sqq);
@@ -301,8 +302,9 @@ static uint8_t bnxt_re_poll_success_scqe(struct bnxt_re_qp *qp,
 		ibvwc->wc_flags = 0;
 		ibvwc->qp_num = qp->qpid;
 		ibvwc->wr_id = swrid->wrid;
-		ibvwc->opcode = (spsn->opc_spsn >> BNXT_RE_PSNS_OPCD_SHIFT) &
-				 BNXT_RE_PSNS_OPCD_MASK;
+		ibvwc->opcode = (le32toh(spsn->opc_spsn) >>
+				BNXT_RE_PSNS_OPCD_SHIFT) &
+				BNXT_RE_PSNS_OPCD_MASK;
 		if (ibvwc->opcode == IBV_WC_RDMA_READ ||
 		    ibvwc->opcode == IBV_WC_COMP_SWAP ||
 		    ibvwc->opcode == IBV_WC_FETCH_ADD)
@@ -473,8 +475,8 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc)
 
 	while (nwc) {
 		cqe = cqq->va + cqq->head * bnxt_re_get_cqe_sz();
+		bnxt_re_le64_to_host((uint64_t *)cqe, cqq->stride);
 		hdr = cqe + sizeof(struct bnxt_re_req_cqe);
-		/* TODO: LE to CPU cqe & hdr */
 		if (!bnxt_re_is_cqe_valid(cq, hdr))
 			break;
 		type = (hdr->flg_st_typ_ph >> BNXT_RE_BCQE_TYPE_SHIFT) &
@@ -708,6 +710,9 @@ static int bnxt_re_check_qp_limits(struct bnxt_re_context *cntx,
 	struct ibv_device_attr devattr;
 	int ret;
 
+	if (attr->qp_type == IBV_QPT_UD)
+		return -ENOSYS;
+
 	ret = bnxt_re_query_device(&cntx->ibvctx, &devattr);
 	if (ret)
 		return ret;
@@ -1019,7 +1024,8 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns,
 	nxt_psn = ((qp->sq_psn + pkt_cnt) & BNXT_RE_PSNS_NPSN_MASK);
 	psns->flg_npsn = nxt_psn;
 	qp->sq_psn = nxt_psn;
-	/* TODO: cpu_to_le64(psns) */
+
+	*(uint64_t *)psns = htole64(*(uint64_t *)psns);
 }
 
 static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr,
@@ -1154,9 +1160,9 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
 			break;
 		}
 
-		/* TODO: cpu_to_le64(wqe) */
 		bnxt_re_fill_wrid(wrid, wr, bytes, qp->cap.sqsig);
 		bnxt_re_fill_psns(qp, psns, wr->opcode, bytes);
+		bnxt_re_host_to_le64((uint64_t *)sqe, sq->stride);
 		bnxt_re_incr_tail(sq);
 		wr = wr->next;
 		wmb(); /* write barrier */
@@ -1188,6 +1194,7 @@ static int bnxt_re_build_rqe(struct bnxt_re_qp *qp, struct ibv_recv_wr *wr,
 			       BNXT_RE_HDR_WS_SHIFT);
 	rwr->wrid = qp->rqq->tail;
 
+	/* Fill wrid */
 	wrid->wrid = wr->wr_id;
 	wrid->bytes = len; /* N.A. for RQE */
 	wrid->sig = 0; /* N.A. for RQE */
@@ -1227,7 +1234,8 @@ int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,
 			*bad = wr;
 			return ENOMEM;
 		}
-		/* TODO: cpu_to_le64(rqe)*/
+
+		bnxt_re_host_to_le64((uint64_t *)rqe, rq->stride);
 		bnxt_re_incr_tail(rq);
 		wr = wr->next;
 
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw

Re: [PATCH rdma-core 06/11] libbnxtre: convert cpu to le all over the place

In reply to a message not in the archive

providers/bnxtre/memory.h static inline void bnxt_re_incr_head(struct bnxt_re_queue *que) · line 113

Quoted 2 lines · Devesh Sharma
providers/bnxtre/memory.h +2 -0
+/* Memory byte order conversion functions. */
+#if __BYTE_ORDER == __BIG_ENDIAN

No reason for this ifdef

Quoted 31 lines
providers/bnxtre/memory.h +31 -0
+static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
+{
+	int qwords, indx;
+
+	if (!bytes || bytes < 8)
+		return -EINVAL;
+
+	qwords = bytes / sizeof(uint64_t);
+	for (indx = 0; indx < qwords; indx++) {
+		if (*(src + indx))
+			*(src + indx) = htole64(*(src + indx));
+	}
+
+	return qwords;
+}
+
+static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
+{
+	int qwords, indx;
+
+	if (!bytes || bytes < 8)
+		return -EINVAL;
+
+	qwords = bytes / sizeof(uint64_t);
+	for (indx = 0; indx < qwords; indx++) {
+		if (*(src + indx))
+			*(src + indx) = le64toh(*(src + indx));
+	}
+
+	return qwords;
+}

providers/bnxtre/memory.h static inline void bnxt_re_incr_head(struct bnxt_re_queue *que) · line 154

Quoted 10 lines
providers/bnxtre/memory.h +10 -0
+#else
+static inline int bnxt_re_host_to_le64(uint64_t *src, int bytes)
+{
+	return 0;
+}
+
+static inline int bnxt_re_le64_to_host(uint64_t *src, int bytes)
+{
+	return 0;
+}

And your alts look broken anyhow. Just use the first version, gcc will optimize it properly..

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#24 lore raw

PATCH 7/11 libbnxtre: Enable UD control path and wqe posting

In reply to a message not in the archive

This patch adds infrastructure needed to enable unreliable datagram control path. It also adds support to allow posting Send WQEs to UD QPs. Following are the major changes:

- Mmap the shared page exported from kernel driver to read AH-ID from kernel space.
- Adds support to create-AH and destroy-AH.
- Add support to allow posting UD WQEs.
- Do not use search-psn memory for UD QPs.

---
 providers/bnxtre/abi.h   |  7 ++++
 providers/bnxtre/main.c  | 17 +++++++++
 providers/bnxtre/main.h  | 13 +++++++
 providers/bnxtre/verbs.c | 98 +++++++++++++++++++++++++++++++++++++++---------
 4 files changed, 117 insertions(+), 18 deletions(-)
providers/bnxtre/abi.h +7 -0
index f660d13..d77bb38 100644
@@ -176,6 +176,13 @@ enum bnxt_re_ud_flags_mask {
 	BNXT_RE_UD_FLAGS_ROCE_IPV6	= 0x03
 };
 
+enum bnxt_re_shpg_offt {
+	BNXT_RE_SHPG_BEG_RESV_OFFT	= 0x00,
+	BNXT_RE_SHPG_AVID_OFFT		= 0x10,
+	BNXT_RE_SHPG_AVID_SIZE		= 0x04,
+	BNXT_RE_SHPG_END_RESV_OFFT	= 0xFF0
+};
+
 struct bnxt_re_db_hdr {
 	__u32 indx;
 	__u32 typ_qid; /* typ: 4, qid:20*/
providers/bnxtre/main.c +17 -0
index effb3b6..c362e72 100644
@@ -134,18 +134,35 @@ static int bnxt_re_init_context(struct verbs_device *vdev,
 	dev->cqe_size = resp.cqe_size;
 	dev->max_cq_depth = resp.max_cqd;
 	pthread_spin_init(&cntx->fqlock, PTHREAD_PROCESS_PRIVATE);
+	/* mmap shared page. */
+	cntx->shpg = mmap(NULL, dev->pg_size, PROT_READ | PROT_WRITE,
+			  MAP_SHARED, cmd_fd, 0);
+	if (cntx->shpg == MAP_FAILED) {
+		cntx->shpg = NULL;
+		goto failed;
+	}
+	pthread_mutex_init(&cntx->shlock, NULL);
+
 	ibvctx->ops = bnxt_re_cntx_ops;
 
 	return 0;
+failed:
+	fprintf(stderr, DEV "Failed to allocate context for device\n");
+	return errno;
 }
 
 static void bnxt_re_uninit_context(struct verbs_device *vdev,
 				   struct ibv_context *ibvctx)
 {
+	struct bnxt_re_dev *dev;
 	struct bnxt_re_context *cntx;
 
+	dev = to_bnxt_re_dev(&vdev->device);
 	cntx = to_bnxt_re_context(ibvctx);
 	/* Unmap if anything device specific was mapped in init_context. */
+	pthread_mutex_destroy(&cntx->shlock);
+	if (cntx->shpg)
+		munmap(cntx->shpg, dev->pg_size);
 	pthread_spin_destroy(&cntx->fqlock);
 }
 
providers/bnxtre/main.h +13 -0
index 5526bc6..c3689a5 100644
@@ -122,6 +122,12 @@ struct bnxt_re_mr {
 	struct ibv_mr ibvmr;
 };
 
+struct bnxt_re_ah {
+	struct ibv_ah ibvah;
+	struct bnxt_re_pd *pd;
+	uint32_t avid;
+};
+
 struct bnxt_re_dev {
 	struct verbs_device vdev;
 	uint8_t abi_version;
@@ -137,6 +143,8 @@ struct bnxt_re_context {
 	uint32_t max_qp;
 	uint32_t max_srq;
 	struct bnxt_re_dpi udpi;
+	void *shpg;
+	pthread_mutex_t shlock;
 	pthread_spinlock_t fqlock;
 };
 
@@ -174,6 +182,11 @@ static inline struct bnxt_re_qp *to_bnxt_re_qp(struct ibv_qp *ibvqp)
 	return container_of(ibvqp, struct bnxt_re_qp, ibvqp);
 }
 
+static inline struct bnxt_re_ah *to_bnxt_re_ah(struct ibv_ah *ibvah)
+{
+	return container_of(ibvah, struct bnxt_re_ah, ibvah);
+}
+
 static inline uint8_t bnxt_re_ibv_to_bnxt_wr_opcd(uint8_t ibv_opcd)
 {
 	uint8_t bnxt_opcd;
providers/bnxtre/verbs.c +80 -18

142 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#25 lore raw

PATCH 8/11 libbnxtre: Enable polling for UD completions

In reply to a message not in the archive

This patch adds support to allow polling of send
and recv completions for a UD qp.

---
 providers/bnxtre/abi.h   |  6 ++++++
 providers/bnxtre/verbs.c | 43 +++++++++++++++++++++++++++++--------------
 2 files changed, 35 insertions(+), 14 deletions(-)
providers/bnxtre/abi.h +6 -0
index d77bb38..447058e 100644
@@ -176,6 +176,12 @@ enum bnxt_re_ud_flags_mask {
 	BNXT_RE_UD_FLAGS_ROCE_IPV6	= 0x03
 };
 
+enum bnxt_re_ud_cqe_mask {
+	BNXT_RE_UD_CQE_MAC_MASK		= 0xFFFFFFFFFFFFULL,
+	BNXT_RE_UD_CQE_SRCQPLO_MASK	= 0xFFFF,
+	BNXT_RE_UD_CQE_SRCQPLO_SHIFT	= 0x30
+};
+
 enum bnxt_re_shpg_offt {
 	BNXT_RE_SHPG_BEG_RESV_OFFT	= 0x00,
 	BNXT_RE_SHPG_AVID_OFFT		= 0x10,
providers/bnxtre/verbs.c +29 -14

102 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw

PATCH 9/11 libbnxtre: Add support for atomic operations

In reply to a message not in the archive

This patch adds support for compare-and-swap and fetch-and-add atomic operations in user library.

---
 providers/bnxtre/abi.h    |  3 ++-
 providers/bnxtre/main.h   |  8 ++++++-
 providers/bnxtre/memory.h |  3 +++
 providers/bnxtre/verbs.c  | 57 ++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 61 insertions(+), 10 deletions(-)
providers/bnxtre/abi.h +2 -1
index 447058e..451af08 100644
@@ -56,7 +56,8 @@ enum bnxt_re_wr_opcode {
 	BNXT_RE_WR_OPCD_ATOMIC_FA	= 0x0B,
 	BNXT_RE_WR_OPCD_LOC_INVAL	= 0x0C,
 	BNXT_RE_WR_OPCD_BIND		= 0x0E,
-	BNXT_RE_WR_OPCD_RECV		= 0x80
+	BNXT_RE_WR_OPCD_RECV		= 0x80,
+	BNXT_RE_WR_OPCD_INVAL		= 0xFF
 };
 
 enum bnxt_re_wr_flags {
providers/bnxtre/main.h +7 -1
index c3689a5..c9b04e1 100644
@@ -207,9 +207,15 @@ static inline uint8_t bnxt_re_ibv_to_bnxt_wr_opcd(uint8_t ibv_opcd)
 	case IBV_WR_RDMA_READ:
 		bnxt_opcd = BNXT_RE_WR_OPCD_RDMA_READ;
 		break;
+	case IBV_WR_ATOMIC_CMP_AND_SWP:
+		bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_CS;
+		break;
+	case IBV_WR_ATOMIC_FETCH_AND_ADD:
+		bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_FA;
+		break;
 		/* TODO: Add other opcodes */
 	default:
-		bnxt_opcd = 0xFF;
+		bnxt_opcd = BNXT_RE_WR_OPCD_INVAL;
 		break;
 	};
 
providers/bnxtre/memory.h +3 -0
index 4360914..4caa5dc 100644
@@ -42,6 +42,9 @@
 
 #include <pthread.h>
 
+#define upper_32_bits(n)	((__u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n)	((__u32)((n) & 0xFFFFFFFFUL))
+
 struct bnxt_re_queue {
 	void *va;
 	uint32_t bytes; /* for munmap */
providers/bnxtre/verbs.c +49 -8

88 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-10-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#28 lore raw

Re: [PATCH rdma-core 09/11] libbnxtre: Add support for atomic operations

Quoted 1 line · Devesh Sharma

+#define upper_32_bits(n) ((__u32)(((n) >> 16) >> 16))

This can be >> 16

Quoted 1 line

+#define lower_32_bits(n) ((__u32)((n) & 0xFFFFFFFFUL))

Do not define macros as functions. Use static inline instead.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#29 lore raw

Re: [PATCH rdma-core 09/11] libbnxtre: Add support for atomic operations

In reply to a message not in the archive
Quoted 89 lines · Devesh Sharma

This patch adds support for compare-and-swap and fetch-and-add atomic operations in user library.

---
 providers/bnxtre/abi.h    |  3 ++-
 providers/bnxtre/main.h   |  8 ++++++-
 providers/bnxtre/memory.h |  3 +++
 providers/bnxtre/verbs.c  | 57 ++++++++++++++++++++++++++++++++++++++++-------
 4 files changed, 61 insertions(+), 10 deletions(-)
providers/bnxtre/abi.h +2 -1
index 447058e..451af08 100644
@@ -56,7 +56,8 @@ enum bnxt_re_wr_opcode {
 	BNXT_RE_WR_OPCD_ATOMIC_FA	= 0x0B,
 	BNXT_RE_WR_OPCD_LOC_INVAL	= 0x0C,
 	BNXT_RE_WR_OPCD_BIND		= 0x0E,
-	BNXT_RE_WR_OPCD_RECV		= 0x80
+	BNXT_RE_WR_OPCD_RECV		= 0x80,
+	BNXT_RE_WR_OPCD_INVAL		= 0xFF
 };
 
 enum bnxt_re_wr_flags {
providers/bnxtre/main.h +7 -1
index c3689a5..c9b04e1 100644
@@ -207,9 +207,15 @@ static inline uint8_t bnxt_re_ibv_to_bnxt_wr_opcd(uint8_t ibv_opcd)
 	case IBV_WR_RDMA_READ:
 		bnxt_opcd = BNXT_RE_WR_OPCD_RDMA_READ;
 		break;
+	case IBV_WR_ATOMIC_CMP_AND_SWP:
+		bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_CS;
+		break;
+	case IBV_WR_ATOMIC_FETCH_AND_ADD:
+		bnxt_opcd = BNXT_RE_WR_OPCD_ATOMIC_FA;
+		break;
 		/* TODO: Add other opcodes */
 	default:
-		bnxt_opcd = 0xFF;
+		bnxt_opcd = BNXT_RE_WR_OPCD_INVAL;
 		break;
 	};
 
providers/bnxtre/memory.h +3 -0
index 4360914..4caa5dc 100644
@@ -42,6 +42,9 @@
 
 #include <pthread.h>
 
+#define upper_32_bits(n)	((__u32)(((n) >> 16) >> 16))
+#define lower_32_bits(n)	((__u32)((n) & 0xFFFFFFFFUL))
+
 struct bnxt_re_queue {
 	void *va;
 	uint32_t bytes; /* for munmap */
providers/bnxtre/verbs.c +11 -0
index 9b92f20..0f5fcde 100644
@@ -1072,6 +1072,9 @@ static int bnxt_re_build_send_sqe(struct bnxt_re_qp *qp, void *wqe,
 
 	/* Fill Header */
 	opcode = bnxt_re_ibv_to_bnxt_wr_opcd(wr->opcode);
+	if (opcode == BNXT_RE_WR_OPCD_INVAL)
+		return -EINVAL;
+
 	hdr->rsv_ws_fl_wt |= (opcode & BNXT_RE_HDR_WT_MASK);
 
 	if (is_inline) {
@@ -1120,6 +1123,44 @@ static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe,
 	return len;
 }
 
+static int bnxt_re_build_cns_sqe(struct bnxt_re_qp *qp, void *wqe,
+				 struct ibv_send_wr *wr)
+{
+	struct bnxt_re_bsqe *hdr = wqe;
+	struct bnxt_re_atomic *sqe = ((void *)wqe +
+				      sizeof(struct bnxt_re_bsqe));
+	uint32_t len;
+

providers/bnxtre/verbs.c static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, · line 1143

Quoted 10 lines
providers/bnxtre/verbs.c +10 -0
+	len = bnxt_re_build_send_sqe(qp, wqe, wr, false);
+	hdr->key_immd = wr->wr.atomic.rkey;
+	sqe->rva_lo = lower_32_bits(wr->wr.atomic.remote_addr);
+	sqe->rva_hi = upper_32_bits(wr->wr.atomic.remote_addr);
+	sqe->cmp_dt_lo = lower_32_bits(wr->wr.atomic.compare_add);
+	sqe->cmp_dt_hi = upper_32_bits(wr->wr.atomic.compare_add);
+	sqe->swp_dt_lo = lower_32_bits(wr->wr.atomic.swap);
+	sqe->swp_dt_hi = upper_32_bits(wr->wr.atomic.swap);
+
+	return len;

It should produce warning, there is type mismatch.
The function declared to return "int", but you are returning "unsigned int".

Quoted 8 lines
providers/bnxtre/verbs.c +8 -0
+}
+
+static int bnxt_re_build_fna_sqe(struct bnxt_re_qp *qp, void *wqe,
+				 struct ibv_send_wr *wr)
+{
+	struct bnxt_re_bsqe *hdr = wqe;
+	struct bnxt_re_atomic *sqe = ((void *)wqe +
+				      sizeof(struct bnxt_re_bsqe));

providers/bnxtre/verbs.c static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, · line 1161

Quoted 10 lines
providers/bnxtre/verbs.c +10 -0
+	uint32_t len;
+
+	len = bnxt_re_build_send_sqe(qp, wqe, wr, false);
+	hdr->key_immd = wr->wr.atomic.rkey;
+	sqe->rva_lo = lower_32_bits(wr->wr.atomic.remote_addr);
+	sqe->rva_hi = upper_32_bits(wr->wr.atomic.remote_addr);
+	sqe->cmp_dt_lo = lower_32_bits(wr->wr.atomic.compare_add);
+	sqe->cmp_dt_hi = upper_32_bits(wr->wr.atomic.compare_add);
+
+	return len;

Ditto

Quoted 19 lines
providers/bnxtre/verbs.c +2 -4
+}
+
 int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
 		      struct ibv_send_wr **bad)
 {
@@ -1173,27 +1214,27 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
 			else
 				bytes = bnxt_re_build_send_sqe(qp, sqe, wr,
 							       is_inline);
-			if (bytes < 0)
-				ret = (bytes == -EINVAL) ? EINVAL : ENOMEM;
 			break;
 		case IBV_WR_RDMA_WRITE_WITH_IMM:
 			hdr->key_immd = wr->imm_data;
 		case IBV_WR_RDMA_WRITE:
 			bytes = bnxt_re_build_rdma_sqe(qp, sqe, wr, is_inline);
-			if (bytes < 0)
-				ret = ENOMEM;
 			break;

providers/bnxtre/verbs.c int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, · line 1230

Quoted 10 lines
providers/bnxtre/verbs.c +5 -2
 		case IBV_WR_RDMA_READ:
 			bytes = bnxt_re_build_rdma_sqe(qp, sqe, wr, false);
-			if (bytes < 0)
-				ret = ENOMEM;
 			break;
+		case IBV_WR_ATOMIC_CMP_AND_SWP:
+			bytes = bnxt_re_build_cns_sqe(qp, sqe, wr);
+			break;
+		case IBV_WR_ATOMIC_FETCH_AND_ADD:
+			bytes = bnxt_re_build_fna_sqe(qp, sqe, wr);

It looks like you forgot break here.

providers/bnxtre/verbs.c int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr, · line 1237

Quoted 9 lines
providers/bnxtre/verbs.c +3 -2
 		default:
-			ret = EINVAL;
+			bytes = -EINVAL;
 			break;
 		}
 
-		if (ret) {
+		if (bytes < 0) {
+			ret = (bytes == -EINVAL) ? EINVAL : ENOMEM;

"bytes" is a definitely wrong name to store both error code and byte size.

Quoted 10 lines
providers/bnxtre/verbs.c +0 -1
 			*bad = wr;
 			break;
 		}
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#30 lore raw

PATCH 10/11 libbnxtre: Add support for SRQ in user lib

In reply to a message not in the archive

This patch adds support for shared receive
queue. Following are the changes:
- Add ABI for user/kernel information exchange.
- Add function to handle SRQ ARMing and DB-ring.
- Add function to create/destroy SRQ.
- Add function to query/modify SRQ.
- Add function to post RQE on a SRQ.

---
 providers/bnxtre/abi.h   |  27 +++++
 providers/bnxtre/db.c    |  18 ++++
 providers/bnxtre/main.h  |  20 +++-
 providers/bnxtre/verbs.c | 261 +++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 288 insertions(+), 38 deletions(-)
providers/bnxtre/abi.h +27 -0
index 451af08..e6fb9e4 100644
@@ -216,6 +216,7 @@ struct bnxt_re_mr_resp {
 	struct ibv_reg_mr_resp resp;
 };
 
+/* CQ */
 struct bnxt_re_cq_req {
 	struct ibv_create_cq cmd;
 	__u64 cq_va;
@@ -263,6 +264,7 @@ struct bnxt_re_term_cqe {
 	__u64 rsvd1;
 };
 
+/* QP */
 struct bnxt_re_qp_req {
 	struct ibv_create_qp cmd;
 	__u64 qpsva;
@@ -354,6 +356,19 @@ struct bnxt_re_rqe {
 	__u64 rsvd[2];
 };
 
+/* SRQ */
+struct bnxt_re_srq_req {
+	struct ibv_create_srq cmd;
+	__u64 srqva;
+	__u64 srq_handle;
+};
+
+struct bnxt_re_srq_resp {
+	struct ibv_create_srq_resp resp;
+	__u32 srqid;
+	__u32 rsvd;
+};
+
 struct bnxt_re_srqe {
 	__u32 srq_tag; /* 20 bits are valid */
 	__u32 rsvd1;
@@ -384,6 +399,18 @@ static inline uint32_t bnxt_re_get_rqe_hdr_sz(void)
 	return sizeof(struct bnxt_re_brqe) + sizeof(struct bnxt_re_rqe);
 }
 
+static inline uint32_t bnxt_re_get_srqe_hdr_sz(void)
+{
+	return sizeof(struct bnxt_re_brqe) + sizeof(struct bnxt_re_srqe);
+}
+
+static inline uint32_t bnxt_re_get_srqe_sz(void)
+{
+	return sizeof(struct bnxt_re_brqe) +
+	       sizeof(struct bnxt_re_srqe) +
+	       BNXT_RE_MAX_INLINE_SIZE;
+}
+
 static inline uint32_t bnxt_re_get_cqe_sz(void)
 {
 	return sizeof(struct bnxt_re_req_cqe) + sizeof(struct bnxt_re_bcqe);
providers/bnxtre/db.c +18 -0
index fc22e0d..5b8b6c0 100644
@@ -75,6 +75,24 @@ void bnxt_re_ring_sq_db(struct bnxt_re_qp *qp)
 	bnxt_re_ring_db(qp->udpi, &hdr);
 }
 
+void bnxt_re_ring_srq_db(struct bnxt_re_srq *srq)
+{
+	struct bnxt_re_db_hdr hdr;
+
+	bnxt_re_init_db_hdr(&hdr, srq->srqq->tail, srq->srqid,
+			    BNXT_RE_QUE_TYPE_SRQ);
+	bnxt_re_ring_db(srq->udpi, &hdr);
+}
+
+void bnxt_re_ring_srq_arm(struct bnxt_re_srq *srq)
+{
+	struct bnxt_re_db_hdr hdr;
+
+	bnxt_re_init_db_hdr(&hdr, srq->cap.srq_limit, srq->srqid,
+			    BNXT_RE_QUE_TYPE_SRQ_ARM);
+	bnxt_re_ring_db(srq->udpi, &hdr);
+}
+
 void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq)
 {
 	struct bnxt_re_db_hdr hdr;
providers/bnxtre/main.h +16 -4
index c9b04e1..661f5e0 100644
@@ -75,10 +75,6 @@ struct bnxt_re_cq {
 	uint8_t  phase;
 };
 
-struct bnxt_re_srq {
-	struct ibv_srq ibvsrq;
-};
-
 struct bnxt_re_wrid {
 	struct bnxt_re_psns *psns;
 	uint64_t wrid;
@@ -95,6 +91,16 @@ struct bnxt_re_qpcap {
 	uint8_t	sqsig;
 };
 
+struct bnxt_re_srq {
+	struct ibv_srq ibvsrq;
+	struct ibv_srq_attr cap;
+	struct bnxt_re_queue *srqq;
+	struct bnxt_re_wrid *srwrid;
+	struct bnxt_re_dpi *udpi;
+	uint32_t srqid;
+	uint32_t pre_count;
+};
+
 struct bnxt_re_qp {
 	struct ibv_qp ibvqp;
 	struct bnxt_re_queue *sqq;
@@ -151,6 +157,7 @@ struct bnxt_re_context {
 /* DB ring functions used internally*/
 void bnxt_re_ring_rq_db(struct bnxt_re_qp *qp);
 void bnxt_re_ring_sq_db(struct bnxt_re_qp *qp);
+void bnxt_re_ring_srq_arm(struct bnxt_re_srq *srq);
 void bnxt_re_ring_srq_db(struct bnxt_re_srq *srq);
 void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq);
 void bnxt_re_ring_cq_arm_db(struct bnxt_re_cq *cq, uint8_t aflag);
@@ -182,6 +189,11 @@ static inline struct bnxt_re_qp *to_bnxt_re_qp(struct ibv_qp *ibvqp)
 	return container_of(ibvqp, struct bnxt_re_qp, ibvqp);
 }
 
+static inline struct bnxt_re_srq *to_bnxt_re_srq(struct ibv_srq *ibvsrq)
+{
+	return container_of(ibvsrq, struct bnxt_re_srq, ibvsrq);
+}
+
 static inline struct bnxt_re_ah *to_bnxt_re_ah(struct ibv_ah *ibvah)
 {
 	return container_of(ibvah, struct bnxt_re_ah, ibvah);
providers/bnxtre/verbs.c +227 -34

350 lines not on this page · raw message

Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-11-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#32 lore raw

Re: [PATCH rdma-core 10/11] libbnxtre: Add support for SRQ in user lib

Quoted 62 lines · Devesh Sharma

This patch adds support for shared receive
queue. Following are the changes:
- Add ABI for user/kernel information exchange.
- Add function to handle SRQ ARMing and DB-ring.
- Add function to create/destroy SRQ.
- Add function to query/modify SRQ.
- Add function to post RQE on a SRQ.

---
 providers/bnxtre/abi.h   |  27 +++++
 providers/bnxtre/db.c    |  18 ++++
 providers/bnxtre/main.h  |  20 +++-
 providers/bnxtre/verbs.c | 261 +++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 288 insertions(+), 38 deletions(-)
providers/bnxtre/abi.h +15 -0
index 451af08..e6fb9e4 100644
@@ -216,6 +216,7 @@ struct bnxt_re_mr_resp {
 	struct ibv_reg_mr_resp resp;
 };
 
+/* CQ */
 struct bnxt_re_cq_req {
 	struct ibv_create_cq cmd;
 	__u64 cq_va;
@@ -263,6 +264,7 @@ struct bnxt_re_term_cqe {
 	__u64 rsvd1;
 };
 
+/* QP */
 struct bnxt_re_qp_req {
 	struct ibv_create_qp cmd;
 	__u64 qpsva;
@@ -354,6 +356,19 @@ struct bnxt_re_rqe {
 	__u64 rsvd[2];
 };
 
+/* SRQ */
+struct bnxt_re_srq_req {
+	struct ibv_create_srq cmd;
+	__u64 srqva;
+	__u64 srq_handle;
+};
+
+struct bnxt_re_srq_resp {
+	struct ibv_create_srq_resp resp;
+	__u32 srqid;
+	__u32 rsvd;
+};
+
 struct bnxt_re_srqe {
 	__u32 srq_tag; /* 20 bits are valid */
 	__u32 rsvd1;
@@ -384,6 +399,18 @@ static inline uint32_t bnxt_re_get_rqe_hdr_sz(void)
 	return sizeof(struct bnxt_re_brqe) + sizeof(struct bnxt_re_rqe);
 }

providers/bnxtre/abi.h static inline uint32_t bnxt_re_get_rqe_hdr_sz(void) · line 410

Quoted 10 lines
providers/bnxtre/abi.h +9 -0
 
+static inline uint32_t bnxt_re_get_srqe_hdr_sz(void)
+{
+	return sizeof(struct bnxt_re_brqe) + sizeof(struct bnxt_re_srqe);
+}
+
+static inline uint32_t bnxt_re_get_srqe_sz(void)
+{
+	return sizeof(struct bnxt_re_brqe) +
+	       sizeof(struct bnxt_re_srqe) +

You introduced the inline function exactly for this.

Quoted 3 lines
providers/bnxtre/abi.h +3 -0
+	       BNXT_RE_MAX_INLINE_SIZE;
+}
+
#33 lore raw

PATCH 11/11 libbnxtre: Add versioning support

In reply to a message not in the archive

This patch adds a new header file to maintain the version of library code. Each time a new patch series is applied, this file would be updated. Currently, the macros declared in this header are not referred anywhere in the code. however, those can be used during RPM file generation.

---
 providers/bnxtre/version.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 providers/bnxtre/version.h
providers/bnxtre/version.h new file +53 -0
new file mode 100644
index 0000000..415ef41
@@ -0,0 +1,53 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: current release version information
+ */
+
+#ifndef __BNXT_RE_VERSION_H__
+#define __BNXT_RE_VERSION_H__
+
+#define	MAJOR_VERSION		"1"
+#define	MINOR_VERSION		"0"
+#define	SUB_MINOR_VERSION	"0"
+
+#define	LIBBNXT_RE_VERSION(a, b, c)	a"."b"."c
+
+#define LIBBNXT_RE_REL_VERSION	LIBBNXT_RE_VERSION(MAJOR_VERSION,\
+						   MINOR_VERSION,\
+						   SUB_MINOR_VERSION)
+#define LIBBNXT_RE_BUILD_VERSION	1.0.0
+
+#endif	/* __BNXT_RE_VERSION_H__ */
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1485641622-30015-12-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]

#35 lore raw

Re: [PATCH rdma-core 11/11] libbnxtre: Add versioning support

Quoted 4 lines · Devesh Sharma

This patch adds a new header file to maintain
the version of library code. Each time a new
patch series is applied, this file would be
updated.

No way, please preserve compatibility between different versions.

Quoted 4 lines

Currently, the macros declared in this
header are not referred anywhere in the code. however, those can be used during RPM file generation.

Quoted 8 lines
---
 providers/bnxtre/version.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 providers/bnxtre/version.h

Any reason why should your driver have different ABI compatibility and RPM generation scheme?

Quoted 67 lines
providers/bnxtre/version.h new file +53 -1
new file mode 100644
index 0000000..415ef41
@@ -0,0 +1,53 @@
+/*
+ * Broadcom NetXtreme-E User Space RoCE driver
+ *
+ * Copyright (c) 2015-2016, Broadcom. All rights reserved.  The term
+ * Broadcom refers to Broadcom Limited and/or its subsidiaries.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Description: current release version information
+ */
+
+#ifndef __BNXT_RE_VERSION_H__
+#define __BNXT_RE_VERSION_H__
+
+#define	MAJOR_VERSION		"1"
+#define	MINOR_VERSION		"0"
+#define	SUB_MINOR_VERSION	"0"
+
+#define	LIBBNXT_RE_VERSION(a, b, c)	a"."b"."c
+
+#define LIBBNXT_RE_REL_VERSION	LIBBNXT_RE_VERSION(MAJOR_VERSION,\
+						   MINOR_VERSION,\
+						   SUB_MINOR_VERSION)
+#define LIBBNXT_RE_BUILD_VERSION	1.0.0
+
+#endif	/* __BNXT_RE_VERSION_H__ */
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#36 lore raw

Re: [PATCH rdma-core 11/11] libbnxtre: Add versioning support

In reply to a message not in the archive
Quoted 6 lines · Devesh Sharma

This patch adds a new header file to maintain the version of library code. Each time a new patch series is applied, this file would be updated. Currently, the macros declared in this header are not referred anywhere in the code. however, those can be used during RPM file generation.

No desire for this upstream.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#37 lore raw
In reply to a message not in the archive
Quoted 5 lines · Devesh Sharma

This series introduces the user space RoCE driver for the Broadcom NetXtreme-E 10/25/40/50 RDMA Ethernet Controller. This driver is dependent on the bnxt_re driver posted earlier to linux-rdma community and is under reveiw.

Quoted 8 lines

This patch series is based on the latest master of rdma-core repository hosted at https://github.com/linux-rdma/rdma-core.git

The GIT for this library is hosted at following URL on github
https://github.com/dsharma283/bnxtre-rdma-core.git
branch: bnxtre-v0

Please review and give your feedback.

Not a complete review, just noting that you did the same thing about not being consistent with your name.  It should be libbnxt_re to match the kernel module name.

Quoted 42 lines

Devesh Sharma (11):
  libbnxtre: introduce bnxtre user space RDMA provider
  libbnxtre: Add support for user memory regions
  libbnxtre: Add support for CQ and QP management
  libbnxtre: Add support for posting and polling
  libbnxtre: Allow apps to poll for flushed completions
  libbnxtre: convert cpu to le all over the place
  libbnxtre: Enable UD control path and wqe posting
  libbnxtre: Enable polling for UD completions
  libbnxtre: Add support for atomic operations
  libbnxtre: Add support for SRQ in user lib
  libbnxtre: Add versioning support

 CMakeLists.txt                  |    1 + MAINTAINERS                     |    5 + providers/bnxtre/CMakeLists.txt |    6 + providers/bnxtre/abi.h          |  418 ++++++++++ providers/bnxtre/bnxtre.driver  |    1 + providers/bnxtre/db.c           |  110 +++

 providers/bnxtre/list.h         |  135 ++++
 providers/bnxtre/main.c         |  220 ++++++
 providers/bnxtre/main.h         |  358 +++++++++

 providers/bnxtre/memory.c       |   77 ++
 providers/bnxtre/memory.h       |  160 ++++
 providers/bnxtre/verbs.c        | 1597
+++++++++++++++++++++++++++++++++++++++
 providers/bnxtre/verbs.h        |  106 +++
 providers/bnxtre/version.h      |   53 ++

 14 files changed, 3247 insertions(+)

 create mode 100644 providers/bnxtre/CMakeLists.txt create mode 100644 providers/bnxtre/abi.h create mode 100644 providers/bnxtre/bnxtre.driver create mode 100644 providers/bnxtre/db.c create mode 100644 providers/bnxtre/list.h create mode 100644 providers/bnxtre/main.c create mode 100644 providers/bnxtre/main.h create mode 100644 providers/bnxtre/memory.c create mode 100644 providers/bnxtre/memory.h create mode 100644 providers/bnxtre/verbs.c create mode 100644 providers/bnxtre/verbs.h create mode 100644 providers/bnxtre/version.h

Signature · 4 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD
#38 lore raw
In reply to a message not in the archive
Quoted 11 lines · Devesh Sharma

This series introduces the user space RoCE driver for the Broadcom NetXtreme-E 10/25/40/50 RDMA Ethernet Controller. This driver is dependent on the bnxt_re driver posted earlier to linux-rdma community and is under reveiw.

This patch series is based on the latest master of rdma-core repository hosted at https://github.com/linux-rdma/rdma-core.git

The GIT for this library is hosted at following URL on github
https://github.com/dsharma283/bnxtre-rdma-core.git
branch: bnxtre-v0

Please make a github pull request for this so we can see that travis succeeds in building it.

You can keep it up to date with feedback using force-push to your branch.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170129225625.GA24051-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#40 lore raw

Hi Everyone,

Thanks for providing your comments and feedback. I will fold-in all the comments in V1 and send it out.

-Regards
Devesh

Quoted 13 lines · Jason Gunthorpe
Quoted 11 lines · Devesh Sharma

This series introduces the user space RoCE driver for the Broadcom NetXtreme-E 10/25/40/50 RDMA Ethernet Controller. This driver is dependent on the bnxt_re driver posted earlier to linux-rdma community and is under reveiw.

This patch series is based on the latest master of rdma-core repository hosted at https://github.com/linux-rdma/rdma-core.git

The GIT for this library is hosted at following URL on github
https://github.com/dsharma283/bnxtre-rdma-core.git
branch: bnxtre-v0

Quoted 6 lines

Please make a github pull request for this so we can see that travis succeeds in building it.

You can keep it up to date with feedback using force-push to your branch.

Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html