Skip to content

Commit

Permalink
bnxt_re/lib: Track and maintain CQ doorbell epoch during CQ resize
Browse files Browse the repository at this point in the history
[ Upstream commit 2bc950a ]

During CQ resize, it is expected that the CQ doorbell 'epoch' needs to
be maintained when switching from the old CQ to the new resized CQ.

On the first CQ doorbell excecuted on the new CQ, we need to check if
the index we are writing is less than the last index written for the
old CQ. If that is the case, we need to flip the 'epoch' so the ASIC
does not get confused and thinks the CQ doorbell is out of order and
therefore drops the doorbell. Note the logic in the ASIC that checks CQ
doorbell ordering is not aware of the CQ resize.

Fixes: 4a85843 ("bnxt_re/lib: Fix the toggle bit changes in resize cq path")
Signed-off-by: Ray Jui <ray.jui@broadcom.com>
Reviewed-by: Chandramohan Akula <chandramohan.akula@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
  • Loading branch information
selvintxavier authored and nmorey committed Oct 1, 2024
1 parent 95947e9 commit f9d5f72
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
22 changes: 22 additions & 0 deletions providers/bnxt_re/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,33 @@ void bnxt_re_ring_srq_arm(struct bnxt_re_srq *srq)
bnxt_re_ring_db(srq->udpi, &hdr);
}

/*
* During CQ resize, it is expected that the epoch needs to be maintained when
* switching from the old CQ to the new resized CQ.
*
* On the first CQ DB excecuted on the new CQ, we need to check if the index we
* are writing is less than the last index written for the old CQ. If that is
* the case, we need to flip the epoch so the ASIC does not get confused and
* think the CQ DB is out of order and therefore drop the DB (note the logic
* in the ASIC that checks CQ DB ordering is not aware of the CQ resize).
*/
static void bnxt_re_cq_resize_check(struct bnxt_re_queue *cqq)
{
if (unlikely(cqq->cq_resized)) {
if (cqq->head < cqq->old_head)
cqq->flags ^= 1UL << BNXT_RE_FLAG_EPOCH_HEAD_SHIFT;

cqq->cq_resized = false;
}
}

void bnxt_re_ring_cq_db(struct bnxt_re_cq *cq)
{
struct bnxt_re_db_hdr hdr;
uint32_t epoch;

bnxt_re_do_pacing(cq->cntx, &cq->rand);
bnxt_re_cq_resize_check(cq->cqq);
epoch = (cq->cqq->flags & BNXT_RE_FLAG_EPOCH_HEAD_MASK) << BNXT_RE_DB_EPOCH_HEAD_SHIFT;
bnxt_re_init_db_hdr(&hdr, cq->cqq->head | epoch, cq->cqid, 0, BNXT_RE_QUE_TYPE_CQ);
bnxt_re_ring_db(cq->udpi, &hdr);
Expand All @@ -191,6 +212,7 @@ void bnxt_re_ring_cq_arm_db(struct bnxt_re_cq *cq, uint8_t aflag)
}

bnxt_re_do_pacing(cq->cntx, &cq->rand);
bnxt_re_cq_resize_check(cq->cqq);
epoch = (cq->cqq->flags & BNXT_RE_FLAG_EPOCH_HEAD_MASK) << BNXT_RE_DB_EPOCH_HEAD_SHIFT;
bnxt_re_init_db_hdr(&hdr, cq->cqq->head | epoch, cq->cqid, toggle, aflag);
bnxt_re_ring_db(cq->udpi, &hdr);
Expand Down
8 changes: 8 additions & 0 deletions providers/bnxt_re/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ struct bnxt_re_queue {
pthread_spinlock_t qlock;
uint32_t msn;
uint32_t msn_tbl_sz;
/*
* This flag is set when CQ is resized. It will be cleared after the
* first CQE is received on the newly resized CQ
*/
bool cq_resized;

/* this tracks the 'head' index on the old CQ before resizing */
uint32_t old_head;
};


Expand Down
7 changes: 5 additions & 2 deletions providers/bnxt_re/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,17 @@ static void bnxt_re_resize_cq_complete(struct bnxt_re_cq *cq)
cq->resize_mem = NULL;
cq->cqq->va = cq->mem->va_head;

/* mark the CQ resize flag and save the old head index */
cq->cqq->cq_resized = true;
cq->cqq->old_head = cq->cqq->head;

cq->cqq->depth = cq->mem->pad;
cq->cqq->stride = cntx->rdev->cqe_size;
cq->cqq->head = 0;
cq->cqq->tail = 0;
cq->phase = BNXT_RE_QUEUE_START_PHASE;
/* Reset epoch portion of the flags */
cq->cqq->flags &= ~(BNXT_RE_FLAG_EPOCH_TAIL_MASK |
BNXT_RE_FLAG_EPOCH_HEAD_MASK);
cq->cqq->flags &= ~(BNXT_RE_FLAG_EPOCH_TAIL_MASK);
bnxt_re_ring_cq_arm_db(cq, BNXT_RE_QUE_TYPE_CQ_CUT_ACK);
}

Expand Down

0 comments on commit f9d5f72

Please sign in to comment.