Skip to content

Commit 3d65bd6

Browse files
committed
bnxt_re/lib: Fix the flush CQE handling
Mainly implements a synchronization between CQ cleanup during destroy_qp and poll_cq. Move the QP to the Flushed lists of the CQ only for the CQ which is currently locked. Also, while cleanup is invoked, remove from the flush list only for the CQ which is currently locked. Fixes: 1190b64 ("bnxt_re/lib: Adds bnxt_re_async_event support") Fixes: fd3077a ("bnxt_re/lib: optimize bnxt_re_poll_term_cqe") Fixes: 400c573 ("bnxt_re/lib: Remove the flush queue lock") Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Reviewed-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com> Reviewed-by: Anantha Prabhu <anantha.prabhu@broadcom.com> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
1 parent c6dc255 commit 3d65bd6

1 file changed

Lines changed: 34 additions & 17 deletions

File tree

providers/bnxt_re/verbs.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -812,29 +812,35 @@ static uint8_t bnxt_re_poll_rcqe(struct bnxt_re_qp *qp, struct ibv_wc *ibvwc,
812812
return pcqe;
813813
}
814814

815-
static void bnxt_re_qp_move_flush_err(struct bnxt_re_qp *qp)
815+
static void bnxt_re_qp_move_flush_err(struct bnxt_re_cq *cq, struct bnxt_re_qp *qp)
816816
{
817-
struct bnxt_re_cq *scq, *rcq;
818-
819-
scq = to_bnxt_re_cq(qp->ibvqp->send_cq);
820-
rcq = to_bnxt_re_cq(qp->ibvqp->recv_cq);
821-
822-
if (qp->qpst != IBV_QPS_ERR)
823-
qp->qpst = IBV_QPS_ERR;
824-
bnxt_re_fque_add_node(&rcq->rfhead, &qp->rnode);
825-
bnxt_re_fque_add_node(&scq->sfhead, &qp->snode);
817+
if (!qp->srq && qp->rcq == cq)
818+
bnxt_re_fque_add_node(&cq->rfhead, &qp->rnode);
819+
if (qp->scq == cq)
820+
bnxt_re_fque_add_node(&cq->sfhead, &qp->snode);
826821
}
827822

828-
static uint8_t bnxt_re_poll_term_cqe(struct bnxt_re_qp *qp, int *cnt)
823+
static uint8_t bnxt_re_poll_term_cqe(struct bnxt_re_cq *cq, struct bnxt_re_qp *qp, int *cnt)
829824
{
825+
struct bnxt_re_cq *other_cq;
826+
830827
/* For now just add the QP to flush list without
831828
* considering the index reported in the CQE.
832829
* Continue reporting flush completions until the
833830
* SQ and RQ are empty.
834831
*/
835832
*cnt = 0;
836-
if (qp->qpst != IBV_QPS_RESET)
837-
bnxt_re_qp_move_flush_err(qp);
833+
if (qp->qpst != IBV_QPS_RESET) {
834+
if (qp->qpst != IBV_QPS_ERR)
835+
qp->qpst = IBV_QPS_ERR;
836+
bnxt_re_qp_move_flush_err(cq, qp);
837+
other_cq = (cq == qp->scq) ? qp->rcq : qp->scq;
838+
if (other_cq && other_cq != cq) {
839+
pthread_spin_lock(&other_cq->cqq->qlock);
840+
bnxt_re_qp_move_flush_err(other_cq, qp);
841+
pthread_spin_unlock(&other_cq->cqq->qlock);
842+
}
843+
}
838844

839845
return 0;
840846
}
@@ -903,7 +909,7 @@ static int bnxt_re_poll_one(struct bnxt_re_cq *cq, int nwc, struct ibv_wc *wc,
903909
(uintptr_t)le64toh(scqe->qp_handle);
904910
if (!qp)
905911
break;
906-
pcqe = bnxt_re_poll_term_cqe(qp, &cnt);
912+
pcqe = bnxt_re_poll_term_cqe(cq, qp, &cnt);
907913
break;
908914
case BNXT_RE_WC_TYPE_COFF:
909915
/* Stop further processing and return */
@@ -1122,8 +1128,10 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq)
11221128

11231129
}
11241130

1125-
bnxt_re_fque_del_node(&qp->snode);
1126-
bnxt_re_fque_del_node(&qp->rnode);
1131+
if (_fque_node_valid(&qp->snode) && qp->scq == cq)
1132+
bnxt_re_fque_del_node(&qp->snode);
1133+
if (!qp->srq && _fque_node_valid(&qp->rnode) && qp->rcq == cq)
1134+
bnxt_re_fque_del_node(&qp->rnode);
11271135
pthread_spin_unlock(&que->qlock);
11281136
}
11291137

@@ -1492,7 +1500,16 @@ void bnxt_re_async_event(struct ibv_context *context,
14921500
case IBV_EVENT_PATH_MIG_ERR: {
14931501
ibvqp = event->element.qp;
14941502
qp = to_bnxt_re_qp(ibvqp);
1495-
bnxt_re_qp_move_flush_err(qp);
1503+
if (qp->qpst != IBV_QPS_ERR)
1504+
qp->qpst = IBV_QPS_ERR;
1505+
pthread_spin_lock(&qp->scq->cqq->qlock);
1506+
bnxt_re_qp_move_flush_err(qp->scq, qp);
1507+
pthread_spin_unlock(&qp->scq->cqq->qlock);
1508+
if (qp->rcq && qp->rcq != qp->scq) {
1509+
pthread_spin_lock(&qp->rcq->cqq->qlock);
1510+
bnxt_re_qp_move_flush_err(qp->rcq, qp);
1511+
pthread_spin_unlock(&qp->rcq->cqq->qlock);
1512+
}
14961513
break;
14971514
}
14981515
case IBV_EVENT_SQ_DRAINED:

0 commit comments

Comments
 (0)