[][kernel][mt7988][eth][Fix DMA init timeout in network-restart stress test]
[Description]
Fix DMA init timeout in network-restart stress test :
1. Turn on the gmac forwarding when mkt_open is only halfway initialized
or start deinit in mtk_close without forbid forwarding in gmac, this
can lead to unknown exceptions.
2. Update the init/deinit order in mtk_open/mtk_close.
3. Move the configure of gdm from mtk_mac_config to mtk_hw_init, avoid
asynchronous operations on gdm config.
4. Update related patches.
[Release-log]
N/A
Change-Id: I80f594948b0c0ddc7eb34bb47e78e2ff74229f6a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6728789
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
index 55234b3..813ccfc 100755
--- a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9990-mt7622-backport-nf-hw-offload-framework-and-ups.patch
@@ -74,27 +74,27 @@
index 2b21f7ed0..819d8a0be 100755
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -2654,12 +2654,17 @@ static int mtk_open(struct net_device *dev)
+@@ -3081,6 +3081,7 @@ static int mtk_open(struct net_device *d
+ struct mtk_phylink_priv *phylink_priv = &mac->phylink_priv;
+ int err, i;
+ struct device_node *phy_node;
++ u32 gdm_config = MTK_GDMA_TO_PDMA;
- /* we run 2 netdevs on the same dma ring so we only bring it up once */
- if (!refcount_read(ð->dma_refcnt)) {
-- int err = mtk_start_dma(eth);
-+ u32 gdm_config = MTK_GDMA_TO_PDMA;
-+ int err;
+ err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0);
+ if (err) {
+@@ -3157,7 +3158,10 @@ static int mtk_open(struct net_device *d
+ if (!phy_node && eth->xgmii->regmap_sgmii[mac->id])
+ regmap_write(eth->xgmii->regmap_sgmii[mac->id], SGMSYS_QPHY_PWR_STATE_CTRL, 0);
-+ err = mtk_start_dma(eth);
- if (err)
- return err;
-
-- mtk_gdm_config(eth, MTK_GDMA_TO_PDMA);
-+ if (eth->soc->offload_version && mtk_ppe_start(ð->ppe) == 0)
+- mtk_gdm_config(eth, mac->id, MTK_GDMA_TO_PDMA);
++ if (eth->soc->offload_version && mtk_ppe_start(ð->ppe) == 0)
+ gdm_config = MTK_GDMA_TO_PPE;
+
-+ mtk_gdm_config(eth, gdm_config);
++ mtk_gdm_config(eth, mac->id, gdm_config);
- /* Indicates CDM to parse the MTK special tag from CPU */
- if (netdev_uses_dsa(dev)) {
-@@ -2772,6 +2777,9 @@ static int mtk_stop(struct net_device *dev)
+ return 0;
+ }
+@@ -3238,6 +3242,9 @@ static int mtk_stop(struct net_device *d
mtk_dma_free(eth);
@@ -104,7 +104,7 @@
return 0;
}
-@@ -3391,6 +3399,7 @@ static const struct net_device_ops mtk_netdev_ops = {
+@@ -3915,6 +3922,7 @@ static const struct net_device_ops mtk_n
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = mtk_poll_controller,
#endif
@@ -112,7 +112,7 @@
};
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
-@@ -3682,6 +3691,17 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4308,6 +4316,17 @@ static int mtk_probe(struct platform_dev
goto err_free_dev;
}
@@ -130,62 +130,38 @@
for (i = 0; i < MTK_MAX_DEVS; i++) {
if (!eth->netdev[i])
continue;
-@@ -3781,12 +3801,13 @@ static const struct mtk_soc_data mt2701_data = {
+@@ -4410,6 +4429,7 @@ static const struct mtk_soc_data mt2701_
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
.has_sram = false,
+ .offload_version = 2,
- .txrx = {
- .txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
- static const struct mtk_soc_data mt7621_data = {
-@@ -3789,12 +3810,13 @@ static const struct mtk_soc_data mt7621_data = {
+ .txrx = {
+ .txd_size = sizeof(struct mtk_tx_dma),
+ .rxd_size = sizeof(struct mtk_rx_dma),
+@@ -4424,6 +4444,7 @@ static const struct mtk_soc_data mt7621_
.required_clks = MT7621_CLKS_BITMAP,
.required_pctl = false,
.has_sram = false,
+ .offload_version = 2,
- .txrx = {
- .txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
- static const struct mtk_soc_data mt7622_data = {
-@@ -3798,12 +3820,13 @@ static const struct mtk_soc_data mt7622_data = {
+ .txrx = {
+ .txd_size = sizeof(struct mtk_tx_dma),
+ .rxd_size = sizeof(struct mtk_rx_dma),
+@@ -4439,6 +4460,7 @@ static const struct mtk_soc_data mt7622_
.required_clks = MT7622_CLKS_BITMAP,
.required_pctl = false,
.has_sram = false,
+ .offload_version = 2,
- .txrx = {
- .txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
- static const struct mtk_soc_data mt7623_data = {
-@@ -3806,12 +3829,13 @@ static const struct mtk_soc_data mt7623_data = {
+ .txrx = {
+ .txd_size = sizeof(struct mtk_tx_dma),
+ .rxd_size = sizeof(struct mtk_rx_dma),
+@@ -4453,6 +4475,7 @@ static const struct mtk_soc_data mt7623_
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
.has_sram = false,
+ .offload_version = 2,
- .txrx = {
- .txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
- static const struct mtk_soc_data mt7629_data = {
+ .txrx = {
+ .txd_size = sizeof(struct mtk_tx_dma),
+ .rxd_size = sizeof(struct mtk_rx_dma),
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index b6380ffeb..349f98503 100755
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9993-add-wed.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9993-add-wed.patch
index 7aabbeb..baa88ef 100755
--- a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9993-add-wed.patch
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9993-add-wed.patch
@@ -146,8 +146,7 @@
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/clk.h>
-@@ -19,13 +20,15 @@
- #include <linux/interrupt.h>
+@@ -20,12 +21,14 @@
#include <linux/pinctrl/devinfo.h>
#include <linux/phylink.h>
#include <linux/gpio/consumer.h>
@@ -162,7 +161,7 @@
#if defined(CONFIG_NET_MEDIATEK_HNAT) || defined(CONFIG_NET_MEDIATEK_HNAT_MODULE)
#include "mtk_hnat/nf_hnat_mtk.h"
-@@ -850,7 +853,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
+@@ -1116,7 +1119,7 @@ static int mtk_init_fq_dma(struct mtk_et
int i;
if (!eth->soc->has_sram) {
@@ -170,8 +169,8 @@
+ eth->scratch_ring = dma_alloc_coherent(eth->dma_dev,
cnt * soc->txrx.txd_size,
ð->phy_scratch_ring,
- GFP_ATOMIC);
-@@ -866,10 +869,10 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
+ GFP_KERNEL);
+@@ -1134,10 +1137,10 @@ static int mtk_init_fq_dma(struct mtk_et
if (unlikely(!eth->scratch_head))
return -ENOMEM;
@@ -184,7 +183,7 @@
return -ENOMEM;
phy_ring_tail = eth->phy_scratch_ring +
-@@ -933,26 +936,26 @@ static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf,
+@@ -1201,26 +1204,26 @@ static void mtk_tx_unmap(struct mtk_eth
{
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
if (tx_buf->flags & MTK_TX_FLAGS_SINGLE0) {
@@ -215,8 +214,8 @@
dma_unmap_addr(tx_buf, dma_addr1),
dma_unmap_len(tx_buf, dma_len1),
DMA_TO_DEVICE);
-@@ -1017,9 +1020,9 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
- itx_buf = mtk_desc_to_tx_buf(ring, itxd);
+@@ -1454,9 +1457,9 @@ static int mtk_tx_map(struct sk_buff *sk
+ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size);
memset(itx_buf, 0, sizeof(*itx_buf));
- txd_info.addr = dma_map_single(eth->dev, skb->data, txd_info.size,
@@ -226,8 +225,8 @@
+ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr)))
return -ENOMEM;
- WRITE_ONCE(itxd->txd1, mapped_addr);
-@@ -1114,10 +1117,10 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,
+ mtk_tx_set_dma_desc(skb, dev, itxd, &txd_info);
+@@ -1497,10 +1500,10 @@ static int mtk_tx_map(struct sk_buff *sk
txd_info.qid = skb->mark & MTK_QDMA_TX_MASK;
txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 &&
!(frag_size - txd_info.size);
@@ -240,15 +239,15 @@
goto err_dma;
mtk_tx_set_dma_desc(skb, dev, txd, &txd_info);
-@@ -1384,6 +1387,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
- struct net_device *netdev;
+@@ -1737,6 +1740,7 @@ static int mtk_poll_rx(struct napi_struc
+ struct net_device *netdev = NULL;
unsigned int pktlen;
dma_addr_t dma_addr = 0;
+ u32 hash, reason;
int mac = 0;
if (eth->hwlro)
-@@ -1427,22 +1431,22 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
+@@ -1787,12 +1791,12 @@ static int mtk_poll_rx(struct napi_struc
netdev->stats.rx_dropped++;
goto release_desc;
}
@@ -263,8 +262,7 @@
skb_free_frag(new_data);
netdev->stats.rx_dropped++;
goto release_desc;
- }
-
+@@ -1801,7 +1805,7 @@ static int mtk_poll_rx(struct napi_struc
addr64 = (MTK_HAS_CAPS(eth->soc->caps, MTK_8GB_ADDRESSING)) ?
((u64)(trxd.rxd2 & 0xf)) << 32 : 0;
@@ -273,8 +271,7 @@
(u64)(trxd.rxd1 | addr64),
ring->buf_size, DMA_FROM_DEVICE);
- /* receive data */
-@@ -1463,6 +1467,17 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
+@@ -1827,6 +1831,17 @@ static int mtk_poll_rx(struct napi_struc
skb_checksum_none_assert(skb);
skb->protocol = eth_type_trans(skb, netdev);
@@ -290,9 +287,9 @@
+ trxd.rxd4 & MTK_RXD4_FOE_ENTRY);
+
if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
- if (trxd.rxd3 & RX_DMA_VTAG_V2)
-@@ -1748,7 +1763,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) ||
+ MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) {
+@@ -2120,7 +2135,7 @@ static int mtk_tx_alloc(struct mtk_eth *
goto no_tx_mem;
if (!eth->soc->has_sram)
@@ -300,8 +297,8 @@
+ ring->dma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz,
&ring->phys, GFP_KERNEL);
else {
- ring->dma = eth->scratch_ring + MTK_DMA_SIZE;
-@@ -1780,6 +1795,6 @@ static int mtk_tx_alloc(struct mtk_eth *eth)
+ ring->dma = eth->scratch_ring + MTK_DMA_SIZE * sz;
+@@ -2154,7 +2169,7 @@ static int mtk_tx_alloc(struct mtk_eth *
* descriptors in ring->dma_pdma.
*/
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
@@ -309,7 +306,8 @@
+ ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz,
&ring->phys_pdma, GFP_KERNEL);
if (!ring->dma_pdma)
-@@ -1839,6 +1854,6 @@ static void mtk_tx_clean(struct mtk_eth *eth)
+ goto no_tx_mem;
+@@ -2215,14 +2230,14 @@ static void mtk_tx_clean(struct mtk_eth
}
if (!eth->soc->has_sram && ring->dma) {
@@ -317,7 +315,7 @@
+ dma_free_coherent(eth->dma_dev,
MTK_DMA_SIZE * soc->txrx.txd_size,
ring->dma, ring->phys);
-@@ -1847,6 +1862,6 @@ static void mtk_tx_clean(struct mtk_eth *eth)
+ ring->dma = NULL;
}
if (ring->dma_pdma) {
@@ -325,7 +323,8 @@
+ dma_free_coherent(eth->dma_dev,
MTK_DMA_SIZE * soc->txrx.txd_size,
ring->dma_pdma, ring->phys_pdma);
-@@ -1892,7 +1907,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
+ ring->dma_pdma = NULL;
+@@ -2267,7 +2282,7 @@ static int mtk_rx_alloc(struct mtk_eth *
if ((!eth->soc->has_sram) || (eth->soc->has_sram
&& (rx_flag != MTK_RX_FLAGS_NORMAL)))
@@ -334,12 +333,10 @@
rx_dma_size * eth->soc->txrx.rxd_size,
&ring->phys, GFP_KERNEL);
else {
-@@ -1907,13 +1922,13 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
- return -ENOMEM;
-
+@@ -2284,11 +2299,11 @@ static int mtk_rx_alloc(struct mtk_eth *
for (i = 0; i < rx_dma_size; i++) {
struct mtk_rx_dma_v2 *rxd;
-
+
- dma_addr_t dma_addr = dma_map_single(eth->dev,
+ dma_addr_t dma_addr = dma_map_single(eth->dma_dev,
ring->data[i] + NET_SKB_PAD + eth->ip_align,
@@ -348,9 +345,9 @@
- if (unlikely(dma_mapping_error(eth->dev, dma_addr)))
+ if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
return -ENOMEM;
-
+
rxd = ring->dma + i * eth->soc->txrx.rxd_size;
-@@ -1968,7 +1983,7 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring, int in_s
+@@ -2360,7 +2375,7 @@ static void mtk_rx_clean(struct mtk_eth
MTK_8GB_ADDRESSING)) ?
((u64)(rxd->rxd2 & 0xf)) << 32 : 0;
@@ -359,7 +356,7 @@
(u64)(rxd->rxd1 | addr64),
ring->buf_size,
DMA_FROM_DEVICE);
-@@ -1982,7 +1997,7 @@ static void mtk_rx_clean(struct mtk_eth *eth, struct mtk_rx_ring *ring, int in_s
+@@ -2374,7 +2389,7 @@ static void mtk_rx_clean(struct mtk_eth
return;
if (ring->dma) {
@@ -368,7 +365,7 @@
ring->dma_size * eth->soc->txrx.rxd_size,
ring->dma,
ring->phys);
-@@ -2462,6 +2477,6 @@ static void mtk_dma_free(struct mtk_eth *eth)
+@@ -2861,7 +2876,7 @@ static void mtk_dma_free(struct mtk_eth
if (eth->netdev[i])
netdev_reset_queue(eth->netdev[i]);
if ( !eth->soc->has_sram && eth->scratch_ring) {
@@ -376,16 +373,8 @@
+ dma_free_coherent(eth->dma_dev,
MTK_DMA_SIZE * soc->txrx.txd_size,
eth->scratch_ring, eth->phy_scratch_ring);
-@@ -2661,7 +2676,7 @@ static int mtk_open(struct net_device *dev)
- if (err)
- return err;
-
-- if (eth->soc->offload_version && mtk_ppe_start(ð->ppe) == 0)
-+ if (eth->soc->offload_version && mtk_ppe_start(eth->ppe) == 0)
- gdm_config = MTK_GDMA_TO_PPE;
-
- mtk_gdm_config(eth, gdm_config);
-@@ -2778,7 +2793,7 @@ static int mtk_stop(struct net_device *dev)
+ eth->scratch_ring = NULL;
+@@ -3243,7 +3258,7 @@ static int mtk_stop(struct net_device *d
mtk_dma_free(eth);
if (eth->soc->offload_version)
@@ -394,16 +383,16 @@
return 0;
}
-@@ -2855,6 +2870,8 @@ static int mtk_napi_init(struct mtk_eth *eth)
+@@ -3320,6 +3335,8 @@ static int mtk_napi_init(struct mtk_eth
static int mtk_hw_init(struct mtk_eth *eth, u32 type)
{
+ u32 dma_mask = ETHSYS_DMA_AG_MAP_PDMA | ETHSYS_DMA_AG_MAP_QDMA |
+ ETHSYS_DMA_AG_MAP_PPE;
int i, ret = 0;
+ u32 val;
- pr_info("[%s] reset_lock:%d, force:%d\n", __func__,
-@@ -2872,6 +2889,10 @@ static int mtk_hw_init(struct mtk_eth *eth, u32 type)
+@@ -3338,6 +3355,10 @@ static int mtk_hw_init(struct mtk_eth *e
goto err_disable_pm;
}
@@ -414,7 +403,7 @@
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
ret = device_reset(eth->dev);
if (ret) {
-@@ -3501,6 +3522,35 @@ free_netdev:
+@@ -4091,6 +4112,35 @@ free_netdev:
return err;
}
@@ -450,7 +439,7 @@
static int mtk_probe(struct platform_device *pdev)
{
struct device_node *mac_np;
-@@ -3514,6 +3564,7 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4104,6 +4154,7 @@ static int mtk_probe(struct platform_dev
eth->soc = of_device_get_match_data(&pdev->dev);
eth->dev = &pdev->dev;
@@ -458,7 +447,7 @@
eth->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(eth->base))
return PTR_ERR(eth->base);
-@@ -3567,6 +3618,16 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4176,6 +4227,16 @@ static int mtk_probe(struct platform_dev
}
}
@@ -473,9 +462,9 @@
+ }
+
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) {
- eth->sgmii = devm_kzalloc(eth->dev, sizeof(*eth->sgmii),
+ eth->xgmii = devm_kzalloc(eth->dev, sizeof(*eth->xgmii),
GFP_KERNEL);
-@@ -3589,6 +3650,22 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4217,6 +4278,22 @@ static int mtk_probe(struct platform_dev
}
}
@@ -498,7 +487,7 @@
for (i = 0; i < MTK_MAX_IRQ_NUM; i++) {
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0)
eth->irq[i] = eth->irq[0];
-@@ -3692,10 +3769,11 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4320,10 +4397,11 @@ static int mtk_probe(struct platform_dev
}
if (eth->soc->offload_version) {
@@ -519,9 +508,9 @@
index 349f98503..b52378bd6
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
-@@ -517,6 +517,9 @@
+@@ -549,6 +549,9 @@
#define RX_DMA_SPORT_MASK 0x7
- #endif
+ #define RX_DMA_SPORT_MASK_V2 0xf
+#define MTK_WDMA0_BASE 0x2800
+#define MTK_WDMA1_BASE 0x2c00
@@ -529,7 +518,7 @@
/* QDMA descriptor txd4 */
#define TX_DMA_CHKSUM (0x7 << 29)
#define TX_DMA_TSO BIT(28)
-@@ -704,6 +707,12 @@
+@@ -773,6 +776,12 @@
#define ETHSYS_FE_RST_CHK_IDLE_EN 0x28
@@ -542,7 +531,7 @@
/* SGMII subsystem config registers */
/* Register to auto-negotiation restart */
#define SGMSYS_PCS_CONTROL_1 0x0
-@@ -1209,6 +1218,7 @@ struct mtk_reset_event {
+@@ -1520,6 +1529,7 @@ struct mtk_phylink_priv {
/* struct mtk_eth - This is the main datasructure for holding the state
* of the driver
* @dev: The device pointer
@@ -550,15 +539,15 @@
* @base: The mapped register i/o base
* @page_lock: Make sure that register operations are atomic
* @tx_irq__lock: Make sure that IRQ register operations are atomic
-@@ -1243,6 +1253,7 @@ struct mtk_reset_event {
+@@ -1554,6 +1564,7 @@ struct mtk_phylink_priv {
struct mtk_eth {
struct device *dev;
+ struct device *dma_dev;
void __iomem *base;
+ void __iomem *sram_base;
spinlock_t page_lock;
- spinlock_t tx_irq_lock;
-@@ -1283,7 +1294,7 @@ struct mtk_eth {
+@@ -1596,7 +1607,7 @@ struct mtk_eth {
spinlock_t syscfg0_lock;
struct timer_list mtk_dma_monitor_timer;
@@ -567,13 +556,15 @@
struct rhashtable flow_table;
};
-@@ -1336,5 +1347,6 @@ void ethsys_reset(struct mtk_eth *eth, u32 reset_bits);
+@@ -1655,6 +1666,7 @@ void ethsys_reset(struct mtk_eth *eth, u
int mtk_eth_offload_init(struct mtk_eth *eth);
int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type,
void *type_data);
+void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev);
- #endif /* MTK_ETH_H */
+ int mtk_mac2xgmii_id(struct mtk_eth *eth, int mac_id);
+ int mtk_usxgmii_init(struct mtk_xgmii *ss, struct device_node *r);
+
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
old mode 100644
new mode 100755
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9995-flow-offload-add-mkhnat-dual-ppe-new-v2.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9995-flow-offload-add-mkhnat-dual-ppe-new-v2.patch
index 6ff62ff..cfb1ad6 100755
--- a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9995-flow-offload-add-mkhnat-dual-ppe-new-v2.patch
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9995-flow-offload-add-mkhnat-dual-ppe-new-v2.patch
@@ -31,15 +31,15 @@
index 01fc1e5c0..3f67bebfe 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -1379,6 +1379,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
+@@ -1732,6 +1732,7 @@ static int mtk_poll_rx(struct napi_struc
u8 *data, *new_data;
- struct mtk_rx_dma *rxd, trxd;
+ struct mtk_rx_dma_v2 *rxd, trxd;
int done = 0;
+ int i;
if (unlikely(!ring))
goto rx_done;
-@@ -1479,14 +1480,20 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
+@@ -1843,14 +1844,20 @@ static int mtk_poll_rx(struct napi_struc
#if defined(CONFIG_MEDIATEK_NETSYS_V2)
reason = FIELD_GET(MTK_RXD5_PPE_CPU_REASON_V2, trxd.rxd5);
@@ -66,22 +66,22 @@
#endif
if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
-@@ -2687,8 +2694,12 @@ static int mtk_open(struct net_device *dev)
- if (err)
- return err;
+@@ -3184,8 +3191,12 @@ static int mtk_open(struct net_device *d
+ if (!phy_node && eth->xgmii->regmap_sgmii[mac->id])
+ regmap_write(eth->xgmii->regmap_sgmii[mac->id], SGMSYS_QPHY_PWR_STATE_CTRL, 0);
-- if (eth->soc->offload_version && mtk_ppe_start(eth->ppe) == 0)
+- if (eth->soc->offload_version && mtk_ppe_start(ð->ppe) == 0)
- gdm_config = MTK_GDMA_TO_PPE;
-+ if (eth->soc->offload_version) {
++ if (eth->soc->offload_version) {
+ gdm_config = MTK_GDMA_TO_PPE0;
+
+ for (i = 0; i < eth->ppe_num; i++)
+ mtk_ppe_start(eth->ppe[i]);
+ }
- mtk_gdm_config(eth, gdm_config);
+ mtk_gdm_config(eth, mac->id, gdm_config);
-@@ -2803,8 +2814,10 @@ static int mtk_stop(struct net_device *dev)
+@@ -3268,8 +3279,10 @@ static int mtk_stop(struct net_device *d
mtk_dma_free(eth);
@@ -94,7 +94,7 @@
return 0;
}
-@@ -3780,15 +3793,35 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4408,15 +4421,35 @@ static int mtk_probe(struct platform_dev
}
if (eth->soc->offload_version) {
@@ -141,9 +141,9 @@
index fce1a7172..b4de7c0c6 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
-@@ -110,7 +110,12 @@
- #define MTK_GDMA_TCS_EN BIT(21)
+@@ -118,7 +118,12 @@
#define MTK_GDMA_UCS_EN BIT(20)
+ #define MTK_GDMA_STRP_CRC BIT(16)
#define MTK_GDMA_TO_PDMA 0x0
-#define MTK_GDMA_TO_PPE 0x3333
+#if defined(CONFIG_MEDIATEK_NETSYS_V2)
@@ -154,8 +154,8 @@
+#endif
#define MTK_GDMA_DROP_ALL 0x7777
- /* Unicast Filter MAC Address Register - Low */
-@@ -1299,7 +1300,8 @@ struct mtk_eth {
+ /* GDM Egress Control Register */
+@@ -1612,7 +1617,8 @@ struct mtk_eth {
spinlock_t syscfg0_lock;
struct timer_list mtk_dma_monitor_timer;
@@ -165,8 +165,8 @@
struct rhashtable flow_table;
};
-@@ -1349,9 +1351,11 @@ int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id);
- void mtk_gdm_config(struct mtk_eth *eth, u32 config);
+@@ -1668,11 +1674,13 @@ int mtk_gmac_usxgmii_path_setup(struct m
+ void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config);
void ethsys_reset(struct mtk_eth *eth, u32 reset_bits);
-int mtk_eth_offload_init(struct mtk_eth *eth);
@@ -178,6 +178,8 @@
+int mtk_ppe_debugfs_init(struct mtk_eth *eth);
+
int mtk_mac2xgmii_id(struct mtk_eth *eth, int mac_id);
+ int mtk_usxgmii_init(struct mtk_xgmii *ss, struct device_node *r);
+ int mtk_xfi_pextp_init(struct mtk_xgmii *ss, struct device_node *r);
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
index d46e91178..3d6ff30ba 100755
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
diff --git a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9998-ethernet-update-ppe-backward-compatible-two-way-hash.patch b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9998-ethernet-update-ppe-backward-compatible-two-way-hash.patch
index 244788d..ab5bbab 100644
--- a/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9998-ethernet-update-ppe-backward-compatible-two-way-hash.patch
+++ b/autobuild_mac80211_release/target/linux/mediatek/patches-5.4/9998-ethernet-update-ppe-backward-compatible-two-way-hash.patch
@@ -2,7 +2,7 @@
index 2c54c9c..d3ba9eb 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -3814,7 +3814,8 @@ static int mtk_probe(struct platform_device *pdev)
+@@ -4442,7 +4442,8 @@ static int mtk_probe(struct platform_dev
for (i = 0; i < eth->ppe_num; i++) {
eth->ppe[i] = mtk_ppe_init(eth,
@@ -12,7 +12,7 @@
if (!eth->ppe[i]) {
err = -ENOMEM;
goto err_free_dev;
-@@ -3927,12 +3928,13 @@ static const struct mtk_soc_data mt2701_data = {
+@@ -4558,6 +4559,7 @@ static const struct mtk_soc_data mt2701_
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
.has_sram = false,
@@ -20,13 +20,7 @@
.offload_version = 2,
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
-@@ -3936,12 +3938,13 @@ static const struct mtk_soc_data mt7621_data = {
+@@ -4573,6 +4575,7 @@ static const struct mtk_soc_data mt7621_
.required_clks = MT7621_CLKS_BITMAP,
.required_pctl = false,
.has_sram = false,
@@ -34,13 +28,7 @@
.offload_version = 2,
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
-@@ -3946,12 +3949,13 @@ static const struct mtk_soc_data mt7622_data = {
+@@ -4589,6 +4592,7 @@ static const struct mtk_soc_data mt7622_
.required_clks = MT7622_CLKS_BITMAP,
.required_pctl = false,
.has_sram = false,
@@ -48,13 +36,7 @@
.offload_version = 2,
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
-@@ -3955,12 +3959,13 @@ static const struct mtk_soc_data mt7623_data = {
+@@ -4604,6 +4608,7 @@ static const struct mtk_soc_data mt7623_
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
.has_sram = false,
@@ -62,13 +44,7 @@
.offload_version = 2,
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma),
- .rxd_size = sizeof(struct mtk_rx_dma),
- .dma_max_len = MTK_TX_DMA_BUF_LEN,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT,
- },
- };
-
-@@ -3974,12 +3979,13 @@ static const struct mtk_soc_data mt7986_data = {
+@@ -4635,6 +4640,7 @@ static const struct mtk_soc_data mt7986_
.required_clks = MT7986_CLKS_BITMAP,
.required_pctl = false,
.has_sram = true,
@@ -76,13 +52,7 @@
.offload_version = 2,
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma_v2),
- .rxd_size = sizeof(struct mtk_rx_dma_v2),
- .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT_V2,
- },
- };
-
-@@ -3984,12 +3990,14 @@ static const struct mtk_soc_data mt7981_data = {
+@@ -4651,6 +4657,8 @@ static const struct mtk_soc_data mt7981_
.required_clks = MT7981_CLKS_BITMAP,
.required_pctl = false,
.has_sram = true,
@@ -91,18 +61,12 @@
.txrx = {
.txd_size = sizeof(struct mtk_tx_dma_v2),
.rxd_size = sizeof(struct mtk_rx_dma_v2),
- .dma_max_len = MTK_TX_DMA_BUF_LEN_V2,
- .dma_len_offset = MTK_TX_DMA_BUF_SHIFT_V2,
- },
- };
-
- static const struct mtk_soc_data rt5350_data = {
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 4a69bd0..35a7543 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
-@@ -1188,6 +1188,7 @@ struct mtk_soc_data {
- u32 caps;
+@@ -1472,6 +1472,7 @@ struct mtk_soc_data {
+ u64 caps;
u32 required_clks;
bool required_pctl;
+ u8 hash_way;
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
index 4655356..e983d6e 100644
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_reset.c
@@ -367,7 +367,8 @@
mtk_w32(eth, val & ~(MAC_MCR_RX_EN), MTK_MAC_MCR(1));
/* Enable GDM drop */
- mtk_gdm_config(eth, MTK_GDMA_DROP_ALL);
+ for (i = 0; i < MTK_MAC_COUNT; i++)
+ mtk_gdm_config(eth, i, MTK_GDMA_DROP_ALL);
/* Disable ADMA Rx */
val = mtk_r32(eth, MTK_PDMA_GLO_CFG);
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 89f1150..889b7fd 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -283,11 +283,6 @@
val |= (GSW_IPG_11 << GSWTX_IPG_SHIFT) |
(GSW_IPG_11 << GSWRX_IPG_SHIFT);
mtk_w32(eth, val, MTK_GSW_CFG);
-
- /* Disable GDM1 RX CRC stripping */
- val = mtk_r32(eth, MTK_GDMA_FWD_CFG(0));
- val &= ~MTK_GDMA_STRP_CRC;
- mtk_w32(eth, val, MTK_GDMA_FWD_CFG(0));
}
static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
@@ -3045,29 +3040,27 @@
return 0;
}
-void mtk_gdm_config(struct mtk_eth *eth, u32 config)
+void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
{
- int i;
+ u32 val;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
return;
- for (i = 0; i < MTK_MAC_COUNT; i++) {
- u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
+ val = mtk_r32(eth, MTK_GDMA_FWD_CFG(id));
- /* default setup the forward port to send frame to PDMA */
- val &= ~0xffff;
+ /* default setup the forward port to send frame to PDMA */
+ val &= ~0xffff;
- /* Enable RX checksum */
- val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
+ /* Enable RX checksum */
+ val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
- val |= config;
+ val |= config;
- if (eth->netdev[i] && netdev_uses_dsa(eth->netdev[i]))
- val |= MTK_GDMA_SPECIAL_TAG;
+ if (eth->netdev[id] && netdev_uses_dsa(eth->netdev[id]))
+ val |= MTK_GDMA_SPECIAL_TAG;
- mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
- }
+ mtk_w32(eth, val, MTK_GDMA_FWD_CFG(id));
}
void mtk_set_pse_drop(u32 config)
@@ -3101,7 +3094,6 @@
if (err)
return err;
- mtk_gdm_config(eth, MTK_GDMA_TO_PDMA);
/* Indicates CDM to parse the MTK special tag from CPU */
if (netdev_uses_dsa(dev)) {
@@ -3163,6 +3155,8 @@
if (!phy_node && eth->xgmii->regmap_sgmii[mac->id])
regmap_write(eth->xgmii->regmap_sgmii[mac->id], SGMSYS_QPHY_PWR_STATE_CTRL, 0);
+ mtk_gdm_config(eth, mac->id, MTK_GDMA_TO_PDMA);
+
return 0;
}
@@ -3197,6 +3191,7 @@
u32 val = 0;
struct device_node *phy_node;
+ mtk_gdm_config(eth, mac->id, MTK_GDMA_DROP_ALL);
netif_tx_disable(dev);
phy_node = of_parse_phandle(mac->of_node, "phy-handle", 0);
@@ -3222,7 +3217,6 @@
if (!refcount_dec_and_test(ð->dma_refcnt))
return 0;
- mtk_gdm_config(eth, MTK_GDMA_DROP_ALL);
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
mtk_rx_irq_disable(eth, MTK_RX_DONE_INT(0));
@@ -3318,6 +3312,7 @@
static int mtk_hw_init(struct mtk_eth *eth, u32 type)
{
int i, ret = 0;
+ u32 val;
pr_info("[%s] reset_lock:%d, force:%d\n", __func__,
atomic_read(&reset_lock), atomic_read(&force));
@@ -3420,6 +3415,11 @@
mtk_w32(eth, 0x00000707, MTK_CDMW0_THRES);
mtk_w32(eth, 0x00000077, MTK_CDMW1_THRES);
+ /* Disable GDM1 RX CRC stripping */
+ val = mtk_r32(eth, MTK_GDMA_FWD_CFG(0));
+ val &= ~MTK_GDMA_STRP_CRC;
+ mtk_w32(eth, val, MTK_GDMA_FWD_CFG(0));
+
/* PSE GDM3 MIB counter has incorrect hw default values,
* so the driver ought to read clear the values beforehand
* in case ethtool retrieve wrong mib values.
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 2f54f96..b617c13 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -1635,7 +1635,7 @@
int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id);
int mtk_gmac_rgmii_path_setup(struct mtk_eth *eth, int mac_id);
int mtk_gmac_usxgmii_path_setup(struct mtk_eth *eth, int mac_id);
-void mtk_gdm_config(struct mtk_eth *eth, u32 config);
+void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config);
void ethsys_reset(struct mtk_eth *eth, u32 reset_bits);
int mtk_mac2xgmii_id(struct mtk_eth *eth, int mac_id);