From patchwork Wed Mar 15 16:48:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9626163 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 CF73E60244 for ; Wed, 15 Mar 2017 16:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0F5B28641 for ; Wed, 15 Mar 2017 16:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B523F2866B; Wed, 15 Mar 2017 16:50:40 +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 029B128641 for ; Wed, 15 Mar 2017 16:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753165AbdCOQue (ORCPT ); Wed, 15 Mar 2017 12:50:34 -0400 Received: from mail-sn1nam02on0059.outbound.protection.outlook.com ([104.47.36.59]:47264 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753124AbdCOQt2 (ORCPT ); Wed, 15 Mar 2017 12:49:28 -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; bh=G0J9tw7JPAYsR/mL+BpP3FkAIbQ++LijpfEmDbgRD84=; b=NfnDtBQm+TJxmOWGRcptYu5bR2W+ZdOoR7lwTj1fmIQqgo95haD5s0ZC6dC3X2l6ciHwFbVWS9ahnvcTqiTCR2OgPyvoDlZoKUuOa0u2dexl5Mna6unpD09JNU9OTLQKlhCNcMf5jLU1r7a+ToSJTX5ygowgd0WK3lk2CU7GyO4= Received: from BLUPR07CA076.namprd07.prod.outlook.com (10.160.24.31) by BLUPR07MB468.namprd07.prod.outlook.com (10.141.202.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17; Wed, 15 Mar 2017 16:49:26 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::128) by BLUPR07CA076.outlook.office365.com (2a01:111:e400:8ae::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.961.17 via Frontend Transport; Wed, 15 Mar 2017 16:49:25 +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 BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.961.10 via Frontend Transport; Wed, 15 Mar 2017 16:49:25 +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; Wed, 15 Mar 2017 09:48:59 -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 v2FGmw12017338; Wed, 15 Mar 2017 09:48:58 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v2FGmwbX017337; Wed, 15 Mar 2017 09:48:58 -0700 From: Himanshu Madhani To: , , CC: , , Subject: [PATCH v4 12/14] qla2xxx: Change scsi host lookup method. Date: Wed, 15 Mar 2017 09:48:54 -0700 Message-ID: <20170315164856.17255-13-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170315164856.17255-1-himanshu.madhani@cavium.com> References: <20170315164856.17255-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)(6009001)(39450400003)(39410400002)(2980300002)(428002)(189002)(199003)(9170700003)(33646002)(54906002)(8656002)(47776003)(189998001)(105586002)(8676002)(81166006)(36756003)(80596001)(5003940100001)(50226002)(8936002)(4326008)(305945005)(356003)(6666003)(2950100002)(2201001)(1076002)(101416001)(2906002)(42186005)(5660300001)(76176999)(50986999)(86362001)(48376002)(107886003)(38730400002)(50466002)(575784001)(87636001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB468; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:Uz5PKLJkNpxJw2Wb18XXvg00S3Gv91NIGEhCDHWdC8WRfJSpN70PoUzqyvw4+9ttmLk7JHTexyBBqXtlGeU2ItqJgsqVnVCy/yx6KnSHdGGxNaCnq36G5NjcY15XZHqYGqry8TwBTL8+G51Ax0UaNkmWY84+GgAYbYtSKNtCnoaI4DV7zupkQC/xPJMmwT90i+u1oB0xVZnDJ3Nzs3c0gj5fB3lGShXVjwXz9Qb1M+6jRrBBi3NlA4rD0j+zdhPSjegEj6YPfoBMRih1lss+IQJ0FiLxMS6X/Z3dsp2mwU3umMwnKJd69tcIFEOico53nzkeogMCmbogedS6B2hNRabNVb+PLQvhqg0EKoeJkV3iTTuhvgjs5hcCsMd/eV+dUNJzOwBE3eRFwAWTaZ4tz5uaOzpT5R9h8ACaZoVSMiEhOgtC5yvlfGoGZUYcbECj6ZBXm9M6tMjzmORC30DWDxcq5ZtCWGnQoHp7uio+rVtkInrNbqD+rI9EYLubikY21aZINWyg9j/iKQHkMWr6epP0EO7vp94rO8o6yGknyZQ= X-MS-Office365-Filtering-Correlation-Id: 9856e44d-5ce7-493b-5a99-08d46bc33d23 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BLUPR07MB468; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB468; 3:2NuLfbG5Kii2wt2R/XGMkXM7pfUm0hsTgCCTwnxs9kinGeQKiGQxb/AFHaesgZxDezsb5fbRQSnLnc/TOg/5wF7acfZpBspAA/PncVt/orKmNlBkFFPHmYerVoFMfanT16Kfv4aHnjPsf7/zWlkfOjTWvi3qA+iBIhwiEKxPyO/e9U9QJ2i6DWgPHxepLBadJEmFIPIRCaT+ba7QnBf3/j0pkdKSkIgY0xKM671KwT5fRLnmtfTQxNcH6Bx+r3y2SyQDFa8QHcMGKGOWj8kN61OdLEmGxNxf5vV0mQ90rosSCqkJT2bgrhdgraf4ABwJ329wcpJ7AlrYzBeiklvM1UmzFclFUkGsNi+zqLFWJ4ejtRyBXp2nPwzC/9oGZVg8; 25:DQZFDqCwCbj1f5nk+dOTAb1HPSvA5w3rLJcCH2ImHhhYcvE3KqqyFmKZ04cIgQ4LkMIWMklB8c/rEbXxYoojF/ptVXnR80K67XP5FirlSWz7nzCv2dxRi10JPw1apEVp44xoX8lbuFC9FhBAjON9PMfivtLL1SfqccJckrijDxko/DuYwvofh4pcY1NgPu/Cor+KWF9mvDg5NCYtnZ1aE2Dgfib0zF/NtbvkiIFmN8qvkBO1EznnwTFteYWI3mTQQO+mftilNnL/xywQsEQWDcIts07UjvAbolF0x4kt18wLGX7JrGxA9me7fATD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816269658); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13017025)(8121501046)(13015025)(5005006)(13023025)(13024025)(13018025)(10201501046)(3002001)(6041248)(20161123562025)(20161123558025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:BLUPR07MB468; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB468; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB468; 4:yJuREsMRd/v1ilkt3xSXB4pdnxr12qMX15QsufoH37aVfcgGLOCwRfjxcZZTY5ldFLZabZl1SX80CCBtIvd/4C5yf0EcNJWUKxSHT78zMAze9R7iMlGMsPD0yVfTBkH+4YYjlF/Xne38CNdt+rl/XzxqnS4lOgndsSI9XaTvpVfYKkLGFlGLoJWpp9FZxA6IsKHBBj6l2c2xtmwogHNLIz0h7U7jleXu74kRif4MCQVGE4wlLwQQApb+TQNuaevNLVLzNpwtMOkY/zEsT9erRo88RJoORykJYdrVcWZhwpC9ByEK2x2R63Ks3i7lsk53u76Gar5S9+2YWzev1ZTOTHhM4xCBQk6lktm5ycYBUSNEpCD0yqhPDA43Y730Kq4ENQ/pJmzsCxYbLw0axyFEuta2soY4BRVDj7klf/OkWCUHQcxeOiDENH2UyzaJvjy2txuNVwfzo10maoibVxc2fy/grpIX4YekoxVTwg5zOfG7ywrB2/Djn+24qr0tdI41DwHtkxZkspdhp0A1sAoiK1xoto7spnlu/Zbj+177sZyY2pkx6zI2eA0CmQbF+2bTOOu23v9ybVm30sPSNaTQ5n93FtK5mfWZSEmv7K1gBOGgy/fEZWFIleX+kBsk27ImrDEWpH2rUmlLO9ZRbe1zXyMmUrAxd0flTQgbBsUfwE5zkog28KdVeNPFpzEA6nKj3ANDyMPfyW/8ggWoWIzixBzxaDziYJtmtw9C38Pr5/bieUQMiFqnIP+L1lCFQ/ez5VBayYUZbkynnGfQbBfRQg== X-Forefront-PRVS: 02475B2A01 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?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5vQeRx?= =?us-ascii?Q?GqItw3d2UvZBYVP2IW2Q5sWCCJgYHqgMPQ95m1GhSQ7GTxuda8KpqbzDCBcZ?= =?us-ascii?Q?BdMdWHq64ISXj43C/4FJtxQMiMKBS8LnxrLF82ogoe+k88c93bE0HlmB+eOx?= =?us-ascii?Q?A4oT4/T6+Yy271PO8wsOBJ?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB468; 6:yY9v3aOl6eRuo2tVfPBryqRsmXNGk1I7hHJWFbfhxiwZlLY5z48hZRJFDse9v20A8QpA5Hsy9Oq70R9cXVY+uDvLbwCRb+HObu5aFeMWKEw6IFo4PSJujPoF9nDQkggLf0gGfhAon8jaXIoIMQJ763wyKv6kk0FS05mSyOrraNmRXWesBdOXH8f9SPAuW5LjSCM8vFtqOOGhAw6qKuIzeVYUjJrHw26RIbQ31ZG+yqosvWyRZ9NOjoJry7PiCXc0LhH6pVgBGkhw1r6cAalxSNvBgadKU0eYX0ztXiXVV3VZY5hVirUUsKM5Q5I3e7flsbtBfIHzUOJyOPXzwvhN5qdLMiIjOQlRn6haUcwuR6De1pvrzNSaoyJ6/m89Qeo/n14xjVUwlNdZO76F6Z/1jw==; 5:zGj1wYmHMCVazd4qa30l3ktlGFUi51GcOfZBb8sqW6EqIz0x5z5Z1hekzzpTt3jUYuDtMZnxUF68nyWnqxdErj6VvC2UGuqbItNUgUPPrKXyI+zFlGW6YTqpiLszA3ITrvwbomEG64fxnlA+xMPDSQ==; 24:yJStNWDTaBm8nYPreh4bLqg5huz+AFw4kYAWCyiFVR0BKdlBwbI1xbZLx3S8miOi4eXOnjJq/Td1OLOSXrEwoz1AeDuSZTVxmh2nN38ixw4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB468; 7:WBAX61ExVMyKHW28EghPJIKXUTWNbm9eP7FNXNtfnmzLjz48OppJPLxsfLA1VmjMiHwTxMdoDL0yR+OSqiZCrxBXLdXOl7vdjmbOjm+u8x2wjfcxxD4LtJQw3EsLEEw5foFcZFzLXtr3O06tf8KSazeRSWJwhb18oct/FnYWbC8FG9BBK3mID+GJcP1ui+g5+zMX0jB0skDl4zPEX4/u202pi9FoS+/s5RY7XBpF++HNQtjgOylviVj9B5BJ84nIAk9u9eATmT7agCBo7jrOMvI5G4SOdF8CIzORwltAeai/ERnC52vt/nWXpEo2Ose+u62U6sS080SbSOvCQeaSEw== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2017 16:49:25.1172 (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: BLUPR07MB468 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 67c0d5aa3212..de952935b5d2 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 089480280558..9251918773b1 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 @@ -3311,6 +3312,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 323b912b47f7..5b2451745e9f 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 b1bfa63f7d4e..b0f6ad3020d3 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3340,8 +3340,8 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) 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, @@ -3419,13 +3419,11 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) /* 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 e40ed570d3c1..53d9579acc74 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -3623,6 +3623,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 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 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 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_mbx + ql_dbg_verbose, vha, 0x10b7, @@ -3641,13 +3647,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 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 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 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 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, 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 54d4e802bde0..344faf59783d 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3469,6 +3469,7 @@ qla2x00_remove_one(struct pci_dev *pdev) 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 38bdcd325fa4..7278e046bf87 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -187,21 +187,23 @@ static inline 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 @@ -6040,6 +6042,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) { @@ -6693,6 +6706,8 @@ qlt_modify_vp_config(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; @@ -6712,6 +6727,13 @@ qlt_probe_one_stage1(struct scsi_qla_host *base_vha, struct qla_hw_data *ha) 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 @@ -6820,25 +6842,69 @@ qlt_mem_free(struct qla_hw_data *ha) 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)