RDMA/bnxt_re: Update kernel user abi to pass chip context
authorDevesh Sharma <devesh.sharma@broadcom.com>
Thu, 7 Feb 2019 06:31:27 +0000 (01:31 -0500)
committerJason Gunthorpe <jgg@mellanox.com>
Thu, 7 Feb 2019 20:24:49 +0000 (13:24 -0700)
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>
drivers/infiniband/hw/bnxt_re/ib_verbs.c
include/uapi/rdma/bnxt_re-abi.h

index 08c1725f371a57d798d05a497933bbe431619d8e..1d7469e23cde0a06a0618f13099fa68b30e6dab0 100644 (file)
@@ -3692,9 +3692,10 @@ struct ib_ucontext *bnxt_re_alloc_ucontext(struct ib_device *ibdev,
                                           struct ib_udata *udata)
 {
        struct bnxt_re_dev *rdev = to_bnxt_re_dev(ibdev, ibdev);
+       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
        struct bnxt_re_uctx_resp resp;
        struct bnxt_re_ucontext *uctx;
-       struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
+       u32 chip_met_rev_num = 0;
        int rc;
 
        dev_dbg(rdev_to_dev(rdev), "ABI version requested %d",
@@ -3719,14 +3720,24 @@ struct ib_ucontext *bnxt_re_alloc_ucontext(struct ib_device *ibdev,
        }
        spin_lock_init(&uctx->sh_lock);
 
-       resp.dev_id = rdev->en_dev->pdev->devfn; /*Temp, Use idr_alloc instead*/
+       resp.comp_mask |= BNXT_RE_UCNTX_CMASK_HAVE_CCTX;
+       chip_met_rev_num = rdev->chip_ctx.chip_num;
+       chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_rev & 0xFF) <<
+                            BNXT_RE_CHIP_ID0_CHIP_REV_SFT;
+       chip_met_rev_num |= ((u32)rdev->chip_ctx.chip_metal & 0xFF) <<
+                            BNXT_RE_CHIP_ID0_CHIP_MET_SFT;
+       resp.chip_id0 = chip_met_rev_num;
+       /* Future extension of chip info */
+       resp.chip_id1 = 0;
+       /*Temp, Use idr_alloc instead */
+       resp.dev_id = rdev->en_dev->pdev->devfn;
        resp.max_qp = rdev->qplib_ctx.qpc_count;
        resp.pg_size = PAGE_SIZE;
        resp.cqe_sz = sizeof(struct cq_base);
        resp.max_cqd = dev_attr->max_cq_wqes;
        resp.rsvd    = 0;
 
-       rc = ib_copy_to_udata(udata, &resp, sizeof(resp));
+       rc = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
        if (rc) {
                dev_err(rdev_to_dev(rdev), "Failed to copy user context");
                rc = -EFAULT;
index a7a6111e50c7f95291a98f6ce9f9cd642941b6e8..dc52e3cf574ca7d92b7898e7a44e6cb6f816cd5c 100644 (file)
 
 #define BNXT_RE_ABI_VERSION    1
 
+#define BNXT_RE_CHIP_ID0_CHIP_NUM_SFT          0x00
+#define BNXT_RE_CHIP_ID0_CHIP_REV_SFT          0x10
+#define BNXT_RE_CHIP_ID0_CHIP_MET_SFT          0x18
+
+enum {
+       BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL
+};
+
 struct bnxt_re_uctx_resp {
        __u32 dev_id;
        __u32 max_qp;
@@ -51,6 +59,9 @@ struct bnxt_re_uctx_resp {
        __u32 cqe_sz;
        __u32 max_cqd;
        __u32 rsvd;
+       __aligned_u64 comp_mask;
+       __u32 chip_id0;
+       __u32 chip_id1;
 };
 
 /*