Commit 04d96139 authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: refine function hclge_dbg_dump_tm_pri()

To improve flexibility, simplicity and maintainability to dump info of
every element of tm priority, add a struct hclge_dbg_item array of tm
priority and fill string of every data according to this array.
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 161ad669
...@@ -926,26 +926,45 @@ static int hclge_dbg_dump_tm_nodes(struct hclge_dev *hdev, char *buf, int len) ...@@ -926,26 +926,45 @@ static int hclge_dbg_dump_tm_nodes(struct hclge_dev *hdev, char *buf, int len)
return 0; return 0;
} }
static const struct hclge_dbg_item tm_pri_items[] = {
{ "ID", 4 },
{ "MODE", 2 },
{ "DWRR", 2 },
{ "C_IR_B", 2 },
{ "C_IR_U", 2 },
{ "C_IR_S", 2 },
{ "C_BS_B", 2 },
{ "C_BS_S", 2 },
{ "C_FLAG", 2 },
{ "C_RATE(Mbps)", 2 },
{ "P_IR_B", 2 },
{ "P_IR_U", 2 },
{ "P_IR_S", 2 },
{ "P_BS_B", 2 },
{ "P_BS_S", 2 },
{ "P_FLAG", 2 },
{ "P_RATE(Mbps)", 0 }
};
static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len)
{ {
struct hclge_tm_shaper_para c_shaper_para; char data_str[ARRAY_SIZE(tm_pri_items)][HCLGE_DBG_DATA_STR_LEN];
struct hclge_tm_shaper_para p_shaper_para; struct hclge_tm_shaper_para c_shaper_para, p_shaper_para;
u8 pri_num, sch_mode, weight; char *result[ARRAY_SIZE(tm_pri_items)], *sch_mode_str;
char *sch_mode_str; char content[HCLGE_DBG_TM_INFO_LEN];
int pos = 0; u8 pri_num, sch_mode, weight, i, j;
int ret; int pos, ret;
u8 i;
ret = hclge_tm_get_pri_num(hdev, &pri_num); ret = hclge_tm_get_pri_num(hdev, &pri_num);
if (ret) if (ret)
return ret; return ret;
pos += scnprintf(buf + pos, len - pos, for (i = 0; i < ARRAY_SIZE(tm_pri_items); i++)
"ID MODE DWRR C_IR_B C_IR_U C_IR_S C_BS_B "); result[i] = &data_str[i][0];
pos += scnprintf(buf + pos, len - pos,
"C_BS_S C_FLAG C_RATE(Mbps) P_IR_B P_IR_U "); hclge_dbg_fill_content(content, sizeof(content), tm_pri_items,
pos += scnprintf(buf + pos, len - pos, NULL, ARRAY_SIZE(tm_pri_items));
"P_IR_S P_BS_B P_BS_S P_FLAG P_RATE(Mbps)\n"); pos = scnprintf(buf, len, "%s", content);
for (i = 0; i < pri_num; i++) { for (i = 0; i < pri_num; i++) {
ret = hclge_tm_get_pri_sch_mode(hdev, i, &sch_mode); ret = hclge_tm_get_pri_sch_mode(hdev, i, &sch_mode);
...@@ -971,21 +990,16 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) ...@@ -971,21 +990,16 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len)
sch_mode_str = sch_mode & HCLGE_TM_TX_SCHD_DWRR_MSK ? "dwrr" : sch_mode_str = sch_mode & HCLGE_TM_TX_SCHD_DWRR_MSK ? "dwrr" :
"sp"; "sp";
pos += scnprintf(buf + pos, len - pos, j = 0;
"%04u %4s %3u %3u %3u %3u ", sprintf(result[j++], "%04u", i);
i, sch_mode_str, weight, c_shaper_para.ir_b, sprintf(result[j++], "%4s", sch_mode_str);
c_shaper_para.ir_u, c_shaper_para.ir_s); sprintf(result[j++], "%3u", weight);
pos += scnprintf(buf + pos, len - pos, hclge_dbg_fill_shaper_content(&c_shaper_para, result, &j);
"%3u %3u %1u %6u ", hclge_dbg_fill_shaper_content(&p_shaper_para, result, &j);
c_shaper_para.bs_b, c_shaper_para.bs_s, hclge_dbg_fill_content(content, sizeof(content), tm_pri_items,
c_shaper_para.flag, c_shaper_para.rate); (const char **)result,
pos += scnprintf(buf + pos, len - pos, ARRAY_SIZE(tm_pri_items));
"%3u %3u %3u %3u %3u ", pos += scnprintf(buf + pos, len - pos, "%s", content);
p_shaper_para.ir_b, p_shaper_para.ir_u,
p_shaper_para.ir_s, p_shaper_para.bs_b,
p_shaper_para.bs_s);
pos += scnprintf(buf + pos, len - pos, "%1u %6u\n",
p_shaper_para.flag, p_shaper_para.rate);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment