From ef12a97354d2be26a9e3d4aeae355bd2aabd9302 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Mon, 8 May 2023 23:39:06 +0800 Subject: [PATCH] ramips: mt7621: add kernel 5.10 support with mtk_hnat --- package/kernel/mt76/Makefile | 8 - target/linux/ramips/Makefile | 4 +- .../files/drivers/net/ethernet/mtk/Kconfig | 8 +- .../drivers/net/ethernet/mtk/mtk_eth_dbg.c | 76 ++++++ .../drivers/net/ethernet/mtk/mtk_eth_soc.c | 35 ++- .../drivers/net/ethernet/mtk/mtk_hnat/hnat.c | 4 + .../drivers/net/ethernet/mtk/mtk_hnat/hnat.h | 5 + .../net/ethernet/mtk/mtk_hnat/hnat_debugfs.c | 9 +- .../files/drivers/net/phy/mtk/mt753x/mt753x.h | 5 + .../drivers/net/phy/mtk/mt753x/mt753x_mdio.c | 26 +- target/linux/ramips/mt7621/config-5.10 | 37 ++- target/linux/ramips/mt7621/target.mk | 2 +- .../901-add-mtk-vendor-ethernet-drivers.patch | 41 ++++ ...hnat-fix-pskb-expand-head-limitation.patch | 20 ++ ...d-support-for-interface-acceleration.patch | 224 ++++++++++++++++++ .../patches-5.10/999-crypto-eip93-fix.patch | 14 -- .../ramips/patches-5.10/999-fix-hwnat.patch | 12 - 17 files changed, 460 insertions(+), 70 deletions(-) create mode 100644 target/linux/ramips/patches-5.10/901-add-mtk-vendor-ethernet-drivers.patch create mode 100644 target/linux/ramips/patches-5.10/902-mtkhnat-fix-pskb-expand-head-limitation.patch create mode 100644 target/linux/ramips/patches-5.10/903-mtkhnat-add-support-for-interface-acceleration.patch delete mode 100644 target/linux/ramips/patches-5.10/999-crypto-eip93-fix.patch delete mode 100644 target/linux/ramips/patches-5.10/999-fix-hwnat.patch diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 160ccab1df0eaf..78d2498218fd43 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -8,17 +8,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/openwrt/mt76 PKG_SOURCE_PROTO:=git - -ifdef CONFIG_LINUX_5_4 -PKG_SOURCE_DATE:=2022-12-22 -PKG_SOURCE_VERSION:=5b509e80384ab019ac11aa90c81ec0dbb5b0d7f2 -PKG_MIRROR_HASH:=6fc25df4d28becd010ff4971b23731c08b53e69381a9e4c868091899712f78a9 -PATCH_DIR:=./patches-5.4 -else PKG_SOURCE_DATE:=2023-04-18 PKG_SOURCE_VERSION:=cddbd796bbc649debe457f7b34b200bbda4fcc53 PKG_MIRROR_HASH:=3c9e24863f3e045dbab1d05cf760ef0f4a21106766987558ce4df6c0964df11a -endif PKG_MAINTAINER:=Felix Fietkau PKG_USE_NINJA:=0 diff --git a/target/linux/ramips/Makefile b/target/linux/ramips/Makefile index 3053906f684966..f7d0e42833caa7 100644 --- a/target/linux/ramips/Makefile +++ b/target/linux/ramips/Makefile @@ -10,8 +10,8 @@ BOARDNAME:=MediaTek Ralink MIPS SUBTARGETS:=mt7620 mt7621 mt76x8 rt288x rt305x rt3883 FEATURES:=squashfs gpio boot-part rootfs-part -KERNEL_PATCHVER:=5.4 -KERNEL_TESTING_PATCHVER:=5.10 +KERNEL_PATCHVER:=5.10 +KERNEL_TESTING_PATCHVER:=5.15 define Target/Description Build firmware images for Ralink RT288x/RT3xxx based boards. diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/Kconfig b/target/linux/ramips/files/drivers/net/ethernet/mtk/Kconfig index e33e3de4074756..fae9219ee87f99 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/Kconfig +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/Kconfig @@ -2,7 +2,7 @@ config NET_VENDOR_RAW_MEDIATEK bool "MediaTek ethernet driver" depends on ARCH_MEDIATEK || SOC_MT7621 || SOC_MT7620 - ---help--- + help If you have a Mediatek SoC with ethernet, say Y. if NET_VENDOR_RAW_MEDIATEK @@ -10,20 +10,20 @@ if NET_VENDOR_RAW_MEDIATEK config NET_MEDIATEK_SOC_GE tristate "MediaTek SoC Gigabit Ethernet support" select PHYLINK - ---help--- + help This driver supports the gigabit ethernet MACs in the MediaTek SoC family. config MEDIATEK_NETSYS_V2 tristate "MediaTek Ethernet NETSYS V2 support" depends on ARCH_MEDIATEK && NET_MEDIATEK_SOC_GE - ---help--- + help This options enable MTK Ethernet NETSYS V2 support config NET_MEDIATEK_HNAT tristate "MediaTek HW NAT support" depends on NET_MEDIATEK_SOC_GE && NF_CONNTRACK && IP_NF_NAT - ---help--- + help This driver supports the hardward Network Address Translation in the MediaTek MT2701/MT7622/MT7629/MT7621 chipset family. diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_dbg.c b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_dbg.c index 50f31af5355dd2..932156f5585b00 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_dbg.c +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_dbg.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "mtk_eth_soc.h" #include "mtk_eth_dbg.h" @@ -610,6 +611,7 @@ static int switch_count_open(struct inode *inode, struct file *file) return single_open(file, esw_cnt_read, 0); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations switch_count_fops = { .owner = THIS_MODULE, .open = switch_count_open, @@ -617,6 +619,14 @@ static const struct file_operations switch_count_fops = { .llseek = seq_lseek, .release = single_release }; +#else +static const struct proc_ops switch_count_fops = { + .proc_open = switch_count_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release +}; +#endif static struct proc_dir_entry *proc_tx_ring, *proc_hwtx_ring, *proc_rx_ring; @@ -662,6 +672,7 @@ static int tx_ring_open(struct inode *inode, struct file *file) return single_open(file, tx_ring_read, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations tx_ring_fops = { .owner = THIS_MODULE, .open = tx_ring_open, @@ -669,6 +680,14 @@ static const struct file_operations tx_ring_fops = { .llseek = seq_lseek, .release = single_release }; +#else +static const struct proc_ops tx_ring_fops = { + .proc_open = tx_ring_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release +}; +#endif int hwtx_ring_read(struct seq_file *seq, void *v) { @@ -709,6 +728,7 @@ static int hwtx_ring_open(struct inode *inode, struct file *file) return single_open(file, hwtx_ring_read, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations hwtx_ring_fops = { .owner = THIS_MODULE, .open = hwtx_ring_open, @@ -716,6 +736,14 @@ static const struct file_operations hwtx_ring_fops = { .llseek = seq_lseek, .release = single_release }; +#else +static const struct proc_ops hwtx_ring_fops = { + .proc_open = hwtx_ring_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release +}; +#endif int rx_ring_read(struct seq_file *seq, void *v) { @@ -757,6 +785,7 @@ static int rx_ring_open(struct inode *inode, struct file *file) return single_open(file, rx_ring_read, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations rx_ring_fops = { .owner = THIS_MODULE, .open = rx_ring_open, @@ -764,6 +793,14 @@ static const struct file_operations rx_ring_fops = { .llseek = seq_lseek, .release = single_release }; +#else +static const struct proc_ops rx_ring_fops = { + .proc_open = rx_ring_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release +}; +#endif static inline u32 mtk_dbg_r32(u32 reg) { @@ -885,6 +922,7 @@ static int dbg_regs_open(struct inode *inode, struct file *file) return single_open(file, dbg_regs_read, 0); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations dbg_regs_fops = { .owner = THIS_MODULE, .open = dbg_regs_open, @@ -892,6 +930,14 @@ static const struct file_operations dbg_regs_fops = { .llseek = seq_lseek, .release = single_release }; +#else +static const struct proc_ops dbg_regs_fops = { + .proc_open = dbg_regs_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release +}; +#endif void hw_lro_stats_update(u32 ring_no, struct mtk_rx_dma *rxd) { @@ -1177,6 +1223,7 @@ static int hw_lro_stats_open(struct inode *inode, struct file *file) return single_open(file, hw_lro_stats_read_wrapper, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations hw_lro_stats_fops = { .owner = THIS_MODULE, .open = hw_lro_stats_open, @@ -1185,6 +1232,15 @@ static const struct file_operations hw_lro_stats_fops = { .write = hw_lro_stats_write, .release = single_release }; +#else +static const struct proc_ops hw_lro_stats_fops = { + .proc_open = hw_lro_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = hw_lro_stats_write, + .proc_release = single_release +}; +#endif int hwlro_agg_cnt_ctrl(int cnt) { @@ -1485,6 +1541,7 @@ static int hw_lro_auto_tlb_open(struct inode *inode, struct file *file) return single_open(file, hw_lro_auto_tlb_read, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations hw_lro_auto_tlb_fops = { .owner = THIS_MODULE, .open = hw_lro_auto_tlb_open, @@ -1493,6 +1550,15 @@ static const struct file_operations hw_lro_auto_tlb_fops = { .write = hw_lro_auto_tlb_write, .release = single_release }; +#else +static const struct proc_ops hw_lro_auto_tlb_fops = { + .proc_open = hwtx_ring_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = hw_lro_auto_tlb_write, + .proc_release = single_release +}; +#endif int reset_event_read(struct seq_file *seq, void *v) { @@ -1542,6 +1608,7 @@ ssize_t reset_event_write(struct file *file, const char __user *buffer, return count; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static const struct file_operations reset_event_fops = { .owner = THIS_MODULE, .open = reset_event_open, @@ -1550,6 +1617,15 @@ static const struct file_operations reset_event_fops = { .write = reset_event_write, .release = single_release }; +#else +static const struct proc_ops reset_event_fops = { + .proc_open = reset_event_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = reset_event_write, + .proc_release = single_release +}; +#endif struct proc_dir_entry *proc_reg_dir; static struct proc_dir_entry *proc_esw_cnt, *proc_dbg_regs, *proc_reset_event; diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_soc.c b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_soc.c index c811c7006a2fa3..dd0bc05491638b 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_soc.c +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_eth_soc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "mtk_eth_soc.h" @@ -437,7 +438,11 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, mac->id, phy_modes(state->interface), err); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) static int mtk_mac_link_state(struct phylink_config *config, +#else +static void mtk_mac_pcs_get_state(struct phylink_config *config, +#endif struct phylink_link_state *state) { struct mtk_mac *mac = container_of(config, struct mtk_mac, @@ -468,7 +473,9 @@ static int mtk_mac_link_state(struct phylink_config *config, if (pmsr & MAC_MSR_TX_FC) state->pause |= MLO_PAUSE_TX; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) return 1; +#endif } static void mtk_mac_an_restart(struct phylink_config *config) @@ -490,9 +497,16 @@ static void mtk_mac_link_down(struct phylink_config *config, unsigned int mode, mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id)); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0) static void mtk_mac_link_up(struct phylink_config *config, unsigned int mode, phy_interface_t interface, struct phy_device *phy) +#else +static void mtk_mac_link_up(struct phylink_config *config, + struct phy_device *phy, + unsigned int mode, phy_interface_t interface, + int speed, int duplex, bool tx_pause, bool rx_pause) +#endif { struct mtk_mac *mac = container_of(config, struct mtk_mac, phylink_config); @@ -590,7 +604,11 @@ static void mtk_validate(struct phylink_config *config, static const struct phylink_mac_ops mtk_phylink_ops = { .validate = mtk_validate, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) .mac_link_state = mtk_mac_link_state, +#else + .mac_pcs_get_state = mtk_mac_pcs_get_state, +#endif .mac_an_restart = mtk_mac_an_restart, .mac_config = mtk_mac_config, .mac_link_down = mtk_mac_link_down, @@ -2490,7 +2508,11 @@ static void mtk_dma_free(struct mtk_eth *eth) } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) static void mtk_tx_timeout(struct net_device *dev) +#else +static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue) +#endif { struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; @@ -3402,9 +3424,15 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) { const __be32 *_id = of_get_property(np, "reg", NULL); struct phylink *phylink; - int phy_mode, id, err; struct mtk_mac *mac; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) + int phy_mode, id, err; +#else + int id, err; + phy_interface_t phy_mode = PHY_INTERFACE_MODE_NA; +#endif + if (!_id) { dev_err(eth->dev, "missing mac id\n"); return -EINVAL; @@ -3448,8 +3476,13 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; /* phylink create */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) phy_mode = of_get_phy_mode(np); if (phy_mode < 0) { +#else + of_get_phy_mode(np, &phy_mode); + if (phy_mode == PHY_INTERFACE_MODE_NA) { +#endif dev_err(eth->dev, "incorrect phy-mode\n"); err = -EINVAL; goto free_netdev; diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.c b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.c index 09b51fa948cf83..4a5da846d8443f 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.c +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.c @@ -735,7 +735,11 @@ static int hnat_probe(struct platform_device *pdev) if (!res) return -ENOENT; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) hnat_priv->fe_base = devm_ioremap_nocache(&pdev->dev, res->start, +#else + hnat_priv->fe_base = devm_ioremap(&pdev->dev, res->start, +#endif res->end - res->start + 1); if (!hnat_priv->fe_base) return -EADDRNOTAVAIL; diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.h b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.h index d6bf7f2494bfcf..97a9071a15a73b 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.h +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat.h @@ -17,8 +17,13 @@ #include #include #include +#include #include "hnat_mcast.h" +#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 4, 0) +#include +#endif + /*--------------------------------------------------------------------------*/ /* Register Offset*/ /*--------------------------------------------------------------------------*/ diff --git a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat_debugfs.c b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat_debugfs.c index d4b9b6368f090d..a3ab80d18bfefe 100644 --- a/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat_debugfs.c +++ b/target/linux/ramips/files/drivers/net/ethernet/mtk/mtk_hnat/hnat_debugfs.c @@ -2262,7 +2262,6 @@ int hnat_init_debugfs(struct mtk_hnat *h) { int ret = 0; struct dentry *root; - struct dentry *file; long i; char name[16]; @@ -2285,10 +2284,18 @@ int hnat_init_debugfs(struct mtk_hnat *h) h->regset[i]->nregs = ARRAY_SIZE(hnat_regs); h->regset[i]->base = h->ppe_base[i]; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) + struct dentry *file; snprintf(name, sizeof(name), "regdump%ld", i); file = debugfs_create_regset32(name, S_IRUGO, root, h->regset[i]); if (!file) { +#else + debugfs_create_regset32(name, S_IRUGO, + root, h->regset[i]); + ret = snprintf(name, sizeof(name), "regdump%ld", i); + if (ret != strlen(name)) { +#endif dev_notice(h->dev, "%s:err at %d\n", __func__, __LINE__); ret = -ENOMEM; goto err1; diff --git a/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x.h b/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x.h index 732bda1d3bb2b4..bd850369609dd0 100644 --- a/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x.h +++ b/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifdef CONFIG_SWCONFIG #include @@ -35,7 +36,11 @@ enum mt753x_model { struct mt753x_port_cfg { struct device_node *np; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int phy_mode; +#else + phy_interface_t phy_mode; +#endif u32 enabled: 1; u32 force_link: 1; u32 speed: 2; diff --git a/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c b/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c index 06a1114b801cd6..7b834ab3747e39 100644 --- a/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c +++ b/target/linux/ramips/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -269,8 +270,13 @@ static void mt753x_load_port_cfg(struct gsw_mt753x *gsw) port_cfg->np = port_np; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) port_cfg->phy_mode = of_get_phy_mode(port_np); if (port_cfg->phy_mode < 0) { +#else + of_get_phy_mode(port_np, &port_cfg->phy_mode); + if (port_cfg->phy_mode == PHY_INTERFACE_MODE_NA) { +#endif dev_info(gsw->dev, "incorrect phy-mode %d\n", port); continue; } @@ -523,7 +529,7 @@ static int mt753x_hw_reset(struct gsw_mt753x *gsw) return 0; } -#if 1 //XDXDXDXD + static int mt753x_mdio_read(struct mii_bus *bus, int addr, int reg) { struct gsw_mt753x *gsw = bus->priv; @@ -566,7 +572,11 @@ static void mt753x_connect_internal_phys(struct gsw_mt753x *gsw, { struct device_node *phy_np; struct mt753x_phy *phy; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) int phy_mode; +#else + phy_interface_t phy_mode = PHY_INTERFACE_MODE_NA; +#endif u32 phyad; if (!mii_np) @@ -579,8 +589,13 @@ static void mt753x_connect_internal_phys(struct gsw_mt753x *gsw, if (phyad >= MT753X_NUM_PHYS) continue; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) phy_mode = of_get_phy_mode(phy_np); if (phy_mode < 0) { +#else + of_get_phy_mode(phy_np, &phy_mode); + if (phy_mode == PHY_INTERFACE_MODE_NA) { +#endif dev_info(gsw->dev, "incorrect phy-mode %d for PHY %d\n", phy_mode, phyad); continue; @@ -655,7 +670,9 @@ static int mt753x_mdio_register(struct gsw_mt753x *gsw) ret = of_mdiobus_register(gsw->gphy_bus, mii_np); if (ret) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0) devm_mdiobus_free(gsw->dev, gsw->gphy_bus); +#endif gsw->gphy_bus = NULL; } else { if (gsw->phy_status_poll) @@ -668,7 +685,6 @@ static int mt753x_mdio_register(struct gsw_mt753x *gsw) return ret; } -#endif static irqreturn_t mt753x_irq_handler(int irq, void *dev) { @@ -772,10 +788,8 @@ static int mt753x_probe(struct platform_device *pdev) "mediatek,phy-poll"); mt753x_add_gsw(gsw); -#if 1 //XDXD - mt753x_mdio_register(gsw); -#endif + mt753x_mdio_register(gsw); mt753x_swconfig_init(gsw); if (sw->post_init) @@ -806,11 +820,9 @@ static int mt753x_remove(struct platform_device *pdev) mt753x_swconfig_destroy(gsw); #endif -#if 1 //XDXD mt753x_disconnect_internal_phys(gsw); mdiobus_unregister(gsw->gphy_bus); -#endif mt753x_remove_gsw(gsw); diff --git a/target/linux/ramips/mt7621/config-5.10 b/target/linux/ramips/mt7621/config-5.10 index fa8a4d8ff969b7..1f6b570d189060 100644 --- a/target/linux/ramips/mt7621/config-5.10 +++ b/target/linux/ramips/mt7621/config-5.10 @@ -25,7 +25,6 @@ CONFIG_CPU_HAS_PREFETCH=y CONFIG_CPU_HAS_RIXI=y CONFIG_CPU_HAS_SYNC=y CONFIG_CPU_IDLE=y -# CONFIG_CPU_IDLE_GOV_LADDER is not set CONFIG_CPU_IDLE_GOV_TEO=y CONFIG_CPU_MIPS32=y # CONFIG_CPU_MIPS32_R1 is not set @@ -41,21 +40,18 @@ CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y CONFIG_CPU_SUPPORTS_HIGHMEM=y CONFIG_CPU_SUPPORTS_MSA=y CONFIG_CRC16=y -CONFIG_CRYPTO_ACOMP2=y -CONFIG_CRYPTO_AEAD=y -CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLAKE2S=y CONFIG_CRYPTO_DEFLATE=y -CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_GF128MUL=y CONFIG_CRYPTO_HASH_INFO=y +CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 CONFIG_CRYPTO_LZO=y -CONFIG_CRYPTO_MANAGER=y -CONFIG_CRYPTO_MANAGER2=y CONFIG_CRYPTO_NULL2=y CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_ZSTD=y CONFIG_CSRC_R4K=y CONFIG_DEBUG_PINCTRL=y -CONFIG_DIMLIB=y CONFIG_DMA_NONCOHERENT=y # CONFIG_DTB_GNUBEE1 is not set # CONFIG_DTB_GNUBEE2 is not set @@ -101,7 +97,9 @@ CONFIG_HAS_IOMEM=y CONFIG_HAS_IOPORT_MAP=y CONFIG_HIGHMEM=y CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=y CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y CONFIG_I2C_GPIO=y CONFIG_I2C_MT7621=y CONFIG_ICPLUS_PHY=y @@ -112,15 +110,15 @@ CONFIG_IRQ_DOMAIN_HIERARCHY=y CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y -# CONFIG_KERNEL_ZSTD is not set CONFIG_LED_TRIGGER_PHY=y CONFIG_LIBFDT=y -CONFIG_LLD_VERSION=0 +CONFIG_LIB_MEMNEQ=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LZO_COMPRESS=y CONFIG_LZO_DECOMPRESS=y CONFIG_MDIO_BUS=y CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y CONFIG_MEMFD_CREATE=y CONFIG_MFD_SYSCON=y CONFIG_MIGRATION=y @@ -129,7 +127,6 @@ CONFIG_MIKROTIK_RB_SYSFS=y CONFIG_MIPS=y CONFIG_MIPS_ASID_BITS=8 CONFIG_MIPS_ASID_SHIFT=0 -CONFIG_MIPS_CBPF_JIT=y CONFIG_MIPS_CLOCK_VSYSCALL=y CONFIG_MIPS_CM=y # CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set @@ -142,6 +139,7 @@ CONFIG_MIPS_CPS_CPUIDLE=y # CONFIG_MIPS_CPS_NS16550_BOOL is not set CONFIG_MIPS_CPS_PM=y CONFIG_MIPS_CPU_SCACHE=y +CONFIG_MIPS_EBPF_JIT=y # CONFIG_MIPS_ELF_APPENDED_DTB is not set CONFIG_MIPS_GIC=y CONFIG_MIPS_L1_CACHE_SHIFT=5 @@ -155,6 +153,7 @@ CONFIG_MIPS_PERF_SHARED_TC_COUNTERS=y CONFIG_MIPS_RAW_APPENDED_DTB=y CONFIG_MIPS_SPRAM=y CONFIG_MODULES_USE_ELF_REL=y +CONFIG_MT753X_GSW=y CONFIG_MT7621_WDT=y # CONFIG_MTD_CFI_INTELEXT is not set CONFIG_MTD_CMDLINE_PARTS=y @@ -185,16 +184,11 @@ CONFIG_NET_DSA=y CONFIG_NET_DSA_MT7530=y CONFIG_NET_DSA_TAG_MTK=y CONFIG_NET_FLOW_LIMIT=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_RALINK_GSW_MT7621=y -CONFIG_NET_RALINK_MDIO=y -CONFIG_NET_RALINK_MDIO_MT7620=y -CONFIG_NET_RALINK_MT7621=y -# CONFIG_NET_RALINK_OFFLOAD is not set -CONFIG_NET_RALINK_SOC=y +CONFIG_NET_MEDIATEK_SOC_GE=y CONFIG_NET_SWITCHDEV=y -CONFIG_NET_VENDOR_MEDIATEK=y +# CONFIG_NET_VENDOR_MEDIATEK is not set # CONFIG_NET_VENDOR_RALINK is not set +CONFIG_NET_VENDOR_RAW_MEDIATEK=y CONFIG_NO_HZ_COMMON=y CONFIG_NO_HZ_IDLE=y CONFIG_NR_CPUS=4 @@ -238,6 +232,7 @@ CONFIG_RCU_NEED_SEGCBLIST=y CONFIG_RCU_STALL_COMMON=y CONFIG_REALTEK_PHY=y CONFIG_REGMAP=y +CONFIG_REGMAP_I2C=y CONFIG_REGMAP_MMIO=y CONFIG_REGULATOR=y CONFIG_REGULATOR_FIXED_VOLTAGE=y @@ -299,7 +294,9 @@ CONFIG_USB_SUPPORT=y CONFIG_USE_OF=y CONFIG_WATCHDOG_CORE=y CONFIG_WEAK_ORDERING=y -CONFIG_WEAK_REORDERING_BEYOND_LLSC=y CONFIG_XPS=y +CONFIG_XXHASH=y CONFIG_ZLIB_DEFLATE=y CONFIG_ZLIB_INFLATE=y +CONFIG_ZSTD_COMPRESS=y +CONFIG_ZSTD_DECOMPRESS=y diff --git a/target/linux/ramips/mt7621/target.mk b/target/linux/ramips/mt7621/target.mk index 7c21c525c71cad..1fd4039d2ed044 100644 --- a/target/linux/ramips/mt7621/target.mk +++ b/target/linux/ramips/mt7621/target.mk @@ -10,7 +10,7 @@ KERNELNAME:=vmlinux vmlinuz # make Kernel/CopyImage use $LINUX_DIR/vmlinuz IMAGES_DIR:=../../.. -DEFAULT_PACKAGES += kmod-mtk-hnat wpad-openssl swconfig kmod-crypto-hw-eip93 +DEFAULT_PACKAGES += kmod-mtk-hnat wpad-openssl swconfig define Target/Description Build firmware images for Ralink MT7621 based boards. diff --git a/target/linux/ramips/patches-5.10/901-add-mtk-vendor-ethernet-drivers.patch b/target/linux/ramips/patches-5.10/901-add-mtk-vendor-ethernet-drivers.patch new file mode 100644 index 00000000000000..c183441c59cc43 --- /dev/null +++ b/target/linux/ramips/patches-5.10/901-add-mtk-vendor-ethernet-drivers.patch @@ -0,0 +1,41 @@ +--- a/drivers/net/ethernet/Kconfig ++++ b/drivers/net/ethernet/Kconfig +@@ -125,6 +125,7 @@ source "drivers/net/ethernet/micrel/Kcon + source "drivers/net/ethernet/microchip/Kconfig" + source "drivers/net/ethernet/moxa/Kconfig" + source "drivers/net/ethernet/mscc/Kconfig" ++source "drivers/net/ethernet/mtk/Kconfig" + source "drivers/net/ethernet/myricom/Kconfig" + + config FEALNX +--- a/drivers/net/ethernet/Makefile ++++ b/drivers/net/ethernet/Makefile +@@ -73,6 +73,7 @@ obj-$(CONFIG_NET_VENDOR_PASEMI) += pasem + obj-$(CONFIG_NET_VENDOR_QLOGIC) += qlogic/ + obj-$(CONFIG_NET_VENDOR_QUALCOMM) += qualcomm/ + obj-$(CONFIG_NET_VENDOR_RALINK) += ralink/ ++obj-$(CONFIG_NET_VENDOR_RAW_MEDIATEK) += mtk/ + obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/ + obj-$(CONFIG_NET_VENDOR_RENESAS) += renesas/ + obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ +--- a/drivers/net/phy/Kconfig ++++ b/drivers/net/phy/Kconfig +@@ -577,6 +577,8 @@ config XILINX_GMII2RGMII + the Reduced Gigabit Media Independent Interface(RGMII) between + Ethernet physical media devices and the Gigabit Ethernet controller. + ++source "drivers/net/phy/mtk/mt753x/Kconfig" ++ + endif # PHYLIB + + config MICREL_KS8995MA +--- a/drivers/net/phy/Makefile ++++ b/drivers/net/phy/Makefile +@@ -99,6 +99,7 @@ obj-$(CONFIG_MICROCHIP_PHY) += microchip + obj-$(CONFIG_MICROCHIP_T1_PHY) += microchip_t1.o + obj-$(CONFIG_MICROSEMI_PHY) += mscc.o + obj-$(CONFIG_NATIONAL_PHY) += national.o ++obj-$(CONFIG_MT753X_GSW) += mtk/mt753x/ + obj-$(CONFIG_NXP_TJA11XX_PHY) += nxp-tja11xx.o + obj-$(CONFIG_QSEMI_PHY) += qsemi.o + obj-$(CONFIG_REALTEK_PHY) += realtek.o diff --git a/target/linux/ramips/patches-5.10/902-mtkhnat-fix-pskb-expand-head-limitation.patch b/target/linux/ramips/patches-5.10/902-mtkhnat-fix-pskb-expand-head-limitation.patch new file mode 100644 index 00000000000000..b8165e7b6ca9ae --- /dev/null +++ b/target/linux/ramips/patches-5.10/902-mtkhnat-fix-pskb-expand-head-limitation.patch @@ -0,0 +1,20 @@ +--- a/net/core/skbuff.c ++++ b/net/core/skbuff.c +@@ -69,6 +69,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -1666,6 +1667,9 @@ int pskb_expand_head(struct sk_buff *skb + skb_shinfo(skb), + offsetof(struct skb_shared_info, frags[skb_shinfo(skb)->nr_frags])); + ++ /*headroom copy*/ ++ memcpy(data, skb->head, FOE_INFO_LEN); ++ + /* + * if shinfo is shared we must drop the old head gracefully, but if it + * is not we can just drop the old head and let the existing refcount diff --git a/target/linux/ramips/patches-5.10/903-mtkhnat-add-support-for-interface-acceleration.patch b/target/linux/ramips/patches-5.10/903-mtkhnat-add-support-for-interface-acceleration.patch new file mode 100644 index 00000000000000..d5ccf009a30dc5 --- /dev/null +++ b/target/linux/ramips/patches-5.10/903-mtkhnat-add-support-for-interface-acceleration.patch @@ -0,0 +1,224 @@ +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1027,6 +1027,8 @@ + struct notifier_block *nb; + }; + ++struct flow_offload_hw_path; ++ + /* + * This structure defines the management hooks for network devices. + * The following hooks can be defined; unless noted otherwise, they are +@@ -1568,6 +1570,7 @@ + struct net_device * (*ndo_get_peer_dev)(struct net_device *dev); + int (*ndo_fill_forward_path)(struct net_device_path_ctx *ctx, + struct net_device_path *path); ++ int (*ndo_flow_offload_check)(struct flow_offload_hw_path *path); + }; + + /** + +--- a/include/linux/ppp_channel.h ++++ b/include/linux/ppp_channel.h +@@ -31,6 +31,7 @@ + int (*fill_forward_path)(struct net_device_path_ctx *, + struct net_device_path *, + const struct ppp_channel *); ++ int (*flow_offload_check)(struct ppp_channel *, struct flow_offload_hw_path *); + }; + + struct ppp_channel { + +--- a/include/net/netfilter/nf_hnat.h ++++ b/include/net/netfilter/nf_hnat.h +@@ -0,0 +1,17 @@ ++#define FLOW_OFFLOAD_PATH_ETHERNET BIT(0) ++#define FLOW_OFFLOAD_PATH_VLAN BIT(1) ++#define FLOW_OFFLOAD_PATH_PPPOE BIT(2) ++#define FLOW_OFFLOAD_PATH_DSLITE BIT(4) ++#define FLOW_OFFLOAD_PATH_6RD BIT(5) ++ ++struct flow_offload_hw_path { ++ struct net_device *dev; ++ struct net_device *virt_dev; ++ u32 flags; ++ ++ u8 eth_src[ETH_ALEN]; ++ u8 eth_dest[ETH_ALEN]; ++ u16 vlan_proto; ++ u16 vlan_id; ++ u16 pppoe_sid; ++}; +--- a/drivers/net/ppp/ppp_generic.c ++++ b/drivers/net/ppp/ppp_generic.c +@@ -52,6 +52,7 @@ + #include + #include + #include ++#include + + #define PPP_VERSION "2.4.2" + +@@ -1487,6 +1488,26 @@ + return chan->ops->fill_forward_path(ctx, path, chan); + } + ++static int ppp_flow_offload_check(struct flow_offload_hw_path *path) ++{ ++ struct ppp *ppp = netdev_priv(path->dev); ++ struct ppp_channel *chan; ++ struct channel *pch; ++ ++ if (ppp->flags & SC_MULTILINK) ++ return -EOPNOTSUPP; ++ ++ if (list_empty(&ppp->channels)) ++ return -ENODEV; ++ ++ pch = list_first_entry(&ppp->channels, struct channel, clist); ++ chan = pch->chan; ++ if (!chan->ops->flow_offload_check) ++ return -EOPNOTSUPP; ++ ++ return chan->ops->flow_offload_check(chan, path); ++} ++ + static const struct net_device_ops ppp_netdev_ops = { + .ndo_init = ppp_dev_init, + .ndo_uninit = ppp_dev_uninit, +@@ -1494,6 +1515,7 @@ + .ndo_do_ioctl = ppp_net_ioctl, + .ndo_get_stats64 = ppp_get_stats64, + .ndo_fill_forward_path = ppp_fill_forward_path, ++ .ndo_flow_offload_check = ppp_flow_offload_check, + }; + + static struct device_type ppp_type = { +--- a/drivers/net/ppp/pppoe.c ++++ b/drivers/net/ppp/pppoe.c +@@ -79,6 +79,7 @@ + #include + + #include ++#include + + #define PPPOE_HASH_BITS 4 + #define PPPOE_HASH_SIZE (1 << PPPOE_HASH_BITS) +@@ -994,9 +996,33 @@ + return 0; + } + ++static int pppoe_flow_offload_check(struct ppp_channel *chan, ++ struct flow_offload_hw_path *path) ++{ ++ struct sock *sk = (struct sock *)chan->private; ++ struct pppox_sock *po = pppox_sk(sk); ++ struct net_device *dev = po->pppoe_dev; ++ ++ if (sock_flag(sk, SOCK_DEAD) || ++ !(sk->sk_state & PPPOX_CONNECTED) || !dev) ++ return -ENODEV; ++ ++ path->dev = po->pppoe_dev; ++ path->flags |= FLOW_OFFLOAD_PATH_PPPOE; ++ memcpy(path->eth_src, po->pppoe_dev->dev_addr, ETH_ALEN); ++ memcpy(path->eth_dest, po->pppoe_pa.remote, ETH_ALEN); ++ path->pppoe_sid = be16_to_cpu(po->num); ++ ++ if (path->dev->netdev_ops->ndo_flow_offload_check) ++ return path->dev->netdev_ops->ndo_flow_offload_check(path); ++ ++ return 0; ++} ++ + static const struct ppp_channel_ops pppoe_chan_ops = { + .start_xmit = pppoe_xmit, + .fill_forward_path = pppoe_fill_forward_path, ++ .flow_offload_check = pppoe_flow_offload_check, + }; + + static int pppoe_recvmsg(struct socket *sock, struct msghdr *m, +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -56,6 +56,7 @@ + #include + #include + #include ++#include + + MODULE_AUTHOR("Ville Nuorvala"); + MODULE_DESCRIPTION("IPv6 tunneling device"); +@@ -1937,6 +1938,20 @@ + } + EXPORT_SYMBOL(ip6_tnl_change_mtu); + ++static int ipip6_dev_flow_offload_check(struct flow_offload_hw_path *path) ++{ ++ struct net_device *dev = path->dev; ++ struct ip6_tnl *tnl = netdev_priv(dev); ++ ++ if (path->flags & FLOW_OFFLOAD_PATH_DSLITE) ++ return -EEXIST; ++ ++ path->flags |= FLOW_OFFLOAD_PATH_DSLITE; ++ path->dev = tnl->dev; ++ ++ return 0; ++} ++ + int ip6_tnl_get_iflink(const struct net_device *dev) + { + struct ip6_tnl *t = netdev_priv(dev); +@@ -2006,6 +2021,7 @@ + .ndo_change_mtu = ip6_tnl_change_mtu, + .ndo_get_stats = ip6_get_stats, + .ndo_get_iflink = ip6_tnl_get_iflink, ++ .ndo_flow_offload_check = ipip6_dev_flow_offload_check, + }; + + #define IPXIPX_FEATURES (NETIF_F_SG | \ +--- a/net/8021q/vlan_dev.c ++++ b/net/8021q/vlan_dev.c +@@ -31,6 +31,8 @@ + #include "vlanproc.h" + #include + #include ++#include ++#include + + /* + * Create the VLAN header for an arbitrary protocol layer +@@ -790,6 +792,25 @@ + return 0; + } + ++static int vlan_dev_flow_offload_check(struct flow_offload_hw_path *path) ++{ ++ struct net_device *dev = path->dev; ++ struct vlan_dev_priv *vlan = vlan_dev_priv(dev); ++ ++ if (path->flags & FLOW_OFFLOAD_PATH_VLAN) ++ return -EEXIST; ++ ++ path->flags |= FLOW_OFFLOAD_PATH_VLAN; ++ path->vlan_proto = vlan->vlan_proto; ++ path->vlan_id = vlan->vlan_id; ++ path->virt_dev = dev; ++ path->dev = vlan->real_dev; ++ ++ if (vlan->real_dev->netdev_ops->ndo_flow_offload_check) ++ return vlan->real_dev->netdev_ops->ndo_flow_offload_check(path); ++ return 0; ++} ++ + static const struct ethtool_ops vlan_ethtool_ops = { + .get_link_ksettings = vlan_ethtool_get_link_ksettings, + .get_drvinfo = vlan_ethtool_get_drvinfo, +@@ -829,6 +850,7 @@ + .ndo_fix_features = vlan_dev_fix_features, + .ndo_get_iflink = vlan_dev_get_iflink, + .ndo_fill_forward_path = vlan_dev_fill_forward_path, ++ .ndo_flow_offload_check = vlan_dev_flow_offload_check, + }; + + static void vlan_dev_free(struct net_device *dev) diff --git a/target/linux/ramips/patches-5.10/999-crypto-eip93-fix.patch b/target/linux/ramips/patches-5.10/999-crypto-eip93-fix.patch deleted file mode 100644 index e11808bf14aaa2..00000000000000 --- a/target/linux/ramips/patches-5.10/999-crypto-eip93-fix.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/include/linux/crypto.h -+++ b/include/linux/crypto.h -@@ -101,6 +101,11 @@ - #define CRYPTO_NOLOAD 0x00008000 - - /* -+ * Transform masks and values (for crt_flags). -+ */ -+#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000 -+ -+/* - * The algorithm may allocate memory during request processing, i.e. during - * encryption, decryption, or hashing. Users can request an algorithm with this - * flag unset if they can't handle memory allocation failures. diff --git a/target/linux/ramips/patches-5.10/999-fix-hwnat.patch b/target/linux/ramips/patches-5.10/999-fix-hwnat.patch deleted file mode 100644 index ef821d6d93a75f..00000000000000 --- a/target/linux/ramips/patches-5.10/999-fix-hwnat.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- a/arch/mips/include/asm/mach-ralink/mt7621/cpu-feature-overrides.h -+++ b/arch/mips/include/asm/mach-ralink/mt7621/cpu-feature-overrides.h -@@ -43,6 +43,9 @@ - #define cpu_has_dsp2 0 - #define cpu_has_mipsmt 1 - -+#define cpu_has_vint 0 -+#define cpu_has_veic 0 -+ - #define cpu_has_64bits 0 - #define cpu_has_64bit_zero_reg 0 - #define cpu_has_64bit_gp_regs 0