Skip to contentSkip to conversation

Broadcom's user library update

PATCH Superseded Devesh Sharma 1 participant 7 messages Jun 15, 2021 InfiniBand

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Broadcom's user library update

The focus of this patch series is to move SQ and RQ wqe posting indices from 128B fixed stride to 16B aligned stride. This allows more flexibility in choosing wqe size.

v4 -> v5
- addressed few minor suggestion.
v3 -> v4
- fixed build warning
v2 -> V3
- Split the ABI change into separate patch
- committed ABI patch using standard rdma-core script.

Devesh Sharma (5):
Update kernel headers
bnxt_re/lib: Read wqe mode from the driver bnxt_re/lib: add a function to initialize software queue bnxt_re/lib: Use separate indices for shadow queue bnxt_re/lib: Move hardware queue to 16B aligned indices

 kernel-headers/rdma/bnxt_re-abi.h |   5 +-
 providers/bnxt_re/bnxt_re-abi.h   |   5 +
 providers/bnxt_re/db.c            |  10 +-
 providers/bnxt_re/main.c          |   4 +
 providers/bnxt_re/main.h          |  25 ++
 providers/bnxt_re/memory.h        |  37 ++-
 providers/bnxt_re/verbs.c         | 523 ++++++++++++++++++++----------
 7 files changed, 429 insertions(+), 180 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/5 Update kernel headers

To commit ?? ("RDMA/bnxt_re: update ABI to pass wqe-mode to user space").

---
 kernel-headers/rdma/bnxt_re-abi.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel-headers/rdma/bnxt_re-abi.h +4 -1
index dc52e3cf..52205ed2 100644
@@ -49,7 +49,8 @@
 #define BNXT_RE_CHIP_ID0_CHIP_MET_SFT		0x18
 
 enum {
-	BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL
+	BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL,
+	BNXT_RE_UCNTX_CMASK_HAVE_MODE = 0x02ULL
 };
 
 struct bnxt_re_uctx_resp {
@@ -62,6 +63,8 @@ struct bnxt_re_uctx_resp {
 	__aligned_u64 comp_mask;
 	__u32 chip_id0;
 	__u32 chip_id1;
+	__u32 mode;
+	__u32 rsvd1; /* padding */
 };
 
 /*
Signature · 1 line
2.25.1
#2 lore raw

PATCH v5 2/5 bnxt_re/lib: Read wqe mode from the driver

In reply to Devesh Sharma

During bnxt_re device context creation, read the wqe mode and store it in context structure and in the QP context structure. wqe mode would be required to change between fixed size wqe and non-fixed sized wqe modes of SQ/RQ in gen-p5 or newer devices.

---
 providers/bnxt_re/bnxt_re-abi.h | 5 +++++
 providers/bnxt_re/main.c        | 4 ++++
 providers/bnxt_re/main.h        | 2 ++
 providers/bnxt_re/verbs.c       | 1 +
 4 files changed, 12 insertions(+)
providers/bnxt_re/bnxt_re-abi.h +5 -0
index c82019e8..d138cd9c 100644
@@ -196,6 +196,11 @@ enum bnxt_re_ud_cqe_mask {
 	BNXT_RE_UD_CQE_SRCQPLO_SHIFT	= 0x30
 };
 
+enum bnxt_re_modes {
+	BNXT_RE_WQE_MODE_STATIC =	0x00,
+	BNXT_RE_WQE_MODE_VARIABLE =	0x01
+};
+
 struct bnxt_re_db_hdr {
 	__le32 indx;
 	__le32 typ_qid; /* typ: 4, qid:20*/
providers/bnxt_re/main.c +4 -0
index 1779e1ec..ee9edd7d 100644
@@ -158,6 +158,10 @@ static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev,
 					 BNXT_RE_CHIP_ID0_CHIP_MET_SFT) &
 					 0xFF;
 	}
