From patchwork Fri Feb 24 21:37:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9591259 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 74E3B601AE for ; Fri, 24 Feb 2017 21:38:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6484828947 for ; Fri, 24 Feb 2017 21:38:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5934028965; Fri, 24 Feb 2017 21:38:43 +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 787B928947 for ; Fri, 24 Feb 2017 21:38:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbdBXVik (ORCPT ); Fri, 24 Feb 2017 16:38:40 -0500 Received: from mail-bn3nam01on0068.outbound.protection.outlook.com ([104.47.33.68]:59968 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751298AbdBXViR (ORCPT ); Fri, 24 Feb 2017 16:38:17 -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=jzHlr8AgQpTQ7NFH6crjLuHbvzSQGxFgsdl1U6Qo3qc=; b=B4Fngb2VqYCgizGk7KzP6Z5fbaEclOTJI98y5KioWQQcBj6cT+nxIllE8MkR40JEYhnn87/0Efppl8y3/mCbAZf1eR5Bjj+CvkXp+flYNDLux1s8kA4lL7FT+dphJ3QZzVu6UbVLaIhDfjx97cOwLzLPdL3Wlg/svJqkN2msQoM= Received: from BY2PR07CA0088.namprd07.prod.outlook.com (10.166.107.41) by CO2PR07MB2629.namprd07.prod.outlook.com (10.166.213.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Fri, 24 Feb 2017 21:37:59 +0000 Received: from BY2FFO11OLC016.protection.gbl (2a01:111:f400:7c0c::111) by BY2PR07CA0088.outlook.office365.com (2a01:111:e400:7bff::41) 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, 24 Feb 2017 21:37:58 +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 BY2FFO11OLC016.mail.protection.outlook.com (10.1.15.61) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.919.10 via Frontend Transport; Fri, 24 Feb 2017 21:37:58 +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, 24 Feb 2017 13:37:45 -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 v1OLbj9K003856; Fri, 24 Feb 2017 13:37:45 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v1OLbjtx003855; Fri, 24 Feb 2017 13:37:45 -0800 From: Himanshu Madhani To: , , CC: , , Subject: [PATCH v3 08/14] qla2xxx: Change scsi host lookup method. Date: Fri, 24 Feb 2017 13:37:37 -0800 Message-ID: <1487972263-3795-9-git-send-email-himanshu.madhani@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487972263-3795-1-git-send-email-himanshu.madhani@cavium.com> References: <1487972263-3795-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)(189002)(199003)(5660300001)(76176999)(4720700003)(1691005)(38730400002)(107886003)(8936002)(575784001)(33646002)(8676002)(81156014)(36756003)(80596001)(81166006)(2201001)(69596002)(50226002)(50466002)(86362001)(6666003)(48376002)(92566002)(2950100002)(42186005)(305945005)(47776003)(626004)(50986999)(101416001)(189998001)(105586002)(5003940100001)(8656002)(356003)(2906002)(4326007)(106466001)(54906002)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB2629; 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; BY2FFO11OLC016; 1:AKt2r4fMJRSNIveoWIyjpqePR8yxrvhBYV+Cl+ezR7R4AeuKL1LDvAaCwuYCO5mvlLXHvhmPdK1gz+BRMynBu8pQiewtfboRRpsHG+PsjMTE6FJn5nRv2Tcn5yuSZKAw7qP0t8Fw8S1a97tgNAqSK3Jv8oc6EA80p33kktp/MUtoYjuSkSgT2/KvVy5PIUajX3gvzTVCwLBl2lLR4CEUEbwtcmGu1I57liywSRyd2eyjx1dn8LybbsvtmiGosIZWP8tekSjZWCb9VmpdrJbtDmaJDTUZGiEgmt2WxzAivrp4V9Lb0NJuZ4Uf0tRQyUjUr3usTudkKf2skxSsZOmEmTWN6innSU7RrnsHZ26yjo4loRJlxedQZMpzuooS/WO7cd6PMZokwHtCKF6zwffKB77WHhkVZJOovekHtpphF2lsapvR+NsMaDK4bDXgBjPBi1QV3FS0XdlC04h1/U2YWOaqrLmrWgahOE+NqprBgPkk/R4yYn4rdBsyVj34oa/B3+0GL78aJ3qDT6h7VqBV9hnF7W97xb8nzpCcnOVvAJE= X-MS-Office365-Filtering-Correlation-Id: 9ea80ceb-89d2-4aa6-5cbd-08d45cfd6709 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CO2PR07MB2629; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2629; 3:g5vGjGIQD+sTJiWZrh5wuhH/XX+WZdO7rMarZKqe3BMMop6rP351Wfo/bWnop1WuAj3Qe3c4JXIEzKS3s031v914x9aqBMR2Q7K5rgVxNxA/SqBgSunlOUuswXJUJRsiVdlYW8CDppsrsxTHxW8dsHyMRLlbcN9wy1VZ7Tt14SoTpRTO8j+sygoq6fuCIB+rcJ6Bm+65OhkrvN3SUMlFG828zc30Sy2NLydcOkt86ubAhhH7StyJeg3xM/TD/rXA2aKmFVxiRv5Bi1AwKjjjjzQi1Ak+o/y6ikOHywtpOptqWqcARCzWBHbPJqnb2oaXDlxGMpdQ8saaufgNC4EPqFr08Q3cnoRk1rGgT35Ymm68dS2qJCDzOjjfQC6TXSeA; 25:pyViSZURxI/gSmRfYnd0j+WexLdC2fbUgyexDtjI3cYspDSykHNEchUu2e0FRQwQoXH5Rc+ayU8eI8p6P0OpPAq1wipsyeNCvMdm5YMmmAsrBW5v8pBRdKvtTZE3Tb0Vg5QNkPM6Wo0uFEiU6r4kSqPmwpFQRaEP/RLsRZei65f49wKBXb312U9jz1reXkVsQSaOfJB2HBDi94T+NujWByPPTLYmh77eHK+zu0h+2GatKF6PqoPJoLW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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)(13017025)(13023025)(13024025)(13015025)(5005006)(13018025)(8121501046)(3002001)(10201501046)(6041248)(20161123558025)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148); SRVR:CO2PR07MB2629; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB2629; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2629; 4:6bhmD9n++6hQPJCATuIdr+k9/AabBMpYNhv2dlna2rwcuy7+lEGO0bGHZaRjI0s5t0AvWPmOX4Z6SM2G8UquzwF84js3zw+rXGgdbkIIJwG07pQtDCmZH7OsLbB97gHdf9b9lBu3NNJqE6nZwLK/dPqr1bfA/TIQ2QHef1IzLNuqBQeU2EOC++9DPSjn9aUK5vfzISpc8HGXqckeiBcINRsJGWSsTBYADRs/+Buoud/q2K6Co69oXd+jlNMAvGfKnJTUuBgmcs/ZvylALMwIRglhEQWdAL7ZTDIqMy1JfdtovwX2sE6FA40hw2/v8aP2Q0EIT5tHsS8hawsUheUg7UJq3DKrd5qTXbcPaFF1VdWJyAN9wBw0ficcMjCjGZ4ZOWZzUp3vKLKJFL//bkdzrf01rWsaj8//g1kAUtwnp5EU5rgHOiWxEVPHiRepe9AoAPQURhbE+C4ohPIoQFPdQjqMv+qhbrfm1j0l6MyKOuSA/NaOSgEWiaa5pysUIHiOU7aZuLq4e/c8weJCSQMqYy1ff+GEfyHTY3md8QGrAyo896K2UubBho0eRxLkZsXLe3+yHf+VbS5OxiZNLhEVfOlAxKR7Nd2osU31Yp6Ot485M9DMJdUtp61B1BDhT9sK0vT4qdcQwvouhYf2hMwAYzMUjO9ENxMQcD0AAQq4rS0KEfEQgODxnsTGQlZCDce2MN89urxjO5dr05UOzS0VOb4YyEJ2IomLcCOn8+7OIpCiCdkUlvZ6mueDTU3S+6wBRwgy8tEhbli++lC7nC7b5w== X-Forefront-PRVS: 0228DDDDD7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB2629; 23:8XZx38vePOXthKmLZA5VDacfhg0ZQ/gSsNmrcqj8w?= =?us-ascii?Q?jPHiLIbuunvVdMuNtkhsBsp2sfY5o2s4iKMlHiEpsFT3g0sUrSUwth8VtP5g?= =?us-ascii?Q?83KlSFLZYC/zI4X/LnGbj1S5iCNWKup2tzjk01PPGHCff8VeFGWsomSqp6rX?= =?us-ascii?Q?rohpAGU22727GnutCzowPaubi0Zxew8aD7zmmuVGT8kzQ5oZrF6zNMSpdz8K?= =?us-ascii?Q?D0RlICKpCWA+8PtlU7uxUlWYtOO+7S1Hmxst9Uy3wqznG0Qy/zyP8pUcST+d?= =?us-ascii?Q?wfKK56ihzA9m1S/KcbClqpJFn4Hgb6gsJueKy5xsbhJnVaiublZQbCch9LLx?= =?us-ascii?Q?UiBawE3kdEOYoh44Osu00gLx1mA7FxiyqdoHEFyMkT7C0uc3FGE2Lc90wcZ4?= =?us-ascii?Q?jpq7d3YCSsY8cMW0fzNhOtrYzMrvD9aGSoj9iw+TBjFs6Es8KrdYq9Bj4GNR?= =?us-ascii?Q?GnFsesRmgOgo1tkSKMreTdsNN0UL8O81+fc7wfdSBHWDZu28ya5FFv08kwy1?= =?us-ascii?Q?E1a/nrxoR5z3e2vyOVb2wET17prLIX3OZkeGmKsHcUv12GQZkZBeGI7rwAQW?= =?us-ascii?Q?kaEHu0na2NHGZgNCT7jk+OQ/qOO765aRUQuMnGtENFTsiVId7JHdSe10fjOK?= =?us-ascii?Q?g3WbRsKhMOTaPtlGH/txfJFmi4/Pi36UiiZFuhsDL2ZnIkVgU3IZ5kuZhm8T?= =?us-ascii?Q?0YFynVwfg1sEIQEhidgrh4laNHY9l15fDR2cRnkaegVPgnzqvN7ne0Tlg/5b?= =?us-ascii?Q?08ZX3Xjn8gtNrSIhrMxH87DJTfgSUJbJ7WmP9J3J/ysWp68KX4mq/B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shkssYdwSeuZfQDeYdIWiYYhDb9j2JEgoGN6qzd6sEY9lOpbv6Ybx7fOaI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2629; 7:Qhle4DTrp/DfPuxDEj2jUGRCblVLOMliswdPShjQB+MKwlxRpB0o3I2JIkMTO1TsMJeYCxLTYiZCAU3jHrcyGKosq9cRZvav23l6yPRSHTmdHaEOTuDVBVOT7FDDbTWPuIhaU6DU8pyom8qMjMY0qmdl5v2dPKmKafC89HE3iU2jjMuXckzBwPmpdVf2QA+BS+DE/m9h3uQQgT3tnppMIWLYtrcUV5f13aCmmPLIUguPvSXYkvkP83CaSj6m9QlAVK9CkCP1w7u/UW42fFxlL6DQwp2z7KytMG/IAGw3tfKyS8/FOeyocOPZetn7eymE2obLVnC5dRVbBYfAR+4dGQ== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Feb 2017 21:37:58.9046 (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: CO2PR07MB2629 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 | 92 +++++++++++++++++++++++++++++++++------ 7 files changed, 100 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 5e2f149..f775b6b 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 @@ -3301,6 +3302,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 3cdeb0e..b5e96b7 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -854,5 +854,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 5b1108b..c3ab96c 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3341,8 +3341,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, @@ -3420,13 +3420,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 0a01730..a113ab3 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3623,6 +3623,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__); @@ -3630,6 +3631,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, @@ -3641,13 +3647,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 */ @@ -3673,12 +3673,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) = @@ -3714,12 +3709,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 4867589..947f3e2 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3489,6 +3489,7 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) 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 873cbf7..2720b8f6 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -184,21 +184,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 @@ -6030,6 +6032,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) { @@ -6683,6 +6696,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; @@ -6702,6 +6717,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 @@ -6808,25 +6830,69 @@ 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); + slot = btree_lookup32(&vha->hw->tgt.host_map, key); + if (slot) + 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)