From 7472476aef263bbf49b19d084875caddb7fe8f2a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 29 Mar 2023 11:38:30 +0200 Subject: [PATCH 1/8] kernel: fix mtk_eth_soc throughput regressions on gigabit PHY ports Fixes issues on MT7621 and MT7623 switch ports, and PHY ports on all SoC Signed-off-by: Felix Fietkau --- ..._eth_soc-fix-tx-throughput-regressio.patch | 31 ++++++++++++++ ...t-mtk_eth_soc-add-support-for-MT7981.patch | 4 +- ..._eth_soc-set-MDIO-bus-clock-frequenc.patch | 4 +- ..._eth_soc-switch-to-external-PCS-driv.patch | 10 ++--- ...net-mtk_eth_soc-enable-threaded-NAPI.patch | 6 +-- ...iatek-ppe-add-support-for-flow-accou.patch | 8 ++-- ..._eth_soc-drop-generic-vlan-rx-offloa.patch | 14 +++---- ..._eth_soc-work-around-issue-with-send.patch | 6 +-- ..._eth_soc-fix-remaining-throughput-re.patch | 42 +++++++++++++++++++ ..._eth_soc-implement-Clause-45-MDIO-ac.patch | 2 +- 10 files changed, 100 insertions(+), 27 deletions(-) create mode 100644 target/linux/generic/backport-5.15/730-18-v6.3-net-ethernet-mtk_eth_soc-fix-tx-throughput-regressio.patch create mode 100644 target/linux/generic/pending-5.15/732-03-net-ethernet-mtk_eth_soc-fix-remaining-throughput-re.patch diff --git a/target/linux/generic/backport-5.15/730-18-v6.3-net-ethernet-mtk_eth_soc-fix-tx-throughput-regressio.patch b/target/linux/generic/backport-5.15/730-18-v6.3-net-ethernet-mtk_eth_soc-fix-tx-throughput-regressio.patch new file mode 100644 index 00000000000..e633f6f1fb8 --- /dev/null +++ b/target/linux/generic/backport-5.15/730-18-v6.3-net-ethernet-mtk_eth_soc-fix-tx-throughput-regressio.patch @@ -0,0 +1,31 @@ +From: Felix Fietkau +Date: Fri, 24 Mar 2023 14:56:58 +0100 +Subject: [PATCH] net: ethernet: mtk_eth_soc: fix tx throughput regression with + direct 1G links + +Using the QDMA tx scheduler to throttle tx to line speed works fine for +switch ports, but apparently caused a regression on non-switch ports. + +Based on a number of tests, it seems that this throttling can be safely +dropped without re-introducing the issues on switch ports that the +tx scheduling changes resolved. + +Link: https://lore.kernel.org/netdev/trinity-92c3826f-c2c8-40af-8339-bc6d0d3ffea4-1678213958520@3c-app-gmx-bs16/ +Fixes: f63959c7eec3 ("net: ethernet: mtk_eth_soc: implement multi-queue support for per-port queues") +Reported-by: Frank Wunderlich +Reported-by: Daniel Golle +Tested-by: Daniel Golle +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -676,8 +676,6 @@ static void mtk_mac_link_up(struct phyli + break; + } + +- mtk_set_queue_speed(mac->hw, mac->id, speed); +- + /* Configure duplex */ + if (duplex == DUPLEX_FULL) + mcr |= MAC_MCR_FORCE_DPX; diff --git a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch index bfa0df30534..066b70c5e2c 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch @@ -34,7 +34,7 @@ mtk_eth_path_name(path), __func__, updated); --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4757,6 +4757,26 @@ static const struct mtk_soc_data mt7629_ +@@ -4755,6 +4755,26 @@ static const struct mtk_soc_data mt7629_ }, }; @@ -61,7 +61,7 @@ static const struct mtk_soc_data mt7986_data = { .reg_map = &mt7986_reg_map, .ana_rgc3 = 0x128, -@@ -4799,6 +4819,7 @@ const struct of_device_id of_mtk_match[] +@@ -4797,6 +4817,7 @@ const struct of_device_id of_mtk_match[] { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, { .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, diff --git a/target/linux/generic/backport-5.15/733-v6.3-19-net-ethernet-mtk_eth_soc-set-MDIO-bus-clock-frequenc.patch b/target/linux/generic/backport-5.15/733-v6.3-19-net-ethernet-mtk_eth_soc-set-MDIO-bus-clock-frequenc.patch index df7ee081f79..9def19d67eb 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-19-net-ethernet-mtk_eth_soc-set-MDIO-bus-clock-frequenc.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-19-net-ethernet-mtk_eth_soc-set-MDIO-bus-clock-frequenc.patch @@ -21,7 +21,7 @@ Signed-off-by: Jakub Kicinski --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -704,8 +704,10 @@ static const struct phylink_mac_ops mtk_ +@@ -702,8 +702,10 @@ static const struct phylink_mac_ops mtk_ static int mtk_mdio_init(struct mtk_eth *eth) { @@ -32,7 +32,7 @@ Signed-off-by: Jakub Kicinski mii_np = of_get_child_by_name(eth->dev->of_node, "mdio-bus"); if (!mii_np) { -@@ -731,6 +733,25 @@ static int mtk_mdio_init(struct mtk_eth +@@ -729,6 +731,25 @@ static int mtk_mdio_init(struct mtk_eth eth->mii_bus->parent = eth->dev; snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%pOFn", mii_np); diff --git a/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch b/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch index 1eca7dfeaf5..203c5dc48bb 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-20-net-ethernet-mtk_eth_soc-switch-to-external-PCS-driv.patch @@ -60,7 +60,7 @@ Signed-off-by: Jakub Kicinski } return NULL; -@@ -3979,8 +3980,17 @@ static int mtk_unreg_dev(struct mtk_eth +@@ -3977,8 +3978,17 @@ static int mtk_unreg_dev(struct mtk_eth return 0; } @@ -78,7 +78,7 @@ Signed-off-by: Jakub Kicinski mtk_unreg_dev(eth); mtk_free_dev(eth); cancel_work_sync(ð->pending_work); -@@ -4410,6 +4420,36 @@ void mtk_eth_set_dma_device(struct mtk_e +@@ -4408,6 +4418,36 @@ void mtk_eth_set_dma_device(struct mtk_e rtnl_unlock(); } @@ -115,7 +115,7 @@ Signed-off-by: Jakub Kicinski static int mtk_probe(struct platform_device *pdev) { struct resource *res = NULL; -@@ -4473,13 +4513,7 @@ static int mtk_probe(struct platform_dev +@@ -4471,13 +4511,7 @@ static int mtk_probe(struct platform_dev } if (MTK_HAS_CAPS(eth->soc->caps, MTK_SGMII)) { @@ -130,7 +130,7 @@ Signed-off-by: Jakub Kicinski if (err) return err; -@@ -4490,14 +4524,17 @@ static int mtk_probe(struct platform_dev +@@ -4488,14 +4522,17 @@ static int mtk_probe(struct platform_dev "mediatek,pctl"); if (IS_ERR(eth->pctl)) { dev_err(&pdev->dev, "no pctl regmap found\n"); @@ -151,7 +151,7 @@ Signed-off-by: Jakub Kicinski } if (eth->soc->offload_version) { -@@ -4657,6 +4694,8 @@ err_deinit_hw: +@@ -4655,6 +4692,8 @@ err_deinit_hw: mtk_hw_deinit(eth); err_wed_exit: mtk_wed_exit(); diff --git a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index 5dcbc6c46a2..a4e3d265033 100644 --- a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -2994,8 +2994,8 @@ static irqreturn_t mtk_handle_irq_rx(int +@@ -2992,8 +2992,8 @@ static irqreturn_t mtk_handle_irq_rx(int eth->rx_events++; if (likely(napi_schedule_prep(ð->rx_napi))) { @@ -20,7 +20,7 @@ Signed-off-by: Felix Fietkau } return IRQ_HANDLED; -@@ -3007,8 +3007,8 @@ static irqreturn_t mtk_handle_irq_tx(int +@@ -3005,8 +3005,8 @@ static irqreturn_t mtk_handle_irq_tx(int eth->tx_events++; if (likely(napi_schedule_prep(ð->tx_napi))) { @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau } return IRQ_HANDLED; -@@ -4675,6 +4675,8 @@ static int mtk_probe(struct platform_dev +@@ -4673,6 +4673,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); diff --git a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch index c7e1d3f6f08..6ca33152fca 100644 --- a/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch +++ b/target/linux/generic/pending-5.15/731-net-ethernet-mediatek-ppe-add-support-for-flow-accou.patch @@ -53,7 +53,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4644,8 +4644,8 @@ static int mtk_probe(struct platform_dev +@@ -4642,8 +4642,8 @@ static int mtk_probe(struct platform_dev for (i = 0; i < num_ppe; i++) { u32 ppe_addr = eth->soc->reg_map->ppe_base + i * 0x400; @@ -64,7 +64,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov if (!eth->ppe[i]) { err = -ENOMEM; goto err_free_dev; -@@ -4772,6 +4772,7 @@ static const struct mtk_soc_data mt7622_ +@@ -4770,6 +4770,7 @@ static const struct mtk_soc_data mt7622_ .required_pctl = false, .offload_version = 2, .hash_offset = 2, @@ -72,7 +72,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .foe_entry_size = sizeof(struct mtk_foe_entry) - 16, .txrx = { .txd_size = sizeof(struct mtk_tx_dma), -@@ -4809,6 +4810,7 @@ static const struct mtk_soc_data mt7629_ +@@ -4807,6 +4808,7 @@ static const struct mtk_soc_data mt7629_ .hw_features = MTK_HW_FEATURES, .required_clks = MT7629_CLKS_BITMAP, .required_pctl = false, @@ -80,7 +80,7 @@ v2: fix wrong variable name in return value check spotted by Denis Kirjanov .txrx = { .txd_size = sizeof(struct mtk_tx_dma), .rxd_size = sizeof(struct mtk_rx_dma), -@@ -4829,6 +4831,7 @@ static const struct mtk_soc_data mt7981_ +@@ -4827,6 +4829,7 @@ static const struct mtk_soc_data mt7981_ .offload_version = 2, .hash_offset = 4, .foe_entry_size = sizeof(struct mtk_foe_entry), diff --git a/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch b/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch index b5e118f9fab..35b296a2553 100644 --- a/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch +++ b/target/linux/generic/pending-5.15/732-00-net-ethernet-mtk_eth_soc-drop-generic-vlan-rx-offloa.patch @@ -17,7 +17,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -1852,9 +1852,7 @@ static int mtk_poll_rx(struct napi_struc +@@ -1850,9 +1850,7 @@ static int mtk_poll_rx(struct napi_struc while (done < budget) { unsigned int pktlen, *rxdcsum; @@ -27,7 +27,7 @@ Signed-off-by: Felix Fietkau dma_addr_t dma_addr; u32 hash, reason; int mac = 0; -@@ -1989,36 +1987,21 @@ static int mtk_poll_rx(struct napi_struc +@@ -1987,36 +1985,21 @@ static int mtk_poll_rx(struct napi_struc skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, netdev); @@ -70,7 +70,7 @@ Signed-off-by: Felix Fietkau skb_record_rx_queue(skb, 0); napi_gro_receive(napi, skb); -@@ -2833,29 +2816,11 @@ static netdev_features_t mtk_fix_feature +@@ -2831,29 +2814,11 @@ static netdev_features_t mtk_fix_feature static int mtk_set_features(struct net_device *dev, netdev_features_t features) { @@ -100,7 +100,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -3169,30 +3134,6 @@ static int mtk_open(struct net_device *d +@@ -3167,30 +3132,6 @@ static int mtk_open(struct net_device *d struct mtk_eth *eth = mac->hw; int i, err; @@ -131,7 +131,7 @@ Signed-off-by: Felix Fietkau err = phylink_of_phy_connect(mac->phylink, mac->of_node, 0); if (err) { netdev_err(dev, "%s: could not attach PHY: %d\n", __func__, -@@ -3233,6 +3174,35 @@ static int mtk_open(struct net_device *d +@@ -3231,6 +3172,35 @@ static int mtk_open(struct net_device *d phylink_start(mac->phylink); netif_tx_start_all_queues(dev); @@ -167,7 +167,7 @@ Signed-off-by: Felix Fietkau return 0; } -@@ -3717,10 +3687,9 @@ static int mtk_hw_init(struct mtk_eth *e +@@ -3715,10 +3685,9 @@ static int mtk_hw_init(struct mtk_eth *e if (!MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) { val = mtk_r32(eth, MTK_CDMP_IG_CTRL); mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); @@ -180,7 +180,7 @@ Signed-off-by: Felix Fietkau /* set interrupt delays based on current Net DIM sample */ mtk_dim_rx(ð->rx_dim.work); -@@ -4367,7 +4336,7 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4365,7 +4334,7 @@ static int mtk_add_mac(struct mtk_eth *e eth->netdev[id]->hw_features |= NETIF_F_LRO; eth->netdev[id]->vlan_features = eth->soc->hw_features & diff --git a/target/linux/generic/pending-5.15/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch b/target/linux/generic/pending-5.15/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch index 72bad79c138..fbf0cb5735e 100644 --- a/target/linux/generic/pending-5.15/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch +++ b/target/linux/generic/pending-5.15/732-01-net-ethernet-mtk_eth_soc-work-around-issue-with-send.patch @@ -16,7 +16,7 @@ Signed-off-by: Felix Fietkau --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -1425,12 +1425,28 @@ static void mtk_wake_queue(struct mtk_et +@@ -1423,12 +1423,28 @@ static void mtk_wake_queue(struct mtk_et } } @@ -45,7 +45,7 @@ Signed-off-by: Felix Fietkau bool gso = false; int tx_num; -@@ -1452,6 +1468,18 @@ static netdev_tx_t mtk_start_xmit(struct +@@ -1450,6 +1466,18 @@ static netdev_tx_t mtk_start_xmit(struct return NETDEV_TX_BUSY; } @@ -64,7 +64,7 @@ Signed-off-by: Felix Fietkau /* TSO: fill MSS info in tcp checksum field */ if (skb_is_gso(skb)) { if (skb_cow_head(skb, 0)) { -@@ -1467,8 +1495,14 @@ static netdev_tx_t mtk_start_xmit(struct +@@ -1465,8 +1493,14 @@ static netdev_tx_t mtk_start_xmit(struct } } diff --git a/target/linux/generic/pending-5.15/732-03-net-ethernet-mtk_eth_soc-fix-remaining-throughput-re.patch b/target/linux/generic/pending-5.15/732-03-net-ethernet-mtk_eth_soc-fix-remaining-throughput-re.patch new file mode 100644 index 00000000000..0aa9382b6bd --- /dev/null +++ b/target/linux/generic/pending-5.15/732-03-net-ethernet-mtk_eth_soc-fix-remaining-throughput-re.patch @@ -0,0 +1,42 @@ +From: Felix Fietkau +Date: Wed, 29 Mar 2023 16:02:54 +0200 +Subject: [PATCH] net: ethernet: mtk_eth_soc: fix remaining throughput + regression + +Based on further tests, it seems that the QDMA shaper is not able to +perform shaping close to the MAC link rate without throughput loss. +This cannot be compensated by increasing the shaping rate, so it seems +to be an internal limit. + +Fix the remaining throughput regression by detecting that condition and +limiting shaping to ports with lower link speed. + +This patch intentionally ignores link speed gain from TRGMII, because +even on such links, shaping to 1000 Mbit/s incurs some throughput +degradation. + +Fixes: f63959c7eec3 ("net: ethernet: mtk_eth_soc: implement multi-queue support for per-port queues") +Reported-by: Frank Wunderlich +Signed-off-by: Felix Fietkau +--- + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -667,6 +667,7 @@ static void mtk_mac_link_up(struct phyli + MAC_MCR_FORCE_RX_FC); + + /* Configure speed */ ++ mac->speed = speed; + switch (speed) { + case SPEED_2500: + case SPEED_1000: +@@ -3145,6 +3146,9 @@ found: + if (dp->index >= MTK_QDMA_NUM_QUEUES) + return NOTIFY_DONE; + ++ if (mac->speed > 0 && mac->speed <= s.base.speed) ++ s.base.speed = 0; ++ + mtk_set_queue_speed(eth, dp->index + 3, s.base.speed); + + return NOTIFY_DONE; diff --git a/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch b/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch index ffa98e3f0d9..4187557b781 100644 --- a/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch +++ b/target/linux/mediatek/patches-5.15/703-v5.17-net-ethernet-mtk_eth_soc-implement-Clause-45-MDIO-ac.patch @@ -103,7 +103,7 @@ Signed-off-by: David S. Miller ret = mtk_mdio_busy_wait(eth); if (ret < 0) -@@ -730,6 +773,7 @@ static int mtk_mdio_init(struct mtk_eth +@@ -729,6 +772,7 @@ static int mtk_mdio_init(struct mtk_eth eth->mii_bus->name = "mdio"; eth->mii_bus->read = mtk_mdio_read; eth->mii_bus->write = mtk_mdio_write; From cd64353bd6724207994d80826f596c7f55528c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 29 Mar 2023 16:17:04 +0200 Subject: [PATCH 2/8] bmips: bcm6348-enet: add PHY support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should ensure that the PHY is properly configured. This is specially needed in devices using the internal PHY for ethernet0. Signed-off-by: Álvaro Fernández Rojas --- .../bmips/dts/bcm6358-huawei-hg556a-b.dts | 7 ++ .../net/ethernet/broadcom/bcm6348-enet.c | 112 ++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts b/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts index 2ad9460a9c7..273470b1bd3 100644 --- a/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts +++ b/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts @@ -145,6 +145,13 @@ nvmem-cells = <&macaddr_cfe_6a0>; nvmem-cell-names = "mac-address"; + + phy-mode = "mii"; + + fixed-link { + speed = <100>; + full-duplex; + }; }; &iudma { diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c index 06a9df1c0a5..75e85aa0f32 100644 --- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c +++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c @@ -489,6 +489,11 @@ struct bcm6348_emac { /* external mii bus */ bool ext_mii; + + /* phy */ + int old_link; + int old_duplex; + int old_pause; }; static inline void emac_writel(struct bcm6348_emac *emac, u32 val, u32 off) @@ -968,6 +973,96 @@ static void bcm6348_emac_disable_mac(struct bcm6348_emac *emac) } while (limit--); } +/* + * set emac duplex parameters + */ +static void bcm6348_emac_set_duplex(struct bcm6348_emac *emac, int fullduplex) +{ + u32 val; + + val = emac_readl(emac, ENET_TXCTL_REG); + if (fullduplex) + val |= ENET_TXCTL_FD_MASK; + else + val &= ~ENET_TXCTL_FD_MASK; + emac_writel(emac, val, ENET_TXCTL_REG); +} + +/* + * set emac flow control parameters + */ +static void bcm6348_emac_set_flow(struct bcm6348_emac *emac, bool rx_en, bool tx_en) +{ + struct bcm6348_iudma *iudma = emac->iudma; + u32 val; + + val = emac_readl(emac, ENET_RXCFG_REG); + if (rx_en) + val |= ENET_RXCFG_ENFLOW_MASK; + else + val &= ~ENET_RXCFG_ENFLOW_MASK; + emac_writel(emac, val, ENET_RXCFG_REG); + + dmas_writel(iudma, emac->rx_desc_dma, DMAS_RSTART_REG, emac->rx_chan); + dmas_writel(iudma, emac->tx_desc_dma, DMAS_RSTART_REG, emac->tx_chan); + + val = dma_readl(iudma, DMA_CFG_REG); + if (tx_en) + val |= DMA_CFG_FLOWCH_MASK(emac->rx_chan); + else + val &= ~DMA_CFG_FLOWCH_MASK(emac->rx_chan); + dma_writel(iudma, val, DMA_CFG_REG); +} + +/* + * adjust emac phy + */ +static void bcm6348_emac_adjust_phy(struct net_device *ndev) +{ + struct phy_device *phydev = ndev->phydev; + struct bcm6348_emac *emac = netdev_priv(ndev); + struct platform_device *pdev = emac->pdev; + struct device *dev = &pdev->dev; + bool status_changed = false; + + if (emac->old_link != phydev->link) { + status_changed = true; + emac->old_link = phydev->link; + } + + if (phydev->link && phydev->duplex != emac->old_duplex) { + bcm6348_emac_set_duplex(emac, phydev->duplex == DUPLEX_FULL); + status_changed = true; + emac->old_duplex = phydev->duplex; + } + + if (phydev->link && phydev->pause != emac->old_pause) { + bool rx_pause_en, tx_pause_en; + + if (phydev->pause) { + rx_pause_en = true; + tx_pause_en = true; + } else { + rx_pause_en = false; + tx_pause_en = false; + } + + bcm6348_emac_set_flow(emac, rx_pause_en, tx_pause_en); + status_changed = true; + emac->old_pause = phydev->pause; + } + + if (status_changed) + dev_info(dev, "%s: phy link %s %s/%s/%s/%s\n", + ndev->name, + phydev->link ? "UP" : "DOWN", + phy_modes(phydev->interface), + phy_speed_to_str(phydev->speed), + phy_duplex_to_str(phydev->duplex), + phydev->pause ? "rx/tx" : "off"); +} + + static int bcm6348_emac_open(struct net_device *ndev) { struct bcm6348_emac *emac = netdev_priv(ndev); @@ -1133,6 +1228,9 @@ static int bcm6348_emac_open(struct net_device *ndev) dmac_writel(iudma, DMAC_IR_PKTDONE_MASK, DMAC_IRMASK_REG, emac->tx_chan); + if (ndev->phydev) + phy_start(ndev->phydev); + netif_carrier_on(ndev); netif_start_queue(ndev); @@ -1171,6 +1269,9 @@ out_freeirq_rx: free_irq(emac->irq_rx, ndev); out_freeirq: + if (ndev->phydev) + phy_disconnect(ndev->phydev); + return ret; } @@ -1183,6 +1284,8 @@ static int bcm6348_emac_stop(struct net_device *ndev) netif_stop_queue(ndev); napi_disable(&emac->napi); + if (ndev->phydev) + phy_stop(ndev->phydev); del_timer_sync(&emac->rx_timeout); /* mask all interrupts */ @@ -1454,6 +1557,10 @@ static int bcm6348_emac_probe(struct platform_device *pdev) emac->tx_ring_size = ENET_DEF_TX_DESC; emac->copybreak = ENET_DEF_CPY_BREAK; + emac->old_link = 0; + emac->old_duplex = -1; + emac->old_pause = -1; + of_get_mac_address(node, ndev->dev_addr); if (is_valid_ether_addr(ndev->dev_addr)) { dev_info(dev, "mtd mac %pM\n", ndev->dev_addr); @@ -1543,6 +1650,11 @@ static int bcm6348_emac_probe(struct platform_device *pdev) netif_carrier_off(ndev); + ndev->phydev = of_phy_get_and_connect(ndev, node, + bcm6348_emac_adjust_phy); + if (IS_ERR_OR_NULL(ndev->phydev)) + dev_warn(dev, "PHY not found!\n"); + dev_info(dev, "%s at 0x%px, IRQ %d\n", ndev->name, emac->base, ndev->irq); From ed2849958f3431ef0340c071c6ca5e8e575d2028 Mon Sep 17 00:00:00 2001 From: Andrew Sim Date: Wed, 29 Mar 2023 09:48:30 +0200 Subject: [PATCH 3/8] mediatek: re-add wireless driver for TUF-AX4200 The wireless driver package was incorrectly removed from the TUF-AX4200 device-packages, resulting in images without wireless functionality. Fixes: d98c4fb8bfab ("mediatek: broaden filogic target description") Signed-off-by: Andrew Sim [rework commit description] Signed-off-by: David Bauer --- target/linux/mediatek/image/filogic.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 318052a03c9..f1fa11b49a8 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -44,7 +44,7 @@ define Device/asus_tuf-ax4200 DEVICE_DTS := mt7986a-asus-tuf-ax4200 DEVICE_DTS_DIR := ../dts DEVICE_DTS_LOADADDR := 0x47000000 - DEVICE_PACKAGES := kmod-usb3 + DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware IMAGES := sysupgrade.bin KERNEL_LOADADDR := 0x48000000 KERNEL = kernel-bin | lzma | \ From 91eca7b04ff1309c7408baa1f1631d7623ce50cf Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Fri, 24 Mar 2023 22:24:26 +0100 Subject: [PATCH 4/8] comgt: add quirk for Mikrotik modems based on Mikrotik R11e-LTE6 The MikroTik R11e-LTE6 modem goes into flight mode (CFUN=4) at startup and the radio is off (*RADIOPOWER: 0): AT+RESET OK OK *SIMDETEC:2,NOS *SIMDETEC:1,SIM *ICCID: 8936500119010596302 *EUICC: 1 +MSTK: 11, D025....74F3 *ADMINDATA: 0, 2, 0 +CPIN: READY *EUICC: 1 *ECCLIST: 5, 0, 112, 0, 000, 0, 08, 0, 118, 0, 911 +CREG: 0 $CREG: 0 +CESQ: 99,99,255,255,255,255 *CESQ: 99,99,255,255,255,255,0 +CGREG: 0 +CEREG: 0 +CESQ: 99,99,255,255,255,255 *CESQ: 99,99,255,255,255,255,0 *RADIOPOWER: 0 +MMSG: 0, 0 +MMSG: 0, 0 +MMSG: 1, 0 +MPBK: 1 While the chat script is able to establish the PPP connection, it's closed instantly by the modem: LCP terminated by peer. local2.info chat[7000]: send (ATD*99***1#^M) local2.info chat[7000]: expect (CONNECT) local2.info chat[7000]: ^M local2.info chat[7000]: ATD*99***1#^M^M local2.info chat[7000]: CONNECT local2.info chat[7000]: -- got it local2.info chat[7000]: send ( ^M) daemon.info pppd[6997]: Serial connection established. kern.info kernel: [ 453.659146] 3g-mikrotik: renamed from ppp0 daemon.info pppd[6997]: Renamed interface ppp0 to 3g-mikrotik daemon.info pppd[6997]: Using interface 3g-mikrotik daemon.notice pppd[6997]: Connect: 3g-mikrotik <--> /dev/ttyACM0 daemon.info pppd[6997]: LCP terminated by peer daemon.notice pppd[6997]: Connection terminated. daemon.notice pppd[6997]: Modem hangup daemon.info pppd[6997]: Exit. daemon.notice netifd: Interface 'mikrotik' is now down Sending "AT+CFUN=1" to modem deactivates the flight mode and solves the issue: daemon.notice netifd: Interface 'mikrotik' is setting up now daemon.notice netifd: mikrotik (7051): sending -> AT+CFUN=1 daemon.notice pppd[7137]: pppd 2.4.9 started by root, uid 0 local2.info chat[7140]: abort on (BUSY) local2.info chat[7140]: abort on (NO CARRIER) local2.info chat[7140]: abort on (ERROR) local2.info chat[7140]: report (CONNECT) local2.info chat[7140]: timeout set to 10 seconds local2.info chat[7140]: send (AT&F^M) local2.info chat[7140]: expect (OK) local2.info chat[7140]: ^M local2.info chat[7140]: +CESQ: 99,99,255,255,255,255^M local2.info chat[7140]: ^M local2.info chat[7140]: *CESQ: 99,99,255,255,255,255,0^M local2.info chat[7140]: AT&F^MAT&F^M^M local2.info chat[7140]: OK local2.info chat[7140]: -- got it ... local2.info chat[7140]: send (ATD*99***1#^M) local2.info chat[7140]: expect (CONNECT) local2.info chat[7140]: ^M local2.info chat[7140]: ATD*99***1#^M^M local2.info chat[7140]: CONNECT local2.info chat[7140]: -- got it local2.info chat[7140]: send ( ^M) daemon.info pppd[7137]: Serial connection established. kern.info kernel: [ 463.094254] 3g-mikrotik: renamed from ppp0 daemon.info pppd[7137]: Renamed interface ppp0 to 3g-mikrotik daemon.info pppd[7137]: Using interface 3g-mikrotik daemon.notice pppd[7137]: Connect: 3g-mikrotik <--> /dev/ttyACM0 daemon.warn pppd[7137]: Could not determine remote IP address: defaulting to 10.64.64.64 daemon.notice pppd[7137]: local IP address 100.112.63.62 daemon.notice pppd[7137]: remote IP address 10.64.64.64 daemon.notice pppd[7137]: primary DNS address 185.29.83.64 daemon.notice pppd[7137]: secondary DNS address 185.62.131.64 daemon.notice netifd: Network device '3g-mikrotik' link is up daemon.notice netifd: Interface 'mikrotik' is now up To send this AT command to the modem the "runcommand.gcom" script dependency is moved from comgt-ncm to comgt. As the comgt-ncm package depends on comgt already, this change is a NOOP from that point of view. But from the modem's point it is a low hanging fruit as the modem is usable with installing comgt and kmod-usb-ncm packages. Signed-off-by: Szabolcs Hubai --- package/network/utils/comgt/Makefile | 4 ++-- package/network/utils/comgt/files/3g.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package/network/utils/comgt/Makefile b/package/network/utils/comgt/Makefile index 24dae2521e3..429c9386027 100644 --- a/package/network/utils/comgt/Makefile +++ b/package/network/utils/comgt/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=comgt PKG_VERSION:=0.32 -PKG_RELEASE:=34 +PKG_RELEASE:=35 PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz PKG_SOURCE_URL:=@SF/comgt @@ -79,6 +79,7 @@ define Package/comgt/install $(INSTALL_DATA) ./files/getcarrier.gcom $(1)/etc/gcom/getcarrier.gcom $(INSTALL_DATA) ./files/getcnum.gcom $(1)/etc/gcom/getcnum.gcom $(INSTALL_DATA) ./files/getimsi.gcom $(1)/etc/gcom/getimsi.gcom + $(INSTALL_DATA) ./files/runcommand.gcom $(1)/etc/gcom/runcommand.gcom $(INSTALL_DIR) $(1)/etc/hotplug.d/tty $(INSTALL_CONF) ./files/3g.usb $(1)/etc/hotplug.d/tty/30-3g $(INSTALL_DIR) $(1)/lib/netifd/proto @@ -96,7 +97,6 @@ endef define Package/comgt-ncm/install $(INSTALL_DIR) $(1)/etc/gcom $(INSTALL_DATA) ./files/ncm.json $(1)/etc/gcom/ncm.json - $(INSTALL_DATA) ./files/runcommand.gcom $(1)/etc/gcom/runcommand.gcom $(INSTALL_DIR) $(1)/lib/netifd/proto $(INSTALL_BIN) ./files/ncm.sh $(1)/lib/netifd/proto/ncm.sh endef diff --git a/package/network/utils/comgt/files/3g.sh b/package/network/utils/comgt/files/3g.sh index 9220cbf5a0a..42ba894e595 100644 --- a/package/network/utils/comgt/files/3g.sh +++ b/package/network/utils/comgt/files/3g.sh @@ -72,6 +72,8 @@ proto_3g_setup() { *) CODE="2,2";; esac export MODE="AT^SYSCFG=${CODE},3FFFFFFF,2,4" + elif echo "$cardinfo" | grep -q "MikroTik"; then + COMMAND="AT+CFUN=1" gcom -d "$device" -s /etc/gcom/runcommand.gcom || return 1 fi if [ -n "$pincode" ]; then From dbd6ebd6d84b35599a0446559576df41f487200e Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Sat, 25 Mar 2023 00:00:27 +0100 Subject: [PATCH 5/8] comgt: ncm: support Mikrotik R11e-LTE6 modem The Mikrotik R11e-LTE6 modem is similar to ZTE MF286R modem, added earlier: it has a Marvel chip, able to work in ACM+RNDIS mode, knows ZTE specific commands, runs OpenWrt Barrier Breaker fork. While the modem is able to offer IPv6 address, the RNDIS setup is unable to complete if there is an IPv6 adress. While it works in ACM+RNDIS mode, the user experience isn't as good as with "proto 3g": the modem happily serves a local IP (192.168.1.xxx) without internet access. Of course, if the modem has enough time (for example at the second dialup), it will serve a public IP. Modifing the DHCP Lease (to a short interval before connect and back to default while finalizing) is a workaround to get a public IP at the first try. A safe workaround for this is to excercise an offline script of the pingcheck program: simply restart (ifdown - ifup) the connection. Another pitfall is that the modem writes a few messages at startup, which confuses the manufacturer detection algorithm and got disabled. daemon.notice netifd: Interface 'mikrotik' is setting up now daemon.notice netifd: mikrotik (2366): Failed to parse message data daemon.notice netifd: mikrotik (2366): WARNING: Variable 'ok' does not exist or is not an array/object daemon.notice netifd: mikrotik (2366): Unsupported modem daemon.notice netifd: mikrotik (2426): Stopping network mikrotik daemon.notice netifd: mikrotik (2426): Failed to parse message data daemon.notice netifd: mikrotik (2426): WARNING: Variable '*simdetec:1,sim' does not exist or is not an array/object daemon.notice netifd: mikrotik (2426): Unsupported modem daemon.notice netifd: Interface 'mikrotik' is now down A workaround for this is to use the "delay" option in the interface configuration. I want to thank Forum members dchard (in topic Adding support for MikroTik hAP ac3 LTE6 kit (D53GR_5HacD2HnD)) [1] and mrhaav (in topic OpenWrt X86_64 + Mikrotik R11e-LTE6) [2] for sharing their experiments and works. Another information page was found at eko.one.pl [3]. [1]: https://forum.openwrt.org/t/137555 [2]: https://forum.openwrt.org/t/151743 [3]: https://eko.one.pl/?p=modem-r11elte Signed-off-by: Szabolcs Hubai --- package/network/utils/comgt/files/ncm.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/package/network/utils/comgt/files/ncm.json b/package/network/utils/comgt/files/ncm.json index 7d9a38fe36d..df0810ddbc7 100644 --- a/package/network/utils/comgt/files/ncm.json +++ b/package/network/utils/comgt/files/ncm.json @@ -112,5 +112,17 @@ ], "connect": "AT+ZGACT=1,${profile}", "disconnect": "AT+ZGACT=0,${profile}" + }, + "\"mikrotik\"": { + "configure": [ + "AT+CFUN=4", + "AT+ZGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",0", + "AT+ZDHCPLEASE=10", + "AT+CFUN=1" + ], + "waitforconnect": "\\\"+ZCONSTAT: 1,${context_type}\\\",\\\"+ZGIPDNS: ${context_type}\\\"", + "connect": "AT+ZGACT=1,${context_type}", + "finalize": "AT+ZDHCPLEASE=0", + "disconnect": "AT+ZGACT=0,1" } } From 5d8f14bfefc6f12e93425ee522bdce75a7c979d6 Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Tue, 7 Mar 2023 15:00:28 +0100 Subject: [PATCH 6/8] kernel: filter out pahole version Pahole version is being autodetected during runtime since kernel 5.15.96 via in-kernel scripts/pahole-version.sh so add CONFIG_PAHOLE_VERSION to kernel filter in order to prevent it from being added to target configs. Signed-off-by: Robert Marko --- target/linux/generic/config-filter | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/generic/config-filter b/target/linux/generic/config-filter index 16daecf3212..201b68dddf2 100644 --- a/target/linux/generic/config-filter +++ b/target/linux/generic/config-filter @@ -9,6 +9,7 @@ CONFIG_CLANG_VERSION=.* # CONFIG_INLINE_.* is not set # CONFIG_LD_.* is not set CONFIG_LLD_VERSION=.* +CONFIG_PAHOLE_VERSION=.* CONFIG_PLUGIN_HOSTCC=".*" # CONFIG_SET_FS is not set # CONFIG_TASKS_.* is not set From a0f100c569fea84e4eb7750c5d85886e9e77cf4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 29 Mar 2023 18:19:11 +0200 Subject: [PATCH 7/8] bmips: bcm6348-enet: register emac driver from iudma MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Register the ethernet driver from iudma, which avoids the attempt to probe the emac driver before iudma and its consequent deferral. The ethernet driver can't work without iudma anyway. Signed-off-by: Álvaro Fernández Rojas --- .../net/ethernet/broadcom/bcm6348-enet.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c index 75e85aa0f32..2bd243089eb 100644 --- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c +++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6348-enet.c @@ -128,6 +128,8 @@ struct bcm6348_iudma { unsigned int dma_channels; }; +int bcm6348_iudma_drivers_register(struct platform_device *pdev); + static inline u32 dma_readl(struct bcm6348_iudma *iudma, u32 off) { u32 val; @@ -269,7 +271,7 @@ static int bcm6348_iudma_probe(struct platform_device *pdev) platform_set_drvdata(pdev, iudma); - return 0; + return bcm6348_iudma_drivers_register(pdev); } static const struct of_device_id bcm6348_iudma_of_match[] = { @@ -1703,4 +1705,15 @@ static struct platform_driver bcm6348_emac_driver = { .probe = bcm6348_emac_probe, .remove = bcm6348_emac_remove, }; -module_platform_driver(bcm6348_emac_driver); + +int bcm6348_iudma_drivers_register(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int ret; + + ret = platform_driver_register(&bcm6348_emac_driver); + if (ret) + dev_err(dev, "error registering emac driver!\n"); + + return ret; +} From 9186da4027bc8d23912621b5471e98e9526f2878 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 29 Mar 2023 19:07:05 +0200 Subject: [PATCH 8/8] ramips: Refresh patches Refresh the ramips kernel patches. Fixes: 7472476aef26 ("kernel: fix mtk_eth_soc throughput regressions on gigabit PHY ports") Signed-off-by: Hauke Mehrtens --- .../700-net-ethernet-mediatek-support-net-labels.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch index c3e0a342a19..285e24429a4 100644 --- a/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch +++ b/target/linux/ramips/patches-5.15/700-net-ethernet-mediatek-support-net-labels.patch @@ -14,7 +14,7 @@ Signed-off-by: René van Dorst --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c -@@ -4259,6 +4259,7 @@ static const struct net_device_ops mtk_n +@@ -4261,6 +4261,7 @@ static const struct net_device_ops mtk_n static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { @@ -22,7 +22,7 @@ Signed-off-by: René van Dorst const __be32 *_id = of_get_property(np, "reg", NULL); phy_interface_t phy_mode; struct phylink *phylink; -@@ -4387,6 +4388,9 @@ static int mtk_add_mac(struct mtk_eth *e +@@ -4389,6 +4390,9 @@ static int mtk_add_mac(struct mtk_eth *e register_netdevice_notifier(&mac->device_notifier); }