From patchwork Wed Dec 20 06:56:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125049 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 BE9B46019C for ; Wed, 20 Dec 2017 06:57:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3C4C29649 for ; Wed, 20 Dec 2017 06:57:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8A482964F; Wed, 20 Dec 2017 06:57:02 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 D2CBF29649 for ; Wed, 20 Dec 2017 06:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932370AbdLTG5A (ORCPT ); Wed, 20 Dec 2017 01:57:00 -0500 Received: from mail-by2nam03on0076.outbound.protection.outlook.com ([104.47.42.76]:56045 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932344AbdLTG44 (ORCPT ); Wed, 20 Dec 2017 01:56:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+skyaeWY8Yk3etWz/b5naqqySQCeIU7MX87gU+86m7E=; b=G5B1lFAW9Y9VcqlxSm8BPYqzF11iWNLkD1vzFkeAfWnVNMuf65TfWvCrQjn4iCLWboZnErat+BExdxRLUCF7GtFK9ISlm2AOUYD6RME/SyeUd27JrD1vOgutdWEQSGz4zDvLMU6lwPi7rhpNEpyIkAslNzrgSRgTcn8Iz67FM0Q= Received: from SN4PR0701CA0021.namprd07.prod.outlook.com (10.161.192.159) by BY2PR0701MB1944.namprd07.prod.outlook.com (10.163.155.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:56:54 +0000 Received: from BN1AFFO11FD027.protection.gbl (2a01:111:f400:7c10::168) by SN4PR0701CA0021.outlook.office365.com (2603:10b6:803:28::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Wed, 20 Dec 2017 06:56:54 +0000 Authentication-Results: spf=permerror (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD027.mail.protection.outlook.com (10.58.52.87) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:56:40 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Tue, 19 Dec 2017 22:56:45 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id vBK6ujfZ021558; Tue, 19 Dec 2017 22:56:45 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6uj25021557; Tue, 19 Dec 2017 22:56:45 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 03/43] qla2xxx: Use IOCB path to submit Control VP MBX command Date: Tue, 19 Dec 2017 22:56:04 -0800 Message-ID: <20171220065644.21511-4-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(396003)(39860400002)(346002)(39380400002)(2980300002)(448002)(199004)(189003)(316002)(36756003)(76176011)(59450400001)(51416003)(81166006)(81156014)(8676002)(1076002)(5660300001)(48376002)(8936002)(50226002)(50466002)(87636003)(478600001)(85326001)(6666003)(86362001)(80596001)(47776003)(356003)(69596002)(575784001)(2906002)(106466001)(110136005)(42186006)(305945005)(16586007)(54906003)(4326008)(2950100002)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0701MB1944; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD027; 1:FKCbxsrSdK48Eaw2N67Z3O/eYUDr15PTqDByAcEdQD4bXJKXIN+noJK0PufbID9u9IL00DE7+6N/yB85IX9hBOk3XMzcJRfrDtHhw5xpkWbmRcG1KUh/RgSa18t6w4u6 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bfcb41d-2e52-4a4b-682f-08d54776d2e7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:BY2PR0701MB1944; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1944; 3:M/AS0JYLHw2Atg1j3OsNDqmoFpZpyyMXNdzMAoJiW2ne4nQdlbiGr0zWzR3lA9ec1KTvu/MBMY/1vKxK+ku98mjKdlDA/ALS/lDh6rOEaofmQlpMa5S/3X20faAehsMJ5P1YXSsGeukBEmkTGefqxEhNczalnzTu7VI9IOU9NQdrL8p8D81kOg41cA9qsb0d3K9AgM5eGavLZh68PUbPtNCFzv12jf55/JJ906X9E/O5F0URRAokMygsDYW25Bpr37+2yQrmP1RMPvEep4/Gm8OrIRbDaXRKAynFr6IVNWHYjSfiha0UYAIuG6OD78lkIvLhiPpq4M38wbo0RoTq57q5eA3p1Fw78gRUljiz6vg=; 25:0+9jERrY8zQ02Y1QZaH6xpFalgaG99TteYPbrlog8x6s6vFWS4qizmiRRF9guNMTks5CNJFg9aTFN2rM3VqBAJz9Kk0pIiTaPZGtYP6KZ1swfMbuxJ+BmkANy4+ur4Wap5myisyo0BvTSukfv5or7cZB7dAD4aPC5NXY90Hx2yrzxIo4twJAdS5LG6JNdsGjnolYHmQRevricwbzcX+ZHCLcVkpGMFIuFmgxIh7rpXjlSwvbWCmeNa0d3VBVUFz670Jsa+GGYhM4Aq4GL6KMTBmD//iz3mhZFfb14Yb9jta31EUvUywV0eUNVC/FVI8sHG7IPxh41Ohz5PZ/YeKAYg== X-MS-TrafficTypeDiagnostic: BY2PR0701MB1944: X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1944; 31:pVA92pjoqgy964wPPYRC/HKNltdn47Ow5rdGfwi347XqPw6cHfmdUW+zss6gkXcA6k5iEgqjbioZH2FDP0wHSXwgwvWlky6WV+EcLCmtRyw3on7D+Ns0pNZwVjwmZklAMGBY8iiqMqzPZsxBYjJy4ODOzYZw9+31TYY/0IKvmtiGmzTb4dSFdL4fHzfUQMsj9+TzgZr/sXGcsf5fttIJPmGTi1FVInBeQc86OrXrS04=; 20:j7RCXM7avVRnyAO3xK3opy7CuUbiFMyJgqSyUQ4ha/K2u7tnGVPK8CMaTCUhl/pKfopRKurwhq/1aMrQ0Qi/MevH2x9xsAR6I8lVUJ5XOxgK7ghq8D4qv0SF2baW5cH6D7SAzffy0m1IKSQ3V+r6CtuE64rvgI/piKC/NyfRo4jBT3+SwS0BZO/2NX6XZevEdx0eqZ3YgbPmcsA+ryd2SPkcJuYsc5EZGGnelR/UwOcPn9hqYROe1ZJRePGO6eazddDeS079ZmiAlka7sVcoSl9yNOhEDFJZUiqpKAPmT8IRtl00P6ruRcLNqNcHXLMRDdmG1D/tgWMI5mIaQ5FXD2z6MMPmXMd54e4AOHBNXakTUtGC0kPrd8/9ogbdLxe/IzMv5Fri71UnPYl3HUprLwkciLm/+Q61ZsHM9AufGls8f8ON2U1hzy283U/31lReKFQagjxXwkJbKDxdh4xB6IlzEIkPHv6OvnC+pBrSFIZsw1/dhNZGctZiyC0K5eMH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(93006095)(93001095)(10201501046)(3002001)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BY2PR0701MB1944; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BY2PR0701MB1944; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1944; 4:rHn+AlNvnEpyqdDlenJSmk6/wEnGaUSYks+I6JBq+n/g8Hpg20eF98X3GIviIU8zm9B+8WFe5H+Wayujs8oZ+tt+z5rQPBkFVCMRkUpQHLvXcWe4pCsMxE8aacETGgAZinXVdFTYxc8E1KEYKhs5srNBy6zEASo2bhyd4kEWDbRYXunLpWhyVw4tl5aVCwwV1zHtC5ftaahhQayAFhDBcBvlxyKRG2frEY/BO/MGJmLZjIUP94QHk/uFKBrJ+Ap9nwwT5SyThWkJpTWygUU3Rw== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0701MB1944; 23:lnJMHtP2sxw9sIZgx6f2xkAiz4FyyR+LBVdxx7n?= =?us-ascii?Q?J3U1LsVQgFBOID+3ZHoj5NswGp1m4BMA/jiji4x9MTUNBPwsft7BGFGL1SPs?= =?us-ascii?Q?IpOtv/05N5gN7HnDDnTubbBpVw0UZqdOo38J6B/bU7Z2H60VCX6LJFEmrSzA?= =?us-ascii?Q?OothihILY8j+TUGPxsX+6FmsGcwKFoaMY7erOYyu7IjQoKaXdrv922gfgvBI?= =?us-ascii?Q?m1Mgyfcm+lBm458h8acp1ONmSUXo4ZvYiF7x5wY4wJ6KMb5d7Gv7Xz7ZE4rH?= =?us-ascii?Q?iY6u3xhIKLlCBCtZDmEhmHhFRn7vFa/lAurk7dlbxsVUYf6qft3gcHd9uLG5?= =?us-ascii?Q?6hadw74RSNcT9Jm2feZK7glkFGJ0mGVO4FrH19wB6emegAuBF/2NzljwqZrw?= =?us-ascii?Q?q+xw6azeg427XdyOfgzu6hNXQawyNzsD9vR+BT4H+cDJI7xj0GDDAcE1VAHj?= =?us-ascii?Q?TLPWtutx2BghKr6a2XnhPqlTJ6sTtSRzX7qzyUOgOQOzHe7RG7zyZG7WMm1u?= =?us-ascii?Q?gt1sG8cDo82WbV/SED5FsNFaqQstAbCUNARX85ezi+mGV1cKAWFQ3FjAIyeJ?= =?us-ascii?Q?0uh1bpts1C/hfzwP23dEjytNiLyEudZSIq2ASE4bW9l5UaDcOJ3hriN6sGdc?= =?us-ascii?Q?rsHx27C0cvC1840hr9n8YUzIbY5S1g7N48IgvCrWx/Lh+VT2NDQRmaOFwY8J?= =?us-ascii?Q?Aw1fz/7L55oEqohrZcbvzgEk/WiNa4/c249p9fNemGdqZmvNAlaZwUkdvmsz?= =?us-ascii?Q?GhtD5b/cgJROCiEtFGlOo+gcxLumr0qDsde1miubHhhE/UuVG/ZNZg2yU3Q5?= =?us-ascii?Q?JAStCdiv1+vTt7ZLiY0WhdBl9Rg+2iMm+bSbJ3Vg//Jx0yRDcLuu++ruxHil?= =?us-ascii?Q?THIC62Tr3kyzvDH+OcT/rgUmAKzVK2bdfFKs/T51CU3X0dHm4T3nVxEj/Ie0?= =?us-ascii?Q?WNj+Z8AEqfIOD0l+KU7DGesDi4jxTGxmPqUDuwsaRtPI5XISSp2XHVplQgQA?= =?us-ascii?Q?vPhGaG0HRQkLIcOAE4Ys1WUscxI+NWqxtR7SqBLXahNWUaA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0701MB1944; 6:rixm/fc6chkGqD9U2VWXLYCyWE86knLm5qV95ZkB6EpJ9GGdtIFJbTMEHfDVz8sc0mqJrKpyeJch0kpqgg8hLYyvxwx9u5ewVDBmCztAblzKGpAg8uyLF7htBJsYAvt2pd+rVzJUvdxt2W8wL0DyLx4WrOVfkMW5mDOvCH4P1fAK+CtqIM0tQsFGVdT2vURorv/loih6Pt2XD1CHS9rMFNEOKXl8dLmLpRrWRozUlj+9uKabK93I+rulYdeMmZFb2arAY5CugltkD3/4qA3EGGtBTWWSXBTuxrmhh3CB1k6Fux8RxzDGTKy7+lk9GpoSxt3lKs0WKMI85KhJdR//kJFNY3rOxVtJqbY68nnswnA=; 5:Djcx11uPz2TEE6HpdxYjckmDVzPK7E4aOa7ZTzFUxyu6Vmkm6lDOeybYx1KZtOTRFjwRhqIDVegLlEyVfdCbrU8uQzVSsy9XFRPZyUfeH9/AgnKmv1o2Hn+8Uzul5EOHMKPMrlABhemICWjDbCmkJMmomL451GG0/Gakr7YheO4=; 24:MgH/2OK62k/0K9ul3Br9mdNlTeSbi1R+brvZS1Mf1HIfwARiNM3+p+P5pzAa7p3olVMNRvMwIM/VdhBbW4PJlTT1j+hSjVGjyvQmm8nazus=; 7:O1gbiYsWYEkwL22G1Wa4ai4PMotbFRalUu6eykMsjwpFKBxgU2nwrgEr7t2tzIuAaI5Ywpi8JW0P24cAJvrMnEBP81Zwql+Mk4XZhEKvDeRud420yr1L3l9Shy/eIC8KuaaWxwK7Apfq9LDvSCENN39hby3cmSLDfZ0SvCN5FMDqBdrMLLftzxPJUYZqilidFec2BsQvGgon/7k1mEDHja4C3IfVOjybUtwzDHBK8YdUThwK5cHe/7eNTT28GPHW SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:40.8675 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bfcb41d-2e52-4a4b-682f-08d54776d2e7 X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0701MB1944 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran Use IOCB patch to submit Control VP MBX command to reduce bottle-neck for mbx interface. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 9 ++++- drivers/scsi/qla2xxx/qla_gs.c | 1 + drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_inline.h | 1 + drivers/scsi/qla2xxx/qla_iocb.c | 23 +++++++++++ drivers/scsi/qla2xxx/qla_isr.c | 35 ++++++++++++++++ drivers/scsi/qla2xxx/qla_mbx.c | 77 ----------------------------------- drivers/scsi/qla2xxx/qla_mid.c | 85 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 154 insertions(+), 78 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 4d65fd973a12..50a570595969 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -472,6 +472,10 @@ struct srb_iocb { uint32_t timeout_sec; struct list_head entry; } nvme; + struct { + u16 cmd; + u16 vp_index; + } ctrlvp; } u; struct timer_list timer; @@ -507,6 +511,7 @@ enum { SPCN_PRLI, SPCN_NVME_LS, SPCN_NVME_CMD, + SPCN_CTRL_VP, }; struct sp_name { @@ -536,7 +541,7 @@ struct sp_name { #define SRB_NVME_CMD 19 #define SRB_NVME_LS 20 #define SRB_PRLI_CMD 21 - +#define SRB_CTRL_VP 22 enum { TYPE_SRB, TYPE_TGT_CMD, @@ -562,6 +567,8 @@ typedef struct srb { struct list_head elem; u32 gen1; /* scratch */ u32 gen2; /* scratch */ + int rc; + struct completion comp; union { struct srb_iocb iocb_cmd; struct bsg_job *bsg_job; diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 7e88e8289157..6aa6dd74fe86 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -41,6 +41,7 @@ struct sp_name sp_str[] = { { SPCN_PRLI, "prli" }, { SPCN_NVME_LS, "nvme_ls" }, { SPCN_NVME_CMD, "nvme_cmd" }, + { SPCN_CTRL_VP, "ctrl_vp" }, }; const char *sp_to_str(uint16_t cmd) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 9d65fbe85e30..24d0f9d419d2 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -135,6 +135,7 @@ qla2x00_async_iocb_timeout(void *data) case SRB_NACK_PLOGI: case SRB_NACK_PRLI: case SRB_NACK_LOGO: + case SRB_CTRL_VP: sp->done(sp, QLA_FUNCTION_TIMEOUT); break; } diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 17d2c20f1f75..4d32426393c7 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -273,6 +273,7 @@ qla2x00_init_timer(srb_t *sp, unsigned long tmo) sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; add_timer(&sp->u.iocb_cmd.timer); sp->free = qla2x00_sp_free; + init_completion(&sp->comp); if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD)) init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); if (sp->type == SRB_ELS_DCMD) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index b5d1423f933d..62b3d0a8a961 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -3368,6 +3368,26 @@ qla_nvme_ls(srb_t *sp, struct pt_ls4_request *cmd_pkt) return rval; } +static void +qla25xx_ctrlvp_iocb(srb_t *sp, struct vp_ctrl_entry_24xx *vce) +{ + int map, pos; + + vce->entry_type = VP_CTRL_IOCB_TYPE; + vce->handle = sp->handle; + vce->entry_count = 1; + vce->command = cpu_to_le16(sp->u.iocb_cmd.u.ctrlvp.cmd); + vce->vp_count = cpu_to_le16(1); + + /* + * index map in firmware starts with 1; decrement index + * this is ok as we never use index 0 + */ + map = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) / 8; + pos = (sp->u.iocb_cmd.u.ctrlvp.vp_index - 1) & 7; + vce->vp_idx_map[map] |= 1 << pos; +} + int qla2x00_start_sp(srb_t *sp) { @@ -3446,6 +3466,9 @@ qla2x00_start_sp(srb_t *sp) case SRB_NACK_LOGO: qla2x00_send_notify_ack_iocb(sp, pkt); break; + case SRB_CTRL_VP: + qla25xx_ctrlvp_iocb(sp, pkt); + break; default: break; } diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index a55bfaa790a3..a265c2d8c9cc 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -1937,6 +1937,37 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) sp->done(sp, ret); } +static void qla_ctrlvp_completed(scsi_qla_host_t *vha, struct req_que *req, + struct vp_ctrl_entry_24xx *vce) +{ + const char func[] = "CTRLVP-IOCB"; + srb_t *sp; + int rval = QLA_SUCCESS; + + sp = qla2x00_get_sp_from_handle(vha, func, req, vce); + if (!sp) + return; + + if (vce->entry_status != 0) { + ql_dbg(ql_dbg_vport, vha, 0x10c4, + "%s: Failed to complete IOCB -- error status (%x)\n", + sp->name, vce->entry_status); + rval = QLA_FUNCTION_FAILED; + } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { + ql_dbg(ql_dbg_vport, vha, 0x10c5, + "%s: Failed to complete IOCB -- completion status (%x) vpidx %x\n", + sp->name, le16_to_cpu(vce->comp_status), + le16_to_cpu(vce->vp_idx_failed)); + rval = QLA_FUNCTION_FAILED; + } else { + ql_dbg(ql_dbg_vport, vha, 0x10c6, + "Done %s.\n", __func__); + } + + sp->rc = rval; + sp->done(sp, rval); +} + /** * qla2x00_process_response_queue() - Process response queue entries. * @ha: SCSI driver HA context @@ -3001,6 +3032,10 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha, qla24xx_mbx_iocb_entry(vha, rsp->req, (struct mbx_24xx_entry *)pkt); break; + case VP_CTRL_IOCB_TYPE: + qla_ctrlvp_completed(vha, rsp->req, + (struct vp_ctrl_entry_24xx *)pkt); + break; default: /* Type Not Supported. */ ql_dbg(ql_dbg_async, vha, 0x5042, diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index f5cbdaeaea1f..956d121cc396 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3946,83 +3946,6 @@ qla24xx_modify_vp_config(scsi_qla_host_t *vha) } /* - * qla24xx_control_vp - * Enable a virtual port for given host - * - * Input: - * ha = adapter block pointer. - * vhba = virtual adapter (unused) - * index = index number for enabled VP - * - * Returns: - * qla2xxx local function return status code. - * - * Context: - * Kernel context. - */ -int -qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) -{ - int rval; - int map, pos; - struct vp_ctrl_entry_24xx *vce; - dma_addr_t vce_dma; - struct qla_hw_data *ha = vha->hw; - int vp_index = vha->vp_idx; - struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); - - ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c1, - "Entered %s enabling index %d.\n", __func__, vp_index); - - if (vp_index == 0 || vp_index >= ha->max_npiv_vports) - return QLA_PARAMETER_ERROR; - - vce = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &vce_dma); - if (!vce) { - ql_log(ql_log_warn, vha, 0x10c2, - "Failed to allocate VP control IOCB.\n"); - return QLA_MEMORY_ALLOC_FAILED; - } - - vce->entry_type = VP_CTRL_IOCB_TYPE; - vce->entry_count = 1; - vce->command = cpu_to_le16(cmd); - vce->vp_count = cpu_to_le16(1); - - /* index map in firmware starts with 1; decrement index - * this is ok as we never use index 0 - */ - map = (vp_index - 1) / 8; - pos = (vp_index - 1) & 7; - mutex_lock(&ha->vport_lock); - vce->vp_idx_map[map] |= 1 << pos; - mutex_unlock(&ha->vport_lock); - - rval = qla2x00_issue_iocb(base_vha, vce, vce_dma, 0); - if (rval != QLA_SUCCESS) { - ql_dbg(ql_dbg_mbx, vha, 0x10c3, - "Failed to issue VP control IOCB (%x).\n", rval); - } else if (vce->entry_status != 0) { - ql_dbg(ql_dbg_mbx, vha, 0x10c4, - "Failed to complete IOCB -- error status (%x).\n", - vce->entry_status); - rval = QLA_FUNCTION_FAILED; - } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { - ql_dbg(ql_dbg_mbx, vha, 0x10c5, - "Failed to complete IOCB -- completion status (%x).\n", - le16_to_cpu(vce->comp_status)); - rval = QLA_FUNCTION_FAILED; - } else { - ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10c6, - "Done %s.\n", __func__); - } - - dma_pool_free(ha->s_dma_pool, vce, vce_dma); - - return rval; -} - -/* * qla2x00_send_change_request * Receive or disable RSCN request from fabric controller * diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index 522d585a1a08..fc61fef5e305 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -894,3 +894,88 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, failed: return 0; } + +static void qla_ctrlvp_sp_done(void *s, int res) +{ + struct srb *sp = s; + + complete(&sp->comp); + /* don't free sp here. Let the caller do the free */ +} + +/* + * qla24xx_control_vp + * Enable a virtual port for given host + * + * Input: + * ha = adapter block pointer. + * vhba = virtual adapter (unused) + * index = index number for enabled VP + * + * Returns: + * qla2xxx local function return status code. + * + * Context: + * Kernel context. + */ +int +qla24xx_control_vp(scsi_qla_host_t *vha, int cmd) +{ + int rval = QLA_MEMORY_ALLOC_FAILED; + struct qla_hw_data *ha = vha->hw; + int vp_index = vha->vp_idx; + struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); + srb_t *sp; + + ql_dbg(ql_dbg_vport, vha, 0x10c1, + "Entered %s cmd %x index %d.\n", __func__, cmd, vp_index); + + if (vp_index == 0 || vp_index >= ha->max_npiv_vports) + return QLA_PARAMETER_ERROR; + + sp = qla2x00_get_sp(base_vha, NULL, GFP_KERNEL); + if (!sp) + goto done; + + sp->type = SRB_CTRL_VP; + sp->name = sp_to_str(SPCN_CTRL_VP); + sp->done = qla_ctrlvp_sp_done; + qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); + sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; + sp->u.iocb_cmd.u.ctrlvp.cmd = cmd; + sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index; + + rval = qla2x00_start_sp(sp); + if (rval != QLA_SUCCESS) { + ql_dbg(ql_dbg_async, vha, 0xffff, + "%s: %s Failed submission. %x.\n", + __func__, sp->name, rval); + goto done_free_sp; + } + + ql_dbg(ql_dbg_vport, vha, 0x113f, "%s hndl %x submitted\n", + sp->name, sp->handle); + + wait_for_completion(&sp->comp); + rval = sp->rc; + switch (rval) { + case QLA_FUNCTION_TIMEOUT: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Timeout. %x.\n", + __func__, sp->name, rval); + break; + case QLA_SUCCESS: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s done.\n", + __func__, sp->name); + goto done_free_sp; + default: + ql_dbg(ql_dbg_vport, vha, 0xffff, "%s: %s Failed. %x.\n", + __func__, sp->name, rval); + goto done_free_sp; + } +done: + return rval; + +done_free_sp: + sp->free(sp); + return rval; +}