From patchwork Tue Mar 20 05:58:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10296447 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 5B42960386 for ; Tue, 20 Mar 2018 05:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B15528AFD for ; Tue, 20 Mar 2018 05:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F7FC2951C; Tue, 20 Mar 2018 05:59:20 +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 2403228AFD for ; Tue, 20 Mar 2018 05:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751765AbeCTF7R (ORCPT ); Tue, 20 Mar 2018 01:59:17 -0400 Received: from mail-sn1nam02on0056.outbound.protection.outlook.com ([104.47.36.56]:32192 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750828AbeCTF7C (ORCPT ); Tue, 20 Mar 2018 01:59:02 -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=fp0FjnZ0Hzbkao6vzuWC5lYRIvdZcibdo6a/LejfbXo=; b=EeU/IDJ6c72pjKvWngQvLeIo2Eo+vh0frWEZf8vCWOAO7NHRWMwHxXKru4e5iz4Xhtab8QLX5QPPFcJsk6IRNgWjaSr6iGdhf2rNycoeKn+1yuQTmqEt9Jb4DlZcvJ2agjwS5atgycKSPkjW9h3CDLOT9Suo33F5u+DU+nnomEc= Received: from SN1PR0701CA0031.namprd07.prod.outlook.com (10.162.96.41) by DM6PR07MB4217.namprd07.prod.outlook.com (20.176.94.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.588.14; Tue, 20 Mar 2018 05:59:01 +0000 Received: from BL2FFO11FD025.protection.gbl (2a01:111:f400:7c09::128) by SN1PR0701CA0031.outlook.office365.com (2a01:111:e400:5173::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.588.14 via Frontend Transport; Tue, 20 Mar 2018 05:59:00 +0000 Authentication-Results: spf=fail (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: 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 BL2FFO11FD025.mail.protection.outlook.com (10.173.161.104) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.527.18 via Frontend Transport; Tue, 20 Mar 2018 05:59:00 +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; Mon, 19 Mar 2018 22:58:40 -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 w2K5weJM005329; Mon, 19 Mar 2018 22:58:40 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w2K5weOf005328; Mon, 19 Mar 2018 22:58:40 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 12/13] qla2xxx: Fix Async GPN_FT for FCP and FC-NVMe scan Date: Mon, 19 Mar 2018 22:58:36 -0700 Message-ID: <20180320055837.5246-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180320055837.5246-1-himanshu.madhani@cavium.com> References: <20180320055837.5246-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)(39860400002)(39380400002)(376002)(346002)(396003)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(186003)(8936002)(6666003)(59450400001)(86362001)(114624004)(2950100002)(87636003)(72206003)(575784001)(36756003)(105606002)(50226002)(1076002)(305945005)(4326008)(2906002)(8676002)(85426001)(336012)(81166006)(110136005)(47776003)(69596002)(54906003)(5660300001)(106466001)(50466002)(356003)(81156014)(48376002)(316002)(80596001)(51416003)(42186006)(26005)(16586007)(76176011)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR07MB4217; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD025; 1:nxEFxsBHb+wl1P9JEQeOHz5v3ylEmup3NltV9go4Oyz33AdAPkPO3mYdIBpycvaD/ytnxsPfzDkXvZUiIP7wEPKxeu2zle9gG2BIpwpAHF6grlt8Qb01q6HXRL/UYtYb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e5eb2ca-0594-4b00-da10-08d58e27ad5c X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM6PR07MB4217; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4217; 3:+wbwt+rM1hnWIKtt0gML1thYtpgdV+pFo/vBCXGnXup+N83c08BAvFgs36GpQ7lW0M7U81SLt4KhNyaK1/Rk+3Vgqtpy9iid8YsqvI1GAzVALCquqeDpJW7EbNSqtZe6/nRk7OS3Th7DEKYmgRWt7biZQiet7NHC0JTX65aStaf5SscM3e0To8r5wnkKOytRHiVilZn/JWsNTXOoB2qwZZH80ltR8jXscltfjoV1E+L2fsK0vQtuLgtFTGoOL3ql2oYNOvUIJ8T3xCsGSSrxQ+sxgyZMjslXtL/MjYgM41LdcYFT/f5JoRa8Nx0wcDvddQoasv+3tf4RYXWmZ8ZLNF/96YgmYFNjDIeoyJ2rZjE=; 25:tfyl9y/duzdygVjmeYhKVsKcjGeJO3z6XXU3qdLkA07fRKBA28lO7gxd8OpCp0bgyaMWMpTAEft62pGcMBe4vxQjOyBbcIfOOZeQ4MqXFrtB2XKXSWIquRH+3a1CQXufHSZZWbaaHXx8pXRcN9jBncP9WDkcJPVq6CzDTmhQtmaMNsjWKM5DDdzCVqC8YbYGzUK4ZQRveVdZ/WeYjL/IcO4+M3oSDlWj4aV0HFubfAWy0uvknOlNG7eey9XQ38W+DUzI5SU5VSggtqyKi32E149d+Z7ZIMBUgbFkPFDYm8RiDncPwXJ4WBW23QGOmcBjZmDwZFfbZbLA9FDRIIoorA== X-MS-TrafficTypeDiagnostic: DM6PR07MB4217: X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4217; 31:BiRdFb7u7tb41zYDf/wazJ/hgI11QAU5FzQW/e1ZAl2MvQ1WWPrVDyAUdn2DCCP/nAW4/ZyK40P1f/ghx64XxQYCflAobAO2IQqC5AyT39dxBPCnMwQsW+lSyMbSvlHKe6mBguQIGT234a6chE+4rupW0+dx/ljHpUO77vKxqAtJg7QcfLWfjJCtdQkNLxY5mU2AxaynSxMUGfpwx7sW8lG/f2xrtIjJc1/YOvvuRW8=; 20:6KjsKiqNkxJOi0hKMI0lMjTdlsIXZLWhiEfjEMMjNzYb14tUuYLMAdcLwsvte9OggUdB0KUsbguGMvbVh4nzYOFxfr49NiUgjMR7YKqwoC3lp/yYbeF47QxqEvm9otl38AuQB1yi//RlHV3E7WVlL82LkLHVWjFSc2o8eD5srpnymfSAp+qcQdc//ahWbolZc5dnCGL1Zjgi55qbbgO/plIGGzmOOnh0ifgoBfzzQ/pc8CgvIIqGuWVkLDAFEOhnP89RXuQlEa26dQscFLgLDM+cAtgKIBkxHB54z95odi66c6sJXRSRsnjvJgJNPwQ0CZU5YfHORRmGbyX94sHMXB1p3IsRFZOr9xI1K80o90NP996tjrmpxJJR913PsC0ehZpL8nvCSRhvcMj8LL4FA0rWJgWXMey9B8kY8j6gaP7t1NBPUYtvI+2EE0456noEav6kvr96ya1NLZYfz/tfxj+uHBBXnVDlcRnAsp68L48R+Lc6JwgzBJ1BVcCyFEaD 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)(3231221)(944501244)(52105095)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:DM6PR07MB4217; BCL:0; PCL:0; RULEID:; SRVR:DM6PR07MB4217; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4217; 4:uo2R+PytjuiH98voTG/grnRHzSwcSieRVmwGMVjugi0yuWOQK3RkyrwTMlVjMIyyfsol6LwCfyM9YYLRPOlx2j4emfLJvlx5J6XlgDqJ6hdPcfxz/VsYBNAjV8n88RptnYqvJzgr6hCnka+SnZYHYewnR/AxiwIXvLlTNFp4IvRN12dIU5r/s70a0VJt9iMVOZ+GahbXBe4JkWtYMcag/XV6XlWMznxc/wMts3i5+5/etsN0C+k/l1ZaEU3ewr2KB5FTmARn3iMihKJujnm5v5WM7bLFt30o5OyJU4qAk9445NoBDaAELo0GfFaN2Onn X-Forefront-PRVS: 061725F016 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR07MB4217; 23:qN8bb3ZJRQ5Co8Xrclvp84itgOsiHLvZHooxUxr/N?= =?us-ascii?Q?eGcLbeM4OJffaVAb5mtVVaQvNxVygjiN7PNXv1w2bhA/ZLB0jghjPapO0PF1?= =?us-ascii?Q?oNmUtQHTbqek8SIv5JYdGaEObdx7UMSPzZtonl/BtTvRzcKa1uU2cbuyMxt2?= =?us-ascii?Q?otImi5kuNUBQfTdxXZRZ7F1qwAuKiEROdQrBksWBGopaXfOiP9DCz47FCJiA?= =?us-ascii?Q?YVq6N2wvRoXyhOZKOY6CSoVRZga7Dk+P0LN8msEPWGCwG8IQyTAyQXEp5eo8?= =?us-ascii?Q?enSzbEuhk5IGtb7c1+ercEWeL0jEKRfcgAFc/u3JgrTZ0eDUOZC9tEiLtumg?= =?us-ascii?Q?gUIEdPoFgc4CoVPtf0OdiCSuajq8j5Pl26k+I2MJu7G6kYecvkz/BmPZRaWR?= =?us-ascii?Q?Np+TgJR29dqNGjpV3tBc8tiiOkv6rgBshnTT9n2A69ukKq4TQR5LTObS4gzP?= =?us-ascii?Q?xDL9MuUnEzxR6y6BFjbqFwCzo1RDVeTiEZYt42xaiF9SRVCd42MyTkytYcA+?= =?us-ascii?Q?vlV4sib/mtVDH1YhlZGZN7HNJQjBE0ogKwGv5OV8guQOgkywq755mzCWUXFw?= =?us-ascii?Q?FWoCSmhWvWfKzArGgibqevOx0HkqCy1PjWBOanPkEEnRKinr8GNAjFoUlHVQ?= =?us-ascii?Q?GRe5JOIeI6XkhQLPhO/ElFcSQumotPirwZgcw9nsTx4nHOcG0Rw1xfMea3W9?= =?us-ascii?Q?5naGno6D3790b7r7g7pg7uwSzIU0ATBCpACpjNqPHOpKfvY7eK6EUg4SgupH?= =?us-ascii?Q?K2vcDQk3jyarUMIHt8yicDPGMkf+S+YpzflKcORphZ3WgboRonVcJjhZYmwx?= =?us-ascii?Q?3JFp2MZovVzuO+JcsmQDM+9FlkOFC8WoFeGiMFTKxIp10T4ISLubvuf94MHA?= =?us-ascii?Q?Q7Uw8eFArCeVpShU7SnrfXB6hycV9sqy0PWE3EEuJZ/6VyeD6AeUTU9szm+j?= =?us-ascii?Q?uWlX7/aTY8LqC8DgbDpnb+K5dWQAiSy6oIQcc1gX5Fv6L80garp/FWTlsKxN?= =?us-ascii?Q?sl0ceDjGnKQgDNTqzPFhmdbnWK/a0MVma3fy4JUCqXIndsc9EWvYMNWrKOqz?= =?us-ascii?Q?kGO5OoMdJS8DhHb8zSBlS5S43r1kf0of7UmK+Mz+fE0B66LJOcOEAd/VsNtU?= =?us-ascii?Q?V9wfeSG1QJsUpKBapEnSmhIAFN1Xlhdm4t5aLjFXpDL9+FoWTENcg=3D=3D?= X-Microsoft-Antispam-Message-Info: dzwySL+6gtrlFJsACWAaAKjYtpYTKoSraqb/Qc2cw7anVTaybqTOy3GBjeVNxIKaBd1dSItxiogocFh5e11/0mplrU/sh9GZ1gzpOtEXyBRGf2zZBmm21rDWVesNbULQ5rvlXjXH3aZEWq1qjlfwpmVhC4EQydYxGITPBhnSg+OK9iqTGOrgl2XQMRwO7Bo6 X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4217; 6:24inOnt8CpREyillnsmiR5Dde6KhfetL5pK7Ie1qHN92i/7EudqHNYiossWJFJb7QZTzxlGLhR7QJmtAPGStN4Sf4K8MCpa7kHUCyTCEDkmiwqgxNp6kLFP8EjAaZOx1bXtWaY0ulGyoevCm8TyNjg9y1cMDkRotJkm0w5gLvkSD1gVq3OG2WhU/ktk7yxdoLCFjsWZiO6I+o3MuNRXRisWUIyjbgqNNuRIUfzW6sEYCZRnTFgOG88P6iEyYw8lcxt4sAVDg5jrWFIQzQhGcXJSXv4kHx/tuOB9tFxK4hKdLD74l74at/awJoazcRzyfaWR2OTuwedphzyO3SjrPs+Rx1oIViZILv1bouKj8ixE=; 5:3vF68x69hi9GFlGEI8vwQI5R14YXlRqHSoUdnV7nSKPxWmBWnIMu4icWOxna0ZcV61Bb4uqCx3N1Oy5EIf5MdzU8lAz9FMTaF+rMe/Bpa8qjJkHWBHGkx6FSA8gF5+yizAKvDnEW47qQ5Q2T47Fq6vFyrRDpTZdn+4yqhsNDTio=; 24:zEs/vXr27xPjFJHJhbUexOtnMh5qy2YHc/W1U4vSNynBH3rT+VFW8u0yVOpEzuerlyPQRhEGWerXnW6isaz9tZHpQTk/h6C2/moRHBSmv10=; 7:bK14qMg7qvvN/8BQ08yZVw4Q/xaXEiIl8R2rTco/9kppAucOL8DrEMEgxyievwvG0PRFLfjtN5h6KaRNp3FIZb4py+K7frOveTXU//86ywHIEhryeOcPCSQPa83pXlhy/tvaXtWP30I71QUgsbia0iw5t88zoJhbkiiu9AjTwjPO6qLtbSvbUH4gVe5A/ad/Ez2wYbs7PNA5sUaYW/fBTvM/EQZQiNpFEVTIh8ni0IW/46lf7Ou9+tZZjqyw4Kxx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2018 05:59:00.2617 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e5eb2ca-0594-4b00-da10-08d58e27ad5c 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: DM6PR07MB4217 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 | 8 ++ drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_gs.c | 272 ++++++++++++++++++++++++++++++---------- drivers/scsi/qla2xxx/qla_init.c | 8 +- drivers/scsi/qla2xxx/qla_os.c | 10 +- 5 files changed, 229 insertions(+), 71 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 6aae126add0c..54625eb2904f 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2217,6 +2217,7 @@ typedef struct { /* FCP-4 types */ #define FC4_TYPE_FCP_SCSI 0x08 +#define FC4_TYPE_NVME 0x28 #define FC4_TYPE_OTHER 0x0 #define FC4_TYPE_UNKNOWN 0xff @@ -2982,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]; }; @@ -3275,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 e4d404c24506..39dd62b8c649 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3858,7 +3858,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; @@ -3931,7 +3930,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); } } @@ -3971,19 +3970,112 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) spin_unlock_irqrestore(&vha->work_lock, flags); } -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, @@ -4011,40 +4103,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) @@ -4095,9 +4198,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; } @@ -4106,10 +4212,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; @@ -4172,15 +4286,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; @@ -4193,9 +4309,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; } @@ -4205,31 +4370,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); @@ -4237,8 +4381,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; @@ -4246,7 +4388,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 15a96dc205d0..77c9177d0c25 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5036,9 +5036,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); } } @@ -5264,8 +5264,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 54f93f9cba48..6fa2467e2a16 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4803,9 +4803,14 @@ 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; + if (e->u.new_sess.fc4_type & FS_FC4TYPE_NVME) { + fcport->fc4_type = FC4_TYPE_OTHER; + fcport->fc4f_nvme = FC4_TYPE_NVME; + } + memcpy(fcport->port_name, e->u.new_sess.port_name, WWN_SIZE); } else { @@ -5021,7 +5026,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);