MAC_MCR_FORCE_DPX | MAC_MCR_FORCE_TX_FC |
MAC_MCR_FORCE_RX_FC);
-@@ -811,6 +812,18 @@ static void mtk_mac_link_up(struct phyli
+@@ -811,6 +812,15 @@ static void mtk_mac_link_up(struct phyli
if (rx_pause)
mcr |= MAC_MCR_FORCE_RX_FC;
-+ if (mode == MLO_AN_PHY && phy && phy_init_eee(phy, false) >= 0) {
-+ switch (speed) {
-+ case SPEED_2500:
-+ case SPEED_1000:
-+ mcr |= MAC_MCR_EEE1G;
-+ break;
-+ case SPEED_100:
-+ mcr |= MAC_MCR_EEE100M;
-+ break;
-+ }
++ if (mode == MLO_AN_PHY && phy && mac->tx_lpi_enabled && phy_init_eee(phy, false) >= 0) {
++ mcr |= MAC_MCR_EEE100M | MAC_MCR_EEE1G;
++ mtk_w32(mac->hw,
++ FIELD_PREP(MAC_EEE_WAKEUP_TIME_1000, 17) |
++ FIELD_PREP(MAC_EEE_WAKEUP_TIME_100, 36) |
++ FIELD_PREP(MAC_EEE_LPI_TXIDLE_THD, mac->txidle_thd_ms),
++ MTK_MAC_EEECR(mac->id));
+ }
+
mcr |= MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK;
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
}
-@@ -3956,6 +3969,7 @@ static int mtk_hw_init(struct mtk_eth *e
- continue;
-
- mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
-+ mtk_w32(eth, FIELD_PREP(MAC_EEE_LPI_TXIDLE_THD, 1), MTK_MAC_EEECR(i));
- mtk_set_mcr_max_rx(netdev_priv(dev),
- dev->mtu + MTK_RX_ETH_HLEN);
- }
-@@ -4476,6 +4490,55 @@ static int mtk_set_pauseparam(struct net
+@@ -4476,6 +4486,61 @@ static int mtk_set_pauseparam(struct net
return phylink_ethtool_set_pauseparam(mac->phylink, pause);
}
+ return ret;
+
+ reg = mtk_r32(mac->hw, MTK_MAC_EEECR(mac->id));
-+ eee->tx_lpi_enabled = !(reg & MAC_EEE_LPI_MODE);
++ eee->tx_lpi_enabled = mac->tx_lpi_enabled;
+ eee->tx_lpi_timer = FIELD_GET(MAC_EEE_LPI_TXIDLE_THD, reg) * 1000;
+
+ return 0;
+ if (ret)
+ return ret;
+
++ mac->tx_lpi_enabled = eee->tx_lpi_enabled;
++ mac->txidle_thd_ms = txidle_thd_ms;
+ mtk_w32(mac->hw, reg, MTK_MAC_EEECR(mac->id));
++ if (eee->eee_enabled && eee->eee_active && eee->tx_lpi_enabled)
++ mtk_m32(mac->hw, 0, MAC_MCR_EEE100M | MAC_MCR_EEE1G, MTK_MAC_MCR(mac->id));
++ else
++ mtk_m32(mac->hw, MAC_MCR_EEE100M | MAC_MCR_EEE1G, 0, MTK_MAC_MCR(mac->id));
+
+ return 0;
+}
static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb,
struct net_device *sb_dev)
{
-@@ -4508,6 +4571,8 @@ static const struct ethtool_ops mtk_etht
+@@ -4508,6 +4573,8 @@ static const struct ethtool_ops mtk_etht
.set_pauseparam = mtk_set_pauseparam,
.get_rxnfc = mtk_get_rxnfc,
.set_rxnfc = mtk_set_rxnfc,
};
static const struct net_device_ops mtk_netdev_ops = {
+@@ -4568,6 +4635,8 @@ static int mtk_add_mac(struct mtk_eth *e
+ }
+ mac = netdev_priv(eth->netdev[id]);
+ eth->mac[id] = mac;
++ mac->tx_lpi_enabled = true;
++ mac->txidle_thd_ms = 1;
+ mac->id = id;
+ mac->hw = eth;
+ mac->of_node = np;
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -453,6 +453,8 @@
/* Mac status registers */
#define MTK_MAC_MSR(x) (0x10108 + (x * 0x100))
#define MAC_MSR_EEE1G BIT(7)
+@@ -1321,6 +1332,8 @@ struct mtk_mac {
+ int id;
+ phy_interface_t interface;
+ u8 ppe_idx;
++ bool tx_lpi_enabled;
++ u8 txidle_thd_ms;
+ int speed;
+ struct device_node *of_node;
+ struct phylink *phylink;
.glo_cfg = 0x4604,
.rst_idx = 0x4608,
.delay_irq = 0x460c,
-@@ -3898,6 +3901,56 @@ static void mtk_set_mcr_max_rx(struct mt
+@@ -3895,6 +3898,56 @@ static void mtk_set_mcr_max_rx(struct mt
mtk_w32(mac->hw, mcr_new, MTK_MAC_MCR(mac->id));
}
static void mtk_hw_reset(struct mtk_eth *eth)
{
u32 val;
-@@ -4358,6 +4411,8 @@ static void mtk_pending_work(struct work
+@@ -4354,6 +4407,8 @@ static void mtk_pending_work(struct work
rtnl_lock();
set_bit(MTK_RESETTING, ð->state);
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -5101,6 +5101,8 @@ static int mtk_probe(struct platform_dev
+@@ -5105,6 +5105,8 @@ static int mtk_probe(struct platform_dev
* for NAPI to work
*/
init_dummy_netdev(ð->dummy_dev);
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -3148,11 +3148,19 @@ static int mtk_dma_init(struct mtk_eth *
+@@ -3145,11 +3145,19 @@ static int mtk_dma_init(struct mtk_eth *
static void mtk_dma_free(struct mtk_eth *eth)
{
const struct mtk_soc_data *soc = eth->soc;
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
-@@ -1347,6 +1347,22 @@ struct mtk_mac {
+@@ -1349,6 +1349,22 @@ struct mtk_mac {
/* the struct describing the SoC. these are declared in the soc_xyz.c files */
extern const struct of_device_id of_mtk_match[];
static inline bool mtk_is_netsys_v1(struct mtk_eth *eth)
{
return eth->soc->version == 1;
-@@ -1361,6 +1377,7 @@ static inline bool mtk_is_netsys_v3_or_g
+@@ -1363,6 +1379,7 @@ static inline bool mtk_is_netsys_v3_or_g
{
return eth->soc->version > 2;
}
#include <net/page_pool/helpers.h>
#include "mtk_eth_soc.h"
-@@ -1609,12 +1610,28 @@ static void mtk_wake_queue(struct mtk_et
+@@ -1606,12 +1607,28 @@ static void mtk_wake_queue(struct mtk_et
}
}
bool gso = false;
int tx_num;
-@@ -1636,6 +1653,18 @@ static netdev_tx_t mtk_start_xmit(struct
+@@ -1633,6 +1650,18 @@ static netdev_tx_t mtk_start_xmit(struct
return NETDEV_TX_BUSY;
}
/* TSO: fill MSS info in tcp checksum field */
if (skb_is_gso(skb)) {
if (skb_cow_head(skb, 0)) {
-@@ -1651,8 +1680,14 @@ static netdev_tx_t mtk_start_xmit(struct
+@@ -1648,8 +1677,14 @@ static netdev_tx_t mtk_start_xmit(struct
}
}
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -2153,7 +2153,7 @@ static int mtk_poll_rx(struct napi_struc
+@@ -2150,7 +2150,7 @@ static int mtk_poll_rx(struct napi_struc
if (ret != XDP_PASS)
goto skip_rx;
if (unlikely(!skb)) {
page_pool_put_full_page(ring->page_pool,
page, true);
-@@ -2191,7 +2191,7 @@ static int mtk_poll_rx(struct napi_struc
+@@ -2188,7 +2188,7 @@ static int mtk_poll_rx(struct napi_struc
dma_unmap_single(eth->dma_dev, ((u64)trxd.rxd1 | addr64),
ring->buf_size, DMA_FROM_DEVICE);
/* QDMA Flow Control Register */
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -3322,12 +3322,14 @@ static int mtk_start_dma(struct mtk_eth
+@@ -3319,12 +3319,14 @@ static int mtk_start_dma(struct mtk_eth
MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO |
MTK_RX_2B_OFFSET | MTK_TX_WB_DDONE;
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -1185,7 +1185,7 @@ static int mtk_init_fq_dma(struct mtk_et
+@@ -1182,7 +1182,7 @@ static int mtk_init_fq_dma(struct mtk_et
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
return -ENOMEM;
u32 mcr;
mcr = mtk_r32(mac->hw, MTK_MAC_MCR(mac->id));
-@@ -829,9 +916,63 @@ static void mtk_mac_link_up(struct phyli
+@@ -826,9 +913,63 @@ static void mtk_mac_link_up(struct phyli
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
}
.mac_finish = mtk_mac_finish,
.mac_link_down = mtk_mac_link_down,
.mac_link_up = mtk_mac_link_up,
-@@ -3430,6 +3571,9 @@ static int mtk_open(struct net_device *d
+@@ -3427,6 +3568,9 @@ static int mtk_open(struct net_device *d
ppe_num = eth->soc->ppe_num;
err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
if (err) {
netdev_err(dev, "%s: could not attach PHY: %d\n", __func__,
-@@ -3580,6 +3724,9 @@ static int mtk_stop(struct net_device *d
+@@ -3577,6 +3721,9 @@ static int mtk_stop(struct net_device *d
for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
mtk_ppe_stop(eth->ppe[i]);
return 0;
}
-@@ -4645,6 +4792,7 @@ static const struct net_device_ops mtk_n
+@@ -4647,6 +4794,7 @@ static const struct net_device_ops mtk_n
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
{
const __be32 *_id = of_get_property(np, "reg", NULL);
phy_interface_t phy_mode;
struct phylink *phylink;
struct mtk_mac *mac;
-@@ -4681,16 +4829,41 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -4685,16 +4833,41 @@ static int mtk_add_mac(struct mtk_eth *e
mac->id = id;
mac->hw = eth;
mac->of_node = np;
}
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
-@@ -4773,8 +4946,21 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -4777,8 +4950,21 @@ static int mtk_add_mac(struct mtk_eth *e
phy_interface_zero(mac->phylink_config.supported_interfaces);
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
mac->phylink_config.supported_interfaces);
phylink = phylink_create(&mac->phylink_config,
of_fwnode_handle(mac->of_node),
phy_mode, &mtk_phylink_ops);
-@@ -4825,6 +5011,26 @@ free_netdev:
+@@ -4829,6 +5015,26 @@ free_netdev:
return err;
}
void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
{
struct net_device *dev, *tmp;
-@@ -4971,7 +5177,8 @@ static int mtk_probe(struct platform_dev
+@@ -4975,7 +5181,8 @@ static int mtk_probe(struct platform_dev
regmap_write(cci, 0, 3);
}
err = mtk_sgmii_init(eth);
if (err)
-@@ -5082,6 +5289,24 @@ static int mtk_probe(struct platform_dev
+@@ -5086,6 +5293,24 @@ static int mtk_probe(struct platform_dev
}
}
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
err = devm_request_irq(eth->dev, eth->irq[0],
mtk_handle_irq, 0,
-@@ -5185,6 +5410,11 @@ static int mtk_remove(struct platform_de
+@@ -5189,6 +5414,11 @@ static int mtk_remove(struct platform_de
mtk_stop(eth->netdev[i]);
mac = netdev_priv(eth->netdev[i]);
phylink_disconnect_phy(mac->phylink);
struct mtk_tx_dma_desc_info {
dma_addr_t addr;
-@@ -1336,6 +1393,9 @@ struct mtk_mac {
+@@ -1338,6 +1395,9 @@ struct mtk_mac {
struct device_node *of_node;
struct phylink *phylink;
struct phylink_config phylink_config;
struct mtk_eth *hw;
struct mtk_hw_stats *hw_stats;
__be32 hwlro_ip[MTK_MAX_LRO_IP_CNT];
-@@ -1459,6 +1519,19 @@ static inline u32 mtk_get_ib2_multicast_
+@@ -1461,6 +1521,19 @@ static inline u32 mtk_get_ib2_multicast_
return MTK_FOE_IB2_MULTICAST;
}
/* read the hardware status register */
void mtk_stats_update_mac(struct mtk_mac *mac);
-@@ -1467,8 +1540,10 @@ u32 mtk_r32(struct mtk_eth *eth, unsigne
+@@ -1469,8 +1542,10 @@ u32 mtk_r32(struct mtk_eth *eth, unsigne
u32 mtk_m32(struct mtk_eth *eth, u32 mask, u32 set, unsigned int reg);
int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id);
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -5446,7 +5446,7 @@ static const struct mtk_soc_data mt2701_
+@@ -5450,7 +5450,7 @@ static const struct mtk_soc_data mt2701_
.desc_size = sizeof(struct mtk_rx_dma),
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
-@@ -5474,7 +5474,7 @@ static const struct mtk_soc_data mt7621_
+@@ -5478,7 +5478,7 @@ static const struct mtk_soc_data mt7621_
.desc_size = sizeof(struct mtk_rx_dma),
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
-@@ -5504,7 +5504,7 @@ static const struct mtk_soc_data mt7622_
+@@ -5508,7 +5508,7 @@ static const struct mtk_soc_data mt7622_
.desc_size = sizeof(struct mtk_rx_dma),
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
-@@ -5533,7 +5533,7 @@ static const struct mtk_soc_data mt7623_
+@@ -5537,7 +5537,7 @@ static const struct mtk_soc_data mt7623_
.desc_size = sizeof(struct mtk_rx_dma),
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
-@@ -5559,7 +5559,7 @@ static const struct mtk_soc_data mt7629_
+@@ -5563,7 +5563,7 @@ static const struct mtk_soc_data mt7629_
.desc_size = sizeof(struct mtk_rx_dma),
.irq_done_mask = MTK_RX_DONE_INT,
.dma_l4_valid = RX_DMA_L4_VALID,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
-@@ -5591,7 +5591,7 @@ static const struct mtk_soc_data mt7981_
+@@ -5595,7 +5595,7 @@ static const struct mtk_soc_data mt7981_
.dma_l4_valid = RX_DMA_L4_VALID_V2,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
};
-@@ -5621,7 +5621,7 @@ static const struct mtk_soc_data mt7986_
+@@ -5625,7 +5625,7 @@ static const struct mtk_soc_data mt7986_
.dma_l4_valid = RX_DMA_L4_VALID_V2,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
},
};
-@@ -5674,7 +5674,7 @@ static const struct mtk_soc_data rt5350_
+@@ -5678,7 +5678,7 @@ static const struct mtk_soc_data rt5350_
.dma_l4_valid = RX_DMA_L4_VALID_PDMA,
.dma_max_len = MTK_TX_DMA_BUF_LEN,
.dma_len_offset = 16,
help
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -4566,6 +4566,7 @@ static int mtk_get_sset_count(struct net
+@@ -4562,6 +4562,7 @@ static int mtk_get_sset_count(struct net
static void mtk_ethtool_pp_stats(struct mtk_eth *eth, u64 *data)
{
struct page_pool_stats stats = {};
int i;
-@@ -4578,6 +4579,7 @@ static void mtk_ethtool_pp_stats(struct
+@@ -4574,6 +4575,7 @@ static void mtk_ethtool_pp_stats(struct
page_pool_get_stats(ring->page_pool, &stats);
}
page_pool_ethtool_stats_get(data, &stats);