[][openwrt][mt7988][pce][add notification chain in PCE]
[Description]
Add notification chain in PCE for other drivers, for example, TOPS,
to register. If cls entry is deleted, other drivers will be notified.
[Release-log]
N/A
Change-Id: Ifb6ef32554f08b52519fa2fcb9e084c349bbc08a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9409295
diff --git a/feed/kernel/pce/src/cls.c b/feed/kernel/pce/src/cls.c
index 3c10cf1..427bc4d 100644
--- a/feed/kernel/pce/src/cls.c
+++ b/feed/kernel/pce/src/cls.c
@@ -15,6 +15,28 @@
#include "pce/internal.h"
#include "pce/netsys.h"
+static RAW_NOTIFIER_HEAD(cls_notif_chain);
+
+int mtk_pce_register_cls_notifier(struct notifier_block *nb)
+{
+ int ret;
+
+ ret = raw_notifier_chain_register(&cls_notif_chain, nb);
+
+ return ret;
+}
+EXPORT_SYMBOL(mtk_pce_register_cls_notifier);
+
+int mtk_pce_unregister_cls_notifier(struct notifier_block *nb)
+{
+ int ret;
+
+ ret = raw_notifier_chain_unregister(&cls_notif_chain, nb);
+
+ return ret;
+}
+EXPORT_SYMBOL(mtk_pce_unregister_cls_notifier);
+
struct cls_hw {
struct cls_entry cls_tbl[FE_MEM_CLS_MAX_INDEX];
DECLARE_BITMAP(cls_used, FE_MEM_CLS_MAX_INDEX);
@@ -159,6 +181,8 @@
if (!cls)
return;
+ raw_notifier_call_chain(&cls_notif_chain, CLS_NOTIFY_DELETE_ENTRY, cls);
+
spin_lock_irqsave(&cls_hw.lock, flag);
clear_bit(cls->idx - 1, cls_hw.cls_used);
spin_unlock_irqrestore(&cls_hw.lock, flag);
diff --git a/feed/kernel/pce/src/inc/pce/cls.h b/feed/kernel/pce/src/inc/pce/cls.h
index 2853c85..57dee18 100644
--- a/feed/kernel/pce/src/inc/pce/cls.h
+++ b/feed/kernel/pce/src/inc/pce/cls.h
@@ -9,6 +9,7 @@
#define _PCE_CLS_H_
#include <linux/platform_device.h>
+#include <linux/notifier.h>
#include "pce/pce.h"
@@ -25,6 +26,15 @@
struct cls_desc cdesc;
};
+enum cls_notifier_event {
+ CLS_NOTIFY_DELETE_ENTRY,
+
+ __CLS_NOTIFY_MAX,
+};
+
+int mtk_pce_register_cls_notifier(struct notifier_block *nb);
+int mtk_pce_unregister_cls_notifier(struct notifier_block *nb);
+
int mtk_pce_cls_enable(void);
void mtk_pce_cls_disable(void);