Broadcom User Space RoCE Driver
v5 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-v5
Please review and give your valuable feedback for the betterment.
v4->v5
-- Removed unwanted inline function definition from
patch-0008
v3->v4
-- Call correct memory-barrier functions before
db ring and before CQE read.
-- Fix sparse warnings.
-- Fix ABI structures and allow byte conversion
when assiging the actual values to the device
specific data-structures.
-- Drop "0009-Add support for SRQ in user lib".
v2->v3
-- Take care of build failure with travis
-- moved wmb() closer to DB rings and used
udma_ordering_write_barrier() instead.
-- Rebased to tip of git tree.
v1->v2
-- Rename directory from bnxtre to bnxt_re
-- Squashed byte-order conversion patch
-- Removed version.h file
Devesh Sharma (8):
libbnxt_re: introduce bnxtre user space RDMA provider
libbnxt_re: Add support for user memory regions
libbnxt_re: Add support for CQ and QP management
libbnxt_re: Add support for posting and polling
libbnxt_re: Allow apps to poll for flushed completions
libbnxt_re: Enable UD control path and wqe posting
libbnxt_re: Enable polling for UD completions
libbnxt_re: Add support for atomic operations
CMakeLists.txt | 1 + MAINTAINERS | 5 + providers/bnxt_re/CMakeLists.txt | 6 + providers/bnxt_re/bnxt_re-abi.h | 353 ++++++++++ providers/bnxt_re/db.c | 93 +++ providers/bnxt_re/flush.h | 85 +++ providers/bnxt_re/main.c | 218 ++++++ providers/bnxt_re/main.h | 376 +++++++++++ providers/bnxt_re/memory.c | 76 +++ providers/bnxt_re/memory.h | 112 +++ providers/bnxt_re/verbs.c | 1385 ++++++++++++++++++++++++++++++++++++++ providers/bnxt_re/verbs.h | 101 +++ 12 files changed, 2811 insertions(+) create mode 100644 providers/bnxt_re/CMakeLists.txt create mode 100644 providers/bnxt_re/bnxt_re-abi.h create mode 100644 providers/bnxt_re/db.c create mode 100644 providers/bnxt_re/flush.h create mode 100644 providers/bnxt_re/main.c create mode 100644 providers/bnxt_re/main.h create mode 100644 providers/bnxt_re/memory.c create mode 100644 providers/bnxt_re/memory.h create mode 100644 providers/bnxt_re/verbs.c create mode 100644 providers/bnxt_re/verbs.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): 1493059995-636-1-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
PATCH v5 1/8 libbnxt_re: 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
v3->v4
-- Changed "bnxtre" to "bnxt_re" in main.h and main.c
v1->v2:
--Deleted bnxtre.driver file
--Dropped HAVE_CONFIG_H macro and cna_table declaration --Renamed abi.h to bnxt_re-abi.h
--- CMakeLists.txt | 1 + MAINTAINERS | 5 + providers/bnxt_re/CMakeLists.txt | 4 + providers/bnxt_re/bnxt_re-abi.h | 59 ++++++++++ providers/bnxt_re/main.c | 190 ++++++++++++++++++++++++++++++ providers/bnxt_re/main.h | 110 ++++++++++++++++++ providers/bnxt_re/verbs.c | 244 +++++++++++++++++++++++++++++++++++++++ providers/bnxt_re/verbs.h | 101 ++++++++++++++++ 8 files changed, 714 insertions(+) create mode 100644 providers/bnxt_re/CMakeLists.txt create mode 100644 providers/bnxt_re/bnxt_re-abi.h create mode 100644 providers/bnxt_re/main.c create mode 100644 providers/bnxt_re/main.h create mode 100644 providers/bnxt_re/verbs.c create mode 100644 providers/bnxt_re/verbs.h
CMakeLists.txt +1 -0
@@ -376,6 +376,7 @@ add_subdirectory(libibcm) # Providers if (HAVE_COHERENT_DMA) +add_subdirectory(providers/bnxt_re) add_subdirectory(providers/cxgb3) # NO SPARSE add_subdirectory(providers/cxgb4) # NO SPARSE add_subdirectory(providers/hns) # NO SPARSE
MAINTAINERS +5 -0
@@ -40,6 +40,11 @@ F: */CMakeLists.txt F: */lib*.map F: buildlib/ +BNXT_RE USERSPACE PROVIDER (for bnxt_re.ko) +M: Devesh Sharma <Devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]> +S: Supported +F: providers/bnxt_re/ + CXGB3 USERSPACE PROVIDER (for iw_cxgb3.ko) M: Steve Wise <[email protected]> S: Supported
providers/bnxt_re/CMakeLists.txt new file +4 -0
@@ -0,0 +1,4 @@ +rdma_provider(bnxt_re + main.c + verbs.c +)
providers/bnxt_re/bnxt_re-abi.h new file +59 -0
59 lines not on this page · raw message
providers/bnxt_re/main.c new file +190 -0
190 lines not on this page · raw message
providers/bnxt_re/main.h new file +110 -0
110 lines not on this page · raw message
providers/bnxt_re/verbs.c new file +244 -0
244 lines not on this page · raw message
providers/bnxt_re/verbs.h new file +101 -0
101 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
PATCH v5 2/8 libbnxt_re: Add support for user memory regions
In reply to a message not in the archiveThis 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/bnxt_re/bnxt_re-abi.h | 4 ++++ providers/bnxt_re/verbs.c | 26 ++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
providers/bnxt_re/bnxt_re-abi.h +4 -0
@@ -56,4 +56,8 @@ struct bnxt_re_pd_resp { __u64 dbr; }; +struct bnxt_re_mr_resp { +struct ibv_reg_mr_resp resp; +}; +#endif
providers/bnxt_re/verbs.c +24 -2
@@ -131,12 +131,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, (uintptr_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
PATCH v5 3/8 libbnxt_re: Add support for CQ and QP management
In reply to a message not in the archiveThis 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.
v3->v4
-- change ABI declarations to use __leXX typedefv1->v2
-- Sorted file list
-- Removed inline functions from ahi.h
--- providers/bnxt_re/CMakeLists.txt | 1 + providers/bnxt_re/bnxt_re-abi.h | 106 ++++++++++++++++++ providers/bnxt_re/main.c | 5 + providers/bnxt_re/main.h | 73 ++++++++++-- providers/bnxt_re/memory.c | 76 +++++++++++++ providers/bnxt_re/memory.h | 76 +++++++++++++ providers/bnxt_re/verbs.c | 236 ++++++++++++++++++++++++++++++++++++++- 7 files changed, 555 insertions(+), 18 deletions(-) create mode 100644 providers/bnxt_re/memory.c create mode 100644 providers/bnxt_re/memory.h
providers/bnxt_re/CMakeLists.txt +1 -0
@@ -1,4 +1,5 @@ rdma_provider(bnxt_re main.c + memory.c verbs.c )
providers/bnxt_re/bnxt_re-abi.h +106 -0
116 lines not on this page · raw message
providers/bnxt_re/main.c +5 -0
@@ -110,8 +110,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));
@@ -122,6 +124,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/bnxt_re/main.h +61 -12
102 lines not on this page · raw message
providers/bnxt_re/memory.c new file +76 -0
76 lines not on this page · raw message
providers/bnxt_re/memory.h new file +76 -0
76 lines not on this page · raw message
providers/bnxt_re/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
PATCH v5 4/8 libbnxt_re: Add support for posting and polling
In reply to a message not in the archiveThis 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.
v3->v4
-- change the write memory barrier and read memory barrier
calls.
-- removed one time byte-order conversion, convert while
assigning instead.
-- take care of sparse error and warnnings.
v1->v2
-- Delete redefinition of "true" and "false" -- Removed unwanted wmb()
-- Removed dead code and fixed return type mismatch.
--- providers/bnxt_re/CMakeLists.txt | 1 + providers/bnxt_re/bnxt_re-abi.h | 174 ++++++++++- providers/bnxt_re/db.c | 93 ++++++ providers/bnxt_re/main.c | 1 + providers/bnxt_re/main.h | 201 +++++++++++- providers/bnxt_re/memory.h | 31 ++ providers/bnxt_re/verbs.c | 654 ++++++++++++++++++++++++++++++++++++--- 7 files changed, 1114 insertions(+), 41 deletions(-) create mode 100644 providers/bnxt_re/db.c
providers/bnxt_re/CMakeLists.txt +1 -0
@@ -1,4 +1,5 @@ rdma_provider(bnxt_re + db.c main.c memory.c verbs.c
providers/bnxt_re/bnxt_re-abi.h +172 -2
196 lines not on this page · raw message
providers/bnxt_re/db.c new file +93 -0
93 lines not on this page · raw message
providers/bnxt_re/main.c +1 -0
@@ -105,6 +105,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/bnxt_re/main.h +197 -4
242 lines not on this page · raw message
providers/bnxt_re/memory.h +31 -0
@@ -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,__le64 *src) +{ + *(volatile __le64 *)dst = *src; +} + +static inline void iowrite32 (__u32 *dst,__le32 *src) +{ + *(volatile __le32 *)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/bnxt_re/verbs.c +619 -35
741 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
PATCH v5 5/8 libbnxt_re: Allow apps to poll for flushed completions
In reply to a message not in the archiveThis 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.
v1->v2
-- Used ccan/list.h instead.
--- providers/bnxt_re/flush.h | 85 ++++++++++++++++ providers/bnxt_re/main.c | 5 + providers/bnxt_re/main.h | 6 ++ providers/bnxt_re/memory.h | 5 + providers/bnxt_re/verbs.c | 245 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 322 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.h
providers/bnxt_re/flush.h new file +85 -0
@@ -0,0 +1,85 @@ +/* +* Broadcom NetXtreme-E User Space RoCE driver +* +* Copyright (c) 2015-2017, 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: A few wrappers for flush queue management +*/ + +#ifndef __FLUSH_H__ +#define __FLUSH_H__ + +#include <ccan/list.h> + +struct bnxt_re_fque_node { +uint8_t valid; +struct list_node list; +}; + +static inline void fque_init_node (struct bnxt_re_fque_node *node) +{ +list_node_init (&node->list); + node->valid = false; +} + +static inline void fque_add_node_tail (struct list_head *head, +struct bnxt_re_fque_node *new) +{ +list_add_tail (head, &new->list); + new->valid = true; +} + +static inline void fque_del_node (struct bnxt_re_fque_node *entry) +{ + entry->valid = false; +list_del (&entry->list); +} + +static inline uint8_t _fque_node_valid (struct bnxt_re_fque_node *node) +{ +return node->valid; +} + +static inline void bnxt_re_fque_add_node (struct list_head *head, +struct bnxt_re_fque_node *node) +{ +if (!_fque_node_valid (node)) +fque_add_node_tail (head, node); +} + +static inline void bnxt_re_fque_del_node (struct bnxt_re_fque_node *node) +{ +if (_fque_node_valid (node)) +fque_del_node (node); +} +#endif /* __FLUSH_H__ */
providers/bnxt_re/main.c +5 -0
@@ -128,6 +128,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 ;
@@ -136,7 +137,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_ops bnxt_re_dev_ops = {
providers/bnxt_re/main.h +6 -0
@@ -50,6 +50,7 @@#include "bnxt_re-abi.h" #include "memory.h" +#include "flush.h" #define DEV "bnxt_re : "
@@ -69,6 +70,8 @@ struct bnxt_re_cq {uint32_t cqid;struct bnxt_re_queue cqq;struct bnxt_re_dpi *udpi; +struct list_head sfhead; +struct list_head rfhead;uint32_t cqe_size;uint8_t phase; };
@@ -104,6 +107,8 @@ struct bnxt_re_qp {struct bnxt_re_cq *rcq;struct bnxt_re_dpi *udpi;struct bnxt_re_qpcap cap; +struct bnxt_re_fque_node snode; +struct bnxt_re_fque_node rnode;uint32_t qpid;uint32_t tbl_indx;uint32_t sq_psn;
@@ -133,6 +138,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/bnxt_re/memory.h +5 -0
@@ -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/bnxt_re/verbs.c +221 -24
318 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
PATCH v5 6/8 libbnxt_re: Enable UD control path and wqe posting
In reply to a message not in the archiveThis 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.
v1->v2
--Removed extra ref of PD in ah structure
--- providers/bnxt_re/bnxt_re-abi.h | 7 ++++ providers/bnxt_re/main.c | 17 ++++++++ providers/bnxt_re/main.h | 12 ++++++ providers/bnxt_re/verbs.c | 91 ++++++++++++++++++++++++++++++++++------- 4 files changed, 113 insertions(+), 14 deletions(-)
providers/bnxt_re/bnxt_re-abi.h +7 -0
@@ -174,6 +174,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 {__le32 indx;__le32 typ_qid;/* typ: 4, qid:20*/
providers/bnxt_re/main.c +17 -0
@@ -129,18 +129,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/bnxt_re/main.h +12 -0
@@ -123,6 +123,11 @@ struct bnxt_re_mr {struct ibv_mr ibvmr; }; +struct bnxt_re_ah { +struct ibv_ah ibvah; +uint32_t avid; +}; +struct bnxt_re_dev {struct verbs_device vdev;uint8_t abi_version;
@@ -138,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; };
@@ -175,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 uint32_t bnxt_re_get_sqe_sz (void ) { return sizeof(struct bnxt_re_bsqe) +
providers/bnxt_re/verbs.c +77 -14
134 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
PATCH v5 7/8 libbnxt_re: Enable polling for UD completions
In reply to a message not in the archiveThis patch adds support to allow polling of send
and recv completions for a UD qp.
--- providers/bnxt_re/bnxt_re-abi.h | 6 ++++++ providers/bnxt_re/verbs.c | 43 +++++++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 14 deletions(-)
providers/bnxt_re/bnxt_re-abi.h +6 -0
@@ -174,6 +174,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/bnxt_re/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
PATCH v5 8/8 libbnxt_re: Add support for atomic operations
In reply to a message not in the archiveThis patch adds support for compare-and-swap and fetch-and-add atomic operations in user library.
v4->v5
-- Removed definition of upper_32_bits and
lower_32_bits.
v3->v4
-- Changed weq init code to match the DMA ABI.v1->v2
-- Fixed the missing "break"
-- Changed macros to inline function
--- providers/bnxt_re/bnxt_re-abi.h | 3 ++- providers/bnxt_re/main.h | 8 ++++++- providers/bnxt_re/verbs.c | 52 ++++++++++++++++++++++++++++++++++------- 3 files changed, 53 insertions(+), 10 deletions(-)
providers/bnxt_re/bnxt_re-abi.h +2 -1
@@ -54,7 +54,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/bnxt_re/main.h +7 -1
@@ -236,9 +236,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/bnxt_re/verbs.c +44 -8
83 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
Quoted 8 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_redriver 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
Quoted 6 lines
The GIT for this library is hosted at following URL on github
https://github.com/dsharma283/bnxtre-rdma-core.git
branch: bnxtre-v5Please review and give your valuable feedback for the betterment.
In general, the driver looked to be in pretty good shape. I've merged it into rdma-core. The only thing I noticed is something that other drivers do as well, but which I have a personal issue with, and that's over use of spin locks in user space IMHO. There are aspects of context that make spin locks OK in the kernel, but those aspects are not true in user space (spin lock can be interrupted and process scheduled away while holding the lock for instance, where as we protect against that in the kernel, the scheduler doesn't know when user space is holding a spin lock, scheduler gives precedent and even extra time slices to processes that appear to be working and making forward progress, and scheduler can't tell the difference between spinning on a lock and making forward progress, so spinning can possibly result in the scheduler keeping the spinning task on the run queue while the task that needs to be brought back onto the run queue is kept waiting, things like this). Unless they've updated pthreads to do stuff that I'm not aware of anyway, which is always possible, I prefer to see mutexes instead of spin locks in user space because they are safer and more likely to result in forward progress in the event of contention. But, as I said, that's just my personal bias. It might be nice if we could devise a test to quantify these issues and see if I'm worried over nothing or if contention on user space spin locks can be as bad as I imagine.
Signature · 9 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD -- 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): [email protected]
Quoted 4 lines · Doug Ledford
I'm not aware of anyway, which is always possible, I prefer to see mutexes instead of spin locks in user space because they are safer and more likely to result in forward progress in the event of contention.
It is true that if the callers of verbs adjust their thread priorities we will certainly completely fail to make forward progess in the worst case situations, as high priority waiters will no yield the CPU.
For this reason alone it is probably a really bad idea to use spinlocks at all in library code.
However, AFAIK, default pthread mutexes well known to be much slower than spinlocks for various cases. They have weird performance aspects from the fairness policy on unlock we may not really want.
Perahps this is why Sean open-coded locks using atomics in rdmacm and acm?
However, there are many kinds of mutex locks in glibc, and perhaps something like PTHREAD_MUTEX_ADAPTIVE_NP gives performance close to a spinlock?
Someone would have to benchmark different options and see.
Since we are so very performance sensitive, we might do well to open-code our own locking primitive, similar to PTHREAD_MUTEX_ADAPTIVE_NP, based on futexes. Inlining the non-contended case alone would probably be notably helpful.
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): 20170424215140.GA14907-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Quoted 6 lines
However, AFAIK, default pthread mutexes well known to be much slower than spinlocks for various cases. They have weird performance aspects from the fairness policy on unlock we may not really want.
Perahps this is why Sean open-coded locks using atomics in rdmacm and acm?
I went with open-coded locks based on v-tune (or whatever it's called now -- I should really know this) performance analysis and benchmarking data. I don't recall the performance gains, but it was definitely measureable.
- Sean
--
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): 1828884A29C6694DAF28B7E6B8A82373AB1169E4-P5GAC/[email protected]
Quoted 11 lines · Sean
Quoted 6 lines
However, AFAIK, default pthread mutexes well known to be much slower than spinlocks for various cases. They have weird performance aspects from the fairness policy on unlock we may not really want.
Perahps this is why Sean open-coded locks using atomics in rdmacm and acm?
I went with open-coded locks based on v-tune (or whatever it's called now -- I should really know this) performance analysis and benchmarking data. I don't recall the performance gains, but it was definitely measureable.
But libfabric uses pthreads?
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): 20170425152843.GA17680-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Quoted 6 lines
Quoted 4 lines
I went with open-coded locks based on v-tune (or whatever it's called now -- I should really know this) performance analysis and benchmarking data. I don't recall the performance gains, but it was definitely measureable.
But libfabric uses pthreads?
Libfabric does, but most of the performance based synchronization is handled in the provider code. And I _think_ there are places where open coded atomics are used. --
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