+
+	if (resp.comp_mask & BNXT_RE_UCNTX_CMASK_HAVE_MODE)
+		cntx->wqe_mode = resp.mode;
+
 	pthread_spin_init(&cntx->fqlock, PTHREAD_PROCESS_PRIVATE);
 	/* mmap shared page. */
 	cntx->shpg = mmap(NULL, rdev->pg_size, PROT_READ | PROT_WRITE,
providers/bnxt_re/main.h +2 -0
index a63719e8..dc8166f2 100644
@@ -146,6 +146,7 @@ struct bnxt_re_qp {
 	uint64_t wqe_cnt;
 	uint16_t mtu;
 	uint16_t qpst;
+	uint32_t qpmode;
 	uint8_t qptyp;
 	/* irdord? */
 };
@@ -178,6 +179,7 @@ struct bnxt_re_context {
 	uint32_t max_srq;
 	struct bnxt_re_dpi udpi;
 	void *shpg;
+	uint32_t wqe_mode;
 	pthread_mutex_t shlock;
 	pthread_spinlock_t fqlock;
 };
providers/bnxt_re/verbs.c +1 -0
index fb2cf5ac..11c01574 100644
@@ -952,6 +952,7 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd,
 		goto fail;
 	/* alloc queues */
 	qp->cctx = &cntx->cctx;
+	qp->qpmode = cntx->wqe_mode & BNXT_RE_WQE_MODE_VARIABLE;
 	if (bnxt_re_alloc_queues(qp, attr, dev->pg_size))
 		goto failq;
 	/* Fill ibv_cmd */
Signature · 1 line
2.25.1
#3 lore raw

PATCH v5 3/5 bnxt_re/lib: add a function to initialize software queue

In reply to Devesh Sharma

Splitting the shadow software queue initialization into a separate function. Same is being called for both RQ and SQ during create QP.

---
 providers/bnxt_re/main.h  |  2 ++
 providers/bnxt_re/verbs.c | 65 ++++++++++++++++++++++++---------------
 2 files changed, 43 insertions(+), 24 deletions(-)
providers/bnxt_re/main.h +2 -0
index dc8166f2..71a449e3 100644
@@ -96,6 +96,8 @@ struct bnxt_re_wrid {
 	uint64_t wrid;
 	uint32_t bytes;
 	int next_idx;
+	uint32_t st_slot_idx;
+	uint8_t slots;
 	uint8_t sig;
 };
 
providers/bnxt_re/verbs.c +41 -24

116 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

PATCH v5 4/5 bnxt_re/lib: Use separate indices for shadow queue

In reply to Devesh Sharma

The shadow queue is used for wrid and flush wqe management. The indices used in this queue are independent to what is actually used by hardware. Thus, detaching the shadow queue indices from hardware queue indices. This even more useful when the hardware queue indices has alignment other than wqe boundary.

---
 providers/bnxt_re/main.h   |  20 ++++++
 providers/bnxt_re/memory.h |   8 +--
 providers/bnxt_re/verbs.c  | 128 ++++++++++++++++++++++---------------
 3 files changed, 101 insertions(+), 55 deletions(-)
providers/bnxt_re/main.h +20 -0
index 71a449e3..5d05dd85 100644
@@ -436,4 +436,24 @@ static inline void bnxt_re_change_cq_phase(struct bnxt_re_cq *cq)
 	if (!cq->cqq.head)
 		cq->phase = (~cq->phase & BNXT_RE_BCQE_PH_MASK);
 }
+
+static inline void *bnxt_re_get_swqe(struct bnxt_re_joint_queue *jqq,
+				     uint32_t *wqe_idx)
+{
+	if (wqe_idx)
+		*wqe_idx = jqq->start_idx;
+	return &jqq->swque[jqq->start_idx];
+}
+
+static inline void bnxt_re_jqq_mod_start(struct bnxt_re_joint_queue *jqq,
+					 uint32_t idx)
+{
+	jqq->start_idx = jqq->swque[idx].next_idx;
+}
+
+static inline void bnxt_re_jqq_mod_last(struct bnxt_re_joint_queue *jqq,
+					uint32_t idx)
+{
+	jqq->last_idx = jqq->swque[idx].next_idx;
+}
 #endif
