From nobody Mon Apr 6 17:07:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AC5AECAAA1 for ; Tue, 6 Sep 2022 09:15:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239612AbiIFJP3 (ORCPT ); Tue, 6 Sep 2022 05:15:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234359AbiIFJPH (ORCPT ); Tue, 6 Sep 2022 05:15:07 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F4A218366; Tue, 6 Sep 2022 02:15:01 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MMKRj2sbGzrSH0; Tue, 6 Sep 2022 17:13:05 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 17:14:58 +0800 Received: from localhost.localdomain (10.69.192.56) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 17:14:58 +0800 From: Guangbin Huang To: , CC: , , , , , , Subject: [PATCH V2 net-next 3/5] net: hns3: debugfs add dump dscp map info Date: Tue, 6 Sep 2022 17:12:21 +0800 Message-ID: <20220906091223.46142-4-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220906091223.46142-1-huangguangbin2@huawei.com> References: <20220906091223.46142-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch add dump the map relation for dscp, priority and TC, and the current tc map mode. Signed-off-by: Guangbin Huang --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + .../ethernet/hisilicon/hns3/hns3_debugfs.c | 7 +++ .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 60 ++++++++++++++++++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethe= rnet/hisilicon/hns3/hnae3.h index 33b5ac47f342..9ae094189d3a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -272,6 +272,7 @@ enum hnae3_dbg_cmd { HNAE3_DBG_CMD_TC_SCH_INFO, HNAE3_DBG_CMD_QOS_PAUSE_CFG, HNAE3_DBG_CMD_QOS_PRI_MAP, + HNAE3_DBG_CMD_QOS_DSCP_MAP, HNAE3_DBG_CMD_QOS_BUF_CFG, HNAE3_DBG_CMD_DEV_INFO, HNAE3_DBG_CMD_TX_BD, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/n= et/ethernet/hisilicon/hns3/hns3_debugfs.c index 93aeb615191d..0f8f5c466871 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -105,6 +105,13 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] =3D { .buf_len =3D HNS3_DBG_READ_LEN, .init =3D hns3_dbg_common_file_init, }, + { + .name =3D "qos_dscp_map", + .cmd =3D HNAE3_DBG_CMD_QOS_DSCP_MAP, + .dentry =3D HNS3_DBG_DENTRY_TM, + .buf_len =3D HNS3_DBG_READ_LEN, + .init =3D hns3_dbg_common_file_init, + }, { .name =3D "qos_buf_cfg", .cmd =3D HNAE3_DBG_CMD_QOS_BUF_CFG, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/d= rivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 59121767a853..55f696d071e5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -14,6 +14,8 @@ static const char * const hclge_mac_state_str[] =3D { "TO_ADD", "TO_DEL", "ACTIVE" }; =20 +static const char * const tc_map_mode_str[] =3D { "PRIO", "DSCP" }; + static const struct hclge_dbg_reg_type_info hclge_dbg_reg_info[] =3D { { .cmd =3D HNAE3_DBG_CMD_REG_BIOS_COMMON, .dfx_msg =3D &hclge_dbg_bios_common_reg[0], @@ -1115,10 +1117,11 @@ static int hclge_dbg_dump_qos_pause_cfg(struct hclg= e_dev *hdev, char *buf, return 0; } =20 +#define HCLGE_DBG_TC_MASK 0x0F + static int hclge_dbg_dump_qos_pri_map(struct hclge_dev *hdev, char *buf, int len) { -#define HCLGE_DBG_TC_MASK 0x0F #define HCLGE_DBG_TC_BIT_WIDTH 4 =20 struct hclge_qos_pri_map_cmd *pri_map; @@ -1152,6 +1155,57 @@ static int hclge_dbg_dump_qos_pri_map(struct hclge_d= ev *hdev, char *buf, return 0; } =20 +static int hclge_dbg_dump_qos_dscp_map(struct hclge_dev *hdev, char *buf, + int len) +{ + struct hclge_desc desc[HCLGE_DSCP_MAP_TC_BD_NUM]; + u8 *req0 =3D (u8 *)desc[0].data; + u8 *req1 =3D (u8 *)desc[1].data; + u8 dscp_tc[HCLGE_MAX_DSCP]; + int pos, ret; + u8 i, j; + + pos =3D scnprintf(buf, len, "tc map mode: %s\n", + tc_map_mode_str[hdev->vport[0].nic.kinfo.tc_map_mode]); + + if (hdev->vport[0].nic.kinfo.tc_map_mode !=3D HNAE3_TC_MAP_MODE_DSCP) + return 0; + + hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_QOS_MAP, true); + desc[0].flag |=3D cpu_to_le16(HCLGE_COMM_CMD_FLAG_NEXT); + hclge_cmd_setup_basic_desc(&desc[1], HCLGE_OPC_QOS_MAP, true); + ret =3D hclge_cmd_send(&hdev->hw, desc, HCLGE_DSCP_MAP_TC_BD_NUM); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed to dump qos dscp map, ret =3D %d\n", ret); + return ret; + } + + pos +=3D scnprintf(buf + pos, len - pos, "\nDSCP PRIO TC\n"); + + /* The low 32 dscp setting use bd0, high 32 dscp setting use bd1 */ + for (i =3D 0; i < HCLGE_MAX_DSCP / HCLGE_DSCP_MAP_TC_BD_NUM; i++) { + j =3D i + HCLGE_MAX_DSCP / HCLGE_DSCP_MAP_TC_BD_NUM; + /* Each dscp setting has 4 bits, so each byte saves two dscp + * setting + */ + dscp_tc[i] =3D req0[i >> 1] >> HCLGE_DSCP_TC_SHIFT(i); + dscp_tc[j] =3D req1[i >> 1] >> HCLGE_DSCP_TC_SHIFT(i); + dscp_tc[i] &=3D HCLGE_DBG_TC_MASK; + dscp_tc[j] &=3D HCLGE_DBG_TC_MASK; + } + + for (i =3D 0; i < HCLGE_MAX_DSCP; i++) { + if (hdev->tm_info.dscp_prio[i] =3D=3D HCLGE_PRIO_ID_INVALID) + continue; + + pos +=3D scnprintf(buf + pos, len - pos, " %2u %u %u\n", + i, hdev->tm_info.dscp_prio[i], dscp_tc[i]); + } + + return 0; +} + static int hclge_dbg_dump_tx_buf_cfg(struct hclge_dev *hdev, char *buf, in= t len) { struct hclge_tx_buff_alloc_cmd *tx_buf_cmd; @@ -2376,6 +2430,10 @@ static const struct hclge_dbg_func hclge_dbg_cmd_fun= c[] =3D { .cmd =3D HNAE3_DBG_CMD_QOS_PRI_MAP, .dbg_dump =3D hclge_dbg_dump_qos_pri_map, }, + { + .cmd =3D HNAE3_DBG_CMD_QOS_DSCP_MAP, + .dbg_dump =3D hclge_dbg_dump_qos_dscp_map, + }, { .cmd =3D HNAE3_DBG_CMD_QOS_BUF_CFG, .dbg_dump =3D hclge_dbg_dump_qos_buf_cfg, --=20 2.33.0