From patchwork Wed Jul 25 17:01:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10544463 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 BC7F79093 for ; Wed, 25 Jul 2018 17:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8DD72A1A0 for ; Wed, 25 Jul 2018 17:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D8F42A843; Wed, 25 Jul 2018 17:01:42 +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 11A362A871 for ; Wed, 25 Jul 2018 17:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729521AbeGYSON (ORCPT ); Wed, 25 Jul 2018 14:14:13 -0400 Received: from mail-sn1nam02on0082.outbound.protection.outlook.com ([104.47.36.82]:33233 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729496AbeGYSOM (ORCPT ); Wed, 25 Jul 2018 14:14:12 -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=1FecYZONyiH2w9zyTuuV3RUrS7CshNtwpFIZXZnrcU4=; b=eYtlxWZNpqdk54yi9c1HDUIUGv1PSvN8MVCQP4HH/93eVohpu3Ijj3/kPQ9M67FzNjKxbZtzlq80ZpUCFT5wYwNvDwH1fuwz3MIoiKcBt/xRRE+emPYh/0kN3Wpj58s3XuzFEN8puu6Nf+EtM+qZFhPCNKjtwPAfkPIxgGWq9QY= Received: from DM5PR07CA0034.namprd07.prod.outlook.com (2603:10b6:3:16::20) by SN1PR07MB4078.namprd07.prod.outlook.com (2603:10b6:802:2e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Wed, 25 Jul 2018 17:01:36 +0000 Received: from DM3NAM05FT022.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::205) by DM5PR07CA0034.outlook.office365.com (2603:10b6:3:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.995.16 via Frontend Transport; Wed, 25 Jul 2018 17:01:36 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=cavium.com; 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 DM3NAM05FT022.mail.protection.outlook.com (10.152.98.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.1017.0 via Frontend Transport; Wed, 25 Jul 2018 17:01:35 +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, 25 Jul 2018 10:01:22 -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 w6PH1MDK010348; Wed, 25 Jul 2018 10:01:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6PH1MWE010347; Wed, 25 Jul 2018 10:01:22 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 11/16] qla2xxx: Fix Management Server NPort handle reservation logic Date: Wed, 25 Jul 2018 10:01:15 -0700 Message-ID: <20180725170120.10269-12-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180725170120.10269-1-himanshu.madhani@cavium.com> References: <20180725170120.10269-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)(39860400002)(346002)(136003)(396003)(2980300002)(438002)(189003)(199004)(36756003)(14444005)(44832011)(126002)(2616005)(476003)(486006)(11346002)(446003)(186003)(5660300001)(81156014)(305945005)(2906002)(47776003)(69596002)(81166006)(50466002)(48376002)(50226002)(336012)(106466001)(26005)(356003)(8936002)(8676002)(80596001)(51416003)(86362001)(575784001)(76176011)(106002)(4326008)(6666003)(54906003)(478600001)(87636003)(16586007)(110136005)(72206003)(1076002)(42186006)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB4078;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;DM3NAM05FT022;1:N7t4mYKRTi60PX844UxTEH5Hah1sil8htxO7Wff9HDnkq+sP7vUpA++m3WVuEup/MX917R9w/FWna7mqImJ1cuNQM5lZ3mUsmBwHX3d+lNp8qcOCUQVqX55aeqDueAp6 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d38fa373-2a21-4dcd-a495-08d5f25047ee X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:SN1PR07MB4078; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4078;3:5yS7xRWj+k9Ksjuk+zgcEcnCUlue0q4SV6Kx/4T00zDg+SQb3xllkVNfI2MXKf+zhh5JxUYSKjH6ePx1sPIiy//dEpEXYRwvntDtOfaDrbOdTUsKW0/6unR2TEHO2DgFhjYh4kRihfnJMHutGaIvg6r8cd1hmoW+AS62sspmGiOB9AF94f4gHMoAvoEJFTzoZSVvmg8v4oZBSPGPIHX24wy5qDACheyKdxfyyxdW61+FvZkztgtt0uMna+EX9YSSXd86epg/6s5sQ61oyUvK7TEFs6NhWCTPtCI1Xr4q5UGxYrHbaxYeG9awv5uOfoFyru7iuULrAruaYpCoGeJqRfJexmoOpmPUoad3jsnHYpo=;25:vQgfe1tphaXEQUQ/FyjmKZqs1lWQYVRiZBcc1bLzrr/P9mO/49UhVtbmznSimrlSjS8F+XcqZQ2OExhgp+JEPyoLldoGgd3B/GATNPacQXsqcKGIcEUWcWWspQvQtiI1YipoZfOPMs2q4iveYu63n5f8nmuMjyXl6J3f4fxbJBooKchCi0/5lZbJRh+YQj6xdSPJTuM6rzqDnq8ka7igUO5VQWuxCahlMz/qKb57cke30RGjBhgvCT23rvaZ9uCy1UJyYkJKiTED7ZjpZ9HKAGAjZWmc/1aQV8ZI8OhTxSRoj+yUloxx1tXw+pxlPXOYja/qbR/jOfKb5hsQLzN8MQ== X-MS-TrafficTypeDiagnostic: SN1PR07MB4078: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4078;31:LDk0Mgm5gJ+BzPE/Z74r3kUrTu1HJtI5NwCLZAZE1V9IxJ+b1bn7TuSJ498ReP60WOP4wwBJJsrV5uVO3oATClsjyasgt8lpT8A+HxYtvTFkEhMCZj1SERy6MFjEj4mP1zqEFabKGW/miQqIxQS0HEGH4izMbIp8qXVqQtCGdVbaLjvAn//C8fR97l4t/VEMlRtQ2Az1P24XC6Frr1dnirdT8s2BeJ70zS8gIN97svU=;20:r+zwYR7q5/o1oHefIatU0HvQpYLFaXcV0wmm2pi37MsQdwA5j/OXFUA3DRSf9/hPYZG9ZsoQvrE4X+AAy7AEJw7D3I6cJrc1NqrOvaQn+vqYNdzZgjkxsIQRFT1yZafDwLwZY7Mg6JIi2PmQkAfoxE6KqPte+awhykzxHsaLNT4vxxP5QSTivk0xD2W4ibZwx+BojJ2E8Mr7Ch8kCW6L9eKvptNH3fIWbo8HRM4gOJ5i+v6tESEtpqoKifXz3u0YoNvGNDzd46D4tuufLXQpJywxLnWaCgjPV0DAj61JVnoOHNH7OTwzjACIufSqNWaxPYaoTOoQ8rgT+VdbBbhDrCr5vLBqFxOthILsON8lZG9pcm6gEzNWXk/An9fM7144Z1u3ElTbzdDrxFgxp753jHpP5X3vbtGPJ+z6jJYbjc+IMCOTLMo6l5eUiuJhttqAoRupljlIwtR9CdLEAfeqhuQJ/Zr0nY5xLaO4D//HDB63wKmRNZOhlxzQm9son/5l 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)(10201501046)(3002001)(93006095)(93004095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:SN1PR07MB4078;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB4078; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4078;4:yXfgttbTXPS8kcUs50psJ0PThkB6cHbYREz2rf7HI9bPxGS1cI3y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7rqB3QplsXqOHdcjYGqgvOMa58dW51y4v+HtGK7Pe6DVJYJPAqE5BBClztxLxZJlEAtR5Tm6XMMTjyo0eZ26cj6gTXk5zc0910gTIwMAFsmwLfB6D98tiKejdg5DzohNRUSGic0bCv4h2NCu22+TlqynJ5r7TJvanmT8iDbkXCHpoKERxr/7wKbwy8RvNIDjI4NMDB3gSolhmwStxhmDAE2i3hTcsIkiLbZ5i/yg==;5:mzo+AcMjtJLfHFf1dGyzl/STd1QKiq1tVRJDNCP5m/9rIOXKK7bLXkjMsS4oDGiB5RmsYEE2EHEsSK/MDnepetPD0OoOqi0131rMqKoHiA8uo0OjwczcU5ynpzqgY8haojGzglqQDJ5anNadOu7W4+wg+rmpxKSGJxq06EvsLxE=;24:GWAdNXwE1oW9RusLOOclxuLm+5f60s788e3VTfIcwLFLMTPlWmGspX0UjPHYMiPytf9s1Yx+eES3UGhrhVZJDm6myOd0/Nz6msjhHHlkpF4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4078;7:msWPCaMe5Te9suJNlrsgjTLkJwFKLkTkDXB7SFa21+BEWvTlC0FIE58Pw66UsPRlotH9nMw6zph0q1J5GMElKYh45Uvg/CLRle+pZZlNMQYyRvDzWEVXoaKsC2uqMOGOod5B9bVGxBoHrUOTrRdidf1uO2zLZB02MZ+1343haDjP8zgnTOPr02VyCTAgvki2e7a/EkKv664LOWKpk5a8yfBcIvVVeb9NptV/SH73W8T8kNd+fVzY+u5/aAnpv8tx X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 17:01:35.7951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d38fa373-2a21-4dcd-a495-08d5f25047ee 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: SN1PR07MB4078 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 2660a48d918a..ad0662a71a17 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 ff79bed54e07..eea378592bc5 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5613,6 +5613,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 aa727d07b702..d620f4bebcd0 100644 --- a/drivers/scsi/qla2xxx/qla_mid.c +++ b/drivers/scsi/qla2xxx/qla_mid.c @@ -492,7 +492,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 106150f1a86e..c781de0bdb66 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3049,7 +3049,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;