From patchwork Wed Dec 20 06:56:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125061 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 21A8D6019C for ; Wed, 20 Dec 2017 06:57:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1742C29649 for ; Wed, 20 Dec 2017 06:57:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BF992964E; Wed, 20 Dec 2017 06:57:15 +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 3F18E2964F for ; Wed, 20 Dec 2017 06:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932430AbdLTG5N (ORCPT ); Wed, 20 Dec 2017 01:57:13 -0500 Received: from mail-by2nam01on0073.outbound.protection.outlook.com ([104.47.34.73]:24389 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932295AbdLTG5F (ORCPT ); Wed, 20 Dec 2017 01:57:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5+HeanE7QJLutOd/HKUIjrBl6gvPqNKQrMJIKVSo82Y=; b=ZkkpwAgyuBPNwtCsR7Ga0OFwKSWe6HkRGhi3xjdEyXQasCzcj6VH4P1ZTjv6n1bfiTXiYQzUoupYx8TxqOcxCStoZMgTdB2Chx12I0AGgmu+CihDo+gNSTEDBPWejE6c4RZb6iOJeaITWS3wwo90F4p4zXZnzbkUxPLBxVt8VXo= Received: from CO2PR07CA0078.namprd07.prod.outlook.com (2603:10b6:100::46) by SN4PR0701MB3822.namprd07.prod.outlook.com (2603:10b6:803:4e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 06:57:03 +0000 Received: from BN1AFFO11FD043.protection.gbl (2a01:111:f400:7c10::161) by CO2PR07CA0078.outlook.office365.com (2603:10b6:100::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.323.15 via Frontend Transport; Wed, 20 Dec 2017 06:57:03 +0000 Authentication-Results: spf=permerror (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: PermError (protection.outlook.com: domain of cavium.com used an invalid SPF mechanism) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BN1AFFO11FD043.mail.protection.outlook.com (10.58.52.190) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 06:56:50 +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; Tue, 19 Dec 2017 22:56:46 -0800 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id vBK6ul2i021582; Tue, 19 Dec 2017 22:56:47 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6ul1M021581; Tue, 19 Dec 2017 22:56:47 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 09/43] qla2xxx: Fix Firmware dump size for Extended login and Exchange Offload Date: Tue, 19 Dec 2017 22:56:10 -0800 Message-ID: <20171220065644.21511-10-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171220065644.21511-1-himanshu.madhani@cavium.com> References: <20171220065644.21511-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(39860400002)(39380400002)(396003)(346002)(2980300002)(448002)(199004)(189003)(72206003)(356003)(81156014)(59450400001)(86362001)(1076002)(2950100002)(8676002)(6666003)(81166006)(110136005)(42186006)(87636003)(36756003)(54906003)(16586007)(76176011)(316002)(85326001)(478600001)(51416003)(575784001)(106466001)(47776003)(8936002)(50226002)(69596002)(48376002)(5660300001)(50466002)(80596001)(4326008)(2906002)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN4PR0701MB3822; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD043; 1:06XByoWrCHaOIewwyCdfuz0UtJ6fvVVEBNc9nHbiaB1n7+cNKpKaIWdH0TftUfhHS9fu/+oN/N1VdQsgnkY1aZMTAMx1TucO+ztbc+aPLwSqVeT6Qssuq7VBvGrQETLG X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b00cd9f2-11f6-49b5-774a-08d54776d861 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:SN4PR0701MB3822; X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3822; 3:ek9dkCzmeLiX68IYfxghCF2ccKshWjbbTYzVa7rWz0qB5GoKwwoasgLO6soxZN9Af0P0Ck1mAIohV5OCR3zNFqTiiuFlVvHAQDToc8PGPulphIQ9l02kCPk+90CQj/4DIyoPZvTkMRLpxdpWbncDn9wuuJpyBk9lqCcNt3RWMbORD9JY+U1PRJtDv1zKI1RadLeeVEm22PjLDG1xA1+wA3J713wbdVm/o/1Y6HxqMXYEd48ibErUb2B6/W+mtOfzbREtQ/DJhR9bCUfEsFgPLSAgftoiG8FuDrKIzk2qMnEAxnyclFuxM/EfBmnsHzWLsjMktPBHXMXIDHViglIoGwJ9tkQlKZ0QUBkGrHUB5Lk=; 25:crlIh8rHwlMZpcuTcYyQ94YLwIw2oWJPnflo2Ghzqg81E0Q3qrCC1YDOXwMNQXMMiWRX6gE1r+vv6YSyay0STx6fdYlSzNNxgZhkQbJ2TgBGWRjbz0nZ3jxqeCBfgKbWcjG9zqlwcUEU7VOVujGtL7sMfA2ENb+tNY2MFgDeGGIV0TcfM8QiIfyjR0uR5kqWPILvFUyr7OYKbDcvq1KVNTV/8W2TUkkaMpmQTAdE4IQwgl0YtrdLBicnAq8yfDSsulTFwnNrzOezwnExd+6gGFyc0qU0pESUyfh5wReNpmmVdk3lQV9GVie4UkC4wg631UkIVrYZmySct9KlcY+erg== X-MS-TrafficTypeDiagnostic: SN4PR0701MB3822: X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3822; 31:9h0UOxJc6jtXQKMVdBGlZk2fcnmmayGqkgKQfgJPrME146ZvZj2Pyee7yYXlA1x4Us93gOEfNm9gGtUjysSfC0IUpdTyZvisDmPQtzsomSM+kdq5zcvzntwsz9u4SErKf4foOda42I2wDkJ01IscY37bqYCA6WFBxnwR4a9jqpgofV7Gw4rW17HY+wUf1CBOxZH0ktxqQFp5tC1EMJ+AEn+b2eBNJkF/lVx8RSK4F2A=; 20:3qy5SwhxEISdHMx00PmRZGYcgxhPBkWfiXXOOgnxw8jxZ/ev5J/iIQC6/frpB6Y2bPdbsSIj+lxpNhc5LUIgsY/EALmBxbIttBX69Oa95mPBdxGVbMK3D4KtWeecuPy/AAJqAWQpua/9ts+JPqVJUZDPYfbJeCWa4fZrNgQaA5SPUNH8LCm/TmjQ4IUmKxj11WYa5j6e3X2gKQ6FzmrJ1tv/4W0exrQt3YEJPbzxlTSJrF5BNK6Axqty2Cjkw91cUgCaEwMBXXB7QHLrlKwyk+h1DwAaiWFWSasYdZvuDSc+axEBcU9fPWN3vHZYMp5Epo0Xhp7Kk56mFdybkrVLZQu5HEj8/3xvyGj1bUnpuLs212YlVdau6y6HzGU4ArrA1Z1/6B2oAU9+4xscrdOijMQpmL9pZqmgl7NO99jXN0ZwPaD5HCT01deG20B6ieEOGBkYPu79aT+BGMoBbc0xXXkFfQPvyU/288/vnFIDi68WtocyXqQ6J06JCGlNb47H X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93001095)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:SN4PR0701MB3822; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN4PR0701MB3822; X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3822; 4:vwUQo7BITnJ/ayJ0OC2bdWf0mQnjBDdIoEOaC5KRIDTQ8mS/0Uy4kqTwJkoaorbK9/UUxaZqfyFgKk1Hi6Fbox9qP/3U8mUO/glU1+8/Gs0nFKcuhTiB844554fIWcnhZ2V9/UUrPwmnDa9gML1PbK+eHsbSGzPGsBSD/Z6fZag7JzqM+gTv+c+eNGHWGoaOEUxjGCH7GSDlQWQLu65khfupQrX43MbaLcUgAuVolvaHADc4z6AmkqMZjyRw8vFB4stOmEhSrzc0H0rOZ8OeOw== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN4PR0701MB3822; 23:GwGQqwrttKribQEbcRwfaeJ7t8L4NpkKUEOlURE?= =?us-ascii?Q?NhGdESrE6e/xDCas96k4ol9XOs2V4V7xj4Raikot9en3o5Xxvn2BWGnsjzUS?= =?us-ascii?Q?CBVDLmBZhy1REDp0qV83tyajUjY7AQdrVVgg6tSm6wr+QNZ9fF98GgxDl4OI?= =?us-ascii?Q?YLHp0EsAvxPaL4lbzfCb2Oorct0+XOhPKvnH2teg0j9UwdpN/D1SZ0Z4mo1N?= =?us-ascii?Q?uRYx6gepZmXAAISsry7ymTTqUaJ2ItqjWdfejmRhWUGcS50eeLGKeodtevBa?= =?us-ascii?Q?zzOdr1vzVN61Mil5uUilXzPC/g28YU3wfS6ThnfZv550mxJ78beNl7qg7e9l?= =?us-ascii?Q?LC2ejp2Ova/jSjZpkfayjbC57rc3WYG3o06MkXBwkRy+CZ6sM3uRnSRC5Aua?= =?us-ascii?Q?JBa+Lsw0XaCVcHlqmLDFp+j+M1LdPPErS3nj75GRt2/SdFG6Fbmr2HmsBB08?= =?us-ascii?Q?JRMIotZ9cHov0FUAjPq26FuF55AQze+Ya7Fexfh95q70LpbBK06gjrswme71?= =?us-ascii?Q?kg1XygDHcn0ptnK+a1EzIkX7/OlJeZH9JmmLCerxQBtdhhCmWFvO3CjOeby9?= =?us-ascii?Q?0qGiCfpJFRJ2oQN2UNPbZ+V6jTscCmTJ60VhVWmGcfse/F8JBiIqOKIxt91S?= =?us-ascii?Q?Dy227N7nN/XhCE0gFuZI8IaS/OlJ3UBxh+MiIVcH35RIIMSPeeBItQHShM3s?= =?us-ascii?Q?+UA5kMSl36dY3hiM9wbTuHcGhVbxG0Owo4/Bsi0/DZiLtMZV7gb3X67nLndf?= =?us-ascii?Q?mjf21gRra2IdmJI8AaFd0BilLtRT9M0Hg5sR2rBm+Z/IAYxY9ciaPp4+UZQJ?= =?us-ascii?Q?5kmfRrtgY3tZ1Hr+WnxYZlZTUs9REf3rwLF1Ms/QnqQ0Ou57IiPuQDu5l72N?= =?us-ascii?Q?qkVp/L/OdlY02d8Ip2F51YoJXyCreIkZkp8gHqXltD1sEx3P9F4Tiv5YZhvF?= =?us-ascii?Q?hpOa4iFT9bPaDB5pWdq/Yg//umeDUFHb6akLNX7e/fKoziyQxcj1YErVnLha?= =?us-ascii?Q?o3GVTXIJCZFLOAVdkOmgCgQJNYRsBmKqfRxl0ii0xK4AxVw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3822; 6:bIxYFNqPOSuxlidDTUpI1bfKmAcZKodU39mGqKEMbI8lVeCSpWchjTdS2HySVe6GFUcOb5GHYUUDM5/J44V3QCNjULII6XbNFsQMFFPJeBwO8aDNcStDVMW63dfaUrP6fpxFPV9Q4G0ynnGXnb8SaeXjGV8IisrOMDRi18ExP7B19XTCTwpi5UDI+q501wAU8mtBovN12YHXz8GL58kMNi2LqNVMvyqsqbi6eJBOyrng6/KOhSG+GZhJhG8FMsYFXg40yn6FTGKN9+OBhYtcwLeAOZriD0QKZVJ0eFIChxhdrmn9xkKQgvUium7b8uEEbp53+AJ48exZuQ4qhggXxeBohES5nW9zogcQ30HbTXU=; 5:4HsDdYRiGjcWDQPsgC/Cqn5eDpYHKQMjUvrjX3fy5ROQXcA6x0lMjUGaMcc7sH0avAP88/zfiN2iN6TaCUUtQuqqw6dtpW8ved5Pqv7+WpQbchT2Li2lGTwSNG3Cesif1scwn4HYZ6tCvim7WbosfSt4GdDa0xwJy+pDSZC3kak=; 24:4umbR7l3mijQBG3BykWIA6pde35cLSfFiyMz5ThRB7GEWAc40Sk4hc+LwMa6xtJ4yDEkYIQQ1+aK+DBJaYJ06ds4UZYJ3/GjTt5LL6KFtaw=; 7:dWL9kvsW4w8w2vqhBDA5Fl0aQk8QOUcoObhh2cs69ikZHJ5614Fo08QmE6N4cqsPD7kKMl7YotlHcsGUeS6JWjNiM1LBwXu4dUIwDfFxIb0eBP6NE0GkTrxOPNsBZG4TFvSlIw7jY2eilvoyWVG2KoeEkBuR6JUed/LZWmfKRTTEn+pukDhFHbzcYZmiA8JsKDid7lIS34L2x39yHblJHJ886U27RYT283kA/MNWJk8blcOesM870fbp1yiiz88P SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:50.1340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b00cd9f2-11f6-49b5-774a-08d54776d861 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: SN4PR0701MB3822 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 This patch adjusts and reallocates fw_dump memory for target mode to save for extended login and exchange offload buffers into dump captured. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_init.c | 209 +++++++++++++++++++++------------------- drivers/scsi/qla2xxx/qla_tmpl.c | 40 +++++++- 2 files changed, 147 insertions(+), 102 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 429305caef47..5cd04bfa5cae 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -2593,70 +2593,27 @@ qla24xx_chip_diag(scsi_qla_host_t *vha) return rval; } -void -qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) +static void +qla2x00_alloc_offload_mem(scsi_qla_host_t *vha) { int rval; - uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, - eft_size, fce_size, mq_size; dma_addr_t tc_dma; void *tc; struct qla_hw_data *ha = vha->hw; - struct req_que *req = ha->req_q_map[0]; - struct rsp_que *rsp = ha->rsp_q_map[0]; - if (ha->fw_dump) { + if (ha->eft) { ql_dbg(ql_dbg_init, vha, 0x00bd, - "Firmware dump already allocated.\n"); + "%s: Offload Mem is already allocated.\n", + __func__); return; } - ha->fw_dumped = 0; - ha->fw_dump_cap_flags = 0; - dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size = 0; - req_q_size = rsp_q_size = 0; - - if (IS_QLA27XX(ha)) - goto try_fce; - - if (IS_QLA2100(ha) || IS_QLA2200(ha)) { - fixed_size = sizeof(struct qla2100_fw_dump); - } else if (IS_QLA23XX(ha)) { - fixed_size = offsetof(struct qla2300_fw_dump, data_ram); - mem_size = (ha->fw_memory_size - 0x11000 + 1) * - sizeof(uint16_t); - } else if (IS_FWI2_CAPABLE(ha)) { - if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) - fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem); - else if (IS_QLA81XX(ha)) - fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem); - else if (IS_QLA25XX(ha)) - fixed_size = offsetof(struct qla25xx_fw_dump, ext_mem); - else - fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); - - mem_size = (ha->fw_memory_size - 0x100000 + 1) * - sizeof(uint32_t); - if (ha->mqenable) { - if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) - mq_size = sizeof(struct qla2xxx_mq_chain); - /* - * Allocate maximum buffer size for all queues. - * Resizing must be done at end-of-dump processing. - */ - mq_size += ha->max_req_queues * - (req->length * sizeof(request_t)); - mq_size += ha->max_rsp_queues * - (rsp->length * sizeof(response_t)); - } - if (ha->tgt.atio_ring) - mq_size += ha->tgt.atio_q_length * sizeof(request_t); + if (IS_FWI2_CAPABLE(ha)) { /* Allocate memory for Fibre Channel Event Buffer. */ if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && !IS_QLA27XX(ha)) goto try_eft; -try_fce: if (ha->fce) dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, ha->fce_dma); @@ -2684,7 +2641,6 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) ql_dbg(ql_dbg_init, vha, 0x00c0, "Allocate (%d KB) for FCE...\n", FCE_SIZE / 1024); - fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; ha->flags.fce_enabled = 1; ha->fce_dma = tc_dma; ha->fce = tc; @@ -2701,7 +2657,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) ql_log(ql_log_warn, vha, 0x00c1, "Unable to allocate (%d KB) for EFT.\n", EFT_SIZE / 1024); - goto cont_alloc; + goto eft_err; } rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); @@ -2710,17 +2666,76 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) "Unable to initialize EFT (%d).\n", rval); dma_free_coherent(&ha->pdev->dev, EFT_SIZE, tc, tc_dma); - goto cont_alloc; + goto eft_err; } ql_dbg(ql_dbg_init, vha, 0x00c3, "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); - eft_size = EFT_SIZE; ha->eft_dma = tc_dma; ha->eft = tc; } -cont_alloc: +eft_err: + return; +} + +void +qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) +{ + uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, + eft_size, fce_size, mq_size; + struct qla_hw_data *ha = vha->hw; + struct req_que *req = ha->req_q_map[0]; + struct rsp_que *rsp = ha->rsp_q_map[0]; + struct qla2xxx_fw_dump *fw_dump; + + dump_size = fixed_size = mem_size = eft_size = fce_size = mq_size = 0; + req_q_size = rsp_q_size = 0; + + if (IS_QLA2100(ha) || IS_QLA2200(ha)) { + fixed_size = sizeof(struct qla2100_fw_dump); + } else if (IS_QLA23XX(ha)) { + fixed_size = offsetof(struct qla2300_fw_dump, data_ram); + mem_size = (ha->fw_memory_size - 0x11000 + 1) * + sizeof(uint16_t); + } else if (IS_FWI2_CAPABLE(ha)) { + if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) + fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem); + else if (IS_QLA81XX(ha)) + fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem); + else if (IS_QLA25XX(ha)) + fixed_size = offsetof(struct qla25xx_fw_dump, ext_mem); + else + fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); + + mem_size = (ha->fw_memory_size - 0x100000 + 1) * + sizeof(uint32_t); + if (ha->mqenable) { + if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) + mq_size = sizeof(struct qla2xxx_mq_chain); + /* + * Allocate maximum buffer size for all queues. + * Resizing must be done at end-of-dump processing. + */ + mq_size += ha->max_req_queues * + (req->length * sizeof(request_t)); + mq_size += ha->max_rsp_queues * + (rsp->length * sizeof(response_t)); + } + if (ha->tgt.atio_ring) + mq_size += ha->tgt.atio_q_length * sizeof(request_t); + /* Allocate memory for Fibre Channel Event Buffer. */ + if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha) && !IS_QLA83XX(ha) && + !IS_QLA27XX(ha)) + goto try_eft; + + fce_size = sizeof(struct qla2xxx_fce_chain) + FCE_SIZE; +try_eft: + ql_dbg(ql_dbg_init, vha, 0x00c3, + "Allocated (%d KB) EFT ...\n", EFT_SIZE / 1024); + eft_size = EFT_SIZE; + } + if (IS_QLA27XX(ha)) { if (!ha->fw_dump_template) { ql_log(ql_log_warn, vha, 0x00ba, @@ -2748,51 +2763,44 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) ha->exlogin_size; allocate: - ha->fw_dump = vmalloc(dump_size); - if (!ha->fw_dump) { - ql_log(ql_log_warn, vha, 0x00c4, - "Unable to allocate (%d KB) for firmware dump.\n", - dump_size / 1024); - - if (ha->fce) { - dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, - ha->fce_dma); - ha->fce = NULL; - ha->fce_dma = 0; - } - - if (ha->eft) { - dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft, - ha->eft_dma); - ha->eft = NULL; - ha->eft_dma = 0; + if (!ha->fw_dump_len || dump_size != ha->fw_dump_len) { + fw_dump = vmalloc(dump_size); + if (!fw_dump) { + ql_log(ql_log_warn, vha, 0x00c4, + "Unable to allocate (%d KB) for firmware dump.\n", + dump_size / 1024); + } else { + if (ha->fw_dump) + vfree(ha->fw_dump); + ha->fw_dump = fw_dump; + + ha->fw_dump_len = dump_size; + ql_dbg(ql_dbg_init, vha, 0x00c5, + "Allocated (%d KB) for firmware dump.\n", + dump_size / 1024); + + if (IS_QLA27XX(ha)) + return; + + ha->fw_dump->signature[0] = 'Q'; + ha->fw_dump->signature[1] = 'L'; + ha->fw_dump->signature[2] = 'G'; + ha->fw_dump->signature[3] = 'C'; + ha->fw_dump->version = htonl(1); + + ha->fw_dump->fixed_size = htonl(fixed_size); + ha->fw_dump->mem_size = htonl(mem_size); + ha->fw_dump->req_q_size = htonl(req_q_size); + ha->fw_dump->rsp_q_size = htonl(rsp_q_size); + + ha->fw_dump->eft_size = htonl(eft_size); + ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); + ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); + + ha->fw_dump->header_size = + htonl(offsetof(struct qla2xxx_fw_dump, isp)); } - return; } - ha->fw_dump_len = dump_size; - ql_dbg(ql_dbg_init, vha, 0x00c5, - "Allocated (%d KB) for firmware dump.\n", dump_size / 1024); - - if (IS_QLA27XX(ha)) - return; - - ha->fw_dump->signature[0] = 'Q'; - ha->fw_dump->signature[1] = 'L'; - ha->fw_dump->signature[2] = 'G'; - ha->fw_dump->signature[3] = 'C'; - ha->fw_dump->version = htonl(1); - - ha->fw_dump->fixed_size = htonl(fixed_size); - ha->fw_dump->mem_size = htonl(mem_size); - ha->fw_dump->req_q_size = htonl(req_q_size); - ha->fw_dump->rsp_q_size = htonl(rsp_q_size); - - ha->fw_dump->eft_size = htonl(eft_size); - ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); - ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); - - ha->fw_dump->header_size = - htonl(offsetof(struct qla2xxx_fw_dump, isp)); } static int @@ -3154,9 +3162,12 @@ qla2x00_setup_chip(scsi_qla_host_t *vha) if (rval != QLA_SUCCESS) goto failed; - if (!fw_major_version && ql2xallocfwdump - && !(IS_P3P_TYPE(ha))) + if (!fw_major_version && !(IS_P3P_TYPE(ha))) + qla2x00_alloc_offload_mem(vha); + + if (ql2xallocfwdump && !(IS_P3P_TYPE(ha))) qla2x00_alloc_fw_dump(vha); + } else { goto failed; } diff --git a/drivers/scsi/qla2xxx/qla_tmpl.c b/drivers/scsi/qla2xxx/qla_tmpl.c index 733e8dcccf5c..731ca0d8520a 100644 --- a/drivers/scsi/qla2xxx/qla_tmpl.c +++ b/drivers/scsi/qla2xxx/qla_tmpl.c @@ -526,7 +526,8 @@ qla27xx_fwdt_entry_t268(struct scsi_qla_host *vha, { ql_dbg(ql_dbg_misc, vha, 0xd20c, "%s: gethb(%x) [%lx]\n", __func__, ent->t268.buf_type, *len); - if (ent->t268.buf_type == T268_BUF_TYPE_EXTD_TRACE) { + switch (ent->t268.buf_type) { + case T268_BUF_TYPE_EXTD_TRACE: if (vha->hw->eft) { if (buf) { ent->t268.buf_size = EFT_SIZE; @@ -538,10 +539,43 @@ qla27xx_fwdt_entry_t268(struct scsi_qla_host *vha, "%s: missing eft\n", __func__); qla27xx_skip_entry(ent, buf); } - } else { - ql_dbg(ql_dbg_misc, vha, 0xd02b, + break; + case T268_BUF_TYPE_EXCH_BUFOFF: + if (vha->hw->exchoffld_buf) { + if (buf) { + ent->t268.buf_size = vha->hw->exchoffld_size; + ent->t268.start_addr = + vha->hw->exchoffld_buf_dma; + } + qla27xx_insertbuf(vha->hw->exchoffld_buf, + vha->hw->exchoffld_size, buf, len); + } else { + ql_dbg(ql_dbg_misc, vha, 0xd028, + "%s: missing exch offld\n", __func__); + qla27xx_skip_entry(ent, buf); + } + break; + case T268_BUF_TYPE_EXTD_LOGIN: + if (vha->hw->exlogin_buf) { + if (buf) { + ent->t268.buf_size = vha->hw->exlogin_size; + ent->t268.start_addr = + vha->hw->exlogin_buf_dma; + } + qla27xx_insertbuf(vha->hw->exlogin_buf, + vha->hw->exlogin_size, buf, len); + } else { + ql_dbg(ql_dbg_misc, vha, 0xd028, + "%s: missing ext login\n", __func__); + qla27xx_skip_entry(ent, buf); + } + break; + + default: + ql_dbg(ql_dbg_async, vha, 0xd02b, "%s: unknown buffer %x\n", __func__, ent->t268.buf_type); qla27xx_skip_entry(ent, buf); + break; } return false;