From patchwork Tue Jul 12 19:36:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9226057 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 62DCA604DB for ; Tue, 12 Jul 2016 19:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51B3D2756B for ; Tue, 12 Jul 2016 19:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 468FD27C38; Tue, 12 Jul 2016 19:37:43 +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 7720827F94 for ; Tue, 12 Jul 2016 19:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751628AbcGLThj (ORCPT ); Tue, 12 Jul 2016 15:37:39 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:29971 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751620AbcGLThe (ORCPT ); Tue, 12 Jul 2016 15:37:34 -0400 Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 12 Jul 2016 12:37:11 -0700 Received: from EX13-CAS-006.vmware.com (smtp-inbound.vmware.com [10.113.191.56]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id DE75E1874F; Tue, 12 Jul 2016 12:37:31 -0700 (PDT) Received: from EX13-CAS-003.vmware.com (10.113.191.53) by EX13-MBX-007.vmware.com (10.113.191.27) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 12 Jul 2016 12:37:31 -0700 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-003.vmware.com (10.113.191.53) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Tue, 12 Jul 2016 12:37:31 -0700 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=idtbl9faJ45aLgGWx2JgA1M17J5QETjX62/NsmrqJrU=; b=qr1ip3DeLLTTSzqCsfGVBP3J2div9kSFwCFZEjCVcryNFuXie2ulTmkcIOpsuHhTfF9SwUQFs7x0w3Kf/gLuZNHvN1vm5xK/aMuUBssWEc0vLBoLS9iNIePlR4JGdVh3FDYZpUWJ4FEtkwXSQTkYZ6DdYqqgNzqLetMVelnZZY4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aditr@vmware.com; Received: from promb-2s-dhcp95-136.eng.vmware.com (208.91.1.34) by BLUPR0501MB834.namprd05.prod.outlook.com (10.141.251.148) with Microsoft SMTP Server (TLS) id 15.1.539.14; Tue, 12 Jul 2016 19:37:28 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v2 02/15] IB/pvrdma: Add device command support Date: Tue, 12 Jul 2016 12:36:32 -0700 Message-ID: <1468352205-9137-3-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468352205-9137-1-git-send-email-aditr@vmware.com> References: <1468352205-9137-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: SN1PR10CA0055.namprd10.prod.outlook.com (10.164.10.151) To BLUPR0501MB834.namprd05.prod.outlook.com (10.141.251.148) X-MS-Office365-Filtering-Correlation-Id: 0dda8dc3-0c6e-4202-7268-08d3aa8bf5d5 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB834; 2:Hd8HtiU5VZ3Wrrgs0khQVd1zKHI++1P6VdEPjf3P4ivY46GfWTR99pd7YaKm4wQGzhVhX233T64xwuKJwpyHd4Lqon2CLlkPWAB2Srhspe4Jc2IBirUqdalpf5/TWseJnrxl/WRIbaKGbr6Yi9k/Ys4U3jo7xb/L4FHluhskUbjjPh7mC8VuskEw9R+FZ4F0; 3:3dmMTsWnegFcCnEN7RnSzxyYJqCTUntWzaCQVCvNeyR0448QBqHqfUKBTNZJRo35cpAOeaI3P9DM4eDZpXsvrp7tI/WPFjnS3dYEMtWhj4m7Uf6XR9H0gBj+pnizH3R0; 25:97nYo2ZzAl0xGtNxvXjm0vInoZ1Padl/aWdqr6dUAK5N8Cft1P2i3hLBNcyGWeV3h/j5ERu+OU/PZPZ8E97Yu/b2QhFeeCMiUYBlrzrwzVwwXfbwOKwMNSb/x4FDrAuAKQe56oFh6dUA/zHhv4ua0OTshIlLAfmsgF8EwI7JQyY3Li9yK9Qc+0XclirW72Q2/uJlJOA507ePojNI7Du3xHcn3Nqu3LUwp8Yx9Xl7SCzYF9bc+NGf9LrCkYvbVC26MGafTvsWRdJMXwZ7Vu5z60KOVibGGm4Xw0lek8kIShWGVOUCruDiGwVQQSAcNSd18YE/AUBHLYAveT68o6YOfqqKCw5esJZ1hh2UOvyzSWb6022mQcDaIIVcN7gbuxGU8uljz2wl2X229yPc3XgW1+j3Y1Ln4g2rUfMoeHMiZxA= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0501MB834; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0501MB834; 31:KCmUwiKNI4v6ixR9FXeTRa2si+6umrQP2sN+YXG1m+p74TcIHkRbOQrJe3DF0nhrJGvLFucsfCC3smNBho3TM7r8JqqIiwUqVoSWbGVdCJmEmme1uI0oFc9L+5xb0GI23UVkkfG2Rm2m8JfAQGIfJILTOi6Rq5QV4ZC4zD/K1gDq3Ix5/g/DSzPD1yCZgFwg9LAfijg5buPtCLFqcrAWGQ==; 20:wX/b612bX/Mteh7jYmCTMP4NnTg8Tq4oWSw0aJzCeh8Chiv6fcjfiIqXSREE1434KYkR2Cw4yqHWIMIOCv/doxjYwM4Us28BlJhvT+jJQXBL/GXt+6WHjomwXUCDzxVOK02NP8zZBC8Nujmo4B0ttaDldkMJxOaWsnf8usX4c2HgTkjLzCAmVBLRyB85HIILTRfDQi5dH+Gdoiqk1E+o5TLp8c25HQaQWFCdMyLiVOw1n34ZhBgYEoSWcvU3SvPQ; 4:YelzRbHfxPLTjVzpCUw7mzP3fVskPBBU7TZ9iZPNCu5RBBjzhjRcJLnx0lS0+ahdFe+VAMOhc9vG3LGc6fm5NUetuyDbCMrdhTS7DY3IBchqCgJeVPZaKqMu/PTx+nSABUcPTGWNomQ+enzeoHdZXMP3Bve7GobboQXdAiLWOU4GsCdpTid4LDWh6rGEtlTRJ7qbVmJH9E4N/KcPw0ufCqvo+2zTHFT31Id5Vuj65Z7t0rCe+/o/vWL+ewI0vrC59Em1rNakaxOEjEL/Gfwq4sdY8+ko97Sry7WMxHeB9XbzIOYny/3Ph28HMGT9pKTmfRF7FdsPsBVtIxuEuGOAqNzu4XUOBz442AHlcpJlG+nwuE9OJy5JP2Y95/dsJsK/TZOywozpusNsaf07wFyJ9h8UyM9stgU7suPEF4Qkv8Rt+yGDF8b1VipamJCXOiyvTzWysshMs faEl50Jo7He8y5t/7czYLV/tXf3iu/uXU k= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(61668805478150)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:BLUPR0501MB834; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0501MB834; X-Forefront-PRVS: 0001227049 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(305945005)(7736002)(50226002)(86362001)(4326007)(2906002)(42186005)(7846002)(68736007)(33646002)(229853001)(106356001)(50986999)(586003)(3846002)(2201001)(6116002)(15975445007)(97736004)(81166006)(81156014)(48376002)(36756003)(5003940100001)(19580395003)(19580405001)(47776003)(2950100001)(77096005)(66066001)(50466002)(4001450100002)(4001430100002)(101416001)(92566002)(189998001)(76176999)(105586002)(8676002)(107886002)(5001770100001)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0501MB834; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (EX13-EDG-OU-002.vmware.com: aditr@vmware.com does not designate permitted sender hosts) Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0501MB834; 23:oMmTnbNSQ1vPvPAo8CLDeyslBeL/tb1K7fMu+vvk?= =?us-ascii?Q?rsOPZCI7TwRy5GNMWTbAihNNztCMKWoZBigENYatfWRCx2GHputRBDsgKPuN?= =?us-ascii?Q?wAtcDM73bsb4cC3LgnRf7NosIMqxfhiTsQbHaMqc0+hh4eDNlV4o5rtgCJyf?= =?us-ascii?Q?zRlt/3SwJs7+TRFhqWQgP5KlM7ZIdPQg/6FzqZpo+MP9wf0zQRgLGEf9v1nB?= =?us-ascii?Q?TKlVNYZ0nqxdZ7aRXT4INEMmY2yrW4ffuL3VvubNKOv99rMtVkzEYqMcvFHl?= =?us-ascii?Q?wwcEhfgaqsmTjR/5nJHcW3NOQ6mLTdzk10aPxt1Q8QD7pGbPDO+yYCMXbQUH?= =?us-ascii?Q?tObX2V1LzS7X8rRTGTVWXCrCr6CbSL0ez7McbhT3tZD+xlPKecT6kcBN6GI5?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Bs9F3MmIH53g2aeLnUKDs= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 19:37:28.0536 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0501MB834 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 This patch enables posting Verb requests and receiving responses to/from the backend PVRDMA emulation layer. Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive --- drivers/infiniband/hw/pvrdma/pvrdma_cmd.c | 104 ++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 drivers/infiniband/hw/pvrdma/pvrdma_cmd.c diff --git a/drivers/infiniband/hw/pvrdma/pvrdma_cmd.c b/drivers/infiniband/hw/pvrdma/pvrdma_cmd.c new file mode 100644 index 0000000..c22debf --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_cmd.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of EITHER the GNU General Public License + * version 2 as published by the Free Software Foundation or the BSD + * 2-Clause License. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License version 2 for more details at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. + * + * You should have received a copy of the GNU General Public License + * along with this program available in the file COPYING in the main + * directory of this source tree. + * + * The BSD 2-Clause License + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "pvrdma.h" + +#define PVRDMA_CMD_TIMEOUT 10000 /* ms */ + +static int pvrdma_cmd_recv(struct pvrdma_dev *dev, union pvrdma_cmd_resp *resp) +{ + dev_dbg(&dev->pdev->dev, "receive response from device\n"); + + spin_lock(&dev->cmd_lock); + memcpy(resp, dev->resp_slot, sizeof(*resp)); + spin_unlock(&dev->cmd_lock); + + return 0; +} + +int +pvrdma_cmd_post(struct pvrdma_dev *dev, union pvrdma_cmd_req *req, + bool expect_resp, union pvrdma_cmd_resp *resp) +{ + int err; + + dev_dbg(&dev->pdev->dev, "post request to device\n"); + + /* Serializiation */ + down(&dev->cmd_sema); + + spin_lock(&dev->cmd_lock); + memcpy(dev->cmd_slot, req, sizeof(*req)); + spin_unlock(&dev->cmd_lock); + + init_completion(&dev->cmd_done); + pvrdma_write_reg(dev, PVRDMA_REG_REQUEST, 0); + + /* Make sure the request is written before reading status. */ + mb(); + err = pvrdma_read_reg(dev, PVRDMA_REG_ERR); + if (err == 0) { + if (expect_resp) { + err = wait_for_completion_interruptible_timeout( + &dev->cmd_done, + msecs_to_jiffies(PVRDMA_CMD_TIMEOUT)); + if (err == 0) { + dev_warn(&dev->pdev->dev, + "completion timeout\n"); + err = -ETIMEDOUT; + } else { + err = pvrdma_cmd_recv(dev, resp); + } + } + } else { + dev_warn(&dev->pdev->dev, "failed to write request %d\n", err); + } + + up(&dev->cmd_sema); + + return err; +}