From patchwork Thu Dec 28 20:33:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10135847 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 74B1460318 for ; Thu, 28 Dec 2017 20:33:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C6A2AD58 for ; Thu, 28 Dec 2017 20:33:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B83A2B3EB; Thu, 28 Dec 2017 20:33:58 +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 6E1812AD58 for ; Thu, 28 Dec 2017 20:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754169AbdL1Ud4 (ORCPT ); Thu, 28 Dec 2017 15:33:56 -0500 Received: from mail-dm3nam03on0081.outbound.protection.outlook.com ([104.47.41.81]:16143 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751220AbdL1Udz (ORCPT ); Thu, 28 Dec 2017 15:33:55 -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=WmgURbewI5Xg5Jm97FEo7vq4dg/fmXCre1ZemUXi+VU=; b=LrRN/tuUeMKGGFVHmz6PUi9//Vgz8oMvGNWYfJ585IQXOGHbJ5Fwb8xTU1aseijIIpbH0Lnkj3HYUlMSDtStU46KOaJ4GOyQmoSN7an4Zq+1mnWBo60pmCZx3bAYNDv9rTsop9L2U2iheAbeatMwx3qmbM/7Jgs+HLVnYh18ea8= Received: from SN4PR0701CA0022.namprd07.prod.outlook.com (2603:10b6:803:28::32) 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; Thu, 28 Dec 2017 20:33:53 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:154) by SN4PR0701CA0022.outlook.office365.com (2603:10b6:803:28::32) 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:33:53 +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:32 +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 vBSKXkk5002799; 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 vBSKXkY7002796; Thu, 28 Dec 2017 12:33:46 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 04/37] qla2xxx: Add boundary checks for exchanges to be offloaded Date: Thu, 28 Dec 2017 12:33:12 -0800 Message-ID: <20171228203345.2702-5-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)(396003)(376002)(39850400004)(39380400002)(346002)(2980300002)(448002)(189003)(199004)(81166006)(8936002)(80596001)(106466001)(85326001)(50226002)(69596002)(72206003)(316002)(2906002)(305945005)(47776003)(48376002)(50466002)(6666003)(2950100002)(8676002)(1076002)(76176011)(5660300001)(4326008)(16586007)(110136005)(36756003)(86362001)(81156014)(478600001)(51416003)(87636003)(42186006)(54906003)(356003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN4PR0701MB3822; H:CAEXCH02.caveonetworks.com; FPR:; SPF:PermError; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD006; 1:tQA4m4KtsdzUwtwWZIBu2MRQOykOr+DRFY7HFV6vD04mluWvumRpi2c+uXttB3QrdKhi3tyyMzixFTgSnGCcDCLovKyAXfEyNUX0klv+gNCvMdMYKk1QIkuRPbqum5my X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e13133f9-f66a-4a17-95f2-08d54e324369 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:lRKfC27PUxycIvcrtXpB5sq1OdhVqjtJaJnTRw/KFve751FqCpy34PFDzhi2qGB+rOCT4znn4y+knmWmiDO5N4GvQNkkJVTl+FS0ByAJ3OJMwky1lsDr53AFAtlE/FDA+cgz+okU+lRhHGrOG8DZ1yk9w2xuNSg0OA4lK4TPH+4nizY4S4uNnSgxVtT48oVR0yX0xyaSskSgbQZOj8K4fiszDW+SqzZaWsHZIS674qlbm2OB4Ox12nxTuukzgtWbbN5yWdRp7o3U5RS8pLofoekOzcgu0lIUUehudtXZ7ryqHSKzSiq4U5Ezs8RjHdN3XYyJXu7mcvFAn9Ioykr5PA==; 25:5iNVTl7Ijoj0Ev1y6iyDq9JMFxnq1BZPaCzdDlWpIftKjmxMGhtx6EwzEIAW5PJBDJKniAZQeTk0RlDpLwJtaFIsiz9U8qu+3NYHk7lwH+sqPPyDkFFebJ+Av090okaVhUL9Z0lrxy/p6//9llipCCl90DFIt+4nkhcLCEnKg86aaxdCzne/v9N0OyaP/SjG9vqPDpIueQ+6ghaL3TDn5+wLqeabiPLyZ1zPA3H07soDb4a28CFU4pXyCAk+DHp3rXB7vfqEqMp83IOOmOAoWbXxwXvEFP7bwj4hkTQBpjLtIJm7zZVEjm0e2gwFISWHsrFQiUEMM1Z4ilmr3iAh1A==; 31:rYBbC9IPljjyp71p1mgMOEnzF3FSJY3inAtGINUWF1O0kDQlRyT8nIymwVACIEvrIT9JL93GPk5Uzlq3JTUSA3AFmsfY7CeuTVFxmzuCPqtOJUIklQxuZYDHihnIN66P0ulXI6tLtGqNjr24mo8yqLtZbor/KMxKgH7mPmiVAqskTSMsT2ukJzm+tomcUDtmCP8SM96G70KXjoia9y14DYHTnfVYgV54nIN575yKwrU= X-MS-TrafficTypeDiagnostic: SN4PR0701MB3822: X-Microsoft-Exchange-Diagnostics: 1; SN4PR0701MB3822; 20:GoNr3Ds7ZG3GNUx7dDKYP+LYoulqQRYO00VapjBhHgP6yawQnonNbNgj+x/pXF5UmDeCWDuZ/xCZQMfJ9rJRsT5hFb1ofQi6io7z9drhWprigpAhQk+L5/UpWy2iggzUe3W60TyUzGT8akjjfV+GT8uGuw4PAntC4Oz/GtGkrz4vbLoGzF4axozzO34+YXYHEGsV/j6aYp+OjoB4T81iDzHmhKdB78PkD48IQYQoJHhKV45dArjPb1AJqNkT2W4UzMAOhNLbHgu2N/X44s+VBjLoyTkIiTfAOPgfCW0cI7+Ib8QyNwWUhcn8wbVONefbrB43wvyYLruxGm3LV5/U8lKfL843/TScw6+VlRGCLkOnKBtJTZjsFbX6cqP3ZfJ3qpVNvyD5RZcSGcApy+Z5Rv5tv0k7wlRgHJ+N7o21DqcvukYElEFXIAtF5sH2fYBVTI51wa0IUt02U5idduYb+5KogbfVdeBQ99AMA1i6vBYjG/D8oYeFKpBs8B9OqA0Z; 4:cEref9/pUIkbGP1tH/dqIv/Qx0eyVYUaJ7y5y46u8oAWlOtAv/1P2+dmdd9FAYiHUrHr2U0I5nYbjcqAIGr7x43jMuzCBcyXmr/kbO6QK232ilrbkqmSQwhmWD2H/lONk+t0a3sTzEqFi7pQNHfEXZC5dZV+PAjRy7Tp60mAOpX4oZkCOlPLbT2EjWktE4FVtSeQQm8YSDGg8ggSByXT+Q8isJL5Igf+Zs0qkm8/zbQec3MjbfYbh3M47zgQ8tnmtl70KoNR6e/96RU9TDNYZg== 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)(3002001)(3231023)(944501075)(10201501046)(93006095)(93001095)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:SN4PR0701MB3822; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SN4PR0701MB3822; X-Forefront-PRVS: 05352A48BE X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN4PR0701MB3822; 23:XSF2u9VlRT5Prd5PhHdj1ivxqSwI2Txs53gUt/p?= =?us-ascii?Q?tzXsc4RMS/6YogVSpbZsubGxaJGGr8UKQXeBAriECBcWEBCq1QitnOYdgKUB?= =?us-ascii?Q?bs9SbirIliXPh9coEbddCBMWN0YR+CWPgBvMC2D76WA1WgAf2gAWmq3/4giW?= =?us-ascii?Q?p1yTKtjpb21XkkGQ++F1pZd+4RlbTIRuGQLAeDwu92GVMJ+guAWe02KByHJK?= =?us-ascii?Q?w1htMWTBTIkJDmr1S+P/Feqo1hwH2zSdxgUTRIR+OzOgaTsI79qIQwx5JCtT?= =?us-ascii?Q?5Lc/2619TUQ0j3Fya1qKglti1L0llWYvbrqCh0ybwEzOTSxSjCZG394T3mo4?= =?us-ascii?Q?g41TQSuSjxuFGFZ8hSnqN+lkNMsmo6BtPBkGad6FG/OsonI4oHyYMb0urE55?= =?us-ascii?Q?PWR7Ib3rjzuLFMqWsyZZJ2UGEVJPC3xalxzjdrBv4PHRO7FYMpTwQGI0sSY9?= =?us-ascii?Q?Do9XovmgoU7eh2eIA5h3Pw5RlVgTMe5OiZXBqgGUQwVlWd5vNKCy0whSUojs?= =?us-ascii?Q?TfFiSOrczXolk4GvYrms/dnsPdyIZ4+rF2YKGHDxCe1COV98m2QAcmuc8CKQ?= =?us-ascii?Q?2CgN9xKL3HuGYUrYVdqny7eT6o6BGZ+GbnN606Zn11gT8LBy4fUKC2txxPZi?= =?us-ascii?Q?b6pnia+URj650qs11xPtmoQ2wwspOJ3N1lKkHkGb68Ys0kmtLwaUKc8qxgRi?= =?us-ascii?Q?rDsteTui19MTmWyoiwoeACDnGqjf9qSVDprhVILEQPBtCneBSs+jDGnRMoI6?= =?us-ascii?Q?+qElfRy6C802HVSDj4cD4vYMEPY9FpNL2s0G0UrBexNjqcOX6AxY9yjHj/gF?= =?us-ascii?Q?HUrIzTXdV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aNEH1cnezj+ENxMwQeL4C+mizfUoVYr4iQVW2Rt1CThYjw19x4W5oFljevPvS0VP+EdeZtJrPH1gRm/5qa1DRwxm+jinn0G SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 20:33:32.5685 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e13133f9-f66a-4a17-95f2-08d54e324369 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 Max boundary for exchange off load is 32k exchanges. If a system is unable to allocate large memory buffer to support this feature, then driver will reduce the number of exchanges down to a value system can support. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_def.h | 3 +++ drivers/scsi/qla2xxx/qla_os.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 969a7dee9f72..043dd51a2760 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -288,6 +288,8 @@ struct name_list_extended { #define ATIO_ENTRY_CNT_24XX 4096 /* Number of ATIO entries. */ #define RESPONSE_ENTRY_CNT_FX00 256 /* Number of response entries.*/ #define FW_DEF_EXCHANGES_CNT 2048 +#define FW_MAX_EXCHANGES_CNT (32 * 1024) +#define REDUCE_EXCHANGES_CNT (8 * 1024) struct req_que; struct qla_tgt_sess; @@ -3506,6 +3508,7 @@ struct qla_hw_data { uint32_t using_lr_setting:1; } flags; + uint16_t max_exchg; uint16_t long_range_distance; /* 32G & above */ #define LR_DISTANCE_5K 1 #define LR_DISTANCE_10K 0 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 987bade1c606..029b95b2bd8a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2789,6 +2789,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->init_cb_size = sizeof(init_cb_t); ha->link_data_rate = PORT_SPEED_UNKNOWN; ha->optrom_size = OPTROM_SIZE_2300; + ha->max_exchg = FW_MAX_EXCHANGES_CNT; /* Assign ISP specific operations. */ if (IS_QLA2100(ha)) { @@ -4230,6 +4231,9 @@ qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) u32 temp; *ret_cnt = FW_DEF_EXCHANGES_CNT; + if (max_cnt > vha->hw->max_exchg) + max_cnt = vha->hw->max_exchg; + if (qla_ini_mode_enabled(vha)) { if (ql2xiniexchg > max_cnt) ql2xiniexchg = max_cnt; @@ -4259,8 +4263,8 @@ int qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) { int rval; - u16 size, max_cnt; - u32 temp; + u16 size, max_cnt; + u32 actual_cnt, totsz; struct qla_hw_data *ha = vha->hw; if (!ha->flags.exchoffld_enabled) @@ -4277,16 +4281,19 @@ qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) return rval; } - qla2x00_number_of_exch(vha, &temp, max_cnt); - temp *= size; + qla2x00_number_of_exch(vha, &actual_cnt, max_cnt); + ql_log(ql_log_info, vha, 0xd014, + "Actual exchange offload count: %d.\n", actual_cnt); + + totsz = actual_cnt * size; - if (temp != ha->exchoffld_size) { + if (totsz != ha->exchoffld_size) { qla2x00_free_exchoffld_buffer(ha); - ha->exchoffld_size = temp; + ha->exchoffld_size = totsz; ql_log(ql_log_info, vha, 0xd016, - "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", - max_cnt, size, temp); + "Exchange offload: max_count=%d, actual count=%d entry sz=0x%x, total sz=0x%x\n", + max_cnt, actual_cnt, size, totsz); ql_log(ql_log_info, vha, 0xd017, "Exchange Buffers requested size = 0x%x\n", @@ -4297,7 +4304,21 @@ qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); if (!ha->exchoffld_buf) { ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, - "Failed to allocate memory for exchoffld_buf_dma.\n"); + "Failed to allocate memory for Exchange Offload.\n"); + + if (ha->max_exchg > + (FW_DEF_EXCHANGES_CNT + REDUCE_EXCHANGES_CNT)) { + ha->max_exchg -= REDUCE_EXCHANGES_CNT; + } else if (ha->max_exchg > + (FW_DEF_EXCHANGES_CNT + 512)) { + ha->max_exchg -= 512; + } else { + ha->flags.exchoffld_enabled = 0; + ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, + "Disabling Exchange offload due to lack of memory\n"); + } + ha->exchoffld_size = 0; + return -ENOMEM; } }