Skip to content

Commit e564447

Browse files
committed
bnxt_re/lib: Add uverbs object handle path for CQ/SRQ toggle page
The kernel driver supports two paths for the GET_TOGGLE_MEM ioctl: - Legacy path (older kernels / older rdma-core): the caller sends BNXT_RE_TOGGLE_MEM_TYPE (enum: CQ or SRQ) and BNXT_RE_TOGGLE_MEM_RES_ID (the hardware queue ID). The kernel performs an XArray lookup per ucontext to find the toggle page. - New path (new kernel + new rdma-core): the caller sends a uverbs object handle (BNXT_RE_TOGGLE_MEM_CQ_HANDLE or BNXT_RE_TOGGLE_MEM_SRQ_HANDLE). The kernel resolves the uobject directly, with built-in ownership verification and pinning. During alloc_ucontext, lib now sets the new request bit BNXT_RE_COMP_MASK_REQ_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT to advertise uobj-handle capability. If the kernel responds with BNXT_RE_UCNTX_CMASK_TOGGLE_MEM_UOBJ_SUPPORT. Based on the negotiated capability, new path will be selected. Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
1 parent 5f4fe35 commit e564447

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

providers/bnxt_re/bnxt_re-abi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ enum {
229229
BNXT_RE_COMP_MASK_UCNTX_POW2_DISABLED = 0x04,
230230
BNXT_RE_COMP_MASK_UCNTX_MSN_TABLE_ENABLED = 0x08,
231231
BNXT_RE_COMP_MASK_UCNTX_RATE_LIMIT_ENABLED = 0x10,
232+
BNXT_RE_COMP_MASK_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT = 0x20,
232233
};
233234

