From patchwork Wed Jul 18 21:26:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10533299 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 3E81C600F4 for ; Wed, 18 Jul 2018 21:27:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C79C29823 for ; Wed, 18 Jul 2018 21:27:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20DCC29837; Wed, 18 Jul 2018 21:27:09 +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 004C929823 for ; Wed, 18 Jul 2018 21:27:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729296AbeGRWGx (ORCPT ); Wed, 18 Jul 2018 18:06:53 -0400 Received: from mail-eopbgr730072.outbound.protection.outlook.com ([40.107.73.72]:30473 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729280AbeGRWGw (ORCPT ); Wed, 18 Jul 2018 18:06:52 -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=LNiaE4WXHzIXfH8XAmX3zSooJqwMMNXV3PYPd7psNf4=; b=YNCjNqjLpK7OhUVyjJfh5EDWuP4K4Y7b25NdxZ+GCEGKxgUTGixNMMx8azZzT0CD0d5bGKOebMFjYLSxqV2dyqxnqbaAk5yXP7Z3jxnqJ26R5xscfg1MLMgZd9/Gag1UkLGJX4MB1wyaNhmuAHHjOuwZnSEsViSUPprJwwk3f5E= Received: from DM5PR07CA0038.namprd07.prod.outlook.com (2603:10b6:3:16::24) by BY2PR07MB1458.namprd07.prod.outlook.com (2a01:111:e400:515f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Wed, 18 Jul 2018 21:26:59 +0000 Received: from DM3NAM05FT029.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e51::203) by DM5PR07CA0038.outlook.office365.com (2603:10b6:3:16::24) 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, 18 Jul 2018 21:26:59 +0000 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 DM3NAM05FT029.mail.protection.outlook.com (10.152.98.140) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.995.0 via Frontend Transport; Wed, 18 Jul 2018 21:26: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; Wed, 18 Jul 2018 14:26:55 -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 w6ILQsmG013364; Wed, 18 Jul 2018 14:26:54 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6ILQslZ013363; Wed, 18 Jul 2018 14:26:54 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 01/12] qla2xxx: Fix N2N link re-connect Date: Wed, 18 Jul 2018 14:26:43 -0700 Message-ID: <20180718212654.13325-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180718212654.13325-1-himanshu.madhani@cavium.com> References: <20180718212654.13325-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)(346002)(39860400002)(376002)(396003)(136003)(2980300002)(438002)(199004)(189003)(305945005)(6346003)(50226002)(76176011)(51416003)(47776003)(1076002)(80596001)(2906002)(69596002)(14444005)(26005)(186003)(81156014)(8676002)(87636003)(5660300001)(110136005)(446003)(356003)(86362001)(44832011)(106466001)(126002)(4326008)(2616005)(48376002)(11346002)(16586007)(8936002)(476003)(478600001)(486006)(36756003)(106002)(81166006)(6666003)(50466002)(336012)(316002)(42186006)(72206003)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB1458; 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; DM3NAM05FT029; 1:XFq8IjBr9OZmyTeY/aehYRdPj1pizHX+of2Zf6lqE1wJy0WSlvGga3oGg25RfY/XP7H0AqdFWe0Gf0+iiHxCvRbrqWtQf190F8UCneTqQQydC73exPfbrsblJy9ojVCc X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1ede2446-d9c8-470a-f46f-08d5ecf531c8 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600067)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:BY2PR07MB1458; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1458; 3:KS6guJO0foKRZ7alT+asfwaGEwx6LWjGZLae2nwTnIjSmsJ+QU+4XNEr1ZhXMTUYaRFyxdYKAPj9gKi8miZQVUlzh7hmy51IDGanb974G761uxoVtz4prOTj0IwF+hU2Azc3TOEfPbnQyQaYIT92PEDjmq04oDJOhQIpiHCQpKvXzSkCGCDIjawbQuTOT3WDSShwZzS4r4LtiFEVcmZ5WvPDD8iUUp8Adq2kHVbDvSPZvu7fj5ce3hOtVTXeC46M6suz01atj8rH52VudcjjbU3oerZD9/nmArHLOI3avq1sauxf7dQ++KDEGXMDzxtA6WVmYQoSU1J07uyV1Qy4f/PBRp1TaUD/O26Hu44YCnk=; 25:TUsIXhDl8+uHsB7UBKt+LXaTIx/BIIs6UwQ2iFBXv+pw8SuJkFGqCd0W/pkk5hcJt7qZMI8B4TuNQdkUEjIchVtxvLOvqLUsZXQnr6tkGM+S47afpU1vj2c8lbJCKk0POiW535B/bZupB4zhI15QnfLKc/EgpBELGUOv+Jsief9qeYRVgHLeVmyp3iCfPG92gtxjz0Rwc1e0tgc3nHWV3zxlHAOcYqskN8qIkr0GozhcjU1Avrxxyy+B1plsKOiIHmVN3cqXw8I6vmnDQFXSavjoi5nOjAkRE6fTuR8OJAt72q1NBjUP0wLVDIaDLA5/nh2aBBcCirHmbPwEuhwhyQ== X-MS-TrafficTypeDiagnostic: BY2PR07MB1458: X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1458; 31:Gr817S9+wNeIEK92qSw8z0L7Vw/ca03q49zfxozL2VLO0bSFs6Dn5aiYUj4Rbt4SH6eNLygrnYyRxV5XGmDuca7qgU1B5CrBiaU2RnvVVrd71XE6YGc1j/i3clxZUO+BjBXOTZhVVQ2eEa+vFD8dpF06eNDghlczc2E7n/A0hYbkWOWXcrCdtp3+kXBeAWQbfVyU+jf3F9Cp63DXOJmEpYjW3xn7QPeZC/P3BL7cC70=; 20:TOp6km5FGHfAIxenwyt/oHqJVeoNnpCcMt6IC6LVn5qtCY6IqBSWRd1kdsZxsycwm8Y3tnEK4N4SDcSAlNmDsAWWRVEk+/g7qb5RsmyFuZQbHq8kPKtcnjGEQwD+3Snbm1Y3U61BY35JRmksqAyFWZxJ933ZDnJnlWodz+2W+J3TZFb6OVvob1FaNik/ZzNYOlxyE355ZvdTvznhoXAKqobUJSRFt4VlQNYmmJHi0e7EYE32iuoO/2YcErKwsS1NpPU0f5s2NJdYSI/r0jnqi68rza2HjzC9SqS9TTgxiDcipCXQ7tp+dYAXaM7VSvbp/MQ5BnqROlUw7nc50mEP8GlRvLzswBVZt3f7nienvlc6ir9BqOr3dc5LjO6xNka9UVqq7E4muwvVdDGtOw6yZsQcLtsbef59eyQA/UFyQ+eIs7qY0GkQjjzXZWa5MOstGI4Kzhzr6Rk4R2DpHyOGJNoTGOorepLa03SsHvU6GxeSIS/TaONEPiDAwjp1DvfO 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)(10201501046)(93006095)(93004095)(3002001)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:BY2PR07MB1458; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1458; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1458; 4:ueO6lSEAi0tko99W5fddq+m8YVpY/dYZMW35X4HM8tN29qlCnySdAqom9UWEHmtdknkV5L1qcxCuiNDM4bkwl41HWQtN463mxLuwHfMQmM61CEmvegZNIKWX/TscWGM42pJQ4Kp8dmYoC+569HNMj8GkB+LuhQ0pAf8BEbf9itRycI/w9aDI6UNoWsgYjIuo9meQSN76CjUCV+25yBs6xdK5Qe/42I3HM5oatqfN6jL6k2FSwfKYZkYQ4+EH7t7xskLvJ5yxF3Ewat2teF0UsZQl3gkdD07NYycRKZQLzuzYEO1IlsXxYk2yk88FLeUj X-Forefront-PRVS: 0737B96801 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR07MB1458; 23:oPnO2sP153mR8ri1Ci6a0RyeXiTG7duxrknRb7Cgh?= =?us-ascii?Q?1ngTAK9I4/r1k8TTSyaM8XcnPXbcSJFtkKmPe0XhDbxN32Fk140k4noA4v57?= =?us-ascii?Q?m1ENbedcoB5T+BIKoQ+fL3/1hyT1XUsMKamBCKlrYRKESeXxLsOyX3LChidO?= =?us-ascii?Q?r96CkSIk/v71qNRZ32l4+sjU/JasCCu+ZmSTaNl1+8oW9m840B89fsxM8Yml?= =?us-ascii?Q?kZ9qujRjhn5t/APRCsTwIq+ZLIzuWHDSV7dl10WJDijqEZZGfP0FQuUBZ402?= =?us-ascii?Q?d6CvrTrwDg0yh+HmYEI/bzZ7a/I1nS4Mtv9vC75ZNyGgwZTzyob0kvKAuQis?= =?us-ascii?Q?yWYo0ry2FqSSOoNiBKLGur9oplmLhFnyRuNEdnjerPPPWuYsAfwKgbiyTZAR?= =?us-ascii?Q?fVRdM1rraF4BoU0bImdwcHvPnz7Vl45JA3zddlHTazhTb87+XRtrUXGqE+yp?= =?us-ascii?Q?1y+2uD1sNtaAP0gQKJENZw8qglAjUbX1AW34X1bJqNvxHjUkLjO55PTTSfoZ?= =?us-ascii?Q?E3ldJ5GjoSkPrKpr+Ob3MH1LzqXlJhyj37j8xix5S0sDFQqHN5ldP5ZHpHP+?= =?us-ascii?Q?aScauREdFw60X7IhPY3X37fm9ONT94EM0otPODiwYKe1Vm+uy3ICmkv+heNk?= =?us-ascii?Q?6+YcqnNkhZln5x8O9w+PEVXVemo6Ffepwl5tRd4Wd0hD6alJav82o9RQLS81?= =?us-ascii?Q?Lk0LiLnaD7B8MgYxoKkF0nGjELL+kwwusweRGsFxr+GfMjIlMvQ4sT2UU89Z?= =?us-ascii?Q?JVEzAsDo6/XJACxunWABmVAUqelaA++UIg6W/uNcm6XQQzzNSzgn8yOogS3d?= =?us-ascii?Q?DmXGmysiAG1bgKhHvy0dAORn/6sBTVAZfrJE6bR2uM/NAc+71py8IOKpnieZ?= =?us-ascii?Q?JR2O1PHRP3jk7IREyalzk3MJTFAieVZBtOVx7Gts2Of7kzpNSOqrvLXVZ4+z?= =?us-ascii?Q?3lWdrh0sY4JomENVvqXT+GJTx69P8juwE2H3Gt3U6lv7D2vrU0fGn4Qks/rg?= =?us-ascii?Q?reJBGEsYY87gLjkXikPO6tKNXc4aR3GHz7c81UMwhtY/Itx3yPlEqeMlOi/0?= =?us-ascii?Q?ZqEofPTFjPLMv84pZPrfTbdPKpKKZ5+xFKCd49Zo3qgAh1pkRpLsEk5eJ540?= =?us-ascii?Q?BwhD7tAufbiAfX42hyWg8sjJohur1BL?= X-Microsoft-Antispam-Message-Info: ld+hJSxjSD+IFJ0z+4rwfESSL5QoeXKdD/BFxabQSI2bBvrWPk7vF0uOdQmmtXO9tAYuPmf84PWhHF8r7rtTNtE88Kl9IerqgiqQecnDHxBkmvteH/93pMLq4jNHzNF9cDSZIQmrAQ931+DW+ZHBj/HvR5MugolqljRmyHEclXuz8Vjxx9NjXsT4hhLsHhHaFF6nG63ngUJXh3/pAS/Pnsbtyp3MNbEW948/5xkTHuRu30LOYi4dq09M3gP8W0F2lw4Em6N+3q1p6z4hQbJfNkDHXCvGz/g9yb/xkYYykjETsRUSEAAuHuE8bAX0BRW/werPoQSmEPglszG0ibig1EFM+keXnXWg877gY6nOsxU= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1458; 6:Tth3WQHgT+8iDTJSDVqQUuceUKWVuxO1AGtPvdC+8vJTM3UxNn+LFJYtdCoN4oVdkgy3cRq8eX27/lQgDFIbddDAxBU+OgMKGSbKNEuBdwUYXOaJjULAX1WzdTxDbS8JVkHTaALD5SCMgLInkQAhYo5Vu6PTSKuDImuPEJOg7gO+AQ4rJhdRDdF2THvEfqDcX9gZOCBTEUID7jFu5oxc/sS6/NgWSG2wgwtlAEAMvPFPAUiG9bip/999XhjagukHGmHyKOlq4RapcRiYTZwS4iKwfROwRRqJXj9BIvl72uYSXbqruZ0cW47ug2iAijG0eIz5a/bwkH4PFWNrOk0lepfieWhzv7yOeMyBuwxc1Tztx/rV3bTCk9fl+L75JHq0EGyYK8zYKoMCADKBTEDqJ34e18hULpXN+/u33uPaNJSuZgJbJkJpHwX6P0uggVYHpFxnfNrTjK2OpYYsemcy5A==; 5:AYyFQvgDbhyKnqcNZPIBlgs3FYrdo6g80RxUwjNBiX0vrXtuwxPstZVa3V1aOV4PEiOr9TMpnuDo03NL9JCx+PipqpM0V4Pb50ifun5MXM3Yhz77TivZDskqotrS8ud1h292q4c05Uhim5S5ClxNd1wCmnXmLMSWyUUyrCllXpQ=; 24:KbyB6dodCnrj04lcTFEeSyBeV7u+j9kE2c5vo0MAQ2LGnWDMYe75uEI4xg+N5GS4FdZQL0RzEbTO4sP2eGmnKRacb/yryps6FCFmNC1SZeE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1458; 7:mhn29HjS957qExcrCYAojlbHkkalOUgpkHyB/9138iFnIuS6snFqLitqW4I/wqNCFj9jhUWv8C879t+r/itZ88c93rWKqzjiLSUbwSVdMbUvXFmgsAuOP/YDhwxSqCKbvB9FubnTF4TFW08iLCOxgC1lSDo5L/Avl5bkzoPfooYR0OFA3CXjhZNtKrFU3aboCnukVS5Ta2V8Q+16EfJhil3o6VcsuxKXfVGlx1gxfMqlmXANMA6pkvB6ExNlhVQy X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 21:26:58.6220 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ede2446-d9c8-470a-f46f-08d5ecf531c8 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: BY2PR07MB1458 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 | 229 +++++++++++++++++++++++++------------- 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, 183 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 b0430a280ce6..b85c7d311376 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,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); - - 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: + switch (vha->hw->current_topology) { default: - if (fcport->loop_id == FC_NO_LOOP_ID) { - qla2x00_find_new_loop_id(vha, fcport); - fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; + 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; + + 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); - 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, 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; } + qla24xx_fcport_handle_login(vha, fcport); + break; - /* FW already picked this loop id for another fcport */ - if (fcport->loop_id == loop_id) - fcport->loop_id = FC_NO_LOOP_ID; + 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 */ @@ -4588,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); @@ -8039,8 +8115,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 a91cca52b5d5..036d52d00b02 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 68560a097ae1..b867fd7417e6 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 d8a36c13aeda..5a87577af7b3 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -2169,7 +2169,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; @@ -3903,28 +3906,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 817c18a8e84d..86f974d9ac17 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -6184,6 +6184,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 b85c833099ff..54e6c8f3e86d 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; }