提交 b0641a90 编写于 作者: Y Yufeng Mo 提交者: Xie XiuQi

net: hns3: get fd rules location before dump in debugfs

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

Currently, the dump fd tcam mode in debugfs is to query all fd tcams,
including empty rules, which is unnecessary. This patch modify to
find the position of useful rules before dump fd tcam, so that it does
not need to query empty rules.

This patch also modifies some help information in debugfs.

Feature or Bugfix:Bugfix
Signed-off-by: NYufeng Mo <moyufeng@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 93ee07d8
......@@ -259,13 +259,13 @@ static void hns3_dbg_help(struct hnae3_handle *h)
dev_info(&h->pdev->dev, "dump mac tnl status\n");
memset(printf_buf, 0, HNS3_DBG_BUF_LEN);
strncat(printf_buf, "dump reg [[bios common] [ssu]",
strncat(printf_buf, "dump reg [[bios common] [ssu <port_id>]",
HNS3_DBG_BUF_LEN - 1);
strncat(printf_buf + strlen(printf_buf),
" [igu egu] [rpu]",
" [igu egu <port_id>] [rpu <tc_queue_num>]",
HNS3_DBG_BUF_LEN - strlen(printf_buf) - 1);
strncat(printf_buf + strlen(printf_buf),
" [rtc] [ppp] [rcb] [tqp]]\n",
" [rtc] [ppp] [rcb] [tqp <queue_num>]]\n",
HNS3_DBG_BUF_LEN - strlen(printf_buf) - 1);
dev_info(&h->pdev->dev, "%s", printf_buf);
......
......@@ -944,24 +944,69 @@ static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
return ret;
}
static int hclge_dbg_get_rules_location(struct hclge_dev *hdev, u16 *rule_locs)
{
struct hclge_fd_rule *rule;
struct hlist_node *node;
int cnt = 0;
spin_lock_bh(&hdev->fd_rule_lock);
hlist_for_each_entry_safe(rule, node, &hdev->fd_rule_list, rule_node) {
rule_locs[cnt] = rule->location;
cnt++;
}
spin_unlock_bh(&hdev->fd_rule_lock);
if (cnt != hdev->hclge_fd_rule_num)
return -EINVAL;
return cnt;
}
static void hclge_dbg_fd_tcam(struct hclge_dev *hdev)
{
u32 i, ret;
int i, ret, rule_cnt;
u16 *rule_locs;
if (!hnae3_dev_fd_supported(hdev)) {
dev_err(&hdev->pdev->dev,
"Only FD-supported dev supports dump fd tcam\n");
return;
}
if (!hdev->hclge_fd_rule_num ||
!hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1])
return;
rule_locs = kzalloc(hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1] * 2,
GFP_KERNEL);
if (!rule_locs)
return;
rule_cnt = hclge_dbg_get_rules_location(hdev, rule_locs);
if (rule_cnt <= 0) {
dev_err(&hdev->pdev->dev, "get error rule number, ret = %d\n",
rule_cnt);
kfree(rule_locs);
return;
}
for (i = 0; i < hdev->fd_cfg.rule_num[0]; i++) {
ret = hclge_dbg_fd_tcam_read(hdev, 0, true, i);
for (i = 0; i < rule_cnt; i++) {
ret = hclge_dbg_fd_tcam_read(hdev, 0, true, rule_locs[i]);
if (ret) {
dev_err(&hdev->pdev->dev,
"get fd tcam key x failed, ret = %d\n", ret);
kfree(rule_locs);
return;
}
ret = hclge_dbg_fd_tcam_read(hdev, 0, false, i);
ret = hclge_dbg_fd_tcam_read(hdev, 0, false, rule_locs[i]);
if (ret) {
dev_err(&hdev->pdev->dev,
"get fd tcam key y failed, ret = %d\n", ret);
kfree(rule_locs);
return;
}
}
kfree(rule_locs);
}
static void hclge_dbg_dump_rst_info(struct hclge_dev *hdev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册