From patchwork Wed Dec 20 06:56:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10125055 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 E80EC6019C for ; Wed, 20 Dec 2017 06:57:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE36829649 for ; Wed, 20 Dec 2017 06:57:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D31962964F; Wed, 20 Dec 2017 06:57: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 37C4F29649 for ; Wed, 20 Dec 2017 06:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932405AbdLTG5H (ORCPT ); Wed, 20 Dec 2017 01:57:07 -0500 Received: from mail-dm3nam03on0074.outbound.protection.outlook.com ([104.47.41.74]:62022 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932344AbdLTG5C (ORCPT ); Wed, 20 Dec 2017 01:57:02 -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=+ZG/SZ8XDfjZq57yRDNH4nDWpsHF9nftHuZnhtXhCzM=; b=b4bZ3844XAxRK+SM20HCMyWiw8q7+Ed7l5nuVd76FnRNoq+JCwKv5XfMm3AQoAZBPWj4QnosYsPNRCOMBmoW72VQ6hU+7pLLfXKT0og0yYfoK6PubWg0C2NXoAdMy16vX9HErj/j9ObEyZhddtcIDc/FkNww9qshyiv/2YAtc6Q= Received: from SN4PR0701CA0005.namprd07.prod.outlook.com (2603:10b6:803:28::15) by MWHPR0701MB3819.namprd07.prod.outlook.com (2603:10b6:301:7f::24) 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:00 +0000 Received: from BN1AFFO11FD027.protection.gbl (2a01:111:f400:7c10::114) by SN4PR0701CA0005.outlook.office365.com (2603:10b6:803:28::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Wed, 20 Dec 2017 06:57: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 BN1AFFO11FD027.mail.protection.outlook.com (10.58.52.87) 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:47 +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:45 -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 vBK6uksI021566; Tue, 19 Dec 2017 22:56:46 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id vBK6ukkE021565; Tue, 19 Dec 2017 22:56:46 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 05/43] qla2xxx: Add boundary checks for exchanges to be offloaded Date: Tue, 19 Dec 2017 22:56:06 -0800 Message-ID: <20171220065644.21511-6-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)(346002)(39380400002)(396003)(39860400002)(376002)(2980300002)(448002)(189003)(199004)(47776003)(5660300001)(8936002)(478600001)(4326008)(72206003)(106466001)(87636003)(50226002)(356003)(81156014)(8676002)(81166006)(69596002)(51416003)(80596001)(305945005)(76176011)(48376002)(1076002)(2906002)(316002)(54906003)(110136005)(42186006)(36756003)(16586007)(2950100002)(6666003)(50466002)(86362001)(85326001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR0701MB3819; 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; BN1AFFO11FD027; 1:5pksuh/kAfOkDWTXCsebReimX7yweXXnF32w6tQdpM086e7oLFNraIKNTqgdWlJqp2ft2IlLmXmyw4B/8RPPDh6G9GcC142ByM1Ew3EZwY6z+vNuL0hU+5z+vqrsF/5u X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db37a6b9-fb53-4268-8e2f-08d54776d69f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR0701MB3819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=; 20:3VsxMOO7eGeZi8+6cWqJI7Ni3rS+P2gnO+kS/nPNp3sdDYZWJEaH915tL4mRx3SYN5SMXgkWhYvNwUCed8rBA4HI422C7sN0j7jBHVvqdTxSLc4nS9e77U4iyNLAD445fzEpKkrUnghpwdJyI/qDAHbTqgssWdSKr86kzz5xOpCyYls9GfW4ADDOVNhV+Q4tuOmRKY5rz5aM977GysSidw6Jwsjfopm8RpwQlbyWRMByta33DqnAEFmsIcTbtGbT5yiszUUWvC+CvYWzBfcyUeJ8zmfwUVDUkM2btAgaVU/uuZ3Hm1aMzz66BlSO5xUl8rxRNh3gYcPOp4gLchkcpXs+T53fNI5BEEKUH+XBDBOoF44KQ4MtNw3yGBaf+wBW2D3sWCye6GWAU7IijFQsF5/1358jVu5rsVA2poI2/rYHMDP7LYoCAH2pXy3g/i/Tec+cgUqRN+qRzL21vQkw24XCZq8gIKlKXzPnce0oTX/BeKkDB5k/AZvd8JG2YfnG 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)(3231023)(93006095)(93001095)(10201501046)(3002001)(6041268)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:MWHPR0701MB3819; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR0701MB3819; X-Microsoft-Exchange-Diagnostics: 1; MWHPR0701MB3819; 4:dpCp3vpcAdqn6kexizFNdF8ChQeswfaY58+lNa2iFlF2/LbHvKfSySShpHqcq9toT3fPHs0FQJdk/nbulLABkTTS6e3W0fyplvCxhX0lLPtzI41x/VEjXy053kulKi4ECy6Hm5tIaN9iUUKV+eRYkK1dr8EhzH2yei59W9myScpjR/2K0DJTy0yKqcXYcpYBRBLL12aXNwsGJwLz9mQr1wN3LSP8ih4Dv4lSKmzrVm/Y3mJGDnMVD61wNal4PKsMTmNOKz3L1MynXOCAgafdaw== X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR0701MB3819; 23:E9vkNJXV6wXeSraHbqQmrit9ePVxWQbeGd2rjIH?= =?us-ascii?Q?cMR3BzCelUxuqaG6HWtUWszhQZZRmB9+pKcuWD5YMaSXL0XSEh106xdHw3wn?= =?us-ascii?Q?GpkfDd8aNHGEOEZgSkA0hFs1hJcNm88qz6HS7rDxk9ROKilFgKyt8aYcpDot?= =?us-ascii?Q?o7jeLVjsqUJ4NC4CiKdXX46iQO9rPBCYvwRCHzSPUO8Yx2ZlHvoGs6W6APr9?= =?us-ascii?Q?wxGU0lK45js1Vv7gpzCpjMzOHRRlLMOZTVfjCasNqiROACbkdx1V70B0mcy9?= =?us-ascii?Q?wDkt2inZDMDDFky6ZkWZI2RQeKy5y1J0nt6JshSTUYCe/U5aV00nWRNUjg/X?= =?us-ascii?Q?2RSYdeBR1zyuCy3BKYQAkSKO03KXeU30Xpa9xnB8qGh0vopsyFT4v3ZSiinO?= =?us-ascii?Q?gxt+70SotBW34LVBnOCvqIjsAZtFWxZkuBCE3Zsew3kJDp/m47QFK7hbmZTU?= =?us-ascii?Q?m55rYvNL+hgEQgWoFTox+AzF5+yad0IWd3CMwRoa1t8R4vDOinhcrD6l6uMP?= =?us-ascii?Q?3tL8rCk6mMUyboOwkDKONE39evih3WOrnrIWll8VH3Tld88MTouCBrxeOp6k?= =?us-ascii?Q?Ze01XwJliau/s8bH1+IL5BC84OIFqiEQPIXJLNml1kcRyfeY0dT64gMESmiV?= =?us-ascii?Q?2VhQ6SPQNwiWndJ0e5bL6UNOiNLKTBE8xSdpvwdEtZ+5spA4y78uJNExJCHe?= =?us-ascii?Q?6PVFVfIYkU+at5BQ7j+7FCdwAidiuC0ckrHa/sQOrUpjR1jjyseJ35+wB1hh?= =?us-ascii?Q?SIOuOKZ1C+FJSnN8d+LypIIUo6MXKR+AUXlGu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ZCiS2AKZ3vBHOUW6j4SEAy5njNremwVNuN5oRT0eOiI+JfrC2jjhIYafTzY/zKxXsdTCIju8WWbT+es/oMbDYWv3t5lLAQn7pApXepChl3Kp+EfKw5c6AP0JYhPj8IJcu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 06:56:47.1855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: db37a6b9-fb53-4268-8e2f-08d54776d69f 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: MWHPR0701MB3819 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 system is unable to allocate large memory buffer to support this feature, then driver will reduce the number 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 50a570595969..ca3ef9360ab9 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; @@ -3542,6 +3544,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; } }