Skip to content

Commit

Permalink
bnxt_re/lib: Clear the push buffer status while processing a chain of…
Browse files Browse the repository at this point in the history
… WRs

When a chain of WRs are received with inline and non inlline data, lib
can incorrectly select inline push path for a non inline buffer. Clear
the local variable pbuf to avoid this sequence.

Also, avoid a local variable try_push as pbuf itself can serve the
purpose.

Signed-off-by: Bhargava Chenna Marreddy <[email protected]>
Signed-off-by: Selvin Xavier <[email protected]>
  • Loading branch information
bmarreddy authored and selvintxavier committed Nov 16, 2023
1 parent 1190b64 commit 26058c0
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions providers/bnxt_re/verbs.c
Expand Up @@ -1509,7 +1509,7 @@ static int bnxt_re_put_inline(struct bnxt_re_queue *que, uint32_t *idx,
}

static int bnxt_re_required_slots(struct bnxt_re_qp *qp, struct ibv_send_wr *wr,
uint32_t *wqe_sz, bool *push)
uint32_t *wqe_sz, void **pbuf)
{
uint32_t wqe_byte;
int ilsize;
Expand All @@ -1519,7 +1519,7 @@ static int bnxt_re_required_slots(struct bnxt_re_qp *qp, struct ibv_send_wr *wr,
if (ilsize > qp->cap.max_inline)
return -EINVAL;
if (qp->push_st_en && ilsize <= qp->max_push_sz)
*push = true;
*pbuf = bnxt_re_get_pbuf(&qp->push_st_en, qp->cntx);
wqe_byte = (ilsize + bnxt_re_get_sqe_hdr_sz());
} else {
wqe_byte = bnxt_re_calc_wqe_sz(wr->num_sge);
Expand Down Expand Up @@ -1686,15 +1686,13 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
uint32_t wqe_size = 0;
bool ring_db = false;
uint8_t sig = 0;
bool try_push;
uint32_t idx;

pthread_spin_lock(&sq->qlock);
while (wr) {

try_push = false;
pbuf = NULL;
slots = bnxt_re_required_slots(qp, wr, &wqe_size, &try_push);
slots = bnxt_re_required_slots(qp, wr, &wqe_size, (void **)&pbuf);
if (bnxt_re_is_que_full(sq, slots) ||
wr->num_sge > qp->cap.max_ssge) {
*bad = wr;
Expand All @@ -1705,15 +1703,15 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
idx = 0;
hdr = bnxt_re_get_hwqe(sq, idx++);
sqe = bnxt_re_get_hwqe(sq, idx++);
if (try_push) {
pbuf = bnxt_re_get_pbuf(&qp->push_st_en, qp->cntx);
if (pbuf) {
pbuf->qpid = qp->qpid;
pbuf->wqe[0] = (uintptr_t)hdr;
pbuf->wqe[1] = (uintptr_t)sqe;
pbuf->st_idx = *sq->dbtail;
}

/* populate push buffer */
if (pbuf) {
pbuf->qpid = qp->qpid;
pbuf->wqe[0] = (uintptr_t)hdr;
pbuf->wqe[1] = (uintptr_t)sqe;
pbuf->st_idx = *sq->dbtail;
}

if (wr->num_sge) {
bytes = bnxt_re_build_sge(sq, &idx, pbuf, wr, qp->cap.max_inline);
if (unlikely(bytes < 0)) {
Expand Down Expand Up @@ -1779,6 +1777,7 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
pbuf->tail = *sq->dbtail;
bnxt_re_fill_push_wcb(qp, pbuf, idx);
bnxt_re_put_pbuf(qp->cntx, pbuf);
pbuf = NULL;
}

qp->wqe_cnt++;
Expand All @@ -1793,6 +1792,9 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
if (ring_db)
bnxt_re_ring_sq_db(qp);

if (pbuf)
bnxt_re_put_pbuf(qp->cntx, pbuf);

pthread_spin_unlock(&sq->qlock);
return ret;
}
Expand Down

0 comments on commit 26058c0

Please sign in to comment.