From 04c5c1ff70467c4230c427328d77667afb8b9668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gonz=C3=A1lez=20Cabanelas?= Date: Tue, 1 Oct 2024 15:45:26 +0200 Subject: [PATCH 01/29] bmips: fix kernel panic caused by missing CBR address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cbr-reg DTS property uses a wrong name causing the RAC kernel panic again on BCM6358 BCM6368 boards. Use the correct cbr-reg name property. Fixes: 7c9644a7b5 ("bmips: backport upstreamed RAC patches") Signed-off-by: Daniel González Cabanelas Link: https://github.com/openwrt/openwrt/pull/16561 Signed-off-by: Robert Marko --- target/linux/bmips/dts/bcm6358.dtsi | 2 +- target/linux/bmips/dts/bcm6368.dtsi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/bmips/dts/bcm6358.dtsi b/target/linux/bmips/dts/bcm6358.dtsi index d5dee7d1502256..fe14055ef7a7da 100644 --- a/target/linux/bmips/dts/bcm6358.dtsi +++ b/target/linux/bmips/dts/bcm6358.dtsi @@ -42,7 +42,7 @@ cpus { #address-cells = <1>; #size-cells = <0>; - mips-cbr-reg = <0xff400000>; + brcm,bmips-cbr-reg = <0xff400000>; mips-hpt-frequency = <150000000>; cpu@0 { diff --git a/target/linux/bmips/dts/bcm6368.dtsi b/target/linux/bmips/dts/bcm6368.dtsi index 84300c980ab0a2..e50f7a1b0c64aa 100644 --- a/target/linux/bmips/dts/bcm6368.dtsi +++ b/target/linux/bmips/dts/bcm6368.dtsi @@ -43,7 +43,7 @@ cpus { #address-cells = <1>; #size-cells = <0>; - mips-cbr-reg = <0xff400000>; + brcm,bmips-cbr-reg = <0xff400000>; mips-hpt-frequency = <200000000>; cpu@0 { From 5ca8a4a03a0a06ee3ed6f0f7d48e059de420710e Mon Sep 17 00:00:00 2001 From: Aleksander Jan Bajkowski Date: Tue, 1 Oct 2024 20:49:55 +0200 Subject: [PATCH 02/29] lantiq: backport latest upstream patches Backport patch that fixes memory disclosure in packet padding. The downstream driver supports statistics, so when a packet cannot be padded the statistics of dropped packets are incremented. The other patches do not introduce any functional changes. Signed-off-by: Aleksander Jan Bajkowski Link: https://github.com/openwrt/openwrt/pull/16563 Signed-off-by: Hauke Mehrtens --- ...et-lantiq_etop-fix-memory-disclosure.patch | 42 +++++++++++ ...t-lantiq_etop-remove-unused-variable.patch | 24 +++++++ ...tiq_etop-remove-redundant-device-nam.patch | 2 +- .../0028-NET-lantiq-various-etop-fixes.patch | 69 ++++++++++--------- ...iq-wifi-and-ethernet-eeprom-handling.patch | 2 +- ...2-add-support-for-other-Lantiq-SoCs.patch} | 15 ++-- ...S-lantiq-improve-USB-initialization.patch} | 14 ++-- 7 files changed, 123 insertions(+), 45 deletions(-) create mode 100644 target/linux/lantiq/patches-6.6/0025-v6.12-net-ethernet-lantiq_etop-fix-memory-disclosure.patch create mode 100644 target/linux/lantiq/patches-6.6/0026-v6.12-net-ethernet-lantiq_etop-remove-unused-variable.patch rename target/linux/lantiq/patches-6.6/{0050-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch => 0050-v6.11-usb-dwc2-add-support-for-other-Lantiq-SoCs.patch} (84%) rename target/linux/lantiq/patches-6.6/{0051-MIPS-lantiq-improve-USB-initialization.patch => 0051-v6.11-MIPS-lantiq-improve-USB-initialization.patch} (79%) diff --git a/target/linux/lantiq/patches-6.6/0025-v6.12-net-ethernet-lantiq_etop-fix-memory-disclosure.patch b/target/linux/lantiq/patches-6.6/0025-v6.12-net-ethernet-lantiq_etop-fix-memory-disclosure.patch new file mode 100644 index 00000000000000..3b2ac25065091c --- /dev/null +++ b/target/linux/lantiq/patches-6.6/0025-v6.12-net-ethernet-lantiq_etop-fix-memory-disclosure.patch @@ -0,0 +1,42 @@ +From 45c0de18ff2dc9af01236380404bbd6a46502c69 Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Mon, 23 Sep 2024 23:49:49 +0200 +Subject: net: ethernet: lantiq_etop: fix memory disclosure + +When applying padding, the buffer is not zeroed, which results in memory +disclosure. The mentioned data is observed on the wire. This patch uses +skb_put_padto() to pad Ethernet frames properly. The mentioned function +zeroes the expanded buffer. + +In case the packet cannot be padded it is silently dropped. Statistics +are also not incremented. This driver does not support statistics in the +old 32-bit format or the new 64-bit format. These will be added in the +future. In its current form, the patch should be easily backported to +stable versions. + +Ethernet MACs on Amazon-SE and Danube cannot do padding of the packets +in hardware, so software padding must be applied. + +Fixes: 504d4721ee8e ("MIPS: Lantiq: Add ethernet driver") +Signed-off-by: Aleksander Jan Bajkowski +Reviewed-by: Jacob Keller +Reviewed-by: Florian Fainelli +Link: https://patch.msgid.link/20240923214949.231511-2-olek2@wp.pl +Signed-off-by: Paolo Abeni +--- + drivers/net/ethernet/lantiq_etop.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/lantiq_etop.c ++++ b/drivers/net/ethernet/lantiq_etop.c +@@ -482,7 +482,9 @@ ltq_etop_tx(struct sk_buff *skb, struct + unsigned long flags; + u32 byte_offset; + +- len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; ++ if (skb_put_padto(skb, ETH_ZLEN)) ++ return NETDEV_TX_OK; ++ len = skb->len; + + if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { + netdev_err(dev, "tx ring full\n"); diff --git a/target/linux/lantiq/patches-6.6/0026-v6.12-net-ethernet-lantiq_etop-remove-unused-variable.patch b/target/linux/lantiq/patches-6.6/0026-v6.12-net-ethernet-lantiq_etop-remove-unused-variable.patch new file mode 100644 index 00000000000000..94f961d2c8289b --- /dev/null +++ b/target/linux/lantiq/patches-6.6/0026-v6.12-net-ethernet-lantiq_etop-remove-unused-variable.patch @@ -0,0 +1,24 @@ +From 1f803c95693f140bed46cd5581b97592e20b723e Mon Sep 17 00:00:00 2001 +From: Aleksander Jan Bajkowski +Date: Thu, 15 Aug 2024 09:49:56 +0200 +Subject: [PATCH] net: ethernet: lantiq_etop: remove unused variable + +Remove a variable that has never been used. + +Signed-off-by: Aleksander Jan Bajkowski +Link: https://patch.msgid.link/20240815074956.155224-1-olek2@wp.pl +Signed-off-by: Jakub Kicinski +--- + drivers/net/ethernet/lantiq_etop.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/drivers/net/ethernet/lantiq_etop.c ++++ b/drivers/net/ethernet/lantiq_etop.c +@@ -95,7 +95,6 @@ struct ltq_etop_priv { + struct mii_bus *mii_bus; + + struct ltq_etop_chan ch[MAX_DMA_CHAN]; +- int tx_free[MAX_DMA_CHAN >> 1]; + + int tx_burst_len; + int rx_burst_len; diff --git a/target/linux/lantiq/patches-6.6/0027-v6.11-net-ethernet-lantiq_etop-remove-redundant-device-nam.patch b/target/linux/lantiq/patches-6.6/0027-v6.11-net-ethernet-lantiq_etop-remove-redundant-device-nam.patch index abaef6c3a80331..b2e06b86349c5e 100644 --- a/target/linux/lantiq/patches-6.6/0027-v6.11-net-ethernet-lantiq_etop-remove-redundant-device-nam.patch +++ b/target/linux/lantiq/patches-6.6/0027-v6.11-net-ethernet-lantiq_etop-remove-redundant-device-nam.patch @@ -21,7 +21,7 @@ Signed-off-by: Jakub Kicinski --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c -@@ -675,7 +675,6 @@ ltq_etop_probe(struct platform_device *p +@@ -676,7 +676,6 @@ ltq_etop_probe(struct platform_device *p err = -ENOMEM; goto err_out; } diff --git a/target/linux/lantiq/patches-6.6/0028-NET-lantiq-various-etop-fixes.patch b/target/linux/lantiq/patches-6.6/0028-NET-lantiq-various-etop-fixes.patch index 788a34d61abfc3..c761757c1c9783 100644 --- a/target/linux/lantiq/patches-6.6/0028-NET-lantiq-various-etop-fixes.patch +++ b/target/linux/lantiq/patches-6.6/0028-NET-lantiq-various-etop-fixes.patch @@ -5,8 +5,8 @@ Subject: [PATCH 28/36] NET: lantiq: various etop fixes Signed-off-by: John Crispin --- - drivers/net/ethernet/lantiq_etop.c | 530 ++++++++++++++++++++--------- - 1 file changed, 375 insertions(+), 155 deletions(-) + drivers/net/ethernet/lantiq_etop.c | 534 ++++++++++++++++++++--------- + 1 file changed, 379 insertions(+), 155 deletions(-) --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -153,7 +153,7 @@ Signed-off-by: John Crispin struct net_device *netdev; struct napi_struct napi; struct ltq_dma_channel dma; -@@ -89,26 +141,39 @@ struct ltq_etop_chan { +@@ -89,25 +141,39 @@ struct ltq_etop_chan { struct ltq_etop_priv { struct net_device *netdev; struct platform_device *pdev; @@ -163,7 +163,6 @@ Signed-off-by: John Crispin struct mii_bus *mii_bus; - struct ltq_etop_chan ch[MAX_DMA_CHAN]; -- int tx_free[MAX_DMA_CHAN >> 1]; + struct ltq_etop_chan txch; + struct ltq_etop_chan rxch; @@ -197,7 +196,7 @@ Signed-off-by: John Crispin if (!ch->skb[ch->dma.desc]) return -ENOMEM; ch->dma.desc_base[ch->dma.desc].addr = -@@ -143,8 +208,11 @@ ltq_etop_hw_receive(struct ltq_etop_chan +@@ -142,8 +208,11 @@ ltq_etop_hw_receive(struct ltq_etop_chan spin_unlock_irqrestore(&priv->lock, flags); skb_put(skb, len); @@ -209,7 +208,7 @@ Signed-off-by: John Crispin } static int -@@ -152,7 +220,9 @@ ltq_etop_poll_rx(struct napi_struct *nap +@@ -151,7 +220,9 @@ ltq_etop_poll_rx(struct napi_struct *nap { struct ltq_etop_chan *ch = container_of(napi, struct ltq_etop_chan, napi); @@ -219,7 +218,7 @@ Signed-off-by: John Crispin while (work_done < budget) { struct ltq_dma_desc *desc = &ch->dma.desc_base[ch->dma.desc]; -@@ -164,7 +234,9 @@ ltq_etop_poll_rx(struct napi_struct *nap +@@ -163,7 +234,9 @@ ltq_etop_poll_rx(struct napi_struct *nap } if (work_done < budget) { napi_complete_done(&ch->napi, work_done); @@ -229,7 +228,7 @@ Signed-off-by: John Crispin } return work_done; } -@@ -176,12 +248,14 @@ ltq_etop_poll_tx(struct napi_struct *nap +@@ -175,12 +248,14 @@ ltq_etop_poll_tx(struct napi_struct *nap container_of(napi, struct ltq_etop_chan, napi); struct ltq_etop_priv *priv = netdev_priv(ch->netdev); struct netdev_queue *txq = @@ -245,7 +244,7 @@ Signed-off-by: John Crispin dev_kfree_skb_any(ch->skb[ch->tx_free]); ch->skb[ch->tx_free] = NULL; memset(&ch->dma.desc_base[ch->tx_free], 0, -@@ -194,7 +268,9 @@ ltq_etop_poll_tx(struct napi_struct *nap +@@ -193,7 +268,9 @@ ltq_etop_poll_tx(struct napi_struct *nap if (netif_tx_queue_stopped(txq)) netif_tx_start_queue(txq); napi_complete(&ch->napi); @@ -255,7 +254,7 @@ Signed-off-by: John Crispin return 1; } -@@ -202,9 +278,11 @@ static irqreturn_t +@@ -201,9 +278,11 @@ static irqreturn_t ltq_etop_dma_irq(int irq, void *_priv) { struct ltq_etop_priv *priv = _priv; @@ -269,7 +268,7 @@ Signed-off-by: John Crispin return IRQ_HANDLED; } -@@ -216,7 +294,7 @@ ltq_etop_free_channel(struct net_device +@@ -215,7 +294,7 @@ ltq_etop_free_channel(struct net_device ltq_dma_free(&ch->dma); if (ch->dma.irq) free_irq(ch->dma.irq, priv); @@ -278,7 +277,7 @@ Signed-off-by: John Crispin struct ltq_dma_channel *dma = &ch->dma; for (dma->desc = 0; dma->desc < LTQ_DESC_NUM; dma->desc++) -@@ -228,80 +306,137 @@ static void +@@ -227,80 +306,137 @@ static void ltq_etop_hw_exit(struct net_device *dev) { struct ltq_etop_priv *priv = netdev_priv(dev); @@ -465,7 +464,7 @@ Signed-off-by: John Crispin } static void -@@ -320,6 +455,39 @@ static const struct ethtool_ops ltq_etop +@@ -319,6 +455,39 @@ static const struct ethtool_ops ltq_etop }; static int @@ -505,7 +504,7 @@ Signed-off-by: John Crispin ltq_etop_mdio_wr(struct mii_bus *bus, int phy_addr, int phy_reg, u16 phy_data) { u32 val = MDIO_REQUEST | -@@ -327,9 +495,9 @@ ltq_etop_mdio_wr(struct mii_bus *bus, in +@@ -326,9 +495,9 @@ ltq_etop_mdio_wr(struct mii_bus *bus, in ((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET) | phy_data; @@ -517,7 +516,7 @@ Signed-off-by: John Crispin return 0; } -@@ -340,12 +508,12 @@ ltq_etop_mdio_rd(struct mii_bus *bus, in +@@ -339,12 +508,12 @@ ltq_etop_mdio_rd(struct mii_bus *bus, in ((phy_addr & MDIO_ADDR_MASK) << MDIO_ADDR_OFFSET) | ((phy_reg & MDIO_REG_MASK) << MDIO_REG_OFFSET); @@ -534,7 +533,7 @@ Signed-off-by: John Crispin return val; } -@@ -361,7 +529,10 @@ ltq_etop_mdio_probe(struct net_device *d +@@ -360,7 +529,10 @@ ltq_etop_mdio_probe(struct net_device *d struct ltq_etop_priv *priv = netdev_priv(dev); struct phy_device *phydev; @@ -546,7 +545,7 @@ Signed-off-by: John Crispin if (!phydev) { netdev_err(dev, "no PHY found\n"); -@@ -369,14 +540,17 @@ ltq_etop_mdio_probe(struct net_device *d +@@ -368,14 +540,17 @@ ltq_etop_mdio_probe(struct net_device *d } phydev = phy_connect(dev, phydev_name(phydev), @@ -566,7 +565,7 @@ Signed-off-by: John Crispin phy_attached_info(phydev); -@@ -397,8 +571,13 @@ ltq_etop_mdio_init(struct net_device *de +@@ -396,8 +571,13 @@ ltq_etop_mdio_init(struct net_device *de } priv->mii_bus->priv = dev; @@ -582,7 +581,7 @@ Signed-off-by: John Crispin priv->mii_bus->name = "ltq_mii"; snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x", priv->pdev->name, priv->pdev->id); -@@ -435,18 +614,21 @@ static int +@@ -434,18 +614,21 @@ static int ltq_etop_open(struct net_device *dev) { struct ltq_etop_priv *priv = netdev_priv(dev); @@ -614,7 +613,7 @@ Signed-off-by: John Crispin netif_tx_start_all_queues(dev); return 0; } -@@ -455,18 +637,19 @@ static int +@@ -454,18 +637,19 @@ static int ltq_etop_stop(struct net_device *dev) { struct ltq_etop_priv *priv = netdev_priv(dev); @@ -644,7 +643,7 @@ Signed-off-by: John Crispin return 0; } -@@ -476,15 +659,16 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -475,17 +659,21 @@ ltq_etop_tx(struct sk_buff *skb, struct int queue = skb_get_queue_mapping(skb); struct netdev_queue *txq = netdev_get_tx_queue(dev, queue); struct ltq_etop_priv *priv = netdev_priv(dev); @@ -657,7 +656,13 @@ Signed-off-by: John Crispin u32 byte_offset; + int len; - len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; +- if (skb_put_padto(skb, ETH_ZLEN)) ++ if (skb_put_padto(skb, ETH_ZLEN)) { ++ dev->stats.tx_dropped++; + return NETDEV_TX_OK; ++ } ++ + len = skb->len; - if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || ch->skb[ch->dma.desc]) { + if ((desc->ctl & (LTQ_DMA_OWN | LTQ_DMA_C)) || @@ -665,7 +670,7 @@ Signed-off-by: John Crispin netdev_err(dev, "tx ring full\n"); netif_tx_stop_queue(txq); return NETDEV_TX_BUSY; -@@ -492,7 +676,7 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -493,7 +681,7 @@ ltq_etop_tx(struct sk_buff *skb, struct /* dma needs to start on a burst length value aligned address */ byte_offset = CPHYSADDR(skb->data) % (priv->tx_burst_len * 4); @@ -674,7 +679,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); -@@ -503,11 +687,11 @@ ltq_etop_tx(struct sk_buff *skb, struct +@@ -504,11 +692,11 @@ ltq_etop_tx(struct sk_buff *skb, struct wmb(); desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP | LTQ_DMA_TX_OFFSET(byte_offset) | (len & LTQ_DMA_SIZE_MASK); @@ -689,7 +694,7 @@ Signed-off-by: John Crispin netif_tx_stop_queue(txq); return NETDEV_TX_OK; -@@ -518,11 +702,14 @@ ltq_etop_change_mtu(struct net_device *d +@@ -519,11 +707,14 @@ ltq_etop_change_mtu(struct net_device *d { struct ltq_etop_priv *priv = netdev_priv(dev); unsigned long flags; @@ -705,7 +710,7 @@ Signed-off-by: John Crispin spin_unlock_irqrestore(&priv->lock, flags); return 0; -@@ -575,6 +762,9 @@ ltq_etop_init(struct net_device *dev) +@@ -576,6 +767,9 @@ ltq_etop_init(struct net_device *dev) if (err) goto err_hw; ltq_etop_change_mtu(dev, 1500); @@ -715,7 +720,7 @@ Signed-off-by: John Crispin memcpy(&mac, &priv->pldata->mac, sizeof(struct sockaddr)); if (!is_valid_ether_addr(mac.sa_data)) { -@@ -592,9 +782,10 @@ ltq_etop_init(struct net_device *dev) +@@ -593,9 +787,10 @@ ltq_etop_init(struct net_device *dev) dev->addr_assign_type = NET_ADDR_RANDOM; ltq_etop_set_multicast_list(dev); @@ -729,7 +734,7 @@ Signed-off-by: John Crispin return 0; err_netdev: -@@ -614,6 +805,9 @@ ltq_etop_tx_timeout(struct net_device *d +@@ -615,6 +810,9 @@ ltq_etop_tx_timeout(struct net_device *d err = ltq_etop_hw_init(dev); if (err) goto err_hw; @@ -739,7 +744,7 @@ Signed-off-by: John Crispin netif_trans_update(dev); netif_wake_queue(dev); return; -@@ -637,14 +831,18 @@ static const struct net_device_ops ltq_e +@@ -638,14 +836,18 @@ static const struct net_device_ops ltq_e .ndo_tx_timeout = ltq_etop_tx_timeout, }; @@ -762,7 +767,7 @@ Signed-off-by: John Crispin res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { -@@ -670,18 +868,54 @@ ltq_etop_probe(struct platform_device *p +@@ -671,18 +873,54 @@ ltq_etop_probe(struct platform_device *p goto err_out; } @@ -823,7 +828,7 @@ Signed-off-by: John Crispin spin_lock_init(&priv->lock); SET_NETDEV_DEV(dev, &pdev->dev); -@@ -697,15 +931,10 @@ ltq_etop_probe(struct platform_device *p +@@ -698,15 +936,10 @@ ltq_etop_probe(struct platform_device *p goto err_free; } @@ -843,7 +848,7 @@ Signed-off-by: John Crispin err = register_netdev(dev); if (err) -@@ -734,31 +963,22 @@ ltq_etop_remove(struct platform_device * +@@ -735,31 +968,22 @@ ltq_etop_remove(struct platform_device * return 0; } diff --git a/target/linux/lantiq/patches-6.6/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch b/target/linux/lantiq/patches-6.6/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch index 3e349d4c32c756..8bb6e5a0da25b4 100644 --- a/target/linux/lantiq/patches-6.6/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch +++ b/target/linux/lantiq/patches-6.6/0035-owrt-lantiq-wifi-and-ethernet-eeprom-handling.patch @@ -203,7 +203,7 @@ Signed-off-by: John Crispin +early_param("ethaddr", setup_ethaddr); --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c -@@ -766,7 +766,11 @@ ltq_etop_init(struct net_device *dev) +@@ -771,7 +771,11 @@ ltq_etop_init(struct net_device *dev) if (err) goto err_hw; diff --git a/target/linux/lantiq/patches-6.6/0050-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch b/target/linux/lantiq/patches-6.6/0050-v6.11-usb-dwc2-add-support-for-other-Lantiq-SoCs.patch similarity index 84% rename from target/linux/lantiq/patches-6.6/0050-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch rename to target/linux/lantiq/patches-6.6/0050-v6.11-usb-dwc2-add-support-for-other-Lantiq-SoCs.patch index 5099c0bb9ee0d0..cb453ff04810d6 100644 --- a/target/linux/lantiq/patches-6.6/0050-USB-DWC2-make-the-lantiq-settings-match-vendor-drive.patch +++ b/target/linux/lantiq/patches-6.6/0050-v6.11-usb-dwc2-add-support-for-other-Lantiq-SoCs.patch @@ -1,7 +1,7 @@ -From de2cad82c4d0872066f83ce59462603852b47f03 Mon Sep 17 00:00:00 2001 +From 5af43708d21c30e2f418cb25d337779c56d235f6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens -Date: Fri, 6 Jan 2017 17:55:24 +0100 -Subject: [PATCH 2/2] usb: dwc2: add support for other Lantiq SoCs +Date: Tue, 9 Jul 2024 00:20:54 +0200 +Subject: [PATCH] usb: dwc2: add support for other Lantiq SoCs The size of the internal RAM of the DesignWare USB controller changed between the different Lantiq SoCs. We have the following sizes: @@ -16,10 +16,15 @@ and for the xrx200 and xrx300 SCs a little bit bigger periodic fifo. The auto detection of max_transfer_size and max_packet_count should work, so remove it. +This patch is included in OpenWrt for many years. + Signed-off-by: Hauke Mehrtens +Acked-by: Minas Harutyunyan +Link: https://lore.kernel.org/r/20240708222054.2727789-1-hauke@hauke-m.de +Signed-off-by: Greg Kroah-Hartman --- - drivers/usb/dwc2/platform.c | 46 ++++++++++++++++++++++++++++++++++++++------- - 1 file changed, 39 insertions(+), 7 deletions(-) + drivers/usb/dwc2/params.c | 30 +++++++++++++++++++++++++----- + 1 file changed, 25 insertions(+), 5 deletions(-) --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c diff --git a/target/linux/lantiq/patches-6.6/0051-MIPS-lantiq-improve-USB-initialization.patch b/target/linux/lantiq/patches-6.6/0051-v6.11-MIPS-lantiq-improve-USB-initialization.patch similarity index 79% rename from target/linux/lantiq/patches-6.6/0051-MIPS-lantiq-improve-USB-initialization.patch rename to target/linux/lantiq/patches-6.6/0051-v6.11-MIPS-lantiq-improve-USB-initialization.patch index 29d696af27235b..558a7fbc257455 100644 --- a/target/linux/lantiq/patches-6.6/0051-MIPS-lantiq-improve-USB-initialization.patch +++ b/target/linux/lantiq/patches-6.6/0051-v6.11-MIPS-lantiq-improve-USB-initialization.patch @@ -1,17 +1,19 @@ -From 14909c4e4e836925668e74fc6e0e85ba0283cbf9 Mon Sep 17 00:00:00 2001 +From 9c7a86c935074525f24cc20e78a7d5150e4600e3 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens -Date: Fri, 6 Jan 2017 17:40:12 +0100 -Subject: [PATCH 2/2] MIPS: lantiq: improve USB initialization +Date: Tue, 9 Jul 2024 00:23:04 +0200 +Subject: [PATCH] MIPS: lantiq: improve USB initialization This adds code to initialize the USB controller and PHY also on Danube, Amazon SE and AR10. This code is based on the Vendor driver from different UGW versions and compared to the hardware documentation. +This patch is included in OpenWrt for many years. + Signed-off-by: Hauke Mehrtens +Signed-off-by: Thomas Bogendoerfer --- - arch/mips/lantiq/xway/sysctrl.c | 20 +++++++ - 2 files changed, 110 insertions(+), 30 deletions(-) - + arch/mips/lantiq/xway/sysctrl.c | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) --- a/arch/mips/lantiq/xway/sysctrl.c +++ b/arch/mips/lantiq/xway/sysctrl.c From 123cb3793fb1bf86df8173d620d05a6169db56fc Mon Sep 17 00:00:00 2001 From: John Audia Date: Mon, 30 Sep 2024 15:58:56 -0400 Subject: [PATCH 03/29] kernel: bump 6.6 to 6.6.53 Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.53 All patches automatically rebased. Build system: x86/64 Build-tested: x86/64/AMD Cezanne, flogic/glinet_gl-mt6000, flogic/xiaomi_redmi-router-ax6000-ubootmod Run-tested: x86/64/AMD Cezanne, flogic/glinet_gl-mt6000, flogic/xiaomi_redmi-router-ax6000-ubootmod Signed-off-by: John Audia Link: https://github.com/openwrt/openwrt/pull/16554 Signed-off-by: Hauke Mehrtens --- include/kernel-6.6 | 4 ++-- ...070-spi-spidev-Completely-disable-the-spidev-warning.patch | 2 +- ...950-0320-spi-spidev-Restore-loading-from-Device-Tree.patch | 2 +- ...netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/kernel-6.6 b/include/kernel-6.6 index 094066fe77e9b8..d096bfabd063f5 100644 --- a/include/kernel-6.6 +++ b/include/kernel-6.6 @@ -1,2 +1,2 @@ -LINUX_VERSION-6.6 = .52 -LINUX_KERNEL_HASH-6.6.52 = 1591ab348399d4aa53121158525056a69c8cf0fe0e90935b0095e9a58e37b4b8 +LINUX_VERSION-6.6 = .53 +LINUX_KERNEL_HASH-6.6.53 = 285d181d1b252b0bf905f040d094215cf183ac98c31a17f9cce9f3537ef4d779 diff --git a/target/linux/bcm27xx/patches-6.6/950-0070-spi-spidev-Completely-disable-the-spidev-warning.patch b/target/linux/bcm27xx/patches-6.6/950-0070-spi-spidev-Completely-disable-the-spidev-warning.patch index 47d727af5ba0db..a83a51eae2d098 100644 --- a/target/linux/bcm27xx/patches-6.6/950-0070-spi-spidev-Completely-disable-the-spidev-warning.patch +++ b/target/linux/bcm27xx/patches-6.6/950-0070-spi-spidev-Completely-disable-the-spidev-warning.patch @@ -13,7 +13,7 @@ Signed-off-by: Phil Elwell --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c -@@ -720,7 +720,7 @@ MODULE_DEVICE_TABLE(spi, spidev_spi_ids) +@@ -721,7 +721,7 @@ MODULE_DEVICE_TABLE(spi, spidev_spi_ids) */ static int spidev_of_check(struct device *dev) { diff --git a/target/linux/bcm27xx/patches-6.6/950-0320-spi-spidev-Restore-loading-from-Device-Tree.patch b/target/linux/bcm27xx/patches-6.6/950-0320-spi-spidev-Restore-loading-from-Device-Tree.patch index a45389d9ef7420..da1bbb78866182 100644 --- a/target/linux/bcm27xx/patches-6.6/950-0320-spi-spidev-Restore-loading-from-Device-Tree.patch +++ b/target/linux/bcm27xx/patches-6.6/950-0320-spi-spidev-Restore-loading-from-Device-Tree.patch @@ -22,4 +22,4 @@ Signed-off-by: Phil Elwell + { .name = "spidev" }, { .name = "bh2228fv" }, { .name = "dh2228fv" }, - { .name = "ltc2488" }, + { .name = "jg10309-01" }, diff --git a/target/linux/generic/pending-6.6/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch b/target/linux/generic/pending-6.6/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch index 827ceff18ba15c..be7405c1a2dbaf 100644 --- a/target/linux/generic/pending-6.6/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch +++ b/target/linux/generic/pending-6.6/701-netfilter-nf_tables-ignore-EOPNOTSUPP-on-flowtable-d.patch @@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c -@@ -8322,7 +8322,7 @@ static int nft_register_flowtable_net_ho +@@ -8327,7 +8327,7 @@ static int nft_register_flowtable_net_ho err = flowtable->data.type->setup(&flowtable->data, hook->ops.dev, FLOW_BLOCK_BIND); From a9540a4e33599c01f0c1547d3e29d73fcd73d0ea Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 2 Oct 2024 12:38:32 +0200 Subject: [PATCH 04/29] mac80211: do not pass a stopped vif to the driver on get_txpower Fixes potential crashes in various drivers when checking the status of interfaces that are down Signed-off-by: Felix Fietkau --- ...-not-pass-a-stopped-vif-to-the-drive.patch | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/321-wifi-mac80211-do-not-pass-a-stopped-vif-to-the-drive.patch diff --git a/package/kernel/mac80211/patches/subsys/321-wifi-mac80211-do-not-pass-a-stopped-vif-to-the-drive.patch b/package/kernel/mac80211/patches/subsys/321-wifi-mac80211-do-not-pass-a-stopped-vif-to-the-drive.patch new file mode 100644 index 00000000000000..f48fa38e5e96ab --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/321-wifi-mac80211-do-not-pass-a-stopped-vif-to-the-drive.patch @@ -0,0 +1,24 @@ +From: Felix Fietkau +Date: Wed, 2 Oct 2024 11:45:35 +0200 +Subject: [PATCH] wifi: mac80211: do not pass a stopped vif to the driver in + .get_txpower + +Avoid potentially crashing in the driver because of uninitialized private data + +Fixes: 5b3dc42b1b0d ("mac80211: add support for driver tx power reporting") +Cc: stable@vger.kernel.org +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/cfg.c ++++ b/net/mac80211/cfg.c +@@ -3134,7 +3134,8 @@ static int ieee80211_get_tx_power(struct + struct ieee80211_local *local = wiphy_priv(wiphy); + struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); + +- if (local->ops->get_txpower) ++ if (local->ops->get_txpower && ++ (sdata->flags & IEEE80211_SDATA_IN_DRIVER)) + return drv_get_txpower(local, sdata, dbm); + + if (local->emulate_chanctx) From 8344ff8524a3c2a95fa501487cd59645156fb0b6 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 12:41:09 +0200 Subject: [PATCH 05/29] mediatek: change the the default SUBTARGET to filogic Signed-off-by: John Crispin --- target/linux/mediatek/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/mediatek/Makefile b/target/linux/mediatek/Makefile index 711cda0791899e..478b00488ba907 100644 --- a/target/linux/mediatek/Makefile +++ b/target/linux/mediatek/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk ARCH:=arm BOARD:=mediatek BOARDNAME:=MediaTek ARM -SUBTARGETS:=mt7622 mt7623 mt7629 filogic +SUBTARGETS:=filogic mt7622 mt7623 mt7629 FEATURES:=dt-overlay emmc fpu gpio nand pci pcie rootfs-part separate_ramdisk squashfs usb KERNEL_PATCHVER:=6.6 From 52e8aeabee5f00327bfbcf13450561dbc4fcdeb5 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 21 Sep 2024 20:17:25 +0200 Subject: [PATCH 06/29] iwinfo: update to latest HEAD 714e419 iwinfo: fix EHT mode reporting for STA interfaces 7eed433 devices: add device id for MediaTek MT7996e Signed-off-by: John Crispin --- package/network/utils/iwinfo/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/utils/iwinfo/Makefile b/package/network/utils/iwinfo/Makefile index 53f8d44f469200..0d7de102260867 100644 --- a/package/network/utils/iwinfo/Makefile +++ b/package/network/utils/iwinfo/Makefile @@ -11,9 +11,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/iwinfo.git -PKG_SOURCE_DATE:=2024-09-17 -PKG_SOURCE_VERSION:=268a662421fa03798881b34658a3d6bd6a30d97d -PKG_MIRROR_HASH:=2ea07521149fb45665184f80ee99595c8b4f06aaf2c1004b74c944da632778de +PKG_SOURCE_DATE:=2024-10-01 +PKG_SOURCE_VERSION:=714e419919d00dd1b3cdce08d9f28a28b2de69ed +PKG_MIRROR_HASH:=e70c179f45ab075dc9216d9cf64e0c0161a89444ae9bd7622e5f877b36adf6d3 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=GPL-2.0 From 92e6b84d158a7fb2aa5d5d9a840fa63aa29ba7a9 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 22 Sep 2024 10:09:41 +0200 Subject: [PATCH 07/29] ucode: update to latest HEAD b610860 Merge pull request #223 from jow-/nl80211-add-eht-attributes 4e0456b nl80211: add EHT mac/phy capabilities c938ee9 Merge pull request #218 from jonasjelonek/add-ioctl 56ebeec fs: add ioctl() file method d0f423b Merge pull request #221 from mikma/fix-getenv 86f1121 lib: test if call to getenv() destroys environ 7af80d9 lib: use copy of environ pointer in getenv() 6ea37c8 ci: bump upload-artifact to v3 26d7292 Merge pull request #214 from jow-/ucode-test-runner fbabec4 tests: replace test runner shell script with ucode implementation e391ef5 main: prevent invalid memory access when executing empty stdin b391fd7 Merge pull request #211 from jow-/hwsim-support bc13278 nl80211: support the MAC80211_HWSIM netlink protocol family f5b5a58 nl80211: drop unused structure members from connection context f6ea6fc nl80211: support conversion from/to struct array attributes 115a84f nl80211: gracefully handle illegal netlink error code Signed-off-by: John Crispin --- package/utils/ucode/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/utils/ucode/Makefile b/package/utils/ucode/Makefile index 9dcd5ff3ab0a48..6ee0cf2a1d56b9 100644 --- a/package/utils/ucode/Makefile +++ b/package/utils/ucode/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=3 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=https://github.com/jow-/ucode.git -PKG_SOURCE_DATE:=2024-07-11 -PKG_SOURCE_VERSION:=1a8a0bcf725520820802ad433db22d8f64fbed6c -PKG_MIRROR_HASH:=0a859c97457a019adc73b028c19e2b334271b2c4de28337f1a18fd35438af3d3 +PKG_SOURCE_DATE:=2024-07-22 +PKG_SOURCE_VERSION:=b610860dd4a0591ff586dd71a50f556a0ddafced +PKG_MIRROR_HASH:=a5ec51dd989174422d3b19b022ff4f863d57eb559c9f08d54c0d10651f598357 PKG_MAINTAINER:=Jo-Philipp Wich PKG_LICENSE:=ISC From b1d6068330c7c23be6d0d2a5c3e8a72ac6e25ac1 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Tue, 20 Aug 2024 08:29:18 +0200 Subject: [PATCH 08/29] hostapd: add CONFIG_DRIVER_11BE_SUPPORT Add option to enable 802.11BE support. Signed-off-by: Janusz Dziedzic --- package/network/services/hostapd/Config.in | 4 ++++ package/network/services/hostapd/Makefile | 6 ++++++ .../network/services/hostapd/src/src/utils/build_features.h | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/package/network/services/hostapd/Config.in b/package/network/services/hostapd/Config.in index 1fff4f8acd530b..742cd78a14627b 100644 --- a/package/network/services/hostapd/Config.in +++ b/package/network/services/hostapd/Config.in @@ -40,6 +40,10 @@ config DRIVER_11AX_SUPPORT default n select WPA_MBO_SUPPORT +config DRIVER_11BE_SUPPORT + bool + default n + config WPA_ENABLE_WEP bool "Enable support for unsecure and obsolete WEP" depends on PACKAGE_hostapd-common diff --git a/package/network/services/hostapd/Makefile b/package/network/services/hostapd/Makefile index 1c0b6548662e37..0e3396262d0c13 100644 --- a/package/network/services/hostapd/Makefile +++ b/package/network/services/hostapd/Makefile @@ -27,6 +27,7 @@ PKG_CONFIG_DEPENDS:= \ CONFIG_WPA_RFKILL_SUPPORT \ CONFIG_DRIVER_11AC_SUPPORT \ CONFIG_DRIVER_11AX_SUPPORT \ + CONFIG_DRIVER_11BE_SUPPORT \ CONFIG_WPA_ENABLE_WEP PKG_BUILD_FLAGS:=gc-sections lto @@ -79,6 +80,10 @@ ifneq ($(CONFIG_DRIVER_11AX_SUPPORT),) HOSTAPD_IEEE80211AX:=y endif +ifneq ($(CONFIG_DRIVER_11BE_SUPPORT),) + HOSTAPD_IEEE80211BE:=y +endif + CORE_DEPENDS = +ucode +libubus +libucode +ucode-mod-fs +ucode-mod-nl80211 +ucode-mod-rtnl +ucode-mod-ubus +ucode-mod-uloop +libblobmsg-json +libudebug OPENSSL_DEPENDS = +PACKAGE_$(1):libopenssl +PACKAGE_$(1):libopenssl-legacy @@ -86,6 +91,7 @@ DRIVER_MAKEOPTS= \ CONFIG_ACS=y CONFIG_DRIVER_NL80211=y \ CONFIG_IEEE80211AC=$(HOSTAPD_IEEE80211AC) \ CONFIG_IEEE80211AX=$(HOSTAPD_IEEE80211AX) \ + CONFIG_IEEE80211BE=$(HOSTAPD_IEEE80211BE) \ CONFIG_MBO=$(CONFIG_WPA_MBO_SUPPORT) \ CONFIG_UCODE=y CONFIG_APUP=y diff --git a/package/network/services/hostapd/src/src/utils/build_features.h b/package/network/services/hostapd/src/src/utils/build_features.h index 553769ecebc84c..cc8831535c68da 100644 --- a/package/network/services/hostapd/src/src/utils/build_features.h +++ b/package/network/services/hostapd/src/src/utils/build_features.h @@ -15,6 +15,10 @@ static inline int has_feature(const char *feat) if (!strcmp(feat, "11ax")) return 1; #endif +#ifdef CONFIG_IEEE80211BE + if (!strcmp(feat, "11be")) + return 1; +#endif #ifdef CONFIG_IEEE80211R if (!strcmp(feat, "11r")) return 1; From d1fc8c3db0e75f625b810cd57c4ee3d9493f8c57 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Tue, 20 Aug 2024 13:22:31 +0200 Subject: [PATCH 09/29] hostapd: fix build when 80211BE enabled In file included from hostapd-wpad-basic-mbedtls/hostapd-2024.03.09~695277a5/src/ap/ubus.h:11, from hostapd-wpad-basic-mbedtls/hostapd-2024.03.09~695277a5/src/ap/hostapd.h:21, from main.c:26: hostapd-2024.03.09~695277a5/src/ap/sta_info.h: In function 'ap_sta_is_mld': hostapd-2024.03.09~695277a5/src/ap/sta_info.h:425:20: error: invalid use of undefined type 'struct hostapd_data' 425 | return hapd->conf->mld_ap && sta && sta->mld_info.mld_sta; | ^~ Signed-off-by: Janusz Dziedzic --- .../803-hostapd-fix-80211be-build.patch | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 package/network/services/hostapd/patches/803-hostapd-fix-80211be-build.patch diff --git a/package/network/services/hostapd/patches/803-hostapd-fix-80211be-build.patch b/package/network/services/hostapd/patches/803-hostapd-fix-80211be-build.patch new file mode 100644 index 00000000000000..55c6e635813c9d --- /dev/null +++ b/package/network/services/hostapd/patches/803-hostapd-fix-80211be-build.patch @@ -0,0 +1,53 @@ +--- a/src/ap/sta_info.c ++++ b/src/ap/sta_info.c +@@ -1836,3 +1836,22 @@ void ap_sta_free_sta_profile(struct mld_ + } + } + #endif /* CONFIG_IEEE80211BE */ ++ ++bool ap_sta_is_mld(struct hostapd_data *hapd, ++ struct sta_info *sta) ++{ ++#ifdef CONFIG_IEEE80211BE ++ return hapd->conf->mld_ap && sta && sta->mld_info.mld_sta; ++#else /* CONFIG_IEEE80211BE */ ++ return false; ++#endif /* CONFIG_IEEE80211BE */ ++} ++ ++void ap_sta_set_mld(struct sta_info *sta, bool mld) ++{ ++#ifdef CONFIG_IEEE80211BE ++ if (sta) ++ sta->mld_info.mld_sta = mld; ++#endif /* CONFIG_IEEE80211BE */ ++} ++ +--- a/src/ap/sta_info.h ++++ b/src/ap/sta_info.h +@@ -417,23 +417,8 @@ int ap_sta_re_add(struct hostapd_data *h + + void ap_free_sta_pasn(struct hostapd_data *hapd, struct sta_info *sta); + +-static inline bool ap_sta_is_mld(struct hostapd_data *hapd, +- struct sta_info *sta) +-{ +-#ifdef CONFIG_IEEE80211BE +- return hapd->conf->mld_ap && sta && sta->mld_info.mld_sta; +-#else /* CONFIG_IEEE80211BE */ +- return false; +-#endif /* CONFIG_IEEE80211BE */ +-} +- +-static inline void ap_sta_set_mld(struct sta_info *sta, bool mld) +-{ +-#ifdef CONFIG_IEEE80211BE +- if (sta) +- sta->mld_info.mld_sta = mld; +-#endif /* CONFIG_IEEE80211BE */ +-} ++bool ap_sta_is_mld(struct hostapd_data *hapd, struct sta_info *sta); ++void ap_sta_set_mld(struct sta_info *sta, bool mld); + + void ap_sta_free_sta_profile(struct mld_info *info); + From 42185bf42950a80c2f1dff78366beea7d7558fbd Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Sun, 1 Sep 2024 10:56:15 +0200 Subject: [PATCH 10/29] wifi-scripts: mac80211.sh: allow EHT* sets Allow to configure 80211BE. Signed-off-by: Janusz Dziedzic --- .../files/lib/netifd/wireless/mac80211.sh | 164 ++++++++++-------- 1 file changed, 88 insertions(+), 76 deletions(-) diff --git a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh index 11b11c411f4358..d6d2cfef8d0bd8 100755 --- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh +++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh @@ -159,77 +159,79 @@ mac80211_hostapd_setup_base() { chan_ofs=0 [ "$band" = "6g" ] && chan_ofs=1 - ieee80211n=1 - ht_capab= - case "$htmode" in - VHT20|HT20|HE20) ;; - HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160) - case "$hwmode" in - a) - case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in - 1) ht_capab="[HT40+]";; - 0) ht_capab="[HT40-]";; - esac - ;; - *) - case "$htmode" in - HT40+) ht_capab="[HT40+]";; - HT40-) ht_capab="[HT40-]";; - *) - if [ "$channel" -lt 7 ]; then - ht_capab="[HT40+]" - else - ht_capab="[HT40-]" - fi - ;; - esac - ;; - esac - [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]" - ;; - *) ieee80211n= ;; - esac - - [ -n "$ieee80211n" ] && { - append base_cfg "ieee80211n=1" "$N" - - set_default ht_coex 0 - append base_cfg "ht_coex=$ht_coex" "$N" - - json_get_vars \ - ldpc:1 \ - greenfield:0 \ - short_gi_20:1 \ - short_gi_40:1 \ - tx_stbc:1 \ - rx_stbc:3 \ - max_amsdu:1 \ - dsss_cck_40:1 - - ht_cap_mask=0 - for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do - ht_cap_mask="$(($ht_cap_mask | $cap))" - done + if [ "$band" != "6g" ]; then + ieee80211n=1 + ht_capab= + case "$htmode" in + VHT20|HT20|HE20|EHT20) ;; + HT40*|VHT40|VHT80|VHT160|HE40|HE80|HE160|EHT40|EHT80|EHT160) + case "$hwmode" in + a) + case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in + 1) ht_capab="[HT40+]";; + 0) ht_capab="[HT40-]";; + esac + ;; + *) + case "$htmode" in + HT40+) ht_capab="[HT40+]";; + HT40-) ht_capab="[HT40-]";; + *) + if [ "$channel" -lt 7 ]; then + ht_capab="[HT40+]" + else + ht_capab="[HT40-]" + fi + ;; + esac + ;; + esac + [ "$auto_channel" -gt 0 ] && ht_capab="[HT40+]" + ;; + *) ieee80211n= ;; + esac - cap_rx_stbc=$((($ht_cap_mask >> 8) & 3)) - [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" - ht_cap_mask="$(( ($ht_cap_mask & ~(0x300)) | ($cap_rx_stbc << 8) ))" - - mac80211_add_capabilities ht_capab_flags $ht_cap_mask \ - LDPC:0x1::$ldpc \ - GF:0x10::$greenfield \ - SHORT-GI-20:0x20::$short_gi_20 \ - SHORT-GI-40:0x40::$short_gi_40 \ - TX-STBC:0x80::$tx_stbc \ - RX-STBC1:0x300:0x100:1 \ - RX-STBC12:0x300:0x200:1 \ - RX-STBC123:0x300:0x300:1 \ - MAX-AMSDU-7935:0x800::$max_amsdu \ - DSSS_CCK-40:0x1000::$dsss_cck_40 - - ht_capab="$ht_capab$ht_capab_flags" - [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N" - } + [ -n "$ieee80211n" ] && { + append base_cfg "ieee80211n=1" "$N" + + set_default ht_coex 0 + append base_cfg "ht_coex=$ht_coex" "$N" + + json_get_vars \ + ldpc:1 \ + greenfield:0 \ + short_gi_20:1 \ + short_gi_40:1 \ + tx_stbc:1 \ + rx_stbc:3 \ + max_amsdu:1 \ + dsss_cck_40:1 + + ht_cap_mask=0 + for cap in $(iw phy "$phy" info | grep 'Capabilities:' | cut -d: -f2); do + ht_cap_mask="$(($ht_cap_mask | $cap))" + done + + cap_rx_stbc=$((($ht_cap_mask >> 8) & 3)) + [ "$rx_stbc" -lt "$cap_rx_stbc" ] && cap_rx_stbc="$rx_stbc" + ht_cap_mask="$(( ($ht_cap_mask & ~(0x300)) | ($cap_rx_stbc << 8) ))" + + mac80211_add_capabilities ht_capab_flags $ht_cap_mask \ + LDPC:0x1::$ldpc \ + GF:0x10::$greenfield \ + SHORT-GI-20:0x20::$short_gi_20 \ + SHORT-GI-40:0x40::$short_gi_40 \ + TX-STBC:0x80::$tx_stbc \ + RX-STBC1:0x300:0x100:1 \ + RX-STBC12:0x300:0x200:1 \ + RX-STBC123:0x300:0x300:1 \ + MAX-AMSDU-7935:0x800::$max_amsdu \ + DSSS_CCK-40:0x1000::$dsss_cck_40 + + ht_capab="$ht_capab$ht_capab_flags" + [ -n "$ht_capab" ] && append base_cfg "ht_capab=$ht_capab" "$N" + } + fi # 802.11ac enable_ac=0 @@ -238,8 +240,8 @@ mac80211_hostapd_setup_base() { idx="$channel" case "$htmode" in - VHT20|HE20) enable_ac=1;; - VHT40|HE40) + VHT20|HE20|EHT20) enable_ac=1;; + VHT40|HE40|EHT40) case "$(( (($channel / 4) + $chan_ofs) % 2 ))" in 1) idx=$(($channel + 2));; 0) idx=$(($channel - 2));; @@ -247,7 +249,7 @@ mac80211_hostapd_setup_base() { enable_ac=1 vht_center_seg0=$idx ;; - VHT80|HE80) + VHT80|HE80|EHT80) case "$(( (($channel / 4) + $chan_ofs) % 4 ))" in 1) idx=$(($channel + 6));; 2) idx=$(($channel + 2));; @@ -258,7 +260,7 @@ mac80211_hostapd_setup_base() { vht_oper_chwidth=1 vht_center_seg0=$idx ;; - VHT160|HE160) + VHT160|HE160|EHT160) if [ "$band" = "6g" ]; then case "$channel" in 1|5|9|13|17|21|25|29) idx=15;; @@ -289,8 +291,8 @@ mac80211_hostapd_setup_base() { [ "$band" = "6g" ] && { op_class= case "$htmode" in - HE20) op_class=131;; - HE*) op_class=$((132 + $vht_oper_chwidth)) + HE20|EHT20) op_class=131;; + HE*|EHT*) op_class=$((132 + $vht_oper_chwidth));; esac [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N" } @@ -417,8 +419,10 @@ mac80211_hostapd_setup_base() { # 802.11ax enable_ax=0 + enable_be=0 case "$htmode" in HE*) enable_ax=1 ;; + EHT*) enable_ax=1; enable_be=1 ;; esac if [ "$enable_ax" != "0" ]; then @@ -492,6 +496,14 @@ mac80211_hostapd_setup_base() { append base_cfg "he_mu_edca_ac_vo_timer=255" "$N" fi + if [ "$enable_be" != "0" ]; then + append base_cfg "ieee80211be=1" "$N" + [ "$hwmode" = "a" ] && { + append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N" + append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N" + } + fi + hostapd_prepare_device_config "$hostapd_conf_file" nl80211 cat >> "$hostapd_conf_file" < Date: Sun, 1 Sep 2024 12:27:54 +0200 Subject: [PATCH 11/29] wifi-scripts: mac80211.sh: enable EHT320 For EHT320 we should also enable HE160. Signed-off-by: Janusz Dziedzic --- .../files/lib/netifd/wireless/mac80211.sh | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh index d6d2cfef8d0bd8..23e557105bdbdc 100755 --- a/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh +++ b/package/network/config/wifi-scripts/files/lib/netifd/wireless/mac80211.sh @@ -260,7 +260,7 @@ mac80211_hostapd_setup_base() { vht_oper_chwidth=1 vht_center_seg0=$idx ;; - VHT160|HE160|EHT160) + VHT160|HE160|EHT160|EHT320) if [ "$band" = "6g" ]; then case "$channel" in 1|5|9|13|17|21|25|29) idx=15;; @@ -288,15 +288,32 @@ mac80211_hostapd_setup_base() { [ "$background_radar" -eq 1 ] && append base_cfg "enable_background_radar=1" "$N" } + + eht_oper_chwidth=$vht_oper_chwidth + eht_center_seg0=$vht_center_seg0 + [ "$band" = "6g" ] && { op_class= case "$htmode" in HE20|EHT20) op_class=131;; + EHT320) + case "$channel" in + 1|5|9|13|17|21|25|29|33|37|41|45|49|53|57|61) idx=31;; + 65|69|73|77|81|85|89|93|97|101|105|109|113|117|121|125) idx=95;; + 129|133|137|141|145|149|153|157|161|165|169|173|177|181|185|189) idx=159;; + 193|197|201|205|209|213|217|221) idx=191;; + esac + + op_class=137 + eht_center_seg0=$idx + eht_oper_chwidth=9 + ;; HE*|EHT*) op_class=$((132 + $vht_oper_chwidth));; esac [ -n "$op_class" ] && append base_cfg "op_class=$op_class" "$N" } [ "$hwmode" = "a" ] || enable_ac=0 + [ "$band" = "6g" ] && enable_ac=0 if [ "$enable_ac" != "0" ]; then json_get_vars \ @@ -499,8 +516,8 @@ mac80211_hostapd_setup_base() { if [ "$enable_be" != "0" ]; then append base_cfg "ieee80211be=1" "$N" [ "$hwmode" = "a" ] && { - append base_cfg "eht_oper_chwidth=$vht_oper_chwidth" "$N" - append base_cfg "eht_oper_centr_freq_seg0_idx=$vht_center_seg0" "$N" + append base_cfg "eht_oper_chwidth=$eht_oper_chwidth" "$N" + append base_cfg "eht_oper_centr_freq_seg0_idx=$eht_center_seg0" "$N" } fi From 7ebd9069f43af08db5d0a5ecacfe684c64176a02 Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Fri, 6 Sep 2024 09:49:18 +0200 Subject: [PATCH 12/29] mt76: mark mt7996e 11BE capable Build hostapd with 11BE support. Signed-off-by: Janusz Dziedzic --- package/kernel/mt76/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile index 9a7c1f85e26a6c..8c3bf3e76bc8eb 100644 --- a/package/kernel/mt76/Makefile +++ b/package/kernel/mt76/Makefile @@ -318,7 +318,8 @@ endef define KernelPackage/mt7996e $(KernelPackage/mt76-default) TITLE:=MediaTek MT7996E wireless driver - DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core +@DRIVER_11AX_SUPPORT +@KERNEL_RELAY + DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-hwmon-core +@DRIVER_11AX_SUPPORT \ + +@KERNEL_RELAY +@DRIVER_11BE_SUPPORT FILES:= $(PKG_BUILD_DIR)/mt7996/mt7996e.ko AUTOLOAD:=$(call AutoProbe,mt7996e) endef From b478b7b1f7b9d402190dc3a9db4cad4c9a6fc50d Mon Sep 17 00:00:00 2001 From: Janusz Dziedzic Date: Fri, 20 Sep 2024 19:43:32 +0200 Subject: [PATCH 13/29] wifi-scripts: detect and configure EHT Check if EHT/11BE supported, configure in board.json and config/wireless. Signed-off-by: Janusz Dziedzic --- .../wifi-scripts/files/lib/wifi/mac80211.uc | 2 +- .../files/usr/share/hostap/wifi-detect.uc | 27 +++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc index 8f25a791b38b3b..b68167b7542649 100644 --- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc +++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc @@ -3,7 +3,7 @@ import { readfile } from "fs"; import * as uci from 'uci'; const bands_order = [ "6G", "5G", "2G" ]; -const htmode_order = [ "HE", "VHT", "HT" ]; +const htmode_order = [ "EHT", "HE", "VHT", "HT" ]; let board = json(readfile("/etc/board.json")); if (!board.wlan) diff --git a/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc b/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc index 6eb6b84c914533..468078ad206960 100644 --- a/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc +++ b/package/network/config/wifi-scripts/files/usr/share/hostap/wifi-detect.uc @@ -113,6 +113,7 @@ function wiphy_detect() { if (band.vht_capa > 0) band_info.vht = true; let he_phy_cap = 0; + let eht_phy_cap = 0; for (let ift in band.iftype_data) { if (!ift.he_cap_phy) @@ -120,7 +121,12 @@ function wiphy_detect() { band_info.he = true; he_phy_cap |= ift.he_cap_phy[0]; - /* TODO: EHT */ + + if (!ift.eht_cap_phy) + continue; + + band_info.eht = true; + eht_phy_cap |= ift.eht_cap_phy[0]; } if (band_name != "2G" && @@ -141,14 +147,19 @@ function wiphy_detect() { push(modes, "VHT20"); if (band_info.he) push(modes, "HE20"); + if (band_info.eht) + push(modes, "EHT20"); if (band.ht_capa & 0x2) { push(modes, "HT40"); if (band_info.vht) push(modes, "VHT40") } - if (he_phy_cap & 0x2) + if (he_phy_cap & 2) push(modes, "HE40"); + if (eht_phy_cap && he_phy_cap & 2) + push(modes, "EHT40"); + for (let freq in band.freqs) { if (freq.disabled) continue; @@ -161,14 +172,26 @@ function wiphy_detect() { if (band_name == "2G") continue; + + if (he_phy_cap & 4) + push(modes, "HE40"); + if (eht_phy_cap && he_phy_cap & 4) + push(modes, "EHT40"); if (band_info.vht) push(modes, "VHT80"); if (he_phy_cap & 4) push(modes, "HE80"); + if (eht_phy_cap && he_phy_cap & 4) + push(modes, "EHT80"); if ((band.vht_capa >> 2) & 0x3) push(modes, "VHT160"); if (he_phy_cap & 0x18) push(modes, "HE160"); + if (eht_phy_cap && he_phy_cap & 0x18) + push(modes, "EHT160"); + + if (eht_phy_cap & 2) + push(modes, "ETH320"); } let entry = wiphy_get_entry(name, path); From 8bfea41eefd43fcfa9be40cb95e27e8daeafaca4 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 18:03:44 +0200 Subject: [PATCH 14/29] umdns: update to latest HEAD fbaca4b cache: improve update call by doing a full refresh probe 93c9036 dns: reply to A/AAAA questions for additional hostnames Signed-off-by: John Crispin --- package/network/services/umdns/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/services/umdns/Makefile b/package/network/services/umdns/Makefile index 2491126bf6c3e1..606dc7274fe3ea 100644 --- a/package/network/services/umdns/Makefile +++ b/package/network/services/umdns/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_URL=$(PROJECT_GIT)/project/mdnsd.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2024-01-08 -PKG_SOURCE_VERSION:=e91ed406ecebb4bc08c346929e25f1b819c19edd -PKG_MIRROR_HASH:=f667e939520f0ce27b63ddcab64eb079d84fd2c61beaad5399bfc5f9276ca62e +PKG_SOURCE_DATE:=2024-09-17 +PKG_SOURCE_VERSION:=fbaca4b6f530d4b2f361ee15c266aa19a708242b +PKG_MIRROR_HASH:=e3fc47a019ea54722b8d7dfc8158307a9fb4a9d18945a1a6794616e3b80d5d3b PKG_MAINTAINER:=John Crispin PKG_LICENSE:=LGPL-2.1 From dc48732ea7be380ba44b806ffb1c857e6c2c2a48 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 18 Sep 2024 14:43:26 +0200 Subject: [PATCH 15/29] hostapd: add the ifname to ubus events Signed-off-by: John Crispin --- package/network/services/hostapd/src/src/ap/ubus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index f21516fc3c78ac..2d9a48d368462a 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -1783,6 +1783,7 @@ int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_req blob_buf_init(&b, 0); blobmsg_add_macaddr(&b, "address", addr); + blobmsg_add_string(&b, "ifname", hapd->conf->iface); if (req->mgmt_frame) blobmsg_add_macaddr(&b, "target", req->mgmt_frame->da); if (req->ssi_signal) From 711885ad686ca5f8b4901334ab8f9e94a3ba7438 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 18 Sep 2024 14:47:31 +0200 Subject: [PATCH 16/29] hostapd: add ifname and vlan_id to sta-authorized notifications Signed-off-by: John Crispin --- package/network/services/hostapd/src/src/ap/ubus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index 2d9a48d368462a..d84d41f930d548 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -1870,6 +1870,9 @@ void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info * blob_buf_init(&b, 0); blobmsg_add_macaddr(&b, "address", sta->addr); + if (sta->vlan_id) + blobmsg_add_u32(&b, "vlan", sta->vlan_id); + blobmsg_add_string(&b, "ifname", hapd->conf->iface); if (auth_alg) blobmsg_add_string(&b, "auth-alg", auth_alg); From dd62f7659b38602dfbefc8894a66c13930b872d1 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 18 Sep 2024 15:21:27 +0200 Subject: [PATCH 17/29] hostapd: add ifname to generic ubus notify code Signed-off-by: John Crispin --- package/network/services/hostapd/src/src/ap/ubus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index d84d41f930d548..4dda2b0571e53e 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -1858,6 +1858,7 @@ void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 * blob_buf_init(&b, 0); blobmsg_add_macaddr(&b, "address", addr); + blobmsg_add_string(&b, "ifname", hapd->conf->iface); ubus_notify(ctx, &hapd->ubus.obj, type, b.head, -1); } From 3ed5f6430b0f07116fabc3d45e5ee1cb7280f6d2 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 18 Sep 2024 15:05:34 +0200 Subject: [PATCH 18/29] hostapd: send a notification via ubus when CSA completed Signed-off-by: John Crispin --- .../services/hostapd/patches/600-ubus_support.patch | 8 ++++++++ package/network/services/hostapd/src/src/ap/ubus.c | 13 +++++++++++++ package/network/services/hostapd/src/src/ap/ubus.h | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/package/network/services/hostapd/patches/600-ubus_support.patch b/package/network/services/hostapd/patches/600-ubus_support.patch index fb3bfb012030bd..256d1cfcc4bd95 100644 --- a/package/network/services/hostapd/patches/600-ubus_support.patch +++ b/package/network/services/hostapd/patches/600-ubus_support.patch @@ -116,6 +116,14 @@ probe/assoc/auth requests via object subscribe. #ifdef CONFIG_P2P if (elems.p2p) { wpabuf_free(sta->p2p_ie); +@@ -1369,6 +1379,7 @@ void hostapd_event_ch_switch(struct host + + wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED + "freq=%d dfs=%d", freq, is_dfs); ++ hostapd_ubus_notify_csa(hapd, freq); + } else if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) { + /* Complete AP configuration for the first bring up. */ + if (is_dfs0 > 0 && --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -475,6 +475,7 @@ void hostapd_free_hapd_data(struct hosta diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c index 4dda2b0571e53e..22567207556599 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.c +++ b/package/network/services/hostapd/src/src/ap/ubus.c @@ -2024,3 +2024,16 @@ void hostapd_ubus_notify_apup_newpeer( ubus_notify(ctx, &hapd->ubus.obj, "apup-newpeer", b.head, -1); } #endif // def CONFIG_APUP + +void hostapd_ubus_notify_csa(struct hostapd_data *hapd, int freq) +{ + if (!hapd->ubus.obj.has_subscribers) + return; + + blob_buf_init(&b, 0); + blobmsg_add_string(&b, "ifname", hapd->conf->iface); + blobmsg_add_u32(&b, "freq", freq); + blobmsg_printf(&b, "bssid", MACSTR, MAC2STR(hapd->conf->bssid)); + + ubus_notify(ctx, &hapd->ubus.obj, "channel-switch", b.head, -1); +} diff --git a/package/network/services/hostapd/src/src/ap/ubus.h b/package/network/services/hostapd/src/src/ap/ubus.h index 5c03cb90ad75b8..055a18c092fa60 100644 --- a/package/network/services/hostapd/src/src/ap/ubus.h +++ b/package/network/services/hostapd/src/src/ap/ubus.h @@ -68,6 +68,7 @@ int hostapd_ubus_notify_bss_transition_query( const u8 *candidate_list, u16 candidate_list_len); void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, const char *auth_alg); +void hostapd_ubus_notify_csa(struct hostapd_data *hapd, int freq); #ifdef CONFIG_APUP void hostapd_ubus_notify_apup_newpeer( @@ -155,6 +156,11 @@ hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta, { } +static inline void +hostapd_ubus_notify_csa(struct hostapd_data *hapd, int freq) +{ +} + #endif #endif From b9eadcf318f55215fbbac62e05b17ea7223eb6f8 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sat, 20 Nov 2021 01:43:20 +0000 Subject: [PATCH 19/29] base-files: uci-defaults: allow setting wireless defaults Introduce new uci-default functions: - ucidef_set_wireless band ssid [encryption] [key] - ucidef_set_country cc They are supposed to be used in /etc/board.d/* scripts to define board-specific defaults for wireless. Signed-off-by: Daniel Golle Signed-off-by: John Crispin --- .../files/lib/functions/uci-defaults.sh | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index b89cc8e9e309ab..ba7288c2c6bcc2 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -642,6 +642,41 @@ ucidef_set_hostname() { json_select .. } +ucidef_set_wireless() { + local band="$1" + local ssid="$2" + local encryption="$3" + local key="$4" + + case "$band" in + all|2g|5g|6g) ;; + *) return;; + esac + [ -z "$ssid" ] && return + + json_select_object wlan + json_select_object defaults + json_select_object ssids + json_select_object "$band" + json_add_string ssid "$ssid" + [ -n "$encryption" ] && json_add_string encryption "$encryption" + [ -n "$key" ] && json_add_string key "$key" + json_select .. + json_select .. + json_select .. + json_select .. +} + +ucidef_set_country() { + local country="$1" + + json_select_object wlan + json_select_object defaults + json_add_string country "$country" + json_select .. + json_select .. +} + ucidef_set_ntpserver() { local server From a8271b0f82657e7ead2acb519bb09d5d6e2c6ee6 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 14 Sep 2024 08:44:19 +0200 Subject: [PATCH 20/29] base-files: uci-defaults: allow setting default credentials and ssh keys Introduce new uci-default functions: - ucidef_set_root_password_hash [hash] - ucidef_set_root_password_plain [plaintext] - ucidef_set_ssh_authorized_key [ssh key] Signed-off-by: John Crispin --- .../files/lib/functions/uci-defaults.sh | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index ba7288c2c6bcc2..507ddfc11ae1ce 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -677,6 +677,29 @@ ucidef_set_country() { json_select .. } +ucidef_set_root_password_plain() { + local passwd="$1" + json_select_object credentials + json_add_string root_password_plain "$passwd" + json_select .. +} + +ucidef_set_root_password_hash() { + local passwd="$1" + json_select_object credentials + json_add_string root_password_hash "$passwd" + json_select .. +} + +ucidef_set_ssh_authorized_key() { + local ssh_key="$1" + json_select_object credentials + json_select_array ssh_authorized_keys + json_add_string "" "$ssh_key" + json_select .. + json_select .. +} + ucidef_set_ntpserver() { local server From fa53a733abbef5a001a5ff9ba1d7b1822e4caae6 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 21 Sep 2024 16:17:17 +0200 Subject: [PATCH 21/29] base-files: uci-defaults: allow setting default timezone Introduce new uci-default functions: - ucidef_set_timezone TZ Signed-off-by: John Crispin --- package/base-files/files/lib/functions/uci-defaults.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 507ddfc11ae1ce..4a710aab2c9356 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -642,6 +642,13 @@ ucidef_set_hostname() { json_select .. } +ucidef_set_timezone() { + local timezone="$1" + json_select_object system + json_add_string timezone "$timezone" + json_select .. +} + ucidef_set_wireless() { local band="$1" local ssid="$2" From e7c7a3c154f2eb83808ec9b3e1a345bda4082781 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 22 Sep 2024 09:06:10 +0200 Subject: [PATCH 22/29] base-files: uci-defaults: allow setting the number of MACs a radio can use Introduce new uci-default functions: - ucidef_set_wireless_mac_count [count] Signed-off-by: John Crispin --- .../files/lib/functions/uci-defaults.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh index 4a710aab2c9356..8355099c355483 100644 --- a/package/base-files/files/lib/functions/uci-defaults.sh +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -684,6 +684,27 @@ ucidef_set_country() { json_select .. } +ucidef_set_wireless_mac_count() { + local band="$1" + local mac_count="$2" + + case "$band" in + 2g|5g|6g) ;; + *) return;; + esac + [ -z "$mac_count" ] && return + + json_select_object wlan + json_select_object defaults + json_select_object ssids + json_select_object "$band" + json_add_string mac_count "$mac_count" + json_select .. + json_select .. + json_select .. + json_select .. +} + ucidef_set_root_password_plain() { local passwd="$1" json_select_object credentials From 7a120ee72e06217d87dfdff819052a84db32fd2b Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 22 Sep 2024 09:04:55 +0200 Subject: [PATCH 23/29] base-files: execute uboot-env script before calling config_generate This allows /etc/board.d/* scripts to use values from the uboot environment. Signed-off-by: John Crispin --- package/base-files/files/etc/init.d/boot | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot index d17754d087942b..c7d1d4af3ad375 100755 --- a/package/base-files/files/etc/init.d/boot +++ b/package/base-files/files/etc/init.d/boot @@ -10,7 +10,6 @@ uci_apply_defaults() { cd /etc/uci-defaults || return 0 files="$(ls)" [ -z "$files" ] && return 0 - mkdir -p /tmp/.uci for file in $files; do ( . "./$(basename $file)" ) && rm -f "$file" done @@ -47,6 +46,8 @@ boot() { sleep 1 } + mkdir -p /tmp/.uci + [ -f /etc/uci-defaults/30_uboot-envtools ] && (. /etc/uci-defaults/30_uboot-envtools) /bin/config_generate rm -f /tmp/.config_pending /sbin/wifi config From 84577e48bcfac9e9f12835ecf13a5e0ba2f71be2 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 14:36:13 +0200 Subject: [PATCH 24/29] uboot-envtools: add fw_loadenv tool This tool will load the uboot environment to /var/run/uboot-env/. This allows more efficient use when accessing multiple variables. Signed-off-by: John Crispin --- package/boot/uboot-envtools/Makefile | 1 + package/boot/uboot-envtools/files/fw_loadenv | 26 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 package/boot/uboot-envtools/files/fw_loadenv diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile index 19c3073c74a936..875afad554cf31 100644 --- a/package/boot/uboot-envtools/Makefile +++ b/package/boot/uboot-envtools/Makefile @@ -71,6 +71,7 @@ define Package/uboot-envtools/install $(LN) fw_printenv $(1)/usr/sbin/fw_setenv $(INSTALL_BIN) ./files/fw_printsys $(1)/usr/sbin $(INSTALL_BIN) ./files/fw_setsys $(1)/usr/sbin + $(INSTALL_BIN) ./files/fw_loadenv $(1)/usr/sbin $(INSTALL_DIR) $(1)/lib $(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib $(INSTALL_DIR) $(1)/etc/uci-defaults diff --git a/package/boot/uboot-envtools/files/fw_loadenv b/package/boot/uboot-envtools/files/fw_loadenv new file mode 100644 index 00000000000000..9fe302ce892315 --- /dev/null +++ b/package/boot/uboot-envtools/files/fw_loadenv @@ -0,0 +1,26 @@ +#!/usr/bin/ucode + +'use strict'; + +const path = '/var/run/uboot-env/'; + +import * as fs from 'fs'; + +if (fs.lsdir(path)) { + warn(`env has already been loaded to ${path}\n`); + exit(0); +} + +let fp = fs.popen('fw_printenv'); +let raw = fp.read('all'); +fp.close(); + +if (!length(raw)) + exit(0); + +fs.mkdir(path); +for (let line in split(raw, '\n')) { + let vals = split(line, '='); + if (vals[0] && vals[1]) + fs.writefile(path + vals[0], vals[1]); +} From b89b19b85436803513dc89681b17918c8fd9521f Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 17:30:46 +0200 Subject: [PATCH 25/29] uboot-envtools: add a board.d script to load defaults from the environment This allows loading default wifi credentials, passwords and ssh keys on firstboot. Signed-off-by: John Crispin --- package/boot/uboot-envtools/Makefile | 2 ++ package/boot/uboot-envtools/files/fw_defaults | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 package/boot/uboot-envtools/files/fw_defaults diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile index 875afad554cf31..61939be6de90e3 100644 --- a/package/boot/uboot-envtools/Makefile +++ b/package/boot/uboot-envtools/Makefile @@ -72,6 +72,8 @@ define Package/uboot-envtools/install $(INSTALL_BIN) ./files/fw_printsys $(1)/usr/sbin $(INSTALL_BIN) ./files/fw_setsys $(1)/usr/sbin $(INSTALL_BIN) ./files/fw_loadenv $(1)/usr/sbin + $(INSTALL_DIR) $(1)/etc/board.d + $(INSTALL_DATA) ./files/fw_defaults $(1)/etc/board.d/05_fw_defaults $(INSTALL_DIR) $(1)/lib $(INSTALL_DATA) ./files/uboot-envtools.sh $(1)/lib $(INSTALL_DIR) $(1)/etc/uci-defaults diff --git a/package/boot/uboot-envtools/files/fw_defaults b/package/boot/uboot-envtools/files/fw_defaults new file mode 100644 index 00000000000000..42558aaa883954 --- /dev/null +++ b/package/boot/uboot-envtools/files/fw_defaults @@ -0,0 +1,17 @@ +. /lib/functions/uci-defaults.sh + +fw_loadenv + +board_config_update + +[ -f /var/run/uboot-env/owrt_ssid -a -f /var/run/uboot-env/owrt_wifi_key ] && + ucidef_set_wireless all "$(cat /var/run/uboot-env/owrt_ssid)" sae-mixed "$(cat /var/run/uboot-env/owrt_wifi_key)" +[ -f /var/run/uboot-env/owrt_country ] && ucidef_set_country "$(cat /var/run/uboot-env/owrt_country)" +[ -f /var/run/uboot-env/owrt_ssh_auth_key ] && ucidef_set_ssh_authorized_key "$(cat /var/run/uboot-env/owrt_ssh_auth_key)" +[ -f /var/run/uboot-env/owrt_root_password_plain ] && ucidef_set_root_password_plain "$(cat /var/run/uboot-env/owrt_root_password_plain)" +[ -f /var/run/uboot-env/owrt_root_password_hash ] && ucidef_set_root_password_hash "$(cat /var/run/uboot-env/owrt_root_password_hash)" +[ -f /var/run/uboot-env/owrt_timezone ] && ucidef_set_timezone "$(cat /var/run/uboot-env/owrt_timezone)" + +board_config_flush + +exit 0 From b506a305fea85cbf1a822dfeb54d5a65906b31df Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 15:10:20 +0200 Subject: [PATCH 26/29] wifi-scripts: populate default wifi credentials and country code from board.json Signed-off-by: John Crispin --- .../wifi-scripts/files/lib/wifi/mac80211.uc | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc index b68167b7542649..9fd6c35e8b4ad0 100644 --- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc +++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc @@ -71,20 +71,34 @@ for (let phy_name, phy in board.wlan) { if (match(phy_name, /^phy[0-9]/)) id = `path='${phy.path}'`; + band_name = lc(band_name); + + let country, defaults, num_global_macaddr; + if (board.wlan.defaults) { + defaults = board.wlan.defaults.ssids?.[band_name]?.ssid ? board.wlan.defaults.ssids?.[band_name] : board.wlan.defaults.ssids?.all; + country = board.wlan.defaults.country; + if (!country && band_name != '2g') + defaults = null; + num_global_macaddr = board.wlan.defaults.ssids?.[band_name]?.mac_count; + } + print(`set ${s}=wifi-device set ${s}.type='mac80211' set ${s}.${id} -set ${s}.band='${lc(band_name)}' +set ${s}.band='${band_name}' set ${s}.channel='${channel}' set ${s}.htmode='${htmode}' -set ${s}.disabled='1' +set ${s}.country='${country || ''}' +set ${s}.num_global_macaddr='${num_global_macaddr || ''}' +set ${s}.disabled='${defaults ? 0 : 1}' set ${si}=wifi-iface set ${si}.device='${name}' set ${si}.network='lan' set ${si}.mode='ap' -set ${si}.ssid='OpenWrt' -set ${si}.encryption='none' +set ${si}.ssid='${defaults?.ssid || "OpenWrt"}' +set ${si}.encryption='${defaults?.encryption || "none"}' +set ${si}.key='${defaults?.key || ""}' `); commit = true; From e428d7999ad1cde66b9b8f0712a628e14ba5e188 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 16:58:24 +0200 Subject: [PATCH 27/29] dropbear: add a uci-defaults script for loading authorized keys Write the ssh authorized key to /etc/dropbear/ssh_authorized_keys if present inside boad.json. Signed-off-by: John Crispin --- package/network/services/dropbear/Makefile | 2 ++ .../services/dropbear/files/dropbear.defaults | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 package/network/services/dropbear/files/dropbear.defaults diff --git a/package/network/services/dropbear/Makefile b/package/network/services/dropbear/Makefile index 3367fd7f74eb92..e9f3bd693c617c 100644 --- a/package/network/services/dropbear/Makefile +++ b/package/network/services/dropbear/Makefile @@ -227,6 +227,8 @@ define Package/dropbear/install $(INSTALL_DIR) $(1)/etc/dropbear $(INSTALL_DIR) $(1)/lib/preinit $(INSTALL_DATA) ./files/dropbear.failsafe $(1)/lib/preinit/99_10_failsafe_dropbear + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_DATA) ./files/dropbear.defaults $(1)/etc/uci-defaults/50-dropbear $(foreach f,$(filter /etc/dropbear/%,$(Package/dropbear/conffiles)),$(if $(wildcard $(TOPDIR)/files/$(f)),chmod 0600 $(TOPDIR)/files/$(f) || :; )) endef diff --git a/package/network/services/dropbear/files/dropbear.defaults b/package/network/services/dropbear/files/dropbear.defaults new file mode 100644 index 00000000000000..e679bee5db29ba --- /dev/null +++ b/package/network/services/dropbear/files/dropbear.defaults @@ -0,0 +1,20 @@ +[ ! -s /etc/dropbear/authorized_keys ] || exit 0 + +. /usr/share/libubox/jshn.sh + +json_init +json_load "$(cat /etc/board.json)" +json_select credentials + json_get_keys keys ssh_authorized_keys + [ -z "$keys" ] || { + touch /etc/dropbear/authorized_keys + uci set dropbear.@dropbear[-1].PasswordAuth='off' + uci set dropbear.@dropbear[-1].RootPasswordAuth='off' + } + json_select ssh_authorized_keys + for key in $keys; do + json_get_var val "$key" + echo "$val" >> /etc/dropbear/authorized_keys + done + json_select .. +json_select .. From 5071e842b99b1fe96f7364693eeb4850a4878e51 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 21 Sep 2024 16:19:24 +0200 Subject: [PATCH 28/29] base-files: add timezone to UCI during config_generate Signed-off-by: John Crispin --- package/base-files/files/bin/config_generate | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate index be21d0079a8a7f..9d1968ce206006 100755 --- a/package/base-files/files/bin/config_generate +++ b/package/base-files/files/bin/config_generate @@ -341,6 +341,11 @@ generate_static_system() { uci -q set "system.@system[-1].compat_version=1.0" fi + local timezone + if json_get_var timezone timezone; then + uci -q set "system.@system[-1].timezone=$timezone" + fi + if json_is_a ntpserver array; then local keys key json_get_keys keys ntpserver From 859bb4dd3fe88ffe6b461559a39e3cc1e0547892 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 21 Sep 2024 17:53:24 +0200 Subject: [PATCH 29/29] base-files: set root password if present inside board.json Add code to set plain password or put the hash into /etc/shadow. Signed-off-by: John Crispin --- .../base-files/files/etc/uci-defaults/50-root-passwd | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 package/base-files/files/etc/uci-defaults/50-root-passwd diff --git a/package/base-files/files/etc/uci-defaults/50-root-passwd b/package/base-files/files/etc/uci-defaults/50-root-passwd new file mode 100644 index 00000000000000..9eddf1559baf33 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/50-root-passwd @@ -0,0 +1,12 @@ +. /usr/share/libubox/jshn.sh + +json_init +json_load "$(cat /etc/board.json)" + +json_select credentials + json_get_vars root_password_hash root_password_hash + [ -z "$root_password_hash" ] || sed -i "s|^root:[^:]*|root:$root_password_hash|g" /etc/shadow + + json_get_vars root_password_plain root_password_plain + [ -z "$root_password_plain" ] || { (echo "$root_password_plain"; sleep 1; echo "$root_password_plain") | passwd root } +json_select ..