From patchwork Thu Dec 28 20:33:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135885 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 0D6E760318 for ; Thu, 28 Dec 2017 20:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B7C2AD58 for ; Thu, 28 Dec 2017 20:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7B5D2B7EC; Thu, 28 Dec 2017 20:34:37 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 C88AC2B3EB for ; Thu, 28 Dec 2017 20:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755321AbdL1Uee (ORCPT ); Thu, 28 Dec 2017 15:34:34 -0500 Received: from mail-dm3nam03on0043.outbound.protection.outlook.com ([104.47.41.43]:37760 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754749AbdL1Ue1 (ORCPT ); Thu, 28 Dec 2017 15:34:27 -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=Y1rbqOy46+7Hl1WwYeuw8PZao/0pt2rZCz/Q95n7Vyw=; b=i1TlwAdPS6GP6OcWoJSxuwd+v6oRlSP27/Z36dAa57JK0KMGQdwBHs4rpJfH9WsyDbB8y3FJKyvi1M8c1Xwq7hJ89qIs5F2hXFKJbfk8SgRp6z8/nto7uObzRO05y/p8tNV+dClfKhdp5KzhZuKRHCXL3RPoMe1SP/uyNghixIw= Received: from BY2PR07CA0086.namprd07.prod.outlook.com (2a01:111:e400:7bff::39) by MWHPR0701MB3820.namprd07.prod.outlook.com (2603:10b6:301:7f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Thu, 28 Dec 2017 20:34:19 +0000 Received: from BN1BFFO11FD008.protection.gbl (2a01:111:f400:7c10::1:159) by BY2PR07CA0086.outlook.office365.com (2a01:111:e400:7bff::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Thu, 28 Dec 2017 20:34:19 +0000 Authentication-Results: spf=permerror (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=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1BFFO11FD008.mail.protection.outlook.com (10.58.144.71) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Thu, 28 Dec 2017 20:33: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.347.0; Thu, 28 Dec 2017 12:33:50 -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 vBSKXo12002934; Thu, 28 Dec 2017 12:33:50 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBSKXosH002933; Thu, 28 Dec 2017 12:33:50 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 27/37] qla2xxx: Add ability to use GPNFT/GNNFT for RSCN handling Date: Thu, 28 Dec 2017 12:33:35 -0800 Message-ID: <20171228203345.2702-28-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171228203345.2702-1-himanshu.madhani@cavium.com> References: <20171228203345.2702-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)(39380400002)(346002)(396003)(39850400004)(2980300002)(448002)(199004)(189003)(1076002)(42186006)(6666003)(5660300001)(356003)(54906003)(110136005)(305945005)(51416003)(85326001)(72206003)(8676002)(4326008)(76176011)(478600001)(87636003)(47776003)(16586007)(81156014)(81166006)(8936002)(86362001)(2950100002)(80596001)(69596002)(316002)(59450400001)(50226002)(106466001)(48376002)(2906002)(36756003)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3820; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD008; 1:zP0ybKQmD/c9zN3Rr53bItreopDB51M+icGkOAGKefZ0wg/+sXM/7iIeOGrdhM5WoMQMaSxi8EmSA/Ao7TkAvR9O9kXvLMLYZBJhIRKov6aPa9yGFD2COXjIGEZ3YF24 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c090531-28a6-49fa-173a-08d54e32532f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR0701MB3820; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3820; 3:BW2g7RonbYqpsWTNL+DXdfZ1UHeJHN3A+jdepluTNnPIiydOvjZEj02Umt9bYj29mECXksCyqkgBHv2/4ggCWWC6z7yweIa7XmnlqoUqWd3u6znBkwyYKVJ8QNv8TpfR4B0LBOvAFgQCmCwjvkGLS7FgsVDqoDmtpeg6g3F7IRBl6d72sdbtPyiVRewqRFpM3rytMOoBC1ySRrGhQAM9tdlujXs8EmsoEv/b0aShEKw6HyV1gF+sO3zcLD/93nx4c1Wcku9g3hamb12XQuR5OL2oaxEBo9WF3ccyBViOUKC8EVlHy6YaMm/yp9gfz1l9r1bYp7gBBUFSpCD7D5GAYQ==; 25:HIHl6BZOOf8KnZFQQzP0H9FcrqaGeyTGWaWepPzTn9S32S5nzrL3uwtVY9fG98Rg60fQNPdhHEIlOJyryuXTL3MNlPM6aEoXlrbTaH9JZhpqQawlohOMkZ+s3ABt3k+Q0tUQD1ca+u6CbQc1H3luT6X8246nyJjMM5tGAALWIDu8bmoyVrRP1EN3GAPHUUxtKUuoTQbxZAIT/hM6Ghvebe8ZxZNcmFJfuMa6VJ3vZ09kKie2BPx42fTm41o6HgUkE8Vnp4OWuwVIUjI9lilnJLes5AiYYwsRmLDWEH/jsPhKP20jipaAW77MSbgZPOiw2bv5UAN3MCf9P0E4BWkntw==; 31:3jhUoWknAJqSpQkzkwBMmptE75s4yqzA+V6fXFLdF+A7KQbI2+LEh6iLdcfFTa0kChiQ9XRa7tlbZM/OX2+9fnjCjs/ZjP49Vwf1+WW1aV5oLsbbkWRyd9E/egbPAhsZXSDr7myI3rFngUPnUuUnUo1ssTelGozdSE0i0IuCO4s/4zoE/3tIT0Wna7lIqMH0s7x7guXa9VPREBuZ3de71unDxaFBMC32qf/4lPPIS6k= X-MS-TrafficTypeDiagnostic: MWHPR0701MB3820: X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3820; 20:SUoG0vW0gXv8VdrFxgiWN7B15WurrQcWtZRit83Jica3cUZnPpR1ySE1IYAghRMNyUpA+Jft0oivQiz0n4G2GU5hPBwydcS8l00U+boq6LQFu5jXPOUHVNZLsTXgMNHuDaWEbFk86BbZTGAPXDjZ00wyrpZpvSopMrL04Tk5zoXmCPuAspZJe4s2jZU/WNihns0a5wDhsPfuxERuHsqvIjrHnPWxC7ZpzktSAbuywkdYNiDr8CuyIOryDhEoDcdXpcfsqVv7eSb2f6ORkIat/PVNJbWHLebJyNOZKvlhD2hNXIXtqcu5CKiHPLbob/Te+IJ63Do8bL4OFXRWR1byxPy4FiDQ+J/CAbr0nnekqKiWu88YC1ltqs6ooasyA0dN9IaX2rGIaAzheb7Wk01ynj93MUyP5byBaAYUMfY/7lKP0yOJ4feHwc13rKklYed0o8YT60RYQutfsdZEWi01UqQu2K+o0uULVozBo1ouHaoZ2LK5FOD5PBfhcDSNinb7; 4:1fCxggID3vfK1JVxGfS+TZfMBLlk0yxaPzwZcTB0Gh86725WNYtUlgOmd6Rs7+j20s/ai3uyPNm169UApJtEMN67O7VJF6A6l3+HM1h1Vlij6YH+Ow6XKrVkqajVT1zojttTJYaPskdN0rTA3eB/tnzUe/L8lKWGQTEYJ5JMXWIJb3qmxy0vo6K5Ui/44Jc8eUThi2QiCQbdukalfQqHlD/AEElNxHvN3v8ZD7s1oYcQEqqJZ5T7me0krCkLCHKInLrpoHLFibNtwzijpwpiO3JlVcebjet4OSzLaVKKTaC7R1sS92EO3S39O6HV82lI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(944501075)(93006095)(93001095)(6041268)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR0701MB3820; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR0701MB3820; X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0701MB3820; 23:DGFL1NdMeREmu9msdFxU0b3QNPk4RbbXsfqt3yA?= =?us-ascii?Q?Vz1Y6SBP+SxlDMXYqFcY+uBN0IVqX+vb4TaQBgJ25tpmF9qlzLWeHNrJz6YG?= =?us-ascii?Q?2TzVxo3iMI5BefWRzZSJrKTaStsRS1RQA+LgPHUiMOCgWMQo/5mN4BPocw1O?= =?us-ascii?Q?UcjC1/NWKJwljiIov6R1gUMHwEhqnfX/jgVmVlEqxlipqKL9z5rKhwaRpPjl?= =?us-ascii?Q?SOQpk0Std8vNrl1pCyM+rDc2i3EMfHSJkWnja/+kFWLspFRcOy5FJBtAjGFJ?= =?us-ascii?Q?9o4ZeLFnNxsQ9Cs7fZiNvNt5Z0czPoJqPrahktHqQqL1XtmO1coSGozqfOwt?= =?us-ascii?Q?9H18t5J2jcA53fhZL0FvzETUffw7ecmy4zjVHnlPQKR5Uin1v/iJyB1Lzd4F?= =?us-ascii?Q?ovL41Vbd+TnIvm68BMixwKJjZpS77mjOBSd/eUcSVEMOoZSBoSL16Jt1A8jV?= =?us-ascii?Q?t8YXMQqoR88tRC9/HGpJP90DG84dLl00oaH8dNpO0R7w/Np6Ib6KRSjTzE7f?= =?us-ascii?Q?iK/lWcwT/nEj56F9NnC/AimHhiMrA28EtoFYXbOJZ0ZG2ZTf2hz0dfCeuub7?= =?us-ascii?Q?XIVEhfPsMrKjrt0FJQgV8ulpxj4+6RT7t0Jb13HGhw/2Rrn2WzxReMfZyTya?= =?us-ascii?Q?VPJIicWO3oYF8Jv8vtmeX5nsOHG0Ak+dxHN4mmCr/tGwJMRVYoA2vNKNW5DI?= =?us-ascii?Q?3SYN4koc3wdUJ8YP6znEStS4a224NiOlMqFhesd/8e3lvExJEsA/194owgvI?= =?us-ascii?Q?F6/jjRUGUB4oICKgmlWmDu4DWVQ1n+HFHqvilcNfbF32gtrXRVDf+FWz76Ui?= =?us-ascii?Q?KWxjWKjos7KUxzX1nZ0y0fkhGhHmEJbS/FqBL7EOAAxrFCmnQYpVItO9UDjH?= =?us-ascii?Q?k8oJjoE7JGOMh2Y6ng6Fpvvhyk6xPg9vz0+kzO4fuiG6WUvubHZmx4hjlvPf?= =?us-ascii?Q?rut7XRbhF4fRFumCKsdF20ppzVrXR4mSLo1otUFKPm7bbi0lkFMrafPQ/BaI?= =?us-ascii?Q?59WNGww95+JOfzOQQFz9LiVeE?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3820; 6:NXDyevuimAgxyAzFadq9k1llvQkxD9l1vu99mWgT3Mwy8/cKihgzV0zKnGor8SrE4xZpsEg1JClzxyx6BvprbFuA1N87YVTomQW2TcnTswcNhE8Wn6af5PeY10ZFvUpWbxOY16DNGC1RWvUaiNy56KYxQnUbtybtgKwkQJ9yl32P+gccr40FoT+d1psPhdyHvTkbsEKrDpx6qbfninb71hy24hVsDItwQtz+vgFUitjSq22hWSJiODDvJ8NT9M6QHFsBoSX3n7act9nScSg+uiuD0TUU4WgJHQ8Lr7muFpP6xJfoZca9mWzfAQL6A47k2+iYbRjziTQIusDTPZhhtIrb8bhfdZZbdfVtYak8Ltc=; 5:wxsPFrTz5KXhcSwVLrDE5jC9Gy0mT6qZY6O7HgMEQpJtGJhFrbVUHrEv0KxKw62UTSuYEThUnZEatLn7gOrEgX8yMJ/ZteafPSE7h3WVrEAa2K5ertrXsM75gcZNGAZ17MBgxiDp9oWJ+vg+qMKex1Efyby8wKrZ6ydydNBebTM=; 24:idrr7rl4PNqiz+U5FePbPGj/45A1erp9U+u303CxuAAufmGtQTQ97l2/xbpMQv15fe3bE1t1H3DrxeqVAXbNwiDRjQGlDxAQlJJsXVX19y0=; 7:Wbj7Ugzbg+LcNpe68xRwrUkIbviLFGefi9X0cLMCAaEIhkWVZLxtPJrc0BdQkE3oqDGd216PvqUz2FtOadt/PaOoqO9wQx2UY3vNvFOm7C0bCtAKqkTztyQxCRX+ipoWE7SXIKYEfvURLwcC0nJucVEBD/EuHEiiIrfK+n4mvy44BqyLkLtAYmpj03aslqLpcTkIX6yNSAWe9ULauE2ezWpMeQj4kP0BCEbhya0Ozx24tuNBa9dA6k1PvXDSvIuC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:58.9819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c090531-28a6-49fa-173a-08d54e32532f 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: MWHPR0701MB3820 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 add ability to use gpnft/gnnft to handle RSCN. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 7 +++ drivers/scsi/qla2xxx/qla_gbl.h | 1 + drivers/scsi/qla2xxx/qla_gs.c | 99 ++++++++++++++++++++++++++++------------- drivers/scsi/qla2xxx/qla_init.c | 65 ++++++++++++++------------- drivers/scsi/qla2xxx/qla_os.c | 1 + 5 files changed, 113 insertions(+), 60 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 68b327827739..0d20f5f8d7ab 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2972,6 +2972,11 @@ struct ct_sns_gpnft_pkt { } p; }; +enum scan_flags_t { + SF_SCANNING = BIT_0, + SF_QUEUED = BIT_1, +}; + struct fab_scan_rp { port_id_t id; u8 port_name[8]; @@ -2981,6 +2986,8 @@ struct fab_scan_rp { struct fab_scan { struct fab_scan_rp *l; u32 size; + enum scan_flags_t scan_flags; + struct delayed_work scan_work; }; /* diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 643cc536454b..3f3863c09de2 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -668,6 +668,7 @@ int qla24xx_post_gfpnid_work(struct scsi_qla_host *, fc_port_t *); int qla24xx_async_gfpnid(scsi_qla_host_t *, fc_port_t *); void qla24xx_handle_gfpnid_event(scsi_qla_host_t *, struct event_arg *); void qla24xx_sp_unmap(scsi_qla_host_t *, srb_t *); +void qla_scan_work_fn(struct work_struct *); /* * Global Function Prototypes in qla_attr.c source file. diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index fff12d770583..963ebcb7cf2c 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -2976,8 +2976,10 @@ void qla24xx_handle_gidpn_event(scsi_qla_host_t *vha, struct event_arg *ea) fc_port_t *fcport = ea->fcport; ql_dbg(ql_dbg_disc, vha, 0x201d, - "%s %8phC login state %d\n", - __func__, fcport->port_name, fcport->fw_login_state); + "%s %8phC DS %d LS %d rc %d login %d|%d rscn %d|%d lid %d\n", + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, + fcport->rscn_gen, ea->sp->gen1, fcport->loop_id); if (fcport->disc_state == DSC_DELETE_PEND) return; @@ -2985,9 +2987,9 @@ void qla24xx_handle_gidpn_event(scsi_qla_host_t *vha, struct event_arg *ea) if (ea->sp->gen2 != fcport->login_gen) { /* PLOGI/PRLI/LOGO came in while cmd was out.*/ ql_dbg(ql_dbg_disc, vha, 0x201e, - "%s %8phC generation changed rscn %d|%d login %d|%d \n", + "%s %8phC generation changed rscn %d|%d n", __func__, fcport->port_name, fcport->last_rscn_gen, - fcport->rscn_gen, fcport->last_login_gen, fcport->login_gen); + fcport->rscn_gen); return; } @@ -3215,11 +3217,10 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *vha, struct event_arg *ea) struct fc_port *fcport = ea->fcport; ql_dbg(ql_dbg_disc, vha, 0x20d8, - "%s %8phC DS %d LS %d rscn %d|%d login %d|%d lid %d\n", + "%s %8phC DS %d LS %d rc %d login %d|%d rscn %d|%d lid %d\n", __func__, fcport->port_name, fcport->disc_state, - fcport->fw_login_state, fcport->last_rscn_gen, fcport->rscn_gen, - fcport->last_login_gen, fcport->login_gen, - fcport->loop_id); + fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, + ea->sp->gen2, fcport->rscn_gen|ea->sp->gen1, fcport->loop_id); if (fcport->disc_state == DSC_DELETE_PEND) return; @@ -3227,10 +3228,8 @@ void qla24xx_handle_gpsc_event(scsi_qla_host_t *vha, struct event_arg *ea) if (ea->sp->gen2 != fcport->login_gen) { /* target side must have changed it. */ ql_dbg(ql_dbg_disc, vha, 0x20d3, - "%s %8phC generation changed rscn %d|%d login %d|%d\n", - __func__, fcport->port_name, fcport->last_rscn_gen, - fcport->rscn_gen, fcport->last_login_gen, - fcport->login_gen); + "%s %8phC generation changed\n", + __func__, fcport->port_name); return; } else if (ea->sp->gen1 != fcport->rscn_gen) { ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", @@ -3862,6 +3861,7 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) bool found; u8 fc4type = sp->gen2; struct fab_scan_rp *rp; + unsigned long flags; ql_dbg(ql_dbg_disc, vha, 0xffff, "%s enter\n", __func__); @@ -3939,16 +3939,15 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) continue; - if (fcport->scan_state == QLA_FCPORT_SCAN) { + if (fcport->scan_state != QLA_FCPORT_FOUND) { if ((qla_dual_mode_enabled(vha) || qla_ini_mode_enabled(vha)) && atomic_read(&fcport->state) == FCS_ONLINE) { qla2x00_mark_device_lost(vha, fcport, ql2xplogiabsentdevice, 0); + if (fcport->loop_id != FC_NO_LOOP_ID && - (fcport->flags & FCF_FCP2_DEVICE) == 0 && - fcport->port_type != FCT_INITIATOR && - fcport->port_type != FCT_BROADCAST) { + (fcport->flags & FCF_FCP2_DEVICE) == 0) { ql_dbg(ql_dbg_disc, vha, 0x20f0, "%s %d %8phC post del sess\n", __func__, __LINE__, @@ -3959,14 +3958,16 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp) continue; } } - } - - if (fcport->scan_state == QLA_FCPORT_FOUND) + } else qla24xx_fcport_handle_login(vha, fcport); } out: qla24xx_sp_unmap(vha, sp); + + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); } static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) @@ -3995,6 +3996,9 @@ static void qla2x00_async_gpnft_gnnft_sp_done(void *s, int res) "Async done-%s timed out.\n", sp->name); sp->free(sp); + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); qla2xxx_wake_dpc(vha); @@ -4086,14 +4090,17 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp, struct ct_sns_req *ct_req; struct ct_sns_pkt *ct_sns; - if (!vha->flags.online) + if (!vha->flags.online) { + vha->scan.scan_flags &= ~SF_SCANNING; goto done_free_sp; + } if (!sp->u.iocb_cmd.u.ctarg.req || !sp->u.iocb_cmd.u.ctarg.rsp) { ql_log(ql_log_warn, vha, 0xffff, "%s: req %p rsp %p are not setup\n", __func__, sp->u.iocb_cmd.u.ctarg.req, sp->u.iocb_cmd.u.ctarg.rsp); + vha->scan.scan_flags &= ~SF_SCANNING; WARN_ON(1); goto done_free_sp; } @@ -4166,14 +4173,25 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) srb_t *sp; struct ct_sns_pkt *ct_sns; u32 rspsz; + unsigned long flags; if (!vha->flags.online) return rval; - sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); - if (!sp) + spin_lock_irqsave(&vha->work_lock, flags); + if (vha->scan.scan_flags & SF_SCANNING) { + spin_unlock_irqrestore(&vha->work_lock, flags); + ql_dbg(ql_dbg_disc, vha, 0xffff, "scan active\n"); return rval; + } + vha->scan.scan_flags |= SF_SCANNING; + spin_unlock_irqrestore(&vha->work_lock, flags); + sp = qla2x00_get_sp(vha, NULL, GFP_KERNEL); + if (!sp) { + vha->scan.scan_flags &= ~SF_SCANNING; + return rval; + } sp->type = SRB_CT_PTHRU_CMD; sp->name = "gpnft"; @@ -4187,6 +4205,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) if (!sp->u.iocb_cmd.u.ctarg.req) { ql_log(ql_log_warn, vha, 0xffff, "Failed to allocate ct_sns request.\n"); + vha->scan.scan_flags &= ~SF_SCANNING; goto done_free_sp; } @@ -4199,6 +4218,7 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) if (!sp->u.iocb_cmd.u.ctarg.rsp) { ql_log(ql_log_warn, vha, 0xffff, "Failed to allocate ct_sns request.\n"); + vha->scan.scan_flags &= ~SF_SCANNING; goto done_free_sp; } @@ -4219,8 +4239,10 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) sp->done = qla2x00_async_gpnft_gnnft_sp_done; rval = qla2x00_start_sp(sp); - if (rval != QLA_SUCCESS) + if (rval != QLA_SUCCESS) { + vha->scan.scan_flags &= ~SF_SCANNING; goto done_free_sp; + } ql_dbg(ql_dbg_disc, vha, 0xffff, "Async-%s hdl=%x FC4Type %x.\n", sp->name, @@ -4248,6 +4270,24 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type) return rval; } +void qla_scan_work_fn(struct work_struct *work) +{ + struct fab_scan *s = container_of(to_delayed_work(work), + struct fab_scan, scan_work); + struct scsi_qla_host *vha = container_of(s, struct scsi_qla_host, + scan); + unsigned long flags; + + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s: schedule loop resync\n", __func__); + set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); + set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + spin_lock_irqsave(&vha->work_lock, flags); + vha->scan.scan_flags &= ~SF_QUEUED; + spin_unlock_irqrestore(&vha->work_lock, flags); +} + /* GNN_ID */ void qla24xx_handle_gnnid_event(scsi_qla_host_t *vha, struct event_arg *ea) { @@ -4367,9 +4407,10 @@ void qla24xx_handle_gfpnid_event(scsi_qla_host_t *vha, struct event_arg *ea) fc_port_t *fcport = ea->fcport; ql_dbg(ql_dbg_disc, vha, 0xffff, - "%s %d %8phC post gpsc fcp_cnt %d\n", - __func__, __LINE__, fcport->port_name, - vha->fcport_count); + "%s %8phC DS %d LS %d rc %d login %d|%d rscn %d|%d fcpcnt %d\n", + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, ea->rc, fcport->login_gen, ea->sp->gen2, + fcport->rscn_gen, ea->sp->gen1, vha->fcport_count); if (fcport->disc_state == DSC_DELETE_PEND) return; @@ -4377,10 +4418,8 @@ void qla24xx_handle_gfpnid_event(scsi_qla_host_t *vha, struct event_arg *ea) if (ea->sp->gen2 != fcport->login_gen) { /* target side must have changed it. */ ql_dbg(ql_dbg_disc, vha, 0x20d3, - "%s %8phC generation changed rscn %d|%d login %d|%d\n", - __func__, fcport->port_name, fcport->last_rscn_gen, - fcport->rscn_gen, fcport->last_login_gen, - fcport->login_gen); + "%s %8phC generation changed\n", + __func__, fcport->port_name); return; } else if (ea->sp->gen1 != fcport->rscn_gen) { ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 75dc76587f43..61534b9bef7b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -453,6 +453,12 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, u8 current_login_state; fcport = ea->fcport; + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s %8phC DS %d LS rc %d %d login %d|%d rscn %d|%d lid %d\n", + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, ea->rc, + fcport->login_gen, fcport->last_login_gen, + fcport->rscn_gen, fcport->last_rscn_gen, vha->loop_id); if (fcport->disc_state == DSC_DELETE_PEND) return; @@ -476,9 +482,8 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, return; } else if (fcport->last_login_gen != fcport->login_gen) { ql_dbg(ql_dbg_disc, vha, 0x20e0, - "%s %8phC login gen changed login %d|%d\n", - __func__, fcport->port_name, - fcport->last_login_gen, fcport->login_gen); + "%s %8phC login gen changed\n", + __func__, fcport->port_name); return; } @@ -1058,7 +1063,6 @@ void __qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea) static void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea) { - int rval = ea->rc; fc_port_t *fcport = ea->fcport; struct port_database_24xx *pd; struct srb *sp = ea->sp; @@ -1068,8 +1072,8 @@ void qla24xx_handle_gpdb_event(scsi_qla_host_t *vha, struct event_arg *ea) fcport->flags &= ~FCF_ASYNC_SENT; ql_dbg(ql_dbg_disc, vha, 0x20d2, - "%s %8phC DS %d LS %d rval %d\n", __func__, fcport->port_name, - fcport->disc_state, pd->current_login_state, rval); + "%s %8phC DS %d LS %d rc %d\n", __func__, fcport->port_name, + fcport->disc_state, pd->current_login_state, ea->rc); if (fcport->disc_state == DSC_DELETE_PEND) return; @@ -1139,11 +1143,11 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport) u64 wwn; ql_dbg(ql_dbg_disc, vha, 0x20d8, - "%s %8phC DS %d LS %d P %d fl %x confl %p rscn %d|%d login %d|%d retry %d lid %d scan %d\n", + "%s %8phC DS %d LS %d P %d fl %x confl %p rscn %d|%d login %d retry %d lid %d scan %d\n", __func__, fcport->port_name, fcport->disc_state, fcport->fw_login_state, fcport->login_pause, fcport->flags, fcport->conflict, fcport->last_rscn_gen, fcport->rscn_gen, - fcport->last_login_gen, fcport->login_gen, fcport->login_retry, + fcport->login_gen, fcport->login_retry, fcport->loop_id, fcport->scan_state); if (fcport->login_retry == 0) @@ -1320,9 +1324,9 @@ void qla24xx_handle_relogin_event(scsi_qla_host_t *vha, void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea) { - fc_port_t *fcport, *f, *tf; + fc_port_t *f, *tf; uint32_t id = 0, mask, rid; - int rc; + unsigned long flags; switch (ea->event) { case FCME_RSCN: @@ -1350,20 +1354,15 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha, struct event_arg *ea) return; switch (ea->id.b.rsvd_1) { case RSCN_PORT_ADDR: - fcport = qla2x00_find_fcport_by_nportid(vha, &ea->id, 1); - if (!fcport) { - /* cable moved */ - rc = qla24xx_post_gpnid_work(vha, &ea->id); - if (rc) { - ql_log(ql_log_warn, vha, 0xd044, - "RSCN GPNID work failed %02x%02x%02x\n", - ea->id.b.domain, ea->id.b.area, - ea->id.b.al_pa); - } - } else { - ea->fcport = fcport; - qla24xx_handle_rscn_event(fcport, ea); + spin_lock_irqsave(&vha->work_lock, flags); + if (vha->scan.scan_flags == 0) { + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s: schedule\n", __func__); + vha->scan.scan_flags |= SF_QUEUED; + schedule_delayed_work(&vha->scan.scan_work, 5); } + spin_unlock_irqrestore(&vha->work_lock, flags); + break; case RSCN_AREA_ADDR: case RSCN_DOM_ADDR: @@ -1642,6 +1641,13 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) unsigned long flags; struct fc_port *fcport = ea->fcport; + ql_dbg(ql_dbg_disc, vha, 0xffff, + "%s %8phC DS %d LS %d rc %d login %d|%d rscn %d|%d data %x|%x iop %x|%x\n", + __func__, fcport->port_name, fcport->disc_state, + fcport->fw_login_state, ea->rc, ea->sp->gen2, fcport->login_gen, + ea->sp->gen2, fcport->rscn_gen|ea->sp->gen1, + ea->data[0], ea->data[1], ea->iop[0], ea->iop[1]); + if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND) || (fcport->fw_login_state == DSC_LS_PRLI_PEND)) { ql_dbg(ql_dbg_disc, vha, 0x20ea, @@ -1656,10 +1662,9 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) if (ea->sp->gen2 != fcport->login_gen) { /* target side must have changed it. */ ql_dbg(ql_dbg_disc, vha, 0x20d3, - "%s %8phC generation changed rscn %d|%d login %d|%d\n", - __func__, fcport->port_name, fcport->last_rscn_gen, - fcport->rscn_gen, fcport->last_login_gen, - fcport->login_gen); + "%s %8phC generation changed\n", + __func__, fcport->port_name); + set_bit(RELOGIN_NEEDED, &vha->dpc_flags); return; } else if (ea->sp->gen1 != fcport->rscn_gen) { ql_dbg(ql_dbg_disc, vha, 0x20d4, "%s %d %8phC post gidpn\n", @@ -5214,9 +5219,6 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) } } - list_for_each_entry(fcport, &vha->vp_fcports, list) { - fcport->scan_state = QLA_FCPORT_SCAN; - } /* Mark the time right before querying FW for connected ports. * This process is long, asynchronous and by the time it's done, @@ -5232,6 +5234,9 @@ qla2x00_configure_fabric(scsi_qla_host_t *vha) if (rval) set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); } else { + list_for_each_entry(fcport, &vha->vp_fcports, list) + fcport->scan_state = QLA_FCPORT_SCAN; + rval = qla2x00_find_all_fabric_devs(vha); } if (rval != QLA_SUCCESS) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 506119df56a8..605100e3c6c6 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4600,6 +4600,7 @@ struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, scsi_remove_host(vha->host); return NULL; } + INIT_DELAYED_WORK(&vha->scan.scan_work, qla_scan_work_fn); sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); ql_dbg(ql_dbg_init, vha, 0x0041,