From patchwork Fri Feb 3 22:40:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9555241 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 ACD5A602B7 for ; Fri, 3 Feb 2017 22:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 970632816B for ; Fri, 3 Feb 2017 22:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BF222818E; Fri, 3 Feb 2017 22:42:16 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B6FD727F9F for ; Fri, 3 Feb 2017 22:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753072AbdBCWmO (ORCPT ); Fri, 3 Feb 2017 17:42:14 -0500 Received: from mail-dm3nam03on0067.outbound.protection.outlook.com ([104.47.41.67]:51168 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753027AbdBCWlz (ORCPT ); Fri, 3 Feb 2017 17:41:55 -0500 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=eAKBcUhJVLuxTv8kMIF5OKQvFxAx5rxU8JtdxMZfp2k=; b=jYfHqV07+zprS0sQUn2AW7BUoTtELS4QgebL9ULShxnfbDskZQ9rpnw84ut1SIu3sfzXnNlZglk6Y/98xQgYLg6+OzPLeeFjTt3gQJN4pQfgxQ4u8i5XSU/Qc4q1Q9RqOEf2eIUH5kRWrvGprIDQcH462X+yP0tmjnDUut7Pho8= Received: from BN6PR07CA0017.namprd07.prod.outlook.com (10.173.33.155) by CO1PR07MB207.namprd07.prod.outlook.com (10.242.167.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Fri, 3 Feb 2017 22:41:52 +0000 Received: from BN1BFFO11FD023.protection.gbl (2a01:111:f400:7c10::1:128) by BN6PR07CA0017.outlook.office365.com (2603:10b6:404:3a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Fri, 3 Feb 2017 22:41:50 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; linux-iscsi.org; dkim=none (message not signed) header.d=none; linux-iscsi.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1BFFO11FD023.mail.protection.outlook.com (10.58.144.86) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.888.7 via Frontend Transport; Fri, 3 Feb 2017 22:41: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.309.2; Fri, 3 Feb 2017 14:41:25 -0800 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 v13MfBVc002368; Fri, 3 Feb 2017 14:41:11 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v13MfB0O002367; Fri, 3 Feb 2017 14:41:11 -0800 From: Himanshu Madhani To: , , , CC: , , Subject: [PATCH v2 08/14] qla2xxx: Change scsi host lookup method Date: Fri, 3 Feb 2017 14:40:49 -0800 Message-ID: <1486161655-2307-9-git-send-email-himanshu.madhani@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1486161655-2307-1-git-send-email-himanshu.madhani@cavium.com> References: <1486161655-2307-1-git-send-email-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)(6009001)(7916002)(39450400003)(2980300002)(428002)(199003)(189002)(4001430100002)(8656002)(189998001)(47776003)(5660300001)(8936002)(38730400001)(80596001)(69596002)(305945005)(356003)(5003940100001)(2201001)(86362001)(50226002)(575784001)(50466002)(48376002)(1691005)(4326007)(2906002)(4720700003)(6666003)(92566002)(2950100002)(54906002)(626004)(36756003)(8676002)(106466001)(42186005)(76176999)(107886002)(81166006)(81156014)(105586002)(50986999)(101416001)(5001770100001)(33646002)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO1PR07MB207; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD023; 1:r9JRYiy78jOPMpVmeiT2KFaYCIbamy4JL0ZdpLsojScdHvJxzRLMfeO0N+nnwjXvkOgupwJ8Jxi3oE8193uHpK3lU08V50Q1PVxJ/QV3yTfr2sIz5XaRAMsB1IVz/E1cLay7Mem2a/WJ8J9gEtfzhbrS3kiISyCkdA+Yj68yIybaagEUtZG3smjyIT9Vh5A0gckOZtPgLpKYo0uTfyy5EhnejH0e4ub8Mhj6n4Zo1YFZvntAe97U8IFEPb1xbdj5B1XJQTnr6d03AugXlSArJFAoYFBfCaay+759bjO3Nh8var8ly4Z5cxj1CcswzHW6Pu41gAoucJm3U4f6jZBi90RJ0PXvo8yppRhxQXbu0oqFqo2ON6EIcXF1/uQ/7vX9F3iwgAPIzNWRO2OauFKaA3P/Qyg07eJNbthpF2/zmsiikLtn5B3V8UxK3QY/LZmfH4JzitWWZMlUr3bJyPaSqG1UxVcHnmzYmoFBFDLRYy7pLATvXK5w3ANZWA5hkujZtR/KXXsNgho1QH6+/ca0Xkh4Jgc3miJ63QtPuJsKhRs= X-MS-Office365-Filtering-Correlation-Id: 595b62e9-e3e3-49b2-754a-08d44c85d80a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO1PR07MB207; X-Microsoft-Exchange-Diagnostics: 1; CO1PR07MB207; 3:8SFk5APmdd1M1g9U8/dDzXaN6F1zQePlJAMO8m++7n1GQ+SqNgykRkdg0ZgyHBFBup17JnABQlrC+vCFHOjfA95I1usnq2Xcj1LKP6Cwt7vWE4rnBQx+nbOMnViv7JMu4Efb+ZKv1HDkkHpoFYmh6L9+vHNugmmNBWPlMq3a9ODuP0GaTBU5j/kO4RaksVBJ1d7p4A8rof7kz5vyQUP+1U8CCRw1dwsrLHPqndiP06WUUmlG4TSQAPuwdfsC5jkluYNDeK2qeMVBgGpl83q2vm4ArDPYw1l2ziBFguAFMWfIRXfdmbfmARHxwU0xo9r0eoU3ZYdULA/RrDBPsqef633QKjHOdOo0Y66WaeN8qo6/+tpNwdCxLlDu4P0CfV11; 25:kaPGO6xxL8s74S9FPNH8NfRXJUlwHkXRcfnyJki7VQ8f+b5873pOelePkOPCCxa/6K0vE4CIm581wlHNe5j/bKRD8pqYhk+DbDWAAUqYbp3M4EYSnXg+Yk7D5i+AJc1x+CyxFpipUFNu1TieePZqxmeGfbxeK4bl6KLhlkqbswPkm+sGWH2yLzg8zaheuz+lb/aoo2abja7kZPjFYNQxWDe2MKz38t55imbzGJHk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tAQ6Tx4K X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089)(21532816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13024025)(8121501046)(5005006)(13015025)(13023025)(13017025)(13018025)(3002001)(10201501046)(6041248)(20161123558025)(20161123555025)(20161123562025)(20161123564025)(20161123560025)(6072148); SRVR:CO1PR07MB207; BCL:0; PCL:0; RULEID:; SRVR:CO1PR07MB207; X-Microsoft-Exchange-Diagnostics: 1; CO1PR07MB207; 4:9m+bWxQygpBo8tzCAlFniG7klCD/w41WNBhtdt7tV4kzl5HEvR1khCcYmaC0eQiRgi0TBr+oZg+qtOJ3qXUsrPWWXa15HhhMAJoi5x7lszBYCdF0AAO+M5yYAWa9c5x86k446TGQ83nTHBn6ttI8R73TvBNRnewpiQw3e3g6/BLpIASLFGOh18vZS7caQ5zqarrtFvfOY3Yh3EiHscrY07wRCRslSDoywfhbDLhz9iIhBKcOPgMAsr2a5tAOcdiIzIOi2zHZCyCOg2wp0aaPaPm53KZGAoUIuab2B1lhz+4DPeXdT8vXHAXoXi5JInhl+JrurAEXLSMqwZuT+EsVTT7T9uzZvpL/ZSTkLOnQpG7W7rOg/pcXm9tix8SCK6CNl+MmKGmktY+cD47Lb68uvG1D6oGWp+2V1VFKvHUVm0s7YWIrAyvJB2gp7tIOW//bM1XXR8Y5gw0FhoFnnqJAWWNe3d82IJxeMKwo3/oMjTWKCCxRWBjLGkivJ7/rxQbqmhg/073KFj0rQbi8fK7ovuetykXx47tXEhY1L4SilmPnu8vRpHOIhQKgQD7p36hTtVNp3//B2WpXCHPlvLoPmD8GAmE/EQIIxBTtV1AxX1XISGYA+rjUWTTgoJgFh9wtlIaWUhRqIZV5FEW7CTTw0TgLLo2amz3gtRWLTGMphdlleVgTb7aAxjFIQLBaqjjxKlu3L0fY8WXggKXvYa3kRXdFw4qiftSSsfvaG57QdpVwBbuoRhGibMLL6ftrjcXxmsB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t5hnQ14Clp/GxXyPIfN8wIgNOh2Dnb7f394h6CyA=; 24:arfX5eZVCfEg/bNmhvWAImw+qxWz7Tg4dmDxlItCSj5txxcDe5tgvuFs9Nqf92htamDPnSLByojO6Xuzjtnw6pwr+hP2vZ1Aqtv0q8OLuIw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO1PR07MB207; 7:jtBlc4KbsCUBGtx4iHo0v0PBAML63B6Y7x70+CPKvxWs4iXxv5Pkjt8jTfsm8R56iBc68bvLsXd6Nf5FExyOAGnF3pa6GI2bgIOad21y94gLRZIz/eK+XecsuQxEO5NQ40DANxbJMMU1wh9rWNjBtEUvUkCB2p1nDyKDFFqKIHebYbj+8RM+X8QkrGLIWaGXxzHo+zciUivqde/XtsBtmATPuO4p2CiLL4UZIM4vXRw21kLCr/p3z5EmuAHbls8inXUXEMBu7h3cgsG7Dr0mwpWGJrUHxHwbqhvP3jeerwkPUGVf5bOFMVL8pYm+vw8mBETrkxTHybK8ofAs5BUl18VkNABnFbNcFtnRimZsxUYBjujv+5AAoCGrMxsMrgAKGlM0rM8r7tIy4S/txCFoqhzF7mj9bNMPxVWA7r+1DGtT/XaZYuuX+6pkWpnm3Wg5S78j5EK5dAD7lLpCOL9hrLfLhsGCeELW2ydv/QEP5IXzWds9wOwoFGrXnYs1f9SvB+RansRxJ2es4JTjytmNFA== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2017 22:41:48.6443 (UTC) 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: CO1PR07MB207 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Quinn Tran For target mode, when new scsi command arrive, driver first performs a look up of the SCSI Host. The current look up method is based on the ALPA portion of the NPort ID. For Cisco switch, the ALPA can not be used as the index. Instead, the new search method is based on the full value of the Nport_ID via btree lib. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/Kconfig | 1 + drivers/scsi/qla2xxx/qla_def.h | 2 + drivers/scsi/qla2xxx/qla_gbl.h | 2 + drivers/scsi/qla2xxx/qla_init.c | 14 +++--- drivers/scsi/qla2xxx/qla_mbx.c | 28 ++++-------- drivers/scsi/qla2xxx/qla_os.c | 1 + drivers/scsi/qla2xxx/qla_target.c | 90 +++++++++++++++++++++++++++++++++------ 7 files changed, 98 insertions(+), 40 deletions(-) diff --git a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig index 67c0d5a..de95293 100644 --- a/drivers/scsi/qla2xxx/Kconfig +++ b/drivers/scsi/qla2xxx/Kconfig @@ -3,6 +3,7 @@ config SCSI_QLA_FC depends on PCI && SCSI depends on SCSI_FC_ATTRS select FW_LOADER + select BTREE ---help--- This qla2xxx driver supports all QLogic Fibre Channel PCI and PCIe host adapters. diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index a15614d..160d74c 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -3318,6 +3319,7 @@ struct qlt_hw_data { spinlock_t sess_lock; int rspq_vector_cpuid; spinlock_t atio_lock ____cacheline_aligned; + struct btree_head32 host_map; }; #define MAX_QFULL_CMDS_ALLOC 8192 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 48a1190..b1e7b82 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -855,5 +855,7 @@ extern struct fc_port *qlt_find_sess_invalidate_other(scsi_qla_host_t *, uint64_t wwn, port_id_t port_id, uint16_t loop_id, struct fc_port **); void qla24xx_delete_sess_fn(struct work_struct *); void qlt_unknown_atio_work_fn(struct work_struct *); +void qlt_update_host_map(struct scsi_qla_host *, port_id_t); +void qlt_remove_target_resources(struct qla_hw_data *); #endif /* _QLA_GBL_H */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 5aca3df..ea6ddcf 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3345,8 +3345,8 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea) uint8_t domain; char connect_type[22]; struct qla_hw_data *ha = vha->hw; - unsigned long flags; scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); + port_id_t id; /* Get host addresses. */ rval = qla2x00_get_adapter_id(vha, @@ -3424,13 +3424,11 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea) /* Save Host port and loop ID. */ /* byte order - Big Endian */ - vha->d_id.b.domain = domain; - vha->d_id.b.area = area; - vha->d_id.b.al_pa = al_pa; - - spin_lock_irqsave(&ha->vport_slock, flags); - qlt_update_vp_map(vha, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); + id.b.domain = domain; + id.b.area = area; + id.b.al_pa = al_pa; + id.b.rsvd_1 = 0; + qlt_update_host_map(vha, id); if (!vha->flags.init_done) ql_log(ql_log_info, vha, 0x2010, diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 4225256..f352889 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3624,6 +3624,7 @@ struct tsk_mgmt_cmd { scsi_qla_host_t *vp = NULL; unsigned long flags; int found; + port_id_t id; ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6, "Entered %s.\n", __func__); @@ -3631,6 +3632,11 @@ struct tsk_mgmt_cmd { if (rptid_entry->entry_status != 0) return; + id.b.domain = rptid_entry->port_id[2]; + id.b.area = rptid_entry->port_id[1]; + id.b.al_pa = rptid_entry->port_id[0]; + id.b.rsvd_1 = 0; + if (rptid_entry->format == 0) { /* loop */ ql_dbg(ql_dbg_async, vha, 0x10b7, @@ -3642,13 +3648,7 @@ struct tsk_mgmt_cmd { rptid_entry->port_id[2], rptid_entry->port_id[1], rptid_entry->port_id[0]); - vha->d_id.b.domain = rptid_entry->port_id[2]; - vha->d_id.b.area = rptid_entry->port_id[1]; - vha->d_id.b.al_pa = rptid_entry->port_id[0]; - - spin_lock_irqsave(&ha->vport_slock, flags); - qlt_update_vp_map(vha, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); + qlt_update_host_map(vha, id); } else if (rptid_entry->format == 1) { /* fabric */ @@ -3674,12 +3674,7 @@ struct tsk_mgmt_cmd { WWN_SIZE); } - vha->d_id.b.domain = rptid_entry->port_id[2]; - vha->d_id.b.area = rptid_entry->port_id[1]; - vha->d_id.b.al_pa = rptid_entry->port_id[0]; - spin_lock_irqsave(&ha->vport_slock, flags); - qlt_update_vp_map(vha, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); + qlt_update_host_map(vha, id); } fc_host_port_name(vha->host) = @@ -3715,12 +3710,7 @@ struct tsk_mgmt_cmd { if (!found) return; - vp->d_id.b.domain = rptid_entry->port_id[2]; - vp->d_id.b.area = rptid_entry->port_id[1]; - vp->d_id.b.al_pa = rptid_entry->port_id[0]; - spin_lock_irqsave(&ha->vport_slock, flags); - qlt_update_vp_map(vp, SET_AL_PA); - spin_unlock_irqrestore(&ha->vport_slock, flags); + qlt_update_host_map(vp, id); /* * Cannot configure here as we are still sitting on the diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 10cb4990..ee0f4fa 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3474,6 +3474,7 @@ uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) qla2x00_free_sysfs_attr(base_vha, true); fc_remove_host(base_vha->host); + qlt_remove_target_resources(ha); scsi_remove_host(base_vha->host); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index a36258d..359a79d 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -182,21 +182,23 @@ static inline int qlt_issue_marker(struct scsi_qla_host *vha, int vha_locked) struct scsi_qla_host *qlt_find_host_by_d_id(struct scsi_qla_host *vha, uint8_t *d_id) { - struct qla_hw_data *ha = vha->hw; - uint8_t vp_idx; - - if ((vha->d_id.b.area != d_id[1]) || (vha->d_id.b.domain != d_id[0])) - return NULL; + struct scsi_qla_host *host; + uint32_t key = 0; - if (vha->d_id.b.al_pa == d_id[2]) + if ((vha->d_id.b.area == d_id[1]) && (vha->d_id.b.domain == d_id[0]) && + (vha->d_id.b.al_pa == d_id[2])) return vha; - BUG_ON(ha->tgt.tgt_vp_map == NULL); - vp_idx = ha->tgt.tgt_vp_map[d_id[2]].idx; - if (likely(test_bit(vp_idx, ha->vp_idx_map))) - return ha->tgt.tgt_vp_map[vp_idx].vha; + key = (uint32_t)d_id[0] << 16; + key |= (uint32_t)d_id[1] << 8; + key |= (uint32_t)d_id[2]; - return NULL; + host = btree_lookup32(&vha->hw->tgt.host_map, key); + if (!host) + ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, + "Unable to find host %06x\n", key); + + return host; } static inline @@ -6017,6 +6019,17 @@ int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha) return 0; } +void qlt_remove_target_resources(struct qla_hw_data *ha) +{ + struct scsi_qla_host *node; + u32 key = 0; + + btree_for_each_safe32(&ha->tgt.host_map, key, node) + btree_remove32(&ha->tgt.host_map, key); + + btree_destroy32(&ha->tgt.host_map); +} + static void qlt_lport_dump(struct scsi_qla_host *vha, u64 wwpn, unsigned char *b) { @@ -6670,6 +6683,8 @@ static void qlt_disable_vha(struct scsi_qla_host *vha) void qlt_probe_one_stage1(struct scsi_qla_host *base_vha, struct qla_hw_data *ha) { + int rc; + if (!QLA_TGT_MODE_ENABLED()) return; @@ -6689,6 +6704,13 @@ static void qlt_disable_vha(struct scsi_qla_host *vha) qlt_unknown_atio_work_fn); qlt_clear_mode(base_vha); + + rc = btree_init32(&ha->tgt.host_map); + if (rc) + ql_log(ql_log_info, base_vha, 0xffff, + "Unable to initialize ha->host_map btree\n"); + + qlt_update_vp_map(base_vha, SET_VP_IDX); } irqreturn_t @@ -6795,25 +6817,67 @@ static void qlt_disable_vha(struct scsi_qla_host *vha) void qlt_update_vp_map(struct scsi_qla_host *vha, int cmd) { + void *slot; + u32 key; + int rc; + if (!QLA_TGT_MODE_ENABLED()) return; + key = vha->d_id.b24; + switch (cmd) { case SET_VP_IDX: vha->hw->tgt.tgt_vp_map[vha->vp_idx].vha = vha; break; case SET_AL_PA: - vha->hw->tgt.tgt_vp_map[vha->d_id.b.al_pa].idx = vha->vp_idx; + slot = btree_lookup32(&vha->hw->tgt.host_map, key); + if (!slot) { + ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, + "Save vha in host_map %p %06x\n", vha, key); + rc = btree_insert32(&vha->hw->tgt.host_map, + key, vha, GFP_ATOMIC); + if (rc) + ql_log(ql_log_info, vha, 0xffff, + "Unable to insert s_id into host_map: %06x\n", + key); + return; + } + ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, + "replace existing vha in host_map %p %06x\n", vha, key); + btree_update32(&vha->hw->tgt.host_map, key, vha); break; case RESET_VP_IDX: vha->hw->tgt.tgt_vp_map[vha->vp_idx].vha = NULL; break; case RESET_AL_PA: - vha->hw->tgt.tgt_vp_map[vha->d_id.b.al_pa].idx = 0; + ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff, + "clear vha in host_map %p %06x\n", vha, key); + btree_remove32(&vha->hw->tgt.host_map, key); + vha->d_id.b24 = 0; break; } } +void qlt_update_host_map(struct scsi_qla_host *vha, port_id_t id) +{ + unsigned long flags; + struct qla_hw_data *ha = vha->hw; + + if (!vha->d_id.b24) { + spin_lock_irqsave(&ha->vport_slock, flags); + vha->d_id = id; + qlt_update_vp_map(vha, SET_AL_PA); + spin_unlock_irqrestore(&ha->vport_slock, flags); + } else if (vha->d_id.b24 != id.b24) { + spin_lock_irqsave(&ha->vport_slock, flags); + qlt_update_vp_map(vha, RESET_AL_PA); + vha->d_id = id; + qlt_update_vp_map(vha, SET_AL_PA); + spin_unlock_irqrestore(&ha->vport_slock, flags); + } +} + static int __init qlt_parse_ini_mode(void) { if (strcasecmp(qlini_mode, QLA2XXX_INI_MODE_STR_EXCLUSIVE) == 0)