Skip to content

Commit

Permalink
bnxt_re/lib: Get the shared SRQ toggle page
Browse files Browse the repository at this point in the history
Implements the UAPI call to get the SRQ toggle page.
Also, get the toggle bit from the shared page and
use it while arming the SRQ.

Signed-off-by: Chandramohan Akula <chandramohan.akula@broadcom.com>
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
  • Loading branch information
chandramohan-akula authored and selvintxavier committed Sep 2, 2024
1 parent 0a75c39 commit b9d13a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion providers/bnxt_re/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,14 @@ void bnxt_re_ring_srq_db(struct bnxt_re_srq *srq)

void bnxt_re_ring_srq_arm(struct bnxt_re_srq *srq)
{
uint32_t *pgptr, toggle = 0;
struct bnxt_re_db_hdr hdr;

pgptr = (uint32_t *)srq->toggle_map;
if (pgptr)
toggle = *pgptr;
bnxt_re_do_pacing(srq->cntx, &srq->rand);
bnxt_re_init_db_hdr(&hdr, srq->cap.srq_limit, srq->srqid, 0,
bnxt_re_init_db_hdr(&hdr, srq->cap.srq_limit, srq->srqid, toggle,
BNXT_RE_QUE_TYPE_SRQ_ARM);
bnxt_re_ring_db(srq->udpi, &hdr);
}
Expand Down
3 changes: 3 additions & 0 deletions providers/bnxt_re/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ struct bnxt_re_srq {
int start_idx;
int last_idx;
bool arm_req;
uint32_t mem_handle;
uint32_t toggle_size;
void *toggle_map;
};

struct bnxt_re_joint_queue {
Expand Down
19 changes: 17 additions & 2 deletions providers/bnxt_re/verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2215,8 +2215,9 @@ struct ibv_srq *bnxt_re_create_srq(struct ibv_pd *ibvpd,
struct ibv_srq_init_attr *attr)
{
struct bnxt_re_context *cntx = to_bnxt_re_context(ibvpd->context);
struct bnxt_re_mmap_info minfo = {};
struct ubnxt_re_srq_resp resp = {};
struct bnxt_re_qattr qattr = {};
struct ubnxt_re_srq_resp resp;
struct ubnxt_re_srq req;
struct bnxt_re_srq *srq;
void *mem;
Expand Down Expand Up @@ -2251,7 +2252,19 @@ struct ibv_srq *bnxt_re_create_srq(struct ibv_pd *ibvpd,
srq->cap.max_sge = attr->attr.max_sge;
srq->cap.srq_limit = attr->attr.srq_limit;
srq->arm_req = false;

if (resp.comp_mask & BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT) {
minfo.type = BNXT_RE_SRQ_TOGGLE_MEM;
minfo.res_id = resp.srqid;
ret = bnxt_re_get_toggle_mem(ibvpd->context, &minfo, &srq->mem_handle);
if (ret)
goto fail;
srq->toggle_map = mmap(NULL, minfo.alloc_size, PROT_READ,
MAP_SHARED, ibvpd->context->cmd_fd,
minfo.alloc_offset);
if (srq->toggle_map == MAP_FAILED)
goto fail;
srq->toggle_size = minfo.alloc_size;
}
return &srq->ibvsrq;
fail:
bnxt_re_free_mem(mem);
Expand Down Expand Up @@ -2285,6 +2298,8 @@ int bnxt_re_destroy_srq(struct ibv_srq *ibvsrq)
if (ret)
return ret;

if (srq->toggle_map)
munmap(srq->toggle_map, srq->toggle_size);
mem = srq->mem;
bnxt_re_free_mem(mem);
return 0;
Expand Down

0 comments on commit b9d13a9

Please sign in to comment.