[][Add clear all entry]
[Description]
Add clear all entry.
echo "3 -1" > /sys/kernel/debug/hnat/hnat_entry
[Release-log]
N/A
Change-Id: I255a635dbdfe86f77532c4f988e42d6cea1f3487
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5272399
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
index 335bd66..71df49c 100644
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_debugfs.c
@@ -305,6 +305,7 @@
pr_info(" 3 <entry_idx> Delete PPE0 specific foe entry of assigned <entry_idx>\n");
pr_info(" 4 <entry_idx> Show PPE1 specific foe entry info. of assigned <entry_idx>\n");
pr_info(" 5 <entry_idx> Delete PPE1 specific foe entry of assigned <entry_idx>\n");
+ pr_info(" When entry_idx is -1, clear all entries\n");
return 0;
}
@@ -531,19 +532,24 @@
if (ppe_id >= CFG_PPE_NUM)
return -EINVAL;
- if (index < 0 || index >= h->foe_etry_num) {
+ if (index < -1 || index >= (int)h->foe_etry_num) {
pr_info("Invalid entry index\n");
return -EINVAL;
}
- entry = h->foe_table_cpu[ppe_id] + index;
- memset(entry, 0, sizeof(struct foe_entry));
+ if (index == -1) {
+ memset(h->foe_table_cpu[ppe_id], 0, h->foe_etry_num * sizeof(struct foe_entry));
+ pr_info("clear all foe entry\n");
+ } else {
+
+ entry = h->foe_table_cpu[ppe_id] + index;
+ memset(entry, 0, sizeof(struct foe_entry));
+ pr_info("delete ppe id = %d, entry idx = %d\n", ppe_id, index);
+ }
/* clear HWNAT cache */
hnat_cache_ebl(1);
- pr_info("delete ppe id = %d, entry idx = %d\n", ppe_id, index);
-
return 0;
}
EXPORT_SYMBOL(entry_delete);