From nobody Tue Oct 7 18:23:15 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBAC7283FE5; Tue, 8 Jul 2025 13:08:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751980084; cv=none; b=bSelA22IVgyrEOuTg2bc1++AtRjEO68Du98xCiTiZURvxuH9N+rLawYtpobnfhcYHxHntW3c2w29YBVxEvqYnIMBdD7XcBdpFadyJvc1OpDmTlkBjnoHIEBDdrNLt3AtwmGjbf5HAIkAC0HqJ+/5vRnjxKqK/dzZAcM5zKvVizw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751980084; c=relaxed/simple; bh=+QIK93mCGjd8myr45mJmnACdf9QWPu0zAa6IPrcCp0I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A9RKnV8q3+QHMO14vnhgfIPWPYlkXg7kb2YvxVqBy2+fNpP1fXkiUOfj8FqSmaTIgpl9wr8Wu+VWQBsPFqR1V84tXcs9hnFQ8WL8YKljqPiExVpSdRkHcLrS6GnGT+DlAqAfvV1Y13skWWpS5gppFMZ/j1C/GaVfOBAHXiyd8JY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bc1WV0ZTJzWfxX; Tue, 8 Jul 2025 21:03:34 +0800 (CST) Received: from kwepemk100013.china.huawei.com (unknown [7.202.194.61]) by mail.maildlp.com (Postfix) with ESMTPS id 72046140156; Tue, 8 Jul 2025 21:07:59 +0800 (CST) Received: from localhost.localdomain (10.90.31.46) by kwepemk100013.china.huawei.com (7.202.194.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 8 Jul 2025 21:07:58 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , , , Subject: [PATCH net-next 06/11] net: hns3: use seq_file for files in mac_list/ in debugfs Date: Tue, 8 Jul 2025 21:00:24 +0800 Message-ID: <20250708130029.1310872-7-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250708130029.1310872-1-shaojijie@huawei.com> References: <20250708130029.1310872-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemk100013.china.huawei.com (7.202.194.61) Content-Type: text/plain; charset="utf-8" From: Yonglong Liu This patch use seq_file for the following nodes: uc/mc Signed-off-by: Yonglong Liu Signed-off-by: Jijie Shao Reviewed-by: Andrew Lunn --- .../ethernet/hisilicon/hns3/hns3_debugfs.c | 4 +- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 57 ++++++------------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/n= et/ethernet/hisilicon/hns3/hns3_debugfs.c index e687e47393e4..b6b3eb2f5652 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -149,14 +149,14 @@ static struct hns3_dbg_cmd_info hns3_dbg_cmd[] =3D { .cmd =3D HNAE3_DBG_CMD_MAC_UC, .dentry =3D HNS3_DBG_DENTRY_MAC, .buf_len =3D HNS3_DBG_READ_LEN_128KB, - .init =3D hns3_dbg_common_file_init, + .init =3D hns3_dbg_common_init_t2, }, { .name =3D "mc", .cmd =3D HNAE3_DBG_CMD_MAC_MC, .dentry =3D HNS3_DBG_DENTRY_MAC, .buf_len =3D HNS3_DBG_READ_LEN, - .init =3D hns3_dbg_common_file_init, + .init =3D hns3_dbg_common_init_t2, }, { .name =3D "mng_tbl", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/d= rivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index e5a5680c2088..29c842d3f184 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -2482,50 +2482,29 @@ hclge_dbg_dump_mac_tnl_status(struct hclge_dev *hde= v, char *buf, int len) return 0; } =20 - -static const struct hclge_dbg_item mac_list_items[] =3D { - { "FUNC_ID", 2 }, - { "MAC_ADDR", 12 }, - { "STATE", 2 }, -}; - -static void hclge_dbg_dump_mac_list(struct hclge_dev *hdev, char *buf, int= len, - bool is_unicast) +static void hclge_dbg_dump_mac_list(struct seq_file *s, bool is_unicast) { - char data_str[ARRAY_SIZE(mac_list_items)][HCLGE_DBG_DATA_STR_LEN]; - char content[HCLGE_DBG_INFO_LEN], str_id[HCLGE_DBG_ID_LEN]; - char *result[ARRAY_SIZE(mac_list_items)]; + struct hclge_dev *hdev =3D hclge_seq_file_to_hdev(s); struct hclge_mac_node *mac_node, *tmp; struct hclge_vport *vport; struct list_head *list; - u32 func_id, i; - int pos =3D 0; + u32 func_id; =20 - for (i =3D 0; i < ARRAY_SIZE(mac_list_items); i++) - result[i] =3D &data_str[i][0]; - - pos +=3D scnprintf(buf + pos, len - pos, "%s MAC_LIST:\n", - is_unicast ? "UC" : "MC"); - hclge_dbg_fill_content(content, sizeof(content), mac_list_items, - NULL, ARRAY_SIZE(mac_list_items)); - pos +=3D scnprintf(buf + pos, len - pos, "%s", content); + seq_printf(s, "%s MAC_LIST:\n", is_unicast ? "UC" : "MC"); + seq_puts(s, "FUNC_ID MAC_ADDR STATE\n"); =20 for (func_id =3D 0; func_id < hdev->num_alloc_vport; func_id++) { vport =3D &hdev->vport[func_id]; list =3D is_unicast ? &vport->uc_mac_list : &vport->mc_mac_list; spin_lock_bh(&vport->mac_list_lock); list_for_each_entry_safe(mac_node, tmp, list, node) { - i =3D 0; - result[i++] =3D hclge_dbg_get_func_id_str(str_id, - func_id); - sprintf(result[i++], "%pM", mac_node->mac_addr); - sprintf(result[i++], "%5s", - hclge_mac_state_str[mac_node->state]); - hclge_dbg_fill_content(content, sizeof(content), - mac_list_items, - (const char **)result, - ARRAY_SIZE(mac_list_items)); - pos +=3D scnprintf(buf + pos, len - pos, "%s", content); + if (func_id) + seq_printf(s, "vf%-7u", func_id - 1U); + else + seq_puts(s, "pf "); + seq_printf(s, "%pM ", mac_node->mac_addr); + seq_printf(s, "%5s\n", + hclge_mac_state_str[mac_node->state]); } spin_unlock_bh(&vport->mac_list_lock); } @@ -2893,16 +2872,16 @@ static int hclge_dbg_dump_ptp_info(struct hclge_dev= *hdev, char *buf, int len) return 0; } =20 -static int hclge_dbg_dump_mac_uc(struct hclge_dev *hdev, char *buf, int le= n) +static int hclge_dbg_dump_mac_uc(struct seq_file *s, void *data) { - hclge_dbg_dump_mac_list(hdev, buf, len, true); + hclge_dbg_dump_mac_list(s, true); =20 return 0; } =20 -static int hclge_dbg_dump_mac_mc(struct hclge_dev *hdev, char *buf, int le= n) +static int hclge_dbg_dump_mac_mc(struct seq_file *s, void *data) { - hclge_dbg_dump_mac_list(hdev, buf, len, false); + hclge_dbg_dump_mac_list(s, false); =20 return 0; } @@ -2954,11 +2933,11 @@ static const struct hclge_dbg_func hclge_dbg_cmd_fu= nc[] =3D { }, { .cmd =3D HNAE3_DBG_CMD_MAC_UC, - .dbg_dump =3D hclge_dbg_dump_mac_uc, + .dbg_read_func =3D hclge_dbg_dump_mac_uc, }, { .cmd =3D HNAE3_DBG_CMD_MAC_MC, - .dbg_dump =3D hclge_dbg_dump_mac_mc, + .dbg_read_func =3D hclge_dbg_dump_mac_mc, }, { .cmd =3D HNAE3_DBG_CMD_MNG_TBL, --=20 2.33.0