diff --git a/include/image.mk b/include/image.mk index 984b64fb9c..300f7a6619 100644 --- a/include/image.mk +++ b/include/image.mk @@ -592,6 +592,7 @@ define Device/Build/image DEVICE_ALT2_MODEL="$(DEVICE_ALT2_MODEL)" \ DEVICE_ALT2_VARIANT="$(DEVICE_ALT2_VARIANT)" \ DEVICE_TITLE="$(DEVICE_TITLE)" \ + DEVICE_PACKAGES="$(DEVICE_PACKAGES)" \ TARGET="$(BOARD)" \ SUBTARGET="$(if $(SUBTARGET),$(SUBTARGET),generic)" \ VERSION_NUMBER="$(VERSION_NUMBER)" \ diff --git a/package/boot/uboot-ramips/Makefile b/package/boot/uboot-ramips/Makefile new file mode 100644 index 0000000000..5229f5cd3c --- /dev/null +++ b/package/boot/uboot-ramips/Makefile @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0-only + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_VERSION:=2020.04 +PKG_RELEASE:=1 + +PKG_HASH:=fe732aaf037d9cc3c0909bad8362af366ae964bbdac6913a34081ff4ad565372 + +include $(INCLUDE_DIR)/u-boot.mk +include $(INCLUDE_DIR)/package.mk + +define U-Boot/Default + BUILD_TARGET:=ramips + UBOOT_IMAGE:=u-boot.bin +endef + +define U-Boot/ravpower_rp-wd009 + BUILD_DEVICES:=ravpower_rp-wd009 + BUILD_SUBTARGET:=mt76x8 + NAME:=RAVPower RP-WD009 + UBOOT_CONFIG:=ravpower-rp-wd009-ram +endef + +UBOOT_TARGETS := \ + ravpower_rp-wd009 + +define Build/InstallDev + $(INSTALL_DIR) $(STAGING_DIR_IMAGE) + $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(VARIANT)-$(UBOOT_IMAGE) +endef + +$(eval $(call BuildPackage/U-Boot)) diff --git a/package/boot/uboot-ramips/patches/0001-add-support-for-RAVPower-RP-WD009.patch b/package/boot/uboot-ramips/patches/0001-add-support-for-RAVPower-RP-WD009.patch new file mode 100644 index 0000000000..1833a627dc --- /dev/null +++ b/package/boot/uboot-ramips/patches/0001-add-support-for-RAVPower-RP-WD009.patch @@ -0,0 +1,290 @@ +From 593db38363297247df731566c2aa307a5d795005 Mon Sep 17 00:00:00 2001 +From: David Bauer +Date: Thu, 18 Jun 2020 00:13:11 +0200 +Subject: [PATCH] add support for RAVPower RP-WD009 + +--- + arch/mips/dts/Makefile | 3 +- + arch/mips/dts/ravpower-rp-wd009.dts | 50 +++++++++++++++++++++ + arch/mips/mach-mtmips/Kconfig | 9 ++++ + board/ravpower/rp-wd009/Kconfig | 12 +++++ + board/ravpower/rp-wd009/Makefile | 3 ++ + board/ravpower/rp-wd009/board.c | 16 +++++++ + configs/ravpower-rp-wd009-ram_defconfig | 59 +++++++++++++++++++++++++ + include/configs/ravpower-rp-wd009.h | 48 ++++++++++++++++++++ + 8 files changed, 199 insertions(+), 1 deletion(-) + create mode 100644 arch/mips/dts/ravpower-rp-wd009.dts + create mode 100644 board/ravpower/rp-wd009/Kconfig + create mode 100644 board/ravpower/rp-wd009/Makefile + create mode 100644 board/ravpower/rp-wd009/board.c + create mode 100644 configs/ravpower-rp-wd009-ram_defconfig + create mode 100644 include/configs/ravpower-rp-wd009.h + +diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile +index c9d75596f2..23868ae1d2 100644 +--- a/arch/mips/dts/Makefile ++++ b/arch/mips/dts/Makefile +@@ -2,7 +2,8 @@ + + dtb-$(CONFIG_ARCH_MTMIPS) += \ + gardena-smart-gateway-mt7688.dtb \ +- linkit-smart-7688.dtb ++ linkit-smart-7688.dtb \ ++ ravpower-rp-wd009.dtb + dtb-$(CONFIG_TARGET_AP121) += ap121.dtb + dtb-$(CONFIG_TARGET_AP143) += ap143.dtb + dtb-$(CONFIG_TARGET_AP152) += ap152.dtb +diff --git a/arch/mips/dts/ravpower-rp-wd009.dts b/arch/mips/dts/ravpower-rp-wd009.dts +new file mode 100644 +index 0000000000..b271d5bfbc +--- /dev/null ++++ b/arch/mips/dts/ravpower-rp-wd009.dts +@@ -0,0 +1,50 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2018 Stefan Roese ++ */ ++ ++/dts-v1/; ++ ++#include "mt7628a.dtsi" ++#include ++ ++/ { ++ compatible = "ravpower,rp-wd009", "ralink,mt7628a-soc"; ++ model = "RAVPower RP-WD009"; ++ ++ aliases { ++ serial0 = &uart0; ++ spi0 = &spi0; ++ }; ++ ++ memory@0 { ++ device_type = "memory"; ++ reg = <0x0 0x4000000>; ++ }; ++ ++ chosen { ++ stdout-path = "serial0:115200n8"; ++ }; ++}; ++ ++&uart0 { ++ status = "okay"; ++}; ++ ++&spi0 { ++ status = "okay"; ++ num-cs = <2>; ++ ++ spi-flash@0 { ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "jedec,spi-nor"; ++ spi-max-frequency = <40000000>; ++ reg = <0>; ++ }; ++}; ++ ++ð { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&ephy_router_mode>; ++}; +diff --git a/arch/mips/mach-mtmips/Kconfig b/arch/mips/mach-mtmips/Kconfig +index c8dcf19c0d..85ac8878ab 100644 +--- a/arch/mips/mach-mtmips/Kconfig ++++ b/arch/mips/mach-mtmips/Kconfig +@@ -32,6 +32,14 @@ config BOARD_GARDENA_SMART_GATEWAY_MT7688 + GARDENA smart Gateway boards have a MT7688 SoC with 128 MiB of RAM + and 8 MiB of flash (SPI NOR) and additional SPI NAND storage. + ++config BOARD_RAVPOWER_RP_WD009 ++ bool "RAVPower RP-WD009" ++ depends on SOC_MT7628 ++ select BOARD_LATE_INIT ++ select SUPPORTS_BOOT_RAM ++ help ++ RAVPower RP-WD009 ++ + config BOARD_LINKIT_SMART_7688 + bool "LinkIt Smart 7688" + depends on SOC_MT7628 +@@ -133,6 +141,7 @@ config SUPPORTS_BOOT_RAM + bool + + source "board/gardena/smart-gateway-mt7688/Kconfig" ++source "board/ravpower/rp-wd009/Kconfig" + source "board/seeed/linkit-smart-7688/Kconfig" + + endmenu +diff --git a/board/ravpower/rp-wd009/Kconfig b/board/ravpower/rp-wd009/Kconfig +new file mode 100644 +index 0000000000..111f8e4478 +--- /dev/null ++++ b/board/ravpower/rp-wd009/Kconfig +@@ -0,0 +1,12 @@ ++if BOARD_RAVPOWER_RP_WD009 ++ ++config SYS_BOARD ++ default "rp-wd009" ++ ++config SYS_VENDOR ++ default "ravpower" ++ ++config SYS_CONFIG_NAME ++ default "ravpower-rp-wd009" ++ ++endif +diff --git a/board/ravpower/rp-wd009/Makefile b/board/ravpower/rp-wd009/Makefile +new file mode 100644 +index 0000000000..70cd7a8e56 +--- /dev/null ++++ b/board/ravpower/rp-wd009/Makefile +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: GPL-2.0+ ++ ++obj-y += board.o +diff --git a/board/ravpower/rp-wd009/board.c b/board/ravpower/rp-wd009/board.c +new file mode 100644 +index 0000000000..eabcf85735 +--- /dev/null ++++ b/board/ravpower/rp-wd009/board.c +@@ -0,0 +1,16 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Copyright (C) 2018 Stefan Roese ++ */ ++ ++ ++int board_early_init_f(void) ++{ ++ return 0; ++} ++ ++ ++int board_late_init(void) ++{ ++ return 0; ++} +diff --git a/configs/ravpower-rp-wd009-ram_defconfig b/configs/ravpower-rp-wd009-ram_defconfig +new file mode 100644 +index 0000000000..08cbf40638 +--- /dev/null ++++ b/configs/ravpower-rp-wd009-ram_defconfig +@@ -0,0 +1,59 @@ ++CONFIG_MIPS=y ++CONFIG_SYS_TEXT_BASE=0x80010000 ++CONFIG_NR_DRAM_BANKS=1 ++CONFIG_ARCH_MTMIPS=y ++CONFIG_MIPS_BOOT_FDT=y ++CONFIG_LEGACY_IMAGE_FORMAT=y ++CONFIG_OF_STDOUT_VIA_ALIAS=y ++CONFIG_USE_BOOTCOMMAND=y ++CONFIG_BOOTCOMMAND="sf probe && mtd read firmware 82000000 && bootm 82000000" ++CONFIG_USE_PREBOOT=y ++CONFIG_SYS_CONSOLE_INFO_QUIET=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_BOARD_RAVPOWER_RP_WD009=y ++CONFIG_BOARD_EARLY_INIT_F=y ++CONFIG_HUSH_PARSER=y ++CONFIG_CMD_LICENSE=y ++# CONFIG_CMD_ELF is not set ++# CONFIG_CMD_XIMG is not set ++CONFIG_CMD_MEMINFO=y ++# CONFIG_CMD_FLASH is not set ++CONFIG_CMD_GPIO=y ++# CONFIG_CMD_LOADS is not set ++CONFIG_CMD_MTD=y ++CONFIG_CMD_SPI=y ++CONFIG_CMD_WDT=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_MII=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_TIME=y ++CONFIG_CMD_UUID=y ++CONFIG_CMD_MTDPARTS=y ++CONFIG_MTDIDS_DEFAULT="nor0=spi0.0" ++CONFIG_MTDPARTS_DEFAULT="spi0.0:192k(factory-uboot),64k(config),64k(factory),1536k(loader),64k(params),64k(user_backup),64k(user),14272k(firmware),64k(mode)" ++CONFIG_DEFAULT_DEVICE_TREE="ravpower-rp-wd009" ++CONFIG_NET_RANDOM_ETHADDR=y ++# CONFIG_DM_DEVICE_REMOVE is not set ++CONFIG_HAVE_BLOCK_DEVICE=y ++CONFIG_LED=y ++CONFIG_LED_BLINK=y ++CONFIG_LED_GPIO=y ++CONFIG_MTD=y ++CONFIG_DM_MTD=y ++CONFIG_SPI_FLASH_GIGADEVICE=y ++CONFIG_SPI_FLASH_MACRONIX=y ++CONFIG_SPI_FLASH_SPANSION=y ++CONFIG_SPI_FLASH_STMICRO=y ++CONFIG_SPI_FLASH_WINBOND=y ++CONFIG_SPI_FLASH_XMC=y ++CONFIG_SPI_FLASH_MTD=y ++CONFIG_MTD_UBI_BEB_LIMIT=22 ++CONFIG_MT7628_ETH=y ++CONFIG_PHY=y ++CONFIG_SPI=y ++CONFIG_MT7621_SPI=y ++CONFIG_SYSRESET_SYSCON=y ++CONFIG_WDT=y ++CONFIG_WDT_MT7621=y ++CONFIG_LZMA=y ++CONFIG_BAUDRATE=57600 +diff --git a/include/configs/ravpower-rp-wd009.h b/include/configs/ravpower-rp-wd009.h +new file mode 100644 +index 0000000000..bb4145197c +--- /dev/null ++++ b/include/configs/ravpower-rp-wd009.h +@@ -0,0 +1,48 @@ ++/* SPDX-License-Identifier: GPL-2.0+ */ ++/* ++ * Copyright (C) 2018 Stefan Roese ++ */ ++ ++#ifndef __CONFIG_RAVPOWER_RP_WD009_H ++#define __CONFIG_RAVPOWER_RP_WD009_H ++ ++/* CPU */ ++#define CONFIG_SYS_MIPS_TIMER_FREQ 290000000 ++ ++/* RAM */ ++#define CONFIG_SYS_SDRAM_BASE 0x80000000 ++ ++#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE + 0x100000 ++ ++#define CONFIG_SYS_INIT_SP_OFFSET 0x400000 ++ ++#ifdef CONFIG_BOOT_RAM ++#define CONFIG_SKIP_LOWLEVEL_INIT ++#endif ++ ++/* UART */ ++#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, \ ++ 230400, 460800, 921600 } ++ ++/* RAM */ ++#define CONFIG_SYS_MEMTEST_START 0x80100000 ++#define CONFIG_SYS_MEMTEST_END 0x80400000 ++ ++/* Memory usage */ ++#define CONFIG_SYS_MAXARGS 64 ++#define CONFIG_SYS_MALLOC_LEN (16 * 1024 * 1024) ++#define CONFIG_SYS_BOOTPARAMS_LEN (128 * 1024) ++#define CONFIG_SYS_CBSIZE 512 ++ ++/* U-Boot */ ++#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE ++ ++/* Environment settings */ ++ ++/* ++ * Environment is right behind U-Boot in flash. Make sure U-Boot ++ * doesn't grow into the environment area. ++ */ ++#define CONFIG_BOARD_SIZE_LIMIT CONFIG_ENV_OFFSET ++ ++#endif /* __CONFIG_RAVPOWER_RP_WD009_H */ +-- +2.27.0 + diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile index 8031a0c62a..0a9b5c0a99 100644 --- a/package/network/services/dropbear/Makefile +++ b/package/network/services/dropbear/Makefile @@ -8,14 +8,14 @@ include $(TOPDIR)/rules.mk PKG_NAME:=dropbear -PKG_VERSION:=2020.79 +PKG_VERSION:=2020.80 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:= \ http://matt.ucc.asn.au/dropbear/releases/ \ https://dropbear.nl/mirror/releases/ -PKG_HASH:=084f00546b1610a3422a0773e2c04cbe1a220d984209e033b548b49f379cc441 +PKG_HASH:=d927941b91f2da150b2033f1a88b6a47999bf0afb1493a73e9216cffdb5d7949 PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE libtomcrypt/LICENSE libtommath/LICENSE diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init index daf111fadb..ab8e908d8c 100755 --- a/package/network/services/dropbear/files/dropbear.init +++ b/package/network/services/dropbear/files/dropbear.init @@ -238,7 +238,7 @@ killclients() while [ "${pid}" -ne 0 ] do # get parent process id - pid=`cut -d ' ' -f 4 "/proc/${pid}/stat"` + pid=$(cut -d ' ' -f 4 "/proc/${pid}/stat") [ "${pid}" -eq 0 ] && break # check if client connection @@ -249,14 +249,14 @@ killclients() done # get all server pids that should be ignored - for server in `cat /var/run/${NAME}.*.pid` + for server in $(cat /var/run/${NAME}.*.pid) do append ignore "${server}" done # get all running pids and kill client connections local skip - for pid in `pidof "${NAME}"` + for pid in $(pidof "${NAME}") do # check if correct program, otherwise process next pid grep -F -q -e "${PROG}" "/proc/${pid}/cmdline" || { diff --git a/package/network/services/dropbear/patches/001-backport_GNU_SOURCE-for-random.patch b/package/network/services/dropbear/patches/001-backport_GNU_SOURCE-for-random.patch deleted file mode 100644 index d9b13d77dd..0000000000 --- a/package/network/services/dropbear/patches/001-backport_GNU_SOURCE-for-random.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 3f5c106a880a02b21739f2022746e6aa7672474c Mon Sep 17 00:00:00 2001 -From: Matt Johnston -Date: Tue, 23 Jun 2020 21:38:46 +0800 -Subject: [PATCH] _GNU_SOURCE for random - ---- - includes.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/includes.h b/includes.h -index e8c3e18..2789f23 100644 ---- a/includes.h -+++ b/includes.h -@@ -125,6 +125,8 @@ - #endif - - #ifdef HAVE_SYS_RANDOM_H -+/* uclibc needs _GNU_SOURCE */ -+#define _GNU_SOURCE - #include - #endif - --- -2.25.1 - diff --git a/package/network/services/dropbear/patches/002-backport-move-GNU_SOURCE-earlier.patch b/package/network/services/dropbear/patches/002-backport-move-GNU_SOURCE-earlier.patch deleted file mode 100644 index 26454c2829..0000000000 --- a/package/network/services/dropbear/patches/002-backport-move-GNU_SOURCE-earlier.patch +++ /dev/null @@ -1,34 +0,0 @@ -From a7a67585cbc3fe5df85c641618b347a51a943356 Mon Sep 17 00:00:00 2001 -From: Matt Johnston -Date: Tue, 23 Jun 2020 22:24:58 +0800 -Subject: [PATCH] move GNU_SOURCE earlier - ---- - includes.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/includes.h b/includes.h -index 2789f23..884ebf7 100644 ---- a/includes.h -+++ b/includes.h -@@ -25,6 +25,8 @@ - #ifndef DROPBEAR_INCLUDES_H_ - #define DROPBEAR_INCLUDES_H_ - -+/* uclibc needs _GNU_SOURCE, maybe other things? */ -+#define _GNU_SOURCE - - #include "options.h" - #include "debug.h" -@@ -125,8 +127,6 @@ - #endif - - #ifdef HAVE_SYS_RANDOM_H --/* uclibc needs _GNU_SOURCE */ --#define _GNU_SOURCE - #include - #endif - --- -2.25.1 - diff --git a/package/network/services/dropbear/patches/010-backport-disable-toom-and-karatsuba.patch b/package/network/services/dropbear/patches/010-backport-disable-toom-and-karatsuba.patch deleted file mode 100644 index 9af291eb01..0000000000 --- a/package/network/services/dropbear/patches/010-backport-disable-toom-and-karatsuba.patch +++ /dev/null @@ -1,17 +0,0 @@ -From: Matt Johnston -Date: Thu, 18 Jun 2020 19:12:07 +0800 -Subject: Disable toom and karatsuba for new libtommath - ---- a/libtommath/tommath_class.h -+++ b/libtommath/tommath_class.h -@@ -1312,6 +1312,10 @@ - #undef BN_MP_KARATSUBA_SQR_C - #undef BN_MP_TOOM_MUL_C - #undef BN_MP_TOOM_SQR_C -+#undef BN_S_MP_KARATSUBA_MUL_C -+#undef BN_S_MP_KARATSUBA_SQR_C -+#undef BN_S_MP_TOOM_MUL_C -+#undef BN_S_MP_TOOM_SQR_C - - #include "dbmalloc.h" - #define MP_MALLOC m_malloc diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init index 49140ad406..c855bbc087 100755 --- a/package/system/zram-swap/files/zram.init +++ b/package/system/zram-swap/files/zram.init @@ -73,7 +73,7 @@ zram_getdev() local zdev=$( zram_dev ) if [ "$(mount | grep $zdev)" ]; then - local idx=`cat /sys/class/zram-control/hot_add` + local idx=$(cat /sys/class/zram-control/hot_add) zdev="$( zram_dev $idx )" fi @@ -89,7 +89,7 @@ zram_comp_algo() return 0 fi - if [ `grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm` -ne 0 ]; then + if [ $(grep -c "$zram_comp_algo" /sys/block/$( basename $dev )/comp_algorithm) -ne 0 ]; then logger -s -t zram_comp_algo -p daemon.debug "Set compression algorithm '$zram_comp_algo' for zram '$dev'" echo $zram_comp_algo > "/sys/block/$( basename $dev )/comp_algorithm" else @@ -147,8 +147,8 @@ zram_compact() # compact zram device (reduce memory allocation overhead) local zdev="/sys/block/$( basename "$1" )" - local old_mem_used=`awk '{print $3}' <$zdev/mm_stat` - local old_overhead=`awk '{print $3-$2}' <$zdev/mm_stat` + local old_mem_used=$(awk '{print $3}' <$zdev/mm_stat) + local old_overhead=$(awk '{print $3-$2}' <$zdev/mm_stat) echo 1 > $zdev/compact diff --git a/package/utils/ravpower-mcu/Makefile b/package/utils/ravpower-mcu/Makefile new file mode 100644 index 0000000000..435445fcc5 --- /dev/null +++ b/package/utils/ravpower-mcu/Makefile @@ -0,0 +1,34 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=ravpower-mcu + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL=https://github.com/blocktrron/ravpower-mcu.git +PKG_MIRROR_HASH:=edde0fda3fc708eac65baff46b5b6f1290ab733d3f4bd7fc027ef45c3d1b5814 +PKG_SOURCE_DATE:=2020-06-19 +PKG_SOURCE_VERSION:=1665d9e9212dcd118629a74fbe658841f81036f7 +PKG_MAINTAINER:=David Bauer +PKG_LICENSE:=GPL-2.0-or-later + +include $(INCLUDE_DIR)/package.mk + +define Package/ravpower-mcu + SECTION:=utils + CATEGORY:=Utilities + TITLE:=Utility to control the RAVPower RP-WD009 PMIC + DEPENDS:=@TARGET_ramips_mt76x8 + URL:=https://github.com/blocktrron/ravpower-mcu/ +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CC="$(TARGET_CC)" \ + CFLAGS="$(TARGET_CFLAGS) -Wall" +endef + +define Package/ravpower-mcu/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/out/ravpower-mcu $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,ravpower-mcu)) diff --git a/scripts/json_add_image_info.py b/scripts/json_add_image_info.py index b6628113ac..768bb10254 100755 --- a/scripts/json_add_image_info.py +++ b/scripts/json_add_image_info.py @@ -54,6 +54,7 @@ image_info = { "sha256": image_hash, } ], + "device_packages": getenv("DEVICE_PACKAGES").split(), "supported_devices": getenv("SUPPORTED_DEVICES").split(), "titles": get_titles(), } diff --git a/scripts/json_overview_image_info.py b/scripts/json_overview_image_info.py index a1418e366d..59d69df314 100755 --- a/scripts/json_overview_image_info.py +++ b/scripts/json_overview_image_info.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 -import json +from os import getenv, environ from pathlib import Path -from os import getenv +from subprocess import run from sys import argv +import json if len(argv) != 2: print("JSON info files script requires ouput file as argument") @@ -31,6 +32,21 @@ for json_file in work_dir.glob("*.json"): image_info["profiles"][device_id]["images"][0] ) + +output["default_packages"] = run( + [ + "make", + "--no-print-directory", + "-C", + f"target/linux/{output['target'].split('/')[0]}", + "val.DEFAULT_PACKAGES", + ], + capture_output=True, + check=True, + env=environ.copy().update({"TOPDIR": Path().cwd()}), + text=True, +).stdout.split() + if output: output_path.write_text(json.dumps(output, sort_keys=True, separators=(",", ":"))) else: diff --git a/target/linux/generic/backport-4.19/392-v5.1-sch_cake-Make-the-dual-modes-fairer.patch b/target/linux/generic/backport-4.19/390-v5.1-sch_cake-Make-the-dual-modes-fairer.patch similarity index 100% rename from target/linux/generic/backport-4.19/392-v5.1-sch_cake-Make-the-dual-modes-fairer.patch rename to target/linux/generic/backport-4.19/390-v5.1-sch_cake-Make-the-dual-modes-fairer.patch diff --git a/target/linux/generic/backport-4.19/393-v5.1-sch_cake-Permit-use-of-connmarks-as-tin-classifiers.patch b/target/linux/generic/backport-4.19/391-v5.1-sch_cake-Permit-use-of-connmarks-as-tin-classifiers.patch similarity index 100% rename from target/linux/generic/backport-4.19/393-v5.1-sch_cake-Permit-use-of-connmarks-as-tin-classifiers.patch rename to target/linux/generic/backport-4.19/391-v5.1-sch_cake-Permit-use-of-connmarks-as-tin-classifiers.patch diff --git a/target/linux/generic/backport-4.19/394-v5.1-sch_cake-Interpret-fwmark-parameter-as-a-bitmask.patch b/target/linux/generic/backport-4.19/392-v5.1-sch_cake-Interpret-fwmark-parameter-as-a-bitmask.patch similarity index 100% rename from target/linux/generic/backport-4.19/394-v5.1-sch_cake-Interpret-fwmark-parameter-as-a-bitmask.patch rename to target/linux/generic/backport-4.19/392-v5.1-sch_cake-Interpret-fwmark-parameter-as-a-bitmask.patch diff --git a/target/linux/generic/backport-4.19/395-v5.4-sch_cake-drop-unused-variable-tin_quantum_prio.patch b/target/linux/generic/backport-4.19/393-v5.5-sch_cake-drop-unused-variable-tin_quantum_prio.patch similarity index 100% rename from target/linux/generic/backport-4.19/395-v5.4-sch_cake-drop-unused-variable-tin_quantum_prio.patch rename to target/linux/generic/backport-4.19/393-v5.5-sch_cake-drop-unused-variable-tin_quantum_prio.patch diff --git a/target/linux/generic/backport-4.19/396-v5.4-sch_cake-Add-missing-NLA-policy-entry-TCA_CAKE_SPLIT.patch b/target/linux/generic/backport-4.19/394-v5.4-sch_cake-Add-missing-NLA-policy-entry-TCA_CAKE_SPLIT.patch similarity index 100% rename from target/linux/generic/backport-4.19/396-v5.4-sch_cake-Add-missing-NLA-policy-entry-TCA_CAKE_SPLIT.patch rename to target/linux/generic/backport-4.19/394-v5.4-sch_cake-Add-missing-NLA-policy-entry-TCA_CAKE_SPLIT.patch diff --git a/target/linux/generic/backport-5.4/398-v5.9-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch b/target/linux/generic/backport-4.19/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch similarity index 97% rename from target/linux/generic/backport-5.4/398-v5.9-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch rename to target/linux/generic/backport-4.19/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch index 7b3396c6c3..12962135d0 100644 --- a/target/linux/generic/backport-5.4/398-v5.9-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch +++ b/target/linux/generic/backport-4.19/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch @@ -53,7 +53,7 @@ Signed-off-by: Kevin Darbyshire-Bryant --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c -@@ -585,26 +585,48 @@ static bool cobalt_should_drop(struct co +@@ -584,26 +584,48 @@ static bool cobalt_should_drop(struct co return drop; } @@ -110,7 +110,7 @@ Signed-off-by: Kevin Darbyshire-Bryant #endif } -@@ -625,23 +647,36 @@ static bool cake_ddst(int flow_mode) +@@ -624,23 +646,36 @@ static bool cake_ddst(int flow_mode) static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb, int flow_mode, u16 flow_override, u16 host_override) { @@ -152,7 +152,7 @@ Signed-off-by: Kevin Darbyshire-Bryant /* flow_hash_from_keys() sorts the addresses by value, so we have * to preserve their order in a separate data structure to treat -@@ -680,12 +715,14 @@ static u32 cake_hash(struct cake_tin_dat +@@ -679,12 +714,14 @@ static u32 cake_hash(struct cake_tin_dat /* This *must* be after the above switch, since as a * side-effect it sorts the src and dst addresses. */ diff --git a/target/linux/generic/backport-4.19/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch b/target/linux/generic/backport-4.19/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch new file mode 100644 index 0000000000..a36095c26c --- /dev/null +++ b/target/linux/generic/backport-4.19/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch @@ -0,0 +1,96 @@ +From 9208d2863ac689a563b92f2161d8d1e7127d0add Mon Sep 17 00:00:00 2001 +From: Ilya Ponetayev +Date: Thu, 25 Jun 2020 22:12:07 +0200 +Subject: [PATCH] sch_cake: don't try to reallocate or unshare skb + unconditionally +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cake_handle_diffserv() tries to linearize mac and network header parts of +skb and to make it writable unconditionally. In some cases it leads to full +skb reallocation, which reduces throughput and increases CPU load. Some +measurements of IPv4 forward + NAPT on MIPS router with 580 MHz single-core +CPU was conducted. It appears that on kernel 4.9 skb_try_make_writable() +reallocates skb, if skb was allocated in ethernet driver via so-called +'build skb' method from page cache (it was discovered by strange increase +of kmalloc-2048 slab at first). + +Obtain DSCP value via read-only skb_header_pointer() call, and leave +linearization only for DSCP bleaching or ECN CE setting. And, as an +additional optimisation, skip diffserv parsing entirely if it is not needed +by the current configuration. + +Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits") +Signed-off-by: Ilya Ponetayev +[ fix a few style issues, reflow commit message ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 41 ++++++++++++++++++++++++++++++----------- + 1 file changed, 30 insertions(+), 11 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -1553,30 +1553,49 @@ static unsigned int cake_drop(struct Qdi + + static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) + { +- int wlen = skb_network_offset(skb); ++ const int offset = skb_network_offset(skb); ++ u16 *buf, buf_; + u8 dscp; + + switch (tc_skb_protocol(skb)) { + case htons(ETH_P_IP): +- wlen += sizeof(struct iphdr); +- if (!pskb_may_pull(skb, wlen) || +- skb_try_make_writable(skb, wlen)) ++ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); ++ if (unlikely(!buf)) + return 0; + +- dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2; +- if (wash && dscp) ++ /* ToS is in the second byte of iphdr */ ++ dscp = ipv4_get_dsfield((struct iphdr *)buf) >> 2; ++ ++ if (wash && dscp) { ++ const int wlen = offset + sizeof(struct iphdr); ++ ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ + ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, 0); ++ } ++ + return dscp; + + case htons(ETH_P_IPV6): +- wlen += sizeof(struct ipv6hdr); +- if (!pskb_may_pull(skb, wlen) || +- skb_try_make_writable(skb, wlen)) ++ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); ++ if (unlikely(!buf)) + return 0; + +- dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; +- if (wash && dscp) ++ /* Traffic class is in the first and second bytes of ipv6hdr */ ++ dscp = ipv6_get_dsfield((struct ipv6hdr *)buf) >> 2; ++ ++ if (wash && dscp) { ++ const int wlen = offset + sizeof(struct ipv6hdr); ++ ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ + ipv6_change_dsfield(ipv6_hdr(skb), INET_ECN_MASK, 0); ++ } ++ + return dscp; + + case htons(ETH_P_ARP): diff --git a/target/linux/generic/backport-4.19/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch b/target/linux/generic/backport-4.19/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch new file mode 100644 index 0000000000..b40bb36c74 --- /dev/null +++ b/target/linux/generic/backport-4.19/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch @@ -0,0 +1,62 @@ +From 8c95eca0bb8c4bd2231a0d581f1ad0d50c90488c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Thu, 25 Jun 2020 22:12:08 +0200 +Subject: [PATCH] sch_cake: don't call diffserv parsing code when it is not + needed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As a further optimisation of the diffserv parsing codepath, we can skip it +entirely if CAKE is configured to neither use diffserv-based +classification, nor to zero out the diffserv bits. + +Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -1551,7 +1551,7 @@ static unsigned int cake_drop(struct Qdi + return idx + (tin << 16); + } + +-static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) ++static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash) + { + const int offset = skb_network_offset(skb); + u16 *buf, buf_; +@@ -1612,14 +1612,17 @@ static struct cake_tin_data *cake_select + { + struct cake_sched_data *q = qdisc_priv(sch); + u32 tin, mark; ++ bool wash; + u8 dscp; + + /* Tin selection: Default to diffserv-based selection, allow overriding +- * using firewall marks or skb->priority. ++ * using firewall marks or skb->priority. Call DSCP parsing early if ++ * wash is enabled, otherwise defer to below to skip unneeded parsing. + */ +- dscp = cake_handle_diffserv(skb, +- q->rate_flags & CAKE_FLAG_WASH); + mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft; ++ wash = !!(q->rate_flags & CAKE_FLAG_WASH); ++ if (wash) ++ dscp = cake_handle_diffserv(skb, wash); + + if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) + tin = 0; +@@ -1630,6 +1633,8 @@ static struct cake_tin_data *cake_select + tin = q->tin_order[TC_H_MIN(skb->priority) - 1]; + + else { ++ if (!wash) ++ dscp = cake_handle_diffserv(skb, wash); + tin = q->tin_index[dscp]; + + if (unlikely(tin >= q->tin_cnt)) diff --git a/target/linux/generic/backport-4.19/398-5.8-sch_cake-fix-a-few-style-nits.patch b/target/linux/generic/backport-4.19/398-5.8-sch_cake-fix-a-few-style-nits.patch new file mode 100644 index 0000000000..a1d72113b7 --- /dev/null +++ b/target/linux/generic/backport-4.19/398-5.8-sch_cake-fix-a-few-style-nits.patch @@ -0,0 +1,40 @@ +From 3f608f0c41360b11b04c763f348b712f651c8bac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Thu, 25 Jun 2020 22:12:09 +0200 +Subject: [PATCH] sch_cake: fix a few style nits +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +I spotted a few nits when comparing the in-tree version of sch_cake with +the out-of-tree one: A redundant error variable declaration shadowing an +outer declaration, and an indentation alignment issue. Fix both of these. + +Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -2713,7 +2713,7 @@ static int cake_init(struct Qdisc *sch, + qdisc_watchdog_init(&q->watchdog, sch); + + if (opt) { +- int err = cake_change(sch, opt, extack); ++ err = cake_change(sch, opt, extack); + + if (err) + return err; +@@ -3030,7 +3030,7 @@ static int cake_dump_class_stats(struct + PUT_STAT_S32(BLUE_TIMER_US, + ktime_to_us( + ktime_sub(now, +- flow->cvars.blue_timer))); ++ flow->cvars.blue_timer))); + } + if (flow->cvars.dropping) { + PUT_STAT_S32(DROP_NEXT_US, diff --git a/target/linux/generic/backport-4.19/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch b/target/linux/generic/backport-4.19/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch new file mode 100644 index 0000000000..e171b4cec7 --- /dev/null +++ b/target/linux/generic/backport-4.19/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch @@ -0,0 +1,57 @@ +From b8392808eb3fc28e523e28cb258c81ca246deb9b Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Thu, 25 Jun 2020 22:18:00 +0200 +Subject: [PATCH] sch_cake: add RFC 8622 LE PHB support to CAKE diffserv + handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change tin mapping on diffserv3, 4 & 8 for LE PHB support, in essence +making LE a member of the Bulk tin. + +Bulk has the least priority and minimum of 1/16th total bandwidth in the +face of higher priority traffic. + +NB: Diffserv 3 & 4 swap tin 0 & 1 priorities from the default order as +found in diffserv8, in case anyone is wondering why it looks a bit odd. + +Signed-off-by: Kevin Darbyshire-Bryant +[ reword commit message slightly ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +--- + net/sched/sch_cake.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -312,8 +312,8 @@ static const u8 precedence[] = { + }; + + static const u8 diffserv8[] = { +- 2, 5, 1, 2, 4, 2, 2, 2, +- 0, 2, 1, 2, 1, 2, 1, 2, ++ 2, 0, 1, 2, 4, 2, 2, 2, ++ 1, 2, 1, 2, 1, 2, 1, 2, + 5, 2, 4, 2, 4, 2, 4, 2, + 3, 2, 3, 2, 3, 2, 3, 2, + 6, 2, 3, 2, 3, 2, 3, 2, +@@ -323,7 +323,7 @@ static const u8 diffserv8[] = { + }; + + static const u8 diffserv4[] = { +- 0, 2, 0, 0, 2, 0, 0, 0, ++ 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 2, 0, 2, 0, 2, 0, + 2, 0, 2, 0, 2, 0, 2, 0, +@@ -334,7 +334,7 @@ static const u8 diffserv4[] = { + }; + + static const u8 diffserv3[] = { +- 0, 0, 0, 0, 2, 0, 0, 0, ++ 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/target/linux/generic/backport-5.4/393-v5.5-sch_cake-drop-unused-variable-tin_quantum_prio.patch b/target/linux/generic/backport-5.4/393-v5.5-sch_cake-drop-unused-variable-tin_quantum_prio.patch new file mode 100644 index 0000000000..2be0d36392 --- /dev/null +++ b/target/linux/generic/backport-5.4/393-v5.5-sch_cake-drop-unused-variable-tin_quantum_prio.patch @@ -0,0 +1,158 @@ +From d7e1738f0a0b0573ac93cf570ba3df9dee61b68e Mon Sep 17 00:00:00 2001 +From: Kevin 'ldir' Darbyshire-Bryant +Date: Wed, 18 Dec 2019 14:05:13 +0000 +Subject: [PATCH 2/2] sch_cake: drop unused variable tin_quantum_prio +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Turns out tin_quantum_prio isn't used anymore and is a leftover from a +previous implementation of diffserv tins. Since the variable isn't used +in any calculations it can be eliminated. + +Drop variable and places where it was set. Rename remaining variable +and consolidate naming of intermediate variables that set it. + +Signed-off-by: Kevin Darbyshire-Bryant +Acked-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +--- + net/sched/sch_cake.c | 59 ++++++++++++++------------------------------ + 1 file changed, 18 insertions(+), 41 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -173,8 +173,7 @@ struct cake_tin_data { + u64 tin_rate_bps; + u16 tin_rate_shft; + +- u16 tin_quantum_prio; +- u16 tin_quantum_band; ++ u16 tin_quantum; + s32 tin_deficit; + u32 tin_backlog; + u32 tin_dropped; +@@ -1919,7 +1918,7 @@ begin: + while (b->tin_deficit < 0 || + !(b->sparse_flow_count + b->bulk_flow_count)) { + if (b->tin_deficit <= 0) +- b->tin_deficit += b->tin_quantum_band; ++ b->tin_deficit += b->tin_quantum; + if (b->sparse_flow_count + b->bulk_flow_count) + empty = false; + +@@ -2241,8 +2240,7 @@ static int cake_config_besteffort(struct + + cake_set_rate(b, rate, mtu, + us_to_ns(q->target), us_to_ns(q->interval)); +- b->tin_quantum_band = 65535; +- b->tin_quantum_prio = 65535; ++ b->tin_quantum = 65535; + + return 0; + } +@@ -2253,8 +2251,7 @@ static int cake_config_precedence(struct + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; +- u32 quantum1 = 256; +- u32 quantum2 = 256; ++ u32 quantum = 256; + u32 i; + + q->tin_cnt = 8; +@@ -2267,18 +2264,14 @@ static int cake_config_precedence(struct + cake_set_rate(b, rate, mtu, us_to_ns(q->target), + us_to_ns(q->interval)); + +- b->tin_quantum_prio = max_t(u16, 1U, quantum1); +- b->tin_quantum_band = max_t(u16, 1U, quantum2); ++ b->tin_quantum = max_t(u16, 1U, quantum); + + /* calculate next class's parameters */ + rate *= 7; + rate >>= 3; + +- quantum1 *= 3; +- quantum1 >>= 1; +- +- quantum2 *= 7; +- quantum2 >>= 3; ++ quantum *= 7; ++ quantum >>= 3; + } + + return 0; +@@ -2347,8 +2340,7 @@ static int cake_config_diffserv8(struct + struct cake_sched_data *q = qdisc_priv(sch); + u32 mtu = psched_mtu(qdisc_dev(sch)); + u64 rate = q->rate_bps; +- u32 quantum1 = 256; +- u32 quantum2 = 256; ++ u32 quantum = 256; + u32 i; + + q->tin_cnt = 8; +@@ -2364,18 +2356,14 @@ static int cake_config_diffserv8(struct + cake_set_rate(b, rate, mtu, us_to_ns(q->target), + us_to_ns(q->interval)); + +- b->tin_quantum_prio = max_t(u16, 1U, quantum1); +- b->tin_quantum_band = max_t(u16, 1U, quantum2); ++ b->tin_quantum = max_t(u16, 1U, quantum); + + /* calculate next class's parameters */ + rate *= 7; + rate >>= 3; + +- quantum1 *= 3; +- quantum1 >>= 1; +- +- quantum2 *= 7; +- quantum2 >>= 3; ++ quantum *= 7; ++ quantum >>= 3; + } + + return 0; +@@ -2414,17 +2402,11 @@ static int cake_config_diffserv4(struct + cake_set_rate(&q->tins[3], rate >> 2, mtu, + us_to_ns(q->target), us_to_ns(q->interval)); + +- /* priority weights */ +- q->tins[0].tin_quantum_prio = quantum; +- q->tins[1].tin_quantum_prio = quantum >> 4; +- q->tins[2].tin_quantum_prio = quantum << 2; +- q->tins[3].tin_quantum_prio = quantum << 4; +- + /* bandwidth-sharing weights */ +- q->tins[0].tin_quantum_band = quantum; +- q->tins[1].tin_quantum_band = quantum >> 4; +- q->tins[2].tin_quantum_band = quantum >> 1; +- q->tins[3].tin_quantum_band = quantum >> 2; ++ q->tins[0].tin_quantum = quantum; ++ q->tins[1].tin_quantum = quantum >> 4; ++ q->tins[2].tin_quantum = quantum >> 1; ++ q->tins[3].tin_quantum = quantum >> 2; + + return 0; + } +@@ -2455,15 +2437,10 @@ static int cake_config_diffserv3(struct + cake_set_rate(&q->tins[2], rate >> 2, mtu, + us_to_ns(q->target), us_to_ns(q->interval)); + +- /* priority weights */ +- q->tins[0].tin_quantum_prio = quantum; +- q->tins[1].tin_quantum_prio = quantum >> 4; +- q->tins[2].tin_quantum_prio = quantum << 4; +- + /* bandwidth-sharing weights */ +- q->tins[0].tin_quantum_band = quantum; +- q->tins[1].tin_quantum_band = quantum >> 4; +- q->tins[2].tin_quantum_band = quantum >> 2; ++ q->tins[0].tin_quantum = quantum; ++ q->tins[1].tin_quantum = quantum >> 4; ++ q->tins[2].tin_quantum = quantum >> 2; + + return 0; + } diff --git a/target/linux/generic/backport-5.4/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch b/target/linux/generic/backport-5.4/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch new file mode 100644 index 0000000000..12962135d0 --- /dev/null +++ b/target/linux/generic/backport-5.4/395-v5.8-net-sch_cake-Take-advantage-of-skb-hash-where-appropriate.patch @@ -0,0 +1,170 @@ +From b0c19ed6088ab41dd2a727b60594b7297c15d6ce Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Fri, 29 May 2020 14:43:44 +0200 +Subject: [PATCH] sch_cake: Take advantage of skb->hash where appropriate +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +While the other fq-based qdiscs take advantage of skb->hash and doesn't +recompute it if it is already set, sch_cake does not. + +This was a deliberate choice because sch_cake hashes various parts of the +packet header to support its advanced flow isolation modes. However, +foregoing the use of skb->hash entirely loses a few important benefits: + +- When skb->hash is set by hardware, a few CPU cycles can be saved by not + hashing again in software. + +- Tunnel encapsulations will generally preserve the value of skb->hash from + before the encapsulation, which allows flow-based qdiscs to distinguish + between flows even though the outer packet header no longer has flow + information. + +It turns out that we can preserve these desirable properties in many cases, +while still supporting the advanced flow isolation properties of sch_cake. +This patch does so by reusing the skb->hash value as the flow_hash part of +the hashing procedure in cake_hash() only in the following conditions: + +- If the skb->hash is marked as covering the flow headers (skb->l4_hash is + set) + +AND + +- NAT header rewriting is either disabled, or did not change any values + used for hashing. The latter is important to match local-origin packets + such as those of a tunnel endpoint. + +The immediate motivation for fixing this was the recent patch to WireGuard +to preserve the skb->hash on encapsulation. As such, this is also what I +tested against; with this patch, added latency under load for competing +flows drops from ~8 ms to sub-1ms on an RRUL test over a WireGuard tunnel +going through a virtual link shaped to 1Gbps using sch_cake. This matches +the results we saw with a similar setup using sch_fq_codel when testing the +WireGuard patch. + +Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 65 ++++++++++++++++++++++++++++++++++---------- + 1 file changed, 51 insertions(+), 14 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -584,26 +584,48 @@ static bool cobalt_should_drop(struct co + return drop; + } + +-static void cake_update_flowkeys(struct flow_keys *keys, ++static bool cake_update_flowkeys(struct flow_keys *keys, + const struct sk_buff *skb) + { + #if IS_ENABLED(CONFIG_NF_CONNTRACK) + struct nf_conntrack_tuple tuple = {}; +- bool rev = !skb->_nfct; ++ bool rev = !skb->_nfct, upd = false; ++ __be32 ip; + + if (tc_skb_protocol(skb) != htons(ETH_P_IP)) +- return; ++ return false; + + if (!nf_ct_get_tuple_skb(&tuple, skb)) +- return; ++ return false; + +- keys->addrs.v4addrs.src = rev ? tuple.dst.u3.ip : tuple.src.u3.ip; +- keys->addrs.v4addrs.dst = rev ? tuple.src.u3.ip : tuple.dst.u3.ip; ++ ip = rev ? tuple.dst.u3.ip : tuple.src.u3.ip; ++ if (ip != keys->addrs.v4addrs.src) { ++ keys->addrs.v4addrs.src = ip; ++ upd = true; ++ } ++ ip = rev ? tuple.src.u3.ip : tuple.dst.u3.ip; ++ if (ip != keys->addrs.v4addrs.dst) { ++ keys->addrs.v4addrs.dst = ip; ++ upd = true; ++ } + + if (keys->ports.ports) { +- keys->ports.src = rev ? tuple.dst.u.all : tuple.src.u.all; +- keys->ports.dst = rev ? tuple.src.u.all : tuple.dst.u.all; ++ __be16 port; ++ ++ port = rev ? tuple.dst.u.all : tuple.src.u.all; ++ if (port != keys->ports.src) { ++ keys->ports.src = port; ++ upd = true; ++ } ++ port = rev ? tuple.src.u.all : tuple.dst.u.all; ++ if (port != keys->ports.dst) { ++ port = keys->ports.dst; ++ upd = true; ++ } + } ++ return upd; ++#else ++ return false; + #endif + } + +@@ -624,23 +646,36 @@ static bool cake_ddst(int flow_mode) + static u32 cake_hash(struct cake_tin_data *q, const struct sk_buff *skb, + int flow_mode, u16 flow_override, u16 host_override) + { ++ bool hash_flows = (!flow_override && !!(flow_mode & CAKE_FLOW_FLOWS)); ++ bool hash_hosts = (!host_override && !!(flow_mode & CAKE_FLOW_HOSTS)); ++ bool nat_enabled = !!(flow_mode & CAKE_FLOW_NAT_FLAG); + u32 flow_hash = 0, srchost_hash = 0, dsthost_hash = 0; + u16 reduced_hash, srchost_idx, dsthost_idx; + struct flow_keys keys, host_keys; ++ bool use_skbhash = skb->l4_hash; + + if (unlikely(flow_mode == CAKE_FLOW_NONE)) + return 0; + +- /* If both overrides are set we can skip packet dissection entirely */ +- if ((flow_override || !(flow_mode & CAKE_FLOW_FLOWS)) && +- (host_override || !(flow_mode & CAKE_FLOW_HOSTS))) ++ /* If both overrides are set, or we can use the SKB hash and nat mode is ++ * disabled, we can skip packet dissection entirely. If nat mode is ++ * enabled there's another check below after doing the conntrack lookup. ++ */ ++ if ((!hash_flows || (use_skbhash && !nat_enabled)) && !hash_hosts) + goto skip_hash; + + skb_flow_dissect_flow_keys(skb, &keys, + FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL); + +- if (flow_mode & CAKE_FLOW_NAT_FLAG) +- cake_update_flowkeys(&keys, skb); ++ /* Don't use the SKB hash if we change the lookup keys from conntrack */ ++ if (nat_enabled && cake_update_flowkeys(&keys, skb)) ++ use_skbhash = false; ++ ++ /* If we can still use the SKB hash and don't need the host hash, we can ++ * skip the rest of the hashing procedure ++ */ ++ if (use_skbhash && !hash_hosts) ++ goto skip_hash; + + /* flow_hash_from_keys() sorts the addresses by value, so we have + * to preserve their order in a separate data structure to treat +@@ -679,12 +714,14 @@ static u32 cake_hash(struct cake_tin_dat + /* This *must* be after the above switch, since as a + * side-effect it sorts the src and dst addresses. + */ +- if (flow_mode & CAKE_FLOW_FLOWS) ++ if (hash_flows && !use_skbhash) + flow_hash = flow_hash_from_keys(&keys); + + skip_hash: + if (flow_override) + flow_hash = flow_override - 1; ++ else if (use_skbhash) ++ flow_hash = skb->hash; + if (host_override) { + dsthost_hash = host_override - 1; + srchost_hash = host_override - 1; diff --git a/target/linux/generic/backport-5.4/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch b/target/linux/generic/backport-5.4/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch new file mode 100644 index 0000000000..a36095c26c --- /dev/null +++ b/target/linux/generic/backport-5.4/396-5.8-sch_cake-don-t-try-to-reallocate-or-unshare-skb-unco.patch @@ -0,0 +1,96 @@ +From 9208d2863ac689a563b92f2161d8d1e7127d0add Mon Sep 17 00:00:00 2001 +From: Ilya Ponetayev +Date: Thu, 25 Jun 2020 22:12:07 +0200 +Subject: [PATCH] sch_cake: don't try to reallocate or unshare skb + unconditionally +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +cake_handle_diffserv() tries to linearize mac and network header parts of +skb and to make it writable unconditionally. In some cases it leads to full +skb reallocation, which reduces throughput and increases CPU load. Some +measurements of IPv4 forward + NAPT on MIPS router with 580 MHz single-core +CPU was conducted. It appears that on kernel 4.9 skb_try_make_writable() +reallocates skb, if skb was allocated in ethernet driver via so-called +'build skb' method from page cache (it was discovered by strange increase +of kmalloc-2048 slab at first). + +Obtain DSCP value via read-only skb_header_pointer() call, and leave +linearization only for DSCP bleaching or ECN CE setting. And, as an +additional optimisation, skip diffserv parsing entirely if it is not needed +by the current configuration. + +Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits") +Signed-off-by: Ilya Ponetayev +[ fix a few style issues, reflow commit message ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 41 ++++++++++++++++++++++++++++++----------- + 1 file changed, 30 insertions(+), 11 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -1553,30 +1553,49 @@ static unsigned int cake_drop(struct Qdi + + static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) + { +- int wlen = skb_network_offset(skb); ++ const int offset = skb_network_offset(skb); ++ u16 *buf, buf_; + u8 dscp; + + switch (tc_skb_protocol(skb)) { + case htons(ETH_P_IP): +- wlen += sizeof(struct iphdr); +- if (!pskb_may_pull(skb, wlen) || +- skb_try_make_writable(skb, wlen)) ++ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); ++ if (unlikely(!buf)) + return 0; + +- dscp = ipv4_get_dsfield(ip_hdr(skb)) >> 2; +- if (wash && dscp) ++ /* ToS is in the second byte of iphdr */ ++ dscp = ipv4_get_dsfield((struct iphdr *)buf) >> 2; ++ ++ if (wash && dscp) { ++ const int wlen = offset + sizeof(struct iphdr); ++ ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ + ipv4_change_dsfield(ip_hdr(skb), INET_ECN_MASK, 0); ++ } ++ + return dscp; + + case htons(ETH_P_IPV6): +- wlen += sizeof(struct ipv6hdr); +- if (!pskb_may_pull(skb, wlen) || +- skb_try_make_writable(skb, wlen)) ++ buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); ++ if (unlikely(!buf)) + return 0; + +- dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> 2; +- if (wash && dscp) ++ /* Traffic class is in the first and second bytes of ipv6hdr */ ++ dscp = ipv6_get_dsfield((struct ipv6hdr *)buf) >> 2; ++ ++ if (wash && dscp) { ++ const int wlen = offset + sizeof(struct ipv6hdr); ++ ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ + ipv6_change_dsfield(ipv6_hdr(skb), INET_ECN_MASK, 0); ++ } ++ + return dscp; + + case htons(ETH_P_ARP): diff --git a/target/linux/generic/backport-5.4/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch b/target/linux/generic/backport-5.4/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch new file mode 100644 index 0000000000..2d9cd29780 --- /dev/null +++ b/target/linux/generic/backport-5.4/397-5.8-sch_cake-don-t-call-diffserv-parsing-code-when-it-is.patch @@ -0,0 +1,62 @@ +From 8c95eca0bb8c4bd2231a0d581f1ad0d50c90488c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Thu, 25 Jun 2020 22:12:08 +0200 +Subject: [PATCH] sch_cake: don't call diffserv parsing code when it is not + needed +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As a further optimisation of the diffserv parsing codepath, we can skip it +entirely if CAKE is configured to neither use diffserv-based +classification, nor to zero out the diffserv bits. + +Fixes: c87b4ecdbe8d ("sch_cake: Make sure we can write the IP header before changing DSCP bits") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -1551,7 +1551,7 @@ static unsigned int cake_drop(struct Qdi + return idx + (tin << 16); + } + +-static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) ++static u8 cake_handle_diffserv(struct sk_buff *skb, bool wash) + { + const int offset = skb_network_offset(skb); + u16 *buf, buf_; +@@ -1612,14 +1612,17 @@ static struct cake_tin_data *cake_select + { + struct cake_sched_data *q = qdisc_priv(sch); + u32 tin, mark; ++ bool wash; + u8 dscp; + + /* Tin selection: Default to diffserv-based selection, allow overriding +- * using firewall marks or skb->priority. ++ * using firewall marks or skb->priority. Call DSCP parsing early if ++ * wash is enabled, otherwise defer to below to skip unneeded parsing. + */ +- dscp = cake_handle_diffserv(skb, +- q->rate_flags & CAKE_FLAG_WASH); + mark = (skb->mark & q->fwmark_mask) >> q->fwmark_shft; ++ wash = !!(q->rate_flags & CAKE_FLAG_WASH); ++ if (wash) ++ dscp = cake_handle_diffserv(skb, wash); + + if (q->tin_mode == CAKE_DIFFSERV_BESTEFFORT) + tin = 0; +@@ -1633,6 +1636,8 @@ static struct cake_tin_data *cake_select + tin = q->tin_order[TC_H_MIN(skb->priority) - 1]; + + else { ++ if (!wash) ++ dscp = cake_handle_diffserv(skb, wash); + tin = q->tin_index[dscp]; + + if (unlikely(tin >= q->tin_cnt)) diff --git a/target/linux/generic/backport-5.4/398-5.8-sch_cake-fix-a-few-style-nits.patch b/target/linux/generic/backport-5.4/398-5.8-sch_cake-fix-a-few-style-nits.patch new file mode 100644 index 0000000000..1160489efb --- /dev/null +++ b/target/linux/generic/backport-5.4/398-5.8-sch_cake-fix-a-few-style-nits.patch @@ -0,0 +1,40 @@ +From 3f608f0c41360b11b04c763f348b712f651c8bac Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= +Date: Thu, 25 Jun 2020 22:12:09 +0200 +Subject: [PATCH] sch_cake: fix a few style nits +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +I spotted a few nits when comparing the in-tree version of sch_cake with +the out-of-tree one: A redundant error variable declaration shadowing an +outer declaration, and an indentation alignment issue. Fix both of these. + +Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -2717,7 +2717,7 @@ static int cake_init(struct Qdisc *sch, + qdisc_watchdog_init(&q->watchdog, sch); + + if (opt) { +- int err = cake_change(sch, opt, extack); ++ err = cake_change(sch, opt, extack); + + if (err) + return err; +@@ -3034,7 +3034,7 @@ static int cake_dump_class_stats(struct + PUT_STAT_S32(BLUE_TIMER_US, + ktime_to_us( + ktime_sub(now, +- flow->cvars.blue_timer))); ++ flow->cvars.blue_timer))); + } + if (flow->cvars.dropping) { + PUT_STAT_S32(DROP_NEXT_US, diff --git a/target/linux/generic/backport-5.4/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch b/target/linux/generic/backport-5.4/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch new file mode 100644 index 0000000000..e171b4cec7 --- /dev/null +++ b/target/linux/generic/backport-5.4/399-5.9-sch_cake-add-RFC-8622-LE-PHB-support-to-CAKE-diffser.patch @@ -0,0 +1,57 @@ +From b8392808eb3fc28e523e28cb258c81ca246deb9b Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Thu, 25 Jun 2020 22:18:00 +0200 +Subject: [PATCH] sch_cake: add RFC 8622 LE PHB support to CAKE diffserv + handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Change tin mapping on diffserv3, 4 & 8 for LE PHB support, in essence +making LE a member of the Bulk tin. + +Bulk has the least priority and minimum of 1/16th total bandwidth in the +face of higher priority traffic. + +NB: Diffserv 3 & 4 swap tin 0 & 1 priorities from the default order as +found in diffserv8, in case anyone is wondering why it looks a bit odd. + +Signed-off-by: Kevin Darbyshire-Bryant +[ reword commit message slightly ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: David S. Miller +--- + net/sched/sch_cake.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -312,8 +312,8 @@ static const u8 precedence[] = { + }; + + static const u8 diffserv8[] = { +- 2, 5, 1, 2, 4, 2, 2, 2, +- 0, 2, 1, 2, 1, 2, 1, 2, ++ 2, 0, 1, 2, 4, 2, 2, 2, ++ 1, 2, 1, 2, 1, 2, 1, 2, + 5, 2, 4, 2, 4, 2, 4, 2, + 3, 2, 3, 2, 3, 2, 3, 2, + 6, 2, 3, 2, 3, 2, 3, 2, +@@ -323,7 +323,7 @@ static const u8 diffserv8[] = { + }; + + static const u8 diffserv4[] = { +- 0, 2, 0, 0, 2, 0, 0, 0, ++ 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 2, 0, 2, 0, 2, 0, + 2, 0, 2, 0, 2, 0, 2, 0, +@@ -334,7 +334,7 @@ static const u8 diffserv4[] = { + }; + + static const u8 diffserv3[] = { +- 0, 0, 0, 0, 2, 0, 0, 0, ++ 0, 1, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/target/linux/generic/hack-4.19/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch b/target/linux/generic/hack-4.19/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch new file mode 100644 index 0000000000..e651743c1d --- /dev/null +++ b/target/linux/generic/hack-4.19/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch @@ -0,0 +1,114 @@ +From a00590d570212c3c633bd463cef8ec7377cc7993 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Tue, 30 Jun 2020 12:07:44 +0100 +Subject: [PATCH] sch_cake: fix IP protocol handling in the presence of VLAN + tags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilya Ponetayev + +CAKE was using the return value of tc_skb_protocol() and expecting it to be +the IP protocol type. This can fail in the presence of QinQ VLAN tags, +making CAKE unable to handle ECN marking and diffserv parsing in this case. +Fix this by implementing our own version of tc_skb_protocol(), which will +use skb->protocol directly, but also parse and skip over any VLAN tags and +return the inner protocol number instead. + +Also fix CE marking by implementing a version of INET_ECN_set_ce() that +uses the same parsing routine. + +Fixes: ea82511518f4 ("sch_cake: Add NAT awareness to packet classifier") +Fixes: b2100cc56fca ("sch_cake: Use tc_skb_protocol() helper for getting packet protocol") +Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") +Signed-off-by: Ilya Ponetayev +[ squash original two patches, rewrite commit message ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 52 +++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 49 insertions(+), 3 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -497,6 +497,52 @@ static bool cobalt_queue_empty(struct co + return down; + } + ++static __be16 cake_skb_proto(const struct sk_buff *skb) ++{ ++ unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr); ++ __be16 proto = skb->protocol; ++ struct vlan_hdr vhdr, *vh; ++ ++ while (proto == htons(ETH_P_8021Q) || proto == htons(ETH_P_8021AD)) { ++ vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr); ++ if (!vh) ++ break; ++ ++ proto = vh->h_vlan_encapsulated_proto; ++ offset += sizeof(vhdr); ++ } ++ ++ return proto; ++} ++ ++static int cake_set_ce(struct sk_buff *skb) ++{ ++ int wlen = skb_network_offset(skb); ++ ++ switch (cake_skb_proto(skb)) { ++ case htons(ETH_P_IP): ++ wlen += sizeof(struct iphdr); ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ ++ return IP_ECN_set_ce(ip_hdr(skb)); ++ ++ case htons(ETH_P_IPV6): ++ wlen += sizeof(struct ipv6hdr); ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ ++ return IP6_ECN_set_ce(skb, ipv6_hdr(skb)); ++ ++ default: ++ return 0; ++ } ++ ++ return 0; ++} ++ + /* Call this with a freshly dequeued packet for possible congestion marking. + * Returns true as an instruction to drop the packet, false for delivery. + */ +@@ -549,7 +595,7 @@ static bool cobalt_should_drop(struct co + + if (next_due && vars->dropping) { + /* Use ECN mark if possible, otherwise drop */ +- drop = !(vars->ecn_marked = INET_ECN_set_ce(skb)); ++ drop = !(vars->ecn_marked = cake_set_ce(skb)); + + vars->count++; + if (!vars->count) +@@ -592,7 +638,7 @@ static bool cake_update_flowkeys(struct + bool rev = !skb->_nfct, upd = false; + __be32 ip; + +- if (tc_skb_protocol(skb) != htons(ETH_P_IP)) ++ if (cake_skb_proto(skb) != htons(ETH_P_IP)) + return false; + + if (!nf_ct_get_tuple_skb(&tuple, skb)) +@@ -1557,7 +1603,7 @@ static u8 cake_handle_diffserv(struct sk + u16 *buf, buf_; + u8 dscp; + +- switch (tc_skb_protocol(skb)) { ++ switch (cake_skb_proto(skb)) { + case htons(ETH_P_IP): + buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); + if (unlikely(!buf)) diff --git a/target/linux/generic/hack-5.4/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch b/target/linux/generic/hack-5.4/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch new file mode 100644 index 0000000000..e651743c1d --- /dev/null +++ b/target/linux/generic/hack-5.4/641-sch_cake-fix-IP-protocol-handling-in-the-presence-of.patch @@ -0,0 +1,114 @@ +From a00590d570212c3c633bd463cef8ec7377cc7993 Mon Sep 17 00:00:00 2001 +From: Kevin Darbyshire-Bryant +Date: Tue, 30 Jun 2020 12:07:44 +0100 +Subject: [PATCH] sch_cake: fix IP protocol handling in the presence of VLAN + tags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilya Ponetayev + +CAKE was using the return value of tc_skb_protocol() and expecting it to be +the IP protocol type. This can fail in the presence of QinQ VLAN tags, +making CAKE unable to handle ECN marking and diffserv parsing in this case. +Fix this by implementing our own version of tc_skb_protocol(), which will +use skb->protocol directly, but also parse and skip over any VLAN tags and +return the inner protocol number instead. + +Also fix CE marking by implementing a version of INET_ECN_set_ce() that +uses the same parsing routine. + +Fixes: ea82511518f4 ("sch_cake: Add NAT awareness to packet classifier") +Fixes: b2100cc56fca ("sch_cake: Use tc_skb_protocol() helper for getting packet protocol") +Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") +Signed-off-by: Ilya Ponetayev +[ squash original two patches, rewrite commit message ] +Signed-off-by: Toke Høiland-Jørgensen +Signed-off-by: Kevin Darbyshire-Bryant +--- + net/sched/sch_cake.c | 52 +++++++++++++++++++++++++++++++++++++++++--- + 1 file changed, 49 insertions(+), 3 deletions(-) + +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -497,6 +497,52 @@ static bool cobalt_queue_empty(struct co + return down; + } + ++static __be16 cake_skb_proto(const struct sk_buff *skb) ++{ ++ unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr); ++ __be16 proto = skb->protocol; ++ struct vlan_hdr vhdr, *vh; ++ ++ while (proto == htons(ETH_P_8021Q) || proto == htons(ETH_P_8021AD)) { ++ vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr); ++ if (!vh) ++ break; ++ ++ proto = vh->h_vlan_encapsulated_proto; ++ offset += sizeof(vhdr); ++ } ++ ++ return proto; ++} ++ ++static int cake_set_ce(struct sk_buff *skb) ++{ ++ int wlen = skb_network_offset(skb); ++ ++ switch (cake_skb_proto(skb)) { ++ case htons(ETH_P_IP): ++ wlen += sizeof(struct iphdr); ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ ++ return IP_ECN_set_ce(ip_hdr(skb)); ++ ++ case htons(ETH_P_IPV6): ++ wlen += sizeof(struct ipv6hdr); ++ if (!pskb_may_pull(skb, wlen) || ++ skb_try_make_writable(skb, wlen)) ++ return 0; ++ ++ return IP6_ECN_set_ce(skb, ipv6_hdr(skb)); ++ ++ default: ++ return 0; ++ } ++ ++ return 0; ++} ++ + /* Call this with a freshly dequeued packet for possible congestion marking. + * Returns true as an instruction to drop the packet, false for delivery. + */ +@@ -549,7 +595,7 @@ static bool cobalt_should_drop(struct co + + if (next_due && vars->dropping) { + /* Use ECN mark if possible, otherwise drop */ +- drop = !(vars->ecn_marked = INET_ECN_set_ce(skb)); ++ drop = !(vars->ecn_marked = cake_set_ce(skb)); + + vars->count++; + if (!vars->count) +@@ -592,7 +638,7 @@ static bool cake_update_flowkeys(struct + bool rev = !skb->_nfct, upd = false; + __be32 ip; + +- if (tc_skb_protocol(skb) != htons(ETH_P_IP)) ++ if (cake_skb_proto(skb) != htons(ETH_P_IP)) + return false; + + if (!nf_ct_get_tuple_skb(&tuple, skb)) +@@ -1557,7 +1603,7 @@ static u8 cake_handle_diffserv(struct sk + u16 *buf, buf_; + u8 dscp; + +- switch (tc_skb_protocol(skb)) { ++ switch (cake_skb_proto(skb)) { + case htons(ETH_P_IP): + buf = skb_header_pointer(skb, offset, sizeof(buf_), &buf_); + if (unlikely(!buf)) diff --git a/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts b/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts new file mode 100644 index 0000000000..5f556af1d3 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_ravpower_rp-wd009.dts @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7628an.dtsi" + +#include +#include + +/ { + compatible = "ravpower,rp-wd009", "mediatek,mt7628an-soc"; + model = "RAVPower RP-WD009"; + + aliases { + led-boot = &led_globe; + led-failsafe = &led_globe; + led-running = &led_globe; + led-upgrade = &led_globe; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + leds { + compatible = "gpio-leds"; + + led_globe: globe { + label = "rp-wd009:white:globe"; + gpios = <&gpio 43 GPIO_ACTIVE_LOW>; + }; + + wlan2 { + label = "rp-wd009:white:wlan2"; + gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + + wlan5 { + label = "rp-wd009:white:wlan5"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + sd_white { + label = "rp-wd009:white:sd"; + gpios = <&gpio 41 GPIO_ACTIVE_LOW>; + }; + + sd_red { + label = "rp-wd009:red:sd"; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 46 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + /* Power interrupt on Pin 39 */ + + rfkill { + label = "rfkill"; + gpios = <&gpio 21 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + backup { + label = "backup"; + gpios = <&gpio 40 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&gpio { + mt7610-power { + gpio-hog; + gpios = <20 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "mt7610-power"; + }; +}; + +&state_default { + gpio { + groups = "uart1", "wled_an", "p0led_an", "p2led_an", "p3led_an", + "p4led_an", "uart2", "pwm0", "i2s"; + function = "gpio"; + }; +}; + +&ehci { + status = "okay"; +}; + +&ohci { + status = "okay"; +}; + +&sdhci { + status = "okay"; +}; + +&i2c { + status = "okay"; + + /* Custom PMIC at 0x0a */ +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <40000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "config"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "loader"; + reg = <0x50000 0x180000>; + }; + + partition@1d0000 { + label = "params"; + reg = <0x1d0000 0x10000>; + read-only; + }; + + partition@1e0000 { + label = "user_backup"; + reg = <0x1e0000 0x10000>; + read-only; + }; + + partition@1f0000 { + label = "user"; + reg = <0x1f0000 0x10000>; + read-only; + }; + + partition@200000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x200000 0xdf0000>; + }; + + partition@ff0000 { + label = "mode"; + reg = <0xff0000 0x10000>; + read-only; + }; + }; + }; +}; + +&wmac { + status = "okay"; +}; + +ðernet { + mtd-mac-address = <&factory 0x4>; +}; diff --git a/target/linux/ramips/dts/mt7628an_tplink_re220-v2.dts b/target/linux/ramips/dts/mt7628an_tplink_re220-v2.dts new file mode 100644 index 0000000000..6e95f87349 --- /dev/null +++ b/target/linux/ramips/dts/mt7628an_tplink_re220-v2.dts @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7628an_tplink_re200.dtsi" + +/ { + compatible = "tplink,re220-v2", "mediatek,mt7628an-soc"; + model = "TP-Link RE220 v2"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + wps { + label = "re220-v2:green:wps"; + gpios = <&gpio 5 GPIO_ACTIVE_LOW>; + }; + + wifi { + label = "re220-v2:green:wifi"; + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "re220-v2:green:lan"; + gpios = <&gpio 39 GPIO_ACTIVE_LOW>; + }; + + led_power: power { + label = "re220-v2:green:power"; + gpios = <&gpio 44 GPIO_ACTIVE_LOW>; + }; + + wifi2g_green { + label = "re220-v2:green:wifi2g"; + gpios = <&gpio 41 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + wifi5g_green { + label = "re220-v2:green:wifi5g"; + gpios = <&gpio 42 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + wifi2g_red { + label = "re220-v2:red:wifi2g"; + gpios = <&gpio 43 GPIO_ACTIVE_LOW>; + }; + + wifi5g_red { + label = "re220-v2:red:wifi5g"; + gpios = <&gpio 40 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&state_default { + gpio { + groups = "p4led_an", "p3led_an", "p2led_an", "p1led_an", + "p0led_an", "wled_an", "i2c", "wdt", "refclk"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index b00e6d8726..93ce59e262 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -111,6 +111,12 @@ define Build/poray-header mv $@.new $@ endef +define Build/ravpower-wd009-factory + mkimage -A mips -T standalone -C none -a 0x80010000 -e 0x80010000 -n "OpenWrt Bootloader" -d $(UBOOT_PATH) $@.new + cat $@ >> $@.new + @mv $@.new $@ +endef + define Build/relocate-kernel rm -rf $@.relocate $(CP) ../../generic/image/relocate $@.relocate diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 605537ace3..310772932b 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -253,6 +253,18 @@ define Device/rakwireless_rak633 endef TARGET_DEVICES += rakwireless_rak633 +define Device/ravpower_rp-wd009 + IMAGE_SIZE := 14272k + DEVICE_VENDOR := RAVPower + DEVICE_MODEL := RP-WD009 + UBOOT_PATH := $(STAGING_DIR_IMAGE)/ravpower_rp-wd009-u-boot.bin + DEVICE_PACKAGES := kmod-mt76x0e kmod-usb2 kmod-usb-ohci \ + kmod-sdhci-mt7620 kmod-i2c-mt7628 ravpower-mcu + IMAGES += factory.bin + IMAGE/factory.bin := $$(sysupgrade_bin) | ravpower-wd009-factory +endef +TARGET_DEVICES += ravpower_rp-wd009 + define Device/skylab_skw92a IMAGE_SIZE := 16064k DEVICE_VENDOR := Skylab @@ -355,6 +367,16 @@ define Device/tplink_re200-v2 endef TARGET_DEVICES += tplink_re200-v2 +define Device/tplink_re220-v2 + $(Device/tplink-safeloader) + IMAGE_SIZE := 7808k + DEVICE_MODEL := RE220 + DEVICE_VARIANT := v2 + DEVICE_PACKAGES := kmod-mt76x0e + TPLINK_BOARD_ID := RE220-V2 +endef +TARGET_DEVICES += tplink_re220-v2 + define Device/tplink_re305-v1 $(Device/tplink-safeloader) IMAGE_SIZE := 6016k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 03cc921be3..0dd1a55b77 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -44,6 +44,9 @@ ramips_setup_interfaces() mikrotik,routerboard-750gr3) ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan" ;; + phicomm,k2p) + ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 ra0 rax0" "wan" + ;; ubnt,edgerouter-x) ucidef_set_interface_lan_wan "eth1 eth2 eth3 eth4" "eth0" ;; diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds index 9db39cbdde..fcc6516c8d 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds @@ -68,6 +68,7 @@ tplink,archer-c50-v4) ucidef_set_led_wlan "wlan5g" "wlan5g" "$boardname:green:wlan5g" "phy1tpt" ;; tplink,re200-v2|\ +tplink,re220-v2|\ tplink,tl-mr3020-v3|\ tplink,tl-wa801nd-v5) ucidef_set_led_netdev "lan" "lan" "$boardname:green:lan" "eth0" diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network index 1cccc16415..ecba0ccb17 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network @@ -14,8 +14,10 @@ ramips_setup_interfaces() mediatek,linkit-smart-7688|\ onion,omega2p|\ onion,omega2|\ + ravpower,rp-wd009|\ tama,w06|\ tplink,re200-v2|\ + tplink,re220-v2|\ tplink,re305-v1|\ tplink,tl-mr3020-v3|\ tplink,tl-wr802n-v4|\ @@ -143,7 +145,8 @@ ramips_setup_macs() wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)" lan_mac=$wan_mac ;; - cudy,wr1000) + cudy,wr1000|\ + wavlink,wl-wn577a2) wan_mac=$(mtd_get_mac_binary factory 0x2e) label_mac=$(mtd_get_mac_binary factory 0x4) ;; @@ -187,10 +190,6 @@ ramips_setup_macs() wiznet,wizfi630s) wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x28)" 1) ;; - wavlink,wl-wn577a2) - wan_mac=$(mtd_get_mac_binary factory 0x2e) - label_mac=$(mtd_get_mac_binary factory 0x4) - ;; skylab,skw92a|\ totolink,lr1200) wan_mac=$(mtd_get_mac_binary factory 0x2e) diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c index f2e4a7ce9a..a97f329a87 100644 --- a/tools/firmware-utils/src/tplink-safeloader.c +++ b/tools/firmware-utils/src/tplink-safeloader.c @@ -1555,6 +1555,49 @@ static struct device_info boards[] = { .last_sysupgrade_partition = "file-system" }, + /** Firmware layout for the RE220 v2 */ + { + .id = "RE220-V2", + .vendor = "", + .support_list = + "SupportList:\n" + "{product_name:RE220,product_ver:2.0.0,special_id:00000000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:41520000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:41550000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:42520000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:43410000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:45530000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:45550000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:49440000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:4a500000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:4b520000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:52550000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:54570000}\n" + "{product_name:RE220,product_ver:2.0.0,special_id:55530000}\n", + .support_trail = '\x00', + .soft_ver = NULL, + + .partitions = { + {"fs-uboot", 0x00000, 0x20000}, + {"firmware", 0x20000, 0x7a0000}, + {"partition-table", 0x7c0000, 0x02000}, + {"default-mac", 0x7c2000, 0x00020}, + {"pin", 0x7c2100, 0x00020}, + {"product-info", 0x7c3100, 0x01000}, + {"soft-version", 0x7c4200, 0x01000}, + {"support-list", 0x7c5200, 0x01000}, + {"profile", 0x7c6200, 0x08000}, + {"config-info", 0x7ce200, 0x00400}, + {"user-config", 0x7d0000, 0x10000}, + {"default-config", 0x7e0000, 0x10000}, + {"radio", 0x7f0000, 0x10000}, + {NULL, 0, 0} + }, + + .first_sysupgrade_partition = "os-image", + .last_sysupgrade_partition = "file-system" + }, + /** Firmware layout for the RE305 v1 */ { .id = "RE305-V1",