Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/bnxt_re: Update kernel user abi to pass chip context

User space verbs provider library would need chip context. Changing the
ABI to add chip version details in structure. Furthermore, changing the
kernel driver ucontext allocation code to initialize the abi structure
with appropriate values.

As suggested by community, appended the new fields at the bottom of the
ABI structure and retaining to older fields as those were in the older
versions.

Keeping the ABI version at 1 and adding a new field in the ucontext
response structure to hold the component mask. The user space library
should check pre-defined flags to figure out if a certain feature is
supported on not.

Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Devesh Sharma and committed by
Jason Gunthorpe
95b86d1c 37f91cff

+25 -3
+14 -3
drivers/infiniband/hw/bnxt_re/ib_verbs.c
··· 3692 3692 struct ib_udata *udata) 3693 3693 { 3694 3694 struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev); 3695 + struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr; 3695 3696 struct bnxt_re_uctx_resp resp; 3696 3697 struct bnxt_re_ucontext *uctx; 3697 - struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr; 3698 + u32 chip_met_rev_num = 0; 3698 3699 int rc; 3699 3700 3700 3701 dev_dbg(rdev_to_dev(rdev), "ABI version requested %d", ··· 3720 3719 } 3721 3720 spin_lock_init(&uctx->sh_lock); 3722 3721 3723 - resp.dev_id = rdev->en_dev->pdev->devfn; /*Temp, Use idr_alloc instead*/ 3722 + resp.comp_mask |= BNXT_RE_UCNTX_CMASK_HAVE_CCTX; 3723 + chip_met_rev_num = rdev->chip_ctx.chip_num; 3724 + chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_rev & 0xFF) << 3725 + BNXT_RE_CHIP_ID0_CHIP_REV_SFT; 3726 + chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_metal & 0xFF) << 3727 + BNXT_RE_CHIP_ID0_CHIP_MET_SFT; 3728 + resp.chip_id0 = chip_met_rev_num; 3729 + /* Future extension of chip info */ 3730 + resp.chip_id1 = 0; 3731 + /*Temp, Use idr_alloc instead */ 3732 + resp.dev_id = rdev->en_dev->pdev->devfn; 3724 3733 resp.max_qp = rdev->qplib_ctx.qpc_count; 3725 3734 resp.pg_size = PAGE_SIZE; 3726 3735 resp.cqe_sz = sizeof(struct cq_base); 3727 3736 resp.max_cqd = dev_attr->max_cq_wqes; 3728 3737 resp.rsvd = 0; 3729 3738 3730 - rc = ib_copy_to_udata(udata, &resp, sizeof(resp)); 3739 + rc = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp))); 3731 3740 if (rc) { 3732 3741 dev_err(rdev_to_dev(rdev), "Failed to copy user context"); 3733 3742 rc = -EFAULT;
+11
include/uapi/rdma/bnxt_re-abi.h
··· 44 44 45 45 #define BNXT_RE_ABI_VERSION 1 46 46 47 + #define BNXT_RE_CHIP_ID0_CHIP_NUM_SFT 0x00 48 + #define BNXT_RE_CHIP_ID0_CHIP_REV_SFT 0x10 49 + #define BNXT_RE_CHIP_ID0_CHIP_MET_SFT 0x18 50 + 51 + enum { 52 + BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL 53 + }; 54 + 47 55 struct bnxt_re_uctx_resp { 48 56 __u32 dev_id; 49 57 __u32 max_qp; ··· 59 51 __u32 cqe_sz; 60 52 __u32 max_cqd; 61 53 __u32 rsvd; 54 + __aligned_u64 comp_mask; 55 + __u32 chip_id0; 56 + __u32 chip_id1; 62 57 }; 63 58 64 59 /*