From patchwork Thu Mar 15 03:35:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10283887 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 D2C7F60291 for ; Thu, 15 Mar 2018 03:35:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C26C3287AD for ; Thu, 15 Mar 2018 03:35:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B713C28807; Thu, 15 Mar 2018 03:35:38 +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 9F135287AD for ; Thu, 15 Mar 2018 03:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752047AbeCODff (ORCPT ); Wed, 14 Mar 2018 23:35:35 -0400 Received: from mail-sn1nam02on0050.outbound.protection.outlook.com ([104.47.36.50]:61152 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751991AbeCODfY (ORCPT ); Wed, 14 Mar 2018 23:35:24 -0400 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=CwDWXoD3xw/0v6rRH7bBEXkWk8bH8nq/87wYw3wf6pk=; b=SesZ41+Lfo6eNV26+ZAPB50ZkRDF9rsDtjKjQlHN4ZXvoQnG7ME5kLjk7wrhHBIDUU6Q68iSmXBXEyYXJqufabG4bEN9koNCAW+yZhK20lameBAuFaAiZOt/OW7wwuWpGvLON2NmQwBdAVlu8plFATQYLrY4YjKj/Ms3AMuZ5Tk= Received: from DM5PR07CA0051.namprd07.prod.outlook.com (2603:10b6:4:ad::16) by BLUPR0701MB2082.namprd07.prod.outlook.com (2a01:111:e400:52f4::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.567.14; Thu, 15 Mar 2018 03:35:20 +0000 Received: from BY2FFO11FD011.protection.gbl (2a01:111:f400:7c0c::179) by DM5PR07CA0051.outlook.office365.com (2603:10b6:4:ad::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.588.14 via Frontend Transport; Thu, 15 Mar 2018 03:35:20 +0000 Authentication-Results: spf=fail (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; HansenPartnership.com; dkim=none (message not signed) header.d=none;HansenPartnership.com; dmarc=none action=none header.from=cavium.com; Received-SPF: Fail (protection.outlook.com: domain of cavium.com does not designate 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD011.mail.protection.outlook.com (10.1.14.129) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.506.19 via Frontend Transport; Thu, 15 Mar 2018 03:35:20 +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; Wed, 14 Mar 2018 20:35:08 -0700 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 w2F3Z7jD012711; Wed, 14 Mar 2018 20:35:07 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w2F3Z7R0012710; Wed, 14 Mar 2018 20:35:07 -0700 From: Himanshu Madhani To: , , , , CC: , Subject: [PATCH v2 12/13] qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan Date: Wed, 14 Mar 2018 20:35:03 -0700 Message-ID: <20180315033504.12628-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180315033504.12628-1-himanshu.madhani@cavium.com> References: <20180315033504.12628-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)(39850400004)(346002)(396003)(39380400002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(8676002)(72206003)(87636003)(42186006)(50226002)(81166006)(59450400001)(69596002)(16586007)(81156014)(36756003)(316002)(105606002)(76176011)(5660300001)(54906003)(106466001)(336012)(4326008)(80596001)(114624004)(8936002)(50466002)(2950100002)(86362001)(6666003)(356003)(478600001)(85426001)(47776003)(48376002)(51416003)(575784001)(186003)(2201001)(2906002)(110136005)(1076002)(26005)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0701MB2082; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD011; 1:UpkTQrAJZUkfNdKiK6bihSMFmbM+rBL+lSm8p4ZYqPLt9ONier9sFuTxy47hhtjeK/JdoMgmTA5RLryanPedA2tiqnN7GII7py8RPMAYcM/7QLF7q114kR8xoY6euIbm X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89ab30c1-fdd4-4cea-b34a-08d58a25c728 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:BLUPR0701MB2082; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB2082; 3:YZQOkNYISYUoZxzfDT/TpL0GwkdTRkhPqRMu3a1McdG8C+WwuV6w7Gg32nPdK0+Y2RTzKleHW+0dacAJ9ucGoSbKn8Y65iDm3cfURLLyXA6y1A7b0pu/nAeRSZ82x2nhLzTb0JEENUmRMUBIYzekMnqkNsNoy51qVeTGu8EDMWi+JkbLWAnYr8GoPF9Iaxwih9f87wQQhkdYCY3jcbkgzjeaBBLIB0B9ekSYrMMNAtpXuGvrhi1Zi0eMQwjlGmDP7pyTWTy4ijZ8q7gDoBqOA5BqtRdXOtojFZba1FO7F2s0jexH+eKr4J3jmy/gezUDfiY5y3ZF03ibWo8WkT+r/KToOcJkvUSNV1HFobtEIAI=; 25:Jd+0sKmvuGTSacC3f//I0290eChBHBD4BXE128UU84btH5NvvtKpGqE6jlJmVhR0zJ9M+7r6HUpn8NXiP31lUNhczyHrjqW2HCVc75s3U+A1mFk4PJi7VncRObVYG4sam4DYSBbItaj0wiZOEM1HTZprJQzOkYKHvrj8E5Tj3XxCOC6LSTCnBE32fxbMcLhazMhvYakqV12ocUlVQL9gGEXzh3xP0Bvdd0FrD6aJc3t6gCmw0J3I1ZvD2RDrM1wTuE8ZLj68LsnE/u3ViZ9ax6iJC7iQFDiZMPGI5KlyMRnjOnas7XOx7XMg8aa0FS4fl0Zv5OkmhT9Um4qnglUGzA== X-MS-TrafficTypeDiagnostic: BLUPR0701MB2082: X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB2082; 31:ROWIfJ8HH7Ug99QVf7onIsa18ovf+I6087iVY1mnQxDScSeIVslmkiprjjDRDHKqmT0ujUU/OsubIC3NQShXosBdqQV8o/e8v7m5MyLVKBZqgIj/QtjVaw1r8RNBqBgPcpcuvekR96FwleU4NzLQvxHVAJmzT+Ihrcb5Xrd7qDz2qX85i6LIKSsUd+fnUD0VtwQco7lPn/Q5YGwQwyDLRk75F2yLFBXDSAPYduvbphE=; 20:9ii891+UJUFvNlQvfGgiRVTTjSZSoy0Al8J/adVseJyxI1vq0/I5jm+scavteq4pjKmNZH4tmWdh+/xaArOebggVyjsthZqPkX/AfMh4C28NWHcqk+9v+37gnEI4lLCmAoF0YoS7belxt86c32H1qLj1zdi1CBdv/R2RMhdoCdHXijkYYtNHPn8JcT0f5P0XcN+54HEExQakVcVBCWZwwSbQxqkn/wIpShK9Y/9lJDLdoVVa1utcjF0vcJ+C7ifImucfuR+jtfRr7oR/0ZRu0SsD+CmNsWWOWGkQL6HzdYBhU22QMxexZi8ddA/5Zz6Etw+8vFOf+WrUe2STLSD797P/FFrPbOb3t9ZVhxIdWgm5qGCiSPedsAoVf+RfuRhl6syTV/dNXm3KATXzIMPh5+8VTlsr6My5/Jg3vLj7AM0kiQVaOE1QUe5SxSToYcfaPMY0HpHXH0Fg91oB1bx00Gi+hs6/iwXr5/j+seotnOJOK77QJKNFzhFLHvXTHYau X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231221)(944501244)(52105095)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BLUPR0701MB2082; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0701MB2082; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB2082; 4:1yicwpO2TC9udkUO7F7HQrwF4258Qb4FaDrrQDyydTH1BWdXenEKS42UT2eHlX1m3UGUcUVNCI7T5AhEjKz2b9P3OmTFnsnUXa5y1ryLt6sRuhnfVrLmvRbRYQdAvfVy4YGhqznwog7t0E3q8rLOh2YOlUvGkLPh8Hpdknes+SN1adRnONFDv5GPTNyi0oM0sG4uAemC1bpp8Z2QdaTlOQqSoGq0l5E17JWzSdWGTIrodULzVacfpVFsGXNPIUSgJ2v9afF2JpBrCqTFZaFBArx/cqn3CzmdBwwG3LIlLg+283bfj37h6oZl3+H588Yd X-Forefront-PRVS: 0612E553B4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0701MB2082; 23:HP2LyVK+7cQx3kjBxhI/dK1USEL5JLjLHrsK8gM?= =?us-ascii?Q?AN4f8a7WVe17m+v1WkD7ltlzy/nGbvotnwpw57DhFQnji3ouhyG9CZHct/1Y?= =?us-ascii?Q?g7nzhUYTv5fvrpmnjyoGL7rHrUTQqlt6hkeTGVmuxMzxb+b/dCGOqnOfejmg?= =?us-ascii?Q?aGmZ4lS3yPcn0lRI216udLZJBeGPhZFd38DNxvbvArO1F3994ZMm27l6pji2?= =?us-ascii?Q?2Vo7JfgzB5bRixKDSpmnFYN1rWqlM1kJFhvlsKsBeKo7QS3jN8bSjyC/6hsx?= =?us-ascii?Q?ROKHqm2DofFyqIveMbVsXsLh6HhyOnu8JkgEf6THHUCebwCbGD9FWtaBDElT?= =?us-ascii?Q?QESK17ldqGINJWqz7ZKKJ5qtTmRD7dHoO4RFTHVMHLe3dES5lbMndBRjL5gX?= =?us-ascii?Q?CDe32A0r+9CyZW9wNRLyU3ECBye49raeMlmw0QLxgzg/kTCDb4lC6IfxmJS9?= =?us-ascii?Q?eEAd3F8Q0VFwg18YJMy9qpaHytK8JQ26zRd0o/bAbA8AvzL1jzZfDhqD5bHj?= =?us-ascii?Q?dtHv+fcfiqfx0Lm2+KrpSISKFHd1+VGyqZA4LhjUGDAkRt2GQ/WcPV8zx0XN?= =?us-ascii?Q?F9f+5cXSf/dfxyjZGHu0Uz2+CGa73HQVyE02UkjFdoBoF7fddBGoCKc7s5rb?= =?us-ascii?Q?eWqdLY0Cbeua3Q/e/ekobEsj1qcPU9aEFP2CO3IQZIeKZSCawvy3RbwCxjaW?= =?us-ascii?Q?2qpGyfMx8HRv37T0oXLPWLLg6X7Uh7/jQOEpo4xQghT0C6F/7p8QKTbTvWVk?= =?us-ascii?Q?/jXrp4YZP+bkuD5hHnbXDn++OiT7rS2UWcgzwIxzEImkyX0eQVKpvmfqeqn4?= =?us-ascii?Q?SmFMDh7kewd3vf9hpyYbeseOzaRYbfRuJdTyK3aRPW47JVLlU+4kwbc1+wCA?= =?us-ascii?Q?zTaspEJm9Ll3mODIdV0hyKPm4pgggpBkTeZu7DGap3xgssORz26h3fCHQZrw?= =?us-ascii?Q?sDd4kh2L56u8w1tzT4z0EPSOASJt0gP2TA6L3AWiBHuEcWrho0OuW+lJxmqU?= =?us-ascii?Q?2qd8VaCtBNIaBVb6vA2F16IZcWXZ4fVGMxnqX4IQ1YMsa74mrLgWbtBmvLPJ?= =?us-ascii?Q?gvYVrIHWUYvBqI3KoQ6ULIEnA7snfYpko4hD0ue4WCkamA90vxufRS1M39WQ?= =?us-ascii?Q?AsQtmV0hsprue2AyRoYBnhXLIhj0QsZf4r3j2q1BX8/xhdnUjFGU5FUgbDq1?= =?us-ascii?Q?qCpYYlwY9n0/l5X0=3D?= X-Microsoft-Antispam-Message-Info: DMw+xAUJM0G7OoF139ftfcASwswZ7dK+ZCELCQCSjs1Y3YasmeK3jHAI312NInDaKV7IU1PsqYA0L4mSSBmFpoBvsKqH+CnXuERa8zT0b3XjgoB7OoxsPtFgS4LvlmLXIZ8zVxNU23wrEu34o73T+67jhw5ktd32j27D/DZc71IgOhMibmmkHCz/ksTeA3Yw X-Microsoft-Exchange-Diagnostics: 1; BLUPR0701MB2082; 6:c4ixBUEFOE9jPtpBndy1YUO+3ywOAD/a4H8ZncsZqrjeuwsE2UMnqjWldgIeo5P6CnPvWiKljJIoRR9O96ylbmyEWGFn3yIoneW9+xT8tfb4qvDTbgtNTlCjXWOfobSAjTe9KuxQVVHssy8FZ8z4blN1x+LlBEDfXylw2Jnu1GHK9AG6T4zWAzlrrs2BcEK2YOJCdfwveh2tdMEA5YKPAJEGX2OjcgxSxhXsGAsOLNKwKQe9dszDof700HoQHPx08nDHnpFFxvgclWev5bgzNcXw7Cq+lp8vV0SCujRP/iOVjL43LyEU4RK2Dq3b6J+eValP9KWqjzJPUfOIc5vF+dw6HDrCkcxTu1tzhD59zUk=; 5:8ksdE+U2EHqW9GRmauiORDsT3JhtrHx/zOnJ7XM7uAFnvWyJOwIlyMTYeYwEFPC6Y6VNYeM12sSBfGCTFOJb9lxveoP4dkJprTeREC3g1ZiqsLiBuZRsp68xcR7AkJXI9dSAMPQzNMX57fgyXCji5pz22PQ2ptrvIg1vmz45D+I=; 24:GBdwDSWJm6fDWHvxC/x+lIlsTX6UHWcaIR5jU8kaG+z/r9zqOTcuLOvKCNitxLpcUMl6GGnxqPoHCfBtaQSZ4pcUW13EqOumX89MGOvPl6M=; 7:wvpgR2n7ZDkIvJoWj0qcwX+WJEpiV2PwIdYyR4b6MVgInnYSoNjb2yTPek8dlLwkbWHYfWK1jDPWwkEC/EsYd0++oODLu5MAiUeOlLzUS6c2x+qxX11r0EqW6BsnWPQi5N+SqQjH9by3LEcQ2gPUuZVvBGxX2TNekL5XYrnj+xkEm3xSZVDGGTfb//YbAZxbKUx1xS9gUSbTdHT0DFDtszNk3qLsm/v0/oYgMpSJfWn4tRFqZjOuzi0Wl0JBlE4b SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2018 03:35:20.0521 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89ab30c1-fdd4-4cea-b34a-08d58a25c728 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: BLUPR0701MB2082 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 This patch combines FCP and FC-NVMe scan into single scan when driver detects FC-NVMe capability on same port. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 7 + drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_gs.c | 274 ++++++++++++++++++++++++++++++---------- drivers/scsi/qla2xxx/qla_init.c | 8 +- drivers/scsi/qla2xxx/qla_os.c | 8 +- 5 files changed, 225 insertions(+), 74 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 576b72bef01d..eb2ec1fb07cb 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2983,8 +2983,14 @@ enum scan_flags_t { SF_QUEUED = BIT_1, }; +enum fc4type_t { + FS_FC4TYPE_FCP = BIT_0, + FS_FC4TYPE_NVME = BIT_1, +}; + struct fab_scan_rp { port_id_t id; + enum fc4type_t fc4type; u8 port_name[8]; u8 node_name[8]; }; @@ -3276,6 +3282,7 @@ struct qla_work_evt { } nack; struct { u8 fc4_type; + srb_t *sp; } gpnft; } u; }; diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 19f44e12926b..3c4c84ed0f0f 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -658,7 +658,7 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *, struct event_arg *); int qla2x00_mgmt_svr_login(scsi_qla_host_t *); void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea); int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport); -int qla24xx_async_gpnft(scsi_qla_host_t *, u8); +int qla24xx_async_gpnft(scsi_qla_host_t *, u8, srb_t *); void qla24xx_async_gpnft_done(scsi_qla_host_t *, srb_t *); void qla24xx_async_gnnft_done(scsi_qla_host_t *, srb_t *); int qla24xx_async_gnnid(scsi_qla_host_t *, fc_port_t *); diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index e6bb78e6f1d4..7ab93a0d19c1 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3860,7 +3860,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) fc_port_t *fcport; u32 i, rc; bool found; - u8 fc4type = sp->gen2; struct fab_scan_rp *rp; unsigned long flags; @@ -3933,7 +3932,7 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) "%s %d %8phC post new sess\n", __func__, __LINE__, rp->port_name); qla24xx_post_newsess_work(vha, &rp->id, rp->port_name, - rp->node_name, NULL, fc4type); + rp->node_name, NULL, rp->fc4type); } } @@ -3972,23 +3971,114 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) vha->scan.scan_flags &= ~SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); - if ((fc4type == FC4_TYPE_FCP_SCSI) && vha->flags.nvme_enabled) - qla24xx_async_gpnft(vha, FC4_TYPE_NVME); } -static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) +static void qla2x00_find_free_fcp_nvme_slot(struct scsi_qla_host *vha, + struct srb *sp) { - struct srb *sp = s; - struct scsi_qla_host *vha = sp->vha; - struct qla_work_evt *e; + struct qla_hw_data *ha = vha->hw; + int num_fibre_dev = ha->max_fibre_devices; struct ct_sns_req *ct_req = (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req; struct ct_sns_gpnft_rsp *ct_rsp = (struct ct_sns_gpnft_rsp *)sp->u.iocb_cmd.u.ctarg.rsp; struct ct_sns_gpn_ft_data *d; struct fab_scan_rp *rp; + u16 cmd = be16_to_cpu(ct_req->command); + u8 fc4_type = sp->gen2; int i, j, k; + port_id_t id; + u8 found; + u64 wwn; + + j = 0; + for (i = 0; i < num_fibre_dev; i++) { + d = &ct_rsp->entries[i]; + + id.b.rsvd_1 = 0; + id.b.domain = d->port_id[0]; + id.b.area = d->port_id[1]; + id.b.al_pa = d->port_id[2]; + wwn = wwn_to_u64(d->port_name); + + if (id.b24 == 0 || wwn == 0) + continue; + + if (fc4_type == FC4_TYPE_FCP_SCSI) { + if (cmd == GPN_FT_CMD) { + rp = &vha->scan.l[j]; + rp->id = id; + memcpy(rp->port_name, d->port_name, 8); + j++; + rp->fc4type = FS_FC4TYPE_FCP; + } else { + for (k = 0; k < num_fibre_dev; k++) { + rp = &vha->scan.l[k]; + if (id.b24 == rp->id.b24) { + memcpy(rp->node_name, + d->port_name, 8); + break; + } + } + } + } else { + /* Search if the fibre device supports FC4_TYPE_NVME */ + if (cmd == GPN_FT_CMD) { + found = 0; + + for (k = 0; k < num_fibre_dev; k++) { + rp = &vha->scan.l[k]; + if (!memcmp(rp->port_name, + d->port_name, 8)) { + /* + * Supports FC-NVMe & FCP + */ + rp->fc4type |= FS_FC4TYPE_NVME; + found = 1; + break; + } + } + + /* We found new FC-NVMe only port */ + if (!found) { + for (k = 0; k < num_fibre_dev; k++) { + rp = &vha->scan.l[k]; + if (wwn_to_u64(rp->port_name)) { + continue; + } else { + rp->id = id; + memcpy(rp->port_name, + d->port_name, 8); + rp->fc4type = + FS_FC4TYPE_NVME; + break; + } + } + } + } else { + for (k = 0; k < num_fibre_dev; k++) { + rp = &vha->scan.l[k]; + if (id.b24 == rp->id.b24) { + memcpy(rp->node_name, + d->port_name, 8); + break; + } + } + } + } + } +} + +static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) +{ + struct srb *sp = s; + struct scsi_qla_host *vha = sp->vha; + struct qla_work_evt *e; + struct ct_sns_req *ct_req = + (struct ct_sns_req *)sp->u.iocb_cmd.u.ctarg.req; u16 cmd = be16_to_cpu(ct_req->command); + u8 fc4_type = sp->gen2; + unsigned long flags; /* gen2 field is holding the fc4type */ ql_dbg(ql_dbg_disc, vha, 0xffff, @@ -4016,40 +4106,51 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) return; } - if (!res) { - port_id_t id; - u64 wwn; + if (!res) + qla2x00_find_free_fcp_nvme_slot(vha, sp); - j = 0; - for (i = 0; i < vha->hw->max_fibre_devices; i++) { - d = &ct_rsp->entries[i]; - - id.b.rsvd_1 = 0; - id.b.domain = d->port_id[0]; - id.b.area = d->port_id[1]; - id.b.al_pa = d->port_id[2]; - wwn = wwn_to_u64(d->port_name); - - if (id.b24 == 0 || wwn == 0) - continue; + if ((fc4_type == FC4_TYPE_FCP_SCSI) && vha->flags.nvme_enabled && + cmd == GNN_FT_CMD) { + del_timer(&sp->u.iocb_cmd.timer); + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); - if (cmd == GPN_FT_CMD) { - rp = &vha->scan.l[j]; - rp->id = id; - memcpy(rp->port_name, d->port_name, 8); - j++; - } else {/* GNN_FT_CMD */ - for (k = 0; k < vha->hw->max_fibre_devices; - k++) { - rp = &vha->scan.l[k]; - if (id.b24 == rp->id.b24) { - memcpy(rp->node_name, - d->port_name, 8); - break; - } - } + e = qla2x00_alloc_work(vha, QLA_EVT_GPNFT); + if (!e) { + /* + * please ignore kernel warning. Otherwise, + * we have mem leak. + */ + if (sp->u.iocb_cmd.u.ctarg.req) { + dma_free_coherent(&vha->hw->pdev->dev, + sizeof(struct ct_sns_pkt), + sp->u.iocb_cmd.u.ctarg.req, + sp->u.iocb_cmd.u.ctarg.req_dma); + sp->u.iocb_cmd.u.ctarg.req = NULL; } + if (sp->u.iocb_cmd.u.ctarg.rsp) { + dma_free_coherent(&vha->hw->pdev->dev, + sizeof(struct ct_sns_pkt), + sp->u.iocb_cmd.u.ctarg.rsp, + sp->u.iocb_cmd.u.ctarg.rsp_dma); + sp->u.iocb_cmd.u.ctarg.rsp = NULL; + } + + ql_dbg(ql_dbg_disc, vha, 0xffff, + "Async done-%s unable to alloc work element\n", + sp->name); + sp->free(sp); + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); + return; } + e->u.gpnft.fc4_type = FC4_TYPE_NVME; + sp->rc = res; + e->u.gpnft.sp = sp; + + qla2x00_post_work(vha, e); + return; } if (cmd == GPN_FT_CMD) @@ -4100,9 +4201,12 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, int rval = QLA_FUNCTION_FAILED; struct ct_sns_req *ct_req; struct ct_sns_pkt *ct_sns; + unsigned long flags; if (!vha->flags.online) { + spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); goto done_free_sp; } @@ -4111,10 +4215,18 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, "%s: req %p rsp %p are not setup\n", __func__, sp->u.iocb_cmd.u.ctarg.req, sp->u.iocb_cmd.u.ctarg.rsp); + spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); WARN_ON(1); goto done_free_sp; } + + ql_dbg(ql_dbg_disc, vha, 0xfffff, + "%s: FC4Type %x, CT-PASSTRHU %s command ctarg rsp size %d, ctarg req size %d\n", + __func__, fc4_type, sp->name, sp->u.iocb_cmd.u.ctarg.rsp_size, + sp->u.iocb_cmd.u.ctarg.req_size); + sp->type = SRB_CT_PTHRU_CMD; sp->name = "gnnft"; sp->gen1 = vha->hw->base_qpair->chip_reset; @@ -4177,15 +4289,17 @@ void qla24xx_async_gpnft_done(scsi_qla_host_t *vha, srb_t *sp) } /* Get WWPN list for certain fc4_type */ -int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) +int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp) { int rval = QLA_FUNCTION_FAILED; struct ct_sns_req *ct_req; - srb_t *sp; struct ct_sns_pkt *ct_sns; u32 rspsz; unsigned long flags; + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s enter\n", __func__); + if (!vha->flags.online) return rval; @@ -4198,9 +4312,58 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) vha->scan.scan_flags |= SF_SCANNING; spin_unlock_irqrestore(&vha->work_lock, flags); - sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); - if (!sp) { - vha->scan.scan_flags &= ~SF_SCANNING; + if (fc4_type == FC4_TYPE_FCP_SCSI) { + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s: Performing FCP Scan\n", __func__); + + if (sp) + sp->free(sp); /* should not happen */ + + sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); + if (!sp) { + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); + return rval; + } + + sp->u.iocb_cmd.u.ctarg.req = dma_zalloc_coherent( + &vha->hw->pdev->dev, sizeof(struct ct_sns_pkt), + &sp->u.iocb_cmd.u.ctarg.req_dma, GFP_KERNEL); + if (!sp->u.iocb_cmd.u.ctarg.req) { + ql_log(ql_log_warn, vha, 0xffff, + "Failed to allocate ct_sns request.\n"); + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); + goto done_free_sp; + } + sp->u.iocb_cmd.u.ctarg.req_size = GPN_FT_REQ_SIZE; + + rspsz = sizeof(struct ct_sns_gpnft_rsp) + + ((vha->hw->max_fibre_devices - 1) * + sizeof(struct ct_sns_gpn_ft_data)); + + sp->u.iocb_cmd.u.ctarg.rsp = dma_zalloc_coherent( + &vha->hw->pdev->dev, rspsz, + &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL); + if (!sp->u.iocb_cmd.u.ctarg.rsp) { + ql_log(ql_log_warn, vha, 0xffff, + "Failed to allocate ct_sns request.\n"); + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); + goto done_free_sp; + } + sp->u.iocb_cmd.u.ctarg.rsp_size = rspsz; + + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s scan list size %d\n", __func__, vha->scan.size); + + memset(vha->scan.l, 0, vha->scan.size); + } else if (!sp) { + ql_dbg(ql_dbg_disc, vha, 0xffff, + "NVME scan did not provide SP\n"); return rval; } @@ -4210,31 +4373,10 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) sp->gen2 = fc4_type; qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); - sp->u.iocb_cmd.u.ctarg.req = dma_zalloc_coherent(&vha->hw->pdev->dev, - sizeof(struct ct_sns_pkt), &sp->u.iocb_cmd.u.ctarg.req_dma, - GFP_KERNEL); - if (!sp->u.iocb_cmd.u.ctarg.req) { - ql_log(ql_log_warn, vha, 0xffff, - "Failed to allocate ct_sns request.\n"); - vha->scan.scan_flags &= ~SF_SCANNING; - goto done_free_sp; - } - rspsz = sizeof(struct ct_sns_gpnft_rsp) + ((vha->hw->max_fibre_devices - 1) * sizeof(struct ct_sns_gpn_ft_data)); - sp->u.iocb_cmd.u.ctarg.rsp = dma_zalloc_coherent(&vha->hw->pdev->dev, - rspsz, &sp->u.iocb_cmd.u.ctarg.rsp_dma, GFP_KERNEL); - if (!sp->u.iocb_cmd.u.ctarg.rsp) { - ql_log(ql_log_warn, vha, 0xffff, - "Failed to allocate ct_sns request.\n"); - vha->scan.scan_flags &= ~SF_SCANNING; - goto done_free_sp; - } - - memset(vha->scan.l, 0, vha->scan.size); - ct_sns = (struct ct_sns_pkt *)sp->u.iocb_cmd.u.ctarg.req; /* CT_IU preamble */ ct_req = qla2x00_prep_ct_req(ct_sns, GPN_FT_CMD, rspsz); @@ -4242,8 +4384,6 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) /* GPN_FT req */ ct_req->req.gpn_ft.port_type = fc4_type; - sp->u.iocb_cmd.u.ctarg.req_size = GPN_FT_REQ_SIZE; - sp->u.iocb_cmd.u.ctarg.rsp_size = rspsz; sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; @@ -4251,7 +4391,9 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) { + spin_lock_irqsave(&vha->work_lock, flags); vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); goto done_free_sp; } diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 5520477a66d9..8aeb0ed524a1 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5039,9 +5039,9 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) fcport->port_name, rval, fcport->fp_speed, mb[0], mb[1]); } else { ql_dbg(ql_dbg_disc, vha, 0x2005, - "iIDMA adjusted to %s GB/s on %8phN.\n", + "iIDMA adjusted to %s GB/s (%X) on %8phN.\n", qla2x00_get_link_speed_str(ha, fcport->fp_speed), - fcport->port_name); + fcport->fp_speed, fcport->port_name); } } @@ -5267,8 +5267,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) qlt_do_generation_tick(vha, &discovery_gen); if (USE_ASYNC_SCAN(ha)) { - rval = QLA_SUCCESS; - rval = qla24xx_async_gpnft(vha, FC4_TYPE_FCP_SCSI); + rval = qla24xx_async_gpnft(vha, FC4_TYPE_FCP_SCSI, + NULL); if (rval) set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); } else { diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 7fe265aca617..00b41528af5a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4821,9 +4821,10 @@ void qla24xx_create_new_sess(struct scsi_qla_host *vha, struct qla_work_evt *e) fcport->d_id = e->u.new_sess.id; fcport->flags |= FCF_FABRIC_DEVICE; fcport->fw_login_state = DSC_LS_PLOGI_PEND; - if (e->u.new_sess.fc4_type == FC4_TYPE_FCP_SCSI) { + if (e->u.new_sess.fc4_type & FS_FC4TYPE_FCP) fcport->fc4_type = FC4_TYPE_FCP_SCSI; - } else if (e->u.new_sess.fc4_type == FC4_TYPE_NVME) { + + if (e->u.new_sess.fc4_type & FS_FC4TYPE_NVME) { fcport->fc4_type = FC4_TYPE_OTHER; fcport->fc4f_nvme = FC4_TYPE_NVME; } @@ -5046,7 +5047,8 @@ qla2x00_do_work(struct scsi_qla_host *vha) e->u.logio.data); break; case QLA_EVT_GPNFT: - qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type); + qla24xx_async_gpnft(vha, e->u.gpnft.fc4_type, + e->u.gpnft.sp); break; case QLA_EVT_GPNFT_DONE: qla24xx_async_gpnft_done(vha, e->u.iosb.sp);