diff --git a/config/Config-devel.in b/config/Config-devel.in index 126462bfc3..87f9157106 100644 --- a/config/Config-devel.in +++ b/config/Config-devel.in @@ -74,6 +74,11 @@ menuconfig DEVEL Store ccache in this directory. If not set, uses './.ccache' + config KERNEL_CFLAGS + string "Kernel extra CFLAGS" if DEVEL + default "-falign-functions=32" if TARGET_bcm53xx + default "" + config EXTERNAL_KERNEL_TREE string "Use external kernel tree" if DEVEL default "" diff --git a/include/kernel.mk b/include/kernel.mk index e4074a48f4..070d1bca75 100644 --- a/include/kernel.mk +++ b/include/kernel.mk @@ -101,7 +101,7 @@ endif KERNEL_MAKE = $(MAKE) $(KERNEL_MAKEOPTS) KERNEL_MAKE_FLAGS = \ - KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR)))" \ + KCFLAGS="$(call iremap,$(BUILD_DIR),$(notdir $(BUILD_DIR))) $(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) $(call qstrip,$(CONFIG_KERNEL_CFLAGS))" \ HOSTCFLAGS="$(HOST_CFLAGS) -Wall -Wmissing-prototypes -Wstrict-prototypes" \ CROSS_COMPILE="$(KERNEL_CROSS)" \ ARCH="$(LINUX_KARCH)" \ diff --git a/rules.mk b/rules.mk index a6bcebc929..acb75312f4 100644 --- a/rules.mk +++ b/rules.mk @@ -62,7 +62,6 @@ ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) -export EXTRA_OPTIMIZATION:=$(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX)) BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX)) SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) diff --git a/target/linux/bcm53xx/base-files/etc/init.d/fastnetwork b/target/linux/bcm53xx/base-files/etc/init.d/fastnetwork new file mode 100755 index 0000000000..1999d13707 --- /dev/null +++ b/target/linux/bcm53xx/base-files/etc/init.d/fastnetwork @@ -0,0 +1,44 @@ +#!/bin/sh /etc/rc.common + +START=25 +USE_PROCD=1 + +start_service() { + reload_service +} + +service_triggers() { + procd_add_reload_trigger "network" + procd_add_reload_trigger "firewall" + procd_add_reload_interface_trigger "lan" +} + +reload_service() { + local packet_steering="$(uci -q get network.@globals[0].packet_steering)" + local num_cpus="$(grep -c "^processor.*:" /proc/cpuinfo)" + local flow_offloading="$(uci -q get firewall.@defaults[0].flow_offloading)" + local flow_offloading_hw="$(uci -q get firewall.@defaults[0].flow_offloading_hw)" + + # Any steering on 1 CPU (BCM47081) worsens network performance + [ "$num_cpus" != 2 ] && return + + [ "$packet_steering" != 1 ] && { + echo 0 > /sys/class/net/br-lan/queues/rx-0/rps_cpus + echo 0 > /sys/class/net/eth0/queues/rx-0/rps_cpus + return + } + + if [ ${flow_offloading_hw:-0} -gt 0 ]; then + # HW offloading + echo 0 > /sys/class/net/br-lan/queues/rx-0/rps_cpus + echo 0 > /sys/class/net/eth0/queues/rx-0/rps_cpus + elif [ ${flow_offloading:-0} -gt 0 ]; then + # SW offloading + # br-lan setup doesn't seem to matter for offloading case + echo 2 > /sys/class/net/eth0/queues/rx-0/rps_cpus + else + # Default + echo 2 > /sys/class/net/br-lan/queues/rx-0/rps_cpus + echo 0 > /sys/class/net/eth0/queues/rx-0/rps_cpus + fi +} diff --git a/target/linux/bcm53xx/base-files/etc/uci-defaults/05_packet_steering b/target/linux/bcm53xx/base-files/etc/uci-defaults/05_packet_steering new file mode 100644 index 0000000000..98c9497815 --- /dev/null +++ b/target/linux/bcm53xx/base-files/etc/uci-defaults/05_packet_steering @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only + +uci set network.@globals[0].packet_steering="1" diff --git a/target/linux/bcm53xx/patches-5.4/600-net-disable-GRO-by-default.patch b/target/linux/bcm53xx/patches-5.4/600-net-disable-GRO-by-default.patch new file mode 100644 index 0000000000..a11054e718 --- /dev/null +++ b/target/linux/bcm53xx/patches-5.4/600-net-disable-GRO-by-default.patch @@ -0,0 +1,32 @@ +From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= +Date: Mon, 20 Jun 2022 10:01:18 +0200 +Subject: [PATCH] net: disable GRO by default +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In many cases GRO improves network performance however it comes at a +cost of chacksums calculations. In case of slow CPU and missing hardware +csum calculation support GRO can actually decrease network speed. + +On BCM4708 *disabling* GRO results in following NAT masquarade speed +changes: +1. 364 Mb/s → 396 Mb/s (packet steering disabled) +2. 341 Mb/s → 566 Mb/s (packet steering enabled) + +Signed-off-by: Rafał Miłecki +--- + include/linux/netdev_features.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/include/linux/netdev_features.h ++++ b/include/linux/netdev_features.h +@@ -224,7 +224,7 @@ static inline int find_next_netdev_featu + #define NETIF_F_UPPER_DISABLES NETIF_F_LRO + + /* changeable features with no special hardware requirements */ +-#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO) ++#define NETIF_F_SOFT_FEATURES (NETIF_F_GSO) + + #define NETIF_F_VLAN_FEATURES (NETIF_F_HW_VLAN_CTAG_FILTER | \ + NETIF_F_HW_VLAN_CTAG_RX | \ diff --git a/target/linux/generic/pending-5.4/201-extra_optimization.patch b/target/linux/generic/pending-5.4/201-extra_optimization.patch deleted file mode 100644 index c606487992..0000000000 --- a/target/linux/generic/pending-5.4/201-extra_optimization.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Felix Fietkau -Subject: Upgrade to Linux 2.6.19 - -- Includes large parts of the patch from #1021 by dpalffy -- Includes RB532 NAND driver changes by n0-1 - -[john@phrozen.org: feix will add this to his upstream queue] - -lede-commit: bff468813f78f81e36ebb2a3f4354de7365e640f -Signed-off-by: Felix Fietkau ---- - Makefile | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- a/Makefile -+++ b/Makefile -@@ -719,11 +719,11 @@ KBUILD_CFLAGS += $(call cc-disable-warni - KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) - - ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE --KBUILD_CFLAGS += -O2 -+KBUILD_CFLAGS += -O2 $(EXTRA_OPTIMIZATION) - else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 --KBUILD_CFLAGS += -O3 -+KBUILD_CFLAGS += -O3 $(EXTRA_OPTIMIZATION) - else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE --KBUILD_CFLAGS += -Os -+KBUILD_CFLAGS += -Os -fno-reorder-blocks -fno-tree-ch $(EXTRA_OPTIMIZATION) - endif - - # Tell gcc to never replace conditional load with a non-conditional one