From patchwork Thu Feb 2 19:42:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9553131 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 E2D67604E1 for ; Thu, 2 Feb 2017 19:45:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D591D28497 for ; Thu, 2 Feb 2017 19:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA52A2847F; Thu, 2 Feb 2017 19:45:08 +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=unavailable 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 DC3692845B for ; Thu, 2 Feb 2017 19:45:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751642AbdBBTo7 (ORCPT ); Thu, 2 Feb 2017 14:44:59 -0500 Received: from mail-by2nam03on0042.outbound.protection.outlook.com ([104.47.42.42]:45824 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750924AbdBBTot (ORCPT ); Thu, 2 Feb 2017 14:44:49 -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=Icdh5zWKlI2zEhqpW2lv1qYfw/JJz0GFxw2VJDZWBto=; b=Lub8wv82hPDxZ57z0AoxxeFmSXsSycEcLb1ox3WGvaB44VHz5EE2pPgHsgm2Y1jpMCOTT6nSO3yiDuf3+fPtUurf45ZKTFLIDqk4RJwRhKFWbS97gnWVzOpcjmP6CdWQi53IS2npr6M6hOlx19duk9dKCKvQq4T326nwZF6py38= Received: from SN1PR0701CA0084.namprd07.prod.outlook.com (10.163.126.52) by SN1PR0701MB2093.namprd07.prod.outlook.com (10.163.132.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.860.13; Thu, 2 Feb 2017 19:43:20 +0000 Received: from BY2FFO11FD003.protection.gbl (2a01:111:f400:7c0c::109) by SN1PR0701CA0084.outlook.office365.com (2a01:111:e400:52fd::52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.874.12 via Frontend Transport; Thu, 2 Feb 2017 19:43:20 +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 BY2FFO11FD003.mail.protection.outlook.com (10.1.14.125) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.874.2 via Frontend Transport; Thu, 2 Feb 2017 19:43:20 +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; Thu, 2 Feb 2017 11:43:09 -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 v12JgsZ2000428; Thu, 2 Feb 2017 11:42:54 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v12JgshP000427; Thu, 2 Feb 2017 11:42:54 -0800 From: Himanshu Madhani To: , , , CC: , , Subject: [PATCH 08/15] qla2xxx: Change scsi host lookup method Date: Thu, 2 Feb 2017 11:42:31 -0800 Message-ID: <1486064558-365-9-git-send-email-himanshu.madhani@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1486064558-365-1-git-send-email-himanshu.madhani@cavium.com> References: <1486064558-365-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)(979002)(6009001)(7916002)(39450400003)(2980300002)(428002)(189002)(199003)(36756003)(47776003)(69596002)(50466002)(5003940100001)(1691005)(92566002)(105586002)(8936002)(81156014)(305945005)(50226002)(80596001)(54906002)(106466001)(48376002)(81166006)(4001430100002)(8676002)(6666003)(356003)(8656002)(4326007)(4720700003)(86362001)(626004)(107886002)(38730400001)(2950100002)(2201001)(33646002)(76176999)(2906002)(575784001)(42186005)(5660300001)(189998001)(5001770100001)(50986999)(101416001)(87636001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0701MB2093; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD003; 1:iBJNVgV8ZiTChK67fnl0XmABLfHvZmo7x/uksp8t6idhX/AMU4ynJN8hKvegezflRpr45Z7XeslAY6y6O/9gRI/wOpeP0FAQK37pQIUNgh8YdLcvoTHxts5XN1H645TtVsqSQ2MiP3ti9iTZ+ZxojXnz4hWAfiotZkuxZuo4OeliSm1VH+oJIKeKGGQufKyfG2+NbR9nBJpw7wWGixDjvAbPPgc8aH2t9h6Th6C6XYkVY/kagTq7ag3RSKZolMy+YDBBUIyqU6EsHrpZl0CTyQQq4fbeNhPWUxjQc+4gwNvG/NPKxBQA2HnQ2SZpOfNWlO/9lkMui6mmVO2kZ9d6vzfT4Cvc/Ts/02RacB1V2L4mHRPb5g/+tmaxoOAzxaUniKxoQSlcPeJ/ot1q6ewMbKlk6PW1K5tEzOPTiRlaanA8xOjgTgN1rvCHfgPIujeRUsJserAzFXVCVpgzKJsH4UinRATi9BmxJ8s5pdrbmsNUKqAuqypI7fL6Cyf7xBl0pxhXRleucmJJWKxoLQ92ahvSqSq9PE3zQgr3diNjU0M= X-MS-Office365-Filtering-Correlation-Id: c9400637-b041-43df-a1c6-08d44ba3be16 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:SN1PR0701MB2093; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2093; 3:6ba3oq66+xYACA1gdGuNRwjQUkxOOtYGPTXbr3u+RXVRO6MkzFNzfT4uxw8AKZrQFERaOXRWr8VURvBOoMNXALLCeYoWV4N1nwvCW5Xfb4yWKqYod7CiDzxHMveeKTgHs7+739GGQJ2Zcf4qfcP/8nbRXza3INLcagH5EO+/dlZso6Eofk/ax7WQgBzT5zUFV2DzfXU5262IJDg//NiSWfNZjjw8nIiQgu8nzoYYHB8K4bKPLjOcDFLCDvnrcOkY3oGHJu33HY/8wAorFBMPYCBGURyLhXjtPeh8boph79y5hx1t3WoFFn5cYoeIvpI8xRGTwzj58iNqKklJsmWPacIsKlkFqOMyVUXRSeRVUJVtTInJVJa6yPWdjN1eYNYj; 25:dqkjKJD1a2HmFpZ8Ba97JBw8CT+oibdgNLsptVOW9gWI1Pucoi44ZMPBRQOzrnQ6nwe7OGh72QdeUKpioj6tD/9FjLBV2ub9QATb47uBgo6VT9S7Mtwa6D5hhJHO3qfi1TU5xok9Dyf2M2BWWaDPxErfMlkQD4anAMvhuzDBmjX3+lzAQpg87MoTBubPvCTQKRv+xL0rjkHScgGZsl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kUfYC2vQonLc2r8d7IYv1fJ7eV8zw/mCcjmKB6x 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)(8121501046)(5005006)(13023025)(13017025)(13015025)(13018025)(13024025)(3002001)(10201501046)(6041248)(20161123555025)(20161123558025)(20161123564025)(20161123562025)(20161123560025)(6072148); SRVR:SN1PR0701MB2093; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0701MB2093; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2093; 4:DK3Bd+ZUkD8rmzoCdV0sN+MU6h26PmTYkTDvT7L9T2Sg/RsSkEQVmJ2erPMfKmRiVSM2qmW8WqGVhWWfsKKAo/eN1jBZS1qzdYdI0cyYLiLmOP5fG/08uFTqSBgvFh2/8JhGgV/Tq7pGEf0Yh0BqlVHNcPw8vvq1MlH6GTH+Tl8ZNO29TLDrN0ipqDP+h6vTkg5S3pCi5buM+8Ko1DhUMRdXpSLvzvwjFtlqUWwMEfJ3+0uecAPc7SLBb1o1JyD/UxlatiLLi9Or/WCjSqn33iL5t3WXxKuHdaBLtFCEQp6EiAOzJ8QXFvHNZE9cd6AwjHSlOCdKPdqMwURL+A6sPQnG9dQ9HGNXE0GKTxpYphf8g4eaLB/IKPsftDxNAXaic1csE79OcAfp5qpW8+q5N8vAXOKBup1GwFztv+fh79B19CJYqXKXBAIWgDkDtVEQ3BlXmUbrqE8r3VDiq00lVnxCqw9Vml8wFapfNchZXKxQA0CrcP6ucIPLf28+fyw6fuXQW1gFij+pkOGqdREI5MDiF064jUiZswWjyxiwcsYn+KTrTuHCAelXHM8hyc3NdQj5hD87EAN1fYIoap7/494xFDGTL0ICIKDQ5bg7XsiZD1EmqL2xSCxYPp98/XOmtEN4qmmuKen1ZWWXRaXN/PgFfIh4uumrBL3acNbtnDf1lqzHr097xNXGLkD8EsC5lzQFDySHJeq1apmpd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md8ymHJFfXsg==; 5:3S8SS3yjV9hnZdxPJlyJNpbqeRsVdFQ5rDEaaSrnnHNmPVR9uAG3GGGKJ2wh827wtlKxZiI8dix0X9KDFKXuMEhXkpKEPi/iV6cpROoPuFWESssTqmwZJLcULb5k3VmwwIZvNNqKe6CYv8X9iwm7tqQ4B9UCNa/FmVJkru6SRNI=; 24:vKuxAl3zliFUzxCt5LP8GVtXDT7e96bzVW34UJA3Y27GZtHEbAbEOEq0GSBBIFQaYK53sxIraaGbpjm8OK0q/s0LCeQx9FsyvLubRP9RnEo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR0701MB2093; 7:Dm4ZvcrzPOxiUu3IW611yXK2oMrk7Q58YWS9lRJCt0KldUmrYbx9W8FBIdN8Ov/EJ0IKHOtR9USuWMQZwC6hgu7rkqcZyKXOZjx3ZJTyNDM2K0FuBrNIcR3wqIutJAVAxvY1wWagJ/jgAmCrJRWJJcc/pYp4dsgzrsfstslOW4mRGZAtzUoxs2AV4mTOKwty5ExYgonPWtbhbIpcNEmZtfYbA4/Rw+HIHzBmaLofoS0pwGbgMDIw0qg4AibOQvXPLF58+Eedkmmw0vLpr4a2ShyS4SBcoUjnpWznwVUhYiKDcRfXZ9odFeGIK1KV6y13+IwYZwOgyDs3Ax7aMRPpAkq57OCStbtfVyQ8S0srFIdM5PynH5Eyvk3KzWxTegxjoUtu3hPLop48jeOVAvKFSHuvffWcPnAnKBk9/mQNQIIiH2LomncZWVKWukApqq/xzECe82TqAvu/reWbO9Rm0OCb2BszF2XVIEJuLVoFp697Uh7jOARN6a0/aH0d+9qNbjQ2mzPXsMEOPm9/truG6Q== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2017 19:43:20.4961 (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: SN1PR0701MB2093 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 f16ee3e..d040d36 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 @@ -3319,6 +3320,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 cacb0d7..dcd190a 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3626,6 +3626,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__); @@ -3633,6 +3634,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, @@ -3644,13 +3650,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 */ @@ -3676,12 +3676,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) = @@ -3717,12 +3712,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 291fc74..56d8ac9 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3472,6 +3472,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 796b0c0..d26a8cb 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 @@ -6034,6 +6036,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) { @@ -6687,6 +6700,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; @@ -6706,6 +6721,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 @@ -6812,25 +6834,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)