providers/bnxt_re/memory.h +4 -4
index 75564c43..5bcdef9a 100644
@@ -97,14 +97,14 @@ static inline uint32_t bnxt_re_incr(uint32_t val, uint32_t max)
 	return (++val & (max - 1));
 }
 
-static inline void bnxt_re_incr_tail(struct bnxt_re_queue *que)
+static inline void bnxt_re_incr_tail(struct bnxt_re_queue *que, uint8_t cnt)
 {
-	que->tail = bnxt_re_incr(que->tail, que->depth);
+	que->tail = (que->tail + cnt) & (que->depth - 1);
 }
 
-static inline void bnxt_re_incr_head(struct bnxt_re_queue *que)
+static inline void bnxt_re_incr_head(struct bnxt_re_queue *que, uint8_t cnt)
 {
-	que->head = bnxt_re_incr(que->head, que->depth);
+	que->head = (que->head + cnt) & (que->depth - 1);
 }
 
 #endif
providers/bnxt_re/verbs.c +77 -51

325 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH v5 5/5 bnxt_re/lib: Move hardware queue to 16B aligned indices

In reply to Devesh Sharma

Move SQ and RQ indices from WQE boundary to
16B boundary alignment. Changing the SQ-wqe posting algorithm accordingly. The new alignment needs to pull a 16B slot from the hardware queue and initialize the current 16B into the hardware buffer. Depending on the max possible wqe size supported by hardware, the number of 16B slots are calculated and pulled for initialization. Currently 128B wqe is supported and it requires 8 slots.

---
 providers/bnxt_re/db.c     |  10 +-
 providers/bnxt_re/main.h   |   1 +
 providers/bnxt_re/memory.h |  33 +++-
 providers/bnxt_re/verbs.c  | 369 ++++++++++++++++++++++++++-----------
 4 files changed, 291 insertions(+), 122 deletions(-)
