From patchwork Wed Jul 6 06:14:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9215535 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 B741E607D9 for ; Wed, 6 Jul 2016 06:31:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A720B286FA for ; Wed, 6 Jul 2016 06:31:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BEB2286FD; Wed, 6 Jul 2016 06:31:42 +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 11DE3286FA for ; Wed, 6 Jul 2016 06:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752413AbcGFGbl (ORCPT ); Wed, 6 Jul 2016 02:31:41 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:54493 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbcGFGbj (ORCPT ); Wed, 6 Jul 2016 02:31:39 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 5 Jul 2016 23:15:06 -0700 Received: from EX13-CAS-001.vmware.com (ex13-cas-001.vmware.com [10.113.191.51]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id C169B407BA; Tue, 5 Jul 2016 23:15:19 -0700 (PDT) Received: from EX13-CAS-001.vmware.com (10.113.191.51) by EX13-MBX-017.vmware.com (10.113.191.37) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Tue, 5 Jul 2016 23:15:19 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-001.vmware.com (10.113.191.51) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Tue, 5 Jul 2016 23:15:19 -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=mIu8EAlJkipPl0IfmfJOhHNRB1Y88auRdkvlzjZ3W0PHNRy/LHdk2jc5n+tdY/uVaayVApyIkMfj4bfLaTP8dsxsjqT+ke9G5C0VZ8FbFcP+eZA0Bgu07HZvczqGFxYnD0Umi1G4gwkcFstJDvOfUwWOk4sHr2YFXQ/DROFOj2c= 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 SN2PR0501MB848.namprd05.prod.outlook.com (10.160.14.146) with Microsoft SMTP Server (TLS) id 15.1.528.16; Wed, 6 Jul 2016 06:15:13 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v1 02/15] IB/pvrdma: Add device command support Date: Tue, 5 Jul 2016 23:14:35 -0700 Message-ID: <1467785688-23229-3-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467785688-23229-1-git-send-email-aditr@vmware.com> References: <1467785688-23229-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CO2PR11CA0028.namprd11.prod.outlook.com (10.141.242.166) To SN2PR0501MB848.namprd05.prod.outlook.com (10.160.14.146) X-MS-Office365-Filtering-Correlation-Id: bf6d92dd-828d-4000-b933-08d3a564e4d1 X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB848; 2:is+fk9EDQWlnSA0oV82o/69V4nK6UwE5Yu8UgEIIDmEIkFj+6zmjElnCPGitqDMciNSMppAu9EkAzxty37WNw+joR6sVRXnLU+JGWmeZH+ThbyN4LC+Oc8tWtO8JAAR58EFDTpjs+2QGoNabDNyJs5i+OwICXYdCuUkQolOWpegFdz72GoxmI8fhVAKyBPu1; 3:64xyKxENJ8nRFFHb0koDmyyHJEaLAuQA2w9ilStuBfKJT1c/277GkFPpbCLGZ36UmayCtls+/6VOb9QFVB1xt3qTNBVDXIFLo1aKl29JVXRE0g4iYmoIvIXrdyrC1sZC X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0501MB848; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB848; 25:49fc33Jp4rKLwAVAD6ORcr4blzCb4CCXjmvkYRkAoJLXQAruA4ZlwUIX6sjNP9/9BZQpa7ShGzOG967bm1eKLreVJ6n2NQldWGa12xjzIJh30Uc7eSOpt7Mob6FUc2Csj6+PhV/DjVtEUSB1M6p+4Zg5EV82wwcukq9Ldkvo0R4S3uZlpk2KoS1hm1xO8uHxv/9SDjvFQqg7ZsqPBxzNgdmGf7DMIQXzBaXqFoZWjV762ShVhrvnh2/otKbbizPrb//Gsfkgd75NGhJkQGtoMAIox6vo1LumHnH0/ahYHdiSc4YbZ92ozZ3Wh9Dy9koCbFx8XZ0jI2BntZPC7FScKeSPc8ZebAeGj4ar7DE4Cj1NusOAwOYkpcRsWcNolAXxSCJuHlzGcEtF+4w2YGXDIfXa0YZu7MHaUOA/hNUwPhyZ75hPWt/vEabEhXGugXN+sgJjoR6ljz4Y8uLUvD0OmtqZDwB7zFg0wKJg6ixk99ONQTXHCbyrGwYEFR3jpxha59jCo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ieWaenXPXx8qjWP1gJEsead5BGD66FtOU5M6ZPYvR4mL0hwJk1CsYL4T3WFjD6GSMwo6L0FrXTH/QTKWuzA/mI27OoFgPoTf/uZoWst/XCajf3Cez8LmYErbn2HhULxrWgNn/kPviEpE9Ky06SaP54X5UPKb3PO2dl97XtBbZD7o7tNlA4S1NzZ GDUIZNIvRMZp92H7LUpza8bnQfnsWjQX7k= 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:SN2PR0501MB848; BCL:0; PCL:0; RULEID:; SRVR:SN2PR0501MB848; X-Forefront-PRVS: 0995196AA2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(189002)(199003)(81166006)(81156014)(4001450100002)(92566002)(86362001)(19580395003)(4001430100002)(19580405001)(7846002)(7736002)(305945005)(8676002)(105586002)(2201001)(586003)(42186005)(33646002)(106356001)(3846002)(5003940100001)(6116002)(48376002)(36756003)(50466002)(5001770100001)(97736004)(189998001)(229853001)(47776003)(66066001)(76176999)(107886002)(50986999)(68736007)(101416001)(50226002)(4326007)(2950100001)(15975445007)(77096005)(2906002)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR0501MB848; H:promb-2s-dhcp95-136.eng.vmware.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; SN2PR0501MB848; 23:o3PkXR583kSPn89TAKvpTKwk8yfthqhBLLQfJQpH?= =?us-ascii?Q?f3wzV6g/RYFZoZqllXreMuZTRvnsJdq1NOHU28u65AC4rtCRLS7fLy1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mwzacd2dz14Z9YfbAtWYq2yd6QdRcE/bI+HZ2xaeUgjXdv88RNl0D0Mwf+6r4TAEPaZivKXvvsgzA3E4pr1WLO3FC2QkdnKzEtQJGmomzC6irO8UxzPw5EDtdRegP4AB9fO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB848; 20:T1+of4JbBMoPCRKhd1VyF7BpXmOKtFxnzUljBbV+X/4V0cuMwfcc5znWhBGAeyblVT95nkpFR49Lk/mBUqj9exGia3MmXHtgr7RFcLsbk6fzQ8o2Tftxf0wo6XV4858rozRUHqDaYBTQGM7WEb2nISWfub6H5CBFnLwoDDibZ+k= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2016 06:15:13.5577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0501MB848 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; +}