From patchwork Thu Aug 2 20:16:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10554173 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 02EB89093 for ; Thu, 2 Aug 2018 20:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E40482C444 for ; Thu, 2 Aug 2018 20:17:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8A002C461; Thu, 2 Aug 2018 20:17:22 +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 E62502C459 for ; Thu, 2 Aug 2018 20:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730730AbeHBWKC (ORCPT ); Thu, 2 Aug 2018 18:10:02 -0400 Received: from mail-eopbgr700071.outbound.protection.outlook.com ([40.107.70.71]:56928 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729639AbeHBWKC (ORCPT ); Thu, 2 Aug 2018 18:10: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:X-MS-Exchange-SenderADCheck; bh=VrPrgjSFUQHNZH3AxbyjOuIvxPISsrwbZrq8TuFB5s0=; b=TRGZxGAjkhjNvpq3UTr/rWskDxDR6MJaTfc4nJOMDz5k9VJzz3viMszAkdSB5Y2HB40xPEmxSlRmCywOy+uZXkdWV8aUhv4igDwSUh5oFYvQDkTZuaPJv4Jz3px8EwDuZyVmZpKxen4nh2tSYUdnaAi3bZHFgb9gdScJ9VNBstI= Received: from DM5PR07CA0089.namprd07.prod.outlook.com (2603:10b6:4:ae::18) by BY2PR07MB1459.namprd07.prod.outlook.com (2a01:111:e400:515f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Thu, 2 Aug 2018 20:17:13 +0000 Received: from BY2NAM05FT006.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::206) by DM5PR07CA0089.outlook.office365.com (2603:10b6:4:ae::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.14 via Frontend Transport; Thu, 2 Aug 2018 20:17:12 +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 BY2NAM05FT006.mail.protection.outlook.com (10.152.100.143) 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; Thu, 2 Aug 2018 20:17:12 +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; Thu, 2 Aug 2018 13:17:01 -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 w72KH0xj007982; Thu, 2 Aug 2018 13:17:00 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w72KH08p007981; Thu, 2 Aug 2018 13:17:00 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 11/16] qla2xxx: Fix Management Server NPort handle reservation logic Date: Thu, 2 Aug 2018 13:16:53 -0700 Message-ID: <20180802201658.7903-12-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180802201658.7903-1-himanshu.madhani@cavium.com> References: <20180802201658.7903-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)(356003)(47776003)(14444005)(4326008)(87636003)(80596001)(44832011)(2906002)(106466001)(36756003)(6666003)(316002)(486006)(446003)(478600001)(2616005)(69596002)(50226002)(5660300001)(50466002)(48376002)(81156014)(42186006)(575784001)(11346002)(86362001)(8676002)(81166006)(305945005)(186003)(72206003)(76176011)(16586007)(110136005)(26005)(126002)(54906003)(476003)(336012)(1076002)(51416003)(106002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB1459;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;BY2NAM05FT006;1:JAnDwpYoItmkxZLHsznpnuhIThJmQY+kOlCImK0eXRK9/0J22PLv4M84WOgjSxg2shuHsdggPZPPq2cm69O5cn9p5c0ZUD6gWhum3mvH6aM4Trx0ADNic9s5jRc4YaFR X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e58dda44-0974-483d-f554-08d5f8b4eead X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BY2PR07MB1459; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;3:349B4jj8MQGPmCHezTZekoCVF9ITwEqq5t11sTzWt5Y3SfioXYnnDGDfMAX7F9RtCCNYGq6QDt1iHLDy23Q4FDwwTjYW1PRafmFqT38JOOWGG89ogcGISst6+0jFG08ebambzRjkrYsg0cHv1rGXKW2sHVcncTByGs6A3KaHqfEgYmW+zbSj5Wijizg6sfjldYyf4CHWQnyJjk0p9r/LwbS14RNGmB5wGeAt68x5mf8HT6Trag+aJ4L/S4rmms/RnBTfmz/Tlit5540mz7a1NEo8jJbgcDVC4nd04rETnk6OfFWa72hfyXaa8ypjab/nr2Foj2+mNSTl8qMQt2dNHthSEX6imukcbp1HgslQ+J0=;25:T+TF/BRV7JmHUlF5E1I1RrcBapNgGmYz4vMgiGUfG4YeHqloUi93YfARuV2LdSGi6F3XUrbnDvIDz3wIQ8Yx+fqYp/CfC1nVKA7GmQ4Si+8AuUZqBdqFxduVyFi5P/OhbsVzSFUf7W7e8ND4nRpY1VXAx/sHW9kBjFeJt8rm4lXE21q6wSwp3894c98fXWbSlm1EdFzkCD1CbVdghDe2pqWf46ER6d34JeZs6u76f9DhiOWwYMP6H+cvNYz2G6pNhrStOJjYxwePnfupGBqSUh5Cnmtzn0zPt6QmkkodXPcB8fqg/yBlspDIweqkCk3j0Q/UxOu672uwxLnrQEP4sg== X-MS-TrafficTypeDiagnostic: BY2PR07MB1459: X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;31:Z38iJYifC0gg+WOaEnJrBPVhD60X5GtmzFGbsaZ+wfo7ymdxvF+AXQsRtv1WxsI0W969d6Oy5if3WBXCNtVw35BnEDuwXB/Wh0l8A7zfxSJ9Qxq3L86a5jbw+U2kPNzqBYQ6uPb05JQAyH8Zto8DE5XfHDUAX+pyP7UJAkMVVixPscoqRBVBomV8777MvACzdGUGRQdNHwMyh7UqUU31EiHc1G+a7xh6wNldRp8KMTQ=;20:mAFanuiotgxWHIOLOkXeRackWDpLhTOiJDNFd9DWEajZxDTfKErEyRovo+Q3U2lAjuq4fK7aKAQ15MZKmkxCW5H1BTLhMAHArNKHx/O1X9YNUW1XkqWlJeU3SKcKio3eUSLUdy/fO3O+H0db61qGfN+rQsTdHH5FxymB/e46fwhUHpN9RyE+e1S2dY3pvAOVPVTKEV+kmLQgyPTgCZj6bzz4BBHyhDtHktg6SoDIK1QCG0O7x6fHOgQdrGfEw/GGskE9B8gbjlobFNrrRAqoSpBDODkmJ0ISxgwCVMQHki63FOuRTz1pHkZximsSE4lkjJFmvZc7e67jboSpcg7+hXyy3oD2HLEJSlM78tMnf1dnX2AjXQTqQKjWvzTN2TRJSpqIw5BJx0Jsc4wpxfkL7urjIu+Z2yBsiq8WCm17J7StYjhEfaPYZj6ujoqrRJAIQuTHOuwrUT2KfmFBQz4pXdF+yeWGHDz7V0WanD5Zh7abMzx380PargmX7gfvFIsj 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93004095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:BY2PR07MB1459;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1459; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB1459;4:E9cILtxuzLzkLrJiFaOgIhvQcNVIrdRW9atYQ5eMnUEuHa63PniaOepBhQeijBiVHUyNlk613CUup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mVj1dTz89fwf/9rPiurCPVePRl5rrnOP2+X+iHvoB1+8eCi7vMOMISA4Hni4g8yysMgTqa2kfzVF1GGitHAggYhtFKlXKhtSssiGP5qGy7mjmtz1EgTAN7ziB5Odwi8s1FkD3vRxEEAJXt7cMN16CHdH1w9wX3OMkvvbXV7qh7IAg3JCQyv7JX4gSzd0RwyXr9sm5lVt+AnHMMyzdfMc60nKDfriFBGVbrIAA==;5:YQ9pfgGpLDCOJLm6ekOoz8e7kY0Pe8CL7kSQfH2oZ5IeefYmkNzjtzAhdqpbILXZKkHrcY9tBdGmAsO7/D1fMS2oA72mIdXLZrGB+qV22s8nf6FKI5nfP5MzSCTt0TGtgzLOHu+cjgFPBbV6WzkFl2qqqsYNwmyBUTz3Lk2V1Yg=;7:UfIUxOTjJFgVdNcNUHbWjF9udRW5WeW3iPblmG4UCJ2i7313m9z9xece2rOmYn/nmM1QimhIX9QymCXNd3bjmFxOe+inye9Ep9rKYYI595w3wVoQvNd1YDZEam3USzlX0LjnhnPuXYQhEeGQoEsKHimdj7bgfOVfqyvaKKVOWvMsLPrlIbolH1xcGQ01behxEC3StpP8foc+RqTiGI3XZuK+UsTgaasVZTgvgwgsuO0swa7TqnF2v/0VR+5tR6lJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 20:17:12.2941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e58dda44-0974-483d-f554-08d5f8b4eead 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: BY2PR07MB1459 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 a10a8bb895e9..9d1a8b2c41a9 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5616,6 +5616,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;