From patchwork Thu Dec 28 20:33:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135855 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 2758D60318 for ; Thu, 28 Dec 2017 20:34:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 170252B7EC for ; Thu, 28 Dec 2017 20:34:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02B0E2B88E; Thu, 28 Dec 2017 20:34: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=-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 0480C2B3EB for ; Thu, 28 Dec 2017 20:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755184AbdL1UeH (ORCPT ); Thu, 28 Dec 2017 15:34:07 -0500 Received: from mail-by2nam01on0040.outbound.protection.outlook.com ([104.47.34.40]:60936 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751220AbdL1UeB (ORCPT ); Thu, 28 Dec 2017 15:34:01 -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=0sKyiTG3uoY5mMrYvSWSyS6c17YKGjDJtx2zgk2as7A=; b=BWItfkpIK1i15v/EctVwT5SN6pb6Z1DCow0wTfiuKo6M0gsiL5Otobd+XqgRb/auowqfCeF0xqKNDfFrTcwn6XdJ89tkSGtO11u27SVltaM6kBeiaZ6OLKn9jjyd+Kkk5lCyHOfB8U9msMvTB0+9cxQdws/RIKyILWROgv8VL74= Received: from SN4PR0701CA0023.namprd07.prod.outlook.com (10.161.192.161) by CY1PR0701MB1948.namprd07.prod.outlook.com (10.163.141.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Thu, 28 Dec 2017 20:34:00 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:149) by SN4PR0701CA0023.outlook.office365.com (2603:10b6:803:28::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Thu, 28 Dec 2017 20:34:00 +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 BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Thu, 28 Dec 2017 20:33:39 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Thu, 28 Dec 2017 12:33:49 -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 vBSKXkxJ002807; Thu, 28 Dec 2017 12:33:46 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBSKXkJa002806; Thu, 28 Dec 2017 12:33:46 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 06/37] qla2xxx: Fix Firmware dump size for Extended login and Exchange Offload Date: Thu, 28 Dec 2017 12:33:14 -0800 Message-ID: <20171228203345.2702-7-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171228203345.2702-1-himanshu.madhani@cavium.com> References: <20171228203345.2702-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)(39380400002)(376002)(346002)(39860400002)(396003)(2980300002)(448002)(199004)(189003)(8676002)(76176011)(2950100002)(5660300001)(356003)(50466002)(50226002)(54906003)(48376002)(6666003)(80596001)(36756003)(1076002)(2906002)(42186006)(47776003)(106466001)(86362001)(16586007)(575784001)(51416003)(316002)(69596002)(81156014)(305945005)(110136005)(8936002)(81166006)(59450400001)(85326001)(478600001)(72206003)(87636003)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1948; 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; BN1BFFO11FD006; 1:YZnWk0kSo0HuCAPV6/6xzwsk1yf6lNamksXpjmd3WdEw2suGQu9vUDsL52c8fSbTHUIdPcuCURb6WD+Vd7SP9Beny9Svb4JLtSJILVWLcZkPgL5HMp6BiGwHIPvkGdpU X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a403847b-76a4-4b34-c81e-08d54e3247ab X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY1PR0701MB1948; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 3:5nXZ3YzZTZUrCIIZssBUmBD56RTaEIam5zhRYsi0iuRYTqGIpBBUYDSb63o1N/GPvIppx8F0JGUsJhFAptif8pSabm7mEHvo2RxtKQ5KF7c4DaLLSHpT7oPAp2ANcUQkVQx6kSCMyK5jXnRk9wj6zOquCD7BkArres5T7zd6gXS0hveTG9ctpyVss2i2g6ALG0e7HxMWKQygYELfpIEvpjOIoJKNPjB6lV7Qc5kHCGHL09VQWJh0o1NTNZ0AIEIkmX5FnoIU0Zei6HadMY7Cnsnh+ZEFBf9uhPegyTEIQSIMiNRxcEy/qQYvcQyLRE0MywGQGl1MTeZ0yO9JlNj5vQ==; 25:N9lgAnhzGGhA4Ig72W5Cu0J/Ll/6FLOWsdGrR5HylLrGROsTkuA/XwlZntlaUcstTah/ApN21OhrVRIM9I/VFxqwQZFl3KXgrcjFwq1dk4Ed8G0WKUJB7S24jS07CYKYsSuCTGmaLp3s3hJXljnMf38EFIdm39HeanHC4v/blAxbq3+aQWB9CKHeOfUwtvAry8V3ijS2vd3Ld5xW3RA5ZDTGoKi/0CQVVeYVcf9JXJ99gwsTiCuiSR0rYso1yyiDYDoBruGpiiGais5DslJ6u6x8wbp69YRCGYtXKgL46kp8pbr2TnaMMXtCerYkWCMzmyELRT8J81o0VG630y+rXHrBtH9TcOswny7mBunuylU= X-MS-TrafficTypeDiagnostic: CY1PR0701MB1948: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 31:YblPL0jPKmJ8S8vArGd9SSJBOdyKcSntyKWluqqd5Oem1ispmJbDqu4HFsAlsLHBmSywaYpg7r5wsW58sqFtqx+Y2KDTpns6OC9L2BqBqj/WpH9X7oviOeKfFuEq0ue47gPRefpU9WxAwgLw83ZFUYTgsDScrg8/KWEim64w4o8N5plNnFLs0O9D00cvXB5tZPBs8HS7r5/2k7dZ4PY4WY6StJ2fcx7lyZCxndcfduo=; 20:B+c6M+0lNT0guJ87w4lgB3qzmxGHRsLmZWX20E6wTowwxfvELKpynar7Tp2sGEXy2uANRfu9qUiKF23oa2Ja0rq2LDYkMxn+p5n8Rqo02w5UggFGvtA7MvdgG57eLqiVY0piWOC75gGLxu/rsyO+RwMt92utgbF9I8J/xaO1ai0MdFgCCNsPEAZdNca6FEZAVvpzZb+eflDT2vA3GAxG51gN4WGhuDWehEt6hmE7Uyd5RvvZq9hhjN+Q74G2hoUl8snTVj7xsxN1n/sRXd2lAqBuQxztv3IGfVC2pk2LBxK8wp5MjEmXGWTsE47vadgueQPReB8nqrOsMe7vRWbNY94SGdnsVTjJ7jc9VRgX9TEx8zW1Y6ezOG0dDZasdIcIRVvZJ7611ZC5tMhtVtfyv5eV8LnbFADHyCmdRMnqBLTdJo9gVLsx0pepBEMLM9rSNJVTRiiFuJ6aRBlfj6aLEK+K5znRZX2iO691PBuJIRqMSxxZ06JMPbdFY4to4oEm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(944501075)(10201501046)(3002001)(6041268)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011); SRVR:CY1PR0701MB1948; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR0701MB1948; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 4:U6k3nXMkbh9VW6RJwBSt36X/yWC/DXtWMlSL73HV/RxA0ilZP+CBsaGVHLEDgvaJSCpbYlC4cevPVPvf/8BPaHZEnsiexQzrPPwk5P+fcBrgiv+p9uvAu1OAE1Q4H2GONIWIEhffT/Rnvcq95TL8Q/v4Em86GSxI8u3Kjbcc29C6lnfcGLVnorl+qP25uocsyggLlI6nE2L4H+ftLj7o6GTeIcQ67znx3GEjIKgoKrZaIHIunKdwSVJDvtMBckkc+jSijh+xYNg+SFwl0d8NFA== X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1948; 23:gCZOgigkZYreV/FL6h5dJoCNqkAPw+uJUFiQngQ?= =?us-ascii?Q?cb9zuF+aM+uwsecru/2cV0OWZFJb+9x7XYpo9VeNjgAgRRPZ7HcxtwHMLrwL?= =?us-ascii?Q?OrXiHj2Zwo5aFiM8lEo1iW8sn2/YSIw75nVaQihBr8GxhIEaRgSqJPTge6jO?= =?us-ascii?Q?W8DRvd/r8CGGaG3rsPMbvwN/LsI2MpiLFGCTPCWfUULgVpWin6V6PVf8PnGs?= =?us-ascii?Q?sz7Yfr2JNg7XTFYS74j6kfzVGwrYMPztrQYwpbgf0/kSz+cvPZyLqEGKndw8?= =?us-ascii?Q?cxqXA69Ah5ZYrO83piFXx8OvVJZgCI5avz9lHhuGI3VOyIVijUgu4ibpB6SU?= =?us-ascii?Q?5Np0wFsIU6IySn9FhbF/JBqeiu+3if0X5XKWGTKwK4Pk2eq+GCX2gKAALlPU?= =?us-ascii?Q?LTFu57yXnSKtw+/voAtIMgxRRfMAE5E5iji1LOEJkQawwQNYRRj3ZKqfAogg?= =?us-ascii?Q?BCmhfxJ/6KSNiWRy/qa4OR4HswIJHqJVUv/HrFlr30hq0kFax7Cxm+wFnjyr?= =?us-ascii?Q?TmvGCWI0CBZnmuwyv3lhqti/SVN1SeST+mADIejlrGmgAoXPF5+xdByP0MoE?= =?us-ascii?Q?I1KM59zUjpv2V1for4LHqDvFjmHgJFH/9uYssgOYFz9VFmiH2xlkhj8NFEig?= =?us-ascii?Q?KRU8Q+T1U9j442epPSPtYKfKLQLkasZYkc4U73qqtfs7S0fr1cOaYwRSnnRw?= =?us-ascii?Q?Pl+lrxgdhW13Zv/G3ry9FX9RXgH/v5IOHaF2511t9+Dotz6Kte5LPhgVR3Qo?= =?us-ascii?Q?UQwWxqB0O+IH0PSasvEmaHevYLXuzbHWGs1wbjl7PRhIc5It2k9qdFMddKmw?= =?us-ascii?Q?+mD8tlbxDjKeQLlaGHQ4G6VlXX4PKrPRkQWaOfvI/x2P83ceP4flNkW5GyXi?= =?us-ascii?Q?W6IMpLxYhp9rJsuJqFrFS06r+vVavrpXlpGQ60eWQsCUwQaWamyjgEgAbWgt?= =?us-ascii?Q?vz/SocvCBHLDasAI30fSlNgHZuY/UnOYtmVo4nYQCpE1CzgtAh/x1Ja6Tkeg?= =?us-ascii?Q?NHOMVDDjKLNH4iEiuDdn1ZSMQWSJrgBc+BHp0ZrnF2rXqkw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1948; 6:yqTHb6GBUN7rpp0qjkLX9jnKo/oq8FaVNy+pdx7o0g49F31l4ZD6dt22eh16MfW8i7WGrCELLsEJ/Q7V8JUrESnuashzFx/Y/6kaBdHEnrZZDwvB4e6Re4WVLcNyWkRf6pE+2ur9iAjvBkRJuLAS6lkl8fkzSoSndHxwZFdyTxyR9nl29S1Dx8bs+JqeuzkVzIlqVBAC/LYXDNVOucLjPJR8JZIDnvbyBTkkkRY9pu2CU2UWX8kEiZBV5Z9gYJZfQ2lfR9x3v1ny+5jhSWwnof240aYw7FYEZU77wkfNaFxrBIfNJ8ZpGvGkv2CZ2DWbFc8EWrM/ncEjxmfkoooODN48YVM9One5YMJbRjJlt7c=; 5:swvtBiUvmT5iOv6c3L+4bX9kla2UApj9+GjIVcbPwJdMsIA96aP5bgDyvzKqi33CtNVL3n1eg2y9UMWnUq3mELHeo2OVZJ6xZr43U+/cHgv3yyn03UcqsoJVp0eQCpPY53Ztjw+9LjnygUb24NykYWbCZhzt2YjQWpw7JH40Ew8=; 24:jwU6o5gRHdakceMjh/r0QZornLL+OGc2LbhhxkvYG0iQiPlY6Wf+Zwnu5CmvdtJ993/maUvKTr+nTqdAweUTHmGvuiZDlzh0SxfJM6FplxQ=; 7:Zf+jnuKRiwIHXMc9qtkcpDg8b/UFatCxyyKKEgqi1Lw/F1aEN3hTmb/dJju0qPeEUBUSnJvXYx2Rct0/B+LHwNFckYMt/8Do03MLnWBa96nj694orlVBdticFMGzbtyGJIFV7D16BBeK4PSjcRyJOA/UM9ay4+nAclEy2qwIccy8CIToDSGxbPNUALpEOpuBQv0SnshP4qoikC7kC8hfdKB3rd3FDe8X50y/nbmKHUDLS6yDG8HczVPt1EA9gu+x SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:39.7132 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a403847b-76a4-4b34-c81e-08d54e3247ab 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: CY1PR0701MB1948 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 5fef2bf55a9f..fc307752b2f5 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 @@ -3118,9 +3126,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;