[rdkb][common][bsp][Refactor and sync kernel from openwrt]

[Description]
6ae9b08 [MAC80211][hnat][Remove w/k patch for C50 flooding issue]
9585b32 [kernel][common][eth][Update phylink_pcs support for the SGMII/USXGMII]
dd245aa [[kernel][mt7988][eth][add reset function from fe to fe&&wdma reset]]
018bb67 [openwrt][mt7988][thermal][Add LVTS hardware configurations]
3b2daf4 [kernel][common][eth][Fix Coverity scan warning]

[Release-log]

Change-Id: If664f1a8fffe691633a83251b64a404e16aff4bc
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
index c23f868..9987630 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_dbg.c
@@ -40,6 +40,8 @@
 u32 hw_lro_timestamp_flush_cnt[MTK_HW_LRO_RING_NUM];
 u32 hw_lro_norule_flush_cnt[MTK_HW_LRO_RING_NUM];
 u32 mtk_hwlro_stats_ebl;
+u32 dbg_show_level;
+
 static struct proc_dir_entry *proc_hw_lro_stats, *proc_hw_lro_auto_tlb;
 typedef int (*mtk_lro_dbg_func) (int par);
 
@@ -396,6 +398,12 @@
 			} else
 				pr_info(" device resetting !!!\n");
 			break;
+		case 4:
+			dbg_show_level = 1;
+			break;
+		case 5:
+			dbg_show_level = 0;
+			break;
 		default:
 			pr_info("Usage: echo [level] > /sys/kernel/debug/mtketh/reset\n");
 			pr_info("Commands:	 [level]\n");
@@ -403,6 +411,8 @@
 			pr_info("			   1	 FE and WDMA reset\n");
 			pr_info("			   2	 enable reset\n");
 			pr_info("			   3	 FE reset\n");
+			pr_info("			   4	enable dump reset info\n");
+			pr_info("			   5	disable dump reset info\n");
 			break;
 	}
 	return count;
@@ -1846,7 +1856,7 @@
 	    proc_create(PROCREG_RESET_EVENT, 0, proc_reg_dir, &reset_event_fops);
 	if (!proc_reset_event)
 		pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_RESET_EVENT);
-
+	dbg_show_level = 1;
 	return 0;
 }
 
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
index eebec74..5ab74ad 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
@@ -25,6 +25,8 @@
 static int mtk_wifi_num = 0;
 static int mtk_rest_cnt = 0;
 u32 mtk_reset_flag = MTK_FE_START_RESET;
+bool mtk_stop_fail;
+
 typedef u32 (*mtk_monitor_xdma_func) (struct mtk_eth *eth);
 
 void mtk_reset_event_update(struct mtk_eth *eth, u32 id)
@@ -51,10 +53,12 @@
 #endif
 	ethsys_reset(eth, reset_bits);
 
-	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) ||
-	    MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3))
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2))
 		regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0x3ffffff);
 
+	if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3))
+		regmap_write(eth->ethsys, ETHSYS_FE_RST_CHK_IDLE_EN, 0x6F8FF);
+
 	return 0;
 }
 
@@ -144,7 +148,8 @@
 
 	if (ret) {
 		mtk_reset_event_update(eth, MTK_EVENT_TOTAL_CNT);
-		mtk_dump_netsys_info(eth);
+		if (dbg_show_level)
+			mtk_dump_netsys_info(eth);
 	}
 
 	return ret;
