[][openwrt][mt7988][tops][separate CLS_ENTRY and TOPS_ENTRY dependency]

[Description]
Refactor TOPS CLS_ENTRY and TOPS_ENTRY.

Separate CLS_ENTRY and TOPS_ENTRY implicit mapping relationship.

In previous implementation, 1 protocol can only occupy a CLS_ENTRY and a
CLS_ENTRY is corresponding to a TOPS_ENTRY. 1 TOPS_ENTRY will have a
tunnel offload function inside TOPS firmware.

However, some of the protocol may occupy several CLS_ENTRY such as ESP.
This kind of protocol may use different CLS_ENTRY to distinguish each
session.
This leads to a problem that TOPS firmware can not handle same protocol
with different TOPS_ENTRY.

To solve this problem, the idea of CLS_ENTRY and TOPS_ENTRY is no longer 1
to 1 mapping. CLS_ENTRY is now allocated dynamically and its index is
carried inside tops_tnl_params so that TOPS firmware can map that
CLS_ENTRY to a TOPS_ENTRY which will be corresponding to a tunnel offload
function.

[Release-log]
N/A

Change-Id: I162a899353b9935602d971947d8514ba8d4e7d3e
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7923904
diff --git a/package-21.02/kernel/tops/src/inc/tunnel.h b/package-21.02/kernel/tops/src/inc/tunnel.h
index 961aa03..387d923 100644
--- a/package-21.02/kernel/tops/src/inc/tunnel.h
+++ b/package-21.02/kernel/tops/src/inc/tunnel.h
@@ -18,6 +18,8 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 
+#include <pce/cls.h>
+
 #include "protocol/l2tp/l2tp.h"
 
 /* tunnel info status */
@@ -107,6 +109,13 @@
 	TNL_INFO_DEBUG_BIT,
 };
 
+struct tops_cls_entry {
+	struct cls_entry *cls;
+	struct list_head node;
+	refcount_t refcnt;
+	bool updated;
+};
+
 /* record outer tunnel header data for HW offloading */
 struct tops_tnl_params {
 	u8 daddr[ETH_ALEN];
@@ -117,6 +126,7 @@
 	__be16 sport;
 	u16 protocol;
 	u8 tops_entry_proto;
+	u8 cls_entry;
 	u8 flag; /* bit: enum tops_tnl_params_flag */
 	union {
 		struct l2tp_param l2tp; /* 4B */
@@ -126,19 +136,26 @@
 struct tops_tnl_info {
 	struct tops_tnl_params tnl_params;
 	struct tops_tnl_params cache;
+	struct tops_tnl_type *tnl_type;
+	struct tops_cls_entry *tcls;
 	struct list_head sync_node;
 	struct hlist_node hlist;
 	struct net_device *dev;
-	struct timer_list taging;
 	spinlock_t lock;
 	u32 tnl_idx;
 	u32 status;
 	u32 flag; /* bit: enum tops_tnl_info_flag */
-	refcount_t refcnt;
 } __aligned(16);
 
 struct tops_tnl_type {
 	const char *type_name;
+	enum tops_entry_type tops_entry;
+
+	int (*cls_entry_setup)(struct tops_tnl_info *tnl_info,
+			       struct cls_desc *cdesc);
+	struct list_head tcls_head;
+	bool use_multi_cls;
+
 	int (*tnl_decap_param_setup)(struct sk_buff *skb,
 				     struct tops_tnl_params *tnl_params);
 	int (*tnl_encap_param_setup)(struct sk_buff *skb,
@@ -149,14 +166,13 @@
 	bool (*tnl_info_match)(struct tops_tnl_params *params1,
 			       struct tops_tnl_params *params2);
 	bool (*tnl_decap_offloadable)(struct sk_buff *skb);
-	enum tops_entry_type tops_entry;
 	bool has_inner_eth;
 };
 
 void mtk_tops_tnl_info_submit_no_tnl_lock(struct tops_tnl_info *tnl_info);
 void mtk_tops_tnl_info_submit(struct tops_tnl_info *tnl_info);
 struct tops_tnl_info *mtk_tops_tnl_info_find(struct tops_tnl_params *tnl_params);
-struct tops_tnl_info *mtk_tops_tnl_info_alloc(void);
+struct tops_tnl_info *mtk_tops_tnl_info_alloc(struct tops_tnl_type *tnl_type);
 void mtk_tops_tnl_info_hash(struct tops_tnl_info *tnl_info);
 
 int mtk_tops_tnl_offload_init(struct platform_device *pdev);