From patchwork Fri May 12 09:22:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 93022 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4961863vqo; Fri, 12 May 2023 02:25:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7azxHxiSJ8pmlOJlASx4gLiJW+rzJjQmRBVwVXUNYm+X5fhWmwzq7wWd+SsQ6iR9qDwRYX X-Received: by 2002:a05:6a20:ce43:b0:f0:718f:8eee with SMTP id id3-20020a056a20ce4300b000f0718f8eeemr25407733pzb.59.1683883526473; Fri, 12 May 2023 02:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683883526; cv=none; d=google.com; s=arc-20160816; b=T13m7rZsxQGGm9/POV/ZdBUrbagmGAWHRxRV9eeS/dvuLY8uLBfaSVPe6fWSNtMHZo ooBLogKsSp5bPE0K9eaSPM1vQ2M5TO33CFQJvuB+e+/0jCj1zew9csLzWfL08e1Z0iSj 5PG4MigaNkUrkH6Dz4tdwEjc8J+U65AZWX0VrSQeY1qm5RYhvpTm9nBVqqmU0A/zqRn0 G65DAvihYkT2BOtO1d/4VgRLrcBdl/2ERNsDsWTaQNUeAbVwYUsxE4Xwr1wVYIiiRXO0 WZ4PFqW4lQdbA9skXPVLQjO03vYkrH5jeRCyyqukOtQBz7YSjt+ZPnJFFlEypAnHu49/ Fx7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Hb8Cvt2A0RJd0oqN0wynZE4uSlZMqfHHTuwvbyX5KUY=; b=JAu9eira3E3WWO+5ed+RQ2/mrTWYtlvsJ1PQmlQ4Vui8/0EdStFiJmEXFDtX+tdhr5 gzwPY9M2PcPlItCJVNvb525le1XtBrQFlvdljRQse0Qx4VlBsFToE+eomZQ1DuLJIiJL 9vr6ILEJK9OULuaz4wfrqYMgDeIvQ8gnTfQJY2nxg+C+YunsUUXQJfYBT9MAPIMz5iFf VxZ5fZRh8N22GKMNW8Ah9A27ZQMOEI1eM4qlPCTnGjrWS9rMoSYJmIJqvW4GMUk9JJ2S vObf5pk/vYIWvwWqgcNHM/w8d4mRT8VNqxzNQ/TR4cWI/hs82pxdMcBoFAJQo8wVZ6H1 Y4uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020aa78427000000b00648d7d58346si5241788pfn.332.2023.05.12.02.25.12; Fri, 12 May 2023 02:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240407AbjELJYv (ORCPT + 99 others); Fri, 12 May 2023 05:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240275AbjELJYs (ORCPT ); Fri, 12 May 2023 05:24:48 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E869DE72B; Fri, 12 May 2023 02:24:46 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QHjsJ1T2wzTkd5; Fri, 12 May 2023 17:20:04 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 12 May 2023 17:24:44 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 1/3] RDMA/hns: Fix timeout attr in query qp for HIP08 Date: Fri, 12 May 2023 17:22:43 +0800 Message-ID: <20230512092245.344442-2-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230512092245.344442-1-huangjunxian6@hisilicon.com> References: <20230512092245.344442-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765679852757281227?= X-GMAIL-MSGID: =?utf-8?q?1765679852757281227?= From: Chengchang Tang On HIP08, the queried timeout attr is different from the timeout attr configured by the user. It is found by rdma-core testcase test_rdmacm_async_traffic: ====================================================================== FAIL: test_rdmacm_async_traffic (tests.test_rdmacm.CMTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "./tests/test_rdmacm.py", line 33, in test_rdmacm_async_traffic self.two_nodes_rdmacm_traffic(CMAsyncConnection, self.rdmacm_traffic, File "./tests/base.py", line 382, in two_nodes_rdmacm_traffic raise(res) AssertionError Fixes: 926a01dc000d ("RDMA/hns: Add QP operations support for hip08 SoC") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 17 ++++++++++++++--- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 84f1167de1d9..3a1c90406ed9 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -5012,7 +5012,6 @@ static int hns_roce_v2_set_abs_fields(struct ib_qp *ibqp, static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout) { #define QP_ACK_TIMEOUT_MAX_HIP08 20 -#define QP_ACK_TIMEOUT_OFFSET 10 #define QP_ACK_TIMEOUT_MAX 31 if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) { @@ -5021,7 +5020,7 @@ static bool check_qp_timeout_cfg_range(struct hns_roce_dev *hr_dev, u8 *timeout) "local ACK timeout shall be 0 to 20.\n"); return false; } - *timeout += QP_ACK_TIMEOUT_OFFSET; + *timeout += HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08; } else if (hr_dev->pci_dev->revision > PCI_REVISION_ID_HIP08) { if (*timeout > QP_ACK_TIMEOUT_MAX) { ibdev_warn(&hr_dev->ib_dev, @@ -5307,6 +5306,18 @@ static int hns_roce_v2_query_qpc(struct hns_roce_dev *hr_dev, u32 qpn, return ret; } +static u8 get_qp_timeout_attr(struct hns_roce_dev *hr_dev, + struct hns_roce_v2_qp_context *context) +{ + u8 timeout; + + timeout = (u8)hr_reg_read(context, QPC_AT); + if (hr_dev->pci_dev->revision == PCI_REVISION_ID_HIP08) + timeout -= HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08; + + return timeout; +} + static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr) @@ -5384,7 +5395,7 @@ static int hns_roce_v2_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, qp_attr->max_dest_rd_atomic = 1 << hr_reg_read(&context, QPC_RR_MAX); qp_attr->min_rnr_timer = (u8)hr_reg_read(&context, QPC_MIN_RNR_TIME); - qp_attr->timeout = (u8)hr_reg_read(&context, QPC_AT); + qp_attr->timeout = get_qp_timeout_attr(hr_dev, &context); qp_attr->retry_cnt = hr_reg_read(&context, QPC_RETRY_NUM_INIT); qp_attr->rnr_retry = hr_reg_read(&context, QPC_RNR_NUM_INIT); diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h index 1b44d2434ab4..7033eae2407c 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h @@ -44,6 +44,8 @@ #define HNS_ROCE_V2_MAX_XRCD_NUM 0x1000000 #define HNS_ROCE_V2_RSV_XRCD_NUM 0 +#define HNS_ROCE_V2_QP_ACK_TIMEOUT_OFS_HIP08 10 + #define HNS_ROCE_V3_SCCC_SZ 64 #define HNS_ROCE_V3_GMV_ENTRY_SZ 32 From patchwork Fri May 12 09:22:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 93038 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4969714vqo; Fri, 12 May 2023 02:43:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6vaCEun+COh968ju+Qqv2lyGAVbAOSc3yUT4G2+HfqaunwrC7xmENAjED3E+QLUdZH/PQc X-Received: by 2002:a17:90b:3a8e:b0:24e:2f9c:ee5e with SMTP id om14-20020a17090b3a8e00b0024e2f9cee5emr25332405pjb.42.1683884619603; Fri, 12 May 2023 02:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683884619; cv=none; d=google.com; s=arc-20160816; b=0qqCgJXeDHNkvlh1AsK26lu9fmflGEqCkEoNKellnYZxVUhq3jd/gsBLdHZV/JQC8r Dt1XlxuS7dIjsPSqGWzrASZkU/Uat16Ghff2uucX+r6O8pXONnHufvMRCGW6FY1n1JUu xtHVl+c5VQPraWuWAHiFbziQOxmx0y5YGzSYABhjOeUobQd3qljYvIxMdi71jfwAj2A2 unCk4trdydwZVfMssZCNtWG1XkoW3lyWzz4N9cRK3wbUmQ31u9XTdKVDItGED+VgP64G 2cvqP7nth+OecwoQdThDASjzO+W1DxApty0Fm5clW8Fjao2uw5RhlQ09PzB46wKmS1+0 cc3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QLKILGdzlhRLwyrvUZKyPldxO3eGnkUU9fmv1j8XJ/4=; b=rCyLrp/DJ3aGL3uHvY9AMRy/6F+ky+xAsbYdDg/nnXBCc/m9Eyh3JvfCFpRZ57dzHt FdA1mN28BfI/QYlILGE3sd3l0YxGUJuH8xTUIg910vtfmiAflgWtKR4OcAxL8bbdvlMf TAqK9Agq48oZtcGdz+PRVd99fErU4z+UkrSvqOVtBoh5VM8Qcx7YER6elMHOku5KePRV UUHi+ZQLsDuX72to6fk7u+tjWuFeakva5i1AbNTyxhe9g3H3wlxUYVrQqanYom5Q0noE gEcsfX5f2hUrb1cx1HbD227k7JLcbUe9ZwEMSsOpEz9N8l09Nxe6GqIrfAMPdRji9dgd wWeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na3-20020a17090b4c0300b0024e1911ab42si28508322pjb.18.2023.05.12.02.43.27; Fri, 12 May 2023 02:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240442AbjELJY4 (ORCPT + 99 others); Fri, 12 May 2023 05:24:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240288AbjELJYt (ORCPT ); Fri, 12 May 2023 05:24:49 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB80100D2; Fri, 12 May 2023 02:24:47 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QHjxF6StmzpVYh; Fri, 12 May 2023 17:23:29 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 12 May 2023 17:24:45 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 2/3] RDMA/hns: Fix base address table allocation Date: Fri, 12 May 2023 17:22:44 +0800 Message-ID: <20230512092245.344442-3-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230512092245.344442-1-huangjunxian6@hisilicon.com> References: <20230512092245.344442-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765680998530513492?= X-GMAIL-MSGID: =?utf-8?q?1765680998530513492?= From: Chengchang Tang For hns, the specification of an entry like resource (E.g. WQE/CQE/EQE) depends on BT page size, buf page size and hopnum. For user mode, the buf page size depends on UMEM. Therefore, the actual specification is controlled by BT page size and hopnum. The current BT page size and hopnum are obtained from firmware. This makes the driver inflexible and introduces unnecessary constraints. Resource allocation failures occur in many scenarios. This patch will calculate whether the BT page size set by firmware is sufficient before allocating BT, and increase the BT page size if it is insufficient. Fixes: 1133401412a9 ("RDMA/hns: Optimize base address table config flow for qp buffer") Signed-off-by: Chengchang Tang Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_mr.c | 43 +++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 37a5cf62f88b..14376490ac22 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -33,6 +33,7 @@ #include #include +#include #include "hns_roce_device.h" #include "hns_roce_cmd.h" #include "hns_roce_hem.h" @@ -909,6 +910,44 @@ static int mtr_init_buf_cfg(struct hns_roce_dev *hr_dev, return page_cnt; } +static u64 cal_pages_per_l1ba(unsigned int ba_per_bt, unsigned int hopnum) +{ + return int_pow(ba_per_bt, hopnum - 1); +} + +static unsigned int cal_best_bt_pg_sz(struct hns_roce_dev *hr_dev, + struct hns_roce_mtr *mtr, + unsigned int pg_shift) +{ + unsigned long cap = hr_dev->caps.page_size_cap; + struct hns_roce_buf_region *re; + unsigned int pgs_per_l1ba; + unsigned int ba_per_bt; + unsigned int ba_num; + int i; + + for_each_set_bit_from(pg_shift, &cap, sizeof(cap) * BITS_PER_BYTE) { + if (!(BIT(pg_shift) & cap)) + continue; + + ba_per_bt = BIT(pg_shift) / BA_BYTE_LEN; + ba_num = 0; + for (i = 0; i < mtr->hem_cfg.region_count; i++) { + re = &mtr->hem_cfg.region[i]; + if (re->hopnum == 0) + continue; + + pgs_per_l1ba = cal_pages_per_l1ba(ba_per_bt, re->hopnum); + ba_num += DIV_ROUND_UP(re->count, pgs_per_l1ba); + } + + if (ba_num <= ba_per_bt) + return pg_shift; + } + + return 0; +} + static int mtr_alloc_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr, unsigned int ba_page_shift) { @@ -917,6 +956,10 @@ static int mtr_alloc_mtt(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr, hns_roce_hem_list_init(&mtr->hem_list); if (!cfg->is_direct) { + ba_page_shift = cal_best_bt_pg_sz(hr_dev, mtr, ba_page_shift); + if (!ba_page_shift) + return -ERANGE; + ret = hns_roce_hem_list_request(hr_dev, &mtr->hem_list, cfg->region, cfg->region_count, ba_page_shift); From patchwork Fri May 12 09:22:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Huang X-Patchwork-Id: 93023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4963561vqo; Fri, 12 May 2023 02:29:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4c9D7/ebBgHQzBhXx6BP/aZVRP+dK+qsA5rB4YCCSL64+QxIwPjIxojy0f76geDf6caSTr X-Received: by 2002:a05:6a20:8f22:b0:101:1e75:78e with SMTP id b34-20020a056a208f2200b001011e75078emr15028194pzk.14.1683883755791; Fri, 12 May 2023 02:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683883755; cv=none; d=google.com; s=arc-20160816; b=GMsCQy5iTYXOlu8Ice9jHNCeFYzAt90RqlXYGlLqfZ6/XUf6LYCu/DkQ24c93AWOSH d8hvQfYgqMfU3zF3TSyacEnqrcmf0jzynPTVmpucGUGXe04eovztVmImM5WLXMJj4crV B3T72d4maul3sO9PWqxrQSUIaC/ojhih4YGvXdEQfcF4oGqO1lbhwIWP+VgivnjiCB5Z cYbKeGzOLpKAsQr7+TnR/XkSijXSWdpocFkeUoVJsGSf8mQ/SWv9WkH33taLRXCv4T7P SSO6oYZciPJYCyJbypSXDS5vx1i7JyMKp1TrYEbTq7dLS8goDh7qoovkuha7wrdNNEhh ZDJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=keSj7gso6oNcPhnQregp1xwwMHcyfIERttnbPX4KvJ8=; b=petddvHZFBKPtq8uFDd1PXgIHMmWjksxQUd3o3Vllf9TpPZgKaw5M422NWF1/BbXtt ESLc29/7q+a6/S9OSTNRxReTfFe70mN4IpBdMEM0vEEV48lnrsigt8BZ8Z7VtKK7hiC4 00Jwtvpe99OiV0F3rbtGqoR9JZ92CF8pwoZoXXXNjDsyw/TdI3gJXyB+e5qOJLnjsxGN 09lyURkuHlVbySDNHDXuSxBfcdlG/DGmZA6uf9eT66CCSyGmV0L8SRAxjc1HNpmGRKeM h0PimTcmcNuCNl4Us44xj6VcZ+CB11SL5laUty8aUmvSy3WhH4IUof2TK3GqnZ9OAeIP e59A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o28-20020a637e5c000000b00513f15fed67si8677426pgn.517.2023.05.12.02.29.02; Fri, 12 May 2023 02:29:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240429AbjELJYy (ORCPT + 99 others); Fri, 12 May 2023 05:24:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240276AbjELJYs (ORCPT ); Fri, 12 May 2023 05:24:48 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DEB100DD; Fri, 12 May 2023 02:24:47 -0700 (PDT) Received: from kwepemi500006.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QHjsJ66SJzTkdb; Fri, 12 May 2023 17:20:04 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500006.china.huawei.com (7.221.188.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 12 May 2023 17:24:45 +0800 From: Junxian Huang To: , CC: , , , Subject: [PATCH for-rc 3/3] RDMA/hns: Modify the value of long message loopback slice Date: Fri, 12 May 2023 17:22:45 +0800 Message-ID: <20230512092245.344442-4-huangjunxian6@hisilicon.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230512092245.344442-1-huangjunxian6@hisilicon.com> References: <20230512092245.344442-1-huangjunxian6@hisilicon.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500006.china.huawei.com (7.221.188.68) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765680093007107655?= X-GMAIL-MSGID: =?utf-8?q?1765680093007107655?= From: Yangyang Li Long message loopback slice is used for achieving traffic balance between QPs. It prevents the problem that QPs with large traffic occupying the hardware pipeline for a long time and QPs with small traffic cannot be scheduled. Currently, its maximum value is set to 16K, which means only after a QP sends 16K will the second QP be scheduled. This value is too large, which will lead to unbalanced traffic scheduling, and thus it needs to be modified. The setting range of the long message loopback slice is modified to be from 1024 (the lower limit supported by hardware) to mtu. Actual testing shows that this value can significantly reduce error in hardware traffic scheduling. This solution is compatible with both HIP08 and HIP09. The modified lp_pktn_ini has a maximum value of 2 (when mtu is 256), so the range checking code for lp_pktn_ini is no longer necessary and needs to be deleted. Fixes: 0e60778efb07 ("RDMA/hns: Modify the value of MAX_LP_MSG_LEN to meet hardware compatibility") Signed-off-by: Yangyang Li Signed-off-by: Junxian Huang --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 3a1c90406ed9..d4c6b9bc0a4e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -4583,11 +4583,9 @@ static int modify_qp_init_to_rtr(struct ib_qp *ibqp, mtu = ib_mtu_enum_to_int(ib_mtu); if (WARN_ON(mtu <= 0)) return -EINVAL; -#define MAX_LP_MSG_LEN 16384 - /* MTU * (2 ^ LP_PKTN_INI) shouldn't be bigger than 16KB */ - lp_pktn_ini = ilog2(MAX_LP_MSG_LEN / mtu); - if (WARN_ON(lp_pktn_ini >= 0xF)) - return -EINVAL; +#define MIN_LP_MSG_LEN 1024 + /* mtu * (2 ^ lp_pktn_ini) should be in the range of 1024 to mtu */ + lp_pktn_ini = ilog2(max(mtu, MIN_LP_MSG_LEN) / mtu); if (attr_mask & IB_QP_PATH_MTU) { hr_reg_write(context, QPC_MTU, ib_mtu);