Skip to content

Commit

Permalink
bnxt_re/lib: Add check for device atomic capability
Browse files Browse the repository at this point in the history
Adds a check in lib for atomic_cap when processing
IB_ATOMIC_WR. If atomic capability is not set,
fail the WR. Also, fail if any atomic requests
which has more than 1 SGE.

Signed-off-by: Damodharam Ammepalli <[email protected]>
Signed-off-by: Hongguang Gao <[email protected]>
Signed-off-by: Saravanan Vajravel <[email protected]>
Signed-off-by: Selvin Xavier <[email protected]>
  • Loading branch information
Saravanan Vajravel authored and selvintxavier committed Nov 16, 2023
1 parent 68f59cd commit 0840465
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions providers/bnxt_re/main.h
Expand Up @@ -146,6 +146,7 @@ struct bnxt_re_qpcap {
uint32_t max_rsge;
uint32_t max_inline;
uint8_t sqsig;
uint8_t is_atomic_cap;
};

struct bnxt_re_srq {
Expand Down
34 changes: 31 additions & 3 deletions providers/bnxt_re/verbs.c
Expand Up @@ -1339,6 +1339,7 @@ struct ibv_qp *bnxt_re_create_qp(struct ibv_pd *ibvpd,
cap->max_rsge = attr->cap.max_recv_sge;
cap->max_inline = attr->cap.max_inline_data;
cap->sqsig = attr->sq_sig_all;
cap->is_atomic_cap = dev->devattr.atomic_cap;
fque_init_node(&qp->snode);
fque_init_node(&qp->rnode);

Expand Down Expand Up @@ -1651,6 +1652,12 @@ static int bnxt_re_build_ud_sqe(struct ibv_send_wr *wr,
return 0;
}

static bool __atomic_not_supported(struct bnxt_re_qp *qp, struct ibv_send_wr *wr)
{
/* Atomic capability disabled or the request has more than 1 SGE */
return (!qp->cap.is_atomic_cap || wr->num_sge > 1);
}

static void bnxt_re_build_cns_sqe(struct ibv_send_wr *wr,
struct bnxt_re_bsqe *hdr,
void *hdr2)
Expand All @@ -1674,6 +1681,25 @@ static void bnxt_re_build_fna_sqe(struct ibv_send_wr *wr,
sqe->swp_dt = htole64(wr->wr.atomic.compare_add);
}

static int bnxt_re_build_atomic_sqe(struct bnxt_re_qp *qp,
struct ibv_send_wr *wr,
struct bnxt_re_bsqe *hdr,
void *hdr2)
{
if (__atomic_not_supported(qp, wr))
return -EINVAL;
switch (wr->opcode) {
case IBV_WR_ATOMIC_CMP_AND_SWP:
bnxt_re_build_cns_sqe(wr, hdr, hdr2);
return 0;
case IBV_WR_ATOMIC_FETCH_AND_ADD:
bnxt_re_build_fna_sqe(wr, hdr, hdr2);
return 0;
default:
return -EINVAL;
}
}

static void bnxt_re_force_rts2rts(struct bnxt_re_qp *qp)
{
struct ibv_qp_attr attr;
Expand Down Expand Up @@ -1766,10 +1792,12 @@ int bnxt_re_post_send(struct ibv_qp *ibvqp, struct ibv_send_wr *wr,
rsqe->rkey = htole32(wr->wr.rdma.rkey);
break;
case IBV_WR_ATOMIC_CMP_AND_SWP:
bnxt_re_build_cns_sqe(wr, hdr, sqe);
break;
case IBV_WR_ATOMIC_FETCH_AND_ADD:
bnxt_re_build_fna_sqe(wr, hdr, sqe);
if (bnxt_re_build_atomic_sqe(qp, wr, hdr, sqe)) {
ret = EINVAL;
*bad = wr;
goto bad_wr;
}
break;
default:
ret = -EINVAL;
Expand Down

0 comments on commit 0840465

Please sign in to comment.