From 11de53729a5501c309a7d838c35fb52b195e2f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Tue, 25 Apr 2023 21:17:52 +0200 Subject: [PATCH 001/113] bmips: increment polled keys interval to 100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need to poll the gpio keys every 20 ms and the linux kernel documentation suggests 100 ms. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bmips/dts/bcm63167-sercomm-h500-s.dtsi | 2 +- target/linux/bmips/dts/bcm63168-comtrend-vr-3032u.dts | 2 +- target/linux/bmips/dts/bcm63168-sercomm-shg2500.dts | 2 +- target/linux/bmips/dts/bcm6318-comtrend-ar-5315u.dts | 2 +- target/linux/bmips/dts/bcm6328-comtrend-ar-5387un.dts | 2 +- target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts | 2 +- target/linux/bmips/dts/bcm6362-huawei-hg253s-v2.dts | 2 +- target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts | 2 +- target/linux/bmips/dts/bcm6368-comtrend-vr-3025u.dts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/target/linux/bmips/dts/bcm63167-sercomm-h500-s.dtsi b/target/linux/bmips/dts/bcm63167-sercomm-h500-s.dtsi index 591029c4635..8e0024a20f5 100644 --- a/target/linux/bmips/dts/bcm63167-sercomm-h500-s.dtsi +++ b/target/linux/bmips/dts/bcm63167-sercomm-h500-s.dtsi @@ -16,7 +16,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; wps { label = "wps"; diff --git a/target/linux/bmips/dts/bcm63168-comtrend-vr-3032u.dts b/target/linux/bmips/dts/bcm63168-comtrend-vr-3032u.dts index 062fdcafe96..8c4611ee881 100644 --- a/target/linux/bmips/dts/bcm63168-comtrend-vr-3032u.dts +++ b/target/linux/bmips/dts/bcm63168-comtrend-vr-3032u.dts @@ -19,7 +19,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; reset { label = "reset"; diff --git a/target/linux/bmips/dts/bcm63168-sercomm-shg2500.dts b/target/linux/bmips/dts/bcm63168-sercomm-shg2500.dts index bcab940771c..bb769b09e1c 100644 --- a/target/linux/bmips/dts/bcm63168-sercomm-shg2500.dts +++ b/target/linux/bmips/dts/bcm63168-sercomm-shg2500.dts @@ -27,7 +27,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; wps { label = "wps"; diff --git a/target/linux/bmips/dts/bcm6318-comtrend-ar-5315u.dts b/target/linux/bmips/dts/bcm6318-comtrend-ar-5315u.dts index 7f2d438efbf..8ac37be495c 100644 --- a/target/linux/bmips/dts/bcm6318-comtrend-ar-5315u.dts +++ b/target/linux/bmips/dts/bcm6318-comtrend-ar-5315u.dts @@ -19,7 +19,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; wps { label = "wps"; diff --git a/target/linux/bmips/dts/bcm6328-comtrend-ar-5387un.dts b/target/linux/bmips/dts/bcm6328-comtrend-ar-5387un.dts index 276858dff72..72802366a08 100644 --- a/target/linux/bmips/dts/bcm6328-comtrend-ar-5387un.dts +++ b/target/linux/bmips/dts/bcm6328-comtrend-ar-5387un.dts @@ -18,7 +18,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; reset { label = "reset"; diff --git a/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts b/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts index 18adc73b63f..716c6227f8a 100644 --- a/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts +++ b/target/linux/bmips/dts/bcm6358-huawei-hg556a-b.dts @@ -18,7 +18,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; help { label = "help"; diff --git a/target/linux/bmips/dts/bcm6362-huawei-hg253s-v2.dts b/target/linux/bmips/dts/bcm6362-huawei-hg253s-v2.dts index e848b99b2c7..2a9a6c559a7 100644 --- a/target/linux/bmips/dts/bcm6362-huawei-hg253s-v2.dts +++ b/target/linux/bmips/dts/bcm6362-huawei-hg253s-v2.dts @@ -18,7 +18,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; reset { label = "reset"; diff --git a/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts b/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts index c96a6c4585b..ddcde2b6889 100644 --- a/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts +++ b/target/linux/bmips/dts/bcm6362-netgear-dgnd3700-v2.dts @@ -21,7 +21,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; wlan { label = "wlan"; diff --git a/target/linux/bmips/dts/bcm6368-comtrend-vr-3025u.dts b/target/linux/bmips/dts/bcm6368-comtrend-vr-3025u.dts index b29078d645d..60029fe7f84 100644 --- a/target/linux/bmips/dts/bcm6368-comtrend-vr-3025u.dts +++ b/target/linux/bmips/dts/bcm6368-comtrend-vr-3025u.dts @@ -18,7 +18,7 @@ keys { compatible = "gpio-keys-polled"; - poll-interval = <20>; + poll-interval = <100>; reset { label = "reset"; From e9f5b773d29ef6d10f5e23e21edb1897a8d828e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 27 Apr 2023 13:47:24 +0200 Subject: [PATCH 002/113] bmips: document GPIO external interrupts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BCM63xx SoCs have an external interrupt controller which can be used for specific GPIO keys. Signed-off-by: Álvaro Fernández Rojas --- target/linux/bmips/dts/bcm6318.dtsi | 1 + target/linux/bmips/dts/bcm63268.dtsi | 1 + target/linux/bmips/dts/bcm6328.dtsi | 1 + target/linux/bmips/dts/bcm6358.dtsi | 1 + target/linux/bmips/dts/bcm6362.dtsi | 1 + target/linux/bmips/dts/bcm6368.dtsi | 1 + .../bcm6318-interrupt-controller.h | 5 ++++ .../bcm63268-interrupt-controller.h | 9 ++++++-- .../bcm6328-interrupt-controller.h | 5 ++++ .../bcm6358-interrupt-controller.h | 7 ++++++ .../bcm6362-interrupt-controller.h | 7 +++++- .../bcm6368-interrupt-controller.h | 23 ++++++++++++------- 12 files changed, 51 insertions(+), 11 deletions(-) diff --git a/target/linux/bmips/dts/bcm6318.dtsi b/target/linux/bmips/dts/bcm6318.dtsi index fc5085c506c..28c656d090e 100644 --- a/target/linux/bmips/dts/bcm6318.dtsi +++ b/target/linux/bmips/dts/bcm6318.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/target/linux/bmips/dts/bcm63268.dtsi b/target/linux/bmips/dts/bcm63268.dtsi index e30cdd862f6..f9a31d36ef7 100644 --- a/target/linux/bmips/dts/bcm63268.dtsi +++ b/target/linux/bmips/dts/bcm63268.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/target/linux/bmips/dts/bcm6328.dtsi b/target/linux/bmips/dts/bcm6328.dtsi index d61903e1548..f45f94f5b86 100644 --- a/target/linux/bmips/dts/bcm6328.dtsi +++ b/target/linux/bmips/dts/bcm6328.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/target/linux/bmips/dts/bcm6358.dtsi b/target/linux/bmips/dts/bcm6358.dtsi index eb8ca0c10d6..b56ec698ba6 100644 --- a/target/linux/bmips/dts/bcm6358.dtsi +++ b/target/linux/bmips/dts/bcm6358.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include / { diff --git a/target/linux/bmips/dts/bcm6362.dtsi b/target/linux/bmips/dts/bcm6362.dtsi index d7fff43c441..e615eaf8b3b 100644 --- a/target/linux/bmips/dts/bcm6362.dtsi +++ b/target/linux/bmips/dts/bcm6362.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/target/linux/bmips/dts/bcm6368.dtsi b/target/linux/bmips/dts/bcm6368.dtsi index baa1c434173..0ac1269166b 100644 --- a/target/linux/bmips/dts/bcm6368.dtsi +++ b/target/linux/bmips/dts/bcm6368.dtsi @@ -6,6 +6,7 @@ #include #include #include +#include #include / { diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6318-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6318-interrupt-controller.h index 34bf929edaf..91d70377cc6 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6318-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6318-interrupt-controller.h @@ -81,4 +81,9 @@ #define BCM6318_IRQ_EPHY2_IDDQ_ENERGY 78 #define BCM6318_IRQ_EPHY3_IDDQ_ENERGY 79 +#define BCM6318_EXTIRQ_0 0 /* GPIO 33 */ +#define BCM6318_EXTIRQ_1 1 +#define BCM6318_EXTIRQ_2 2 +#define BCM6318_EXTIRQ_3 3 + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM6318_H */ diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm63268-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm63268-interrupt-controller.h index 84a5f44611d..90b7890f505 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm63268-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm63268-interrupt-controller.h @@ -35,9 +35,9 @@ #define BCM63268_IRQ_ATM_DMA3 29 #define BCM63268_IRQ_WAKE_ON_IRQ 30 #define BCM63268_IRQ_GPHY 31 -#define BCM63268_IRQ_DECT0 32 +#define BCM63268_IRQ_DECT0 32 #define BCM63268_IRQ_DECT1 33 -#define BCM63268_IRQ_UART1 34 +#define BCM63268_IRQ_UART1 34 #define BCM63268_IRQ_WLAN_GPIO 35 #define BCM63268_IRQ_USB_CTL_TX_DMA 36 #define BCM63268_IRQ_USB_BULK_TX_DMA 37 @@ -83,4 +83,9 @@ #define BCM63268_IRQ_ATM_DMA19 79 #define BCM63268_IRQ_LSSPI 80 +#define BCM63268_EXTIRQ_0 0 /* GPIO 32 */ +#define BCM63268_EXTIRQ_1 1 /* GPIO 33 */ +#define BCM63268_EXTIRQ_2 2 /* GPIO 34 */ +#define BCM63268_EXTIRQ_3 3 /* GPIO 35 */ + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM63268_H */ diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6328-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6328-interrupt-controller.h index 1f5192d9fee..2a6a1da8886 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6328-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6328-interrupt-controller.h @@ -65,4 +65,9 @@ #define BCM6328_IRQ_ATM_DMA19 62 #define BCM6328_IRQ_SAR 63 +#define BCM6328_EXTIRQ_0 0 /* GPIO 23 */ +#define BCM6328_EXTIRQ_1 1 /* GPIO 24 */ +#define BCM6328_EXTIRQ_2 2 /* GPIO 15 */ +#define BCM6328_EXTIRQ_3 3 /* GPIO 12 */ + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM6328_H */ diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6358-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6358-interrupt-controller.h index dc412d1f596..51c7e50cf49 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6358-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6358-interrupt-controller.h @@ -35,4 +35,11 @@ #define BCM6358_IRQ_DG 30 #define BCM6358_IRQ_MPI 31 +#define BCM6358_EXTIRQ0_0 0 /* GPIO 34 */ +#define BCM6358_EXTIRQ0_1 1 /* GPIO 35 */ +#define BCM6358_EXTIRQ0_2 2 /* GPIO 36 */ +#define BCM6358_EXTIRQ0_3 3 /* GPIO 37 */ +#define BCM6358_EXTIRQ1_4 0 /* GPIO 32 */ +#define BCM6358_EXTIRQ1_5 1 /* GPIO 33 */ + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM6358_H */ diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6362-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6362-interrupt-controller.h index 2cb329204a4..bec089b1592 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6362-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6362-interrupt-controller.h @@ -65,7 +65,12 @@ #define BCM6362_IRQ_ATM_DMA15 59 #define BCM6362_IRQ_ATM_DMA16 60 #define BCM6362_IRQ_ATM_DMA17 61 -#define BCM6362_IRQ_ATM_DMA18 62 +#define BCM6362_IRQ_ATM_DMA18 62 #define BCM6362_IRQ_ATM_DMA19 63 +#define BCM6362_EXTIRQ_0 0 /* GPIO 24 */ +#define BCM6362_EXTIRQ_1 1 /* GPIO 25 */ +#define BCM6362_EXTIRQ_2 2 /* GPIO 26 */ +#define BCM6362_EXTIRQ_3 3 /* GPIO 27 */ + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM6362_H */ diff --git a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6368-interrupt-controller.h b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6368-interrupt-controller.h index 96a73d645e6..0f362007495 100644 --- a/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6368-interrupt-controller.h +++ b/target/linux/bmips/files/include/dt-bindings/interrupt-controller/bcm6368-interrupt-controller.h @@ -35,14 +35,14 @@ #define BCM6368_IRQ_USB_BULK_TX_DMA 29 #define BCM6368_IRQ_USB_ISO_RX_DMA 30 #define BCM6368_IRQ_USB_ISO_TX_DMA 31 -#define BCM6368_IRQ_ENETSW_RX_DMA0 32 -#define BCM6368_IRQ_ENETSW_RX_DMA1 33 -#define BCM6368_IRQ_ENETSW_RX_DMA2 34 -#define BCM6368_IRQ_ENETSW_RX_DMA3 35 -#define BCM6368_IRQ_ENETSW_TX_DMA0 36 -#define BCM6368_IRQ_ENETSW_TX_DMA1 37 -#define BCM6368_IRQ_ENETSW_TX_DMA2 38 -#define BCM6368_IRQ_ENETSW_TX_DMA3 39 +#define BCM6368_IRQ_ENETSW_RX_DMA0 32 +#define BCM6368_IRQ_ENETSW_RX_DMA1 33 +#define BCM6368_IRQ_ENETSW_RX_DMA2 34 +#define BCM6368_IRQ_ENETSW_RX_DMA3 35 +#define BCM6368_IRQ_ENETSW_TX_DMA0 36 +#define BCM6368_IRQ_ENETSW_TX_DMA1 37 +#define BCM6368_IRQ_ENETSW_TX_DMA2 38 +#define BCM6368_IRQ_ENETSW_TX_DMA3 39 #define BCM6368_IRQ_ATM_DMA0 40 #define BCM6368_IRQ_ATM_DMA1 41 #define BCM6368_IRQ_ATM_DMA2 42 @@ -68,4 +68,11 @@ #define BCM6368_IRQ_PCM_DMA0 62 #define BCM6368_IRQ_PCM_DMA1 63 +#define BCM6368_EXTIRQ0_0 0 /* GPIO 34 */ +#define BCM6368_EXTIRQ0_1 1 /* GPIO 35 */ +#define BCM6368_EXTIRQ0_2 2 /* GPIO 36 */ +#define BCM6368_EXTIRQ0_3 3 /* GPIO 37 */ +#define BCM6368_EXTIRQ1_4 0 /* GPIO 32 */ +#define BCM6368_EXTIRQ1_5 1 /* GPIO 33 */ + #endif /* __DT_BINDINGS_INTERRUPT_CONTROLLER_BCM6368_H */ From c3549b931902e02a76a5cdf31817c58a8c315f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 27 Apr 2023 13:49:10 +0200 Subject: [PATCH 003/113] bmips: fix external interrupt controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - irq_domain_add_simple() can't be used on bmips since interrupts aren't hardcoded with specific offsets for internal and external as opposed to bcm63xx. This is needed to avoid collisions with other interrupts. - remove unused bcm63xx-specific code. Signed-off-by: Álvaro Fernández Rojas --- ...ort-for-bcm6345-style-external-inter.patch | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/target/linux/bmips/patches-5.15/100-irqchip-add-support-for-bcm6345-style-external-inter.patch b/target/linux/bmips/patches-5.15/100-irqchip-add-support-for-bcm6345-style-external-inter.patch index ba55107bb10..d64426ea1d2 100644 --- a/target/linux/bmips/patches-5.15/100-irqchip-add-support-for-bcm6345-style-external-inter.patch +++ b/target/linux/bmips/patches-5.15/100-irqchip-add-support-for-bcm6345-style-external-inter.patch @@ -73,7 +73,7 @@ Signed-off-by: Jonas Gorski obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o --- /dev/null +++ b/drivers/irqchip/irq-bcm6345-ext.c -@@ -0,0 +1,299 @@ +@@ -0,0 +1,280 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive @@ -94,14 +94,6 @@ Signed-off-by: Jonas Gorski +#include +#include + -+#ifdef CONFIG_BCM63XX -+#include -+ -+#define VIRQ_BASE IRQ_EXTERNAL_BASE -+#else -+#define VIRQ_BASE 0 -+#endif -+ +#define MAX_IRQS 4 + +#define EXTIRQ_CFG_SENSE 0 @@ -271,7 +263,6 @@ Signed-off-by: Jonas Gorski +{ + struct intc_data *data; + unsigned int i; -+ int start = VIRQ_BASE; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) @@ -296,17 +287,7 @@ Signed-off-by: Jonas Gorski + data->chip.irq_unmask = bcm6345_ext_intc_irq_unmask; + data->chip.irq_set_type = bcm6345_ext_intc_set_type; + -+ /* -+ * If we have less than 4 irqs, this is the second controller on -+ * bcm63xx. So increase the VIRQ start to not overlap with the first -+ * one, but only do so if we actually use a non-zero start. -+ * -+ * This can be removed when bcm63xx has no legacy users anymore. -+ */ -+ if (start && num_irqs < 4) -+ start += 4; -+ -+ data->domain = irq_domain_add_simple(node, num_irqs, start, ++ data->domain = irq_domain_add_linear(node, num_irqs, + &bcm6345_ext_domain_ops, data); + if (!data->domain) { + kfree(data); From de0ed4ffbfba7cb39acc93f783c3eccb1e3859d2 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 13 Apr 2023 11:38:54 +0200 Subject: [PATCH 004/113] generic: Convert incorrect generic/5.15 patches again OpenWrt's developer guide prefers having actual patches so they an be sent upstream more easily. However, in the case of hack-5.15 patches which are not meant for upstream, adding proper fields allows for `git am` to properly function. This commit tries to rectify that, by digging in the history to find where and how it was first added. Signed-off-by: Olliver Schinagl Signed-off-by: Daniel Golle --- ...net-mtk_eth_soc-add-support-for-MT7981.patch | 17 +++++++++++++++++ ...s-mtk-lynxi-workaround-2500BaseX-no-an.patch | 13 +++++++++++++ .../795-backport-phylink_pcs-helpers.patch | 17 +++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch index 066b70c5e2c..c1cf323800c 100644 --- a/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch +++ b/target/linux/generic/backport-5.15/733-v6.3-18-net-ethernet-mtk_eth_soc-add-support-for-MT7981.patch @@ -1,3 +1,20 @@ +From f5d43ddd334b7c32fcaed9ba46afbd85cb467f1f Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 19 Mar 2023 12:56:28 +0000 +Subject: [PATCH] net: ethernet: mtk_eth_soc: add support for MT7981 SoC + +The MediaTek MT7981 SoC comes with two 1G/2.5G SGMII ports, just like +MT7986. + +In addition MT7981 is equipped with a built-in 1000Base-T PHY which can +be used with GMAC1. + +As many MT7981 boards make use of inverting SGMII signal polarity, add +new device-tree attribute 'mediatek,pn_swap' to support them. + +Signed-off-by: Daniel Golle +Signed-off-by: Jakub Kicinski + --- a/drivers/net/ethernet/mediatek/mtk_eth_path.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_path.c @@ -96,12 +96,20 @@ static int set_mux_gmac2_gmac0_to_gephy( diff --git a/target/linux/generic/hack-5.15/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch b/target/linux/generic/hack-5.15/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch index b03f0feab27..8b7f2f09557 100644 --- a/target/linux/generic/hack-5.15/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch +++ b/target/linux/generic/hack-5.15/750-net-pcs-mtk-lynxi-workaround-2500BaseX-no-an.patch @@ -1,3 +1,16 @@ +From 880d1311335120f64447ca9d11933872d734e19a Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Mon, 27 Mar 2023 18:41:54 +0100 +Subject: [PATCH] generic: pcs-mtk-lynxi: add hack to use 2500Base-X without AN + +Using 2500Base-T SFP modules e.g. on the BananaPi R3 requires manually +disabling auto-negotiation, e.g. using ethtool. While a proper fix +using SFP quirks is being discussed upstream, bring a work-around to +restore user experience to what it was before the switch to the +dedicated SGMII PCS driver. + +Signed-off-by: Daniel Golle + --- a/drivers/net/pcs/pcs-mtk-lynxi.c +++ b/drivers/net/pcs/pcs-mtk-lynxi.c @@ -92,14 +92,23 @@ static void mtk_pcs_lynxi_get_state(stru diff --git a/target/linux/generic/hack-5.15/795-backport-phylink_pcs-helpers.patch b/target/linux/generic/hack-5.15/795-backport-phylink_pcs-helpers.patch index 2ccdc905a5c..b1e7065a8b9 100644 --- a/target/linux/generic/hack-5.15/795-backport-phylink_pcs-helpers.patch +++ b/target/linux/generic/hack-5.15/795-backport-phylink_pcs-helpers.patch @@ -1,3 +1,20 @@ +From 027586ae8ecacff49757ed854c020f35d24a599c Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sat, 11 Mar 2023 03:44:41 +0000 +Subject: [PATCH] generic: backport some phylink helper functions + +It isn't feasible to literally backport all upstream phylink_pcs changes +down to Linux 5.15: It's just too many patches, and many downstream +drivers and hacks are likely to break. We are too close to branching off +to risk this, and it's also just too much work. +Instead just add helper functions used by modern PCS drivers while keeping +the original functions instact as well. While this may add a kilobyte or +two of extra kernel size, it has the advantage that we get the best of both +worlds: None of the existing codepaths are touched, but yet we have the +option to backport singular improvements to Ethernet drivers where needed. + +Signed-off-by: Daniel Golle + --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -584,10 +584,37 @@ int phylink_speed_up(struct phylink *pl) From 1e8b318ebe72d2c865b140f8075583fcda22783d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Thu, 27 Apr 2023 17:46:12 +0200 Subject: [PATCH 005/113] broadcom-sprom: update to latest version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces SPROMs with the ones from bmips fixups to prevent errors such as: https://github.com/openwrt/openwrt/pull/11474#issuecomment-1524235591 Signed-off-by: Álvaro Fernández Rojas --- package/firmware/broadcom-sprom/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/firmware/broadcom-sprom/Makefile b/package/firmware/broadcom-sprom/Makefile index 23c07942d37..01bca2c35b7 100644 --- a/package/firmware/broadcom-sprom/Makefile +++ b/package/firmware/broadcom-sprom/Makefile @@ -3,9 +3,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=broadcom-sprom -PKG_SOURCE_DATE:=2023-04-19 -PKG_SOURCE_VERSION:=d1d94f2407d9090ce72363614bbb87230a92ba44 -PKG_MIRROR_HASH:=76cc5590a577713a65a512db12014d4fef61d9c67750e9f69753b358f442db8e +PKG_SOURCE_DATE:=2023-04-27 +PKG_SOURCE_VERSION:=d36f7fcb37711106a3a2652b576436cb09aa5b6f +PKG_MIRROR_HASH:=fde251ab4ed26d61c95269316119710d6ccb8fe30ef13305d08b3e7d7d8a4c60 PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git From 2c530fcb972c112e7a2b10f9c21ac6d276624b5e Mon Sep 17 00:00:00 2001 From: David Bauer Date: Thu, 27 Apr 2023 22:24:15 +0200 Subject: [PATCH 006/113] ramips: reduce Archer AX23 / MR70X SPI-frequency It was brought to attention the Archer AX23 v1 fails to read jffs2 data from time to time. While this is not reproducible on my unit, it is on others. Reducing the SPI frequency does the trick. While it worked with at lest 40 MHz, opt for the cautious side and choose a save frequency of 25 MHz. Apply the same treatment to the Mercusys MR70X which uses a similar design just in case. Signed-off-by: David Bauer --- target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts | 2 +- target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts b/target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts index 7eb94ba9cfc..245d130a1fc 100644 --- a/target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts +++ b/target/linux/ramips/dts/mt7621_mercusys_mr70x-v1.dts @@ -52,7 +52,7 @@ flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <80000000>; + spi-max-frequency = <25000000>; partitions { compatible = "fixed-partitions"; diff --git a/target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts b/target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts index 5c2ef1fa11c..50834c58664 100644 --- a/target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts +++ b/target/linux/ramips/dts/mt7621_tplink_archer-ax23-v1.dts @@ -85,7 +85,7 @@ flash@0 { compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <80000000>; + spi-max-frequency = <25000000>; partitions { compatible = "fixed-partitions"; From ec6f80663ed80e50844d0c032121e0bec46ff297 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 29 Apr 2023 10:25:18 +0200 Subject: [PATCH 007/113] mediatek: remove mt753x driver It is unused Signed-off-by: Felix Fietkau --- .../files/drivers/net/phy/mtk/mt753x/Kconfig | 3 - .../files/drivers/net/phy/mtk/mt753x/Makefile | 11 - .../files/drivers/net/phy/mtk/mt753x/mt7530.c | 631 ------------ .../files/drivers/net/phy/mtk/mt753x/mt7530.h | 13 - .../files/drivers/net/phy/mtk/mt753x/mt7531.c | 918 ------------------ .../files/drivers/net/phy/mtk/mt753x/mt7531.h | 13 - .../files/drivers/net/phy/mtk/mt753x/mt753x.h | 213 ---- .../net/phy/mtk/mt753x/mt753x_common.c | 90 -- .../drivers/net/phy/mtk/mt753x/mt753x_mdio.c | 597 ------------ .../drivers/net/phy/mtk/mt753x/mt753x_nl.c | 382 -------- .../drivers/net/phy/mtk/mt753x/mt753x_nl.h | 43 - .../drivers/net/phy/mtk/mt753x/mt753x_regs.h | 294 ------ .../net/phy/mtk/mt753x/mt753x_swconfig.c | 510 ---------- .../net/phy/mtk/mt753x/mt753x_swconfig.h | 29 - .../drivers/net/phy/mtk/mt753x/mt753x_vlan.c | 183 ---- .../drivers/net/phy/mtk/mt753x/mt753x_vlan.h | 40 - 16 files changed, 3970 deletions(-) delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Kconfig delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Makefile delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_common.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_regs.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.h delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.c delete mode 100644 target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.h diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Kconfig b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Kconfig deleted file mode 100644 index d9e0230cf07..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Kconfig +++ /dev/null @@ -1,3 +0,0 @@ - -config MT753X_GSW - tristate "Driver for the MediaTek MT753x switch" diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Makefile b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Makefile deleted file mode 100644 index 7aae451cd16..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# Makefile for MediaTek MT753x gigabit switch -# - -obj-$(CONFIG_MT753X_GSW) += mt753x.o - -mt753x-$(CONFIG_SWCONFIG) += mt753x_swconfig.o - -mt753x-y += mt753x_mdio.o mt7530.o mt7531.o \ - mt753x_common.o mt753x_vlan.o \ - mt753x_nl.o diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.c deleted file mode 100644 index 6a94d0d2f4b..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.c +++ /dev/null @@ -1,631 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#include -#include - -#include "mt753x.h" -#include "mt753x_regs.h" - -/* MT7530 registers */ - -/* Unique fields of PMCR for MT7530 */ -#define FORCE_MODE BIT(15) - -/* Unique fields of GMACCR for MT7530 */ -#define VLAN_SUPT_NO_S 14 -#define VLAN_SUPT_NO_M 0x1c000 -#define LATE_COL_DROP BIT(13) - -/* Unique fields of (M)HWSTRAP for MT7530 */ -#define BOND_OPTION BIT(24) -#define P5_PHY0_SEL BIT(20) -#define CHG_TRAP BIT(16) -#define LOOPDET_DIS BIT(14) -#define P5_INTF_SEL_GMAC5 BIT(13) -#define SMI_ADDR_S 11 -#define SMI_ADDR_M 0x1800 -#define XTAL_FSEL_S 9 -#define XTAL_FSEL_M 0x600 -#define P6_INTF_DIS BIT(8) -#define P5_INTF_MODE_RGMII BIT(7) -#define P5_INTF_DIS_S BIT(6) -#define C_MDIO_BPS_S BIT(5) -#define EEPROM_EN_S BIT(4) - -/* PHY EEE Register bitmap of define */ -#define PHY_DEV07 0x07 -#define PHY_DEV07_REG_03C 0x3c - -/* PHY Extend Register 0x14 bitmap of define */ -#define PHY_EXT_REG_14 0x14 - -/* Fields of PHY_EXT_REG_14 */ -#define PHY_EN_DOWN_SHFIT BIT(4) - -/* PHY Token Ring Register 0x10 bitmap of define */ -#define PHY_TR_REG_10 0x10 - -/* PHY Token Ring Register 0x12 bitmap of define */ -#define PHY_TR_REG_12 0x12 - -/* PHY LPI PCS/DSP Control Register bitmap of define */ -#define PHY_LPI_REG_11 0x11 - -/* PHY DEV 0x1e Register bitmap of define */ -#define PHY_DEV1E 0x1e -#define PHY_DEV1E_REG_123 0x123 -#define PHY_DEV1E_REG_A6 0xa6 - -/* Values of XTAL_FSEL */ -#define XTAL_20MHZ 1 -#define XTAL_40MHZ 2 -#define XTAL_25MHZ 3 - -#define P6ECR 0x7830 -#define P6_INTF_MODE_TRGMII BIT(0) - -#define TRGMII_TXCTRL 0x7a40 -#define TRAIN_TXEN BIT(31) -#define TXC_INV BIT(30) -#define TX_DOEO BIT(29) -#define TX_RST BIT(28) - -#define TRGMII_TD0_CTRL 0x7a50 -#define TRGMII_TD1_CTRL 0x7a58 -#define TRGMII_TD2_CTRL 0x7a60 -#define TRGMII_TD3_CTRL 0x7a68 -#define TRGMII_TXCTL_CTRL 0x7a70 -#define TRGMII_TCK_CTRL 0x7a78 -#define TRGMII_TD_CTRL(n) (0x7a50 + (n) * 8) -#define NUM_TRGMII_CTRL 6 -#define TX_DMPEDRV BIT(31) -#define TX_DM_SR BIT(15) -#define TX_DMERODT BIT(14) -#define TX_DMOECTL BIT(13) -#define TX_TAP_S 8 -#define TX_TAP_M 0xf00 -#define TX_TRAIN_WD_S 0 -#define TX_TRAIN_WD_M 0xff - -#define TRGMII_TD0_ODT 0x7a54 -#define TRGMII_TD1_ODT 0x7a5c -#define TRGMII_TD2_ODT 0x7a64 -#define TRGMII_TD3_ODT 0x7a6c -#define TRGMII_TXCTL_ODT 0x7574 -#define TRGMII_TCK_ODT 0x757c -#define TRGMII_TD_ODT(n) (0x7a54 + (n) * 8) -#define NUM_TRGMII_ODT 6 -#define TX_DM_DRVN_PRE_S 30 -#define TX_DM_DRVN_PRE_M 0xc0000000 -#define TX_DM_DRVP_PRE_S 28 -#define TX_DM_DRVP_PRE_M 0x30000000 -#define TX_DM_TDSEL_S 24 -#define TX_DM_TDSEL_M 0xf000000 -#define TX_ODTEN BIT(23) -#define TX_DME_PRE BIT(20) -#define TX_DM_DRVNT0 BIT(19) -#define TX_DM_DRVPT0 BIT(18) -#define TX_DM_DRVNTE BIT(17) -#define TX_DM_DRVPTE BIT(16) -#define TX_DM_ODTN_S 12 -#define TX_DM_ODTN_M 0x7000 -#define TX_DM_ODTP_S 8 -#define TX_DM_ODTP_M 0x700 -#define TX_DM_DRVN_S 4 -#define TX_DM_DRVN_M 0xf0 -#define TX_DM_DRVP_S 0 -#define TX_DM_DRVP_M 0x0f - -#define P5RGMIIRXCR 0x7b00 -#define CSR_RGMII_RCTL_CFG_S 24 -#define CSR_RGMII_RCTL_CFG_M 0x7000000 -#define CSR_RGMII_RXD_CFG_S 16 -#define CSR_RGMII_RXD_CFG_M 0x70000 -#define CSR_RGMII_EDGE_ALIGN BIT(8) -#define CSR_RGMII_RXC_90DEG_CFG_S 4 -#define CSR_RGMII_RXC_90DEG_CFG_M 0xf0 -#define CSR_RGMII_RXC_0DEG_CFG_S 0 -#define CSR_RGMII_RXC_0DEG_CFG_M 0x0f - -#define P5RGMIITXCR 0x7b04 -#define CSR_RGMII_TXEN_CFG_S 16 -#define CSR_RGMII_TXEN_CFG_M 0x70000 -#define CSR_RGMII_TXD_CFG_S 8 -#define CSR_RGMII_TXD_CFG_M 0x700 -#define CSR_RGMII_TXC_CFG_S 0 -#define CSR_RGMII_TXC_CFG_M 0x1f - -#define CHIP_REV 0x7ffc -#define CHIP_NAME_S 16 -#define CHIP_NAME_M 0xffff0000 -#define CHIP_REV_S 0 -#define CHIP_REV_M 0x0f - -/* MMD registers */ -#define CORE_PLL_GROUP2 0x401 -#define RG_SYSPLL_EN_NORMAL BIT(15) -#define RG_SYSPLL_VODEN BIT(14) -#define RG_SYSPLL_POSDIV_S 5 -#define RG_SYSPLL_POSDIV_M 0x60 - -#define CORE_PLL_GROUP4 0x403 -#define RG_SYSPLL_DDSFBK_EN BIT(12) -#define RG_SYSPLL_BIAS_EN BIT(11) -#define RG_SYSPLL_BIAS_LPF_EN BIT(10) - -#define CORE_PLL_GROUP5 0x404 -#define RG_LCDDS_PCW_NCPO1_S 0 -#define RG_LCDDS_PCW_NCPO1_M 0xffff - -#define CORE_PLL_GROUP6 0x405 -#define RG_LCDDS_PCW_NCPO0_S 0 -#define RG_LCDDS_PCW_NCPO0_M 0xffff - -#define CORE_PLL_GROUP7 0x406 -#define RG_LCDDS_PWDB BIT(15) -#define RG_LCDDS_ISO_EN BIT(13) -#define RG_LCCDS_C_S 4 -#define RG_LCCDS_C_M 0x70 -#define RG_LCDDS_PCW_NCPO_CHG BIT(3) - -#define CORE_PLL_GROUP10 0x409 -#define RG_LCDDS_SSC_DELTA_S 0 -#define RG_LCDDS_SSC_DELTA_M 0xfff - -#define CORE_PLL_GROUP11 0x40a -#define RG_LCDDS_SSC_DELTA1_S 0 -#define RG_LCDDS_SSC_DELTA1_M 0xfff - -#define CORE_GSWPLL_GCR_1 0x040d -#define GSWPLL_PREDIV_S 14 -#define GSWPLL_PREDIV_M 0xc000 -#define GSWPLL_POSTDIV_200M_S 12 -#define GSWPLL_POSTDIV_200M_M 0x3000 -#define GSWPLL_EN_PRE BIT(11) -#define GSWPLL_FBKSEL BIT(10) -#define GSWPLL_BP BIT(9) -#define GSWPLL_BR BIT(8) -#define GSWPLL_FBKDIV_200M_S 0 -#define GSWPLL_FBKDIV_200M_M 0xff - -#define CORE_GSWPLL_GCR_2 0x040e -#define GSWPLL_POSTDIV_500M_S 8 -#define GSWPLL_POSTDIV_500M_M 0x300 -#define GSWPLL_FBKDIV_500M_S 0 -#define GSWPLL_FBKDIV_500M_M 0xff - -#define TRGMII_GSW_CLK_CG 0x0410 -#define TRGMIICK_EN BIT(1) -#define GSWCK_EN BIT(0) - -static int mt7530_mii_read(struct gsw_mt753x *gsw, int phy, int reg) -{ - if (phy < MT753X_NUM_PHYS) - phy = (gsw->phy_base + phy) & MT753X_SMI_ADDR_MASK; - - return mdiobus_read(gsw->host_bus, phy, reg); -} - -static void mt7530_mii_write(struct gsw_mt753x *gsw, int phy, int reg, u16 val) -{ - if (phy < MT753X_NUM_PHYS) - phy = (gsw->phy_base + phy) & MT753X_SMI_ADDR_MASK; - - mdiobus_write(gsw->host_bus, phy, reg, val); -} - -static int mt7530_mmd_read(struct gsw_mt753x *gsw, int addr, int devad, u16 reg) -{ - u16 val; - - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->host_bus->mdio_lock); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ACC_CTL_REG, - (MMD_ADDR << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M)); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ADDR_DATA_REG, reg); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ACC_CTL_REG, - (MMD_DATA << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M)); - - val = gsw->host_bus->read(gsw->host_bus, addr, MII_MMD_ADDR_DATA_REG); - - mutex_unlock(&gsw->host_bus->mdio_lock); - - return val; -} - -static void mt7530_mmd_write(struct gsw_mt753x *gsw, int addr, int devad, - u16 reg, u16 val) -{ - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->host_bus->mdio_lock); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ACC_CTL_REG, - (MMD_ADDR << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M)); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ADDR_DATA_REG, reg); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ACC_CTL_REG, - (MMD_DATA << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M)); - - gsw->host_bus->write(gsw->host_bus, addr, MII_MMD_ADDR_DATA_REG, val); - - mutex_unlock(&gsw->host_bus->mdio_lock); -} - -static void mt7530_core_reg_write(struct gsw_mt753x *gsw, u32 reg, u32 val) -{ - gsw->mmd_write(gsw, 0, 0x1f, reg, val); -} - -static void mt7530_trgmii_setting(struct gsw_mt753x *gsw) -{ - u16 i; - - mt7530_core_reg_write(gsw, CORE_PLL_GROUP5, 0x0780); - mdelay(1); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP6, 0); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP10, 0x87); - mdelay(1); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP11, 0x87); - - /* PLL BIAS enable */ - mt7530_core_reg_write(gsw, CORE_PLL_GROUP4, - RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN); - mdelay(1); - - /* PLL LPF enable */ - mt7530_core_reg_write(gsw, CORE_PLL_GROUP4, - RG_SYSPLL_DDSFBK_EN | - RG_SYSPLL_BIAS_EN | RG_SYSPLL_BIAS_LPF_EN); - - /* sys PLL enable */ - mt7530_core_reg_write(gsw, CORE_PLL_GROUP2, - RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN | - (1 << RG_SYSPLL_POSDIV_S)); - - /* LCDDDS PWDS */ - mt7530_core_reg_write(gsw, CORE_PLL_GROUP7, - (3 << RG_LCCDS_C_S) | - RG_LCDDS_PWDB | RG_LCDDS_ISO_EN); - mdelay(1); - - /* Enable MT7530 TRGMII clock */ - mt7530_core_reg_write(gsw, TRGMII_GSW_CLK_CG, GSWCK_EN | TRGMIICK_EN); - - /* lower Tx Driving */ - for (i = 0 ; i < NUM_TRGMII_ODT; i++) - mt753x_reg_write(gsw, TRGMII_TD_ODT(i), - (4 << TX_DM_DRVP_S) | (4 << TX_DM_DRVN_S)); -} - -static void mt7530_rgmii_setting(struct gsw_mt753x *gsw) -{ - u32 val; - - mt7530_core_reg_write(gsw, CORE_PLL_GROUP5, 0x0c80); - mdelay(1); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP6, 0); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP10, 0x87); - mdelay(1); - mt7530_core_reg_write(gsw, CORE_PLL_GROUP11, 0x87); - - val = mt753x_reg_read(gsw, TRGMII_TXCTRL); - val &= ~TXC_INV; - mt753x_reg_write(gsw, TRGMII_TXCTRL, val); - - mt753x_reg_write(gsw, TRGMII_TCK_CTRL, - (8 << TX_TAP_S) | (0x55 << TX_TRAIN_WD_S)); -} - -static int mt7530_mac_port_setup(struct gsw_mt753x *gsw) -{ - u32 hwstrap, p6ecr = 0, p5mcr, p6mcr, phyad; - - hwstrap = mt753x_reg_read(gsw, MHWSTRAP); - hwstrap &= ~(P6_INTF_DIS | P5_INTF_MODE_RGMII | P5_INTF_DIS_S); - hwstrap |= P5_INTF_SEL_GMAC5; - if (!gsw->port5_cfg.enabled) { - p5mcr = FORCE_MODE; - hwstrap |= P5_INTF_DIS_S; - } else { - p5mcr = (IPG_96BIT_WITH_SHORT_IPG << IPG_CFG_S) | - MAC_MODE | MAC_TX_EN | MAC_RX_EN | - BKOFF_EN | BACKPR_EN; - - if (gsw->port5_cfg.force_link) { - p5mcr |= FORCE_MODE | FORCE_LINK | FORCE_RX_FC | - FORCE_TX_FC; - p5mcr |= gsw->port5_cfg.speed << FORCE_SPD_S; - - if (gsw->port5_cfg.duplex) - p5mcr |= FORCE_DPX; - } - - switch (gsw->port5_cfg.phy_mode) { - case PHY_INTERFACE_MODE_MII: - case PHY_INTERFACE_MODE_GMII: - break; - case PHY_INTERFACE_MODE_RGMII: - hwstrap |= P5_INTF_MODE_RGMII; - break; - default: - dev_info(gsw->dev, "%s is not supported by port5\n", - phy_modes(gsw->port5_cfg.phy_mode)); - p5mcr = FORCE_MODE; - hwstrap |= P5_INTF_DIS_S; - } - - /* Port5 to PHY direct mode */ - if (of_property_read_u32(gsw->port5_cfg.np, "phy-address", - &phyad)) - goto parse_p6; - - if (phyad != 0 && phyad != 4) { - dev_info(gsw->dev, - "Only PHY 0/4 can be connected to Port 5\n"); - goto parse_p6; - } - - hwstrap &= ~P5_INTF_SEL_GMAC5; - if (phyad == 0) - hwstrap |= P5_PHY0_SEL; - else - hwstrap &= ~P5_PHY0_SEL; - } - -parse_p6: - if (!gsw->port6_cfg.enabled) { - p6mcr = FORCE_MODE; - hwstrap |= P6_INTF_DIS; - } else { - p6mcr = (IPG_96BIT_WITH_SHORT_IPG << IPG_CFG_S) | - MAC_MODE | MAC_TX_EN | MAC_RX_EN | - BKOFF_EN | BACKPR_EN; - - if (gsw->port6_cfg.force_link) { - p6mcr |= FORCE_MODE | FORCE_LINK | FORCE_RX_FC | - FORCE_TX_FC; - p6mcr |= gsw->port6_cfg.speed << FORCE_SPD_S; - - if (gsw->port6_cfg.duplex) - p6mcr |= FORCE_DPX; - } - - switch (gsw->port6_cfg.phy_mode) { - case PHY_INTERFACE_MODE_RGMII: - p6ecr = BIT(1); - break; - case PHY_INTERFACE_MODE_TRGMII: - /* set MT7530 central align */ - p6ecr = BIT(0); - break; - default: - dev_info(gsw->dev, "%s is not supported by port6\n", - phy_modes(gsw->port6_cfg.phy_mode)); - p6mcr = FORCE_MODE; - hwstrap |= P6_INTF_DIS; - } - } - - mt753x_reg_write(gsw, MHWSTRAP, hwstrap); - mt753x_reg_write(gsw, P6ECR, p6ecr); - - mt753x_reg_write(gsw, PMCR(5), p5mcr); - mt753x_reg_write(gsw, PMCR(6), p6mcr); - - return 0; -} - -static void mt7530_core_pll_setup(struct gsw_mt753x *gsw) -{ - u32 hwstrap; - - hwstrap = mt753x_reg_read(gsw, HWSTRAP); - - switch ((hwstrap & XTAL_FSEL_M) >> XTAL_FSEL_S) { - case XTAL_40MHZ: - /* Disable MT7530 core clock */ - mt7530_core_reg_write(gsw, TRGMII_GSW_CLK_CG, 0); - - /* disable MT7530 PLL */ - mt7530_core_reg_write(gsw, CORE_GSWPLL_GCR_1, - (2 << GSWPLL_POSTDIV_200M_S) | - (32 << GSWPLL_FBKDIV_200M_S)); - - /* For MT7530 core clock = 500Mhz */ - mt7530_core_reg_write(gsw, CORE_GSWPLL_GCR_2, - (1 << GSWPLL_POSTDIV_500M_S) | - (25 << GSWPLL_FBKDIV_500M_S)); - - /* Enable MT7530 PLL */ - mt7530_core_reg_write(gsw, CORE_GSWPLL_GCR_1, - (2 << GSWPLL_POSTDIV_200M_S) | - (32 << GSWPLL_FBKDIV_200M_S) | - GSWPLL_EN_PRE); - - usleep_range(20, 40); - - /* Enable MT7530 core clock */ - mt7530_core_reg_write(gsw, TRGMII_GSW_CLK_CG, GSWCK_EN); - break; - default: - /* TODO: PLL settings for 20/25MHz */ - break; - } - - hwstrap = mt753x_reg_read(gsw, HWSTRAP); - hwstrap |= CHG_TRAP; - if (gsw->direct_phy_access) - hwstrap &= ~C_MDIO_BPS_S; - else - hwstrap |= C_MDIO_BPS_S; - - mt753x_reg_write(gsw, MHWSTRAP, hwstrap); - - if (gsw->port6_cfg.enabled && - gsw->port6_cfg.phy_mode == PHY_INTERFACE_MODE_TRGMII) { - mt7530_trgmii_setting(gsw); - } else { - /* RGMII */ - mt7530_rgmii_setting(gsw); - } - - /* delay setting for 10/1000M */ - mt753x_reg_write(gsw, P5RGMIIRXCR, - CSR_RGMII_EDGE_ALIGN | - (2 << CSR_RGMII_RXC_0DEG_CFG_S)); - mt753x_reg_write(gsw, P5RGMIITXCR, 0x14 << CSR_RGMII_TXC_CFG_S); -} - -static int mt7530_sw_detect(struct gsw_mt753x *gsw, struct chip_rev *crev) -{ - u32 rev; - - rev = mt753x_reg_read(gsw, CHIP_REV); - - if (((rev & CHIP_NAME_M) >> CHIP_NAME_S) == MT7530) { - if (crev) { - crev->rev = rev & CHIP_REV_M; - crev->name = "MT7530"; - } - - return 0; - } - - return -ENODEV; -} - -static void mt7530_phy_setting(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - /* Disable EEE */ - gsw->mmd_write(gsw, i, PHY_DEV07, PHY_DEV07_REG_03C, 0); - - /* Enable HW auto downshift */ - gsw->mii_write(gsw, i, 0x1f, 0x1); - val = gsw->mii_read(gsw, i, PHY_EXT_REG_14); - val |= PHY_EN_DOWN_SHFIT; - gsw->mii_write(gsw, i, PHY_EXT_REG_14, val); - - /* Increase SlvDPSready time */ - gsw->mii_write(gsw, i, 0x1f, 0x52b5); - gsw->mii_write(gsw, i, PHY_TR_REG_10, 0xafae); - gsw->mii_write(gsw, i, PHY_TR_REG_12, 0x2f); - gsw->mii_write(gsw, i, PHY_TR_REG_10, 0x8fae); - - /* Increase post_update_timer */ - gsw->mii_write(gsw, i, 0x1f, 0x3); - gsw->mii_write(gsw, i, PHY_LPI_REG_11, 0x4b); - gsw->mii_write(gsw, i, 0x1f, 0); - - /* Adjust 100_mse_threshold */ - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_123, 0xffff); - - /* Disable mcc */ - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_A6, 0x300); - } -} - -static inline bool get_phy_access_mode(const struct device_node *np) -{ - return of_property_read_bool(np, "mt7530,direct-phy-access"); -} - -static int mt7530_sw_init(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - gsw->direct_phy_access = get_phy_access_mode(gsw->dev->of_node); - - /* Force MT7530 to use (in)direct PHY access */ - val = mt753x_reg_read(gsw, HWSTRAP); - val |= CHG_TRAP; - if (gsw->direct_phy_access) - val &= ~C_MDIO_BPS_S; - else - val |= C_MDIO_BPS_S; - mt753x_reg_write(gsw, MHWSTRAP, val); - - /* Read PHY address base from HWSTRAP */ - gsw->phy_base = (((val & SMI_ADDR_M) >> SMI_ADDR_S) << 3) + 8; - gsw->phy_base &= MT753X_SMI_ADDR_MASK; - - if (gsw->direct_phy_access) { - gsw->mii_read = mt7530_mii_read; - gsw->mii_write = mt7530_mii_write; - gsw->mmd_read = mt7530_mmd_read; - gsw->mmd_write = mt7530_mmd_write; - } else { - gsw->mii_read = mt753x_mii_read; - gsw->mii_write = mt753x_mii_write; - gsw->mmd_read = mt753x_mmd_ind_read; - gsw->mmd_write = mt753x_mmd_ind_write; - } - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - val = gsw->mii_read(gsw, i, MII_BMCR); - val |= BMCR_PDOWN; - gsw->mii_write(gsw, i, MII_BMCR, val); - } - - /* Force MAC link down before reset */ - mt753x_reg_write(gsw, PMCR(5), FORCE_MODE); - mt753x_reg_write(gsw, PMCR(6), FORCE_MODE); - - /* Switch soft reset */ - /* BUG: sw reset causes gsw int flooding */ - mt753x_reg_write(gsw, SYS_CTRL, SW_PHY_RST | SW_SYS_RST | SW_REG_RST); - usleep_range(10, 20); - - /* global mac control settings configuration */ - mt753x_reg_write(gsw, GMACCR, - LATE_COL_DROP | (15 << MTCC_LMT_S) | - (2 << MAX_RX_JUMBO_S) | RX_PKT_LEN_MAX_JUMBO); - - mt7530_core_pll_setup(gsw); - mt7530_mac_port_setup(gsw); - - return 0; -} - -static int mt7530_sw_post_init(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - mt7530_phy_setting(gsw); - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - val = gsw->mii_read(gsw, i, MII_BMCR); - val &= ~BMCR_PDOWN; - gsw->mii_write(gsw, i, MII_BMCR, val); - } - - return 0; -} - -struct mt753x_sw_id mt7530_id = { - .model = MT7530, - .detect = mt7530_sw_detect, - .init = mt7530_sw_init, - .post_init = mt7530_sw_post_init -}; diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.h deleted file mode 100644 index 40243d4e5ab..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7530.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - */ - -#ifndef _MT7530_H_ -#define _MT7530_H_ - -#include "mt753x.h" - -extern struct mt753x_sw_id mt7530_id; - -#endif /* _MT7530_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.c deleted file mode 100644 index 7ebf09c102b..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.c +++ /dev/null @@ -1,918 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Zhanguo Ju - */ - -#include -#include -#include - -#include "mt753x.h" -#include "mt753x_regs.h" - -/* MT7531 registers */ -#define SGMII_REG_BASE 0x5000 -#define SGMII_REG_PORT_BASE 0x1000 -#define SGMII_REG(p, r) (SGMII_REG_BASE + \ - (p) * SGMII_REG_PORT_BASE + (r)) -#define PCS_CONTROL_1(p) SGMII_REG(p, 0x00) -#define SGMII_MODE(p) SGMII_REG(p, 0x20) -#define QPHY_PWR_STATE_CTRL(p) SGMII_REG(p, 0xe8) -#define PHYA_CTRL_SIGNAL3(p) SGMII_REG(p, 0x128) - -/* Fields of PCS_CONTROL_1 */ -#define SGMII_LINK_STATUS BIT(18) -#define SGMII_AN_ENABLE BIT(12) -#define SGMII_AN_RESTART BIT(9) - -/* Fields of SGMII_MODE */ -#define SGMII_REMOTE_FAULT_DIS BIT(8) -#define SGMII_IF_MODE_FORCE_DUPLEX BIT(4) -#define SGMII_IF_MODE_FORCE_SPEED_S 0x2 -#define SGMII_IF_MODE_FORCE_SPEED_M 0x0c -#define SGMII_IF_MODE_ADVERT_AN BIT(1) - -/* Values of SGMII_IF_MODE_FORCE_SPEED */ -#define SGMII_IF_MODE_FORCE_SPEED_10 0 -#define SGMII_IF_MODE_FORCE_SPEED_100 1 -#define SGMII_IF_MODE_FORCE_SPEED_1000 2 - -/* Fields of QPHY_PWR_STATE_CTRL */ -#define PHYA_PWD BIT(4) - -/* Fields of PHYA_CTRL_SIGNAL3 */ -#define RG_TPHY_SPEED_S 2 -#define RG_TPHY_SPEED_M 0x0c - -/* Values of RG_TPHY_SPEED */ -#define RG_TPHY_SPEED_1000 0 -#define RG_TPHY_SPEED_2500 1 - -/* Unique fields of (M)HWSTRAP for MT7531 */ -#define XTAL_FSEL_S 7 -#define XTAL_FSEL_M BIT(7) -#define PHY_EN BIT(6) -#define CHG_STRAP BIT(8) - -/* Efuse Register Define */ -#define GBE_EFUSE 0x7bc8 -#define GBE_SEL_EFUSE_EN BIT(0) - -/* PHY ENABLE Register bitmap define */ -#define PHY_DEV1F 0x1f -#define PHY_DEV1F_REG_44 0x44 -#define PHY_DEV1F_REG_104 0x104 -#define PHY_DEV1F_REG_10A 0x10a -#define PHY_DEV1F_REG_10B 0x10b -#define PHY_DEV1F_REG_10C 0x10c -#define PHY_DEV1F_REG_10D 0x10d -#define PHY_DEV1F_REG_268 0x268 -#define PHY_DEV1F_REG_269 0x269 -#define PHY_DEV1F_REG_403 0x403 - -/* Fields of PHY_DEV1F_REG_403 */ -#define GBE_EFUSE_SETTING BIT(3) -#define PHY_EN_BYPASS_MODE BIT(4) -#define POWER_ON_OFF BIT(5) -#define PHY_PLL_M GENMASK(9, 8) -#define PHY_PLL_SEL(x) (((x) << 8) & GENMASK(9, 8)) - -/* PHY EEE Register bitmap of define */ -#define PHY_DEV07 0x07 -#define PHY_DEV07_REG_03C 0x3c - -/* PHY Extend Register 0x14 bitmap of define */ -#define PHY_EXT_REG_14 0x14 - -/* Fields of PHY_EXT_REG_14 */ -#define PHY_EN_DOWN_SHFIT BIT(4) - -/* PHY Extend Register 0x17 bitmap of define */ -#define PHY_EXT_REG_17 0x17 - -/* Fields of PHY_EXT_REG_17 */ -#define PHY_LINKDOWN_POWER_SAVING_EN BIT(4) - -/* PHY Token Ring Register 0x10 bitmap of define */ -#define PHY_TR_REG_10 0x10 - -/* PHY Token Ring Register 0x12 bitmap of define */ -#define PHY_TR_REG_12 0x12 - -/* PHY DEV 0x1e Register bitmap of define */ -#define PHY_DEV1E 0x1e -#define PHY_DEV1E_REG_13 0x13 -#define PHY_DEV1E_REG_14 0x14 -#define PHY_DEV1E_REG_41 0x41 -#define PHY_DEV1E_REG_A6 0xa6 -#define PHY_DEV1E_REG_0C6 0x0c6 -#define PHY_DEV1E_REG_0FE 0x0fe -#define PHY_DEV1E_REG_123 0x123 -#define PHY_DEV1E_REG_189 0x189 - -/* Fields of PHY_DEV1E_REG_0C6 */ -#define PHY_POWER_SAVING_S 8 -#define PHY_POWER_SAVING_M 0x300 -#define PHY_POWER_SAVING_TX 0x0 - -/* Fields of PHY_DEV1E_REG_189 */ -#define DESCRAMBLER_CLEAR_EN 0x1 - -/* Values of XTAL_FSEL_S */ -#define XTAL_40MHZ 0 -#define XTAL_25MHZ 1 - -#define PLLGP_EN 0x7820 -#define EN_COREPLL BIT(2) -#define SW_CLKSW BIT(1) -#define SW_PLLGP BIT(0) - -#define PLLGP_CR0 0x78a8 -#define RG_COREPLL_EN BIT(22) -#define RG_COREPLL_POSDIV_S 23 -#define RG_COREPLL_POSDIV_M 0x3800000 -#define RG_COREPLL_SDM_PCW_S 1 -#define RG_COREPLL_SDM_PCW_M 0x3ffffe -#define RG_COREPLL_SDM_PCW_CHG BIT(0) - -/* TOP Signals Status Register */ -#define TOP_SIG_SR 0x780c -#define PAD_DUAL_SGMII_EN BIT(1) - -/* RGMII and SGMII PLL clock */ -#define ANA_PLLGP_CR2 0x78b0 -#define ANA_PLLGP_CR5 0x78bc - -/* GPIO mode define */ -#define GPIO_MODE_REGS(x) (0x7c0c + (((x) / 8) * 4)) -#define GPIO_MODE_S 4 - -/* GPIO GROUP IOLB SMT0 Control */ -#define SMT0_IOLB 0x7f04 -#define SMT_IOLB_5_SMI_MDC_EN BIT(5) - -/* Unique fields of PMCR for MT7531 */ -#define FORCE_MODE_EEE1G BIT(25) -#define FORCE_MODE_EEE100 BIT(26) -#define FORCE_MODE_TX_FC BIT(27) -#define FORCE_MODE_RX_FC BIT(28) -#define FORCE_MODE_DPX BIT(29) -#define FORCE_MODE_SPD BIT(30) -#define FORCE_MODE_LNK BIT(31) -#define FORCE_MODE BIT(15) - -#define CHIP_REV 0x781C -#define CHIP_NAME_S 16 -#define CHIP_NAME_M 0xffff0000 -#define CHIP_REV_S 0 -#define CHIP_REV_M 0x0f -#define CHIP_REV_E1 0x0 - -#define CLKGEN_CTRL 0x7500 -#define CLK_SKEW_OUT_S 8 -#define CLK_SKEW_OUT_M 0x300 -#define CLK_SKEW_IN_S 6 -#define CLK_SKEW_IN_M 0xc0 -#define RXCLK_NO_DELAY BIT(5) -#define TXCLK_NO_REVERSE BIT(4) -#define GP_MODE_S 1 -#define GP_MODE_M 0x06 -#define GP_CLK_EN BIT(0) - -/* Values of GP_MODE */ -#define GP_MODE_RGMII 0 -#define GP_MODE_MII 1 -#define GP_MODE_REV_MII 2 - -/* Values of CLK_SKEW_IN */ -#define CLK_SKEW_IN_NO_CHANGE 0 -#define CLK_SKEW_IN_DELAY_100PPS 1 -#define CLK_SKEW_IN_DELAY_200PPS 2 -#define CLK_SKEW_IN_REVERSE 3 - -/* Values of CLK_SKEW_OUT */ -#define CLK_SKEW_OUT_NO_CHANGE 0 -#define CLK_SKEW_OUT_DELAY_100PPS 1 -#define CLK_SKEW_OUT_DELAY_200PPS 2 -#define CLK_SKEW_OUT_REVERSE 3 - -/* Proprietory Control Register of Internal Phy device 0x1e */ -#define RXADC_CONTROL_3 0xc2 -#define RXADC_LDO_CONTROL_2 0xd3 - -/* Proprietory Control Register of Internal Phy device 0x1f */ -#define TXVLD_DA_271 0x271 -#define TXVLD_DA_272 0x272 -#define TXVLD_DA_273 0x273 - -/* DSP Channel and NOD_ADDR*/ -#define DSP_CH 0x2 -#define DSP_NOD_ADDR 0xD - -/* gpio pinmux pins and functions define */ -static int gpio_int_pins[] = {0}; -static int gpio_int_funcs[] = {1}; -static int gpio_mdc_pins[] = {11, 20}; -static int gpio_mdc_funcs[] = {2, 2}; -static int gpio_mdio_pins[] = {12, 21}; -static int gpio_mdio_funcs[] = {2, 2}; - -static int mt7531_set_port_sgmii_force_mode(struct gsw_mt753x *gsw, u32 port, - struct mt753x_port_cfg *port_cfg) -{ - u32 speed, port_base, val; - ktime_t timeout; - u32 timeout_us; - - if (port < 5 || port >= MT753X_NUM_PORTS) { - dev_info(gsw->dev, "port %d is not a SGMII port\n", port); - return -EINVAL; - } - - port_base = port - 5; - - switch (port_cfg->speed) { - case MAC_SPD_1000: - speed = RG_TPHY_SPEED_1000; - break; - case MAC_SPD_2500: - speed = RG_TPHY_SPEED_2500; - break; - default: - dev_info(gsw->dev, "invalid SGMII speed idx %d for port %d\n", - port_cfg->speed, port); - - speed = RG_TPHY_SPEED_1000; - } - - /* Step 1: Speed select register setting */ - val = mt753x_reg_read(gsw, PHYA_CTRL_SIGNAL3(port_base)); - val &= ~RG_TPHY_SPEED_M; - val |= speed << RG_TPHY_SPEED_S; - mt753x_reg_write(gsw, PHYA_CTRL_SIGNAL3(port_base), val); - - /* Step 2 : Disable AN */ - val = mt753x_reg_read(gsw, PCS_CONTROL_1(port_base)); - val &= ~SGMII_AN_ENABLE; - mt753x_reg_write(gsw, PCS_CONTROL_1(port_base), val); - - /* Step 3: SGMII force mode setting */ - val = mt753x_reg_read(gsw, SGMII_MODE(port_base)); - val &= ~SGMII_IF_MODE_ADVERT_AN; - val &= ~SGMII_IF_MODE_FORCE_SPEED_M; - val |= SGMII_IF_MODE_FORCE_SPEED_1000 << SGMII_IF_MODE_FORCE_SPEED_S; - val |= SGMII_IF_MODE_FORCE_DUPLEX; - /* For sgmii force mode, 0 is full duplex and 1 is half duplex */ - if (port_cfg->duplex) - val &= ~SGMII_IF_MODE_FORCE_DUPLEX; - - mt753x_reg_write(gsw, SGMII_MODE(port_base), val); - - /* Step 4: XXX: Disable Link partner's AN and set force mode */ - - /* Step 5: XXX: Special setting for PHYA ==> reserved for flexible */ - - /* Step 6 : Release PHYA power down state */ - val = mt753x_reg_read(gsw, QPHY_PWR_STATE_CTRL(port_base)); - val &= ~PHYA_PWD; - mt753x_reg_write(gsw, QPHY_PWR_STATE_CTRL(port_base), val); - - /* Step 7 : Polling SGMII_LINK_STATUS */ - timeout_us = 2000000; - timeout = ktime_add_us(ktime_get(), timeout_us); - while (1) { - val = mt753x_reg_read(gsw, PCS_CONTROL_1(port_base)); - val &= SGMII_LINK_STATUS; - - if (val) - break; - - if (ktime_compare(ktime_get(), timeout) > 0) - return -ETIMEDOUT; - } - - return 0; -} - -static int mt7531_set_port_sgmii_an_mode(struct gsw_mt753x *gsw, u32 port, - struct mt753x_port_cfg *port_cfg) -{ - u32 speed, port_base, val; - ktime_t timeout; - u32 timeout_us; - - if (port < 5 || port >= MT753X_NUM_PORTS) { - dev_info(gsw->dev, "port %d is not a SGMII port\n", port); - return -EINVAL; - } - - port_base = port - 5; - - switch (port_cfg->speed) { - case MAC_SPD_1000: - speed = RG_TPHY_SPEED_1000; - break; - case MAC_SPD_2500: - speed = RG_TPHY_SPEED_2500; - break; - default: - dev_info(gsw->dev, "invalid SGMII speed idx %d for port %d\n", - port_cfg->speed, port); - - speed = RG_TPHY_SPEED_1000; - } - - /* Step 1: Speed select register setting */ - val = mt753x_reg_read(gsw, PHYA_CTRL_SIGNAL3(port_base)); - val &= ~RG_TPHY_SPEED_M; - val |= speed << RG_TPHY_SPEED_S; - mt753x_reg_write(gsw, PHYA_CTRL_SIGNAL3(port_base), val); - - /* Step 2: Remote fault disable */ - val = mt753x_reg_read(gsw, SGMII_MODE(port)); - val |= SGMII_REMOTE_FAULT_DIS; - mt753x_reg_write(gsw, SGMII_MODE(port), val); - - /* Step 3: Setting Link partner's AN enable = 1 */ - - /* Step 4: Setting Link partner's device ability for speed/duplex */ - - /* Step 5: AN re-start */ - val = mt753x_reg_read(gsw, PCS_CONTROL_1(port)); - val |= SGMII_AN_RESTART; - mt753x_reg_write(gsw, PCS_CONTROL_1(port), val); - - /* Step 6: Special setting for PHYA ==> reserved for flexible */ - - /* Step 7 : Polling SGMII_LINK_STATUS */ - timeout_us = 2000000; - timeout = ktime_add_us(ktime_get(), timeout_us); - while (1) { - val = mt753x_reg_read(gsw, PCS_CONTROL_1(port_base)); - val &= SGMII_LINK_STATUS; - - if (val) - break; - - if (ktime_compare(ktime_get(), timeout) > 0) - return -ETIMEDOUT; - } - - return 0; -} - -static int mt7531_set_port_rgmii(struct gsw_mt753x *gsw, u32 port) -{ - u32 val; - - if (port != 5) { - dev_info(gsw->dev, "RGMII mode is not available for port %d\n", - port); - return -EINVAL; - } - - val = mt753x_reg_read(gsw, CLKGEN_CTRL); - val |= GP_CLK_EN; - val &= ~GP_MODE_M; - val |= GP_MODE_RGMII << GP_MODE_S; - val |= TXCLK_NO_REVERSE; - val |= RXCLK_NO_DELAY; - val &= ~CLK_SKEW_IN_M; - val |= CLK_SKEW_IN_NO_CHANGE << CLK_SKEW_IN_S; - val &= ~CLK_SKEW_OUT_M; - val |= CLK_SKEW_OUT_NO_CHANGE << CLK_SKEW_OUT_S; - mt753x_reg_write(gsw, CLKGEN_CTRL, val); - - return 0; -} - -static int mt7531_mac_port_setup(struct gsw_mt753x *gsw, u32 port, - struct mt753x_port_cfg *port_cfg) -{ - u32 pmcr; - u32 speed; - - if (port < 5 || port >= MT753X_NUM_PORTS) { - dev_info(gsw->dev, "port %d is not a MAC port\n", port); - return -EINVAL; - } - - if (port_cfg->enabled) { - pmcr = (IPG_96BIT_WITH_SHORT_IPG << IPG_CFG_S) | - MAC_MODE | MAC_TX_EN | MAC_RX_EN | - BKOFF_EN | BACKPR_EN; - - if (port_cfg->force_link) { - /* PMCR's speed field 0x11 is reserved, - * sw should set 0x10 - */ - speed = port_cfg->speed; - if (port_cfg->speed == MAC_SPD_2500) - speed = MAC_SPD_1000; - - pmcr |= FORCE_MODE_LNK | FORCE_LINK | - FORCE_MODE_SPD | FORCE_MODE_DPX | - FORCE_MODE_RX_FC | FORCE_MODE_TX_FC | - FORCE_RX_FC | FORCE_TX_FC | - (speed << FORCE_SPD_S); - - if (port_cfg->duplex) - pmcr |= FORCE_DPX; - } - } else { - pmcr = FORCE_MODE_LNK; - } - - switch (port_cfg->phy_mode) { - case PHY_INTERFACE_MODE_RGMII: - mt7531_set_port_rgmii(gsw, port); - break; - case PHY_INTERFACE_MODE_SGMII: - if (port_cfg->force_link) - mt7531_set_port_sgmii_force_mode(gsw, port, port_cfg); - else - mt7531_set_port_sgmii_an_mode(gsw, port, port_cfg); - break; - default: - if (port_cfg->enabled) - dev_info(gsw->dev, "%s is not supported by port %d\n", - phy_modes(port_cfg->phy_mode), port); - - pmcr = FORCE_MODE_LNK; - } - - mt753x_reg_write(gsw, PMCR(port), pmcr); - - return 0; -} - -static void mt7531_core_pll_setup(struct gsw_mt753x *gsw) -{ - u32 hwstrap; - u32 val; - - val = mt753x_reg_read(gsw, TOP_SIG_SR); - if (val & PAD_DUAL_SGMII_EN) - return; - - hwstrap = mt753x_reg_read(gsw, HWSTRAP); - - switch ((hwstrap & XTAL_FSEL_M) >> XTAL_FSEL_S) { - case XTAL_25MHZ: - /* Step 1 : Disable MT7531 COREPLL */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val &= ~EN_COREPLL; - mt753x_reg_write(gsw, PLLGP_EN, val); - - /* Step 2: switch to XTAL output */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= SW_CLKSW; - mt753x_reg_write(gsw, PLLGP_EN, val); - - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_EN; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Step 3: disable PLLGP and enable program PLLGP */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= SW_PLLGP; - mt753x_reg_write(gsw, PLLGP_EN, val); - - /* Step 4: program COREPLL output frequency to 500MHz */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_POSDIV_M; - val |= 2 << RG_COREPLL_POSDIV_S; - mt753x_reg_write(gsw, PLLGP_CR0, val); - usleep_range(25, 35); - - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_SDM_PCW_M; - val |= 0x140000 << RG_COREPLL_SDM_PCW_S; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Set feedback divide ratio update signal to high */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val |= RG_COREPLL_SDM_PCW_CHG; - mt753x_reg_write(gsw, PLLGP_CR0, val); - /* Wait for at least 16 XTAL clocks */ - usleep_range(10, 20); - - /* Step 5: set feedback divide ratio update signal to low */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_SDM_PCW_CHG; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Enable 325M clock for SGMII */ - mt753x_reg_write(gsw, ANA_PLLGP_CR5, 0xad0000); - - /* Enable 250SSC clock for RGMII */ - mt753x_reg_write(gsw, ANA_PLLGP_CR2, 0x4f40000); - - /* Step 6: Enable MT7531 PLL */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val |= RG_COREPLL_EN; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= EN_COREPLL; - mt753x_reg_write(gsw, PLLGP_EN, val); - usleep_range(25, 35); - - break; - case XTAL_40MHZ: - /* Step 1 : Disable MT7531 COREPLL */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val &= ~EN_COREPLL; - mt753x_reg_write(gsw, PLLGP_EN, val); - - /* Step 2: switch to XTAL output */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= SW_CLKSW; - mt753x_reg_write(gsw, PLLGP_EN, val); - - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_EN; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Step 3: disable PLLGP and enable program PLLGP */ - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= SW_PLLGP; - mt753x_reg_write(gsw, PLLGP_EN, val); - - /* Step 4: program COREPLL output frequency to 500MHz */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_POSDIV_M; - val |= 2 << RG_COREPLL_POSDIV_S; - mt753x_reg_write(gsw, PLLGP_CR0, val); - usleep_range(25, 35); - - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_SDM_PCW_M; - val |= 0x190000 << RG_COREPLL_SDM_PCW_S; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Set feedback divide ratio update signal to high */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val |= RG_COREPLL_SDM_PCW_CHG; - mt753x_reg_write(gsw, PLLGP_CR0, val); - /* Wait for at least 16 XTAL clocks */ - usleep_range(10, 20); - - /* Step 5: set feedback divide ratio update signal to low */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val &= ~RG_COREPLL_SDM_PCW_CHG; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - /* Enable 325M clock for SGMII */ - mt753x_reg_write(gsw, ANA_PLLGP_CR5, 0xad0000); - - /* Enable 250SSC clock for RGMII */ - mt753x_reg_write(gsw, ANA_PLLGP_CR2, 0x4f40000); - - /* Step 6: Enable MT7531 PLL */ - val = mt753x_reg_read(gsw, PLLGP_CR0); - val |= RG_COREPLL_EN; - mt753x_reg_write(gsw, PLLGP_CR0, val); - - val = mt753x_reg_read(gsw, PLLGP_EN); - val |= EN_COREPLL; - mt753x_reg_write(gsw, PLLGP_EN, val); - usleep_range(25, 35); - break; - } -} - -static int mt7531_internal_phy_calibration(struct gsw_mt753x *gsw) -{ - return 0; -} - -static int mt7531_sw_detect(struct gsw_mt753x *gsw, struct chip_rev *crev) -{ - u32 rev, topsig; - - rev = mt753x_reg_read(gsw, CHIP_REV); - - if (((rev & CHIP_NAME_M) >> CHIP_NAME_S) == MT7531) { - if (crev) { - topsig = mt753x_reg_read(gsw, TOP_SIG_SR); - - crev->rev = rev & CHIP_REV_M; - crev->name = topsig & PAD_DUAL_SGMII_EN ? - "MT7531AE" : "MT7531BE"; - } - - return 0; - } - - return -ENODEV; -} - -static void pinmux_set_mux_7531(struct gsw_mt753x *gsw, u32 pin, u32 mode) -{ - u32 val; - - val = mt753x_reg_read(gsw, GPIO_MODE_REGS(pin)); - val &= ~(0xf << (pin & 7) * GPIO_MODE_S); - val |= mode << (pin & 7) * GPIO_MODE_S; - mt753x_reg_write(gsw, GPIO_MODE_REGS(pin), val); -} - -static int mt7531_set_gpio_pinmux(struct gsw_mt753x *gsw) -{ - u32 group = 0; - struct device_node *np = gsw->dev->of_node; - - /* Set GPIO 0 interrupt mode */ - pinmux_set_mux_7531(gsw, gpio_int_pins[0], gpio_int_funcs[0]); - - of_property_read_u32(np, "mediatek,mdio_master_pinmux", &group); - - /* group = 0: do nothing, 1: 1st group (AE), 2: 2nd group (BE) */ - if (group > 0 && group <= 2) { - group--; - pinmux_set_mux_7531(gsw, gpio_mdc_pins[group], - gpio_mdc_funcs[group]); - pinmux_set_mux_7531(gsw, gpio_mdio_pins[group], - gpio_mdio_funcs[group]); - } - - return 0; -} - -static void mt7531_phy_pll_setup(struct gsw_mt753x *gsw) -{ - u32 hwstrap; - u32 val; - - hwstrap = mt753x_reg_read(gsw, HWSTRAP); - - switch ((hwstrap & XTAL_FSEL_M) >> XTAL_FSEL_S) { - case XTAL_25MHZ: - /* disable pll auto calibration */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_104, 0x608); - - /* change pll sel */ - val = gsw->mmd_read(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_403); - val &= ~(PHY_PLL_M); - val |= PHY_PLL_SEL(3); - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_403, val); - - /* set divider ratio */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_10A, 0x1009); - - /* set divider ratio */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_10B, 0x7c6); - - /* capacitance and resistance adjustment */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_10C, 0xa8be); - - break; - case XTAL_40MHZ: - /* disable pll auto calibration */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_104, 0x608); - - /* change pll sel */ - val = gsw->mmd_read(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_403); - val &= ~(PHY_PLL_M); - val |= PHY_PLL_SEL(3); - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_403, val); - - /* set divider ratio */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_10A, 0x1018); - - /* set divider ratio */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_10B, 0xc676); - - /* capacitance and resistance adjustment */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_10C, 0xd8be); - break; - } - - /* power down pll. additional delay is not required via mdio access */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_10D, 0x10); - - /* power up pll */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_10D, 0x14); -} - -static void mt7531_phy_setting(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - /* Adjust DAC TX Delay */ - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_44, 0xc0); - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - /* Disable EEE */ - gsw->mmd_write(gsw, i, PHY_DEV07, PHY_DEV07_REG_03C, 0); - - /* Enable HW auto downshift */ - gsw->mii_write(gsw, i, 0x1f, 0x1); - val = gsw->mii_read(gsw, i, PHY_EXT_REG_14); - val |= PHY_EN_DOWN_SHFIT; - gsw->mii_write(gsw, i, PHY_EXT_REG_14, val); - - /* Increase SlvDPSready time */ - gsw->mii_write(gsw, i, 0x1f, 0x52b5); - gsw->mii_write(gsw, i, PHY_TR_REG_10, 0xafae); - gsw->mii_write(gsw, i, PHY_TR_REG_12, 0x2f); - gsw->mii_write(gsw, i, PHY_TR_REG_10, 0x8fae); - gsw->mii_write(gsw, i, 0x1f, 0); - - /* Adjust 100_mse_threshold */ - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_123, 0xffff); - - /* Disable mcc */ - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_A6, 0x300); - - /* PHY link down power saving enable */ - val = gsw->mii_read(gsw, i, PHY_EXT_REG_17); - val |= PHY_LINKDOWN_POWER_SAVING_EN; - gsw->mii_write(gsw, i, PHY_EXT_REG_17, val); - - val = gsw->mmd_read(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_0C6); - val &= ~PHY_POWER_SAVING_M; - val |= PHY_POWER_SAVING_TX << PHY_POWER_SAVING_S; - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_0C6, val); - - /* Set TX Pair delay selection */ - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_13, 0x404); - gsw->mmd_write(gsw, i, PHY_DEV1E, PHY_DEV1E_REG_14, 0x404); - } -} - -static void mt7531_adjust_line_driving(struct gsw_mt753x *gsw, u32 port) -{ - /* For ADC timing margin window for LDO calibration */ - gsw->mmd_write(gsw, port, PHY_DEV1E, RXADC_LDO_CONTROL_2, 0x2222); - - /* Adjust AD sample timing */ - gsw->mmd_write(gsw, port, PHY_DEV1E, RXADC_CONTROL_3, 0x4444); - - /* Adjust Line driver current for different mode */ - gsw->mmd_write(gsw, port, PHY_DEV1F, TXVLD_DA_271, 0x2ca5); - - /* Adjust Line driver current for different mode */ - gsw->mmd_write(gsw, port, PHY_DEV1F, TXVLD_DA_272, 0xc6b); - - /* Adjust Line driver amplitude for 10BT */ - gsw->mmd_write(gsw, port, PHY_DEV1F, TXVLD_DA_273, 0x3000); - - /* Adjust RX Echo path filter */ - gsw->mmd_write(gsw, port, PHY_DEV1E, PHY_DEV1E_REG_0FE, 0x2); - - /* Adjust RX HVGA bias current */ - gsw->mmd_write(gsw, port, PHY_DEV1E, PHY_DEV1E_REG_41, 0x3333); - - /* Adjust TX class AB driver 1 */ - gsw->mmd_write(gsw, port, PHY_DEV1F, PHY_DEV1F_REG_268, 0x388); - - /* Adjust TX class AB driver 2 */ - gsw->mmd_write(gsw, port, PHY_DEV1F, PHY_DEV1F_REG_269, 0x4448); -} - -static void mt7531_eee_setting(struct gsw_mt753x *gsw, u32 port) -{ - u32 tr_reg_control; - u32 val; - - /* Disable generate signal to clear the scramble_lock when lpi mode */ - val = gsw->mmd_read(gsw, port, PHY_DEV1E, PHY_DEV1E_REG_189); - val &= ~DESCRAMBLER_CLEAR_EN; - gsw->mmd_write(gsw, port, PHY_DEV1E, PHY_DEV1E_REG_189, val); - - /* roll back CR*/ - gsw->mii_write(gsw, port, 0x1f, 0x52b5); - gsw->mmd_write(gsw, port, 0x1e, 0x2d1, 0); - tr_reg_control = (1 << 15) | (0 << 13) | (DSP_CH << 11) | - (DSP_NOD_ADDR << 7) | (0x8 << 1); - gsw->mii_write(gsw, port, 17, 0x1b); - gsw->mii_write(gsw, port, 18, 0); - gsw->mii_write(gsw, port, 16, tr_reg_control); - tr_reg_control = (1 << 15) | (0 << 13) | (DSP_CH << 11) | - (DSP_NOD_ADDR << 7) | (0xf << 1); - gsw->mii_write(gsw, port, 17, 0); - gsw->mii_write(gsw, port, 18, 0); - gsw->mii_write(gsw, port, 16, tr_reg_control); - - tr_reg_control = (1 << 15) | (0 << 13) | (DSP_CH << 11) | - (DSP_NOD_ADDR << 7) | (0x10 << 1); - gsw->mii_write(gsw, port, 17, 0x500); - gsw->mii_write(gsw, port, 18, 0); - gsw->mii_write(gsw, port, 16, tr_reg_control); - gsw->mii_write(gsw, port, 0x1f, 0); -} - -static int mt7531_sw_init(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - gsw->phy_base = (gsw->smi_addr + 1) & MT753X_SMI_ADDR_MASK; - - gsw->mii_read = mt753x_mii_read; - gsw->mii_write = mt753x_mii_write; - gsw->mmd_read = mt753x_mmd_read; - gsw->mmd_write = mt753x_mmd_write; - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - val = gsw->mii_read(gsw, i, MII_BMCR); - val |= BMCR_ISOLATE; - gsw->mii_write(gsw, i, MII_BMCR, val); - } - - /* Force MAC link down before reset */ - mt753x_reg_write(gsw, PMCR(5), FORCE_MODE_LNK); - mt753x_reg_write(gsw, PMCR(6), FORCE_MODE_LNK); - - /* Switch soft reset */ - mt753x_reg_write(gsw, SYS_CTRL, SW_SYS_RST | SW_REG_RST); - usleep_range(10, 20); - - /* Enable MDC input Schmitt Trigger */ - val = mt753x_reg_read(gsw, SMT0_IOLB); - mt753x_reg_write(gsw, SMT0_IOLB, val | SMT_IOLB_5_SMI_MDC_EN); - - /* Set 7531 gpio pinmux */ - mt7531_set_gpio_pinmux(gsw); - - /* Global mac control settings */ - mt753x_reg_write(gsw, GMACCR, - (15 << MTCC_LMT_S) | (11 << MAX_RX_JUMBO_S) | - RX_PKT_LEN_MAX_JUMBO); - - mt7531_core_pll_setup(gsw); - mt7531_mac_port_setup(gsw, 5, &gsw->port5_cfg); - mt7531_mac_port_setup(gsw, 6, &gsw->port6_cfg); - - return 0; -} - -static int mt7531_sw_post_init(struct gsw_mt753x *gsw) -{ - int i; - u32 val; - - mt7531_phy_pll_setup(gsw); - - /* Internal PHYs are disabled by default. SW should enable them. - * Note that this may already be enabled in bootloader stage. - */ - val = gsw->mmd_read(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_403); - val |= PHY_EN_BYPASS_MODE; - val &= ~POWER_ON_OFF; - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_403, val); - - mt7531_phy_setting(gsw); - - for (i = 0; i < MT753X_NUM_PHYS; i++) { - val = gsw->mii_read(gsw, i, MII_BMCR); - val &= ~BMCR_ISOLATE; - gsw->mii_write(gsw, i, MII_BMCR, val); - } - - for (i = 0; i < MT753X_NUM_PHYS; i++) - mt7531_adjust_line_driving(gsw, i); - - for (i = 0; i < MT753X_NUM_PHYS; i++) - mt7531_eee_setting(gsw, i); - - val = mt753x_reg_read(gsw, CHIP_REV); - val &= CHIP_REV_M; - if (val == CHIP_REV_E1) { - mt7531_internal_phy_calibration(gsw); - } else { - val = mt753x_reg_read(gsw, GBE_EFUSE); - if (val & GBE_SEL_EFUSE_EN) { - val = gsw->mmd_read(gsw, 0, PHY_DEV1F, - PHY_DEV1F_REG_403); - val &= ~GBE_EFUSE_SETTING; - gsw->mmd_write(gsw, 0, PHY_DEV1F, PHY_DEV1F_REG_403, - val); - } else { - mt7531_internal_phy_calibration(gsw); - } - } - - return 0; -} - -struct mt753x_sw_id mt7531_id = { - .model = MT7531, - .detect = mt7531_sw_detect, - .init = mt7531_sw_init, - .post_init = mt7531_sw_post_init -}; - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Zhanguo Ju "); -MODULE_DESCRIPTION("Driver for MediaTek MT753x Gigabit Switch"); diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.h deleted file mode 100644 index 52c8a49fd30..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt7531.h +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - */ - -#ifndef _MT7531_H_ -#define _MT7531_H_ - -#include "mt753x.h" - -extern struct mt753x_sw_id mt7531_id; - -#endif /* _MT7531_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x.h deleted file mode 100644 index 27cd6f4f1e3..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x.h +++ /dev/null @@ -1,213 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#ifndef _MT753X_H_ -#define _MT753X_H_ - -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_SWCONFIG -#include -#endif - -#include "mt753x_vlan.h" - -#define MT753X_DFL_CPU_PORT 6 -#define MT753X_NUM_PHYS 5 - -#define MT753X_DFL_SMI_ADDR 0x1f -#define MT753X_SMI_ADDR_MASK 0x1f - -struct gsw_mt753x; - -enum mt753x_model { - MT7530 = 0x7530, - MT7531 = 0x7531 -}; - -struct mt753x_port_cfg { - struct device_node *np; - phy_interface_t phy_mode; - u32 enabled: 1; - u32 force_link: 1; - u32 speed: 2; - u32 duplex: 1; -}; - -struct mt753x_phy { - struct gsw_mt753x *gsw; - struct net_device netdev; - struct phy_device *phydev; -}; - -struct gsw_mt753x { - u32 id; - - struct device *dev; - struct mii_bus *host_bus; - struct mii_bus *gphy_bus; - struct mutex mii_lock; /* MII access lock */ - u32 smi_addr; - u32 phy_base; - int direct_phy_access; - - enum mt753x_model model; - const char *name; - - struct mt753x_port_cfg port5_cfg; - struct mt753x_port_cfg port6_cfg; - - int phy_status_poll; - struct mt753x_phy phys[MT753X_NUM_PHYS]; - - int phy_link_sts; - - int irq; - int reset_pin; - struct work_struct irq_worker; - -#ifdef CONFIG_SWCONFIG - struct switch_dev swdev; - u32 cpu_port; -#endif - - int global_vlan_enable; - struct mt753x_vlan_entry vlan_entries[MT753X_NUM_VLANS]; - struct mt753x_port_entry port_entries[MT753X_NUM_PORTS]; - - int (*mii_read)(struct gsw_mt753x *gsw, int phy, int reg); - void (*mii_write)(struct gsw_mt753x *gsw, int phy, int reg, u16 val); - - int (*mmd_read)(struct gsw_mt753x *gsw, int addr, int devad, u16 reg); - void (*mmd_write)(struct gsw_mt753x *gsw, int addr, int devad, u16 reg, - u16 val); - - struct list_head list; -}; - -struct chip_rev { - const char *name; - u32 rev; -}; - -struct mt753x_sw_id { - enum mt753x_model model; - int (*detect)(struct gsw_mt753x *gsw, struct chip_rev *crev); - int (*init)(struct gsw_mt753x *gsw); - int (*post_init)(struct gsw_mt753x *gsw); -}; - -extern struct list_head mt753x_devs; - -struct gsw_mt753x *mt753x_get_gsw(u32 id); -struct gsw_mt753x *mt753x_get_first_gsw(void); -void mt753x_put_gsw(void); -void mt753x_lock_gsw(void); - -u32 mt753x_reg_read(struct gsw_mt753x *gsw, u32 reg); -void mt753x_reg_write(struct gsw_mt753x *gsw, u32 reg, u32 val); - -int mt753x_mii_read(struct gsw_mt753x *gsw, int phy, int reg); -void mt753x_mii_write(struct gsw_mt753x *gsw, int phy, int reg, u16 val); - -int mt753x_mmd_read(struct gsw_mt753x *gsw, int addr, int devad, u16 reg); -void mt753x_mmd_write(struct gsw_mt753x *gsw, int addr, int devad, u16 reg, - u16 val); - -int mt753x_mmd_ind_read(struct gsw_mt753x *gsw, int addr, int devad, u16 reg); -void mt753x_mmd_ind_write(struct gsw_mt753x *gsw, int addr, int devad, u16 reg, - u16 val); - -void mt753x_irq_worker(struct work_struct *work); -void mt753x_irq_enable(struct gsw_mt753x *gsw); - -/* MDIO Indirect Access Registers */ -#define MII_MMD_ACC_CTL_REG 0x0d -#define MMD_CMD_S 14 -#define MMD_CMD_M 0xc000 -#define MMD_DEVAD_S 0 -#define MMD_DEVAD_M 0x1f - -/* MMD_CMD: MMD commands */ -#define MMD_ADDR 0 -#define MMD_DATA 1 - -#define MII_MMD_ADDR_DATA_REG 0x0e - -/* Procedure of MT753x Internal Register Access - * - * 1. Internal Register Address - * - * The MT753x has a 16-bit register address and each register is 32-bit. - * This means the lowest two bits are not used as the register address is - * 4-byte aligned. - * - * Rest of the valid bits are divided into two parts: - * Bit 15..6 is the Page address - * Bit 5..2 is the low address - * - * ------------------------------------------------------------------- - * | 15 14 13 12 11 10 9 8 7 6 | 5 4 3 2 | 1 0 | - * |----------------------------------------|---------------|--------| - * | Page Address | Address | Unused | - * ------------------------------------------------------------------- - * - * 2. MDIO access timing - * - * The MT753x uses the following MDIO timing for a single register read - * - * Phase 1: Write Page Address - * ------------------------------------------------------------------- - * | ST | OP | PHY_ADDR | TYPE | RSVD | TA | RSVD | PAGE_ADDR | - * ------------------------------------------------------------------- - * | 01 | 01 | 11111 | 1 | 1111 | xx | 00000 | REG_ADDR[15..6] | - * ------------------------------------------------------------------- - * - * Phase 2: Write low Address & Read low word - * ------------------------------------------------------------------- - * | ST | OP | PHY_ADDR | TYPE | LOW_ADDR | TA | DATA | - * ------------------------------------------------------------------- - * | 01 | 10 | 11111 | 0 | REG_ADDR[5..2] | xx | DATA[15..0] | - * ------------------------------------------------------------------- - * - * Phase 3: Read high word - * ------------------------------------------------------------------- - * | ST | OP | PHY_ADDR | TYPE | RSVD | TA | DATA | - * ------------------------------------------------------------------- - * | 01 | 10 | 11111 | 1 | 0000 | xx | DATA[31..16] | - * ------------------------------------------------------------------- - * - * The MT753x uses the following MDIO timing for a single register write - * - * Phase 1: Write Page Address (The same as read) - * - * Phase 2: Write low Address and low word - * ------------------------------------------------------------------- - * | ST | OP | PHY_ADDR | TYPE | LOW_ADDR | TA | DATA | - * ------------------------------------------------------------------- - * | 01 | 01 | 11111 | 0 | REG_ADDR[5..2] | xx | DATA[15..0] | - * ------------------------------------------------------------------- - * - * Phase 3: write high word - * ------------------------------------------------------------------- - * | ST | OP | PHY_ADDR | TYPE | RSVD | TA | DATA | - * ------------------------------------------------------------------- - * | 01 | 01 | 11111 | 1 | 0000 | xx | DATA[31..16] | - * ------------------------------------------------------------------- - * - */ - -/* Internal Register Address fields */ -#define MT753X_REG_PAGE_ADDR_S 6 -#define MT753X_REG_PAGE_ADDR_M 0xffc0 -#define MT753X_REG_ADDR_S 2 -#define MT753X_REG_ADDR_M 0x3c -#endif /* _MT753X_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_common.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_common.c deleted file mode 100644 index 4015ddf1258..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_common.c +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#include -#include - -#include "mt753x.h" -#include "mt753x_regs.h" - -void mt753x_irq_enable(struct gsw_mt753x *gsw) -{ - u32 val; - int i; - - /* Record initial PHY link status */ - for (i = 0; i < MT753X_NUM_PHYS; i++) { - val = gsw->mii_read(gsw, i, MII_BMSR); - if (val & BMSR_LSTATUS) - gsw->phy_link_sts |= BIT(i); - } - - val = BIT(MT753X_NUM_PHYS) - 1; - - mt753x_reg_write(gsw, SYS_INT_EN, val); -} - -static void display_port_link_status(struct gsw_mt753x *gsw, u32 port) -{ - u32 pmsr, speed_bits; - const char *speed; - - pmsr = mt753x_reg_read(gsw, PMSR(port)); - - speed_bits = (pmsr & MAC_SPD_STS_M) >> MAC_SPD_STS_S; - - switch (speed_bits) { - case MAC_SPD_10: - speed = "10Mbps"; - break; - case MAC_SPD_100: - speed = "100Mbps"; - break; - case MAC_SPD_1000: - speed = "1Gbps"; - break; - case MAC_SPD_2500: - speed = "2.5Gbps"; - break; - } - - if (pmsr & MAC_LNK_STS) { - dev_info(gsw->dev, "Port %d Link is Up - %s/%s\n", - port, speed, (pmsr & MAC_DPX_STS) ? "Full" : "Half"); - } else { - dev_info(gsw->dev, "Port %d Link is Down\n", port); - } -} - -void mt753x_irq_worker(struct work_struct *work) -{ - struct gsw_mt753x *gsw; - u32 sts, physts, laststs; - int i; - - gsw = container_of(work, struct gsw_mt753x, irq_worker); - - sts = mt753x_reg_read(gsw, SYS_INT_STS); - - /* Check for changed PHY link status */ - for (i = 0; i < MT753X_NUM_PHYS; i++) { - if (!(sts & PHY_LC_INT(i))) - continue; - - laststs = gsw->phy_link_sts & BIT(i); - physts = !!(gsw->mii_read(gsw, i, MII_BMSR) & BMSR_LSTATUS); - physts <<= i; - - if (physts ^ laststs) { - gsw->phy_link_sts ^= BIT(i); - display_port_link_status(gsw, i); - } - } - - mt753x_reg_write(gsw, SYS_INT_STS, sts); - - enable_irq(gsw->irq); -} diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c deleted file mode 100644 index 3e2e6d68aed..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_mdio.c +++ /dev/null @@ -1,597 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mt753x.h" -#include "mt753x_swconfig.h" -#include "mt753x_regs.h" -#include "mt753x_nl.h" -#include "mt7530.h" -#include "mt7531.h" - -static u32 mt753x_id; -struct list_head mt753x_devs; -static DEFINE_MUTEX(mt753x_devs_lock); - -static struct mt753x_sw_id *mt753x_sw_ids[] = { - &mt7530_id, - &mt7531_id, -}; - -u32 mt753x_reg_read(struct gsw_mt753x *gsw, u32 reg) -{ - u32 high, low; - - mutex_lock(&gsw->host_bus->mdio_lock); - - gsw->host_bus->write(gsw->host_bus, gsw->smi_addr, 0x1f, - (reg & MT753X_REG_PAGE_ADDR_M) >> MT753X_REG_PAGE_ADDR_S); - - low = gsw->host_bus->read(gsw->host_bus, gsw->smi_addr, - (reg & MT753X_REG_ADDR_M) >> MT753X_REG_ADDR_S); - - high = gsw->host_bus->read(gsw->host_bus, gsw->smi_addr, 0x10); - - mutex_unlock(&gsw->host_bus->mdio_lock); - - return (high << 16) | (low & 0xffff); -} - -void mt753x_reg_write(struct gsw_mt753x *gsw, u32 reg, u32 val) -{ - mutex_lock(&gsw->host_bus->mdio_lock); - - gsw->host_bus->write(gsw->host_bus, gsw->smi_addr, 0x1f, - (reg & MT753X_REG_PAGE_ADDR_M) >> MT753X_REG_PAGE_ADDR_S); - - gsw->host_bus->write(gsw->host_bus, gsw->smi_addr, - (reg & MT753X_REG_ADDR_M) >> MT753X_REG_ADDR_S, val & 0xffff); - - gsw->host_bus->write(gsw->host_bus, gsw->smi_addr, 0x10, val >> 16); - - mutex_unlock(&gsw->host_bus->mdio_lock); -} - -/* Indirect MDIO clause 22/45 access */ -static int mt753x_mii_rw(struct gsw_mt753x *gsw, int phy, int reg, u16 data, - u32 cmd, u32 st) -{ - ktime_t timeout; - u32 val, timeout_us; - int ret = 0; - - timeout_us = 100000; - timeout = ktime_add_us(ktime_get(), timeout_us); - while (1) { - val = mt753x_reg_read(gsw, PHY_IAC); - - if ((val & PHY_ACS_ST) == 0) - break; - - if (ktime_compare(ktime_get(), timeout) > 0) - return -ETIMEDOUT; - } - - val = (st << MDIO_ST_S) | - ((cmd << MDIO_CMD_S) & MDIO_CMD_M) | - ((phy << MDIO_PHY_ADDR_S) & MDIO_PHY_ADDR_M) | - ((reg << MDIO_REG_ADDR_S) & MDIO_REG_ADDR_M); - - if (cmd == MDIO_CMD_WRITE || cmd == MDIO_CMD_ADDR) - val |= data & MDIO_RW_DATA_M; - - mt753x_reg_write(gsw, PHY_IAC, val | PHY_ACS_ST); - - timeout_us = 100000; - timeout = ktime_add_us(ktime_get(), timeout_us); - while (1) { - val = mt753x_reg_read(gsw, PHY_IAC); - - if ((val & PHY_ACS_ST) == 0) - break; - - if (ktime_compare(ktime_get(), timeout) > 0) - return -ETIMEDOUT; - } - - if (cmd == MDIO_CMD_READ || cmd == MDIO_CMD_READ_C45) { - val = mt753x_reg_read(gsw, PHY_IAC); - ret = val & MDIO_RW_DATA_M; - } - - return ret; -} - -int mt753x_mii_read(struct gsw_mt753x *gsw, int phy, int reg) -{ - int val; - - if (phy < MT753X_NUM_PHYS) - phy = (gsw->phy_base + phy) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - val = mt753x_mii_rw(gsw, phy, reg, 0, MDIO_CMD_READ, MDIO_ST_C22); - mutex_unlock(&gsw->mii_lock); - - return val; -} - -void mt753x_mii_write(struct gsw_mt753x *gsw, int phy, int reg, u16 val) -{ - if (phy < MT753X_NUM_PHYS) - phy = (gsw->phy_base + phy) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - mt753x_mii_rw(gsw, phy, reg, val, MDIO_CMD_WRITE, MDIO_ST_C22); - mutex_unlock(&gsw->mii_lock); -} - -int mt753x_mmd_read(struct gsw_mt753x *gsw, int addr, int devad, u16 reg) -{ - int val; - - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - mt753x_mii_rw(gsw, addr, devad, reg, MDIO_CMD_ADDR, MDIO_ST_C45); - val = mt753x_mii_rw(gsw, addr, devad, 0, MDIO_CMD_READ_C45, - MDIO_ST_C45); - mutex_unlock(&gsw->mii_lock); - - return val; -} - -void mt753x_mmd_write(struct gsw_mt753x *gsw, int addr, int devad, u16 reg, - u16 val) -{ - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - mt753x_mii_rw(gsw, addr, devad, reg, MDIO_CMD_ADDR, MDIO_ST_C45); - mt753x_mii_rw(gsw, addr, devad, val, MDIO_CMD_WRITE, MDIO_ST_C45); - mutex_unlock(&gsw->mii_lock); -} - -int mt753x_mmd_ind_read(struct gsw_mt753x *gsw, int addr, int devad, u16 reg) -{ - u16 val; - - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - - mt753x_mii_rw(gsw, addr, MII_MMD_ACC_CTL_REG, - (MMD_ADDR << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M), - MDIO_CMD_WRITE, MDIO_ST_C22); - - mt753x_mii_rw(gsw, addr, MII_MMD_ADDR_DATA_REG, reg, - MDIO_CMD_WRITE, MDIO_ST_C22); - - mt753x_mii_rw(gsw, addr, MII_MMD_ACC_CTL_REG, - (MMD_DATA << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M), - MDIO_CMD_WRITE, MDIO_ST_C22); - - val = mt753x_mii_rw(gsw, addr, MII_MMD_ADDR_DATA_REG, 0, - MDIO_CMD_READ, MDIO_ST_C22); - - mutex_unlock(&gsw->mii_lock); - - return val; -} - -void mt753x_mmd_ind_write(struct gsw_mt753x *gsw, int addr, int devad, u16 reg, - u16 val) -{ - if (addr < MT753X_NUM_PHYS) - addr = (gsw->phy_base + addr) & MT753X_SMI_ADDR_MASK; - - mutex_lock(&gsw->mii_lock); - - mt753x_mii_rw(gsw, addr, MII_MMD_ACC_CTL_REG, - (MMD_ADDR << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M), - MDIO_CMD_WRITE, MDIO_ST_C22); - - mt753x_mii_rw(gsw, addr, MII_MMD_ADDR_DATA_REG, reg, - MDIO_CMD_WRITE, MDIO_ST_C22); - - mt753x_mii_rw(gsw, addr, MII_MMD_ACC_CTL_REG, - (MMD_DATA << MMD_CMD_S) | - ((devad << MMD_DEVAD_S) & MMD_DEVAD_M), - MDIO_CMD_WRITE, MDIO_ST_C22); - - mt753x_mii_rw(gsw, addr, MII_MMD_ADDR_DATA_REG, val, - MDIO_CMD_WRITE, MDIO_ST_C22); - - mutex_unlock(&gsw->mii_lock); -} - -static inline int mt753x_get_duplex(const struct device_node *np) -{ - return of_property_read_bool(np, "full-duplex"); -} - -static void mt753x_load_port_cfg(struct gsw_mt753x *gsw) -{ - struct device_node *port_np; - struct device_node *fixed_link_node; - struct mt753x_port_cfg *port_cfg; - u32 port; - - for_each_child_of_node(gsw->dev->of_node, port_np) { - if (!of_device_is_compatible(port_np, "mediatek,mt753x-port")) - continue; - - if (!of_device_is_available(port_np)) - continue; - - if (of_property_read_u32(port_np, "reg", &port)) - continue; - - switch (port) { - case 5: - port_cfg = &gsw->port5_cfg; - break; - case 6: - port_cfg = &gsw->port6_cfg; - break; - default: - continue; - } - - if (port_cfg->enabled) { - dev_info(gsw->dev, "duplicated node for port%d\n", - port_cfg->phy_mode); - continue; - } - - port_cfg->np = port_np; - - if (of_get_phy_mode(port_np, &port_cfg->phy_mode) < 0) { - dev_info(gsw->dev, "incorrect phy-mode %d\n", port); - continue; - } - - fixed_link_node = of_get_child_by_name(port_np, "fixed-link"); - if (fixed_link_node) { - u32 speed; - - port_cfg->force_link = 1; - port_cfg->duplex = mt753x_get_duplex(fixed_link_node); - - if (of_property_read_u32(fixed_link_node, "speed", - &speed)) { - speed = 0; - continue; - } - - of_node_put(fixed_link_node); - - switch (speed) { - case 10: - port_cfg->speed = MAC_SPD_10; - break; - case 100: - port_cfg->speed = MAC_SPD_100; - break; - case 1000: - port_cfg->speed = MAC_SPD_1000; - break; - case 2500: - port_cfg->speed = MAC_SPD_2500; - break; - default: - dev_info(gsw->dev, "incorrect speed %d\n", - speed); - continue; - } - } - - port_cfg->enabled = 1; - } -} - -static void mt753x_add_gsw(struct gsw_mt753x *gsw) -{ - mutex_lock(&mt753x_devs_lock); - gsw->id = mt753x_id++; - INIT_LIST_HEAD(&gsw->list); - list_add_tail(&gsw->list, &mt753x_devs); - mutex_unlock(&mt753x_devs_lock); -} - -static void mt753x_remove_gsw(struct gsw_mt753x *gsw) -{ - mutex_lock(&mt753x_devs_lock); - list_del(&gsw->list); - mutex_unlock(&mt753x_devs_lock); -} - - -struct gsw_mt753x *mt753x_get_gsw(u32 id) -{ - struct gsw_mt753x *dev; - - mutex_lock(&mt753x_devs_lock); - - list_for_each_entry(dev, &mt753x_devs, list) { - if (dev->id == id) - return dev; - } - - mutex_unlock(&mt753x_devs_lock); - - return NULL; -} - -struct gsw_mt753x *mt753x_get_first_gsw(void) -{ - struct gsw_mt753x *dev; - - mutex_lock(&mt753x_devs_lock); - - list_for_each_entry(dev, &mt753x_devs, list) - return dev; - - mutex_unlock(&mt753x_devs_lock); - - return NULL; -} - -void mt753x_put_gsw(void) -{ - mutex_unlock(&mt753x_devs_lock); -} - -void mt753x_lock_gsw(void) -{ - mutex_lock(&mt753x_devs_lock); -} - -static int mt753x_hw_reset(struct gsw_mt753x *gsw) -{ - struct device_node *np = gsw->dev->of_node; - struct reset_control *rstc; - int mcm; - int ret = -EINVAL; - - mcm = of_property_read_bool(np, "mediatek,mcm"); - if (mcm) { - rstc = devm_reset_control_get(gsw->dev, "mcm"); - ret = IS_ERR(rstc); - if (IS_ERR(rstc)) { - dev_err(gsw->dev, "Missing reset ctrl of switch\n"); - return ret; - } - - reset_control_assert(rstc); - msleep(30); - reset_control_deassert(rstc); - - gsw->reset_pin = -1; - return 0; - } - - gsw->reset_pin = of_get_named_gpio(np, "reset-gpios", 0); - if (gsw->reset_pin < 0) { - dev_err(gsw->dev, "Missing reset pin of switch\n"); - return ret; - } - - ret = devm_gpio_request(gsw->dev, gsw->reset_pin, "mt753x-reset"); - if (ret) { - dev_info(gsw->dev, "Failed to request gpio %d\n", - gsw->reset_pin); - return ret; - } - - gpio_direction_output(gsw->reset_pin, 0); - msleep(30); - gpio_set_value(gsw->reset_pin, 1); - msleep(500); - - return 0; -} - -static irqreturn_t mt753x_irq_handler(int irq, void *dev) -{ - struct gsw_mt753x *gsw = dev; - - disable_irq_nosync(gsw->irq); - - schedule_work(&gsw->irq_worker); - - return IRQ_HANDLED; -} - -static int mt753x_probe(struct platform_device *pdev) -{ - struct gsw_mt753x *gsw; - struct mt753x_sw_id *sw; - struct device_node *np = pdev->dev.of_node; - struct device_node *mdio; - struct mii_bus *mdio_bus; - int ret = -EINVAL; - struct chip_rev rev; - struct mt753x_mapping *map; - int i; - - mdio = of_parse_phandle(np, "mediatek,mdio", 0); - if (!mdio) - return -EINVAL; - - mdio_bus = of_mdio_find_bus(mdio); - if (!mdio_bus) - return -EPROBE_DEFER; - - gsw = devm_kzalloc(&pdev->dev, sizeof(struct gsw_mt753x), GFP_KERNEL); - if (!gsw) - return -ENOMEM; - - gsw->host_bus = mdio_bus; - gsw->dev = &pdev->dev; - mutex_init(&gsw->mii_lock); - - /* Switch hard reset */ - if (mt753x_hw_reset(gsw)) - goto fail; - - /* Fetch the SMI address dirst */ - if (of_property_read_u32(np, "mediatek,smi-addr", &gsw->smi_addr)) - gsw->smi_addr = MT753X_DFL_SMI_ADDR; - - /* Get LAN/WAN port mapping */ - map = mt753x_find_mapping(np); - if (map) { - mt753x_apply_mapping(gsw, map); - gsw->global_vlan_enable = 1; - dev_info(gsw->dev, "LAN/WAN VLAN setting=%s\n", map->name); - } - - /* Load MAC port configurations */ - mt753x_load_port_cfg(gsw); - - /* Check for valid switch and then initialize */ - for (i = 0; i < ARRAY_SIZE(mt753x_sw_ids); i++) { - if (!mt753x_sw_ids[i]->detect(gsw, &rev)) { - sw = mt753x_sw_ids[i]; - - gsw->name = rev.name; - gsw->model = sw->model; - - dev_info(gsw->dev, "Switch is MediaTek %s rev %d", - gsw->name, rev.rev); - - /* Initialize the switch */ - ret = sw->init(gsw); - if (ret) - goto fail; - - break; - } - } - - if (i >= ARRAY_SIZE(mt753x_sw_ids)) { - dev_err(gsw->dev, "No mt753x switch found\n"); - goto fail; - } - - gsw->irq = platform_get_irq(pdev, 0); - if (gsw->irq >= 0) { - ret = devm_request_irq(gsw->dev, gsw->irq, mt753x_irq_handler, - 0, dev_name(gsw->dev), gsw); - if (ret) { - dev_err(gsw->dev, "Failed to request irq %d\n", - gsw->irq); - goto fail; - } - - INIT_WORK(&gsw->irq_worker, mt753x_irq_worker); - } - - platform_set_drvdata(pdev, gsw); - - gsw->phy_status_poll = of_property_read_bool(gsw->dev->of_node, - "mediatek,phy-poll"); - - mt753x_add_gsw(gsw); - - mt753x_swconfig_init(gsw); - - if (sw->post_init) - sw->post_init(gsw); - - if (gsw->irq >= 0) - mt753x_irq_enable(gsw); - - return 0; - -fail: - devm_kfree(&pdev->dev, gsw); - - return ret; -} - -static int mt753x_remove(struct platform_device *pdev) -{ - struct gsw_mt753x *gsw = platform_get_drvdata(pdev); - - if (gsw->irq >= 0) - cancel_work_sync(&gsw->irq_worker); - - if (gsw->reset_pin >= 0) - devm_gpio_free(&pdev->dev, gsw->reset_pin); - -#ifdef CONFIG_SWCONFIG - mt753x_swconfig_destroy(gsw); -#endif - - mt753x_remove_gsw(gsw); - - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static const struct of_device_id mt753x_ids[] = { - { .compatible = "mediatek,mt753x" }, - { }, -}; - -MODULE_DEVICE_TABLE(of, mt753x_ids); - -static struct platform_driver mt753x_driver = { - .probe = mt753x_probe, - .remove = mt753x_remove, - .driver = { - .name = "mt753x", - .of_match_table = mt753x_ids, - }, -}; - -static int __init mt753x_init(void) -{ - int ret; - - INIT_LIST_HEAD(&mt753x_devs); - ret = platform_driver_register(&mt753x_driver); - - mt753x_nl_init(); - - return ret; -} -module_init(mt753x_init); - -static void __exit mt753x_exit(void) -{ - mt753x_nl_exit(); - - platform_driver_unregister(&mt753x_driver); -} -module_exit(mt753x_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Weijie Gao "); -MODULE_DESCRIPTION("Driver for MediaTek MT753x Gigabit Switch"); diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.c deleted file mode 100644 index ccde2c9209c..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.c +++ /dev/null @@ -1,382 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Sirui Zhao - */ - -#include -#include -#include -#include -#include - -#include "mt753x.h" -#include "mt753x_nl.h" - -struct mt753x_nl_cmd_item { - enum mt753x_cmd cmd; - bool require_dev; - int (*process)(struct genl_info *info, struct gsw_mt753x *gsw); - u32 nr_required_attrs; - const enum mt753x_attr *required_attrs; -}; - -static int mt753x_nl_response(struct sk_buff *skb, struct genl_info *info); - -/* -static const struct nla_policy mt753x_nl_cmd_policy[] = { - [MT753X_ATTR_TYPE_MESG] = { .type = NLA_STRING }, - [MT753X_ATTR_TYPE_PHY] = { .type = NLA_S32 }, - [MT753X_ATTR_TYPE_REG] = { .type = NLA_S32 }, - [MT753X_ATTR_TYPE_VAL] = { .type = NLA_S32 }, - [MT753X_ATTR_TYPE_DEV_NAME] = { .type = NLA_S32 }, - [MT753X_ATTR_TYPE_DEV_ID] = { .type = NLA_S32 }, - [MT753X_ATTR_TYPE_DEVAD] = { .type = NLA_S32 }, -}; -*/ - -static const struct genl_ops mt753x_nl_ops[] = { - { - .cmd = MT753X_CMD_REQUEST, - .doit = mt753x_nl_response, -// .policy = mt753x_nl_cmd_policy, - .flags = GENL_ADMIN_PERM, - }, { - .cmd = MT753X_CMD_READ, - .doit = mt753x_nl_response, -// .policy = mt753x_nl_cmd_policy, - .flags = GENL_ADMIN_PERM, - }, { - .cmd = MT753X_CMD_WRITE, - .doit = mt753x_nl_response, -// .policy = mt753x_nl_cmd_policy, - .flags = GENL_ADMIN_PERM, - }, -}; - -static struct genl_family mt753x_nl_family = { - .name = MT753X_GENL_NAME, - .version = MT753X_GENL_VERSION, - .maxattr = MT753X_NR_ATTR_TYPE, - .ops = mt753x_nl_ops, - .n_ops = ARRAY_SIZE(mt753x_nl_ops), -}; - -static int mt753x_nl_list_devs(char *buff, int size) -{ - struct gsw_mt753x *gsw; - int len, total = 0; - char buf[80]; - - memset(buff, 0, size); - - mt753x_lock_gsw(); - - list_for_each_entry(gsw, &mt753x_devs, list) { - len = snprintf(buf, sizeof(buf), - "id: %d, model: %s, node: %s\n", - gsw->id, gsw->name, gsw->dev->of_node->name); - strncat(buff, buf, size - total); - total += len; - } - - mt753x_put_gsw(); - - return total; -} - -static int mt753x_nl_prepare_reply(struct genl_info *info, u8 cmd, - struct sk_buff **skbp) -{ - struct sk_buff *msg; - void *reply; - - if (!info) - return -EINVAL; - - msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); - if (!msg) - return -ENOMEM; - - /* Construct send-back message header */ - reply = genlmsg_put(msg, info->snd_portid, info->snd_seq, - &mt753x_nl_family, 0, cmd); - if (!reply) { - nlmsg_free(msg); - return -EINVAL; - } - - *skbp = msg; - return 0; -} - -static int mt753x_nl_send_reply(struct sk_buff *skb, struct genl_info *info) -{ - struct genlmsghdr *genlhdr = nlmsg_data(nlmsg_hdr(skb)); - void *reply = genlmsg_data(genlhdr); - - /* Finalize a generic netlink message (update message header) */ - genlmsg_end(skb, reply); - - /* reply to a request */ - return genlmsg_reply(skb, info); -} - -static s32 mt753x_nl_get_s32(struct genl_info *info, enum mt753x_attr attr, - s32 defval) -{ - struct nlattr *na; - - na = info->attrs[attr]; - if (na) - return nla_get_s32(na); - - return defval; -} - -static int mt753x_nl_get_u32(struct genl_info *info, enum mt753x_attr attr, - u32 *val) -{ - struct nlattr *na; - - na = info->attrs[attr]; - if (na) { - *val = nla_get_u32(na); - return 0; - } - - return -1; -} - -static struct gsw_mt753x *mt753x_nl_parse_find_gsw(struct genl_info *info) -{ - struct gsw_mt753x *gsw; - struct nlattr *na; - int gsw_id; - - na = info->attrs[MT753X_ATTR_TYPE_DEV_ID]; - if (na) { - gsw_id = nla_get_s32(na); - if (gsw_id >= 0) - gsw = mt753x_get_gsw(gsw_id); - else - gsw = mt753x_get_first_gsw(); - } else { - gsw = mt753x_get_first_gsw(); - } - - return gsw; -} - -static int mt753x_nl_get_swdevs(struct genl_info *info, struct gsw_mt753x *gsw) -{ - struct sk_buff *rep_skb = NULL; - char dev_info[512]; - int ret; - - ret = mt753x_nl_list_devs(dev_info, sizeof(dev_info)); - if (!ret) { - pr_info("No switch registered\n"); - return -EINVAL; - } - - ret = mt753x_nl_prepare_reply(info, MT753X_CMD_REPLY, &rep_skb); - if (ret < 0) - goto err; - - ret = nla_put_string(rep_skb, MT753X_ATTR_TYPE_MESG, dev_info); - if (ret < 0) - goto err; - - return mt753x_nl_send_reply(rep_skb, info); - -err: - if (rep_skb) - nlmsg_free(rep_skb); - - return ret; -} - -static int mt753x_nl_reply_read(struct genl_info *info, struct gsw_mt753x *gsw) -{ - struct sk_buff *rep_skb = NULL; - s32 phy, devad, reg; - int value; - int ret = 0; - - phy = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_PHY, -1); - devad = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_DEVAD, -1); - reg = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_REG, -1); - - if (reg < 0) - goto err; - - ret = mt753x_nl_prepare_reply(info, MT753X_CMD_READ, &rep_skb); - if (ret < 0) - goto err; - - if (phy >= 0) { - if (devad < 0) - value = gsw->mii_read(gsw, phy, reg); - else - value = gsw->mmd_read(gsw, phy, devad, reg); - } else { - value = mt753x_reg_read(gsw, reg); - } - - ret = nla_put_s32(rep_skb, MT753X_ATTR_TYPE_REG, reg); - if (ret < 0) - goto err; - - ret = nla_put_s32(rep_skb, MT753X_ATTR_TYPE_VAL, value); - if (ret < 0) - goto err; - - return mt753x_nl_send_reply(rep_skb, info); - -err: - if (rep_skb) - nlmsg_free(rep_skb); - - return ret; -} - -static int mt753x_nl_reply_write(struct genl_info *info, struct gsw_mt753x *gsw) -{ - struct sk_buff *rep_skb = NULL; - s32 phy, devad, reg; - u32 value; - int ret = 0; - - phy = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_PHY, -1); - devad = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_DEVAD, -1); - reg = mt753x_nl_get_s32(info, MT753X_ATTR_TYPE_REG, -1); - - if (mt753x_nl_get_u32(info, MT753X_ATTR_TYPE_VAL, &value)) - goto err; - - if (reg < 0) - goto err; - - ret = mt753x_nl_prepare_reply(info, MT753X_CMD_WRITE, &rep_skb); - if (ret < 0) - goto err; - - if (phy >= 0) { - if (devad < 0) - gsw->mii_write(gsw, phy, reg, value); - else - gsw->mmd_write(gsw, phy, devad, reg, value); - } else { - mt753x_reg_write(gsw, reg, value); - } - - ret = nla_put_s32(rep_skb, MT753X_ATTR_TYPE_REG, reg); - if (ret < 0) - goto err; - - ret = nla_put_s32(rep_skb, MT753X_ATTR_TYPE_VAL, value); - if (ret < 0) - goto err; - - return mt753x_nl_send_reply(rep_skb, info); - -err: - if (rep_skb) - nlmsg_free(rep_skb); - - return ret; -} - -static const enum mt753x_attr mt753x_nl_cmd_read_attrs[] = { - MT753X_ATTR_TYPE_REG -}; - -static const enum mt753x_attr mt753x_nl_cmd_write_attrs[] = { - MT753X_ATTR_TYPE_REG, - MT753X_ATTR_TYPE_VAL -}; - -static const struct mt753x_nl_cmd_item mt753x_nl_cmds[] = { - { - .cmd = MT753X_CMD_REQUEST, - .require_dev = false, - .process = mt753x_nl_get_swdevs - }, { - .cmd = MT753X_CMD_READ, - .require_dev = true, - .process = mt753x_nl_reply_read, - .required_attrs = mt753x_nl_cmd_read_attrs, - .nr_required_attrs = ARRAY_SIZE(mt753x_nl_cmd_read_attrs), - }, { - .cmd = MT753X_CMD_WRITE, - .require_dev = true, - .process = mt753x_nl_reply_write, - .required_attrs = mt753x_nl_cmd_write_attrs, - .nr_required_attrs = ARRAY_SIZE(mt753x_nl_cmd_write_attrs), - } -}; - -static int mt753x_nl_response(struct sk_buff *skb, struct genl_info *info) -{ - struct genlmsghdr *hdr = nlmsg_data(info->nlhdr); - const struct mt753x_nl_cmd_item *cmditem = NULL; - struct gsw_mt753x *gsw = NULL; - u32 sat_req_attrs = 0; - int i, ret; - - for (i = 0; i < ARRAY_SIZE(mt753x_nl_cmds); i++) { - if (hdr->cmd == mt753x_nl_cmds[i].cmd) { - cmditem = &mt753x_nl_cmds[i]; - break; - } - } - - if (!cmditem) { - pr_info("mt753x-nl: unknown cmd %u\n", hdr->cmd); - return -EINVAL; - } - - for (i = 0; i < cmditem->nr_required_attrs; i++) { - if (info->attrs[cmditem->required_attrs[i]]) - sat_req_attrs++; - } - - if (sat_req_attrs != cmditem->nr_required_attrs) { - pr_info("mt753x-nl: missing required attr(s) for cmd %u\n", - hdr->cmd); - return -EINVAL; - } - - if (cmditem->require_dev) { - gsw = mt753x_nl_parse_find_gsw(info); - if (!gsw) { - pr_info("mt753x-nl: failed to find switch dev\n"); - return -EINVAL; - } - } - - ret = cmditem->process(info, gsw); - - mt753x_put_gsw(); - - return ret; -} - -int __init mt753x_nl_init(void) -{ - int ret; - - ret = genl_register_family(&mt753x_nl_family); - if (ret) { - pr_info("mt753x-nl: genl_register_family_with_ops failed\n"); - return ret; - } - - return 0; -} - -void __exit mt753x_nl_exit(void) -{ - genl_unregister_family(&mt753x_nl_family); -} diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.h deleted file mode 100644 index 85dc9e791a2..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_nl.h +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Sirui Zhao - */ - -#ifndef _MT753X_NL_H_ -#define _MT753X_NL_H_ - -#define MT753X_GENL_NAME "mt753x" -#define MT753X_GENL_VERSION 0x1 - -enum mt753x_cmd { - MT753X_CMD_UNSPEC = 0, - MT753X_CMD_REQUEST, - MT753X_CMD_REPLY, - MT753X_CMD_READ, - MT753X_CMD_WRITE, - - __MT753X_CMD_MAX, -}; - -enum mt753x_attr { - MT753X_ATTR_TYPE_UNSPEC = 0, - MT753X_ATTR_TYPE_MESG, - MT753X_ATTR_TYPE_PHY, - MT753X_ATTR_TYPE_DEVAD, - MT753X_ATTR_TYPE_REG, - MT753X_ATTR_TYPE_VAL, - MT753X_ATTR_TYPE_DEV_NAME, - MT753X_ATTR_TYPE_DEV_ID, - - __MT753X_ATTR_TYPE_MAX, -}; - -#define MT753X_NR_ATTR_TYPE (__MT753X_ATTR_TYPE_MAX - 1) - -#ifdef __KERNEL__ -int __init mt753x_nl_init(void); -void __exit mt753x_nl_exit(void); -#endif /* __KERNEL__ */ - -#endif /* _MT753X_NL_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_regs.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_regs.h deleted file mode 100644 index 3f23ae200ed..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_regs.h +++ /dev/null @@ -1,294 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#ifndef _MT753X_REGS_H_ -#define _MT753X_REGS_H_ - -#include - -/* Values of Egress TAG Control */ -#define ETAG_CTRL_UNTAG 0 -#define ETAG_CTRL_TAG 2 -#define ETAG_CTRL_SWAP 1 -#define ETAG_CTRL_STACK 3 - -#define VTCR 0x90 -#define VAWD1 0x94 -#define VAWD2 0x98 - -/* Fields of VTCR */ -#define VTCR_BUSY BIT(31) -#define IDX_INVLD BIT(16) -#define VTCR_FUNC_S 12 -#define VTCR_FUNC_M 0xf000 -#define VTCR_VID_S 0 -#define VTCR_VID_M 0xfff - -/* Values of VTCR_FUNC */ -#define VTCR_READ_VLAN_ENTRY 0 -#define VTCR_WRITE_VLAN_ENTRY 1 -#define VTCR_INVD_VLAN_ENTRY 2 -#define VTCR_ENABLE_VLAN_ENTRY 3 -#define VTCR_READ_ACL_ENTRY 4 -#define VTCR_WRITE_ACL_ENTRY 5 -#define VTCR_READ_TRTCM_TABLE 6 -#define VTCR_WRITE_TRTCM_TABLE 7 -#define VTCR_READ_ACL_MASK_ENTRY 8 -#define VTCR_WRITE_ACL_MASK_ENTRY 9 -#define VTCR_READ_ACL_RULE_ENTRY 10 -#define VTCR_WRITE_ACL_RULE_ENTRY 11 -#define VTCR_READ_ACL_RATE_ENTRY 12 -#define VTCR_WRITE_ACL_RATE_ENTRY 13 - -/* VLAN entry fields */ -/* VAWD1 */ -#define PORT_STAG BIT(31) -#define IVL_MAC BIT(30) -#define EG_CON BIT(29) -#define VTAG_EN BIT(28) -#define COPY_PRI BIT(27) -#define USER_PRI_S 24 -#define USER_PRI_M 0x7000000 -#define PORT_MEM_S 16 -#define PORT_MEM_M 0xff0000 -#define S_TAG1_S 4 -#define S_TAG1_M 0xfff0 -#define FID_S 1 -#define FID_M 0x0e -#define VENTRY_VALID BIT(0) - -/* VAWD2 */ -#define S_TAG2_S 16 -#define S_TAG2_M 0xffff0000 -#define PORT_ETAG_S(p) ((p) * 2) -#define PORT_ETAG_M 0x03 - -#define PORT_CTRL_BASE 0x2000 -#define PORT_CTRL_PORT_OFFSET 0x100 -#define PORT_CTRL_REG(p, r) (PORT_CTRL_BASE + \ - (p) * PORT_CTRL_PORT_OFFSET + (r)) -#define CKGCR(p) PORT_CTRL_REG(p, 0x00) -#define PCR(p) PORT_CTRL_REG(p, 0x04) -#define PIC(p) PORT_CTRL_REG(p, 0x08) -#define PSC(p) PORT_CTRL_REG(p, 0x0c) -#define PVC(p) PORT_CTRL_REG(p, 0x10) -#define PPBV1(p) PORT_CTRL_REG(p, 0x14) -#define PPBV2(p) PORT_CTRL_REG(p, 0x18) -#define BSR(p) PORT_CTRL_REG(p, 0x1c) -#define STAG01 PORT_CTRL_REG(p, 0x20) -#define STAG23 PORT_CTRL_REG(p, 0x24) -#define STAG45 PORT_CTRL_REG(p, 0x28) -#define STAG67 PORT_CTRL_REG(p, 0x2c) - -#define PPBV(p, g) (PPBV1(p) + ((g) / 2) * 4) - -/* Fields of PCR */ -#define MLDV2_EN BIT(30) -#define EG_TAG_S 28 -#define EG_TAG_M 0x30000000 -#define PORT_PRI_S 24 -#define PORT_PRI_M 0x7000000 -#define PORT_MATRIX_S 16 -#define PORT_MATRIX_M 0xff0000 -#define UP2DSCP_EN BIT(12) -#define UP2TAG_EN BIT(11) -#define ACL_EN BIT(10) -#define PORT_TX_MIR BIT(9) -#define PORT_RX_MIR BIT(8) -#define ACL_MIR BIT(7) -#define MIS_PORT_FW_S 4 -#define MIS_PORT_FW_M 0x70 -#define VLAN_MIS BIT(2) -#define PORT_VLAN_S 0 -#define PORT_VLAN_M 0x03 - -/* Values of PORT_VLAN */ -#define PORT_MATRIX_MODE 0 -#define FALLBACK_MODE 1 -#define CHECK_MODE 2 -#define SECURITY_MODE 3 - -/* Fields of PVC */ -#define STAG_VPID_S 16 -#define STAG_VPID_M 0xffff0000 -#define DIS_PVID BIT(15) -#define FORCE_PVID BIT(14) -#define PT_VPM BIT(12) -#define PT_OPTION BIT(11) -#define PVC_EG_TAG_S 8 -#define PVC_EG_TAG_M 0x700 -#define VLAN_ATTR_S 6 -#define VLAN_ATTR_M 0xc0 -#define PVC_PORT_STAG BIT(5) -#define BC_LKYV_EN BIT(4) -#define MC_LKYV_EN BIT(3) -#define UC_LKYV_EN BIT(2) -#define ACC_FRM_S 0 -#define ACC_FRM_M 0x03 - -/* Values of VLAN_ATTR */ -#define VA_USER_PORT 0 -#define VA_STACK_PORT 1 -#define VA_TRANSLATION_PORT 2 -#define VA_TRANSPARENT_PORT 3 - -/* Fields of PPBV */ -#define GRP_PORT_PRI_S(g) (((g) % 2) * 16 + 13) -#define GRP_PORT_PRI_M 0x07 -#define GRP_PORT_VID_S(g) (((g) % 2) * 16) -#define GRP_PORT_VID_M 0xfff - -#define PORT_MAC_CTRL_BASE 0x3000 -#define PORT_MAC_CTRL_PORT_OFFSET 0x100 -#define PORT_MAC_CTRL_REG(p, r) (PORT_MAC_CTRL_BASE + \ - (p) * PORT_MAC_CTRL_PORT_OFFSET + (r)) -#define PMCR(p) PORT_MAC_CTRL_REG(p, 0x00) -#define PMEEECR(p) PORT_MAC_CTRL_REG(p, 0x04) -#define PMSR(p) PORT_MAC_CTRL_REG(p, 0x08) -#define PINT_EN(p) PORT_MAC_CTRL_REG(p, 0x10) -#define PINT_STS(p) PORT_MAC_CTRL_REG(p, 0x14) - -#define GMACCR (PORT_MAC_CTRL_BASE + 0xe0) -#define TXCRC_EN BIT(19) -#define RXCRC_EN BIT(18) -#define PRMBL_LMT_EN BIT(17) -#define MTCC_LMT_S 9 -#define MTCC_LMT_M 0x1e00 -#define MAX_RX_JUMBO_S 2 -#define MAX_RX_JUMBO_M 0x3c -#define MAX_RX_PKT_LEN_S 0 -#define MAX_RX_PKT_LEN_M 0x3 - -/* Values of MAX_RX_PKT_LEN */ -#define RX_PKT_LEN_1518 0 -#define RX_PKT_LEN_1536 1 -#define RX_PKT_LEN_1522 2 -#define RX_PKT_LEN_MAX_JUMBO 3 - -/* Fields of PMCR */ -#define IPG_CFG_S 18 -#define IPG_CFG_M 0xc0000 -#define EXT_PHY BIT(17) -#define MAC_MODE BIT(16) -#define MAC_TX_EN BIT(14) -#define MAC_RX_EN BIT(13) -#define MAC_PRE BIT(11) -#define BKOFF_EN BIT(9) -#define BACKPR_EN BIT(8) -#define FORCE_EEE1G BIT(7) -#define FORCE_EEE1000 BIT(6) -#define FORCE_RX_FC BIT(5) -#define FORCE_TX_FC BIT(4) -#define FORCE_SPD_S 2 -#define FORCE_SPD_M 0x0c -#define FORCE_DPX BIT(1) -#define FORCE_LINK BIT(0) - -/* Fields of PMSR */ -#define EEE1G_STS BIT(7) -#define EEE100_STS BIT(6) -#define RX_FC_STS BIT(5) -#define TX_FC_STS BIT(4) -#define MAC_SPD_STS_S 2 -#define MAC_SPD_STS_M 0x0c -#define MAC_DPX_STS BIT(1) -#define MAC_LNK_STS BIT(0) - -/* Values of MAC_SPD_STS */ -#define MAC_SPD_10 0 -#define MAC_SPD_100 1 -#define MAC_SPD_1000 2 -#define MAC_SPD_2500 3 - -/* Values of IPG_CFG */ -#define IPG_96BIT 0 -#define IPG_96BIT_WITH_SHORT_IPG 1 -#define IPG_64BIT 2 - -#define MIB_COUNTER_BASE 0x4000 -#define MIB_COUNTER_PORT_OFFSET 0x100 -#define MIB_COUNTER_REG(p, r) (MIB_COUNTER_BASE + \ - (p) * MIB_COUNTER_PORT_OFFSET + (r)) -#define STATS_TDPC 0x00 -#define STATS_TCRC 0x04 -#define STATS_TUPC 0x08 -#define STATS_TMPC 0x0C -#define STATS_TBPC 0x10 -#define STATS_TCEC 0x14 -#define STATS_TSCEC 0x18 -#define STATS_TMCEC 0x1C -#define STATS_TDEC 0x20 -#define STATS_TLCEC 0x24 -#define STATS_TXCEC 0x28 -#define STATS_TPPC 0x2C -#define STATS_TL64PC 0x30 -#define STATS_TL65PC 0x34 -#define STATS_TL128PC 0x38 -#define STATS_TL256PC 0x3C -#define STATS_TL512PC 0x40 -#define STATS_TL1024PC 0x44 -#define STATS_TOC 0x48 -#define STATS_RDPC 0x60 -#define STATS_RFPC 0x64 -#define STATS_RUPC 0x68 -#define STATS_RMPC 0x6C -#define STATS_RBPC 0x70 -#define STATS_RAEPC 0x74 -#define STATS_RCEPC 0x78 -#define STATS_RUSPC 0x7C -#define STATS_RFEPC 0x80 -#define STATS_ROSPC 0x84 -#define STATS_RJEPC 0x88 -#define STATS_RPPC 0x8C -#define STATS_RL64PC 0x90 -#define STATS_RL65PC 0x94 -#define STATS_RL128PC 0x98 -#define STATS_RL256PC 0x9C -#define STATS_RL512PC 0xA0 -#define STATS_RL1024PC 0xA4 -#define STATS_ROC 0xA8 -#define STATS_RDPC_CTRL 0xB0 -#define STATS_RDPC_ING 0xB4 -#define STATS_RDPC_ARL 0xB8 - -#define SYS_CTRL 0x7000 -#define SW_PHY_RST BIT(2) -#define SW_SYS_RST BIT(1) -#define SW_REG_RST BIT(0) - -#define SYS_INT_EN 0x7008 -#define SYS_INT_STS 0x700c -#define MAC_PC_INT BIT(16) -#define PHY_INT(p) BIT((p) + 8) -#define PHY_LC_INT(p) BIT(p) - -#define PHY_IAC 0x701c -#define PHY_ACS_ST BIT(31) -#define MDIO_REG_ADDR_S 25 -#define MDIO_REG_ADDR_M 0x3e000000 -#define MDIO_PHY_ADDR_S 20 -#define MDIO_PHY_ADDR_M 0x1f00000 -#define MDIO_CMD_S 18 -#define MDIO_CMD_M 0xc0000 -#define MDIO_ST_S 16 -#define MDIO_ST_M 0x30000 -#define MDIO_RW_DATA_S 0 -#define MDIO_RW_DATA_M 0xffff - -/* MDIO_CMD: MDIO commands */ -#define MDIO_CMD_ADDR 0 -#define MDIO_CMD_WRITE 1 -#define MDIO_CMD_READ 2 -#define MDIO_CMD_READ_C45 3 - -/* MDIO_ST: MDIO start field */ -#define MDIO_ST_C45 0 -#define MDIO_ST_C22 1 - -#define HWSTRAP 0x7800 -#define MHWSTRAP 0x7804 - -#endif /* _MT753X_REGS_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.c deleted file mode 100644 index 342ad576b29..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.c +++ /dev/null @@ -1,510 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mt753x.h" -#include "mt753x_swconfig.h" -#include "mt753x_regs.h" - -#define MT753X_PORT_MIB_TXB_ID 18 /* TxByte */ -#define MT753X_PORT_MIB_RXB_ID 37 /* RxByte */ - -#define MIB_DESC(_s, _o, _n) \ - { \ - .size = (_s), \ - .offset = (_o), \ - .name = (_n), \ - } - -struct mt753x_mib_desc { - unsigned int size; - unsigned int offset; - const char *name; -}; - -static const struct mt753x_mib_desc mt753x_mibs[] = { - MIB_DESC(1, STATS_TDPC, "TxDrop"), - MIB_DESC(1, STATS_TCRC, "TxCRC"), - MIB_DESC(1, STATS_TUPC, "TxUni"), - MIB_DESC(1, STATS_TMPC, "TxMulti"), - MIB_DESC(1, STATS_TBPC, "TxBroad"), - MIB_DESC(1, STATS_TCEC, "TxCollision"), - MIB_DESC(1, STATS_TSCEC, "TxSingleCol"), - MIB_DESC(1, STATS_TMCEC, "TxMultiCol"), - MIB_DESC(1, STATS_TDEC, "TxDefer"), - MIB_DESC(1, STATS_TLCEC, "TxLateCol"), - MIB_DESC(1, STATS_TXCEC, "TxExcCol"), - MIB_DESC(1, STATS_TPPC, "TxPause"), - MIB_DESC(1, STATS_TL64PC, "Tx64Byte"), - MIB_DESC(1, STATS_TL65PC, "Tx65Byte"), - MIB_DESC(1, STATS_TL128PC, "Tx128Byte"), - MIB_DESC(1, STATS_TL256PC, "Tx256Byte"), - MIB_DESC(1, STATS_TL512PC, "Tx512Byte"), - MIB_DESC(1, STATS_TL1024PC, "Tx1024Byte"), - MIB_DESC(2, STATS_TOC, "TxByte"), - MIB_DESC(1, STATS_RDPC, "RxDrop"), - MIB_DESC(1, STATS_RFPC, "RxFiltered"), - MIB_DESC(1, STATS_RUPC, "RxUni"), - MIB_DESC(1, STATS_RMPC, "RxMulti"), - MIB_DESC(1, STATS_RBPC, "RxBroad"), - MIB_DESC(1, STATS_RAEPC, "RxAlignErr"), - MIB_DESC(1, STATS_RCEPC, "RxCRC"), - MIB_DESC(1, STATS_RUSPC, "RxUnderSize"), - MIB_DESC(1, STATS_RFEPC, "RxFragment"), - MIB_DESC(1, STATS_ROSPC, "RxOverSize"), - MIB_DESC(1, STATS_RJEPC, "RxJabber"), - MIB_DESC(1, STATS_RPPC, "RxPause"), - MIB_DESC(1, STATS_RL64PC, "Rx64Byte"), - MIB_DESC(1, STATS_RL65PC, "Rx65Byte"), - MIB_DESC(1, STATS_RL128PC, "Rx128Byte"), - MIB_DESC(1, STATS_RL256PC, "Rx256Byte"), - MIB_DESC(1, STATS_RL512PC, "Rx512Byte"), - MIB_DESC(1, STATS_RL1024PC, "Rx1024Byte"), - MIB_DESC(2, STATS_ROC, "RxByte"), - MIB_DESC(1, STATS_RDPC_CTRL, "RxCtrlDrop"), - MIB_DESC(1, STATS_RDPC_ING, "RxIngDrop"), - MIB_DESC(1, STATS_RDPC_ARL, "RxARLDrop") -}; - -enum { - /* Global attributes. */ - MT753X_ATTR_ENABLE_VLAN, -}; - -static int mt753x_get_vlan_enable(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - val->value.i = gsw->global_vlan_enable; - - return 0; -} - -static int mt753x_set_vlan_enable(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - gsw->global_vlan_enable = val->value.i != 0; - - return 0; -} - -static int mt753x_get_port_pvid(struct switch_dev *dev, int port, int *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - if (port >= MT753X_NUM_PORTS) - return -EINVAL; - - *val = mt753x_reg_read(gsw, PPBV1(port)); - *val &= GRP_PORT_VID_M; - - return 0; -} - -static int mt753x_set_port_pvid(struct switch_dev *dev, int port, int pvid) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - if (port >= MT753X_NUM_PORTS) - return -EINVAL; - - if (pvid < MT753X_MIN_VID || pvid > MT753X_MAX_VID) - return -EINVAL; - - gsw->port_entries[port].pvid = pvid; - - return 0; -} - -static int mt753x_get_vlan_ports(struct switch_dev *dev, struct switch_val *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - u32 member; - u32 etags; - int i; - - val->len = 0; - - if (val->port_vlan < 0 || val->port_vlan >= MT753X_NUM_VLANS) - return -EINVAL; - - mt753x_vlan_ctrl(gsw, VTCR_READ_VLAN_ENTRY, val->port_vlan); - - member = mt753x_reg_read(gsw, VAWD1); - member &= PORT_MEM_M; - member >>= PORT_MEM_S; - - etags = mt753x_reg_read(gsw, VAWD2); - - for (i = 0; i < MT753X_NUM_PORTS; i++) { - struct switch_port *p; - int etag; - - if (!(member & BIT(i))) - continue; - - p = &val->value.ports[val->len++]; - p->id = i; - - etag = (etags >> PORT_ETAG_S(i)) & PORT_ETAG_M; - - if (etag == ETAG_CTRL_TAG) - p->flags |= BIT(SWITCH_PORT_FLAG_TAGGED); - else if (etag != ETAG_CTRL_UNTAG) - dev_info(gsw->dev, - "vlan egress tag control neither untag nor tag.\n"); - } - - return 0; -} - -static int mt753x_set_vlan_ports(struct switch_dev *dev, struct switch_val *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - u8 member = 0; - u8 etags = 0; - int i; - - if (val->port_vlan < 0 || val->port_vlan >= MT753X_NUM_VLANS || - val->len > MT753X_NUM_PORTS) - return -EINVAL; - - for (i = 0; i < val->len; i++) { - struct switch_port *p = &val->value.ports[i]; - - if (p->id >= MT753X_NUM_PORTS) - return -EINVAL; - - member |= BIT(p->id); - - if (p->flags & BIT(SWITCH_PORT_FLAG_TAGGED)) - etags |= BIT(p->id); - } - - gsw->vlan_entries[val->port_vlan].member = member; - gsw->vlan_entries[val->port_vlan].etags = etags; - - return 0; -} - -static int mt753x_set_vid(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - int vlan; - u16 vid; - - vlan = val->port_vlan; - vid = (u16)val->value.i; - - if (vlan < 0 || vlan >= MT753X_NUM_VLANS) - return -EINVAL; - - if (vid < MT753X_MIN_VID || vid > MT753X_MAX_VID) - return -EINVAL; - - gsw->vlan_entries[vlan].vid = vid; - return 0; -} - -static int mt753x_get_vid(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - val->value.i = val->port_vlan; - return 0; -} - -static int mt753x_get_port_link(struct switch_dev *dev, int port, - struct switch_port_link *link) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - u32 speed, pmsr; - - if (port < 0 || port >= MT753X_NUM_PORTS) - return -EINVAL; - - pmsr = mt753x_reg_read(gsw, PMSR(port)); - - link->link = pmsr & MAC_LNK_STS; - link->duplex = pmsr & MAC_DPX_STS; - speed = (pmsr & MAC_SPD_STS_M) >> MAC_SPD_STS_S; - - switch (speed) { - case MAC_SPD_10: - link->speed = SWITCH_PORT_SPEED_10; - break; - case MAC_SPD_100: - link->speed = SWITCH_PORT_SPEED_100; - break; - case MAC_SPD_1000: - link->speed = SWITCH_PORT_SPEED_1000; - break; - case MAC_SPD_2500: - /* TODO: swconfig has no support for 2500 now */ - link->speed = SWITCH_PORT_SPEED_UNKNOWN; - break; - } - - return 0; -} - -static int mt753x_set_port_link(struct switch_dev *dev, int port, - struct switch_port_link *link) -{ -#ifndef MODULE - if (port >= MT753X_NUM_PHYS) - return -EINVAL; - - return switch_generic_set_link(dev, port, link); -#else - return -ENOTSUPP; -#endif -} - -static u64 get_mib_counter(struct gsw_mt753x *gsw, int i, int port) -{ - unsigned int offset; - u64 lo, hi, hi2; - - offset = mt753x_mibs[i].offset; - - if (mt753x_mibs[i].size == 1) - return mt753x_reg_read(gsw, MIB_COUNTER_REG(port, offset)); - - do { - hi = mt753x_reg_read(gsw, MIB_COUNTER_REG(port, offset + 4)); - lo = mt753x_reg_read(gsw, MIB_COUNTER_REG(port, offset)); - hi2 = mt753x_reg_read(gsw, MIB_COUNTER_REG(port, offset + 4)); - } while (hi2 != hi); - - return (hi << 32) | lo; -} - -static int mt753x_get_port_mib(struct switch_dev *dev, - const struct switch_attr *attr, - struct switch_val *val) -{ - static char buf[4096]; - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - int i, len = 0; - - if (val->port_vlan >= MT753X_NUM_PORTS) - return -EINVAL; - - len += snprintf(buf + len, sizeof(buf) - len, - "Port %d MIB counters\n", val->port_vlan); - - for (i = 0; i < ARRAY_SIZE(mt753x_mibs); ++i) { - u64 counter; - - len += snprintf(buf + len, sizeof(buf) - len, - "%-11s: ", mt753x_mibs[i].name); - counter = get_mib_counter(gsw, i, val->port_vlan); - len += snprintf(buf + len, sizeof(buf) - len, "%llu\n", - counter); - } - - val->value.s = buf; - val->len = len; - return 0; -} - -static int mt753x_get_port_stats(struct switch_dev *dev, int port, - struct switch_port_stats *stats) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - if (port < 0 || port >= MT753X_NUM_PORTS) - return -EINVAL; - - stats->tx_bytes = get_mib_counter(gsw, MT753X_PORT_MIB_TXB_ID, port); - stats->rx_bytes = get_mib_counter(gsw, MT753X_PORT_MIB_RXB_ID, port); - - return 0; -} - -static void mt753x_port_isolation(struct gsw_mt753x *gsw) -{ - int i; - - for (i = 0; i < MT753X_NUM_PORTS; i++) - mt753x_reg_write(gsw, PCR(i), - BIT(gsw->cpu_port) << PORT_MATRIX_S); - - mt753x_reg_write(gsw, PCR(gsw->cpu_port), PORT_MATRIX_M); - - for (i = 0; i < MT753X_NUM_PORTS; i++) - mt753x_reg_write(gsw, PVC(i), - (0x8100 << STAG_VPID_S) | - (VA_TRANSPARENT_PORT << VLAN_ATTR_S)); -} - -static int mt753x_apply_config(struct switch_dev *dev) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - if (!gsw->global_vlan_enable) { - mt753x_port_isolation(gsw); - return 0; - } - - mt753x_apply_vlan_config(gsw); - - return 0; -} - -static int mt753x_reset_switch(struct switch_dev *dev) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - int i; - - memset(gsw->port_entries, 0, sizeof(gsw->port_entries)); - memset(gsw->vlan_entries, 0, sizeof(gsw->vlan_entries)); - - /* set default vid of each vlan to the same number of vlan, so the vid - * won't need be set explicitly. - */ - for (i = 0; i < MT753X_NUM_VLANS; i++) - gsw->vlan_entries[i].vid = i; - - return 0; -} - -static int mt753x_phy_read16(struct switch_dev *dev, int addr, u8 reg, - u16 *value) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - *value = gsw->mii_read(gsw, addr, reg); - - return 0; -} - -static int mt753x_phy_write16(struct switch_dev *dev, int addr, u8 reg, - u16 value) -{ - struct gsw_mt753x *gsw = container_of(dev, struct gsw_mt753x, swdev); - - gsw->mii_write(gsw, addr, reg, value); - - return 0; -} - -static const struct switch_attr mt753x_global[] = { - { - .type = SWITCH_TYPE_INT, - .name = "enable_vlan", - .description = "VLAN mode (1:enabled)", - .max = 1, - .id = MT753X_ATTR_ENABLE_VLAN, - .get = mt753x_get_vlan_enable, - .set = mt753x_set_vlan_enable, - } -}; - -static const struct switch_attr mt753x_port[] = { - { - .type = SWITCH_TYPE_STRING, - .name = "mib", - .description = "Get MIB counters for port", - .get = mt753x_get_port_mib, - .set = NULL, - }, -}; - -static const struct switch_attr mt753x_vlan[] = { - { - .type = SWITCH_TYPE_INT, - .name = "vid", - .description = "VLAN ID (0-4094)", - .set = mt753x_set_vid, - .get = mt753x_get_vid, - .max = 4094, - }, -}; - -static const struct switch_dev_ops mt753x_swdev_ops = { - .attr_global = { - .attr = mt753x_global, - .n_attr = ARRAY_SIZE(mt753x_global), - }, - .attr_port = { - .attr = mt753x_port, - .n_attr = ARRAY_SIZE(mt753x_port), - }, - .attr_vlan = { - .attr = mt753x_vlan, - .n_attr = ARRAY_SIZE(mt753x_vlan), - }, - .get_vlan_ports = mt753x_get_vlan_ports, - .set_vlan_ports = mt753x_set_vlan_ports, - .get_port_pvid = mt753x_get_port_pvid, - .set_port_pvid = mt753x_set_port_pvid, - .get_port_link = mt753x_get_port_link, - .set_port_link = mt753x_set_port_link, - .get_port_stats = mt753x_get_port_stats, - .apply_config = mt753x_apply_config, - .reset_switch = mt753x_reset_switch, - .phy_read16 = mt753x_phy_read16, - .phy_write16 = mt753x_phy_write16, -}; - -int mt753x_swconfig_init(struct gsw_mt753x *gsw) -{ - struct device_node *np = gsw->dev->of_node; - struct switch_dev *swdev; - int ret; - - if (of_property_read_u32(np, "mediatek,cpuport", &gsw->cpu_port)) - gsw->cpu_port = MT753X_DFL_CPU_PORT; - - swdev = &gsw->swdev; - - swdev->name = gsw->name; - swdev->alias = gsw->name; - swdev->cpu_port = gsw->cpu_port; - swdev->ports = MT753X_NUM_PORTS; - swdev->vlans = MT753X_NUM_VLANS; - swdev->ops = &mt753x_swdev_ops; - - ret = register_switch(swdev, NULL); - if (ret) { - dev_notice(gsw->dev, "Failed to register switch %s\n", - swdev->name); - return ret; - } - - mt753x_apply_config(swdev); - - return 0; -} - -void mt753x_swconfig_destroy(struct gsw_mt753x *gsw) -{ - unregister_switch(&gsw->swdev); -} diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.h deleted file mode 100644 index f000364ee8b..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_swconfig.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - * Author: Weijie Gao - */ - -#ifndef _MT753X_SWCONFIG_H_ -#define _MT753X_SWCONFIG_H_ - -#ifdef CONFIG_SWCONFIG -#include -#include "mt753x.h" - -int mt753x_swconfig_init(struct gsw_mt753x *gsw); -void mt753x_swconfig_destroy(struct gsw_mt753x *gsw); -#else -static inline int mt753x_swconfig_init(struct gsw_mt753x *gsw) -{ - mt753x_apply_vlan_config(gsw); - - return 0; -} - -static inline void mt753x_swconfig_destroy(struct gsw_mt753x *gsw) -{ -} -#endif - -#endif /* _MT753X_SWCONFIG_H_ */ diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.c b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.c deleted file mode 100644 index 4d88eee8de6..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.c +++ /dev/null @@ -1,183 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2018 MediaTek Inc. - */ - -#include "mt753x.h" -#include "mt753x_regs.h" - -struct mt753x_mapping mt753x_def_mapping[] = { - { - .name = "llllw", - .pvids = { 1, 1, 1, 1, 2, 2, 1 }, - .members = { 0, 0x4f, 0x30 }, - .etags = { 0, 0, 0 }, - .vids = { 0, 1, 2 }, - }, { - .name = "wllll", - .pvids = { 2, 1, 1, 1, 1, 2, 1 }, - .members = { 0, 0x5e, 0x21 }, - .etags = { 0, 0, 0 }, - .vids = { 0, 1, 2 }, - }, { - .name = "lwlll", - .pvids = { 1, 2, 1, 1, 1, 2, 1 }, - .members = { 0, 0x5d, 0x22 }, - .etags = { 0, 0, 0 }, - .vids = { 0, 1, 2 }, - }, -}; - -void mt753x_vlan_ctrl(struct gsw_mt753x *gsw, u32 cmd, u32 val) -{ - int i; - - mt753x_reg_write(gsw, VTCR, - VTCR_BUSY | ((cmd << VTCR_FUNC_S) & VTCR_FUNC_M) | - (val & VTCR_VID_M)); - - for (i = 0; i < 300; i++) { - u32 val = mt753x_reg_read(gsw, VTCR); - - if ((val & VTCR_BUSY) == 0) - break; - - usleep_range(1000, 1100); - } - - if (i == 300) - dev_info(gsw->dev, "vtcr timeout\n"); -} - -static void mt753x_write_vlan_entry(struct gsw_mt753x *gsw, int vlan, u16 vid, - u8 ports, u8 etags) -{ - int port; - u32 val; - - /* vlan port membership */ - if (ports) - mt753x_reg_write(gsw, VAWD1, - IVL_MAC | VTAG_EN | VENTRY_VALID | - ((ports << PORT_MEM_S) & PORT_MEM_M)); - else - mt753x_reg_write(gsw, VAWD1, 0); - - /* egress mode */ - val = 0; - for (port = 0; port < MT753X_NUM_PORTS; port++) { - if (etags & BIT(port)) - val |= ETAG_CTRL_TAG << PORT_ETAG_S(port); - else - val |= ETAG_CTRL_UNTAG << PORT_ETAG_S(port); - } - mt753x_reg_write(gsw, VAWD2, val); - - /* write to vlan table */ - mt753x_vlan_ctrl(gsw, VTCR_WRITE_VLAN_ENTRY, vid); -} - -void mt753x_apply_vlan_config(struct gsw_mt753x *gsw) -{ - int i, j; - u8 tag_ports; - u8 untag_ports; - - /* set all ports as security mode */ - for (i = 0; i < MT753X_NUM_PORTS; i++) - mt753x_reg_write(gsw, PCR(i), - PORT_MATRIX_M | SECURITY_MODE); - - /* check if a port is used in tag/untag vlan egress mode */ - tag_ports = 0; - untag_ports = 0; - - for (i = 0; i < MT753X_NUM_VLANS; i++) { - u8 member = gsw->vlan_entries[i].member; - u8 etags = gsw->vlan_entries[i].etags; - - if (!member) - continue; - - for (j = 0; j < MT753X_NUM_PORTS; j++) { - if (!(member & BIT(j))) - continue; - - if (etags & BIT(j)) - tag_ports |= 1u << j; - else - untag_ports |= 1u << j; - } - } - - /* set all untag-only ports as transparent and the rest as user port */ - for (i = 0; i < MT753X_NUM_PORTS; i++) { - u32 pvc_mode = 0x8100 << STAG_VPID_S; - - if (untag_ports & BIT(i) && !(tag_ports & BIT(i))) - pvc_mode = (0x8100 << STAG_VPID_S) | - (VA_TRANSPARENT_PORT << VLAN_ATTR_S); - - mt753x_reg_write(gsw, PVC(i), pvc_mode); - } - - /* first clear the switch vlan table */ - for (i = 0; i < MT753X_NUM_VLANS; i++) - mt753x_write_vlan_entry(gsw, i, i, 0, 0); - - /* now program only vlans with members to avoid - * clobbering remapped entries in later iterations - */ - for (i = 0; i < MT753X_NUM_VLANS; i++) { - u16 vid = gsw->vlan_entries[i].vid; - u8 member = gsw->vlan_entries[i].member; - u8 etags = gsw->vlan_entries[i].etags; - - if (member) - mt753x_write_vlan_entry(gsw, i, vid, member, etags); - } - - /* Port Default PVID */ - for (i = 0; i < MT753X_NUM_PORTS; i++) { - int vlan = gsw->port_entries[i].pvid; - u16 pvid = 0; - u32 val; - - if (vlan < MT753X_NUM_VLANS && gsw->vlan_entries[vlan].member) - pvid = gsw->vlan_entries[vlan].vid; - - val = mt753x_reg_read(gsw, PPBV1(i)); - val &= ~GRP_PORT_VID_M; - val |= pvid; - mt753x_reg_write(gsw, PPBV1(i), val); - } -} - -struct mt753x_mapping *mt753x_find_mapping(struct device_node *np) -{ - const char *map; - int i; - - if (of_property_read_string(np, "mediatek,portmap", &map)) - return NULL; - - for (i = 0; i < ARRAY_SIZE(mt753x_def_mapping); i++) - if (!strcmp(map, mt753x_def_mapping[i].name)) - return &mt753x_def_mapping[i]; - - return NULL; -} - -void mt753x_apply_mapping(struct gsw_mt753x *gsw, struct mt753x_mapping *map) -{ - int i = 0; - - for (i = 0; i < MT753X_NUM_PORTS; i++) - gsw->port_entries[i].pvid = map->pvids[i]; - - for (i = 0; i < MT753X_NUM_VLANS; i++) { - gsw->vlan_entries[i].member = map->members[i]; - gsw->vlan_entries[i].etags = map->etags[i]; - gsw->vlan_entries[i].vid = map->vids[i]; - } -} diff --git a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.h b/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.h deleted file mode 100644 index c726b8eacdc..00000000000 --- a/target/linux/mediatek/files/drivers/net/phy/mtk/mt753x/mt753x_vlan.h +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2018 MediaTek Inc. - */ - -#ifndef _MT753X_VLAN_H_ -#define _MT753X_VLAN_H_ - -#define MT753X_NUM_PORTS 7 -#define MT753X_NUM_VLANS 4095 -#define MT753X_MAX_VID 4095 -#define MT753X_MIN_VID 0 - -struct gsw_mt753x; - -struct mt753x_port_entry { - u16 pvid; -}; - -struct mt753x_vlan_entry { - u16 vid; - u8 member; - u8 etags; -}; - -struct mt753x_mapping { - char *name; - u16 pvids[MT753X_NUM_PORTS]; - u8 members[MT753X_NUM_VLANS]; - u8 etags[MT753X_NUM_VLANS]; - u16 vids[MT753X_NUM_VLANS]; -}; - -extern struct mt753x_mapping mt753x_defaults[]; - -void mt753x_vlan_ctrl(struct gsw_mt753x *gsw, u32 cmd, u32 val); -void mt753x_apply_vlan_config(struct gsw_mt753x *gsw); -struct mt753x_mapping *mt753x_find_mapping(struct device_node *np); -void mt753x_apply_mapping(struct gsw_mt753x *gsw, struct mt753x_mapping *map); -#endif /* _MT753X_VLAN_H_ */ From e1c0bda3fc9a01c461591864bd0163b052b5783d Mon Sep 17 00:00:00 2001 From: Glen Huang Date: Wed, 26 Apr 2023 22:38:24 +0800 Subject: [PATCH 008/113] kernel: crypto: crypto-rng: select SHA512 for >= 5.14.0 drbg swtiched to use HMAC(SHA-512) since 5.14.0 https://github.com/torvalds/linux/commit/5261cdf457ce3635bf18d393a3c1991dcfaf9d02 Signed-off-by: Glen Huang --- package/kernel/linux/modules/crypto.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk index 4950b94c62d..98bcb9e8747 100644 --- a/package/kernel/linux/modules/crypto.mk +++ b/package/kernel/linux/modules/crypto.mk @@ -827,7 +827,9 @@ $(eval $(call KernelPackage,crypto-rmd160)) define KernelPackage/crypto-rng TITLE:=CryptoAPI random number generation - DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac +kmod-crypto-sha256 + DEPENDS:=+kmod-crypto-hash +kmod-crypto-hmac \ + +LINUX_5_10:kmod-crypto-sha256 \ + +LINUX_5_15:kmod-crypto-sha512 KCONFIG:= \ CONFIG_CRYPTO_DRBG \ CONFIG_CRYPTO_DRBG_HMAC=y \ From 1c5cafa3ebcb6427e95f221eec3ffe27bc7a76c9 Mon Sep 17 00:00:00 2001 From: Eneas U de Queiroz Date: Wed, 26 Apr 2023 08:35:23 -0300 Subject: [PATCH 009/113] openssl: fix low-severity CVE-2023-1255 This applies commit 02ac9c94 to fix this OpenSSL Security Advisory issued on 20th April 2023[1]: Input buffer over-read in AES-XTS implementation on 64 bit ARM (CVE-2023-1255) ============================================================== Severity: Low Issue summary: The AES-XTS cipher decryption implementation for 64 bit ARM platform contains a bug that could cause it to read past the input buffer, leading to a crash. Impact summary: Applications that use the AES-XTS algorithm on the 64 bit ARM platform can crash in rare circumstances. The AES-XTS algorithm is usually used for disk encryption. The AES-XTS cipher decryption implementation for 64 bit ARM platform will read past the end of the ciphertext buffer if the ciphertext size is 4 mod 5 in 16 byte blocks, e.g. 144 bytes or 1024 bytes. If the memory after the ciphertext buffer is unmapped, this will trigger a crash which results in a denial of service. If an attacker can control the size and location of the ciphertext buffer being decrypted by an application using AES-XTS on 64 bit ARM, the application is affected. This is fairly unlikely making this issue a Low severity one. 1. https://www.openssl.org/news/secadv/20230420.txt Signed-off-by: Eneas U de Queiroz --- package/libs/openssl/Makefile | 2 +- ...oid-buffer-overrread-in-AES-XTS-decr.patch | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 package/libs/openssl/patches/220-aesv8-armx.pl-Avoid-buffer-overrread-in-AES-XTS-decr.patch diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile index 2abb348546b..bd1cfed447b 100644 --- a/package/libs/openssl/Makefile +++ b/package/libs/openssl/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=openssl PKG_VERSION:=3.0.8 -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_BUILD_FLAGS:=no-mips16 gc-sections PKG_BUILD_PARALLEL:=1 diff --git a/package/libs/openssl/patches/220-aesv8-armx.pl-Avoid-buffer-overrread-in-AES-XTS-decr.patch b/package/libs/openssl/patches/220-aesv8-armx.pl-Avoid-buffer-overrread-in-AES-XTS-decr.patch new file mode 100644 index 00000000000..d6a45aec21e --- /dev/null +++ b/package/libs/openssl/patches/220-aesv8-armx.pl-Avoid-buffer-overrread-in-AES-XTS-decr.patch @@ -0,0 +1,39 @@ +From 02ac9c9420275868472f33b01def01218742b8bb Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Mon, 17 Apr 2023 16:51:20 +0200 +Subject: [PATCH] aesv8-armx.pl: Avoid buffer overrread in AES-XTS decryption + +Original author: Nevine Ebeid (Amazon) +Fixes: CVE-2023-1255 + +The buffer overread happens on decrypts of 4 mod 5 sizes. +Unless the memory just after the buffer is unmapped this is harmless. + +Reviewed-by: Paul Dale +Reviewed-by: Tom Cosgrove +(Merged from https://github.com/openssl/openssl/pull/20759) + +(cherry picked from commit 72dfe46550ee1f1bbfacd49f071419365bc23304) + +diff --git a/crypto/aes/asm/aesv8-armx.pl b/crypto/aes/asm/aesv8-armx.pl +index 6a7bf05d1b..bd583e2c89 100755 +--- a/crypto/aes/asm/aesv8-armx.pl ++++ b/crypto/aes/asm/aesv8-armx.pl +@@ -3353,7 +3353,7 @@ $code.=<<___ if ($flavour =~ /64/); + .align 4 + .Lxts_dec_tail4x: + add $inp,$inp,#16 +- vld1.32 {$dat0},[$inp],#16 ++ tst $tailcnt,#0xf + veor $tmp1,$dat1,$tmp0 + vst1.8 {$tmp1},[$out],#16 + veor $tmp2,$dat2,$tmp2 +@@ -3362,6 +3362,8 @@ $code.=<<___ if ($flavour =~ /64/); + veor $tmp4,$dat4,$tmp4 + vst1.8 {$tmp3-$tmp4},[$out],#32 + ++ b.eq .Lxts_dec_abort ++ vld1.32 {$dat0},[$inp],#16 + b .Lxts_done + .align 4 + .Lxts_outer_dec_tail: From 2bab7d273e02bb463c121233d5d7e74157844305 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 15:28:01 +0200 Subject: [PATCH 010/113] kernel: Initialize RNG using CPU RNG and bootloader This activates the following kernel options by default: * CONFIG_RANDOM_TRUST_CPU * CONFIG_RANDOM_TRUST_BOOTLOADER With these option Linux will also use data from the CPU RNG e.g. RDRAND and the bootloader to initialize the Linux RNG if such sources are available. These random bits are used in addition to the other sources, no other sources are getting deactivated. I read that the Chacha mixer isn't vulnerable to injected entropy, so this should not be a problem even if these sources might inject bad random data. The Linux kernel suggests to activate both options, Debian also activates them. This does not increase kernel code size. Signed-off-by: Hauke Mehrtens --- target/linux/generic/config-5.10 | 4 ++-- target/linux/generic/config-5.15 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index cde0fdb0a04..33583298485 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -4704,8 +4704,8 @@ CONFIG_PWRSEQ_SIMPLE=y # CONFIG_RALINK is not set # CONFIG_RANDOM32_SELFTEST is not set # CONFIG_RANDOMIZE_BASE is not set -# CONFIG_RANDOM_TRUST_BOOTLOADER is not set -# CONFIG_RANDOM_TRUST_CPU is not set +CONFIG_RANDOM_TRUST_BOOTLOADER=y +CONFIG_RANDOM_TRUST_CPU=y # CONFIG_RAPIDIO is not set # CONFIG_RAS is not set # CONFIG_RAW_DRIVER is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 239a6452310..004688c4707 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -4946,8 +4946,8 @@ CONFIG_PWRSEQ_SIMPLE=y # CONFIG_RANDOM32_SELFTEST is not set # CONFIG_RANDOMIZE_BASE is not set # CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT is not set -# CONFIG_RANDOM_TRUST_BOOTLOADER is not set -# CONFIG_RANDOM_TRUST_CPU is not set +CONFIG_RANDOM_TRUST_BOOTLOADER=y +CONFIG_RANDOM_TRUST_CPU=y # CONFIG_RAPIDIO is not set # CONFIG_RAS is not set # CONFIG_RAW_DRIVER is not set From ff536eca585431a9c90b9e835df818a27decf730 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 15:07:36 +0200 Subject: [PATCH 011/113] kernel: Activate CONFIG_SLAB_FREELIST_HARDENED This activates some extra checks in SLAB or SLUB to make it harder to execute kernel heap exploits. This adds a minor performance degradation which I haven't measured-. Many mainstream Linux distributions also activate this option. Signed-off-by: Hauke Mehrtens --- target/linux/generic/config-5.10 | 2 +- target/linux/generic/config-5.15 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 33583298485..5b2aad99c36 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -5463,7 +5463,7 @@ CONFIG_SIGNALFD=y # CONFIG_SKY2_DEBUG is not set # CONFIG_SLAB is not set CONFIG_SLABINFO=y -# CONFIG_SLAB_FREELIST_HARDENED is not set +CONFIG_SLAB_FREELIST_HARDENED=y # CONFIG_SLAB_FREELIST_RANDOM is not set CONFIG_SLAB_MERGE_DEFAULT=y # CONFIG_SLHC is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 004688c4707..eae1adb5dd8 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -5753,7 +5753,7 @@ CONFIG_SIGNALFD=y # CONFIG_SKY2_DEBUG is not set # CONFIG_SLAB is not set CONFIG_SLABINFO=y -# CONFIG_SLAB_FREELIST_HARDENED is not set +CONFIG_SLAB_FREELIST_HARDENED=y # CONFIG_SLAB_FREELIST_RANDOM is not set CONFIG_SLAB_MERGE_DEFAULT=y # CONFIG_SLHC is not set From 1f41b6bb83a528a67934c5504094903afff7ab15 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 19:36:22 +0200 Subject: [PATCH 012/113] kernel: Activate CONFIG_SCHED_STACK_END_CHECK This activates the CONFIG_SCHED_STACK_END_CHECK option. The kernel will check if the kernel stack overflowed in the schedule() function. This just adds a very small computational overhead. This option is activated in Debian by default. Signed-off-by: Hauke Mehrtens --- target/linux/generic/config-5.10 | 2 +- target/linux/generic/config-5.15 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 5b2aad99c36..9645072a558 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -5017,7 +5017,7 @@ CONFIG_SCHED_HRTICK=y # CONFIG_SCHED_MC is not set CONFIG_SCHED_OMIT_FRAME_POINTER=y # CONFIG_SCHED_SMT is not set -# CONFIG_SCHED_STACK_END_CHECK is not set +CONFIG_SCHED_STACK_END_CHECK=y # CONFIG_SCHED_TRACER is not set # CONFIG_SCR24X is not set # CONFIG_SCSI is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index eae1adb5dd8..3d5a8606734 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -5274,7 +5274,7 @@ CONFIG_SCHED_HRTICK=y # CONFIG_SCHED_MC is not set CONFIG_SCHED_OMIT_FRAME_POINTER=y # CONFIG_SCHED_SMT is not set -# CONFIG_SCHED_STACK_END_CHECK is not set +CONFIG_SCHED_STACK_END_CHECK=y # CONFIG_SCHED_TRACER is not set # CONFIG_SCR24X is not set # CONFIG_SCSI is not set From 626c84340d54c07f46f6ae111ff4389980a86c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= Date: Sat, 29 Apr 2023 07:41:32 +0100 Subject: [PATCH 013/113] kernel: mtk_bmt: refactor to avoid deep recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Linksys E8450 (mt7622) device running current master has recently started crashing: [ 0.562900] mtk-ecc 1100e000.ecc: probed [ 0.570254] spi-nand spi2.0: Fidelix SPI NAND was found. [ 0.575576] spi-nand spi2.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64 [ 0.583780] mtk-snand 1100d000.spi: ECC strength: 4 bits per 512 bytes [ 0.682930] Insufficient stack space to handle exception! [ 0.682939] ESR: 0x0000000096000047 -- DABT (current EL) [ 0.682946] FAR: 0xffffffc008c47fe0 [ 0.682948] Task stack: [0xffffffc008c48000..0xffffffc008c4c000] [ 0.682951] IRQ stack: [0xffffffc008008000..0xffffffc00800c000] [ 0.682954] Overflow stack: [0xffffff801feb00a0..0xffffff801feb10a0] [ 0.682959] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G S 5.15.107 #0 [ 0.682966] Hardware name: Linksys E8450 (DT) [ 0.682969] pstate: 800000c5 (Nzcv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.682975] pc : dequeue_entity+0x0/0x250 [ 0.682988] lr : dequeue_task_fair+0x98/0x290 [ 0.682992] sp : ffffffc008c48030 [ 0.682994] x29: ffffffc008c48030 x28: 0000000000000001 x27: ffffff801feb6380 [ 0.683004] x26: 0000000000000001 x25: ffffff801feb6300 x24: ffffff8000068000 [ 0.683011] x23: 0000000000000001 x22: 0000000000000009 x21: 0000000000000000 [ 0.683017] x20: ffffff801feb6380 x19: ffffff8000068080 x18: 0000000017a740a6 [ 0.683024] x17: ffffffc008bae748 x16: ffffffc008bae6d8 x15: ffffffffffffffff [ 0.683031] x14: ffffffffffffffff x13: 0000000000000000 x12: 0000000f00000101 [ 0.683038] x11: 0000000000000449 x10: 0000000000000127 x9 : 0000000000000000 [ 0.683044] x8 : 0000000000000125 x7 : 0000000000116da1 x6 : 0000000000116da1 [ 0.683051] x5 : 00000000001165a1 x4 : ffffff801feb6e00 x3 : 0000000000000000 [ 0.683058] x2 : 0000000000000009 x1 : ffffff8000068080 x0 : ffffff801feb6380 [ 0.683066] Kernel panic - not syncing: kernel stack overflow [ 0.683069] SMP: stopping secondary CPUs [ 1.648361] SMP: failed to stop secondary CPUs 0-1 [ 1.648366] Kernel Offset: disabled [ 1.648368] CPU features: 0x00003000,00000802 [ 1.648372] Memory Limit: none Several factors contributed to this issue: 1. The mtk_bmt driver recursively calls its scan_bmt() helper function during device initialization, while looking for a valid block mapping table (BMT). 2. Commit fa4dc86e98 ("kernel: backport MEMREAD ioctl"): - increased the size of some stack-allocated structures (like struct mtd_oob_ops, used in bbt_nand_read(), which is indirectly called from scan_bmt()), - increased the stack size for some functions (for example, spinand_mtd_read(), which is indirectly called from scan_bmt(), now uses an extra stack-allocated struct mtd_ecc_stats). 3. OpenWrt currently compiles the kernel with the -fno-optimize-sibling-calls flag, which prevents tail-call optimization. Collectively, all of these factors caused stack usage in the mtk_bmt driver to grow excessively large, triggering stack overflows. Recursion is not really necessary in scan_bmt() as it simply iterates over flash memory blocks in reverse order, looking for a valid BMT. Refactor the logic contained in the scan_bmt() and read_bmt() functions in target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c so that deep recursion is prevented (and therefore also any potential stack overflows it may cause). Link: https://lists.openwrt.org/pipermail/openwrt-devel/2023-April/040872.html Signed-off-by: Michał Kępień --- .../files/drivers/mtd/nand/mtk_bmt_v2.c | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c index 2770376e98b..6b06948c0f4 100644 --- a/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c +++ b/target/linux/generic/files/drivers/mtd/nand/mtk_bmt_v2.c @@ -191,36 +191,6 @@ static u16 get_bmt_index(struct bbmt *bmt) return 0; } -static int -read_bmt(u16 block, unsigned char *dat, unsigned char *fdm, int fdm_len) -{ - u32 len = bmtd.bmt_pgs << bmtd.pg_shift; - - return bbt_nand_read(blk_pg(block), dat, len, fdm, fdm_len); -} - -static struct bbbt *scan_bmt(u16 block) -{ - u8 fdm[4]; - - if (block < bmtd.pool_lba) - return NULL; - - if (read_bmt(block, bmtd.bbt_buf, fdm, sizeof(fdm))) - return scan_bmt(block - 1); - - if (is_valid_bmt(bmtd.bbt_buf, fdm)) { - bmtd.bmt_blk_idx = get_bmt_index(bmt_tbl((struct bbbt *)bmtd.bbt_buf)); - if (bmtd.bmt_blk_idx == 0) { - pr_info("[BBT] FATAL ERR: bmt block index is wrong!\n"); - return NULL; - } - pr_info("[BBT] BMT.v2 is found at 0x%x\n", block); - return (struct bbbt *)bmtd.bbt_buf; - } else - return scan_bmt(block - 1); -} - /* Write the Burner Bad Block Table to Nand Flash * n - write BMT to bmt_tbl[n] */ @@ -472,7 +442,30 @@ static int mtk_bmt_init_v2(struct device_node *np) /* Scanning start from the first page of the last block * of whole flash */ - bmtd.bbt = scan_bmt(bmtd.total_blks - 1); + bmtd.bbt = NULL; + for (u16 block = bmtd.total_blks - 1; !bmtd.bbt && block >= bmtd.pool_lba; block--) { + u8 fdm[4]; + + if (bbt_nand_read(blk_pg(block), bmtd.bbt_buf, bufsz, fdm, sizeof(fdm))) { + /* Read failed, try the previous block */ + continue; + } + + if (!is_valid_bmt(bmtd.bbt_buf, fdm)) { + /* No valid BMT found, try the previous block */ + continue; + } + + bmtd.bmt_blk_idx = get_bmt_index(bmt_tbl((struct bbbt *)bmtd.bbt_buf)); + if (bmtd.bmt_blk_idx == 0) { + pr_info("[BBT] FATAL ERR: bmt block index is wrong!\n"); + break; + } + + pr_info("[BBT] BMT.v2 is found at 0x%x\n", block); + bmtd.bbt = (struct bbbt *)bmtd.bbt_buf; + } + if (!bmtd.bbt) { /* BMT not found */ if (bmtd.total_blks > BB_TABLE_MAX + BMT_TABLE_MAX) { From 4c54ec74fccb422dc34665adf6d1f8b8eede203e Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 26 Apr 2023 12:06:07 +0200 Subject: [PATCH 014/113] tools/coreutils: update to 9.3 Update to latest bugfix release. Remove upstreamed patches: - 001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch - 002-date-diagnose-f-read-errors.patch Signed-off-by: Nick Hainke --- tools/coreutils/Makefile | 4 +- ...flink-auto-to-fallback-in-more-cases.patch | 126 ------------------ .../002-date-diagnose-f-read-errors.patch | 20 --- 3 files changed, 2 insertions(+), 148 deletions(-) delete mode 100644 tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch delete mode 100644 tools/coreutils/patches/002-date-diagnose-f-read-errors.patch diff --git a/tools/coreutils/Makefile b/tools/coreutils/Makefile index 23f2ea2cfbf..f799e83c5b6 100644 --- a/tools/coreutils/Makefile +++ b/tools/coreutils/Makefile @@ -8,11 +8,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=coreutils PKG_CPE_ID:=cpe:/a:gnu:coreutils -PKG_VERSION:=9.2 +PKG_VERSION:=9.3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/coreutils -PKG_HASH:=6885ff47b9cdb211de47d368c17853f406daaf98b148aaecdf10de29cc04b0b3 +PKG_HASH:=adbcfcfe899235b71e8768dcf07cd532520b7f54f9a8064843f8d199a904bbaa HOST_BUILD_PARALLEL := 1 diff --git a/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch b/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch deleted file mode 100644 index 5416177a15d..00000000000 --- a/tools/coreutils/patches/001-copy-fix-reflink-auto-to-fallback-in-more-cases.patch +++ /dev/null @@ -1,126 +0,0 @@ -From 093a8b4bfaba60005f14493ce7ef11ed665a0176 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Thu, 23 Mar 2023 13:19:04 +0000 -Subject: [PATCH] copy: fix --reflink=auto to fallback in more cases - -On restricted systems like android or some containers, -FICLONE could return EPERM, EACCES, or ENOTTY, -which would have induced the command to fail to copy -rather than falling back to a more standard copy. - -* src/copy.c (is_terminal_failure): A new function refactored -from handle_clone_fail(). -(is_CLONENOTSUP): Merge in the handling of EACCES, ENOTTY, EPERM -as they also pertain to determination of whether cloning is supported -if we ever use this function in that context. -(handle_clone_fail): Use is_terminal_failure() in all cases, -so that we assume a terminal failure in less errno cases. -* NEWS: Mention the bug fix. -Addresses https://bugs.gnu.org/62404 ---- ---- a/src/copy.c -+++ b/src/copy.c -@@ -278,15 +278,27 @@ create_hole (int fd, char const *name, b - } - - --/* Whether the errno from FICLONE, or copy_file_range -- indicates operation is not supported for this file or file system. */ -+/* Whether the errno indicates the operation is a transient failure. -+ I.e., a failure that would indicate the operation _is_ supported, -+ but has failed in a terminal way. */ -+ -+static bool -+is_terminal_error (int err) -+{ -+ return err == EIO || err == ENOMEM || err == ENOSPC || err == EDQUOT; -+} -+ -+ -+/* Whether the errno from FICLONE, or copy_file_range indicates -+ the operation is not supported/allowed for this file or process. */ - - static bool - is_CLONENOTSUP (int err) - { -- return err == ENOSYS || is_ENOTSUP (err) -+ return err == ENOSYS || err == ENOTTY || is_ENOTSUP (err) - || err == EINVAL || err == EBADF -- || err == EXDEV || err == ETXTBSY; -+ || err == EXDEV || err == ETXTBSY -+ || err == EPERM || err == EACCES; - } - - -@@ -339,20 +351,18 @@ sparse_copy (int src_fd, int dest_fd, ch - { - copy_debug.offload = COPY_DEBUG_UNSUPPORTED; - -- if (is_CLONENOTSUP (errno)) -- break; -- -- /* copy_file_range might not be enabled in seccomp filters, -- so retry with a standard copy. EPERM can also occur -- for immutable files, but that would only be in the edge case -- where the file is made immutable after creating/truncating, -+ /* Consider operation unsupported only if no data copied. -+ For example, EPERM could occur if copy_file_range not enabled -+ in seccomp filters, so retry with a standard copy. EPERM can -+ also occur for immutable files, but that would only be in the -+ edge case where the file is made immutable after creating, - in which case the (more accurate) error is still shown. */ -- if (errno == EPERM && *total_n_read == 0) -+ if (*total_n_read == 0 && is_CLONENOTSUP (errno)) - break; - - /* ENOENT was seen sometimes across CIFS shares, resulting in - no data being copied, but subsequent standard copies succeed. */ -- if (errno == ENOENT && *total_n_read == 0) -+ if (*total_n_read == 0 && errno == ENOENT) - break; - - if (errno == EINTR) -@@ -1172,17 +1182,15 @@ handle_clone_fail (int dst_dirfd, char c - char const* src_name, char const* dst_name, - int dest_desc, bool new_dst, enum Reflink_type reflink_mode) - { -- /* If the clone operation is creating the destination, -- then don't try and cater for all non transient file system errors, -- and instead only cater for specific transient errors. */ -- bool transient_failure; -- if (dest_desc < 0) /* currently for fclonefileat(). */ -- transient_failure = errno == EIO || errno == ENOMEM -- || errno == ENOSPC || errno == EDQUOT; -- else /* currently for FICLONE. */ -- transient_failure = ! is_CLONENOTSUP (errno); -+ /* When the clone operation fails, report failure only with errno values -+ known to mean trouble when the clone is supported and called properly. -+ Do not report failure merely because !is_CLONENOTSUP (errno), -+ as systems may yield oddball errno values here with FICLONE. -+ Also is_CLONENOTSUP() is not appropriate for the range of errnos -+ possible from fclonefileat(), so it's more consistent to avoid. */ -+ bool report_failure = is_terminal_error (errno); - -- if (reflink_mode == REFLINK_ALWAYS || transient_failure) -+ if (reflink_mode == REFLINK_ALWAYS || report_failure) - error (0, errno, _("failed to clone %s from %s"), - quoteaf_n (0, dst_name), quoteaf_n (1, src_name)); - -@@ -1190,14 +1198,14 @@ handle_clone_fail (int dst_dirfd, char c - but cloned no data. */ - if (new_dst /* currently not for fclonefileat(). */ - && reflink_mode == REFLINK_ALWAYS -- && ((! transient_failure) || lseek (dest_desc, 0, SEEK_END) == 0) -+ && ((! report_failure) || lseek (dest_desc, 0, SEEK_END) == 0) - && unlinkat (dst_dirfd, dst_relname, 0) != 0 && errno != ENOENT) - error (0, errno, _("cannot remove %s"), quoteaf (dst_name)); - -- if (! transient_failure) -+ if (! report_failure) - copy_debug.reflink = COPY_DEBUG_UNSUPPORTED; - -- if (reflink_mode == REFLINK_ALWAYS || transient_failure) -+ if (reflink_mode == REFLINK_ALWAYS || report_failure) - return false; - - return true; diff --git a/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch b/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch deleted file mode 100644 index 5174af1aa0c..00000000000 --- a/tools/coreutils/patches/002-date-diagnose-f-read-errors.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 9c5e542fd190a14431092e3b6cb45d18fe95f26f Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Tue, 28 Mar 2023 01:52:43 -0700 -Subject: [PATCH] date: diagnose -f read errors - -* src/date.c (batch_convert): Diagnose read errors, fixing Bug#62497. ---- ---- a/src/date.c -+++ b/src/date.c -@@ -368,7 +368,9 @@ batch_convert (char const *input_filenam - ssize_t line_length = getline (&line, &buflen, in_stream); - if (line_length < 0) - { -- /* FIXME: detect/handle error here. */ -+ if (ferror (in_stream)) -+ die (EXIT_FAILURE, errno, _("%s: read error"), -+ quotef (input_filename)); - break; - } - From ec6bcda8e49815efeee845da50defc85ae068b79 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Mon, 24 Apr 2023 08:21:20 +0200 Subject: [PATCH 015/113] tools/patchelf: update to 0.18.0 Release Notes: https://github.com/NixOS/patchelf/releases/tag/0.18.0 Signed-off-by: Nick Hainke --- tools/patchelf/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/patchelf/Makefile b/tools/patchelf/Makefile index 3ddd611cd84..bbda3a9e40a 100644 --- a/tools/patchelf/Makefile +++ b/tools/patchelf/Makefile @@ -7,11 +7,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=patchelf -PKG_VERSION:=0.17.2 +PKG_VERSION:=0.18.0 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://github.com/NixOS/patchelf/releases/download/$(PKG_VERSION) -PKG_HASH:=bae2ea376072e422c196218dd9bdef0548ccc08da4de9f36b4672df84ea2d8e2 +PKG_HASH:=1952b2a782ba576279c211ee942e341748fdb44997f704dd53def46cd055470b HOST_BUILD_PARALLEL:=1 HOST_FIXUP:=autoreconf From 512bb17f3e2a15d52191bb45d63c8d8739f85584 Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Fri, 7 Feb 2020 12:50:22 +0100 Subject: [PATCH 016/113] umbim: add support for non-dhcp mode There are mbim compatible wwan modules available which do not support the dhcp autoconfiguration. (e.g. gemalto Cinterion ELS81) This adds the possibility to get the configuration parameters from mbim. Signed-off-by: Martin Schiller Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 88 ++++++++++++++----- 1 file changed, 65 insertions(+), 23 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 64bb8176a04..492e06829de 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -19,6 +19,7 @@ proto_mbim_init_config() { proto_config_add_string auth proto_config_add_string username proto_config_add_string password + proto_config_add_boolean dhcp proto_config_add_defaults } @@ -27,8 +28,8 @@ _proto_mbim_setup() { local tid=2 local ret - local device apn pincode delay allow_roaming allow_partner $PROTO_DEFAULT_OPTIONS - json_get_vars device apn pincode delay auth username password allow_roaming allow_partner $PROTO_DEFAULT_OPTIONS + local device apn pincode delay allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS [ -n "$ctl_device" ] && device=$ctl_device @@ -153,28 +154,69 @@ _proto_mbim_setup() { done tid=$((tid + 1)) + echo "mbim[$$]" "Connected" + + if [ "$dhcp" = 0 ]; then + echo "mbim[$$]" "Setting up $ifname" + eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') + tid=$((tid + 1)) + + proto_init_update "$ifname" 1 + proto_send_update "$interface" + + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ipaddr + json_add_string "" "$ipv4address" + json_close_array + json_add_string gateway "$ipv4gateway" + json_add_array dns + json_add_string "" "$ipv4dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ip6addr + json_add_string "" "$ipv6address" + json_close_array + json_add_string ip6gw "$ipv6gateway" + json_add_array dns + json_add_string "" "$ipv6dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + else + echo "mbim[$$]" "Starting DHCP on $ifname" + proto_init_update "$ifname" 1 + proto_send_update "$interface" + + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + fi + uci_set_state network $interface tid "$tid" - - echo "mbim[$$]" "Connected, starting DHCP" - proto_init_update "$ifname" 1 - proto_send_update "$interface" - - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "dhcp" - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" - - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" } proto_mbim_setup() { From 0be14c622b809e7d3551c21e7ac6dbae6b0403f8 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Tue, 15 Feb 2022 01:44:32 +0100 Subject: [PATCH 017/113] umbim: connect session for only the selected PDP type Previous implementation automatically set up connections for both IPv4 and IPv6, even if one of them isn't supported. Respect the "pdptype" option in the same way, as it is done for QMI or NCM, and only start the respective PDN sessions, if set. Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 104 ++++++++++-------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 492e06829de..08f95ddc6f2 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -20,6 +20,7 @@ proto_mbim_init_config() { proto_config_add_string username proto_config_add_string password proto_config_add_boolean dhcp + proto_config_add_string pdptype proto_config_add_defaults } @@ -28,8 +29,8 @@ _proto_mbim_setup() { local tid=2 local ret - local device apn pincode delay allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS - json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp $PROTO_DEFAULT_OPTIONS + local device apn pincode delay allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS [ -n "$ctl_device" ] && device=$ctl_device @@ -147,8 +148,11 @@ _proto_mbim_setup() { } tid=$((tid + 1)) + pdptype=$(echo "$pdptype" | awk '{print tolower($0)}') + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ipv4v6" + echo "mbim[$$]" "Connect to network" - while ! umbim $DBG -n -t $tid -d $device connect "$apn" "$auth" "$username" "$password"; do + while ! umbim $DBG -n -t $tid -d $device connect "$pdptype:$apn" "$auth" "$username" "$password"; do tid=$((tid + 1)) sleep 1; done @@ -164,56 +168,64 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "static" - json_add_array ipaddr - json_add_string "" "$ipv4address" - json_close_array - json_add_string gateway "$ipv4gateway" - json_add_array dns - json_add_string "" "$ipv4dnsserver" - json_close_array - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ipaddr + json_add_string "" "$ipv4address" + json_close_array + json_add_string gateway "$ipv4gateway" + json_add_array dns + json_add_string "" "$ipv4dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" - json_add_string proto "static" - json_add_array ip6addr - json_add_string "" "$ipv6address" - json_close_array - json_add_string ip6gw "$ipv6gateway" - json_add_array dns - json_add_string "" "$ipv6dnsserver" - json_close_array - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "static" + json_add_array ip6addr + json_add_string "" "$ipv6address" + json_close_array + json_add_string ip6gw "$ipv6gateway" + json_add_array dns + json_add_string "" "$ipv6dnsserver" + json_close_array + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } else echo "mbim[$$]" "Starting DHCP on $ifname" proto_init_update "$ifname" 1 proto_send_update "$interface" - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "dhcp" - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" + [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" + json_add_string proto "dhcpv6" + json_add_string extendprefix 1 + proto_add_dynamic_defaults + json_close_object + ubus call network add_dynamic "$(json_dump)" + } fi uci_set_state network $interface tid "$tid" From da84eddedbf0abc8e17b0bfbeac53de1bca1a918 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 9 Jan 2023 22:08:07 +0100 Subject: [PATCH 018/113] umbim: fail connect step immediately Subsequent calls to 'umbim connect' do not have any effect if a failure occured, and in such case an infinite loop without timeout is created, leading to possibility of interface stuck at connecting forever. Drop this loop, and issue MBIM disconnect properly, so netifd can restart from scratch. This issue can be observed with Sierra EM7455 at changing APN, which causes network re-registration by default, and a MBIM transaction timeout, which is resolved on next interface bringup by netifd. Signed-off-by: Lech Perczak --- .../network/utils/umbim/files/lib/netifd/proto/mbim.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 08f95ddc6f2..c6fa6665ef3 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -152,10 +152,13 @@ _proto_mbim_setup() { [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ipv4v6" echo "mbim[$$]" "Connect to network" - while ! umbim $DBG -n -t $tid -d $device connect "$pdptype:$apn" "$auth" "$username" "$password"; do + umbim $DBG -n -t $tid -d $device connect "$pdptype:$apn" "$auth" "$username" "$password" || { + echo "mbim[$$]" "Failed to connect bearer" tid=$((tid + 1)) - sleep 1; - done + umbim $DBG -t $tid -d "$device" disconnect + proto_notify_error "$interface" CONNECT_FAILED + return 1 + } tid=$((tid + 1)) echo "mbim[$$]" "Connected" From 356a6f0eee93ffd03e8f398446ceded144c6237f Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 21 Feb 2022 22:48:10 +0100 Subject: [PATCH 019/113] umbim: detect actual connection IP type Current implementation needlessly creates both IPv4 and IPv6 sub-interfaces for single-stack IP types. Limit this only to selected IP type. While at that, ensure that IP type is also passed to umbim during "connect" phase. In addition, detect the actual established connection type returned by umbim and set up subinterfaces according to that, not to requested configuration. While at that, allow empty IP type explicitly, interpreted as "any" according to MBIM specification. Signed-off-by: Lech Perczak --- .../utils/umbim/files/lib/netifd/proto/mbim.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index c6fa6665ef3..c5f36632710 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -149,10 +149,13 @@ _proto_mbim_setup() { tid=$((tid + 1)) pdptype=$(echo "$pdptype" | awk '{print tolower($0)}') - [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ipv4v6" + local req_pdptype="" # Pass "default" PDP type to umbim if unconfigured + [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && req_pdptype="$pdptype:" + + local connect_state echo "mbim[$$]" "Connect to network" - umbim $DBG -n -t $tid -d $device connect "$pdptype:$apn" "$auth" "$username" "$password" || { + connect_state=$(umbim $DBG -n -t $tid -d $device connect "$req_pdptype$apn" "$auth" "$username" "$password") || { echo "mbim[$$]" "Failed to connect bearer" tid=$((tid + 1)) umbim $DBG -t $tid -d "$device" disconnect @@ -161,6 +164,9 @@ _proto_mbim_setup() { } tid=$((tid + 1)) + echo "$connect_state" + local iptype="$(echo "$connect_state" | grep iptype: | awk '{print $4}')" + echo "mbim[$$]" "Connected" if [ "$dhcp" = 0 ]; then @@ -171,7 +177,7 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" - [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { + [ "$iptype" != "ipv6" ] && { json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" @@ -188,7 +194,7 @@ _proto_mbim_setup() { ubus call network add_dynamic "$(json_dump)" } - [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + [ "$iptype" != "ipv4" ] && { json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" From 9bb4b9a968ab72aaca199a6c21b29adbeb83a839 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 19 Jul 2021 19:04:09 +0200 Subject: [PATCH 020/113] umbim: use IP configuration provided by MBIM by default Previously, DHCP was used. According to MBIM Specification v1.0 errata 1 [1], section 10.5.20, MBIM_CID_IP_CONFIGURATION, if MBIM information element containing IP configuration is available, host shall use it, and fall back to in-band mechanisms to acquire it therwise - therefore make static configuration the default. [1] https://www.usb.org/document-library/mobile-broadband-interface-model-v10-errata-1-and-adopters-agreement Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index c5f36632710..3867411818a 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -169,7 +169,7 @@ _proto_mbim_setup() { echo "mbim[$$]" "Connected" - if [ "$dhcp" = 0 ]; then + if [ -z "$dhcp" -o "$dhcp" = 0 ]; then echo "mbim[$$]" "Setting up $ifname" eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') tid=$((tid + 1)) From c84bf89b3a8f6c93ad30a906b514edcf0077bb51 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 19 Jul 2021 19:15:53 +0200 Subject: [PATCH 021/113] umbim: inherit "peerdns" option from parent interface MBIM protocol handler should intherit "peerdns" options from parent interface on sub-interfaces, otherwise upstream DNS servers are applied regardless of configuration. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 3867411818a..133c6ef5e6a 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -187,7 +187,7 @@ _proto_mbim_setup() { json_close_array json_add_string gateway "$ipv4gateway" json_add_array dns - json_add_string "" "$ipv4dnsserver" + [ "$peerdns" = 0 ] || json_add_string "" "$ipv4dnsserver" json_close_array proto_add_dynamic_defaults json_close_object @@ -204,7 +204,7 @@ _proto_mbim_setup() { json_close_array json_add_string ip6gw "$ipv6gateway" json_add_array dns - json_add_string "" "$ipv6dnsserver" + [ "$peerdns" = 0 ] || json_add_string "" "$ipv6dnsserver" json_close_array proto_add_dynamic_defaults json_close_object From c1e0d077444b7570d64772338d81db336c94ea94 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 19 Jul 2021 19:26:02 +0200 Subject: [PATCH 022/113] umbim: inherit firewall zone membership from parent interface Fix an issue where subinterfaces were not added to the same firewall zone as their parent. Inspired by 64bb88841fb. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 133c6ef5e6a..e7866340aed 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -169,6 +169,8 @@ _proto_mbim_setup() { echo "mbim[$$]" "Connected" + local zone="$(fw3 -q network "$interface" 2>/dev/null)" + if [ -z "$dhcp" -o "$dhcp" = 0 ]; then echo "mbim[$$]" "Setting up $ifname" eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') @@ -190,6 +192,7 @@ _proto_mbim_setup() { [ "$peerdns" = 0 ] || json_add_string "" "$ipv4dnsserver" json_close_array proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" } @@ -207,6 +210,7 @@ _proto_mbim_setup() { [ "$peerdns" = 0 ] || json_add_string "" "$ipv6dnsserver" json_close_array proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" } @@ -221,6 +225,7 @@ _proto_mbim_setup() { json_add_string ifname "@$interface" json_add_string proto "dhcp" proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" } @@ -232,6 +237,7 @@ _proto_mbim_setup() { json_add_string proto "dhcpv6" json_add_string extendprefix 1 proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" } From 03692dee736b98ba419d4e21e82819f93b637256 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 19 Jul 2021 21:16:08 +0200 Subject: [PATCH 023/113] umbim: restructure IPv4/IPv6 handling Check whether interface is configured per IP type, not per DHCP. This is preparation to allow fallback to DHCP if static IP configuration is not available, which is the default option for MBIM modems Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 54 +++++++++---------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index e7866340aed..9af5b69ac11 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -171,15 +171,15 @@ _proto_mbim_setup() { local zone="$(fw3 -q network "$interface" 2>/dev/null)" - if [ -z "$dhcp" -o "$dhcp" = 0 ]; then - echo "mbim[$$]" "Setting up $ifname" - eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') - tid=$((tid + 1)) + echo "mbim[$$]" "Setting up $ifname" + eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') + tid=$((tid + 1)) - proto_init_update "$ifname" 1 - proto_send_update "$interface" + proto_init_update "$ifname" 1 + proto_send_update "$interface" - [ "$iptype" != "ipv6" ] && { + [ "$iptype" != "ipv6" ] && { + if [ -z "$dhcp" -o "$dhcp" = 0 ]; then json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" @@ -195,9 +195,21 @@ _proto_mbim_setup() { [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" - } + else + echo "mbim[$$]" "Starting DHCP on $ifname" + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" + json_add_string proto "dhcp" + proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" + json_close_object + ubus call network add_dynamic "$(json_dump)" + fi + } - [ "$iptype" != "ipv4" ] && { + [ "$iptype" != "ipv4" ] && { + if [ -z "$dhcp" -o "$dhcp" = 0 ]; then json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" @@ -213,24 +225,8 @@ _proto_mbim_setup() { [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" - } - else - echo "mbim[$$]" "Starting DHCP on $ifname" - proto_init_update "$ifname" 1 - proto_send_update "$interface" - - [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv4v6" ] && { - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" - json_add_string proto "dhcp" - proto_add_dynamic_defaults - [ -n "$zone" ] && json_add_string zone "$zone" - json_close_object - ubus call network add_dynamic "$(json_dump)" - } - - [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { + else + echo "mbim[$$]" "Starting DHCPv6 on $ifname" json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" @@ -240,8 +236,8 @@ _proto_mbim_setup() { [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" - } - fi + fi + } uci_set_state network $interface tid "$tid" } From 464d81fe4a831181b2bb2a03b50442a86f3ce0be Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 9 Jan 2023 22:54:07 +0100 Subject: [PATCH 024/113] umbim: separate DHCPv6 configuration from DHCP(v4) Now, that sub-interface setup is split by IP type, and separate checks are performed for DHCP selection, it is possible to control DHCP on v4 an v6 sub-interfaces instantly. Add "dhcpv6" variable, akin to QMI option, to control behaviour of DHCPv6 separately from IPv4 option, which is required for some mobile operators. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 9af5b69ac11..d8df783a926 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -20,6 +20,7 @@ proto_mbim_init_config() { proto_config_add_string username proto_config_add_string password proto_config_add_boolean dhcp + proto_config_add_boolean dhcpv6 proto_config_add_string pdptype proto_config_add_defaults } @@ -29,8 +30,8 @@ _proto_mbim_setup() { local tid=2 local ret - local device apn pincode delay allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS - json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp pdptype $PROTO_DEFAULT_OPTIONS + local device apn pincode delay allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS [ -n "$ctl_device" ] && device=$ctl_device @@ -209,7 +210,7 @@ _proto_mbim_setup() { } [ "$iptype" != "ipv4" ] && { - if [ -z "$dhcp" -o "$dhcp" = 0 ]; then + if [ -z "$dhcpv6" -o "$dhcpv6" = 0 ]; then json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" From ca8df8a992211c7f61434372b07afcbe0d94ff9f Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Mon, 19 Jul 2021 21:28:07 +0200 Subject: [PATCH 025/113] umbim: use static config by default, fallback to DHCP Finally, inspired by ModemManager's logic, make static configuration obtained through MBIM control channel, preferred. If IP configuration is not available this way, fallback to DHCP(v6) if enabled, else do not create a sub-interface for unavailable IP type. Signed-off-by: Lech Perczak --- .../utils/umbim/files/lib/netifd/proto/mbim.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index d8df783a926..294dc64400a 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -179,8 +179,11 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" + [ -z "$dhcp" ] && dhcp=1 + [ -z "$dhcpv6" ] && dhcpv6=1 + [ "$iptype" != "ipv6" ] && { - if [ -z "$dhcp" -o "$dhcp" = 0 ]; then + if [ -n "$ipv4address" ]; then json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" @@ -196,7 +199,7 @@ _proto_mbim_setup() { [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" - else + elif [ "$dhcp" != 0 ]; then echo "mbim[$$]" "Starting DHCP on $ifname" json_init json_add_string name "${interface}_4" @@ -210,7 +213,7 @@ _proto_mbim_setup() { } [ "$iptype" != "ipv4" ] && { - if [ -z "$dhcpv6" -o "$dhcpv6" = 0 ]; then + if [ -n "$ipv6address" ]; then json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" @@ -226,7 +229,7 @@ _proto_mbim_setup() { [ -n "$zone" ] && json_add_string zone "$zone" json_close_object ubus call network add_dynamic "$(json_dump)" - else + elif [ "$dhcpv6" != 0 ]; then echo "mbim[$$]" "Starting DHCPv6 on $ifname" json_init json_add_string name "${interface}_6" From e2655e0a6beacc45ae763b509cb447d4777aecf6 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Tue, 20 Jul 2021 22:57:10 +0200 Subject: [PATCH 026/113] umbim: respect 'Enable IPv6 negotiation' option Don't bring IPv6 part of interface up if it's disabled, or system does not support it. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 294dc64400a..aee0feb4bab 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -19,6 +19,7 @@ proto_mbim_init_config() { proto_config_add_string auth proto_config_add_string username proto_config_add_string password + [ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6 proto_config_add_boolean dhcp proto_config_add_boolean dhcpv6 proto_config_add_string pdptype @@ -33,6 +34,8 @@ _proto_mbim_setup() { local device apn pincode delay allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS + [ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6 + [ -n "$ctl_device" ] && device=$ctl_device [ -n "$device" ] || { @@ -150,6 +153,7 @@ _proto_mbim_setup() { tid=$((tid + 1)) pdptype=$(echo "$pdptype" | awk '{print tolower($0)}') + [ "$ipv6" = 0 ] && pdptype="ipv4" local req_pdptype="" # Pass "default" PDP type to umbim if unconfigured [ "$pdptype" = "ipv4" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && req_pdptype="$pdptype:" From 9ddbcd73d8a6e4251414ff578d1dce1c846bdf4e Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Fri, 6 Aug 2021 22:29:57 +0200 Subject: [PATCH 027/113] umbim: pass ipXtable to child interfaces Inspired by commti e51aa699f7ca, allow setting specific routing tables via ip4table and ip6table options, by passing them on child interfaces created by MBIM protocol handler. Signed-off-by: Lech Perczak --- .../network/utils/umbim/files/lib/netifd/proto/mbim.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index aee0feb4bab..fd8b345797a 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -31,8 +31,10 @@ _proto_mbim_setup() { local tid=2 local ret - local device apn pincode delay allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS - json_get_vars device apn pincode delay auth username password allow_roaming allow_partner dhcp dhcpv6 pdptype $PROTO_DEFAULT_OPTIONS + local device apn pincode delay auth username password allow_roaming allow_partner + local dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS + json_get_vars device apn pincode delay auth username password allow_roaming allow_partner + json_get_vars dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS [ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6 @@ -201,6 +203,7 @@ _proto_mbim_setup() { json_close_array proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" json_close_object ubus call network add_dynamic "$(json_dump)" elif [ "$dhcp" != 0 ]; then @@ -211,6 +214,7 @@ _proto_mbim_setup() { json_add_string proto "dhcp" proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" json_close_object ubus call network add_dynamic "$(json_dump)" fi @@ -231,6 +235,7 @@ _proto_mbim_setup() { json_close_array proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" json_close_object ubus call network add_dynamic "$(json_dump)" elif [ "$dhcpv6" != 0 ]; then @@ -242,6 +247,7 @@ _proto_mbim_setup() { json_add_string extendprefix 1 proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" json_close_object ubus call network add_dynamic "$(json_dump)" fi From 5f873df8d4b79521e5f8f7ea55e8b299bfef0d24 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 03:02:08 +0100 Subject: [PATCH 028/113] umbim: log output of 'config' step Display full configuration obtained using MBIM control channel in the log, from umbim output verbatim, for easier troubleshooting, and in preparation for parser refactoring. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index fd8b345797a..9ab77242321 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -179,7 +179,9 @@ _proto_mbim_setup() { local zone="$(fw3 -q network "$interface" 2>/dev/null)" echo "mbim[$$]" "Setting up $ifname" - eval $(umbim $DBG -n -t $tid -d $device config | sed 's/: /=/g') + local mbimconfig="$(umbim $DBG -n -t $tid -d $device config)" + echo "$mbimconfig" + eval $(echo "$mbimconfig" | sed 's/: /=/g') tid=$((tid + 1)) proto_init_update "$ifname" 1 From f01fff63fbe61186128e000a3bccb7ed159fcb0c Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 13:21:32 +0100 Subject: [PATCH 029/113] umbim: add "_proto_mbim_get_field" helper Add a new helper to extract IP configuration from umbim output. This is required to extract fields which can possibly have multiple values, namely IP addresses and DNS servers, and get rid of primitive parser using 'eval' builtin without support for this. Signed-off-by: Lech Perczak --- .../utils/umbim/files/lib/netifd/proto/mbim.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 9ab77242321..8f1ae9ac253 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -26,6 +26,18 @@ proto_mbim_init_config() { proto_config_add_defaults } +_proto_mbim_get_field() { + local field="$1" + shift + local mbimconfig="$@" + echo "$mbimconfig" | while read -r line; do + variable=${line%%:*} + [ "$variable" = "$field" ] || continue; + value=${line##* } + echo -n "$value " + done +} + _proto_mbim_setup() { local interface="$1" local tid=2 From c13a1b412b12662ca314c1616dc446d2fddf5d50 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 13:35:15 +0100 Subject: [PATCH 030/113] umbim: support multiple-valued configuration fields MBIM supports multiple values for IP address and DNS server, and such configuration is available through output of MBIM. Use new helper method to support adding multiple addresses and DNS servers to static interfaces for both IPv4 and IPv6. Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 8f1ae9ac253..3ef87bdb51a 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -203,18 +203,29 @@ _proto_mbim_setup() { [ -z "$dhcpv6" ] && dhcpv6=1 [ "$iptype" != "ipv6" ] && { + ipv4address=$(_proto_mbim_get_field ipv4address "$mbimconfig") if [ -n "$ipv4address" ]; then json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" json_add_string proto "static" + json_add_array ipaddr - json_add_string "" "$ipv4address" - json_close_array - json_add_string gateway "$ipv4gateway" - json_add_array dns - [ "$peerdns" = 0 ] || json_add_string "" "$ipv4dnsserver" + for address in $ipv4address; do + json_add_string "" "$address" + done json_close_array + + json_add_string gateway $(_proto_mbim_get_field ipv4gateway "$mbimconfig") + + [ "$peerdns" = 0 ] || { + json_add_array dns + for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do + json_add_string "" "$server" + done + json_close_array + } + proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" @@ -235,18 +246,29 @@ _proto_mbim_setup() { } [ "$iptype" != "ipv4" ] && { + ipv6address=$(_proto_mbim_get_field ipv6address "$mbimconfig") if [ -n "$ipv6address" ]; then json_init json_add_string name "${interface}_6" json_add_string ifname "@$interface" json_add_string proto "static" + json_add_array ip6addr - json_add_string "" "$ipv6address" - json_close_array - json_add_string ip6gw "$ipv6gateway" - json_add_array dns - [ "$peerdns" = 0 ] || json_add_string "" "$ipv6dnsserver" + for address in $ipv6address; do + json_add_string "" "$address" + done json_close_array + + json_add_string ip6gw $(_proto_mbim_get_field ipv6gateway "$mbimconfig") + + [ "$peerdns" = 0 ] || { + json_add_array dns + for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do + json_add_string "" "$server" + done + json_close_array + } + proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" From 9808b09b91e805a4ae2e11521faf3cd8e5cf8270 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 13:43:12 +0100 Subject: [PATCH 031/113] umbim: drop IP configuration parsing using 'eval' Finally, when new helper is in use, drop old IP configuration parser. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 3ef87bdb51a..617407cd085 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -193,7 +193,6 @@ _proto_mbim_setup() { echo "mbim[$$]" "Setting up $ifname" local mbimconfig="$(umbim $DBG -n -t $tid -d $device config)" echo "$mbimconfig" - eval $(echo "$mbimconfig" | sed 's/: /=/g') tid=$((tid + 1)) proto_init_update "$ifname" 1 From 2bfbc2dbd8b0d9570a8df0d8d8db93c2a9fcec01 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 14:02:15 +0100 Subject: [PATCH 032/113] umbim: delegate RFC7278 IPv6 prefixes from OOB config Delegate prefixes received through MBIM control channel the same way, as would be done through DHCP, according to RFC7278. Signed-off-by: Lech Perczak --- package/network/utils/umbim/files/lib/netifd/proto/mbim.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 617407cd085..eab5cf3de69 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -258,6 +258,12 @@ _proto_mbim_setup() { done json_close_array + json_add_array ip6prefix + for address in $ipv6address; do + json_add_string "" "$address" + done + json_close_array + json_add_string ip6gw $(_proto_mbim_get_field ipv6gateway "$mbimconfig") [ "$peerdns" = 0 ] || { From e4db21b413e65bdfe0491a0ff5749d0bdfde04d4 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 16:01:02 +0100 Subject: [PATCH 033/113] umbim: handle MTU configuration Allow setting interface MTU through UCI. If this is not set, use MBIM-provided MTU, if provided through control channel. If separate MTUs are provided for IPv4 and IPv6, apply larger of them. This is very unlikely and possible only for IPv4v6 dual-stack configuration. Signed-off-by: Lech Perczak --- .../utils/umbim/files/lib/netifd/proto/mbim.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index eab5cf3de69..7ac3cb1c70c 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -23,6 +23,7 @@ proto_mbim_init_config() { proto_config_add_boolean dhcp proto_config_add_boolean dhcpv6 proto_config_add_string pdptype + proto_config_add_int mtu proto_config_add_defaults } @@ -44,9 +45,9 @@ _proto_mbim_setup() { local ret local device apn pincode delay auth username password allow_roaming allow_partner - local dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS + local dhcp dhcpv6 pdptype ip4table ip6table mtu $PROTO_DEFAULT_OPTIONS json_get_vars device apn pincode delay auth username password allow_roaming allow_partner - json_get_vars dhcp dhcpv6 pdptype ip4table ip6table $PROTO_DEFAULT_OPTIONS + json_get_vars dhcp dhcpv6 pdptype ip4table ip6table mtu $PROTO_DEFAULT_OPTIONS [ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6 @@ -294,6 +295,19 @@ _proto_mbim_setup() { fi } + [ -z "$mtu" ] && { + local ipv4mtu=$(_proto_mbim_get_field ipv4mtu "$mbimconfig") + ipv4mtu="${ipv4mtu:-0}" + local ipv6mtu=$(_proto_mbim_get_field ipv6mtu "$mbimconfig") + ipv6mtu="${ipv6mtu:-0}" + + mtu=$((ipv6mtu > ipv4mtu ? ipv6mtu : ipv4mtu)) + } + [ -n "$mtu" -a "$mtu" != 0 ] && { + echo Setting MTU of $ifname to $mtu + /sbin/ip link set dev $ifname mtu $mtu + } + uci_set_state network $interface tid "$tid" } From aa7873a9e6f69f04cafcbb37a6b3ad1f4e6f1a69 Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 17:51:25 +0100 Subject: [PATCH 034/113] umbim: extract common code from static and dhcp(v6) setup procedure Beginnings and endings of sub-interface creation procedure were literally duplicates - extract them outside if "if" blocks Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 50 ++++++------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index 7ac3cb1c70c..da3f4842233 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -203,11 +203,11 @@ _proto_mbim_setup() { [ -z "$dhcpv6" ] && dhcpv6=1 [ "$iptype" != "ipv6" ] && { + json_init + json_add_string name "${interface}_4" + json_add_string ifname "@$interface" ipv4address=$(_proto_mbim_get_field ipv4address "$mbimconfig") if [ -n "$ipv4address" ]; then - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" json_add_string proto "static" json_add_array ipaddr @@ -225,32 +225,23 @@ _proto_mbim_setup() { done json_close_array } - - proto_add_dynamic_defaults - [ -n "$zone" ] && json_add_string zone "$zone" - [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" - json_close_object - ubus call network add_dynamic "$(json_dump)" elif [ "$dhcp" != 0 ]; then echo "mbim[$$]" "Starting DHCP on $ifname" - json_init - json_add_string name "${interface}_4" - json_add_string ifname "@$interface" json_add_string proto "dhcp" - proto_add_dynamic_defaults - [ -n "$zone" ] && json_add_string zone "$zone" - [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" - json_close_object - ubus call network add_dynamic "$(json_dump)" fi + proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" + json_close_object + ubus call network add_dynamic "$(json_dump)" } [ "$iptype" != "ipv4" ] && { + json_init + json_add_string name "${interface}_6" + json_add_string ifname "@$interface" ipv6address=$(_proto_mbim_get_field ipv6address "$mbimconfig") if [ -n "$ipv6address" ]; then - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" json_add_string proto "static" json_add_array ip6addr @@ -274,25 +265,16 @@ _proto_mbim_setup() { done json_close_array } - - proto_add_dynamic_defaults - [ -n "$zone" ] && json_add_string zone "$zone" - [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" - json_close_object - ubus call network add_dynamic "$(json_dump)" elif [ "$dhcpv6" != 0 ]; then echo "mbim[$$]" "Starting DHCPv6 on $ifname" - json_init - json_add_string name "${interface}_6" - json_add_string ifname "@$interface" json_add_string proto "dhcpv6" json_add_string extendprefix 1 - proto_add_dynamic_defaults - [ -n "$zone" ] && json_add_string zone "$zone" - [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" - json_close_object - ubus call network add_dynamic "$(json_dump)" fi + proto_add_dynamic_defaults + [ -n "$zone" ] && json_add_string zone "$zone" + [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" + json_close_object + ubus call network add_dynamic "$(json_dump)" } [ -z "$mtu" ] && { From d256ab730910a638dc61a2ee1c01576404dab52e Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Sat, 6 Nov 2021 17:56:03 +0100 Subject: [PATCH 035/113] umbim: include MBIM-provided DNS servers also with DHCP mode In MBIM interfaces, DNS servers may be provided out-of-band regardless whether DHCP is used for configuration, or not. Move the DNS configuration outside "if" blocks to support that. Signed-off-by: Lech Perczak --- .../umbim/files/lib/netifd/proto/mbim.sh | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index da3f4842233..bf07137fc4e 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -217,18 +217,19 @@ _proto_mbim_setup() { json_close_array json_add_string gateway $(_proto_mbim_get_field ipv4gateway "$mbimconfig") - - [ "$peerdns" = 0 ] || { - json_add_array dns - for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do - json_add_string "" "$server" - done - json_close_array - } elif [ "$dhcp" != 0 ]; then echo "mbim[$$]" "Starting DHCP on $ifname" json_add_string proto "dhcp" fi + + [ "$peerdns" = 0 ] || { + json_add_array dns + for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do + json_add_string "" "$server" + done + json_close_array + } + proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" @@ -258,18 +259,20 @@ _proto_mbim_setup() { json_add_string ip6gw $(_proto_mbim_get_field ipv6gateway "$mbimconfig") - [ "$peerdns" = 0 ] || { - json_add_array dns - for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do - json_add_string "" "$server" - done - json_close_array - } elif [ "$dhcpv6" != 0 ]; then echo "mbim[$$]" "Starting DHCPv6 on $ifname" json_add_string proto "dhcpv6" json_add_string extendprefix 1 fi + + [ "$peerdns" = 0 ] || { + json_add_array dns + for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do + json_add_string "" "$server" + done + json_close_array + } + proto_add_dynamic_defaults [ -n "$zone" ] && json_add_string zone "$zone" [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" From 28df7f7ff251d8684caa60f07ed0ba0c4a8e71f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Tue, 4 Apr 2023 19:41:26 +0200 Subject: [PATCH 036/113] ramips: mt7621: add support for ZyXEL WSM20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ZyXEL WSM20 aka Multy M1 is a cheap mesh router system by ZyXEL based on the MT7621 CPU. Specifications ============== SoC: MediaTek MT7621AT (880MHz) RAM: 256MiB Flash: 128MiB NAND Wireless: 802.11ax (2x2 MT7915E DBDC) Ethernet: 4x 10/100/1000 (MT7530) Button: 1x WPS, 1x Reset, 1x LED On/Off LED: 7 LEDs (3x white, 2x red, 2x green) MAC address assignment ====================== The MAC address assignment follows stock: The label MAC address is the LAN MAC address, the WAN address is read from flash. The WiFi MAC addresses are set in userspace to label MAC + 1 and label MAC + 2. Installation (web interface) ============================ The device is cloud-managed, but there is a hidden local firmware upgrade page in the OEM web interface. The device has to be registered in the cloud in order to be able to access this page. The system has a dual firmware design, there is no way to tell which firmware is currently booted. Therefore, an -initramfs version is flashed first. 1. Log into the OEM web GUI 2. Access the hidden upgrade page by navigating to https://192.168.212.1/gui/#/main/debug/firmwareupgrade 3. Upload the -initramfs-kernel.bin file and flash it 4. Wait for OpenWrt to boot and log in via SSH 5. Transfer the sysupgrade file via SCP 6. Run sysupgrade to install the image 7. Reboot and enjoy NB: If the initramfs version was installed in RAS2, the sysupgrade script sets the boot number to the first partition. A backup has to be performed manually in case the OEM firwmare should be kept. Installation (UART method) ========================== The UART method is more difficult, as the boot loader does not have a timeout set. A semi-working stock firmware is required to configure it: 1. Attach UART 2. Boot the stock firmware until the message about failsafe mode appears 3. Enter failsafe mode by pressing "f" and "Enter" 4. Type "mount_root" 5. Run "fw_setenv bootmenu_delay 3" 6. Reboot, U-Boot now presents a menu 7. The -initramfs-kernel.bin image can be flashed using the menu 8. Run the regular sysupgrade for a permanent installation Changing the partition to boot is a bit cumbersome in U-Boot, as there is no menu to select it. It can only be checked using mstc_bootnum. To change it, issue the following commands in U-Boot: nand read 1800000 53c0000 800 mw.b 1800004 1 1 nand erase 53c0000 800 nand write 1800000 53c0000 800 This selects FW1. Replace "mw.b 1800004 1 1" by "mw.b 1800004 2 1" to change to the second slot. Back to stock ============= It is possible to flash back to stock, but a OEM firmware upgrade is required. ZyXEL does not provide the link on its website, but the link can be acquired from the OEM web GUI by analyzing the transferred JSON objects. It is then a matter of writing the firmware to Kernel2 and setting the boot partition to FW2: mtd write zyxel.bin Kernel2 echo -ne "\x02" | dd of=/dev/mtdblock7 count=1 bs=1 seek=4 conv=notrunc Signed-off-by: Andreas Böhler Credits to forum users Annick and SirLouen for their initial work on this device --- package/boot/uboot-envtools/files/ramips | 3 +- .../linux/ramips/dts/mt7621_zyxel_wsm20.dts | 233 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 39 +++ .../mt7621/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 + .../mt7621/base-files/lib/upgrade/platform.sh | 4 + .../mt7621/base-files/lib/upgrade/zyxel.sh | 39 +++ 7 files changed, 324 insertions(+), 2 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_zyxel_wsm20.dts create mode 100644 target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index bc562100365..4b7eeb8960e 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -62,7 +62,8 @@ h3c,tx1801-plus|\ h3c,tx1806|\ jcg,q20|\ linksys,e7350|\ -netgear,wax202) +netgear,wax202|\ +zyxel,wsm20) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; haier,har-20s2u1|\ diff --git a/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts b/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts new file mode 100644 index 00000000000..315e2e1d797 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zyxel_wsm20.dts @@ -0,0 +1,233 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "zyxel,wsm20", "mediatek,mt7621-soc"; + model = "ZyXEL WSM20"; + + aliases { + led-boot = &led_system_white; + led-failsafe = &led_system_red; + led-running = &led_system_white; + led-upgrade = &led_system_red; + label-mac-device = &gmac0; + }; + + chosen { + bootargs-override = "console=ttyS0,115200n1"; + }; + + leds { + compatible = "gpio-leds"; + + led_system_white: led-0 { + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + label = "white:system"; + }; + + led_system_red: led-1 { + gpios = <&gpio 4 GPIO_ACTIVE_LOW>; + label = "red:system"; + }; + + led-2 { + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + label = "green:led1"; + }; + + led-3 { + gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + label = "white:led2"; + }; + + led-4 { + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + label = "green:led3"; + }; + + led-5 { + gpios = <&gpio 17 GPIO_ACTIVE_HIGH>; + label = "red:led4"; + }; + + led-6 { + gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + label = "white:led5"; + }; + }; + + keys { + compatible = "gpio-keys"; + + led { + label = "led"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x0 0x100000>; + label = "Bootloader"; + read-only; + }; + + partition@100000 { + reg = <0x100000 0x100000>; + label = "Config"; + }; + + factory: partition@200000 { + reg = <0x200000 0x1c0000>; + label = "Factory"; + read-only; + }; + + partition@3c0000 { + reg = <0x3c0000 0x2800000>; + label = "firmware"; + + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "kernel"; + reg = <0x0 0x800000>; + }; + + partition@800000 { + label = "ubi"; + reg = <0x800000 0x2000000>; + }; + }; + + partition@2bc0000 { + reg = <0x2bc0000 0x2800000>; + label = "Kernel2"; + }; + + partition@53c0000 { + reg = <0x53c0000 0x100000>; + label = "persist"; + }; + + partition@54c0000 { + reg = <0x54c0000 0x400000>; + label = "rootfs_data"; + read-only; + }; + + partition@58C0000 { + reg = <0x58c0000 0x25c0000>; + label = "app"; + read-only; + }; + + partition@7e80000 { + reg = <0x7e80000 0x100000>; + label = "crt"; + read-only; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_1fdfa>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_factory_1fdf4>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + mediatek,disable-radar-background; + }; +}; + +&pcie2 { + status = "disabled"; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan3"; + }; + port@2 { + status = "okay"; + label = "lan2"; + }; + port@3 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + +&factory { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_1fdfa: macaddr@1fdfa { + reg = <0x1fdfa 0x6>; + }; + + macaddr_factory_1fdf4: macaddr@1fdf4 { + reg = <0x1fdf4 0x6>; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index df89877c9a2..96bfab3fef3 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -62,6 +62,29 @@ define Build/iodata-mstc-header ) endef +define Build/znet-header + $(eval version=$(word 1,$(1))) + ( \ + data_size_crc="$$(dd if=$@ 2>/dev/null | gzip -c | \ + tail -c 8 | od -An -N4 -tx4 --endian big | tr -d ' \n')"; \ + payload_len="$$(dd if=$@ bs=4 count=1 skip=1 2>/dev/null | od -An -tdI --endian big | tr -d ' \n')"; \ + payload_size_crc="$$(dd if=$@ ibs=1 count=$$payload_len 2>/dev/null | gzip -c | \ + tail -c 8 | od -An -N4 -tx4 --endian big | tr -d ' \n')"; \ + echo -ne "\x5A\x4E\x45\x54" | dd bs=4 count=1 conv=sync 2>/dev/null; \ + echo -ne "$$(printf '%08x' $$(stat -c%s $@) | fold -s2 | xargs -I {} echo \\x{} | tac | tr -d '\n')" | \ + dd bs=4 count=1 conv=sync 2>/dev/null; \ + echo -ne "$$(echo $$data_size_crc | sed 's/../\\x&/g')" | \ + dd bs=4 count=1 conv=sync 2>/dev/null; \ + echo -ne "$$(echo $$payload_size_crc | sed 's/../\\x&/g')" | \ + dd bs=4 count=1 conv=sync 2>/dev/null; \ + echo -ne "\x12\x34\x56\x78" | dd bs=4 count=1 conv=sync 2>/dev/null; \ + echo -ne "$(version)" | dd bs=28 count=1 conv=sync 2>/dev/null; \ + dd if=/dev/zero bs=262096 count=1 conv=sync 2>/dev/null | tr "\000" "\377"; \ + cat $@; \ + ) > $@.new + mv $@.new $@ +endef + define Build/belkin-header $(eval magic=$(word 1,$(1))) $(eval hw_ver=$(word 2,$(1))) @@ -2875,3 +2898,19 @@ define Device/zyxel_wap6805 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef TARGET_DEVICES += zyxel_wap6805 + +define Device/zyxel_wsm20 + $(Device/dsa-migration) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 8192k + IMAGE_SIZE := 41943040 + UBINIZE_OPTS := -E 5 + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := WSM20 + DEVICE_PACKAGES := kmod-mt7915-firmware + KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0 + KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += zyxel_wsm20 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 e357b47a4ca..39c8080e832 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -49,7 +49,8 @@ ramips_setup_interfaces() xiaomi,mi-router-cr6606|\ xiaomi,mi-router-cr6608|\ xiaomi,mi-router-cr6609|\ - xiaomi,redmi-router-ac2100) + xiaomi,redmi-router-ac2100|\ + zyxel,wsm20) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; asiarf,ap7621-001|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index b6337f397b8..f042830e025 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -181,4 +181,9 @@ case "$board" in [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress ;; + zyxel,wsm20) + hw_mac_addr="$(mtd_get_mac_binary Factory 0x1fdfa)" + [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress + ;; esac diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index bfdbd6a09d7..ce5fdd61ed0 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -155,6 +155,10 @@ platform_do_upgrade() { CI_KERNPART="Kernel" nand_do_upgrade "$1" ;; + zyxel,wsm20) + zyxel_mstc_upgrade_prepare + nand_do_upgrade "$1" + ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh new file mode 100644 index 00000000000..59c8d237dda --- /dev/null +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/zyxel.sh @@ -0,0 +1,39 @@ +# +# Copyright (C) 2023 OpenWrt.org +# + +. /lib/functions.sh + +zyxel_mstc_prepare_fail() { + echo "failed to check and prepare the environment, rebooting..." + umount -a + reboot -f +} + +zyxel_mstc_upgrade_prepare() { + local persist_mtd="$(find_mtd_part persist)" + local firmware_mtd="$(find_mtd_part firmware)" + + if [ -z "$persist_mtd" ] || [ -z "$firmware_mtd" ]; then + echo 'cannot find mtd partition(s) "persist" or "firmware"' + zyxel_mstc_prepare_fail + fi + + local bootnum=$(hexdump -s 4 -n 1 -e '"%x"' ${persist_mtd}) + + if [ "$bootnum" != "1" ] && [ "$bootnum" != "2" ]; then + echo "failed to get bootnum, please check the value at 0x4 in ${persist_mtd}" + zyxel_mstc_prepare_fail + fi + echo "current: bootnum => ${bootnum}" + + [ "$(fw_printenv -n bootmenu_delay)" = "3" ] || fw_setenv bootmenu_delay 3 + + if [ "$bootnum" = "2" ]; then + if ! ( echo -ne "\x01" | dd of=${persist_mtd} count=1 bs=1 seek=4 conv=notrunc 2>/dev/null ); then + echo "failed to set new boot partition" + zyxel_mstc_prepare_fail + fi + echo "### switch to 1st os-image on next boot ###" + fi +} From 626b37d70aad163089598e33da2590f838f6dd8c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 15:52:56 +0200 Subject: [PATCH 037/113] kernel: Activate CONFIG_HARDENED_USERCOPY for all targets This activates CONFIG_HARDENED_USERCOPY for the remaining targets. This adds additional checks in the copy_from_user() and copy_to_user() functions. This was not activated for ARCHS38 before because of a bug in the Linux kernel 5.4 till 5.14, which as fixed and is described here: https://github.com/foss-for-synopsys-dwc-arc-processors/linux/issues/15 I do not know why this was deactivated for mt7629 and rockchip. Signed-off-by: Hauke Mehrtens --- target/linux/archs38/config-5.15 | 1 - target/linux/mediatek/mt7629/config-5.15 | 1 - target/linux/rockchip/armv8/config-5.10 | 1 - target/linux/rockchip/armv8/config-5.15 | 1 - 4 files changed, 4 deletions(-) diff --git a/target/linux/archs38/config-5.15 b/target/linux/archs38/config-5.15 index 5e180aaf99b..d4b1c5ab602 100644 --- a/target/linux/archs38/config-5.15 +++ b/target/linux/archs38/config-5.15 @@ -110,7 +110,6 @@ CONFIG_GPIO_GENERIC=y CONFIG_GPIO_SNPS_CREG=y CONFIG_GRACE_PERIOD=y CONFIG_HANDLE_DOMAIN_IRQ=y -# CONFIG_HARDENED_USERCOPY is not set CONFIG_HAS_DMA=y CONFIG_HAS_IOMEM=y CONFIG_HZ_PERIODIC=y diff --git a/target/linux/mediatek/mt7629/config-5.15 b/target/linux/mediatek/mt7629/config-5.15 index 32f75d6528b..46104ece48f 100644 --- a/target/linux/mediatek/mt7629/config-5.15 +++ b/target/linux/mediatek/mt7629/config-5.15 @@ -131,7 +131,6 @@ CONFIG_GENERIC_TIME_VSYSCALL=y CONFIG_GENERIC_VDSO_32=y CONFIG_GPIO_CDEV=y CONFIG_HANDLE_DOMAIN_IRQ=y -# CONFIG_HARDENED_USERCOPY is not set CONFIG_HARDEN_BRANCH_PREDICTOR=y CONFIG_HARDIRQS_SW_RESEND=y CONFIG_HAS_DMA=y diff --git a/target/linux/rockchip/armv8/config-5.10 b/target/linux/rockchip/armv8/config-5.10 index 1488da23a8b..220b0ec198e 100644 --- a/target/linux/rockchip/armv8/config-5.10 +++ b/target/linux/rockchip/armv8/config-5.10 @@ -249,7 +249,6 @@ CONFIG_GPIO_DWAPB=y CONFIG_GPIO_GENERIC=y CONFIG_GPIO_GENERIC_PLATFORM=y CONFIG_HANDLE_DOMAIN_IRQ=y -# CONFIG_HARDENED_USERCOPY is not set CONFIG_HARDIRQS_SW_RESEND=y CONFIG_HAS_DMA=y CONFIG_HAS_IOMEM=y diff --git a/target/linux/rockchip/armv8/config-5.15 b/target/linux/rockchip/armv8/config-5.15 index 5f94e0c9f22..d6377f905f0 100644 --- a/target/linux/rockchip/armv8/config-5.15 +++ b/target/linux/rockchip/armv8/config-5.15 @@ -248,7 +248,6 @@ CONFIG_GPIO_GENERIC=y CONFIG_GPIO_GENERIC_PLATFORM=y CONFIG_GPIO_ROCKCHIP=y CONFIG_HANDLE_DOMAIN_IRQ=y -# CONFIG_HARDENED_USERCOPY is not set CONFIG_HARDIRQS_SW_RESEND=y CONFIG_HAS_DMA=y CONFIG_HAS_IOMEM=y From ca5555d27e6c62229a3f17d7ac2158d3c24b6af9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 19:52:22 +0200 Subject: [PATCH 038/113] kernel: Activate CONFIG_ARM64_SW_TTBR0_PAN This activates the CONFIG_ARM64_SW_TTBR0_PAN option for all arm64 kernels by default. The CONFIG_ARM64_SW_TTBR0_PAN option prevents the kernel form accessing user space memory directly. This makes it harder to exploit the kernel. This is activated by default and was already activate on all other arm64 targets before. Signed-off-by: Hauke Mehrtens --- target/linux/mediatek/filogic/config-5.15 | 1 - target/linux/mediatek/mt7622/config-5.15 | 1 - target/linux/rockchip/armv8/config-5.10 | 1 - target/linux/rockchip/armv8/config-5.15 | 1 - 4 files changed, 4 deletions(-) diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 5f924065a4d..883e194be43 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -24,7 +24,6 @@ CONFIG_ARM64_MODULE_PLTS=y CONFIG_ARM64_PAGE_SHIFT=12 CONFIG_ARM64_PA_BITS=48 CONFIG_ARM64_PA_BITS_48=y -# CONFIG_ARM64_SW_TTBR0_PAN is not set CONFIG_ARM64_TAGGED_ADDR_ABI=y CONFIG_ARM64_VA_BITS=39 CONFIG_ARM64_VA_BITS_39=y diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 14a0bec31a5..5224e1c8088 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -26,7 +26,6 @@ CONFIG_ARM64_MODULE_PLTS=y CONFIG_ARM64_PAGE_SHIFT=12 CONFIG_ARM64_PA_BITS=48 CONFIG_ARM64_PA_BITS_48=y -# CONFIG_ARM64_SW_TTBR0_PAN is not set CONFIG_ARM64_TAGGED_ADDR_ABI=y CONFIG_ARM64_VA_BITS=39 CONFIG_ARM64_VA_BITS_39=y diff --git a/target/linux/rockchip/armv8/config-5.10 b/target/linux/rockchip/armv8/config-5.10 index 220b0ec198e..794283fcd96 100644 --- a/target/linux/rockchip/armv8/config-5.10 +++ b/target/linux/rockchip/armv8/config-5.10 @@ -36,7 +36,6 @@ CONFIG_ARM64_PA_BITS_48=y CONFIG_ARM64_PTR_AUTH=y CONFIG_ARM64_RAS_EXTN=y CONFIG_ARM64_SVE=y -# CONFIG_ARM64_SW_TTBR0_PAN is not set CONFIG_ARM64_TAGGED_ADDR_ABI=y CONFIG_ARM64_UAO=y CONFIG_ARM64_VA_BITS=48 diff --git a/target/linux/rockchip/armv8/config-5.15 b/target/linux/rockchip/armv8/config-5.15 index d6377f905f0..dc1fbb3d545 100644 --- a/target/linux/rockchip/armv8/config-5.15 +++ b/target/linux/rockchip/armv8/config-5.15 @@ -40,7 +40,6 @@ CONFIG_ARM64_PTR_AUTH=y CONFIG_ARM64_PTR_AUTH_KERNEL=y CONFIG_ARM64_RAS_EXTN=y CONFIG_ARM64_SVE=y -# CONFIG_ARM64_SW_TTBR0_PAN is not set CONFIG_ARM64_TAGGED_ADDR_ABI=y CONFIG_ARM64_VA_BITS=48 # CONFIG_ARM64_VA_BITS_39 is not set From 0fc3a4aa105e56b4a9cb7398dd1b88e75d5d283b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 15:40:59 +0200 Subject: [PATCH 039/113] kernel: Deactivate CONFIG_LEGACY_PTYS The legacy (BSD) PTY support could open security problems in a system, We do not need them in OpenWrt, deactivate this option in all targets. Debian also deactivates this option. Signed-off-by: Hauke Mehrtens --- target/linux/mpc85xx/config-5.10 | 2 -- target/linux/mpc85xx/config-5.15 | 2 -- target/linux/realtek/rtl838x/config-5.10 | 2 -- target/linux/realtek/rtl838x/config-5.15 | 2 -- target/linux/realtek/rtl839x/config-5.10 | 2 -- target/linux/realtek/rtl839x/config-5.15 | 2 -- target/linux/realtek/rtl930x/config-5.10 | 2 -- target/linux/realtek/rtl930x/config-5.15 | 2 -- target/linux/realtek/rtl931x/config-5.10 | 2 -- target/linux/realtek/rtl931x/config-5.15 | 2 -- target/linux/rockchip/armv8/config-5.10 | 2 -- target/linux/rockchip/armv8/config-5.15 | 2 -- 12 files changed, 24 deletions(-) diff --git a/target/linux/mpc85xx/config-5.10 b/target/linux/mpc85xx/config-5.10 index 1885a961fed..c2044fabd05 100644 --- a/target/linux/mpc85xx/config-5.10 +++ b/target/linux/mpc85xx/config-5.10 @@ -112,8 +112,6 @@ CONFIG_IRQ_WORK=y CONFIG_ISA_DMA_API=y CONFIG_KERNEL_START=0xc0000000 # CONFIG_KSI8560 is not set -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOWMEM_CAM_NUM=3 diff --git a/target/linux/mpc85xx/config-5.15 b/target/linux/mpc85xx/config-5.15 index 42d17c13610..9c051e63c12 100644 --- a/target/linux/mpc85xx/config-5.15 +++ b/target/linux/mpc85xx/config-5.15 @@ -112,8 +112,6 @@ CONFIG_IRQ_WORK=y CONFIG_ISA_DMA_API=y CONFIG_KERNEL_START=0xc0000000 # CONFIG_KSI8560 is not set -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_LOWMEM_CAM_NUM=3 diff --git a/target/linux/realtek/rtl838x/config-5.10 b/target/linux/realtek/rtl838x/config-5.10 index 9749eec27be..e763557a9f4 100644 --- a/target/linux/realtek/rtl838x/config-5.10 +++ b/target/linux/realtek/rtl838x/config-5.10 @@ -116,8 +116,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_MARVELL_PHY=y diff --git a/target/linux/realtek/rtl838x/config-5.15 b/target/linux/realtek/rtl838x/config-5.15 index 4e4ed9f44b7..ad2c1b43cce 100644 --- a/target/linux/realtek/rtl838x/config-5.15 +++ b/target/linux/realtek/rtl838x/config-5.15 @@ -114,8 +114,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_MARVELL_PHY=y diff --git a/target/linux/realtek/rtl839x/config-5.10 b/target/linux/realtek/rtl839x/config-5.10 index 9377d482d7e..d464c722251 100644 --- a/target/linux/realtek/rtl839x/config-5.10 +++ b/target/linux/realtek/rtl839x/config-5.10 @@ -109,8 +109,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LLD_VERSION=0 CONFIG_LOCK_DEBUGGING_SUPPORT=y diff --git a/target/linux/realtek/rtl839x/config-5.15 b/target/linux/realtek/rtl839x/config-5.15 index 17edb2b3bb1..5fa52ba882e 100644 --- a/target/linux/realtek/rtl839x/config-5.15 +++ b/target/linux/realtek/rtl839x/config-5.15 @@ -111,8 +111,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_MARVELL_PHY=y diff --git a/target/linux/realtek/rtl930x/config-5.10 b/target/linux/realtek/rtl930x/config-5.10 index bd275a28ba7..f61a200c914 100644 --- a/target/linux/realtek/rtl930x/config-5.10 +++ b/target/linux/realtek/rtl930x/config-5.10 @@ -100,8 +100,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LLD_VERSION=0 CONFIG_LOCK_DEBUGGING_SUPPORT=y diff --git a/target/linux/realtek/rtl930x/config-5.15 b/target/linux/realtek/rtl930x/config-5.15 index 35365370efa..af5f2ca7a31 100644 --- a/target/linux/realtek/rtl930x/config-5.15 +++ b/target/linux/realtek/rtl930x/config-5.15 @@ -95,8 +95,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_MARVELL_PHY=y diff --git a/target/linux/realtek/rtl931x/config-5.10 b/target/linux/realtek/rtl931x/config-5.10 index 1a6546c0313..36e74868047 100644 --- a/target/linux/realtek/rtl931x/config-5.10 +++ b/target/linux/realtek/rtl931x/config-5.10 @@ -101,8 +101,6 @@ CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LLD_VERSION=0 CONFIG_LOCK_DEBUGGING_SUPPORT=y diff --git a/target/linux/realtek/rtl931x/config-5.15 b/target/linux/realtek/rtl931x/config-5.15 index 3abc49a4e95..2da27941c74 100644 --- a/target/linux/realtek/rtl931x/config-5.15 +++ b/target/linux/realtek/rtl931x/config-5.15 @@ -103,8 +103,6 @@ CONFIG_IRQ_WORK=y CONFIG_JFFS2_ZLIB=y CONFIG_KMAP_LOCAL=y CONFIG_LEDS_GPIO=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y CONFIG_MARVELL_PHY=y diff --git a/target/linux/rockchip/armv8/config-5.10 b/target/linux/rockchip/armv8/config-5.10 index 794283fcd96..5f4ded36e0c 100644 --- a/target/linux/rockchip/armv8/config-5.10 +++ b/target/linux/rockchip/armv8/config-5.10 @@ -313,8 +313,6 @@ CONFIG_LEDS_PWM=y CONFIG_LEDS_SYSCON=y CONFIG_LEDS_TRIGGER_CPU=y CONFIG_LEDS_TRIGGER_PANIC=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=16 CONFIG_LIBCRC32C=y CONFIG_LIBFDT=y CONFIG_LOCALVERSION_AUTO=y diff --git a/target/linux/rockchip/armv8/config-5.15 b/target/linux/rockchip/armv8/config-5.15 index dc1fbb3d545..bb604897146 100644 --- a/target/linux/rockchip/armv8/config-5.15 +++ b/target/linux/rockchip/armv8/config-5.15 @@ -312,8 +312,6 @@ CONFIG_LEDS_PWM=y CONFIG_LEDS_SYSCON=y CONFIG_LEDS_TRIGGER_CPU=y CONFIG_LEDS_TRIGGER_PANIC=y -CONFIG_LEGACY_PTYS=y -CONFIG_LEGACY_PTY_COUNT=16 CONFIG_LIBCRC32C=y CONFIG_LIBFDT=y CONFIG_LOCALVERSION_AUTO=y From 7815c55f7d0ee4bef94ddc54c4845c399f964719 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 19:48:54 +0200 Subject: [PATCH 040/113] kernel: Deactivate CONFIG_COMPAT This deactivates the CONFIG_COMPAT kernel option. With CONFIG_COMPAT the kernel will provide syscall interfaces for arm32 binaries in addition to the interfaces needed for arm64 binaries. In OpenWrt the complete userspace is compiled for this specific architecture and support for 32 bit ARM applications is not needed. This reduces the size and the attack surface for the systems. On all other targets CONFIG_COMPAT is already deactivated. Signed-off-by: Hauke Mehrtens --- target/linux/mediatek/mt7622/config-5.15 | 4 ---- target/linux/rockchip/armv8/config-5.10 | 4 ---- target/linux/rockchip/armv8/config-5.15 | 3 --- 3 files changed, 11 deletions(-) diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 5224e1c8088..9fb6f7befd6 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -87,11 +87,7 @@ CONFIG_COMMON_CLK_MT7622_HIFSYS=y # CONFIG_COMMON_CLK_MT8183_VENCSYS is not set # CONFIG_COMMON_CLK_MT8516 is not set # CONFIG_COMMON_CLK_MT8516_AUDSYS is not set -CONFIG_COMPAT=y CONFIG_COMPAT_32BIT_TIME=y -CONFIG_COMPAT_BINFMT_ELF=y -CONFIG_COMPAT_NETLINK_MESSAGES=y -CONFIG_COMPAT_OLD_SIGACTION=y CONFIG_CONFIGFS_FS=y CONFIG_CONSOLE_LOGLEVEL_DEFAULT=15 # CONFIG_CPUFREQ_DT is not set diff --git a/target/linux/rockchip/armv8/config-5.10 b/target/linux/rockchip/armv8/config-5.10 index 5f4ded36e0c..2d250219a87 100644 --- a/target/linux/rockchip/armv8/config-5.10 +++ b/target/linux/rockchip/armv8/config-5.10 @@ -117,11 +117,7 @@ CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_RK808=y CONFIG_COMMON_CLK_ROCKCHIP=y CONFIG_COMMON_CLK_SCPI=y -CONFIG_COMPAT=y CONFIG_COMPAT_32BIT_TIME=y -CONFIG_COMPAT_BINFMT_ELF=y -CONFIG_COMPAT_NETLINK_MESSAGES=y -CONFIG_COMPAT_OLD_SIGACTION=y CONFIG_CONFIGFS_FS=y CONFIG_CONSOLE_TRANSLATIONS=y CONFIG_CONTIG_ALLOC=y diff --git a/target/linux/rockchip/armv8/config-5.15 b/target/linux/rockchip/armv8/config-5.15 index bb604897146..bb7f44a2c4d 100644 --- a/target/linux/rockchip/armv8/config-5.15 +++ b/target/linux/rockchip/armv8/config-5.15 @@ -115,10 +115,7 @@ CONFIG_COMMON_CLK=y CONFIG_COMMON_CLK_RK808=y CONFIG_COMMON_CLK_ROCKCHIP=y CONFIG_COMMON_CLK_SCPI=y -CONFIG_COMPAT=y CONFIG_COMPAT_32BIT_TIME=y -CONFIG_COMPAT_BINFMT_ELF=y -CONFIG_COMPAT_OLD_SIGACTION=y CONFIG_CONFIGFS_FS=y CONFIG_CONSOLE_TRANSLATIONS=y CONFIG_CONTIG_ALLOC=y From 829a50d242287060c749882b7bf9af4c6a4505b4 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 19:56:42 +0200 Subject: [PATCH 041/113] bcm27xx: Deactivate CONFIG_OABI_COMPAT This deactivates the kernel option CONFIG_OABI_COMPAT. The old arm OABI is not needed any more, we compile all applications for the new ARM EABI. This reduces the attack surface of the kernel syscall interface. On all other targets CONFIG_OABI_COMPAT is already deactivated. Signed-off-by: Hauke Mehrtens --- target/linux/bcm27xx/bcm2708/config-5.15 | 1 - target/linux/bcm27xx/bcm2709/config-5.15 | 1 - 2 files changed, 2 deletions(-) diff --git a/target/linux/bcm27xx/bcm2708/config-5.15 b/target/linux/bcm27xx/bcm2708/config-5.15 index fc6e1eaac07..bd507298568 100644 --- a/target/linux/bcm27xx/bcm2708/config-5.15 +++ b/target/linux/bcm27xx/bcm2708/config-5.15 @@ -256,7 +256,6 @@ CONFIG_NO_HZ=y CONFIG_NO_HZ_COMMON=y CONFIG_NO_HZ_IDLE=y CONFIG_NVMEM=y -CONFIG_OABI_COMPAT=y CONFIG_OF=y CONFIG_OF_ADDRESS=y CONFIG_OF_CONFIGFS=y diff --git a/target/linux/bcm27xx/bcm2709/config-5.15 b/target/linux/bcm27xx/bcm2709/config-5.15 index df02b090057..82d91f3024f 100644 --- a/target/linux/bcm27xx/bcm2709/config-5.15 +++ b/target/linux/bcm27xx/bcm2709/config-5.15 @@ -320,7 +320,6 @@ CONFIG_NO_HZ_COMMON=y CONFIG_NO_HZ_IDLE=y CONFIG_NR_CPUS=4 CONFIG_NVMEM=y -CONFIG_OABI_COMPAT=y CONFIG_OF=y CONFIG_OF_ADDRESS=y CONFIG_OF_CONFIGFS=y From e4c7703d2a62b8914e4723adae3f67c68a57532c Mon Sep 17 00:00:00 2001 From: Rani Hod Date: Sun, 9 Apr 2023 22:47:58 +0300 Subject: [PATCH 042/113] ramips: add support for D-Link DAP-1620 B1 The DAP-1620 rev B is a wall-plug AC1300 repeater. Specifications: - MT7621AT, 256 MiB RAM, 16 MiB SPI NOR - MT7615DN 2x2 802.11n +2x2 802.11ac (DBDC) - Ethernet: 1 port 10/100/1000 - Status LEDs (1x red+green) - LED RSSI bargraph (2x green, 1x red+green) Installation: - Keep reset button pressed during plug-in - Web Recovery Updater is at 192.168.0.50 - Upload factory.bin, confirm flashing (seems to work best with Chromium-based browsers) Revert to OEM firmware: - tail -c+117 DAP1620B1_FW212B03.bin | \ openssl aes-256-cbc -d -md md5 -out decrypted.bin \ -k 905503a4e0c3cd3c1ce062246de427a68962347e - flash decrypted.bin via D-Link Web Recovery Signed-off-by: Rani Hod --- include/image-commands.mk | 7 + .../ramips/dts/mt7621_dlink_dap-1620-b1.dts | 158 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 18 +- .../mt7621/base-files/etc/board.d/01_leds | 7 + .../mt7621/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 15 +- 6 files changed, 198 insertions(+), 8 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_dlink_dap-1620-b1.dts diff --git a/include/image-commands.mk b/include/image-commands.mk index 47d9d1ab888..0c13f30fef6 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -126,6 +126,13 @@ define Build/append-string echo -n $(1) >> $@ endef +define Build/append-md5sum-ascii-salted + cp $@ $@.salted + echo -ne $(1) >> $@.salted + $(STAGING_DIR_HOST)/bin/mkhash md5 $@.salted | head -c32 >> $@ + rm $@.salted +endef + define Build/append-ubi sh $(TOPDIR)/scripts/ubinize-image.sh \ $(if $(UBOOTENV_IN_UBI),--uboot-env) \ diff --git a/target/linux/ramips/dts/mt7621_dlink_dap-1620-b1.dts b/target/linux/ramips/dts/mt7621_dlink_dap-1620-b1.dts new file mode 100644 index 00000000000..919e5be4b9c --- /dev/null +++ b/target/linux/ramips/dts/mt7621_dlink_dap-1620-b1.dts @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "dlink,dap-1620-b1", "mediatek,mt7621-soc"; + model = "D-Link DAP-1620 B1"; + + aliases { + label-mac-device = &gmac0; + + led-boot = &led_status_red; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_red; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: status_red { + label = "red:status"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + + led_status_green: status_green { + label = "green:status"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + rssi_low_red { + label = "red:rssilow"; + gpios = <&gpio 25 GPIO_ACTIVE_LOW>; + }; + + rssi_low_green { + label = "green:rssilow"; + gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + }; + + rssi_med_green { + label = "green:rssimed"; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + }; + + rssi_high_green { + label = "green:rssihigh"; + gpios = <&gpio 22 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_e000: macaddr@e000 { + reg = <0xe000 0x6>; + }; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + /* The correct MAC addresses are set in 10_fix_wifi_mac. */ + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_e000>; + nvmem-cell-names = "mac-address"; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan"; + }; + }; +}; + +ðernet { + pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>; +}; + +&state_default { + gpio { + groups = "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; + diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 96bfab3fef3..c362046b8e8 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -7,7 +7,7 @@ include ./common-tp-link.mk DEFAULT_SOC := mt7621 -DEVICE_VARS += ELECOM_HWNAME LINKSYS_HWNAME +DEVICE_VARS += ELECOM_HWNAME LINKSYS_HWNAME DLINK_HWID ifdef CONFIG_LINUX_5_10 DTS_CPPFLAGS += -DDTS_LEGACY @@ -554,6 +554,22 @@ define Device/cudy_x6 endef TARGET_DEVICES += cudy_x6 +define Device/dlink_dap-1620-b1 + DEVICE_VENDOR := D-Link + DEVICE_MODEL := DAP-1620 + DEVICE_VARIANT := B1 + DEVICE_PACKAGES := kmod-mt7615-firmware rssileds + DLINK_HWID := MT76XMT7621-RP-PR2475-NA + IMAGE_SIZE := 16064k + IMAGES += factory.bin + IMAGE/factory.bin := $$(sysupgrade_bin) | \ + check-size 11009992 | pad-to 11009992 | \ + append-md5sum-ascii-salted ffff | \ + append-string $$(DLINK_HWID) | \ + check-size +endef +TARGET_DEVICES += dlink_dap-1620-b1 + define Device/dlink_dap-x1860-a1 $(Device/dsa-migration) IMAGE_SIZE := 53248k diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 59150bd514f..726d26f0776 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -60,6 +60,13 @@ jcg,y2|\ xzwifi,creativebox-v1) ucidef_set_led_netdev "internet" "internet" "blue:internet" "wan" ;; +dlink,dap-1620-b1) + ucidef_set_rssimon "wlan1" "200000" "1" + ucidef_set_led_rssi "rssilow" "RSSILOW" "red:rssilow" "wlan1" "1" "40" + ucidef_set_led_rssi "rssimediumlow" "RSSIMEDIUMLOW" "green:rssilow" "wlan1" "21" "100" + ucidef_set_led_rssi "rssimediumhigh" "RSSIMEDIUMHIGH" "green:rssimed" "wlan1" "61" "100" + ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "green:rssihigh" "wlan1" "81" "100" + ;; dlink,dap-x1860-a1) ucidef_set_rssimon "wlan1" "200000" "1" ucidef_set_led_rssi "rssilow" "RSSILOW" "orange:rssilow" "wlan1" "1" "25" 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 39c8080e832..871d7fc7d9a 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -14,6 +14,7 @@ ramips_setup_interfaces() ampedwireless,ally-00x19k|\ asus,rp-ac56|\ asus,rp-ac87|\ + dlink,dap-1620-b1|\ dlink,dap-x1860-a1|\ edimax,re23s|\ mikrotik,ltap-2hnd|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index f042830e025..9db115fcae6 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -32,13 +32,7 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress ;; - dlink,dap-x1860-a1) - hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" - [ "$PHYNBR" = "0" ] && \ - macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "1" ] && \ - macaddr_add $hw_mac_addr 4 > /sys${DEVPATH}/macaddress - ;; + dlink,dap-1620-b1|\ dlink,dir-853-a1) lan_mac_addr="$(mtd_get_mac_binary factory 0xe000)" [ "$PHYNBR" = "0" ] && \ @@ -46,6 +40,13 @@ case "$board" in [ "$PHYNBR" = "1" ] && \ macaddr_add $lan_mac_addr 2 > /sys${DEVPATH}/macaddress ;; + dlink,dap-x1860-a1) + hw_mac_addr="$(mtd_get_mac_binary factory 0x4)" + [ "$PHYNBR" = "0" ] && \ + macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress + [ "$PHYNBR" = "1" ] && \ + macaddr_add $hw_mac_addr 4 > /sys${DEVPATH}/macaddress + ;; dlink,dir-853-a3) [ "$PHYNBR" = "0" ] && \ macaddr_setbit_la "$(mtd_get_mac_binary factory 0xe000)" \ From c31319b66934f554f6c337b4cfa888b1fb74faa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20V=C3=A1zquez?= Date: Sat, 21 Jan 2023 22:34:28 +0100 Subject: [PATCH 043/113] ramips: lzma-loader: Refactor loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Delete unused lantiq makefile * Delete redundant makefiles and unify them into the main makefile * Refactor and unify board code into a single file * Add support and review subtarget specific board support Signed-off-by: Antonio Vázquez --- target/linux/ramips/image/Makefile | 1 + .../linux/ramips/image/lzma-loader/Makefile | 4 ++ .../ramips/image/lzma-loader/src/Makefile | 25 ++++++++-- .../image/lzma-loader/src/board-mt7621.c | 39 --------------- .../image/lzma-loader/src/board-ralink.c | 42 ---------------- .../ramips/image/lzma-loader/src/board.c | 48 +++++++++++++++++++ .../ramips/image/lzma-loader/src/lantiq.mk | 1 - .../ramips/image/lzma-loader/src/mt7621.mk | 1 - .../ramips/image/lzma-loader/src/ralink.mk | 1 - 9 files changed, 75 insertions(+), 87 deletions(-) delete mode 100644 target/linux/ramips/image/lzma-loader/src/board-mt7621.c delete mode 100644 target/linux/ramips/image/lzma-loader/src/board-ralink.c create mode 100644 target/linux/ramips/image/lzma-loader/src/board.c delete mode 100644 target/linux/ramips/image/lzma-loader/src/lantiq.mk delete mode 100644 target/linux/ramips/image/lzma-loader/src/mt7621.mk delete mode 100644 target/linux/ramips/image/lzma-loader/src/ralink.mk diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index 275251ff6bf..baa930e684c 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -43,6 +43,7 @@ define Build/loader-common BOARD="$(BOARDNAME)" PLATFORM="$(LOADER_PLATFORM)" \ LZMA_TEXT_START=$(LZMA_TEXT_START) \ LOADADDR=$(LOADADDR) \ + SUBTARGET=$(SUBTARGET) \ $(1) compile loader.$(LOADER_TYPE) mv "$@.$(LOADER_TYPE)" "$@" rm -rf $@.src diff --git a/target/linux/ramips/image/lzma-loader/Makefile b/target/linux/ramips/image/lzma-loader/Makefile index 4cf700d8c64..7b87941e029 100644 --- a/target/linux/ramips/image/lzma-loader/Makefile +++ b/target/linux/ramips/image/lzma-loader/Makefile @@ -18,6 +18,8 @@ FLASH_OFFS := FLASH_MAX := BOARD := PLATFORM := +SUBTARGET := +CACHE_FLAGS := -DCONFIG_CACHELINE_SIZE=32 ifeq ($(TARGET_DIR),) TARGET_DIR := $(KDIR) @@ -46,6 +48,8 @@ loader-compile: $(PKG_BUILD_DIR)/.prepared FLASH_MAX=$(FLASH_MAX) \ BOARD="$(BOARD)" \ PLATFORM="$(PLATFORM)" \ + SUBTARGET="$(SUBTARGET)" \ + CACHE_FLAGS="$(CACHE_FLAGS)" \ clean all loader.gz: $(PKG_BUILD_DIR)/loader.bin diff --git a/target/linux/ramips/image/lzma-loader/src/Makefile b/target/linux/ramips/image/lzma-loader/src/Makefile index 97fd6dad47b..478cf17f29c 100644 --- a/target/linux/ramips/image/lzma-loader/src/Makefile +++ b/target/linux/ramips/image/lzma-loader/src/Makefile @@ -23,6 +23,7 @@ FLASH_START := FLASH_OFFS := FLASH_MAX := PLATFORM := +SUBTARGET := CACHE_FLAGS := CC := $(CROSS_COMPILE)gcc @@ -31,8 +32,6 @@ OBJCOPY := $(CROSS_COMPILE)objcopy OBJDUMP := $(CROSS_COMPILE)objdump -include $(PLATFORM).mk - BIN_FLAGS := -O binary -R .reginfo -R .note -R .comment -R .mdebug \ -R .MIPS.abiflags -S @@ -54,7 +53,27 @@ LDFLAGS += -flto -fwhole-program -Wl,-z,max-page-size=4096 O_FORMAT = $(shell $(OBJDUMP) -i | head -2 | grep elf32) -OBJECTS := head.o loader.o cache.o board-$(PLATFORM).o printf.o LzmaDecode.o +OBJECTS := head.o loader.o cache.o board.o printf.o LzmaDecode.o + +ifeq ($(strip $(SUBTARGET)),) +$(error "Please specify a SUBTARGET!") +endif + +ifeq ($(strip $(SUBTARGET)),mt7620) +CFLAGS += -DSOC_MT7620 +endif + +ifeq ($(strip $(SUBTARGET)),mt7621) +CFLAGS += -DSOC_MT7621 +endif + +ifeq ($(strip $(SUBTARGET)),rt305x) +CFLAGS += -DSOC_RT305X +endif + +ifeq ($(strip $(SUBTARGET)),rt3883) +CFLAGS += -DSOC_RT3883 +endif ifneq ($(strip $(LOADER_DATA)),) OBJECTS += data.o diff --git a/target/linux/ramips/image/lzma-loader/src/board-mt7621.c b/target/linux/ramips/image/lzma-loader/src/board-mt7621.c deleted file mode 100644 index b90b2ed89fc..00000000000 --- a/target/linux/ramips/image/lzma-loader/src/board-mt7621.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Arch specific code for mt7621 based boards, based on code for Ralink boards - * - * Copyright (C) 2018 Tobias Schramm - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include -#include "config.h" - -#define READREG(r) *(volatile uint32_t *)(r) -#define WRITEREG(r,v) *(volatile uint32_t *)(r) = v - -#define KSEG1ADDR(_x) (((_x) & 0x1fffffff) | 0xa0000000) - -#define UART_BASE 0xBE000C00 - -#define UART_TBR_OFFSET 0x00 -#define UART_LSR_OFFSET 0x14 - -#define UART_LSR_TEMT (1 << 6) - -#define UART_READ(r) READREG(UART_BASE + (r)) -#define UART_WRITE(r,v) WRITEREG(UART_BASE + (r), (v)) - -void board_putc(int ch) -{ - while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0); - UART_WRITE(UART_TBR_OFFSET, ch); - while (((UART_READ(UART_LSR_OFFSET)) & UART_LSR_TEMT) == 0); -} - -void board_init(void) -{ -} diff --git a/target/linux/ramips/image/lzma-loader/src/board-ralink.c b/target/linux/ramips/image/lzma-loader/src/board-ralink.c deleted file mode 100644 index 7c947ec6ebe..00000000000 --- a/target/linux/ramips/image/lzma-loader/src/board-ralink.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Arch specific code for Ralink based boards - * - * Copyright (C) 2013 John Crispin - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation. - */ - -#include -#include "config.h" - -#define READREG(r) *(volatile unsigned int *)(r) -#define WRITEREG(r,v) *(volatile unsigned int *)(r) = v - -#define KSEG1ADDR(_x) (((_x) & 0x1fffffff) | 0xa0000000) - -#ifdef CONFIG_SOC_RT288X -#define UART_BASE 0xb0300c00 -#else -#define UART_BASE 0xb0000c00 -#endif - -#define UART_TX 1 -#define UART_LSR 7 - -#define UART_LSR_THRE 0x20 - -#define UART_READ(r) READREG(UART_BASE + 4 * (r)) -#define UART_WRITE(r,v) WRITEREG(UART_BASE + 4 * (r), (v)) - -void board_putc(int ch) -{ - while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0); - UART_WRITE(UART_TX, ch); - while (((UART_READ(UART_LSR)) & UART_LSR_THRE) == 0); -} - -void board_init(void) -{ -} diff --git a/target/linux/ramips/image/lzma-loader/src/board.c b/target/linux/ramips/image/lzma-loader/src/board.c new file mode 100644 index 00000000000..ae9da380738 --- /dev/null +++ b/target/linux/ramips/image/lzma-loader/src/board.c @@ -0,0 +1,48 @@ +/* + * Arch specific code for ramips based boards + * + * Copyright (C) 2013 John Crispin + * Copyright (C) 2018 Tobias Schramm + * Copyright (C) 2023 Antonio Vázquez + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include + +#if defined(SOC_MT7620) || defined(SOC_RT3883) +#define UART_BASE 0xb0000c00 +#define UART_THR (UART_BASE + 0x04) +#define UART_LSR (UART_BASE + 0x1c) +#define UART_LSR_THRE_MASK 0x40 +#elif defined(SOC_MT7621) +#define UART_BASE 0xbe000c00 +#define UART_THR (UART_BASE + 0x00) +#define UART_LSR (UART_BASE + 0x14) +#define UART_LSR_THRE_MASK 0x20 +#elif defined(SOC_RT305X) +#define UART_BASE 0x10000500 +#define UART_THR (UART_BASE + 0x04) +#define UART_LSR (UART_BASE + 0x1c) +#define UART_LSR_THRE_MASK 0x20 +#else +#error "Unsupported SOC..." +#endif + +// Helper functions +#define READREG(r) (*(volatile uint32_t *)(r)) +#define WRITEREG(r,v) (*(volatile uint32_t *)(r)) = v + + +void board_init(void) +{ +} + +void board_putc(int ch) +{ + while ((READREG(UART_LSR) & UART_LSR_THRE_MASK) == 0); + WRITEREG(UART_THR, ch); + while ((READREG(UART_LSR) & UART_LSR_THRE_MASK) == 0); +} diff --git a/target/linux/ramips/image/lzma-loader/src/lantiq.mk b/target/linux/ramips/image/lzma-loader/src/lantiq.mk deleted file mode 100644 index 413764593b4..00000000000 --- a/target/linux/ramips/image/lzma-loader/src/lantiq.mk +++ /dev/null @@ -1 +0,0 @@ -CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(32 * 1024)" -DCONFIG_CACHELINE_SIZE=32 diff --git a/target/linux/ramips/image/lzma-loader/src/mt7621.mk b/target/linux/ramips/image/lzma-loader/src/mt7621.mk deleted file mode 100644 index 3ff5fddf980..00000000000 --- a/target/linux/ramips/image/lzma-loader/src/mt7621.mk +++ /dev/null @@ -1 +0,0 @@ -CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(16 * 1024)" -DCONFIG_CACHELINE_SIZE=32 diff --git a/target/linux/ramips/image/lzma-loader/src/ralink.mk b/target/linux/ramips/image/lzma-loader/src/ralink.mk deleted file mode 100644 index 3ff5fddf980..00000000000 --- a/target/linux/ramips/image/lzma-loader/src/ralink.mk +++ /dev/null @@ -1 +0,0 @@ -CACHE_FLAGS+=-DCONFIG_ICACHE_SIZE="(32 * 1024)" -DCONFIG_DCACHE_SIZE="(16 * 1024)" -DCONFIG_CACHELINE_SIZE=32 From 15e21d373b3ad6ec17be76c48d5ad32266bc4fe7 Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Sat, 22 Apr 2023 06:58:01 +0000 Subject: [PATCH 044/113] ramips: TP-Link EC330-G5u v1: switch to mac-address-ascii The TP-Link EC330-G5u v1 router has MAC address that stored in factory mtd in ascii format. This commit makes the router use of "mac-address-ascii" in dts. After the change: 1. All MAC addresses are explicitly assigned in dts (the workarounds in network scripts are no longer needed); 2. gmac0 (eth0) MAC address is no longer random. Signed-off-by: Mikhail Zhilkin --- .../ramips/dts/mt7621_tplink_ec330-g5u-v1.dts | 26 +++++++++++++++++++ .../mt7621/base-files/etc/board.d/02_network | 5 ---- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 5 ---- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts b/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts index b128a7d7a84..6c9cc407015 100644 --- a/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts +++ b/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts @@ -11,6 +11,8 @@ model = "TP-Link EC330-G5u v1"; aliases { + label-mac-device = &gmac0; + led-boot = &led_power; led-failsafe = &led_power; led-running = &led_power; @@ -226,6 +228,14 @@ label = "factory"; reg = <0x7800000 0x400000>; read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_165: macaddr@165 { + reg = <0x165 0x11>; + }; }; partition@0_wholeflash { @@ -246,6 +256,9 @@ reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x8000>; ieee80211-freq-limit = <2400000 2500000>; + + nvmem-cells = <&macaddr_factory_165>; + nvmem-cell-names = "mac-address-ascii"; }; }; @@ -255,13 +268,26 @@ reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x14000>; ieee80211-freq-limit = <5000000 6000000>; + + nvmem-cells = <&macaddr_factory_165>; + nvmem-cell-names = "mac-address-ascii"; + mac-address-increment = <(2)>; }; }; +&gmac0 { + nvmem-cells = <&macaddr_factory_165>; + nvmem-cell-names = "mac-address-ascii"; +}; + &gmac1 { status = "okay"; label = "wan"; phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_factory_165>; + nvmem-cell-names = "mac-address-ascii"; + mac-address-increment = <(1)>; }; &mdio { 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 871d7fc7d9a..a986e9bac91 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -245,11 +245,6 @@ ramips_setup_macs() label_mac=$(cat "/sys/firmware/mikrotik/hard_config/mac_base") lan_mac=$label_mac ;; - tplink,ec330-g5u-v1) - label_mac="$(mtd_get_mac_text factory 0x165)" - lan_mac=$label_mac - wan_mac=$(macaddr_add $label_mac 1) - ;; tplink,er605-v2) CI_UBIPART="firmware" label_mac=$(mtd_get_mac_uci_config_ubi "tddp") diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 9db115fcae6..746a88bd12f 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -161,11 +161,6 @@ case "$board" in hw_mac_addr="$(mtd_get_mac_binary product-info 0x8)" macaddr_add "$hw_mac_addr" "$PHYNBR" > "/sys${DEVPATH}/macaddress" ;; - tplink,ec330-g5u-v1) - hw_mac_addr="$(mtd_get_mac_text factory 0x165)" - [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress - ;; yuncore,ax820) [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(mtd_get_mac_binary Factory 0xe000)" > /sys${DEVPATH}/macaddress From 4a043dc9d46e36882afbecb20f479e335549bd4b Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Sat, 22 Apr 2023 09:35:44 +0000 Subject: [PATCH 045/113] ramips: add factory image for TP-Link EC330-G5u v1 This commit adds factory.bin image for TP-Link EC330-G5u v1. This allows to install OpenWrt without connecting a serial cable (UART). Installation using factory image -------------------------------- Tested with "3.16.0 0.9.1 v6037.0 Build 191016 Rel.30619nb" TP-Link firmware. 1. Login to the router web interface (http://192.168.0.1/ by default) and save running config to "conf.bin" file 2. Open configuration file in any TP-Link config editor (e.g. https://jahed.github.io/tp-link-config-editor/) 3. Find "DeviceInfo" section and insert a new string "" according to the following example: ... ... 4. Save configuration file and upload changed configuration using stock firmware interface 5. Login using telnet to IP:192.168.0.1 (Username:admin, password:1234) 6. Run "cat /proc/mtd | grep mtd7" a. If the result is 'mtd7: 03000000 00020000 "rootfs" 03400000', then install stock firmware using web interface to toggle booted firmware image from "os1" to "os0" b. If the result is 'mtd7: 03000000 00020000 "rootfs" 00400000', then all is ok, go to the next step 7. Set up a tftp server with OpenWrt factory.bin image (IP:192.168.0.100 in this example) 8. Login using telnet to 192.168.0.1 9. Download OpenWrt factory.bin image from the tftp server: cd /tmp tftp -g -r factory.bin 192.168.0.100 10. Write OpenWrt factory.bin image: dd if=/tmp/factory.bin of=/dev/mtdblock1 11. Power cycle the router Signed-off-by: Mikhail Zhilkin --- target/linux/ramips/image/mt7621.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index c362046b8e8..24daba43aa0 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -2214,6 +2214,9 @@ define Device/tplink_ec330-g5u-v1 uImage-tplink-c9 firmware 'OS IMAGE ($(VERSION_DIST))' KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \ uImage none + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \ + append-ubi | check-size IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | check-size endef TARGET_DEVICES += tplink_ec330-g5u-v1 From 80c1105b0339516344f12364a599070ab1c9a41a Mon Sep 17 00:00:00 2001 From: John Audia Date: Sat, 29 Apr 2023 04:00:30 -0400 Subject: [PATCH 046/113] kernel: bump 5.10 to 5.10.179 All patches automatically rebased. Signed-off-by: John Audia --- include/kernel-5.10 | 4 ++-- .../425-at803x-allow-sgmii-aneg-override.patch | 2 +- .../patches-5.10/280-activate_ssb_support_in_usb.patch | 4 ++-- .../patches-5.10/039-v6.2-bcma-support-SPROM-rev-11.patch | 2 +- .../backport-5.10/630-v5.15-page_pool_frag_support.patch | 8 ++++---- ...13-0006-net-dsa-b53-mmap-Add-device-tree-support.patch | 4 ++-- .../generic/hack-5.10/721-net-add-packet-mangeling.patch | 4 ++-- .../linux/generic/pending-5.10/655-increase_skb_pad.patch | 2 +- .../680-NET-skip-GRO-for-foreign-MAC-addresses.patch | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/kernel-5.10 b/include/kernel-5.10 index e5a47e33d21..bc3926bb3df 100644 --- a/include/kernel-5.10 +++ b/include/kernel-5.10 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.10 = .178 -LINUX_KERNEL_HASH-5.10.178 = 1acfade3715e560f00fb30615d5471e24b3940b549381558787aee9734e7a8af +LINUX_VERSION-5.10 = .179 +LINUX_KERNEL_HASH-5.10.179 = 1bbd445c154b053eea46acc883be548a98179988a9ed3a0b81bddfbf30a37e29 diff --git a/target/linux/ath79/patches-5.10/425-at803x-allow-sgmii-aneg-override.patch b/target/linux/ath79/patches-5.10/425-at803x-allow-sgmii-aneg-override.patch index 92c64ac9c48..ef1e5a6b4a3 100644 --- a/target/linux/ath79/patches-5.10/425-at803x-allow-sgmii-aneg-override.patch +++ b/target/linux/ath79/patches-5.10/425-at803x-allow-sgmii-aneg-override.patch @@ -16,7 +16,7 @@ Submitted-by: Adrian Schmutzler --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c -@@ -830,6 +830,13 @@ static int at803x_aneg_done(struct phy_d +@@ -959,6 +959,13 @@ static int at803x_aneg_done(struct phy_d if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { phydev_warn(phydev, "803x_aneg_done: SGMII link is not ok\n"); aneg_done = 0; diff --git a/target/linux/bcm47xx/patches-5.10/280-activate_ssb_support_in_usb.patch b/target/linux/bcm47xx/patches-5.10/280-activate_ssb_support_in_usb.patch index de8bb4297d0..f6e9e6d30a6 100644 --- a/target/linux/bcm47xx/patches-5.10/280-activate_ssb_support_in_usb.patch +++ b/target/linux/bcm47xx/patches-5.10/280-activate_ssb_support_in_usb.patch @@ -5,7 +5,7 @@ This prevents the options from being delete with make kernel_oldconfig. --- a/drivers/bcma/Kconfig +++ b/drivers/bcma/Kconfig -@@ -32,6 +32,7 @@ config BCMA_HOST_PCI +@@ -36,6 +36,7 @@ config BCMA_HOST_PCI config BCMA_HOST_SOC bool "Support for BCMA in a SoC" depends on HAS_IOMEM @@ -15,7 +15,7 @@ This prevents the options from being delete with make kernel_oldconfig. the memory. This only works with the Broadcom SoCs from the --- a/drivers/ssb/Kconfig +++ b/drivers/ssb/Kconfig -@@ -136,6 +136,7 @@ config SSB_SFLASH +@@ -141,6 +141,7 @@ config SSB_SFLASH config SSB_EMBEDDED bool depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE diff --git a/target/linux/bcm53xx/patches-5.10/039-v6.2-bcma-support-SPROM-rev-11.patch b/target/linux/bcm53xx/patches-5.10/039-v6.2-bcma-support-SPROM-rev-11.patch index 7c9eb5537e1..5ebc78ca202 100644 --- a/target/linux/bcm53xx/patches-5.10/039-v6.2-bcma-support-SPROM-rev-11.patch +++ b/target/linux/bcm53xx/patches-5.10/039-v6.2-bcma-support-SPROM-rev-11.patch @@ -17,7 +17,7 @@ Signed-off-by: Linus Walleij --- a/drivers/bcma/sprom.c +++ b/drivers/bcma/sprom.c -@@ -165,7 +165,7 @@ static int bcma_sprom_valid(struct bcma_ +@@ -170,7 +170,7 @@ static int bcma_sprom_valid(struct bcma_ return err; revision = sprom[words - 1] & SSB_SPROM_REVISION_REV; diff --git a/target/linux/generic/backport-5.10/630-v5.15-page_pool_frag_support.patch b/target/linux/generic/backport-5.10/630-v5.15-page_pool_frag_support.patch index 09fb69f2516..dad4803848a 100644 --- a/target/linux/generic/backport-5.10/630-v5.15-page_pool_frag_support.patch +++ b/target/linux/generic/backport-5.10/630-v5.15-page_pool_frag_support.patch @@ -677,7 +677,7 @@ #if IS_ENABLED(CONFIG_NF_CONNTRACK) #include #endif -@@ -786,7 +787,8 @@ struct sk_buff { +@@ -787,7 +788,8 @@ struct sk_buff { fclone:2, peeked:1, head_frag:1, @@ -687,7 +687,7 @@ #ifdef CONFIG_SKB_EXTENSIONS __u8 active_extensions; #endif -@@ -3029,9 +3031,15 @@ static inline void skb_frag_ref(struct s +@@ -3030,9 +3032,15 @@ static inline void skb_frag_ref(struct s * * Releases a reference on the paged fragment @frag. */ @@ -705,7 +705,7 @@ } /** -@@ -3043,7 +3051,7 @@ static inline void __skb_frag_unref(skb_ +@@ -3044,7 +3052,7 @@ static inline void __skb_frag_unref(skb_ */ static inline void skb_frag_unref(struct sk_buff *skb, int f) { @@ -714,7 +714,7 @@ } /** -@@ -4642,5 +4650,12 @@ static inline u64 skb_get_kcov_handle(st +@@ -4643,5 +4651,12 @@ static inline u64 skb_get_kcov_handle(st #endif } diff --git a/target/linux/generic/backport-5.10/740-v5.13-0006-net-dsa-b53-mmap-Add-device-tree-support.patch b/target/linux/generic/backport-5.10/740-v5.13-0006-net-dsa-b53-mmap-Add-device-tree-support.patch index c1014b20bcf..48494d13e47 100644 --- a/target/linux/generic/backport-5.10/740-v5.13-0006-net-dsa-b53-mmap-Add-device-tree-support.patch +++ b/target/linux/generic/backport-5.10/740-v5.13-0006-net-dsa-b53-mmap-Add-device-tree-support.patch @@ -24,8 +24,8 @@ Signed-off-by: David S. Miller #include #include #include -@@ -228,11 +229,65 @@ static const struct b53_io_ops b53_mmap_ - .write64 = b53_mmap_write64, +@@ -242,11 +243,65 @@ static const struct b53_io_ops b53_mmap_ + .phy_write16 = b53_mmap_phy_write16, }; +static int b53_mmap_probe_of(struct platform_device *pdev, diff --git a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch index a80ce4baae8..fed3848a9c5 100644 --- a/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch +++ b/target/linux/generic/hack-5.10/721-net-add-packet-mangeling.patch @@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau */ --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2727,6 +2727,10 @@ static inline int pskb_trim(struct sk_bu +@@ -2728,6 +2728,10 @@ static inline int pskb_trim(struct sk_bu return (len < skb->len) ? __pskb_trim(skb, len) : 0; } @@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau /** * pskb_trim_unique - remove end from a paged unique (not cloned) buffer * @skb: buffer to alter -@@ -2858,16 +2862,6 @@ static inline struct sk_buff *dev_alloc_ +@@ -2859,16 +2863,6 @@ static inline struct sk_buff *dev_alloc_ } diff --git a/target/linux/generic/pending-5.10/655-increase_skb_pad.patch b/target/linux/generic/pending-5.10/655-increase_skb_pad.patch index 0b25a76416c..dafafad5881 100644 --- a/target/linux/generic/pending-5.10/655-increase_skb_pad.patch +++ b/target/linux/generic/pending-5.10/655-increase_skb_pad.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2693,7 +2693,7 @@ static inline int pskb_network_may_pull( +@@ -2694,7 +2694,7 @@ static inline int pskb_network_may_pull( * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD diff --git a/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch b/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch index 12a7fb5a7d6..d948848cc61 100644 --- a/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch +++ b/target/linux/generic/pending-5.10/680-NET-skip-GRO-for-foreign-MAC-addresses.patch @@ -22,7 +22,7 @@ Signed-off-by: Felix Fietkau #endif --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -863,6 +863,7 @@ struct sk_buff { +@@ -864,6 +864,7 @@ struct sk_buff { __u8 decrypted:1; #endif __u8 scm_io_uring:1; From 45f5115253362c82296eb212742381e90199b3ef Mon Sep 17 00:00:00 2001 From: John Audia Date: Sat, 29 Apr 2023 07:22:29 -0400 Subject: [PATCH 047/113] kernel: bump 5.15 to 5.15.109 Removed upstreamed: backport-5.15/743-v6.3-0005-net-dsa-b53-mmap-add-phy-ops.patch[1] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.109&id=357fa038d93d0e9159a0f0d45bae0f8654e2ade5 Build system: x86_64 Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia --- include/kernel-5.15 | 4 +- ...-gen-LRU-per-node-lru_gen_page-lists.patch | 2 +- ...ize-metadata-to-skb_shared_info-for-.patch | 2 +- ....3-0005-net-dsa-b53-mmap-add-phy-ops.patch | 49 ------------------- .../721-net-add-packet-mangeling.patch | 4 +- ...e_mem_map-with-ARCH_PFN_OFFSET-calcu.patch | 2 +- .../pending-5.15/655-increase_skb_pad.patch | 2 +- ...T-skip-GRO-for-foreign-MAC-addresses.patch | 2 +- ...pecific-data-to-struct-skb_shared_in.patch | 2 +- ...eplace-deprecated-perst-gpio-with-pe.patch | 2 +- ...ts-qcom-hk01-use-GPIO-flags-for-tlmm.patch | 2 +- 11 files changed, 12 insertions(+), 61 deletions(-) delete mode 100644 target/linux/generic/backport-5.15/743-v6.3-0005-net-dsa-b53-mmap-add-phy-ops.patch diff --git a/include/kernel-5.15 b/include/kernel-5.15 index 9cd730ca502..6bc20e7ff8c 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .108 -LINUX_KERNEL_HASH-5.15.108 = 8beb69ada46f1cbca2f4cf901ec078846035c1cd925d9471422f65aff74243ba +LINUX_VERSION-5.15 = .109 +LINUX_KERNEL_HASH-5.15.109 = 066c4bbcbe3c480068a2e302f52b1708f340ecaaf633ec43d7f791bbeac5771a diff --git a/target/linux/generic/backport-5.15/020-v6.3-26-mm-multi-gen-LRU-per-node-lru_gen_page-lists.patch b/target/linux/generic/backport-5.15/020-v6.3-26-mm-multi-gen-LRU-per-node-lru_gen_page-lists.patch index cf01c3997a2..f54e828de10 100644 --- a/target/linux/generic/backport-5.15/020-v6.3-26-mm-multi-gen-LRU-per-node-lru_gen_page-lists.patch +++ b/target/linux/generic/backport-5.15/020-v6.3-26-mm-multi-gen-LRU-per-node-lru_gen_page-lists.patch @@ -354,7 +354,7 @@ Signed-off-by: Andrew Morton static void mem_cgroup_css_free(struct cgroup_subsys_state *css) --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -7645,6 +7645,7 @@ static void __init free_area_init_node(i +@@ -7661,6 +7661,7 @@ static void __init free_area_init_node(i pgdat_set_deferred_range(pgdat); free_area_init_core(pgdat); diff --git a/target/linux/generic/backport-5.15/607-v5.18-net-skbuff-add-size-metadata-to-skb_shared_info-for-.patch b/target/linux/generic/backport-5.15/607-v5.18-net-skbuff-add-size-metadata-to-skb_shared_info-for-.patch index a0344a332a3..36f55d511ad 100644 --- a/target/linux/generic/backport-5.15/607-v5.18-net-skbuff-add-size-metadata-to-skb_shared_info-for-.patch +++ b/target/linux/generic/backport-5.15/607-v5.18-net-skbuff-add-size-metadata-to-skb_shared_info-for-.patch @@ -21,7 +21,7 @@ Signed-off-by: Alexei Starovoitov --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -567,6 +567,7 @@ struct skb_shared_info { +@@ -568,6 +568,7 @@ struct skb_shared_info { * Warning : all fields before dataref are cleared in __alloc_skb() */ atomic_t dataref; diff --git a/target/linux/generic/backport-5.15/743-v6.3-0005-net-dsa-b53-mmap-add-phy-ops.patch b/target/linux/generic/backport-5.15/743-v6.3-0005-net-dsa-b53-mmap-add-phy-ops.patch deleted file mode 100644 index f35ae2588b6..00000000000 --- a/target/linux/generic/backport-5.15/743-v6.3-0005-net-dsa-b53-mmap-add-phy-ops.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 45977e58ce65ed0459edc9a0466d9dfea09463f5 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= -Date: Thu, 23 Mar 2023 20:48:41 +0100 -Subject: [PATCH] net: dsa: b53: mmap: add phy ops -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Implement phy_read16() and phy_write16() ops for B53 MMAP to avoid accessing -B53_PORT_MII_PAGE registers which hangs the device. -This access should be done through the MDIO Mux bus controller. - -Signed-off-by: Álvaro Fernández Rojas -Acked-by: Florian Fainelli -Signed-off-by: David S. Miller ---- - drivers/net/dsa/b53/b53_mmap.c | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - ---- a/drivers/net/dsa/b53/b53_mmap.c -+++ b/drivers/net/dsa/b53/b53_mmap.c -@@ -216,6 +216,18 @@ static int b53_mmap_write64(struct b53_d - return 0; - } - -+static int b53_mmap_phy_read16(struct b53_device *dev, int addr, int reg, -+ u16 *value) -+{ -+ return -EIO; -+} -+ -+static int b53_mmap_phy_write16(struct b53_device *dev, int addr, int reg, -+ u16 value) -+{ -+ return -EIO; -+} -+ - static const struct b53_io_ops b53_mmap_ops = { - .read8 = b53_mmap_read8, - .read16 = b53_mmap_read16, -@@ -227,6 +239,8 @@ static const struct b53_io_ops b53_mmap_ - .write32 = b53_mmap_write32, - .write48 = b53_mmap_write48, - .write64 = b53_mmap_write64, -+ .phy_read16 = b53_mmap_phy_read16, -+ .phy_write16 = b53_mmap_phy_write16, - }; - - static int b53_mmap_probe_of(struct platform_device *pdev, diff --git a/target/linux/generic/hack-5.15/721-net-add-packet-mangeling.patch b/target/linux/generic/hack-5.15/721-net-add-packet-mangeling.patch index 16bb4855ff3..dbdb141c6dc 100644 --- a/target/linux/generic/hack-5.15/721-net-add-packet-mangeling.patch +++ b/target/linux/generic/hack-5.15/721-net-add-packet-mangeling.patch @@ -71,7 +71,7 @@ Signed-off-by: Felix Fietkau */ --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2854,6 +2854,10 @@ static inline int pskb_trim(struct sk_bu +@@ -2855,6 +2855,10 @@ static inline int pskb_trim(struct sk_bu return (len < skb->len) ? __pskb_trim(skb, len) : 0; } @@ -82,7 +82,7 @@ Signed-off-by: Felix Fietkau /** * pskb_trim_unique - remove end from a paged unique (not cloned) buffer * @skb: buffer to alter -@@ -3004,16 +3008,6 @@ static inline struct sk_buff *dev_alloc_ +@@ -3005,16 +3009,6 @@ static inline struct sk_buff *dev_alloc_ } diff --git a/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch b/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch index c1313c82f4d..ac5e3a69b80 100644 --- a/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch +++ b/target/linux/generic/pending-5.15/120-Fix-alloc_node_mem_map-with-ARCH_PFN_OFFSET-calcu.patch @@ -71,7 +71,7 @@ Signed-off-by: Tobias Wolf --- a/mm/page_alloc.c +++ b/mm/page_alloc.c -@@ -7604,7 +7604,7 @@ static void __init alloc_node_mem_map(st +@@ -7620,7 +7620,7 @@ static void __init alloc_node_mem_map(st if (pgdat == NODE_DATA(0)) { mem_map = NODE_DATA(0)->node_mem_map; if (page_to_pfn(mem_map) != pgdat->node_start_pfn) diff --git a/target/linux/generic/pending-5.15/655-increase_skb_pad.patch b/target/linux/generic/pending-5.15/655-increase_skb_pad.patch index d1bb72d3535..5d100270a90 100644 --- a/target/linux/generic/pending-5.15/655-increase_skb_pad.patch +++ b/target/linux/generic/pending-5.15/655-increase_skb_pad.patch @@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -2820,7 +2820,7 @@ static inline int pskb_network_may_pull( +@@ -2821,7 +2821,7 @@ static inline int pskb_network_may_pull( * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD diff --git a/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch b/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch index e9705fae461..091e65f31e0 100644 --- a/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch +++ b/target/linux/generic/pending-5.15/680-NET-skip-GRO-for-foreign-MAC-addresses.patch @@ -22,7 +22,7 @@ Signed-off-by: Felix Fietkau #endif --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -892,6 +892,7 @@ struct sk_buff { +@@ -893,6 +893,7 @@ struct sk_buff { #ifdef CONFIG_IPV6_NDISC_NODETYPE __u8 ndisc_nodetype:2; #endif diff --git a/target/linux/ipq40xx/patches-5.15/700-skbuff-add-DSA-specific-data-to-struct-skb_shared_in.patch b/target/linux/ipq40xx/patches-5.15/700-skbuff-add-DSA-specific-data-to-struct-skb_shared_in.patch index 582b98cc7db..385364c076e 100644 --- a/target/linux/ipq40xx/patches-5.15/700-skbuff-add-DSA-specific-data-to-struct-skb_shared_in.patch +++ b/target/linux/ipq40xx/patches-5.15/700-skbuff-add-DSA-specific-data-to-struct-skb_shared_in.patch @@ -31,7 +31,7 @@ Signed-off-by: Gabor Juhos --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h -@@ -563,6 +563,9 @@ struct skb_shared_info { +@@ -564,6 +564,9 @@ struct skb_shared_info { unsigned int gso_type; u32 tskey; diff --git a/target/linux/ipq807x/patches-5.15/0054-v6.1-arm64-dts-qcom-replace-deprecated-perst-gpio-with-pe.patch b/target/linux/ipq807x/patches-5.15/0054-v6.1-arm64-dts-qcom-replace-deprecated-perst-gpio-with-pe.patch index b4ecd776a60..35f4676a150 100644 --- a/target/linux/ipq807x/patches-5.15/0054-v6.1-arm64-dts-qcom-replace-deprecated-perst-gpio-with-pe.patch +++ b/target/linux/ipq807x/patches-5.15/0054-v6.1-arm64-dts-qcom-replace-deprecated-perst-gpio-with-pe.patch @@ -32,7 +32,7 @@ Link: https://lore.kernel.org/r/20220506152107.1527552-9-dmitry.baryshkov@linaro + perst-gpios = <&tlmm 58 0x1>; }; - &pcie_phy0 { + &pcie_qmp0 { --- a/arch/arm64/boot/dts/qcom/ipq8074-hk10.dtsi +++ b/arch/arm64/boot/dts/qcom/ipq8074-hk10.dtsi @@ -39,12 +39,12 @@ diff --git a/target/linux/ipq807x/patches-5.15/0068-v6.2-arm64-dts-qcom-hk01-use-GPIO-flags-for-tlmm.patch b/target/linux/ipq807x/patches-5.15/0068-v6.2-arm64-dts-qcom-hk01-use-GPIO-flags-for-tlmm.patch index 829e2278a00..93c57d9ea93 100644 --- a/target/linux/ipq807x/patches-5.15/0068-v6.2-arm64-dts-qcom-hk01-use-GPIO-flags-for-tlmm.patch +++ b/target/linux/ipq807x/patches-5.15/0068-v6.2-arm64-dts-qcom-hk01-use-GPIO-flags-for-tlmm.patch @@ -39,4 +39,4 @@ Link: https://lore.kernel.org/r/20221107092930.33325-3-robimarko@gmail.com + perst-gpios = <&tlmm 58 GPIO_ACTIVE_LOW>; }; - &pcie_phy0 { + &pcie_qmp0 { From 28b3a5e6b5b17520d62745cac5cfa07e4793fe5c Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 30 Apr 2023 03:59:55 +0100 Subject: [PATCH 048/113] generic: net: phy: realtek: detect early version of RTL8221B Early versions (?) of the RTL8221B PHY cannot be identified in a regular Clause-45 bus scan as the PHY doesn't report the implemented MMDs correctly but returns 0 instead. Implement custom identify function using the PKGID instead of iterating over the implemented MMDs to work-around this problem. Signed-off-by: Daniel Golle --- ...tek-detect-early-version-of-RTL8221B.patch | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch diff --git a/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch b/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch new file mode 100644 index 00000000000..6d414bfbade --- /dev/null +++ b/target/linux/generic/pending-5.15/730-net-phy-realtek-detect-early-version-of-RTL8221B.patch @@ -0,0 +1,63 @@ +From 0de82310d2b32e78ff79d42c08b1122a6ede3778 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Sun, 30 Apr 2023 00:15:41 +0100 +Subject: [PATCH] net: phy: realtek: detect early version of RTL8221B + +Early versions (?) of the RTL8221B PHY cannot be identified in a regular +Clause-45 bus scan as the PHY doesn't report the implemented MMDs +correctly but returns 0 instead. +Implement custom identify function using the PKGID instead of iterating +over the implemented MMDs. + +Signed-off-by: Daniel Golle + +--- a/drivers/net/phy/realtek.c ++++ b/drivers/net/phy/realtek.c +@@ -744,6 +744,38 @@ static int rtl8226_match_phy_device(stru + rtlgen_supports_2_5gbps(phydev); + } + ++static int rtl8221b_vb_cg_match_phy_device(struct phy_device *phydev) ++{ ++ int val; ++ u32 id; ++ ++ if (phydev->mdio.bus->probe_capabilities >= MDIOBUS_C45) { ++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID1); ++ if (val < 0) ++ return 0; ++ ++ id = val << 16; ++ val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PKGID2); ++ if (val < 0) ++ return 0; ++ ++ id |= val; ++ } else { ++ val = phy_read(phydev, MII_PHYSID1); ++ if (val < 0) ++ return 0; ++ ++ id = val << 16; ++ val = phy_read(phydev, MII_PHYSID2); ++ if (val < 0) ++ return 0; ++ ++ id |= val; ++ } ++ ++ return (id == 0x001cc849); ++} ++ + static int rtl822x_probe(struct phy_device *phydev) + { + struct device *dev = &phydev->mdio.dev; +@@ -1084,7 +1116,7 @@ static struct phy_driver realtek_drvs[] + .write_page = rtl821x_write_page, + .soft_reset = genphy_soft_reset, + }, { +- PHY_ID_MATCH_EXACT(0x001cc849), ++ .match_phy_device = rtl8221b_vb_cg_match_phy_device, + .name = "RTL8221B-VB-CG 2.5Gbps PHY", + .get_features = rtl822x_get_features, + .config_init = rtl8221b_config_init, From 3221128639e43d5bcf3a06eda769350a75b3dc72 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 30 Apr 2023 04:01:12 +0100 Subject: [PATCH 049/113] mediatek: no longer hard-code WAN PHY of Netgear WAX206 The RealTek 2.5G PHY providing the WAN port of the Netgear WAX206 has previously been hard-coded in the device tree. Now that the PHY can be probed correctly also via Clause-45 MDIO, use that instead. Signed-off-by: Daniel Golle --- target/linux/mediatek/dts/mt7622-netgear-wax206.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/dts/mt7622-netgear-wax206.dts b/target/linux/mediatek/dts/mt7622-netgear-wax206.dts index 3846fabbeda..9e877b85f16 100644 --- a/target/linux/mediatek/dts/mt7622-netgear-wax206.dts +++ b/target/linux/mediatek/dts/mt7622-netgear-wax206.dts @@ -185,7 +185,7 @@ nvmem-cells = <&macaddr_factory_7fffa>; nvmem-cell-names = "mac-address"; phy-handle = <&rtl8221b_phy>; - phy-mode = "sgmii"; + phy-mode = "2500base-x"; reg = <5>; }; @@ -204,7 +204,7 @@ }; rtl8221b_phy: ethernet-phy@7 { - compatible = "ethernet-phy-id001c.c849"; + compatible = "ethernet-phy-ieee802.3-c45"; reg = <7>; reset-gpios = <&pio 101 GPIO_ACTIVE_LOW>; interrupts = <52 IRQ_TYPE_LEVEL_HIGH>; From cf8d861978dbfdb572a25db460db464b50d9e809 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 11 Mar 2023 21:34:25 +0100 Subject: [PATCH 050/113] realtek: hpe_1920-8g: add phy-handle for SFP ports The switch driver actually expects every port to have a PHY handle, and several branches in the code determine if a port is valid by checking for a non-zero phy field. Signed-off-by: Jan Hoffmann --- target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts | 2 ++ target/linux/realtek/dts-5.15/rtl8380_hpe_1920-8g.dts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts index b51c75f3552..6ddb2d8dcc6 100644 --- a/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts +++ b/target/linux/realtek/dts-5.10/rtl8380_hpe_1920-8g.dts @@ -87,6 +87,7 @@ port@24 { reg = <24>; label = "lan9"; + phy-handle = <&phy24>; phy-mode = "1000base-x"; managed = "in-band-status"; sfp = <&sfp0>; @@ -95,6 +96,7 @@ port@26 { reg = <26>; label = "lan10"; + phy-handle = <&phy26>; phy-mode = "1000base-x"; managed = "in-band-status"; sfp = <&sfp1>; diff --git a/target/linux/realtek/dts-5.15/rtl8380_hpe_1920-8g.dts b/target/linux/realtek/dts-5.15/rtl8380_hpe_1920-8g.dts index b51c75f3552..6ddb2d8dcc6 100644 --- a/target/linux/realtek/dts-5.15/rtl8380_hpe_1920-8g.dts +++ b/target/linux/realtek/dts-5.15/rtl8380_hpe_1920-8g.dts @@ -87,6 +87,7 @@ port@24 { reg = <24>; label = "lan9"; + phy-handle = <&phy24>; phy-mode = "1000base-x"; managed = "in-band-status"; sfp = <&sfp0>; @@ -95,6 +96,7 @@ port@26 { reg = <26>; label = "lan10"; + phy-handle = <&phy26>; phy-mode = "1000base-x"; managed = "in-band-status"; sfp = <&sfp1>; From e38de40f8dd350344407fe5a91e81191f6960804 Mon Sep 17 00:00:00 2001 From: Felix Baumann Date: Fri, 21 Apr 2023 03:39:38 +0200 Subject: [PATCH 051/113] ramips: mt7621: add support for Cudy X6 v2 Rename existing device to v1 and create common .dtsi Difference to v1: 16MB Flash Specifications: SoC: MediaTek MT7621 RAM: 256 MB Flash: 16 MB (SPI NOR, XM25QH128C on my device) WiFi: MediaTek MT7915E Switch: 1 WAN, 4 LAN (Gigabit) Buttons: Reset, WPS LEDs: Two Power LEDs (blue and red; together they form purple) Power: DC 12V 1A center positive Serial: 115200 8N1 C440 - (3V3 - GND - RX - TX) - C41 | v1 and v2 (P - G - R - T) | v2 labels them on the board Installation: Download and flash the manufacturer's built OpenWrt image available at http://www.cudytech.com/openwrt_software_download Install the new OpenWrt image via luci (System -> Backup/Flash firmware) Be sure to NOT keep settings. Recovery: Loads only signed manufacture firmware due to bootloader RSA verification Serve tftp-recovery image as /recovery.bin on 192.168.1.88/24 Connect to any lan ethernet port Power on the device while holding the reset button Wait at least 8 seconds before releasing reset button for image to download MAC addresses as verified by OEM firmware: use address source LAN f4:a4:54:86:75:a2 label WAN f4:a4:54:86:75:a3 label + 1 2g f4:a4:54:86:75:a2 label 5g f6:a4:54:b6:75:a2 label + LA-Bit set + 4th oktet increased The label MAC address is found in bdinfo 0xde00. Signed-off-by: Felix Baumann --- target/linux/ramips/dts/mt7621_cudy_x6-v1.dts | 58 +++++++++++++++++++ target/linux/ramips/dts/mt7621_cudy_x6-v2.dts | 58 +++++++++++++++++++ ...mt7621_cudy_x6.dts => mt7621_cudy_x6.dtsi} | 51 +--------------- target/linux/ramips/image/mt7621.mk | 19 +++++- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 +- 5 files changed, 137 insertions(+), 52 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_cudy_x6-v1.dts create mode 100644 target/linux/ramips/dts/mt7621_cudy_x6-v2.dts rename target/linux/ramips/dts/{mt7621_cudy_x6.dts => mt7621_cudy_x6.dtsi} (68%) diff --git a/target/linux/ramips/dts/mt7621_cudy_x6-v1.dts b/target/linux/ramips/dts/mt7621_cudy_x6-v1.dts new file mode 100644 index 00000000000..cfae15e5659 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_cudy_x6-v1.dts @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_cudy_x6.dtsi" + +/ { + compatible = "cudy,x6-v1", "mediatek,mt7621-soc"; + model = "CUDY X6 v1"; +}; + +&partitions { + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x1f80000>; + }; + + partition@1fd0000 { + label = "debug"; + reg = <0x1fd0000 0x10000>; + read-only; + }; + + partition@1fe0000 { + label = "backup"; + reg = <0x1fe0000 0x10000>; + read-only; + }; + + partition@1ff0000 { + label = "bdinfo"; + reg = <0x1ff0000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_de00: macaddr@de00 { + reg = <0xde00 0x6>; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +&wifi { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; +}; diff --git a/target/linux/ramips/dts/mt7621_cudy_x6-v2.dts b/target/linux/ramips/dts/mt7621_cudy_x6-v2.dts new file mode 100644 index 00000000000..16fa15befc4 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_cudy_x6-v2.dts @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_cudy_x6.dtsi" + +/ { + compatible = "cudy,x6-v2", "mediatek,mt7621-soc"; + model = "CUDY X6 v2"; +}; + +&partitions { + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xf80000>; + }; + + partition@fd0000 { + label = "debug"; + reg = <0xfd0000 0x10000>; + read-only; + }; + + partition@fe0000 { + label = "backup"; + reg = <0xfe0000 0x10000>; + read-only; + }; + + partition@ff0000 { + label = "bdinfo"; + reg = <0xff0000 0x10000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_de00: macaddr@de00 { + reg = <0xde00 0x6>; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; + mac-address-increment = <1>; +}; + +&wifi { + nvmem-cells = <&macaddr_bdinfo_de00>; + nvmem-cell-names = "mac-address"; +}; diff --git a/target/linux/ramips/dts/mt7621_cudy_x6.dts b/target/linux/ramips/dts/mt7621_cudy_x6.dtsi similarity index 68% rename from target/linux/ramips/dts/mt7621_cudy_x6.dts rename to target/linux/ramips/dts/mt7621_cudy_x6.dtsi index 5d5bb5150cc..4c34f58a4b2 100644 --- a/target/linux/ramips/dts/mt7621_cudy_x6.dts +++ b/target/linux/ramips/dts/mt7621_cudy_x6.dtsi @@ -6,9 +6,6 @@ #include / { - compatible = "cudy,x6", "mediatek,mt7621-soc"; - model = "CUDY X6"; - aliases { led-boot = &led_internet_blue; led-failsafe = &led_internet_red; @@ -61,7 +58,7 @@ reg = <0>; spi-max-frequency = <50000000>; - partitions { + partitions: partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; @@ -84,37 +81,7 @@ read-only; }; - partition@50000 { - compatible = "denx,uimage"; - label = "firmware"; - reg = <0x50000 0x1f80000>; - }; - - partition@1fd0000 { - label = "debug"; - reg = <0x1fd0000 0x10000>; - read-only; - }; - - partition@1fe0000 { - label = "backup"; - reg = <0x1fe0000 0x10000>; - read-only; - }; - - partition@1ff0000 { - label = "bdinfo"; - reg = <0x1ff0000 0x10000>; - read-only; - - compatible = "nvmem-cells"; - #address-cells = <1>; - #size-cells = <1>; - - macaddr_bdinfo_de00: macaddr@de00 { - reg = <0xde00 0x6>; - }; - }; + /* additional partitions in DTS */ }; }; }; @@ -124,30 +91,18 @@ }; &pcie1 { - wifi@0,0 { + wifi:wifi@0,0 { compatible = "mediatek,mt76"; reg = <0x0000 0 0 0 0>; mediatek,mtd-eeprom = <&factory 0x0000>; mediatek,disable-radar-background; - - nvmem-cells = <&macaddr_bdinfo_de00>; - nvmem-cell-names = "mac-address"; }; }; -&gmac0 { - nvmem-cells = <&macaddr_bdinfo_de00>; - nvmem-cell-names = "mac-address"; -}; - &gmac1 { status = "okay"; label = "wan"; phy-handle = <ðphy4>; - - nvmem-cells = <&macaddr_bdinfo_de00>; - nvmem-cell-names = "mac-address"; - mac-address-increment = <1>; }; &mdio { diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 24daba43aa0..135febe3a6d 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -543,16 +543,29 @@ define Device/cudy_wr2100 endef TARGET_DEVICES += cudy_wr2100 -define Device/cudy_x6 +define Device/cudy_x6-v1 $(Device/dsa-migration) IMAGE_SIZE := 32256k DEVICE_VENDOR := Cudy DEVICE_MODEL := X6 + DEVICE_VARIANT := v1 UIMAGE_NAME := R13 DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools - SUPPORTED_DEVICES += R13 + SUPPORTED_DEVICES += cudy,x6 R13 endef -TARGET_DEVICES += cudy_x6 +TARGET_DEVICES += cudy_x6-v1 + +define Device/cudy_x6-v2 + $(Device/dsa-migration) + IMAGE_SIZE := 15872k + DEVICE_VENDOR := Cudy + DEVICE_MODEL := X6 + DEVICE_VARIANT := v2 + UIMAGE_NAME := R30 + DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools + SUPPORTED_DEVICES += cudy,x6 R30 +endef +TARGET_DEVICES += cudy_x6-v2 define Device/dlink_dap-1620-b1 DEVICE_VENDOR := D-Link diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 746a88bd12f..80c72735430 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -27,7 +27,8 @@ case "$board" in hw_mac_addr=$(macaddr_unsetbit $hw_mac_addr 28) [ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress ;; - cudy,x6) + cudy,x6-v1|\ + cudy,x6-v2) hw_mac_addr="$(mtd_get_mac_binary bdinfo 0xde00)" [ "$PHYNBR" = "1" ] && \ macaddr_setbit_la "$(macaddr_add $hw_mac_addr 0x100000)" > /sys${DEVPATH}/macaddress From 5b0b464e496a17304aa51fa44d7cb863a827a9d3 Mon Sep 17 00:00:00 2001 From: Chukun Pan Date: Tue, 18 Apr 2023 23:05:21 +0800 Subject: [PATCH 052/113] uboot-mediatek: remove duplicate config in mt7986 Some config was written twice by mistake, fix it. Signed-off-by: Chukun Pan --- .../uboot-mediatek/patches/430-add-bpi-r3.patch | 16 ++++------------ .../patches/431-add-xiaomi_redmi-ax6000.patch | 3 +-- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch index 855f39ed972..53369feaf23 100644 --- a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch +++ b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch @@ -11,7 +11,7 @@ mt7986a-sd-rfb.dtb \ --- /dev/null +++ b/configs/mt7986a_bpi-r3-emmc_defconfig -@@ -0,0 +1,198 @@ +@@ -0,0 +1,196 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -28,7 +28,6 @@ +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y +CONFIG_SYS_LOAD_ADDR=0x46000000 -+CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_AUTOBOOT_KEYED=y +CONFIG_BOOTDELAY=30 @@ -201,7 +200,6 @@ +CONFIG_SPI_FLASH_MTD=y +CONFIG_SPI_FLASH_WINBOND=y +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set -+CONFIG_CMD_MTD=y +CONFIG_CMD_SF=y +CONFIG_CMD_NAND=y +CONFIG_CMD_NAND_TRIMFFS=y @@ -212,7 +210,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-nor_defconfig -@@ -0,0 +1,197 @@ +@@ -0,0 +1,195 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -229,7 +227,6 @@ +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y +CONFIG_SYS_LOAD_ADDR=0x46000000 -+CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_AUTOBOOT_KEYED=y +CONFIG_BOOTDELAY=30 @@ -403,7 +400,6 @@ +CONFIG_SPI_FLASH_MTD=y +CONFIG_SPI_FLASH_WINBOND=y +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set -+CONFIG_CMD_MTD=y +CONFIG_CMD_SF=y +CONFIG_LMB_MAX_REGIONS=64 +CONFIG_USE_IPADDR=y @@ -412,7 +408,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-sd_defconfig -@@ -0,0 +1,198 @@ +@@ -0,0 +1,196 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -429,7 +425,6 @@ +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y +CONFIG_SYS_LOAD_ADDR=0x46000000 -+CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_AUTOBOOT_KEYED=y +CONFIG_BOOTDELAY=30 @@ -602,7 +597,6 @@ +CONFIG_SPI_FLASH_MTD=y +CONFIG_SPI_FLASH_WINBOND=y +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set -+CONFIG_CMD_MTD=y +CONFIG_CMD_SF=y +CONFIG_CMD_NAND=y +CONFIG_CMD_NAND_TRIMFFS=y @@ -613,7 +607,7 @@ +CONFIG_SERVERIP="192.168.1.254" --- /dev/null +++ b/configs/mt7986a_bpi-r3-snand_defconfig -@@ -0,0 +1,199 @@ +@@ -0,0 +1,197 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -630,7 +624,6 @@ +CONFIG_DEBUG_UART_CLOCK=40000000 +CONFIG_DEBUG_UART=y +CONFIG_SYS_LOAD_ADDR=0x46000000 -+CONFIG_NET_RANDOM_ETHADDR=y +CONFIG_SMBIOS_PRODUCT_NAME="" +CONFIG_AUTOBOOT_KEYED=y +CONFIG_BOOTDELAY=30 @@ -804,7 +797,6 @@ +#CONFIG_SPI_FLASH_MTD=y +#CONFIG_SPI_FLASH_WINBOND=y +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set -+CONFIG_CMD_MTD=y +#CONFIG_CMD_SF=y +CONFIG_CMD_NAND=y +CONFIG_CMD_NAND_TRIMFFS=y diff --git a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch index 2d3f1aabea0..098fc4e5e80 100644 --- a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch +++ b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/configs/mt7986_xiaomi_redmi-ax6000_defconfig -@@ -0,0 +1,180 @@ +@@ -0,0 +1,179 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y @@ -173,7 +173,6 @@ +CONFIG_USE_DEFAULT_ENV_FILE=y +CONFIG_MTD_SPI_NAND=y +CONFIG_MTK_SPIM=y -+CONFIG_CMD_MTD=y +CONFIG_CMD_NAND=y +CONFIG_CMD_NAND_TRIMFFS=y +CONFIG_LMB_MAX_REGIONS=64 From ab8ead3e2d2d43c67536ec64076dec5d725408cd Mon Sep 17 00:00:00 2001 From: Chukun Pan Date: Wed, 19 Apr 2023 23:02:09 +0800 Subject: [PATCH 053/113] uboot-mediatek: fix CONFIG_TEXT_BASE variable CONFIG_SYS_TEXT_BASE has been renamed to CONFIG_TEXT_BASE in uboot v2023.01 [1], fixes all this variable. [1] https://github.com/u-boot/u-boot/commit/984639039f4cfe32ec2cc531d6ace05326ac49eb Fixes: 3d5c5427 ("uboot-mediatek: update to U-Boot 2023.01") Signed-off-by: Chukun Pan --- ...ard-mt7629-add-support-for-booting-from-SPI-NAND.patch | 2 +- ...d-mt7981-add-reference-board-using-new-spi-nand-.patch | 2 +- .../patches/404-add-bananapi_bpi-r64_defconfigs.patch | 6 +++--- .../uboot-mediatek/patches/410-add-linksys-e8450.patch | 2 +- .../uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch | 2 +- package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch | 8 ++++---- .../patches/431-add-xiaomi_redmi-ax6000.patch | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch index 571b883fb99..797d925e173 100644 --- a/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch +++ b/package/boot/uboot-mediatek/patches/100-18-board-mt7629-add-support-for-booting-from-SPI-NAND.patch @@ -163,7 +163,7 @@ Signed-off-by: Weijie Gao +CONFIG_SYS_ARCH_TIMER=y +CONFIG_SYS_THUMB_BUILD=y +CONFIG_ARCH_MEDIATEK=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_ENV_SIZE=0x20000 diff --git a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch index 1d855bf4607..cf2019fcba6 100644 --- a/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch +++ b/package/boot/uboot-mediatek/patches/100-20-board-mt7981-add-reference-board-using-new-spi-nand-.patch @@ -167,7 +167,7 @@ Signed-off-by: Weijie Gao +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_NR_DRAM_BANKS=1 +CONFIG_ENV_SIZE=0x20000 diff --git a/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch b/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch index 85bcd00db0d..135eb90e2b9 100644 --- a/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch +++ b/package/boot/uboot-mediatek/patches/404-add-bananapi_bpi-r64_defconfigs.patch @@ -5,7 +5,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7622=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_LOAD_ADDR=0x40080000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y @@ -257,7 +257,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7622=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_LOAD_ADDR=0x40080000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y @@ -469,7 +469,7 @@ +CONFIG_ARM=y +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_LOAD_ADDR=0x40080000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y diff --git a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch index 2e85e6c3ce6..3fc2c554bb0 100644 --- a/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch +++ b/package/boot/uboot-mediatek/patches/410-add-linksys-e8450.patch @@ -5,7 +5,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7622=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_LOAD_ADDR=0x40080000 +CONFIG_USE_DEFAULT_ENV_FILE=y diff --git a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch index 88e724ebb8c..1955958b9b0 100644 --- a/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch +++ b/package/boot/uboot-mediatek/patches/412-add-ubnt-unifi-6-lr.patch @@ -5,7 +5,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7622=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_LOAD_ADDR=0x40080000 +CONFIG_USE_DEFAULT_ENV_FILE=y diff --git a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch index 53369feaf23..880b1b4d322 100644 --- a/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch +++ b/package/boot/uboot-mediatek/patches/430-add-bpi-r3.patch @@ -16,7 +16,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7986=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_NR_DRAM_BANKS=1 @@ -215,7 +215,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7986=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_NR_DRAM_BANKS=1 @@ -413,7 +413,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7986=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_NR_DRAM_BANKS=1 @@ -612,7 +612,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7986=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_NR_DRAM_BANKS=1 diff --git a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch index 098fc4e5e80..88e426366ba 100644 --- a/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch +++ b/package/boot/uboot-mediatek/patches/431-add-xiaomi_redmi-ax6000.patch @@ -5,7 +5,7 @@ +CONFIG_POSITION_INDEPENDENT=y +CONFIG_ARCH_MEDIATEK=y +CONFIG_TARGET_MT7986=y -+CONFIG_SYS_TEXT_BASE=0x41e00000 ++CONFIG_TEXT_BASE=0x41e00000 +CONFIG_SYS_MALLOC_F_LEN=0x4000 +CONFIG_SYS_HAS_NONCACHED_MEMORY=y +CONFIG_NR_DRAM_BANKS=1 From 6c9b526e84e73880eaf72cb656b5908bc5c3f792 Mon Sep 17 00:00:00 2001 From: Chukun Pan Date: Thu, 20 Apr 2023 23:03:08 +0800 Subject: [PATCH 054/113] uboot-mediatek: fixes build when nmbm enabled The image_header_t typedef has been removed from uboot v2023.01 [1], replaced with legacy struct. [1] https://github.com/u-boot/u-boot/commit/f3543e69442ca393e52df253d9c5d45bc189d471 Fixes: 3d5c542 ("uboot-mediatek: update to U-Boot 2023.01") Signed-off-by: Chukun Pan --- .../patches/100-09-cmd-add-nmbm-command.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch index c1188c62a58..6b319384d51 100644 --- a/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch +++ b/package/boot/uboot-mediatek/patches/100-09-cmd-add-nmbm-command.patch @@ -205,9 +205,9 @@ Signed-off-by: Weijie Gao +#endif + } + -+ ret = mtd_read(mtd, off, sizeof(image_header_t), &retlen, ++ ret = mtd_read(mtd, off, sizeof(struct legacy_img_hdr), &retlen, + (void *)loadaddr); -+ if (ret || retlen != sizeof(image_header_t)) { ++ if (ret || retlen != sizeof(struct legacy_img_hdr)) { + printf("Failed to read NMBM at offset 0x%08llx\n", off); + return CMD_RET_FAILURE; + } @@ -215,7 +215,7 @@ Signed-off-by: Weijie Gao + switch (genimg_get_format((void *)loadaddr)) { +#if defined(CONFIG_LEGACY_IMAGE_FORMAT) + case IMAGE_FORMAT_LEGACY: -+ size = image_get_image_size((image_header_t *)loadaddr); ++ size = image_get_image_size((struct legacy_img_hdr *)loadaddr); + image_name = "legacy"; + break; +#endif From c306385474f4f183657423be708ac7813ee38b47 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Mon, 1 May 2023 17:56:36 +0200 Subject: [PATCH 055/113] lantiq: mark source only The target is currently broken with Kernel 5.15 and no one in sight to fix it. Instead of stalling the next release indefinitely, make it source only and see if someone steps up to fix it. Signed-off-by: Paul Spooren --- target/linux/lantiq/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/lantiq/Makefile b/target/linux/lantiq/Makefile index 08618fa9a3a..69746eb05c3 100644 --- a/target/linux/lantiq/Makefile +++ b/target/linux/lantiq/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk BOARD:=lantiq BOARDNAME:=Lantiq -FEATURES:=squashfs +FEATURES:=squashfs source-only SUBTARGETS:=xrx200 xway xway_legacy falcon ase KERNEL_PATCHVER:=5.10 From 626f5f77f76ac01a562df5423fe43bb1ecfdbc05 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Mon, 1 May 2023 17:52:34 +0200 Subject: [PATCH 056/113] omap: mark source only The target is currently broken with Kernel 5.15 and no one in sight to fix it. Instead of stalling the next release indefinitely, make it source only and see if someone steps up to fix it. Signed-off-by: Paul Spooren --- target/linux/omap/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/omap/Makefile b/target/linux/omap/Makefile index 364fa07e8e1..6dc1565f063 100644 --- a/target/linux/omap/Makefile +++ b/target/linux/omap/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=omap BOARDNAME:=TI OMAP3/4/AM33xx -FEATURES:=usb usbgadget ext4 targz fpu audio display nand rootfs-part squashfs +FEATURES:=usb usbgadget ext4 targz fpu audio display nand rootfs-part squashfs source-only CPU_TYPE:=cortex-a8 CPU_SUBTYPE:=vfpv3 SUBTARGETS:=generic From 467aa08f8ae0123adf973bb9e637a7763a53d60d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 22 Apr 2023 18:45:43 +0200 Subject: [PATCH 057/113] kernel: Activate CONFIG_SLAB_FREELIST_RANDOM This activates CONFIG_SLAB_FREELIST_RANDOM. This option make the free list less predictable. This makes it harder to exploit heap based security vulnerabilities. This adds a little bit more code to the kernel and a small additional compute overhead. This option is activated in Debian by default. Signed-off-by: Hauke Mehrtens --- target/linux/generic/config-5.10 | 2 +- target/linux/generic/config-5.15 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 9645072a558..49325971f61 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -5464,7 +5464,7 @@ CONFIG_SIGNALFD=y # CONFIG_SLAB is not set CONFIG_SLABINFO=y CONFIG_SLAB_FREELIST_HARDENED=y -# CONFIG_SLAB_FREELIST_RANDOM is not set +CONFIG_SLAB_FREELIST_RANDOM=y CONFIG_SLAB_MERGE_DEFAULT=y # CONFIG_SLHC is not set # CONFIG_SLICOSS is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 3d5a8606734..c6af24ec661 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -5754,7 +5754,7 @@ CONFIG_SIGNALFD=y # CONFIG_SLAB is not set CONFIG_SLABINFO=y CONFIG_SLAB_FREELIST_HARDENED=y -# CONFIG_SLAB_FREELIST_RANDOM is not set +CONFIG_SLAB_FREELIST_RANDOM=y CONFIG_SLAB_MERGE_DEFAULT=y # CONFIG_SLHC is not set # CONFIG_SLICOSS is not set From 3cac52f9a134cb2317660596d0cefe1c419c3220 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Mon, 24 Apr 2023 22:00:18 +0200 Subject: [PATCH 058/113] ipq40xx: convert AVM FRITZ!Repeater 3000 to DSA Convert the repeater to DSA. Signed-off-by: Nick Hainke --- .../ipq40xx/base-files/etc/board.d/02_network | 1 + .../dts/qcom-ipq4019-fritzrepeater-3000.dts | 20 +++++++++++++++++++ target/linux/ipq40xx/image/generic.mk | 3 +-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index 2e0e8d33cd6..cb318d36a30 100644 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -61,6 +61,7 @@ ipq40xx_setup_interfaces() avm,fritzbox-7530) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ;; + avm,fritzrepeater-3000|\ cellc,rtl30vw) ucidef_set_interface_lan "lan1 lan2" ;; diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-fritzrepeater-3000.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-fritzrepeater-3000.dts index babf07727a6..8d88bc15211 100644 --- a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-fritzrepeater-3000.dts +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-fritzrepeater-3000.dts @@ -247,3 +247,23 @@ }; }; }; + +&gmac { + status = "okay"; +}; + +&switch { + status = "okay"; +}; + +&swport4 { + status = "okay"; + + label = "lan1"; +}; + +&swport5 { + status = "okay"; + + label = "lan2"; +}; diff --git a/target/linux/ipq40xx/image/generic.mk b/target/linux/ipq40xx/image/generic.mk index 8fa4f4175a2..adce4fe0f26 100644 --- a/target/linux/ipq40xx/image/generic.mk +++ b/target/linux/ipq40xx/image/generic.mk @@ -295,8 +295,7 @@ define Device/avm_fritzrepeater-3000 SOC := qcom-ipq4019 DEVICE_PACKAGES := ath10k-firmware-qca9984-ct fritz-caldata fritz-tffs-nand endef -# Missing DSA Setup -#TARGET_DEVICES += avm_fritzrepeater-3000 +TARGET_DEVICES += avm_fritzrepeater-3000 define Device/buffalo_wtr-m2133hp $(call Device/FitImage) From 4fa9ec125ac5b4dfbccdf440e156feb18fb896d0 Mon Sep 17 00:00:00 2001 From: John Audia Date: Mon, 1 May 2023 03:54:24 -0400 Subject: [PATCH 059/113] kernel: bump 5.15 to 5.15.110 All patches automatically rebased. Build system: x86_64 Build-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: bcm2711/RPi4B, ramips/tplink_archer-a6-v3, filogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia --- include/kernel-5.15 | 4 ++-- ...mm-add-dummy-pmd_young-for-architectures-not-having-.patch | 2 +- .../hack-5.15/780-usb-net-MeigLink_modem_support.patch | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/kernel-5.15 b/include/kernel-5.15 index 6bc20e7ff8c..78aeee04fa8 100644 --- a/include/kernel-5.15 +++ b/include/kernel-5.15 @@ -1,2 +1,2 @@ -LINUX_VERSION-5.15 = .109 -LINUX_KERNEL_HASH-5.15.109 = 066c4bbcbe3c480068a2e302f52b1708f340ecaaf633ec43d7f791bbeac5771a +LINUX_VERSION-5.15 = .110 +LINUX_KERNEL_HASH-5.15.110 = 9829fcc77b9978dce97a26980dec445caf2410024696625dbb2314ead4830b5b diff --git a/target/linux/generic/backport-5.15/020-v6.1-17-mm-add-dummy-pmd_young-for-architectures-not-having-.patch b/target/linux/generic/backport-5.15/020-v6.1-17-mm-add-dummy-pmd_young-for-architectures-not-having-.patch index c91252eb6b2..1c10c168a50 100644 --- a/target/linux/generic/backport-5.15/020-v6.1-17-mm-add-dummy-pmd_young-for-architectures-not-having-.patch +++ b/target/linux/generic/backport-5.15/020-v6.1-17-mm-add-dummy-pmd_young-for-architectures-not-having-.patch @@ -40,7 +40,7 @@ Signed-off-by: Andrew Morton return !!(pmd_val(pmd) & _PAGE_ACCESSED); --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h -@@ -531,6 +531,7 @@ static inline int pmd_dirty(pmd_t pmd) +@@ -535,6 +535,7 @@ static inline int pmd_dirty(pmd_t pmd) return pte_dirty(pmd_pte(pmd)); } diff --git a/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch b/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch index f8f91b22675..367d66fc666 100644 --- a/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch +++ b/target/linux/generic/hack-5.15/780-usb-net-MeigLink_modem_support.patch @@ -29,7 +29,7 @@ Subject: [PATCH] net/usb/qmi_wwan: add MeigLink modem support #define QUECTEL_VENDOR_ID 0x2c7c /* These Quectel products use Quectel's vendor ID */ -@@ -1164,6 +1166,11 @@ static const struct usb_device_id option +@@ -1169,6 +1171,11 @@ static const struct usb_device_id option .driver_info = ZLP }, { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96), .driver_info = RSVD(4) }, From 3980dfcd05741bd650d0e3d0938bfd071ffa7824 Mon Sep 17 00:00:00 2001 From: Tony Ambardar Date: Tue, 29 Nov 2022 17:52:46 -0800 Subject: [PATCH 060/113] kernel: fix handling of CONFIG_DYNAMIC_DEBUG Since CONFIG_DYNAMIC_DEBUG is already managed via the KERNEL_DYNAMIC_DEBUG setting in Config-kernel.in (default N), remove or disable it in target configs which unconditionally enable it, along with the related setting CONFIG_DYNAMIC_DEBUG_CORE. This saves several KB in the kernels for ipq40xx, ipq806x, filogic, mt7622, qoriq, and sunxi. Signed-off-by: Tony Ambardar --- target/linux/generic/config-5.10 | 2 +- target/linux/generic/config-5.15 | 2 +- target/linux/ipq40xx/config-5.15 | 1 - target/linux/ipq806x/config-5.10 | 1 - target/linux/ipq806x/config-5.15 | 1 - target/linux/mediatek/filogic/config-5.15 | 1 - target/linux/mediatek/mt7622/config-5.15 | 1 - target/linux/qoriq/config-5.15 | 1 - target/linux/sunxi/config-5.15 | 1 - 9 files changed, 2 insertions(+), 9 deletions(-) diff --git a/target/linux/generic/config-5.10 b/target/linux/generic/config-5.10 index 49325971f61..9c4aad86c14 100644 --- a/target/linux/generic/config-5.10 +++ b/target/linux/generic/config-5.10 @@ -1746,7 +1746,7 @@ CONFIG_DVB_MAX_ADAPTERS=16 # CONFIG_DW_EDMA_PCIE is not set # CONFIG_DW_WATCHDOG is not set # CONFIG_DYNAMIC_DEBUG is not set -CONFIG_DYNAMIC_DEBUG_CORE=y +# CONFIG_DYNAMIC_DEBUG_CORE is not set # CONFIG_E100 is not set # CONFIG_E1000 is not set # CONFIG_E1000E is not set diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index c6af24ec661..132f65c8068 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -1830,7 +1830,7 @@ CONFIG_DVB_MAX_ADAPTERS=16 # CONFIG_DW_WATCHDOG is not set # CONFIG_DW_XDATA_PCIE is not set # CONFIG_DYNAMIC_DEBUG is not set -CONFIG_DYNAMIC_DEBUG_CORE=y +# CONFIG_DYNAMIC_DEBUG_CORE is not set # CONFIG_E100 is not set # CONFIG_E1000 is not set # CONFIG_E1000E is not set diff --git a/target/linux/ipq40xx/config-5.15 b/target/linux/ipq40xx/config-5.15 index 32260fa08c9..88029caf763 100644 --- a/target/linux/ipq40xx/config-5.15 +++ b/target/linux/ipq40xx/config-5.15 @@ -144,7 +144,6 @@ CONFIG_DMA_SHARED_BUFFER=y CONFIG_DMA_VIRTUAL_CHANNELS=y CONFIG_DTC=y CONFIG_DT_IDLE_STATES=y -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_EEPROM_AT24=y diff --git a/target/linux/ipq806x/config-5.10 b/target/linux/ipq806x/config-5.10 index 826dd734551..1f1af06b29d 100644 --- a/target/linux/ipq806x/config-5.10 +++ b/target/linux/ipq806x/config-5.10 @@ -135,7 +135,6 @@ CONFIG_DT_IDLE_STATES=y # CONFIG_DWMAC_GENERIC is not set CONFIG_DWMAC_IPQ806X=y # CONFIG_DWMAC_QCOM_ETHQOS is not set -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_ETHERNET_PACKET_MANGLE=y diff --git a/target/linux/ipq806x/config-5.15 b/target/linux/ipq806x/config-5.15 index 0bd6dde11cb..6d710e61f56 100644 --- a/target/linux/ipq806x/config-5.15 +++ b/target/linux/ipq806x/config-5.15 @@ -136,7 +136,6 @@ CONFIG_DT_IDLE_STATES=y # CONFIG_DWMAC_GENERIC is not set CONFIG_DWMAC_IPQ806X=y # CONFIG_DWMAC_QCOM_ETHQOS is not set -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_ETHERNET_PACKET_MANGLE=y diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 883e194be43..41f127ea5b5 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -127,7 +127,6 @@ CONFIG_DMA_OF=y CONFIG_DMA_REMAP=y CONFIG_DMA_VIRTUAL_CHANNELS=y CONFIG_DTC=y -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_SUPPORT=y CONFIG_EINT_MTK=y CONFIG_EXT4_FS=y diff --git a/target/linux/mediatek/mt7622/config-5.15 b/target/linux/mediatek/mt7622/config-5.15 index 9fb6f7befd6..1ce6d852ba1 100644 --- a/target/linux/mediatek/mt7622/config-5.15 +++ b/target/linux/mediatek/mt7622/config-5.15 @@ -150,7 +150,6 @@ CONFIG_DMA_OF=y CONFIG_DMA_REMAP=y CONFIG_DMA_VIRTUAL_CHANNELS=y CONFIG_DTC=y -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_SUPPORT=y CONFIG_EINT_MTK=y CONFIG_EXT4_FS=y diff --git a/target/linux/qoriq/config-5.15 b/target/linux/qoriq/config-5.15 index bf487462d5e..8ebee2bb14f 100644 --- a/target/linux/qoriq/config-5.15 +++ b/target/linux/qoriq/config-5.15 @@ -93,7 +93,6 @@ CONFIG_DMA_OPS_BYPASS=y CONFIG_DPAA_ERRATUM_A050385=y CONFIG_DTC=y CONFIG_DUMMY_CONSOLE=y -CONFIG_DYNAMIC_DEBUG=y CONFIG_E500=y # CONFIG_E5500_CPU is not set CONFIG_E6500_CPU=y diff --git a/target/linux/sunxi/config-5.15 b/target/linux/sunxi/config-5.15 index 17c4d910c8e..9771ee8b4cf 100644 --- a/target/linux/sunxi/config-5.15 +++ b/target/linux/sunxi/config-5.15 @@ -136,7 +136,6 @@ CONFIG_DVB_CORE=y CONFIG_DWMAC_GENERIC=y # CONFIG_DWMAC_SUN8I is not set CONFIG_DWMAC_SUNXI=y -CONFIG_DYNAMIC_DEBUG=y CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_ELF_CORE=y From 3d66f551611de37b88182c64efa091298a9e7f2c Mon Sep 17 00:00:00 2001 From: Tony Ambardar Date: Mon, 24 Apr 2023 22:28:44 -0700 Subject: [PATCH 061/113] kernel: improve handling of CONFIG_IO_URING Kernel setting CONFIG_IO_URING supports high-performance I/O for file access and servers, generally for more performant platforms, and adds ~45 KB to kernel sizes. The need for this on less "beefy" devices is questionable, as is the size cost considering many platforms have kernel size limits which require tricky repartitioning if outgrown. The size cost is also large relative to the ~180 KB bump expected between major OpenWRT kernel releases. No OpenWrt packages have hard dependencies on this; samba4 and mariadb can take advantage if available (+KERNEL_IO_URING:liburing) but otherwise build and work fine. Since CONFIG_IO_URING is already managed via the KERNEL_IO_URING setting in Config-kernel.in (default Y), remove it from those target configs which unconditionally enable it, and update the defaults to enable it conditionally only on more powerful 64-bit x86 and arm devices. It may still be manually enabled as needed for high-performance custom builds. Signed-off-by: Tony Ambardar --- config/Config-kernel.in | 3 ++- target/linux/airoha/config-5.15 | 1 - target/linux/bcm53xx/config-5.10 | 1 - target/linux/bcm53xx/config-5.15 | 1 - target/linux/gemini/config-5.10 | 1 - target/linux/gemini/config-5.15 | 1 - target/linux/imx/config-5.15 | 1 - target/linux/ipq40xx/config-5.15 | 1 - target/linux/mediatek/filogic/config-5.15 | 1 - target/linux/mediatek/mt7623/config-5.15 | 1 - target/linux/mediatek/mt7629/config-5.15 | 1 - target/linux/rockchip/armv8/config-5.10 | 1 - target/linux/rockchip/armv8/config-5.15 | 1 - target/linux/x86/config-5.10 | 1 - target/linux/x86/config-5.15 | 1 - 15 files changed, 2 insertions(+), 15 deletions(-) diff --git a/config/Config-kernel.in b/config/Config-kernel.in index c7b1864235b..979a44660db 100644 --- a/config/Config-kernel.in +++ b/config/Config-kernel.in @@ -469,7 +469,8 @@ config KERNEL_AIO config KERNEL_IO_URING bool "Compile the kernel with io_uring support" - default y if !SMALL_FLASH + depends on !SMALL_FLASH + default y if (x86_64 || aarch64) config KERNEL_FHANDLE bool "Compile the kernel with support for fhandle syscalls" diff --git a/target/linux/airoha/config-5.15 b/target/linux/airoha/config-5.15 index adc8cdfb9bb..2ccdb05060a 100644 --- a/target/linux/airoha/config-5.15 +++ b/target/linux/airoha/config-5.15 @@ -135,7 +135,6 @@ CONFIG_INITRAMFS_SOURCE="" # CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set CONFIG_IOMMU_SUPPORT=y -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/bcm53xx/config-5.10 b/target/linux/bcm53xx/config-5.10 index 9850aa9563e..04b972131a7 100644 --- a/target/linux/bcm53xx/config-5.10 +++ b/target/linux/bcm53xx/config-5.10 @@ -165,7 +165,6 @@ CONFIG_HW_RANDOM_BCM2835=y CONFIG_HZ_FIXED=0 CONFIG_HZ_PERIODIC=y CONFIG_INITRAMFS_SOURCE="" -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/bcm53xx/config-5.15 b/target/linux/bcm53xx/config-5.15 index 3941c22b9c3..a09937defad 100644 --- a/target/linux/bcm53xx/config-5.15 +++ b/target/linux/bcm53xx/config-5.15 @@ -171,7 +171,6 @@ CONFIG_HW_RANDOM_BCM2835=y CONFIG_HZ_FIXED=0 CONFIG_HZ_PERIODIC=y CONFIG_INITRAMFS_SOURCE="" -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/gemini/config-5.10 b/target/linux/gemini/config-5.10 index 698dc44b495..19dc2692f20 100644 --- a/target/linux/gemini/config-5.10 +++ b/target/linux/gemini/config-5.10 @@ -216,7 +216,6 @@ CONFIG_INPUT_KEYBOARD=y # CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set CONFIG_IOMMU_SUPPORT=y -CONFIG_IO_URING=y CONFIG_IPC_NS=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y diff --git a/target/linux/gemini/config-5.15 b/target/linux/gemini/config-5.15 index b3b7a7dd127..b76371fbdc6 100644 --- a/target/linux/gemini/config-5.15 +++ b/target/linux/gemini/config-5.15 @@ -217,7 +217,6 @@ CONFIG_INPUT_KEYBOARD=y # CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set CONFIG_IOMMU_SUPPORT=y -CONFIG_IO_URING=y CONFIG_IPC_NS=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y diff --git a/target/linux/imx/config-5.15 b/target/linux/imx/config-5.15 index 0c9b7d22b4e..90b8c285fd0 100644 --- a/target/linux/imx/config-5.15 +++ b/target/linux/imx/config-5.15 @@ -233,7 +233,6 @@ CONFIG_IMX_SDMA=y CONFIG_IMX_THERMAL=y # CONFIG_IMX_WEIM is not set CONFIG_INITRAMFS_SOURCE="" -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/ipq40xx/config-5.15 b/target/linux/ipq40xx/config-5.15 index 88029caf763..d5bde551783 100644 --- a/target/linux/ipq40xx/config-5.15 +++ b/target/linux/ipq40xx/config-5.15 @@ -210,7 +210,6 @@ CONFIG_INITRAMFS_SOURCE="" # CONFIG_IOMMU_IO_PGTABLE_ARMV7S is not set # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set CONFIG_IOMMU_SUPPORT=y -CONFIG_IO_URING=y # CONFIG_IPQ_APSS_PLL is not set CONFIG_IPQ_GCC_4019=y # CONFIG_IPQ_GCC_6018 is not set diff --git a/target/linux/mediatek/filogic/config-5.15 b/target/linux/mediatek/filogic/config-5.15 index 41f127ea5b5..96ff95be13d 100644 --- a/target/linux/mediatek/filogic/config-5.15 +++ b/target/linux/mediatek/filogic/config-5.15 @@ -186,7 +186,6 @@ CONFIG_I2C_MT65XX=y CONFIG_ICPLUS_PHY=y CONFIG_ILLEGAL_POINTER_VALUE=0xdead000000000000 CONFIG_INITRAMFS_SOURCE="" -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/mediatek/mt7623/config-5.15 b/target/linux/mediatek/mt7623/config-5.15 index fa99dd50bb0..2d3523d762a 100644 --- a/target/linux/mediatek/mt7623/config-5.15 +++ b/target/linux/mediatek/mt7623/config-5.15 @@ -281,7 +281,6 @@ CONFIG_IOMMU_IO_PGTABLE_ARMV7S=y # CONFIG_IOMMU_IO_PGTABLE_ARMV7S_SELFTEST is not set # CONFIG_IOMMU_IO_PGTABLE_LPAE is not set CONFIG_IOMMU_SUPPORT=y -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/mediatek/mt7629/config-5.15 b/target/linux/mediatek/mt7629/config-5.15 index 46104ece48f..03fad40cca6 100644 --- a/target/linux/mediatek/mt7629/config-5.15 +++ b/target/linux/mediatek/mt7629/config-5.15 @@ -142,7 +142,6 @@ CONFIG_HW_RANDOM=y CONFIG_HW_RANDOM_MTK=y CONFIG_HZ_FIXED=0 CONFIG_INITRAMFS_SOURCE="" -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/rockchip/armv8/config-5.10 b/target/linux/rockchip/armv8/config-5.10 index 2d250219a87..637c54be6f1 100644 --- a/target/linux/rockchip/armv8/config-5.10 +++ b/target/linux/rockchip/armv8/config-5.10 @@ -287,7 +287,6 @@ CONFIG_IOMMU_IO_PGTABLE_LPAE=y # CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST is not set CONFIG_IOMMU_SUPPORT=y # CONFIG_IO_STRICT_DEVMEM is not set -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/rockchip/armv8/config-5.15 b/target/linux/rockchip/armv8/config-5.15 index bb7f44a2c4d..51a14055f31 100644 --- a/target/linux/rockchip/armv8/config-5.15 +++ b/target/linux/rockchip/armv8/config-5.15 @@ -287,7 +287,6 @@ CONFIG_IOMMU_IO_PGTABLE_LPAE=y # CONFIG_IOMMU_IO_PGTABLE_LPAE_SELFTEST is not set CONFIG_IOMMU_SUPPORT=y # CONFIG_IO_STRICT_DEVMEM is not set -CONFIG_IO_URING=y CONFIG_IRQCHIP=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y diff --git a/target/linux/x86/config-5.10 b/target/linux/x86/config-5.10 index 6868dec18a7..4616fcba078 100644 --- a/target/linux/x86/config-5.10 +++ b/target/linux/x86/config-5.10 @@ -181,7 +181,6 @@ CONFIG_IO_DELAY_0X80=y # CONFIG_IO_DELAY_0XED is not set # CONFIG_IO_DELAY_NONE is not set # CONFIG_IO_DELAY_UDELAY is not set -CONFIG_IO_URING=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y CONFIG_IRQ_FORCED_THREADING=y diff --git a/target/linux/x86/config-5.15 b/target/linux/x86/config-5.15 index a3d8db26ae2..ee7ab9d6dee 100644 --- a/target/linux/x86/config-5.15 +++ b/target/linux/x86/config-5.15 @@ -183,7 +183,6 @@ CONFIG_IO_DELAY_0X80=y # CONFIG_IO_DELAY_0XED is not set # CONFIG_IO_DELAY_NONE is not set # CONFIG_IO_DELAY_UDELAY is not set -CONFIG_IO_URING=y CONFIG_IRQ_DOMAIN=y CONFIG_IRQ_DOMAIN_HIERARCHY=y CONFIG_IRQ_FORCED_THREADING=y From 8469e1968b8a02ea235470b98155721eaf97117a Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Thu, 4 May 2023 14:02:04 +0200 Subject: [PATCH 062/113] Revert "lantiq: mark source only" This reverts commit c306385474f4f183657423be708ac7813ee38b47. It should be sufficient to disable only the xrx200 subtarget. Signed-off-by: Aleksander Jan Bajkowski --- target/linux/lantiq/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/lantiq/Makefile b/target/linux/lantiq/Makefile index 69746eb05c3..08618fa9a3a 100644 --- a/target/linux/lantiq/Makefile +++ b/target/linux/lantiq/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk BOARD:=lantiq BOARDNAME:=Lantiq -FEATURES:=squashfs source-only +FEATURES:=squashfs SUBTARGETS:=xrx200 xway xway_legacy falcon ase KERNEL_PATCHVER:=5.10 From 0c117e1f6ccbee684ea0589d9024ca9dec4679c9 Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Thu, 4 May 2023 13:30:35 +0200 Subject: [PATCH 063/113] lantiq: xrx200: mark subtarget as source-only The current problems blocking the switch to the kernel 5.15 are related to the GSWIP driver. This driver is only used by the xrx200 subtarget. The other subtargets are unaffected by this problem. Signed-off-by: Aleksander Jan Bajkowski --- target/linux/lantiq/xrx200/target.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/lantiq/xrx200/target.mk b/target/linux/lantiq/xrx200/target.mk index 0f119edd6fa..6e01fc79e47 100644 --- a/target/linux/lantiq/xrx200/target.mk +++ b/target/linux/lantiq/xrx200/target.mk @@ -1,7 +1,7 @@ ARCH:=mips SUBTARGET:=xrx200 BOARDNAME:=XRX200 -FEATURES+=atm nand ramdisk +FEATURES+=atm nand ramdisk source-only CPU_TYPE:=24kc DEFAULT_PACKAGES+=kmod-leds-gpio \ From ffd7c05aa72ee56b836903159540f9470aeef121 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 20 Apr 2023 12:31:16 -0400 Subject: [PATCH 064/113] prereq-build: add check for true and false Some uses cases, like with autotools, need a path for 'true' if we use them to force something to skip. This will work by default on Linux hosts, and require MacOS hosts to get coreutils, which is currently installed in the CI for 'macos-latest' host. In the future, prereq stage can be reworked to search for the actual binary instead of relying on env. Signed-off-by: Michael Pratt --- include/prereq-build.mk | 7 +++++++ rules.mk | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/include/prereq-build.mk b/include/prereq-build.mk index 8fae92ab977..14a22108805 100644 --- a/include/prereq-build.mk +++ b/include/prereq-build.mk @@ -8,6 +8,13 @@ include $(INCLUDE_DIR)/prereq.mk SHELL:=sh PKG_NAME:=Build dependency +$(eval $(call TestHostCommand,true, \ + Please install GNU 'coreutils', \ + $(TRUE))) + +$(eval $(call TestHostCommand,false, \ + Please install GNU 'coreutils', \ + $(FALSE); [ $$$$$$$$? = 1 ] && $(TRUE))) # Required for the toolchain $(eval $(call TestHostCommand,working-make, \ diff --git a/rules.mk b/rules.mk index 57d7995d4fa..cc7904ac728 100644 --- a/rules.mk +++ b/rules.mk @@ -268,6 +268,14 @@ FIND:=find PATCH:=patch PYTHON:=python3 +ifeq ($(HOST_OS),Darwin) + TRUE:=/usr/bin/env gtrue + FALSE:=/usr/bin/env gfalse +else + TRUE:=/usr/bin/env true + FALSE:=/usr/bin/env false +endif + INSTALL_BIN:=install -m0755 INSTALL_SUID:=install -m4755 INSTALL_DIR:=install -d -m0755 From c52d938481651b6f9e0a4087652c99b805716ed8 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 14 Apr 2023 02:06:53 -0400 Subject: [PATCH 065/113] autotools: add list of fake paths to tools A list that can be used by some packages in order to force the skipping of every execution of autoreconf. Signed-off-by: Michael Pratt --- include/autotools.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/autotools.mk b/include/autotools.mk index c378efe6f9d..d0e4b3642f5 100644 --- a/include/autotools.mk +++ b/include/autotools.mk @@ -26,6 +26,8 @@ AM_TOOL_PATHS:= \ AUTOPOINT=true \ GTKDOCIZE=true +AM_TOOL_PATHS_FAKE:=$(subst = ,=,$(patsubst "%,"$(TRUE)",$(subst =,= ",$(AM_TOOL_PATHS)))) + # 1: build dir # 2: remove files # 3: automake paths From fe33d5ba13370027165b9acf2bd895f5b4d9a4ea Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 22 Mar 2023 18:29:24 -0400 Subject: [PATCH 066/113] tools: add gnulib source By having a local copy of gnulib, we can: import the latest macro fixes into any package, get rid of some statically stored macros that were otherwise missing, bootstrap GNU tools with the latest relevant source without having to wait for a release or rely on git submodules, and possibly more... The patch assists in bootstrapping by ignoring the building of po files using gettext, and also to allow a user-defined path to a program to include parameters. Signed-off-by: Michael Pratt --- rules.mk | 1 + tools/Makefile | 1 + tools/gnulib/Makefile | 25 +++++++++++ tools/gnulib/patches/000-bootstrap.patch | 54 ++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 tools/gnulib/Makefile create mode 100644 tools/gnulib/patches/000-bootstrap.patch diff --git a/rules.mk b/rules.mk index cc7904ac728..dcac49667bb 100644 --- a/rules.mk +++ b/rules.mk @@ -358,6 +358,7 @@ ifeq ($(CONFIG_BUILD_LOG),y) endif export BISON_PKGDATADIR:=$(STAGING_DIR_HOST)/share/bison +export HOST_GNULIB_SRCDIR:=$(STAGING_DIR_HOST)/share/gnulib export M4:=$(STAGING_DIR_HOST)/bin/m4 define shvar diff --git a/tools/Makefile b/tools/Makefile index 7e8fbad107e..3bf94827cf6 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -45,6 +45,7 @@ tools-y += findutils tools-y += firmware-utils tools-y += flex tools-y += gengetopt +tools-y += gnulib tools-y += libressl tools-y += libtool tools-y += lzma diff --git a/tools/gnulib/Makefile b/tools/gnulib/Makefile new file mode 100644 index 00000000000..c5b7e78c548 --- /dev/null +++ b/tools/gnulib/Makefile @@ -0,0 +1,25 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gnulib +PKG_CPE_ID:=cpe:/a:gnu:$(PKG_NAME) +PKG_VERSION:=f9a4ee73c3e7b544f640d0d04b55983d3a7b894e# # master + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://git.savannah.gnu.org/cgit/$(PKG_NAME).git/snapshot +PKG_HASH:=514716d58987a9c0de0d69fb22d42bcd19edf80eed099882a004ff162060f1a8 + +include $(INCLUDE_DIR)/host-build.mk + +define Host/Configure +endef + +define Host/Install + $(INSTALL_DIR) $(1)/share/gnulib + $(CP) $(HOST_BUILD_DIR)/* $(1)/share/gnulib/ +endef + +define Host/Clean + rm -rf $(STAGING_DIR_HOST)/share/gnulib +endef + +$(eval $(call HostBuild)) diff --git a/tools/gnulib/patches/000-bootstrap.patch b/tools/gnulib/patches/000-bootstrap.patch new file mode 100644 index 00000000000..40ed41125c5 --- /dev/null +++ b/tools/gnulib/patches/000-bootstrap.patch @@ -0,0 +1,54 @@ +--- a/build-aux/bootstrap ++++ b/build-aux/bootstrap +@@ -237,14 +237,14 @@ test -r "$conffile" && . "$conffile" + + check_exists() { + if test "$1" = "--verbose"; then +- ($2 --version /dev/null 2>&1 ++ ($2 $3 $4 --version /dev/null 2>&1 + if test $? -ge 126; then + # If not found, run with diagnostics as one may be + # presented with env variables to set to find the right version +- ($2 --version /dev/null 2>&1 ++ ($@ --version /dev/null 2>&1 + fi + + test $? -lt 126 +@@ -309,7 +309,7 @@ p + q' + + get_version() { +- app=$1 ++ app="$@" + + $app --version >/dev/null 2>&1 || { $app --version; return 1; } + +@@ -366,13 +366,13 @@ check_versions() { + if [ "$req_ver" = "-" ]; then + # Merely require app to exist; not all prereq apps are well-behaved + # so we have to rely on $? rather than get_version. +- if ! check_exists --verbose $app; then ++ if ! check_exists --verbose "$app"; then + warn_ "Error: '$app' not found" + ret=1 + fi + else + # Require app to produce a new enough version string. +- inst_ver=$(get_version $app) ++ inst_ver=$(get_version "$app") + if [ ! "$inst_ver" ]; then + warn_ "Error: '$app' not found" + ret=1 +@@ -1135,7 +1135,7 @@ autogen() + # two just-pre-run programs. + + # Import from gettext. +- with_gettext=yes ++ with_gettext=no + grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ + with_gettext=no + From e4977f614ffa2aaaaba0b5944747848b5b02f25a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 22 Mar 2023 18:46:30 -0400 Subject: [PATCH 067/113] tools/missing-macros: prefer macros provided by gnulib source These 7 macro files are provided by gnulib, so we can now replace these statically stored copies with the latest copy from GNU sources. Signed-off-by: Michael Pratt --- tools/gnulib/Makefile | 2 + tools/missing-macros/src/README | 13 - tools/missing-macros/src/m4/inttypes_h.m4 | 26 - tools/missing-macros/src/m4/lib-ld.m4 | 110 --- tools/missing-macros/src/m4/lib-link.m4 | 774 ---------------------- tools/missing-macros/src/m4/lib-prefix.m4 | 224 ------- tools/missing-macros/src/m4/progtest.m4 | 92 --- tools/missing-macros/src/m4/stdint_h.m4 | 26 - tools/missing-macros/src/m4/wint_t.m4 | 28 - 9 files changed, 2 insertions(+), 1293 deletions(-) delete mode 100644 tools/missing-macros/src/m4/inttypes_h.m4 delete mode 100644 tools/missing-macros/src/m4/lib-ld.m4 delete mode 100644 tools/missing-macros/src/m4/lib-link.m4 delete mode 100644 tools/missing-macros/src/m4/lib-prefix.m4 delete mode 100644 tools/missing-macros/src/m4/progtest.m4 delete mode 100644 tools/missing-macros/src/m4/stdint_h.m4 delete mode 100644 tools/missing-macros/src/m4/wint_t.m4 diff --git a/tools/gnulib/Makefile b/tools/gnulib/Makefile index c5b7e78c548..43d86c213c7 100644 --- a/tools/gnulib/Makefile +++ b/tools/gnulib/Makefile @@ -14,6 +14,8 @@ define Host/Configure endef define Host/Install + $(INSTALL_DIR) $(1)/share/aclocal + $(INSTALL_DATA) $(HOST_BUILD_DIR)/m4/*.m4 $(1)/share/aclocal/ $(INSTALL_DIR) $(1)/share/gnulib $(CP) $(HOST_BUILD_DIR)/* $(1)/share/gnulib/ endef diff --git a/tools/missing-macros/src/README b/tools/missing-macros/src/README index d2305ff5575..dd9a9d3c962 100644 --- a/tools/missing-macros/src/README +++ b/tools/missing-macros/src/README @@ -2,26 +2,13 @@ The m4/ directory below contains various m4 macros used by different packages in the OpenWrt feed. -From GNU gettext: -Library linking and rpath helper macros. - - lib-ld.m4 - lib-link.m4 - lib-prefix.m4 - Integer data type test macros. intmax.m4 - wint_t.m4 inttypes-pri.m4 uintmax_t.m4 - stdint_h.m4 intdiv0.m4 - inttypes_h.m4 -Program test macro. - - progtest.m4 GNU libc version test macros. diff --git a/tools/missing-macros/src/m4/inttypes_h.m4 b/tools/missing-macros/src/m4/inttypes_h.m4 deleted file mode 100644 index 782d77ed8b1..00000000000 --- a/tools/missing-macros/src/m4/inttypes_h.m4 +++ /dev/null @@ -1,26 +0,0 @@ -# inttypes_h.m4 serial 9 -dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, -# doesn't clash with , and declares uintmax_t. - -AC_DEFUN([gl_AC_HEADER_INTTYPES_H], -[ - AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], - [AC_TRY_COMPILE( - [#include -#include ], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_inttypes_h=yes], - [gl_cv_header_inttypes_h=no])]) - if test $gl_cv_header_inttypes_h = yes; then - AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], - [Define if exists, doesn't clash with , - and declares uintmax_t. ]) - fi -]) diff --git a/tools/missing-macros/src/m4/lib-ld.m4 b/tools/missing-macros/src/m4/lib-ld.m4 deleted file mode 100644 index ebb30528bd5..00000000000 --- a/tools/missing-macros/src/m4/lib-ld.m4 +++ /dev/null @@ -1,110 +0,0 @@ -# lib-ld.m4 serial 4 (gettext-0.18) -dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Subroutines of libtool.m4, -dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision -dnl with libtool.m4. - -dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. -AC_DEFUN([AC_LIB_PROG_LD_GNU], -[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], -[# I'd rather use --version here, but apparently some GNU ld's only accept -v. -case `$LD -v 2>&1 conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by GCC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]* | [A-Za-z]:[\\/]*)] - [re_direlt='/[^/][^/]*/\.\./'] - # Canonicalize the path of ld - ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` - while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL([acl_cv_path_LD], -[if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" - for ac_dir in $PATH; do - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some GNU ld's only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in - *GNU* | *'with BFD'*) - test "$with_gnu_ld" != no && break ;; - *) - test "$with_gnu_ld" != yes && break ;; - esac - fi - done - IFS="$ac_save_ifs" -else - acl_cv_path_LD="$LD" # Let the user override the test with a path. -fi]) -LD="$acl_cv_path_LD" -if test -n "$LD"; then - AC_MSG_RESULT([$LD]) -else - AC_MSG_RESULT([no]) -fi -test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) -AC_LIB_PROG_LD_GNU -]) diff --git a/tools/missing-macros/src/m4/lib-link.m4 b/tools/missing-macros/src/m4/lib-link.m4 deleted file mode 100644 index c73bd8e3a47..00000000000 --- a/tools/missing-macros/src/m4/lib-link.m4 +++ /dev/null @@ -1,774 +0,0 @@ -# lib-link.m4 serial 21 (gettext-0.18) -dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -AC_PREREQ([2.54]) - -dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and -dnl augments the CPPFLAGS variable. -dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname -dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - ac_cv_lib[]Name[]_libs="$LIB[]NAME" - ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" - ac_cv_lib[]Name[]_cppflags="$INC[]NAME" - ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" - ]) - LIB[]NAME="$ac_cv_lib[]Name[]_libs" - LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" - INC[]NAME="$ac_cv_lib[]Name[]_cppflags" - LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - AC_SUBST([LIB]NAME[_PREFIX]) - dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the - dnl results of this search when this library appears as a dependency. - HAVE_LIB[]NAME=yes - popdef([NAME]) - popdef([Name]) -]) - -dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) -dnl searches for libname and the libraries corresponding to explicit and -dnl implicit dependencies, together with the specified include files and -dnl the ability to compile and link the specified testcode. The missing-message -dnl defaults to 'no' and may contain additional hints for the user. -dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} -dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and -dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs -dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. -dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname -dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], -[ - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - AC_REQUIRE([AC_LIB_RPATH]) - pushdef([Name],[translit([$1],[./-], [___])]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - - dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME - dnl accordingly. - AC_LIB_LINKFLAGS_BODY([$1], [$2]) - - dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, - dnl because if the user has installed lib[]Name and not disabled its use - dnl via --without-lib[]Name-prefix, he wants to use it. - ac_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) - - AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ - ac_save_LIBS="$LIBS" - dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, - dnl because these -l options might require -L options that are present in - dnl LIBS. -l options benefit only from the -L options listed before it. - dnl Otherwise, add it to the front of LIBS, because it may be a static - dnl library that depends on another static library that is present in LIBS. - dnl Static libraries benefit only from the static libraries listed after - dnl it. - case " $LIB[]NAME" in - *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; - *) LIBS="$LIB[]NAME $LIBS" ;; - esac - AC_TRY_LINK([$3], [$4], - [ac_cv_lib[]Name=yes], - [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) - LIBS="$ac_save_LIBS" - ]) - if test "$ac_cv_lib[]Name" = yes; then - HAVE_LIB[]NAME=yes - AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) - AC_MSG_CHECKING([how to link with lib[]$1]) - AC_MSG_RESULT([$LIB[]NAME]) - else - HAVE_LIB[]NAME=no - dnl If $LIB[]NAME didn't lead to a usable library, we don't need - dnl $INC[]NAME either. - CPPFLAGS="$ac_save_CPPFLAGS" - LIB[]NAME= - LTLIB[]NAME= - LIB[]NAME[]_PREFIX= - fi - AC_SUBST([HAVE_LIB]NAME) - AC_SUBST([LIB]NAME) - AC_SUBST([LTLIB]NAME) - AC_SUBST([LIB]NAME[_PREFIX]) - popdef([NAME]) - popdef([Name]) -]) - -dnl Determine the platform dependent parameters needed to use rpath: -dnl acl_libext, -dnl acl_shlibext, -dnl acl_hardcode_libdir_flag_spec, -dnl acl_hardcode_libdir_separator, -dnl acl_hardcode_direct, -dnl acl_hardcode_minus_L. -AC_DEFUN([AC_LIB_RPATH], -[ - dnl Tell automake >= 1.10 to complain if config.rpath is missing. - m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) - AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS - AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld - AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host - AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir - AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - ]) - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - dnl Determine whether the user wants rpath handling at all. - AC_ARG_ENABLE([rpath], - [ --disable-rpath do not hardcode runtime library paths], - :, enable_rpath=yes) -]) - -dnl AC_LIB_FROMPACKAGE(name, package) -dnl declares that libname comes from the given package. The configure file -dnl will then not have a --with-libname-prefix option but a -dnl --with-package-prefix option. Several libraries can come from the same -dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar -dnl macro call that searches for libname. -AC_DEFUN([AC_LIB_FROMPACKAGE], -[ - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - define([acl_frompackage_]NAME, [$2]) - popdef([NAME]) - pushdef([PACK],[$2]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - define([acl_libsinpackage_]PACKUP, - m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) - popdef([PACKUP]) - popdef([PACK]) -]) - -dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and -dnl the libraries corresponding to explicit and implicit dependencies. -dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. -dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found -dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. -AC_DEFUN([AC_LIB_LINKFLAGS_BODY], -[ - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) - pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], - [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) - pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) - dnl Autoconf >= 2.61 supports dots in --with options. - pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_ARG_WITH(P_A_C_K[-prefix], -[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib - --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -]) - dnl Search the library and its dependencies in $additional_libdir and - dnl $LDFLAGS. Using breadth-first-seach. - LIB[]NAME= - LTLIB[]NAME= - INC[]NAME= - LIB[]NAME[]_PREFIX= - dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been - dnl computed. So it has to be reset here. - HAVE_LIB[]NAME= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='$1 $2' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - dnl See if it was already located by an earlier AC_LIB_LINKFLAGS - dnl or AC_LIB_HAVE_LINKFLAGS call. - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" - else - dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined - dnl that this library doesn't exist. So just drop it. - : - fi - else - dnl Search the library lib$name in $additional_libdir and $LDFLAGS - dnl and the already constructed $LIBNAME/$LTLIBNAME. - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - dnl The same code as in the loop below: - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - dnl First look for a shared library. - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - dnl Then look for a static library. - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - dnl Found the library. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - dnl Linking with a shared library. We attempt to hardcode its - dnl directory into the executable's runpath, unless it's the - dnl standard /usr/lib. - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - dnl No hardcoding is needed. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - dnl The hardcoding into $LIBNAME is system dependent. - if test "$acl_hardcode_direct" = yes; then - dnl Using DIR/libNAME.so during linking hardcodes DIR into the - dnl resulting binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode DIR into the resulting - dnl binary. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - dnl Rely on "-L$found_dir". - dnl But don't add it if it's already contained in the LDFLAGS - dnl or the already constructed $LIBNAME - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" - else - dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH - dnl here, because this doesn't fit in flags passed to the - dnl compiler. So give up. No hardcoding. This affects only - dnl very old systems. - dnl FIXME: Not sure whether we should use - dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" - dnl here. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - dnl Linking with a static library. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" - else - dnl We shouldn't come here, but anyway it's good to have a - dnl fallback. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" - fi - fi - dnl Assume the include files are nearby. - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = '$1'; then - LIB[]NAME[]_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - dnl Potentially add $additional_includedir to $INCNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's /usr/local/include and we are using GCC on Linux, - dnl 3. if it's already present in $CPPFLAGS or the already - dnl constructed $INCNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INC[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $INCNAME. - INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - dnl Look for dependencies. - if test -n "$found_la"; then - dnl Read the .la file. It defines the variables - dnl dlname, library_names, old_library, dependency_libs, current, - dnl age, revision, installed, dlopen, dlpreopen, libdir. - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - dnl We use only dependency_libs. - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's /usr/local/lib and we are using GCC on Linux, - dnl 3. if it's already present in $LDFLAGS or the already - dnl constructed $LIBNAME, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LIBNAME. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIB[]NAME; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LTLIBNAME. - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - dnl Potentially add DIR to rpathdirs. - dnl The rpathdirs will be appended to $LIBNAME at the end. - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - dnl Potentially add DIR to ltrpathdirs. - dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - dnl Handle this in the next round. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - dnl Handle this in the next round. Throw away the .la's - dnl directory; it is already contained in a preceding -L - dnl option. - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - dnl Most likely an immediate library name. - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" - ;; - esac - done - fi - else - dnl Didn't find the library; assume it is in the system directories - dnl known to the linker and runtime loader. (All the system - dnl directories known to the linker should also be known to the - dnl runtime loader, otherwise the system is severely misconfigured.) - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user must - dnl pass all path elements in one option. We can arrange that for a - dnl single library, but not when more than one $LIBNAMEs are used. - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - else - dnl The -rpath options are cumulative. - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - dnl When using libtool, the option that works for both libraries and - dnl executables is -R. The -R options are cumulative. - for found_dir in $ltrpathdirs; do - LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" - done - fi - popdef([P_A_C_K]) - popdef([PACKLIBS]) - popdef([PACKUP]) - popdef([PACK]) - popdef([NAME]) -]) - -dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, -dnl unless already present in VAR. -dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes -dnl contains two or three consecutive elements that belong together. -AC_DEFUN([AC_LIB_APPENDTOVAR], -[ - for element in [$2]; do - haveit= - for x in $[$1]; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - [$1]="${[$1]}${[$1]:+ }$element" - fi - done -]) - -dnl For those cases where a variable contains several -L and -l options -dnl referring to unknown libraries and directories, this macro determines the -dnl necessary additional linker options for the runtime path. -dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) -dnl sets LDADDVAR to linker options needed together with LIBSVALUE. -dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, -dnl otherwise linking without libtool is assumed. -AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], -[ - AC_REQUIRE([AC_LIB_RPATH]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - $1= - if test "$enable_rpath" != no; then - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - dnl Use an explicit option to hardcode directories into the resulting - dnl binary. - rpathdirs= - next= - for opt in $2; do - if test -n "$next"; then - dir="$next" - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= - else - case $opt in - -L) next=yes ;; - -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` - dnl No need to hardcode the standard /usr/lib. - if test "X$dir" != "X/usr/$acl_libdirstem" \ - && test "X$dir" != "X/usr/$acl_libdirstem2"; then - rpathdirs="$rpathdirs $dir" - fi - next= ;; - *) next= ;; - esac - fi - done - if test "X$rpathdirs" != "X"; then - if test -n ""$3""; then - dnl libtool is used for linking. Use -R options. - for dir in $rpathdirs; do - $1="${$1}${$1:+ }-R$dir" - done - else - dnl The linker is used for linking directly. - if test -n "$acl_hardcode_libdir_separator"; then - dnl Weird platform: only the last -rpath option counts, the user - dnl must pass all path elements in one option. - alldirs= - for dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="$flag" - else - dnl The -rpath options are cumulative. - for dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - $1="${$1}${$1:+ }$flag" - done - fi - fi - fi - fi - fi - AC_SUBST([$1]) -]) diff --git a/tools/missing-macros/src/m4/lib-prefix.m4 b/tools/missing-macros/src/m4/lib-prefix.m4 deleted file mode 100644 index 1601ceaefd3..00000000000 --- a/tools/missing-macros/src/m4/lib-prefix.m4 +++ /dev/null @@ -1,224 +0,0 @@ -# lib-prefix.m4 serial 7 (gettext-0.18) -dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. - -dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and -dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't -dnl require excessive bracketing. -ifdef([AC_HELP_STRING], -[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], -[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) - -dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed -dnl to access previously installed libraries. The basic assumption is that -dnl a user will want packages to use other packages he previously installed -dnl with the same --prefix option. -dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate -dnl libraries, but is otherwise very convenient. -AC_DEFUN([AC_LIB_PREFIX], -[ - AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_CANONICAL_HOST]) - AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) - AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) - dnl By default, look in $includedir and $libdir. - use_additional=yes - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - AC_LIB_ARG_WITH([lib-prefix], -[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib - --without-lib-prefix don't search for libraries in includedir and libdir], -[ - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - AC_LIB_WITH_FINAL_PREFIX([ - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - ]) - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - fi - fi -]) - if test $use_additional = yes; then - dnl Potentially add $additional_includedir to $CPPFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/include, - dnl 2. if it's already present in $CPPFLAGS, - dnl 3. if it's /usr/local/include and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - for x in $CPPFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - dnl Really add $additional_includedir to $CPPFLAGS. - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" - fi - fi - fi - fi - dnl Potentially add $additional_libdir to $LDFLAGS. - dnl But don't add it - dnl 1. if it's the standard /usr/lib, - dnl 2. if it's already present in $LDFLAGS, - dnl 3. if it's /usr/local/lib and we are using GCC on Linux, - dnl 4. if it doesn't exist as a directory. - if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then - haveit= - for x in $LDFLAGS; do - AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then - if test -n "$GCC"; then - case $host_os in - linux*) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - dnl Really add $additional_libdir to $LDFLAGS. - LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" - fi - fi - fi - fi - fi -]) - -dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, -dnl acl_final_exec_prefix, containing the values to which $prefix and -dnl $exec_prefix will expand at the end of the configure script. -AC_DEFUN([AC_LIB_PREPARE_PREFIX], -[ - dnl Unfortunately, prefix and exec_prefix get only finally determined - dnl at the end of configure. - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the -dnl variables prefix and exec_prefix bound to the values they will have -dnl at the end of the configure script. -AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], -[ - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - $1 - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -]) - -dnl AC_LIB_PREPARE_MULTILIB creates -dnl - a variable acl_libdirstem, containing the basename of the libdir, either -dnl "lib" or "lib64" or "lib/64", -dnl - a variable acl_libdirstem2, as a secondary possible value for -dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or -dnl "lib/amd64". -AC_DEFUN([AC_LIB_PREPARE_MULTILIB], -[ - dnl There is no formal standard regarding lib and lib64. - dnl On glibc systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine - dnl the compiler's default mode by looking at the compiler's library search - dnl path. If at least one of its elements ends in /lib64 or points to a - dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. - dnl Otherwise we use the default, namely "lib". - dnl On Solaris systems, the current practice is that on a system supporting - dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under - dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or - dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. - AC_REQUIRE([AC_CANONICAL_HOST]) - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment - dnl . - dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." - dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the - dnl symlink is missing, so we set acl_libdirstem2 too. - AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], - [AC_EGREP_CPP([sixtyfour bits], [ -#ifdef _LP64 -sixtyfour bits -#endif - ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) - ]) - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" -]) diff --git a/tools/missing-macros/src/m4/progtest.m4 b/tools/missing-macros/src/m4/progtest.m4 deleted file mode 100644 index 2d804ac99d7..00000000000 --- a/tools/missing-macros/src/m4/progtest.m4 +++ /dev/null @@ -1,92 +0,0 @@ -# progtest.m4 serial 6 (gettext-0.18) -dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. -dnl -dnl This file can can be used in projects which are not available under -dnl the GNU General Public License or the GNU Library General Public -dnl License but which still want to provide support for the GNU gettext -dnl functionality. -dnl Please note that the actual code of the GNU gettext library is covered -dnl by the GNU Library General Public License, and the rest of the GNU -dnl gettext package package is covered by the GNU General Public License. -dnl They are *not* in the public domain. - -dnl Authors: -dnl Ulrich Drepper , 1996. - -AC_PREREQ([2.50]) - -# Search path for a program which passes the given test. - -dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, -dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -AC_DEFUN([AM_PATH_PROG_WITH_TEST], -[ -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh -fi - -# Find out how to test for executable files. Don't use a zero-byte file, -# as systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - ac_executable_p="test -x" -else - ac_executable_p="test -f" -fi -rm -f conf$$.file - -# Extract the first word of "$2", so it can be a program name with args. -set dummy $2; ac_word=[$]2 -AC_MSG_CHECKING([for $ac_word]) -AC_CACHE_VAL([ac_cv_path_$1], -[case "[$]$1" in - [[\\/]]* | ?:[[\\/]]*) - ac_cv_path_$1="[$]$1" # Let the user override the test with a path. - ;; - *) - ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in ifelse([$5], , $PATH, [$5]); do - IFS="$ac_save_IFS" - test -z "$ac_dir" && ac_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then - echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD - if [$3]; then - ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" - break 2 - fi - fi - done - done - IFS="$ac_save_IFS" -dnl If no 4th arg is given, leave the cache variable unset, -dnl so AC_PATH_PROGS will keep looking. -ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" -])dnl - ;; -esac])dnl -$1="$ac_cv_path_$1" -if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then - AC_MSG_RESULT([$][$1]) -else - AC_MSG_RESULT([no]) -fi -AC_SUBST([$1])dnl -]) diff --git a/tools/missing-macros/src/m4/stdint_h.m4 b/tools/missing-macros/src/m4/stdint_h.m4 deleted file mode 100644 index b8e3c6cc711..00000000000 --- a/tools/missing-macros/src/m4/stdint_h.m4 +++ /dev/null @@ -1,26 +0,0 @@ -# stdint_h.m4 serial 8 -dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Paul Eggert. - -# Define HAVE_STDINT_H_WITH_UINTMAX if exists, -# doesn't clash with , and declares uintmax_t. - -AC_DEFUN([gl_AC_HEADER_STDINT_H], -[ - AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], - [AC_TRY_COMPILE( - [#include -#include ], - [uintmax_t i = (uintmax_t) -1; return !i;], - [gl_cv_header_stdint_h=yes], - [gl_cv_header_stdint_h=no])]) - if test $gl_cv_header_stdint_h = yes; then - AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], - [Define if exists, doesn't clash with , - and declares uintmax_t. ]) - fi -]) diff --git a/tools/missing-macros/src/m4/wint_t.m4 b/tools/missing-macros/src/m4/wint_t.m4 deleted file mode 100644 index a6c7d15cb50..00000000000 --- a/tools/missing-macros/src/m4/wint_t.m4 +++ /dev/null @@ -1,28 +0,0 @@ -# wint_t.m4 serial 4 (gettext-0.18) -dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl From Bruno Haible. -dnl Test whether has the 'wint_t' type. -dnl Prerequisite: AC_PROG_CC - -AC_DEFUN([gt_TYPE_WINT_T], -[ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_TRY_COMPILE([ -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be included - before . */ -#include -#include -#include -#include - wint_t foo = (wchar_t)'\0';], , - [gt_cv_c_wint_t=yes], [gt_cv_c_wint_t=no])]) - if test $gt_cv_c_wint_t = yes; then - AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) - fi -]) From d39c6cd29b212a6ad5d864893c7687f976600dd4 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 23 Mar 2023 03:42:04 -0400 Subject: [PATCH 068/113] tools/missing-macros: bump version of makeinfo alternative script Some new releases of GNU tools are checking for a higher version of makeinfo than what our scripted alternative shows when working with checked-out sources instead of releases. Since this is a "fake" makeinfo we can also just fake the version. Signed-off-by: Michael Pratt --- tools/missing-macros/src/bin/makeinfo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/missing-macros/src/bin/makeinfo b/tools/missing-macros/src/bin/makeinfo index e163cba0843..d698f7b79c5 100755 --- a/tools/missing-macros/src/bin/makeinfo +++ b/tools/missing-macros/src/bin/makeinfo @@ -26,7 +26,7 @@ Getopt::Long::GetOptions( if ($version) { - print "makeinfo (OpenWrt stub) 4.13\n"; + print "makeinfo (OpenWrt stub) 9.99\n"; exit 0; } From 89a8269c109b56364bc5c7a63afb8e2888ba9143 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 29 Mar 2023 17:00:18 -0400 Subject: [PATCH 069/113] tools/automake: move file requirements to higher strictness GNU standards requires certain files at the top-level directory of a package that automake is used with, mostly documentation. If one of these files happens to be missing, autoreconf would fail. Move these file requirements to the more strict 'GNITS' setting. Link: https://www.gnu.org/software/automake/manual/html_node/Strictness.html Signed-off-by: Michael Pratt --- .../patches/101-do-not-require-files.patch | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tools/automake/patches/101-do-not-require-files.patch diff --git a/tools/automake/patches/101-do-not-require-files.patch b/tools/automake/patches/101-do-not-require-files.patch new file mode 100644 index 00000000000..3a8c9fcb47b --- /dev/null +++ b/tools/automake/patches/101-do-not-require-files.patch @@ -0,0 +1,29 @@ +--- a/bin/automake.in ++++ b/bin/automake.in +@@ -4513,7 +4513,7 @@ sub handle_gettext () + && grep ($_ eq 'intl', @subdirs)); + } + +- require_file ($ac_gettext_location, GNU, 'ABOUT-NLS'); ++ require_file ($ac_gettext_location, GNITS, 'ABOUT-NLS'); + } + + # Emit makefile footer. +@@ -5641,7 +5641,7 @@ sub check_gnu_standards () + # otherwise require non-.md. + my $required + = (! -f $file && -f "$file.md") ? "$file.md" : $file; +- require_file ("$am_file.am", GNU, $required); ++ require_file ("$am_file.am", GNITS, $required); + } + + # Accept one of these three licenses; default to COPYING. +@@ -5655,7 +5655,7 @@ sub check_gnu_standards () + last; + } + } +- require_file ("$am_file.am", GNU, 'COPYING') ++ require_file ("$am_file.am", GNITS, 'COPYING') + unless $license; + } + From e764a909e3d468a5597373cac087ecc008540e2d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 25 Mar 2023 01:01:36 -0400 Subject: [PATCH 070/113] tools/flex: override SUBDIRS variable with Makefile Instead of editing the SUBDIRS variable with a patch, it can be overriden at the end of the command line when invoking Make. Skip the build for po files as well, which is causing a conflict depending on the version of gettext detected, and macros present. Signed-off-by: Michael Pratt --- tools/flex/Makefile | 8 ++++++-- tools/flex/patches/100-disable-tests-docs.patch | 13 ------------- 2 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 tools/flex/patches/100-disable-tests-docs.patch diff --git a/tools/flex/Makefile b/tools/flex/Makefile index da037ae72d8..86ba5a4415d 100644 --- a/tools/flex/Makefile +++ b/tools/flex/Makefile @@ -21,13 +21,17 @@ include $(INCLUDE_DIR)/host-build.mk HOST_CONFIGURE_ARGS += --disable-shared +define Host/Compile + $(call Host/Compile/Default,SUBDIRS='src tools') +endef + define Host/Install - $(call Host/Install/Default) + $(call Host/Compile/Default,install SUBDIRS='src tools') $(LN) flex $(STAGING_DIR_HOST)/bin/lex endef define Host/Uninstall - -$(call Host/Compile/Default,uninstall) + -$(call Host/Compile/Default,uninstall SUBDIRS='src tools') endef define Host/Clean diff --git a/tools/flex/patches/100-disable-tests-docs.patch b/tools/flex/patches/100-disable-tests-docs.patch deleted file mode 100644 index f7097f2127d..00000000000 --- a/tools/flex/patches/100-disable-tests-docs.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/Makefile.am -+++ b/Makefile.am -@@ -43,10 +43,7 @@ EXTRA_DIST = \ - - SUBDIRS = \ - src \ -- doc \ -- examples \ - po \ -- tests \ - tools - - # Create the ChangeLog, but only if we're inside a git working directory From 4437434b8a4c8c4f9000caeb773c1aa248a6d29a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 26 Mar 2023 04:11:13 -0400 Subject: [PATCH 071/113] tools/gengetopt: override SUBDIRS variable with Makefile Instead of editing the SUBDIRS variable with a patch, it can be overriden at the end of the command line when invoking Make. This tool has a series of recursive Makefiles in each subdirectory, therefore SUBDIRS is set to a pattern of Make functions so that the result is variable depending on the current subdirectory that Make is being invoked in. By eliminating the patch, autoreconf is no longer required. Signed-off-by: Michael Pratt --- tools/gengetopt/Makefile | 6 +++- .../gengetopt/patches/100-no-tests-docs.patch | 33 ------------------- 2 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 tools/gengetopt/patches/100-no-tests-docs.patch diff --git a/tools/gengetopt/Makefile b/tools/gengetopt/Makefile index 563ecccf9dd..5a5b5eb7cbb 100644 --- a/tools/gengetopt/Makefile +++ b/tools/gengetopt/Makefile @@ -13,12 +13,16 @@ PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/$(PKG_NAME) PKG_HASH:=b941aec9011864978dd7fdeb052b1943535824169d2aa2b0e7eae9ab807584ac -HOST_FIXUP:=autoreconf +PKG_SUBDIRS:=$$$$(foreach dir,gl src skels,$$$$(wildcard $$$$(dir)) ) HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk +define Host/Compile + $(call Host/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)') +endef + define Host/Install $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/gengetopt $(STAGING_DIR_HOST)/bin/ endef diff --git a/tools/gengetopt/patches/100-no-tests-docs.patch b/tools/gengetopt/patches/100-no-tests-docs.patch deleted file mode 100644 index d8c53af4fb7..00000000000 --- a/tools/gengetopt/patches/100-no-tests-docs.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- a/Makefile.am -+++ b/Makefile.am -@@ -18,7 +18,7 @@ - ACLOCAL_AMFLAGS = -I m4 -I gl/m4 - - EXTRA_DIST = configure TODO LICENSE gl/m4/gnulib-cache.m4 --SUBDIRS = gl src doc tests -+SUBDIRS = gl src - - gengetoptdoc_DATA = ChangeLog COPYING NEWS THANKS INSTALL README LICENSE - ---- a/Makefile.in -+++ b/Makefile.in -@@ -593,7 +593,7 @@ top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - ACLOCAL_AMFLAGS = -I m4 -I gl/m4 - EXTRA_DIST = configure TODO LICENSE gl/m4/gnulib-cache.m4 --SUBDIRS = gl src doc tests -+SUBDIRS = gl src - gengetoptdoc_DATA = ChangeLog COPYING NEWS THANKS INSTALL README LICENSE - TARBALL = $(top_builddir)/gengetopt-$(PACKAGE_VERSION).tar.xz - all: config.h ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -16,7 +16,7 @@ - # with gengetopt; see the file COPYING. If not, write to the Free Software - # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - --SUBDIRS = skels tests -+SUBDIRS = skels - - bin_PROGRAMS = gengetopt - From ca8577f930713999fe27bdb2bd8c33ac8afb5bc8 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 15 Apr 2023 19:54:43 -0400 Subject: [PATCH 072/113] gettext-full: override SUBDIRS variable with Makefile Instead of editing the SUBDIRS variable with a patch, it can be overriden at the end of the command line when invoking Make. This tool has a series of recursive Makefiles in each subdirectory, therefore SUBDIRS is set to a pattern of Make functions so that the result is variable depending on the current subdirectory that Make is being invoked in. Some of the subdirectories don't have a Makefile and are just storing files for another subdirectory Makefile target, therefore we have to place a fake Makefile that does nothing. Signed-off-by: Michael Pratt --- package/libs/gettext-full/Makefile | 45 ++++++++++++++++++- .../patches/001-no_examples_and_tests.patch | 22 --------- 2 files changed, 44 insertions(+), 23 deletions(-) delete mode 100644 package/libs/gettext-full/patches/001-no_examples_and_tests.patch diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile index 2319401baf5..6e185a37ab7 100644 --- a/package/libs/gettext-full/Makefile +++ b/package/libs/gettext-full/Makefile @@ -27,6 +27,35 @@ PKG_BUILD_DEPENDS:=gettext-full/host PKG_BUILD_PARALLEL:=0 HOST_BUILD_PARALLEL:=0 +PKG_SUBDIRS:= \ + $$$$(foreach dir, \ + intl \ + intl-csharp \ + intl-java \ + its \ + gnulib-lib \ + gnulib-local \ + lib \ + $$$$(SUBDIR_libasprintf) \ + libgettextpo \ + libgrep \ + libtextstyle \ + m4 \ + misc \ + po \ + projects \ + src \ + styles \ + gettext-runtime \ + gettext-tools \ + ,$$$$(wildcard $$$$(dir)) ) + +PKG_MAKEFILES_FAKE:= \ + gnulib-local/m4/Makefile \ + libtextstyle/gnulib-local/Makefile \ + libtextstyle/m4/Makefile \ + m4/Makefile + include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -75,6 +104,16 @@ HOST_CONFIGURE_VARS += \ HOST_CFLAGS += $(HOST_FPIC) +define Host/Compile + $(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(HOST_BUILD_DIR)/$(makefile); ) + $(call Host/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)') +endef + +define Build/Compile + $(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(PKG_BUILD_DIR)/$(makefile); ) + $(call Build/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)') +endef + define Build/InstallDev $(INSTALL_DIR) $(1)/usr/lib/libintl-full/include $(CP) $(PKG_INSTALL_DIR)/usr/include/libintl.h $(1)/usr/lib/libintl-full/include/ @@ -89,10 +128,14 @@ define Build/InstallDev endef define Host/Install - $(call Host/Install/Default) + $(call Host/Compile/Default,install SUBDIRS='$(PKG_SUBDIRS)') $(LN) msgfmt $(STAGING_DIR_HOSTPKG)/bin/gmsgfmt endef +define Build/Install + $(call Build/Install/Default,install SUBDIRS='$(PKG_SUBDIRS)') +endef + define Package/libintl-full/install $(INSTALL_DIR) $(1)/usr/lib $(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.so.* $(1)/usr/lib/ diff --git a/package/libs/gettext-full/patches/001-no_examples_and_tests.patch b/package/libs/gettext-full/patches/001-no_examples_and_tests.patch deleted file mode 100644 index d813d20ed64..00000000000 --- a/package/libs/gettext-full/patches/001-no_examples_and_tests.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/gettext-runtime/Makefile.am -+++ b/gettext-runtime/Makefile.am -@@ -27,7 +27,7 @@ SUBDIR_libasprintf = libasprintf - else - SUBDIR_libasprintf = - endif --SUBDIRS = doc intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po man m4 tests -+SUBDIRS = intl intl-java intl-csharp gnulib-lib $(SUBDIR_libasprintf) src po m4 - - EXTRA_DIST = BUGS - ---- a/gettext-tools/Makefile.am -+++ b/gettext-tools/Makefile.am -@@ -19,7 +19,7 @@ - AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies - ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 - --SUBDIRS = intl gnulib-lib libgrep src libgettextpo po its projects styles emacs misc man m4 tests system-tests gnulib-tests examples doc -+SUBDIRS = intl gnulib-lib libgrep src libgettextpo po its projects styles misc m4 - - EXTRA_DIST = misc/DISCLAIM - MOSTLYCLEANFILES = core *.stackdump From 2070a2ca27bdb2b1e4e1587274e192e42f247516 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 19 Apr 2023 04:40:42 -0400 Subject: [PATCH 073/113] gperf: add from packages feed Add gperf which is required for building gettext after using the autogen.sh script. Signed-off-by: Michael Pratt --- package/devel/gperf/Makefile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 package/devel/gperf/Makefile diff --git a/package/devel/gperf/Makefile b/package/devel/gperf/Makefile new file mode 100644 index 00000000000..f0f794ee2d9 --- /dev/null +++ b/package/devel/gperf/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gperf +PKG_VERSION:=3.1 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=@GNU/gperf +PKG_HASH:=588546b945bba4b70b6a3a616e80b4ab466e3f33024a352fc2198112cdbb3ae2 + +PKG_LICENSE:=GPL-3.0 +PKG_LICENSE_FILES:=COPYING + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk + +HOST_CPPFLAGS:=-I$(HOST_BUILD_DIR)/lib -I$(HOST_BUILD_DIR)/src $(HOST_CPPFLAGS) +TARGET_CPPFLAGS:=-I$(PKG_BUILD_DIR)/lib -I$(PKG_BUILD_DIR)/src $(TARGET_CPPFLAGS) + +define Package/gperf + SECTION:=devel + CATEGORY:=Development + TITLE:=GNU gperf + URL:=http://www.gnu.org/software/gperf +endef + +define Package/gperf/description + GNU gperf is a perfect hash function generator. For a given list of strings, + it produces a hash function and hash table, in form of C or C++ code, + for looking up a value depending on the input string. + The hash function is perfect, which means that the hash table has no collisions, + and the hash table lookup needs a single string comparison only. +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,gperf)) From 9b0b46985c112c664354dc745d8cfb313166744b Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 19 Apr 2023 12:52:04 -0400 Subject: [PATCH 074/113] libxml2: add from packages feed Add libxml2 which can be used to build gettext instead of the old built-in substitute for it. Signed-off-by: Michael Pratt --- package/libs/libxml2/Makefile | 206 +++++++++++++++++++ package/libs/libxml2/patches/010-iconv.patch | 12 ++ 2 files changed, 218 insertions(+) create mode 100644 package/libs/libxml2/Makefile create mode 100644 package/libs/libxml2/patches/010-iconv.patch diff --git a/package/libs/libxml2/Makefile b/package/libs/libxml2/Makefile new file mode 100644 index 00000000000..e93d1c06bd4 --- /dev/null +++ b/package/libs/libxml2/Makefile @@ -0,0 +1,206 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libxml2 +PKG_VERSION:=2.10.3 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@GNOME/libxml2/$(basename $(PKG_VERSION)) +PKG_HASH:=5d2cc3d78bec3dbe212a9d7fa629ada25a7da928af432c93060ff5c17ee28a9c + +PKG_LICENSE:=MIT +PKG_LICENSE_FILES:=COPYING +PKG_CPE_ID:=cpe:/a:xmlsoft:libxml2 + +include $(INCLUDE_DIR)/host-build.mk +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/libxml2 + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Gnome XML library + URL:=http://xmlsoft.org/ + DEPENDS:=+libpthread +zlib $(ICONV_DEPENDS) +endef + +define Package/libxml2/description + A library for manipulating XML and HTML resources. +endef + +define Package/libxml2-dev + SECTION:=devel + CATEGORY:=Development + SUBMENU:=Libraries + TITLE:=Development files for libxml2 + URL:=http://xmlsoft.org/ + DEPENDS:=+libxml2 +endef + +define Package/libxml2-dev/description + A library for manipulating XML and HTML resources. + + This package contains the headers and xml2-config binary. +endef + +define Package/libxml2-utils + SECTION:=utils + CATEGORY:=Utilities + TITLE:=XML command line utilities (xmllint...) + URL:=http://xmlsoft.org/ + DEPENDS:=+libxml2 +endef + +define Package/libxml2-utils/description + This package contains the binaries xmllint and xmlcatalog + from libxml2, a library for manipulating XML and HTML resources. +endef + +CMAKE_HOST_OPTIONS += \ + -DBUILD_SHARED_LIBS=OFF \ + -DLIBXML2_WITH_C14N=ON \ + -DLIBXML2_WITH_CATALOG=OFF \ + -DLIBXML2_WITH_DEBUG=ON \ + -DLIBXML2_WITH_FTP=OFF \ + -DLIBXML2_WITH_HTML=ON \ + -DLIBXML2_WITH_HTTP=OFF \ + -DLIBXML2_WITH_ICONV=ON \ + -DLIBXML2_WITH_ICU=OFF \ + -DLIBXML2_WITH_ISO8859X=OFF \ + -DLIBXML2_WITH_LEGACY=OFF \ + -DLIBXML2_WITH_LZMA=OFF \ + -DLIBXML2_WITH_MEM_DEBUG=OFF \ + -DLIBXML2_WITH_MODULES=OFF \ + -DLIBXML2_WITH_OUTPUT=ON \ + -DLIBXML2_WITH_PATTERN=ON \ + -DLIBXML2_WITH_PROGRAMS=OFF \ + -DLIBXML2_WITH_PUSH=ON \ + -DLIBXML2_WITH_PYTHON=OFF \ + -DLIBXML2_WITH_READER=ON \ + -DLIBXML2_WITH_REGEXPS=ON \ + -DLIBXML2_WITH_RUN_DEBUG=OFF \ + -DLIBXML2_WITH_SAX1=ON \ + -DLIBXML2_WITH_SCHEMAS=ON \ + -DLIBXML2_WITH_SCHEMATRON=OFF \ + -DLIBXML2_WITH_TESTS=OFF \ + -DLIBXML2_WITH_THREADS=ON \ + -DLIBXML2_WITH_THREAD_ALLOC=OFF \ + -DLIBXML2_WITH_TREE=ON \ + -DLIBXML2_WITH_VALID=ON \ + -DLIBXML2_WITH_WRITER=ON \ + -DLIBXML2_WITH_XINCLUDE=ON \ + -DLIBXML2_WITH_XPATH=ON \ + -DLIBXML2_WITH_XPTR=ON \ + -DLIBXML2_WITH_XPTR_LOCS=ON \ + -DLIBXML2_WITH_ZLIB=ON + +CMAKE_OPTIONS += \ + -DBUILD_SHARED_LIBS=ON \ + -DLIBXML2_WITH_C14N=ON \ + -DLIBXML2_WITH_CATALOG=OFF \ + -DLIBXML2_WITH_DEBUG=ON \ + -DLIBXML2_WITH_FTP=OFF \ + -DLIBXML2_WITH_HTML=ON \ + -DLIBXML2_WITH_HTTP=OFF \ + -DLIBXML2_WITH_ICONV=ON \ + -DLIBXML2_WITH_ICU=OFF \ + -DLIBXML2_WITH_ISO8859X=OFF \ + -DLIBXML2_WITH_LEGACY=OFF \ + -DLIBXML2_WITH_LZMA=OFF \ + -DLIBXML2_WITH_MEM_DEBUG=OFF \ + -DLIBXML2_WITH_MODULES=OFF \ + -DLIBXML2_WITH_OUTPUT=ON \ + -DLIBXML2_WITH_PATTERN=ON \ + -DLIBXML2_WITH_PROGRAMS=ON \ + -DLIBXML2_WITH_PUSH=ON \ + -DLIBXML2_WITH_PYTHON=OFF \ + -DLIBXML2_WITH_READER=ON \ + -DLIBXML2_WITH_REGEXPS=ON \ + -DLIBXML2_WITH_RUN_DEBUG=OFF \ + -DLIBXML2_WITH_SAX1=ON \ + -DLIBXML2_WITH_SCHEMAS=ON \ + -DLIBXML2_WITH_SCHEMATRON=OFF \ + -DLIBXML2_WITH_TESTS=OFF \ + -DLIBXML2_WITH_THREADS=ON \ + -DLIBXML2_WITH_THREAD_ALLOC=OFF \ + -DLIBXML2_WITH_TREE=ON \ + -DLIBXML2_WITH_VALID=ON \ + -DLIBXML2_WITH_WRITER=ON \ + -DLIBXML2_WITH_XINCLUDE=ON \ + -DLIBXML2_WITH_XPATH=ON \ + -DLIBXML2_WITH_XPTR=ON \ + -DLIBXML2_WITH_XPTR_LOCS=ON \ + -DLIBXML2_WITH_ZLIB=ON \ + -DHAVE_LIBHISTORY=OFF \ + -DHAVE_LIBREADLINE=OFF + +define Build/InstallDev + $(INSTALL_DIR) $(2)/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/xml2-config \ + $(2)/bin/$(GNU_TARGET_NAME)-xml2-config + $(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \ + $(2)/bin/$(GNU_TARGET_NAME)-xml2-config + $(LN) $(GNU_TARGET_NAME)-xml2-config $(2)/bin/xml2-config + + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/xmlcatalog $(1)/usr/bin/ + $(CP) $(PKG_INSTALL_DIR)/usr/bin/xmllint $(1)/usr/bin/ + + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/libxml2 $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so* $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/cmake/libxml2 + $(CP) $(PKG_INSTALL_DIR)/usr/lib/cmake/libxml2-$(PKG_VERSION)/*.cmake \ + $(1)/usr/lib/cmake/libxml2 + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libxml-2.0.pc $(1)/usr/lib/pkgconfig/ + + $(INSTALL_DIR) $(2)/share/aclocal/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(2)/share/aclocal +endef + +define Host/Install + $(call Host/Install/Default) + mv $(1)/bin/xml2-config $(1)/bin/$(GNU_HOST_NAME)-xml2-config + $(LN) $(GNU_HOST_NAME)-xml2-config $(1)/bin/xml2-config +endef + +define Package/libxml2/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so.* $(1)/usr/lib/ +endef + +define Package/libxml2-dev/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/xml2-config $(1)/usr/bin/ + $(SED) "s,$(STAGING_DIR),,g" $(1)/usr/bin/xml2-config + + $(INSTALL_DIR) $(1)/usr/include/ + $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/{cmake,pkgconfig} + $(CP) $(PKG_INSTALL_DIR)/usr/lib/{cmake,pkgconfig} $(1)/usr/lib/ + $(SED) "s,$(STAGING_DIR),,g" $(1)/usr/lib/pkgconfig/*.pc + + $(INSTALL_DIR) $(1)/usr/share/aclocal + $(CP) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(1)/usr/share/aclocal +endef + +define Package/libxml2-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(CP) $(PKG_INSTALL_DIR)/usr/bin/xmllint $(1)/usr/bin/ + $(CP) $(PKG_INSTALL_DIR)/usr/bin/xmlcatalog $(1)/usr/bin/ +endef + +$(eval $(call HostBuild)) +$(eval $(call BuildPackage,libxml2)) +$(eval $(call BuildPackage,libxml2-dev)) +$(eval $(call BuildPackage,libxml2-utils)) diff --git a/package/libs/libxml2/patches/010-iconv.patch b/package/libs/libxml2/patches/010-iconv.patch new file mode 100644 index 00000000000..e35b7ce9394 --- /dev/null +++ b/package/libs/libxml2/patches/010-iconv.patch @@ -0,0 +1,12 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -496,6 +496,9 @@ if(LIBXML2_WITH_PROGRAMS) + add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM}) + target_compile_definitions(${PROGRAM} PRIVATE SYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}") + target_link_libraries(${PROGRAM} LibXml2) ++ if(LIBXML2_WITH_ICONV AND NOT Iconv_IS_BUILT_IN) ++ target_link_libraries(${PROGRAM} iconv) ++ endif() + if(HAVE_LIBHISTORY) + target_link_libraries(${PROGRAM} history) + endif() From f7fbe77115924d831dfa7e5b9dc8903b4ccaaf07 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 16 Apr 2023 23:20:57 -0400 Subject: [PATCH 075/113] gettext-full: set gperf as build prerequisite Require gperf to be built before gettext. Signed-off-by: Michael Pratt --- package/libs/gettext-full/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile index 6e185a37ab7..440cff13412 100644 --- a/package/libs/gettext-full/Makefile +++ b/package/libs/gettext-full/Makefile @@ -25,6 +25,8 @@ PKG_FIXUP:=autoreconf PKG_INSTALL:=1 PKG_BUILD_DEPENDS:=gettext-full/host PKG_BUILD_PARALLEL:=0 + +HOST_BUILD_DEPENDS:=gperf/host HOST_BUILD_PARALLEL:=0 PKG_SUBDIRS:= \ From d95d5d2a3a895f5374b56ab349f628578cd4149b Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 16 Apr 2023 11:04:31 -0400 Subject: [PATCH 076/113] gettext-full: link to local libxml2 Some users have reported that gettext builds are attempting to link to libxml2 while it was supposed to be configured to use it's own built-in substitute. Configure gettext to require and link to our local libxml2 explicitly. Add a patch to revert upstream commit 87927a4e2 which forces libtextstyle to use the built-in libxml, no matter what the configuration is, making that option configurable again after the configure script is regenerated. Reported-by: Tianling Shen Signed-off-by: Michael Pratt --- package/libs/gettext-full/Makefile | 7 +++-- .../100-libxml-no-force-included.patch | 31 +++++++++++++++++++ .../patches/150-disable_libxml_iconv.patch | 22 ------------- 3 files changed, 35 insertions(+), 25 deletions(-) create mode 100644 package/libs/gettext-full/patches/100-libxml-no-force-included.patch delete mode 100644 package/libs/gettext-full/patches/150-disable_libxml_iconv.patch diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile index 440cff13412..a92932f3759 100644 --- a/package/libs/gettext-full/Makefile +++ b/package/libs/gettext-full/Makefile @@ -23,10 +23,10 @@ PKG_CPE_ID:=cpe:/a:gnu:gettext PKG_FIXUP:=autoreconf PKG_INSTALL:=1 -PKG_BUILD_DEPENDS:=gettext-full/host +PKG_BUILD_DEPENDS:=gettext-full/host libxml2 PKG_BUILD_PARALLEL:=0 -HOST_BUILD_DEPENDS:=gperf/host +HOST_BUILD_DEPENDS:=gperf/host libxml2/host HOST_BUILD_PARALLEL:=0 PKG_SUBDIRS:= \ @@ -86,6 +86,7 @@ CONFIGURE_ARGS += \ --with-included-gettext \ --without-libintl-prefix \ --without-libexpat-prefix \ + --with-libxml2-prefix=$(STAGING_DIR) \ --without-emacs HOST_CONFIGURE_ARGS += \ @@ -96,7 +97,7 @@ HOST_CONFIGURE_ARGS += \ --disable-java \ --disable-openmp \ --without-emacs \ - --without-libxml2-prefix + --with-libxml2-prefix=$(STAGING_DIR_HOSTPKG) HOST_CONFIGURE_VARS += \ EMACS="no" \ diff --git a/package/libs/gettext-full/patches/100-libxml-no-force-included.patch b/package/libs/gettext-full/patches/100-libxml-no-force-included.patch new file mode 100644 index 00000000000..af5c0a47ee8 --- /dev/null +++ b/package/libs/gettext-full/patches/100-libxml-no-force-included.patch @@ -0,0 +1,31 @@ +--- a/libtextstyle/gnulib-local/modules/libxml.diff ++++ /dev/null +@@ -1,28 +0,0 @@ +-*** libxml.orig 2018-10-28 14:37:07.007164889 +0100 +---- libxml 2019-02-14 22:19:29.994771110 +0100 +-*************** +-*** 118,124 **** +- fabs +- +- configure.ac: +-! gl_LIBXML +- +- Makefile.am: +- if INCLUDED_LIBXML +---- 118,133 ---- +- fabs +- +- configure.ac: +-! # In libtextstyle, we don't want to use an external libxml, because its +-! # dependencies and their dynamic relocations have an impact on the startup +-! # time of a program that is linked with it. As you can see by using +-! # 'readelf -r ... | wc -l' and 'readelf -d ... | grep NEEDED': +-! # - libxml2.so has more than 3300 relocations and depends on libicuuc. +-! # - libicuuc.so has more than 4900 relocations and depends on libstdc++. +-! # - libstdc++.so has more than 4600 relocations. +-! # These are more than 12800 relocations, to perform at program startup. +-! # So, force the use of the included libxml part. +-! gl_LIBXML([yes]) +- +- Makefile.am: +- if INCLUDED_LIBXML diff --git a/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch b/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch deleted file mode 100644 index bf60ecbdb5e..00000000000 --- a/package/libs/gettext-full/patches/150-disable_libxml_iconv.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/gettext-tools/gnulib-lib/libxml/xmlversion.in.h -+++ b/gettext-tools/gnulib-lib/libxml/xmlversion.in.h -@@ -302,7 +302,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i - * - * Whether iconv support is available - */ --#if 1 -+#if 0 - #define LIBXML_ICONV_ENABLED - #endif - ---- a/gnulib-local/lib/libxml/xmlversion.in.h -+++ b/gnulib-local/lib/libxml/xmlversion.in.h -@@ -302,7 +302,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(i - * - * Whether iconv support is available - */ --#if 1 -+#if 0 - #define LIBXML_ICONV_ENABLED - #endif - From 87e902fcdcce0e3d1287deb901f934aabf7ec183 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 23 Mar 2023 03:53:52 -0400 Subject: [PATCH 077/113] tools/libtool: bootstrap to local gnulib source Using the local gnulib source during bootstrap allows for fine-grained control over the macros and source files for use with libtool but part of gnulib instead of libtool, without having to wait for a release or deal with gnulib as a git submodule. Signed-off-by: Michael Pratt --- tools/Makefile | 2 +- tools/libtool/Makefile | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 3bf94827cf6..3f12828a8f3 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -104,7 +104,7 @@ $(curdir)/gmp/compile := $(curdir)/libtool/compile $(curdir)/isl/compile := $(curdir)/gmp/compile $(curdir)/liblzo/compile := $(curdir)/cmake/compile $(curdir)/libressl/compile := $(curdir)/pkgconf/compile -$(curdir)/libtool/compile := $(curdir)/automake/compile $(curdir)/missing-macros/compile +$(curdir)/libtool/compile := $(curdir)/automake/compile $(curdir)/gnulib/compile $(curdir)/missing-macros/compile $(curdir)/lz4/compile := $(curdir)/meson/compile $(curdir)/lzma-old/compile := $(curdir)/zlib/compile $(curdir)/lzop/compile := $(curdir)/cmake/compile $(curdir)/liblzo/compile diff --git a/tools/libtool/Makefile b/tools/libtool/Makefile index b4f3ecc36ba..11871914782 100644 --- a/tools/libtool/Makefile +++ b/tools/libtool/Makefile @@ -18,17 +18,31 @@ HOST_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/host-build.mk +export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR) + HOST_CONFIGURE_VARS += \ lt_cv_sys_dlsearch_path="" +define Host/Bootstrap + ( \ + cd $(HOST_BUILD_DIR); \ + $(AM_TOOL_PATHS) \ + ./bootstrap \ + --force \ + --skip-git \ + --skip-po \ + --gnulib-srcdir=$(GNULIB_SRCDIR) \ + ) +endef + define Host/Prepare $(call Host/Prepare/Default) $(call Host/Uninstall) - $(if $(QUILT),,(cd $(HOST_BUILD_DIR); touch README-release; $(AM_TOOL_PATHS) ./bootstrap --skip-git --skip-po --force)) + $(if $(QUILT),,$(call Host/Bootstrap)) endef define Host/Configure - $(if $(QUILT),(cd $(HOST_BUILD_DIR); touch README-release; $(AM_TOOL_PATHS) ./bootstrap --skip-git --skip-po --force)) + $(if $(QUILT),$(call Host/Bootstrap)) $(call Host/Configure/Default) endef From 09f8f21ae33402201c14a125a37b64746415642d Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 23 Mar 2023 03:49:01 -0400 Subject: [PATCH 078/113] tools/coreutils: bootstrap to local gnulib source Using the local gnulib source during bootstrap allows for fine-grained control over the macros and source files for use with coreutils but part of gnulib instead of coreutils, without having to wait for a release or deal with gnulib as a git submodule. In this case, the execution of autotools must be skipped by force. Autoconf and Automake during bootstrap on coreutils only works right when using directly checked-out source. There is a symbol in gnulib, @GNULIB_TIME@ that is not yet defined in coreutils source, so we use the backup of lib/time.in.h instead of the one provided by gnulib source. Signed-off-by: Michael Pratt --- tools/Makefile | 1 + tools/coreutils/Makefile | 27 +++++++++++++ tools/coreutils/patches/000-bootstrap.patch | 45 +++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tools/coreutils/patches/000-bootstrap.patch diff --git a/tools/Makefile b/tools/Makefile index 3f12828a8f3..40c3ec1ab09 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -127,6 +127,7 @@ $(curdir)/squashfs4/compile := $(curdir)/xz/compile $(curdir)/zlib/compile $(curdir)/zstd/compile := $(curdir)/meson/compile ifneq ($(HOST_OS),Linux) + $(curdir)/coreutils/compile += $(curdir)/automake/compile $(curdir)/bison/compile $(curdir)/gnulib/compile $(curdir)/squashfs4/compile += $(curdir)/coreutils/compile tools-y += coreutils endif diff --git a/tools/coreutils/Makefile b/tools/coreutils/Makefile index f799e83c5b6..233ab1585d7 100644 --- a/tools/coreutils/Makefile +++ b/tools/coreutils/Makefile @@ -20,15 +20,42 @@ BUILD_PROGRAMS = date readlink touch ln chown ginstall include $(INCLUDE_DIR)/host-build.mk +export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR) + BUILD_BINS = $(patsubst %,src/%,$(BUILD_PROGRAMS)) HOST_CONFIGURE_ARGS += \ --enable-install-program=$(subst $(space),$(comma),$(strip $(BUILD_PROGRAMS))) HOST_MAKE_FLAGS += \ + $(AM_TOOL_PATHS_FAKE) \ PROGRAMS="$(BUILD_BINS)" \ LIBRARIES= MANS= SUBDIRS=. +define Host/Bootstrap + ( \ + cd $(HOST_BUILD_DIR); \ + $(AM_TOOL_PATHS_FAKE) \ + ./bootstrap \ + --bootstrap-sync \ + --force \ + --no-git \ + --skip-po \ + --gnulib-srcdir=$(GNULIB_SRCDIR) \ + ) +endef + +define Host/Prepare + $(call Host/Prepare/Default) + $(if $(QUILT),,$(call Host/Bootstrap)) +endef + +define Host/Configure + $(if $(QUILT),$(call Host/Bootstrap)) + -$(CP) $(HOST_BUILD_DIR)/lib/time.in.h~ $(HOST_BUILD_DIR)/lib/time.in.h # @GNULIB_TIME@ not defined + $(call Host/Configure/Default) +endef + define Host/Install $(INSTALL_DIR) $(1)/bin $(INSTALL_BIN) $(patsubst %,$(HOST_BUILD_DIR)/%,$(BUILD_BINS)) $(1)/bin/ diff --git a/tools/coreutils/patches/000-bootstrap.patch b/tools/coreutils/patches/000-bootstrap.patch new file mode 100644 index 00000000000..91be9d338a2 --- /dev/null +++ b/tools/coreutils/patches/000-bootstrap.patch @@ -0,0 +1,45 @@ +--- a/bootstrap ++++ b/bootstrap +@@ -278,7 +278,7 @@ check_exists() { + ($2 --version /dev/null 2>&1 ++ ($@ --version /dev/null 2>&1 + fi + + test $? -lt 126 +@@ -563,7 +563,7 @@ p + q' + + get_version() { +- app=$1 ++ app="$@" + + $app --version >/dev/null 2>&1 || { $app --version; return 1; } + +@@ -620,13 +620,13 @@ check_versions() { + if [ "$req_ver" = "-" ]; then + # Merely require app to exist; not all prereq apps are well-behaved + # so we have to rely on $? rather than get_version. +- if ! check_exists --verbose $app; then ++ if ! check_exists --verbose "$app"; then + warn_ "Error: '$app' not found" + ret=1 + fi + else + # Require app to produce a new enough version string. +- inst_ver=$(get_version $app) ++ inst_ver=$(get_version "$app") + if [ ! "$inst_ver" ]; then + warn_ "Error: '$app' not found" + ret=1 +@@ -923,7 +923,7 @@ version_controlled_file() { + # two just-pre-run programs. + + # Import from gettext. +-with_gettext=yes ++with_gettext=no + grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ + with_gettext=no + From d167adbc4418b664dd825b8b4e7085c2c7322271 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 16 Apr 2023 18:32:14 -0400 Subject: [PATCH 079/113] gettext-full: bootstrap to local gnulib source Using the local gnulib source during autogen.sh allows for fine-grained control over the macros and source files for use with gettext but part of gnulib instead of gettext, without having to wait for a release or deal with gnulib as a git submodule. This is an alternative to running autoreconf. It also removes the need to patch macros in the case where there is a conflict between the source and our aclocal directory. Signed-off-by: Michael Pratt --- package/libs/gettext-full/Makefile | 41 ++- .../libs/gettext-full/patches/010-m4.patch | 342 ------------------ 2 files changed, 39 insertions(+), 344 deletions(-) delete mode 100644 package/libs/gettext-full/patches/010-m4.patch diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile index a92932f3759..c8700de550a 100644 --- a/package/libs/gettext-full/Makefile +++ b/package/libs/gettext-full/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gettext-full PKG_VERSION:=0.21.1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=gettext-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@GNU/gettext @@ -21,7 +21,6 @@ PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=GPL-3.0-or-later PKG_CPE_ID:=cpe:/a:gnu:gettext -PKG_FIXUP:=autoreconf PKG_INSTALL:=1 PKG_BUILD_DEPENDS:=gettext-full/host libxml2 PKG_BUILD_PARALLEL:=0 @@ -69,6 +68,8 @@ define Package/libintl-full ABI_VERSION:=8 endef +export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR) + TARGET_CFLAGS += $(FPIC) ifneq ($(HOST_OS),Linux) TARGET_CFLAGS += -I$(STAGING_DIR_HOSTPKG)/include @@ -107,11 +108,47 @@ HOST_CONFIGURE_VARS += \ HOST_CFLAGS += $(HOST_FPIC) +define Host/Bootstrap + ( \ + cd $(HOST_BUILD_DIR); \ + $(AM_TOOL_PATHS) \ + ./autogen.sh \ + ) +endef + +define Host/Prepare + $(call Host/Prepare/Default) + $(if $(QUILT),,$(call Host/Bootstrap)) +endef + +define Host/Configure + $(if $(QUILT),$(call Host/Bootstrap)) + $(call Host/Configure/Default) +endef + define Host/Compile $(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(HOST_BUILD_DIR)/$(makefile); ) $(call Host/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)') endef +define Build/Bootstrap + ( \ + cd $(PKG_BUILD_DIR); \ + $(AM_TOOL_PATHS) \ + ./autogen.sh \ + ) +endef + +define Build/Prepare + $(call Build/Prepare/Default) + $(if $(QUILT),,$(call Build/Bootstrap)) +endef + +define Build/Configure + $(if $(QUILT),$(call Build/Bootstrap)) + $(call Build/Configure/Default) +endef + define Build/Compile $(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(PKG_BUILD_DIR)/$(makefile); ) $(call Build/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)') diff --git a/package/libs/gettext-full/patches/010-m4.patch b/package/libs/gettext-full/patches/010-m4.patch deleted file mode 100644 index fe896db3123..00000000000 --- a/package/libs/gettext-full/patches/010-m4.patch +++ /dev/null @@ -1,342 +0,0 @@ ---- a/gettext-runtime/gnulib-m4/stddef_h.m4 -+++ b/gettext-runtime/gnulib-m4/stddef_h.m4 -@@ -9,7 +9,7 @@ dnl A placeholder for , for pl - AC_DEFUN_ONCE([gl_STDDEF_H], - [ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - - dnl Persuade OpenBSD to declare max_align_t. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) ---- a/gettext-runtime/gnulib-m4/stdint.m4 -+++ b/gettext-runtime/gnulib-m4/stdint.m4 -@@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - AC_REQUIRE([gl_LIMITS_H]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - - dnl For backward compatibility. Some packages may still be testing these - dnl macros. ---- a/gettext-runtime/gnulib-m4/wchar_h.m4 -+++ b/gettext-runtime/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], - - AC_REQUIRE([gl_FEATURES_H]) - -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else ---- a/gettext-runtime/gnulib-m4/wchar_t.m4 -+++ b/gettext-runtime/gnulib-m4/wchar_t.m4 -@@ -8,7 +8,7 @@ dnl From Bruno Haible. - dnl Test whether has the 'wchar_t' type. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WCHAR_T], -+AC_DEFUN([gt_TYPE_WCHAR_T_GT], - [ - AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_COMPILE_IFELSE( ---- a/gettext-runtime/gnulib-m4/wctype_h.m4 -+++ b/gettext-runtime/gnulib-m4/wctype_h.m4 -@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H], - fi - AC_SUBST([HAVE_ISWCNTRL]) - -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else ---- a/gettext-runtime/gnulib-m4/wcwidth.m4 -+++ b/gettext-runtime/gnulib-m4/wcwidth.m4 -@@ -12,8 +12,8 @@ AC_DEFUN([gl_FUNC_WCWIDTH], - dnl Persuade glibc to declare wcwidth(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - - AC_CHECK_HEADERS_ONCE([wchar.h]) - AC_CHECK_FUNCS_ONCE([wcwidth]) ---- a/gettext-runtime/gnulib-m4/wint_t.m4 -+++ b/gettext-runtime/gnulib-m4/wint_t.m4 -@@ -9,7 +9,7 @@ dnl Test whether has the 'wint - dnl or would, if present, override 'wint_t'. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WINT_T], -+AC_DEFUN([gt_TYPE_WINT_T_GT], - [ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_COMPILE_IFELSE( ---- a/gettext-runtime/libasprintf/configure.ac -+++ b/gettext-runtime/libasprintf/configure.ac -@@ -76,8 +76,8 @@ dnl Checks for typedefs, structures, and - AC_C_INLINE - AC_TYPE_SIZE_T - AC_TYPE_LONG_LONG_INT --gt_TYPE_WCHAR_T --gt_TYPE_WINT_T -+gt_TYPE_WCHAR_T_GT -+gt_TYPE_WINT_T_GT - AC_TYPE_MBSTATE_T - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], ---- a/gettext-runtime/libasprintf/gnulib-m4/wchar_t.m4 -+++ b/gettext-runtime/libasprintf/gnulib-m4/wchar_t.m4 -@@ -8,7 +8,7 @@ dnl From Bruno Haible. - dnl Test whether has the 'wchar_t' type. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WCHAR_T], -+AC_DEFUN([gt_TYPE_WCHAR_T_GT], - [ - AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_COMPILE_IFELSE( ---- a/gettext-runtime/libasprintf/gnulib-m4/wint_t.m4 -+++ b/gettext-runtime/libasprintf/gnulib-m4/wint_t.m4 -@@ -9,7 +9,7 @@ dnl Test whether has the 'wint - dnl or would, if present, override 'wint_t'. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WINT_T], -+AC_DEFUN([gt_TYPE_WINT_T_GT], - [ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_COMPILE_IFELSE( ---- a/gettext-runtime/m4/intl.m4 -+++ b/gettext-runtime/m4/intl.m4 -@@ -31,8 +31,8 @@ AC_DEFUN([AM_INTL_SUBDIR], - AC_REQUIRE([gl_VISIBILITY])dnl - AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl - AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl -- AC_REQUIRE([gt_TYPE_WCHAR_T])dnl -- AC_REQUIRE([gt_TYPE_WINT_T])dnl -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT])dnl -+ AC_REQUIRE([gt_TYPE_WINT_T_GT])dnl - AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) - AC_REQUIRE([gt_TYPE_INTMAX_T]) - AC_REQUIRE([gt_PRINTF_POSIX]) ---- a/gettext-tools/gnulib-m4/stdint.m4 -+++ b/gettext-tools/gnulib-m4/stdint.m4 -@@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - AC_REQUIRE([gl_LIMITS_H]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - - dnl For backward compatibility. Some packages may still be testing these - dnl macros. ---- a/gettext-tools/gnulib-m4/vasnprintf.m4 -+++ b/gettext-tools/gnulib-m4/vasnprintf.m4 -@@ -32,16 +32,16 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF], - # Prerequisites of lib/printf-args.h, lib/printf-args.c. - AC_DEFUN([gl_PREREQ_PRINTF_ARGS], - [ -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - ]) - - # Prerequisites of lib/printf-parse.h, lib/printf-parse.c. - AC_DEFUN([gl_PREREQ_PRINTF_PARSE], - [ - AC_REQUIRE([gl_FEATURES_H]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - AC_REQUIRE([AC_TYPE_SIZE_T]) - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], -@@ -54,8 +54,8 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE], - AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], - [ - AC_REQUIRE([AC_FUNC_ALLOCA]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) - dnl Use the _snprintf function only if it is declared (because on NetBSD it - dnl is defined as a weak alias of snprintf; we prefer to use the latter). ---- a/gettext-tools/gnulib-m4/wchar_h.m4 -+++ b/gettext-tools/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], - - AC_REQUIRE([gl_FEATURES_H]) - -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else ---- a/gettext-tools/gnulib-m4/wchar_t.m4 -+++ b/gettext-tools/gnulib-m4/wchar_t.m4 -@@ -8,7 +8,7 @@ dnl From Bruno Haible. - dnl Test whether has the 'wchar_t' type. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WCHAR_T], -+AC_DEFUN([gt_TYPE_WCHAR_T_GT], - [ - AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_COMPILE_IFELSE( ---- a/gettext-tools/gnulib-m4/wctype_h.m4 -+++ b/gettext-tools/gnulib-m4/wctype_h.m4 -@@ -22,7 +22,7 @@ AC_DEFUN_ONCE([gl_WCTYPE_H], - fi - AC_SUBST([HAVE_ISWCNTRL]) - -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else ---- a/gettext-tools/gnulib-m4/wcwidth.m4 -+++ b/gettext-tools/gnulib-m4/wcwidth.m4 -@@ -12,8 +12,8 @@ AC_DEFUN([gl_FUNC_WCWIDTH], - dnl Persuade glibc to declare wcwidth(). - AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) - -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - - AC_CHECK_HEADERS_ONCE([wchar.h]) - AC_CHECK_FUNCS_ONCE([wcwidth]) ---- a/gettext-tools/gnulib-m4/wint_t.m4 -+++ b/gettext-tools/gnulib-m4/wint_t.m4 -@@ -9,7 +9,7 @@ dnl Test whether has the 'wint - dnl or would, if present, override 'wint_t'. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WINT_T], -+AC_DEFUN([gt_TYPE_WINT_T_GT], - [ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_COMPILE_IFELSE( ---- a/libtextstyle/gnulib-m4/stdint.m4 -+++ b/libtextstyle/gnulib-m4/stdint.m4 -@@ -15,7 +15,7 @@ AC_DEFUN_ONCE([gl_STDINT_H], - AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles - - AC_REQUIRE([gl_LIMITS_H]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - - dnl For backward compatibility. Some packages may still be testing these - dnl macros. ---- a/libtextstyle/gnulib-m4/vasnprintf.m4 -+++ b/libtextstyle/gnulib-m4/vasnprintf.m4 -@@ -32,16 +32,16 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF], - # Prerequisites of lib/printf-args.h, lib/printf-args.c. - AC_DEFUN([gl_PREREQ_PRINTF_ARGS], - [ -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - ]) - - # Prerequisites of lib/printf-parse.h, lib/printf-parse.c. - AC_DEFUN([gl_PREREQ_PRINTF_PARSE], - [ - AC_REQUIRE([gl_FEATURES_H]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - AC_REQUIRE([AC_TYPE_SIZE_T]) - AC_CHECK_TYPE([ptrdiff_t], , - [AC_DEFINE([ptrdiff_t], [long], -@@ -54,8 +54,8 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE], - AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], - [ - AC_REQUIRE([AC_FUNC_ALLOCA]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) - dnl Use the _snprintf function only if it is declared (because on NetBSD it - dnl is defined as a weak alias of snprintf; we prefer to use the latter). ---- a/libtextstyle/gnulib-m4/wchar_h.m4 -+++ b/libtextstyle/gnulib-m4/wchar_h.m4 -@@ -27,7 +27,7 @@ AC_DEFUN_ONCE([gl_WCHAR_H], - - AC_REQUIRE([gl_FEATURES_H]) - -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - if test $gt_cv_c_wint_t = yes; then - HAVE_WINT_T=1 - else ---- a/libtextstyle/gnulib-m4/wchar_t.m4 -+++ b/libtextstyle/gnulib-m4/wchar_t.m4 -@@ -8,7 +8,7 @@ dnl From Bruno Haible. - dnl Test whether has the 'wchar_t' type. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WCHAR_T], -+AC_DEFUN([gt_TYPE_WCHAR_T_GT], - [ - AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], - [AC_COMPILE_IFELSE( ---- a/libtextstyle/gnulib-m4/wint_t.m4 -+++ b/libtextstyle/gnulib-m4/wint_t.m4 -@@ -9,7 +9,7 @@ dnl Test whether has the 'wint - dnl or would, if present, override 'wint_t'. - dnl Prerequisite: AC_PROG_CC - --AC_DEFUN([gt_TYPE_WINT_T], -+AC_DEFUN([gt_TYPE_WINT_T_GT], - [ - AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], - [AC_COMPILE_IFELSE( ---- a/gettext-tools/gnulib-m4/gnulib-comp.m4 -+++ b/gettext-tools/gnulib-m4/gnulib-comp.m4 -@@ -2218,8 +2218,8 @@ changequote([, ])dnl - AC_REQUIRE([gl_SOCKETLIB]) - AC_REQUIRE([gl_SOCKETS]) - gl_TYPE_SOCKLEN_T -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -- AC_REQUIRE([gt_TYPE_WINT_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) -+ AC_REQUIRE([gt_TYPE_WINT_T_GT]) - gl_FUNC_STRERROR_R - AS_IF([test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1], [ - AC_LIBOBJ([strerror_r]) ---- a/libtextstyle/gnulib-m4/stddef_h.m4 -+++ b/libtextstyle/gnulib-m4/stddef_h.m4 -@@ -9,7 +9,7 @@ dnl A placeholder for , for pl - AC_DEFUN_ONCE([gl_STDDEF_H], - [ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - - dnl Persuade OpenBSD to declare max_align_t. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) ---- a/gettext-tools/gnulib-m4/stddef_h.m4 -+++ b/gettext-tools/gnulib-m4/stddef_h.m4 -@@ -9,7 +9,7 @@ dnl A placeholder for , for pl - AC_DEFUN_ONCE([gl_STDDEF_H], - [ - AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) -- AC_REQUIRE([gt_TYPE_WCHAR_T]) -+ AC_REQUIRE([gt_TYPE_WCHAR_T_GT]) - - dnl Persuade OpenBSD to declare max_align_t. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) From 97d20525b24e96558f974858f4d8ad6d9148e61f Mon Sep 17 00:00:00 2001 From: Yuu Toriyama Date: Thu, 4 May 2023 19:26:13 +0900 Subject: [PATCH 080/113] wireless-regdb: update to 2023.05.03 Changes: 43f81b4 wireless-regdb: update regulatory database based on preceding changes 66f245d wireless-regdb: Update regulatory rules for Hong Kong (HK) e78c450 wireless-regdb: update regulatory rules for India (IN) 1647bb6 wireless-regdb: Update regulatory rules for Russia (RU). Remove DFS requirement. c076f21 Update regulatory info for Russia (RU) on 6GHz Signed-off-by: Yuu Toriyama --- package/firmware/wireless-regdb/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/firmware/wireless-regdb/Makefile b/package/firmware/wireless-regdb/Makefile index 9b4a5c105f4..9ce2a397ff5 100644 --- a/package/firmware/wireless-regdb/Makefile +++ b/package/firmware/wireless-regdb/Makefile @@ -1,12 +1,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=wireless-regdb -PKG_VERSION:=2023.02.13 +PKG_VERSION:=2023.05.03 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/software/network/wireless-regdb/ -PKG_HASH:=fe81e8a8694dc4753a45087a1c4c7e1b48dee5a59f5f796ce374ea550f0b2e73 +PKG_HASH:=f254d08ab3765aeae2b856222e11a95d44aef519a6663877c71ef68fae4c8c12 PKG_MAINTAINER:=Felix Fietkau From 9464e9e209bb2df22f314276785bea80b1cfee0e Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 3 May 2023 20:10:32 +0200 Subject: [PATCH 081/113] lantiq: xway: use capital letters in Fritz!Box name Rename to Fritz!Box to keep naming uniform. Fixes: ceac4ae3b403 ("lantiq: xway: add support for AVM FRITZ!Box 7330") Signed-off-by: Nick Hainke --- target/linux/lantiq/image/ar9.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/lantiq/image/ar9.mk b/target/linux/lantiq/image/ar9.mk index 5732a3432cb..9a0d68433ce 100644 --- a/target/linux/lantiq/image/ar9.mk +++ b/target/linux/lantiq/image/ar9.mk @@ -18,7 +18,7 @@ define Device/avm_fritz7320 DEVICE_ALT0_VENDOR := 1&1 DEVICE_ALT0_MODEL := HomeServer DEVICE_ALT1_VENDOR := AVM - DEVICE_ALT1_MODEL := Fritz!box 7330 + DEVICE_ALT1_MODEL := Fritz!Box 7330 SOC := ar9 IMAGE_SIZE := 15744k LOADER_FLASH_OFFS := 0x31000 From c6419d1946996aa859cef9df897a0c1c1f796d11 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Wed, 22 Feb 2023 19:55:56 +0100 Subject: [PATCH 082/113] lantiq: switch to Kernel 5.15 by default Getting ready for the next release. Signed-off-by: Paul Spooren --- target/linux/lantiq/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/linux/lantiq/Makefile b/target/linux/lantiq/Makefile index 08618fa9a3a..2e166a5f373 100644 --- a/target/linux/lantiq/Makefile +++ b/target/linux/lantiq/Makefile @@ -9,8 +9,7 @@ BOARDNAME:=Lantiq FEATURES:=squashfs SUBTARGETS:=xrx200 xway xway_legacy falcon ase -KERNEL_PATCHVER:=5.10 -KERNEL_TESTING_PATCHVER:=5.15 +KERNEL_PATCHVER:=5.15 define Target/Description Build firmware images for Lantiq SoC From 1e88a16248601da03d78da7939d412588ad0ea52 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 27 Apr 2023 23:00:30 +0200 Subject: [PATCH 083/113] toolchain: gcc: copy patches from 12.x to 13.x This simplifies the gcc bump patch review. Signed-off-by: Nick Hainke --- .../patches-13.x/002-case_insensitive.patch | 24 +++ .../gcc/patches-13.x/010-documentation.patch | 35 +++++ .../patches-13.x/110-Fix-MIPS-PR-84790.patch | 20 +++ .../gcc/patches-13.x/230-musl_libssp.patch | 13 ++ .../300-mips_Os_cpu_rtx_cost_model.patch | 21 +++ .../810-arm-softfloat-libgcc.patch | 33 ++++ .../gcc/patches-13.x/820-libgcc_pic.patch | 44 ++++++ .../840-armv4_pass_fix-v4bx_to_ld.patch | 28 ++++ .../patches-13.x/850-use_shared_libgcc.patch | 54 +++++++ .../patches-13.x/851-libgcc_no_compat.patch | 22 +++ .../patches-13.x/870-ppc_no_crtsavres.patch | 11 ++ .../gcc/patches-13.x/881-no_tm_section.patch | 11 ++ .../gcc/patches-13.x/900-bad-mips16-crt.patch | 9 ++ .../gcc/patches-13.x/910-mbsd_multi.patch | 146 ++++++++++++++++++ .../920-specs_nonfatal_getenv.patch | 22 +++ ...mpilation-when-making-cross-compiler.patch | 67 ++++++++ .../970-macos_arm64-building-fix.patch | 45 ++++++ 17 files changed, 605 insertions(+) create mode 100644 toolchain/gcc/patches-13.x/002-case_insensitive.patch create mode 100644 toolchain/gcc/patches-13.x/010-documentation.patch create mode 100644 toolchain/gcc/patches-13.x/110-Fix-MIPS-PR-84790.patch create mode 100644 toolchain/gcc/patches-13.x/230-musl_libssp.patch create mode 100644 toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch create mode 100644 toolchain/gcc/patches-13.x/810-arm-softfloat-libgcc.patch create mode 100644 toolchain/gcc/patches-13.x/820-libgcc_pic.patch create mode 100644 toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch create mode 100644 toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch create mode 100644 toolchain/gcc/patches-13.x/851-libgcc_no_compat.patch create mode 100644 toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch create mode 100644 toolchain/gcc/patches-13.x/881-no_tm_section.patch create mode 100644 toolchain/gcc/patches-13.x/900-bad-mips16-crt.patch create mode 100644 toolchain/gcc/patches-13.x/910-mbsd_multi.patch create mode 100644 toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch create mode 100644 toolchain/gcc/patches-13.x/960-gotools-fix-compilation-when-making-cross-compiler.patch create mode 100644 toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch diff --git a/toolchain/gcc/patches-13.x/002-case_insensitive.patch b/toolchain/gcc/patches-13.x/002-case_insensitive.patch new file mode 100644 index 00000000000..409497e5a3d --- /dev/null +++ b/toolchain/gcc/patches-13.x/002-case_insensitive.patch @@ -0,0 +1,24 @@ +commit 81cc26c706b2bc8c8c1eb1a322e5c5157900836e +Author: Felix Fietkau +Date: Sun Oct 19 21:45:51 2014 +0000 + + gcc: do not assume that the Mac OS X filesystem is case insensitive + + Signed-off-by: Felix Fietkau + + SVN-Revision: 42973 + +--- a/include/filenames.h ++++ b/include/filenames.h +@@ -44,11 +44,6 @@ extern "C" { + # define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c) + # define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f) + #else /* not DOSish */ +-# if defined(__APPLE__) +-# ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM +-# define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1 +-# endif +-# endif /* __APPLE__ */ + # define HAS_DRIVE_SPEC(f) (0) + # define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c) + # define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f) diff --git a/toolchain/gcc/patches-13.x/010-documentation.patch b/toolchain/gcc/patches-13.x/010-documentation.patch new file mode 100644 index 00000000000..39ee48ed67c --- /dev/null +++ b/toolchain/gcc/patches-13.x/010-documentation.patch @@ -0,0 +1,35 @@ +commit 098bd91f5eae625c7d2ee621e10930fc4434e5e2 +Author: Luka Perkov +Date: Tue Feb 26 16:16:33 2013 +0000 + + gcc: don't build documentation + + This closes #13039. + + Signed-off-by: Luka Perkov + + SVN-Revision: 35807 + +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -3366,18 +3366,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) + doc/gccint.info: $(TEXI_GCCINT_FILES) + doc/cppinternals.info: $(TEXI_CPPINT_FILES) + +-doc/%.info: %.texi +- if [ x$(BUILD_INFO) = xinfo ]; then \ +- $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \ +- -I $(gcc_docdir)/include -o $@ $<; \ +- fi ++doc/%.info: + + # Duplicate entry to handle renaming of gccinstall.info +-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES) +- if [ x$(BUILD_INFO) = xinfo ]; then \ +- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \ +- -I $(gcc_docdir)/include -o $@ $<; \ +- fi ++doc/gccinstall.info: + + doc/cpp.dvi: $(TEXI_CPP_FILES) + doc/gcc.dvi: $(TEXI_GCC_FILES) diff --git a/toolchain/gcc/patches-13.x/110-Fix-MIPS-PR-84790.patch b/toolchain/gcc/patches-13.x/110-Fix-MIPS-PR-84790.patch new file mode 100644 index 00000000000..856fd6a46ce --- /dev/null +++ b/toolchain/gcc/patches-13.x/110-Fix-MIPS-PR-84790.patch @@ -0,0 +1,20 @@ +Fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84790. +MIPS16 functions have a static assembler prologue which clobbers +registers v0 and v1. Add these register clobbers to function call +instructions. + +--- a/gcc/config/mips/mips.cc ++++ b/gcc/config/mips/mips.cc +@@ -3134,6 +3134,12 @@ mips_emit_call_insn (rtx pattern, rtx or + emit_insn (gen_update_got_version ()); + } + ++ if (TARGET_MIPS16 && TARGET_USE_GOT) ++ { ++ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS16_PIC_TEMP); ++ clobber_reg (&CALL_INSN_FUNCTION_USAGE (insn), MIPS_PROLOGUE_TEMP (word_mode)); ++ } ++ + if (TARGET_MIPS16 + && TARGET_EXPLICIT_RELOCS + && TARGET_CALL_CLOBBERED_GP) diff --git a/toolchain/gcc/patches-13.x/230-musl_libssp.patch b/toolchain/gcc/patches-13.x/230-musl_libssp.patch new file mode 100644 index 00000000000..3ce5e49587f --- /dev/null +++ b/toolchain/gcc/patches-13.x/230-musl_libssp.patch @@ -0,0 +1,13 @@ +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -985,7 +985,9 @@ proper position among the other output f + #endif + + #ifndef LINK_SSP_SPEC +-#ifdef TARGET_LIBC_PROVIDES_SSP ++#if DEFAULT_LIBC == LIBC_MUSL ++#define LINK_SSP_SPEC "-lssp_nonshared" ++#elif defined(TARGET_LIBC_PROVIDES_SSP) + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit:}" + #else diff --git a/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch new file mode 100644 index 00000000000..1d223f2a0f6 --- /dev/null +++ b/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch @@ -0,0 +1,21 @@ +commit ecf7671b769fe96f7b5134be442089f8bdba55d2 +Author: Felix Fietkau +Date: Thu Aug 4 20:29:45 2016 +0200 + +gcc: add a patch to generate better code with Os on mips + +Also happens to reduce compressed code size a bit + +Signed-off-by: Felix Fietkau + +--- a/gcc/config/mips/mips.cc ++++ b/gcc/config/mips/mips.cc +@@ -20216,7 +20216,7 @@ mips_option_override (void) + flag_pcc_struct_return = 0; + + /* Decide which rtx_costs structure to use. */ +- if (optimize_size) ++ if (0 && optimize_size) + mips_cost = &mips_rtx_cost_optimize_size; + else + mips_cost = &mips_rtx_cost_data[mips_tune]; diff --git a/toolchain/gcc/patches-13.x/810-arm-softfloat-libgcc.patch b/toolchain/gcc/patches-13.x/810-arm-softfloat-libgcc.patch new file mode 100644 index 00000000000..5c9d86aead7 --- /dev/null +++ b/toolchain/gcc/patches-13.x/810-arm-softfloat-libgcc.patch @@ -0,0 +1,33 @@ +commit 8570c4be394cff7282f332f97da2ff569a927ddb +Author: Imre Kaloz +Date: Wed Feb 2 20:06:12 2011 +0000 + + fixup arm soft-float symbols + + SVN-Revision: 25325 + +--- a/libgcc/config/arm/t-linux ++++ b/libgcc/config/arm/t-linux +@@ -1,6 +1,10 @@ + LIB1ASMSRC = arm/lib1funcs.S + LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \ +- _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 ++ _ctzsi2 _arm_addsubdf3 _arm_addsubsf3 \ ++ _arm_negdf2 _arm_muldivdf3 _arm_cmpdf2 _arm_unorddf2 \ ++ _arm_fixdfsi _arm_fixunsdfsi _arm_truncdfsf2 \ ++ _arm_negsf2 _arm_muldivsf3 _arm_cmpsf2 _arm_unordsf2 \ ++ _arm_fixsfsi _arm_fixunssfsi + + # Just for these, we omit the frame pointer since it makes such a big + # difference. +--- a/gcc/config/arm/linux-elf.h ++++ b/gcc/config/arm/linux-elf.h +@@ -58,8 +58,6 @@ + %{shared:-lc} \ + %{!shared:%{profile:-lc_p}%{!profile:-lc}}" + +-#define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc" +- + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" + + #define LINUX_TARGET_LINK_SPEC "%{h*} \ diff --git a/toolchain/gcc/patches-13.x/820-libgcc_pic.patch b/toolchain/gcc/patches-13.x/820-libgcc_pic.patch new file mode 100644 index 00000000000..525a95b5657 --- /dev/null +++ b/toolchain/gcc/patches-13.x/820-libgcc_pic.patch @@ -0,0 +1,44 @@ +commit c96312958c0621e72c9b32da5bc224ffe2161384 +Author: Felix Fietkau +Date: Mon Oct 19 23:26:09 2009 +0000 + + gcc: create a proper libgcc_pic.a static library for relinking (4.3.3+ for now, backport will follow) + + SVN-Revision: 18086 + +--- a/libgcc/Makefile.in ++++ b/libgcc/Makefile.in +@@ -930,11 +930,12 @@ $(libgcov-driver-objects): %$(objext): $ + + # Static libraries. + libgcc.a: $(libgcc-objects) ++libgcc_pic.a: $(libgcc-s-objects) + libgcov.a: $(libgcov-objects) + libunwind.a: $(libunwind-objects) + libgcc_eh.a: $(libgcc-eh-objects) + +-libgcc.a libgcov.a libunwind.a libgcc_eh.a: ++libgcc.a libgcov.a libunwind.a libgcc_eh.a libgcc_pic.a: + -rm -f $@ + + objects="$(objects)"; \ +@@ -958,7 +959,7 @@ all: libunwind.a + endif + + ifeq ($(enable_shared),yes) +-all: libgcc_eh.a libgcc_s$(SHLIB_EXT) ++all: libgcc_eh.a libgcc_pic.a libgcc_s$(SHLIB_EXT) + ifneq ($(LIBUNWIND),) + all: libunwind$(SHLIB_EXT) + libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +@@ -1164,6 +1165,10 @@ install-shared: + chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a + ++ $(INSTALL_DATA) libgcc_pic.a $(mapfile) $(DESTDIR)$(inst_libdir)/ ++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_pic.a ++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_pic.a ++ + $(subst @multilib_dir@,$(MULTIDIR),$(subst \ + @shlib_base_name@,libgcc_s,$(subst \ + @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) diff --git a/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch new file mode 100644 index 00000000000..e3cb616c4e4 --- /dev/null +++ b/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch @@ -0,0 +1,28 @@ +commit 7edc8ca5456d9743dd0075eb3cc5b04f4f24c8cc +Author: Imre Kaloz +Date: Wed Feb 2 19:34:36 2011 +0000 + + add armv4 fixup patches + + SVN-Revision: 25322 + + +--- a/gcc/config/arm/linux-eabi.h ++++ b/gcc/config/arm/linux-eabi.h +@@ -91,10 +91,15 @@ + #define MUSL_DYNAMIC_LINKER \ + "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" + ++/* For armv4 we pass --fix-v4bx to linker to support EABI */ ++#undef TARGET_FIX_V4BX_SPEC ++#define TARGET_FIX_V4BX_SPEC " %{mcpu=arm8|mcpu=arm810|mcpu=strongarm*"\ ++ "|march=armv4|mcpu=fa526|mcpu=fa626:--fix-v4bx}" ++ + /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to + use the GNU/Linux version, not the generic BPABI version. */ + #undef LINK_SPEC +-#define LINK_SPEC EABI_LINK_SPEC \ ++#define LINK_SPEC EABI_LINK_SPEC TARGET_FIX_V4BX_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \ + LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) + diff --git a/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch b/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch new file mode 100644 index 00000000000..7be30f32831 --- /dev/null +++ b/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch @@ -0,0 +1,54 @@ +commit dcfc40358b5a3cae7320c17f8d1cebd5ad5540cd +Author: Felix Fietkau +Date: Sun Feb 12 20:25:47 2012 +0000 + + gcc 4.6: port over the missing patch 850-use_shared_libgcc.patch to prevent libgcc crap from leaking into every single binary + + SVN-Revision: 30486 +--- a/gcc/config/arm/linux-eabi.h ++++ b/gcc/config/arm/linux-eabi.h +@@ -132,10 +132,6 @@ + "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} " \ + LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) + +-/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we +- do not use -lfloat. */ +-#undef LIBGCC_SPEC +- + /* Clear the instruction cache from `beg' to `end'. This is + implemented in lib1funcs.S, so ensure an error if this definition + is used. */ +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -71,6 +71,10 @@ see the files COPYING3 and COPYING.RUNTI + builtin_version ("CRuntime_Musl"); \ + } while (0) + ++#ifndef LIBGCC_SPEC ++#define LIBGCC_SPEC "%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:-lgcc_s}}" ++#endif ++ + /* Determine which dynamic linker to use depending on whether GLIBC or + uClibc or Bionic or musl is the default C library and whether + -muclibc or -mglibc or -mbionic or -mmusl has been passed to change +--- a/libgcc/mkmap-symver.awk ++++ b/libgcc/mkmap-symver.awk +@@ -136,5 +136,5 @@ function output(lib) { + else if (inherit[lib]) + printf("} %s;\n", inherit[lib]); + else +- printf ("\n local:\n\t*;\n};\n"); ++ printf ("\n\t*;\n};\n"); + } +--- a/gcc/config/rs6000/linux.h ++++ b/gcc/config/rs6000/linux.h +@@ -67,6 +67,9 @@ + #undef CPP_OS_DEFAULT_SPEC + #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)" + ++#undef LIBGCC_SPEC ++#define LIBGCC_SPEC "%{!static:%{!static-libgcc:-lgcc_s}} -lgcc" ++ + #undef LINK_SHLIB_SPEC + #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}} \ + %{static-pie:-static -pie --no-dynamic-linker -z text}" diff --git a/toolchain/gcc/patches-13.x/851-libgcc_no_compat.patch b/toolchain/gcc/patches-13.x/851-libgcc_no_compat.patch new file mode 100644 index 00000000000..d710e407174 --- /dev/null +++ b/toolchain/gcc/patches-13.x/851-libgcc_no_compat.patch @@ -0,0 +1,22 @@ +commit 64661de100da1ec1061ef3e5e400285dce115e6b +Author: Felix Fietkau +Date: Sun May 10 13:16:35 2015 +0000 + + gcc: add some size optimization patches + + Signed-off-by: Felix Fietkau + + SVN-Revision: 45664 + +--- a/libgcc/config/t-libunwind ++++ b/libgcc/config/t-libunwind +@@ -2,8 +2,7 @@ + + HOST_LIBGCC2_CFLAGS += -DUSE_GAS_SYMVER + +-LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c \ +- $(srcdir)/unwind-compat.c $(srcdir)/unwind-dw2-fde-compat.c ++LIB2ADDEH = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c + LIB2ADDEHSTATIC = $(srcdir)/unwind-sjlj.c $(srcdir)/unwind-c.c + + # Override the default value from t-slibgcc-elf-ver and mention -lunwind diff --git a/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch new file mode 100644 index 00000000000..e51079dc13c --- /dev/null +++ b/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch @@ -0,0 +1,11 @@ +--- a/gcc/config/rs6000/rs6000-logue.cc ++++ b/gcc/config/rs6000/rs6000-logue.cc +@@ -348,7 +348,7 @@ rs6000_savres_strategy (rs6000_stack_t * + /* Define cutoff for using out-of-line functions to save registers. */ + if (DEFAULT_ABI == ABI_V4 || TARGET_ELF) + { +- if (!optimize_size) ++ if (1) + { + strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS; + strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS; diff --git a/toolchain/gcc/patches-13.x/881-no_tm_section.patch b/toolchain/gcc/patches-13.x/881-no_tm_section.patch new file mode 100644 index 00000000000..2029910fd07 --- /dev/null +++ b/toolchain/gcc/patches-13.x/881-no_tm_section.patch @@ -0,0 +1,11 @@ +--- a/libgcc/crtstuff.c ++++ b/libgcc/crtstuff.c +@@ -152,7 +152,7 @@ call_ ## FUNC (void) \ + #endif + + #if !defined(USE_TM_CLONE_REGISTRY) && defined(OBJECT_FORMAT_ELF) +-# define USE_TM_CLONE_REGISTRY 1 ++# define USE_TM_CLONE_REGISTRY 0 + #elif !defined(USE_TM_CLONE_REGISTRY) + # define USE_TM_CLONE_REGISTRY 0 + #endif diff --git a/toolchain/gcc/patches-13.x/900-bad-mips16-crt.patch b/toolchain/gcc/patches-13.x/900-bad-mips16-crt.patch new file mode 100644 index 00000000000..dd6e9dc889a --- /dev/null +++ b/toolchain/gcc/patches-13.x/900-bad-mips16-crt.patch @@ -0,0 +1,9 @@ +--- a/libgcc/config/mips/t-mips16 ++++ b/libgcc/config/mips/t-mips16 +@@ -43,3 +43,6 @@ SYNC_CFLAGS = -mno-mips16 + + # Version these symbols if building libgcc.so. + SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips16.ver ++ ++CRTSTUFF_T_CFLAGS += -mno-mips16 ++CRTSTUFF_T_CFLAGS_S += -mno-mips16 diff --git a/toolchain/gcc/patches-13.x/910-mbsd_multi.patch b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch new file mode 100644 index 00000000000..4033c5b23bc --- /dev/null +++ b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch @@ -0,0 +1,146 @@ +commit 99368862e44740ff4fd33760893f04e14f9dbdf1 +Author: Felix Fietkau +Date: Tue Jul 31 00:52:27 2007 +0000 + + Port the mbsd_multi patch from freewrt, which adds -fhonour-copts. This will emit warnings in packages that don't use our target cflags properly + + SVN-Revision: 8256 + + This patch brings over a feature from MirBSD: + * -fhonour-copts + If this option is not given, it's warned (depending + on environment variables). This is to catch errors + of misbuilt packages which override CFLAGS themselves. + + This patch was authored by Thorsten Glaser + with copyright assignment to the FSF in effect. + +--- a/gcc/c-family/c-opts.cc ++++ b/gcc/c-family/c-opts.cc +@@ -107,6 +107,9 @@ static dump_flags_t original_dump_flags; + /* Whether any standard preincluded header has been preincluded. */ + static bool done_preinclude; + ++/* Check if a port honours COPTS. */ ++static int honour_copts = 0; ++ + static void handle_OPT_d (const char *); + static void set_std_cxx98 (int); + static void set_std_cxx11 (int); +@@ -478,6 +481,12 @@ c_common_handle_option (size_t scode, co + flag_no_builtin = !value; + break; + ++ case OPT_fhonour_copts: ++ if (c_language == clk_c) { ++ honour_copts++; ++ } ++ break; ++ + case OPT_fconstant_string_class_: + constant_string_class_name = arg; + break; +@@ -1218,6 +1227,47 @@ c_common_init (void) + return false; + } + ++ if (c_language == clk_c) { ++ char *ev = getenv ("GCC_HONOUR_COPTS"); ++ int evv; ++ if (ev == NULL) ++ evv = -1; ++ else if ((*ev == '0') || (*ev == '\0')) ++ evv = 0; ++ else if (*ev == '1') ++ evv = 1; ++ else if (*ev == '2') ++ evv = 2; ++ else if (*ev == 's') ++ evv = -1; ++ else { ++ warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1"); ++ evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */ ++ } ++ if (evv == 1) { ++ if (honour_copts == 0) { ++ error ("someone does not honour COPTS at all in lenient mode"); ++ return false; ++ } else if (honour_copts != 1) { ++ warning (0, "someone does not honour COPTS correctly, passed %d times", ++ honour_copts); ++ } ++ } else if (evv == 2) { ++ if (honour_copts == 0) { ++ error ("someone does not honour COPTS at all in strict mode"); ++ return false; ++ } else if (honour_copts != 1) { ++ error ("someone does not honour COPTS correctly, passed %d times", ++ honour_copts); ++ return false; ++ } ++ } else if (evv == 0) { ++ if (honour_copts != 1) ++ inform (UNKNOWN_LOCATION, "someone does not honour COPTS correctly, passed %d times", ++ honour_copts); ++ } ++ } ++ + return true; + } + +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -1755,6 +1755,9 @@ C++ ObjC++ Optimization Alias(fexception + fhonor-std + C++ ObjC++ WarnRemoved + ++fhonour-copts ++C ObjC C++ ObjC++ RejectNegative ++ + fhosted + C ObjC + Assume normal C execution environment. +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -1770,6 +1770,9 @@ fharden-conditional-branches + Common Var(flag_harden_conditional_branches) Optimization + Harden conditional branches by checking reversed conditions. + ++fhonour-copts ++Common RejectNegative ++ + ; Nonzero means ignore `#ident' directives. 0 means handle them. + ; Generate position-independent code for executables if possible + ; On SVR4 targets, it also controls whether or not to emit a +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -9596,6 +9596,17 @@ This option is only supported for C and + @option{-Wall} and by @option{-Wpedantic}, which can be disabled with + @option{-Wno-pointer-sign}. + ++@item -fhonour-copts ++@opindex fhonour-copts ++If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not ++given at least once, and warn if it is given more than once. ++If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not ++given exactly once. ++If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option ++is not given exactly once. ++The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}. ++This flag and environment variable only affect the C language. ++ + @item -Wstack-protector + @opindex Wstack-protector + @opindex Wno-stack-protector +--- a/gcc/opts.cc ++++ b/gcc/opts.cc +@@ -2692,6 +2692,9 @@ common_handle_option (struct gcc_options + add_comma_separated_to_vector (&opts->x_flag_ignored_attributes, arg); + break; + ++ case OPT_fhonour_copts: ++ break; ++ + case OPT_Werror: + dc->warning_as_error_requested = value; + break; diff --git a/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch new file mode 100644 index 00000000000..0f7d40b244d --- /dev/null +++ b/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch @@ -0,0 +1,22 @@ +Author: Jo-Philipp Wich +Date: Sat Apr 21 03:02:39 2012 +0000 + + gcc: add patch to make the getenv() spec function nonfatal if requested environment variable is unset + + SVN-Revision: 31390 + +--- a/gcc/gcc.cc ++++ b/gcc/gcc.cc +@@ -10213,8 +10213,10 @@ getenv_spec_function (int argc, const ch + } + + if (!value) +- fatal_error (input_location, +- "environment variable %qs not defined", varname); ++ { ++ warning (input_location, "environment variable %qs not defined", varname); ++ value = ""; ++ } + + /* We have to escape every character of the environment variable so + they are not interpreted as active spec characters. A diff --git a/toolchain/gcc/patches-13.x/960-gotools-fix-compilation-when-making-cross-compiler.patch b/toolchain/gcc/patches-13.x/960-gotools-fix-compilation-when-making-cross-compiler.patch new file mode 100644 index 00000000000..b1d7576328f --- /dev/null +++ b/toolchain/gcc/patches-13.x/960-gotools-fix-compilation-when-making-cross-compiler.patch @@ -0,0 +1,67 @@ +From dda6b050cd74a352670787a294596a9c56c21327 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Fri, 4 May 2018 18:20:53 +0800 +Subject: [PATCH] gotools: fix compilation when making cross compiler + +libgo is "the runtime support library for the Go programming language. +This library is intended for use with the Go frontend." + +gccgo will link target files with libgo.so which depends on libgcc_s.so.1, but +the linker will complain that it cannot find it. That's because shared libgcc +is not present in the install directory yet. libgo.so was made without problem +because gcc will emit -lgcc_s when compiled with -shared option. When gotools +were being made, it was supplied with -static-libgcc thus no link option was +provided. Check LIBGO in gcc/go/gcc-spec.c for how gccgo make a builtin spec +for linking with libgo.so + +- GccgoCrossCompilation, https://github.com/golang/go/wiki/GccgoCrossCompilation +- Cross-building instructions, http://www.eglibc.org/archives/patches/msg00078.html + +When 3-pass GCC compilation is used, shared libgcc runtime libraries will be +available after gcc pass2 completed and will meet the gotools link requirement +at gcc pass3 +--- + gotools/Makefile.am | 4 +++- + gotools/Makefile.in | 4 +++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +--- a/gotools/Makefile.am ++++ b/gotools/Makefile.am +@@ -26,6 +26,7 @@ PWD_COMMAND = $${PWDCMD-pwd} + STAMP = echo timestamp > + + libgodir = ../$(target_noncanonical)/libgo ++libgccdir = ../$(target_noncanonical)/libgcc + LIBGODEP = $(libgodir)/libgo.la + + LIBGOTOOL = $(libgodir)/libgotool.a +@@ -41,7 +42,8 @@ GOCFLAGS = $(CFLAGS_FOR_TARGET) + GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS) + + AM_GOCFLAGS = -I $(libgodir) +-AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs ++AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \ ++ -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s + GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@ + + libgosrcdir = $(srcdir)/../libgo/go +--- a/gotools/Makefile.in ++++ b/gotools/Makefile.in +@@ -337,6 +337,7 @@ mkinstalldirs = $(SHELL) $(toplevel_srcd + PWD_COMMAND = $${PWDCMD-pwd} + STAMP = echo timestamp > + libgodir = ../$(target_noncanonical)/libgo ++libgccdir = ../$(target_noncanonical)/libgcc + LIBGODEP = $(libgodir)/libgo.la + LIBGOTOOL = $(libgodir)/libgotool.a + @NATIVE_FALSE@GOCOMPILER = $(GOC) +@@ -346,7 +347,8 @@ LIBGOTOOL = $(libgodir)/libgotool.a + GOCFLAGS = $(CFLAGS_FOR_TARGET) + GOCOMPILE = $(GOCOMPILER) $(GOCFLAGS) + AM_GOCFLAGS = -I $(libgodir) +-AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs ++AM_LDFLAGS = -L $(libgodir) -L $(libgodir)/.libs \ ++ -L $(libgccdir) -L $(libgccdir)/.libs -lgcc_s + GOLINK = $(GOCOMPILER) $(GOCFLAGS) $(AM_GOCFLAGS) $(LDFLAGS) $(AM_LDFLAGS) -o $@ + libgosrcdir = $(srcdir)/../libgo/go + cmdsrcdir = $(libgosrcdir)/cmd diff --git a/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch b/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch new file mode 100644 index 00000000000..86fa68e1b10 --- /dev/null +++ b/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch @@ -0,0 +1,45 @@ +commit 9c6e71079b46ad5433165feaa2001450f2017b56 +Author: Przemysław Buczkowski +Date: Mon Aug 16 13:16:21 2021 +0100 + + GCC: Patch for Apple Silicon compatibility + + This patch fixes a linker error occuring when compiling + the cross-compiler on macOS and ARM64 architecture. + + Adapted from: + https://github.com/richfelker/musl-cross-make/issues/116#issuecomment-823612404 + + Change-Id: Ia3ee98a163bbb62689f42e2da83a5ef36beb0913 + Reviewed-on: https://review.haiku-os.org/c/buildtools/+/4329 + Reviewed-by: John Scipione + Reviewed-by: Adrien Destugues + +--- a/gcc/config/aarch64/aarch64.h ++++ b/gcc/config/aarch64/aarch64.h +@@ -1290,7 +1290,7 @@ extern const char *aarch64_rewrite_mcpu + #define MCPU_TO_MARCH_SPEC_FUNCTIONS \ + { "rewrite_mcpu", aarch64_rewrite_mcpu }, + +-#if defined(__aarch64__) ++#if defined(__aarch64__) && ! defined(__APPLE__) + extern const char *host_detect_local_cpu (int argc, const char **argv); + #define HAVE_LOCAL_CPU_DETECT + # define EXTRA_SPEC_FUNCTIONS \ +--- a/gcc/config/host-darwin.cc ++++ b/gcc/config/host-darwin.cc +@@ -23,6 +23,8 @@ + #include "options.h" + #include "diagnostic-core.h" + #include "config/host-darwin.h" ++#include "hosthooks.h" ++#include "hosthooks-def.h" + #include + + /* For Darwin (macOS only) platforms, without ASLR (PIE) enabled on the +@@ -181,3 +183,5 @@ darwin_gt_pch_use_address (void *&addr, + + return 1; + } ++ ++const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; From 29128b0bd43532404d965d22338554fce624db6a Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 27 Apr 2023 23:03:14 +0200 Subject: [PATCH 084/113] toolchain: gcc: add support for GCC 13 Release Notes: https://gcc.gnu.org/pipermail/gcc-announce/2023/000175.html Manually Refreshed: - 910-mbsd_multi.patch - 970-macos_arm64-building-fix.patch Automatically Refreshed: - 010-documentation.patch - 230-musl_libssp.patch - 300-mips_Os_cpu_rtx_cost_model.patch - 820-libgcc_pic.patch - 840-armv4_pass_fix-v4bx_to_ld.patch - 850-use_shared_libgcc.patch - 870-ppc_no_crtsavres.patch - 920-specs_nonfatal_getenv.patch Signed-off-by: Nick Hainke --- toolchain/gcc/Config.in | 3 +++ toolchain/gcc/Config.version | 5 +++++ toolchain/gcc/common.mk | 10 +++++++--- .../gcc/patches-13.x/010-documentation.patch | 2 +- toolchain/gcc/patches-13.x/230-musl_libssp.patch | 2 +- .../300-mips_Os_cpu_rtx_cost_model.patch | 2 +- toolchain/gcc/patches-13.x/820-libgcc_pic.patch | 6 +++--- .../840-armv4_pass_fix-v4bx_to_ld.patch | 2 +- .../gcc/patches-13.x/850-use_shared_libgcc.patch | 8 ++++---- .../gcc/patches-13.x/870-ppc_no_crtsavres.patch | 2 +- toolchain/gcc/patches-13.x/910-mbsd_multi.patch | 16 ++++++++-------- .../patches-13.x/920-specs_nonfatal_getenv.patch | 2 +- .../970-macos_arm64-building-fix.patch | 8 ++++---- 13 files changed, 40 insertions(+), 28 deletions(-) diff --git a/toolchain/gcc/Config.in b/toolchain/gcc/Config.in index d150c9cc4ba..9156f9c2635 100644 --- a/toolchain/gcc/Config.in +++ b/toolchain/gcc/Config.in @@ -11,6 +11,9 @@ choice config GCC_USE_VERSION_12 bool "gcc 12.x" + + config GCC_USE_VERSION_13 + bool "gcc 13.x" endchoice config GCC_USE_GRAPHITE diff --git a/toolchain/gcc/Config.version b/toolchain/gcc/Config.version index 7d4bedfbe99..1c1b0a04a10 100644 --- a/toolchain/gcc/Config.version +++ b/toolchain/gcc/Config.version @@ -2,7 +2,12 @@ config GCC_VERSION_11 default y if GCC_USE_VERSION_11 bool +config GCC_VERSION_13 + default y if GCC_USE_VERSION_13 + bool + config GCC_VERSION string default "11.3.0" if GCC_VERSION_11 + default "13.1.0" if GCC_VERSION_13 default "12.2.0" diff --git a/toolchain/gcc/common.mk b/toolchain/gcc/common.mk index 25f7e1ef702..ebe4b484cfd 100644 --- a/toolchain/gcc/common.mk +++ b/toolchain/gcc/common.mk @@ -37,6 +37,10 @@ ifeq ($(PKG_VERSION),12.2.0) PKG_HASH:=e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff endif +ifeq ($(PKG_VERSION),13.1.0) + PKG_HASH:=61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86 +endif + PATCH_DIR=../patches-$(GCC_MAJOR_VERSION).x BUGURL=http://bugs.openwrt.org/ @@ -187,10 +191,10 @@ define Host/SetToolchainInfo endef -ifeq ($(GCC_MAJOR_VERSION),12) - GCC_VERSION_FILE:=gcc/genversion.cc -else +ifeq ($(GCC_MAJOR_VERSION),11) GCC_VERSION_FILE:=gcc/version.c +else + GCC_VERSION_FILE:=gcc/genversion.cc endif ifneq ($(GCC_PREPARE),) diff --git a/toolchain/gcc/patches-13.x/010-documentation.patch b/toolchain/gcc/patches-13.x/010-documentation.patch index 39ee48ed67c..9646568afeb 100644 --- a/toolchain/gcc/patches-13.x/010-documentation.patch +++ b/toolchain/gcc/patches-13.x/010-documentation.patch @@ -12,7 +12,7 @@ Date: Tue Feb 26 16:16:33 2013 +0000 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in -@@ -3366,18 +3366,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) +@@ -3397,18 +3397,10 @@ doc/gcc.info: $(TEXI_GCC_FILES) doc/gccint.info: $(TEXI_GCCINT_FILES) doc/cppinternals.info: $(TEXI_CPPINT_FILES) diff --git a/toolchain/gcc/patches-13.x/230-musl_libssp.patch b/toolchain/gcc/patches-13.x/230-musl_libssp.patch index 3ce5e49587f..fee068e1d60 100644 --- a/toolchain/gcc/patches-13.x/230-musl_libssp.patch +++ b/toolchain/gcc/patches-13.x/230-musl_libssp.patch @@ -1,6 +1,6 @@ --- a/gcc/gcc.cc +++ b/gcc/gcc.cc -@@ -985,7 +985,9 @@ proper position among the other output f +@@ -972,7 +972,9 @@ proper position among the other output f #endif #ifndef LINK_SSP_SPEC diff --git a/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch b/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch index 1d223f2a0f6..ce21e0433d1 100644 --- a/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch +++ b/toolchain/gcc/patches-13.x/300-mips_Os_cpu_rtx_cost_model.patch @@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc -@@ -20216,7 +20216,7 @@ mips_option_override (void) +@@ -20213,7 +20213,7 @@ mips_option_override (void) flag_pcc_struct_return = 0; /* Decide which rtx_costs structure to use. */ diff --git a/toolchain/gcc/patches-13.x/820-libgcc_pic.patch b/toolchain/gcc/patches-13.x/820-libgcc_pic.patch index 525a95b5657..7d102981904 100644 --- a/toolchain/gcc/patches-13.x/820-libgcc_pic.patch +++ b/toolchain/gcc/patches-13.x/820-libgcc_pic.patch @@ -8,7 +8,7 @@ Date: Mon Oct 19 23:26:09 2009 +0000 --- a/libgcc/Makefile.in +++ b/libgcc/Makefile.in -@@ -930,11 +930,12 @@ $(libgcov-driver-objects): %$(objext): $ +@@ -933,11 +933,12 @@ $(libgcov-driver-objects): %$(objext): $ # Static libraries. libgcc.a: $(libgcc-objects) @@ -22,7 +22,7 @@ Date: Mon Oct 19 23:26:09 2009 +0000 -rm -f $@ objects="$(objects)"; \ -@@ -958,7 +959,7 @@ all: libunwind.a +@@ -961,7 +962,7 @@ all: libunwind.a endif ifeq ($(enable_shared),yes) @@ -31,7 +31,7 @@ Date: Mon Oct 19 23:26:09 2009 +0000 ifneq ($(LIBUNWIND),) all: libunwind$(SHLIB_EXT) libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) -@@ -1164,6 +1165,10 @@ install-shared: +@@ -1167,6 +1168,10 @@ install-shared: chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a diff --git a/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch b/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch index e3cb616c4e4..82935f3d1d0 100644 --- a/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch +++ b/toolchain/gcc/patches-13.x/840-armv4_pass_fix-v4bx_to_ld.patch @@ -9,7 +9,7 @@ Date: Wed Feb 2 19:34:36 2011 +0000 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h -@@ -91,10 +91,15 @@ +@@ -88,10 +88,15 @@ #define MUSL_DYNAMIC_LINKER \ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" diff --git a/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch b/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch index 7be30f32831..f4505ee70ff 100644 --- a/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch +++ b/toolchain/gcc/patches-13.x/850-use_shared_libgcc.patch @@ -7,8 +7,8 @@ Date: Sun Feb 12 20:25:47 2012 +0000 SVN-Revision: 30486 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h -@@ -132,10 +132,6 @@ - "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} " \ +@@ -129,10 +129,6 @@ + "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} " \ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) -/* Use the default LIBGCC_SPEC, not the version in linux-elf.h, as we @@ -20,8 +20,8 @@ Date: Sun Feb 12 20:25:47 2012 +0000 is used. */ --- a/gcc/config/linux.h +++ b/gcc/config/linux.h -@@ -71,6 +71,10 @@ see the files COPYING3 and COPYING.RUNTI - builtin_version ("CRuntime_Musl"); \ +@@ -58,6 +58,10 @@ see the files COPYING3 and COPYING.RUNTI + builtin_assert ("system=posix"); \ } while (0) +#ifndef LIBGCC_SPEC diff --git a/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch b/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch index e51079dc13c..0dca68899eb 100644 --- a/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch +++ b/toolchain/gcc/patches-13.x/870-ppc_no_crtsavres.patch @@ -1,6 +1,6 @@ --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc -@@ -348,7 +348,7 @@ rs6000_savres_strategy (rs6000_stack_t * +@@ -344,7 +344,7 @@ rs6000_savres_strategy (rs6000_stack_t * /* Define cutoff for using out-of-line functions to save registers. */ if (DEFAULT_ABI == ABI_V4 || TARGET_ELF) { diff --git a/toolchain/gcc/patches-13.x/910-mbsd_multi.patch b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch index 4033c5b23bc..095fc62f69e 100644 --- a/toolchain/gcc/patches-13.x/910-mbsd_multi.patch +++ b/toolchain/gcc/patches-13.x/910-mbsd_multi.patch @@ -17,7 +17,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc -@@ -107,6 +107,9 @@ static dump_flags_t original_dump_flags; +@@ -104,6 +104,9 @@ static size_t include_cursor; /* Whether any standard preincluded header has been preincluded. */ static bool done_preinclude; @@ -27,7 +27,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 static void handle_OPT_d (const char *); static void set_std_cxx98 (int); static void set_std_cxx11 (int); -@@ -478,6 +481,12 @@ c_common_handle_option (size_t scode, co +@@ -475,6 +478,12 @@ c_common_handle_option (size_t scode, co flag_no_builtin = !value; break; @@ -40,7 +40,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 case OPT_fconstant_string_class_: constant_string_class_name = arg; break; -@@ -1218,6 +1227,47 @@ c_common_init (void) +@@ -1228,6 +1237,47 @@ c_common_init (void) return false; } @@ -90,7 +90,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt -@@ -1755,6 +1755,9 @@ C++ ObjC++ Optimization Alias(fexception +@@ -1837,6 +1837,9 @@ C++ ObjC++ Optimization Alias(fexception fhonor-std C++ ObjC++ WarnRemoved @@ -102,7 +102,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 Assume normal C execution environment. --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -1770,6 +1770,9 @@ fharden-conditional-branches +@@ -1801,6 +1801,9 @@ fharden-conditional-branches Common Var(flag_harden_conditional_branches) Optimization Harden conditional branches by checking reversed conditions. @@ -114,7 +114,7 @@ Date: Tue Jul 31 00:52:27 2007 +0000 ; On SVR4 targets, it also controls whether or not to emit a --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -9596,6 +9596,17 @@ This option is only supported for C and +@@ -10061,6 +10061,17 @@ This option is only supported for C and @option{-Wall} and by @option{-Wpedantic}, which can be disabled with @option{-Wno-pointer-sign}. @@ -129,12 +129,12 @@ Date: Tue Jul 31 00:52:27 2007 +0000 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}. +This flag and environment variable only affect the C language. + - @item -Wstack-protector @opindex Wstack-protector @opindex Wno-stack-protector + @item -Wstack-protector --- a/gcc/opts.cc +++ b/gcc/opts.cc -@@ -2692,6 +2692,9 @@ common_handle_option (struct gcc_options +@@ -2767,6 +2767,9 @@ common_handle_option (struct gcc_options add_comma_separated_to_vector (&opts->x_flag_ignored_attributes, arg); break; diff --git a/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch b/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch index 0f7d40b244d..265ca22c0c3 100644 --- a/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch +++ b/toolchain/gcc/patches-13.x/920-specs_nonfatal_getenv.patch @@ -7,7 +7,7 @@ Date: Sat Apr 21 03:02:39 2012 +0000 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc -@@ -10213,8 +10213,10 @@ getenv_spec_function (int argc, const ch +@@ -10174,8 +10174,10 @@ getenv_spec_function (int argc, const ch } if (!value) diff --git a/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch b/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch index 86fa68e1b10..7844268e7e2 100644 --- a/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch +++ b/toolchain/gcc/patches-13.x/970-macos_arm64-building-fix.patch @@ -17,15 +17,15 @@ Date: Mon Aug 16 13:16:21 2021 +0100 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h -@@ -1290,7 +1290,7 @@ extern const char *aarch64_rewrite_mcpu - #define MCPU_TO_MARCH_SPEC_FUNCTIONS \ - { "rewrite_mcpu", aarch64_rewrite_mcpu }, +@@ -1185,7 +1185,7 @@ extern enum aarch64_code_model aarch64_c + /* Extra specs when building a native AArch64-hosted compiler. + Option rewriting rules based on host system. */ -#if defined(__aarch64__) +#if defined(__aarch64__) && ! defined(__APPLE__) extern const char *host_detect_local_cpu (int argc, const char **argv); #define HAVE_LOCAL_CPU_DETECT - # define EXTRA_SPEC_FUNCTIONS \ + # define EXTRA_SPEC_FUNCTIONS \ --- a/gcc/config/host-darwin.cc +++ b/gcc/config/host-darwin.cc @@ -23,6 +23,8 @@ From a6d689632c5326e4869937c0ff5f9c72f6190729 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Wed, 3 May 2023 16:46:52 +0200 Subject: [PATCH 085/113] toolchain: gcc: backport patch for gcc 13 fixing access path analysis While improving access path analysis a typo happened. Now it can happen that gcc misscompiles. The patch is fixing the issue. However, also other gcc versions 10.2+ are affected. They also should be bumped or the fix should be backported. For more bug information have a look at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109585 Signed-off-by: Nick Hainke --- ...imization-109585-alias-analysis-typo.patch | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch diff --git a/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch b/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch new file mode 100644 index 00000000000..7f73be43253 --- /dev/null +++ b/toolchain/gcc/patches-13.x/001-rtl-optimization-109585-alias-analysis-typo.patch @@ -0,0 +1,69 @@ +From bb406a6aea336966681927a27f54ee89c4fd4ea1 Mon Sep 17 00:00:00 2001 +From: Richard Biener +Date: Mon, 24 Apr 2023 13:31:07 +0200 +Subject: [PATCH] rtl-optimization/109585 - alias analysis typo + +When r10-514-gc6b84edb6110dd2b4fb improved access path analysis +it introduced a typo that triggers when there's an access to a +trailing array in the first access path leading to false +disambiguation. + + PR rtl-optimization/109585 + * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo. + + * gcc.dg/torture/pr109585.c: New testcase. + +(cherry picked from commit 6d4bd27a60447c7505cb4783e675e98a191a8904) +--- + gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++ + gcc/tree-ssa-alias.cc | 2 +- + 2 files changed, 34 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c + +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/torture/pr109585.c +@@ -0,0 +1,33 @@ ++/* { dg-do run } */ ++ ++#include ++ ++struct P { ++ long v; ++ struct P *n; ++}; ++ ++struct F { ++ long x; ++ struct P fam[]; ++}; ++ ++int __attribute__((noipa)) ++f(struct F *f, int i) ++{ ++ struct P *p = f->fam; ++ asm("" : "+r"(f): "r"(p)); ++ p->v = 0; ++ p->n = 0; ++ return f->fam->n != 0; ++} ++ ++int ++main() ++{ ++ struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P)); ++ m->fam[0].n = &m->fam[1]; ++ if (f (m, 0)) ++ abort (); ++ return 0; ++} +--- a/gcc/tree-ssa-alias.cc ++++ b/gcc/tree-ssa-alias.cc +@@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1, + /* If we didn't find a common base, try the other way around. */ + if (cmp_outer <= 0 + || (end_struct_ref1 +- && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0)) ++ && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0)) + { + int res = aliasing_component_refs_walk (ref2, type2, base2, + offset2, max_size2, From 638a10e1753f8041253e92a3cb5b82ac297f9c19 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 4 May 2023 09:07:13 +0200 Subject: [PATCH 086/113] generic: 5.15: add patch fixing compiling mvebu with gcc-13 Fixes errors in the form of: drivers/ata/libahci.c: In function 'ahci_led_store': ././include/linux/compiler_types.h:334:45: error: call to '__compiletime_assert_363' declared with attribute error: BUILD_BUG_ON failed: sizeof(_s) > sizeof(long) 334 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ ././include/linux/compiler_types.h:315:25: note: in definition of macro '__compiletime_assert' 315 | prefix ## suffix(); \ | ^~~~~~ ././include/linux/compiler_types.h:334:9: note: in expansion of macro '_compiletime_assert' 334 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) | ^~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG' 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) | ^~~~~~~~~~~~~~~~ ./include/linux/nospec.h:62:9: note: in expansion of macro 'BUILD_BUG_ON' 62 | BUILD_BUG_ON(sizeof(_s) > sizeof(long)); \ | ^~~~~~~~~~~~ drivers/ata/libahci.c:1143:23: note: in expansion of macro 'array_index_nospec' 1143 | pmp = array_index_nospec(pmp, EM_MAX_SLOTS); | ^~~~~~~~~~~~~~~~~~ Signed-off-by: Nick Hainke --- ...a-ahci-fix-enum-constants-for-gcc-13.patch | 348 ++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 target/linux/generic/backport-5.15/830-v6.2-ata-ahci-fix-enum-constants-for-gcc-13.patch diff --git a/target/linux/generic/backport-5.15/830-v6.2-ata-ahci-fix-enum-constants-for-gcc-13.patch b/target/linux/generic/backport-5.15/830-v6.2-ata-ahci-fix-enum-constants-for-gcc-13.patch new file mode 100644 index 00000000000..0d81d24e09c --- /dev/null +++ b/target/linux/generic/backport-5.15/830-v6.2-ata-ahci-fix-enum-constants-for-gcc-13.patch @@ -0,0 +1,348 @@ +From f07788079f515ca4a681c5f595bdad19cfbd7b1d Mon Sep 17 00:00:00 2001 +From: Arnd Bergmann +Date: Sat, 3 Dec 2022 11:54:25 +0100 +Subject: [PATCH] ata: ahci: fix enum constants for gcc-13 + +gcc-13 slightly changes the type of constant expressions that are defined +in an enum, which triggers a compile time sanity check in libata: + +linux/drivers/ata/libahci.c: In function 'ahci_led_store': +linux/include/linux/compiler_types.h:357:45: error: call to '__compiletime_assert_302' declared with attribute error: BUILD_BUG_ON failed: sizeof(_s) > sizeof(long) +357 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) + +The new behavior is that sizeof() returns the same value for the +constant as it does for the enum type, which is generally more sensible +and consistent. + +The problem in libata is that it contains a single enum definition for +lots of unrelated constants, some of which are large positive (unsigned) +integers like 0xffffffff, while others like (1<<31) are interpreted as +negative integers, and this forces the enum type to become 64 bit wide +even though most constants would still fit into a signed 32-bit 'int'. + +Fix this by changing the entire enum definition to use BIT(x) in place +of (1< +Cc: linux-ide@vger.kernel.org +Cc: Damien Le Moal +Cc: stable@vger.kernel.org +Cc: Randy Dunlap +Signed-off-by: Arnd Bergmann +Tested-by: Luis Machado +Signed-off-by: Damien Le Moal +--- + drivers/ata/ahci.h | 245 +++++++++++++++++++++++---------------------- + 1 file changed, 123 insertions(+), 122 deletions(-) + +--- a/drivers/ata/ahci.h ++++ b/drivers/ata/ahci.h +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + + /* Enclosure Management Control */ + #define EM_CTRL_MSG_TYPE 0x000f0000 +@@ -54,12 +55,12 @@ enum { + AHCI_PORT_PRIV_FBS_DMA_SZ = AHCI_CMD_SLOT_SZ + + AHCI_CMD_TBL_AR_SZ + + (AHCI_RX_FIS_SZ * 16), +- AHCI_IRQ_ON_SG = (1 << 31), +- AHCI_CMD_ATAPI = (1 << 5), +- AHCI_CMD_WRITE = (1 << 6), +- AHCI_CMD_PREFETCH = (1 << 7), +- AHCI_CMD_RESET = (1 << 8), +- AHCI_CMD_CLR_BUSY = (1 << 10), ++ AHCI_IRQ_ON_SG = BIT(31), ++ AHCI_CMD_ATAPI = BIT(5), ++ AHCI_CMD_WRITE = BIT(6), ++ AHCI_CMD_PREFETCH = BIT(7), ++ AHCI_CMD_RESET = BIT(8), ++ AHCI_CMD_CLR_BUSY = BIT(10), + + RX_FIS_PIO_SETUP = 0x20, /* offset of PIO Setup FIS data */ + RX_FIS_D2H_REG = 0x40, /* offset of D2H Register FIS data */ +@@ -77,37 +78,37 @@ enum { + HOST_CAP2 = 0x24, /* host capabilities, extended */ + + /* HOST_CTL bits */ +- HOST_RESET = (1 << 0), /* reset controller; self-clear */ +- HOST_IRQ_EN = (1 << 1), /* global IRQ enable */ +- HOST_MRSM = (1 << 2), /* MSI Revert to Single Message */ +- HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ ++ HOST_RESET = BIT(0), /* reset controller; self-clear */ ++ HOST_IRQ_EN = BIT(1), /* global IRQ enable */ ++ HOST_MRSM = BIT(2), /* MSI Revert to Single Message */ ++ HOST_AHCI_EN = BIT(31), /* AHCI enabled */ + + /* HOST_CAP bits */ +- HOST_CAP_SXS = (1 << 5), /* Supports External SATA */ +- HOST_CAP_EMS = (1 << 6), /* Enclosure Management support */ +- HOST_CAP_CCC = (1 << 7), /* Command Completion Coalescing */ +- HOST_CAP_PART = (1 << 13), /* Partial state capable */ +- HOST_CAP_SSC = (1 << 14), /* Slumber state capable */ +- HOST_CAP_PIO_MULTI = (1 << 15), /* PIO multiple DRQ support */ +- HOST_CAP_FBS = (1 << 16), /* FIS-based switching support */ +- HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ +- HOST_CAP_ONLY = (1 << 18), /* Supports AHCI mode only */ +- HOST_CAP_CLO = (1 << 24), /* Command List Override support */ +- HOST_CAP_LED = (1 << 25), /* Supports activity LED */ +- HOST_CAP_ALPM = (1 << 26), /* Aggressive Link PM support */ +- HOST_CAP_SSS = (1 << 27), /* Staggered Spin-up */ +- HOST_CAP_MPS = (1 << 28), /* Mechanical presence switch */ +- HOST_CAP_SNTF = (1 << 29), /* SNotification register */ +- HOST_CAP_NCQ = (1 << 30), /* Native Command Queueing */ +- HOST_CAP_64 = (1 << 31), /* PCI DAC (64-bit DMA) support */ ++ HOST_CAP_SXS = BIT(5), /* Supports External SATA */ ++ HOST_CAP_EMS = BIT(6), /* Enclosure Management support */ ++ HOST_CAP_CCC = BIT(7), /* Command Completion Coalescing */ ++ HOST_CAP_PART = BIT(13), /* Partial state capable */ ++ HOST_CAP_SSC = BIT(14), /* Slumber state capable */ ++ HOST_CAP_PIO_MULTI = BIT(15), /* PIO multiple DRQ support */ ++ HOST_CAP_FBS = BIT(16), /* FIS-based switching support */ ++ HOST_CAP_PMP = BIT(17), /* Port Multiplier support */ ++ HOST_CAP_ONLY = BIT(18), /* Supports AHCI mode only */ ++ HOST_CAP_CLO = BIT(24), /* Command List Override support */ ++ HOST_CAP_LED = BIT(25), /* Supports activity LED */ ++ HOST_CAP_ALPM = BIT(26), /* Aggressive Link PM support */ ++ HOST_CAP_SSS = BIT(27), /* Staggered Spin-up */ ++ HOST_CAP_MPS = BIT(28), /* Mechanical presence switch */ ++ HOST_CAP_SNTF = BIT(29), /* SNotification register */ ++ HOST_CAP_NCQ = BIT(30), /* Native Command Queueing */ ++ HOST_CAP_64 = BIT(31), /* PCI DAC (64-bit DMA) support */ + + /* HOST_CAP2 bits */ +- HOST_CAP2_BOH = (1 << 0), /* BIOS/OS handoff supported */ +- HOST_CAP2_NVMHCI = (1 << 1), /* NVMHCI supported */ +- HOST_CAP2_APST = (1 << 2), /* Automatic partial to slumber */ +- HOST_CAP2_SDS = (1 << 3), /* Support device sleep */ +- HOST_CAP2_SADM = (1 << 4), /* Support aggressive DevSlp */ +- HOST_CAP2_DESO = (1 << 5), /* DevSlp from slumber only */ ++ HOST_CAP2_BOH = BIT(0), /* BIOS/OS handoff supported */ ++ HOST_CAP2_NVMHCI = BIT(1), /* NVMHCI supported */ ++ HOST_CAP2_APST = BIT(2), /* Automatic partial to slumber */ ++ HOST_CAP2_SDS = BIT(3), /* Support device sleep */ ++ HOST_CAP2_SADM = BIT(4), /* Support aggressive DevSlp */ ++ HOST_CAP2_DESO = BIT(5), /* DevSlp from slumber only */ + + /* registers for each SATA port */ + PORT_LST_ADDR = 0x00, /* command list DMA addr */ +@@ -129,24 +130,24 @@ enum { + PORT_DEVSLP = 0x44, /* device sleep */ + + /* PORT_IRQ_{STAT,MASK} bits */ +- PORT_IRQ_COLD_PRES = (1 << 31), /* cold presence detect */ +- PORT_IRQ_TF_ERR = (1 << 30), /* task file error */ +- PORT_IRQ_HBUS_ERR = (1 << 29), /* host bus fatal error */ +- PORT_IRQ_HBUS_DATA_ERR = (1 << 28), /* host bus data error */ +- PORT_IRQ_IF_ERR = (1 << 27), /* interface fatal error */ +- PORT_IRQ_IF_NONFATAL = (1 << 26), /* interface non-fatal error */ +- PORT_IRQ_OVERFLOW = (1 << 24), /* xfer exhausted available S/G */ +- PORT_IRQ_BAD_PMP = (1 << 23), /* incorrect port multiplier */ +- +- PORT_IRQ_PHYRDY = (1 << 22), /* PhyRdy changed */ +- PORT_IRQ_DEV_ILCK = (1 << 7), /* device interlock */ +- PORT_IRQ_CONNECT = (1 << 6), /* port connect change status */ +- PORT_IRQ_SG_DONE = (1 << 5), /* descriptor processed */ +- PORT_IRQ_UNK_FIS = (1 << 4), /* unknown FIS rx'd */ +- PORT_IRQ_SDB_FIS = (1 << 3), /* Set Device Bits FIS rx'd */ +- PORT_IRQ_DMAS_FIS = (1 << 2), /* DMA Setup FIS rx'd */ +- PORT_IRQ_PIOS_FIS = (1 << 1), /* PIO Setup FIS rx'd */ +- PORT_IRQ_D2H_REG_FIS = (1 << 0), /* D2H Register FIS rx'd */ ++ PORT_IRQ_COLD_PRES = BIT(31), /* cold presence detect */ ++ PORT_IRQ_TF_ERR = BIT(30), /* task file error */ ++ PORT_IRQ_HBUS_ERR = BIT(29), /* host bus fatal error */ ++ PORT_IRQ_HBUS_DATA_ERR = BIT(28), /* host bus data error */ ++ PORT_IRQ_IF_ERR = BIT(27), /* interface fatal error */ ++ PORT_IRQ_IF_NONFATAL = BIT(26), /* interface non-fatal error */ ++ PORT_IRQ_OVERFLOW = BIT(24), /* xfer exhausted available S/G */ ++ PORT_IRQ_BAD_PMP = BIT(23), /* incorrect port multiplier */ ++ ++ PORT_IRQ_PHYRDY = BIT(22), /* PhyRdy changed */ ++ PORT_IRQ_DEV_ILCK = BIT(7), /* device interlock */ ++ PORT_IRQ_CONNECT = BIT(6), /* port connect change status */ ++ PORT_IRQ_SG_DONE = BIT(5), /* descriptor processed */ ++ PORT_IRQ_UNK_FIS = BIT(4), /* unknown FIS rx'd */ ++ PORT_IRQ_SDB_FIS = BIT(3), /* Set Device Bits FIS rx'd */ ++ PORT_IRQ_DMAS_FIS = BIT(2), /* DMA Setup FIS rx'd */ ++ PORT_IRQ_PIOS_FIS = BIT(1), /* PIO Setup FIS rx'd */ ++ PORT_IRQ_D2H_REG_FIS = BIT(0), /* D2H Register FIS rx'd */ + + PORT_IRQ_FREEZE = PORT_IRQ_HBUS_ERR | + PORT_IRQ_IF_ERR | +@@ -162,34 +163,34 @@ enum { + PORT_IRQ_PIOS_FIS | PORT_IRQ_D2H_REG_FIS, + + /* PORT_CMD bits */ +- PORT_CMD_ASP = (1 << 27), /* Aggressive Slumber/Partial */ +- PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ +- PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ +- PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */ +- PORT_CMD_ESP = (1 << 21), /* External Sata Port */ +- PORT_CMD_HPCP = (1 << 18), /* HotPlug Capable Port */ +- PORT_CMD_PMP = (1 << 17), /* PMP attached */ +- PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ +- PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ +- PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */ +- PORT_CMD_CLO = (1 << 3), /* Command list override */ +- PORT_CMD_POWER_ON = (1 << 2), /* Power up device */ +- PORT_CMD_SPIN_UP = (1 << 1), /* Spin up device */ +- PORT_CMD_START = (1 << 0), /* Enable port DMA engine */ +- +- PORT_CMD_ICC_MASK = (0xf << 28), /* i/f ICC state mask */ +- PORT_CMD_ICC_ACTIVE = (0x1 << 28), /* Put i/f in active state */ +- PORT_CMD_ICC_PARTIAL = (0x2 << 28), /* Put i/f in partial state */ +- PORT_CMD_ICC_SLUMBER = (0x6 << 28), /* Put i/f in slumber state */ ++ PORT_CMD_ASP = BIT(27), /* Aggressive Slumber/Partial */ ++ PORT_CMD_ALPE = BIT(26), /* Aggressive Link PM enable */ ++ PORT_CMD_ATAPI = BIT(24), /* Device is ATAPI */ ++ PORT_CMD_FBSCP = BIT(22), /* FBS Capable Port */ ++ PORT_CMD_ESP = BIT(21), /* External Sata Port */ ++ PORT_CMD_HPCP = BIT(18), /* HotPlug Capable Port */ ++ PORT_CMD_PMP = BIT(17), /* PMP attached */ ++ PORT_CMD_LIST_ON = BIT(15), /* cmd list DMA engine running */ ++ PORT_CMD_FIS_ON = BIT(14), /* FIS DMA engine running */ ++ PORT_CMD_FIS_RX = BIT(4), /* Enable FIS receive DMA engine */ ++ PORT_CMD_CLO = BIT(3), /* Command list override */ ++ PORT_CMD_POWER_ON = BIT(2), /* Power up device */ ++ PORT_CMD_SPIN_UP = BIT(1), /* Spin up device */ ++ PORT_CMD_START = BIT(0), /* Enable port DMA engine */ ++ ++ PORT_CMD_ICC_MASK = (0xfu << 28), /* i/f ICC state mask */ ++ PORT_CMD_ICC_ACTIVE = (0x1u << 28), /* Put i/f in active state */ ++ PORT_CMD_ICC_PARTIAL = (0x2u << 28), /* Put i/f in partial state */ ++ PORT_CMD_ICC_SLUMBER = (0x6u << 28), /* Put i/f in slumber state */ + + /* PORT_FBS bits */ + PORT_FBS_DWE_OFFSET = 16, /* FBS device with error offset */ + PORT_FBS_ADO_OFFSET = 12, /* FBS active dev optimization offset */ + PORT_FBS_DEV_OFFSET = 8, /* FBS device to issue offset */ + PORT_FBS_DEV_MASK = (0xf << PORT_FBS_DEV_OFFSET), /* FBS.DEV */ +- PORT_FBS_SDE = (1 << 2), /* FBS single device error */ +- PORT_FBS_DEC = (1 << 1), /* FBS device error clear */ +- PORT_FBS_EN = (1 << 0), /* Enable FBS */ ++ PORT_FBS_SDE = BIT(2), /* FBS single device error */ ++ PORT_FBS_DEC = BIT(1), /* FBS device error clear */ ++ PORT_FBS_EN = BIT(0), /* Enable FBS */ + + /* PORT_DEVSLP bits */ + PORT_DEVSLP_DM_OFFSET = 25, /* DITO multiplier offset */ +@@ -197,50 +198,50 @@ enum { + PORT_DEVSLP_DITO_OFFSET = 15, /* DITO offset */ + PORT_DEVSLP_MDAT_OFFSET = 10, /* Minimum assertion time */ + PORT_DEVSLP_DETO_OFFSET = 2, /* DevSlp exit timeout */ +- PORT_DEVSLP_DSP = (1 << 1), /* DevSlp present */ +- PORT_DEVSLP_ADSE = (1 << 0), /* Aggressive DevSlp enable */ ++ PORT_DEVSLP_DSP = BIT(1), /* DevSlp present */ ++ PORT_DEVSLP_ADSE = BIT(0), /* Aggressive DevSlp enable */ + + /* hpriv->flags bits */ + + #define AHCI_HFLAGS(flags) .private_data = (void *)(flags) + +- AHCI_HFLAG_NO_NCQ = (1 << 0), +- AHCI_HFLAG_IGN_IRQ_IF_ERR = (1 << 1), /* ignore IRQ_IF_ERR */ +- AHCI_HFLAG_IGN_SERR_INTERNAL = (1 << 2), /* ignore SERR_INTERNAL */ +- AHCI_HFLAG_32BIT_ONLY = (1 << 3), /* force 32bit */ +- AHCI_HFLAG_MV_PATA = (1 << 4), /* PATA port */ +- AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ +- AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ +- AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */ +- AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */ +- AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */ +- AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as ++ AHCI_HFLAG_NO_NCQ = BIT(0), ++ AHCI_HFLAG_IGN_IRQ_IF_ERR = BIT(1), /* ignore IRQ_IF_ERR */ ++ AHCI_HFLAG_IGN_SERR_INTERNAL = BIT(2), /* ignore SERR_INTERNAL */ ++ AHCI_HFLAG_32BIT_ONLY = BIT(3), /* force 32bit */ ++ AHCI_HFLAG_MV_PATA = BIT(4), /* PATA port */ ++ AHCI_HFLAG_NO_MSI = BIT(5), /* no PCI MSI */ ++ AHCI_HFLAG_NO_PMP = BIT(6), /* no PMP */ ++ AHCI_HFLAG_SECT255 = BIT(8), /* max 255 sectors */ ++ AHCI_HFLAG_YES_NCQ = BIT(9), /* force NCQ cap on */ ++ AHCI_HFLAG_NO_SUSPEND = BIT(10), /* don't suspend */ ++ AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = BIT(11), /* treat SRST timeout as + link offline */ +- AHCI_HFLAG_NO_SNTF = (1 << 12), /* no sntf */ +- AHCI_HFLAG_NO_FPDMA_AA = (1 << 13), /* no FPDMA AA */ +- AHCI_HFLAG_YES_FBS = (1 << 14), /* force FBS cap on */ +- AHCI_HFLAG_DELAY_ENGINE = (1 << 15), /* do not start engine on ++ AHCI_HFLAG_NO_SNTF = BIT(12), /* no sntf */ ++ AHCI_HFLAG_NO_FPDMA_AA = BIT(13), /* no FPDMA AA */ ++ AHCI_HFLAG_YES_FBS = BIT(14), /* force FBS cap on */ ++ AHCI_HFLAG_DELAY_ENGINE = BIT(15), /* do not start engine on + port start (wait until + error-handling stage) */ +- AHCI_HFLAG_NO_DEVSLP = (1 << 17), /* no device sleep */ +- AHCI_HFLAG_NO_FBS = (1 << 18), /* no FBS */ ++ AHCI_HFLAG_NO_DEVSLP = BIT(17), /* no device sleep */ ++ AHCI_HFLAG_NO_FBS = BIT(18), /* no FBS */ + + #ifdef CONFIG_PCI_MSI +- AHCI_HFLAG_MULTI_MSI = (1 << 20), /* per-port MSI(-X) */ ++ AHCI_HFLAG_MULTI_MSI = BIT(20), /* per-port MSI(-X) */ + #else + /* compile out MSI infrastructure */ + AHCI_HFLAG_MULTI_MSI = 0, + #endif +- AHCI_HFLAG_WAKE_BEFORE_STOP = (1 << 22), /* wake before DMA stop */ +- AHCI_HFLAG_YES_ALPM = (1 << 23), /* force ALPM cap on */ +- AHCI_HFLAG_NO_WRITE_TO_RO = (1 << 24), /* don't write to read ++ AHCI_HFLAG_WAKE_BEFORE_STOP = BIT(22), /* wake before DMA stop */ ++ AHCI_HFLAG_YES_ALPM = BIT(23), /* force ALPM cap on */ ++ AHCI_HFLAG_NO_WRITE_TO_RO = BIT(24), /* don't write to read + only registers */ +- AHCI_HFLAG_IS_MOBILE = (1 << 25), /* mobile chipset, use ++ AHCI_HFLAG_IS_MOBILE = BIT(25), /* mobile chipset, use + SATA_MOBILE_LPM_POLICY + as default lpm_policy */ +- AHCI_HFLAG_SUSPEND_PHYS = (1 << 26), /* handle PHYs during ++ AHCI_HFLAG_SUSPEND_PHYS = BIT(26), /* handle PHYs during + suspend/resume */ +- AHCI_HFLAG_NO_SXS = (1 << 28), /* SXS not supported */ ++ AHCI_HFLAG_NO_SXS = BIT(28), /* SXS not supported */ + + /* ap->flags bits */ + +@@ -256,22 +257,22 @@ enum { + EM_MAX_RETRY = 5, + + /* em_ctl bits */ +- EM_CTL_RST = (1 << 9), /* Reset */ +- EM_CTL_TM = (1 << 8), /* Transmit Message */ +- EM_CTL_MR = (1 << 0), /* Message Received */ +- EM_CTL_ALHD = (1 << 26), /* Activity LED */ +- EM_CTL_XMT = (1 << 25), /* Transmit Only */ +- EM_CTL_SMB = (1 << 24), /* Single Message Buffer */ +- EM_CTL_SGPIO = (1 << 19), /* SGPIO messages supported */ +- EM_CTL_SES = (1 << 18), /* SES-2 messages supported */ +- EM_CTL_SAFTE = (1 << 17), /* SAF-TE messages supported */ +- EM_CTL_LED = (1 << 16), /* LED messages supported */ ++ EM_CTL_RST = BIT(9), /* Reset */ ++ EM_CTL_TM = BIT(8), /* Transmit Message */ ++ EM_CTL_MR = BIT(0), /* Message Received */ ++ EM_CTL_ALHD = BIT(26), /* Activity LED */ ++ EM_CTL_XMT = BIT(25), /* Transmit Only */ ++ EM_CTL_SMB = BIT(24), /* Single Message Buffer */ ++ EM_CTL_SGPIO = BIT(19), /* SGPIO messages supported */ ++ EM_CTL_SES = BIT(18), /* SES-2 messages supported */ ++ EM_CTL_SAFTE = BIT(17), /* SAF-TE messages supported */ ++ EM_CTL_LED = BIT(16), /* LED messages supported */ + + /* em message type */ +- EM_MSG_TYPE_LED = (1 << 0), /* LED */ +- EM_MSG_TYPE_SAFTE = (1 << 1), /* SAF-TE */ +- EM_MSG_TYPE_SES2 = (1 << 2), /* SES-2 */ +- EM_MSG_TYPE_SGPIO = (1 << 3), /* SGPIO */ ++ EM_MSG_TYPE_LED = BIT(0), /* LED */ ++ EM_MSG_TYPE_SAFTE = BIT(1), /* SAF-TE */ ++ EM_MSG_TYPE_SES2 = BIT(2), /* SES-2 */ ++ EM_MSG_TYPE_SGPIO = BIT(3), /* SGPIO */ + }; + + struct ahci_cmd_hdr { From bbc7de3b164f43f44feff9ef8e72a2b475953eec Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Fri, 5 May 2023 14:50:13 +0200 Subject: [PATCH 087/113] generic: 5.15: remove outdated symbols Remove symbols that are no longer present in 5.15: - CONFIG_CRYPTO_RMD128 - CONFIG_CRYPTO_RMD256 - CONFIG_CRYPTO_RMD320 - CONFIG_CRYPTO_SALSA20 - CONFIG_CRYPTO_TGR192 - CONFIG_RAW_DRIVER - CONFIG_ENABLE_MUST_CHECK Signed-off-by: Nick Hainke --- target/linux/generic/config-5.15 | 8 -------- 1 file changed, 8 deletions(-) diff --git a/target/linux/generic/config-5.15 b/target/linux/generic/config-5.15 index 132f65c8068..aa1f6a5e35b 100644 --- a/target/linux/generic/config-5.15 +++ b/target/linux/generic/config-5.15 @@ -1220,14 +1220,9 @@ CONFIG_CRYPTO_PCRYPT=y # CONFIG_CRYPTO_POLY1305_MIPS is not set # CONFIG_CRYPTO_POLY1305_NEON is not set # CONFIG_CRYPTO_POLY1305_X86_64 is not set -# CONFIG_CRYPTO_RMD128 is not set # CONFIG_CRYPTO_RMD160 is not set -# CONFIG_CRYPTO_RMD256 is not set -# CONFIG_CRYPTO_RMD320 is not set # CONFIG_CRYPTO_RNG is not set # CONFIG_CRYPTO_RSA is not set -# CONFIG_CRYPTO_SALSA20 is not set -# CONFIG_CRYPTO_SALSA20_586 is not set # CONFIG_CRYPTO_SEED is not set # CONFIG_CRYPTO_SEQIV is not set # CONFIG_CRYPTO_SERPENT is not set @@ -1260,7 +1255,6 @@ CONFIG_CRYPTO_SKCIPHER2=y # CONFIG_CRYPTO_STREEBOG is not set # CONFIG_CRYPTO_TEA is not set # CONFIG_CRYPTO_TEST is not set -# CONFIG_CRYPTO_TGR192 is not set # CONFIG_CRYPTO_TWOFISH is not set # CONFIG_CRYPTO_TWOFISH_586 is not set # CONFIG_CRYPTO_TWOFISH_COMMON is not set @@ -1860,7 +1854,6 @@ CONFIG_ELFCORE=y # CONFIG_EMAC_ROCKCHIP is not set CONFIG_EMBEDDED=y # CONFIG_EM_TIMER_STI is not set -# CONFIG_ENABLE_MUST_CHECK is not set CONFIG_ENABLE_WARN_DEPRECATED=y # CONFIG_ENA_ETHERNET is not set # CONFIG_ENC28J60 is not set @@ -4950,7 +4943,6 @@ CONFIG_RANDOM_TRUST_BOOTLOADER=y CONFIG_RANDOM_TRUST_CPU=y # CONFIG_RAPIDIO is not set # CONFIG_RAS is not set -# CONFIG_RAW_DRIVER is not set # CONFIG_RBTREE_TEST is not set # CONFIG_RCU_BOOST is not set CONFIG_RCU_CPU_STALL_TIMEOUT=60 From ae417de437dd106bc0d8e7f08d57abd6853f1fd3 Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Thu, 4 May 2023 21:52:28 +0200 Subject: [PATCH 088/113] realtek: adapt patch description to it's current use The patch is not doing anymore what the descriptions says. Update it. Signed-off-by: Nick Hainke --- .../303-gpio-update-dependencies-for-gpio-realtek-otto.patch | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/linux/realtek/patches-5.10/303-gpio-update-dependencies-for-gpio-realtek-otto.patch b/target/linux/realtek/patches-5.10/303-gpio-update-dependencies-for-gpio-realtek-otto.patch index 5f0986b9051..1763d31fb0d 100644 --- a/target/linux/realtek/patches-5.10/303-gpio-update-dependencies-for-gpio-realtek-otto.patch +++ b/target/linux/realtek/patches-5.10/303-gpio-update-dependencies-for-gpio-realtek-otto.patch @@ -1,11 +1,10 @@ From 9bac1c20b8f39f2e0e342b087add5093b94feaed Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Wed, 5 May 2021 22:05:39 +0900 -Subject: realtek: backport gpio-realtek-otto driver from 5.13 to 5.10 +Subject: realtek: fix gpio-realtek-otto driver dependency -This patch backports "gpio-realtek-otto" driver to Kernel 5.10. "MACH_REALTEK_RTL" is used as a platform name in upstream, but "RTL838X" -is used in OpenWrt, so update the dependency by the additional patch. +is used in OpenWrt, so fix the dependency by renaming it. Submitted-by: INAGAKI Hiroshi --- From 15abf8d18b9cbfe133c66b610bbaeecf50d3842e Mon Sep 17 00:00:00 2001 From: Robert Marko Date: Fri, 5 May 2023 19:30:15 +0200 Subject: [PATCH 089/113] mac80211: ath11k: sync with ath-next Synchronize the ath11k backports with the current ath-next tree. This replaces the 160MHz with the upstreamed one, fixes 6GHz only WIPHY registration, allows SAR usage on WCN6750 and plenty of REO fixes. Signed-off-by: Robert Marko --- ...1k-Remove-redundant-pci_clear_master.patch | 58 +++++++ ...ble-Spectral-scan-upon-removing-inte.patch | 36 +++++ ...ath11k-enable-SAR-support-on-WCN6750.patch | 29 ++++ ...pci-Add-more-MODULE_FIRMWARE-entries.patch | 36 +++++ ...t-a-warning-when-crypto_alloc_shash-.patch | 34 +++++ ...re-frags-from-uninitialized-peer-in-.patch | 104 +++++++++++++ ...-undefined-behavior-with-__fls-in-dp.patch | 29 ++++ ...double-free-of-peer-rx_tid-during-re.patch | 144 ++++++++++++++++++ ...wifi-ath11k-Prevent-REO-cmd-failures.patch | 43 ++++++ ...peer-mac-information-in-failure-case.patch | 74 +++++++++ ...tx-status-reporting-in-encap-offload.patch | 119 +++++++++++++++ ...-incorrect-update-of-radiotap-fields.patch | 49 ++++++ ...SKB-corruption-in-REO-destination-ri.patch | 70 +++++++++ ...emove-disabling-of-80-80-and-160-MHz.patch | 49 ++++++ ...registration-of-6Ghz-only-phy-withou.patch | 61 ++++++++ ...emove-disabling-of-80-80-and-160-MHz.patch | 130 ---------------- 16 files changed, 935 insertions(+), 130 deletions(-) create mode 100644 package/kernel/mac80211/patches/ath11k/0055-wifi-ath11k-Remove-redundant-pci_clear_master.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0056-wifi-ath11k-Disable-Spectral-scan-upon-removing-inte.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0057-wifi-ath11k-enable-SAR-support-on-WCN6750.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0058-wifi-ath11k-pci-Add-more-MODULE_FIRMWARE-entries.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0059-wifi-ath11k-print-a-warning-when-crypto_alloc_shash-.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0060-wifi-ath11k-Ignore-frags-from-uninitialized-peer-in-.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0061-wifi-ath11k-fix-undefined-behavior-with-__fls-in-dp.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0062-wifi-ath11k-fix-double-free-of-peer-rx_tid-during-re.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0063-wifi-ath11k-Prevent-REO-cmd-failures.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0064-wifi-ath11k-add-peer-mac-information-in-failure-case.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0065-wifi-ath11k-fix-tx-status-reporting-in-encap-offload.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0066-wifi-ath11k-Fix-incorrect-update-of-radiotap-fields.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0067-wifi-ath11k-Fix-SKB-corruption-in-REO-destination-ri.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0068-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch create mode 100644 package/kernel/mac80211/patches/ath11k/0069-wifi-ath11k-fix-registration-of-6Ghz-only-phy-withou.patch delete mode 100644 package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch diff --git a/package/kernel/mac80211/patches/ath11k/0055-wifi-ath11k-Remove-redundant-pci_clear_master.patch b/package/kernel/mac80211/patches/ath11k/0055-wifi-ath11k-Remove-redundant-pci_clear_master.patch new file mode 100644 index 00000000000..0439727e72f --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0055-wifi-ath11k-Remove-redundant-pci_clear_master.patch @@ -0,0 +1,58 @@ +From f812e2a9f85d6bea78957ccb5197e4491316848b Mon Sep 17 00:00:00 2001 +From: Cai Huoqing +Date: Thu, 23 Mar 2023 19:26:09 +0800 +Subject: [PATCH] wifi: ath11k: Remove redundant pci_clear_master + +Remove pci_clear_master to simplify the code, +the bus-mastering is also cleared in do_pci_disable_device, +like this: +./drivers/pci/pci.c:2197 +static void do_pci_disable_device(struct pci_dev *dev) +{ + u16 pci_command; + + pci_read_config_word(dev, PCI_COMMAND, &pci_command); + if (pci_command & PCI_COMMAND_MASTER) { + pci_command &= ~PCI_COMMAND_MASTER; + pci_write_config_word(dev, PCI_COMMAND, pci_command); + } + + pcibios_disable_device(dev); +}. +And dev->is_busmaster is set to 0 in pci_disable_device. + +Signed-off-by: Cai Huoqing +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230323112613.7550-1-cai.huoqing@linux.dev +--- + drivers/net/wireless/ath/ath11k/pci.c | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -540,7 +540,7 @@ static int ath11k_pci_claim(struct ath11 + if (!ab->mem) { + ath11k_err(ab, "failed to map pci bar %d\n", ATH11K_PCI_BAR_NUM); + ret = -EIO; +- goto clear_master; ++ goto release_region; + } + + ab->mem_ce = ab->mem; +@@ -548,8 +548,6 @@ static int ath11k_pci_claim(struct ath11 + ath11k_dbg(ab, ATH11K_DBG_BOOT, "boot pci_mem 0x%pK\n", ab->mem); + return 0; + +-clear_master: +- pci_clear_master(pdev); + release_region: + pci_release_region(pdev, ATH11K_PCI_BAR_NUM); + disable_device: +@@ -565,7 +563,6 @@ static void ath11k_pci_free_region(struc + + pci_iounmap(pci_dev, ab->mem); + ab->mem = NULL; +- pci_clear_master(pci_dev); + pci_release_region(pci_dev, ATH11K_PCI_BAR_NUM); + if (pci_is_enabled(pci_dev)) + pci_disable_device(pci_dev); diff --git a/package/kernel/mac80211/patches/ath11k/0056-wifi-ath11k-Disable-Spectral-scan-upon-removing-inte.patch b/package/kernel/mac80211/patches/ath11k/0056-wifi-ath11k-Disable-Spectral-scan-upon-removing-inte.patch new file mode 100644 index 00000000000..44532a4d720 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0056-wifi-ath11k-Disable-Spectral-scan-upon-removing-inte.patch @@ -0,0 +1,36 @@ +From 5c690db63b45c6c4c4932b13173af71df369dba5 Mon Sep 17 00:00:00 2001 +From: Tamizh Chelvam Raja +Date: Tue, 28 Mar 2023 12:41:50 +0530 +Subject: [PATCH] wifi: ath11k: Disable Spectral scan upon removing interface + +Host might receive spectral events during interface +down sequence and this might create below errors. + +failed to handle dma buf release event -22 +failed to handle dma buf release event -22 + +Fix this by disabling spectral config during remove interface. + +Tested-on: IPQ5018 hw1.0 AHB WLAN.HK.2.6.0.1-00861-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Tamizh Chelvam Raja +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230328071150.29645-1-quic_tamizhr@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -6685,6 +6685,11 @@ static void ath11k_mac_op_remove_interfa + ath11k_dbg(ab, ATH11K_DBG_MAC, "mac remove interface (vdev %d)\n", + arvif->vdev_id); + ++ ret = ath11k_spectral_vif_stop(arvif); ++ if (ret) ++ ath11k_warn(ab, "failed to stop spectral for vdev %i: %d\n", ++ arvif->vdev_id, ret); ++ + if (arvif->vdev_type == WMI_VDEV_TYPE_STA) + ath11k_mac_11d_scan_stop(ar); + diff --git a/package/kernel/mac80211/patches/ath11k/0057-wifi-ath11k-enable-SAR-support-on-WCN6750.patch b/package/kernel/mac80211/patches/ath11k/0057-wifi-ath11k-enable-SAR-support-on-WCN6750.patch new file mode 100644 index 00000000000..5e64e552c1d --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0057-wifi-ath11k-enable-SAR-support-on-WCN6750.patch @@ -0,0 +1,29 @@ +From abf57d84973ce1abcb67504ac0df8aea1fe09a76 Mon Sep 17 00:00:00 2001 +From: Youghandhar Chintala +Date: Tue, 28 Mar 2023 17:04:55 +0530 +Subject: [PATCH] wifi: ath11k: enable SAR support on WCN6750 + +Currently, SAR is enabled only on WCN6855, enable this for WCN6750 too. This +functionality gets triggered, when the user space application calls +NL80211_CMD_SET_SAR_SPECS. + +Tested-on: WCN6750 hw1.0 AHB WLAN.MSL.1.0.1-00887-QCAMSLSWPLZ-1 + +Signed-off-by: Youghandhar Chintala +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230328113455.11252-1-quic_youghand@quicinc.com +--- + drivers/net/wireless/ath/ath11k/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/core.c ++++ b/drivers/net/wireless/ath/ath11k/core.c +@@ -593,7 +593,7 @@ static const struct ath11k_hw_params ath + .current_cc_support = true, + .dbr_debug_support = false, + .global_reset = false, +- .bios_sar_capa = NULL, ++ .bios_sar_capa = &ath11k_hw_sar_capa_wcn6855, + .m3_fw_support = false, + .fixed_bdf_addr = false, + .fixed_mem_region = false, diff --git a/package/kernel/mac80211/patches/ath11k/0058-wifi-ath11k-pci-Add-more-MODULE_FIRMWARE-entries.patch b/package/kernel/mac80211/patches/ath11k/0058-wifi-ath11k-pci-Add-more-MODULE_FIRMWARE-entries.patch new file mode 100644 index 00000000000..585864eff2e --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0058-wifi-ath11k-pci-Add-more-MODULE_FIRMWARE-entries.patch @@ -0,0 +1,36 @@ +From 06c58473969239e00d76b683edd511952060ca56 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Thu, 30 Mar 2023 16:37:18 +0200 +Subject: [PATCH] wifi: ath11k: pci: Add more MODULE_FIRMWARE() entries + +As there are a few more models supported by the driver, let's add the +missing MODULE_FIRMWARE() entries for them. The lack of them resulted +in the missing device enablement on some systems, such as the +installation image of openSUSE. + +While we are at it, use the wildcard instead of listing each firmware +files individually for each. + +Signed-off-by: Takashi Iwai +Reviewed-by: Simon Horman +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230330143718.19511-1-tiwai@suse.de +--- + drivers/net/wireless/ath/ath11k/pci.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/pci.c ++++ b/drivers/net/wireless/ath/ath11k/pci.c +@@ -1036,7 +1036,8 @@ module_exit(ath11k_pci_exit); + MODULE_DESCRIPTION("Driver support for Qualcomm Technologies 802.11ax WLAN PCIe devices"); + MODULE_LICENSE("Dual BSD/GPL"); + +-/* QCA639x 2.0 firmware files */ +-MODULE_FIRMWARE(ATH11K_FW_DIR "/QCA6390/hw2.0/" ATH11K_BOARD_API2_FILE); +-MODULE_FIRMWARE(ATH11K_FW_DIR "/QCA6390/hw2.0/" ATH11K_AMSS_FILE); +-MODULE_FIRMWARE(ATH11K_FW_DIR "/QCA6390/hw2.0/" ATH11K_M3_FILE); ++/* firmware files */ ++MODULE_FIRMWARE(ATH11K_FW_DIR "/QCA6390/hw2.0/*"); ++MODULE_FIRMWARE(ATH11K_FW_DIR "/QCN9074/hw1.0/*"); ++MODULE_FIRMWARE(ATH11K_FW_DIR "/WCN6855/hw2.0/*"); ++MODULE_FIRMWARE(ATH11K_FW_DIR "/WCN6855/hw2.1/*"); diff --git a/package/kernel/mac80211/patches/ath11k/0059-wifi-ath11k-print-a-warning-when-crypto_alloc_shash-.patch b/package/kernel/mac80211/patches/ath11k/0059-wifi-ath11k-print-a-warning-when-crypto_alloc_shash-.patch new file mode 100644 index 00000000000..fab52a0fa7b --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0059-wifi-ath11k-print-a-warning-when-crypto_alloc_shash-.patch @@ -0,0 +1,34 @@ +From a87a9110ac0dcbfd9458b6665c141fa1c16a669d Mon Sep 17 00:00:00 2001 +From: Kalle Valo +Date: Wed, 5 Apr 2023 12:04:25 +0300 +Subject: [PATCH] wifi: ath11k: print a warning when crypto_alloc_shash() fails + +Christoph reported that ath11k failed to initialise when michael_mic.ko +module was not installed. To make it easier to notice that case print a +warning when crypto_alloc_shash() fails. + +Compile tested only. + +Reported-by: Christoph Hellwig +Link: https://lore.kernel.org/all/20221130133016.GC3055@lst.de/ +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230405090425.1351-1-kvalo@kernel.org +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -3106,8 +3106,11 @@ int ath11k_peer_rx_frag_setup(struct ath + int i; + + tfm = crypto_alloc_shash("michael_mic", 0, 0); +- if (IS_ERR(tfm)) ++ if (IS_ERR(tfm)) { ++ ath11k_warn(ab, "failed to allocate michael_mic shash: %ld\n", ++ PTR_ERR(tfm)); + return PTR_ERR(tfm); ++ } + + spin_lock_bh(&ab->base_lock); + diff --git a/package/kernel/mac80211/patches/ath11k/0060-wifi-ath11k-Ignore-frags-from-uninitialized-peer-in-.patch b/package/kernel/mac80211/patches/ath11k/0060-wifi-ath11k-Ignore-frags-from-uninitialized-peer-in-.patch new file mode 100644 index 00000000000..5bbf9e04a4d --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0060-wifi-ath11k-Ignore-frags-from-uninitialized-peer-in-.patch @@ -0,0 +1,104 @@ +From a06bfb3c9f69f303692cdae87bc0899d2ae8b2a6 Mon Sep 17 00:00:00 2001 +From: Harshitha Prem +Date: Tue, 4 Apr 2023 00:11:54 +0530 +Subject: [PATCH] wifi: ath11k: Ignore frags from uninitialized peer in dp. + +When max virtual ap interfaces are configured in all the bands with +ACS and hostapd restart is done every 60s, a crash is observed at +random times. +In this certain scenario, a fragmented packet is received for +self peer, for which rx_tid and rx_frags are not initialized in +datapath. While handling this fragment, crash is observed as the +rx_frag list is uninitialised and when we walk in +ath11k_dp_rx_h_sort_frags, skb null leads to exception. + +To address this, before processing received fragments we check +dp_setup_done flag is set to ensure that peer has completed its +dp peer setup for fragment queue, else ignore processing the +fragments. + +Call trace: + ath11k_dp_process_rx_err+0x550/0x1084 [ath11k] + ath11k_dp_service_srng+0x70/0x370 [ath11k] + 0xffffffc009693a04 + __napi_poll+0x30/0xa4 + net_rx_action+0x118/0x270 + __do_softirq+0x10c/0x244 + irq_exit+0x64/0xb4 + __handle_domain_irq+0x88/0xac + gic_handle_irq+0x74/0xbc + el1_irq+0xf0/0x1c0 + arch_cpu_idle+0x10/0x18 + do_idle+0x104/0x248 + cpu_startup_entry+0x20/0x64 + rest_init+0xd0/0xdc + arch_call_rest_init+0xc/0x14 + start_kernel+0x480/0x4b8 + Code: f9400281 f94066a2 91405021 b94a0023 (f9406401) + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Harshitha Prem +Signed-off-by: Nagarajan Maran +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403184155.8670-2-quic_nmaran@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp.c | 4 +++- + drivers/net/wireless/ath/ath11k/dp_rx.c | 8 ++++++++ + drivers/net/wireless/ath/ath11k/peer.h | 1 + + 3 files changed, 12 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp.c ++++ b/drivers/net/wireless/ath/ath11k/dp.c +@@ -36,6 +36,7 @@ void ath11k_dp_peer_cleanup(struct ath11 + } + + ath11k_peer_rx_tid_cleanup(ar, peer); ++ peer->dp_setup_done = false; + crypto_free_shash(peer->tfm_mmic); + spin_unlock_bh(&ab->base_lock); + } +@@ -72,7 +73,8 @@ int ath11k_dp_peer_setup(struct ath11k * + ret = ath11k_peer_rx_frag_setup(ar, addr, vdev_id); + if (ret) { + ath11k_warn(ab, "failed to setup rx defrag context\n"); +- return ret; ++ tid--; ++ goto peer_clean; + } + + /* TODO: Setup other peer specific resource used in data path */ +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -3130,6 +3130,7 @@ int ath11k_peer_rx_frag_setup(struct ath + } + + peer->tfm_mmic = tfm; ++ peer->dp_setup_done = true; + spin_unlock_bh(&ab->base_lock); + + return 0; +@@ -3575,6 +3576,13 @@ static int ath11k_dp_rx_frag_h_mpdu(stru + ret = -ENOENT; + goto out_unlock; + } ++ if (!peer->dp_setup_done) { ++ ath11k_warn(ab, "The peer %pM [%d] has uninitialized datapath\n", ++ peer->addr, peer_id); ++ ret = -ENOENT; ++ goto out_unlock; ++ } ++ + rx_tid = &peer->rx_tid[tid]; + + if ((!skb_queue_empty(&rx_tid->rx_frags) && seqno != rx_tid->cur_sn) || +--- a/drivers/net/wireless/ath/ath11k/peer.h ++++ b/drivers/net/wireless/ath/ath11k/peer.h +@@ -35,6 +35,7 @@ struct ath11k_peer { + u16 sec_type; + u16 sec_type_grp; + bool is_authorized; ++ bool dp_setup_done; + }; + + void ath11k_peer_unmap_event(struct ath11k_base *ab, u16 peer_id); diff --git a/package/kernel/mac80211/patches/ath11k/0061-wifi-ath11k-fix-undefined-behavior-with-__fls-in-dp.patch b/package/kernel/mac80211/patches/ath11k/0061-wifi-ath11k-fix-undefined-behavior-with-__fls-in-dp.patch new file mode 100644 index 00000000000..d68c19f1609 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0061-wifi-ath11k-fix-undefined-behavior-with-__fls-in-dp.patch @@ -0,0 +1,29 @@ +From 41e02bf4ae32cf2ac47b08b4caaa9c1a032e4ce7 Mon Sep 17 00:00:00 2001 +From: Harshitha Prem +Date: Tue, 4 Apr 2023 00:11:55 +0530 +Subject: [PATCH] wifi: ath11k: fix undefined behavior with __fls in dp + +"__fls" would have an undefined behavior if the argument is passed +as "0". Hence, added changes to handle the same. + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Harshitha Prem +Signed-off-by: Nagarajan Maran +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403184155.8670-3-quic_nmaran@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -3598,7 +3598,7 @@ static int ath11k_dp_rx_frag_h_mpdu(stru + goto out_unlock; + } + +- if (frag_no > __fls(rx_tid->rx_frag_bitmap)) ++ if (!rx_tid->rx_frag_bitmap || (frag_no > __fls(rx_tid->rx_frag_bitmap))) + __skb_queue_tail(&rx_tid->rx_frags, msdu); + else + ath11k_dp_rx_h_sort_frags(ar, &rx_tid->rx_frags, msdu); diff --git a/package/kernel/mac80211/patches/ath11k/0062-wifi-ath11k-fix-double-free-of-peer-rx_tid-during-re.patch b/package/kernel/mac80211/patches/ath11k/0062-wifi-ath11k-fix-double-free-of-peer-rx_tid-during-re.patch new file mode 100644 index 00000000000..dd37b1e4fa8 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0062-wifi-ath11k-fix-double-free-of-peer-rx_tid-during-re.patch @@ -0,0 +1,144 @@ +From 93a91f40c25c3d0e61f8540a7accf105090f9995 Mon Sep 17 00:00:00 2001 +From: Harshitha Prem +Date: Mon, 17 Apr 2023 13:35:00 +0300 +Subject: [PATCH] wifi: ath11k: fix double free of peer rx_tid during reo cmd + failure + +Peer rx_tid is locally copied thrice during peer_rx_tid_cleanup to +send REO_CMD_UPDATE_RX_QUEUE followed by REO_CMD_FLUSH_CACHE to flush +all aged REO descriptors from HW cache. + +When sending REO_CMD_FLUSH_CACHE fails, we do dma unmap of already +mapped rx_tid->vaddr and free it. This is not checked during +reo_cmd_list_cleanup() and dp_reo_cmd_free() before trying to free and +unmap again. + +Fix this by setting rx_tid->vaddr NULL in rx tid delete and also +wherever freeing it to check in reo_cmd_list_cleanup() and +reo_cmd_free() before trying to free again. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Sathishkumar Muruganandam +Signed-off-by: Harshitha Prem +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403182420.23375-2-quic_hprem@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 43 ++++++++++++++++++------- + 1 file changed, 31 insertions(+), 12 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -668,13 +668,18 @@ void ath11k_dp_reo_cmd_list_cleanup(stru + struct ath11k_dp *dp = &ab->dp; + struct dp_reo_cmd *cmd, *tmp; + struct dp_reo_cache_flush_elem *cmd_cache, *tmp_cache; ++ struct dp_rx_tid *rx_tid; + + spin_lock_bh(&dp->reo_cmd_lock); + list_for_each_entry_safe(cmd, tmp, &dp->reo_cmd_list, list) { + list_del(&cmd->list); +- dma_unmap_single(ab->dev, cmd->data.paddr, +- cmd->data.size, DMA_BIDIRECTIONAL); +- kfree(cmd->data.vaddr); ++ rx_tid = &cmd->data; ++ if (rx_tid->vaddr) { ++ dma_unmap_single(ab->dev, rx_tid->paddr, ++ rx_tid->size, DMA_BIDIRECTIONAL); ++ kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; ++ } + kfree(cmd); + } + +@@ -682,9 +687,13 @@ void ath11k_dp_reo_cmd_list_cleanup(stru + &dp->reo_cmd_cache_flush_list, list) { + list_del(&cmd_cache->list); + dp->reo_cmd_cache_flush_count--; +- dma_unmap_single(ab->dev, cmd_cache->data.paddr, +- cmd_cache->data.size, DMA_BIDIRECTIONAL); +- kfree(cmd_cache->data.vaddr); ++ rx_tid = &cmd_cache->data; ++ if (rx_tid->vaddr) { ++ dma_unmap_single(ab->dev, rx_tid->paddr, ++ rx_tid->size, DMA_BIDIRECTIONAL); ++ kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; ++ } + kfree(cmd_cache); + } + spin_unlock_bh(&dp->reo_cmd_lock); +@@ -698,10 +707,12 @@ static void ath11k_dp_reo_cmd_free(struc + if (status != HAL_REO_CMD_SUCCESS) + ath11k_warn(dp->ab, "failed to flush rx tid hw desc, tid %d status %d\n", + rx_tid->tid, status); +- +- dma_unmap_single(dp->ab->dev, rx_tid->paddr, rx_tid->size, +- DMA_BIDIRECTIONAL); +- kfree(rx_tid->vaddr); ++ if (rx_tid->vaddr) { ++ dma_unmap_single(dp->ab->dev, rx_tid->paddr, rx_tid->size, ++ DMA_BIDIRECTIONAL); ++ kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; ++ } + } + + static void ath11k_dp_reo_cache_flush(struct ath11k_base *ab, +@@ -740,6 +751,7 @@ static void ath11k_dp_reo_cache_flush(st + dma_unmap_single(ab->dev, rx_tid->paddr, rx_tid->size, + DMA_BIDIRECTIONAL); + kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; + } + } + +@@ -792,6 +804,7 @@ free_desc: + dma_unmap_single(ab->dev, rx_tid->paddr, rx_tid->size, + DMA_BIDIRECTIONAL); + kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; + } + + void ath11k_peer_rx_tid_delete(struct ath11k *ar, +@@ -804,6 +817,8 @@ void ath11k_peer_rx_tid_delete(struct at + if (!rx_tid->active) + return; + ++ rx_tid->active = false; ++ + cmd.flag = HAL_REO_CMD_FLG_NEED_STATUS; + cmd.addr_lo = lower_32_bits(rx_tid->paddr); + cmd.addr_hi = upper_32_bits(rx_tid->paddr); +@@ -818,9 +833,11 @@ void ath11k_peer_rx_tid_delete(struct at + dma_unmap_single(ar->ab->dev, rx_tid->paddr, rx_tid->size, + DMA_BIDIRECTIONAL); + kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; + } + +- rx_tid->active = false; ++ rx_tid->paddr = 0; ++ rx_tid->size = 0; + } + + static int ath11k_dp_rx_link_desc_return(struct ath11k_base *ab, +@@ -967,6 +984,7 @@ static void ath11k_dp_rx_tid_mem_free(st + dma_unmap_single(ab->dev, rx_tid->paddr, rx_tid->size, + DMA_BIDIRECTIONAL); + kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; + + rx_tid->active = false; + +@@ -1067,7 +1085,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + return ret; + + err_mem_free: +- kfree(vaddr); ++ kfree(rx_tid->vaddr); ++ rx_tid->vaddr = NULL; + + return ret; + } diff --git a/package/kernel/mac80211/patches/ath11k/0063-wifi-ath11k-Prevent-REO-cmd-failures.patch b/package/kernel/mac80211/patches/ath11k/0063-wifi-ath11k-Prevent-REO-cmd-failures.patch new file mode 100644 index 00000000000..4b9af180620 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0063-wifi-ath11k-Prevent-REO-cmd-failures.patch @@ -0,0 +1,43 @@ +From a8ae833657a45746debde85c38bb7f070d344026 Mon Sep 17 00:00:00 2001 +From: Harshitha Prem +Date: Mon, 17 Apr 2023 13:35:01 +0300 +Subject: [PATCH] wifi: ath11k: Prevent REO cmd failures + +Prevent REO cmd failures causing double free by increasing REO cmd +ring size and moving REO status ring mask to IRQ group 3 from group +0 to separate from tx completion ring on IRQ group 0 which may delay +reo status processing. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Sathishkumar Muruganandam +Signed-off-by: Harshitha Prem +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403182420.23375-3-quic_hprem@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp.h | 2 +- + drivers/net/wireless/ath/ath11k/hw.c | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp.h ++++ b/drivers/net/wireless/ath/ath11k/dp.h +@@ -214,7 +214,7 @@ struct ath11k_pdev_dp { + #define DP_REO_REINJECT_RING_SIZE 32 + #define DP_RX_RELEASE_RING_SIZE 1024 + #define DP_REO_EXCEPTION_RING_SIZE 128 +-#define DP_REO_CMD_RING_SIZE 128 ++#define DP_REO_CMD_RING_SIZE 256 + #define DP_REO_STATUS_RING_SIZE 2048 + #define DP_RXDMA_BUF_RING_SIZE 4096 + #define DP_RXDMA_REFILL_RING_SIZE 2048 +--- a/drivers/net/wireless/ath/ath11k/hw.c ++++ b/drivers/net/wireless/ath/ath11k/hw.c +@@ -1233,6 +1233,7 @@ const struct ath11k_hw_ring_mask ath11k_ + ATH11K_RX_WBM_REL_RING_MASK_0, + }, + .reo_status = { ++ 0, 0, 0, + ATH11K_REO_STATUS_RING_MASK_0, + }, + .rxdma2host = { diff --git a/package/kernel/mac80211/patches/ath11k/0064-wifi-ath11k-add-peer-mac-information-in-failure-case.patch b/package/kernel/mac80211/patches/ath11k/0064-wifi-ath11k-add-peer-mac-information-in-failure-case.patch new file mode 100644 index 00000000000..fbcbdfff712 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0064-wifi-ath11k-add-peer-mac-information-in-failure-case.patch @@ -0,0 +1,74 @@ +From 20487cc3ff36bbfa9505f0a078ba98f09abfc717 Mon Sep 17 00:00:00 2001 +From: Harshitha Prem +Date: Mon, 17 Apr 2023 13:35:01 +0300 +Subject: [PATCH] wifi: ath11k: add peer mac information in failure cases + +During reo command failure, the peer mac detail for which the reo +command was not successful is unknown. Hence, to improve the +debuggability, add the peer mac information in the failure cases +which would be useful during multi client cases. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Sathishkumar Muruganandam +Signed-off-by: Harshitha Prem +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403182420.23375-4-quic_hprem@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -1009,7 +1009,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + + peer = ath11k_peer_find(ab, vdev_id, peer_mac); + if (!peer) { +- ath11k_warn(ab, "failed to find the peer to set up rx tid\n"); ++ ath11k_warn(ab, "failed to find the peer %pM to set up rx tid\n", ++ peer_mac); + spin_unlock_bh(&ab->base_lock); + return -ENOENT; + } +@@ -1022,7 +1023,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + ba_win_sz, ssn, true); + spin_unlock_bh(&ab->base_lock); + if (ret) { +- ath11k_warn(ab, "failed to update reo for rx tid %d\n", tid); ++ ath11k_warn(ab, "failed to update reo for peer %pM rx tid %d\n: %d", ++ peer_mac, tid, ret); + return ret; + } + +@@ -1030,8 +1032,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + peer_mac, paddr, + tid, 1, ba_win_sz); + if (ret) +- ath11k_warn(ab, "failed to send wmi command to update rx reorder queue, tid :%d (%d)\n", +- tid, ret); ++ ath11k_warn(ab, "failed to send wmi rx reorder queue for peer %pM tid %d: %d\n", ++ peer_mac, tid, ret); + return ret; + } + +@@ -1064,6 +1066,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + ret = dma_mapping_error(ab->dev, paddr); + if (ret) { + spin_unlock_bh(&ab->base_lock); ++ ath11k_warn(ab, "failed to setup dma map for peer %pM rx tid %d: %d\n", ++ peer_mac, tid, ret); + goto err_mem_free; + } + +@@ -1077,8 +1081,8 @@ int ath11k_peer_rx_tid_setup(struct ath1 + ret = ath11k_wmi_peer_rx_reorder_queue_setup(ar, vdev_id, peer_mac, + paddr, tid, 1, ba_win_sz); + if (ret) { +- ath11k_warn(ar->ab, "failed to setup rx reorder queue, tid :%d (%d)\n", +- tid, ret); ++ ath11k_warn(ar->ab, "failed to setup rx reorder queue for peer %pM tid %d: %d\n", ++ peer_mac, tid, ret); + ath11k_dp_rx_tid_mem_free(ab, peer_mac, vdev_id, tid); + } + diff --git a/package/kernel/mac80211/patches/ath11k/0065-wifi-ath11k-fix-tx-status-reporting-in-encap-offload.patch b/package/kernel/mac80211/patches/ath11k/0065-wifi-ath11k-fix-tx-status-reporting-in-encap-offload.patch new file mode 100644 index 00000000000..e2fe419158f --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0065-wifi-ath11k-fix-tx-status-reporting-in-encap-offload.patch @@ -0,0 +1,119 @@ +From 6257c702264c44d74c6b71f0c62a7665da2dc356 Mon Sep 17 00:00:00 2001 +From: Pradeep Kumar Chitrapu +Date: Mon, 17 Apr 2023 13:35:02 +0300 +Subject: [PATCH] wifi: ath11k: fix tx status reporting in encap offload mode + +ieee80211_tx_status() treats packets in 802.11 frame format and +tries to extract sta address from packet header. When tx encap +offload is enabled, this becomes invalid operation. Hence, switch +to using ieee80211_tx_status_ext() after filling in station +address for handling both 802.11 and 802.3 frames. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Pradeep Kumar Chitrapu +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403195738.25367-2-quic_pradeepc@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp.h | 4 +++ + drivers/net/wireless/ath/ath11k/dp_tx.c | 33 ++++++++++++++++++++++++- + drivers/net/wireless/ath/ath11k/dp_tx.h | 1 + + 3 files changed, 37 insertions(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/dp.h ++++ b/drivers/net/wireless/ath/ath11k/dp.h +@@ -303,12 +303,16 @@ struct ath11k_dp { + + #define HTT_TX_WBM_COMP_STATUS_OFFSET 8 + ++#define HTT_INVALID_PEER_ID 0xffff ++ + /* HTT tx completion is overlaid in wbm_release_ring */ + #define HTT_TX_WBM_COMP_INFO0_STATUS GENMASK(12, 9) + #define HTT_TX_WBM_COMP_INFO0_REINJECT_REASON GENMASK(16, 13) + #define HTT_TX_WBM_COMP_INFO0_REINJECT_REASON GENMASK(16, 13) + + #define HTT_TX_WBM_COMP_INFO1_ACK_RSSI GENMASK(31, 24) ++#define HTT_TX_WBM_COMP_INFO2_SW_PEER_ID GENMASK(15, 0) ++#define HTT_TX_WBM_COMP_INFO2_VALID BIT(21) + + struct htt_tx_wbm_completion { + u32 info0; +--- a/drivers/net/wireless/ath/ath11k/dp_tx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.c +@@ -316,10 +316,12 @@ ath11k_dp_tx_htt_tx_complete_buf(struct + struct dp_tx_ring *tx_ring, + struct ath11k_dp_htt_wbm_tx_status *ts) + { ++ struct ieee80211_tx_status status = { 0 }; + struct sk_buff *msdu; + struct ieee80211_tx_info *info; + struct ath11k_skb_cb *skb_cb; + struct ath11k *ar; ++ struct ath11k_peer *peer; + + spin_lock(&tx_ring->tx_idr_lock); + msdu = idr_remove(&tx_ring->txbuf_idr, ts->msdu_id); +@@ -341,6 +343,11 @@ ath11k_dp_tx_htt_tx_complete_buf(struct + + dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE); + ++ if (!skb_cb->vif) { ++ dev_kfree_skb_any(msdu); ++ return; ++ } ++ + memset(&info->status, 0, sizeof(info->status)); + + if (ts->acked) { +@@ -355,7 +362,23 @@ ath11k_dp_tx_htt_tx_complete_buf(struct + } + } + +- ieee80211_tx_status(ar->hw, msdu); ++ spin_lock_bh(&ab->base_lock); ++ peer = ath11k_peer_find_by_id(ab, ts->peer_id); ++ if (!peer || !peer->sta) { ++ ath11k_dbg(ab, ATH11K_DBG_DATA, ++ "dp_tx: failed to find the peer with peer_id %d\n", ++ ts->peer_id); ++ spin_unlock_bh(&ab->base_lock); ++ dev_kfree_skb_any(msdu); ++ return; ++ } ++ spin_unlock_bh(&ab->base_lock); ++ ++ status.sta = peer->sta; ++ status.info = info; ++ status.skb = msdu; ++ ++ ieee80211_tx_status_ext(ar->hw, &status); + } + + static void +@@ -379,7 +402,15 @@ ath11k_dp_tx_process_htt_tx_complete(str + ts.msdu_id = msdu_id; + ts.ack_rssi = FIELD_GET(HTT_TX_WBM_COMP_INFO1_ACK_RSSI, + status_desc->info1); ++ ++ if (FIELD_GET(HTT_TX_WBM_COMP_INFO2_VALID, status_desc->info2)) ++ ts.peer_id = FIELD_GET(HTT_TX_WBM_COMP_INFO2_SW_PEER_ID, ++ status_desc->info2); ++ else ++ ts.peer_id = HTT_INVALID_PEER_ID; ++ + ath11k_dp_tx_htt_tx_complete_buf(ab, tx_ring, &ts); ++ + break; + case HAL_WBM_REL_HTT_TX_COMP_STATUS_REINJ: + case HAL_WBM_REL_HTT_TX_COMP_STATUS_INSPECT: +--- a/drivers/net/wireless/ath/ath11k/dp_tx.h ++++ b/drivers/net/wireless/ath/ath11k/dp_tx.h +@@ -13,6 +13,7 @@ struct ath11k_dp_htt_wbm_tx_status { + u32 msdu_id; + bool acked; + int ack_rssi; ++ u16 peer_id; + }; + + void ath11k_dp_tx_update_txcompl(struct ath11k *ar, struct hal_tx_status *ts); diff --git a/package/kernel/mac80211/patches/ath11k/0066-wifi-ath11k-Fix-incorrect-update-of-radiotap-fields.patch b/package/kernel/mac80211/patches/ath11k/0066-wifi-ath11k-Fix-incorrect-update-of-radiotap-fields.patch new file mode 100644 index 00000000000..4f94580100f --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0066-wifi-ath11k-Fix-incorrect-update-of-radiotap-fields.patch @@ -0,0 +1,49 @@ +From 2f0c9ac8362da09c80f1cd422ef7fd6fa9b252b9 Mon Sep 17 00:00:00 2001 +From: Pradeep Kumar Chitrapu +Date: Mon, 17 Apr 2023 13:35:02 +0300 +Subject: [PATCH] wifi: ath11k: Fix incorrect update of radiotap fields + +Fix incorrect update of ppdu stats causing incorrect radiotap +fields. + +Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Pradeep Kumar Chitrapu +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403195738.25367-3-quic_pradeepc@quicinc.com +--- + drivers/net/wireless/ath/ath11k/hal_rx.c | 4 ++-- + drivers/net/wireless/ath/ath11k/hal_rx.h | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/hal_rx.c ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.c +@@ -1029,7 +1029,7 @@ ath11k_hal_rx_parse_mon_status_tlv(struc + info1 = __le32_to_cpu(vht_sig->info1); + + ppdu_info->ldpc = FIELD_GET(HAL_RX_VHT_SIG_A_INFO_INFO1_SU_MU_CODING, +- info0); ++ info1); + ppdu_info->mcs = FIELD_GET(HAL_RX_VHT_SIG_A_INFO_INFO1_MCS, + info1); + gi_setting = FIELD_GET(HAL_RX_VHT_SIG_A_INFO_INFO1_GI_SETTING, +@@ -1452,7 +1452,7 @@ ath11k_hal_rx_parse_mon_status_tlv(struc + * PHYRX_OTHER_RECEIVE_INFO TLV. + */ + ppdu_info->rssi_comb = +- FIELD_GET(HAL_RX_PHYRX_RSSI_LEGACY_INFO_INFO1_RSSI_COMB, ++ FIELD_GET(HAL_RX_PHYRX_RSSI_LEGACY_INFO_INFO0_RSSI_COMB, + __le32_to_cpu(rssi->info0)); + + if (db2dbm) { +--- a/drivers/net/wireless/ath/ath11k/hal_rx.h ++++ b/drivers/net/wireless/ath/ath11k/hal_rx.h +@@ -385,7 +385,7 @@ struct hal_rx_he_sig_b2_ofdma_info { + __le32 info0; + } __packed; + +-#define HAL_RX_PHYRX_RSSI_LEGACY_INFO_INFO1_RSSI_COMB GENMASK(15, 8) ++#define HAL_RX_PHYRX_RSSI_LEGACY_INFO_INFO0_RSSI_COMB GENMASK(15, 8) + + #define HAL_RX_PHYRX_RSSI_PREAMBLE_PRI20 GENMASK(7, 0) + diff --git a/package/kernel/mac80211/patches/ath11k/0067-wifi-ath11k-Fix-SKB-corruption-in-REO-destination-ri.patch b/package/kernel/mac80211/patches/ath11k/0067-wifi-ath11k-Fix-SKB-corruption-in-REO-destination-ri.patch new file mode 100644 index 00000000000..8b300f3a790 --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0067-wifi-ath11k-Fix-SKB-corruption-in-REO-destination-ri.patch @@ -0,0 +1,70 @@ +From f9fff67d2d7ca6fa8066132003a3deef654c55b1 Mon Sep 17 00:00:00 2001 +From: Nagarajan Maran +Date: Mon, 17 Apr 2023 13:35:02 +0300 +Subject: [PATCH] wifi: ath11k: Fix SKB corruption in REO destination ring + +While running traffics for a long time, randomly an RX descriptor +filled with value "0" from REO destination ring is received. +This descriptor which is invalid causes the wrong SKB (SKB stored in +the IDR lookup with buffer id "0") to be fetched which in turn +causes SKB memory corruption issue and the same leads to crash +after some time. + +Changed the start id for idr allocation to "1" and the buffer id "0" +is reserved for error validation. Introduced Sanity check to validate +the descriptor, before processing the SKB. + +Crash Signature : + +Unable to handle kernel paging request at virtual address 3f004900 +PC points to "b15_dma_inv_range+0x30/0x50" +LR points to "dma_cache_maint_page+0x8c/0x128". +The Backtrace obtained is as follows: +[<8031716c>] (b15_dma_inv_range) from [<80313a4c>] (dma_cache_maint_page+0x8c/0x128) +[<80313a4c>] (dma_cache_maint_page) from [<80313b90>] (__dma_page_dev_to_cpu+0x28/0xcc) +[<80313b90>] (__dma_page_dev_to_cpu) from [<7fb5dd68>] (ath11k_dp_process_rx+0x1e8/0x4a4 [ath11k]) +[<7fb5dd68>] (ath11k_dp_process_rx [ath11k]) from [<7fb53c20>] (ath11k_dp_service_srng+0xb0/0x2ac [ath11k]) +[<7fb53c20>] (ath11k_dp_service_srng [ath11k]) from [<7f67bba4>] (ath11k_pci_ext_grp_napi_poll+0x1c/0x78 [ath11k_pci]) +[<7f67bba4>] (ath11k_pci_ext_grp_napi_poll [ath11k_pci]) from [<807d5cf4>] (__napi_poll+0x28/0xb8) +[<807d5cf4>] (__napi_poll) from [<807d5f28>] (net_rx_action+0xf0/0x280) +[<807d5f28>] (net_rx_action) from [<80302148>] (__do_softirq+0xd0/0x280) +[<80302148>] (__do_softirq) from [<80320408>] (irq_exit+0x74/0xd4) +[<80320408>] (irq_exit) from [<803638a4>] (__handle_domain_irq+0x90/0xb4) +[<803638a4>] (__handle_domain_irq) from [<805bedec>] (gic_handle_irq+0x58/0x90) +[<805bedec>] (gic_handle_irq) from [<80301a78>] (__irq_svc+0x58/0x8c) + +Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 + +Signed-off-by: Nagarajan Maran +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230403191533.28114-1-quic_nmaran@quicinc.com +--- + drivers/net/wireless/ath/ath11k/dp_rx.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/dp_rx.c ++++ b/drivers/net/wireless/ath/ath11k/dp_rx.c +@@ -389,10 +389,10 @@ int ath11k_dp_rxbufs_replenish(struct at + goto fail_free_skb; + + spin_lock_bh(&rx_ring->idr_lock); +- buf_id = idr_alloc(&rx_ring->bufs_idr, skb, 0, +- rx_ring->bufs_max * 3, GFP_ATOMIC); ++ buf_id = idr_alloc(&rx_ring->bufs_idr, skb, 1, ++ (rx_ring->bufs_max * 3) + 1, GFP_ATOMIC); + spin_unlock_bh(&rx_ring->idr_lock); +- if (buf_id < 0) ++ if (buf_id <= 0) + goto fail_dma_unmap; + + desc = ath11k_hal_srng_src_get_next_entry(ab, srng); +@@ -2665,6 +2665,9 @@ try_again: + cookie); + mac_id = FIELD_GET(DP_RXDMA_BUF_COOKIE_PDEV_ID, cookie); + ++ if (unlikely(buf_id == 0)) ++ continue; ++ + ar = ab->pdevs[mac_id].ar; + rx_ring = &ar->dp.rx_refill_buf_ring; + spin_lock_bh(&rx_ring->idr_lock); diff --git a/package/kernel/mac80211/patches/ath11k/0068-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch b/package/kernel/mac80211/patches/ath11k/0068-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch new file mode 100644 index 00000000000..ce5ffd273be --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0068-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch @@ -0,0 +1,49 @@ +From b100722a777f6455d913666a376f81342b2cb995 Mon Sep 17 00:00:00 2001 +From: Muna Sinada +Date: Mon, 17 Apr 2023 13:22:27 -0700 +Subject: [PATCH] wifi: ath11k: Remove disabling of 80+80 and 160 MHz + +This is a regression fix for 80+80 and 160 MHz support bits being +cleared, therefore not adverised. Remove disable of 80+80 and 160 MHz +capability flags and assign valid center frequency 2 similar to +VHT80_80. + +Fixes: 38dfe775d0ab ("wifi: ath11k: push MU-MIMO params from hostapd to hardware") +Reported-by: Robert Marko +Tested-by: Robert Marko # IPQ8074 WLAN.HK.2.9.0.1-01385-QCAHKSWPL_SILICONZ-1 +Link: https://bugzilla.kernel.org/show_bug.cgi?id=217299 +Co-developed-by: P Praneesh +Signed-off-by: P Praneesh +Signed-off-by: Muna Sinada +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/1681762947-13882-1-git-send-email-quic_msinada@quicinc.com +--- + drivers/net/wireless/ath/ath11k/mac.c | 4 ---- + drivers/net/wireless/ath/ath11k/wmi.c | 3 ++- + 2 files changed, 2 insertions(+), 5 deletions(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -5585,10 +5585,6 @@ static int ath11k_mac_copy_he_cap(struct + + he_cap_elem->mac_cap_info[1] &= + IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK; +- he_cap_elem->phy_cap_info[0] &= +- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; +- he_cap_elem->phy_cap_info[0] &= +- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; + + he_cap_elem->phy_cap_info[5] &= + ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK; +--- a/drivers/net/wireless/ath/ath11k/wmi.c ++++ b/drivers/net/wireless/ath/ath11k/wmi.c +@@ -871,7 +871,8 @@ static void ath11k_wmi_put_wmi_channel(s + + chan->band_center_freq2 = arg->channel.band_center_freq1; + +- } else if (arg->channel.mode == MODE_11AC_VHT80_80) { ++ } else if ((arg->channel.mode == MODE_11AC_VHT80_80) || ++ (arg->channel.mode == MODE_11AX_HE80_80)) { + chan->band_center_freq2 = arg->channel.band_center_freq2; + } else { + chan->band_center_freq2 = 0; diff --git a/package/kernel/mac80211/patches/ath11k/0069-wifi-ath11k-fix-registration-of-6Ghz-only-phy-withou.patch b/package/kernel/mac80211/patches/ath11k/0069-wifi-ath11k-fix-registration-of-6Ghz-only-phy-withou.patch new file mode 100644 index 00000000000..32468dbc4ca --- /dev/null +++ b/package/kernel/mac80211/patches/ath11k/0069-wifi-ath11k-fix-registration-of-6Ghz-only-phy-withou.patch @@ -0,0 +1,61 @@ +From e2ceb1de2f83aafd8003f0b72dfd4b7441e97d14 Mon Sep 17 00:00:00 2001 +From: Maxime Bizon +Date: Fri, 21 Apr 2023 16:54:45 +0200 +Subject: [PATCH] wifi: ath11k: fix registration of 6Ghz-only phy without the + full channel range + +Because of what seems to be a typo, a 6Ghz-only phy for which the BDF +does not allow the 7115Mhz channel will fail to register: + + WARNING: CPU: 2 PID: 106 at net/wireless/core.c:907 wiphy_register+0x914/0x954 + Modules linked in: ath11k_pci sbsa_gwdt + CPU: 2 PID: 106 Comm: kworker/u8:5 Not tainted 6.3.0-rc7-next-20230418-00549-g1e096a17625a-dirty #9 + Hardware name: Freebox V7R Board (DT) + Workqueue: ath11k_qmi_driver_event ath11k_qmi_driver_event_work + pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) + pc : wiphy_register+0x914/0x954 + lr : ieee80211_register_hw+0x67c/0xc10 + sp : ffffff800b123aa0 + x29: ffffff800b123aa0 x28: 0000000000000000 x27: 0000000000000000 + x26: 0000000000000000 x25: 0000000000000006 x24: ffffffc008d51418 + x23: ffffffc008cb0838 x22: ffffff80176c2460 x21: 0000000000000168 + x20: ffffff80176c0000 x19: ffffff80176c03e0 x18: 0000000000000014 + x17: 00000000cbef338c x16: 00000000d2a26f21 x15: 00000000ad6bb85f + x14: 0000000000000020 x13: 0000000000000020 x12: 00000000ffffffbd + x11: 0000000000000208 x10: 00000000fffffdf7 x9 : ffffffc009394718 + x8 : ffffff80176c0528 x7 : 000000007fffffff x6 : 0000000000000006 + x5 : 0000000000000005 x4 : ffffff800b304284 x3 : ffffff800b304284 + x2 : ffffff800b304d98 x1 : 0000000000000000 x0 : 0000000000000000 + Call trace: + wiphy_register+0x914/0x954 + ieee80211_register_hw+0x67c/0xc10 + ath11k_mac_register+0x7c4/0xe10 + ath11k_core_qmi_firmware_ready+0x1f4/0x570 + ath11k_qmi_driver_event_work+0x198/0x590 + process_one_work+0x1b8/0x328 + worker_thread+0x6c/0x414 + kthread+0x100/0x104 + ret_from_fork+0x10/0x20 + ---[ end trace 0000000000000000 ]--- + ath11k_pci 0002:01:00.0: ieee80211 registration failed: -22 + ath11k_pci 0002:01:00.0: failed register the radio with mac80211: -22 + ath11k_pci 0002:01:00.0: failed to create pdev core: -22 + +Signed-off-by: Maxime Bizon +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20230421145445.2612280-1-mbizon@freebox.fr +--- + drivers/net/wireless/ath/ath11k/mac.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/wireless/ath/ath11k/mac.c ++++ b/drivers/net/wireless/ath/ath11k/mac.c +@@ -8892,7 +8892,7 @@ static int ath11k_mac_setup_channels_rat + } + + if (supported_bands & WMI_HOST_WLAN_5G_CAP) { +- if (reg_cap->high_5ghz_chan >= ATH11K_MAX_6G_FREQ) { ++ if (reg_cap->high_5ghz_chan >= ATH11K_MIN_6G_FREQ) { + channels = kmemdup(ath11k_6ghz_channels, + sizeof(ath11k_6ghz_channels), GFP_KERNEL); + if (!channels) { diff --git a/package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch b/package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch deleted file mode 100644 index 6fcd76b1a7a..00000000000 --- a/package/kernel/mac80211/patches/ath11k/101-wifi-ath11k-Remove-disabling-of-80-80-and-160-MHz.patch +++ /dev/null @@ -1,130 +0,0 @@ -From patchwork Mon Apr 17 20:22:27 2023 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -X-Patchwork-Submitter: Muna Sinada -X-Patchwork-Id: 13214540 -X-Patchwork-Delegate: kvalo@adurom.com -Return-Path: -X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on - aws-us-west-2-korg-lkml-1.web.codeaurora.org -Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) - by smtp.lore.kernel.org (Postfix) with ESMTP id 8C359C77B76 - for ; - Mon, 17 Apr 2023 20:26:40 +0000 (UTC) -Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand - id S230070AbjDQU0j (ORCPT - ); - Mon, 17 Apr 2023 16:26:39 -0400 -Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53306 "EHLO - lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org - with ESMTP id S229914AbjDQU0h (ORCPT - ); - Mon, 17 Apr 2023 16:26:37 -0400 -Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com - [205.220.180.131]) - by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67CE24C33 - for ; - Mon, 17 Apr 2023 13:26:24 -0700 (PDT) -Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) - by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id - 33HIsf5q010173; - Mon, 17 Apr 2023 20:22:47 GMT -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; - h=from : to : cc : - subject : date : message-id : mime-version : content-type; s=qcppdkim1; - bh=FGtbeAR6pG0KxyEKVLIRzkq1RXlKfaVfRT1iixzMcII=; - b=jSdZBeFj4RAdCiUPrL/F9n+ufnpxT1pJNfZuA0tfEnUf54SCGUuHT5LtRdojYVh31YSS - aAGDRFvl7tIKqq/c6h4tm7SDdlhWF+MU3sH1YJNrwDeMAUZD+RnviJjo+GfgnEtp9+z7 - PA75vGkpKiuMh6M8QFYB+/XxrJmx/XJBNESfMdAjBuMXnQf4S2yJ/IMwSxPkYKMU3lC6 - DNnUAcgC/8wawYt8T1d8gKWq5CgWls4i1quveZghsbGUuL01i7SRXdKVianDJJsHEa0G - /brUp6LMMeJUgEI8wBfFAtcknzN0ADMVEqsJr+AHvQXnb1iHZyafl6BAeupXNS+Yi+fJ sw== -Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com - [129.46.96.20]) - by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q171gh1hb-1 - (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 - verify=NOT); - Mon, 17 Apr 2023 20:22:47 +0000 -Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com - [10.47.209.196]) - by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id - 33HKMjHs007640 - (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 - verify=NOT); - Mon, 17 Apr 2023 20:22:46 GMT -Received: from msinada-linux.qualcomm.com (10.80.80.8) by - nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server - (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id - 15.2.986.42; Mon, 17 Apr 2023 13:22:44 -0700 -From: Muna Sinada -To: -CC: , - Muna Sinada , - P Praneesh -Subject: [PATCH] wifi: ath11k: Remove disabling of 80+80 and 160 MHz -Date: Mon, 17 Apr 2023 13:22:27 -0700 -Message-ID: <1681762947-13882-1-git-send-email-quic_msinada@quicinc.com> -X-Mailer: git-send-email 2.7.4 -MIME-Version: 1.0 -X-Originating-IP: [10.80.80.8] -X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To - nalasex01a.na.qualcomm.com (10.47.209.196) -X-QCInternal: smtphost -X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 - signatures=585085 -X-Proofpoint-GUID: wqGG1zw0KpXNYk_yFYb16HwLWt9V-6o4 -X-Proofpoint-ORIG-GUID: wqGG1zw0KpXNYk_yFYb16HwLWt9V-6o4 -X-Proofpoint-Virus-Version: vendor=baseguard - engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 - definitions=2023-04-17_13,2023-04-17_01,2023-02-09_01 -X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 - priorityscore=1501 mlxscore=0 - mlxlogscore=796 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 - clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 - classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 - definitions=main-2304170181 -Precedence: bulk -List-ID: -X-Mailing-List: linux-wireless@vger.kernel.org - -This is a regression fix for 80+80 and 160 MHz support bits being -cleared, therefore not adverised. Remove disable of 80+80 and 160 MHz -capability flags and assign valid center frequency 2 similar to -VHT80_80. - -Fixes: 38dfe775d0ab ("wifi: ath11k: push MU-MIMO params from hostapd to hardware") -Reported-by: Robert Marko -Link: https://bugzilla.kernel.org/show_bug.cgi?id=217299 -Co-developed-by: P Praneesh -Signed-off-by: P Praneesh -Signed-off-by: Muna Sinada ---- - drivers/net/wireless/ath/ath11k/mac.c | 4 ---- - drivers/net/wireless/ath/ath11k/wmi.c | 3 ++- - 2 files changed, 2 insertions(+), 5 deletions(-) - ---- a/drivers/net/wireless/ath/ath11k/mac.c -+++ b/drivers/net/wireless/ath/ath11k/mac.c -@@ -5585,10 +5585,6 @@ static int ath11k_mac_copy_he_cap(struct - - he_cap_elem->mac_cap_info[1] &= - IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK; -- he_cap_elem->phy_cap_info[0] &= -- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G; -- he_cap_elem->phy_cap_info[0] &= -- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G; - - he_cap_elem->phy_cap_info[5] &= - ~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK; ---- a/drivers/net/wireless/ath/ath11k/wmi.c -+++ b/drivers/net/wireless/ath/ath11k/wmi.c -@@ -871,7 +871,8 @@ static void ath11k_wmi_put_wmi_channel(s - - chan->band_center_freq2 = arg->channel.band_center_freq1; - -- } else if (arg->channel.mode == MODE_11AC_VHT80_80) { -+ } else if ((arg->channel.mode == MODE_11AC_VHT80_80) || -+ (arg->channel.mode == MODE_11AX_HE80_80)) { - chan->band_center_freq2 = arg->channel.band_center_freq2; - } else { - chan->band_center_freq2 = 0; From 2526b98a624b0b4912634258c386e6c10f7dd52a Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sat, 6 May 2023 02:45:57 +0200 Subject: [PATCH 090/113] tools/xz: update to 5.4.3 Changelog: https://git.tukaani.org/?p=xz.git;a=blob;f=NEWS;h=2f4d35adca6198671434d2988803cc9316ad1ec8;hb=c247d06e1f6cada9a76f4f6225cbd97ea760f52f#l5 Signed-off-by: Nick Hainke --- tools/xz/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/xz/Makefile b/tools/xz/Makefile index 22d2bf32399..67f96aa0de2 100644 --- a/tools/xz/Makefile +++ b/tools/xz/Makefile @@ -7,12 +7,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=xz -PKG_VERSION:=5.4.2 +PKG_VERSION:=5.4.3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=@SF/lzmautils \ http://tukaani.org/xz -PKG_HASH:=aa49909cbd9028c4666a35fa4975f9a6203ed98154fbb8223ee43ef9ceee97c3 +PKG_HASH:=9243a04598d7a70c1f567a0143a255581ac5c64b140fd55fd5cbc1e00b0e6f90 PKG_CPE_ID:=cpe:/a:tukaani:xz HOST_BUILD_PARALLEL:=1 From 08cc6bc6649f0f184868bd950e38c6107abba0ae Mon Sep 17 00:00:00 2001 From: Kabuli Chana Date: Sat, 29 Apr 2023 09:59:53 -0600 Subject: [PATCH 091/113] mwlwifi: update to version 10.3.9.1-20230429 resolve disconnect issue, upstream PR412 Signed-off-by: Kabuli Chana --- package/kernel/mwlwifi/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/kernel/mwlwifi/Makefile b/package/kernel/mwlwifi/Makefile index 34dceabf59b..130ed01fdc2 100644 --- a/package/kernel/mwlwifi/Makefile +++ b/package/kernel/mwlwifi/Makefile @@ -15,9 +15,9 @@ PKG_LICENSE_FILES:= PKG_SOURCE_URL:=https://github.com/kaloz/mwlwifi PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2023-03-11 -PKG_SOURCE_VERSION:=c916ac13376d1b0801f3f787277fa47ce6b694eb -PKG_MIRROR_HASH:=b95001b60fe5c28f08be5a52b65276d99877be57e567ad7afab95860f6aff57d +PKG_SOURCE_DATE:=2023-04-29 +PKG_SOURCE_VERSION:=6a436714d2ea0d0adf39fc4d7d45e6a17fcc9371 +PKG_MIRROR_HASH:=dcc320a8f859b732ff65c7ded0b5199a625bfba05a775a6bed15ed3c10cb2748 PKG_MAINTAINER:=Imre Kaloz PKG_BUILD_PARALLEL:=1 From ed1217eac188b8d4649730b8cf6d35eac6dcd1a8 Mon Sep 17 00:00:00 2001 From: Felix Baumann Date: Sun, 30 Apr 2023 22:36:09 +0200 Subject: [PATCH 092/113] ramips: mt7621: rename Asus RT-AC57U to v1 rename RT-AC57U to avoid confusion with unsupported revisions 2 and 3 Signed-off-by: Felix Baumann --- ...mt7621_asus_rt-ac57u.dts => mt7621_asus_rt-ac57u-v1.dts} | 4 ++-- target/linux/ramips/image/mt7621.mk | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename target/linux/ramips/dts/{mt7621_asus_rt-ac57u.dts => mt7621_asus_rt-ac57u-v1.dts} (97%) diff --git a/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts b/target/linux/ramips/dts/mt7621_asus_rt-ac57u-v1.dts similarity index 97% rename from target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts rename to target/linux/ramips/dts/mt7621_asus_rt-ac57u-v1.dts index 4e8c68ddf16..bb1c86c2d5d 100644 --- a/target/linux/ramips/dts/mt7621_asus_rt-ac57u.dts +++ b/target/linux/ramips/dts/mt7621_asus_rt-ac57u-v1.dts @@ -6,8 +6,8 @@ #include / { - compatible = "asus,rt-ac57u", "mediatek,mt7621-soc"; - model = "ASUS RT-AC57U"; + compatible = "asus,rt-ac57u-v1", "mediatek,mt7621-soc"; + model = "ASUS RT-AC57U v1"; aliases { led-boot = &led_power; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 135febe3a6d..3e910e88f69 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -286,17 +286,19 @@ define Device/asus_rp-ac87 endef TARGET_DEVICES += asus_rp-ac87 -define Device/asus_rt-ac57u +define Device/asus_rt-ac57u-v1 $(Device/dsa-migration) DEVICE_VENDOR := ASUS DEVICE_MODEL := RT-AC57U + DEVICE_VARIANT := v1 DEVICE_ALT0_VENDOR := ASUS DEVICE_ALT0_MODEL := RT-AC1200GU IMAGE_SIZE := 16064k DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \ kmod-usb-ledtrig-usbport + SUPPORTED_DEVICES += asus,rt-ac57u endef -TARGET_DEVICES += asus_rt-ac57u +TARGET_DEVICES += asus_rt-ac57u-v1 define Device/asus_rt-ac65p $(Device/dsa-migration) From 8bc4aaf45cee578f6e527b1582d0dcf065dc81c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Mon, 10 Apr 2023 23:31:34 +0200 Subject: [PATCH 093/113] ath79: refactor ZTE MF28x dts files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move common dts entries of ZTE MF281 and ZTE MF286 to a common .dtsi file to reduce redundancies. Signed-off-by: Andreas Böhler --- target/linux/ath79/dts/qca9563_zte_mf281.dts | 343 ++++++------------ target/linux/ath79/dts/qca9563_zte_mf286.dtsi | 127 +------ target/linux/ath79/dts/qca9563_zte_mf28x.dtsi | 136 +++++++ 3 files changed, 255 insertions(+), 351 deletions(-) create mode 100644 target/linux/ath79/dts/qca9563_zte_mf28x.dtsi diff --git a/target/linux/ath79/dts/qca9563_zte_mf281.dts b/target/linux/ath79/dts/qca9563_zte_mf281.dts index 2f4b7316bf9..9205061e243 100644 --- a/target/linux/ath79/dts/qca9563_zte_mf281.dts +++ b/target/linux/ath79/dts/qca9563_zte_mf281.dts @@ -3,246 +3,157 @@ // Copyright (c) 2021, 2022 Lech Perczak // Copyright (c) 2022 David Bauer -#include "qca956x.dtsi" - -#include -#include -#include +#include "qca9563_zte_mf28x.dtsi" / { model = "ZTE MF281"; compatible = "zte,mf281", "qca,qca9563"; - aliases { - led-boot = &led_debug; - led-failsafe = &led_debug; - led-running = &led_debug; - led-upgrade = &led_debug; - label-mac-device = ð0; - }; - leds { - compatible = "gpio-leds"; pinctrl-names = "default"; pinctrl-0 = <&enable_wlan_led_gpio>; - - /* Hidden SMD LED below signal strength LEDs. - * Visible through slits underside of the case. - */ - led_debug: debug { - label = "green:debug"; - gpios = <&gpio 7 GPIO_ACTIVE_LOW>; - default-state = "on"; - }; - }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - linux,code = ; - gpios = <&gpio 2 GPIO_ACTIVE_LOW>; - debounce-interval = <60>; - }; - - wps { - label = "wps"; - linux,code = ; - gpios = <&gpio 1 GPIO_ACTIVE_LOW>; - debounce-interval = <60>; - }; - }; - - /* This GPIO is used to reset whole board _including_ the modem */ - gpio-restart { - compatible = "gpio-restart"; - gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - active-delay = <3000>; - inactive-delay = <1000>; }; }; -&spi { - status = "okay"; +&led_debug { + label = "green:debug"; + color = ; +}; - flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <25000000>; +&boot_flash { + partitions { + partition@0 { + label = "u-boot"; + reg = <0x0 0xa0000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0xa0000 0x20000>; + read-only; + }; + }; +}; + +&system_flash { + partitions { + partition@0 { + label = "fota-flag"; + reg = <0x000000 0xa0000>; + read-only; + }; + + partition@a0000 { + label = "art"; + reg = <0xa0000 0x80000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + cal_caldata_1000: cal@1000 { + reg = <0x1000 0x440>; + }; + + cal_caldata_5000: cal@5000 { + reg = <0x5000 0x2f20>; + }; + }; + + partition@120000 { + label = "mac"; + reg = <0x120000 0x80000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_mac_0: macaddr@0 { + reg = <0x0 0x6>; + }; + }; + + partition@1a0000 { + label = "reserved2"; + reg = <0x1a0000 0xc0000>; + read-only; + }; + + partition@260000 { + label = "cfg-param"; + reg = <0x260000 0x400000>; + read-only; + }; + + partition@660000 { + label = "log"; + reg = <0x660000 0x400000>; + read-only; + }; + + partition@a60000 { + label = "oops"; + reg = <0xa60000 0xa0000>; + read-only; + }; + + partition@b00000 { + label = "reserved3"; + reg = <0xb00000 0x500000>; + read-only; + }; + + partition@1000000 { + label = "web"; + reg = <0x1000000 0x800000>; + read-only; + }; + + partition@1800000 { + label = "firmware"; + reg = <0x1800000 0x1d00000>; - partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; partition@0 { - label = "u-boot"; - reg = <0x0 0xa0000>; - read-only; + label = "kernel"; + reg = <0x0 0x600000>; }; - partition@80000 { - label = "u-boot-env"; - reg = <0xa0000 0x20000>; - read-only; + partition@600000 { + label = "ubi"; + reg = <0x600000 0x1700000>; }; }; - }; - flash@1 { - compatible = "spi-nand"; - reg = <1>; - spi-max-frequency = <25000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "fota-flag"; - reg = <0x000000 0xa0000>; - read-only; - }; - - partition@a0000 { - label = "art"; - reg = <0xa0000 0x80000>; - read-only; - - compatible = "nvmem-cells"; - #address-cells = <1>; - #size-cells = <1>; - - cal_caldata_1000: cal@1000 { - reg = <0x1000 0x440>; - }; - - cal_caldata_5000: cal@5000 { - reg = <0x5000 0x2f20>; - }; - }; - - partition@120000 { - label = "mac"; - reg = <0x120000 0x80000>; - read-only; - - compatible = "nvmem-cells"; - #address-cells = <1>; - #size-cells = <1>; - - macaddr_mac_0: macaddr@0 { - reg = <0x0 0x6>; - }; - }; - - partition@1a0000 { - label = "reserved2"; - reg = <0x1a0000 0xc0000>; - read-only; - }; - - partition@260000 { - label = "cfg-param"; - reg = <0x260000 0x400000>; - read-only; - }; - - partition@660000 { - label = "log"; - reg = <0x660000 0x400000>; - read-only; - }; - - partition@a60000 { - label = "oops"; - reg = <0xa60000 0xa0000>; - read-only; - }; - - partition@b00000 { - label = "reserved3"; - reg = <0xb00000 0x500000>; - read-only; - }; - - partition@1000000 { - label = "web"; - reg = <0x1000000 0x800000>; - read-only; - }; - - partition@1800000 { - label = "firmware"; - reg = <0x1800000 0x1d00000>; - - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "kernel"; - reg = <0x0 0x600000>; - }; - - partition@600000 { - label = "ubi"; - reg = <0x600000 0x1700000>; - }; - }; - - partition@3500000 { - label = "data"; - reg = <0x3500000 0x1900000>; - read-only; - }; - - partition@4e00000 { - label = "fota"; - reg = <0x4e00000 0x3200000>; - read-only; - }; + partition@3500000 { + label = "data"; + reg = <0x3500000 0x1900000>; + read-only; }; - }; -}; -&mdio0 { - status = "okay"; - - phy0: ethernet-phy@0 { - reg = <0>; - phy-mode = "sgmii"; - - qca,ar8327-initvals = < - 0x04 0x00080080 /* PORT0 PAD MODE CTRL */ - 0x7c 0x0000007e /* PORT0_STATUS */ - >; + partition@4e00000 { + label = "fota"; + reg = <0x4e00000 0x3200000>; + read-only; + }; }; }; ð0 { - status = "okay"; - - phy-mode = "sgmii"; - phy-handle = <&phy0>; - nvmem-cells = <&macaddr_mac_0>; nvmem-cell-names = "mac-address"; }; -&pcie { - status = "okay"; - - wifi@0,0 { - compatible = "qcom,ath10k"; - reg = <0x0 0 0 0 0>; - - nvmem-cells = <&macaddr_mac_0>, <&cal_caldata_5000>; - nvmem-cell-names = "mac-address", "pre-calibration"; - mac-address-increment = <1>; - }; +&wifi_ath10k { + nvmem-cells = <&macaddr_mac_0>, <&cal_caldata_5000>; + nvmem-cell-names = "mac-address", "pre-calibration"; + mac-address-increment = <1>; }; &pinmux { @@ -252,24 +163,6 @@ }; &wmac { - status = "okay"; - nvmem-cells = <&macaddr_mac_0>, <&cal_caldata_1000>; nvmem-cell-names = "mac-address", "calibration"; }; - -&usb_phy0 { - status = "okay"; -}; - -&usb0 { - status = "okay"; -}; - -&usb_phy1 { - status = "okay"; -}; - -&usb1 { - status = "okay"; -}; diff --git a/target/linux/ath79/dts/qca9563_zte_mf286.dtsi b/target/linux/ath79/dts/qca9563_zte_mf286.dtsi index f794195c3f0..df9a9d3f698 100644 --- a/target/linux/ath79/dts/qca9563_zte_mf286.dtsi +++ b/target/linux/ath79/dts/qca9563_zte_mf286.dtsi @@ -1,36 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT // Copyright (c) 2021 Cezary Jackiewicz // Copyright (c) 2021, 2022 Lech Perczak -#include "qca956x.dtsi" - -#include -#include -#include +#include "qca9563_zte_mf28x.dtsi" / { - aliases { - led-boot = &led_debug; - led-failsafe = &led_debug; - led-running = &led_debug; - led-upgrade = &led_debug; - label-mac-device = ð0; - }; - leds { - compatible = "gpio-leds"; pinctrl-names = "default"; pinctrl-0 = <&enable_wlan_led_gpio>; - /* Hidden SMD LED below signal strength LEDs. - * Visible through slits underside of the case, - * and slightly through the case below signal state LEDs - */ - led_debug: led-0 { - function = LED_FUNCTION_DEBUG; - gpios = <&gpio 7 GPIO_ACTIVE_LOW>; - default-state = "on"; - }; - led-1 { function = LED_FUNCTION_WLAN; color = ; @@ -40,22 +17,6 @@ }; keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - linux,code = ; - gpios = <&gpio 2 GPIO_ACTIVE_LOW>; - debounce-interval = <60>; - }; - - wps { - label = "wps"; - linux,code = ; - gpios = <&gpio 1 GPIO_ACTIVE_LOW>; - debounce-interval = <60>; - }; - wifi { label = "wifi"; linux,code = ; @@ -63,72 +24,6 @@ debounce-interval = <60>; }; }; - - /* This GPIO is used to reset whole board _including_ the modem */ - gpio-restart { - compatible = "gpio-restart"; - gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; - active-delay = <3000>; - inactive-delay = <1000>; - }; -}; - -&spi { - status = "okay"; - - boot_flash: flash@0 { - compatible = "jedec,spi-nor"; - reg = <0>; - spi-max-frequency = <25000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - }; - }; - - system_flash: flash@1 { - compatible = "spi-nand"; - reg = <1>; - spi-max-frequency = <25000000>; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - }; - }; -}; - -&mdio0 { - status = "okay"; - - phy0: ethernet-phy@0 { - reg = <0>; - phy-mode = "sgmii"; - - qca,ar8327-initvals = < - 0x04 0x00080080 /* PORT0 PAD MODE CTRL */ - 0x7c 0x0000007e /* PORT0_STATUS */ - >; - }; -}; - -ð0 { - status = "okay"; - - phy-mode = "sgmii"; - phy-handle = <&phy0>; -}; - -&pcie { - status = "okay"; - - wifi_ath10k: wifi@0,0 { - compatible = "qcom,ath10k"; - reg = <0x0 0 0 0 0>; - }; }; &pinmux { @@ -136,23 +31,3 @@ pinctrl-single,bits = <0x10 0x0 0xff000000>; }; }; - -&wmac { - status = "okay"; -}; - -&usb_phy0 { - status = "okay"; -}; - -&usb0 { - status = "okay"; -}; - -&usb_phy1 { - status = "okay"; -}; - -&usb1 { - status = "okay"; -}; diff --git a/target/linux/ath79/dts/qca9563_zte_mf28x.dtsi b/target/linux/ath79/dts/qca9563_zte_mf28x.dtsi new file mode 100644 index 00000000000..1edcd7e5ea6 --- /dev/null +++ b/target/linux/ath79/dts/qca9563_zte_mf28x.dtsi @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright (c) 2021 Cezary Jackiewicz +// Copyright (c) 2021, 2022 Lech Perczak +#include "qca956x.dtsi" + +#include +#include +#include + +/ { + aliases { + led-boot = &led_debug; + led-failsafe = &led_debug; + led-running = &led_debug; + led-upgrade = &led_debug; + label-mac-device = ð0; + }; + + leds { + compatible = "gpio-leds"; + + /* Hidden SMD LED below signal strength LEDs. + * Visible through slits underside of the case, + * and slightly through the case below signal state LEDs + */ + led_debug: led-0 { + function = LED_FUNCTION_DEBUG; + gpios = <&gpio 7 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 2 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + }; + + /* This GPIO is used to reset whole board _including_ the modem */ + gpio-restart { + compatible = "gpio-restart"; + gpios = <&gpio 5 GPIO_ACTIVE_HIGH>; + active-delay = <3000>; + inactive-delay = <1000>; + }; +}; + +&spi { + status = "okay"; + + boot_flash: flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; + + system_flash: flash@1 { + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <25000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + phy-mode = "sgmii"; + + qca,ar8327-initvals = < + 0x04 0x00080080 /* PORT0 PAD MODE CTRL */ + 0x7c 0x0000007e /* PORT0_STATUS */ + >; + }; +}; + +ð0 { + status = "okay"; + + phy-mode = "sgmii"; + phy-handle = <&phy0>; +}; + +&pcie { + status = "okay"; + + wifi_ath10k: wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0x0 0 0 0 0>; + }; +}; + +&wmac { + status = "okay"; +}; + +&usb_phy0 { + status = "okay"; +}; + +&usb0 { + status = "okay"; +}; + +&usb_phy1 { + status = "okay"; +}; + +&usb1 { + status = "okay"; +}; From 590d1fd0e636f627bbfeb988909ec36cc5450a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Sat, 29 Apr 2023 20:48:47 +0200 Subject: [PATCH 094/113] ath79: add support for ZTE MF282 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ZTE MF282 is a LTE router used (exclusively?) by the network operator "3". Specifications ============== SoC: QCA9563 (775MHz) RAM: 128MiB Flash: 8MiB SPI-NOR + 128MiB SPI-NAND LAN: 1x GBit LAN LTE: ZTE MF270 (Cat4), detected as P685M WiFi: QCA9880ac + QCA9560bgn MAC addresses ============= LAN: from config WiFi 1: from config WiFi 2: +1 Installation ============ TFTP installation using UART is preferred. Disassemble the device and connect serial. Put the initramfs image as openwrt.bin to your TFTP server and configure a static IP of 192.168.1.100. Load the initramfs image by typing: setenv serverip 192.168.1.100 setenv ipaddr 192.168.1.1 tftpboot 0x82000000 openwrt.bin bootm 0x82000000 From this intiramfs boot you can take a backup of the currently installed partitions as no vendor firmware is available for download. Once booted, transfer the sysupgrade image and run sysupgrade. LTE Modem ========= The LTE modem is probably the same as in the MF283+, all instructions apply. Configuring the connection using modemmanager works properly, the modem provides three serial ports and a QMI CDC ethernet interface. Signed-off-by: Andreas Böhler --- target/linux/ath79/dts/qca9563_zte_mf282.dts | 129 ++++++++++++++++++ target/linux/ath79/image/nand.mk | 8 ++ .../nand/base-files/etc/board.d/02_network | 4 + 3 files changed, 141 insertions(+) create mode 100644 target/linux/ath79/dts/qca9563_zte_mf282.dts diff --git a/target/linux/ath79/dts/qca9563_zte_mf282.dts b/target/linux/ath79/dts/qca9563_zte_mf282.dts new file mode 100644 index 00000000000..1f3038daced --- /dev/null +++ b/target/linux/ath79/dts/qca9563_zte_mf282.dts @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +// Copyright (c) 2021 Cezary Jackiewicz +// Copyright (c) 2021, 2022 Lech Perczak +// Copyright (c) 2022 David Bauer +// Copyright (c) 2023 Andreas Böhler + +#include "qca9563_zte_mf28x.dtsi" + +/ { + model = "ZTE MF282"; + compatible = "zte,mf282", "qca,qca9563"; + + ubi-concat { + compatible = "mtd-concat"; + devices = <&ubiconcat0 &ubiconcat1>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + reg = <0x0 0x7440000>; + label = "ubi"; + }; + }; + }; +}; + +&led_debug { + label = "blue:debug"; + color = ; +}; + +&boot_flash { + partitions { + partition@0 { + label = "u-boot"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "u-boot-env"; + reg = <0x80000 0x20000>; + read-only; + }; + }; +}; + +&system_flash { + partitions { + partition@0 { + label = "fota-flag"; + reg = <0x000000 0x140000>; + read-only; + }; + + partition@140000 { + label = "caldata"; + reg = <0x140000 0x140000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + cal_caldata_1000: cal@1000 { + reg = <0x1000 0x440>; + }; + + cal_caldata_5000: cal@5000 { + reg = <0x5000 0x844>; + }; + }; + + partition@280000 { + label = "mac"; + reg = <0x280000 0x140000>; + read-only; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_mac_0: macaddr@0 { + reg = <0x0 0x6>; + }; + }; + + /* This encompasses stock cfg-param, oops, web partitions, + * which can be overwritten safely + */ + ubiconcat0: partition@3c0000 { + label = "ubiconcat0"; + reg = <0x3c0000 0xf40000>; + }; + + /* Kernel MTD size is increased to 8MB from stock 3MB */ + partition@1300000 { + label = "kernel"; + reg = <0x1300000 0x800000>; + }; + + /* This encompasses stock rootfs, data, fota partitions, + * which can be overwritten safely + */ + ubiconcat1: partition@1b00000 { + label = "ubiconcat1"; + reg = <0x1b00000 0x6500000>; + }; + }; +}; + +ð0 { + nvmem-cells = <&macaddr_mac_0>; + nvmem-cell-names = "mac-address"; +}; + +&wifi_ath10k { + nvmem-cells = <&macaddr_mac_0>, <&cal_caldata_5000>; + nvmem-cell-names = "mac-address", "calibration"; + mac-address-increment = <1>; +}; + +&wmac { + nvmem-cells = <&macaddr_mac_0>, <&cal_caldata_1000>; + nvmem-cell-names = "mac-address", "calibration"; +}; diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index 40c57d8b06f..10a54850106 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -390,6 +390,14 @@ define Device/zte_mf281 endef TARGET_DEVICES += zte_mf281 +define Device/zte_mf282 + $(Device/zte_mf28x_common) + DEVICE_MODEL := MF282 + DEVICE_PACKAGES += ath10k-firmware-qca988x-ct kmod-usb-net-qmi-wwan \ + kmod-usb-serial-option uqmi +endef +TARGET_DEVICES += zte_mf282 + define Device/zte_mf286 $(Device/zte_mf28x_common) DEVICE_MODEL := MF286 diff --git a/target/linux/ath79/nand/base-files/etc/board.d/02_network b/target/linux/ath79/nand/base-files/etc/board.d/02_network index 137f3aa11b3..243c5bb7aaa 100644 --- a/target/linux/ath79/nand/base-files/etc/board.d/02_network +++ b/target/linux/ath79/nand/base-files/etc/board.d/02_network @@ -66,6 +66,10 @@ ath79_setup_interfaces() ucidef_add_switch "switch0" \ "0@eth0" "5:lan" ;; + zte,mf282) + ucidef_set_interface_lan "eth0" + ucidef_set_interface "wan" device "/dev/cdc-wdm0" protocol "qmi" + ;; zte,mf286|\ zte,mf286a|\ zte,mf286r) From 12b96757e5425c9fc4c38e564d0448ecf5655acc Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Sun, 30 Apr 2023 11:53:40 +0200 Subject: [PATCH 095/113] iproute2: update to 6.3.0 Release Notes: https://lore.kernel.org/netdev/20230427090253.7a92616b@hermes.local/T/ Signed-off-by: Nick Hainke --- package/network/utils/iproute2/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile index 2cd14fe83dc..101ca673244 100644 --- a/package/network/utils/iproute2/Makefile +++ b/package/network/utils/iproute2/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=iproute2 -PKG_VERSION:=6.2.0 +PKG_VERSION:=6.3.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2 -PKG_HASH:=4d72730200ec5b2aabaa1a2f20553c6748292f065d9a154c7d5e22559df9fd62 +PKG_HASH:=dfb2a98db96e7a653cffc6693335a1a466e29a34b6ac528be48f35e1d2766732 PKG_BUILD_PARALLEL:=1 PKG_BUILD_DEPENDS:=iptables PKG_LICENSE:=GPL-2.0 From 1108f6cb8b115608c486552f1210fea5b955ea5f Mon Sep 17 00:00:00 2001 From: Lech Perczak Date: Wed, 3 May 2023 14:34:25 +0200 Subject: [PATCH 096/113] umbim: allow forcing DHCP/DHCPv6 configuration To support the widest variety of modems, allow restoring previous behaviour of configuring the link throug means of DHCP(v6) exclusively. Change the default value of "dhcp" and "dhcpv6" UCI options to "auto", while keeping the default behaviour of "prefer out-of-band configuration", intact. Setting "dhcp" or "dhcpv6" to boolean 1 will now force using DHCP and DHCPv6, respectively. Signed-off-by: Lech Perczak --- .../utils/umbim/files/lib/netifd/proto/mbim.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh index bf07137fc4e..50913e7fa04 100755 --- a/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh +++ b/package/network/utils/umbim/files/lib/netifd/proto/mbim.sh @@ -20,8 +20,8 @@ proto_mbim_init_config() { proto_config_add_string username proto_config_add_string password [ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6 - proto_config_add_boolean dhcp - proto_config_add_boolean dhcpv6 + proto_config_add_string dhcp + proto_config_add_string dhcpv6 proto_config_add_string pdptype proto_config_add_int mtu proto_config_add_defaults @@ -199,15 +199,15 @@ _proto_mbim_setup() { proto_init_update "$ifname" 1 proto_send_update "$interface" - [ -z "$dhcp" ] && dhcp=1 - [ -z "$dhcpv6" ] && dhcpv6=1 + [ -z "$dhcp" ] && dhcp="auto" + [ -z "$dhcpv6" ] && dhcpv6="auto" [ "$iptype" != "ipv6" ] && { json_init json_add_string name "${interface}_4" json_add_string ifname "@$interface" ipv4address=$(_proto_mbim_get_field ipv4address "$mbimconfig") - if [ -n "$ipv4address" ]; then + if [ -n "$ipv4address" -a "$dhcp" != 1 ]; then json_add_string proto "static" json_add_array ipaddr @@ -222,7 +222,7 @@ _proto_mbim_setup() { json_add_string proto "dhcp" fi - [ "$peerdns" = 0 ] || { + [ "$peerdns" = 0 -a "$dhcp" != 1 ] || { json_add_array dns for server in $(_proto_mbim_get_field ipv4dnsserver "$mbimconfig"); do json_add_string "" "$server" @@ -242,7 +242,7 @@ _proto_mbim_setup() { json_add_string name "${interface}_6" json_add_string ifname "@$interface" ipv6address=$(_proto_mbim_get_field ipv6address "$mbimconfig") - if [ -n "$ipv6address" ]; then + if [ -n "$ipv6address" -a "$dhcpv6" != 1 ]; then json_add_string proto "static" json_add_array ip6addr @@ -265,7 +265,7 @@ _proto_mbim_setup() { json_add_string extendprefix 1 fi - [ "$peerdns" = 0 ] || { + [ "$peerdns" = 0 -a "$dhcpv6" != 1 ] || { json_add_array dns for server in $(_proto_mbim_get_field ipv6dnsserver "$mbimconfig"); do json_add_string "" "$server" From ecdb24814f540cb67cfa0ca64f32d76889853d15 Mon Sep 17 00:00:00 2001 From: Maximilian Weinmann Date: Fri, 4 Nov 2022 00:23:44 +0700 Subject: [PATCH 097/113] ramips: add support for SNR-CPE-ME1 SNR-CPE-ME1 is a wireless WiFi 5 router manufactured by SNR/NAG company. Specification: - SoC : MediaTek MT7621A - RAM : DDR3 256 MiB - Flash : SPI-NOR 16 MiB (GD25Q128CSIG) - WLAN : 2.4 GHz (MediaTek MT7603EN) 5 GHz (MediaTek MT7610EN) - Ethernet : 10/100/1000 Mbps x5 - Switch : MediaTek MT7530 (in SoC) - USB : 3.0 x1 - UART : through-hole on PCB - [J4] 3.3V, RX, TX, GND (57600n8) - Power : 12 VDC, 2 A Flash instruction via TFTP: 1. Boot SNR-CPE-ME1 to recovery mode (hold the reset button while power on) 2. Send firmware via TFTP client: TFTP Server address: 192.168.1.1 TFTP Client address: 192.168.1.131 3. Wait ~120 seconds to complete flashing 4. Do sysupgrade using web-interface Signed-off-by: Maximilian Weinmann --- package/boot/uboot-envtools/files/ramips | 1 + .../linux/ramips/dts/mt7621_snr-cpe-me1.dts | 212 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 12 + .../mt7621/base-files/etc/board.d/01_leds | 3 + 4 files changed, 228 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_snr-cpe-me1.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 4b7eeb8960e..f981fc73efc 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -87,6 +87,7 @@ linksys,ea8100-v2|\ mts,wg430223) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" ;; +snr,snr-cpe-me1|\ snr,snr-cpe-me2-sfp|\ snr,cpe-w4n-mt) idx="$(find_mtd_index uboot-env)" diff --git a/target/linux/ramips/dts/mt7621_snr-cpe-me1.dts b/target/linux/ramips/dts/mt7621_snr-cpe-me1.dts new file mode 100644 index 00000000000..7f0dbf772df --- /dev/null +++ b/target/linux/ramips/dts/mt7621_snr-cpe-me1.dts @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "snr,snr-cpe-me1", "mediatek,mt7621-soc"; + model = "SNR-CPE-ME1"; + + aliases { + label-mac-device = &gmac1; + + led-boot = &led_usb; + led-failsafe = &led_vpn; + led-running = &led_green; + led-upgrade = &led_sys; + }; + + leds { + compatible = "gpio-leds"; + + led_usb: led-0 { // USB Activity + color = ; + function = LED_FUNCTION_USB; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; // [JTAG] JTDO + }; + + led_vpn: led-1 { // VPN Activity + color = ; + function = LED_FUNCTION_INDICATOR; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; // [JTAG] JTCLK + }; + + led_sys: led-2 { // System config + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; // [I2C] I2C_SD + panic-indicator; + }; + + led_green: led-3 { // ? LED + color = ; + function = LED_FUNCTION_HEARTBEAT; + gpios = <&gpio 15 GPIO_ACTIVE_LOW>; // [JTAG] JTMS + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "Reset Button"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; // [JTAG] JTDI + linux,code = ; + }; + }; + + reg_usb_vbus: regulator { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio 17 GPIO_ACTIVE_HIGH>; + enable-active-high; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_factory_e000>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy4>; + + nvmem-cells = <&macaddr_factory_e006>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy4: ethernet-phy@4 { + reg = <4>; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { // MT7603EN + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { // MT7610EN + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { // GD25Q128CSIG + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <44000000>; // 44 MHz + + 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; + + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_factory_e000: macaddr@e000 { + reg = <0xe000 0x6>; + }; + + macaddr_factory_e006: macaddr@e006 { + reg = <0xe006 0x6>; + }; + }; + + partition@50000 { + compatible = "openwrt,uimage", "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + + partition@30001 { + label = "uboot-env"; + reg = <0x30000 0x1000>; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "i2c", "jtag"; + function = "gpio"; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; + + port@1 { + status = "okay"; + label = "lan3"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&xhci { + vbus-supply = <®_usb_vbus>; + vusb33-supply = <®_3p3v>; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 3e910e88f69..d33937a8d74 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -2031,6 +2031,18 @@ define Device/sim_simax1800t endef TARGET_DEVICES += sim_simax1800t +define Device/snr_snr-cpe-me1 + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + IMAGE_SIZE := 15040k + DEVICE_VENDOR := SNR + DEVICE_MODEL := SNR-CPE-ME1 + UIMAGE_NAME := SNR-CPE-ME1-5GHZ-MT + DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x0e kmod-usb3 \ + kmod-usb-ledtrig-usbport uboot-envtools +endef +TARGET_DEVICES += snr_snr-cpe-me1 + define Device/snr_snr-cpe-me2-lite $(Device/dsa-migration) $(Device/uimage-lzma-loader) diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 726d26f0776..b243acbbbf4 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -163,6 +163,9 @@ oraybox,x3a) ucidef_set_led_netdev "wan" "wan link" "red:status" "wan" ucidef_set_led_netdev "lan" "lan link" "green:status" "br-lan" ;; +snr,snr-cpe-me1) + ucidef_set_led_usbport "usb" "USB" "green:usb" "usb1-port1" "usb2-port1" + ;; tplink,archer-a6-v3|\ tplink,archer-ax23-v1|\ tplink,archer-c6-v3|\ From ca81441769dfb10645292eb1ea44ea1b54768a28 Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Tue, 19 Jul 2022 13:34:17 +0200 Subject: [PATCH 098/113] ls-rcw: Add ls1028ardb support Support RCW for NXP LS1028ARDB reference board. Signed-off-by: Wojciech Dubowik --- package/firmware/layerscape/ls-rcw/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/firmware/layerscape/ls-rcw/Makefile b/package/firmware/layerscape/ls-rcw/Makefile index d16b69be2d0..1925eeafeff 100644 --- a/package/firmware/layerscape/ls-rcw/Makefile +++ b/package/firmware/layerscape/ls-rcw/Makefile @@ -31,6 +31,8 @@ BOARDS := \ ls1012a-rdb \ ls1012a-frdm \ ls1012a-frwy-sdboot \ + ls1028a-rdb \ + ls1028a-rdb-sdboot \ ls1043a-rdb \ ls1043a-rdb-sdboot \ ls1046a-frwy \ @@ -47,6 +49,8 @@ BOARDS := \ RCW_ls1012a-rdb :=ls1012ardb/R_SPNH_3508/rcw_1000_default.bin RCW_ls1012a-frdm :=ls1012afrdm/N_SSNP_3305/rcw_800.bin RCW_ls1012a-frwy-sdboot :=ls1012afrwy/N_SSNP_3305/rcw_1000_default.bin +RCW_ls1028a-rdb :=ls1028ardb/R_SQPP_0x85bb/rcw_1300.bin +RCW_ls1028a-rdb-sdboot :=ls1028ardb/R_SQPP_0x85bb/rcw_1500_sdboot.bin RCW_ls1043a-rdb :=ls1043ardb/RR_FQPP_1455/rcw_1600.bin RCW_ls1043a-rdb-sdboot :=ls1043ardb/RR_FQPP_1455/rcw_1600_sdboot.bin RCW_ls1046a-frwy :=ls1046afrwy/NN_NNQNNPNP_3040_0506/rcw_1600_qspiboot.bin From 29149a9b35d52081e62a42b7d60336a58e01728e Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Wed, 12 Apr 2023 14:36:11 +0200 Subject: [PATCH 099/113] uboot-layerscape: Don't fixup kaslr seed when no node There seems to be a difference in firmware calling convention between upstream and NXP kernels. On some cpus like ls1028 it will hang on firmware secure get random when using LF uboot with upstream kernel. Instead of commenting it out, don't call get radnom seed when "kaslr-seed" is not present in device tree. Signed-off-by: Wojciech Dubowik --- ...rmware-get-random-when-no-kaslr-seed.patch | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch diff --git a/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch b/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch new file mode 100644 index 00000000000..681ec90f1ce --- /dev/null +++ b/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch @@ -0,0 +1,33 @@ +Index: uboot-layerscape-lf-6.1.1-1.0.0/arch/arm/cpu/armv8/sec_firmware.c +=================================================================== +--- uboot-layerscape-lf-6.1.1-1.0.0.orig/arch/arm/cpu/armv8/sec_firmware.c ++++ uboot-layerscape-lf-6.1.1-1.0.0/arch/arm/cpu/armv8/sec_firmware.c +@@ -473,12 +473,6 @@ int fdt_fixup_kaslr(void *fdt) + return 0; + } + +- ret = sec_firmware_get_random(rand, 8); +- if (ret < 0) { +- printf("WARNING: No random number to set kaslr-seed\n"); +- return 0; +- } +- + err = fdt_check_header(fdt); + if (err < 0) { + printf("fdt_chosen: %s\n", fdt_strerror(err)); +@@ -490,6 +484,15 @@ int fdt_fixup_kaslr(void *fdt) + if (nodeoffset < 0) + return 0; + ++ if (fdt_find_or_add_subnode(fdt, nodeoffset, "kaslr-seed")) ++ return 0; ++ ++ ret = sec_firmware_get_random(rand, 8); ++ if (ret < 0) { ++ printf("WARNING: No random number to set kaslr-seed\n"); ++ return 0; ++ } ++ + err = fdt_setprop(fdt, nodeoffset, "kaslr-seed", rand, + sizeof(rand)); + if (err < 0) { From b812844c438fae135ba3c65374b2d187bbe070c4 Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Wed, 12 Apr 2023 12:07:32 +0200 Subject: [PATCH 100/113] uboot-layerscape: Add ls1028ardb support Support uboot for NXP LS1028ARDB reference board. GIC V3 has to be disabled in the uboot config to allow booting upstream kernels. This patch can be dropped once uboot is updated to 2022.04 version to nxp-qoriq github lf-6.1.1 branch. Signed-off-by: Wojciech Dubowik --- package/boot/uboot-layerscape/Makefile | 12 ++++++++++++ .../files/fsl_ls1028a-rdb-sdboot-uEnv.txt | 10 ++++++++++ .../uboot-layerscape/files/fsl_ls1028a-rdb-uEnv.txt | 9 +++++++++ ...4-disable-gic-initialization-for-ls1028ardb.patch | 8 ++++++++ 4 files changed, 39 insertions(+) create mode 100644 package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-sdboot-uEnv.txt create mode 100644 package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-uEnv.txt create mode 100644 package/boot/uboot-layerscape/patches/0004-disable-gic-initialization-for-ls1028ardb.patch diff --git a/package/boot/uboot-layerscape/Makefile b/package/boot/uboot-layerscape/Makefile index 53d21f59dc9..f21e51c0189 100644 --- a/package/boot/uboot-layerscape/Makefile +++ b/package/boot/uboot-layerscape/Makefile @@ -45,6 +45,16 @@ define U-Boot/fsl_ls1012a-frwy-sdboot ENV_SIZE:=0x10000 endef +define U-Boot/fsl_ls1028a-rdb + NAME:=NXP LS1028ARDB + UBOOT_CONFIG:=ls1028ardb_tfa +endef + +define U-Boot/fsl_ls1028a-rdb-sdboot + NAME:=NXP LS1028ARDB SD Card Boot + UBOOT_CONFIG:=ls1028ardb_tfa +endef + define U-Boot/fsl_ls1043a-rdb NAME:=NXP LS1043ARDB UBOOT_CONFIG:=ls1043ardb_tfa @@ -127,6 +137,8 @@ UBOOT_TARGETS := \ fsl_ls1012a-frdm \ fsl_ls1012a-rdb \ fsl_ls1012a-frwy-sdboot \ + fsl_ls1028a-rdb \ + fsl_ls1028a-rdb-sdboot \ fsl_ls1043a-rdb \ fsl_ls1043a-rdb-sdboot \ fsl_ls1046a-frwy \ diff --git a/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-sdboot-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-sdboot-uEnv.txt new file mode 100644 index 00000000000..3c39c2263de --- /dev/null +++ b/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-sdboot-uEnv.txt @@ -0,0 +1,10 @@ +fdtaddr=0x8f000000 +loadaddr=0x81000000 +fdt_high=0x8fffffff +initrd_high=0xffffffffffffffff +hwconfig=fsl_ddr:bank_intlv=auto +sd_boot=ext4load mmc 0:1 $loadaddr fitImage;bootm $loadaddr +bootargs=root=/dev/mmcblk0p2 rw rootwait rootfstype=squashfs,f2fs noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 +bootcmd=echo starting openwrt ...;run sd_boot +bootdelay=3 +fsl_bootcmd_mcinitcmd_set=y diff --git a/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-uEnv.txt b/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-uEnv.txt new file mode 100644 index 00000000000..21d41d15b53 --- /dev/null +++ b/package/boot/uboot-layerscape/files/fsl_ls1028a-rdb-uEnv.txt @@ -0,0 +1,9 @@ +fdtaddr=0x8f000000 +loadaddr=0x81000000 +bootm_size=0x10000000 +hwconfig=fsl_ddr:bank_intlv=auto +qspi_boot=sf probe 0:0;sf read $loadaddr 1000000 1000000;bootm $loadaddr +bootargs=rootfstype=squashfs,jffs2 noinitrd earlycon=uart8250,mmio,0x21c0500 console=ttyS0,115200 mtdparts=20c0000.spi:1m(bl2),4m(fip),1m(u-boot-env),128k(secure-boot-headers),48m@0x1000000(firmware) +bootcmd=echo starting openwrt ...;run qspi_boot +bootdelay=3 +fsl_bootcmd_mcinitcmd_set=y diff --git a/package/boot/uboot-layerscape/patches/0004-disable-gic-initialization-for-ls1028ardb.patch b/package/boot/uboot-layerscape/patches/0004-disable-gic-initialization-for-ls1028ardb.patch new file mode 100644 index 00000000000..72011ae3a9b --- /dev/null +++ b/package/boot/uboot-layerscape/patches/0004-disable-gic-initialization-for-ls1028ardb.patch @@ -0,0 +1,8 @@ +--- a/configs/ls1028ardb_tfa_defconfig ++++ b/configs/ls1028ardb_tfa_defconfig +@@ -1,5 +1,4 @@ + CONFIG_ARM=y +-CONFIG_GIC_V3_ITS=y + CONFIG_TARGET_LS1028ARDB=y + CONFIG_TFABOOT=y + CONFIG_SYS_MALLOC_F_LEN=0x6000 From 7700a6f8266cb12fbfd32456a3ae8181bc1cf347 Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Tue, 19 Jul 2022 13:33:39 +0200 Subject: [PATCH 101/113] tfa-layerscape: Add ls1028ardb support Support TF-a for NXP LS1028ARDB reference board. Signed-off-by: Wojciech Dubowik --- package/boot/tfa-layerscape/Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package/boot/tfa-layerscape/Makefile b/package/boot/tfa-layerscape/Makefile index 072036da2f1..adcc005b83f 100644 --- a/package/boot/tfa-layerscape/Makefile +++ b/package/boot/tfa-layerscape/Makefile @@ -63,6 +63,18 @@ define Trusted-Firmware-A/ls1012a-frwy-sdboot BOOT_MODE:=qspi endef +define Trusted-Firmware-A/ls1028a-rdb + TITLE:=NXP LS1028ARDB + PLAT:=ls1028ardb + BOOT_MODE:=flexspi_nor +endef + +define Trusted-Firmware-A/ls1028a-rdb-sdboot + TITLE:=NXP LS1028ARDB SD Boot + PLAT:=ls1028ardb + BOOT_MODE:=sd +endef + define Trusted-Firmware-A/ls1043a-rdb NAME:=NXP LS1043ARDB PLAT:=ls1043ardb @@ -133,6 +145,8 @@ TFA_TARGETS := \ ls1012a-frdm \ ls1012a-rdb \ ls1012a-frwy-sdboot \ + ls1028a-rdb \ + ls1028a-rdb-sdboot \ ls1043a-rdb \ ls1043a-rdb-sdboot \ ls1046a-frwy \ From 924a5aabc708d2ab84ae9c05a580db75b188534f Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Tue, 19 Jul 2022 13:35:12 +0200 Subject: [PATCH 102/113] layerscape: Add ls1028ardb support Add support for NXP LS1028ARDB reference board. It's a dual core Coretex-A53 board with 4G RAM and 5 Eternet ports (4 ports are connected to MSCC Felix switch). The original layout of NXP board has been kept but firmware images are adapted to be more sysupgrade friendly. At the moment NOR and SD boots are supported. NOR flash instructions: * make sd card with sdboot image * boot * write firmware image to spi flash $ mtd write /tmp/openwrt-layerscape-armv8_64b-fsl_ls1028a-rdb- squashfs-firmware.bin /dev/mtd0 * change jumper to NOR boot and reset V3: * Added board specific network defaults for lan/wan v2: * Added INA220 curent monitor, PCF2129 RTC clock and NXP SA56004ED temperature sensor to default packages * removed compat fixups for thist board Signed-off-by: Wojciech Dubowik --- target/linux/layerscape/README | 10 ++++ .../base-files/etc/board.d/02_network | 4 ++ .../base-files/lib/preinit/79_move_config | 1 + .../base-files/lib/upgrade/platform.sh | 5 ++ target/linux/layerscape/image/armv8_64b.mk | 47 +++++++++++++++++++ 5 files changed, 67 insertions(+) diff --git a/target/linux/layerscape/README b/target/linux/layerscape/README index a8d18464687..1e3f707b4f1 100644 --- a/target/linux/layerscape/README +++ b/target/linux/layerscape/README @@ -12,6 +12,7 @@ users can bring up the board without difficulty. LS1012ARDB (QSPI NOR boot) LS1012AFRDM (QSPI NOR boot) LS1012AFRWY (QSPI NOR boot) + LS1028ARDB (QSPI NOR boot | SD card boot) LS1043ARDB (NOR boot | SD card boot) LS1046ARDB (QSPI NOR boot | SD card boot) LS1046AFRWY (QSPI NOR boot | SD card boot) @@ -95,6 +96,15 @@ from SD card. (sdcard.img images are gz-iped to save space. Please extract them => sf write a0000000 0 $filesize => reset +* LS1028ARDB + Board has only one bank. Those commands will replace stock bootloader + and firmware. + => tftp a0000000 -firmware.bin + => sf probe 0:0 + => sf erase 0 +$filesize + => sf write a0000000 0 $filesize + => reset + * LS1043ARDB Start up from bank0, and program firmware to bank4 with below commands. Switch to bank4 to start up OpenWrt. diff --git a/target/linux/layerscape/base-files/etc/board.d/02_network b/target/linux/layerscape/base-files/etc/board.d/02_network index b46f0b06215..172172c12c6 100644 --- a/target/linux/layerscape/base-files/etc/board.d/02_network +++ b/target/linux/layerscape/base-files/etc/board.d/02_network @@ -5,6 +5,10 @@ board_config_update case "$(board_name)" in + fsl,ls1028a-rdb|\ + fsl,ls1028a-rdb-sdboot) + ucidef_set_interfaces_lan_wan "swp0 swp1 swp2 swp3" "eth0" + ;; traverse,ls1043v) ucidef_set_interface_lan "eth0 eth1 eth2 eth3" ucidef_set_interface_wan "eth4" diff --git a/target/linux/layerscape/base-files/lib/preinit/79_move_config b/target/linux/layerscape/base-files/lib/preinit/79_move_config index 901a289b66f..5519e059d9d 100644 --- a/target/linux/layerscape/base-files/lib/preinit/79_move_config +++ b/target/linux/layerscape/base-files/lib/preinit/79_move_config @@ -10,6 +10,7 @@ move_config() { fsl,ls1012a-frwy-sdboot | \ fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr-sdboot | \ + fsl,ls1028a-rdb-sdboot | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-frwy-sdboot | \ fsl,ls1046a-rdb-sdboot | \ diff --git a/target/linux/layerscape/base-files/lib/upgrade/platform.sh b/target/linux/layerscape/base-files/lib/upgrade/platform.sh index 857be5a744b..e88dfdf145c 100644 --- a/target/linux/layerscape/base-files/lib/upgrade/platform.sh +++ b/target/linux/layerscape/base-files/lib/upgrade/platform.sh @@ -71,6 +71,7 @@ platform_copy_config() { fsl,ls1012a-frwy-sdboot | \ fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr-sdboot | \ + fsl,ls1028a-rdb-sdboot | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-frwy-sdboot | \ fsl,ls1046a-rdb-sdboot | \ @@ -95,6 +96,8 @@ platform_check_image() { fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr | \ fsl,ls1021a-twr-sdboot | \ + fsl,ls1028a-rdb | \ + fsl,ls1028a-rdb-sdboot | \ fsl,ls1043a-rdb | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-frwy | \ @@ -130,6 +133,7 @@ platform_do_upgrade() { fsl,ls1012a-frdm | \ fsl,ls1012a-rdb | \ fsl,ls1021a-twr | \ + fsl,ls1028a-rdb | \ fsl,ls1043a-rdb | \ fsl,ls1046a-frwy | \ fsl,ls1046a-rdb | \ @@ -142,6 +146,7 @@ platform_do_upgrade() { fsl,ls1012a-frwy-sdboot | \ fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr-sdboot | \ + fsl,ls1028a-rdb-sdboot | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-frwy-sdboot | \ fsl,ls1046a-rdb-sdboot | \ diff --git a/target/linux/layerscape/image/armv8_64b.mk b/target/linux/layerscape/image/armv8_64b.mk index 4a69f1c19e1..f5a6a055fb2 100644 --- a/target/linux/layerscape/image/armv8_64b.mk +++ b/target/linux/layerscape/image/armv8_64b.mk @@ -98,6 +98,53 @@ define Device/fsl_ls1012a-frwy-sdboot endef TARGET_DEVICES += fsl_ls1012a-frwy-sdboot +define Device/fsl_ls1028a-rdb + DEVICE_VENDOR := NXP + DEVICE_MODEL := LS1028A-RDB + DEVICE_VARIANT := Default + DEVICE_DTS := freescale/fsl-ls1028a-rdb + KERNEL = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb + DEVICE_PACKAGES += \ + trusted-firmware-a-ls1028a-rdb \ + kmod-hwmon-ina2xx \ + kmod-hwmon-lm90 \ + kmod-rtc-pcf2127 + IMAGE/firmware.bin := \ + ls-clean | \ + ls-append $(1)-bl2.pbl | pad-to 1M | \ + ls-append $(1)-fip.bin | pad-to 5M | \ + ls-append $(1)-uboot-env.bin | pad-to 16M | \ + append-kernel | \ + append-rootfs | pad-rootfs | check-size + IMAGE/sysupgrade.bin := \ + append-kernel | \ + append-rootfs | pad-rootfs | \ + check-size $(LS_SYSUPGRADE_IMAGE_SIZE) | append-metadata +endef +TARGET_DEVICES += fsl_ls1028a-rdb + +define Device/fsl_ls1028a-rdb-sdboot + $(Device/fsl-sdboot) + DEVICE_VENDOR := NXP + DEVICE_MODEL := LS1028A-RDB + DEVICE_VARIANT := SD Card Boot + DEVICE_DTS := freescale/fsl-ls1028a-rdb + DEVICE_PACKAGES += \ + trusted-firmware-a-ls1028a-rdb-sdboot \ + kmod-hwmon-ina2xx \ + kmod-hwmon-lm90 \ + kmod-rtc-pcf2127 + IMAGE/sdcard.img.gz := \ + ls-clean | \ + ls-append-sdhead $(1) | pad-to 4K | \ + ls-append $(1)-bl2.pbl | pad-to 1M | \ + ls-append $(1)-fip.bin | pad-to 5M | \ + ls-append $(1)-uboot-env.bin | pad-to 16M | \ + ls-append-kernel | pad-to $(LS_SD_ROOTFSPART_OFFSET)M | \ + append-rootfs | pad-to $(LS_SD_IMAGE_SIZE)M | gzip +endef +TARGET_DEVICES += fsl_ls1028a-rdb-sdboot + define Device/fsl_ls1043a-rdb $(Device/fix-sysupgrade) DEVICE_VENDOR := NXP From 326eb6e482498a676c22d4daa1629ce8c273980d Mon Sep 17 00:00:00 2001 From: Wojciech Dubowik Date: Wed, 12 Apr 2023 15:22:13 +0200 Subject: [PATCH 103/113] layerscape: Add support for Felix DSA switch It's present on LS1028ARDB reference board from NXP. Signed-off-by: Wojciech Dubowik --- target/linux/layerscape/armv8_64b/config-5.15 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/linux/layerscape/armv8_64b/config-5.15 b/target/linux/layerscape/armv8_64b/config-5.15 index 73815b174de..3fe55e61188 100644 --- a/target/linux/layerscape/armv8_64b/config-5.15 +++ b/target/linux/layerscape/armv8_64b/config-5.15 @@ -495,6 +495,7 @@ CONFIG_MOUSE_PS2_TRACKPOINT=y # CONFIG_MOUSE_VSXXXAA is not set CONFIG_MPILIB=y CONFIG_MRP=y +CONFIG_MSCC_OCELOT_SWITCH_LIB=y CONFIG_MTD_CFI_ADV_OPTIONS=y # CONFIG_MTD_CFI_GEOMETRY is not set CONFIG_MTD_CFI_STAA=y @@ -527,6 +528,10 @@ CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK=y CONFIG_NEED_SG_DMA_LENGTH=y CONFIG_NET_DEVLINK=y +CONFIG_NET_DSA=y +CONFIG_NET_DSA_MSCC_FELIX=y +CONFIG_NET_DSA_TAG_OCELOT=y +CONFIG_NET_DSA_TAG_OCELOT_8021Q=y CONFIG_NET_FAILOVER=y CONFIG_NET_FLOW_LIMIT=y CONFIG_NET_NS=y From 3af984e46e37d5fa2e700143d85a199c85653872 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 6 May 2023 19:28:52 +0200 Subject: [PATCH 104/113] realtek: properly update port masks when port leaves bridge Correctly update the isolation mask of the port being configured. The port_bitmap variable should contain all other bridge members and needs to be actually removed from the isolation mask instead of added to it. Also actually remove the port being configured from the pm field of the other ports, so that any other ports that are currently disabled will be configured correctly when they are enabled. Fixes: df8e6be59a1f ("rtl838x: add new architecture") [fixed updating pm field of other ports] Fixes: 2b88563ee5aa ("realtek: update the tree to the latest refactored version") [reintroduced incorrect pm field update] Fixes: 27029277f98d ("realtek: add switch driver support for the RTL93XX based switches") Signed-off-by: Jan Hoffmann --- .../realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 10 +++++----- .../realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 63461ff5734..220f1d5d281 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1227,7 +1227,7 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *bridge) { struct rtl838x_switch_priv *priv = ds->priv; - u64 port_bitmap = BIT_ULL(priv->cpu_port), v; + u64 port_bitmap = 0, v; int i; pr_debug("%s %x: %d", __func__, (u32)priv, port); @@ -1245,16 +1245,16 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, if (priv->ports[i].enable) priv->r->traffic_disable(i, port); - priv->ports[i].pm |= BIT_ULL(port); - port_bitmap &= ~BIT_ULL(i); + priv->ports[i].pm &= ~BIT_ULL(port); + port_bitmap |= BIT_ULL(i); } } store_mcgroups(priv, port); - /* Add all other ports to this port matrix. */ + /* Remove all other ports from this port matrix. */ if (priv->ports[port].enable) { v = priv->r->traffic_get(port); - v |= port_bitmap; + v &= ~port_bitmap; priv->r->traffic_set(port, v); } priv->ports[port].pm &= ~port_bitmap; diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 83a0441ce27..7eebb2107f8 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1212,7 +1212,7 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *bridge) { struct rtl838x_switch_priv *priv = ds->priv; - u64 port_bitmap = BIT_ULL(priv->cpu_port), v; + u64 port_bitmap = 0, v; pr_debug("%s %x: %d", __func__, (u32)priv, port); mutex_lock(&priv->reg_mutex); @@ -1229,16 +1229,16 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, if (priv->ports[i].enable) priv->r->traffic_disable(i, port); - priv->ports[i].pm |= BIT_ULL(port); - port_bitmap &= ~BIT_ULL(i); + priv->ports[i].pm &= ~BIT_ULL(port); + port_bitmap |= BIT_ULL(i); } } store_mcgroups(priv, port); - /* Add all other ports to this port matrix. */ + /* Remove all other ports from this port matrix. */ if (priv->ports[port].enable) { v = priv->r->traffic_get(port); - v |= port_bitmap; + v &= ~port_bitmap; priv->r->traffic_set(port, v); } priv->ports[port].pm &= ~port_bitmap; From 4c0a1667f3e752d31b22ca699a9a3fda5eb47dc7 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 6 May 2023 19:28:53 +0200 Subject: [PATCH 105/113] realtek: initialize port masks to match the default state All ports are disabled by default, so configure the port isolation masks and the pm field accordingly in the setup function. When port_enable is called for a port, the isolation masks will be set up so that traffic can flow between the port and the CPU. While at it, change the code to also use the traffic_set method in rtl83xx_setup, instead of writing to the RTL838x_PORT_ISO_CTRL(i) registers directly. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 23 +++++++++---------- .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 23 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 220f1d5d281..b5b39336a68 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -176,7 +176,6 @@ static int rtl83xx_setup(struct dsa_switch *ds) { int i; struct rtl838x_switch_priv *priv = ds->priv; - u64 port_bitmap = BIT_ULL(priv->cpu_port); pr_debug("%s called\n", __func__); @@ -187,18 +186,16 @@ static int rtl83xx_setup(struct dsa_switch *ds) priv->ports[i].enable = false; priv->ports[priv->cpu_port].enable = true; - /* Isolate ports from each other: traffic only CPU <-> port */ - /* Setting bit j in register RTL838X_PORT_ISO_CTRL(i) allows - * traffic from source port i to destination port j + /* Configure ports so they are disabled by default, but once enabled + * they will work in isolated mode (only traffic between port and CPU). */ for (i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) { - priv->r->set_port_reg_be(BIT_ULL(priv->cpu_port) | BIT_ULL(i), - priv->r->port_iso_ctrl(i)); - port_bitmap |= BIT_ULL(i); + priv->ports[i].pm = BIT_ULL(priv->cpu_port); + priv->r->traffic_set(i, BIT_ULL(i)); } } - priv->r->set_port_reg_be(port_bitmap, priv->r->port_iso_ctrl(priv->cpu_port)); + priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); if (priv->family_id == RTL8380_FAMILY_ID) rtl838x_print_matrix(); @@ -240,7 +237,6 @@ static int rtl93xx_setup(struct dsa_switch *ds) { int i; struct rtl838x_switch_priv *priv = ds->priv; - u32 port_bitmap = BIT(priv->cpu_port); pr_info("%s called\n", __func__); @@ -258,13 +254,16 @@ static int rtl93xx_setup(struct dsa_switch *ds) priv->ports[i].enable = false; priv->ports[priv->cpu_port].enable = true; + /* Configure ports so they are disabled by default, but once enabled + * they will work in isolated mode (only traffic between port and CPU). + */ for (i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) { - priv->r->traffic_set(i, BIT_ULL(priv->cpu_port) | BIT_ULL(i)); - port_bitmap |= BIT_ULL(i); + priv->ports[i].pm = BIT_ULL(priv->cpu_port); + priv->r->traffic_set(i, BIT_ULL(i)); } } - priv->r->traffic_set(priv->cpu_port, port_bitmap); + priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); rtl930x_print_matrix(); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 7eebb2107f8..3ecdda205f4 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -167,7 +167,6 @@ static void rtl83xx_port_set_salrn(struct rtl838x_switch_priv *priv, static int rtl83xx_setup(struct dsa_switch *ds) { struct rtl838x_switch_priv *priv = ds->priv; - u64 port_bitmap = BIT_ULL(priv->cpu_port); pr_debug("%s called\n", __func__); @@ -178,18 +177,16 @@ static int rtl83xx_setup(struct dsa_switch *ds) priv->ports[i].enable = false; priv->ports[priv->cpu_port].enable = true; - /* Isolate ports from each other: traffic only CPU <-> port */ - /* Setting bit j in register RTL838X_PORT_ISO_CTRL(i) allows - * traffic from source port i to destination port j + /* Configure ports so they are disabled by default, but once enabled + * they will work in isolated mode (only traffic between port and CPU). */ for (int i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) { - priv->r->set_port_reg_be(BIT_ULL(priv->cpu_port) | BIT_ULL(i), - priv->r->port_iso_ctrl(i)); - port_bitmap |= BIT_ULL(i); + priv->ports[i].pm = BIT_ULL(priv->cpu_port); + priv->r->traffic_set(i, BIT_ULL(i)); } } - priv->r->set_port_reg_be(port_bitmap, priv->r->port_iso_ctrl(priv->cpu_port)); + priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); if (priv->family_id == RTL8380_FAMILY_ID) rtl838x_print_matrix(); @@ -229,7 +226,6 @@ static int rtl83xx_setup(struct dsa_switch *ds) static int rtl93xx_setup(struct dsa_switch *ds) { struct rtl838x_switch_priv *priv = ds->priv; - u32 port_bitmap = BIT(priv->cpu_port); pr_info("%s called\n", __func__); @@ -247,13 +243,16 @@ static int rtl93xx_setup(struct dsa_switch *ds) priv->ports[i].enable = false; priv->ports[priv->cpu_port].enable = true; + /* Configure ports so they are disabled by default, but once enabled + * they will work in isolated mode (only traffic between port and CPU). + */ for (int i = 0; i < priv->cpu_port; i++) { if (priv->ports[i].phy) { - priv->r->traffic_set(i, BIT_ULL(priv->cpu_port) | BIT_ULL(i)); - port_bitmap |= BIT_ULL(i); + priv->ports[i].pm = BIT_ULL(priv->cpu_port); + priv->r->traffic_set(i, BIT_ULL(i)); } } - priv->r->traffic_set(priv->cpu_port, port_bitmap); + priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); rtl930x_print_matrix(); From 5d34fc92eccc7d8f3fd35fd5841c110ca1aefc13 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 6 May 2023 19:28:54 +0200 Subject: [PATCH 106/113] realtek: fix standalone ports in presence of static fdb entries The registers L2_PORT_STATIC_MV_ACT seem to specify the action to take when the source address of a packet exists as a static fdb entry on another port. By default the configured action is to drop such packets. For standalone ports, this behaviour is undesired, as all traffic should be forwarded to the CPU. So change the action to forward on standalone ports. A situation where this issue can occur is when a non-offloaded bond interface is part of a bridge. In that case, the CPU port will have fdb entries for devices connected to the bond interface, which are managed by the assisted learning feature. For now, this is only implemented for RTL838x/RTL839x, as the available set of registers differs for the other devices. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 15 +++++++++++++++ .../files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c | 10 ++++++++++ .../files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h | 14 ++++++++++++++ .../files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c | 11 +++++++++++ .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 15 +++++++++++++++ .../files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c | 10 ++++++++++ .../files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h | 14 ++++++++++++++ .../files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c | 11 +++++++++++ 8 files changed, 100 insertions(+) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index b5b39336a68..2d603cd42cd 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -197,6 +197,14 @@ static int rtl83xx_setup(struct dsa_switch *ds) } priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); + /* For standalone ports, forward packets even if a static fdb + * entry for the source address exists on another port. + */ + if (priv->r->set_static_move_action) { + for (i = 0; i <= priv->cpu_port; i++) + priv->r->set_static_move_action(i, true); + } + if (priv->family_id == RTL8380_FAMILY_ID) rtl838x_print_matrix(); else @@ -1217,6 +1225,10 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, priv->r->traffic_set(port, v); } priv->ports[port].pm |= port_bitmap; + + if (priv->r->set_static_move_action) + priv->r->set_static_move_action(port, false); + mutex_unlock(&priv->reg_mutex); return 0; @@ -1258,6 +1270,9 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, } priv->ports[port].pm &= ~port_bitmap; + if (priv->r->set_static_move_action) + priv->r->set_static_move_action(port, true); + mutex_unlock(&priv->reg_mutex); } diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c index 9ce50989790..74ad0312768 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.c @@ -559,6 +559,15 @@ static void rtl838x_enable_bcast_flood(int port, bool enable) } +static void rtl838x_set_static_move_action(int port, bool forward) +{ + int shift = MV_ACT_PORT_SHIFT(port); + u32 val = forward ? MV_ACT_FORWARD : MV_ACT_DROP; + + sw_w32_mask(MV_ACT_MASK << shift, val << shift, + RTL838X_L2_PORT_STATIC_MV_ACT(port)); +} + static void rtl838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]) { int i; @@ -1750,6 +1759,7 @@ const struct rtl838x_reg rtl838x_reg = { .enable_flood = rtl838x_enable_flood, .enable_mcast_flood = rtl838x_enable_mcast_flood, .enable_bcast_flood = rtl838x_enable_bcast_flood, + .set_static_move_action = rtl838x_set_static_move_action, .stp_get = rtl838x_stp_get, .stp_set = rtl838x_stp_set, .mac_port_ctrl = rtl838x_mac_port_ctrl, diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h index 19049e4c957..3f1f1d49f8e 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h @@ -251,6 +251,19 @@ #define RTL930X_L2_PORT_NEW_SA_FWD(p) (0x8FF4 + (((p / 10) << 2))) #define RTL931X_L2_PORT_NEW_SA_FWD(p) (0xC830 + (((p / 10) << 2))) +#define RTL838X_L2_PORT_MV_ACT(p) (0x335c + (((p >> 4) << 2))) +#define RTL839X_L2_PORT_MV_ACT(p) (0x3b80 + (((p >> 4) << 2))) + +#define RTL838X_L2_PORT_STATIC_MV_ACT(p) (0x327c + (((p >> 4) << 2))) +#define RTL839X_L2_PORT_STATIC_MV_ACT(p) (0x38dc + (((p >> 4) << 2))) + +#define MV_ACT_PORT_SHIFT(p) ((p % 16) * 2) +#define MV_ACT_MASK 0x3 +#define MV_ACT_FORWARD 0 +#define MV_ACT_DROP 1 +#define MV_ACT_TRAP2CPU 2 +#define MV_ACT_COPY2CPU 3 + #define RTL930X_ST_CTRL (0x8798) #define RTL930X_L2_PORT_SABLK_CTRL (0x905c) @@ -982,6 +995,7 @@ struct rtl838x_reg { void (*enable_flood)(int port, bool enable); void (*enable_mcast_flood)(int port, bool enable); void (*enable_bcast_flood)(int port, bool enable); + void (*set_static_move_action)(int port, bool forward); void (*stp_get)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]); void (*stp_set)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]); int (*mac_force_mode_ctrl)(int port); diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c index 986a4b5f45c..c34bff78d73 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl839x.c @@ -602,6 +602,16 @@ static void rtl839x_enable_bcast_flood(int port, bool enable) { } + +static void rtl839x_set_static_move_action(int port, bool forward) +{ + int shift = MV_ACT_PORT_SHIFT(port); + u32 val = forward ? MV_ACT_FORWARD : MV_ACT_DROP; + + sw_w32_mask(MV_ACT_MASK << shift, val << shift, + RTL839X_L2_PORT_STATIC_MV_ACT(port)); +} + irqreturn_t rtl839x_switch_irq(int irq, void *dev_id) { struct dsa_switch *ds = dev_id; @@ -1893,6 +1903,7 @@ const struct rtl838x_reg rtl839x_reg = { .enable_flood = rtl839x_enable_flood, .enable_mcast_flood = rtl839x_enable_mcast_flood, .enable_bcast_flood = rtl839x_enable_bcast_flood, + .set_static_move_action = rtl839x_set_static_move_action, .stp_get = rtl839x_stp_get, .stp_set = rtl839x_stp_set, .mac_force_mode_ctrl = rtl839x_mac_force_mode_ctrl, diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 3ecdda205f4..703306498e0 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -188,6 +188,14 @@ static int rtl83xx_setup(struct dsa_switch *ds) } priv->r->traffic_set(priv->cpu_port, BIT_ULL(priv->cpu_port)); + /* For standalone ports, forward packets even if a static fdb + * entry for the source address exists on another port. + */ + if (priv->r->set_static_move_action) { + for (int i = 0; i <= priv->cpu_port; i++) + priv->r->set_static_move_action(i, true); + } + if (priv->family_id == RTL8380_FAMILY_ID) rtl838x_print_matrix(); else @@ -1202,6 +1210,10 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, priv->r->traffic_set(port, v); } priv->ports[port].pm |= port_bitmap; + + if (priv->r->set_static_move_action) + priv->r->set_static_move_action(port, false); + mutex_unlock(&priv->reg_mutex); return 0; @@ -1242,6 +1254,9 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, } priv->ports[port].pm &= ~port_bitmap; + if (priv->r->set_static_move_action) + priv->r->set_static_move_action(port, true); + mutex_unlock(&priv->reg_mutex); } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c index 504b29822a1..606066aeea9 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.c @@ -543,6 +543,15 @@ static void rtl838x_enable_bcast_flood(int port, bool enable) } +static void rtl838x_set_static_move_action(int port, bool forward) +{ + int shift = MV_ACT_PORT_SHIFT(port); + u32 val = forward ? MV_ACT_FORWARD : MV_ACT_DROP; + + sw_w32_mask(MV_ACT_MASK << shift, val << shift, + RTL838X_L2_PORT_STATIC_MV_ACT(port)); +} + static void rtl838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]) { u32 cmd = 1 << 15 | /* Execute cmd */ @@ -1717,6 +1726,7 @@ const struct rtl838x_reg rtl838x_reg = { .enable_flood = rtl838x_enable_flood, .enable_mcast_flood = rtl838x_enable_mcast_flood, .enable_bcast_flood = rtl838x_enable_bcast_flood, + .set_static_move_action = rtl838x_set_static_move_action, .stp_get = rtl838x_stp_get, .stp_set = rtl838x_stp_set, .mac_port_ctrl = rtl838x_mac_port_ctrl, diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h index a4bfc285a60..bfab576e06e 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h @@ -249,6 +249,19 @@ #define RTL930X_L2_PORT_NEW_SA_FWD(p) (0x8FF4 + (((p / 10) << 2))) #define RTL931X_L2_PORT_NEW_SA_FWD(p) (0xC830 + (((p / 10) << 2))) +#define RTL838X_L2_PORT_MV_ACT(p) (0x335c + (((p >> 4) << 2))) +#define RTL839X_L2_PORT_MV_ACT(p) (0x3b80 + (((p >> 4) << 2))) + +#define RTL838X_L2_PORT_STATIC_MV_ACT(p) (0x327c + (((p >> 4) << 2))) +#define RTL839X_L2_PORT_STATIC_MV_ACT(p) (0x38dc + (((p >> 4) << 2))) + +#define MV_ACT_PORT_SHIFT(p) ((p % 16) * 2) +#define MV_ACT_MASK 0x3 +#define MV_ACT_FORWARD 0 +#define MV_ACT_DROP 1 +#define MV_ACT_TRAP2CPU 2 +#define MV_ACT_COPY2CPU 3 + #define RTL930X_ST_CTRL (0x8798) #define RTL930X_L2_PORT_SABLK_CTRL (0x905c) @@ -978,6 +991,7 @@ struct rtl838x_reg { void (*enable_flood)(int port, bool enable); void (*enable_mcast_flood)(int port, bool enable); void (*enable_bcast_flood)(int port, bool enable); + void (*set_static_move_action)(int port, bool forward); void (*stp_get)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]); void (*stp_set)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]); int (*mac_force_mode_ctrl)(int port); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c index 06fdbd89361..fe5572a4476 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl839x.c @@ -590,6 +590,16 @@ static void rtl839x_enable_bcast_flood(int port, bool enable) { } + +static void rtl839x_set_static_move_action(int port, bool forward) +{ + int shift = MV_ACT_PORT_SHIFT(port); + u32 val = forward ? MV_ACT_FORWARD : MV_ACT_DROP; + + sw_w32_mask(MV_ACT_MASK << shift, val << shift, + RTL839X_L2_PORT_STATIC_MV_ACT(port)); +} + irqreturn_t rtl839x_switch_irq(int irq, void *dev_id) { struct dsa_switch *ds = dev_id; @@ -1855,6 +1865,7 @@ const struct rtl838x_reg rtl839x_reg = { .enable_flood = rtl839x_enable_flood, .enable_mcast_flood = rtl839x_enable_mcast_flood, .enable_bcast_flood = rtl839x_enable_bcast_flood, + .set_static_move_action = rtl839x_set_static_move_action, .stp_get = rtl839x_stp_get, .stp_set = rtl839x_stp_set, .mac_force_mode_ctrl = rtl839x_mac_force_mode_ctrl, From 8ea27bb959b2181a3f3ca08d3f11b2a116960c87 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sat, 6 May 2023 19:28:55 +0200 Subject: [PATCH 107/113] realtek: handle changed flags in VLAN configuration The port_vlan_add method may be called while a port is already a member of that VLAN, so it needs to be able to handle changed flags. Fix it to properly handle when the PVID or UNTAGGED flag was previously set, but now no longer is. To reduce duplication, move PVID configuration to a separate function. Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 42 ++++++++++--------- .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 38 +++++++++-------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 2d603cd42cd..e9fc6f15ed0 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1450,6 +1450,20 @@ static int rtl83xx_vlan_prepare(struct dsa_switch *ds, int port, return 0; } +static void rtl83xx_vlan_set_pvid(struct rtl838x_switch_priv *priv, + int port, int pvid) +{ + /* Set both inner and outer PVID of the port */ + priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, pvid); + priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, pvid); + priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, + PBVLAN_MODE_UNTAG_AND_PRITAG); + priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, + PBVLAN_MODE_UNTAG_AND_PRITAG); + + priv->ports[port].pvid = pvid; +} + static void rtl83xx_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { @@ -1468,20 +1482,11 @@ static void rtl83xx_vlan_add(struct dsa_switch *ds, int port, mutex_lock(&priv->reg_mutex); - if (vlan->flags & BRIDGE_VLAN_INFO_PVID) { - for (v = vlan->vid_begin; v <= vlan->vid_end; v++) { - if (!v) - continue; - /* Set both inner and outer PVID of the port */ - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, v); - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, v); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - - priv->ports[port].pvid = vlan->vid_end; - } + for (v = vlan->vid_begin; v <= vlan->vid_end; v++) { + if (vlan->flags & BRIDGE_VLAN_INFO_PVID) + rtl83xx_vlan_set_pvid(priv, port, v); + else if (priv->ports[port].pvid == v) + rtl83xx_vlan_set_pvid(priv, port, 0); } for (v = vlan->vid_begin; v <= vlan->vid_end; v++) { @@ -1503,6 +1508,8 @@ static void rtl83xx_vlan_add(struct dsa_switch *ds, int port, info.tagged_ports |= BIT_ULL(port); if (vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED) info.untagged_ports |= BIT_ULL(port); + else + info.untagged_ports &= ~BIT_ULL(port); priv->r->vlan_set_untagged(v, info.untagged_ports); pr_debug("Untagged ports, VLAN %d: %llx\n", v, info.untagged_ports); @@ -1537,12 +1544,7 @@ static int rtl83xx_vlan_del(struct dsa_switch *ds, int port, for (v = vlan->vid_begin; v <= vlan->vid_end; v++) { /* Reset to default if removing the current PVID */ if (v == pvid) { - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, 0); - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, 0); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, - PBVLAN_MODE_UNTAG_AND_PRITAG); + rtl83xx_vlan_set_pvid(priv, port, 0); } /* Get port memberships of this vlan */ priv->r->vlan_tables_read(v, &info); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 703306498e0..b50330e1b97 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1434,6 +1434,20 @@ static int rtl83xx_vlan_prepare(struct dsa_switch *ds, int port, return 0; } +static void rtl83xx_vlan_set_pvid(struct rtl838x_switch_priv *priv, + int port, int pvid) +{ + /* Set both inner and outer PVID of the port */ + priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, pvid); + priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, pvid); + priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, + PBVLAN_MODE_UNTAG_AND_PRITAG); + priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, + PBVLAN_MODE_UNTAG_AND_PRITAG); + + priv->ports[port].pvid = pvid; +} + static int rtl83xx_vlan_add(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan, struct netlink_ext_ack *extack) @@ -1456,17 +1470,10 @@ static int rtl83xx_vlan_add(struct dsa_switch *ds, int port, mutex_lock(&priv->reg_mutex); - if (vlan->flags & BRIDGE_VLAN_INFO_PVID && vlan->vid) { - /* Set both inner and outer PVID of the port */ - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, vlan->vid); - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, vlan->vid); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - - priv->ports[port].pvid = vlan->vid; - } + if (vlan->flags & BRIDGE_VLAN_INFO_PVID) + rtl83xx_vlan_set_pvid(priv, port, vlan->vid); + else if (priv->ports[port].pvid == vlan->vid) + rtl83xx_vlan_set_pvid(priv, port, 0); /* Get port memberships of this vlan */ priv->r->vlan_tables_read(vlan->vid, &info); @@ -1486,6 +1493,8 @@ static int rtl83xx_vlan_add(struct dsa_switch *ds, int port, info.tagged_ports |= BIT_ULL(port); if (vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED) info.untagged_ports |= BIT_ULL(port); + else + info.untagged_ports &= ~BIT_ULL(port); priv->r->vlan_set_untagged(vlan->vid, info.untagged_ports); pr_debug("Untagged ports, VLAN %d: %llx\n", vlan->vid, info.untagged_ports); @@ -1518,12 +1527,7 @@ static int rtl83xx_vlan_del(struct dsa_switch *ds, int port, /* Reset to default if removing the current PVID */ if (vlan->vid == pvid) { - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_INNER, 0); - priv->r->vlan_port_pvid_set(port, PBVLAN_TYPE_OUTER, 0); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_INNER, - PBVLAN_MODE_UNTAG_AND_PRITAG); - priv->r->vlan_port_pvidmode_set(port, PBVLAN_TYPE_OUTER, - PBVLAN_MODE_UNTAG_AND_PRITAG); + rtl83xx_vlan_set_pvid(priv, port, 0); } /* Get port memberships of this vlan */ priv->r->vlan_tables_read(vlan->vid, &info); From 81931756e1490547f8a6e1ef510b52af28c60909 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:30 +0200 Subject: [PATCH 108/113] realtek: fix writing/deletion of CAM entries Actually use the index returned by rtl83xx_find_l2_cam_entry. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 8 ++++---- .../realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index e9fc6f15ed0..672675e884d 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1678,7 +1678,7 @@ static int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port, } // Hash buckets full, try CAM - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { rtl83xx_setup_l2_uc_entry(&e, port, vid, mac); @@ -1714,7 +1714,7 @@ static int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { e.valid = false; @@ -1816,7 +1816,7 @@ static void rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, } // Hash buckets full, try CAM - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { if (e.valid) { @@ -1876,7 +1876,7 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index b50330e1b97..dbf87a60728 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1660,7 +1660,7 @@ static int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port, } /* Hash buckets full, try CAM */ - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { rtl83xx_setup_l2_uc_entry(&e, port, vid, mac); @@ -1698,7 +1698,7 @@ static int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { e.valid = false; @@ -1794,7 +1794,7 @@ static int rtl83xx_port_mdb_add(struct dsa_switch *ds, int port, } /* Hash buckets full, try CAM */ - rtl83xx_find_l2_cam_entry(priv, seed, false, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, false, &e); if (idx >= 0) { if (e.valid) { @@ -1857,7 +1857,7 @@ int rtl83xx_port_mdb_del(struct dsa_switch *ds, int port, } /* Check CAM for spillover from hash buckets */ - rtl83xx_find_l2_cam_entry(priv, seed, true, &e); + idx = rtl83xx_find_l2_cam_entry(priv, seed, true, &e); if (idx >= 0) { portmask = rtl83xx_mc_group_del_port(priv, e.mc_portmask_index, port); From 57df840670b6038866ebed877ed9827276b730fe Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:31 +0200 Subject: [PATCH 109/113] realtek: don't treat first multicast portmask entry as reserved There doesn't appear to be a reason to do this, as only the last entry is actually reserved for unknown multicast. This also fixes two issues: - As the increment happened after the bounds check, the value of the actually reserved last entry could be overwritten. - On deletion of entries, a corresponding decrement was missing, causing the wrong entry to be marked as free. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 - target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 1 - 2 files changed, 2 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 672675e884d..e45919d8b50 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -994,7 +994,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - mc_group++; // We cannot use group 0, as this is used for lookup miss flooding portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); priv->r->write_mcast_pmask(mc_group, portmask); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index dbf87a60728..43b6d502f70 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -981,7 +981,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - mc_group++; /* We cannot use group 0, as this is used for lookup miss flooding */ portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); priv->r->write_mcast_pmask(mc_group, portmask); From 3356126b8263a5176bd1b633d428865fb0a4ced5 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:32 +0200 Subject: [PATCH 110/113] realtek: actually remove port from multicast portmask Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 1 + target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 1 + 2 files changed, 2 insertions(+) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index e45919d8b50..bdcbb0a0743 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1024,6 +1024,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr pr_info("%s: %d is lag slave. ignore\n", __func__, port); return portmask; } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (portmask == BIT_ULL(priv->cpu_port)) { portmask &= ~BIT_ULL(priv->cpu_port); diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 43b6d502f70..811c897234c 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1011,6 +1011,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr pr_info("%s: %d is lag slave. ignore\n", __func__, port); return portmask; } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (portmask == BIT_ULL(priv->cpu_port)) { portmask &= ~BIT_ULL(priv->cpu_port); From 6772ae1172ad12cf81b141fd9c5441ad18c0dddf Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:33 +0200 Subject: [PATCH 111/113] realtek: don't add CPU port to multicast portmasks There shouldn't be any reason to forward all multicast to the CPU. The original commit message also doesn't provide a reason for this seemingly unrelated change. The current implementation of the delete method is also broken, as it entirely removes any entry when the portmask contains only the CPU port, even if it was explicitly created. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 7 ++----- .../linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index bdcbb0a0743..270ec172e39 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -994,7 +994,7 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); + portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); return mc_group; @@ -1026,11 +1026,8 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr } portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); - if (portmask == BIT_ULL(priv->cpu_port)) { - portmask &= ~BIT_ULL(priv->cpu_port); - priv->r->write_mcast_pmask(mc_group, portmask); + if (!portmask) clear_bit(mc_group, priv->mc_group_bm); - } return portmask; } diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index 811c897234c..b4cb39ed5d8 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -981,7 +981,7 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) } set_bit(mc_group, priv->mc_group_bm); - portmask = BIT_ULL(port) | BIT_ULL(priv->cpu_port); + portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); return mc_group; @@ -1013,11 +1013,8 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr } portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); - if (portmask == BIT_ULL(priv->cpu_port)) { - portmask &= ~BIT_ULL(priv->cpu_port); - priv->r->write_mcast_pmask(mc_group, portmask); + if (!portmask) clear_bit(mc_group, priv->mc_group_bm); - } return portmask; } From 98a3b52380b7c2632c60c54d86d5c562f5eabfe4 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:34 +0200 Subject: [PATCH 112/113] realtek: remove store_mcgroups/load_mcgroups The current implementation only works when store and load are called for the same port without any other calls in between. This is because the store function only saves a single port number instead of a portmask for each group. It also doesn't take into account that the allocation of multicast group entries might change between store/load calls. As a result, the multicast port mask table gets corrupted. This also includes the reserved entry for unknown multicast, which gets corrupted even when no other mdb entries have been added. Remove the code for storing/loading multicast groups entirely, as the original commit message doesn't offer a convincing reason why this would be necessary in the first place. Fixes: 724e4af530cd ("realtek: Store and Restore MC memberships for port enable/disable") Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 30 ------------------- .../drivers/net/dsa/rtl83xx/rtl838x.h | 1 - .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 26 ---------------- .../drivers/net/dsa/rtl83xx/rtl838x.h | 1 - 4 files changed, 58 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 270ec172e39..6e615be0e50 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -1032,31 +1032,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr return portmask; } -static void store_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - int mc_group; - - for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - u64 portmask = priv->r->read_mcast_pmask(mc_group); - if (portmask & BIT_ULL(port)) { - priv->mc_group_saves[mc_group] = port; - rtl83xx_mc_group_del_port(priv, mc_group, port); - } - } -} - -static void load_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - int mc_group; - - for (mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - if (priv->mc_group_saves[mc_group] == port) { - rtl83xx_mc_group_add_port(priv, mc_group, port); - priv->mc_group_saves[mc_group] = -1; - } - } -} - static int rtl83xx_port_enable(struct dsa_switch *ds, int port, struct phy_device *phydev) { @@ -1075,8 +1050,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port, /* add port to switch mask of CPU_PORT */ priv->r->traffic_enable(priv->cpu_port, port); - load_mcgroups(priv, port); - if (priv->is_lagmember[port]) { pr_debug("%s: %d is lag slave. ignore\n", __func__, port); return 0; @@ -1112,7 +1085,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port) // BUG: This does not work on RTL931X /* remove port from switch mask of CPU_PORT */ priv->r->traffic_disable(priv->cpu_port, port); - store_mcgroups(priv, port); /* remove all other ports in the same bridge from switch mask of port */ v = priv->r->traffic_get(port); @@ -1212,7 +1184,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - load_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { @@ -1257,7 +1228,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - store_mcgroups(priv, port); /* Remove all other ports from this port matrix. */ if (priv->ports[port].enable) { diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h index 3f1f1d49f8e..81656799a7f 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1086,7 +1086,6 @@ struct rtl838x_switch_priv { struct notifier_block fib_nb; bool eee_enabled; unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5]; - int mc_group_saves[MAX_MC_GROUPS]; int n_pie_blocks; struct rhashtable tc_ht; unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5]; diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index b4cb39ed5d8..df78aa3737f 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -1019,27 +1019,6 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr return portmask; } -static void store_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - u64 portmask = priv->r->read_mcast_pmask(mc_group); - if (portmask & BIT_ULL(port)) { - priv->mc_group_saves[mc_group] = port; - rtl83xx_mc_group_del_port(priv, mc_group, port); - } - } -} - -static void load_mcgroups(struct rtl838x_switch_priv *priv, int port) -{ - for (int mc_group = 0; mc_group < MAX_MC_GROUPS; mc_group++) { - if (priv->mc_group_saves[mc_group] == port) { - rtl83xx_mc_group_add_port(priv, mc_group, port); - priv->mc_group_saves[mc_group] = -1; - } - } -} - static int rtl83xx_port_enable(struct dsa_switch *ds, int port, struct phy_device *phydev) { @@ -1058,8 +1037,6 @@ static int rtl83xx_port_enable(struct dsa_switch *ds, int port, /* add port to switch mask of CPU_PORT */ priv->r->traffic_enable(priv->cpu_port, port); - load_mcgroups(priv, port); - if (priv->is_lagmember[port]) { pr_debug("%s: %d is lag slave. ignore\n", __func__, port); return 0; @@ -1095,7 +1072,6 @@ static void rtl83xx_port_disable(struct dsa_switch *ds, int port) /* BUG: This does not work on RTL931X */ /* remove port from switch mask of CPU_PORT */ priv->r->traffic_disable(priv->cpu_port, port); - store_mcgroups(priv, port); /* remove all other ports in the same bridge from switch mask of port */ v = priv->r->traffic_get(port); @@ -1197,7 +1173,6 @@ static int rtl83xx_port_bridge_join(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - load_mcgroups(priv, port); /* Add all other ports to this port matrix. */ if (priv->ports[port].enable) { @@ -1241,7 +1216,6 @@ static void rtl83xx_port_bridge_leave(struct dsa_switch *ds, int port, port_bitmap |= BIT_ULL(i); } } - store_mcgroups(priv, port); /* Remove all other ports from this port matrix. */ if (priv->ports[port].enable) { diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h index bfab576e06e..24d18d61faf 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1082,7 +1082,6 @@ struct rtl838x_switch_priv { struct notifier_block fib_nb; bool eee_enabled; unsigned long int mc_group_bm[MAX_MC_GROUPS >> 5]; - int mc_group_saves[MAX_MC_GROUPS]; int n_pie_blocks; struct rhashtable tc_ht; unsigned long int pie_use_bm[MAX_PIE_ENTRIES >> 5]; From a872570c043f5beee21c3af695f1a5a77f7eab04 Mon Sep 17 00:00:00 2001 From: Jan Hoffmann Date: Sun, 7 May 2023 01:05:35 +0200 Subject: [PATCH 113/113] realtek: remove redundant is_lagmember checks All callers of the rtl83xx_mc_group_* functions already do the same check, so these aren't needed. For rtl83xx_mc_group_alloc, this branch also incorrectly returned 0 instead of a negative value. If the branch wasn't effectively dead code anyway, this could potentially have caused bugs, as 0 is a valid multicast group entry index. Fixes: cde31976e375 ("realtek: Add support for Layer 2 Multicast") Signed-off-by: Jan Hoffmann --- .../files-5.10/drivers/net/dsa/rtl83xx/dsa.c | 15 ++------------- .../files-5.15/drivers/net/dsa/rtl83xx/dsa.c | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c index 6e615be0e50..bff42b088ad 100644 --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c @@ -988,11 +988,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) if (mc_group >= MAX_MC_GROUPS - 1) return -1; - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return 0; - } - set_bit(mc_group, priv->mc_group_bm); portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1005,10 +1000,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask |= BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1020,10 +1012,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (!portmask) diff --git a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c index df78aa3737f..3c67ce5adbb 100644 --- a/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c +++ b/target/linux/realtek/files-5.15/drivers/net/dsa/rtl83xx/dsa.c @@ -975,11 +975,6 @@ static int rtl83xx_mc_group_alloc(struct rtl838x_switch_priv *priv, int port) if (mc_group >= MAX_MC_GROUPS - 1) return -1; - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return 0; - } - set_bit(mc_group, priv->mc_group_bm); portmask = BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -992,10 +987,7 @@ static u64 rtl83xx_mc_group_add_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask |= BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); @@ -1007,10 +999,7 @@ static u64 rtl83xx_mc_group_del_port(struct rtl838x_switch_priv *priv, int mc_gr u64 portmask = priv->r->read_mcast_pmask(mc_group); pr_debug("%s: %d\n", __func__, port); - if (priv->is_lagmember[port]) { - pr_info("%s: %d is lag slave. ignore\n", __func__, port); - return portmask; - } + portmask &= ~BIT_ULL(port); priv->r->write_mcast_pmask(mc_group, portmask); if (!portmask)