From patchwork Wed Aug 3 23:27:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adit Ranadive X-Patchwork-Id: 9262337 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 915F46048F for ; Wed, 3 Aug 2016 23:32:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7662A27F3E for ; Wed, 3 Aug 2016 23:32:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66B2E2807E; Wed, 3 Aug 2016 23:32:26 +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 9299527F3E for ; Wed, 3 Aug 2016 23:32:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932493AbcHCXcV (ORCPT ); Wed, 3 Aug 2016 19:32:21 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:9868 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932449AbcHCXcU (ORCPT ); Wed, 3 Aug 2016 19:32:20 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 3 Aug 2016 16:27:46 -0700 Received: from EX13-CAS-006.vmware.com (smtp-inbound.vmware.com [10.113.191.56]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 77998B06CA; Wed, 3 Aug 2016 16:28:30 -0700 (PDT) Received: from EX13-CAS-002.vmware.com (10.113.191.52) by EX13-MBX-020.vmware.com (10.113.191.40) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Wed, 3 Aug 2016 16:28:30 -0700 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (10.113.170.11) by EX13-CAS-002.vmware.com (10.113.191.52) with Microsoft SMTP Server (TLS) id 15.0.1156.6 via Frontend Transport; Wed, 3 Aug 2016 16:28:30 -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=6m6QsMylGMoHiqrSnLFOtb4zuu/VZnhjHTNUj+OwEho=; b=P9rRS1JGvsJnc6yRzzaekoW+MOkWnAGfMrYkp1dX2DjFp+r8YgZAPqr8l/a325eatijxsfGcEA3/XGr/+9q6m4zKLL5vd/LB0GAMIjKUTZK7diMI2rTCj3Npx7WK+WNhMTD00OlZWkHTzoAWPqVtDc6vnbl5do8yIQX1NMapKrM= 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 SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Wed, 3 Aug 2016 23:28:18 +0000 From: Adit Ranadive To: , , CC: Adit Ranadive , , , , Subject: [PATCH v3 07/15] IB/pvrdma: Add device command support Date: Wed, 3 Aug 2016 16:27:36 -0700 Message-ID: <1470266864-16888-8-git-send-email-aditr@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470266864-16888-1-git-send-email-aditr@vmware.com> References: <1470266864-16888-1-git-send-email-aditr@vmware.com> MIME-Version: 1.0 X-Originating-IP: [208.91.1.34] X-ClientProxiedBy: CY1PR12CA0084.namprd12.prod.outlook.com (10.163.230.52) To SN2PR0501MB847.namprd05.prod.outlook.com (10.160.14.145) X-MS-Office365-Filtering-Correlation-Id: 9137df08-8bfd-4861-71ab-08d3bbf5da58 X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 2:fmjp8anVX8clEEmJlY9HwTqwOby9Ae7OWq42lX7Dhf2Dr9eBS20q+9WaD4NxIa+bJPqer5Sl2vukF1FmhxTZV4+tEf6OdRkLuTLnFRrYZYBGV8vu8IqjOYujtPbFgoVECixaDxNf+DALXRI3Jh5AHzZgWXjB8RQOrWQPsgL5Fs68+3CX7hRdYzgQSbjBvijN; 3:Xr2DNwAH0tp4Di1L00o9YhtKXfnIqBn7/JdPTCI2LLHIA6pNb7tviRUAO/MAYHcomHRfjCfgV5dvbtkQb4lC5g3uaWRpzSN/OBnrXZ4aiZDVdEAWKqgg9DRDxmuMouOt; 25:nL7OzsOLsmsRiaJne6GKwWhISdBvfIEWb9/39BIlWnl+ocVSOzrwWVnGiawy/v+vFu8D4CZWMpo3d56QWuaqjqRoxHrJHCnpZtUTFTEG8+SJGJp1m4H+EzNV7qLuXo9WNd/0eWpAPDBseUHAfK7shszBku/I21qjdpIkMAU/BBMV7FJgVD+8nQDvR0OIX1DPukdwtEqaOAboBwjFfO50ifnIZH5gfQ5rZ2/wqE2j0GpVe09Rq/vXYLv5B6QHKNrgVWndeEnQLW9A/uGksGJ/bgmYjATY3ZEk+nTSWV4bBMZWq8Nz91m24ewAptxSKZ2mKrfdUNPOVerxrbP1AV/Gvlh8FbKEKdiBpxKFhRbslKBsn8fhUS9MfSn5RxogUl2DHckJkZgjG49p98TD3leeNQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 31:SRccrMZkdVdtNMBsFDXULOFx6g0Y+klLnW7+pUEnn3aHRPo1ObzJuPQdgbwDBi+JJSWsr67jpXHgT35UeEAnFmhoI8oPrzJwQ6H3pzN7JNfe8XXo7tlvHUSaBJlms2/tj0Rf9gRdu/NkxsvL1jHbK7XiJs2Fo1svZzesTJnF2PTu2y/UAuGEESQtL+m0nKjXwFD03vGUdlaL1szsx9mWSE4GXW6zUJekUwZAjBhd5NU=; 20:3AyejKBV7p8qcxD4ouepimYQ2Nfj3BbAX++UN36Pc+b4durFUWQJWHkQVRqQS+zymTTLE09GzMFgjAL4j95Uq82cmyRYOl5XTYOUVlwU/9dNalJgBkk5teAw73HOyj0ZqBBgq5MseHknXWlC2JkFIi6g9r5Ce9WperDCK3HGU/Q2P7HXQnpfDX+ex/lpGB0a6VOttR2BwvaHWkJGb2vs8tUlc830jG49GQMz2upaSaOlNBcgCrDdg2IA6RBhXAJm 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)(8121501046)(5005006)(10201501046)(3002001); SRVR:SN2PR0501MB847; BCL:0; PCL:0; RULEID:; SRVR:SN2PR0501MB847; X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 4:1RhYqZf65FaCRAwow0sUayoPrYa0tBuEASFDPIOg7gLVhApl9fiZEwmewtkKmlAN6tJhWHeHL8u7R6OtoRjhNQt9WBmnw+G+FDG3tG1gruOTCVuP2C6a76fkNtOjODCUjKM34ICfZRc/MEtyZtcNC1+HrnktGXMSim2ufeMUf+MEZUuYddQ1JIFAq+4V5fEKyMABCesEB8lJMeLI6ffPRQU7T+vY/IRMnIkbM66toNjuzkH8zqeYQuaVrzVAGBUOfLiffF43jqoyj52w14kaGfig5dJCBd3jGOSp+MX9gid9PquUYkG75HByIB0FxZsna//s3sLjqUDSmZz6EZEMB0QXmdHKjlxsnz8AN69BykAcshBUryc4F2hhGVU1oklnX8nZ3y0fVEnez1M9WaAr5BsI1VtwjQvwfu9DyhTdXao+lHJTi6UXIHPHmUgXxHaez4zYTWThcyI3XFrXrJ6WpMDOOA2aUj6Vm1XJ3QPLE80= X-Forefront-PRVS: 00235A1EEF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(4001450100002)(66066001)(106356001)(189998001)(33646002)(92566002)(107886002)(5001770100001)(77096005)(15975445007)(229853001)(48376002)(50466002)(101416001)(97736004)(2950100001)(42186005)(586003)(47776003)(68736007)(76176999)(50986999)(4001430100002)(2906002)(105586002)(7846002)(7736002)(305945005)(81156014)(50226002)(86362001)(81166006)(8676002)(6116002)(36756003)(3846002)(5003940100001)(19580405001)(19580395003)(2201001)(4326007)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR0501MB847; 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; SN2PR0501MB847; 23:Vypirn03pW00bxPtw97WpwhmN2l4tKtD8NWaL5FG?= =?us-ascii?Q?kXxtw4+M/XFspwzCjN93x2A3wkepmxU5EYBJlhBW7S/FvxAqJuR5VxXyls9d?= =?us-ascii?Q?iklKrAJ0ORBzPvABInj5E32hAAnwlq7MOaD7DcBG73NgcUHwgXckti9JOXry?= =?us-ascii?Q?i2CAlgAgxG4RoIyw03qKwfNUJ/1BIwV19PwHtIJBkjVI8L9AOiDv8N6Z2a9i?= =?us-ascii?Q?bAlMbOeFYsE6J9S3N1AdV3bz8d2MoQb+4hJbE30rf7gq0QxcUgpQXvLy+pSU?= =?us-ascii?Q?CePkr5HrzLVplW5udykYWrXVY1VhYsdcJYjUipL1BCE1UaXl3SUyyOJJWlJ6?= =?us-ascii?Q?NwJxjiVn2FTa3GxRVe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IvPmNC0g?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 6:8qR8HnSuQcRSD8yAQptJ9lqUtsMJKHhJAGJJHlWH0SFz6aTsJnmLtJOW54A/wuKY9SqkIbqI8IegSRBfH2lZX+V19RlfUxdyQ4iZmR2TX0sWJ9ObkjORYpi5HwUKbBe3Zx+1UiWr3xM83tcAHb8VPM7hNtJbiznFZcQUBW8CFoICN4baX76zLakwJ4jz/JQsEHksEkWJx7C+fuoccKb62PPu5K+3XUcqNhu0hrl5eWJRoQ+//kBYKxGfvi3l0DYDPQxuwtvnT+nlqZeAX2Q2q0FFBk0AMoEac0Cw+H1vh3o=; 5:CcnEtQuRgmBIUUihUEj4GyNi6Vo+zQ6NxDDP3phXgclkIAA9veGO0J+Gr3jQuzBHTUzKfUhRYptxMEZKmZNaHza/nlwmL5hBhTVxKyXR3WqdTd9SlAYjkbi57JYpLlzaxO2bG/jaHi62gOw8C656Yw==; 24:wf1M4BlR7TwFvC3FmMa7q+DZxBHm3M0IHT7GL/wlJ+Vl2RPpR3588gMOlMAr++t7+2C5ZW8svQcHNwY+wpKrNYC2RAeKhYzCo48zxs6VfEY=; 7:vW/R4E2wlWYHM1H0jcuu/Lu6+4HQ8qxIdjUuXBe6PVC54mC8kUmlARBWWK78g9KQ/2C/6tKwnTetGS9o8YgtHkR68SSFam+ozry95cmFnBYnUMfGpHT0cBPpMol59T215PTuaixD3bgvAMeqFstrYElvAhWD3SiVEq0O+QVnqlOxqWDSyuJfBhZO0qCWE9iWoQcHJcqid1AwYl9Z5rihChc970zm8MVWdSXlf+a3e4eH0kmaXt83BFFHcUP7T1Df SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN2PR0501MB847; 20:5jORwk3AeMazb/2KGHZhk6JCrwtnmk4BNmQfrBYj/xqz38XjOLIA6EYAEivRwdTyDDbS2OakdiFMOOS7LxYKNs35YlDmVQeSheFIh/NWvnhPnwi2oiKJbaF1NFIhageYrR04y6LHkRnnOU6H6duFlRtSWhllyohSwhbJEnsxyoY= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2016 23:28:18.3201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0501MB847 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. Changes v2->v3: - Converted pvrdma_cmd_recv to inline. - Added a min check in the memcpy to cmd_slot. - Removed the boolean from pvrdma_cmd_post. Reviewed-by: Jorgen Hansen Reviewed-by: George Zhang Reviewed-by: Aditya Sarwade Reviewed-by: Bryan Tan Signed-off-by: Adit Ranadive Reviewed-by: Yuval Shaia --- drivers/infiniband/hw/pvrdma/pvrdma_cmd.c | 105 ++++++++++++++++++++++++++++++ 1 file changed, 105 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..45aa31f --- /dev/null +++ b/drivers/infiniband/hw/pvrdma/pvrdma_cmd.c @@ -0,0 +1,105 @@ +/* + * 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 inline 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, + 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, min(PAGE_SIZE, 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 (resp != NULL) { + err = wait_for_completion_interruptible_timeout( + &dev->cmd_done, + msecs_to_jiffies(PVRDMA_CMD_TIMEOUT)); + if (err == 0 || err == -ERESTARTSYS) { + dev_err(&dev->pdev->dev, + "completion timeout or interrupted\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; +}