Skip to content

Commit 181028a

Browse files
chandramohan-akularleon
authored andcommitted
RDMA/bnxt_re: Share a page to expose per SRQ info with userspace
Gen P7 adapters needs to share a toggle bits information received in kernel driver with the user space. User space needs this info to arm the SRQ. User space application can get this page using the UAPI routines. Library will mmap this page and get the toggle bits to be used in the next ARM Doorbell. Uses a hash list to map the SRQ structure from the SRQ ID. SRQ structure is retrieved from the hash list while the library calls the UAPI routine to get the toggle page mapping. Currently the full page is mapped per SRQ. This can be optimized to enable multiple SRQs from the same application share the same page and different offsets in the page Signed-off-by: Chandramohan Akula <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent b420763 commit 181028a

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

drivers/infiniband/hw/bnxt_re/bnxt_re.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ struct bnxt_re_pacing {
141141
#define BNXT_RE_GRC_FIFO_REG_BASE 0x2000
142142

143143
#define MAX_CQ_HASH_BITS (16)
144+
#define MAX_SRQ_HASH_BITS (16)
144145
struct bnxt_re_dev {
145146
struct ib_device ibdev;
146147
struct list_head list;
@@ -196,6 +197,7 @@ struct bnxt_re_dev {
196197
struct work_struct dbq_fifo_check_work;
197198
struct delayed_work dbq_pacing_work;
198199
DECLARE_HASHTABLE(cq_hash, MAX_CQ_HASH_BITS);
200+
DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS);
199201
};
200202

201203
#define to_bnxt_re_dev(ptr, member) \

drivers/infiniband/hw/bnxt_re/ib_verbs.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,10 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata)
17071707

17081708
if (qplib_srq->cq)
17091709
nq = qplib_srq->cq->nq;
1710+
if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
1711+
free_page((unsigned long)srq->uctx_srq_page);
1712+
hash_del(&srq->hash_entry);
1713+
}
17101714
bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq);
17111715
ib_umem_release(srq->umem);
17121716
atomic_dec(&rdev->stats.res.srq_count);
@@ -1811,9 +1815,18 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
18111815
}
18121816

18131817
if (udata) {
1814-
struct bnxt_re_srq_resp resp;
1818+
struct bnxt_re_srq_resp resp = {};
18151819

18161820
resp.srqid = srq->qplib_srq.id;
1821+
if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) {
1822+
hash_add(rdev->srq_hash, &srq->hash_entry, srq->qplib_srq.id);
1823+
srq->uctx_srq_page = (void *)get_zeroed_page(GFP_KERNEL);
1824+
if (!srq->uctx_srq_page) {
1825+
rc = -ENOMEM;
1826+
goto fail;
1827+
}
1828+
resp.comp_mask |= BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT;
1829+
}
18171830
rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
18181831
if (rc) {
18191832
ibdev_err(&rdev->ibdev, "SRQ copy to udata failed!");
@@ -4291,6 +4304,19 @@ static struct bnxt_re_cq *bnxt_re_search_for_cq(struct bnxt_re_dev *rdev, u32 cq
42914304
return cq;
42924305
}
42934306

4307+
static struct bnxt_re_srq *bnxt_re_search_for_srq(struct bnxt_re_dev *rdev, u32 srq_id)
4308+
{
4309+
struct bnxt_re_srq *srq = NULL, *tmp_srq;
4310+
4311+
hash_for_each_possible(rdev->srq_hash, tmp_srq, hash_entry, srq_id) {
4312+
if (tmp_srq->qplib_srq.id == srq_id) {
4313+
srq = tmp_srq;
4314+
break;
4315+
}
4316+
}
4317+
return srq;
4318+
}
4319+
42944320
/* Helper function to mmap the virtual memory from user app */
42954321
int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
42964322
{
@@ -4519,6 +4545,7 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund
45194545
struct bnxt_re_ucontext *uctx;
45204546
struct ib_ucontext *ib_uctx;
45214547
struct bnxt_re_dev *rdev;
4548+
struct bnxt_re_srq *srq;
45224549
u32 length = PAGE_SIZE;
45234550
struct bnxt_re_cq *cq;
45244551
u64 mem_offset;
@@ -4550,6 +4577,11 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund
45504577
addr = (u64)cq->uctx_cq_page;
45514578
break;
45524579
case BNXT_RE_SRQ_TOGGLE_MEM:
4580+
srq = bnxt_re_search_for_srq(rdev, res_id);
4581+
if (!srq)
4582+
return -EINVAL;
4583+
4584+
addr = (u64)srq->uctx_srq_page;
45534585
break;
45544586

45554587
default:

drivers/infiniband/hw/bnxt_re/ib_verbs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct bnxt_re_srq {
7878
struct ib_umem *umem;
7979
spinlock_t lock; /* protect srq */
8080
void *uctx_srq_page;
81+
struct hlist_node hash_entry;
8182
};
8283

8384
struct bnxt_re_qp {

drivers/infiniband/hw/bnxt_re/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,10 @@ static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev)
139139
if (bnxt_re_hwrm_qcaps(rdev))
140140
dev_err(rdev_to_dev(rdev),
141141
"Failed to query hwrm qcaps\n");
142-
if (bnxt_qplib_is_chip_gen_p7(rdev->chip_ctx))
142+
if (bnxt_qplib_is_chip_gen_p7(rdev->chip_ctx)) {
143143
cctx->modes.toggle_bits |= BNXT_QPLIB_CQ_TOGGLE_BIT;
144+
cctx->modes.toggle_bits |= BNXT_QPLIB_SRQ_TOGGLE_BIT;
145+
}
144146
}
145147

146148
static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
@@ -1771,6 +1773,8 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev)
17711773
bnxt_re_vf_res_config(rdev);
17721774
}
17731775
hash_init(rdev->cq_hash);
1776+
if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT)
1777+
hash_init(rdev->srq_hash);
17741778

17751779
return 0;
17761780
free_sctx:

include/uapi/rdma/bnxt_re-abi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,14 @@ struct bnxt_re_srq_req {
141141
__aligned_u64 srq_handle;
142142
};
143143

144+
enum bnxt_re_srq_mask {
145+
BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT = 0x1,
146+
};
147+
144148
struct bnxt_re_srq_resp {
145149
__u32 srqid;
150+
__u32 rsvd; /* padding */
151+
__aligned_u64 comp_mask;
146152
};
147153

148154
enum bnxt_re_shpg_offt {

0 commit comments

Comments
 (0)