[][kernel][mt7988][eth][Refactor QDMA rate limit for the TOPS]
[Description]
Refactor QDMA rate limit for the TOPS.
Due to the previous method, some of phylink's functions for getting
the maximum speed for rate adaptation were removed. Therefore, it
causes the GMAC to be unable to configure the speed correctly when
the PHY is running in rate adaptation mode.
Without this path, the GMAC is unable to configure the speed correctly
when the PHY is running in rate adaptation mode.
[Release-log]
N/A
Change-Id: If380e6f1bc9f80eaa3ba89c3ebb13dc854b13984
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/9632660
diff --git a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index b61bfb2..737d2f3 100644
--- a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -1185,6 +1185,8 @@
u32 mcr, mcr_cur, sts;
mac->speed = speed;
+ if (phy)
+ mac->phy_speed = phy->speed;
if (mac->type == MTK_GDM_TYPE) {
mcr_cur = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
diff --git a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 15bb8dd..61bad4c 100644
--- a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -2117,6 +2117,7 @@
unsigned int mode;
unsigned int type;
int speed;
+ int phy_speed;
struct device_node *of_node;
struct phylink *phylink;
struct phylink_config phylink_config;
diff --git a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
index f8ae4c7..05f28e9 100644
--- a/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
+++ b/21.02/files/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_hnat/hnat_nf_hook.c
@@ -946,13 +946,13 @@
mac = netdev_priv(dev);
- switch (mac->speed) {
+ switch (mac->phy_speed) {
case SPEED_100:
case SPEED_1000:
case SPEED_2500:
case SPEED_5000:
case SPEED_10000:
- max_man = mac->speed / SPEED_100;
+ max_man = mac->phy_speed / SPEED_100;
break;
default:
return;
diff --git a/21.02/files/target/linux/mediatek/patches-5.4/999-2729-net-phy-remove-reporting-line-rate-to-mac.patch b/21.02/files/target/linux/mediatek/patches-5.4/999-2729-net-phy-remove-reporting-line-rate-to-mac.patch
deleted file mode 100644
index 4f62103..0000000
--- a/21.02/files/target/linux/mediatek/patches-5.4/999-2729-net-phy-remove-reporting-line-rate-to-mac.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/drivers/net/phy/phylink.c
-+++ b/drivers/net/phy/phylink.c
-@@ -686,7 +686,10 @@ static void phylink_link_up(struct phyli
- * the link_state) to the interface speed, and will send
- * pause frames to the MAC to limit its transmission speed.
- */
-- speed = phylink_interface_max_speed(link_state.interface);
-+ /* For tunnel HW offload, we need to get true link rate to
-+ * set QDMA rate limit as link rate.
-+ */
-+ // speed = phylink_interface_max_speed(link_state.interface);
- duplex = DUPLEX_FULL;
- rx_pause = true;
- break;