Broadcom User Space RoCE Driver
v3 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-v3
Please review and give your valuable feedback for the betterment.
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 (9):
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
libbnxt_re: Add support for SRQ in user lib
CMakeLists.txt | 1 + MAINTAINERS | 5 + providers/bnxt_re/CMakeLists.txt | 6 + providers/bnxt_re/bnxt_re-abi.h | 375 +++++++++ providers/bnxt_re/db.c | 110 +++ providers/bnxt_re/flush.h | 85 ++ providers/bnxt_re/main.c | 218 ++++++ providers/bnxt_re/main.h | 398 ++++++++++ providers/bnxt_re/memory.c | 76 ++ providers/bnxt_re/memory.h | 154 ++++ providers/bnxt_re/verbs.c | 1584 ++++++++++++++++++++++++++++++++++++++ providers/bnxt_re/verbs.h | 101 +++ 12 files changed, 3113 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): 1489574253-20300-1-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
PATCH v3 1/9 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
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 | 242 +++++++++++++++++++++++++++++++++++++++ providers/bnxt_re/verbs.h | 101 ++++++++++++++++ 8 files changed, 712 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
@@ -379,6 +379,7 @@ add_subdirectory(libibcm) # Providers if (HAVE_COHERENT_DMA) +add_subdirectory(providers/bnxt_re) add_subdirectory(providers/cxgb3) add_subdirectory(providers/cxgb4) add_subdirectory(providers/hns)
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 +242 -0
242 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 v3 2/9 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
@@ -129,12 +129,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 v3 3/9 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.
v1->v2
-- Sorted file list
-- Removed inline functions from ahi.h
--- providers/bnxt_re/CMakeLists.txt | 1 + providers/bnxt_re/bnxt_re-abi.h | 113 +++++++++++++++++++ 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, 562 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 +113 -0
123 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 v3 4/9 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.
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 | 92 ++++++ providers/bnxt_re/main.c | 1 + providers/bnxt_re/main.h | 199 +++++++++++- providers/bnxt_re/memory.h | 63 ++++ providers/bnxt_re/verbs.c | 661 ++++++++++++++++++++++++++++++++++++--- 7 files changed, 1150 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 +92 -0
92 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 +195 -4
240 lines not on this page · raw message
providers/bnxt_re/memory.h +63 -0
67 lines not on this page · raw message
providers/bnxt_re/verbs.c +626 -35
748 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): 1489574253-20300-5-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling
Review
Quoted 4 lines · Devesh Sharma
(quoted diff) +4
-0+ + pthread_spin_lock(&dpi->db_lock); + *dbval = htole64(*dbval); + udma_ordering_write_barrier();
The ordering_write_barrier is basically an equivalent barrier to a spinlock, so this is an unnecessary pattern.
However, you still always need udma_to_device_barrier before triggering chip DMA.
There is also no udma_from_device_barrier() in this driver, which can't be right, please add one around bnxt_re_is_cqe_valid most likely.
Your github branch doesn't compile, btw.
I ran it through sparse, this is what I suggest..
providers/bnxt_re/bnxt_re-abi.h +2 -2
@@ -243,7 +243,7 @@ struct bnxt_re_req_cqe {struct bnxt_re_rc_cqe {__u32 length; -__u32 imm_key; +__be32 imm_key;__u64 qp_handle;__u64 mr_handle; };
@@ -282,7 +282,7 @@ struct bnxt_re_bsqe { };struct bnxt_re_psns { -__u32 opc_spsn; +__le32 opc_spsn;__u32 flg_npsn; };
providers/bnxt_re/verbs.c +9 -7
@@ -581,9 +581,10 @@ static int bnxt_re_poll_flush_wcs(struct bnxt_re_queue *que, wrid = &wridp[head];if (wrid->psns) { psns = wrid->psns; - opcode = (psns->opc_spsn >>BNXT_RE_PSNS_OPCD_SHIFT ) & -BNXT_RE_PSNS_OPCD_MASK ; - } + opcode = (le32toh (psns->opc_spsn) >> +BNXT_RE_PSNS_OPCD_SHIFT ) & +BNXT_RE_PSNS_OPCD_MASK ; + } ibvwc->status =IBV_WC_WR_FLUSH_ERR ; ibvwc->opcode = opcode;
@@ -1032,10 +1033,11 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, uint8_t opcode, uint32_t len) { uint32_t pkt_cnt = 0, nxt_psn; +uint32_t opc_spsn =0 ;memset (psns,0 ,sizeof (*psns));if (qp->qptyp ==IBV_QPT_RC ) { - psns->opc_spsn = qp->sq_psn &BNXT_RE_PSNS_SPSN_MASK ; + opc_spsn = qp->sq_psn &BNXT_RE_PSNS_SPSN_MASK ; pkt_cnt = (len / qp->mtu);if (len % qp->mtu) pkt_cnt++;
@@ -1044,9 +1046,9 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, qp->sq_psn = nxt_psn; } opcode =bnxt_re_ibv_wr_to_wc_opcd (opcode); - psns->opc_spsn |= ((opcode &BNXT_RE_PSNS_OPCD_MASK ) << -BNXT_RE_PSNS_OPCD_SHIFT ); - *(uint64_t *)psns =htole64 (*(uint64_t *)psns); + opc_spsn |= + ((opcode &BNXT_RE_PSNS_OPCD_MASK ) <<BNXT_RE_PSNS_OPCD_SHIFT ); + psns->opc_spsn =htole32 (opc_spsn); } static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr,
--
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): 20170315163454.GD29562-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Re: [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling
Quoted 11 lines · Jason Gunthorpe
Review
Quoted 4 lines · Devesh Sharma
(quoted diff) +4
-0+ + pthread_spin_lock(&dpi->db_lock); + *dbval = htole64(*dbval); + udma_ordering_write_barrier();The
ordering_write_barrieris basically an equivalent barrier to a spinlock, so this is an unnecessary pattern.However, you still always need
udma_to_device_barrierbefore triggering chip DMA.
I will change this in V4.
Quoted 4 lines
There is also no
udma_from_device_barrier()in this driver, which can't be right, please add one aroundbnxt_re_is_cqe_validmost likely.
Ok, I will put it in next version.
Quoted 4 lines
Your github branch doesn't compile, btw.
I ran it through sparse, this is what I suggest..
Thanks for the suggestion, I will run sparse and try to fix all of it.
Quoted 57 lines
providers/bnxt_re/bnxt_re-abi.h +2
-2@@ -243,7 +243,7 @@ struct bnxt_re_req_cqe {struct bnxt_re_rc_cqe {__u32 length; -__u32 imm_key; +__be32 imm_key;__u64 qp_handle;__u64 mr_handle; };@@ -282,7 +282,7 @@ struct bnxt_re_bsqe { };struct bnxt_re_psns { -__u32 opc_spsn; +__le32 opc_spsn;__u32 flg_npsn; };providers/bnxt_re/verbs.c +6
-4@@ -581,9 +581,10 @@ static int bnxt_re_poll_flush_wcs(struct bnxt_re_queue *que, wrid = &wridp[head];if (wrid->psns) { psns = wrid->psns; - opcode = (psns->opc_spsn >>BNXT_RE_PSNS_OPCD_SHIFT ) & -BNXT_RE_PSNS_OPCD_MASK ; - } + opcode = (le32toh (psns->opc_spsn) >> +BNXT_RE_PSNS_OPCD_SHIFT ) & +BNXT_RE_PSNS_OPCD_MASK ; + } ibvwc->status =IBV_WC_WR_FLUSH_ERR ; ibvwc->opcode = opcode;@@ -1032,10 +1033,11 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, uint8_t opcode, uint32_t len) { uint32_t pkt_cnt = 0, nxt_psn; +uint32_t opc_spsn =0 ;memset (psns,0 ,sizeof (*psns));if (qp->qptyp ==IBV_QPT_RC ) { - psns->opc_spsn = qp->sq_psn &BNXT_RE_PSNS_SPSN_MASK ; + opc_spsn = qp->sq_psn &BNXT_RE_PSNS_SPSN_MASK ; pkt_cnt = (len / qp->mtu);if (len % qp->mtu) pkt_cnt++;@@ -1044,9 +1046,9 @@ static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, qp->sq_psn = nxt_psn; }
providers/bnxt_re/verbs.c static void bnxt_re_fill_psns(struct bnxt_re_qp *qp, struct bnxt_re_psns *psns, · line 1054
Quoted 10 lines
providers/bnxt_re/verbs.c +3
-3opcode =bnxt_re_ibv_wr_to_wc_opcd (opcode); - psns->opc_spsn |= ((opcode &BNXT_RE_PSNS_OPCD_MASK ) << -BNXT_RE_PSNS_OPCD_SHIFT ); - *(uint64_t *)psns =htole64 (*(uint64_t *)psns); + opc_spsn |= + ((opcode &BNXT_RE_PSNS_OPCD_MASK ) <<BNXT_RE_PSNS_OPCD_SHIFT ); + psns->opc_spsn =htole32 (opc_spsn); } static void bnxt_re_fill_wrid(struct bnxt_re_wrid *wrid, struct ibv_send_wr *wr,
--
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): CANjDDBh9JP-0W4NDW4p-Jx2fivcSKS9ZAt5AdLRdQPXH8WxxCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling
Quoted 5 lines · Devesh Sharma
Quoted 3 lines
Your github branch doesn't compile, btw.
I ran it through sparse, this is what I suggest..
Thanks for the suggestion, I will run sparse and try to fix all of it.
You will need my sparse branch to do this:
https://github.com/linux-rdma/rdma-core/pull/100
There were a few places still producing warnings, at least two should be fixed with __force
You should make a PR for this once you get Leon's changes and rebase it the current master.
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): 20170316161754.GF23821-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Re: [rdma-core v3 4/9] libbnxt_re: Add support for posting and polling
Okay, I will get it done.
Quoted 12 lines · Jason Gunthorpe
Quoted 5 lines · Devesh Sharma
Quoted 3 lines
Your github branch doesn't compile, btw.
I ran it through sparse, this is what I suggest..
Thanks for the suggestion, I will run sparse and try to fix all of it.
You will need my sparse branch to do this:
Quoted 7 lines
There were a few places still producing warnings, at least two should be fixed with
__forceYou should make a PR for this once you get Leon's changes and rebase it the current master.
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
PATCH v3 5/9 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 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 "bnxtre : "
@@ -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 +219 -24
316 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): 1489574253-20300-6-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions
Quoted 113 lines · Devesh Sharma
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 thecon_idxreported.
Step-3: Report the completion with actual error to consumer, and
without bothering about thecon_idxreported 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
-- Usedccan/list.hinstead.--- 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.hproviders/bnxt_re/flush.h new file +57
-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) +{
providers/bnxt_re/flush.h line 67
Quoted 10 lines
providers/bnxt_re/flush.h new file +10
-0+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); +} +
I don't see the point of these wrappers.
Quoted 47 lines
providers/bnxt_re/flush.h new file +18
-0+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 +0
-0
providers/bnxt_re/main.h line 55
Quoted 6 lines
providers/bnxt_re/main.h +1
-0@@ -50,6 +50,7 @@#include "bnxt_re-abi.h" #include "memory.h" +#include "flush.h" #define DEV "bnxtre : "
Isn't "bnxt_re"?
Quoted 379 lines
providers/bnxt_re/main.h +5
-0@@ -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 +219
-25@@ -202,6 +202,9 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, cq->cqq.tail = resp.tail; cq->udpi = &cntx->udpi; +list_head_init (&cq->sfhead); +list_head_init (&cq->rfhead); +return &cq->ibvcq; cmdfail:bnxt_re_free_aligned (&cq->cqq);@@ -230,6 +233,47 @@ int bnxt_re_destroy_cq(struct ibv_cq *ibvcq)return 0 ; } +static uint8_t bnxt_re_poll_err_scqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc, +struct bnxt_re_bcqe *hdr, +struct bnxt_re_req_cqe *scqe,int *cnt) +{ +struct bnxt_re_queue *sq = qp->sqq; +struct bnxt_re_context *cntx; +struct bnxt_re_wrid *swrid; +struct bnxt_re_psns *spsn; +struct bnxt_re_cq *scq; +uint32_t head = sq->head; +uint8_t status; + + scq =to_bnxt_re_cq (qp->ibvqp.send_cq); + cntx =to_bnxt_re_context (scq->ibvcq.context); + swrid = &qp->swrid[head]; + spsn = swrid->psns; + + *cnt =1 ; + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) & +BNXT_RE_BCQE_STATUS_MASK ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, true); + ibvwc->wc_flags =0 ; + ibvwc->wr_id = swrid->wrid; + ibvwc->qp_num = qp->qpid; + 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); + +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&scq->sfhead, &qp->snode); +pthread_spin_unlock (&cntx->fqlock); + +return false; +} + static uint8_t bnxt_re_poll_success_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr,@@ -284,21 +328,53 @@ static uint8_t bnxt_re_poll_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ; -if (status ==BNXT_RE_REQ_ST_OK ) { +if (status ==BNXT_RE_REQ_ST_OK ) pcqe =bnxt_re_poll_success_scqe (qp, ibvwc, hdr, scqe, cnt); - }else { -/* TODO: Handle error completion properly. */ -fprintf (stderr,"%s(): swc with error, vendor status = %d\n" , - __func__, status); - *cnt =1 ; - ibvwc->status =bnxt_re_to_ibv_wc_status (status, true); - ibvwc->wr_id = qp->swrid[qp->sqq->head].wrid; -bnxt_re_incr_head (qp->sqq); - } +else + pcqe =bnxt_re_poll_err_scqe (qp, ibvwc, hdr, scqe, cnt);return pcqe; } +static int bnxt_re_poll_err_rcqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc, +struct bnxt_re_bcqe *hdr, +struct bnxt_re_rc_cqe *rcqe) +{ +struct bnxt_re_queue *rq = qp->rqq; +struct bnxt_re_wrid *rwrid; +struct bnxt_re_cq *rcq; +struct bnxt_re_context *cntx; +uint32_t head = rq->head; +uint8_t status; + + rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); + cntx =to_bnxt_re_context (rcq->ibvcq.context); + + rwrid = &qp->rwrid[head]; + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) & +BNXT_RE_BCQE_STATUS_MASK ; +/* skip h/w flush errors */ +if (status ==BNXT_RE_RSP_ST_HW_FLUSH ) +return 0 ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); +/* TODO: Add SRQ Processing here */ +if (qp->rqq) { + ibvwc->wr_id = rwrid->wrid; + ibvwc->qp_num = qp->qpid; + ibvwc->opcode =IBV_WC_RECV ; + ibvwc->byte_len =0 ; +bnxt_re_incr_head (qp->rqq); +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode); +pthread_spin_unlock (&cntx->fqlock); + } + +return 1 ; +} + static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr,@@ -346,18 +422,37 @@ static uint8_t bnxt_re_poll_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ; -if (status ==BNXT_RE_RSP_ST_OK ) { + *cnt =1 ; +if (status ==BNXT_RE_RSP_ST_OK )bnxt_re_poll_success_rcqe (qp, ibvwc, hdr, rcqe); - *cnt =1 ; - }else { -/* TODO: Process error completions properly.*/ - *cnt =1 ; - ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); -if (qp->rqq) { - ibvwc->wr_id = qp->rwrid[qp->rqq->head].wrid; -bnxt_re_incr_head (qp->rqq); - } - } +else + *cnt =bnxt_re_poll_err_rcqe (qp, ibvwc, hdr, rcqe); + +return pcqe; +} + +static uint8_t bnxt_re_poll_term_cqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc,void *cqe,int *cnt) +{ +struct bnxt_re_context *cntx; +struct bnxt_re_cq *scq, *rcq; +uint8_t pcqe = false; + + scq =to_bnxt_re_cq (qp->ibvqp.send_cq); + rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); + cntx =to_bnxt_re_context (scq->ibvcq.context); +/* For now just add the QP to flush list without +* considering the index reported in the CQE. +* Continue reporting flush completions until the +* SQ and RQ are empty. +*/ + *cnt =0 ; +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode); +bnxt_re_fque_add_node (&scq->sfhead, &qp->snode); +pthread_spin_unlock (&cntx->fqlock);return pcqe; }@@ -410,6 +505,12 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc)case BNXT_RE_WC_TYPE_RECV_RAW :break ;case BNXT_RE_WC_TYPE_TERM : + scqe = cqe; + qp_handle = (uint64_t *)&scqe->qp_handle; + qp = (struct bnxt_re_qp *)(uintptr_t )scqe->qp_handle; +if (!qp) +break ; + pcqe =bnxt_re_poll_term_cqe (qp, wc, cqe, &cnt);break ;case BNXT_RE_WC_TYPE_COFF :break ;@@ -442,22 +543,107 @@ bail:return dqed; } +static int bnxt_re_poll_flush_wcs (struct bnxt_re_queue *que, +struct bnxt_re_wrid *wridp, +struct ibv_wc *ibvwc,uint32_t qpid, +int nwc) +{ +struct bnxt_re_wrid *wrid; +struct bnxt_re_psns *psns; +uint32_t cnt =0 , head; +uint8_t opcode =IBV_WC_RECV ; + +while (nwc) { +if (bnxt_re_is_que_empty (que)) +break ; + head = que->head; + wrid = &wridp[head]; +if (wrid->psns) { + psns = wrid->psns; + opcode = (psns->opc_spsn >>BNXT_RE_PSNS_OPCD_SHIFT ) & +BNXT_RE_PSNS_OPCD_MASK ; + } + + ibvwc->status =IBV_WC_WR_FLUSH_ERR ; + ibvwc->opcode = opcode; + ibvwc->wr_id = wrid->wrid; + ibvwc->qp_num = qpid; + ibvwc->byte_len =0 ; + ibvwc->wc_flags =0 ; + +bnxt_re_incr_head (que); + nwc--; + cnt++; + ibvwc++; + } + +return cnt; +} + +static int bnxt_re_poll_flush_lists (struct bnxt_re_cq *cq,uint32_t nwc, +struct ibv_wc *ibvwc) +{ +struct bnxt_re_fque_node *cur, *tmp; +struct bnxt_re_qp *qp; +struct bnxt_re_queue *que; +int dqed =0 , left; + +/* Check if flush Qs are empty */ +if (list_empty (&cq->sfhead) &&list_empty (&cq->rfhead)) +return 0 ; + +if (!list_empty (&cq->sfhead)) { +list_for_each_safe (&cq->sfhead, cur, tmp, list) { + qp = container_of(cur, struct bnxt_re_qp, snode); + que = qp->sqq; +if (bnxt_re_is_que_empty (que)) +continue ; + dqed =bnxt_re_poll_flush_wcs (que, qp->swrid, ibvwc, + qp->qpid, nwc); + } + } + + left = nwc - dqed; +if (!left) +return dqed; + +if (!list_empty (&cq->rfhead)) { +list_for_each_safe (&cq->rfhead, cur, tmp, list) { + qp = container_of(cur, struct bnxt_re_qp, rnode); + que = qp->rqq; +if (!que ||bnxt_re_is_que_empty (que)) +continue ; + dqed +=bnxt_re_poll_flush_wcs (que, qp->rwrid, + ibvwc + dqed, qp->qpid, + left); + } + } + +return dqed; +} +int bnxt_re_poll_cq (struct ibv_cq *ibvcq,int nwc,struct ibv_wc *wc) {struct bnxt_re_cq *cq =to_bnxt_re_cq (ibvcq); -int dqed; +struct bnxt_re_context *cntx =to_bnxt_re_context (ibvcq->context); +int dqed, left =0 ;pthread_spin_lock (&cq->cqq.qlock); dqed =bnxt_re_poll_one (cq, nwc, wc);pthread_spin_unlock (&cq->cqq.qlock); - -/* TODO: Flush Management*/ +/* Check if anything is there to flush. */ +pthread_spin_lock (&cntx->fqlock); + left = nwc - dqed; +if (left) + dqed +=bnxt_re_poll_flush_lists (cq, left, (wc + dqed)); +pthread_spin_unlock (&cntx->fqlock);return dqed; }static void bnxt_re_cleanup_cq (struct bnxt_re_qp *qp,struct bnxt_re_cq *cq) { +struct bnxt_re_context *cntx;struct bnxt_re_queue *que = &cq->cqq;struct bnxt_re_bcqe *hdr;struct bnxt_re_req_cqe *scqe;@@ -465,6 +651,8 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq)void *cqe;int indx, type; + cntx =to_bnxt_re_context (cq->ibvcq.context); +pthread_spin_lock (&que->qlock);for (indx =0 ; indx < que->depth; indx++) { cqe = que->va + indx *bnxt_re_get_cqe_sz ();@@ -487,6 +675,11 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq) }pthread_spin_unlock (&que->qlock); + +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_del_node (&qp->snode); +bnxt_re_fque_del_node (&qp->rnode); +pthread_spin_unlock (&cntx->fqlock); }void bnxt_re_cq_event (struct ibv_cq *ibvcq)@@ -679,6 +872,8 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, cap->max_rsge = attr->cap.max_recv_sge; cap->max_inline = attr->cap.max_inline_data; cap->sqsig = attr->sq_sig_all; +fque_init_node (&qp->snode); +fque_init_node (&qp->rnode);return &qp->ibvqp; failcmd: --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): 20170315192028.GI2079-U/[email protected]
Re: [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions
Quoted 118 lines · Leon Romanovsky
Quoted 117 lines · Devesh Sharma
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 thecon_idxreported.
Step-3: Report the completion with actual error to consumer, and
without bothering about thecon_idxreported 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
-- Usedccan/list.hinstead.--- 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.hproviders/bnxt_re/flush.h new file +61
-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; +} +
Quoted 8 lines
providers/bnxt_re/flush.h line 67
Quoted 6 lines
providers/bnxt_re/flush.h new file +6
-0+static inline void fque_del_node (struct bnxt_re_fque_node *entry) +{ + entry->valid = false; +list_del (&entry->list); +} +I don't see the point of these wrappers.
Wanted to keep "entry->valid" as a property of list element rather mixing it in the QP structure to keep things clean. Thus, could not resist to keep those.
Quoted 49 lines
Quoted 49 lines
providers/bnxt_re/flush.h new file +18
-0+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 +0
-0@@ -50,6 +50,7 @@
Quoted 7 lines
providers/bnxt_re/main.h line 55
Quoted 5 lines
providers/bnxt_re/main.h +1
-0#include "bnxt_re-abi.h" #include "memory.h" +#include "flush.h" #define DEV "bnxtre : "Isn't "
bnxt_re"?
True, I will fix it.
Quoted 376 lines
Quoted 376 lines
providers/bnxt_re/main.h +5
-0@@ -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 +219
-25@@ -202,6 +202,9 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe, cq->cqq.tail = resp.tail; cq->udpi = &cntx->udpi; +list_head_init (&cq->sfhead); +list_head_init (&cq->rfhead); +return &cq->ibvcq; cmdfail:bnxt_re_free_aligned (&cq->cqq);@@ -230,6 +233,47 @@ int bnxt_re_destroy_cq(struct ibv_cq *ibvcq)return 0 ; } +static uint8_t bnxt_re_poll_err_scqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc, +struct bnxt_re_bcqe *hdr, +struct bnxt_re_req_cqe *scqe,int *cnt) +{ +struct bnxt_re_queue *sq = qp->sqq; +struct bnxt_re_context *cntx; +struct bnxt_re_wrid *swrid; +struct bnxt_re_psns *spsn; +struct bnxt_re_cq *scq; +uint32_t head = sq->head; +uint8_t status; + + scq =to_bnxt_re_cq (qp->ibvqp.send_cq); + cntx =to_bnxt_re_context (scq->ibvcq.context); + swrid = &qp->swrid[head]; + spsn = swrid->psns; + + *cnt =1 ; + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) & +BNXT_RE_BCQE_STATUS_MASK ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, true); + ibvwc->wc_flags =0 ; + ibvwc->wr_id = swrid->wrid; + ibvwc->qp_num = qp->qpid; + 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); + +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&scq->sfhead, &qp->snode); +pthread_spin_unlock (&cntx->fqlock); + +return false; +} + static uint8_t bnxt_re_poll_success_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr,@@ -284,21 +328,53 @@ static uint8_t bnxt_re_poll_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ; -if (status ==BNXT_RE_REQ_ST_OK ) { +if (status ==BNXT_RE_REQ_ST_OK ) pcqe =bnxt_re_poll_success_scqe (qp, ibvwc, hdr, scqe, cnt); - }else { -/* TODO: Handle error completion properly. */ -fprintf (stderr,"%s(): swc with error, vendor status = %d\n" , - __func__, status); - *cnt =1 ; - ibvwc->status =bnxt_re_to_ibv_wc_status (status, true); - ibvwc->wr_id = qp->swrid[qp->sqq->head].wrid; -bnxt_re_incr_head (qp->sqq); - } +else + pcqe =bnxt_re_poll_err_scqe (qp, ibvwc, hdr, scqe, cnt);return pcqe; } +static int bnxt_re_poll_err_rcqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc, +struct bnxt_re_bcqe *hdr, +struct bnxt_re_rc_cqe *rcqe) +{ +struct bnxt_re_queue *rq = qp->rqq; +struct bnxt_re_wrid *rwrid; +struct bnxt_re_cq *rcq; +struct bnxt_re_context *cntx; +uint32_t head = rq->head; +uint8_t status; + + rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); + cntx =to_bnxt_re_context (rcq->ibvcq.context); + + rwrid = &qp->rwrid[head]; + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) & +BNXT_RE_BCQE_STATUS_MASK ; +/* skip h/w flush errors */ +if (status ==BNXT_RE_RSP_ST_HW_FLUSH ) +return 0 ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); +/* TODO: Add SRQ Processing here */ +if (qp->rqq) { + ibvwc->wr_id = rwrid->wrid; + ibvwc->qp_num = qp->qpid; + ibvwc->opcode =IBV_WC_RECV ; + ibvwc->byte_len =0 ; +bnxt_re_incr_head (qp->rqq); +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode); +pthread_spin_unlock (&cntx->fqlock); + } + +return 1 ; +} + static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr,@@ -346,18 +422,37 @@ static uint8_t bnxt_re_poll_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc, status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ; -if (status ==BNXT_RE_RSP_ST_OK ) { + *cnt =1 ; +if (status ==BNXT_RE_RSP_ST_OK )bnxt_re_poll_success_rcqe (qp, ibvwc, hdr, rcqe); - *cnt =1 ; - }else { -/* TODO: Process error completions properly.*/ - *cnt =1 ; - ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); -if (qp->rqq) { - ibvwc->wr_id = qp->rwrid[qp->rqq->head].wrid; -bnxt_re_incr_head (qp->rqq); - } - } +else + *cnt =bnxt_re_poll_err_rcqe (qp, ibvwc, hdr, rcqe); + +return pcqe; +} + +static uint8_t bnxt_re_poll_term_cqe (struct bnxt_re_qp *qp, +struct ibv_wc *ibvwc,void *cqe,int *cnt) +{ +struct bnxt_re_context *cntx; +struct bnxt_re_cq *scq, *rcq; +uint8_t pcqe = false; + + scq =to_bnxt_re_cq (qp->ibvqp.send_cq); + rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); + cntx =to_bnxt_re_context (scq->ibvcq.context); +/* For now just add the QP to flush list without +* considering the index reported in the CQE. +* Continue reporting flush completions until the +* SQ and RQ are empty. +*/ + *cnt =0 ; +if (qp->qpst !=IBV_QPS_ERR ) + qp->qpst =IBV_QPS_ERR ; +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode); +bnxt_re_fque_add_node (&scq->sfhead, &qp->snode); +pthread_spin_unlock (&cntx->fqlock);return pcqe; }@@ -410,6 +505,12 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc)case BNXT_RE_WC_TYPE_RECV_RAW :break ;case BNXT_RE_WC_TYPE_TERM : + scqe = cqe; + qp_handle = (uint64_t *)&scqe->qp_handle; + qp = (struct bnxt_re_qp *)(uintptr_t )scqe->qp_handle; +if (!qp) +break ; + pcqe =bnxt_re_poll_term_cqe (qp, wc, cqe, &cnt);break ;case BNXT_RE_WC_TYPE_COFF :break ;@@ -442,22 +543,107 @@ bail:return dqed; } +static int bnxt_re_poll_flush_wcs (struct bnxt_re_queue *que, +struct bnxt_re_wrid *wridp, +struct ibv_wc *ibvwc,uint32_t qpid, +int nwc) +{ +struct bnxt_re_wrid *wrid; +struct bnxt_re_psns *psns; +uint32_t cnt =0 , head; +uint8_t opcode =IBV_WC_RECV ; + +while (nwc) { +if (bnxt_re_is_que_empty (que)) +break ; + head = que->head; + wrid = &wridp[head]; +if (wrid->psns) { + psns = wrid->psns; + opcode = (psns->opc_spsn >>BNXT_RE_PSNS_OPCD_SHIFT ) & +BNXT_RE_PSNS_OPCD_MASK ; + } + + ibvwc->status =IBV_WC_WR_FLUSH_ERR ; + ibvwc->opcode = opcode; + ibvwc->wr_id = wrid->wrid; + ibvwc->qp_num = qpid; + ibvwc->byte_len =0 ; + ibvwc->wc_flags =0 ; + +bnxt_re_incr_head (que); + nwc--; + cnt++; + ibvwc++; + } + +return cnt; +} + +static int bnxt_re_poll_flush_lists (struct bnxt_re_cq *cq,uint32_t nwc, +struct ibv_wc *ibvwc) +{ +struct bnxt_re_fque_node *cur, *tmp; +struct bnxt_re_qp *qp; +struct bnxt_re_queue *que; +int dqed =0 , left; + +/* Check if flush Qs are empty */ +if (list_empty (&cq->sfhead) &&list_empty (&cq->rfhead)) +return 0 ; + +if (!list_empty (&cq->sfhead)) { +list_for_each_safe (&cq->sfhead, cur, tmp, list) { + qp = container_of(cur, struct bnxt_re_qp, snode); + que = qp->sqq; +if (bnxt_re_is_que_empty (que)) +continue ; + dqed =bnxt_re_poll_flush_wcs (que, qp->swrid, ibvwc, + qp->qpid, nwc); + } + } + + left = nwc - dqed; +if (!left) +return dqed; + +if (!list_empty (&cq->rfhead)) { +list_for_each_safe (&cq->rfhead, cur, tmp, list) { + qp = container_of(cur, struct bnxt_re_qp, rnode); + que = qp->rqq; +if (!que ||bnxt_re_is_que_empty (que)) +continue ; + dqed +=bnxt_re_poll_flush_wcs (que, qp->rwrid, + ibvwc + dqed, qp->qpid, + left); + } + } + +return dqed; +} +int bnxt_re_poll_cq (struct ibv_cq *ibvcq,int nwc,struct ibv_wc *wc) {struct bnxt_re_cq *cq =to_bnxt_re_cq (ibvcq); -int dqed; +struct bnxt_re_context *cntx =to_bnxt_re_context (ibvcq->context); +int dqed, left =0 ;pthread_spin_lock (&cq->cqq.qlock); dqed =bnxt_re_poll_one (cq, nwc, wc);pthread_spin_unlock (&cq->cqq.qlock); - -/* TODO: Flush Management*/ +/* Check if anything is there to flush. */ +pthread_spin_lock (&cntx->fqlock); + left = nwc - dqed; +if (left) + dqed +=bnxt_re_poll_flush_lists (cq, left, (wc + dqed)); +pthread_spin_unlock (&cntx->fqlock);return dqed; }static void bnxt_re_cleanup_cq (struct bnxt_re_qp *qp,struct bnxt_re_cq *cq) { +struct bnxt_re_context *cntx;struct bnxt_re_queue *que = &cq->cqq;struct bnxt_re_bcqe *hdr;struct bnxt_re_req_cqe *scqe;@@ -465,6 +651,8 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq)void *cqe;int indx, type; + cntx =to_bnxt_re_context (cq->ibvcq.context); +pthread_spin_lock (&que->qlock);for (indx =0 ; indx < que->depth; indx++) { cqe = que->va + indx *bnxt_re_get_cqe_sz ();@@ -487,6 +675,11 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq) }pthread_spin_unlock (&que->qlock); + +pthread_spin_lock (&cntx->fqlock); +bnxt_re_fque_del_node (&qp->snode); +bnxt_re_fque_del_node (&qp->rnode); +pthread_spin_unlock (&cntx->fqlock); }void bnxt_re_cq_event (struct ibv_cq *ibvcq)@@ -679,6 +872,8 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, cap->max_rsge = attr->cap.max_recv_sge; cap->max_inline = attr->cap.max_inline_data; cap->sqsig = attr->sq_sig_all; +fque_init_node (&qp->snode); +fque_init_node (&qp->rnode);return &qp->ibvqp; failcmd: --1.8.3.1
Quoted 4 lines
Quoted 4 lines
--
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
--
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): CANjDDBgPrPPDBOy9N4X=XdU9AUTFpL2pE9-9kPvqAcYj09vDLA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions
Quoted 128 lines · Devesh Sharma
Quoted 118 lines · Leon Romanovsky
Quoted 117 lines · Devesh Sharma
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 thecon_idxreported.
Step-3: Report the completion with actual error to consumer, and
without bothering about thecon_idxreported 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
-- Usedccan/list.hinstead.--- 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.hproviders/bnxt_re/flush.h new file +61
-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; +} +Quoted 8 lines
providers/bnxt_re/flush.h line 67
Quoted 6 lines
providers/bnxt_re/flush.h new file +6
-0+static inline void fque_del_node (struct bnxt_re_fque_node *entry) +{ + entry->valid = false; +list_del (&entry->list); +} +I don't see the point of these wrappers.
Quoted 3 lines
Wanted to keep "
entry->valid" as a property of list element rather mixing it in the QP structure to keep things clean. Thus, could not resist to keep those.
It looks like list == NULL can do the trick.
Thanks
A message that is not in the archive (sent off-list or not yet received): 20170319081258.GR2079-U/[email protected]
Re: [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions
Hi Leon,
Will it okay if I revisit this change as a bug fix I need to validate the entire scheme with the suggested change.
Quoted 129 lines · Leon Romanovsky
Quoted 128 lines · Devesh Sharma
Quoted 126 lines · Leon Romanovsky
Quoted 113 lines · Devesh Sharma
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 thecon_idxreported.
Step-3: Report the completion with actual error to consumer, and
without bothering about thecon_idxreported 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
-- Usedccan/list.hinstead.--- 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.hproviders/bnxt_re/flush.h new file +57
-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) +{providers/bnxt_re/flush.h line 67
Quoted 10 lines
providers/bnxt_re/flush.h new file +10
-0+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); +} +I don't see the point of these wrappers.
Quoted 7 lines
Quoted 3 lines
Wanted to keep "
entry->valid" as a property of list element rather mixing it in the QP structure to keep things clean. Thus, could not resist to keep those.It looks like list == NULL can do the trick.
Thanks
--
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): CANjDDBiLnAhJWGfJ2TfJ=3_RoQW_KrfDBkxcSp586JuEL4hQXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [rdma-core v3 5/9] libbnxt_re: Allow apps to poll for flushed completions
Quoted 4 lines · Devesh Sharma
Hi Leon,
Will it okay if I revisit this change as a bug fix I need to validate the entire scheme with the suggested change.
Our past experience shows that developers tend to lost interest and disappear once they submitted their code.
I'm not saying that you are one of such developers, but would be happy to see fixed code before actually merging.
Thanks
Quoted 138 lines · Leon Romanovsky
Quoted 136 lines · Devesh Sharma
Quoted 128 lines · Leon Romanovsky
Quoted 118 lines · Devesh Sharma
Quoted 117 lines
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 thecon_idxreported.
Step-3: Report the completion with actual error to consumer, and
without bothering about thecon_idxreported 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
-- Usedccan/list.hinstead.--- 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 | 243 ++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 320 insertions(+), 24 deletions(-) create mode 100644 providers/bnxt_re/flush.hproviders/bnxt_re/flush.h new file +61
-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; +} +Quoted 8 lines
providers/bnxt_re/flush.h line 67
Quoted 6 lines
providers/bnxt_re/flush.h new file +6
-0+static inline void fque_del_node (struct bnxt_re_fque_node *entry) +{ + entry->valid = false; +list_del (&entry->list); +} +I don't see the point of these wrappers.
Quoted 3 lines
Wanted to keep "
entry->valid" as a property of list element rather mixing it in the QP structure to keep things clean. Thus, could not resist to keep those.It looks like list == NULL can do the trick.
Thanks
PATCH v3 6/9 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 | 92 ++++++++++++++++++++++++++++++++++------- 4 files changed, 113 insertions(+), 15 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 {__u32 indx;__u32 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 -15
135 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 v3 7/9 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 v3 8/9 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.
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/memory.h | 10 +++++++ providers/bnxt_re/verbs.c | 58 +++++++++++++++++++++++++++++++++++------ 4 files changed, 69 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/memory.h +10 -0
@@ -83,6 +83,16 @@ static inline void iowrite32(__u32 *dst, uint32_t *src) *(volatile __u32 *)dst = *src; } +static inline __u32 upper_32_bits (uint64_t n) +{ +return (__u32)((n >>16 ) >>16 ); +} + +static inline __u32 lower_32_bits (uint64_t n) +{ +return (__u32)(n &0xFFFFFFFFUL ); +} +/* Basic queue operation */ static inline uint32_t bnxt_re_is_que_full (struct bnxt_re_queue *que) {
providers/bnxt_re/verbs.c +50 -8
89 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): 1489574253-20300-9-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [rdma-core v3 8/9] libbnxt_re: Add support for atomic operations
Quoted 99 lines · Devesh Sharma
This patch adds support for compare-and-swap and fetch-and-add atomic operations in user library.
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/memory.h | 10 +++++++ providers/bnxt_re/verbs.c | 58 +++++++++++++++++++++++++++++++++++------ 4 files changed, 69 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/memory.h +10
-0@@ -83,6 +83,16 @@ static inline void iowrite32(__u32 *dst, uint32_t *src) *(volatile __u32 *)dst = *src; } +static inline __u32 upper_32_bits (uint64_t n) +{ +return (__u32)((n >>16 ) >>16 ); +} + +static inline __u32 lower_32_bits (uint64_t n) +{ +return (__u32)(n &0xFFFFFFFFUL ); +} +/* Basic queue operation */ static inline uint32_t bnxt_re_is_que_full (struct bnxt_re_queue *que) {providers/bnxt_re/verbs.c +10
-0@@ -1068,6 +1068,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) {@@ -1116,6 +1119,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 )); +int len;
providers/bnxt_re/verbs.c static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, · line 1138
Quoted 10 lines
providers/bnxt_re/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); +
Sorry for my question, but why do you need to separate uint64_t variable to two __u32? Why can't you declare one __u64?
Quoted 68 lines
providers/bnxt_re/verbs.c +30
-9+return len; +} + +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 )); +int 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; +} +int bnxt_re_post_send (struct ibv_qp *ibvqp,struct ibv_send_wr *wr,struct ibv_send_wr **bad) {@@ -1169,27 +1210,28 @@ 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 ;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);break ;default : - ret =EINVAL ; + bytes = -EINVAL ;break ; } -if (ret) { +if (bytes <0 ) { + ret = (bytes == -EINVAL ) ?EINVAL :ENOMEM ; *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
A message that is not in the archive (sent off-list or not yet received): 20170315191515.GH2079-U/[email protected]
Re: [rdma-core v3 8/9] libbnxt_re: Add support for atomic operations
Quoted 105 lines · Leon Romanovsky
Quoted 104 lines · Devesh Sharma
This patch adds support for compare-and-swap and fetch-and-add atomic operations in user library.
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/memory.h | 10 +++++++ providers/bnxt_re/verbs.c | 58 +++++++++++++++++++++++++++++++++++------ 4 files changed, 69 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/memory.h +10
-0@@ -83,6 +83,16 @@ static inline void iowrite32(__u32 *dst, uint32_t *src) *(volatile __u32 *)dst = *src; } +static inline __u32 upper_32_bits (uint64_t n) +{ +return (__u32)((n >>16 ) >>16 ); +} + +static inline __u32 lower_32_bits (uint64_t n) +{ +return (__u32)(n &0xFFFFFFFFUL ); +} +/* Basic queue operation */ static inline uint32_t bnxt_re_is_que_full (struct bnxt_re_queue *que) {providers/bnxt_re/verbs.c +15
-0@@ -1068,6 +1068,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) {@@ -1116,6 +1119,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 )); +int 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);
Quoted 8 lines
providers/bnxt_re/verbs.c static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, · line 1138
Quoted 5 lines
providers/bnxt_re/verbs.c +5
-0+ 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); +Sorry for my question, but why do you need to separate
uint64_tvariable to two__u32? Why can't you declare one__u64?
It may help 32 bit CPU during byte order conversion.
Quoted 65 lines
Quoted 65 lines
providers/bnxt_re/verbs.c +30
-9+return len; +} + +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 )); +int 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; +} +int bnxt_re_post_send (struct ibv_qp *ibvqp,struct ibv_send_wr *wr,struct ibv_send_wr **bad) {@@ -1169,27 +1210,28 @@ 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 ;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);break ;default : - ret =EINVAL ; + bytes = -EINVAL ;break ; } -if (ret) { +if (bytes <0 ) { + ret = (bytes == -EINVAL ) ?EINVAL :ENOMEM ; *bad = wr;break ; } --1.8.3.1
Quoted 4 lines
Quoted 4 lines
--
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
--
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): CANjDDBjGCCc8MLLQ3jhToWyc0Z+Qm3pYejz3BrMrRketDdZbEw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [rdma-core v3 8/9] libbnxt_re: Add support for atomic operations
Quoted 27 lines · Devesh Sharma
Quoted 17 lines · Leon Romanovsky
Quoted 16 lines · Devesh Sharma
providers/bnxt_re/verbs.c +12
-0@@ -1116,6 +1119,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 )); +int 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);Quoted 8 lines
providers/bnxt_re/verbs.c static int bnxt_re_build_rdma_sqe(struct bnxt_re_qp *qp, void *wqe, · line 1138
Quoted 5 lines
providers/bnxt_re/verbs.c +5
-0+ 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); +Sorry for my question, but why do you need to separate
uint64_tvariable to two__u32? Why can't you declare one__u64?
Quoted 1 line
It may help 32 bit CPU during byte order conversion.
Does that mean that you consider optimizing for 32-bit CPUs more important than optimizing for 64-bit CPUs? Does this also mean that you expect that the macros you introduced in your driver to be more efficient than the glibc endianness conversion macros? Sorry but this sounds like a weird explanation to me. I agree with Leon that it would be a significant improvement if 64-bit data types would be used instead of using numerous lower_32_bits() / upper_32_bits() calls.
Bart.--
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]
Re: [rdma-core v3 8/9] libbnxt_re: Add support for atomic operations
Quoted 6 lines · Bart Van Assche
Does that mean that you consider optimizing for 32-bit CPUs more important than optimizing for 64-bit CPUs? Does this also mean that you expect that the macros you introduced in your driver to be more efficient than the glibc endianness conversion macros? Sorry but this sounds like a weird explanation to me. I agree with Leon that it would be a significant improvement if 64-bit data types would be used instead of using numerous
lower_32_bits()/upper_32_bits()calls.
I actually think this is all just wrong.
For instance looking at bnxt_re_atomic I see it is written to a wqe/sqe buf, which come from here:
sqe = (void *)(sq->va + (sq->tail * sq->stride));
Which suggests it is DMA'd from the NIC, and I suspect it is 64 bit aligned.
The driver does a whole struct 64 bit by 64 bit byteswap on every sqe:
bnxt_re_host_to_le64((uint64_t *)sqe, sq->stride);
Which means if we look at BE then this struct:
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;
};becomes
struct bnxt_re_atomic {
__le32 rva_hi;
__le32 rva_lo;
__le32 swp_dt_hi;
__le32 swp_dt_lo;
__le32 cmp_dt_hi;
__le32 cmp_dt_lo;
};Which doesn't look like it will work right to me.
I think Bart is basically right, you need to elimiante all of the calls to bnxt_re_host_to_le64 and related, directly use __leXX in your DMA structures and byte swap when storing.
For instance, if instead you do:
struct bnxt_re_atomic {
__le64 rva;
__le64 swp_dt;
__le64 cmp_dt;
};Then things will just work out properly and you will end up with the same memory image for DMA on BE or LE platforms.
Does the kernel driver have the same problem?
Also, please use the kernel ABI file directly (see how mw_pvrdma-abi.h makes this happen) as much as possible, drop the copies out of providers/bnxt_re/bnxt_re-abi.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
PATCH v3 9/9 libbnxt_re: Add support for SRQ in user lib
In reply to a message not in the archiveThis 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/bnxt_re/bnxt_re-abi.h | 15 +++ providers/bnxt_re/db.c | 18 +++ providers/bnxt_re/main.h | 32 ++++- providers/bnxt_re/verbs.c | 259 ++++++++++++++++++++++++++++++++++------ 4 files changed, 286 insertions(+), 38 deletions(-)
providers/bnxt_re/bnxt_re-abi.h +15 -0
@@ -214,6 +214,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;
@@ -261,6 +262,7 @@ struct bnxt_re_term_cqe {__u64 rsvd1; }; +/* QP */ struct bnxt_re_qp_req {struct ibv_create_qp cmd;__u64 qpsva;
@@ -352,6 +354,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;
providers/bnxt_re/db.c +18 -0
@@ -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/bnxt_re/main.h +28 -4
@@ -76,10 +76,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;
@@ -96,6 +92,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);
@@ -211,6 +223,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/bnxt_re/verbs.c +225 -34
348 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): 1489574253-20300-10-git-send-email-devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]
Re: [rdma-core v3 9/9] libbnxt_re: Add support for SRQ in user lib
Quoted 299 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/bnxt_re/bnxt_re-abi.h | 15 +++ providers/bnxt_re/db.c | 18 +++ providers/bnxt_re/main.h | 32 ++++- providers/bnxt_re/verbs.c | 259 ++++++++++++++++++++++++++++++++++------ 4 files changed, 286 insertions(+), 38 deletions(-)providers/bnxt_re/bnxt_re-abi.h +15
-0@@ -214,6 +214,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;@@ -261,6 +262,7 @@ struct bnxt_re_term_cqe {__u64 rsvd1; }; +/* QP */ struct bnxt_re_qp_req {struct ibv_create_qp cmd;__u64 qpsva;@@ -352,6 +354,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;providers/bnxt_re/db.c +18
-0@@ -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/bnxt_re/main.h +28
-4@@ -76,10 +76,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;@@ -96,6 +92,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);@@ -211,6 +223,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/bnxt_re/verbs.c +37
-29@@ -339,36 +339,40 @@ static uint8_t bnxt_re_poll_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc,static int bnxt_re_poll_err_rcqe (struct bnxt_re_qp *qp,struct ibv_wc *ibvwc,struct bnxt_re_bcqe *hdr,void *cqe) { -struct bnxt_re_queue *rq = qp->rqq; +struct bnxt_re_queue *rq;struct bnxt_re_wrid *rwrid;struct bnxt_re_cq *rcq;struct bnxt_re_context *cntx; -uint32_t head = rq->head;uint8_t status; rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); cntx =to_bnxt_re_context (rcq->ibvcq.context); - rwrid = &qp->rwrid[head]; +if (!qp->srq) { + rq = qp->rqq; + rwrid = &qp->rwrid[rq->head]; + }else { + rq = qp->srq->srqq; + rwrid = &qp->srq->srwrid[rq->head]; + } + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ;/* skip h/w flush errors */ if (status ==BNXT_RE_RSP_ST_HW_FLUSH )return 0 ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); -/* TODO: Add SRQ Processing here */ -if (qp->rqq) { - ibvwc->wr_id = rwrid->wrid; - ibvwc->qp_num = qp->qpid; - ibvwc->opcode =IBV_WC_RECV ; - ibvwc->byte_len =0 ; - ibvwc->wc_flags =0 ; -if (qp->qptyp ==IBV_QPT_UD ) - ibvwc->src_qp =0 ; + ibvwc->wr_id = rwrid->wrid; + ibvwc->qp_num = qp->qpid; + ibvwc->opcode =IBV_WC_RECV ; + ibvwc->byte_len =0 ; + ibvwc->wc_flags =0 ; +if (qp->qptyp ==IBV_QPT_UD ) + ibvwc->src_qp =0 ; +bnxt_re_incr_head (rq); -bnxt_re_incr_head (qp->rqq); -if (qp->qpst !=IBV_QPS_ERR ) - qp->qpst =IBV_QPS_ERR ; +if (!qp->srq) {pthread_spin_lock (&cntx->fqlock);bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode);pthread_spin_unlock (&cntx->fqlock);@@ -396,14 +400,19 @@ static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp,struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr, void *cqe) { - struct bnxt_re_queue *rq = qp->rqq; + struct bnxt_re_queue *rq;struct bnxt_re_wrid *rwrid;struct bnxt_re_rc_cqe *rcqe; -uint32_t head = rq->head;uint8_t flags, is_imm, is_rdma; rcqe = cqe; - rwrid = &qp->rwrid[head]; +if (!qp->srq) { + rq = qp->rqq; + rwrid = &qp->rwrid[rq->head]; + }else { + rq = qp->srq->srqq; + rwrid = &qp->srq->srwrid[rq->head]; + } ibvwc->status =IBV_WC_SUCCESS ; ibvwc->wr_id = rwrid->wrid;@@ -512,9 +521,6 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc) qp = (struct bnxt_re_qp *)(uintptr_t )rcqe->qp_handle;if (!qp)break ;/*stale cqe. should be rung.*/ -if (qp->srq) - goto bail;/*TODO: Add SRQ poll */ - pcqe =bnxt_re_poll_rcqe (qp, wc, cqe, &cnt);break ;case BNXT_RE_WC_TYPE_RECV_RAW :@@ -554,7 +560,7 @@ skipp_real:if (hw_polled)bnxt_re_ring_cq_db (cq); -bail: +return dqed; }@@ -752,9 +758,7 @@ static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp, 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 { +if (!attr->srq) { qp->rqq =calloc (1 ,sizeof (struct bnxt_re_queue ));if (!qp->rqq) {free (qp->sqq);@@ -767,10 +771,12 @@ static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp,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->rqq) { +if (qp->rwrid) +free (qp->rwrid); +pthread_spin_destroy (&qp->rqq->qlock); +bnxt_re_free_aligned (qp->rqq); + }if (qp->swrid)free (qp->swrid);@@ -881,6 +887,8 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, qp->qpst =IBV_QPS_RESET ; qp->scq =to_bnxt_re_cq (attr->send_cq); qp->rcq =to_bnxt_re_cq (attr->recv_cq); +if (attr->srq) + qp->srq =to_bnxt_re_srq (attr->srq); qp->udpi = &cntx->udpi;/* Save/return the altered Caps. */ attr->cap.max_send_wr = cap->max_swr;
providers/bnxt_re/verbs.c int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, · line 1335
Quoted 9 lines
providers/bnxt_re/verbs.c +6
-0@@ -1319,32 +1327,215 @@ int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,return 0 ; } +static void bnxt_re_srq_free_queue_ptr (struct bnxt_re_srq *srq) +{ +if (srq && srq->srqq) +free (srq->srqq); +if (srq) +free (srq);
No need to check for NULL before calling to free().
Quoted 128 lines
providers/bnxt_re/verbs.c +110
-3+} + +static struct bnxt_re_srq *bnxt_re_srq_alloc_queue_ptr (void ) +{ +struct bnxt_re_srq *srq; + + srq =calloc (1 ,sizeof (struct bnxt_re_srq )); +if (!srq) +return NULL ; + + srq->srqq =calloc (1 ,sizeof (struct bnxt_re_queue )); +if (!srq->srqq) { +free (srq); +return NULL ; + } + +return srq; +} + +static void bnxt_re_srq_free_queue (struct bnxt_re_srq *srq) +{ +if (srq->srwrid) +free (srq->srwrid); +pthread_spin_destroy (&srq->srqq->qlock); +bnxt_re_free_aligned (srq->srqq); +} + +static int bnxt_re_srq_alloc_queue (struct bnxt_re_srq *srq, +struct ibv_srq_init_attr *attr, +uint32_t pg_size) +{ +struct bnxt_re_queue *que; +int ret; + + que = srq->srqq; + que->depth =roundup_pow_of_two (attr->attr.max_wr +1 ); + que->stride =bnxt_re_get_srqe_sz (); + ret =bnxt_re_alloc_aligned (que, pg_size); +if (ret) + goto bail; +pthread_spin_init (&que->qlock,PTHREAD_PROCESS_PRIVATE ); +/* For SRQ only bnxt_re_wrid.wrid is used. */ + srq->srwrid =calloc (que->depth,sizeof (struct bnxt_re_wrid )); +if (!srq->srwrid) { + ret = -ENOMEM ; + goto bail; + } +/*TODO: update actual max depth. */ +return 0 ; +bail: +bnxt_re_srq_free_queue (srq); +return ret; +} +struct ibv_srq *bnxt_re_create_srq (struct ibv_pd *ibvpd,struct ibv_srq_init_attr *attr) { +struct bnxt_re_srq *srq; +struct bnxt_re_srq_req cmd; +struct bnxt_re_srq_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); +int ret; + +/*TODO: Check max limit on queue depth and sge.*/ + srq =bnxt_re_srq_alloc_queue_ptr (); +if (!srq) + goto fail; + +if (bnxt_re_srq_alloc_queue (srq, attr, dev->pg_size)) + goto fail; + + cmd.srqva = (uintptr_t )srq->srqq->va; + cmd.srq_handle = (uintptr_t )srq; + ret =ibv_cmd_create_srq (ibvpd, &srq->ibvsrq, attr, + &cmd.cmd,sizeof (cmd), + &resp.resp,sizeof (resp)); +if (ret) + goto fail; + + srq->srqid = resp.srqid; + srq->udpi = &cntx->udpi; + srq->cap.max_wr = srq->srqq->depth; + srq->cap.max_sge = attr->attr.max_sge; + srq->cap.srq_limit = attr->attr.srq_limit; + srq->pre_count =0 ; + +return &srq->ibvsrq; +fail: +bnxt_re_srq_free_queue_ptr (srq);return NULL ; }int bnxt_re_modify_srq (struct ibv_srq *ibvsrq,struct ibv_srq_attr *attr, -int init_attr) +int attr_mask) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +struct ibv_modify_srq cmd; +int status =0 ; + + status =ibv_cmd_modify_srq (ibvsrq, attr, attr_mask, + &cmd,sizeof (cmd)); +if (!status && ((attr_mask &IBV_SRQ_LIMIT ) && + (srq->cap.srq_limit != attr->srq_limit))) { + srq->cap.srq_limit = attr->srq_limit; + } + +return status; }int bnxt_re_destroy_srq (struct ibv_srq *ibvsrq) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +int ret; + + ret =ibv_cmd_destroy_srq (ibvsrq); +if (ret) +return ret; +bnxt_re_srq_free_queue (srq); +bnxt_re_srq_free_queue_ptr (srq); + +return 0 ; }int bnxt_re_query_srq (struct ibv_srq *ibvsrq,struct ibv_srq_attr *attr)
providers/bnxt_re/verbs.c int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, · line 1469
Quoted 10 lines
providers/bnxt_re/verbs.c +8
-1{ -return -ENOSYS ; +struct ibv_query_srq cmd; +int status; + + status =ibv_cmd_query_srq (ibvsrq, attr, &cmd,sizeof (cmd)); +if (status) +return status; + +return 0 ;
You can return status directly without need of if(..).
Quoted 80 lines
providers/bnxt_re/verbs.c +64
-2+} + +static int bnxt_re_build_srqe (struct bnxt_re_srq *srq, +struct ibv_recv_wr *wr,void *srqe) +{ +struct bnxt_re_brqe *hdr = srqe; +struct bnxt_re_rqe *rwr; +struct bnxt_re_sge *sge; +struct bnxt_re_wrid *wrid; +int wqe_sz, len; + + rwr = (srqe +sizeof (struct bnxt_re_brqe )); + sge = (srqe +bnxt_re_get_srqe_hdr_sz ()); + wrid = &srq->srwrid[srq->srqq->tail]; + + len =bnxt_re_build_sge (sge, wr->sg_list, wr->num_sge, false); + hdr->rsv_ws_fl_wt =BNXT_RE_WR_OPCD_RECV ; + wqe_sz = wr->num_sge + (bnxt_re_get_srqe_hdr_sz () >>4 );/* 16B align */ + hdr->rsv_ws_fl_wt |= ((wqe_sz &BNXT_RE_HDR_WS_MASK ) << +BNXT_RE_HDR_WS_SHIFT ); + rwr->wrid = srq->srqq->tail; + +/* Fill wrid */ + wrid->wrid = wr->wr_id; + wrid->bytes = len;/* N.A. for RQE */ + wrid->sig =0 ;/* N.A. for RQE */ + +return len; }int bnxt_re_post_srq_recv (struct ibv_srq *ibvsrq,struct ibv_recv_wr *wr,struct ibv_recv_wr **bad) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +struct bnxt_re_queue *rq = srq->srqq; +void *srqe; +int ret; + +pthread_spin_lock (&rq->qlock); +while (wr) { +if (bnxt_re_is_que_full (rq) || + wr->num_sge > srq->cap.max_sge) { + *bad = wr; +pthread_spin_unlock (&rq->qlock); +return ENOMEM ; + } + + srqe = (void *)(rq->va + (rq->tail * rq->stride)); +memset (srqe,0 ,bnxt_re_get_srqe_sz ()); + ret =bnxt_re_build_srqe (srq, wr, srqe); +if (ret <0 ) { +pthread_spin_unlock (&rq->qlock); + *bad = wr; +return ENOMEM ; + } + +bnxt_re_host_to_le64 ((uint64_t *)srqe, rq->stride); +bnxt_re_incr_tail (rq); + wr = wr->next; +bnxt_re_ring_srq_db (srq); +if ((srq->pre_count < srq->srqq->depth) && + (++srq->pre_count > srq->cap.srq_limit)) { + srq->pre_count = srq->srqq->depth; +bnxt_re_ring_srq_arm (srq); + } + } +pthread_spin_unlock (&rq->qlock); + +return 0 ; }struct ibv_ah *bnxt_re_create_ah (struct ibv_pd *ibvpd,struct ibv_ah_attr *attr) --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): 20170315192408.GJ2079-U/[email protected]
Re: [rdma-core v3 9/9] libbnxt_re: Add support for SRQ in user lib
Okay, I will fix it in v4.
Quoted 525 lines · Leon Romanovsky
Quoted 299 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/bnxt_re/bnxt_re-abi.h | 15 +++ providers/bnxt_re/db.c | 18 +++ providers/bnxt_re/main.h | 32 ++++- providers/bnxt_re/verbs.c | 259 ++++++++++++++++++++++++++++++++++------ 4 files changed, 286 insertions(+), 38 deletions(-)providers/bnxt_re/bnxt_re-abi.h +15
-0@@ -214,6 +214,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;@@ -261,6 +262,7 @@ struct bnxt_re_term_cqe {__u64 rsvd1; }; +/* QP */ struct bnxt_re_qp_req {struct ibv_create_qp cmd;__u64 qpsva;@@ -352,6 +354,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;providers/bnxt_re/db.c +18
-0@@ -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/bnxt_re/main.h +28
-4@@ -76,10 +76,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;@@ -96,6 +92,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);@@ -211,6 +223,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/bnxt_re/verbs.c +37
-29@@ -339,36 +339,40 @@ static uint8_t bnxt_re_poll_scqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc,static int bnxt_re_poll_err_rcqe (struct bnxt_re_qp *qp,struct ibv_wc *ibvwc,struct bnxt_re_bcqe *hdr,void *cqe) { -struct bnxt_re_queue *rq = qp->rqq; +struct bnxt_re_queue *rq;struct bnxt_re_wrid *rwrid;struct bnxt_re_cq *rcq;struct bnxt_re_context *cntx; -uint32_t head = rq->head;uint8_t status; rcq =to_bnxt_re_cq (qp->ibvqp.recv_cq); cntx =to_bnxt_re_context (rcq->ibvcq.context); - rwrid = &qp->rwrid[head]; +if (!qp->srq) { + rq = qp->rqq; + rwrid = &qp->rwrid[rq->head]; + }else { + rq = qp->srq->srqq; + rwrid = &qp->srq->srwrid[rq->head]; + } + status = (hdr->flg_st_typ_ph >>BNXT_RE_BCQE_STATUS_SHIFT ) &BNXT_RE_BCQE_STATUS_MASK ;/* skip h/w flush errors */ if (status ==BNXT_RE_RSP_ST_HW_FLUSH )return 0 ; + ibvwc->status =bnxt_re_to_ibv_wc_status (status, false); -/* TODO: Add SRQ Processing here */ -if (qp->rqq) { - ibvwc->wr_id = rwrid->wrid; - ibvwc->qp_num = qp->qpid; - ibvwc->opcode =IBV_WC_RECV ; - ibvwc->byte_len =0 ; - ibvwc->wc_flags =0 ; -if (qp->qptyp ==IBV_QPT_UD ) - ibvwc->src_qp =0 ; + ibvwc->wr_id = rwrid->wrid; + ibvwc->qp_num = qp->qpid; + ibvwc->opcode =IBV_WC_RECV ; + ibvwc->byte_len =0 ; + ibvwc->wc_flags =0 ; +if (qp->qptyp ==IBV_QPT_UD ) + ibvwc->src_qp =0 ; +bnxt_re_incr_head (rq); -bnxt_re_incr_head (qp->rqq); -if (qp->qpst !=IBV_QPS_ERR ) - qp->qpst =IBV_QPS_ERR ; +if (!qp->srq) {pthread_spin_lock (&cntx->fqlock);bnxt_re_fque_add_node (&rcq->rfhead, &qp->rnode);pthread_spin_unlock (&cntx->fqlock);@@ -396,14 +400,19 @@ static void bnxt_re_poll_success_rcqe(struct bnxt_re_qp *qp,struct ibv_wc *ibvwc, struct bnxt_re_bcqe *hdr, void *cqe) { - struct bnxt_re_queue *rq = qp->rqq; + struct bnxt_re_queue *rq;struct bnxt_re_wrid *rwrid;struct bnxt_re_rc_cqe *rcqe; -uint32_t head = rq->head;uint8_t flags, is_imm, is_rdma; rcqe = cqe; - rwrid = &qp->rwrid[head]; +if (!qp->srq) { + rq = qp->rqq; + rwrid = &qp->rwrid[rq->head]; + }else { + rq = qp->srq->srqq; + rwrid = &qp->srq->srwrid[rq->head]; + } ibvwc->status =IBV_WC_SUCCESS ; ibvwc->wr_id = rwrid->wrid;@@ -512,9 +521,6 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc) qp = (struct bnxt_re_qp *)(uintptr_t )rcqe->qp_handle;if (!qp)break ;/*stale cqe. should be rung.*/ -if (qp->srq) - goto bail;/*TODO: Add SRQ poll */ - pcqe =bnxt_re_poll_rcqe (qp, wc, cqe, &cnt);break ;case BNXT_RE_WC_TYPE_RECV_RAW :@@ -554,7 +560,7 @@ skipp_real:if (hw_polled)bnxt_re_ring_cq_db (cq); -bail: +return dqed; }@@ -752,9 +758,7 @@ static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp, 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 { +if (!attr->srq) { qp->rqq =calloc (1 ,sizeof (struct bnxt_re_queue ));if (!qp->rqq) {free (qp->sqq);@@ -767,10 +771,12 @@ static int bnxt_re_alloc_queue_ptr(struct bnxt_re_qp *qp,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->rqq) { +if (qp->rwrid) +free (qp->rwrid); +pthread_spin_destroy (&qp->rqq->qlock); +bnxt_re_free_aligned (qp->rqq); + }if (qp->swrid)free (qp->swrid);@@ -881,6 +887,8 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd, qp->qpst =IBV_QPS_RESET ; qp->scq =to_bnxt_re_cq (attr->send_cq); qp->rcq =to_bnxt_re_cq (attr->recv_cq); +if (attr->srq) + qp->srq =to_bnxt_re_srq (attr->srq); qp->udpi = &cntx->udpi;/* Save/return the altered Caps. */ attr->cap.max_send_wr = cap->max_swr;providers/bnxt_re/verbs.c int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, · line 1335
Quoted 9 lines
providers/bnxt_re/verbs.c +6
-0@@ -1319,32 +1327,215 @@ int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr,return 0 ; } +static void bnxt_re_srq_free_queue_ptr (struct bnxt_re_srq *srq) +{ +if (srq && srq->srqq) +free (srq->srqq); +if (srq) +free (srq);No need to check for NULL before calling to
free().Quoted 128 lines
providers/bnxt_re/verbs.c +110
-3+} + +static struct bnxt_re_srq *bnxt_re_srq_alloc_queue_ptr (void ) +{ +struct bnxt_re_srq *srq; + + srq =calloc (1 ,sizeof (struct bnxt_re_srq )); +if (!srq) +return NULL ; + + srq->srqq =calloc (1 ,sizeof (struct bnxt_re_queue )); +if (!srq->srqq) { +free (srq); +return NULL ; + } + +return srq; +} + +static void bnxt_re_srq_free_queue (struct bnxt_re_srq *srq) +{ +if (srq->srwrid) +free (srq->srwrid); +pthread_spin_destroy (&srq->srqq->qlock); +bnxt_re_free_aligned (srq->srqq); +} + +static int bnxt_re_srq_alloc_queue (struct bnxt_re_srq *srq, +struct ibv_srq_init_attr *attr, +uint32_t pg_size) +{ +struct bnxt_re_queue *que; +int ret; + + que = srq->srqq; + que->depth =roundup_pow_of_two (attr->attr.max_wr +1 ); + que->stride =bnxt_re_get_srqe_sz (); + ret =bnxt_re_alloc_aligned (que, pg_size); +if (ret) + goto bail; +pthread_spin_init (&que->qlock,PTHREAD_PROCESS_PRIVATE ); +/* For SRQ only bnxt_re_wrid.wrid is used. */ + srq->srwrid =calloc (que->depth,sizeof (struct bnxt_re_wrid )); +if (!srq->srwrid) { + ret = -ENOMEM ; + goto bail; + } +/*TODO: update actual max depth. */ +return 0 ; +bail: +bnxt_re_srq_free_queue (srq); +return ret; +} +struct ibv_srq *bnxt_re_create_srq (struct ibv_pd *ibvpd,struct ibv_srq_init_attr *attr) { +struct bnxt_re_srq *srq; +struct bnxt_re_srq_req cmd; +struct bnxt_re_srq_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); +int ret; + +/*TODO: Check max limit on queue depth and sge.*/ + srq =bnxt_re_srq_alloc_queue_ptr (); +if (!srq) + goto fail; + +if (bnxt_re_srq_alloc_queue (srq, attr, dev->pg_size)) + goto fail; + + cmd.srqva = (uintptr_t )srq->srqq->va; + cmd.srq_handle = (uintptr_t )srq; + ret =ibv_cmd_create_srq (ibvpd, &srq->ibvsrq, attr, + &cmd.cmd,sizeof (cmd), + &resp.resp,sizeof (resp)); +if (ret) + goto fail; + + srq->srqid = resp.srqid; + srq->udpi = &cntx->udpi; + srq->cap.max_wr = srq->srqq->depth; + srq->cap.max_sge = attr->attr.max_sge; + srq->cap.srq_limit = attr->attr.srq_limit; + srq->pre_count =0 ; + +return &srq->ibvsrq; +fail: +bnxt_re_srq_free_queue_ptr (srq);return NULL ; }int bnxt_re_modify_srq (struct ibv_srq *ibvsrq,struct ibv_srq_attr *attr, -int init_attr) +int attr_mask) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +struct ibv_modify_srq cmd; +int status =0 ; + + status =ibv_cmd_modify_srq (ibvsrq, attr, attr_mask, + &cmd,sizeof (cmd)); +if (!status && ((attr_mask &IBV_SRQ_LIMIT ) && + (srq->cap.srq_limit != attr->srq_limit))) { + srq->cap.srq_limit = attr->srq_limit; + } + +return status; }int bnxt_re_destroy_srq (struct ibv_srq *ibvsrq) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +int ret; + + ret =ibv_cmd_destroy_srq (ibvsrq); +if (ret) +return ret; +bnxt_re_srq_free_queue (srq); +bnxt_re_srq_free_queue_ptr (srq); + +return 0 ; }int bnxt_re_query_srq (struct ibv_srq *ibvsrq,struct ibv_srq_attr *attr)providers/bnxt_re/verbs.c int bnxt_re_post_recv(struct ibv_qp *ibvqp, struct ibv_recv_wr *wr, · line 1469
Quoted 10 lines
providers/bnxt_re/verbs.c +8
-1{ -return -ENOSYS ; +struct ibv_query_srq cmd; +int status; + + status =ibv_cmd_query_srq (ibvsrq, attr, &cmd,sizeof (cmd)); +if (status) +return status; + +return 0 ;You can return status directly without need of if(..).
Quoted 72 lines
providers/bnxt_re/verbs.c +64
-1+} + +static int bnxt_re_build_srqe (struct bnxt_re_srq *srq, +struct ibv_recv_wr *wr,void *srqe) +{ +struct bnxt_re_brqe *hdr = srqe; +struct bnxt_re_rqe *rwr; +struct bnxt_re_sge *sge; +struct bnxt_re_wrid *wrid; +int wqe_sz, len; + + rwr = (srqe +sizeof (struct bnxt_re_brqe )); + sge = (srqe +bnxt_re_get_srqe_hdr_sz ()); + wrid = &srq->srwrid[srq->srqq->tail]; + + len =bnxt_re_build_sge (sge, wr->sg_list, wr->num_sge, false); + hdr->rsv_ws_fl_wt =BNXT_RE_WR_OPCD_RECV ; + wqe_sz = wr->num_sge + (bnxt_re_get_srqe_hdr_sz () >>4 );/* 16B align */ + hdr->rsv_ws_fl_wt |= ((wqe_sz &BNXT_RE_HDR_WS_MASK ) << +BNXT_RE_HDR_WS_SHIFT ); + rwr->wrid = srq->srqq->tail; + +/* Fill wrid */ + wrid->wrid = wr->wr_id; + wrid->bytes = len;/* N.A. for RQE */ + wrid->sig =0 ;/* N.A. for RQE */ + +return len; }int bnxt_re_post_srq_recv (struct ibv_srq *ibvsrq,struct ibv_recv_wr *wr,struct ibv_recv_wr **bad) { -return -ENOSYS ; +struct bnxt_re_srq *srq =to_bnxt_re_srq (ibvsrq); +struct bnxt_re_queue *rq = srq->srqq; +void *srqe; +int ret; + +pthread_spin_lock (&rq->qlock); +while (wr) { +if (bnxt_re_is_que_full (rq) || + wr->num_sge > srq->cap.max_sge) { + *bad = wr; +pthread_spin_unlock (&rq->qlock); +return ENOMEM ; + } + + srqe = (void *)(rq->va + (rq->tail * rq->stride)); +memset (srqe,0 ,bnxt_re_get_srqe_sz ()); + ret =bnxt_re_build_srqe (srq, wr, srqe); +if (ret <0 ) { +pthread_spin_unlock (&rq->qlock); + *bad = wr; +return ENOMEM ; + } + +bnxt_re_host_to_le64 ((uint64_t *)srqe, rq->stride); +bnxt_re_incr_tail (rq); + wr = wr->next; +bnxt_re_ring_srq_db (srq); +if ((srq->pre_count < srq->srqq->depth) && + (++srq->pre_count > srq->cap.srq_limit)) { + srq->pre_count = srq->srqq->depth; +bnxt_re_ring_srq_arm (srq); + } + } +pthread_spin_unlock (&rq->qlock); + +return 0 ; }
Quoted 8 lines
Quoted 8 lines
providers/bnxt_re/verbs.c +0
-1struct ibv_ah *bnxt_re_create_ah (struct ibv_pd *ibvpd,struct ibv_ah_attr *attr) --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
--
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