From patchwork Wed Jul 25 17:01:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10544477 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 6F2AF112E for ; Wed, 25 Jul 2018 17:05:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 566FB2A72B for ; Wed, 25 Jul 2018 17:05:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A3032A816; Wed, 25 Jul 2018 17:05:35 +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 331B52A72B for ; Wed, 25 Jul 2018 17:05:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728634AbeGYSSG (ORCPT ); Wed, 25 Jul 2018 14:18:06 -0400 Received: from mail-by2nam01on0061.outbound.protection.outlook.com ([104.47.34.61]:19648 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728913AbeGYSSG (ORCPT ); Wed, 25 Jul 2018 14:18:06 -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=1/JvaO4xG0u2Uq959EQGujkhsQ4QF2gc2Ig9urVj9q4=; b=GTv4cxFGg9df6lV0gCel0DPCUIM37HmR3Ed4uIlrS2VWUDlD1yeG6yoHHiX50H1LKnT/AZhIuuaXF37kmAaQ/cT0TXR5qay79jvTgtL2YgdDc9hjxe79Dp+HtwINMqTV/VrURqqmoBcDdDzH/BiOjS8LvyvK2J7tcmoNQrz/8Ks= Received: from DM5PR07CA0039.namprd07.prod.outlook.com (2603:10b6:3:16::25) by DM5PR07MB4071.namprd07.prod.outlook.com (2603:10b6:4:b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Wed, 25 Jul 2018 17:01:26 +0000 Received: from DM3NAM05FT022.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::203) by DM5PR07CA0039.outlook.office365.com (2603:10b6:3:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Wed, 25 Jul 2018 17:01:26 +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 DM3NAM05FT022.mail.protection.outlook.com (10.152.98.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.1017.0 via Frontend Transport; Wed, 25 Jul 2018 17:01:26 +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; Wed, 25 Jul 2018 10:01:21 -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 w6PH1Kme010312; Wed, 25 Jul 2018 10:01:20 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6PH1Kc3010311; Wed, 25 Jul 2018 10:01:20 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 02/16] qla2xxx: Fix N2N link re-connect Date: Wed, 25 Jul 2018 10:01:06 -0700 Message-ID: <20180725170120.10269-3-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180725170120.10269-1-himanshu.madhani@cavium.com> References: <20180725170120.10269-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)(39860400002)(136003)(376002)(346002)(2980300002)(438002)(199004)(189003)(80596001)(110136005)(47776003)(186003)(486006)(106002)(44832011)(5660300001)(476003)(356003)(6666003)(11346002)(446003)(305945005)(126002)(69596002)(50226002)(2616005)(54906003)(16586007)(42186006)(2906002)(50466002)(48376002)(316002)(14444005)(86362001)(36756003)(76176011)(336012)(8936002)(4326008)(106466001)(26005)(478600001)(51416003)(87636003)(1076002)(575784001)(8676002)(81166006)(81156014)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR07MB4071;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;DM3NAM05FT022;1:5wNg3/IkoqDbQ/PtwizzJ+JtTzscQcj23c1GsW601kDmRiziMtuZLwWuUu0bk88oIfjHXks7LR/8OV57IAeWq56/NoSce4mHMiyW/+zIM77VfbYS2RjAse22xvd6FSCQ X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 207f0fa5-0c80-4444-7a73-08d5f250425a X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4608076)(2017052603328)(7153060);SRVR:DM5PR07MB4071; X-Microsoft-Exchange-Diagnostics: 1;DM5PR07MB4071;3:uRwyR+FV6ML4uJ0/YynOr6gaqKw5Ldp0dFQtHUYYyRmqFKMT62U3FoCWRes+5OjyRmeVHQdhdBY1glUVEQ7tkXg22Iu48lPf7lfgCpbVa7I/w9nNE/1Nw6zpEWSi80xkDAMylsr0xVn0Umi7F/Au/W/0DbjcyNf3xgobs6LpJ2kamb855+31M8CczI4qWE+Rr6l/5UC0BOa3GE4MbWY57RXRUujhBUYlzuwpBj3Usyqeuiv7xigw/ktsG8kWCyHc/3hDkfEWC+FAhaSXnKu0EtfgdFuMVKQ8IkFLN0JbRlhEhvCJRvkx8xbF/Rx4/bE0FREEoalJ5NXS3hSPC9Pf5ydKwJlN56JOyE6bufPzG0g=;25:viXmvhyXK6iCdeYOjL++uPxe8skk4qukyyR6Xu+hJwhSWlkKfp1hRolpPbP0trrWcSzG/VLuh5+7fXErRMQ6JCu600KlOOUg+ASTndFztcqmbjh7Y2vyt/e5HOQJTDJkjcDmUDbmtnMOicLqOgEfKalxtQe3kFaduFo74ipeR1JloWR6oJvAe2ruPJTHVNzjgRgsija6YaNm1oIxF0OtQc+wxTyJFPQsJ3DysxrkzswhescLXx687lXDXpKoEek9QWX9/hmKXlLM70/njRX4T7cM3jralRzDOPwlMDMF4a7o5Eyi/Y5cxd7Jfn7nea1W8Q1zlRWiS0sqsEKdNkwDlg== X-MS-TrafficTypeDiagnostic: DM5PR07MB4071: X-Microsoft-Exchange-Diagnostics: 1;DM5PR07MB4071;31:J3J3WO1/4YyI6LtLMWvbXULrtK4azPSWr9zb0XJhXamPNqBOsHyFtCJxY1C+EBWWmC7ARV3aY3dPuM/VOLAEwANmOlExC2z7bbMCKDc8gcLo245Ssgmn/seeF3sEJbr+1O3GFjL7yiAyjAD6HInZPqxxbleatWvByuIKDCig2tFoYhjrVUc78BAb8ejJv+VRElwnX86/NXoQAjYwd6KLdHVpMHOzhMxSUwxDe10xIhw=;20:iw872VbW3YxIe33LtyPxpYzn8rWdckUUhz/jGxskvHMu0J5/Q3mmF6if3vGPCowAE0v9YDxRfV05GVfYI+2uwn+cY4L5lNpO0L0riGGJrb6EYxG+HKdZ04EXekImmKLk4Ue6VoJ+aVQyb2hq/UopoNHZATM6+6GMz59ptI3eG34RbaPasEzN1TYaZOdcRK6BRYjuhCUkC2ycbaaFoEhiqZVWhIiE43GI3Wnd2eWsAC2LcuMYW1ZYl+hONrxR24RgqwjyhdRqu7Atxr42xYd5RKZRvYSr1HwTKqjBy4qAATsq/LBdqzi6gqGwy/jhQsKJGhWTX7rrIppGofsPHXHuF6QslvhZ+WVyBFR+jQZ6Bv+x4J2Qu7/JVXhD8tbQHVaOCheqNZoM9FnP7EKHl4Ea8bFnT7E7axlG17iVSyv2twBZiJlnL6FwYfRZi0dkTJUHHv0tGdiyahgVy8bkLHbPOtb18MWfdJCkG1whTLCxra9T167p1Ji3sQyWDExXbVnS 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93004095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:DM5PR07MB4071;BCL:0;PCL:0;RULEID:;SRVR:DM5PR07MB4071; X-Microsoft-Exchange-Diagnostics: 1;DM5PR07MB4071;4:fQmk0OjpbH9H8EVmgOUaThpcIiA1mcLl8+VoXfJqf71pvb8yQL2H12prII8gG/S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ihx+UMCK4FmG8Bwxy/pzLK41DGRURcMqf8+YYfmkh08KqEQEiYY53pY6tFu7CrCghM7vrCOIotNgywOiRYBckA0SCKM2q0fOooVGpybbV8u5FnCPrvz8rTK1FDoZM71vyi5EYy4+DeopVNq7hXw3lfZqIPlNbnlpWd4b4uq8EYES4ZLlj4jWvbeSUONNe4OA7tSNelUEQuypskvW/GhdSt5cYeYFzYcAa6OKLR8BUiCKmEd8yYDyXMDayjxrhiRg==;5:zI+K6NB4beIn+vWDKZgeA9x714xAzqhuuyo3BJZi7DY2TOSomw/3y4hmX7V12xG94vlh8l2x7wzggr8+v2feUW/6/Ex9sX/+nvuLNql/jq+msWEZuy2PbiK1X3rN0XJ85uAKnF+WVf4joNfXtZqNift0ge4OFct77xylH+B4V6Q=;7:fSwl6vQ2HHh2I5ilRxLVgC/TVL2ZLrzmKSLFlSMJar71w99Juh3iEUXziOMgdoKAR7qgnCHwJdOcqzVvljrlUQj5eTzakPtUcVV4VcBozvwyr+RywiybbNDZx0YHFULE1q3gO7H81t6FH1AnIEp98LDcN7bibajE0kKQeH1EAPbfp9qrVjrgUQqaujcQHfx3ErKxRrfoXMwEaqkb/Db8O29mDue7P6iyLKv7sXndbRLr4jCC36qtN/T4mhax+dut SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 17:01:26.4355 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 207f0fa5-0c80-4444-7a73-08d5f250425a 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: DM5PR07MB4071 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 | 223 +++++++++++++++++++++++++------------- 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, 179 insertions(+), 106 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 0f94b1d62d3f..b595479d445b 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -379,6 +379,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; @@ -4238,7 +4239,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 f7d03cddb583..258f95c79c06 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,68 +572,124 @@ 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_find_new_loop_id(vha, 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_clear_loop_id(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); - if (conflict_fcport) { - qlt_schedule_sess_for_deletion - (conflict_fcport); - ql_dbg(ql_dbg_disc, vha, 0x20e6, + 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, 0x20e6, "%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 */ @@ -4591,20 +4675,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); @@ -7930,8 +8004,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 7756106d4555..36cbb29c84f6 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -911,7 +911,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 f0ec13d48bf3..59cc02c946d7 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 1fbd16c8c9a7..d42ad3a1f9ef 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -6179,6 +6179,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 9952e51f2e90..5fad046f8a93 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; @@ -4715,6 +4720,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; }