From patchwork Thu Mar 15 03:34:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10283869 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 7D3C8602BD for ; Thu, 15 Mar 2018 03:35:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B16E287AD for ; Thu, 15 Mar 2018 03:35:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F87A28806; Thu, 15 Mar 2018 03:35:20 +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 459CF287AD for ; Thu, 15 Mar 2018 03:35:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751903AbeCODfS (ORCPT ); Wed, 14 Mar 2018 23:35:18 -0400 Received: from mail-by2nam01on0043.outbound.protection.outlook.com ([104.47.34.43]:20448 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751613AbeCODfN (ORCPT ); Wed, 14 Mar 2018 23:35:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rC/FwIbLQmGd8gIHa4Mv6+m57X7x4Cy/wjJ+HJjrb8g=; b=OQE+P9qqBLv/lkNxOkbscTvx0bon6LxLSL3ejSTxzFbrboDQcm1MMoc1tnnT4s4CeJNQZBtG6/DKa3ByezGlhhnU8ukZsIuiAxWKuA76IYbSyLjqZvbPaV9flXAxY4YZUGpDMsoXAWm0cfDghNupqPGaYhTyx76UYXmwjJY0yGA= Received: from CO2PR07CA0079.namprd07.prod.outlook.com (2603:10b6:100::47) by DM6PR07MB4220.namprd07.prod.outlook.com (2603:10b6:5:bd::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Thu, 15 Mar 2018 03:35:12 +0000 Received: from BY2FFO11OLC012.protection.gbl (2a01:111:f400:7c0c::171) by CO2PR07CA0079.outlook.office365.com (2603:10b6:100::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.588.14 via Frontend Transport; Thu, 15 Mar 2018 03:35:12 +0000 Authentication-Results: spf=fail (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; HansenPartnership.com; dkim=none (message not signed) header.d=none;HansenPartnership.com; dmarc=none action=none header.from=cavium.com; Received-SPF: Fail (protection.outlook.com: domain of cavium.com does not designate 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 BY2FFO11OLC012.mail.protection.outlook.com (10.1.15.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.527.18 via Frontend Transport; Thu, 15 Mar 2018 03:35:12 +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, 14 Mar 2018 20:35:06 -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 w2F3Z5fi012675; Wed, 14 Mar 2018 20:35:05 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w2F3Z5YZ012674; Wed, 14 Mar 2018 20:35:05 -0700 From: Himanshu Madhani To: , , , , CC: , Subject: [PATCH v2 03/13] qla2xxx: Add changes for devloss timeout in driver Date: Wed, 14 Mar 2018 20:34:54 -0700 Message-ID: <20180315033504.12628-4-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180315033504.12628-1-himanshu.madhani@cavium.com> References: <20180315033504.12628-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)(39860400002)(39380400002)(346002)(396003)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(356003)(5660300001)(305945005)(4326008)(48376002)(26005)(316002)(110136005)(16586007)(54906003)(336012)(59450400001)(6666003)(2950100002)(76176011)(51416003)(87636003)(105606002)(186003)(478600001)(86362001)(42186006)(47776003)(1076002)(106466001)(2201001)(81166006)(81156014)(50226002)(69596002)(36756003)(85426001)(2906002)(8936002)(8676002)(50466002)(72206003)(575784001)(80596001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR07MB4220; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Fail; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC012; 1:VA8HLEcWPV2HqgN6eHSr2xT2lxvBL7IHuu9THp27vJwtL/W4l6JogcyCSois7z3rCTrcufHr8qN8su5I5QYAKkJj8ttsPbHY3n5KGkdwN6z40mUwFkKpNh1v7elEtBzG X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4994d6a-bac7-4278-6ed0-08d58a25c280 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060); SRVR:DM6PR07MB4220; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4220; 3:VYeqDTvgikV+X0saCGdW+25uryigP0dsKWFJiNKGTgHzhlL+pBSj1XLXhsE67h7O7jJ3QcBlOnRZUHSVTDtDlOSdt5QL/472hTGqVWbFZAnKz3wFKJm5JAFYiF4fEI4WeojXHUuokdJDtAGIt7bVzAcliaVlBHCcAtfHX43Cx0OEDsrP/4amMKhbTsS2OwQmKX56MDRkqZT6Uz7ISnSRfmYlGdQx3eEwVQzM2kN4YguhhRAPRm1WsSsGyW+uwPWa9nzxkJC+NWC48Ke5EDjhm6PofZHMzjemTV85hO68BRkyePsaFZG4qGacilsKISaXqr9ideHCovkR1gEFjEwvf9SU0dFT+L55mM1PAADTy4M=; 25:+wlg8xbA7IjrdRdZSeF/SKRysFSNhvcAcoUNzevysOv/PbwY7bwntCCRJgpuFhdyv5GlplO1L3xxgViBwSKcTvDT61U7cMaFEFtqKzqyJn49ZDrzJL9viCwEzD0nUh5/BRF7/rb+pgmWYlWhpuFu9XI7g6skqAuuF/oug4ao2psBLRmt0jlU+E44XNoO9f9UyJuDXPHb1VL02Y4C9eoc3bEELEEcF8SxBQU4nfjoq0tMoVCw8fGyPoeKB/DReS05TuPDh2k6psYOEtFWJ7pz6XvSsA+34I2t1m3u8qBAeLZYsLyp8Ga8Zacl1lqJjUa/HSUV/adndExNMQjAyFre+A== X-MS-TrafficTypeDiagnostic: DM6PR07MB4220: X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4220; 31:6PI8ytVB6+t9iqSFH/+hSowjcPQ7fruhNrJe5jA3jftuIkAW7bjtg/7ktENozQvj1U7jWy0TB0/xFZxh4KEZ5buP0jTp7XuLkV+TSCOEH3V1STp/AhKIenxLFdCF1dpHOt6n7deYIMvfEviDae9KXEN+i5AtOEdldV6MZ5CyxsVe9IszeWtgj5/fwd1YkqP4dbAlAOim+QtFyAZNQjYT1EufPIE3QjAHGO1QhrPd5ow=; 20:L6OwOthhAfPVyNbnG01zbQURfXHUbKbzq/QSW8OuOR911sdz4D2A/STGZlRzHOY73iTQDAbA0dC6QPSDss5bupFyPPWoTAroB46hs8+TGOv430dIw5O8Gb64bbBq3RcNLF5HWl/Zl6YwzUkH8/VvpPx3FANc8HCm61dYGSXKpi47BYwFiLyfLr81LoyjDfN3Bvsv1s9Z6dKjsdCg342a0IIOj41msyxJARAcC9XgBwXhtdkKvXpKjsfAAwZei9mLTyirV8Gn18cerhLgDcQV47qUnvVJuRrWhviF6UJcJN+r4ZZBXXXDkhkrC47yA5HTSwu2PoxaRybu8QiH4dc6WUhklFcknI1iiB0VA3coXmKmawwzDK0hFbr/K53Qlb0MUhq5MmyJfcbQGwFCQNwzK1QekSK6pi5hfX9tiqFtnp5Twsj/e3BbpnZ6Q9mVTXRVZ9Rd1X7BXaz/b2QjtGMqR5V57Ro2REtA09E7TDxpkrWGUIZulMJUA/h0nJe1b8J4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231221)(944501244)(52105095)(6041310)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:DM6PR07MB4220; BCL:0; PCL:0; RULEID:; SRVR:DM6PR07MB4220; X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4220; 4:VVgd0P1lrzfcK5yGnDuqVQHFGeHCjYX7G7p60V+Qvi3bwD5z2cK3BVjN4TsKII4D/WB48Lc2A5JxyFjTaz8kocl1ut19LLxVkBGFUXlvYVpuCvuMYji7ZZNNbCqaTkVIi/6JGol5G8EUyP8vedKqAaw03AWxX0xkw+uSDQRDJl5WVvRrfFPN3u4Lisev8aJGueIlTHU4/1qJ9yjqX7NTXDCDU99EukpGHLROFPy6Wg2d7ondLrDhtkgqSUeEUb2CP0iFa6uE9e6qSpTIdHYPDg== X-Forefront-PRVS: 0612E553B4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR07MB4220; 23:N0L/ibp94m2YhU4Jy0tcQGXXUl42zfkDthyTnAcBu?= =?us-ascii?Q?w9Ap6/01xaTprcLhCmh3Iw9ASqBT13hXkDoIpc/JYL38oB0JVaFfaJfyaAQE?= =?us-ascii?Q?zgoiVcafBBvyiKE6iO3kgDcguZDIGpuVxJaL0f/cHMQVCgoI3biu2mkYyvRG?= =?us-ascii?Q?0K34Z1GOhWxuyZOO0vBIgKHaYfmi/wvNQgoRg5jfn5mUgPu615v1MxXxnqJO?= =?us-ascii?Q?0JWU59j2oz5WqKE236HJLkQjOgEqNjAvrzJX/gQo55ljV4jgHmpNHgsbB2ko?= =?us-ascii?Q?136uOMYKdbkinSqhlsGzwX0L+EO8seQoBztyFoQfjv/Ugp+5aeoNKwSXQSpt?= =?us-ascii?Q?Nv5S2v9cAAsELKqTfVwpLRVdf2klvBYdSEVzma4Jncm2+T20L6rC8uf/0jj3?= =?us-ascii?Q?WR6wS4idhDaB5HkzSNL2ISJydv+v7Hf4QTT5odrIZ8YVf3E8dFseVZh2GnPJ?= =?us-ascii?Q?tT/tnHPNdcPSmCbax2b+QFEtEath5wMP8/jqlJmh9Gx6cUy9UcJ3cV6y40jG?= =?us-ascii?Q?LTM3nml9FoB8RHktGLoDGfwneXY9PxyVO7RAI+sjiYIXO42OOsdWqAxhxb8+?= =?us-ascii?Q?RY6JO5uugBln+oan+C6OISvr86i9G5c980JOLNRgjUmSrFvVJOtLgGPA3PZR?= =?us-ascii?Q?vIfF0lYLVGnlluc+muh4Tli74h1J5IVZXj+hqwWjUb9T5ryPC6gE4sggdULA?= =?us-ascii?Q?Crjco0hyrNPtKMtwCIRulwoHg4UnqCvSwyItBqB9XPs111I01VhnUpIRhjT8?= =?us-ascii?Q?vlQNQEvd32Fq+8ALlAQXFF5UU2eC3ZAXBiXHhefK6xeih6Q/qcPzXpSl1fFV?= =?us-ascii?Q?ZVEAgd/g6Awvvif233ZFp2I90LNUM3d4tfO40VXC30cyVwEAM6l6qwb1JH3r?= =?us-ascii?Q?qWSIXL/noCj/gifSrPxnKsDsgf9WKfJmkjoJM66pLNZ6l6mtwepv0u83dZHp?= =?us-ascii?Q?9tHjlcagrpnH6H+qPahzgfY12qvv/rIxgMUaIkJV4nsEvDNfjxhyWWof/CVI?= =?us-ascii?Q?1ZuOIsVRA/wY76UVPjUxNLv+JHH+vCiWf5+pjc0EFkiXgn2zzdWKBvxP1gna?= =?us-ascii?Q?g2Do4zpdCggksYbphzZym0e9oY5NXaM99BD4ntqC4v3sVNE+ciuiZD/qgcRB?= =?us-ascii?Q?OiffdVx5Z98QWx3EWrZFZWwdbcDhbMH4OO4J0b5bpFx+RNS19NJ+Q=3D=3D?= X-Microsoft-Antispam-Message-Info: ouezxJlgJLvGY0psPOLylm447Eo0WVFl1Dn9R8AaQ1w7kKK1aF3SM0XNGC9ny/SH9cjoTFzKSeO9NyJMqGalpAbJqWoay3ORLR/fxuwolyuEAnjCjpUp5xpRDod4a/XsjTYKDVR+0RDJpZ2fQfZQEkk/QBxdRbT5WUSihuuZIs97c/H4dzArhqfNp/mGBwFE X-Microsoft-Exchange-Diagnostics: 1; DM6PR07MB4220; 6:uqicKROrsiNk/vMuPWi3fTSar+i8sig3SIjkEizFrnC9GLgbc7ZYjaQ9v+cNS5PnmAFjdBIUOvC+BMOmQX6gpNXlVdwgOfbHIh/F3In5OqH8Z6EVStfywp6pprwrOF3ModNGMbonU3e1UGsX/zqEIHhxdtghWYvWLR4FeIktBpk0VfjWHEaBLwfRuUuwuicm49voChe4zLr+o+SQKtDvNvYDv5F6TnyeS8+wT+JB6l1Uj9OeH3vl8NzNs97aXqV7zZNHDwx4LIeINQPFH/5ZWDBrI636sSreC7d5fk2q4QJjXN2PvVRWWzAtkcpMydYzdfO/ss8tAI993P3FA7W8aJBIXk1jTvW5m41fx80A8+o=; 5:4RgMxyXLWcp2Q1SGNLSNBryv4NL+K8Reb/cBFYBBbW1++dWdmtfjGg0CIys84bGVtinmDk7Ey1CLskS55eWKAo3KOtbMV6QTP6/rUHgN3+XtH6v5nmCXPQ5//DPqOgJYsMky+YgKFt1F7Wg0wReTVNc5cyO6DUcL/3Zy3fVfIn0=; 24:Pik2MNqhzDCyGzBj9t30PB9nWYwUUbZg8c7JmeEtkcOR63liHzeoSlSpB7zDmqBLBKOuMC/kxcrcoiBrOI/bf9J57gGlxCU+dlhiadxU+us=; 7:O0RS/VepYQ/g/aSw7Lq7SRqLg8b4YCC4KFdhqpcRzuNcoRORxccoUxtDGfTEl/6oQX19tf+NOMIJWHsQm2YqvJ1jWVQcK7I3U5pzh/EZFSiHjVfsSMzY+LrdnXrycsYtCKBZADPkebMRN1ZaKVeDVo1LRmzwiDUM0Ytunbx2ncyuRSzAteb5kJp6O0C7/cc19Y9vu4L/IzU9XviQjLIG/M/fOklygbISSx3dOy+oWXiaG8g+u/cysc/Vtw4XBNt3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2018 03:35:12.2229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4994d6a-bac7-4278-6ed0-08d58a25c280 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: DM6PR07MB4220 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: Darren Trapp Add support for error recovery within devloss timeout, now that FC-NVMe transport support devloss timeout. Signed-off-by: Darren Trapp Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn --- drivers/scsi/qla2xxx/qla_def.h | 1 + drivers/scsi/qla2xxx/qla_init.c | 8 +++ drivers/scsi/qla2xxx/qla_isr.c | 5 +- drivers/scsi/qla2xxx/qla_nvme.c | 142 +++++++++++++++++--------------------- drivers/scsi/qla2xxx/qla_nvme.h | 6 +- drivers/scsi/qla2xxx/qla_target.c | 13 ++-- drivers/scsi/qla2xxx/qla_target.h | 2 +- 7 files changed, 87 insertions(+), 90 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index c9689f97c307..737492048d8a 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -2356,6 +2356,7 @@ typedef struct fc_port { #define NVME_PRLI_SP_DISCOVERY BIT_3 uint8_t nvme_flag; #define NVME_FLAG_REGISTERED 4 +#define NVME_FLAG_DELETING 2 struct fc_port *conflict; unsigned char logout_completed; diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 6caccc52376a..dec3e2cdaffa 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -5520,6 +5520,14 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha) break; } + if (fcport->fc4f_nvme) { + if (fcport->disc_state == DSC_DELETE_PEND) { + fcport->disc_state = DSC_GNL; + vha->fcport_count--; + fcport->login_succ = 0; + } + } + if (found) { spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); continue; diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 79f538448364..011261a9d585 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -1911,7 +1911,7 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) } else { switch (le16_to_cpu(sts->comp_status)) { case CS_COMPLETE: - ret = 0; + ret = QLA_SUCCESS; break; case CS_ABORTED: @@ -1923,7 +1923,8 @@ qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk) "NVME-%s ERR Handling - hdl=%x completion status(%x) resid=%x ox_id=%x\n", sp->name, sp->handle, sts->comp_status, le32_to_cpu(sts->residual_len), sts->ox_id); - fd->transferred_length = fd->payload_length; + fd->transferred_length = 0; + iocb->u.nvme.rsp_pyld_len = 0; ret = QLA_ABORTED; break; diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c index 162a523b985e..a8e81fc14c44 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.c +++ b/drivers/scsi/qla2xxx/qla_nvme.c @@ -16,15 +16,13 @@ static void qla_nvme_unregister_remote_port(struct work_struct *); int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) { - struct nvme_rport *rport; + struct qla_nvme_rport *rport; + struct nvme_fc_port_info req; int ret; if (!IS_ENABLED(CONFIG_NVME_FC)) return 0; - if (fcport->nvme_flag & NVME_FLAG_REGISTERED) - return 0; - if (!vha->flags.nvme_enabled) { ql_log(ql_log_info, vha, 0x2100, "%s: Not registering target since Host NVME is not enabled\n", @@ -33,38 +31,35 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) } if (!(fcport->nvme_prli_service_param & - (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY))) + (NVME_PRLI_SP_TARGET | NVME_PRLI_SP_DISCOVERY)) || + (fcport->nvme_flag & NVME_FLAG_REGISTERED)) return 0; INIT_WORK(&fcport->nvme_del_work, qla_nvme_unregister_remote_port); - rport = kzalloc(sizeof(*rport), GFP_KERNEL); - if (!rport) { - ql_log(ql_log_warn, vha, 0x2101, - "%s: unable to alloc memory\n", __func__); - return -ENOMEM; - } - rport->req.port_name = wwn_to_u64(fcport->port_name); - rport->req.node_name = wwn_to_u64(fcport->node_name); - rport->req.port_role = 0; + memset(&req, 0, sizeof(struct nvme_fc_port_info)); + req.port_name = wwn_to_u64(fcport->port_name); + req.node_name = wwn_to_u64(fcport->node_name); + req.port_role = 0; + req.dev_loss_tmo = NVME_FC_DEV_LOSS_TMO; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR) - rport->req.port_role = FC_PORT_ROLE_NVME_INITIATOR; + req.port_role = FC_PORT_ROLE_NVME_INITIATOR; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_TARGET) - rport->req.port_role |= FC_PORT_ROLE_NVME_TARGET; + req.port_role |= FC_PORT_ROLE_NVME_TARGET; if (fcport->nvme_prli_service_param & NVME_PRLI_SP_DISCOVERY) - rport->req.port_role |= FC_PORT_ROLE_NVME_DISCOVERY; + req.port_role |= FC_PORT_ROLE_NVME_DISCOVERY; - rport->req.port_id = fcport->d_id.b24; + req.port_id = fcport->d_id.b24; ql_log(ql_log_info, vha, 0x2102, "%s: traddr=nn-0x%016llx:pn-0x%016llx PortID:%06x\n", - __func__, rport->req.node_name, rport->req.port_name, - rport->req.port_id); + __func__, req.node_name, req.port_name, + req.port_id); - ret = nvme_fc_register_remoteport(vha->nvme_local_port, &rport->req, + ret = nvme_fc_register_remoteport(vha->nvme_local_port, &req, &fcport->nvme_remote_port); if (ret) { ql_log(ql_log_warn, vha, 0x212e, @@ -73,10 +68,11 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) return ret; } - fcport->nvme_remote_port->private = fcport; - fcport->nvme_flag |= NVME_FLAG_REGISTERED; + rport = fcport->nvme_remote_port->private; rport->fcport = fcport; list_add_tail(&rport->list, &vha->nvme_rport_list); + + fcport->nvme_flag |= NVME_FLAG_REGISTERED; return 0; } @@ -174,26 +170,23 @@ static void qla_nvme_sp_done(void *ptr, int res) if (!atomic_dec_and_test(&sp->ref_count)) return; - if (!(sp->fcport->nvme_flag & NVME_FLAG_REGISTERED)) - goto rel; - - if (unlikely(res == QLA_FUNCTION_FAILED)) - fd->status = NVME_SC_INTERNAL; - else + if (res == QLA_SUCCESS) fd->status = 0; + else + fd->status = NVME_SC_INTERNAL; fd->rcv_rsplen = nvme->u.nvme.rsp_pyld_len; list_add_tail(&nvme->u.nvme.entry, &sp->qpair->nvme_done_list); + return; -rel: - qla2xxx_rel_qpair_sp(sp->qpair, sp); } static void qla_nvme_ls_abort(struct nvme_fc_local_port *lport, struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) { struct nvme_private *priv = fd->private; - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; srb_t *sp = priv->sp; int rval; struct qla_hw_data *ha = fcport->vha->hw; @@ -218,7 +211,8 @@ static void qla_nvme_ls_complete(struct work_struct *work) static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, struct nvme_fc_remote_port *rport, struct nvmefc_ls_req *fd) { - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; struct srb_iocb *nvme; struct nvme_private *priv = fd->private; struct scsi_qla_host *vha; @@ -226,9 +220,6 @@ static int qla_nvme_ls_req(struct nvme_fc_local_port *lport, struct qla_hw_data *ha; srb_t *sp; - if (!(fcport->nvme_flag & NVME_FLAG_REGISTERED)) - return rval; - vha = fcport->vha; ha = vha->hw; /* Alloc SRB structure */ @@ -275,7 +266,8 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, struct nvme_private *priv = fd->private; srb_t *sp = priv->sp; int rval; - fc_port_t *fcport = rport->private; + struct qla_nvme_rport *qla_rport = rport->private; + fc_port_t *fcport = qla_rport->fcport; struct qla_hw_data *ha = fcport->vha->hw; rval = ha->isp_ops->abort_command(sp); @@ -288,11 +280,10 @@ static void qla_nvme_fcp_abort(struct nvme_fc_local_port *lport, static void qla_nvme_poll(struct nvme_fc_local_port *lport, void *hw_queue_handle) { - struct scsi_qla_host *vha = lport->private; - unsigned long flags; struct qla_qpair *qpair = hw_queue_handle; + unsigned long flags; + struct scsi_qla_host *vha = lport->private; - /* Acquire ring specific lock */ spin_lock_irqsave(&qpair->qp_lock, flags); qla24xx_process_response_queue(vha, qpair->rsp); spin_unlock_irqrestore(&qpair->qp_lock, flags); @@ -495,6 +486,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, srb_t *sp; struct qla_qpair *qpair = hw_queue_handle; struct nvme_private *priv; + struct qla_nvme_rport *qla_rport = rport->private; if (!fd) { ql_log(ql_log_warn, NULL, 0x2134, "NO NVMe FCP request\n"); @@ -502,14 +494,14 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, } priv = fd->private; - fcport = rport->private; + fcport = qla_rport->fcport; if (!fcport) { ql_log(ql_log_warn, NULL, 0x210e, "No fcport ptr\n"); return rval; } vha = fcport->vha; - if ((!qpair) || (!(fcport->nvme_flag & NVME_FLAG_REGISTERED))) + if (!qpair) return -EBUSY; /* Alloc SRB structure */ @@ -552,22 +544,27 @@ static void qla_nvme_localport_delete(struct nvme_fc_local_port *lport) static void qla_nvme_remoteport_delete(struct nvme_fc_remote_port *rport) { fc_port_t *fcport; - struct nvme_rport *r_port, *trport; + struct qla_nvme_rport *qla_rport = rport->private, *trport; - fcport = rport->private; + fcport = qla_rport->fcport; fcport->nvme_remote_port = NULL; fcport->nvme_flag &= ~NVME_FLAG_REGISTERED; - list_for_each_entry_safe(r_port, trport, + list_for_each_entry_safe(qla_rport, trport, &fcport->vha->nvme_rport_list, list) { - if (r_port->fcport == fcport) { - list_del(&r_port->list); + if (qla_rport->fcport == fcport) { + list_del(&qla_rport->list); break; } } - kfree(r_port); complete(&fcport->nvme_del_done); + if (!test_bit(UNLOADING, &fcport->vha->dpc_flags)) { + INIT_WORK(&fcport->free_work, qlt_free_session_done); + schedule_work(&fcport->free_work); + } + + fcport->nvme_flag &= ~(NVME_FLAG_REGISTERED | NVME_FLAG_DELETING); ql_log(ql_log_info, fcport->vha, 0x2110, "remoteport_delete of %p completed.\n", fcport); } @@ -587,7 +584,7 @@ static struct nvme_fc_port_template qla_nvme_fc_transport = { .max_dif_sgl_segments = 64, .dma_boundary = 0xFFFFFFFF, .local_priv_sz = 8, - .remote_priv_sz = 0, + .remote_priv_sz = sizeof(struct qla_nvme_rport), .lsrqst_priv_sz = sizeof(struct nvme_private), .fcprqst_priv_sz = sizeof(struct nvme_private), }; @@ -606,22 +603,6 @@ static int qla_nvme_wait_on_command(srb_t *sp) return ret; } -static int qla_nvme_wait_on_rport_del(fc_port_t *fcport) -{ - int ret = QLA_SUCCESS; - int timeout; - - timeout = wait_for_completion_timeout(&fcport->nvme_del_done, - msecs_to_jiffies(2000)); - if (!timeout) { - ret = QLA_FUNCTION_FAILED; - ql_log(ql_log_info, fcport->vha, 0x2111, - "timed out waiting for fcport=%p to delete\n", fcport); - } - - return ret; -} - void qla_nvme_abort(struct qla_hw_data *ha, struct srb *sp) { int rval; @@ -636,7 +617,7 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work) { struct fc_port *fcport = container_of(work, struct fc_port, nvme_del_work); - struct nvme_rport *rport, *trport; + struct qla_nvme_rport *qla_rport, *trport; if (!IS_ENABLED(CONFIG_NVME_FC)) return; @@ -644,51 +625,52 @@ static void qla_nvme_unregister_remote_port(struct work_struct *work) ql_log(ql_log_warn, NULL, 0x2112, "%s: unregister remoteport on %p\n",__func__, fcport); - list_for_each_entry_safe(rport, trport, + list_for_each_entry_safe(qla_rport, trport, &fcport->vha->nvme_rport_list, list) { - if (rport->fcport == fcport) { + if (qla_rport->fcport == fcport) { ql_log(ql_log_info, fcport->vha, 0x2113, "%s: fcport=%p\n", __func__, fcport); init_completion(&fcport->nvme_del_done); nvme_fc_unregister_remoteport( fcport->nvme_remote_port); - qla_nvme_wait_on_rport_del(fcport); + wait_for_completion(&fcport->nvme_del_done); + break; } } } void qla_nvme_delete(struct scsi_qla_host *vha) { - struct nvme_rport *rport, *trport; + struct qla_nvme_rport *qla_rport, *trport; fc_port_t *fcport; int nv_ret; if (!IS_ENABLED(CONFIG_NVME_FC)) return; - list_for_each_entry_safe(rport, trport, &vha->nvme_rport_list, list) { - fcport = rport->fcport; + list_for_each_entry_safe(qla_rport, trport, + &vha->nvme_rport_list, list) { + fcport = qla_rport->fcport; ql_log(ql_log_info, fcport->vha, 0x2114, "%s: fcport=%p\n", __func__, fcport); init_completion(&fcport->nvme_del_done); nvme_fc_unregister_remoteport(fcport->nvme_remote_port); - qla_nvme_wait_on_rport_del(fcport); + wait_for_completion(&fcport->nvme_del_done); } if (vha->nvme_local_port) { init_completion(&vha->nvme_del_done); + ql_log(ql_log_info, vha, 0x2116, + "unregister localport=%p\n", + vha->nvme_local_port); nv_ret = nvme_fc_unregister_localport(vha->nvme_local_port); - if (nv_ret == 0) - ql_log(ql_log_info, vha, 0x2116, - "unregistered localport=%p\n", - vha->nvme_local_port); - else + if (nv_ret) ql_log(ql_log_info, vha, 0x2115, "Unregister of localport failed\n"); - wait_for_completion_timeout(&vha->nvme_del_done, - msecs_to_jiffies(5000)); + else + wait_for_completion(&vha->nvme_del_done); } } diff --git a/drivers/scsi/qla2xxx/qla_nvme.h b/drivers/scsi/qla2xxx/qla_nvme.h index 7f05fa1c77db..7becfc1b3e69 100644 --- a/drivers/scsi/qla2xxx/qla_nvme.h +++ b/drivers/scsi/qla2xxx/qla_nvme.h @@ -14,6 +14,9 @@ #include "qla_def.h" +/* default dev loss time (seconds) before transport tears down ctrl */ +#define NVME_FC_DEV_LOSS_TMO 30 + #define NVME_ATIO_CMD_OFF 32 #define NVME_FIRST_PACKET_CMDLEN (64 - NVME_ATIO_CMD_OFF) #define Q2T_NVME_NUM_TAGS 2048 @@ -31,8 +34,7 @@ struct nvme_private { int comp_status; }; -struct nvme_rport { - struct nvme_fc_port_info req; +struct qla_nvme_rport { struct list_head list; struct fc_port *fcport; }; diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 245005f1e93e..40f1f0ab67cc 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -961,7 +961,7 @@ qlt_send_first_logo(struct scsi_qla_host *vha, qlt_port_logo_t *logo) logo->cmd_count, res); } -static void qlt_free_session_done(struct work_struct *work) +void qlt_free_session_done(struct work_struct *work) { struct fc_port *sess = container_of(work, struct fc_port, free_work); @@ -1169,11 +1169,14 @@ void qlt_unreg_sess(struct fc_port *sess) sess->last_rscn_gen = sess->rscn_gen; sess->last_login_gen = sess->login_gen; - if (sess->nvme_flag & NVME_FLAG_REGISTERED) + if (sess->nvme_flag & NVME_FLAG_REGISTERED && + !(sess->nvme_flag & NVME_FLAG_DELETING)) { + sess->nvme_flag |= NVME_FLAG_DELETING; schedule_work(&sess->nvme_del_work); - - INIT_WORK(&sess->free_work, qlt_free_session_done); - schedule_work(&sess->free_work); + } else { + INIT_WORK(&sess->free_work, qlt_free_session_done); + schedule_work(&sess->free_work); + } } EXPORT_SYMBOL(qlt_unreg_sess); diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index bb67b5a284a8..728ce74358e7 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -1016,7 +1016,7 @@ extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int); extern int __init qlt_init(void); extern void qlt_exit(void); extern void qlt_update_vp_map(struct scsi_qla_host *, int); - +extern void qlt_free_session_done(struct work_struct *); /* * This macro is used during early initializations when host->active_mode * is not set. Right now, ha value is ignored.