Skip to content

Commit 44b6b88

Browse files
Yufeng Modavem330
authored andcommitted
net: hns3: get FD rules location before dump in debugfs
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. Signed-off-by: Yufeng Mo <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a3374d7 commit 44b6b88

File tree

1 file changed

+67
-7
lines changed

1 file changed

+67
-7
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ static void hclge_dbg_dump_mng_table(struct hclge_dev *hdev)
886886
}
887887
}
888888

889-
static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
890-
bool sel_x, u32 loc)
889+
static int hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
890+
bool sel_x, u32 loc)
891891
{
892892
struct hclge_fd_tcam_config_1_cmd *req1;
893893
struct hclge_fd_tcam_config_2_cmd *req2;
@@ -912,7 +912,7 @@ static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
912912

913913
ret = hclge_cmd_send(&hdev->hw, desc, 3);
914914
if (ret)
915-
return;
915+
return ret;
916916

917917
dev_info(&hdev->pdev->dev, " read result tcam key %s(%u):\n",
918918
sel_x ? "x" : "y", loc);
@@ -931,16 +931,76 @@ static void hclge_dbg_fd_tcam_read(struct hclge_dev *hdev, u8 stage,
931931
req = (u32 *)req3->tcam_data;
932932
for (i = 0; i < 5; i++)
933933
dev_info(&hdev->pdev->dev, "%08x\n", *req++);
934+
935+
return ret;
936+
}
937+
938+
static int hclge_dbg_get_rules_location(struct hclge_dev *hdev, u16 *rule_locs)
939+
{
940+
struct hclge_fd_rule *rule;
941+
struct hlist_node *node;
942+
int cnt = 0;
943+
944+
spin_lock_bh(&hdev->fd_rule_lock);
945+
hlist_for_each_entry_safe(rule, node, &hdev->fd_rule_list, rule_node) {
946+
rule_locs[cnt] = rule->location;
947+
cnt++;
948+
}
949+
spin_unlock_bh(&hdev->fd_rule_lock);
950+
951+
if (cnt != hdev->hclge_fd_rule_num)
952+
return -EINVAL;
953+
954+
return cnt;
934955
}
935956

936957
static void hclge_dbg_fd_tcam(struct hclge_dev *hdev)
937958
{
938-
u32 i;
959+
int i, ret, rule_cnt;
960+
u16 *rule_locs;
961+
962+
if (!hnae3_dev_fd_supported(hdev)) {
963+
dev_err(&hdev->pdev->dev,
964+
"Only FD-supported dev supports dump fd tcam\n");
965+
return;
966+
}
967+
968+
if (!hdev->hclge_fd_rule_num ||
969+
!hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1])
970+
return;
971+
972+
rule_locs = kcalloc(hdev->fd_cfg.rule_num[HCLGE_FD_STAGE_1],
973+
sizeof(u16), GFP_KERNEL);
974+
if (!rule_locs)
975+
return;
939976

940-
for (i = 0; i < hdev->fd_cfg.rule_num[0]; i++) {
941-
hclge_dbg_fd_tcam_read(hdev, 0, true, i);
942-
hclge_dbg_fd_tcam_read(hdev, 0, false, i);
977+
rule_cnt = hclge_dbg_get_rules_location(hdev, rule_locs);
978+
if (rule_cnt <= 0) {
979+
dev_err(&hdev->pdev->dev,
980+
"failed to get rule number, ret = %d\n", rule_cnt);
981+
kfree(rule_locs);
982+
return;
943983
}
984+
985+
for (i = 0; i < rule_cnt; i++) {
986+
ret = hclge_dbg_fd_tcam_read(hdev, 0, true, rule_locs[i]);
987+
if (ret) {
988+
dev_err(&hdev->pdev->dev,
989+
"failed to get fd tcam key x, ret = %d\n", ret);
990+
kfree(rule_locs);
991+
return;
992+
}
993+
994+
ret = hclge_dbg_fd_tcam_read(hdev, 0, false, rule_locs[i]);
995+
if (ret) {
996+
dev_err(&hdev->pdev->dev,
997+
"failed to get fd tcam key y, ret = %d\n", ret);
998+
kfree(rule_locs);
999+
return;
1000+
}
1001+
}
1002+
1003+
kfree(rule_locs);
9441004
}
9451005

9461006
void hclge_dbg_dump_rst_info(struct hclge_dev *hdev)

0 commit comments

Comments
 (0)