@@ -619,6 +624,7 @@
 	switch (event) {
 	case MTK_WIFI_RESET_DONE:
 	case MTK_FE_STOP_TRAFFIC_DONE:
+		pr_info("%s rcv done event:%x\n", __func__, event);
 		mtk_rest_cnt--;
 		if(!mtk_rest_cnt) {
 			complete(&wait_ser_done);
@@ -633,6 +639,13 @@
 		mtk_wifi_num--;
 		mtk_rest_cnt = mtk_wifi_num;
 		break;
+	case MTK_FE_STOP_TRAFFIC_DONE_FAIL:
+		mtk_stop_fail = true;
+		mtk_reset_flag = MTK_FE_START_RESET;
+		pr_info("%s rcv done event:%x\n", __func__, event);
+		complete(&wait_ser_done);
+		mtk_rest_cnt = mtk_wifi_num;
+		break;
 	default:
 		break;
 	}
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.h b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.h
index 096331b..4ac77c8 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.h
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.h
@@ -18,6 +18,8 @@
 #define MTK_FE_STOP_TRAFFIC	(0x2005)
 #define MTK_FE_STOP_TRAFFIC_DONE	(0x2006)
 #define MTK_FE_START_TRAFFIC	(0x2007)
+#define MTK_FE_STOP_TRAFFIC_DONE_FAIL	(0x2008)
+
 
 /* ADMA Rx Debug Monitor */
 #define MTK_ADMA_RX_DBG0	(PDMA_BASE + 0x238)
@@ -67,6 +69,7 @@
 extern atomic_t reset_lock;
 extern struct completion wait_nat_done;
 extern u32 mtk_reset_flag;
+extern bool mtk_stop_fail;
 
 irqreturn_t mtk_handle_fe_irq(int irq, void *_eth);
 u32 mtk_check_reset_event(struct mtk_eth *eth, u32 status);
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index ad73fdb..05a5595 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1096,7 +1096,7 @@
 {
 	struct device_node *mii_np;
 	int max_clk = 2500000, divider;
-	int ret;
+	int ret = 0;
 	u32 val;
 
 	mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus");
@@ -3959,8 +3959,20 @@
 				eth->netdev[i]);
 		}
 		rtnl_unlock();
-		if (!wait_for_completion_timeout(&wait_ser_done, 3000))
+		if (!wait_for_completion_timeout(&wait_ser_done, 3000)) {
+			if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3) &&
+				(mtk_stop_fail)) {
+				pr_info("send MTK_FE_START_RESET stop\n");
+				rtnl_lock();
+				call_netdevice_notifiers(MTK_FE_START_RESET,
+					eth->netdev[i]);
+				rtnl_unlock();
+				if (!wait_for_completion_timeout(&wait_ser_done,
+					3000))
+					pr_warn("wait for MTK_FE_START_RESET\n");
+				}
 			pr_warn("wait for MTK_FE_START_RESET\n");
+		}
 		rtnl_lock();
 		break;
 	}
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index f279ad5..03c18f0 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -1822,6 +1822,7 @@
 extern struct mtk_eth *g_eth;
 extern const struct of_device_id of_mtk_match[];
 extern u32 mtk_hwlro_stats_ebl;
+extern u32 dbg_show_level;
 
 /* read the hardware status register */
 void mtk_stats_update_mac(struct mtk_mac *mac);
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/thermal/mediatek/soc_temp_lvts.c b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/thermal/mediatek/soc_temp_lvts.c
index 570ac17..d3f32ca 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/thermal/mediatek/soc_temp_lvts.c
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/files-5.4/drivers/thermal/mediatek/soc_temp_lvts.c
@@ -37,6 +37,7 @@
 	(DEVICE_WRITE | RG_TSV2F_CTRL_4 << 8 | 0xFC)
 #define SET_TS_RSV_V5 (DEVICE_WRITE | RG_TSV2F_CTRL_1 << 8 | 0x8D)
 #define SET_TS_EN_V5  (DEVICE_WRITE | RG_TSV2F_CTRL_0 << 8 | 0xF1)
+#define SET_TS_V2VF_RSV_V5 (DEVICE_WRITE | RG_TSV2F_CTRL_3 << 8 | 0x04)
 
 #define SET_MANUAL_RCK_V5	  (DEVICE_WRITE | RG_TSV2F_CTRL_6 << 8 | 0x00)
 #define SELECT_SENSOR_RCK_V5(id)  (DEVICE_WRITE | RG_TSV2F_CTRL_5 << 8 | (id))
@@ -1154,6 +1155,7 @@
 				  i);
 		lvts_write_device(lvts_data, SET_TS_RSV_V5, i);
 		lvts_write_device(lvts_data, SET_TS_EN_V5, i);
+		lvts_write_device(lvts_data, SET_TS_V2VF_RSV_V5, i);
 	}
 
 	lvts_data->counting_window_us = 20;
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
index a7dfc86..7d4c5d6 100755
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/flow_patch/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
@@ -6125,7 +6125,7 @@
 index 000000000..ae1eb2656
 --- /dev/null
 +++ b/net/netfilter/xt_FLOWOFFLOAD.c
