Skip to content

Commit 01a4380

Browse files
authored
Merge pull request #1495 from selvintxavier/bug_fixes
bnxt_re/lib: driver fixes in resize_cq path
2 parents 4a68e16 + 5ac2b2f commit 01a4380

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

providers/bnxt_re/db.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,33 @@ void bnxt_re_ring_srq_arm(struct bnxt_re_srq *srq)
169169
bnxt_re_ring_db(srq->udpi, &hdr);
170170
}
171171

172+
/*
173+
* During CQ resize, it is expected that the epoch needs to be maintained when
174+
* switching from the old CQ to the new resized CQ.
175+
*
176+
* On the first CQ DB excecuted on the new CQ, we need to check if the index we
177+
* are writing is less than the last index written for the old CQ. If that is
178+
* the case, we need to flip the epoch so the ASIC does not get confused and
179+
* think the CQ DB is out of order and therefore drop the DB (note the logic
180+
* in the ASIC that checks CQ DB ordering is not aware of the CQ resize).
181+
*/
182+
static void bnxt_re_cq_resize_check(struct bnxt_re_queue *cqq)
183+
{
184+
if (unlikely(cqq->cq_resized)) {
185+
if (cqq->head < cqq->old_head)
186+
cqq->flags ^= 1UL << BNXT_RE_FLAG_EPOCH_HEAD_SHIFT;
187+
188+
cqq->cq_resized = false;
189+
}
190+
}
191+
172192
void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq)
173193
{
174194
struct bnxt_re_db_hdr hdr;
175195
uint32_t epoch;
176196

177197
bnxt_re_do_pacing(cq->cntx, &cq->rand);
198+
bnxt_re_cq_resize_check(cq->cqq);
178199
epoch = (cq->cqq->flags & BNXT_RE_FLAG_EPOCH_HEAD_MASK) << BNXT_RE_DB_EPOCH_HEAD_SHIFT;
179200
bnxt_re_init_db_hdr(&hdr, cq->cqq->head | epoch, cq->cqid, 0, BNXT_RE_QUE_TYPE_CQ);
180201
bnxt_re_ring_db(cq->udpi, &hdr);
@@ -195,6 +216,7 @@ void bnxt_re_ring_cq_arm_db(struct bnxt_re_cq *cq, uint8_t aflag)
195216
}
196217

197218
bnxt_re_do_pacing(cq->cntx, &cq->rand);
219+
bnxt_re_cq_resize_check(cq->cqq);
198220
epoch = (cq->cqq->flags & BNXT_RE_FLAG_EPOCH_HEAD_MASK) << BNXT_RE_DB_EPOCH_HEAD_SHIFT;
199221
bnxt_re_init_db_hdr(&hdr, cq->cqq->head | epoch, cq->cqid, toggle, aflag);
200222
bnxt_re_ring_db(cq->udpi, &hdr);

providers/bnxt_re/memory.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ struct bnxt_re_queue {
8787
pthread_spinlock_t qlock;
8888
uint32_t msn;
8989
uint32_t msn_tbl_sz;
90+
/*
91+
* This flag is set when CQ is resized. It will be cleared after the
92+
* first CQE is received on the newly resized CQ
93+
*/
94+
bool cq_resized;
95+
96+
/* this tracks the 'head' index on the old CQ before resizing */
97+
uint32_t old_head;
9098
};
9199

92100

providers/bnxt_re/verbs.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,17 @@ static void bnxt_re_resize_cq_complete(struct bnxt_re_cq *cq)
420420
cq->resize_mem = NULL;
421421
cq->cqq->va = cq->mem->va_head;
422422

423+
/* mark the CQ resize flag and save the old head index */
424+
cq->cqq->cq_resized = true;
425+
cq->cqq->old_head = cq->cqq->head;
426+
423427
cq->cqq->depth = cq->mem->pad;
424428
cq->cqq->stride = cntx->rdev->cqe_size;
425429
cq->cqq->head = 0;
426430
cq->cqq->tail = 0;
427431
cq->phase = BNXT_RE_QUEUE_START_PHASE;
428432
/* Reset epoch portion of the flags */
429-
cq->cqq->flags &= ~(BNXT_RE_FLAG_EPOCH_TAIL_MASK |
430-
BNXT_RE_FLAG_EPOCH_HEAD_MASK);
433+
cq->cqq->flags &= ~(BNXT_RE_FLAG_EPOCH_TAIL_MASK);
431434
bnxt_re_ring_cq_arm_db(cq, BNXT_RE_QUE_TYPE_CQ_CUT_ACK);
432435
}
433436

@@ -438,6 +441,8 @@ int bnxt_re_resize_cq(struct ibv_cq *ibvcq, int ncqe)
438441
struct bnxt_re_cq *cq = to_bnxt_re_cq(ibvcq);
439442
struct ib_uverbs_resize_cq_resp resp = {};
440443
struct ubnxt_re_resize_cq cmd = {};
444+
uint16_t msec_wait = 100;
445+
uint16_t exit_cnt = 20;
441446
int rc = 0;
442447

443448
if (ncqe > dev->max_cq_depth)
@@ -488,6 +493,13 @@ int bnxt_re_resize_cq(struct ibv_cq *ibvcq, int ncqe)
488493
list_add_tail(&cq->prev_cq_head, &compl->list);
489494
compl = NULL;
490495
memset(&tmp_wc, 0, sizeof(tmp_wc));
496+
} else {
497+
exit_cnt--;
498+
if (unlikely(!exit_cnt)) {
499+
rc = -EIO;
500+
break;
501+
}
502+
bnxt_re_sub_sec_busy_wait(msec_wait * 1000000);
491503
}
492504
}
493505
done:
@@ -544,6 +556,7 @@ static uint8_t bnxt_re_poll_err_scqe(struct bnxt_re_qp *qp,
544556
status = (le32toh(hdr->flg_st_typ_ph) >> BNXT_RE_BCQE_STATUS_SHIFT) &
545557
BNXT_RE_BCQE_STATUS_MASK;
546558
ibvwc->status = bnxt_re_to_ibv_wc_status(status, true);
559+
ibvwc->vendor_err = status;
547560
ibvwc->wc_flags = 0;
548561
ibvwc->wr_id = swrid->wrid;
549562
ibvwc->qp_num = qp->qpid;
@@ -663,6 +676,7 @@ static int bnxt_re_poll_err_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc,
663676
return 0;
664677

665678
ibvwc->status = bnxt_re_to_ibv_wc_status(status, false);
679+
ibvwc->vendor_err = status;
666680
ibvwc->qp_num = qp->qpid;
667681
ibvwc->opcode = IBV_WC_RECV;
668682
ibvwc->byte_len = 0;

0 commit comments

Comments
 (0)