[][MAC80211][hnat][Sync Flowblock framework to the OpenWRT_trunk_20230525]

[Description]
Change Flowblock framework to the OpenWRT_trunk_20230525.
  - Sync Flowblock common part drivers to the OpenWRT_trunk_20230525.
  - Refactor dual PPE patch to the upstream style.
  - Refactor backward compatible two way hash to the upstream style.
  - Refactor per flow accounting patch to the upstream style.
  - Refactor MT7988 patch based on MT7986 upstream style.

If without this patch, kernel cannot use up-to-date PPE driver for the
Flowblock.

[Release-log]
N/A


Change-Id: Ic83991e2fdc95e57961f0355cc1ff3b1f604feea
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7628461
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3012-flow-offload-ovs-support.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3012-flow-offload-ovs-support.patch
new file mode 100755
index 0000000..b9c0831
--- /dev/null
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/999-3012-flow-offload-ovs-support.patch
@@ -0,0 +1,75 @@
+From 81ebcc8c2e1f6c95c1bb27b1c74003277321cf2d Mon Sep 17 00:00:00 2001
+From: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
+Date: Tue, 13 Jun 2023 17:08:22 +0800
+Subject: [PATCH] 999-3012-flow-offload-ovs-support
+
+---
+ net/openvswitch/vport-internal_dev.c | 46 ++++++++++++++++++++++++++++
+ 1 file changed, 46 insertions(+)
+
+diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c
+index 58a7b83..8475727 100644
+--- a/net/openvswitch/vport-internal_dev.c
++++ b/net/openvswitch/vport-internal_dev.c
+@@ -113,12 +113,58 @@ internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
+ 	}
+ }
+ 
++static int internal_dev_fill_forward_path(struct net_device_path_ctx *ctx, struct net_device_path *path)
++{
++	struct vport *vport;
++	int i;
++	struct table_instance *ti;
++	struct datapath *dp;
++	struct sw_flow_key *key;
++	struct sw_flow_actions *sf_acts;
++	struct nlattr *a;
++	int rem;
++
++	vport = ovs_internal_dev_get_vport(ctx->dev);
++	dp = vport->dp;
++	ti = rcu_dereference_ovsl(dp->table.ti);
++
++	for (i = 0; i < ti->n_buckets; i++) {
++		struct sw_flow *flow;
++		struct hlist_head *head = &ti->buckets[i];
++		struct hlist_node *n;
++
++		hlist_for_each_entry_safe(flow, n, head, flow_table.node[ti->node_ver]) {
++			key = &flow->key;
++
++			if((!memcmp(ctx->dev->dev_addr, key->eth.dst, ETH_ALEN)) && (!memcmp(ctx->daddr, key->eth.src, ETH_ALEN))){
++				sf_acts = rcu_dereference_ovsl(flow->sf_acts);
++				for (a = sf_acts->actions, rem = sf_acts->actions_len; rem > 0;
++			     	 a = nla_next(a, &rem)) {
++				 	if(nla_type(a) == OVS_ACTION_ATTR_OUTPUT){
++						vport = ovs_vport_rcu(dp, key->phy.in_port);
++						goto out;
++			 		}
++		     	}
++			}
++		}
++	}
++
++out:
++
++	path->type = DEV_PATH_BRIDGE;
++	path->dev = ctx->dev;
++	ctx->dev = vport->dev;
++
++	return 0;
++}
++
+ static const struct net_device_ops internal_dev_netdev_ops = {
+ 	.ndo_open = internal_dev_open,
+ 	.ndo_stop = internal_dev_stop,
+ 	.ndo_start_xmit = internal_dev_xmit,
+ 	.ndo_set_mac_address = eth_mac_addr,
+ 	.ndo_get_stats64 = internal_get_stats,
++	.ndo_fill_forward_path	 = internal_dev_fill_forward_path,
+ };
+ 
+ static struct rtnl_link_ops internal_dev_link_ops __read_mostly = {
+-- 
+2.18.0
+