From patchwork Sat Jan 26 05:55:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devesh Sharma X-Patchwork-Id: 10782333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5943513B5 for ; Sat, 26 Jan 2019 05:55:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 488AB2FC37 for ; Sat, 26 Jan 2019 05:55:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CF2C2FC43; Sat, 26 Jan 2019 05:55:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC72F2FC37 for ; Sat, 26 Jan 2019 05:55:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbfAZFz5 (ORCPT ); Sat, 26 Jan 2019 00:55:57 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:43341 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbfAZFz5 (ORCPT ); Sat, 26 Jan 2019 00:55:57 -0500 Received: by mail-ed1-f67.google.com with SMTP id f9so8980964eds.10 for ; Fri, 25 Jan 2019 21:55:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LjAS/08FzseZG+HlgnPW6Lok6tc83Us4lUNXxB+Rngc=; b=BQxfMY9KLGJJ3cLZHe0VZ3iHkTSt0Be0PlqkGVICYblvbipq2P1iXef+wJ7mC1nX9D jGKsK65XNj+rubWFc7gwPWiIiPlNFH8bFpxxvmmfU+FDHVxYimo1XBrxPQcKrmo4iokH 0DpI23EiFeqOOKLvAEvUyZgMAQUAkhCMC8FC4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LjAS/08FzseZG+HlgnPW6Lok6tc83Us4lUNXxB+Rngc=; b=OnftIP4OqUhpBQv7DSgRuL0mASWlU7oHHeOJzL543XK2bSQAOg07eTm4AjaWFLZJ1e m8cjaBcvK7dIl0Ixq03pwJG3LELnM4T9cAs41GttqwJ/bZaYZm118ONsLmvpud1IAwfY QwccMURutE7XbcLEWDdoydk4X51pzdu9uIVpyktIfdfGnIIldTtCeEoep1PsaIpotIJP +pSrbX2MR4yEGZbWDFWBXseaPMnjdSRY9xOKqgHza7LRzeP74vqc5MbcE8IJAYIoAvmT 036IF2ikoS54tEdpFBtEqBreA4pEMNrf5FBPmxRW8YRgNGj1hFxboK+/kh+zdbMyJrE7 ytVQ== X-Gm-Message-State: AJcUukeIssGVp2kBp6Ynw+MwB9zgQii6KvnFItJVmGNGMhywSp6aGg56 YcKC2ZaM2EAsKSB6aUn4zHFBGByBiv+KxyC6XIWQavkk6wei77ypNytbDlP2IB+1q7m5yfpRsHD ajzTGEXuwB0Qp3hcIboRdhWiikELE4zk/nrIvCA6haeIEGANX1at2OecSr3KC4cmK+FxspRRy4C 1j9QQ= X-Google-Smtp-Source: ALg8bN4VDXUJ51IxgLMzz5+3bUWI1o+MDIqKS5DZLo+Ox4zHTwQDT3a0j+T06MEnOQHsuloKShvvkQ== X-Received: by 2002:a50:c11a:: with SMTP id l26mr13350312edf.233.1548482155376; Fri, 25 Jan 2019 21:55:55 -0800 (PST) Received: from neo00-el73.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c53sm13091363ede.26.2019.01.25.21.55.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Jan 2019 21:55:54 -0800 (PST) From: Devesh Sharma To: linux-rdma@vger.kernel.org Cc: dledford@redhat.com, jgg@mellanox.com, Devesh Sharma Subject: [for-next V4 6/7] RDMA/bnxt_re: Update kernel user abi to pass chip context Date: Sat, 26 Jan 2019 00:55:19 -0500 Message-Id: <1548482120-10898-7-git-send-email-devesh.sharma@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1548482120-10898-1-git-send-email-devesh.sharma@broadcom.com> References: <1548482120-10898-1-git-send-email-devesh.sharma@broadcom.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 17 ++++++++++++++--- include/uapi/rdma/bnxt_re-abi.h | 11 +++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 08c1725..1d7469e 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -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; diff --git a/include/uapi/rdma/bnxt_re-abi.h b/include/uapi/rdma/bnxt_re-abi.h index a7a6111..dc52e3c 100644 --- a/include/uapi/rdma/bnxt_re-abi.h +++ b/include/uapi/rdma/bnxt_re-abi.h @@ -44,6 +44,14 @@ #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; }; /*