Skip to content

Commit a519952

Browse files
authored
Merge pull request #1738 from selvintxavier/bug_fixes
bnxt_re/lib: Bug fixes
2 parents b53605f + 240a4f7 commit a519952

1 file changed

Lines changed: 41 additions & 21 deletions

File tree

providers/bnxt_re/verbs.c

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ int bnxt_re_get_toggle_mem(struct ibv_context *ibvctx,
122122
DECLARE_COMMAND_BUFFER(cmd,
123123
BNXT_RE_OBJECT_GET_TOGGLE_MEM,
124124
BNXT_RE_METHOD_GET_TOGGLE_MEM,
125-
4);
125+
6);
126126
struct ib_uverbs_attr *handle;
127127
int ret;
128128

@@ -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 */
@@ -969,6 +975,7 @@ static int bnxt_re_poll_flush_wcs(struct bnxt_re_joint_queue *jqq,
969975
}
970976

971977
ibvwc->status = IBV_WC_WR_FLUSH_ERR;
978+
ibvwc->vendor_err = 0;
972979
ibvwc->opcode = opcode;
973980
ibvwc->wr_id = wrid->wrid;
974981
ibvwc->qp_num = qpid;
@@ -1122,8 +1129,10 @@ static void bnxt_re_cleanup_cq(struct bnxt_re_qp *qp, struct bnxt_re_cq *cq)
11221129

11231130
}
11241131

1125-
bnxt_re_fque_del_node(&qp->snode);
1126-
bnxt_re_fque_del_node(&qp->rnode);
1132+
if (_fque_node_valid(&qp->snode) && qp->scq == cq)
1133+
bnxt_re_fque_del_node(&qp->snode);
1134+
if (!qp->srq && _fque_node_valid(&qp->rnode) && qp->rcq == cq)
1135+
bnxt_re_fque_del_node(&qp->rnode);
11271136
pthread_spin_unlock(&que->qlock);
11281137
}
11291138

@@ -1492,7 +1501,16 @@ void bnxt_re_async_event(struct ibv_context *context,
14921501
case IBV_EVENT_PATH_MIG_ERR: {
14931502
ibvqp = event->element.qp;
14941503
qp = to_bnxt_re_qp(ibvqp);
1495-
bnxt_re_qp_move_flush_err(qp);
1504+
if (qp->qpst != IBV_QPS_ERR)
1505+
qp->qpst = IBV_QPS_ERR;
1506+
pthread_spin_lock(&qp->scq->cqq->qlock);
1507+
bnxt_re_qp_move_flush_err(qp->scq, qp);
1508+
pthread_spin_unlock(&qp->scq->cqq->qlock);
1509+
if (qp->rcq && qp->rcq != qp->scq) {
1510+
pthread_spin_lock(&qp->rcq->cqq->qlock);
1511+
bnxt_re_qp_move_flush_err(qp->rcq, qp);
1512+
pthread_spin_unlock(&qp->rcq->cqq->qlock);
1513+
}
14961514
break;
14971515
}
14981516
case IBV_EVENT_SQ_DRAINED:
@@ -2141,7 +2159,7 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd,
21412159
struct ibv_qp *qp;
21422160

21432161
memset(&attr_ex, 0, sizeof(attr_ex));
2144-
memcpy(&attr_ex, attr, sizeof(attr_ex));
2162+
memcpy(&attr_ex, attr, sizeof(*attr));
21452163
attr_ex.comp_mask = IBV_QP_INIT_ATTR_PD;
21462164
attr_ex.pd = ibvpd;
21472165
qp = __bnxt_re_create_qp(ibvpd->context, &attr_ex);
@@ -2174,7 +2192,8 @@ int bnxt_re_modify_qp(struct ibv_qp *ibvqp, struct ibv_qp_attr *attr,
21742192
if (qp->jrqq) {
21752193
qp->jrqq->hwque->head = 0;
21762194
qp->jrqq->hwque->tail = 0;
2177-
bnxt_re_cleanup_cq(qp, qp->rcq);
2195+
if (qp->rcq != qp->scq)
2196+
bnxt_re_cleanup_cq(qp, qp->rcq);
21782197
qp->jrqq->start_idx = 0;
21792198
qp->jrqq->last_idx = 0;
21802199
}
@@ -2220,8 +2239,9 @@ int bnxt_re_destroy_qp(struct ibv_qp *ibvqp)
22202239
bnxt_re_put_pbuf(qp->cntx, qp->pbuf);
22212240
qp->pbuf = NULL;
22222241
}
2223-
bnxt_re_cleanup_cq(qp, qp->rcq);
22242242
bnxt_re_cleanup_cq(qp, qp->scq);
2243+
if (qp->rcq != qp->scq)
2244+
bnxt_re_cleanup_cq(qp, qp->rcq);
22252245
mem = qp->mem;
22262246
bnxt_re_free_mem(mem);
22272247
return 0;

0 commit comments

Comments
 (0)