providers/bnxt_re/db.c +6 -4
index 3c797573..e99b7b62 100644
@@ -62,18 +62,20 @@ static void bnxt_re_init_db_hdr(struct bnxt_re_db_hdr *hdr, uint32_t indx,
 void bnxt_re_ring_rq_db(struct bnxt_re_qp *qp)
 {
 	struct bnxt_re_db_hdr hdr;
+	uint32_t tail;
 
-	bnxt_re_init_db_hdr(&hdr, qp->jrqq->hwque->tail,
-			    qp->qpid, BNXT_RE_QUE_TYPE_RQ);
+	tail = qp->jrqq->hwque->tail / qp->jrqq->hwque->max_slots;
+	bnxt_re_init_db_hdr(&hdr, tail, qp->qpid, BNXT_RE_QUE_TYPE_RQ);
 	bnxt_re_ring_db(qp->udpi, &hdr);
 }
 
 void bnxt_re_ring_sq_db(struct bnxt_re_qp *qp)
 {
 	struct bnxt_re_db_hdr hdr;
+	uint32_t tail;
 
-	bnxt_re_init_db_hdr(&hdr, qp->jsqq->hwque->tail,
-			    qp->qpid, BNXT_RE_QUE_TYPE_SQ);
+	tail = qp->jsqq->hwque->tail / qp->jsqq->hwque->max_slots;
+	bnxt_re_init_db_hdr(&hdr, tail, qp->qpid, BNXT_RE_QUE_TYPE_SQ);
 	bnxt_re_ring_db(qp->udpi, &hdr);
 }
 
providers/bnxt_re/main.h +1 -0
index 5d05dd85..2e6131ae 100644
@@ -44,6 +44,7 @@
 #include <stddef.h>
 #include <endian.h>
 #include <pthread.h>
+#include <sys/param.h>
 
 #include <infiniband/driver.h>
 #include <util/udma_barrier.h>
providers/bnxt_re/memory.h +25 -8
index 5bcdef9a..35fb057e 100644
@@ -57,6 +57,8 @@ struct bnxt_re_queue {
 	 * and the consumer indices in the queue
 	 */
 	uint32_t diff;
+	uint32_t esize;
+	uint32_t max_slots;
 	pthread_spinlock_t qlock;
 };
 
@@ -82,29 +84,44 @@ int bnxt_re_alloc_aligned(struct bnxt_re_queue *que, uint32_t pg_size);
 void bnxt_re_free_aligned(struct bnxt_re_queue *que);
 
 /* Basic queue operation */
-static inline uint32_t bnxt_re_is_que_full(struct bnxt_re_queue *que)
+static inline void *bnxt_re_get_hwqe(struct bnxt_re_queue *que, uint32_t idx)
 {
-	return (((que->diff + que->tail) & (que->depth - 1)) == que->head);
+	idx += que->tail;
+	if (idx >= que->depth)
+		idx -= que->depth;
+	return (void *)(que->va + (idx << 4));
 }
 
-static inline uint32_t bnxt_re_is_que_empty(struct bnxt_re_queue *que)
+static inline bool bnxt_re_is_que_full(struct bnxt_re_queue *que,
+				       uint32_t slots)
 {
-	return que->tail == que->head;
+	int32_t avail, head, tail;
+
+	head = que->head;
+	tail = que->tail;
+	avail = head - tail;
+	if (head <= tail)
+		avail += que->depth;
+	return avail <= (slots + que->diff);
 }
 
-static inline uint32_t bnxt_re_incr(uint32_t val, uint32_t max)
+static inline bool bnxt_re_is_que_empty(struct bnxt_re_queue *que)
 {
-	return (++val & (max - 1));
+	return que->tail == que->head;
 }
 
 static inline void bnxt_re_incr_tail(struct bnxt_re_queue *que, uint8_t cnt)
 {
-	que->tail = (que->tail + cnt) & (que->depth - 1);
+	que->tail += cnt;
+	if (que->tail >= que->depth)
+		que->tail %= que->depth;
 }
 
 static inline void bnxt_re_incr_head(struct bnxt_re_queue *que, uint8_t cnt)
 {
-	que->head = (que->head + cnt) & (que->depth - 1);
+	que->head += cnt;
+	if (que->head >= que->depth)
+		que->head %= que->depth;
 }
 
 #endif
providers/bnxt_re/verbs.c +259 -110

612 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw
In reply to Devesh Sharma

@Jason Gunthorpe
Build is not going through on these patches

Build log #L12

Docker login fail with exit code 1

how to fix?

Quoted 33 lines · Devesh Sharma

The focus of this patch series is to move SQ and RQ wqe posting indices from 128B fixed stride to 16B aligned stride. This allows more flexibility in choosing wqe size.

v4 -> v5
- addressed few minor suggestion.
v3 -> v4
- fixed build warning
v2 -> V3
- Split the ABI change into separate patch
- committed ABI patch using standard rdma-core script.

Devesh Sharma (5):
Update kernel headers
bnxt_re/lib: Read wqe mode from the driver bnxt_re/lib: add a function to initialize software queue bnxt_re/lib: Use separate indices for shadow queue bnxt_re/lib: Move hardware queue to 16B aligned indices

 kernel-headers/rdma/bnxt_re-abi.h |   5 +-
 providers/bnxt_re/bnxt_re-abi.h   |   5 +
 providers/bnxt_re/db.c            |  10 +-
 providers/bnxt_re/main.c          |   4 +
 providers/bnxt_re/main.h          |  25 ++
 providers/bnxt_re/memory.h        |  37 ++-
 providers/bnxt_re/verbs.c         | 523 ++++++++++++++++++++----------
 7 files changed, 429 insertions(+), 180 deletions(-)

--
2.25.1

Signature · 2 lines
-Regards
Devesh