From patchwork Wed Aug 1 06:13:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10551749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21ED01822 for ; Wed, 1 Aug 2018 06:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11D582A5FC for ; Wed, 1 Aug 2018 06:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 063A52A64D; Wed, 1 Aug 2018 06:13:52 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 83E3E2A5FC for ; Wed, 1 Aug 2018 06:13:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733213AbeHAH5s (ORCPT ); Wed, 1 Aug 2018 03:57:48 -0400 Received: from mail-co1nam03on0061.outbound.protection.outlook.com ([104.47.40.61]:11199 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733192AbeHAH5s (ORCPT ); Wed, 1 Aug 2018 03:57:48 -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:X-MS-Exchange-SenderADCheck; bh=KBn17moMSoV7prm30SawXzlwX+QON0zoK5a9MZkcIWE=; b=dg1p2XZFza7lg4LEeAaXBc8mptR2g65S+PH5clJcc5oUWHlLUDmwWQhjRD1LqXYG/M7Mk0sQjsAnG8FGXe5r5XBUKNr0dEUZj/ODsW4qMkovaQY/ecXRnwS53hVZ/n9pExSVjKShCeQhls26c/Szz+U6OVGJZCoqUqi5hS5BChE= Received: from SN4PR0701CA0007.namprd07.prod.outlook.com (2603:10b6:803:28::17) by SN1PR07MB4077.namprd07.prod.outlook.com (2603:10b6:802:2c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.14; Wed, 1 Aug 2018 06:13:49 +0000 Received: from BY2NAM05FT053.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::207) by SN4PR0701CA0007.outlook.office365.com (2603:10b6:803:28::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.14 via Frontend Transport; Wed, 1 Aug 2018 06:13:49 +0000 Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 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 BY2NAM05FT053.mail.protection.outlook.com (10.152.100.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1038.3 via Frontend Transport; Wed, 1 Aug 2018 06:13:48 +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, 31 Jul 2018 23:13:37 -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 w716DcLs028789; Tue, 31 Jul 2018 23:13:38 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w716DcVJ028788; Tue, 31 Jul 2018 23:13:38 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 11/16] qla2xxx: Fix Management Server NPort handle reservation logic Date: Tue, 31 Jul 2018 23:13:30 -0700 Message-ID: <20180801061335.28709-12-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180801061335.28709-1-himanshu.madhani@cavium.com> References: <20180801061335.28709-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)(346002)(136003)(39850400004)(2980300002)(438002)(199004)(189003)(110136005)(54906003)(8676002)(81166006)(81156014)(5660300001)(50226002)(8936002)(52396003)(305945005)(6666003)(316002)(356003)(16586007)(42186006)(80596001)(69596002)(4326008)(51416003)(47776003)(186003)(44832011)(478600001)(48376002)(11346002)(50466002)(72206003)(106466001)(336012)(126002)(476003)(14444005)(76176011)(106002)(2906002)(1076002)(36756003)(446003)(87636003)(486006)(575784001)(86362001)(6346003)(26005)(2616005);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB4077;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BY2NAM05FT053;1:Z/VsnJFran8u1dxn4b6zEBkaQXqS0N4FFs3EVpXxSyXmqaWiK63N+Zb45zYvUBdOiae+kepWtdKQzTF/sWdVDPhBSqZx8okSHY0+8YlXPT/yX/4d2A4vahcgQV8VcySK X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 463db2b0-c0c0-4e27-0266-08d5f775f21d X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:SN1PR07MB4077; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4077;3:Niis/i2hUmjg0rK508ICtUlGj73WShqwpNlTvuMX0kQkIFqGuJjmAl8xH8MCU3rehYHQchSDVH2a7x/kh+Y//yEFMxxztBwP0N0d+R2kM91OB5xjyyx5ZEqnJzPXugUbH+EBVePdDNcL8yDW5SGhDx2t3+t/xF+U4n2gPHWV5NQUoj7s+AXXQbCm/87l9OcmXh8gvF7BS3Kq0Q4piPJZojRRWiCsL1z6aDSAJ6glQCPAFNF7RauMTSXVIN9ggsu7cTKqgkRLdTRQWlFrymrrfR4UYF8rjnHbXyMJN1tDvlP/JyWex6mNi0KhvB5jn9LcxY8k4q1COQMKKFuIUMowsvUQc4zMIEkI/MGQDwGCgsI=;25:sswpXQbsXoQ/JqgmEVggRWxzYWvBMMe3Sdcfrdfu7MK4KPuxpXswCRyiXlj9M6nYyrZrqH+HBQ6jRSk86qdXdktllB/8ho28DB+tb/ChkhnAR0noIlc0j3vUZELefuxj8824CobgXPe5WOIrNURJ8FG88PRr582PxuaJhnHNz9SQtPjYd1nX8Oayousq3LUlAIVaDfPTXdZ3lQIulpii/EKM0TUlmaZHiD8b3IgINHhZpQQHlW2FpH82UieZiq9xlHr2uBLLrToVFhf6Cc7zY5FscZOy2uW9znpRK0sWI2ZvIpIsaV1XbOWbrJNXQTwTPG3i+TyLE83vEtavClJVXQ== X-MS-TrafficTypeDiagnostic: SN1PR07MB4077: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4077;31:3WkjtW3CAQhQ8IJUX5J58VGVPpruzqprWdBC9PHecVrDwPLSMCUd7Kt2pAnMfCvG5ydScZOvt4ilvxKwj8P7lxvMN73WgDoVBWNgq/wfUjMcDF9Pr4iyrSfid4cOVHPXsLPDAK0jnWA0D4WLn60Ls8ZlDS64GidKVBOIkCZLRSr3kQJE/kv2kJXT85gtAsdf06TYWg6tnhVb3mTDGGAPgJPAMnBe49llO2gjgmWDEoE=;20:U8NNMW3xjDh0APLQxcInjic0KhSXn343qS0uc+zEjTfrs+06hOIL9UUnYIIFxe0tO/yIEubkJwAfTy43nTeAo3+KResgGXJBgGie64DorSKHB7vR/dUsDcKTEaOUOqukUTGDrcTZEHj8htRy0LT8g2tGGcctuCFvbLo3r0ZB/RgRCs4zXU4NraT9NiTYRoaRlIKsU4gEqCvlCWMyE1AFWUfVAmHLNIbdkuiTCKcBOMifY/LfLov2pNzp4tmkaae2RDPnaCU8+YuaDiHFVp98B3FrbqcBRLT6KlS/W/8spq0vDI7P3ZnXkKmS3BVIq3oAzPcRbLTP8MgERwCvRTSgnRDjR0luiTppxJrzpR0DPKtMavO/Ffm1gOYzs6XCNIIro/Wv2L7wgvI4bDrlKLRdLFXIUWsN/1duI+aH2KENLyw0Af3VpVbrZjbOfqqXspho3drJao39f16EmjAxgnE+YvKjT4Gb4a35KkkgXg8L9osMDGdpuKxTPW/hVSzwwTbf X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93004095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:SN1PR07MB4077;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB4077; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4077;4:FFZqpvgIqYEFeHV2Gt+eqE7fJzIwe2sLTASK/nUknsFRjpDPub9okPWNpS/NkopnDzKf7yxBUanKq+8YwoBI62lKyz+yLYYCraaHbIxdv7M4x3+54DaynKHjNqAJ6XZ8sYFfQUL7MAYhJMUM+/xPtb7aZ6YBs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ekJ3rZe0QemsZixyhX0h/LzTnT1+9NIYkT1lF5Oi1b1+Q2hD2sRwhBkBRfQLlvoAt9b1Tw0QkSYttR4U5Godgs+kLuUCJGMd4I9JJfSsE39i+vswxko4XK5aL7NlvpRVyOH9y4zYEaeILVK+NPhBQsw==;5:mhEqbzj51M7iNN4UtsH2wRLlkNiALUE4OIi/Jgd6KpI8d6LKysTLJeXSGUEz8ZXsK7RbLn1QjODCNt4ZkZvMx18l4PBzuxaEnLTStDcVsUAj9EXMaiC//iIJIUnMtr+3CT+BYTAXdSWLxYBgYDD7zHpEzM4H4zlP5dS9g3uFod8=;7:fVFjziTOStBYL+bhqMlI9pKvSjYUTTXrchYa3sY/3dMG8ddw77tFTfrA5WXo88CqoftJ5iMnBS0IGFo2jhtFpWFKQa0CPyXdwwUYTjnfr0zlr1PzRzkR71PgzEtQiGSz0u+orWkGpGLuMQ7KnYF/bqsSfQYm5cUFLP7bovKreBtFdQwRYPZIE7Xt6Wkgg32jsoyNE1JGHOT122xd0yia1jFC+M2JcUyaVE8qC0UczC/U5MUe6lpOmdZR5rMCSiPI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2018 06:13:48.5827 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 463db2b0-c0c0-4e27-0266-08d5f775f21d 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: SN1PR07MB4077 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 After selecting the NPort handle/loop_id, set a bit in the loop_id_map to prevent others from selecting the same NPort handle. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_init.c | 28 ++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_mid.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index f68eb6096559..00fbd49a9a7a 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -118,6 +118,7 @@ extern int qla2x00_post_async_prlo_done_work(struct scsi_qla_host *, fc_port_t *, uint16_t *); int qla_post_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); void qla_do_iidma_work(struct scsi_qla_host *vha, fc_port_t *fcport); +int qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *); /* * Global Data in qla_os.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 7a984f5e6f11..e92f60a73bc3 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5615,6 +5615,34 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) } +/* FW does not set aside Loop id for MGMT Server/FFFFFAh */ +int +qla2x00_reserve_mgmt_server_loop_id(scsi_qla_host_t *vha) +{ + int loop_id = FC_NO_LOOP_ID; + int lid = NPH_MGMT_SERVER - vha->vp_idx; + unsigned long flags; + struct qla_hw_data *ha = vha->hw; + + if (vha->vp_idx == 0) { + set_bit(NPH_MGMT_SERVER, ha->loop_id_map); + return NPH_MGMT_SERVER; + } + + /* pick id from high and work down to low */ + spin_lock_irqsave(&ha->vport_slock, flags); + for (; lid > 0; lid--) { + if (!test_bit(lid, vha->hw->loop_id_map)) { + set_bit(lid, vha->hw->loop_id_map); + loop_id = lid; + break; + } + } + spin_unlock_irqrestore(&ha->vport_slock, flags); + + return loop_id; +} + /* * qla2x00_fabric_login * Issue fabric login command. diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c index f6f0a759a7c2..14bc88bc4a5a 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -485,7 +485,7 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) "Couldn't allocate vp_id.\n"); goto create_vhost_failed; } - vha->mgmt_svr_loop_id = NPH_MGMT_SERVER; + vha->mgmt_svr_loop_id = qla2x00_reserve_mgmt_server_loop_id(vha); vha->dpc_flags = 0L; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 04e0c7f51e68..48d1003c8178 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3048,7 +3048,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) host = base_vha->host; base_vha->req = req; if (IS_QLA2XXX_MIDTYPE(ha)) - base_vha->mgmt_svr_loop_id = NPH_MGMT_SERVER; + base_vha->mgmt_svr_loop_id = + qla2x00_reserve_mgmt_server_loop_id(base_vha); else base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + base_vha->vp_idx;