-@@ -0,0 +1,785 @@
+@@ -0,0 +1,776 @@
 +/*
 + * Copyright (C) 2018-2021 Felix Fietkau <nbd@nbd.name>
 + *
@@ -6510,28 +6510,19 @@
 +	return dev_fill_forward_path(dev, ha, stack);
 +}
 +
-+static int nf_dev_forward_path(struct sk_buff *skb,
-+				struct nf_flow_route *route,
++static int nf_dev_forward_path(struct nf_flow_route *route,
 +				const struct nf_conn *ct,
 +				enum ip_conntrack_dir dir,
 +				struct net_device **devs)
 +{
 +	const struct dst_entry *dst = route->tuple[dir].dst;
-+	struct ethhdr *eth = eth_hdr(skb);
 +	struct net_device_path_stack stack;
 +	struct nf_forward_info info = {};
 +	unsigned char ha[ETH_ALEN];
 +	int i;
 +
-+	if (nf_dev_fill_forward_path(route, dst, ct, dir, ha, &stack) >= 0) {
-+		if (!(ct->status & IPS_NAT_MASK)) {
-+			if (dir == IP_CT_DIR_ORIGINAL)
-+				memcpy(info.h_source, eth->h_source, ETH_ALEN);
-+			else if (dir == IP_CT_DIR_REPLY)
-+				memcpy(info.h_source, eth->h_dest, ETH_ALEN);
-+		}
++	if (nf_dev_fill_forward_path(route, dst, ct, dir, ha, &stack) >= 0)
 +		nf_dev_path_info(&stack, &info, ha);
-+	}
 +
 +	devs[!dir] = (struct net_device *)info.indev;
 +	if (!info.indev)
@@ -6617,11 +6608,11 @@
 +	nf_default_forward_path(route, this_dst, dir, devs);
 +	nf_default_forward_path(route, other_dst, !dir, devs);
 +
-+	if (route->tuple[dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH &&
++	if (route->tuple[dir].xmit_type	== FLOW_OFFLOAD_XMIT_NEIGH &&
 +	    route->tuple[!dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH) {
-+		if (nf_dev_forward_path(skb, route, ct, dir, devs))
++		if (nf_dev_forward_path(route, ct, dir, devs))
 +			return -1;
-+		if (nf_dev_forward_path(skb, route, ct, !dir, devs))
++		if (nf_dev_forward_path(route, ct, !dir, devs))
 +			return -1;
 +	}
 +
@@ -6648,10 +6639,10 @@
 +	if (ret)
 +		goto err_route_dir1;
 +
-+	if (route->tuple[dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH &&
++	if (route->tuple[dir].xmit_type	== FLOW_OFFLOAD_XMIT_NEIGH &&
 +	    route->tuple[!dir].xmit_type == FLOW_OFFLOAD_XMIT_NEIGH) {
-+		if (nf_dev_forward_path(skb, route, ct, dir, devs) ||
-+		    nf_dev_forward_path(skb, route, ct, !dir, devs)) {
++		if (nf_dev_forward_path(route, ct, dir, devs) ||
++		    nf_dev_forward_path(route, ct, !dir, devs)) {
 +			ret = -1;
 +			goto err_route_dir2;
 +		}
diff --git a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/757-net-phy-add-phylink-pcs-support.patch b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/757-net-phy-add-phylink-pcs-support.patch
index f449505..83da92d 100644
--- a/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/757-net-phy-add-phylink-pcs-support.patch
+++ b/recipes-kernel/linux/linux-mediatek-5.4/mediatek/patches-5.4/757-net-phy-add-phylink-pcs-support.patch
@@ -426,7 +426,7 @@
  	ASSERT_RTNL();
  
  	phylink_info(pl, "configuring for %s/%s link mode\n",
-@@ -1029,15 +1215,12 @@ void phylink_start(struct phylink *pl)
+@@ -1029,15 +1215,13 @@ void phylink_start(struct phylink *pl)
  	/* Apply the link configuration to the MAC when starting. This allows
  	 * a fixed-link to start with the correct parameters, and also
  	 * ensures that we set the appropriate advertisement for Serdes links.
@@ -441,6 +441,7 @@
  	 * switches using 802.3z negotiation to ensure they see our modes.
  	 */
 -	phylink_mac_an_restart(pl);
++	phylink_resolve_flow(pl, &pl->link_config);
 +	phylink_mac_initial_config(pl, true);
  
  	clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);