From patchwork Wed Aug 23 06:19:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9916637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD49460327 for ; Wed, 23 Aug 2017 06:19:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E37827FB0 for ; Wed, 23 Aug 2017 06:19:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92F7E28556; Wed, 23 Aug 2017 06:19:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 CF4E827FB0 for ; Wed, 23 Aug 2017 06:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbdHWGTW (ORCPT ); Wed, 23 Aug 2017 02:19:22 -0400 Received: from mail-dm3nam03on0079.outbound.protection.outlook.com ([104.47.41.79]:61327 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753057AbdHWGTV (ORCPT ); Wed, 23 Aug 2017 02:19:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xgymzcQLCZFxjKVn840jJzFGkoLING1d258EfQki6p0=; b=RD5mtz35bDonmEWlpovGdDmc6I9ulhIgg9HcaU3omBhqOBwkP2TWf+PgVREUjqNns5umc/4jhFA7bwwV0TfTXtG8cOfsgYgjr3RtlN6jN0lwi4pNq0uXgl0ADYkrvdYIO8Sz4zgoLYJOtcZAo7usLlC1TMpzKs4iE2DPPSgtfuc= Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by DM5PR05MB3516.namprd05.prod.outlook.com (10.174.242.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.4; Wed, 23 Aug 2017 06:19:19 +0000 From: Adit Ranadive To: dledford@redhat.com, linux-rdma@vger.kernel.org Cc: Bryan Tan , pv-drivers@vmware.com, Adit Ranadive Subject: [PATCH for-next v1 1/2] RDMA/vmw_pvrdma: Add RoCEv2 support Date: Tue, 22 Aug 2017 23:19:00 -0700 Message-Id: <91bf53451b8618acc731f6b8b4235103abae7687.1503468979.git.aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CO2PR05CA0071.namprd05.prod.outlook.com (10.166.88.167) To DM5PR05MB3516.namprd05.prod.outlook.com (10.174.242.145) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 569cae5e-d1d3-43f3-0349-08d4e9eee3bf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR05MB3516; X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB3516; 3:2ysXDqOOtAOT12Lt0UpewQ+d/KdNFL7V6z6/f4SvV3AxtZihDoYviR98a3Zrp8EvUqLxZ/IAp7SIWamMWtvCr16efWSx+f7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9NO2L3CbxgRZ7l6rl2bxPcUtFnZbU45OwKV5OQ9a/MzlywzPHOiyLoBwtBC9w7ZTHNt+dgyM80ATxwZZGXUAyotjGIRGf9kwr9MOms/eQAOrfJ567jJTt/Ke8LhqnXfdmQ/myve+O41LLtvK27pAEq9O7ocGvXt/hU2DfXDZIQjt5aFt732A5hqFjIJcnsr6t6UhquDRasq0J6NxWOq6+oB2OpQiLlNmG1DCtPevf1v5THU8RBMs45eFUEe/El5; 4:wVWo2VLaZS1dBObGukglbj20LncYGiMAWHiryoEIpnr2Vxh2KPS/+FoVoLE87wKh9TROW9+UP7TzoQXJqXMSuOZfEXR2QPjr41VPfxPlDX1eDLy5kFVvtbnAYJnLon0lN5RocOJieHlMI3OdIbfqBYWbVJZqckNQsEOEKuLUHEFZ9TrZdwVd47FgstTSBIAAuP1qKIJyRrOI1nCRDgINFWT8vhguOgCYT2cVRI4/GsiE84TtoAgpEhf6dBBSEO3511pn4CBJyu1j2FM6WRM61Qw8Fr1nkb+kTX6l41T7j18= X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR05MB3516; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR05MB3516; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(189002)(199003)(6486002)(118296001)(189998001)(101416001)(4326008)(105586002)(33646002)(6666003)(2950100002)(97736004)(106356001)(305945005)(2906002)(7350300001)(25786009)(53936002)(5003940100001)(110136004)(47776003)(36756003)(107886003)(42186005)(478600001)(3846002)(7736002)(50466002)(81166006)(48376002)(86362001)(68736007)(575784001)(54906002)(50226002)(81156014)(6116002)(50986999)(8676002)(5660300001)(66066001)(76176999); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR05MB3516; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aditr@vmware.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR05MB3516; 23:BRBFOghAx5wWJcoDaUwsJz03BM1Mn50dAGZJcbd8O?= =?us-ascii?Q?ne3aicT2J8kOX5ws5d0lKTxsISwioGtOpxIXkIG3VtroG5Wu8KcvsUoqQRlH?= =?us-ascii?Q?IYF6i7EU7t2QmMB7TnR3SxZLMeLVvoLMdJW7/9BQCpqow9aqt/dg6dYsRrb+?= =?us-ascii?Q?BpCp5MlREsNxvjVl1X5Z/aqPnDEgKe4IEAgG2QdBL5joViqyMR+sv9RMl8xK?= =?us-ascii?Q?uVQrqKLqhr1rhmpaXoTp/UV0NT7TZUl51gMfJu6fBMtvJ8CgWhsyG+vmRFhz?= =?us-ascii?Q?w57F+iWh9Srrmvqb/DtetopcxYNSe7kfW2vD2Zzz6vNyDSzugSfBO3fI8nUC?= =?us-ascii?Q?p1W9hECl5J2pEAfUWriZBJREuKhMeq9jzelGK1TITejjvTADCBZYeQaGz5dE?= =?us-ascii?Q?3zIL8RgKuFOztEQYVtWQyusz3OVFlsAqPgDiCitbXuEaWrNyMOQCP+H457g/?= =?us-ascii?Q?ysWCp9K9fHyw2stWbdHWIMm8teXkyUNnlH7B54+ihXsVJS4BTH2yGgdjcwK5?= =?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6u01sWgdP48+Q8RhRGs8qEyUTbonup+9qDJ7D1M2/HhJqr2FAcCCSPd2VEfEdiVf9ZDBgNLvg9v85A==; 5:0PezwRk4SjYK3L0+cHaP77GkoAoxsquHLKn524fqfz2unxqRbFHZau5vEC/vDuZEesHg4rq4/yXVbstXRJdPQRAbsMgVa/iuKqSkfyWvCphKOsaGNVYtYoe8hdU6001T4cvMM1xTi7jpa6OYl5JqNA==; 24:ksJhk496ek0zG5YJ2f2EjxnH5dv1vreVwAOVtZwL8t3GKBrEEGmUCxHm+F3HFIHd3UGD+mEA3ckisfczTc6dJfqVSBlpuUtNJVkXZyiv65I=; 7:EzXDHEy4dc+gQsYwVbXLTHT2ObQvMo8reRpkFicX/zuycka9lzYEs9YwtWSIIfzUoWNsv+7ydM+XTvc64FbNZ1dDmlJtqB2qH8X+NZPVt2Nv4ggI1c6CvTPNOOiXff9VWl0MFK/v2beIQgp5ZD2jph+h4je5GvXZwGp9cbwr297t9jjg09tSoFTUypGzGSOpuTu49BZo7YqPI2AvjSl6IaFeggl+18KY0WKyGOmoSgU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR05MB3516; 20:h4OdVVtKojewzGbZt5wixiVnYYnb0NbtjIMYlj0O5M39WrWbqsLdAafcm1E+NAX5rgb5d8EpdbnREMx6y5U1xQx3C/HcdLn2u42YgvqlH/7II1kEFZGEuEYGs6IwhOFFN1Y5tgHHfBYrQg3VaDxTTql/tyFJlasjGhLLq6bLYdI= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 06:19:19.1485 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR05MB3516 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 From: Bryan Tan The driver version is bumped for compatibility purposes. Also, send correct GID type during register to device. Added compatibility check macros for the device. Reviewed-by: Jorgen Hansen Reviewed-by: Aditya Sarwade Signed-off-by: Bryan Tan Signed-off-by: Adit Ranadive Reviewed-by: Leon Romanovsky Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/vmw_pvrdma/pvrdma.h | 2 ++ drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h | 28 +++++++++++++++++- drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c | 36 ++++++++++------------- drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c | 7 +++++ 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h index 8e2f0a1..663a0c3 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma.h @@ -194,6 +194,7 @@ struct pvrdma_dev { void *resp_slot; unsigned long flags; struct list_head device_link; + unsigned int dsr_version; /* Locking and interrupt information. */ spinlock_t cmd_lock; /* Command lock. */ @@ -444,6 +445,7 @@ void pvrdma_ah_attr_to_rdma(struct rdma_ah_attr *dst, const struct pvrdma_ah_attr *src); void rdma_ah_attr_to_pvrdma(struct pvrdma_ah_attr *dst, const struct rdma_ah_attr *src); +u8 ib_gid_type_to_pvrdma(enum ib_gid_type gid_type); int pvrdma_uar_table_init(struct pvrdma_dev *dev); void pvrdma_uar_table_cleanup(struct pvrdma_dev *dev); diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h index 09078cc..3a308ff 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h @@ -50,7 +50,15 @@ #include "pvrdma_verbs.h" -#define PVRDMA_VERSION 17 +/* + * PVRDMA version macros. Some new features require updates to PVRDMA_VERSION. + * These macros allow us to check for different features if necessary. + */ + +#define PVRDMA_ROCEV1_VERSION 17 +#define PVRDMA_ROCEV2_VERSION 18 +#define PVRDMA_VERSION PVRDMA_ROCEV2_VERSION + #define PVRDMA_BOARD_ID 1 #define PVRDMA_REV_ID 1 @@ -123,6 +131,24 @@ #define PVRDMA_GID_TYPE_FLAG_ROCE_V1 BIT(0) #define PVRDMA_GID_TYPE_FLAG_ROCE_V2 BIT(1) +/* + * Version checks. This checks whether each version supports specific + * capabilities from the device. + */ + +#define PVRDMA_IS_VERSION17(_dev) \ + (_dev->dsr_version == PVRDMA_ROCEV1_VERSION && \ + _dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V1) + +#define PVRDMA_IS_VERSION18(_dev) \ + (_dev->dsr_version >= PVRDMA_ROCEV2_VERSION && \ + (_dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V1 || \ + _dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V2)) \ + +#define PVRDMA_SUPPORTED(_dev) \ + ((_dev->dsr->caps.mode == PVRDMA_DEVICE_MODE_ROCE) && \ + (PVRDMA_IS_VERSION17(_dev) || PVRDMA_IS_VERSION18(_dev))) + enum pvrdma_pci_resource { PVRDMA_PCI_RESOURCE_MSIX, /* BAR0: MSI-X, MMIO. */ PVRDMA_PCI_RESOURCE_REG, /* BAR1: Registers, MMIO. */ diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c index 5b00156..6ce709a 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_main.c @@ -128,10 +128,14 @@ static int pvrdma_init_device(struct pvrdma_dev *dev) static int pvrdma_port_immutable(struct ib_device *ibdev, u8 port_num, struct ib_port_immutable *immutable) { + struct pvrdma_dev *dev = to_vdev(ibdev); struct ib_port_attr attr; int err; - immutable->core_cap_flags = RDMA_CORE_PORT_IBA_ROCE; + if (dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V1) + immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE; + else if (dev->dsr->caps.gid_types == PVRDMA_GID_TYPE_FLAG_ROCE_V2) + immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP; err = ib_query_port(ibdev, port_num, &attr); if (err) @@ -569,6 +573,7 @@ static void pvrdma_free_slots(struct pvrdma_dev *dev) static int pvrdma_add_gid_at_index(struct pvrdma_dev *dev, const union ib_gid *gid, + u8 gid_type, int index) { int ret; @@ -586,7 +591,7 @@ static int pvrdma_add_gid_at_index(struct pvrdma_dev *dev, cmd_bind->mtu = ib_mtu_enum_to_int(IB_MTU_1024); cmd_bind->vlan = 0xfff; cmd_bind->index = index; - cmd_bind->gid_type = PVRDMA_GID_TYPE_FLAG_ROCE_V1; + cmd_bind->gid_type = gid_type; ret = pvrdma_cmd_post(dev, &req, NULL, 0); if (ret < 0) { @@ -607,7 +612,9 @@ static int pvrdma_add_gid(struct ib_device *ibdev, { struct pvrdma_dev *dev = to_vdev(ibdev); - return pvrdma_add_gid_at_index(dev, gid, index); + return pvrdma_add_gid_at_index(dev, gid, + ib_gid_type_to_pvrdma(attr->gid_type), + index); } static int pvrdma_del_gid_at_index(struct pvrdma_dev *dev, int index) @@ -722,7 +729,6 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, int ret; unsigned long start; unsigned long len; - unsigned int version; dma_addr_t slot_dma = 0; dev_dbg(&pdev->dev, "initializing driver %s\n", pci_name(pdev)); @@ -819,13 +825,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, goto err_unmap_regs; } - version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION); + dev->dsr_version = pvrdma_read_reg(dev, PVRDMA_REG_VERSION); dev_info(&pdev->dev, "device version %d, driver version %d\n", - version, PVRDMA_VERSION); - if (version < PVRDMA_VERSION) { - dev_err(&pdev->dev, "incompatible device version\n"); - goto err_uar_unmap; - } + dev->dsr_version, PVRDMA_VERSION); dev->dsr = dma_alloc_coherent(&pdev->dev, sizeof(*dev->dsr), &dev->dsrbase, GFP_KERNEL); @@ -896,17 +898,9 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, /* Make sure the write is complete before reading status. */ mb(); - /* Currently, the driver only supports RoCE mode. */ - if (dev->dsr->caps.mode != PVRDMA_DEVICE_MODE_ROCE) { - dev_err(&pdev->dev, "unsupported transport %d\n", - dev->dsr->caps.mode); - ret = -EFAULT; - goto err_free_cq_ring; - } - - /* Currently, the driver only supports RoCE V1. */ - if (!(dev->dsr->caps.gid_types & PVRDMA_GID_TYPE_FLAG_ROCE_V1)) { - dev_err(&pdev->dev, "driver needs RoCE v1 support\n"); + /* The driver supports RoCE V1 and V2. */ + if (!PVRDMA_SUPPORTED(dev)) { + dev_err(&pdev->dev, "driver needs RoCE v1 or v2 support\n"); ret = -EFAULT; goto err_free_cq_ring; } diff --git a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c index ec6a4ca..fb0c5c0 100644 --- a/drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c +++ b/drivers/infiniband/hw/vmw_pvrdma/pvrdma_misc.c @@ -303,3 +303,10 @@ void rdma_ah_attr_to_pvrdma(struct pvrdma_ah_attr *dst, dst->port_num = rdma_ah_get_port_num(src); memcpy(&dst->dmac, src->roce.dmac, sizeof(dst->dmac)); } + +u8 ib_gid_type_to_pvrdma(enum ib_gid_type gid_type) +{ + return (gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP) ? + PVRDMA_GID_TYPE_FLAG_ROCE_V2 : + PVRDMA_GID_TYPE_FLAG_ROCE_V1; +}