234235
enum bnxt_re_que_flags_mask {

providers/bnxt_re/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev,
200200

201201
req.comp_mask |= BNXT_RE_COMP_MASK_REQ_UCNTX_POW2_SUPPORT;
202202
req.comp_mask |= BNXT_RE_COMP_MASK_REQ_UCNTX_VAR_WQE_SUPPORT;
203+
req.comp_mask |= BNXT_RE_COMP_MASK_REQ_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT;
203204
if (ibv_cmd_get_context(&cntx->ibvctx, &req.ibv_cmd, sizeof(req),
204205
NULL, &resp.ibv_resp, sizeof(resp)))
205206
goto failed;
@@ -231,7 +232,8 @@ static struct verbs_context *bnxt_re_alloc_context(struct ibv_device *vdev,
231232
cntx->comp_mask |= BNXT_RE_COMP_MASK_UCNTX_MSN_TABLE_ENABLED;
232233
if (resp.comp_mask & BNXT_RE_UCNTX_CMASK_QP_RATE_LIMIT_ENABLED)
233234
cntx->comp_mask |= BNXT_RE_COMP_MASK_UCNTX_RATE_LIMIT_ENABLED;
234-
235+
if (resp.comp_mask & BNXT_RE_UCNTX_CMASK_TOGGLE_MEM_UOBJ_SUPPORT)
236+
cntx->comp_mask |= BNXT_RE_COMP_MASK_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT;
235237
/* mmap shared page. */
236238
cntx->shpg = mmap(NULL, rdev->pg_size, PROT_READ | PROT_WRITE,
237239
MAP_SHARED, cmd_fd, 0);

providers/bnxt_re/main.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ struct bnxt_re_pacing_data {
283283
};
284284

285285
struct bnxt_re_mmap_info {
286-
__u32 type;
286+
enum bnxt_re_get_toggle_mem_type type;
287287
__u32 dpi;
288288
__u64 alloc_offset;
289289
__u32 alloc_size;
@@ -319,6 +319,7 @@ int bnxt_re_alloc_page(struct ibv_context *ibvctx,
319319
int bnxt_re_notify_drv(struct ibv_context *ibvctx);
320320
int bnxt_re_get_toggle_mem(struct ibv_context *ibvctx,
321321
struct bnxt_re_mmap_info *minfo,
322+
uint32_t obj_handle,
322323
uint32_t *page_handle);
323324

324325
/* pointer conversion functions*/
@@ -637,4 +638,6 @@ static inline void bnxt_re_sub_sec_busy_wait(uint32_t nsec)
637638

638639
#define BNXT_RE_MSN_TBL_EN(a) ((a)->comp_mask & BNXT_RE_COMP_MASK_UCNTX_MSN_TABLE_ENABLED)
639640
#define BNXT_RE_RATE_LIMIT_EN(a) ((a)->comp_mask & BNXT_RE_COMP_MASK_UCNTX_RATE_LIMIT_ENABLED)
641+
#define BNXT_RE_TOGGLE_MEM_UOBJ_EN(a) \
642+
((a)->comp_mask & BNXT_RE_COMP_MASK_UCNTX_TOGGLE_MEM_UOBJ_SUPPORT)
640643
#endif

providers/bnxt_re/verbs.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ static int bnxt_re_map_db_page(struct ibv_context *ibvctx,
117117

118118
int bnxt_re_get_toggle_mem(struct ibv_context *ibvctx,
119119
struct bnxt_re_mmap_info *minfo,
120+
uint32_t obj_handle,
120121
uint32_t *page_handle)
121122
{
123+
struct bnxt_re_context *cntx = to_bnxt_re_context(ibvctx);
122124
DECLARE_COMMAND_BUFFER(cmd,
123125
BNXT_RE_OBJECT_GET_TOGGLE_MEM,
124126
BNXT_RE_METHOD_GET_TOGGLE_MEM,
@@ -127,15 +129,21 @@ int bnxt_re_get_toggle_mem(struct ibv_context *ibvctx,
127129
int ret;
128130

129131
handle = fill_attr_out_obj(cmd, BNXT_RE_TOGGLE_MEM_HANDLE);
130-
fill_attr_const_in(cmd, BNXT_RE_TOGGLE_MEM_TYPE, minfo->type);
131-
fill_attr_in(cmd, BNXT_RE_TOGGLE_MEM_RES_ID, &minfo->res_id, sizeof(minfo->res_id));
132-
fill_attr_out_ptr(cmd, BNXT_RE_TOGGLE_MEM_MMAP_PAGE, &minfo->alloc_offset);
132+
if (BNXT_RE_TOGGLE_MEM_UOBJ_EN(cntx)) {
133+
if (minfo->type == BNXT_RE_CQ_TOGGLE_MEM)
134+
fill_attr_in_obj(cmd, BNXT_RE_TOGGLE_MEM_CQ_HANDLE, obj_handle);
135+
else
136+
fill_attr_in_obj(cmd, BNXT_RE_TOGGLE_MEM_SRQ_HANDLE, obj_handle);
137+
} else {
138+
fill_attr_const_in(cmd, BNXT_RE_TOGGLE_MEM_TYPE, minfo->type);
139+
fill_attr_in(cmd, BNXT_RE_TOGGLE_MEM_RES_ID,
140+
&minfo->res_id, sizeof(minfo->res_id));
141+
}
142+
fill_attr_out_ptr(cmd, BNXT_RE_TOGGLE_MEM_MMAP_PAGE, &minfo->alloc_offset);
133143
fill_attr_out_ptr(cmd, BNXT_RE_TOGGLE_MEM_MMAP_LENGTH, &minfo->alloc_size);
134144
fill_attr_out_ptr(cmd, BNXT_RE_TOGGLE_MEM_MMAP_OFFSET, &minfo->pg_offset);
135145

136-
137146
ret = execute_ioctl(ibvctx, cmd);
138-
139147
if (ret)
140148
return ret;
141149
if (page_handle)
@@ -389,10 +397,10 @@ struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
389397
cq->rand.seed = cq->cqid;
390398

391399
if (resp.comp_mask & BNXT_RE_CQ_TOGGLE_PAGE_SUPPORT) {
392-
393400
minfo.type = BNXT_RE_CQ_TOGGLE_MEM;
394401
minfo.res_id = resp.cqid;
395-
ret = bnxt_re_get_toggle_mem(ibvctx, &minfo, &cq->mem_handle);
402+
ret = bnxt_re_get_toggle_mem(ibvctx, &minfo, cq->ibvcq.handle,
403+
&cq->mem_handle);
396404
if (ret)
397405
goto cmdfail;
398406
cq->toggle_map = mmap(NULL, minfo.alloc_size, PROT_READ,
@@ -2843,7 +2851,8 @@ struct ibv_srq *bnxt_re_create_srq(struct ibv_pd *ibvpd,
28432851
if (resp.comp_mask & BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT) {
28442852
minfo.type = BNXT_RE_SRQ_TOGGLE_MEM;
28452853
minfo.res_id = resp.srqid;
2846-
ret = bnxt_re_get_toggle_mem(ibvpd->context, &minfo, &srq->mem_handle);
2854+
ret = bnxt_re_get_toggle_mem(ibvpd->context, &minfo,
2855+
srq->ibvsrq.handle, &srq->mem_handle);
28472856
if (ret)
28482857
goto fail;
28492858
srq->toggle_map = mmap(NULL, minfo.alloc_size, PROT_READ,

0 commit comments

Comments
 (0)