From patchwork Thu Aug 2 20:16:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10554187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95DF61708 for ; Thu, 2 Aug 2018 20:21:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DE572C4CF for ; Thu, 2 Aug 2018 20:21:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7228C2C464; Thu, 2 Aug 2018 20:21:14 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 539492C4CF for ; Thu, 2 Aug 2018 20:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727355AbeHBWNz (ORCPT ); Thu, 2 Aug 2018 18:13:55 -0400 Received: from mail-co1nam03on0069.outbound.protection.outlook.com ([104.47.40.69]:43560 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727136AbeHBWNy (ORCPT ); Thu, 2 Aug 2018 18:13:54 -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:X-MS-Exchange-SenderADCheck; bh=tXjhiBKYPThYZby09BHInMxwOsQpPVZWeYfKta1C85Y=; b=NIMh0igAOKl0GyXi2tb5E86xpViVllUWA7jvE5C7kLPiG77xW07J9A/niGwJnKBtG1g4w9tz5j7FAnUA9XZ4ICB6kg01ZWYbNEw2WjcsC6jLd9hVjhtdKKcopDU+t+c8EvxASDacdlKgWhV5FTPHmsBAL1S40Y4y+QDWB7KU5ns= Received: from BYAPR07CA0016.namprd07.prod.outlook.com (2603:10b6:a02:bc::29) by SN1PR07MB4080.namprd07.prod.outlook.com (2603:10b6:802:2e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.15; Thu, 2 Aug 2018 20:17:04 +0000 Received: from BY2NAM05FT024.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::201) by BYAPR07CA0016.outlook.office365.com (2603:10b6:a02:bc::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1017.15 via Frontend Transport; Thu, 2 Aug 2018 20:17:04 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=cavium.com; Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2NAM05FT024.mail.protection.outlook.com (10.152.100.161) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.1038.3 via Frontend Transport; Thu, 2 Aug 2018 20:17:04 +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, 2 Aug 2018 13:16: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 w72KGwTC007946; Thu, 2 Aug 2018 13:16:58 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w72KGweo007945; Thu, 2 Aug 2018 13:16:58 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v3 02/16] qla2xxx: Fix N2N link re-connect Date: Thu, 2 Aug 2018 13:16:44 -0700 Message-ID: <20180802201658.7903-3-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180802201658.7903-1-himanshu.madhani@cavium.com> References: <20180802201658.7903-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)(396003)(136003)(39860400002)(346002)(376002)(2980300002)(438002)(199004)(189003)(81156014)(80596001)(36756003)(26005)(8936002)(76176011)(87636003)(305945005)(8676002)(16586007)(2906002)(42186006)(478600001)(5660300001)(72206003)(47776003)(54906003)(110136005)(106002)(1076002)(106466001)(356003)(6666003)(51416003)(81166006)(50226002)(4326008)(11346002)(575784001)(86362001)(44832011)(336012)(486006)(126002)(14444005)(48376002)(476003)(50466002)(446003)(2616005)(186003)(69596002)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB4080;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Pass;LANG:en;PTR:50-232-66-26-static.hfc.comcastbusiness.net;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BY2NAM05FT024;1:GAeiLyrjGsfW4Zg72dFkecV9PY65bHrl+6ydx91gqzyxQs7AY2tBEwxbijPDoDtY6g9H+FQRFF2kptNfHq2jmOsVdLPcc5Zan0DsM6m0naCvJnTqaU7e06UgZ4MvvbUs X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5def58e-31d1-4999-fbfa-08d5f8b4e9ce X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060);SRVR:SN1PR07MB4080; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4080;3:StjaPBc8a7bD7yOSqF/jApqXYFArsV7LsHMYU8pKvZT/yQICDJ0p6ZvfEZk2sZ1xkeSOSU1MixZD4XU7MSKXFXRIBygZFkBZg4A2NmFIc6Za+kUT1TJzxSq7nA5/udSlicrxwqZCvPtKArFxKUJphCfTHUTnz0d8yCf6RUNn3pa9Nipc47w4/rrciOaja46jQ6Y151C7nEvYFXDZT+IukMqXNNY0JjIYWWoTJ9KbRSsQmGmtfOJZl5IWmyMDFQHLlpfmRFihVqV799GlgeZj4wHSolzJN8dG9O17HuJWbUZzGf9afSSvUsdc6k9VpGFWSlhXM2dxhRia3mSTfJTR6LmfroHQV+JfaKaaer5Vc3M=;25:lICG0b1D8jK4tEkzlD8tpUYO1/zBfqtpLj5/eSW6JvUpbFDVPvlRmuo6DMP5giXzfJxlpedH1bGzanJ7fjwQq2gCuVxIKwzEw9K1Yus7Wq9yBtuDXv2BKoN4zTtzFhhB7UwftQRJcV2gfqBQ5a6vFUiNnTTsmilytIvlnTLsFRFOL910KKJGSFmXwer6SmixqieRUZ0C3Hlr6feO4RUqyrzZJNUKuVBhwp+Fy/GPLDFEfb06iySS/AY6RzY04tbbsCHPgjJxzmJ5R+Qjgwdade54Q8BBwKsCcZT42VU9kk40XNHJE/vYXKGHb3AFKLkE/bbUcDuC2OQPvqD2SL3Lng== X-MS-TrafficTypeDiagnostic: SN1PR07MB4080: X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4080;31:zmM4E5MaFwmqub8/2f6UxGnVbmquoExwWv4Kt6EFz/4pLLGu87cjr5a2rXvGzaNkVqKBIAqHIyWOFJbYqJrwhI8cU4zf5Bn1/qJJ3Tn6M5+DhLkefyL3RkUJunJ3wEGfc9JmT3jUEXGvqoZKR3MDXzZhREg7RpgAroIrzG4Wr6QGskpGsT4fDVHVM0gM4NJkz0BLMfIX6XP/3UylcoQ2k/pcseqFAnpDM3jXIHU8YOo=;20:b+ml5/XnoDi4IEoSO9TXucU4wBlJ/iie80sGQq+TfHDPu3YPPpZIPe49y1a8d+nGvcT210i6GWgxZr7RLdZQ0z+VBNMqq13l5R9bZEeiS0S1ZknPbQ7E5WlB1mCtiao2fmYfjB9k9FEGwWpcIoUOm6Or4JpSOmNODz7tX6PnE++mfAIma83J1/Mm1+6XziX2KICluGLKbIc48O4rlPEyvctCol1hB/UfhFwGsqthbalkL85nVmjHSR8R+An60FrLZ70KSs0kzJEpaS1/DggbrFQK1UVi3v+LJhheGL9gK1zMYPvzuP2vF6mcvHK0QG4d44HfCxV0ReqLPIuOl1fzEv4999DxzHGFN1+/9SPme2w87UuPjb+ae/bkt+6cPdhLpJwuykHI81QVM0q3szl/zGOeVSK35C/q8AToPY2QuYQdxhh2YJZuOTd44VkMwpGEejl6bQ+T3523K637a0AY+t+zwhslH/R5QqjpCWrTT7QN1TdxlIc7RqqCyoMSDCqq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(21532816269658); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93004095)(3231311)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:SN1PR07MB4080;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB4080; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB4080;4:EyxePoKHDPnWsWk+46yrEW33IFhkOCtLLKgpvok/lj+KsCeN1jZBuDPXz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zJxOKZVrR4kVY66fCghpXqvCaQf0RKbyTOelfu6qSHZ0Dsefkm3Lx4CoMUI6A6h4jYFswG3dX2BQHdZQOlYHXM5c0UkxO1a04+bw42kAvhT9LJVPq/o2F68isX9fRmE9+72cKVep37REiGhTuZdIOTsBWcjsexL3s9qkiTDpMqe9kEC5BR5amkTFbkMxGIxfAPwV/aHHnt0Pq3NvHxIEGusLCzviTwEKnHx2g==;5:Uw4sylakP17cmhpjufdIbVpnsxHluv9+F+DJezb/hnG8gLmyk1cf3T/F5+byvxteAkB9s0P4ae0GKaxgU0ZbIOTBMneo2zLfYp6MQugbnE4reqzKADB8No6QRMYTM/hOWL1jLLPkjWKx6zROGSQT2DNEvhs7XZpbCM8LAixxVU4=;7:3StkVhcHoA3S6dOrHCDkx5vQ4xuLtipNkBRePKSSrTB8ofOYYZ9OnOZ2FPrEcGNNXZBsRMlgSHDHj/K+TfcoZh0j3Qi/tKtt8A1ACFnmXuKaLZCrgntNDx9GyJN1+T6wC5mbxbRLV2V0k3ErnDQVKO2DMoQdYge5daBKgUg7k1pmk/YVNHXscvUlRQ57mUQEJqxVRkvlZBNnMhe2koNFxPovs2ytcZ2zLZWHtjXVub2GtKj5UZ9GHkHY9w77t8Y1 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 20:17:04.1063 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5def58e-31d1-4999-fbfa-08d5f8b4e9ce 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: SN1PR07MB4080 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 In case of N2N connect, when sg_regset for bus/device/host was causing driver and firmware state to go out of sync. This patch fixes this link instablity when reconnect is attempted after link flap. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 3 +- drivers/scsi/qla2xxx/qla_init.c | 227 +++++++++++++++++++++++++------------- drivers/scsi/qla2xxx/qla_iocb.c | 15 ++- drivers/scsi/qla2xxx/qla_isr.c | 3 +- drivers/scsi/qla2xxx/qla_mbx.c | 27 +---- drivers/scsi/qla2xxx/qla_os.c | 5 + drivers/scsi/qla2xxx/qla_target.c | 9 ++ 7 files changed, 181 insertions(+), 108 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 9442e18aef6f..ee4d1f4fdf95 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -377,6 +377,7 @@ struct srb_iocb { #define SRB_LOGIN_COND_PLOGI BIT_1 #define SRB_LOGIN_SKIP_PRLI BIT_2 #define SRB_LOGIN_NVME_PRLI BIT_3 +#define SRB_LOGIN_PRLI_ONLY BIT_4 uint16_t data[2]; u32 iop[2]; } logio; @@ -4236,7 +4237,7 @@ typedef struct scsi_qla_host { #define FCOE_CTX_RESET_NEEDED 18 /* Initiate FCoE context reset */ #define MPI_RESET_NEEDED 19 /* Initiate MPI FW reset */ #define ISP_QUIESCE_NEEDED 20 /* Driver need some quiescence */ -#define FREE_BIT 21 +#define N2N_LINK_RESET 21 #define PORT_UPDATE_NEEDED 22 #define FX00_RESET_RECOVERY 23 #define FX00_TARGET_SCAN 24 diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 1de78697dc0d..52e163553e90 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -160,6 +160,22 @@ qla2x00_async_login_sp_done(void *ptr, int res) sp->free(sp); } +static inline bool +fcport_is_smaller(fc_port_t *fcport) +{ + if (wwn_to_u64(fcport->port_name) < + wwn_to_u64(fcport->vha->port_name)) + return true; + else + return false; +} + +static inline bool +fcport_is_bigger(fc_port_t *fcport) +{ + return !fcport_is_smaller(fcport); +} + int qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, uint16_t *data) @@ -189,13 +205,18 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport, qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); sp->done = qla2x00_async_login_sp_done; - lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; + if (N2N_TOPO(fcport->vha->hw) && fcport_is_bigger(fcport)) { + lio->u.logio.flags |= SRB_LOGIN_PRLI_ONLY; + } else { + lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; - if (fcport->fc4f_nvme) - lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; + if (fcport->fc4f_nvme) + lio->u.logio.flags |= SRB_LOGIN_SKIP_PRLI; + + if (data[1] & QLA_LOGIO_LOGIN_RETRIED) + lio->u.logio.flags |= SRB_LOGIN_RETRIED; + } - if (data[1] & QLA_LOGIO_LOGIN_RETRIED) - lio->u.logio.flags |= SRB_LOGIN_RETRIED; rval = qla2x00_start_sp(sp); if (rval != QLA_SUCCESS) { fcport->flags |= FCF_LOGIN_NEEDED; @@ -497,15 +518,18 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, for (i = 0; i < n; i++) { e = &vha->gnl.l[i]; wwn = wwn_to_u64(e->port_name); + id.b.domain = e->port_id[2]; + id.b.area = e->port_id[1]; + id.b.al_pa = e->port_id[0]; + id.b.rsvd_1 = 0; if (memcmp((u8 *)&wwn, fcport->port_name, WWN_SIZE)) continue; + if (IS_SW_RESV_ADDR(id)) + continue; + found = 1; - id.b.domain = e->port_id[2]; - id.b.area = e->port_id[1]; - id.b.al_pa = e->port_id[0]; - id.b.rsvd_1 = 0; loop_id = le16_to_cpu(e->nport_handle); loop_id = (loop_id & 0x7fff); @@ -518,14 +542,18 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, loop_id, fcport->loop_id); - if ((id.b24 != fcport->d_id.b24) || - ((fcport->loop_id != FC_NO_LOOP_ID) && - (fcport->loop_id != loop_id))) { - ql_dbg(ql_dbg_disc, vha, 0x20e3, - "%s %d %8phC post del sess\n", - __func__, __LINE__, fcport->port_name); - qlt_schedule_sess_for_deletion(fcport); - return; + switch (fcport->disc_state) { + case DSC_DELETE_PEND: + case DSC_DELETED: + break; + default: + if ((id.b24 != fcport->d_id.b24) || + ((fcport->loop_id != FC_NO_LOOP_ID) && + (fcport->loop_id != loop_id))) { + qlt_schedule_sess_for_deletion(fcport); + return; + } + break; } fcport->loop_id = loop_id; @@ -544,66 +572,122 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, fcport->login_pause = 1; } - if (fcport->fc4f_nvme) + if (fcport->fc4f_nvme) current_login_state = e->current_login_state >> 4; else current_login_state = e->current_login_state & 0xf; - switch (current_login_state) { - case DSC_LS_PRLI_COMP: - ql_dbg(ql_dbg_disc, vha, 0x20e4, - "%s %d %8phC post gpdb\n", - __func__, __LINE__, fcport->port_name); + switch (vha->hw->current_topology) { + default: + switch (current_login_state) { + case DSC_LS_PRLI_COMP: + ql_dbg(ql_dbg_disc + ql_dbg_verbose, + vha, 0x20e4, "%s %d %8phC post gpdb\n", + __func__, __LINE__, fcport->port_name); - if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) - fcport->port_type = FCT_INITIATOR; - else - fcport->port_type = FCT_TARGET; + if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) + fcport->port_type = FCT_INITIATOR; + else + fcport->port_type = FCT_TARGET; + data[0] = data[1] = 0; + qla2x00_post_async_adisc_work(vha, fcport, + data); + break; + case DSC_LS_PORT_UNAVAIL: + default: + if (fcport->loop_id != FC_NO_LOOP_ID) + qla2x00_clear_loop_id(fcport); - data[0] = data[1] = 0; - qla2x00_post_async_adisc_work(vha, fcport, data); - break; - case DSC_LS_PORT_UNAVAIL: - default: - if (fcport->loop_id == FC_NO_LOOP_ID) { - qla2x00_find_new_loop_id(vha, fcport); + fcport->loop_id = loop_id; fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; + qla24xx_fcport_handle_login(vha, fcport); + break; } - ql_dbg(ql_dbg_disc, vha, 0x20e5, - "%s %d %8phC\n", - __func__, __LINE__, fcport->port_name); - qla24xx_fcport_handle_login(vha, fcport); break; - } + case ISP_CFG_N: + switch (current_login_state) { + case DSC_LS_PRLI_COMP: + if ((e->prli_svc_param_word_3[0] & BIT_4) == 0) + fcport->port_type = FCT_INITIATOR; + else + fcport->port_type = FCT_TARGET; + + data[0] = data[1] = 0; + qla2x00_post_async_adisc_work(vha, fcport, + data); + break; + case DSC_LS_PLOGI_COMP: + if (fcport_is_bigger(fcport)) { + /* local adapter is smaller */ + if (fcport->loop_id != FC_NO_LOOP_ID) + qla2x00_clear_loop_id(fcport); + + fcport->loop_id = loop_id; + qla24xx_fcport_handle_login(vha, + fcport); + break; + } + /* drop through */ + default: + if (fcport_is_smaller(fcport)) { + /* local adapter is bigger */ + if (fcport->loop_id != FC_NO_LOOP_ID) + qla2x00_clear_loop_id(fcport); + + fcport->loop_id = loop_id; + qla24xx_fcport_handle_login(vha, + fcport); + } + break; + } + break; + } /* switch (ha->current_topology) */ } if (!found) { - /* fw has no record of this port */ - for (i = 0; i < n; i++) { - e = &vha->gnl.l[i]; - id.b.domain = e->port_id[0]; - id.b.area = e->port_id[1]; - id.b.al_pa = e->port_id[2]; - id.b.rsvd_1 = 0; - loop_id = le16_to_cpu(e->nport_handle); - - if (fcport->d_id.b24 == id.b24) { - conflict_fcport = - qla2x00_find_fcport_by_wwpn(vha, - e->port_name, 0); - ql_dbg(ql_dbg_disc, vha, 0x20e6, - "%s %d %8phC post del sess\n", - __func__, __LINE__, - conflict_fcport->port_name); - qlt_schedule_sess_for_deletion - (conflict_fcport); + switch (vha->hw->current_topology) { + case ISP_CFG_F: + case ISP_CFG_FL: + for (i = 0; i < n; i++) { + e = &vha->gnl.l[i]; + id.b.domain = e->port_id[0]; + id.b.area = e->port_id[1]; + id.b.al_pa = e->port_id[2]; + id.b.rsvd_1 = 0; + loop_id = le16_to_cpu(e->nport_handle); + + if (fcport->d_id.b24 == id.b24) { + conflict_fcport = + qla2x00_find_fcport_by_wwpn(vha, + e->port_name, 0); + ql_dbg(ql_dbg_disc + ql_dbg_verbose, + vha, 0x20e5, + "%s %d %8phC post del sess\n", + __func__, __LINE__, + conflict_fcport->port_name); + qlt_schedule_sess_for_deletion + (conflict_fcport); + } + /* + * FW already picked this loop id for + * another fcport + */ + if (fcport->loop_id == loop_id) + fcport->loop_id = FC_NO_LOOP_ID; } - - /* FW already picked this loop id for another fcport */ - if (fcport->loop_id == loop_id) - fcport->loop_id = FC_NO_LOOP_ID; + qla24xx_fcport_handle_login(vha, fcport); + break; + case ISP_CFG_N: + /* + * FW handles the initial login for n2n. + * Do link reinit to trigger this auto login. + */ + set_bit(N2N_LINK_RESET, &vha->dpc_flags); + qla2xxx_wake_dpc(vha); + break; + default: + break; } - qla24xx_fcport_handle_login(vha, fcport); } } /* gnl_event */ @@ -4590,20 +4674,10 @@ qla2x00_configure_loop(scsi_qla_host_t *vha) } else if (ha->current_topology == ISP_CFG_N) { clear_bit(RSCN_UPDATE, &flags); - if (ha->flags.rida_fmt2) { - /* With Rida Format 2, the login is already triggered. - * We know who is on the other side of the wire. - * No need to login to do login to find out or drop into - * qla2x00_configure_local_loop(). - */ + if (qla_tgt_mode_enabled(vha)) { + /* allow the other side to start the login */ clear_bit(LOCAL_LOOP_UPDATE, &flags); set_bit(RELOGIN_NEEDED, &vha->dpc_flags); - } else { - if (qla_tgt_mode_enabled(vha)) { - /* allow the other side to start the login */ - clear_bit(LOCAL_LOOP_UPDATE, &flags); - set_bit(RELOGIN_NEEDED, &vha->dpc_flags); - } } } else if (ha->current_topology == ISP_CFG_NL) { clear_bit(RSCN_UPDATE, &flags); @@ -7929,8 +8003,7 @@ qla81xx_nvram_config(scsi_qla_host_t *vha) } /* enable RIDA Format2 */ - if (qla_tgt_mode_enabled(vha) || qla_dual_mode_enabled(vha)) - icb->firmware_options_3 |= BIT_0; + icb->firmware_options_3 |= BIT_0; if (IS_QLA27XX(ha)) { icb->firmware_options_3 |= BIT_8; diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index b349e9b94c08..e1ff2e27e59f 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -2240,12 +2240,15 @@ qla24xx_login_iocb(srb_t *sp, struct logio_entry_24xx *logio) struct srb_iocb *lio = &sp->u.iocb_cmd; logio->entry_type = LOGINOUT_PORT_IOCB_TYPE; - logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); - - if (lio->u.logio.flags & SRB_LOGIN_COND_PLOGI) - logio->control_flags |= cpu_to_le16(LCF_COND_PLOGI); - if (lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI) - logio->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); + if (lio->u.logio.flags & SRB_LOGIN_PRLI_ONLY) { + logio->control_flags = cpu_to_le16(LCF_COMMAND_PRLI); + } else { + logio->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI); + if (lio->u.logio.flags & SRB_LOGIN_COND_PLOGI) + logio->control_flags |= cpu_to_le16(LCF_COND_PLOGI); + if (lio->u.logio.flags & SRB_LOGIN_SKIP_PRLI) + logio->control_flags |= cpu_to_le16(LCF_SKIP_PRLI); + } logio->nport_handle = cpu_to_le16(sp->fcport->loop_id); logio->port_id[0] = sp->fcport->d_id.b.al_pa; logio->port_id[1] = sp->fcport->d_id.b.area; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 9fa5a2557f2c..e90fb17d2121 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -908,7 +908,8 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) if (!atomic_read(&vha->loop_down_timer)) atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); - qla2x00_mark_all_devices_lost(vha, 1); + if (!N2N_TOPO(ha)) + qla2x00_mark_all_devices_lost(vha, 1); } if (vha->vp_idx) { diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 7e875f575229..4e42ce057a37 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -2177,7 +2177,10 @@ qla2x00_lip_reset(scsi_qla_host_t *vha) mcp->out_mb = MBX_2|MBX_1|MBX_0; } else if (IS_FWI2_CAPABLE(vha->hw)) { mcp->mb[0] = MBC_LIP_FULL_LOGIN; - mcp->mb[1] = BIT_6; + if (N2N_TOPO(vha->hw)) + mcp->mb[1] = BIT_4; /* re-init */ + else + mcp->mb[1] = BIT_6; /* LIP */ mcp->mb[2] = 0; mcp->mb[3] = vha->hw->loop_reset_delay; mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; @@ -3911,28 +3914,6 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, if (fcport) { fcport->plogi_nack_done_deadline = jiffies + HZ; fcport->scan_state = QLA_FCPORT_FOUND; - switch (fcport->disc_state) { - case DSC_DELETED: - ql_dbg(ql_dbg_disc, vha, 0x210d, - "%s %d %8phC login\n", - __func__, __LINE__, fcport->port_name); - qla24xx_fcport_handle_login(vha, fcport); - break; - case DSC_DELETE_PEND: - break; - default: - qlt_schedule_sess_for_deletion(fcport); - break; - } - } else { - id.b.al_pa = rptid_entry->u.f2.remote_nport_id[0]; - id.b.area = rptid_entry->u.f2.remote_nport_id[1]; - id.b.domain = rptid_entry->u.f2.remote_nport_id[2]; - qla24xx_post_newsess_work(vha, &id, - rptid_entry->u.f2.port_name, - rptid_entry->u.f2.node_name, - NULL, - FC4_TYPE_UNKNOWN); } } } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index e881fce7477a..eb804e2feedf 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -6186,6 +6186,11 @@ qla2x00_do_dpc(void *data) if (!IS_QLAFX00(ha)) qla2x00_do_dpc_all_vps(base_vha); + if (test_and_clear_bit(N2N_LINK_RESET, + &base_vha->dpc_flags)) { + qla2x00_lip_reset(base_vha); + } + ha->dpc_active = 0; end_loop: set_current_state(TASK_INTERRUPTIBLE); diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 3de11153d1d3..9d10989ed027 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -805,6 +805,10 @@ qlt_plogi_ack_find_add(struct scsi_qla_host *vha, port_id_t *id, list_for_each_entry(pla, &vha->plogi_ack_list, list) { if (pla->id.b24 == id->b24) { + ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0x210d, + "%s %d %8phC Term INOT due to new INOT", + __func__, __LINE__, + pla->iocb.u.isp24.port_name); qlt_send_term_imm_notif(vha, &pla->iocb, 1); memcpy(&pla->iocb, iocb, sizeof(pla->iocb)); return pla; @@ -1073,6 +1077,7 @@ void qlt_free_session_done(struct work_struct *work) struct qlt_plogi_ack_t *con = sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]; struct imm_ntfy_from_isp *iocb; + own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; if (con) { iocb = &con->iocb; @@ -4716,6 +4721,10 @@ static int qlt_handle_login(struct scsi_qla_host *vha, pla = qlt_plogi_ack_find_add(vha, &port_id, iocb); if (!pla) { + ql_dbg(ql_dbg_disc + ql_dbg_verbose, vha, 0xffff, + "%s %d %8phC Term INOT due to mem alloc fail", + __func__, __LINE__, + iocb->u.isp24.port_name); qlt_send_term_imm_notif(vha, iocb, 1); goto out; }