From nobody Tue Oct 7 07:18:18 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 E856022A4CC; Mon, 14 Jul 2025 06:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473887; cv=none; b=FLh+4H7Pb1mlO2gqzE0S4s1ENbeH+gx/bBJ2XQp7hMi7yH1Uq4yORVmQopPf1c2HAVcBJB8ak8mZC/zRmc2rCw+kbNJpODepDGmxSnbV/zt59dm8Ij/fS6J2pSb/n+H3PjGS1C+TdsxruFfO5rHE+03N3I69jYundxwmTblb4xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752473887; c=relaxed/simple; bh=WFu6NGQubLZGzt3GTkvErn371U+aBhnkHBWaz2JHaCY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Pf74atkmox3a86IEcHlR2Jp7t5q5TECEfu9+r913LbJ1AAjvRztQvAvnSu2Ht7SETeKa0qtZyLhiMicRiJepUjYoru9NJRvMLSI9I6+m/rliHvYOni6PQVHCmKUrKrHQ1SF2BsND+d1kBd7kOI6TNA3achvVcjb9Spha3JCOtXY= 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.187 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.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4bgX9Y15qMz13Mmc; Mon, 14 Jul 2025 14:15:13 +0800 (CST) Received: from kwepemk100013.china.huawei.com (unknown [7.202.194.61]) by mail.maildlp.com (Postfix) with ESMTPS id 4476B1402F0; Mon, 14 Jul 2025 14:17:58 +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; Mon, 14 Jul 2025 14:17:57 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , , , Subject: [PATCH V3 net-next 06/10] net: hns3: use seq_file for files in mac_list/ in debugfs Date: Mon, 14 Jul 2025 14:10:33 +0800 Message-ID: <20250714061037.2616413-7-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250714061037.2616413-1-shaojijie@huawei.com> References: <20250714061037.2616413-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: kwepems500001.china.huawei.com (7.221.188.70) 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 Acked-by: Arnd Bergmann --- .../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 61a5ae95f313..1fecfeeff93d 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