[PATCH] base-files: migrate old UCI network bridge ports syntax

2024-05-18 Thread Rafał Miłecki
From: Rafał Miłecki 

netifd supports more accurate "ports" option (instead of "ifname") for
years now. Relevant changes were even backported to OpenWrt 21.02. Add
uci-defaults script that translates config files using deprecated
syntax.

Identical commit f716c30241d5 ended up reverted back in 2021 by
80be798d4a4f due to breaking downgrades. With 19.07 support ended it
should no longer be an issue.

Signed-off-by: Rafał Miłecki 
---
 .../uci-defaults/11_network-migrate-bridges   | 23 +++
 1 file changed, 23 insertions(+)
 create mode 100644 
package/base-files/files/etc/uci-defaults/11_network-migrate-bridges

diff --git 
a/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges 
b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
new file mode 100644
index 00..745648531f
--- /dev/null
+++ b/package/base-files/files/etc/uci-defaults/11_network-migrate-bridges
@@ -0,0 +1,23 @@
+. /lib/functions.sh
+
+migrate_ports() {
+   local config="$1"
+   local type ports ifname
+
+   config_get type "$config" type
+   [ "$type" != "bridge" ] && return
+
+   config_get ports "$config" ports
+   [ -n "$ports" ] && return
+
+   config_get ifname "$config" ifname
+   [ -z "$ifname" ] && return
+
+   for port in $ifname; do uci add_list network.$config.ports="$port"; done
+   uci delete network.$config.ifname
+}
+
+config_load network
+config_foreach migrate_ports device
+
+exit 1
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 2/2] mt76: update to Git HEAD (2024-04-03)

2024-05-16 Thread Rafał Miłecki
From: Felix Fietkau 

605624a4e17b mt76: fix path to page_pool helper include
e4de3592c4e3 wifi: mt76: mt7603: fix tx queue of loopback packets
446f652c967c wifi: mt76: mt7603: add wpdma tx eof flag for PSE client reset
669aba47a145 wifi: mt76: mt7915: fix HE PHY capability regression
5914ea57a31f wifi: mt76: mt7915: workaround dubious x | !y warning
e8b5991f7dac wifi: mt76: mt7915: workaround too long expansion sparse warnings
e507b4e32ead wifi: mt76: mt7921: fix fw used for offload check for mt7922
725f531c1459 wifi: mt76: connac: check for null before dereferencing
b108dda7e201 wifi: mt76: mt7996: fix size of txpower MCU command
5b7616491f07 wifi: mt76: mt7921: introduce mt7920 PCIe support
0436995feca9 wifi: mt76: mt7921s: fix potential hung tasks during chip recovery
75759dca73d5 wifi: mt76: mt7925: ensure 4-byte alignment for suspend & wow 
command
b96ab5e62010 wifi: mt76: mt7996: fix uninitialized variable in 
mt7996_irq_tasklet()
7ff11c7259a3 wifi: mt76: sdio: move mcu queue size check inside critical section
02846a5d0f0f wifi: mt76: mt7915: Remove unused of_gpio.h
cb8df32e0475 wifi: mt76: mt7996: disable rx header translation for BMC entry
a4c4b550512e wifi: mt76: connac: use peer address for station BMC entry
260c5b7c3ba0 wifi: mt76: mt7996: set RCPI value in rate control command
0b7e645db9c2 wifi: mt76: connac: enable HW CSO module for mt7996
f19035fe0b4d wifi: mt76: mt7996: fix non-main BSS no beacon issue for MBSS 
scenario
424e9df466ce wifi: mt76: mt7996: fix potential memory leakage when reading chip 
temperature
f70cb4f0508e wifi: mt76: connac: enable critical packet mode support for mt7992
5f1bf8865247 wifi: mt76: mt7996: add sanity checks for background radar trigger
1e336a8582dc wifi: mt76: connac: use muar idx 0xe for non-mt799x as well

Signed-off-by: Felix Fietkau 
(cherry picked from commit a10a6fbac794b30885d65ec817ebdcfe9f94d78a)
Signed-off-by: Rafał Miłecki 
---
 package/kernel/mt76/Makefile  |  8 +-
 ...7996-fix-size-of-txpower-MCU-command.patch | 56 ---
 ...-fix-uninitialized-variable-in-mt799.patch | 27 -
 ...-fix-potential-memory-leakage-when-r.patch | 39 
 ...-check-for-null-before-dereferencing.patch | 27 -
 ...-use-muar-idx-0xe-for-non-mt799x-as-.patch | 25 -
 ...603-fix-tx-queue-of-loopback-packets.patch | 99 ---
 ...-add-wpdma-tx-eof-flag-for-PSE-clien.patch | 24 -
 8 files changed, 4 insertions(+), 301 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0002-wifi-mt76-mt7996-fix-size-of-txpower-MCU-command.patch
 delete mode 100644 
package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-uninitialized-variable-in-mt799.patch
 delete mode 100644 
package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-potential-memory-leakage-when-r.patch
 delete mode 100644 
package/kernel/mt76/patches/0005-wifi-mt76-connac-check-for-null-before-dereferencing.patch
 delete mode 100644 
package/kernel/mt76/patches/0006-wifi-mt76-connac-use-muar-idx-0xe-for-non-mt799x-as-.patch
 delete mode 100644 
package/kernel/mt76/patches/0007-wifi-mt76-mt7603-fix-tx-queue-of-loopback-packets.patch
 delete mode 100644 
package/kernel/mt76/patches/0008-wifi-mt76-mt7603-add-wpdma-tx-eof-flag-for-PSE-clien.patch

diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 88087dc9cc..3f48c76faa 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -1,16 +1,16 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mt76
-PKG_RELEASE=2
+PKG_RELEASE=1
 
 PKG_LICENSE:=GPLv2
 PKG_LICENSE_FILES:=
 
 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2024-03-18
-PKG_SOURCE_VERSION:=2135e201e7a9339e018d4e2d4a33c73266e674d7
-PKG_MIRROR_HASH:=810f636c60c86e6a426c676c3bf7aaea2f711feb31f4a66889d485112b612745
+PKG_SOURCE_DATE:=2024-04-03
+PKG_SOURCE_VERSION:=1e336a8582dce2ef32ddd440d423e9afef961e71
+PKG_MIRROR_HASH:=f3801af80d5f9c1aa266c9401d4dfa2d501df0382c81fd249150e17dddc70936
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_USE_NINJA:=0
diff --git 
a/package/kernel/mt76/patches/0002-wifi-mt76-mt7996-fix-size-of-txpower-MCU-command.patch
 
b/package/kernel/mt76/patches/0002-wifi-mt76-mt7996-fix-size-of-txpower-MCU-command.patch
deleted file mode 100644
index f3d824558d..00
diff --git 
a/package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-uninitialized-variable-in-mt799.patch
 
b/package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-uninitialized-variable-in-mt799.patch
deleted file mode 100644
index c121bec972..00
diff --git 
a/package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-potential-memory-leakage-when-r.patch
 
b/package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-potential-memory-leakage-when-r.patch
deleted file mode 100644
index 421ace147e..00
diff --git 
a/package/kernel/mt76/patches/0005-wifi-mt76-connac-check-for-null-before-dereferencing.patch
 
b/package/kernel/mt76/patches/0005-wifi-mt76-connac-check-for-null-before-dereferencing.p

[PATCH 23.05 1/2] mt76: update to Git HEAD (2024-03-18)

2024-05-16 Thread Rafał Miłecki
From: Felix Fietkau 

a903d3169193 wifi: mt76: mt7921: fix a potential association failure upon 
resuming
eb0d0ce344f3 wifi: mt76: mt7921: fix suspend issue on MediaTek COB platform
841bf82e9958 wifi: mt76: fix the issue of missing txpwr settings from ch153 to 
ch177
ce7ccc540168 wifi: mt76: Remove redundant assignment to variable tidno
a238df940d6f wifi: mt76: mt7915: initialize rssi on adding stations
46c7d1849dbd wifi: mt76: replace skb_put with skb_put_zero
b5640b3153c7 wifi: mt76: fix tx packet loss when scanning on DBDC
7b054e5cb3af wifi: mt76: mt7915: fix mcu command format for mt7915 tx stats
3f27a64a8010 wifi: mt76: mt7915: fix bogus Tx/Rx airtime duration values
4f681a8fbc91 wifi: mt76: mt7915: fix HE PHY capabilities IE for station mode
8ede229eb8b5 wifi: mt76: mt7915: only set MT76_MCU_RESET for the main phy
2330781b8c5f wifi: mt76: mt7996: only set MT76_MCU_RESET for the main phy
e5fb6995e7eb wifi: mt76: mt7915: add support for disabling in-band discovery
b4a917417c85 wifi: mt76: mt7915: add mt7986, mt7916 and mt7981 pre-calibration
2135e201e7a9 mt76: mt7915: add fallback in case of missing precal data

Signed-off-by: Felix Fietkau 
(cherry picked from commit 85ad6b9569683d6cc5808d1797af7de0e781aa1d)
Signed-off-by: Rafał Miłecki 
---
 package/kernel/mt76/Makefile  |  6 ++--
 ...e-issue-of-missing-txpwr-settings-fr.patch | 28 ---
 2 files changed, 3 insertions(+), 31 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0001-wifi-mt76-fix-the-issue-of-missing-txpwr-settings-fr.patch

diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 22269277da..88087dc9cc 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
 
 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2024-02-03
-PKG_SOURCE_VERSION:=6124ea9135ed512671933f5520c46842906c78bc
-PKG_MIRROR_HASH:=acc326d7b15c9c72b494ed601300be329553f896e65c7f045e6a09327304c34a
+PKG_SOURCE_DATE:=2024-03-18
+PKG_SOURCE_VERSION:=2135e201e7a9339e018d4e2d4a33c73266e674d7
+PKG_MIRROR_HASH:=810f636c60c86e6a426c676c3bf7aaea2f711feb31f4a66889d485112b612745
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_USE_NINJA:=0
diff --git 
a/package/kernel/mt76/patches/0001-wifi-mt76-fix-the-issue-of-missing-txpwr-settings-fr.patch
 
b/package/kernel/mt76/patches/0001-wifi-mt76-fix-the-issue-of-missing-txpwr-settings-fr.patch
deleted file mode 100644
index ef7816a1a7..00
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 0/2] mt76: update

2024-05-16 Thread Rafał Miłecki
From: Rafał Miłecki 

This updated mt76 to the latest version. That code is still a bit new
so I'm not going to push those patches yet. I'd like mt76 code to be at
least 3 months old before updating to it. It's in case there are any
regressions to be discovered yet.

Felix Fietkau (2):
  mt76: update to Git HEAD (2024-03-18)
  mt76: update to Git HEAD (2024-04-03)

 package/kernel/mt76/Makefile  |  8 +-
 ...e-issue-of-missing-txpwr-settings-fr.patch | 28 --
 ...7996-fix-size-of-txpower-MCU-command.patch | 56 ---
 ...-fix-uninitialized-variable-in-mt799.patch | 27 -
 ...-fix-potential-memory-leakage-when-r.patch | 39 
 ...-check-for-null-before-dereferencing.patch | 27 -
 ...-use-muar-idx-0xe-for-non-mt799x-as-.patch | 25 -
 ...603-fix-tx-queue-of-loopback-packets.patch | 99 ---
 ...-add-wpdma-tx-eof-flag-for-PSE-clien.patch | 24 -
 9 files changed, 4 insertions(+), 329 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0001-wifi-mt76-fix-the-issue-of-missing-txpwr-settings-fr.patch
 delete mode 100644 
package/kernel/mt76/patches/0002-wifi-mt76-mt7996-fix-size-of-txpower-MCU-command.patch
 delete mode 100644 
package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-uninitialized-variable-in-mt799.patch
 delete mode 100644 
package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-potential-memory-leakage-when-r.patch
 delete mode 100644 
package/kernel/mt76/patches/0005-wifi-mt76-connac-check-for-null-before-dereferencing.patch
 delete mode 100644 
package/kernel/mt76/patches/0006-wifi-mt76-connac-use-muar-idx-0xe-for-non-mt799x-as-.patch
 delete mode 100644 
package/kernel/mt76/patches/0007-wifi-mt76-mt7603-fix-tx-queue-of-loopback-packets.patch
 delete mode 100644 
package/kernel/mt76/patches/0008-wifi-mt76-mt7603-add-wpdma-tx-eof-flag-for-PSE-clien.patch

-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 1/2] mt76: update to Git HEAD (2024-01-18)

2024-05-09 Thread Rafał Miłecki
From: Felix Fietkau 

83e3947e2c52 linux-firmware: update firmware for MT7922 WiFi device
ddaa8cb6e81a linux-firmware: update firmware for MT7921 WiFi device
f83b1601cc10 linux-firmware: update firmware for MT7922 WiFi device
61d334ab0f33 linux-firmware: add firmware for MT7925
a7836e4c8a60 wifi: mt76: disable HW AMSDU when using fixed rate
a8571ebbcd95 wifi: mt76: check txs format before getting skb by pid
3d5890e2cab3 wifi: mt76: mt7915: fix error recovery with WED enabled
703c26d01197 wifi: mt76: mt7915: add locking for accessing mapped registers
f77188160441 wifi: mt76: mt7915: update mt798x_wmac_adie_patch_7976

Signed-off-by: Felix Fietkau 
(cherry picked from commit a28cedbdab96be9bee39bb70098a1508c0252a8a)
---
 package/kernel/mt76/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 65f6ca1e8e..1fea3bd0e9 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
 
 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2023-12-18
-PKG_SOURCE_VERSION:=bebd9cffc2aeb2cecb40aadbb8c6eab3bdf7971b
-PKG_MIRROR_HASH:=580261755bc3f251b8bc5f7f610274693c067432187570694d2f2ccab0edb62b
+PKG_SOURCE_DATE:=2024-01-18
+PKG_SOURCE_VERSION:=f77188160441d5f77f08dd517632ae3f60c653b0
+PKG_MIRROR_HASH:=133a5e44624fe1933c893ee0b8ac75a847753f3490c26518c2ed9798f9ef53e0
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_USE_NINJA:=0
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 2/2] mt76: update to Git HEAD (2024-02-03)

2024-05-09 Thread Rafał Miłecki
From: Felix Fietkau 

a9693e1979c2 linux-firmware: add firmware for MT7996
0258dc90e3a1 wifi: mt76: mt7603: fix reading target power from eeprom
3e81173d9e2b wifi: mt76: mt7603: initialize chainmask
786a339bac36 wifi: mt76: mt7996: fix fortify warning
bc37a7ebc267 wifi: mt76: mt7996: fix fw loading timeout
027bab6a88a3 wifi: mt76: usb: create a dedicated queue for psd traffic
e8909c610c3b wifi: mt76: usb: store usb endpoint in mt76_queue
8b3d96fa4ead wifi: mt76: mt792xu: enable dmashdl support
7864d7ad0ed0 wifi: mt76: mt76x2u: add netgear wdna3100v3 to device table
27c81f7c1480 wifi: mt76: mt7925: fix connect to 80211b mode fail in 2Ghz band
b7443c63069a wifi: mt76: mt7925: fix SAP no beacon issue in 5Ghz and 6Ghz band
bab721a65f5a wifi: mt76: mt7925: fix mcu query command fail
1f0f71ed81e8 wifi: mt76: mt7925: fix wmm queue mapping
bcfe2ad966f3 wifi: mt76: mt7925: fix fw download fail
f982c3d67a29 wifi: mt76: mt7925: fix WoW failed in encrypted mode
6a72716ec213 wifi: mt76: mt7925: fix the wrong header translation config
50928b7e1359 wifi: mt76: mt7925: add flow to avoid chip bt function fail
762ab4530e8f wifi: mt76: mt7925: add support to set ifs time by mcu command
87deaf82efa4 wifi: mt76: mt7925: update PCIe DMA settings
c190c1576522 wifi: mt76: mt7925: support temperature sensor
025d5734caba wifi: mt76: mt7996: check txs format before getting skb by pid
4768bfa2baca wifi: mt76: mt7996: fix TWT issues
a65e3eced907 wifi: mt76: mt7996: disable AMSDU for non-data frames
d71716d93aee wifi: mt76: mt7996: fix incorrect interpretation of EHT MCS caps
f21728f3f4bd wifi: mt76: mt7996: ensure 4-byte alignment for beacon commands
68dad7dacd2a wifi: mt76: mt7996: fix HE beamformer phy cap for station vif
66a28f340cdc wifi: mt76: mt7996: mark GCMP IGTK unsupported
b47ad8a7764e wifi: mt76: mt7996: fix efuse reading issue
c2fc7dae7b72 wifi: mt76: mt7996: remove TXS queue setting
e0f1ed168ed5 wifi: mt76: mt7996: add locking for accessing mapped registers
d0cc92c1fd08 wifi: mt76: connac: set correct muar_idx for mt799x chipsets
ae0c62279adc wifi: mt76: mt7996: fix HIF_TXD_V2_1 value
ecc14276af54 wifi: mt76: mt792x: fix ethtool warning
9827df56b241 wifi: mt76: move wed common utilities in wed.c
dccbd2598505 wifi: mt76: mt7925: fix the wrong data type for scan command
9907f4f20261 wifi: mt76: mt792x: add the illegal value check for mtcl table of 
acpi
1b088a7ac06d wifi: mt76: mt7921e: fix use-after-free in free_irq()
f3c5b4820d7f wifi: mt76: mt7925e: fix use-after-free in free_irq()
d75eac9f5531 wifi: mt76: mt7921: fix incorrect type conversion for CLC command
7bd5401f5bb1 wifi: mt76: mt792x: fix a potential loading failure of the 6Ghz 
channel config from ACPI
ea55196bc4a0 wifi: mt76: mt792x: update the country list of EU for ACPI SAR
6124ea9135ed wifi: mt76: mt7921: fix the unfinished command of regd_notifier 
before suspend

Signed-off-by: Felix Fietkau 
(cherry picked from commit 114190d8ae61fb3a7671852fbd7f0ca3279a5625)
---
 package/kernel/mt76/Makefile  | 24 +++-
 ...wifi-mt76-mt7996-fix-fortify-warning.patch | 26 
 ...i-mt76-mt7996-fix-fw-loading-timeout.patch | 38 
 ...-check-txs-format-before-getting-skb.patch | 60 ---
 ...-fix-incorrect-type-conversion-for-C.patch | 38 
 5 files changed, 21 insertions(+), 165 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-fortify-warning.patch
 delete mode 100644 
package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-fw-loading-timeout.patch
 delete mode 100644 
package/kernel/mt76/patches/0005-wifi-mt76-mt7996-check-txs-format-before-getting-skb.patch
 delete mode 100644 
package/kernel/mt76/patches/0006-wifi-mt76-mt7921-fix-incorrect-type-conversion-for-C.patch

diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 1fea3bd0e9..4f0fb5f69d 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -8,9 +8,9 @@ PKG_LICENSE_FILES:=
 
 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2024-01-18
-PKG_SOURCE_VERSION:=f77188160441d5f77f08dd517632ae3f60c653b0
-PKG_MIRROR_HASH:=133a5e44624fe1933c893ee0b8ac75a847753f3490c26518c2ed9798f9ef53e0
+PKG_SOURCE_DATE:=2024-02-03
+PKG_SOURCE_VERSION:=6124ea9135ed512671933f5520c46842906c78bc
+PKG_MIRROR_HASH:=acc326d7b15c9c72b494ed601300be329553f896e65c7f045e6a09327304c34a
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_USE_NINJA:=0
@@ -323,6 +323,12 @@ define KernelPackage/mt7996e
   AUTOLOAD:=$(call AutoProbe,mt7996e)
 endef
 
+define KernelPackage/mt7996-firmware
+  $(KernelPackage/mt76-default)
+  TITLE:=MediaTek MT7996 firmware
+  DEPENDS+=+kmod-mt7996e
+endef
+
 define KernelPackage/mt7925-common
   $(KernelPackage/mt76-default)
   TITLE:=MediaTek MT7925 wireless driver common code
@@ -610,6 +616,17 @@ define KernelPackage/mt7922-firmware/install
$(1)/lib/firmware/mediatek
 endef
 
+define KernelPackage/mt7996-firmware/install
+   

[PATCH 23.05 0/2] mt76: firmwares, minor power fixes, mt7925/mt7996 stability

2024-05-09 Thread Rafał Miłecki
From: Rafał Miłecki 

Update 23.05 mt76 to the 3 months old version which should we well
tested by now. There are minor fixes, updated firmwares and mt7996 out
of box support thanks to the included firmware files.

Felix Fietkau (2):
  mt76: update to Git HEAD (2024-01-18)
  mt76: update to Git HEAD (2024-02-03)

 package/kernel/mt76/Makefile  | 24 +++-
 ...wifi-mt76-mt7996-fix-fortify-warning.patch | 26 
 ...i-mt76-mt7996-fix-fw-loading-timeout.patch | 38 
 ...-check-txs-format-before-getting-skb.patch | 60 ---
 ...-fix-incorrect-type-conversion-for-C.patch | 38 
 5 files changed, 21 insertions(+), 165 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0003-wifi-mt76-mt7996-fix-fortify-warning.patch
 delete mode 100644 
package/kernel/mt76/patches/0004-wifi-mt76-mt7996-fix-fw-loading-timeout.patch
 delete mode 100644 
package/kernel/mt76/patches/0005-wifi-mt76-mt7996-check-txs-format-before-getting-skb.patch
 delete mode 100644 
package/kernel/mt76/patches/0006-wifi-mt76-mt7921-fix-incorrect-type-conversion-for-C.patch

-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 0/2] mt76: update for some fixes & important features

2024-04-29 Thread Rafał Miłecki
From: Rafał Miłecki 

I'd like to slightly update mt76 for 23.05.

This update:
1. Is important for MT7996 (important features including WED support)
2. Includes minor fixes for mt7915 & mt7921

Felix Fietkau (2):
  mt76: update to the latest version
  mt76: update to Git HEAD (2023-12-08)

 package/kernel/mt76/Makefile  | 56 +--
 ..._wed-rename-mtk_rxbm_desc-in-mtk_wed.patch | 24 
 2 files changed, 52 insertions(+), 28 deletions(-)
 delete mode 100644 
package/kernel/mt76/patches/0001-net-ethernet-mtk_wed-rename-mtk_rxbm_desc-in-mtk_wed.patch

-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 23.05 1/2] mt76: update to the latest version

2024-04-29 Thread Rafał Miłecki
From: Felix Fietkau 

b5d13611d35e mt76: mt7915: fix monitor mode issues
bbbac7deee3d wifi: mt76: rename mt76_packet_id_init/flush to 
mt76_wcid_init/cleanup
f1e1e67d97d1 wifi: mt76: fix race condition related to checking tx queue fill 
status
b3f739a64e6b wifi: mt76: mt7996: add eht rx rate support
ca4917062f17 wifi: mt76: mt76x0: remove dead code in mt76x0_phy_get_target_power
325a0c493199 wifi: mt76: mt7996: fill txd by host driver
cd371fcc98d4 mt76: mt7996: sync with upstream
d71f8d1b172b wifi: mt76: use atomic iface iteration for pre-TBTT work
8d5ea32d4895 wifi: mt76: remove unused error path in mt76_connac_tx_complete_skb
01860c02c505 wifi: mt76: add DMA mapping error check in mt76_alloc_txwi()
62ddb6d46a97 wifi: mt76: connac: introduce helper for mt7925 chipset
0837f37e998b wifi: mt76: mt792x: support mt7925 chip init
899ff378082b wifi: mt76: connac: export functions for mt7925
c3858b5bf347 wifi: mt76: connac: add eht support for phy mode config
5df6b26a9fc5 wifi: mt76: connac: add eht support for tx power
a8081345c636 wifi: mt76: connac: add data field in struct tlv
9b38aebecf78 wifi: mt76: connac: add more unified command IDs
84984e6dc87d wifi: mt76: connac: add more unified event IDs
6fe92398c9ce wifi: mt76: mt7996: set correct wcid in txp
2cfe2fb0bb80 wifi: mt76: mt7996: fix beamform mcu cmd configuration
e512241bb5bb wifi: mt76: mt7996: fix beamformee ss subfield in EHT PHY cap
719a98f832c7 wifi: mt76: mt7996: fix wmm queue mapping
9723562f2a5b wifi: mt76: mt7996: fix rx rate report for CBW320-2
1bb5a6a54943 wifi: mt76: mt7996: fix TWT command format
751b054891f6 wifi: mt76: mt7996: only set vif teardown cmds at remove interface
fea1e10c7741 wifi: mt76: mt7996: support more options for 
mt7996_set_bitrate_mask()
d497ee8aa2f5 wifi: mt76: mt7996: support per-band LED control
8ccc8441 wifi: mt76: Use PTR_ERR_OR_ZERO() to simplify code
161f70217edf wifi: mt76: mt7921e: Support MT7992 IP in Xiaomi Redmibook 15 Pro 
(2023)
7d25bfc3f0cc wifi: mt76: fix clang-specific fortify warnings
5971aa968401 wifi: mt76: connac: add MBSSID support for mt7996
5a47dd323be1 wifi: mt76: update beacon size limitation
d5b4b81dcc9e wifi: mt76: check sta rx control frame to multibss capability
af0e1f6dafb5 wifi: mt76: fix potential memory leak of beacon commands
65d91a833b01 wifi: mt76: get rid of false alamrs of tx emission issues
29411e52059f wifi: mt76: fix per-band IEEE80211_CONF_MONITOR flag comparison
4da62774038a wifi: mt76: check vif type before reporting cca and csa
4a85678fe089 wifi: mt76: mt7915: update mpdu density capability
791a45cffadf wifi: mt76: mt7915: fix beamforming availability check
08e1e6cb7d41 wifi: mt76: Drop unnecessary error check for debugfs_create_dir()
d1881b1b2bf6 wifi: mt76: move struct ieee80211_chanctx_conf up to struct 
mt76_vif
66d5694e1898 wifi: mt76: mt7921: fix the wrong rate pickup for the chanctx 
driver
9fc37b0ac546 wifi: mt76: mt7921: fix the wrong rate selected in fw for the 
chanctx driver
2afc7285f75d wifi: mt76: mt7925: add Mediatek Wi-Fi7 driver for mt7925 chips

Signed-off-by: Felix Fietkau 
(cherry picked from commit ef8e2f66f563d0d1864be37075dacf3f13defdc7)
Signed-off-by: Rafał Miłecki 
---
 package/kernel/mt76/Makefile | 56 +---
 1 file changed, 52 insertions(+), 4 deletions(-)

diff --git a/package/kernel/mt76/Makefile b/package/kernel/mt76/Makefile
index 500735303f..dd75390ee7 100644
--- a/package/kernel/mt76/Makefile
+++ b/package/kernel/mt76/Makefile
@@ -1,16 +1,16 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mt76
-PKG_RELEASE=2
+PKG_RELEASE=1
 
 PKG_LICENSE:=GPLv2
 PKG_LICENSE_FILES:=
 
 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_DATE:=2023-09-11
-PKG_SOURCE_VERSION:=f1e1e67d97d1e9a8bb01b59ab20c45ebc985a958
-PKG_MIRROR_HASH:=41fde79de5bec3aaafdb64658475a1fa99bc483b8122e6aad9b2aa8aa8edfce6
+PKG_SOURCE_DATE:=2023-09-18
+PKG_SOURCE_VERSION:=2afc7285f75dca5a0583fd917285bf33f1429cc6
+PKG_MIRROR_HASH:=2c9556b298246277ac2d65415e4449f98e6d5fdb99e0d0a92262f162df772bbc
 
 PKG_MAINTAINER:=Felix Fietkau 
 PKG_USE_NINJA:=0
@@ -315,6 +315,38 @@ define KernelPackage/mt7921e
   AUTOLOAD:=$(call AutoProbe,mt7921e)
 endef
 
+define KernelPackage/mt7996e
+  $(KernelPackage/mt76-default)
+  TITLE:=MediaTek MT7996E wireless driver
+  DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac
+  FILES:= $(PKG_BUILD_DIR)/mt7996/mt7996e.ko
+  AUTOLOAD:=$(call AutoProbe,mt7996e)
+endef
+
+define KernelPackage/mt7925-common
+  $(KernelPackage/mt76-default)
+  TITLE:=MediaTek MT7925 wireless driver common code
+  HIDDEN:=1
+  DEPENDS+=+kmod-mt792x-common +@DRIVER_11AX_SUPPORT +kmod-hwmon-core
+  FILES:= $(PKG_BUILD_DIR)/mt7925/mt7925-common.ko
+endef
+
+define KernelPackage/mt7925u
+  $(KernelPackage/mt76-default)
+  TITLE:=MediaTek MT7925U wireless driver
+  DEPENDS+=+kmod-mt792x-usb +kmod-mt7925-common
+  FILES:= $(PKG_BUILD_DIR)/mt7925/mt7925u.ko
+  AUTOLOAD:=$(call AutoProbe,mt7921u)
+endef
+
+define KernelPackage/mt7925e

[PATCH 23.05 2/2] mt76: update to Git HEAD (2023-12-08)

2024-04-29 Thread Rafał Miłecki
From: Felix Fietkau 

890ae4d717f1 wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling
fcc2f3d82bc9 wifi: mt76: fix lock dependency problem for wed_lock
77cc14596202 wifi: mt76: mt792x: move mt7921_skb_add_usb_sdio_hdr in mt792x 
module
bc85355885d1 wifi: mt76: mt792x: move some common usb code in mt792x module
c27f01c4c834 wifi: mt76: mt7996: get tx_retries and tx_failed from txfree
30aba4c18307 wifi: mt76: mt7996: Add mcu commands for getting sta tx statistic
119bebff244b wifi: mt76: mt7996: enable PPDU-TxS to host
a4005e0e83e7 wifi: mt76: mt7996: remove periodic MPDU TXS request
d6cc20bf5913 wifi: mt76: reduce spin_lock_bh held up in mt76_dma_rx_cleanup
5d94251d641c wifi: mt76: mt7921: move connac nic capability handling to mt7921
266341b5019d wifi: mt76: mt7921: enable set txpower for UNII-4
581449ac5274 wifi: mt76: mt7921: add 6GHz power type support for clc
9bfd669e9477 wifi: mt76: mt7921: get regulatory information from the clc event
4a0f839da0f1 wifi: mt76: mt7921: update the channel usage when the regd domain 
changed
f4df423d3d56 wifi: mt76: add ability to explicitly forbid LED registration with 
DT
54d369e79972 wifi: mt76: mt7921: support 5.9/6GHz channel config in acpi
b39b6cba220f wifi: mt76: mt7996: fix uninitialized variable in parsing txfree
77194e652885 wifi: mt76: fix typo in mt76_get_of_eeprom_from_nvmem function
c37738fc9097 wifi: mt76: limit support of precal loading for mt7915 to MTD only
d6e8aa634a19 wifi: mt76: make mt76_get_of_eeprom static again
d1c671a90eba wifi: mt76: permit to use alternative cell name to eeprom NVMEM 
load
5539001fe4e3 wifi: mt76: permit to load precal from NVMEM cell for mt7915
48d413380685 wifi: mt76: Remove unnecessary (void*) conversions
ea2814289147 wifi: mt76: mmio: move mt76_mmio_wed_{init,release}_rx_buf in 
common code
9fb0277d7ee8 wifi: mt76: move mt76_mmio_wed_offload_{enable,disable} in common 
code
4b47145ecf44 wifi: mt76: move mt76_net_setup_tc in common code
d798d5d6f770 wifi: mt76: introduce mt76_queue_is_wed_tx_free utility routine
48b0cedbf83f wifi: mt76: introduce wed pointer in mt76_queue
c550204e347d wifi: mt76: increase MT_QFLAG_WED_TYPE size
2e7f30f22cfd wifi: mt76: mt7996: add wed tx support
ec8765a02fc8 wifi: mt76: dma: introduce __mt76_dma_queue_reset utility routine
a469aaac9784 wifi: mt76: mt7996: use u16 for val field in mt7996_mcu_set_rro 
signature
abca260a15c4 wifi: mt76: mt7996: add wed rx support
be2e74c0c495 wifi: mt76: move wed reset common code in mt76 module
7f17e164fbb4 wifi: mt76: mt7996: add wed reset support
0f89bf58efda wifi: mt76: mt7996: add wed rro delete session garbage collector
a58b75f863ca wifi: mt76: mt7915: fallback to non-wed mode if 
platform_get_resource fails in mt7915_mmio_wed_init()
36d2ddd94eeb wifi: mt76: mt7996: add support for variants with auxiliary RX path
cec7720c9341 wifi: mt76: mt7996: add TX statistics for EHT mode in debugfs
9852093062e8 wifi: mt76: connac: add thermal protection support for mt7996
955540a4df74 wifi: mt76: mt7996: add thermal sensor device support
af41374a3b8e wifi: mt76: connac: add beacon duplicate TX mode support for mt7996
3c98d7b7fa23 wifi: mt76: mt7996: fix the size of struct bss_rate_tlv
ee2169c00539 wifi: mt76: mt7996: adjust WFDMA settings to improve performance
0aead5de68a7 wifi: mt76: connac: set fixed_bw bit in TX descriptor for fixed 
rate frames
ab5580ff5a4f wifi: mt76: mt7996: handle IEEE80211_RC_SMPS_CHANGED
eed234afed7e wifi: mt76: mt7996: align the format of fixed rate command
d9a855285b95 wifi: mt76: mt7996: fix rate usage of inband discovery frames
47799aefe263 wifi: mt76: change txpower init to per-phy
264e1ecfe1b4 wifi: mt76: mt7996: add txpower setting support
c7b243b127eb wifi: mt76: use chainmask for power delta calculation
05f433900a02 wifi: mt76: mt7996: switch to mcu command for TX GI report
ae963198e605 wifi: mt76: mt7996: fix alignment of sta info event
d0d2e03591d6 wifi: mt76: mt7996: rework ampdu params setting
e87f4efc7638 wifi: mt76: connac: add beacon protection support for mt7996
0dfcc53a8e5d wifi: mt76: connac: fix EHT phy mode check
30c54a53bf8b wifi: mt76: mt7915: fix EEPROM offset of TSSI flag on MT7981
17297c97b737 wifi: mt76: mt7915: also MT7981 is 3T3R but nss2 on 5 GHz band
eeb48c081034 wifi: mt76: mt7996: fix mt7996_mcu_all_sta_info_event struct 
packing
b74ad922659c wifi: mt76: mt7996: introduce mt7996_band_valid()
51cb541c1e53 wifi: mt76: connac: add firmware support for mt7992
c0eda4d96ec8 wifi: mt76: mt7996: add DMA support for mt7992
f12471968a53 wifi: mt76: mt7996: rework register offsets for mt7992
8d11dae73eb8 wifi: mt76: mt7996: support mt7992 eeprom loading
6c2b2c37abd7 wifi: mt76: mt7996: adjust interface num and wtbl size for mt7992
df1d3b3c67e5 wifi: mt76: connac: add new definition of tx descriptor
f997e759cea5 wifi: mt76: mt7996: add PCI IDs for mt7992
94e3632e4e93 wifi: mt76: mt7925: remove iftype from mt7925_init_eht_caps 
signature
9c7b98c03173 net: ethernet: mtk_wed: rename mtk_rxbm_desc in 

[PATCH] mediatek: include "kmod-mt7915e" package per device

2024-04-22 Thread Rafał Miłecki
From: Rafał Miłecki 

mt7915e driver supports MT7915 & MT7916 devices and MT7981 & MT7986
on-SoC wireless controllers. Devices based on MT7988 and possibly other
next chipsets are quite unlikely to need it (MT7988 was designed to be
used with MT7996).

Move kmod-mt7915e to DEVICE_PACKAGES of relevant devices.

Signed-off-by: Rafał Miłecki 
---
 target/linux/mediatek/filogic/target.mk |  2 +-
 target/linux/mediatek/image/filogic.mk  | 98 -
 2 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/target/linux/mediatek/filogic/target.mk 
b/target/linux/mediatek/filogic/target.mk
index c87552f196..d1637e06af 100644
--- a/target/linux/mediatek/filogic/target.mk
+++ b/target/linux/mediatek/filogic/target.mk
@@ -2,7 +2,7 @@ ARCH:=aarch64
 SUBTARGET:=filogic
 BOARDNAME:=Filogic 8x0 (MT798x)
 CPU_TYPE:=cortex-a53
-DEFAULT_PACKAGES += fitblk kmod-phy-aquantia kmod-crypto-hw-safexcel 
kmod-mt7915e wpad-basic-mbedtls uboot-envtools
+DEFAULT_PACKAGES += fitblk kmod-phy-aquantia kmod-crypto-hw-safexcel 
wpad-basic-mbedtls uboot-envtools
 KERNELNAME:=Image dtbs
 
 define Target/Description
diff --git a/target/linux/mediatek/image/filogic.mk 
b/target/linux/mediatek/image/filogic.mk
index c3de23f5e8..635dccd679 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -110,7 +110,7 @@ define Device/acelink_ew-7886cax
   DEVICE_MODEL := EW-7886CAX
   DEVICE_DTS := mt7986a-acelink-ew-7886cax
   DEVICE_DTS_DIR := ../dts
-  DEVICE_PACKAGES := kmod-mt7986-firmware mt7986-wo-firmware
+  DEVICE_PACKAGES := kmod-mt7915e kmod-mt7986-firmware mt7986-wo-firmware
   UBINIZE_OPTS := -E 5
   BLOCKSIZE := 128k
   PAGESIZE := 2048
@@ -128,7 +128,7 @@ define Device/acer_predator-w6
   DEVICE_DTS := mt7986a-acer-predator-w6
   DEVICE_DTS_DIR := ../dts
   DEVICE_DTS_LOADADDR := 0x4700
-  DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware kmod-mt7916-firmware 
mt7986-wo-firmware e2fsprogs f2fsck mkf2fs
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7915e kmod-mt7916-firmware 
kmod-mt7986-firmware mt7986-wo-firmware e2fsprogs f2fsck mkf2fs
   IMAGES := sysupgrade.bin
   KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword 
$$(DEVICE_DTS)).dtb
   KERNEL_INITRAMFS := kernel-bin | lzma | \
@@ -141,7 +141,7 @@ define Device/adtran_smartrg
   DEVICE_VENDOR := Adtran
   DEVICE_DTS_DIR := ../dts
   DEVICE_PACKAGES := e2fsprogs f2fsck mkf2fs kmod-hwmon-pwmfan \
-kmod-mt7986-firmware mt7986-wo-firmware
+kmod-mt7915e kmod-mt7986-firmware mt7986-wo-firmware
   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
@@ -163,7 +163,7 @@ define Device/smartrg_sdg-8622
 $(call Device/adtran_smartrg)
   DEVICE_MODEL := SDG-8622
   DEVICE_DTS := mt7986a-smartrg-SDG-8622
-  DEVICE_PACKAGES += kmod-mt7915-firmware
+  DEVICE_PACKAGES += kmod-mt7915e kmod-mt7915-firmware
 endef
 TARGET_DEVICES += smartrg_sdg-8622
 
@@ -171,7 +171,7 @@ define Device/smartrg_sdg-8632
 $(call Device/adtran_smartrg)
   DEVICE_MODEL := SDG-8632
   DEVICE_DTS := mt7986a-smartrg-SDG-8632
-  DEVICE_PACKAGES += kmod-mt7915-firmware
+  DEVICE_PACKAGES += kmod-mt7915e kmod-mt7915-firmware
 endef
 TARGET_DEVICES += smartrg_sdg-8632
 
@@ -180,7 +180,7 @@ define Device/asus_rt-ax59u
   DEVICE_MODEL := RT-AX59U
   DEVICE_DTS := mt7986a-asus-rt-ax59u
   DEVICE_DTS_DIR := ../dts
-  DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7915e kmod-mt7986-firmware 
mt7986-wo-firmware
   IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += asus_rt-ax59u
@@ -191,7 +191,7 @@ define Device/asus_tuf-ax4200
   DEVICE_DTS := mt7986a-asus-tuf-ax4200
   DEVICE_DTS_DIR := ../dts
   DEVICE_DTS_LOADADDR := 0x4700
-  DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7915e kmod-mt7986-firmware 
mt7986-wo-firmware
   IMAGES := sysupgrade.bin
   KERNEL := kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
@@ -207,7 +207,7 @@ define Device/asus_tuf-ax6000
   DEVICE_DTS := mt7986a-asus-tuf-ax6000
   DEVICE_DTS_DIR := ../dts
   DEVICE_DTS_LOADADDR := 0x4700
-  DEVICE_PACKAGES := kmod-usb3 kmod-mt7986-firmware mt7986-wo-firmware
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7915e kmod-mt7986-firmware 
mt7986-wo-firmware
   IMAGES := sysupgrade.bin
   KERNEL := kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
@@ -227,7 +227,7 @@ define Device/bananapi_bpi-r3
   mt7986a-bananapi-bpi-r3-respeaker-2mics
   DEVICE_DTS_DIR := $(DTS_DIR)/
   DEVICE_DTS_LOADADDR := 0x43f0
-  DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7986-firmware 
kmod-sfp kmod-usb3 \
+  DEVICE_PACKAGES := kmod-hwmon-pwmfan kmod-i2c-gpio kmod-mt7915e 
kmod-mt7986-firmware kmod-sfp kmod-usb3 \
 e2fsprogs f2fsck mkf2fs mt7986-wo-firmware
 

[PATCH 23.05 1/2] mac80211: backport ieee80211_vif_is_mld()

2024-04-19 Thread Rafał Miłecki
From: Rafał Miłecki 

It's needed by some drivers, e.g. mt7925, see:
mt7925/mcu.c:2181:23: error: implicit declaration of function 
'ieee80211_vif_is_mld' [-Werror=implicit-function-declaration]

Signed-off-by: Rafał Miłecki 
---
 ...-mac80211-warn-only-once-on-AP-probe.patch |  32 ++
 ...6.5-wifi-mac80211-HW-restart-for-MLO.patch | 171 ++
 ...1-implement-proper-AP-MLD-HW-restart.patch |  84 +++
 ...d-getter-functions-for-vif-MLD-state.patch | 538 ++
 4 files changed, 825 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/subsys/346-v6.4-wifi-mac80211-warn-only-once-on-AP-probe.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/347-v6.5-wifi-mac80211-HW-restart-for-MLO.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/348-v6.5-wifi-mac80211-implement-proper-AP-MLD-HW-restart.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/349-v6.5-wifi-mac80211-Add-getter-functions-for-vif-MLD-state.patch

diff --git 
a/package/kernel/mac80211/patches/subsys/346-v6.4-wifi-mac80211-warn-only-once-on-AP-probe.patch
 
b/package/kernel/mac80211/patches/subsys/346-v6.4-wifi-mac80211-warn-only-once-on-AP-probe.patch
new file mode 100644
index 00..3844ae6f7f
--- /dev/null
+++ 
b/package/kernel/mac80211/patches/subsys/346-v6.4-wifi-mac80211-warn-only-once-on-AP-probe.patch
@@ -0,0 +1,32 @@
+From a1e91ef92392e5da15a1a16f8545ede2c02f7049 Mon Sep 17 00:00:00 2001
+From: Johannes Berg 
+Date: Wed, 1 Mar 2023 12:09:24 +0200
+Subject: [PATCH] wifi: mac80211: warn only once on AP probe
+
+We should perhaps support this API for MLO, but it's not
+clear that it makes sense, in any case then we'd have to
+update it to probe the correct BSS.
+
+For now, if it happens, warn only once so that we don't
+get flooded with messages if the driver misbehaves and
+calls this.
+
+Signed-off-by: Johannes Berg 
+Signed-off-by: Gregory Greenman 
+Link: 
https://lore.kernel.org/r/20230301115906.1c8499b6fbe6.I1a76a2be3b42ff93904870ac069f0319507adc23@changeid
+Signed-off-by: Johannes Berg 
+---
+ net/mac80211/mlme.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/mac80211/mlme.c
 b/net/mac80211/mlme.c
+@@ -3233,7 +3233,7 @@ static void ieee80211_mgd_probe_ap(struc
+   struct ieee80211_if_managed *ifmgd = >u.mgd;
+   bool already = false;
+ 
+-  if (WARN_ON(sdata->vif.valid_links))
++  if (WARN_ON_ONCE(sdata->vif.valid_links))
+   return;
+ 
+   if (!ieee80211_sdata_running(sdata))
diff --git 
a/package/kernel/mac80211/patches/subsys/347-v6.5-wifi-mac80211-HW-restart-for-MLO.patch
 
b/package/kernel/mac80211/patches/subsys/347-v6.5-wifi-mac80211-HW-restart-for-MLO.patch
new file mode 100644
index 00..d61f583bca
--- /dev/null
+++ 
b/package/kernel/mac80211/patches/subsys/347-v6.5-wifi-mac80211-HW-restart-for-MLO.patch
@@ -0,0 +1,171 @@
+From acb8bca343f8d5b8697d027771abf8a371580d53 Mon Sep 17 00:00:00 2001
+From: Johannes Berg 
+Date: Thu, 4 May 2023 16:45:05 +0300
+Subject: [PATCH] wifi: mac80211: HW restart for MLO
+
+Implement proper reconfiguration for interfaces that are
+doing MLO, in order to be able to recover from HW restart
+correctly.
+
+Signed-off-by: Johannes Berg 
+Signed-off-by: Gregory Greenman 
+Link: 
https://lore.kernel.org/r/20230504134511.828474-6-gregory.green...@intel.com
+Signed-off-by: Johannes Berg 
+---
+ net/mac80211/util.c | 107 ++--
+ 1 file changed, 73 insertions(+), 34 deletions(-)
+
+--- a/net/mac80211/util.c
 b/net/mac80211/util.c
+@@ -2493,21 +2493,55 @@ int ieee80211_reconfig(struct ieee80211_
+ 
+   /* Finally also reconfigure all the BSS information */
+   list_for_each_entry(sdata, >interfaces, list) {
++  /* common change flags for all interface types - link only */
++  u32 changed = BSS_CHANGED_ERP_CTS_PROT |
++BSS_CHANGED_ERP_PREAMBLE |
++BSS_CHANGED_ERP_SLOT |
++BSS_CHANGED_HT |
++BSS_CHANGED_BASIC_RATES |
++BSS_CHANGED_BEACON_INT |
++BSS_CHANGED_BSSID |
++BSS_CHANGED_CQM |
++BSS_CHANGED_QOS |
++BSS_CHANGED_TXPOWER |
++BSS_CHANGED_MCAST_RATE;
++  struct ieee80211_link_data *link = NULL;
+   unsigned int link_id;
+-  u32 changed;
++  u32 active_links = 0;
+ 
+   if (!ieee80211_sdata_running(sdata))
+   continue;
+ 
+   sdata_lock(sdata);
++  if (sdata->vif.valid_links) {
++  struct ieee80211_bss_conf 
*old[IEEE80211_MLD_MAX_NUM_LINKS] = {
++  [0] = >vif.bss_conf,
++  };
++
++  if (sdata->vif.type == N

[PATCH 23.05 2/2] mac80211: backport ieee80211_set_sband_iftype_data()

2024-04-19 Thread Rafał Miłecki
From: Rafał Miłecki 

It's needed by some drivers, e.g. mt7925, see:
mt7925/main.c:264:9: error: implicit declaration of function 
'_ieee80211_set_sband_iftype_data' [-Werror=implicit-function-declaration]

Signed-off-by: Rafał Miłecki 
---
 ...d-ieee80211_set_sband_iftype_data-he.patch | 49 +++
 1 file changed, 49 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/subsys/781-wifi-cfg80211-add-ieee80211_set_sband_iftype_data-he.patch

diff --git 
a/package/kernel/mac80211/patches/subsys/781-wifi-cfg80211-add-ieee80211_set_sband_iftype_data-he.patch
 
b/package/kernel/mac80211/patches/subsys/781-wifi-cfg80211-add-ieee80211_set_sband_iftype_data-he.patch
new file mode 100644
index 00..c2bfdebb97
--- /dev/null
+++ 
b/package/kernel/mac80211/patches/subsys/781-wifi-cfg80211-add-ieee80211_set_sband_iftype_data-he.patch
@@ -0,0 +1,49 @@
+From: Johannes Berg 
+Date: Mon, 28 Aug 2023 09:54:39 +0200
+Subject: [PATCH] wifi: cfg80211: add ieee80211_set_sband_iftype_data() helper
+ macro
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Johannes Berg 
+[rmilecki: extract from the e8c1841278a7]
+Signed-off-by: Rafał Miłecki 
+---
+
+--- a/include/net/cfg80211.h
 b/include/net/cfg80211.h
+@@ -555,6 +555,33 @@ struct ieee80211_supported_band {
+ };
+ 
+ /**
++ * _ieee80211_set_sband_iftype_data - set sband iftype data array
++ * @sband: the sband to initialize
++ * @iftd: the iftype data array pointer
++ * @n_iftd: the length of the iftype data array
++ *
++ * Set the sband iftype data array; use this where the length cannot
++ * be derived from the ARRAY_SIZE() of the argument, but prefer
++ * ieee80211_set_sband_iftype_data() where it can be used.
++ */
++static inline void
++_ieee80211_set_sband_iftype_data(struct ieee80211_supported_band *sband,
++   const struct ieee80211_sband_iftype_data *iftd,
++   u16 n_iftd)
++{
++  sband->iftype_data = iftd;
++  sband->n_iftype_data = n_iftd;
++}
++
++/**
++ * ieee80211_set_sband_iftype_data - set sband iftype data array
++ * @sband: the sband to initialize
++ * @iftd: the iftype data array
++ */
++#define ieee80211_set_sband_iftype_data(sband, iftd)  \
++  _ieee80211_set_sband_iftype_data(sband, iftd, ARRAY_SIZE(iftd))
++
++/**
+  * ieee80211_get_sband_iftype_data - return sband data for a given iftype
+  * @sband: the sband to search for the STA on
+  * @iftype: enum nl80211_iftype
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH openwrt-23.05] mac80211: backport some upstream EHT patches

2024-04-01 Thread Rafał Miłecki
From: Rafał Miłecki 

Those changes are needed by Wi-Fi 7 drivers.

Signed-off-by: Rafał Miłecki 
---
In master branch mac80211 package was updated from 6.1 to 6.5 to include
required EHT code. We probably don't want to do that for openwrt-23.05
as it's a rather big change.

It still would be nice to allow using Wi-Fi 7 drivers / devices.
Backporting those few subsystem patches should be enough for that and
also pretty safe.

 package/kernel/mac80211/Makefile  |   2 +-
 ...Transition-Disable-policy-during-por.patch | 189 +
 ...ort-minimal-EHT-rate-reporting-on-RX.patch | 179 
 ...1-mlme-handle-EHT-channel-puncturing.patch | 387 ++
 ...ve-puncturing-bitmap-validation-from.patch | 219 ++
 ...idate-and-configure-puncturing-bitma.patch | 169 
 ...clude-puncturing-bitmap-in-channel-s.patch | 263 
 ...mac80211-configure-puncturing-bitmap.patch | 107 +
 ...d-EHT-MU-MIMO-related-flags-in-ieee8.patch |  68 +++
 .../500-mac80211_configure_antenna_gain.patch |  35 +-
 .../780-avoid-crashing-missing-band.patch |   2 +-
 11 files changed, 1600 insertions(+), 20 deletions(-)
 create mode 100644 
package/kernel/mac80211/patches/subsys/341-v6.2-cfg80211-Update-Transition-Disable-policy-during-por.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/342-v6.3-mac80211-support-minimal-EHT-rate-reporting-on-RX.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/343-v6.3-wifi-mac80211-mlme-handle-EHT-channel-puncturing.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/344-v6.3-0001-wifi-cfg80211-move-puncturing-bitmap-validation-from.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/344-v6.3-0002-wifi-nl80211-validate-and-configure-puncturing-bitma.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/344-v6.3-0003-wifi-cfg80211-include-puncturing-bitmap-in-channel-s.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/344-v6.3-0004-wifi-mac80211-configure-puncturing-bitmap.patch
 create mode 100644 
package/kernel/mac80211/patches/subsys/345-v6.4-wifi-mac80211-add-EHT-MU-MIMO-related-flags-in-ieee8.patch

diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index 248b48c3c1..a7472ee779 100644
--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=mac80211
 
 PKG_VERSION:=6.1.24
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 # PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/
 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
 PKG_HASH:=5d39aca7e34c33cb9b3e366117b2e86841b7bdd37933679d6b1e61be6b150648
diff --git 
a/package/kernel/mac80211/patches/subsys/341-v6.2-cfg80211-Update-Transition-Disable-policy-during-por.patch
 
b/package/kernel/mac80211/patches/subsys/341-v6.2-cfg80211-Update-Transition-Disable-policy-during-por.patch
new file mode 100644
index 00..d0551c509f
--- /dev/null
+++ 
b/package/kernel/mac80211/patches/subsys/341-v6.2-cfg80211-Update-Transition-Disable-policy-during-por.patch
@@ -0,0 +1,189 @@
+From 0ff57171d6d225558c81a69439d5323e35b40549 Mon Sep 17 00:00:00 2001
+From: Vinayak Yadawad 
+Date: Wed, 7 Sep 2022 18:14:48 +0530
+Subject: [PATCH] cfg80211: Update Transition Disable policy during port
+ authorization
+
+In case of 4way handshake offload, transition disable policy
+updated by the AP during EAPOL 3/4 is not updated to the upper layer.
+This results in mismatch between transition disable policy
+between the upper layer and the driver. This patch addresses this
+issue by updating transition disable policy as part of port
+authorization indication.
+
+Signed-off-by: Vinayak Yadawad 
+Signed-off-by: Johannes Berg 
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c  |  2 +-
+ include/net/cfg80211.h   |  4 +++-
+ include/uapi/linux/nl80211.h |  3 +++
+ net/wireless/core.h  |  5 -
+ net/wireless/nl80211.c   |  8 +++-
+ net/wireless/nl80211.h   |  3 ++-
+ net/wireless/sme.c   | 12 
+ net/wireless/util.c  |  4 +++-
+ 8 files changed, 31 insertions(+), 10 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
 b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -6005,7 +6005,7 @@ done:
+   brcmf_dbg(CONN, "Report roaming result\n");
+ 
+   if (profile->use_fwsup == BRCMF_PROFILE_FWSUP_1X && profile->is_ft) {
+-  cfg80211_port_authorized(ndev, profile->bssid, GFP_KERNEL);
++  cfg80211_port_authorized(ndev, profile->bssid, NULL, 0, 
GFP_KERNEL);
+   brcmf_dbg(CONN, "Report port authorized\n");
+   }
+ 
+--- a/include/net/cfg80211.h
 b/include/ne

Re: [PATCH] base-files: sysupgrade: fix generating backup to stdout

2024-03-04 Thread Rafał Miłecki

On 4.03.2024 08:15, Rafał Miłecki wrote:

From: Rafał Miłecki 

Before recent change "tar" command was called with an "-f" argument
which accepts "-" for stdout output. Bring back support for that feature
with new code.

Fixes: e36cc530927c ("base-files: sysupgrade: use tar helper to include 
installed_packages.txt")
Fixes: https://github.com/openwrt/openwrt/issues/14773
Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 


Obsoleted by the commit 6f6406a1321b ("base-files: sysupgrade: fix streaming backup 
archives to stdout")

https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=6f6406a1321b4ead1d61abdea450d7c76bd5a927

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] base-files: sysupgrade: handle errors when generating backup

2024-03-04 Thread Rafał Miłecki
From: Rafał Miłecki 

1. Return error if any step of generating tar file fails
2. Use pipefail to avoid calling "gzip" if tar failed

Fixes: e36cc530927c ("base-files: sysupgrade: use tar helper to include 
installed_packages.txt")
Reported-by: Luiz Angelo Daros de Luca 
Cc: Luiz Angelo Daros de Luca 
Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 45 +++-
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 720f3da3fa..80e65b199a 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -237,6 +237,7 @@ include /lib/upgrade
 create_backup_archive() {
local conf_tar="$1"
local disabled
+   local err
 
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
@@ -251,31 +252,43 @@ create_backup_archive() {
v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
+   set -o pipefail
{
-   for service in /etc/init.d/*; do
-   if ! $service enabled; then
+   local ret=0
+
+   if [ $ret -eq 0 ]; then
+   for service in /etc/init.d/*; do
+   if ! $service enabled; then
disabled="$disabled$service disable\n"
-   fi
-   done
-   disabled="$disabled\nexit 0"
-   tar_print_member "/etc/uci-defaults/10_disable_services" 
"$(echo -e $disabled)"
+   fi
+   done
+   disabled="$disabled\nexit 0"
+   tar_print_member 
"/etc/uci-defaults/10_disable_services" "$(echo -e $disabled)" || ret=1
+   fi
 
# Part of archive with installed packages info
-   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
-   # Format: pkg-name{rom,overlay,unknown}
-   # rom is used for pkgs in /rom, even if updated later
-   tar_print_member "$INSTALLED_PACKAGES" "$(find 
/usr/lib/opkg/info -name "*.control" \( \
-   \( -exec test -f /rom/{} \; -exec echo {} rom 
\; \) -o \
-   \( -exec test -f /overlay/upper/{} \; -exec 
echo {} overlay \; \) -o \
-   \( -exec echo {} unknown \; \) \
-   \) | sed -e 's,.*/,,;s/\.control /\t/')"
+   if [ $ret -eq 0 ]; then
+   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
+   # Format: pkg-name{rom,overlay,unknown}
+   # rom is used for pkgs in /rom, even if updated 
later
+   tar_print_member "$INSTALLED_PACKAGES" "$(find 
/usr/lib/opkg/info -name "*.control" \( \
+   \( -exec test -f /rom/{} \; -exec echo 
{} rom \; \) -o \
+   \( -exec test -f /overlay/upper/{} \; 
-exec echo {} overlay \; \) -o \
+   \( -exec echo {} unknown \; \) \
+   \) | sed -e 's,.*/,,;s/\.control 
/\t/')" || ret=1
+   fi
fi
 
# Rest of archive with config files and ending padding
-   tar c${TAR_V} -C / -T "$CONFFILES"
+   if [ $ret -eq 0 ]; then
+   tar c${TAR_V} -C / -T "$CONFFILES" || ret=1
+   fi
+
+   [ $ret -eq 0 ]
} | gzip > "${conf_tar:-/proc/self/fd/1}"
+   err=$?
+   set +o pipefail
 
-   local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
[ -f "$conf_tar" ] && rm -f "$conf_tar"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] base-files: sysupgrade: fix generating backup to stdout

2024-03-03 Thread Rafał Miłecki
From: Rafał Miłecki 

Before recent change "tar" command was called with an "-f" argument
which accepts "-" for stdout output. Bring back support for that feature
with new code.

Fixes: e36cc530927c ("base-files: sysupgrade: use tar helper to include 
installed_packages.txt")
Fixes: https://github.com/openwrt/openwrt/issues/14773
Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 78ec455067..b1a7335bc0 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -236,12 +236,15 @@ include /lib/upgrade
 
 create_backup_archive() {
local conf_tar="$1"
+   local output_file=""
local disabled
 
+   [ "$conf_tar" != "-" ] && output_file="$conf_tar"
+
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
-   rm -f "$conf_tar"
+   [ -n "$output_file" ] && rm -f "$output_file"
return 0
}
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
@@ -272,12 +275,12 @@ create_backup_archive() {
 
# Rest of archive with config files and ending padding
tar c${TAR_V} -C / -T "$CONFFILES"
-   } | gzip > "$conf_tar"
+   } | gzip > "${output_file:-/dev/stdout}"
 
local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
-   rm -f "$conf_tar"
+   [ -n "$output_file" ] && rm -f "$output_file"
fi
 
rm -f "$CONFFILES"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V3 1/3] base-files: sysupgrade: add tar.sh with helpers for building archives

2024-02-28 Thread Rafał Miłecki
From: Jo-Philipp Wich 

This allows building uncompressed tar archives from shell scripts (and
compressing them later if needed)

Signed-off-by: Rafał Miłecki 
---
V2: Simplify dd in __tar_print_padding (I still think helper is useful)
Hardcode 0/0/ root/root for now as most likely it'll be enough
Simplify name validation (leasing slash)
Reorder some variables
V3: Fix dd in __tar_print_padding
Rename functions
Drop unused functions
Document usage

 package/base-files/files/lib/upgrade/tar.sh | 71 +
 1 file changed, 71 insertions(+)
 create mode 100644 package/base-files/files/lib/upgrade/tar.sh

diff --git a/package/base-files/files/lib/upgrade/tar.sh 
b/package/base-files/files/lib/upgrade/tar.sh
new file mode 100644
index 00..a9d1d559e6
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/tar.sh
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+# Example usage:
+#
+# {
+# tar_print_member "date.txt" "It's $(date +"%Y")"
+# tar_print_trailer
+# } > test.tar
+
+__tar_print_padding() {
+   dd if=/dev/zero bs=1 count=$1 2>/dev/null
+}
+
+tar_print_member() {
+   local name="$1"
+   local content="$2"
+   local mtime="${3:-$(date +%s)}"
+   local mode=644
+   local uid=0
+   local gid=0
+   local size=${#content}
+   local type=0
+   local link=""
+   local username="root"
+   local groupname="root"
+
+   # 100 byte of padding bytes, using 0x01 since the shell does not 
tolerate null bytes in strings
+   local 
pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1'
+
+   # validate name (strip leading slash if present)
+   name=${name#/}
+
+   # truncate string header values to their maximum length
+   name=${name:0:100}
+   link=${link:0:100}
+   username=${username:0:32}
+   groupname=${groupname:0:32}
+
+   # construct header part before checksum field
+   local header1="${name}${pad:0:$((100 - ${#name}))}"
+   header1="${header1}$(printf '%07d\1' $mode)"
+   header1="${header1}$(printf '%07o\1' $uid)"
+   header1="${header1}$(printf '%07o\1' $gid)"
+   header1="${header1}$(printf '%011o\1' $size)"
+   header1="${header1}$(printf '%011o\1' $mtime)"
+
+   # construct header part after checksum field
+   local header2="$(printf '%d' $type)"
+   header2="${header2}${link}${pad:0:$((100 - ${#link}))}"
+   header2="${header2}ustar  ${pad:0:1}"
+   header2="${header2}${username}${pad:0:$((32 - ${#username}))}"
+   header2="${header2}${groupname}${pad:0:$((32 - ${#groupname}))}"
+
+   # calculate checksum over header fields
+   local checksum=0
+   for byte in $(printf '%s%8s%s' "$header1" "" "$header2" | tr '\1' '\0' 
| hexdump -ve '1/1 "%u "'); do
+   checksum=$((checksum + byte))
+   done
+
+   # print member header, padded to 512 byte
+   printf '%s%06o\0 %s' "$header1" $checksum "$header2" | tr '\1' '\0'
+   __tar_print_padding 183
+
+   # print content data, padded to multiple of 512 byte
+   printf "%s" "$content"
+   __tar_print_padding $((512 - (size % 512)))
+}
+
+tar_print_trailer() {
+   __tar_print_padding 1024
+}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V3 3/3] base-files: sysupgrade: add uci-defaults script disabling services #2

2024-02-28 Thread Rafał Miłecki
From: Rafał Miłecki 

Disabled services should be kept disabled after sysupgrade. This can be
easily handled using a proper uci-defaults script.

Extend sysupgrade to check for disabled services, generate uci-defaults
script disabling them and include it in backup.

Cc: Christian Marangi 
Cc: Jo-Philipp Wich 
Cc: Jonas Gorski 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 9 +
 1 file changed, 9 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index a11e17615c..78ec455067 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -236,6 +236,7 @@ include /lib/upgrade
 
 create_backup_archive() {
local conf_tar="$1"
+   local disabled
 
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
@@ -250,6 +251,14 @@ create_backup_archive() {
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
{
+   for service in /etc/init.d/*; do
+   if ! $service enabled; then
+   disabled="$disabled$service disable\n"
+   fi
+   done
+   disabled="$disabled\nexit 0"
+   tar_print_member "/etc/uci-defaults/10_disable_services" 
"$(echo -e $disabled)"
+
# Part of archive with installed packages info
if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
# Format: pkg-name{rom,overlay,unknown}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V3 2/3] base-files: sysupgrade: use tar helper to include installed_packages.txt

2024-02-28 Thread Rafał Miłecki
From: Rafał Miłecki 

Replace mount + overlay with manually built tar archive that gets
prepended to the actual config files backup. This allows more
flexibility with including extra backup files. They can be included at
any paths and don't require writing to flash or mounting an overlay
which has its own limitations (mount points).

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 44 +---
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 6b3fb0666f..a11e17615c 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -237,8 +237,6 @@ include /lib/upgrade
 create_backup_archive() {
local conf_tar="$1"
 
-   local umount_etcbackup_dir=0
-
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
@@ -248,41 +246,31 @@ create_backup_archive() {
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
ask_bool 0 "Edit config file list" && vi "$CONFFILES"
 
-   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
-   echo "${INSTALLED_PACKAGES}" >> "$CONFFILES"
-   mkdir -p "$ETCBACKUP_DIR"
-   # Avoid touching filesystem on each backup
-   RAMFS="$(mktemp -d -t sysupgrade.XX)"
-   mkdir -p "$RAMFS/upper" "$RAMFS/work"
-   mount -t overlay overlay -o 
lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work 
$ETCBACKUP_DIR &&
-   umount_etcbackup_dir=1 || {
-   echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to 
avoid touching disk while saving the list of installed packages." >&2
-   ask_bool 0 "Abort" && exit
-   }
-
-   # Format: pkg-name{rom,overlay,unknown}
-   # rom is used for pkgs in /rom, even if updated later
-   find /usr/lib/opkg/info -name "*.control" \( \
-   \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
-   \( -exec test -f /overlay/upper/{} \; -exec echo {} 
overlay \; \) -o \
-   \( -exec echo {} unknown \; \) \
-   \) | sed -e 's,.*/,,;s/\.control /\t/' > 
${INSTALLED_PACKAGES}
-   fi
-
v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
-   tar c${TAR_V}zf "$conf_tar" -C / -T "$CONFFILES"
+   {
+   # Part of archive with installed packages info
+   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
+   # Format: pkg-name{rom,overlay,unknown}
+   # rom is used for pkgs in /rom, even if updated later
+   tar_print_member "$INSTALLED_PACKAGES" "$(find 
/usr/lib/opkg/info -name "*.control" \( \
+   \( -exec test -f /rom/{} \; -exec echo {} rom 
\; \) -o \
+   \( -exec test -f /overlay/upper/{} \; -exec 
echo {} overlay \; \) -o \
+   \( -exec echo {} unknown \; \) \
+   \) | sed -e 's,.*/,,;s/\.control /\t/')"
+   fi
+
+   # Rest of archive with config files and ending padding
+   tar c${TAR_V} -C / -T "$CONFFILES"
+   } | gzip > "$conf_tar"
+
local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
rm -f "$conf_tar"
fi
 
-   [ "$umount_etcbackup_dir" -eq 1 ] && {
-   umount "$ETCBACKUP_DIR"
-   rm -rf "$RAMFS"
-   }
rm -f "$CONFFILES"
 
return "$err"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V2 2/3] base-files: sysupgrade: use tar helper to include installed_packages.txt

2024-02-28 Thread Rafał Miłecki
From: Rafał Miłecki 

Replace mount + overlay with manually built tar archive that gets
prepended to the actual config files backup. This allows more
flexibility with including extra backup files. They can be included at
any paths and don't require writing to flash or mounting an overlay
which has its own limitations (mount points).

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 44 +---
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 6b3fb0666f..9d5d736aef 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -237,8 +237,6 @@ include /lib/upgrade
 create_backup_archive() {
local conf_tar="$1"
 
-   local umount_etcbackup_dir=0
-
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
@@ -248,41 +246,31 @@ create_backup_archive() {
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
ask_bool 0 "Edit config file list" && vi "$CONFFILES"
 
-   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
-   echo "${INSTALLED_PACKAGES}" >> "$CONFFILES"
-   mkdir -p "$ETCBACKUP_DIR"
-   # Avoid touching filesystem on each backup
-   RAMFS="$(mktemp -d -t sysupgrade.XX)"
-   mkdir -p "$RAMFS/upper" "$RAMFS/work"
-   mount -t overlay overlay -o 
lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work 
$ETCBACKUP_DIR &&
-   umount_etcbackup_dir=1 || {
-   echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to 
avoid touching disk while saving the list of installed packages." >&2
-   ask_bool 0 "Abort" && exit
-   }
-
-   # Format: pkg-name{rom,overlay,unknown}
-   # rom is used for pkgs in /rom, even if updated later
-   find /usr/lib/opkg/info -name "*.control" \( \
-   \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
-   \( -exec test -f /overlay/upper/{} \; -exec echo {} 
overlay \; \) -o \
-   \( -exec echo {} unknown \; \) \
-   \) | sed -e 's,.*/,,;s/\.control /\t/' > 
${INSTALLED_PACKAGES}
-   fi
-
v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
-   tar c${TAR_V}zf "$conf_tar" -C / -T "$CONFFILES"
+   {
+   # Part of archive with installed packages info
+   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
+   # Format: pkg-name{rom,overlay,unknown}
+   # rom is used for pkgs in /rom, even if updated later
+   tar_make_member_inline "$INSTALLED_PACKAGES" "$(find 
/usr/lib/opkg/info -name "*.control" \( \
+   \( -exec test -f /rom/{} \; -exec echo {} rom 
\; \) -o \
+   \( -exec test -f /overlay/upper/{} \; -exec 
echo {} overlay \; \) -o \
+   \( -exec echo {} unknown \; \) \
+   \) | sed -e 's,.*/,,;s/\.control /\t/')"
+   fi
+
+   # Rest of archive with config files and ending padding
+   tar c${TAR_V} -C / -T "$CONFFILES"
+   } | gzip > "$conf_tar"
+
local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
rm -f "$conf_tar"
fi
 
-   [ "$umount_etcbackup_dir" -eq 1 ] && {
-   umount "$ETCBACKUP_DIR"
-   rm -rf "$RAMFS"
-   }
rm -f "$CONFFILES"
 
return "$err"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V2 3/3] base-files: sysupgrade: add uci-defaults script disabling services #2

2024-02-28 Thread Rafał Miłecki
From: Rafał Miłecki 

Disabled services should be kept disabled after sysupgrade. This can be
easily handled using a proper uci-defaults script.

Extend sysupgrade to check for disabled services, generate uci-defaults
script disabling them and include it in backup.

Cc: Christian Marangi 
Cc: Jo-Philipp Wich 
Cc: Jonas Gorski 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 9 +
 1 file changed, 9 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 9d5d736aef..8c6200d7e9 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -236,6 +236,7 @@ include /lib/upgrade
 
 create_backup_archive() {
local conf_tar="$1"
+   local disabled
 
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
@@ -250,6 +251,14 @@ create_backup_archive() {
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
{
+   for service in /etc/init.d/*; do
+   if ! $service enabled; then
+   disabled="$disabled$service disable\n"
+   fi
+   done
+   disabled="$disabled\nexit 0"
+   tar_make_member_inline "/etc/uci-defaults/10_disable_services" 
"$(echo -e $disabled)"
+
# Part of archive with installed packages info
if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
# Format: pkg-name{rom,overlay,unknown}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH V2 1/3] base-files: sysupgrade: add tar.sh with helpers for building archives

2024-02-28 Thread Rafał Miłecki
From: Jo-Philipp Wich 

This allows building uncompressed tar archives from shell scripts (and
compressing them later if needed)

Signed-off-by: Rafał Miłecki 
---
V2: Simplify dd in __tar_print_padding (I still think helper is useful)
Hardcode 0/0/ root/root for now as most likely it'll be enough
Simplify name validation (leasing slash)
Reorder some variables

 package/base-files/files/lib/upgrade/tar.sh | 78 +
 1 file changed, 78 insertions(+)
 create mode 100644 package/base-files/files/lib/upgrade/tar.sh

diff --git a/package/base-files/files/lib/upgrade/tar.sh 
b/package/base-files/files/lib/upgrade/tar.sh
new file mode 100644
index 00..406d5fd71b
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/tar.sh
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+__tar_print_padding() {
+   dd if=/dev/zero bs=$1 count=1 2>/dev/null
+}
+
+__tar_make_member() {
+   local name="$1"
+   local content="$2"
+   local mtime="$3"
+   local mode=644
+   local uid=0
+   local gid=0
+   local size=${#content}
+   local type=0
+   local link=""
+   local username="root"
+   local groupname="root"
+
+   # 100 byte of padding bytes, using 0x01 since the shell does not 
tolerate null bytes in strings
+   local 
pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1'
+
+   # validate name (strip leading slash if present)
+   name=${name#/}
+
+   # truncate string header values to their maximum length
+   name=${name:0:100}
+   link=${link:0:100}
+   username=${username:0:32}
+   groupname=${groupname:0:32}
+
+   # construct header part before checksum field
+   local header1="${name}${pad:0:$((100 - ${#name}))}"
+   header1="${header1}$(printf '%07d\1' $mode)"
+   header1="${header1}$(printf '%07o\1' $uid)"
+   header1="${header1}$(printf '%07o\1' $gid)"
+   header1="${header1}$(printf '%011o\1' $size)"
+   header1="${header1}$(printf '%011o\1' $mtime)"
+
+   # construct header part after checksum field
+   local header2="$(printf '%d' $type)"
+   header2="${header2}${link}${pad:0:$((100 - ${#link}))}"
+   header2="${header2}ustar  ${pad:0:1}"
+   header2="${header2}${username}${pad:0:$((32 - ${#username}))}"
+   header2="${header2}${groupname}${pad:0:$((32 - ${#groupname}))}"
+
+   # calculate checksum over header fields
+   local checksum=0
+   for byte in $(printf '%s%8s%s' "$header1" "" "$header2" | tr '\1' '\0' 
| hexdump -ve '1/1 "%u "'); do
+   checksum=$((checksum + byte))
+   done
+
+   # print member header, padded to 512 byte
+   printf '%s%06o\0 %s' "$header1" $checksum "$header2" | tr '\1' '\0'
+   __tar_print_padding 183
+
+   # print content data, padded to multiple of 512 byte
+   printf "%s" "$content"
+   __tar_print_padding $((512 - (size % 512)))
+}
+
+tar_make_member_from_file() {
+   local name="$1"
+
+   __tar_make_member "$name" "$(cat $name)" "$(date +%s -r "$1")"
+}
+
+tar_make_member_inline() {
+   local name="$1"
+   local content="$2"
+   local mtime="${3:-$(date +%s)}"
+
+   __tar_make_member "$name" "$content" "$mtime"
+}
+
+tar_close() {
+   __tar_print_padding 1024
+}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH 1/3] base-files: sysupgrade: add tar.sh with helpers for building archives

2024-02-27 Thread Rafał Miłecki

On 26.02.2024 22:27, Paul D wrote:

diff --git a/package/base-files/files/lib/upgrade/tar.sh 
b/package/base-files/files/lib/upgrade/tar.sh
new file mode 100644
index 00..00057dd760
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/tar.sh
@@ -0,0 +1,84 @@


No shebang?


Files /lib/upgrade/*.sh are for including.



+# SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+__tar_print_padding() {
+    [ $1 -eq 0 ] || dd if=/dev/zero bs=$1 count=1 2>/dev/null
+}
+
+__tar_make_member() {
+    local name="$1"
+    local content="$2"
+    local username="$3"
+    local groupname="$4"
+    local mtime="$5"
+    local mode=644
+    local uid=0
+    local gid=0
+    local size=${#content}
+    local type=0
+    local link=""
+


recommend that they're ordered here same as struct order:

struct posix_header
{  /* byte offset */
   char name[100];   /*   0 */
   char mode[8]; /* 100 */
   char uid[8];  /* 108 */
   char gid[8];  /* 116 */
   char size[12];    /* 124 */
   char mtime[12];   /* 136 */
   char chksum[8];   /* 148 */
   char typeflag;    /* 156 */
   char linkname[100];   /* 157 */
   char magic[6];    /* 257 */
   char version[2];  /* 263 */
   char uname[32];   /* 265 */
   char gname[32];   /* 297 */
   char devmajor[8]; /* 329 */
   char devminor[8]; /* 337 */
   char prefix[155]; /* 345 */
     /* 500 */
};


I'm not sure about it. In the first place I want code to be easy to
understand and maintain. Using some non-natural order (like messing with
order of argument variables and local variables) will be confusing.



+    local 
pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1'
+


maybe try:

local pad=$(printf '\1%.0s' $(seq 100))


They produce the same result I believe:

# echo 
$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1'
 | md5sum
59c89925a4ef5bee948db1ec5dc9a4c4  -

# echo $(printf '\1%.0s' $(seq 100)) | md5sum
59c89925a4ef5bee948db1ec5dc9a4c4  -

The first is longer however it avoids two subshell executions. I don't
think there's a single winner here.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: OpenWrt One - celebrating 20 years of OpenWrt

2024-02-26 Thread Rafał Miłecki

Hi John!

On 9.01.2024 11:49, John Crispin wrote:

In 2024 the OpenWrt project turns 20 years! Let's celebrate this anniversary by 
launching our own first and fully upstream supported hardware design.

If the community likes the idea outlined below in greater details, we would 
like to start a vote.


Is there any update / schedule you could share?

I'm really looking forward to this device.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/3] base-files: sysupgrade: add tar.sh with helpers for building archives

2024-02-26 Thread Rafał Miłecki
From: Jo-Philipp Wich 

This allows building uncompressed tar archives from shell scripts (and
compressing them later if needed)

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/lib/upgrade/tar.sh | 84 +
 1 file changed, 84 insertions(+)
 create mode 100644 package/base-files/files/lib/upgrade/tar.sh

diff --git a/package/base-files/files/lib/upgrade/tar.sh 
b/package/base-files/files/lib/upgrade/tar.sh
new file mode 100644
index 00..00057dd760
--- /dev/null
+++ b/package/base-files/files/lib/upgrade/tar.sh
@@ -0,0 +1,84 @@
+# SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+__tar_print_padding() {
+   [ $1 -eq 0 ] || dd if=/dev/zero bs=$1 count=1 2>/dev/null
+}
+
+__tar_make_member() {
+   local name="$1"
+   local content="$2"
+   local username="$3"
+   local groupname="$4"
+   local mtime="$5"
+   local mode=644
+   local uid=0
+   local gid=0
+   local size=${#content}
+   local type=0
+   local link=""
+
+   # 100 byte of padding bytes, using 0x01 since the shell does not tolate 
null bytes in strings
+   local 
pad=$'\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1'
+
+   # validate name
+   if [ "${name:0:1}" = "/" ]; then
+   name="${name:1}"
+   fi
+
+   # truncate string header values to their maximum length
+   name=${name:0:100}
+   link=${link:0:100}
+   username=${username:0:32}
+   groupname=${groupname:0:32}
+
+   # construct header part before checksum field
+   local header1="${name}${pad:0:$((100 - ${#name}))}"
+   header1="${header1}$(printf '%07d\1' $mode)"
+   header1="${header1}$(printf '%07o\1' $uid)"
+   header1="${header1}$(printf '%07o\1' $gid)"
+   header1="${header1}$(printf '%011o\1' $size)"
+   header1="${header1}$(printf '%011o\1' $mtime)"
+
+   # construct header part after checksum field
+   local header2="$(printf '%d' $type)"
+   header2="${header2}${link}${pad:0:$((100 - ${#link}))}"
+   header2="${header2}ustar  ${pad:0:1}"
+   header2="${header2}${username}${pad:0:$((32 - ${#username}))}"
+   header2="${header2}${groupname}${pad:0:$((32 - ${#groupname}))}"
+
+   # calculate checksum over header fields
+   local checksum=0
+   for byte in $(printf '%s%8s%s' "$header1" "" "$header2" | tr '\1' '\0' 
| hexdump -ve '1/1 "%u "'); do
+   checksum=$((checksum + byte))
+   done
+
+   # print member header, padded to 512 byte
+   printf '%s%06o\0 %s' "$header1" $checksum "$header2" | tr '\1' '\0'
+   __tar_print_padding 183
+
+   # print content data, padded to multiple of 512 byte
+   printf "%s" "$content"
+   __tar_print_padding $((512 - (size % 512)))
+}
+
+tar_make_member_from_file() {
+   local name="$1"
+   local username="$(ls -l "$1" | tr -s ' ' | cut -d ' ' -f 3)"
+   local groupname="$(ls -l "$1" | tr -s ' ' | cut -d ' ' -f 4)"
+
+   __tar_make_member "$name" "$(cat $name)" "$username" "$groupname" 
"$(date +%s -r "$1")"
+}
+
+tar_make_member_inline() {
+   local name="$1"
+   local content="$2"
+   local username="${3:-root}"
+   local groupname="${4:-root}"
+   local mtime="${5:-$(date +%s)}"
+
+   __tar_make_member "$name" "$content" "$username" "$groupname" "$mtime"
+}
+
+tar_close() {
+   __tar_print_padding 1024
+}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 3/3] base-files: sysupgrade: add uci-defaults script disabling services #2

2024-02-26 Thread Rafał Miłecki
From: Rafał Miłecki 

Disabled services should be kept disabled after sysupgrade. This can be
easily handled using a proper uci-defaults script.

Extend sysupgrade to check for disabled services, generate uci-defaults
script disabling them and include it in backup.

Cc: Christian Marangi 
Cc: Jo-Philipp Wich 
Cc: Jonas Gorski 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 9 +
 1 file changed, 9 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 9d5d736aef..8c6200d7e9 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -236,6 +236,7 @@ include /lib/upgrade
 
 create_backup_archive() {
local conf_tar="$1"
+   local disabled
 
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
@@ -250,6 +251,14 @@ create_backup_archive() {
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
{
+   for service in /etc/init.d/*; do
+   if ! $service enabled; then
+   disabled="$disabled$service disable\n"
+   fi
+   done
+   disabled="$disabled\nexit 0"
+   tar_make_member_inline "/etc/uci-defaults/10_disable_services" 
"$(echo -e $disabled)"
+
# Part of archive with installed packages info
if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
# Format: pkg-name{rom,overlay,unknown}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/3] base-files: sysupgrade: use tar helper to include installed_packages.txt

2024-02-26 Thread Rafał Miłecki
From: Rafał Miłecki 

Replace mount + overlay with manually built tar archive that gets
prepended to the actual config files backup. This allows more
flexibility with including extra backup files. They can be included at
any paths and don't require writing to flash or mounting an overlay
which has its own limitations (mount points).

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 44 +---
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 6b3fb0666f..9d5d736aef 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -237,8 +237,6 @@ include /lib/upgrade
 create_backup_archive() {
local conf_tar="$1"
 
-   local umount_etcbackup_dir=0
-
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
@@ -248,41 +246,31 @@ create_backup_archive() {
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
ask_bool 0 "Edit config file list" && vi "$CONFFILES"
 
-   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
-   echo "${INSTALLED_PACKAGES}" >> "$CONFFILES"
-   mkdir -p "$ETCBACKUP_DIR"
-   # Avoid touching filesystem on each backup
-   RAMFS="$(mktemp -d -t sysupgrade.XX)"
-   mkdir -p "$RAMFS/upper" "$RAMFS/work"
-   mount -t overlay overlay -o 
lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work 
$ETCBACKUP_DIR &&
-   umount_etcbackup_dir=1 || {
-   echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to 
avoid touching disk while saving the list of installed packages." >&2
-   ask_bool 0 "Abort" && exit
-   }
-
-   # Format: pkg-name{rom,overlay,unknown}
-   # rom is used for pkgs in /rom, even if updated later
-   find /usr/lib/opkg/info -name "*.control" \( \
-   \( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
-   \( -exec test -f /overlay/upper/{} \; -exec echo {} 
overlay \; \) -o \
-   \( -exec echo {} unknown \; \) \
-   \) | sed -e 's,.*/,,;s/\.control /\t/' > 
${INSTALLED_PACKAGES}
-   fi
-
v "Saving config files..."
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
sed -i -e 's,^/,,' "$CONFFILES"
-   tar c${TAR_V}zf "$conf_tar" -C / -T "$CONFFILES"
+   {
+   # Part of archive with installed packages info
+   if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
+   # Format: pkg-name{rom,overlay,unknown}
+   # rom is used for pkgs in /rom, even if updated later
+   tar_make_member_inline "$INSTALLED_PACKAGES" "$(find 
/usr/lib/opkg/info -name "*.control" \( \
+   \( -exec test -f /rom/{} \; -exec echo {} rom 
\; \) -o \
+   \( -exec test -f /overlay/upper/{} \; -exec 
echo {} overlay \; \) -o \
+   \( -exec echo {} unknown \; \) \
+   \) | sed -e 's,.*/,,;s/\.control /\t/')"
+   fi
+
+   # Rest of archive with config files and ending padding
+   tar c${TAR_V} -C / -T "$CONFFILES"
+   } | gzip > "$conf_tar"
+
local err=$?
if [ "$err" -ne 0 ]; then
echo "Failed to create the configuration backup."
rm -f "$conf_tar"
fi
 
-   [ "$umount_etcbackup_dir" -eq 1 ] && {
-   umount "$ETCBACKUP_DIR"
-   rm -rf "$RAMFS"
-   }
rm -f "$CONFFILES"
 
return "$err"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils 4/4] pc1crypt: make decrypt/encrypt functions take void * as argument

2024-02-22 Thread Rafał Miłecki
From: Rafał Miłecki 

Make them more generic regarding accepted data buffers.

This fixes:

src/pc1crypt.c: In function ‘main’:
src/pc1crypt.c:322:26: warning: pointer targets in passing argument 2 of 
‘pc1_decrypt_buf’ differ in signedness [-Wpointer-sign]
pc1_decrypt_buf(, buf, datalen);
  ^~~
src/pc1crypt.c:324:26: warning: pointer targets in passing argument 2 of 
‘pc1_encrypt_buf’ differ in signedness [-Wpointer-sign]
pc1_encrypt_buf(, buf, datalen);
  ^~~

Signed-off-by: Rafał Miłecki 
---
 src/pc1crypt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/pc1crypt.c b/src/pc1crypt.c
index be1038b..458c234 100644
--- a/src/pc1crypt.c
+++ b/src/pc1crypt.c
@@ -167,18 +167,18 @@ static void pc1_init(struct pc1_ctx *pc1)
strcpy(pc1->cle, "Remsaalps!123456");
 }
 
-static void pc1_decrypt_buf(struct pc1_ctx *pc1, unsigned char *buf,
-   unsigned len)
+static void pc1_decrypt_buf(struct pc1_ctx *pc1, void *data, unsigned len)
 {
+   unsigned char *buf = data;
unsigned i;
 
for (i = 0; i < len; i++)
buf[i] = pc1_decrypt(pc1, buf[i]);
 }
 
-static void pc1_encrypt_buf(struct pc1_ctx *pc1, unsigned char *buf,
-   unsigned len)
+static void pc1_encrypt_buf(struct pc1_ctx *pc1, void *data, unsigned len)
 {
+   unsigned char *buf = data;
unsigned i;
 
for (i = 0; i < len; i++)
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils 3/4] uimage_sgehdr: drop unused "ltmp" variable

2024-02-22 Thread Rafał Miłecki
From: Rafał Miłecki 

This fixes:

src/uimage_sgehdr.c: In function ‘main’:
src/uimage_sgehdr.c:76:6: warning: unused variable ‘ltmp’ [-Wunused-variable]
  int ltmp;
  ^~~~

Signed-off-by: Rafał Miłecki 
---
 src/uimage_sgehdr.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/uimage_sgehdr.c b/src/uimage_sgehdr.c
index 6d62c04..c15243e 100644
--- a/src/uimage_sgehdr.c
+++ b/src/uimage_sgehdr.c
@@ -73,7 +73,6 @@ int main(int argc, char *argv[])
char *hversion = NULL;
char *sversion = NULL;
int padsz = IH_PAD_BYTES;
-   int ltmp;
 
while ((opt = getopt(argc, argv, "i:o:m:h:s:")) != -1) {
switch (opt) {
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils 1/4] srec2bin: drop unused "dum" variable

2024-02-22 Thread Rafał Miłecki
From: Rafał Miłecki 

This fixes:
src/srec2bin.c: In function ‘checksum’:
src/srec2bin.c:297:7: warning: variable ‘dum’ set but not used 
[-Wunused-but-set-variable]
   int dum;
   ^~~

Signed-off-by: Rafał Miłecki 
---
 src/srec2bin.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/srec2bin.c b/src/srec2bin.c
index ad4222d..9a88909 100644
--- a/src/srec2bin.c
+++ b/src/srec2bin.c
@@ -294,7 +294,6 @@ int checksum(char *cp,int count)
 {
   char *scp;
   int cksum;
-  int dum;
 
   scp=cp;
   while(*scp)
@@ -309,8 +308,6 @@ int checksum(char *cp,int count)
   while(count)
   {
 cksum += gh(scp,2);
-if (count == 2)
-dum = ~cksum;
 scp += 2;
 count--;
   }
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils 2/4] uimage_sgehdr: use "char" type for header struct strings

2024-02-22 Thread Rafał Miłecki
From: Rafał Miłecki 

This fixes:

src/uimage_sgehdr.c: In function ‘main’:
src/uimage_sgehdr.c:152:10: warning: pointer targets in passing argument 1 of 
‘strncpy’ differ in signedness [-Wpointer-sign]
  strncpy(imgh->sgeih_p, model, sizeof(imgh->sgeih_p));
  ^~~~
src/uimage_sgehdr.c:153:10: warning: pointer targets in passing argument 1 of 
‘strncpy’ differ in signedness [-Wpointer-sign]
  strncpy(imgh->sgeih_sv, sversion, sizeof(imgh->sgeih_sv));
  ^~~~
src/uimage_sgehdr.c:154:10: warning: pointer targets in passing argument 1 of 
‘strncpy’ differ in signedness [-Wpointer-sign]
  strncpy(imgh->sgeih_hv, hversion, sizeof(imgh->sgeih_hv));
  ^~~~

Signed-off-by: Rafał Miłecki 
---
 src/uimage_sgehdr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/uimage_sgehdr.c b/src/uimage_sgehdr.c
index 28143a8..6d62c04 100644
--- a/src/uimage_sgehdr.c
+++ b/src/uimage_sgehdr.c
@@ -40,9 +40,9 @@ struct image_header {
uint8_t ih_type;/* Image Type   */
uint8_t ih_comp;/* Compression Type */
uint8_t ih_name[IH_NMLEN];  /* Image Name   */
-   uint8_t sgeih_p[SGE_PRODUCTLEN];/* sge_Product  
*/
-   uint8_t sgeih_sv[SGE_VERSIONLEN];   /* sge Software Version 
*/
-   uint8_t sgeih_hv[SGE_VERSIONLEN];   /* sge Hardware Version 
*/
+   charsgeih_p[SGE_PRODUCTLEN];/* sge_Product  
*/
+   charsgeih_sv[SGE_VERSIONLEN];   /* sge Software Version 
*/
+   charsgeih_hv[SGE_VERSIONLEN];   /* sge Hardware Version 
*/
 };
 
 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: sysupgrade is broken

2024-02-21 Thread Rafał Miłecki

On 21.02.2024 20:52, e9hack wrote:

root@WLAN-DSL9:~# sysupgrade -b /var/config-backup.tar.gz
Wed Feb 21 20:48:30 CET 2024 upgrade: Saving config files...
tar: var/dhcp.leases: No such file or directory
tar: var/lib/logrotate.status: No such file or directory
tar: var/log/logrotate.log: No such file or directory
tar: error exit delayed from previous errors
Failed to create the configuration backup.


I can reproduce that. The problem is caused by:
mount -t overlay overlay -o lowerdir=/,upperdir="$tmp/upper",workdir="$tmp/work" 
"$dir"

Apparently lowerdir=/ doesn't work as I expected. In $dir I can see
squashfs + overlay changes but I don't see mounts.

root@OpenWrt:/# ls -l $dir/tmp/
root@OpenWrt:/# ls -l $dir/rom/
-rw-r--r--1 root root   116 Feb 19 12:53 note
root@OpenWrt:/# ls -l $dir/dev/
crw---1 root root5,   1 Feb 19 12:53 console

I'm not sure if there is an easy way to solve that. Anyone?

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[WIP RFC luci] luci-mod-network: provide control over /etc/init.d/dnsmasq service

2024-02-16 Thread Rafał Miłecki
From: Rafał Miłecki 

It's easier to control service from the same page that allows
configuring it.

Cc: Jo-Philipp Wich 
Signed-off-by: Rafał Miłecki 
---
Over years we got a lot of redundant "enabled" (or "disabled") UCI
config options where it'd be perfecly enough to use init.d script for
controlling it.

There are probably two reasons for that:
1. sysupgrade not preserving disabled services state
2. UI being more friendly by allowing disabling on configuration page

The first issue is being handled as sysupgrade improvement.
This change show how we could make UI more friendly for services
management and hopefully avoid redundant "enabled" UCI config options.

 .../resources/view/network/dhcp.js| 47 ++-
 1 file changed, 45 insertions(+), 2 deletions(-)

diff --git 
a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js 
b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
index 7b0ae3c1f9..8b6a849915 100644
--- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
+++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js
@@ -9,7 +9,7 @@
 'require validation';
 'require tools.widgets as widgets';
 
-var callHostHints, callDUIDHints, callDHCPLeases, CBILeaseStatus, 
CBILease6Status;
+var callHostHints, callDUIDHints, callDHCPLeases, callRcList, 
CBIServiceEnabled, CBIServiceRunning, CBILeaseStatus, CBILease6Status;
 
 callHostHints = rpc.declare({
object: 'luci-rpc',
@@ -29,6 +29,37 @@ callDHCPLeases = rpc.declare({
expect: { '': {} }
 });
 
+callRcList = rpc.declare({
+   object: 'rc',
+   method: 'list',
+   params: ['name'],
+   expect: { '': {} }
+});
+
+CBIServiceEnabled = form.DummyValue.extend({
+   renderWidget: function(section_id, option_id, cfgvalue) {
+   return E([], [
+   E('span', {}, cfgvalue ? _('Enabled') : _('Disabled')),
+   ' ',
+   E('button', {
+   'class': 'btn'
+   }, [ cfgvalue ? _('Disable') : _('Enable') ])
+   ]);
+   },
+});
+
+CBIServiceRunning = form.DummyValue.extend({
+   renderWidget: function(section_id, option_id, cfgvalue) {
+   return E([], [
+   E('span', {}, cfgvalue ? _('Started') : _('Stopped')),
+   ' ',
+   E('button', {
+   'class': 'btn'
+   }, [ cfgvalue ? _('Stop') : _('Start') ])
+   ]);
+   },
+});
+
 CBILeaseStatus = form.DummyValue.extend({
renderWidget: function(section_id, option_id, cfgvalue) {
return E([
@@ -277,7 +308,8 @@ return view.extend({
callHostHints(),
callDUIDHints(),
getDHCPPools(),
-   network.getNetworks()
+   network.getNetworks(),
+   callRcList('dnsmasq')
]);
},
 
@@ -287,6 +319,7 @@ return view.extend({
duids = hosts_duids_pools[1],
pools = hosts_duids_pools[2],
networks = hosts_duids_pools[3],
+   service = hosts_duids_pools[4],
m, s, o, ss, so;
 
let noi18nstrings = {
@@ -315,6 +348,16 @@ return view.extend({
m = new form.Map('dhcp', _('DHCP and DNS'),
_('Dnsmasq is a lightweight DHCP server and DNS forwarder.'));
 
+   s = m.section(form.TypedSection);
+   s.anonymous = true;
+   s.cfgsections = function() { return [ '_status' ] };
+
+   o = s.option(CBIServiceEnabled, '_enabled', _('Autostart'));
+   o.cfgvalue = function() { return service.dnsmasq.enabled; };
+
+   o = s.option(CBIServiceRunning, '_running', _('Current 
status'));
+   o.cfgvalue = function() { return service.dnsmasq.running; };
+
s = m.section(form.TypedSection, 'dnsmasq');
s.anonymous = false;
s.addremove = true;
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] base-files: sysupgrade: include uci-defaults script disabling services

2024-02-15 Thread Rafał Miłecki

On 15.02.2024 18:46, Paul D wrote:

On 2024-02-15 15:42, Rafał Miłecki wrote:

On 14.02.2024 21:50, Paul D wrote:

Would services not do better to be tracked within uci and its config files in 
/etc/config?


Well, it's a part of a mess we have in our init/config code. It was only
last week that Jo was discussing it with Ansuel. In short we have:
1. Packages with no UCI config option for enabling/disabling
2. Packages with "enable"
3. Packages with "enabled"
4. Packages with "disable"
5. Packages with "disabled"

I'm pretty sure most users are used to enabling/disabling services
using UCI config option but not all of them have such possibility. That
is the case my change is meant to deal with.

An alternative would be to make sure every package uses "enabled" (or
"disabled") UCI option. Should we do that?



Is 'on' or 'off' in the config perhaps simpler? I think it avoids the 
linguistic differences of past participle vs present simple. (Sometimes this 
distinction is important to have.)

Otherwise 'en/disabled' is a good paradigm to encourage in configs.


Do you mean "on" and "off" as option values? How would you call such option? "enabled"? 
:P Something like "status" would be misleading again.

Or if you mean "on" and "off" as option names then what value should we assign?
uci set foo.config.on=1
?

No, I don't think "on" / "off" is a good option at all.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] base-files: sysupgrade: include uci-defaults script disabling services

2024-02-15 Thread Rafał Miłecki

On 14.02.2024 21:50, Paul D wrote:

Would services not do better to be tracked within uci and its config files in 
/etc/config?


Well, it's a part of a mess we have in our init/config code. It was only
last week that Jo was discussing it with Ansuel. In short we have:
1. Packages with no UCI config option for enabling/disabling
2. Packages with "enable"
3. Packages with "enabled"
4. Packages with "disable"
5. Packages with "disabled"

I'm pretty sure most users are used to enabling/disabling services
using UCI config option but not all of them have such possibility. That
is the case my change is meant to deal with.

An alternative would be to make sure every package uses "enabled" (or
"disabled") UCI option. Should we do that?



Or do changes to those files there risk triggering other procd actions to the 
services they dictate?


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] base-files: sysupgrade: include uci-defaults script disabling services

2024-02-14 Thread Rafał Miłecki
From: Rafał Miłecki 

Disabled services should be kept disabled after sysupgrade. This can be
easily handled using a proper uci-defaults script.

Extend sysupgrade to check for disabled services, generate uci-defaults
script disabling them and include it in backup.

Cc: Christian Marangi 
Cc: Jo-Philipp Wich 
Cc: Jonas Gorski 
Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 1e09f65e07..b1ada062ed 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -273,6 +273,16 @@ create_backup_archive() {
\) | sed -e 's,.*/,,;s/\.control /\t/' > 
"$dir/${INSTALLED_PACKAGES}"
fi
 
+   mkdir -p $dir/etc/uci-defaults/
+   touch $dir/etc/uci-defaults/10_disable_services
+   for service in /etc/init.d/*; do
+   if ! $service enabled; then
+   echo "$service disable" >> 
$dir/etc/uci-defaults/10_disable_services
+   fi
+   done
+   echo "exit 0" >> $dir/etc/uci-defaults/10_disable_services
+   echo "/etc/uci-defaults/10_disable_services" >> "$CONFFILES"
+
v "Saving config files..."
sed -i 's/^\///' "$CONFFILES" # Drop leading slashes
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v2] scripts: create kernel configuration upgrade script

2024-02-14 Thread Rafał Miłecki

On 7.02.2024 02:16, Elliott Mitchell wrote:

diff --git a/scripts/kernel_upgrade.pl b/scripts/kernel_upgrade.pl
new file mode 100755
index 00..b9fe5882a3
--- /dev/null
+++ b/scripts/kernel_upgrade.pl
@@ -0,0 +1,261 @@
+#!/usr/bin/env perl
+#
+# Copyright (C) 2024 Elliott Mitchell  #
+#  #
+# This is free software, licensed under the GNU General Public License #
+# v3.  See /LICENSE for more information.  #
+#


OpenWrt is GPL 2.0 licensed. This this is GPL 3.0 only.

It seems to be independent script (right now) but:
1. What if one day we make it share some common code?
2. What about using it to produce GPL 2.0 code?

This may be more or less obvious to some of us but should we have a
lawyer opinion to be sure?

Personally I'm against such mixing licenses in our tools (script).

Also: please use SPDX header to simplify licensing info.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH RFC] base-files: sysupgrade: always setup overlay when creating backup

2024-02-13 Thread Rafał Miłecki
From: Rafał Miłecki 

Setting overlay while creating backup allows including extra files in
archive without actually writing them to flash. Right now this feature
is limited to /etc/backup/ directory and is used only for including
installed_packages.txt.

Extend this solution to make it more generic:
1. Always mount overlay while creating backup
2. Overlay whole / to don't limit it to /etc/backup/

This allows including any additional files in backups and adding more
sysupgrade features.

Cc: Luiz Angelo Daros de Luca 
Cc: Christian Marangi 
Cc: Jo-Philipp Wich 
Cc: Jonas Gorski 
Signed-off-by: Rafał Miłecki 
---
This will allow me to include /etc/uci-defaults/ scripts in backups so
we can e.g. have script disabling previously disabled services.

 package/base-files/files/sbin/sysupgrade | 37 ++--
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 1fcd44da2a..1e09f65e07 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -237,7 +237,8 @@ include /lib/upgrade
 create_backup_archive() {
local conf_tar="$1"
 
-   local umount_etcbackup_dir=0
+   local overlay
+   local dir
 
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
@@ -248,17 +249,20 @@ create_backup_archive() {
run_hooks "$CONFFILES" $sysupgrade_init_conffiles
ask_bool 0 "Edit config file list" && vi "$CONFFILES"
 
+   # Mount root directory with temporary overlay on top of it.
+   # This allows including extra (temporary) files in backup archive
+   # without messing actual rootfs.
+   overlay="$(mktemp -d -t overlay.XX)"
+   mkdir -p "$overlay/upper" "$overlay/work"
+   dir="$(mktemp -d -t backup.XX)"
+   if ! mount -t overlay overlay -o 
lowerdir=/,upperdir="$overlay/upper",workdir="$overlay/work" "$dir"; then
+   echo "Cannot mount backup overlay to $dir." >&2
+   ask_bool 0 "Abort" && exit
+   fi
+
if [ "$SAVE_INSTALLED_PKGS" -eq 1 ]; then
echo "${INSTALLED_PACKAGES}" >> "$CONFFILES"
-   mkdir -p "$ETCBACKUP_DIR"
-   # Avoid touching filesystem on each backup
-   RAMFS="$(mktemp -d -t sysupgrade.XX)"
-   mkdir -p "$RAMFS/upper" "$RAMFS/work"
-   mount -t overlay overlay -o 
lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work 
$ETCBACKUP_DIR &&
-   umount_etcbackup_dir=1 || {
-   echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to 
avoid touching disk while saving the list of installed packages." >&2
-   ask_bool 0 "Abort" && exit
-   }
+   mkdir -p "$dir/$ETCBACKUP_DIR"
 
# Format: pkg-name{rom,overlay,unkown}
# rom is used for pkgs in /rom, even if updated later
@@ -266,22 +270,23 @@ create_backup_archive() {
\( -exec test -f /rom/{} \; -exec echo {} rom \; \) -o \
\( -exec test -f /overlay/upper/{} \; -exec echo {} 
overlay \; \) -o \
\( -exec echo {} unknown \; \) \
-   \) | sed -e 's,.*/,,;s/\.control /\t/' > 
${INSTALLED_PACKAGES}
+   \) | sed -e 's,.*/,,;s/\.control /\t/' > 
"$dir/${INSTALLED_PACKAGES}"
fi
 
v "Saving config files..."
+   sed -i 's/^\///' "$CONFFILES" # Drop leading slashes
[ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
-   tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null
+   tar c${TAR_V}zf "$conf_tar" -C "${dir:-/}" -T "$CONFFILES"
if [ "$?" -ne 0 ]; then
echo "Failed to create the configuration backup."
rm -f "$conf_tar"
exit 1
fi
 
-   [ "$umount_etcbackup_dir" -eq 1 ] && {
-   umount "$ETCBACKUP_DIR"
-   rm -rf "$RAMFS"
-   }
+   umount "$dir"
+   rm -rf "$dir"
+   rm -rf "$overlay"
+
rm -f "$CONFFILES"
 }
 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] mediatek: filogic: move mt7981 on-SoC blocks to "soc" node in DT

2024-02-13 Thread Rafał Miłecki
From: Rafał Miłecki 

It's a standard way of grouping on-SoC hardware blocks and this matches
upstream DTS.

Signed-off-by: Rafał Miłecki 
---
 .../arch/arm64/boot/dts/mediatek/mt7981.dtsi  | 1245 +
 .../arch/arm64/boot/dts/mediatek/mt7981.dtsi  | 1245 +
 2 files changed, 1252 insertions(+), 1238 deletions(-)

diff --git 
a/target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7981.dtsi 
b/target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7981.dtsi
index cb161df81e..35946cbefe 100644
--- a/target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7981.dtsi
+++ b/target/linux/mediatek/files-5.15/arch/arm64/boot/dts/mediatek/mt7981.dtsi
@@ -41,16 +41,632 @@
};
};
 
-   pwm: pwm@10048000 {
-   compatible = "mediatek,mt7981-pwm";
-   reg = <0 0x10048000 0 0x1000>;
-   #pwm-cells = <2>;
-   clocks = < CLK_INFRA_PWM_STA>,
-< CLK_INFRA_PWM_HCK>,
-< CLK_INFRA_PWM1_CK>,
-< CLK_INFRA_PWM2_CK>,
-< CLK_INFRA_PWM3_CK>;
-   clock-names = "top", "main", "pwm1", "pwm2", "pwm3";
+   soc {
+   compatible = "simple-bus";
+   ranges;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   pwm: pwm@10048000 {
+   compatible = "mediatek,mt7981-pwm";
+   reg = <0 0x10048000 0 0x1000>;
+   #pwm-cells = <2>;
+   clocks = < CLK_INFRA_PWM_STA>,
+< CLK_INFRA_PWM_HCK>,
+< CLK_INFRA_PWM1_CK>,
+< CLK_INFRA_PWM2_CK>,
+< CLK_INFRA_PWM3_CK>;
+   clock-names = "top", "main", "pwm1", "pwm2", "pwm3";
+   };
+
+   thermal: thermal@1100c800 {
+   #thermal-sensor-cells = <1>;
+   compatible = "mediatek,mt7981-thermal", 
"mediatek,mt7986-thermal";
+   reg = <0 0x1100c800 0 0x800>;
+   interrupts = ;
+   clocks = < CLK_INFRA_THERM_CK>,
+< CLK_INFRA_ADC_26M_CK>;
+   clock-names = "therm", "auxadc";
+   mediatek,auxadc = <>;
+   mediatek,apmixedsys = <>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
+   };
+
+   auxadc: adc@1100d000 {
+   compatible = "mediatek,mt7981-auxadc",
+"mediatek,mt7986-auxadc",
+"mediatek,mt7622-auxadc";
+   reg = <0 0x1100d000 0 0x1000>;
+   clocks = < CLK_INFRA_ADC_26M_CK>,
+< CLK_INFRA_ADC_FRC_CK>;
+   clock-names = "main", "32k";
+   #io-channel-cells = <1>;
+   };
+
+   wdma: wdma@15104800 {
+   compatible = "mediatek,wed-wdma";
+   reg = <0 0x15104800 0 0x400>,
+ <0 0x15104c00 0 0x400>;
+   };
+
+   ap2woccif: ap2woccif@151a5000 {
+   compatible = "mediatek,ap2woccif";
+   reg = <0 0x151a5000 0 0x1000>,
+ <0 0x151ad000 0 0x1000>;
+   interrupt-parent = <>;
+   interrupts = ,
+;
+   };
+
+   infracfg: infracfg@10001000 {
+   compatible = "mediatek,mt7981-infracfg", "syscon";
+   reg = <0 0x10001000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   topckgen: topckgen@1001B000 {
+   compatible = "mediatek,mt7981-topckgen", "syscon";
+   reg = <0 0x1001B000 0 0x1000>;
+   #clock-cells = <1>;
+   };
+
+   apmixedsys: apmixedsys@1001E000 {
+   compatible = "mediatek,mt7981-apmixedsys", 
"mediatek,mt7986-apmixedsys", "syscon";
+   reg = <0 0x1001E000 0 0x100

[PATCH 4/5] base-files: sysupgrade: s/do_save_conffiles/create_backup_archive/

2024-02-12 Thread Rafał Miłecki
From: Rafał Miłecki 

Rename function to more accurate and self-explanatory name:
1. Use "archive" in name as this functions creates tar archive
2. Avoid "conffiles" as this function may archive more than that

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index f5a4441dc9..e7de1f3446 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -234,7 +234,7 @@ fi
 
 include /lib/upgrade
 
-do_save_conffiles() {
+create_backup_archive() {
local conf_tar="$1"
 
local umount_etcbackup_dir=0
@@ -294,7 +294,7 @@ if [ $CONF_BACKUP_LIST -eq 1 ]; then
 fi
 
 if [ -n "$CONF_BACKUP" ]; then
-   do_save_conffiles "$CONF_BACKUP"
+   create_backup_archive "$CONF_BACKUP"
exit $?
 fi
 
@@ -364,7 +364,7 @@ if [ -n "$CONF_IMAGE" ]; then
get_image "$CONF_IMAGE" "cat" > "$CONF_TAR"
export SAVE_CONFIG=1
 elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then
-   [ $TEST -eq 1 ] || do_save_conffiles "$CONF_TAR"
+   [ $TEST -eq 1 ] || create_backup_archive "$CONF_TAR"
export SAVE_CONFIG=1
 else
[ $TEST -eq 1 ] || rm -f "$CONF_TAR"
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/5] base-files: sysupgrade: replace UMOUNT_ETCBACKUP_DIR with a local variable

2024-02-12 Thread Rafał Miłecki
From: Rafał Miłecki 

It was used inside do_save_conffiles() only.

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 9315091302..afcd868bae 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -24,7 +24,6 @@ export NEED_IMAGE=
 export HELP=0
 export FORCE=0
 export TEST=0
-export UMOUNT_ETCBACKUP_DIR=0
 
 # parse options
 while [ -n "$1" ]; do
@@ -225,6 +224,8 @@ include /lib/upgrade
 do_save_conffiles() {
local conf_tar="$1"
 
+   local umount_etcbackup_dir=0
+
[ "$(rootfs_type)" = "tmpfs" ] && {
echo "Cannot save config while running from ramdisk." >&2
ask_bool 0 "Abort" && exit
@@ -241,7 +242,7 @@ do_save_conffiles() {
RAMFS="$(mktemp -d -t sysupgrade.XX)"
mkdir -p "$RAMFS/upper" "$RAMFS/work"
mount -t overlay overlay -o 
lowerdir=$ETCBACKUP_DIR,upperdir=$RAMFS/upper,workdir=$RAMFS/work 
$ETCBACKUP_DIR &&
-   UMOUNT_ETCBACKUP_DIR=1 || {
+   umount_etcbackup_dir=1 || {
echo "Cannot mount '$ETCBACKUP_DIR' as tmpfs to 
avoid touching disk while saving the list of installed packages." >&2
ask_bool 0 "Abort" && exit
}
@@ -264,7 +265,7 @@ do_save_conffiles() {
exit 1
fi
 
-   [ "$UMOUNT_ETCBACKUP_DIR" -eq 1 ] && {
+   [ "$umount_etcbackup_dir" -eq 1 ] && {
umount "$ETCBACKUP_DIR"
rm -rf "$RAMFS"
}
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 5/5] base-files: sysupgrade: rename add_*files() functions

2024-02-12 Thread Rafał Miłecki
From: Rafał Miłecki 

Usage of word "add" was somehow misleading in those functions:
1. They don't really add (as in: append) anything. Result files are
   created from scratch.
2. It wasn't clear what adding files means. It could be understood as
   adding actual files somewhere (to existing archive?).

Also the word "add" was also a bit ambiguous.

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index e7de1f3446..1fcd44da2a 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -155,7 +155,7 @@ list_static_conffiles() {
\( -type f -o -type l \) $filter 2>/dev/null
 }
 
-add_conffiles() {
+build_list_of_backup_config_files() {
local file="$1"
 
( list_static_conffiles "$find_filter"; list_changed_conffiles ) |
@@ -163,7 +163,7 @@ add_conffiles() {
return 0
 }
 
-add_overlayfiles() {
+build_list_of_backup_overlay_files() {
local file="$1"
 
local packagesfiles=$1.packagesfiles
@@ -218,9 +218,9 @@ if [ $SAVE_OVERLAY = 1 ]; then
echo "Cannot find '/overlay/upper/etc', required for '-c'" >&2
exit 1
}
-   sysupgrade_init_conffiles="add_overlayfiles"
+   sysupgrade_init_conffiles="build_list_of_backup_overlay_files"
 else
-   sysupgrade_init_conffiles="add_conffiles"
+   sysupgrade_init_conffiles="build_list_of_backup_config_files"
 fi
 
 find_filter=""
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 3/5] base-files: sysupgrade: exit with no error for --help

2024-02-12 Thread Rafał Miłecki
From: Rafał Miłecki 

Calling "sysupgrade --help" should result in printing help and exiting
with 0 code.

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 38dda3b9a4..f5a4441dc9 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -63,9 +63,7 @@ while [ -n "$1" ]; do
shift;
 done
 
-IMAGE="$1"
-
-[ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] 
&& {
+print_help() {
cat <...] 
$0 [-q] [-i] [-c] [-u] [-o] [-k]  
@@ -105,9 +103,20 @@ backup-command:
 sysupgrade -b. Does not create a backup file.
 
 EOF
-   exit 1
 }
 
+IMAGE="$1"
+
+if [ $HELP -gt 0 ]; then
+   print_help
+   exit 0
+fi
+
+if [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 ]; then
+   print_help
+   exit 1
+fi
+
 [ -n "$IMAGE" -a -n "$NEED_IMAGE" ] && {
cat <<-EOF
-b|--create-backup and -r|--restore-backup do not perform a 
firmware upgrade.
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/5] base-files: sysupgrade: group & cleanup global variables

2024-02-12 Thread Rafał Miłecki
From: Rafał Miłecki 

Group & describe them by type, drop unneeded exports.

Signed-off-by: Rafał Miłecki 
---
 package/base-files/files/sbin/sysupgrade | 64 
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index afcd868bae..38dda3b9a4 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -4,26 +4,35 @@
 . /lib/functions/system.sh
 . /usr/share/libubox/jshn.sh
 
-# initialize defaults
+# File-local constants
+CONF_TAR=/tmp/sysupgrade.tgz
+ETCBACKUP_DIR=/etc/backup
+INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt
+COMMAND=/lib/upgrade/do_stage2
+
+# File-local globals
+SAVE_OVERLAY=0
+SAVE_OVERLAY_PATH=
+SAVE_PARTITIONS=1
+SAVE_INSTALLED_PKGS=0
+SKIP_UNCHANGED=0
+CONF_IMAGE=
+CONF_BACKUP_LIST=0
+CONF_BACKUP=
+CONF_RESTORE=
+NEED_IMAGE=
+HELP=0
+TEST=0
+
+# Globals accessed in other files
 export MTD_ARGS=""
 export MTD_CONFIG_ARGS=""
 export INTERACTIVE=0
 export VERBOSE=1
 export SAVE_CONFIG=1
-export SAVE_OVERLAY=0
-export SAVE_OVERLAY_PATH=
-export SAVE_PARTITIONS=1
-export SAVE_INSTALLED_PKGS=0
-export SKIP_UNCHANGED=0
-export CONF_IMAGE=
-export CONF_BACKUP_LIST=0
-export CONF_BACKUP=
-export CONF_RESTORE=
 export IGNORE_MINOR_COMPAT=0
-export NEED_IMAGE=
-export HELP=0
 export FORCE=0
-export TEST=0
+export CONFFILES=/tmp/sysupgrade.conffiles
 
 # parse options
 while [ -n "$1" ]; do
@@ -32,18 +41,18 @@ while [ -n "$1" ]; do
-v) export VERBOSE="$(($VERBOSE + 1))";;
-q) export VERBOSE="$(($VERBOSE - 1))";;
-n) export SAVE_CONFIG=0;;
-   -c) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;;
-   -o) export SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;;
-   -p) export SAVE_PARTITIONS=0;;
-   -k) export SAVE_INSTALLED_PKGS=1;;
-   -u) export SKIP_UNCHANGED=1;;
-   -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; 
shift;;
-   -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; 
shift;;
-   -l|--list-backup) export CONF_BACKUP_LIST=1;;
-   -f) export CONF_IMAGE="$2"; shift;;
+   -c) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/etc;;
+   -o) SAVE_OVERLAY=1 SAVE_OVERLAY_PATH=/;;
+   -p) SAVE_PARTITIONS=0;;
+   -k) SAVE_INSTALLED_PKGS=1;;
+   -u) SKIP_UNCHANGED=1;;
+   -b|--create-backup) CONF_BACKUP="$2" NEED_IMAGE=1; shift;;
+   -r|--restore-backup) CONF_RESTORE="$2" NEED_IMAGE=1; shift;;
+   -l|--list-backup) CONF_BACKUP_LIST=1;;
+   -f) CONF_IMAGE="$2"; shift;;
-F|--force) export FORCE=1;;
-   -T|--test) export TEST=1;;
-   -h|--help) export HELP=1; break;;
+   -T|--test) TEST=1;;
+   -h|--help) HELP=1; break;;
--ignore-minor-compat-version) export IGNORE_MINOR_COMPAT=1;;
-*)
echo "Invalid option: $1" >&2
@@ -54,11 +63,6 @@ while [ -n "$1" ]; do
shift;
 done
 
-export CONFFILES=/tmp/sysupgrade.conffiles
-export CONF_TAR=/tmp/sysupgrade.tgz
-export ETCBACKUP_DIR=/etc/backup
-export INSTALLED_PACKAGES=${ETCBACKUP_DIR}/installed_packages.txt
-
 IMAGE="$1"
 
 [ -z "$IMAGE" -a -z "$NEED_IMAGE" -a $CONF_BACKUP_LIST -eq 0 -o $HELP -gt 0 ] 
&& {
@@ -365,8 +369,6 @@ fi
 install_bin /sbin/upgraded
 v "Commencing upgrade. Closing all shell sessions."
 
-COMMAND='/lib/upgrade/do_stage2'
-
 if [ -n "$FAILSAFE" ]; then
printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade
lock -u /tmp/.failsafe
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH RFC] aquantia-firmware: package MediaTek's Aquantia AQR113C firmware

2024-02-05 Thread Rafał Miłecki

On 5.02.2024 15:21, Daniel Golle wrote:

On Mon, Feb 05, 2024 at 02:23:08PM +0100, Rafał Miłecki wrote:

From: Rafał Miłecki 

Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
have it stored on flash and some need filesystem to provide it.


Are you aware of any MediaTek boards which do come with AQR113C but
don't bring their own dedicated firmware flash/EEPROM IC connected
directly to first PHY?
UniFi 6 LR v1/v2 (Aquantia AQR112C) and MT7988RFB (Aquantia AQR113C)
both come with a dedidated flash/EEPROM IC for the PHY firmware.
However, that firmware (esp. on the UniFi 6 LR) may of course be
outdated by now and we may want to load newer firmware from within
Linux anyway.


I'm not sure if I can verify using Linux if there is EEPROM attached to
any of two PHYs on my board. I don't believe Linux's PHY driver exposes
possibly-attached EEPROM as any Linux device.

I think however that with EEPROM present I wouldn't need Linux driver
to load PHY firmware. In my board case I need to do that which makes me
believe there is no EEPROM chip with firmware present.

--
Rafał Miłecki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH RFC] aquantia-firmware: package MediaTek's Aquantia AQR113C firmware

2024-02-05 Thread Rafał Miłecki

On 5.02.2024 15:15, Robert Marko wrote:

On Mon, 5 Feb 2024 at 14:23, Rafał Miłecki  wrote:


From: Rafał Miłecki 

Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
have it stored on flash and some need filesystem to provide it.

MediaTek holds its own AQR113C firmware file for its boards. Package it.


Hi Rafal, not going into details of this patch, but what is the
license situation with
redistributing the AQR firmware?


Good question. I don't know.

Cc linux-mediatek@
Can we get some licensing help, please?



Initial firmware file
Rhe-05.06-Candidate7-AQR_Mediatek_23B_StartOff_ID45623_VER36657.cld was
added in the commit:

commit 24ba51c5be18613127b2d8407b0223174624b130
Author: developer 
Date:   Tue Nov 15 11:22:46 2022 +0800

[][kernel][mt7988][eth][Change AQR113C firmware download method to MDIO 
gangload]

[Description]
Change AQR113C firmware download method to MDIO gangload.

If without this patch, AQR113C cannot boot from MDIO gangload.

[Release-log]
N/A


Change-Id: Iddc29f5e1c73c772bcea9313938b6daccc10025a
Reviewed-on: 
https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6781059

with not licensing details.



Later there was a firmware update update handled by adding file:
Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld in the commit:

commit 405b1e31f924b97d379719fb39f0d28c0fac43a9
Author: developer 
Date:   Tue Mar 28 17:00:41 2023 +0800

[][kernel][mt7988][eth][Fix AQR113C 5GBASE-T compliance test mode4 tone1 
fail issue]

[Description]
Fix AQR113C 5GBASE-T compliance test mode4 tone1 fail issue by
updating firmware version to
Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld.

If without this patch, AQR113C might not pass the 5GBASE-T mode4 tone1
items for the compliance test.

[Release-log]
N/A


Change-Id: I3b2c6e6cf1a6ba8183daa7e30110ff2c839c5989
Reviewed-on: 
https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/7305781

but again with not licensing info.



I also can't find any readme file specifying licensing of those files.


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH RFC] aquantia-firmware: package MediaTek's Aquantia AQR113C firmware

2024-02-05 Thread Rafał Miłecki
From: Rafał Miłecki 

Aquantia AQR113C is PHY that needs loading a firmware. Some devices may
have it stored on flash and some need filesystem to provide it.

MediaTek holds its own AQR113C firmware file for its boards. Package it.

The problem is obtaining that firmware:
1. Cloning whole repo seems like an overkill for copying a single file
2. Public git server doesn't support git protocol (and so git archive)
3. Gitiles UI doesn't allow downloading raw files (nor binaries as text)

The only option seems to be downloading tar archive of "firmware"
directory. The problem is such archives generated by Gitiles differ on
every download so a checksum can't be specified.

Due to all above a custom download is implemented in "Build/Prepare".
Then firmware gets simply extracted and packaged.

Cc: Robert Marko 
Cc: Christian Marangi 
Cc: Daniel Golle 
Signed-off-by: Rafał Miłecki 
---
 package/firmware/aquantia-firmware/Makefile | 36 +
 1 file changed, 36 insertions(+)
 create mode 100644 package/firmware/aquantia-firmware/Makefile

diff --git a/package/firmware/aquantia-firmware/Makefile 
b/package/firmware/aquantia-firmware/Makefile
new file mode 100644
index 00..9cf67f41bb
--- /dev/null
+++ b/package/firmware/aquantia-firmware/Makefile
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=aquantia-firmware
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/aquantia-mediatek-aqr113c-firmware
+  SECTION:=firmware
+  CATEGORY:=Firmware
+  TITLE:=MediaTek's firmware for Aquantia AQR113C
+endef
+
+define Build/Prepare
+   mkdir -p $(PKG_BUILD_DIR)
+
+   # Download for "aquantia-mediatek-aqr113c-firmware" package
+   wget \
+   -O 
$(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz
 \
+   
"https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+archive/refs/heads/master/21.02/files/target/linux/mediatek/mt7988/base-files/lib/firmware.tar.gz;
+   tar xf 
$(DL_DIR)/mtk-openwrt-feeds-refs_heads_master-21.02-files-target-linux-mediatek-mt7988-base-files-lib-firmware.tar.gz
 -C $(PKG_BUILD_DIR)
+   # TODO: Verify extracted firmware checksum
+endef
+
+define Build/Compile
+
+endef
+
+define Package/aquantia-mediatek-aqr113c-firmware/install
+   $(INSTALL_DIR) $(1)/lib/firmware
+   $(INSTALL_DATA) 
$(PKG_BUILD_DIR)/Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld 
$(1)/lib/firmware/
+endef
+
+$(eval $(call BuildPackage,aquantia-mediatek-aqr113c-firmware))
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: Future of the broadcom-wl package?

2024-01-29 Thread Rafał Miłecki

On 26.01.2024 18:45, Felix Fietkau wrote:

does anybody still care about the broadcom-wl package in OpenWrt?
I think it would be nice if we could get rid of it, along with the code support 
and abstraction for different wireless drivers.
It would also allow us to rewrite iwinfo in ucode with nl80211 as the only 
supported API, which helps keep things simple.

Would anybody be opposed to declaring 23.05 to be the last release to support 
broadcom-wl?


Go ahead and drop it!

If anyone wants that driver it should receive cfg80211 API layer so it
can be used with generic tools.

It should be quite doable and actually I know there were GPL 2 licsensed
wl_cfg80211.c files (with wl_cfg80211_add_virtual_iface() and friends)
floating around in various projects.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] mediatek: filogic: replace built-in Aquantia driver with module

2024-01-17 Thread Rafał Miłecki
From: Rafał Miłecki 

Some Aquantia PHYs (e.g. AQR113C) require firmware to be uploaded by
host system. With built-in drivers this doesn't work in OpenWrt /
embeddded as filesystem isn't available during PHY probe. That results
in delays like:
[1.588068] Aquantia AQR113C mdio-bus:00: Falling back to sysfs fallback 
for: Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld
[   64.526387] Aquantia AQR113C mdio-bus:00: failed to find FW file 
Rhe-05.06-Candidate9-AQR_Mediatek_23B_P5_ID45824_LCLVER1.cld (-110)

Switch to module to postpone PHY probe to init state.

Signed-off-by: Rafał Miłecki 
---
 target/linux/mediatek/filogic/config-5.15 | 1 -
 target/linux/mediatek/filogic/config-6.1  | 1 -
 target/linux/mediatek/filogic/target.mk   | 2 +-
 3 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/target/linux/mediatek/filogic/config-5.15 
b/target/linux/mediatek/filogic/config-5.15
index 8ba0b0efe8..783447ac9c 100644
--- a/target/linux/mediatek/filogic/config-5.15
+++ b/target/linux/mediatek/filogic/config-5.15
@@ -1,6 +1,5 @@
 CONFIG_64BIT=y
 # CONFIG_AHCI_MTK is not set
-CONFIG_AQUANTIA_PHY=y
 CONFIG_ARCH_DMA_ADDR_T_64BIT=y
 CONFIG_ARCH_KEEP_MEMBLOCK=y
 CONFIG_ARCH_MEDIATEK=y
diff --git a/target/linux/mediatek/filogic/config-6.1 
b/target/linux/mediatek/filogic/config-6.1
index 1687aadbc1..1eaf57b06e 100644
--- a/target/linux/mediatek/filogic/config-6.1
+++ b/target/linux/mediatek/filogic/config-6.1
@@ -1,6 +1,5 @@
 CONFIG_64BIT=y
 # CONFIG_AHCI_MTK is not set
-CONFIG_AQUANTIA_PHY=y
 CONFIG_ARCH_BINFMT_ELF_EXTRA_PHDRS=y
 CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE=y
 CONFIG_ARCH_DMA_ADDR_T_64BIT=y
diff --git a/target/linux/mediatek/filogic/target.mk 
b/target/linux/mediatek/filogic/target.mk
index dd4c4c1448..182b229db2 100644
--- a/target/linux/mediatek/filogic/target.mk
+++ b/target/linux/mediatek/filogic/target.mk
@@ -2,7 +2,7 @@ ARCH:=aarch64
 SUBTARGET:=filogic
 BOARDNAME:=Filogic 8x0 (MT798x)
 CPU_TYPE:=cortex-a53
-DEFAULT_PACKAGES += kmod-crypto-hw-safexcel kmod-mt7915e wpad-basic-mbedtls 
uboot-envtools
+DEFAULT_PACKAGES += kmod-phy-aquantia kmod-crypto-hw-safexcel kmod-mt7915e 
wpad-basic-mbedtls uboot-envtools
 KERNELNAME:=Image dtbs
 
 define Target/Description
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install

2024-01-10 Thread Rafał Miłecki

On 26.11.2023 21:47, Rafał Miłecki wrote:

From: Rafał Miłecki 

Reloading service from uci-defaults script is a hack to workaround
postinst limitation. It should not be executed during boot as other
uci-defaults scripts may want to adjust uhttpd's config too.

Cc: Hauke Mehrtens 
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Signed-off-by: Rafał Miłecki 


PATCH obsoleted by
[PATCH] uhttpd: handle reload after uhttpd-mod-ubus installation using postinst
https://patchwork.ozlabs.org/project/openwrt/patch/20231227152045.18336-1-zaj...@gmail.com/



---
  package/network/services/uhttpd/Makefile   |  2 +-
  package/network/services/uhttpd/files/ubus.default | 13 -
  2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/package/network/services/uhttpd/Makefile 
b/package/network/services/uhttpd/Makefile
index 02a02405fd..9405070626 100644
--- a/package/network/services/uhttpd/Makefile
+++ b/package/network/services/uhttpd/Makefile
@@ -8,7 +8,7 @@
  include $(TOPDIR)/rules.mk
  
  PKG_NAME:=uhttpd

-PKG_RELEASE:=1
+PKG_RELEASE:=2
  
  PKG_SOURCE_PROTO:=git

  PKG_SOURCE_URL=$(PROJECT_GIT)/project/uhttpd.git
diff --git a/package/network/services/uhttpd/files/ubus.default 
b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..e2240a1018 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -12,6 +12,17 @@ fi
commit=1
  }
  
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload

+# Normally (when executing this script during boot) we want to adjust config
+# only. Actual uhttpd start will happen later.
+#
+# If this is package installation in a running system however then we need to
+# reload uhttpd to make ubus access work right after. Ideally this should be
+# handled by a "postinst" script but those get executed *before* uci-defaults
+# scripts. For that reason we abuse uci-defaults to call init.d script.
+#
+# Check for $PKG_ROOT to detect "opkg install" case in a running system.
+if [ -n "$PKG_ROOT" ]; then
+   [ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+fi
  
  exit 0



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: OpenWrt One - celebrating 20 years of OpenWrt

2024-01-09 Thread Rafał Miłecki

On 9.01.2024 13:29, John Crispin wrote:

On 09.01.24 12:56, Robert Marko wrote:

---SNIP---


Why not 6GHz?

6GHz requires an external card, and I doubt you can fit that in the
target price.

Regards,
Robert


correct. as mentioned in the email, we wanted to start out small. also upstream 
mac80211 is still missing a bunch of 11be related features.


6 GHz doesn't imply 802.11be, does it? I'm really not sure.

Does MediaTek have any 802.11ax solutions that cover both: 5 GHz and
6 GHz? Maybe it'd be worth checking if that's an option and then use
voting to see if people care?

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: OpenWrt One - celebrating 20 years of OpenWrt

2024-01-09 Thread Rafał Miłecki

On 9.01.2024 11:49, John Crispin wrote:

If the community likes the idea outlined below in greater details, we would 
like to start a vote.


I'm afraid it's a bit unclear what do you expect here ;) People at IRC
started wondering too.

I love idea of this project and I'll surely be interested in buying
some units. I hope we can take care of some case with OpenWrt branding.

So are you looking for just a generic interest feedback? Or some
technical comments? What are next steps for this project and do you
could use some community help?

--
Rafał Miłecki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH dt-schema] schemas: chosen: Add OpenWrt LEDs properties for system states

2024-01-09 Thread Rafał Miłecki
From: Rafał Miłecki 

OpenWrt project provides downstream support for thousands of embedded
home network devices. Its custom requirement for DT is to provide info
about LEDs roles. Currently it does it by using custom non-documented
aliases. While formally valid (aliases.yaml doesn't limit names or
purposes of aliases) it's quite a loose solution.

Document 4 precise "chosen" biding properties with clearly documented
OpenWrt usage. This will allow upstreaming tons of DTS files that noone
cared about so far as those would need to be patched downstream anyway.

Signed-off-by: Rafał Miłecki 
---
A few weeks ago I was seeking for a help regarding OpenWrt's need for
specifing LEDs roles in DT, see:

Describing LEDs roles in device tree?
https://lore.kernel.org/linux-devicetree/ee912a89-4fd7-43c3-a79b-16659a035...@gmail.com/T/#u

I DON'T think OpenWrt's current solution with aliases is good enough:
* It's not clearly documented
* It may vary from other projects usa case
* It may be refused by random maintainers I think

I decided to suggest 4 OpenWrt-prefixed properties for "chosen". I'm
hoping this small custom binding is sth we could go with. I'm really
looking forward to upstreaming OpenWrt's downstream DTS files so other
projects (e.g. Buildroot) can use them.

If you have any better fitting solution in mind please let me know. I
should be fine with anything that lets me solve this downstream mess
situation.

 dtschema/schemas/chosen.yaml | 9 +
 1 file changed, 9 insertions(+)

diff --git a/dtschema/schemas/chosen.yaml b/dtschema/schemas/chosen.yaml
index 6d5c3f1..96d0db7 100644
--- a/dtschema/schemas/chosen.yaml
+++ b/dtschema/schemas/chosen.yaml
@@ -264,4 +264,13 @@ properties:
 patternProperties:
   "^framebuffer": true
 
+  "^openwrt,led-(boot|failsafe|running|upgrade)$":
+$ref: types.yaml#/definitions/string
+description:
+  OpenWrt choice of LED for a given role. Value must be a full path 
(encoded
+  as a string) to a relevant LED node.
+
+  Property user may use specified path to control proper LED during current
+  system boot phase.
+
 additionalProperties: false
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] uhttpd: handle reload after uhttpd-mod-ubus installation using postinst

2023-12-27 Thread Rafał Miłecki
From: Rafał Miłecki 

Use postinst script to reload service instead of uci-defaults hack. It's
possible thanks to recent base-files change that executes postinst after
uci-defaults.

This fixes support for uhttpd customizations. It's possible (again) to
adjust uhttpd config with custom uci-defaults before it gets started.

Cc: Hauke Mehrtens 
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Ref: b799dd3c705d ("base-files: execute package's "postinst" after executing 
uci-defaults")
Signed-off-by: Rafał Miłecki 
---
This is a clean fix compared to my proposed hack:
[PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install
https://patchwork.ozlabs.org/project/openwrt/patch/20231126204739.14315-1-zaj...@gmail.com/

I'm planning to push it in few days unless base-files change blows up
some existing packages.

 package/network/services/uhttpd/Makefile   | 9 -
 package/network/services/uhttpd/files/ubus.default | 6 --
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/package/network/services/uhttpd/Makefile 
b/package/network/services/uhttpd/Makefile
index 02a02405fd..37117bf911 100644
--- a/package/network/services/uhttpd/Makefile
+++ b/package/network/services/uhttpd/Makefile
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uhttpd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uhttpd.git
@@ -107,6 +107,13 @@ define Package/uhttpd-mod-ubus/install
$(INSTALL_DATA) ./files/ubus.default 
$(1)/etc/uci-defaults/00_uhttpd_ubus
 endef
 
+define Package/uhttpd-mod-ubus/postinst
+#!/bin/sh
+if [ -z "$${IPKG_INSTROOT}" ]; then
+   /etc/init.d/uhttpd reload
+fi
+endef
+
 define Package/uhttpd-mod-ucode/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uhttpd_ucode.so $(1)/usr/lib/
diff --git a/package/network/services/uhttpd/files/ubus.default 
b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..d0a218a0ad 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -1,17 +1,11 @@
 #!/bin/sh
 
-commit=0
-
 if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then
uci set uhttpd.main.ubus_prefix=/ubus
-   commit=1
 fi
 
 [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
-   commit=1
 }
 
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
-
 exit 0
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] mediatek: filogic: use fixed layout cell "mac-base" for Xiaomi WR30U

2023-12-04 Thread Rafał Miłecki

On 28.07.2023 13:28, Rafał Miłecki wrote:

From: Rafał Miłecki 

Cc: Hank Moretti 
Cc: Hauke Mehrtens 
Signed-off-by: Rafał Miłecki 
---
Hank: can you runtime test this, please?


It remained unanswered but change got handled by Rosen:
405bc5be130a ("mediatek: convert to nvmem-layout")
3eb899fd3675 ("mediatek: use mac-base")



---
  .../dts/mt7981b-xiaomi-mi-router-wr30u.dtsi | 17 ++---
  1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi 
b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
index 9467b18a7e..4f8c3046d2 100644
--- a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
+++ b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
@@ -73,9 +73,8 @@
reg = <0>;
phy-mode = "2500base-x";
  
-		nvmem-cells = <_factory_4>;

+   nvmem-cells = <_factory_4 (-1)>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(-1)>;
  
  		fixed-link {

speed = <2500>;
@@ -177,12 +176,16 @@
reg = <0x18 0x20>;
read-only;
  
-compatible = "nvmem-cells";

-   #address-cells = <1>;
-   #size-cells = <1>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
  
-macaddr_factory_4: macaddr@4 {

-   reg = <0x4 0x6>;
+   macaddr_factory_4: macaddr@4 {
+   compatible = "mac-base";
+   reg = <0x4 0x6>;
+   #nvmem-cell-cells = <1>;
+   };
};
};
  



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] kernel: force atomic renames in ubifs

2023-11-26 Thread Rafał Miłecki

Hi Richard,

On 1.03.2022 20:37, Richard Weinberger wrote:

- Ursprüngliche Mail -

Von: "Rafał Miłecki" 
An: "OpenWrt Development List" 
CC: "Koen Vandeputte" , "richard" , "Rafał 
Miłecki" 
Gesendet: Dienstag, 1. März 2022 20:13:29
Betreff: [PATCH] kernel: force atomic renames in ubifs



From: Rafał Miłecki 

This deals with user-spaces apps that don't handle all syncing
correctly. It prevents user ending up with an empty file.

Signed-off-by: Rafał Miłecki 
---
.../510-ubifs-force-atomic-renames.patch  | 46 +++
.../510-ubifs-force-atomic-renames.patch  | 46 +++
2 files changed, 92 insertions(+)
create mode 100644
target/linux/generic/pending-5.10/510-ubifs-force-atomic-renames.patch
create mode 100644
target/linux/generic/pending-5.4/510-ubifs-force-atomic-renames.patch

diff --git
a/target/linux/generic/pending-5.10/510-ubifs-force-atomic-renames.patch
b/target/linux/generic/pending-5.10/510-ubifs-force-atomic-renames.patch
new file mode 100644
index 00..80f5f1b910
--- /dev/null
+++ b/target/linux/generic/pending-5.10/510-ubifs-force-atomic-renames.patch
@@ -0,0 +1,46 @@
+From: Richard Weinberger 
+Date: Mon, 28 Feb 2022 16:07:41 +0100
+Subject: [PATCH] ubifs: force atomic renames
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Before actual rename make sure that the old inode data has been flash
+written. This is similar to what other filesystems do and workarounds
+bugs in some user-space apps.
+
+With this change updating file using tmpfile & rename() will never
+result in losing all content e.g. on power cut.


Please slow down a bit. :-)
The commit message is not written by me and also not entirely correct.

The patch is not about making rename atomic. rename is already atomic
on UBIFS.
It is about syncing in flight pages when a file is overwritten by rename.

While I plan to upstream this change it still needs more testing.
I'm also not sure about the overhead it causes. Flushing the write buffers
can cause more garbage collection and may trigger write amplification.


I didn't end up pushing this change to OpenWrt since your e-mail. I use
it however in my project in production in thousands of devices. I'd very
much like to see a proper change upstream.

Could you take a look at it, please?


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] uhttpd: uhttpd-mod-ubus: reload uhttpd only if it's runtime install

2023-11-26 Thread Rafał Miłecki
From: Rafał Miłecki 

Reloading service from uci-defaults script is a hack to workaround
postinst limitation. It should not be executed during boot as other
uci-defaults scripts may want to adjust uhttpd's config too.

Cc: Hauke Mehrtens 
Fixes: d25d281fd668 ("uhttpd: Reload config after uhttpd-mod-ubus was added")
Signed-off-by: Rafał Miłecki 
---
 package/network/services/uhttpd/Makefile   |  2 +-
 package/network/services/uhttpd/files/ubus.default | 13 -
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/package/network/services/uhttpd/Makefile 
b/package/network/services/uhttpd/Makefile
index 02a02405fd..9405070626 100644
--- a/package/network/services/uhttpd/Makefile
+++ b/package/network/services/uhttpd/Makefile
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uhttpd
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/uhttpd.git
diff --git a/package/network/services/uhttpd/files/ubus.default 
b/package/network/services/uhttpd/files/ubus.default
index 474016c1c5..e2240a1018 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -12,6 +12,17 @@ fi
commit=1
 }
 
-[ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+# Normally (when executing this script during boot) we want to adjust config
+# only. Actual uhttpd start will happen later.
+#
+# If this is package installation in a running system however then we need to
+# reload uhttpd to make ubus access work right after. Ideally this should be
+# handled by a "postinst" script but those get executed *before* uci-defaults
+# scripts. For that reason we abuse uci-defaults to call init.d script.
+#
+# Check for $PKG_ROOT to detect "opkg install" case in a running system.
+if [ -n "$PKG_ROOT" ]; then
+   [ "$commit" = 1 ] && uci commit uhttpd && /etc/init.d/uhttpd reload
+fi
 
 exit 0
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH RFC] base-files: execute package's "postinst" after executing uci-defaults

2023-11-26 Thread Rafał Miłecki
From: Rafał Miłecki 

With this change "postinst" scripts can perform extra actions after
applying all kind of fixups implemented using uci-defaults.

This is needed e.g. by uhttpd-mod-ubus which after installation in a
running systems needs to:
1. Update uhttpd config using its uci-defaults script
2. Reload uhttpd

Cc: Hauke Mehrtens 
Signed-off-by: Rafał Miłecki 
---
I noticed that kind of hacky code was added in the commit d25d281fd668
("uhttpd: Reload config after uhttpd-mod-ubus was added") to reload
uhttpd after "opkg install". It abuses uci-defaults script to call
init.d script. It's a wrong idea as uci-defaults should run before
running services during first boot. It doesn't allow further config
adjustments by other uci-defaults as uhttpd gets started early.

This change would allow moving uhttpd-mod-ubus's reload to postinst.

The question is: can this change break anything?

 package/base-files/files/lib/functions.sh | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh 
b/package/base-files/files/lib/functions.sh
index d9628dbb7a..851d2f1791 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -270,11 +270,6 @@ default_postinst() {
 
add_group_and_user "${pkgname}"
 
-   if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
-   ( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
-   ret=$?
-   fi
-
if [ -d "$root/rootfs-overlay" ]; then
cp -R $root/rootfs-overlay/. $root/
rm -fR $root/rootfs-overlay/
@@ -300,6 +295,11 @@ default_postinst() {
rm -f /tmp/luci-indexcache
fi
 
+   if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
+   ( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
+   ret=$?
+   fi
+
local shell="$(command -v bash)"
for i in $(grep -s "^/etc/init.d/" "$root$filelist"); do
if [ -n "$root" ]; then
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] mediatek: filogic: add Acelink EW-7886CAX support

2023-11-20 Thread Rafał Miłecki
From: Rafał Miłecki 

Acelink EW-7886CAX is an MT7986A (AKA Filogic 830) based access point.
It has 512 MiB of RAM, one 2.5 Gbps PoE (802.3at) Ethernet port and
on-SoC Wi-Fi.

My unit came with Mediatek's firmware (based on OpenWrt 21.02)
installed. It was possible to simply upgrade using OpenWrt's sysupgrade
tool.

Another verified upgrade method is using U-Boot (requires UART). During
every boot there is "U-Boot Boot Menu". Selecting option "2. Upgrade
firmware" allows using U-Boot's tftp client to load and flash factory
image.

Signed-off-by: Rafał Miłecki 
---
 .../dts/mt7986a-acelink-ew-7886cax.dts| 236 ++
 target/linux/mediatek/image/filogic.mk|  17 ++
 2 files changed, 253 insertions(+)
 create mode 100644 target/linux/mediatek/dts/mt7986a-acelink-ew-7886cax.dts

diff --git a/target/linux/mediatek/dts/mt7986a-acelink-ew-7886cax.dts 
b/target/linux/mediatek/dts/mt7986a-acelink-ew-7886cax.dts
new file mode 100644
index 00..bdbcf1f364
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7986a-acelink-ew-7886cax.dts
@@ -0,0 +1,236 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+
+/dts-v1/;
+#include 
+#include 
+#include 
+
+#include "mt7986a.dtsi"
+
+/ {
+   model = "Acelink EW-7886CAX";
+   compatible = "acelink,ew-7886cax", "mediatek,mt7986a";
+
+   aliases {
+   serial0 = 
+   led-boot = _status_blue;
+   led-running = _status_green;
+   led-upgrade = _status_red;
+   led-failsafe = _status_red;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   memory@4000 {
+   reg = <0 0x4000 0 0x2000>;
+   device_type = "memory";
+   };
+
+   keys {
+   compatible = "gpio-keys";
+
+   key-restart {
+   label = "Reset";
+   gpios = < 7 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   led_status_red: led-0 {
+   function = LED_FUNCTION_STATUS;
+   color = ;
+   gpios = < 18 GPIO_ACTIVE_HIGH>;
+   };
+
+   led_status_green: led-1 {
+   function = LED_FUNCTION_STATUS;
+   color = ;
+   gpios = < 19 GPIO_ACTIVE_HIGH>;
+   };
+
+   led_status_blue: led-2 {
+   function = LED_FUNCTION_STATUS;
+   color = ;
+   gpios = < 20 GPIO_ACTIVE_HIGH>;
+   };
+   };
+};
+
+ {
+   status = "okay";
+};
+
+ {
+   spi_flash_pins: spi-flash-pins-33-to-38 {
+   mux {
+   function = "spi";
+   groups = "spi0", "spi0_wp_hold";
+   };
+   conf-pu {
+   pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
+   drive-strength = <8>;
+   mediatek,pull-up-adv = <0>; /* bias-disable */
+   };
+   conf-pd {
+   pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
+   drive-strength = <8>;
+   mediatek,pull-down-adv = <0>; /* bias-disable */
+   };
+   };
+
+   wf_2g_5g_pins: wf_2g_5g-pins {
+   mux {
+   function = "wifi";
+   groups = "wf_2g", "wf_5g";
+   };
+   conf {
+   pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
+  "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
+  "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
+  "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
+  "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
+  "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
+  "WF1_TOP_CLK", "WF1_TOP_DATA";
+   drive-strength = <4>;
+   };
+   };
+
+   wf_dbdc_pins: wf-dbdc-pins {
+   mux {
+   function = "wifi";
+   groups = "wf_dbdc";
+   };
+  

Describing LEDs roles in device tree?

2023-11-20 Thread Rafał Miłecki

Hi!

Our current binding Documentation/devicetree/bindings/leds/common.yaml
allows describing some generic LED parameters. Most common are color and
function.

Now, many systems will want further & more specialized description of
LEDs. Most common roles I can think of:
1. System is booting
2. System is running
3. System's failure

For kernel usage role we actually have a "panic-indicator" property.

Are those extra roles something we could put in DT?

Please note that "function" on its own is not sufficient as multiple
LEDs my share the same function name but its meaning may vary depending
on color.

OpenWrt developers started (ab?)using aliases in downstream/modified DT
files for such purposes. Example:

aliases {
led-boot = _status_blue;
led-running = _status_green;
led-failsafe = _status_red;
};

Above could work with some adjustments but I'm not sure if it's
acceptable for upstream binding. Also what if OpenWrt wants to define
different roles than another project? Prefixes?

With Linux a problem is also a lack of mapping between
/proc/device-tree/leds/*
and
/sys/class/leds/*
With "label" present its simple but some guessing logic is needed for
function + color properties (it's actually missing in OpenWrt right now)

Any suggestions for DT-based solution?

--
Rafał Miłecki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] kernel: drop "mac-address-increment-byte" DT property support

2023-11-15 Thread Rafał Miłecki
From: Rafał Miłecki 

This downstream DT property is not used by any DTS file anymore.

Signed-off-by: Rafał Miłecki 
---
 ...net-add-mac-address-increment-support.patch | 18 --
 ...683-of_net-add-mac-address-to-of-tree.patch |  2 +-
 ...et-do-mac-address-increment-only-once.patch |  9 -
 ...net-add-mac-address-increment-support.patch | 18 --
 ...683-of_net-add-mac-address-to-of-tree.patch |  2 +-
 ...et-do-mac-address-increment-only-once.patch |  9 -
 6 files changed, 18 insertions(+), 40 deletions(-)

diff --git 
a/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch
 
b/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch
index f6ae9f31f1..73eabf4f37 100644
--- 
a/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch
+++ 
b/target/linux/generic/pending-5.15/682-of_net-add-mac-address-increment-support.patch
@@ -20,14 +20,12 @@ Signed-off-by: Ansuel Smith 
 
 --- a/net/core/of_net.c
 +++ b/net/core/of_net.c
-@@ -119,28 +119,63 @@ static int of_get_mac_addr_nvmem(struct
+@@ -119,10 +119,19 @@ static int of_get_mac_addr_nvmem(struct
   * this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
   * but is all zeros.
   *
 + * DT can tell the system to increment the mac-address after is extracted by
 + * using:
-+ * - mac-address-increment-byte to decide what byte to increase
-+ *   (if not defined is increased the last byte)
 + * - mac-address-increment to decide how much to increase. The value WILL
 + *   overflow to other bytes if the increment is over 255 or the total
 + *   increment will exceed 255 of the current byte.
@@ -38,19 +36,11 @@ Signed-off-by: Ansuel Smith 
  */
  int of_get_mac_address(struct device_node *np, u8 *addr)
  {
-+  u32 inc_idx, mac_inc, mac_val;
++  u32 mac_inc, mac_val;
int ret;
  
-+  /* Check first if the increment byte is present and valid.
-+   * If not set assume to increment the last byte if found.
-+   */
-+  if (of_property_read_u32(np, "mac-address-increment-byte", _idx))
-+  inc_idx = 5;
-+  if (inc_idx < 3 || inc_idx > 5)
-+  return -EINVAL;
-+
if (!np)
-   return -ENODEV;
+@@ -130,17 +139,33 @@ int of_get_mac_address(struct device_nod
  
ret = of_get_mac_addr(np, "mac-address", addr);
if (!ret)
@@ -75,7 +65,7 @@ Signed-off-by: Ansuel Smith 
 +  if (!of_property_read_u32(np, "mac-address-increment", _inc)) {
 +  /* Convert to a contiguous value */
 +  mac_val = (addr[3] << 16) + (addr[4] << 8) + addr[5];
-+  mac_val += mac_inc << 8 * (5-inc_idx);
++  mac_val += mac_inc;
 +
 +  /* Apply the incremented value handling overflow case */
 +  addr[3] = (mac_val >> 16) & 0xff;
diff --git 
a/target/linux/generic/pending-5.15/683-of_net-add-mac-address-to-of-tree.patch 
b/target/linux/generic/pending-5.15/683-of_net-add-mac-address-to-of-tree.patch
index f7ef06a14a..29144ce8b4 100644
--- 
a/target/linux/generic/pending-5.15/683-of_net-add-mac-address-to-of-tree.patch
+++ 
b/target/linux/generic/pending-5.15/683-of_net-add-mac-address-to-of-tree.patch
@@ -45,7 +45,7 @@ property. This way, the MAC address can be accessed using 
procfs.
  /**
   * of_get_mac_address()
   * @np:   Caller's Device Node
-@@ -175,6 +196,7 @@ found:
+@@ -165,6 +186,7 @@ found:
addr[5] = (mac_val >> 0) & 0xff;
}
  
diff --git 
a/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
 
b/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
index 44d88e31a2..c37c451989 100644
--- 
a/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
+++ 
b/target/linux/generic/pending-5.15/684-of_net-do-mac-address-increment-only-once.patch
@@ -16,16 +16,15 @@ Signed-off-by: Will Moss 
 
 --- a/net/core/of_net.c
 +++ b/net/core/of_net.c
-@@ -194,6 +194,12 @@ found:
+@@ -184,6 +184,11 @@ found:
addr[3] = (mac_val >> 16) & 0xff;
addr[4] = (mac_val >> 8) & 0xff;
addr[5] = (mac_val >> 0) & 0xff;
 +
-+  /* Remove mac-address-increment and mac-address-increment-byte
-+   * DT property to make sure MAC address would not get 
incremented
-+   * more if this function is stared again. */
++  /* Remove mac-address-increment DT property to make sure MAC
++   * address would not get incremented more if this function is
++   * stared again. */
 +  of_remove_property(np, of_find_property(np, 
"mac-address-increment", NULL));
-+  of_remove_property(np, of_find_property(np, 
"mac-address-increment-byte", NULL));

[PATCH] ath79: use "fixed-layout" for Embedded Wireless devices

2023-11-10 Thread Rafał Miłecki
From: Rafał Miłecki 

Those devices have Ethernet interfaces using base MAC address increased
by 0x40 in the 3rd indexed byte (00:00:00:FF:00:00). To describe that we
were using a custom (downstream) "mac-address-increment-byte" property.

The same result can be achieved by using "mac-base" with a properly
adjusted offset value (0x40 << 16). It may be not pretty but it should
work without custom property or downstream kernel patch to support it.

Cc: Ansuel Smith 
Cc: Catrinel Catrinescu 
Cc: Felix Fietkau 
Signed-off-by: Rafał Miłecki 
---
 .../dts/ar9331_embeddedwireless_dorin.dts | 26 
 .../dts/ar9344_embeddedwireless_balin.dts | 30 ++-
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/target/linux/ath79/dts/ar9331_embeddedwireless_dorin.dts 
b/target/linux/ath79/dts/ar9331_embeddedwireless_dorin.dts
index de6b709b5c..6286f203ef 100644
--- a/target/linux/ath79/dts/ar9331_embeddedwireless_dorin.dts
+++ b/target/linux/ath79/dts/ar9331_embeddedwireless_dorin.dts
@@ -85,6 +85,18 @@
label = "art";
reg = <0xff 0x01>;
read-only;
+
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_art_1002: macaddr@1002 {
+   compatible = "mac-base";
+   reg = <0x1002 0x6>;
+   #nvmem-cell-cells = <1>;
+   };
+   };
};
};
};
@@ -93,10 +105,8 @@
  {
status = "okay";
 
-   nvmem-cells = <_art_1002>;
+   nvmem-cells = <_art_1002 0x40>;
nvmem-cell-names = "mac-address";
-   mac-address-increment-byte = <3>;
-   mac-address-increment = <0x40>;
 };
 
  {
@@ -108,13 +118,3 @@
 
mtd-cal-data = < 0x1000>;
 };
-
- {
-   compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   macaddr_art_1002: macaddr@1002 {
-   reg = <0x1002 0x6>;
-   };
-};
diff --git a/target/linux/ath79/dts/ar9344_embeddedwireless_balin.dts 
b/target/linux/ath79/dts/ar9344_embeddedwireless_balin.dts
index a84c273f86..de13865818 100644
--- a/target/linux/ath79/dts/ar9344_embeddedwireless_balin.dts
+++ b/target/linux/ath79/dts/ar9344_embeddedwireless_balin.dts
@@ -83,16 +83,20 @@
reg = <0xff 0x01>;
read-only;
 
-   compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   calibration_art_1000: calibration_data@1000 {
-   reg = <0x1000 0x440>;
-   };
-
-   macaddr_art_1002: macaddr@1002 {
-   reg = <0x1002 0x6>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   calibration_art_1000: 
calibration_data@1000 {
+   reg = <0x1000 0x440>;
+   };
+
+   macaddr_art_1002: macaddr@1002 {
+   compatible = "mac-base";
+   reg = <0x1002 0x6>;
+   #nvmem-cell-cells = <1>;
+   };
};
};
};
@@ -106,10 +110,8 @@
  {
status = "okay";
 
-   nvmem-cells = <_art_1002>;
+   nvmem-cells = <_art_1002 0x40>;
nvmem-cell-names = "mac-address";
-   mac-address-increment-byte = <3>;
-   mac-address-increment = <0x40>;
 
gmac-config {
device = <>;
@@ -121,7 +123,7 @@
  {
status = "okay";
 
-   nvmem-cells = <_art_1002>, <_art_1000>;
+   nvmem-cells = <_art_1002 0>, <_art_1000>;
nvmem-cell-names = "mac-address", "calibration";
 };
 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] kernel: of: add DT MAC address bitwise operation support

2023-11-10 Thread Rafał Miłecki

On 2023-11-10 10:41, Shiji Yang wrote:

From: Shiji Yang 

This patch allow user to perform basic bitwise clear/set operation on
OF DT MAC address. We use two new added dt-bindings to specific the
MAC address bits clear/set mask. "mac-address-bitwise-set" can be used
to set bit. And "mac-address-bitwise-clear" can be used to clear bit.


I'd like this binding to be documented and send upstream for a review.

I know 804-nvmem-core-support-mac-base-fixed-layout-cells.patch is still
not upstreamed and I'm not proud of it (I'm waiting for upstream NVMEM
layouts reword). Still we have an /official/ "mac-base" binding at
least. I'd be nice to have DT guys opinion on binding like this.

--
Rafał Miłecki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] kernel: of: remove "mac-address-ascii" support hack

2023-11-10 Thread Rafał Miłecki

On 2023-11-10 10:28, Shiji Yang wrote:

From: Shiji Yang 

ASCII MAC address can be handled by nvmem "fixed-layout" now. And all
related devices were converted to the new "mac-base" layout format.
It's time to remove this hack.


Oh, I was hoping for that for a long time. Looks great.

--
Rafał Miłecki

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] kernel: provide better control & help for SLUB configuration

2023-11-07 Thread Rafał Miłecki
From: Rafał Miłecki 

Allow selecting KERNEL_SLUB_DEBUG and KERNEL_SLUB_DEBUG_ON manually and
provide detailed help for both.

Signed-off-by: Rafał Miłecki 
---
 config/Config-kernel.in | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/config/Config-kernel.in b/config/Config-kernel.in
index a1209d82f3..4529c81fc7 100644
--- a/config/Config-kernel.in
+++ b/config/Config-kernel.in
@@ -682,10 +682,21 @@ config KERNEL_PRINTK_TIME
default y
 
 config KERNEL_SLUB_DEBUG
-   bool
+   bool "Enable SLUB debugging support"
+   help
+ This enables various debugging features:
+   - Accepts "slub_debug" kernel parameter
+   - Provides caches debugging options (e.g. tracing, validating)
+   - Adds /sys/kernel/slab/ attrs for reading amounts of *objects*
+   - Enables /proc/slabinfo support
+   - Prints into when running out of memory
 
 config KERNEL_SLUB_DEBUG_ON
-   bool
+   depends on KERNEL_SLUB_DEBUG
+   bool "Boot kernel with basic caches debugging enabled"
+   help
+ This enables by default sanity_checks, red_zone, poison and store_user
+ debugging options for all caches.
 
 config KERNEL_SLABINFO
select KERNEL_SLUB_DEBUG
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] treewide: disable CONFIG_SLUB_DEBUG in target configs

2023-11-07 Thread Rafał Miłecki
From: Rafał Miłecki 

From the symbol help message:
> SLUB has extensive debug support features. Disabling these can result
> in significant savings in code size.

There seems to be no need to enable those debugging features for
standard use.

Signed-off-by: Rafał Miłecki 
---
 target/linux/layerscape/armv7/config-5.15 | 1 -
 target/linux/layerscape/armv7/config-6.1  | 2 --
 target/linux/oxnas/config-5.15| 1 -
 target/linux/qoriq/config-5.15| 1 -
 target/linux/rockchip/armv8/config-5.15   | 1 -
 target/linux/rockchip/armv8/config-6.1| 2 --
 target/linux/sifiveu/config-6.1   | 2 --
 7 files changed, 10 deletions(-)

diff --git a/target/linux/layerscape/armv7/config-5.15 
b/target/linux/layerscape/armv7/config-5.15
index b5df343f4e..121151f58f 100644
--- a/target/linux/layerscape/armv7/config-5.15
+++ b/target/linux/layerscape/armv7/config-5.15
@@ -562,7 +562,6 @@ CONFIG_SERIAL_XILINX_PS_UART=y
 CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
 CONFIG_SGL_ALLOC=y
 CONFIG_SG_POOL=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SMP_ON_UP=y
 CONFIG_SMSC_PHY=y
diff --git a/target/linux/layerscape/armv7/config-6.1 
b/target/linux/layerscape/armv7/config-6.1
index 0ff16d346e..d60e5824db 100644
--- a/target/linux/layerscape/armv7/config-6.1
+++ b/target/linux/layerscape/armv7/config-6.1
@@ -580,7 +580,6 @@ CONFIG_SERIAL_XILINX_PS_UART=y
 CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
 CONFIG_SGL_ALLOC=y
 CONFIG_SG_POOL=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SMP_ON_UP=y
 CONFIG_SMSC_PHY=y
@@ -626,7 +625,6 @@ CONFIG_SQUASHFS_ZLIB=y
 CONFIG_SRAM=y
 CONFIG_SRAM_EXEC=y
 CONFIG_SRCU=y
-CONFIG_STACKDEPOT=y
 CONFIG_STACKTRACE=y
 CONFIG_STAGING_BOARD=y
 # CONFIG_STRIP_ASM_SYMS is not set
diff --git a/target/linux/oxnas/config-5.15 b/target/linux/oxnas/config-5.15
index 9540a76774..0cf06ee580 100644
--- a/target/linux/oxnas/config-5.15
+++ b/target/linux/oxnas/config-5.15
@@ -245,7 +245,6 @@ CONFIG_SERIO=y
 CONFIG_SERIO_LIBPS2=y
 CONFIG_SERIO_SERPORT=y
 CONFIG_SGL_ALLOC=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SOCK_DIAG=y
 CONFIG_SPARSE_IRQ=y
 CONFIG_SPLIT_PTLOCK_CPUS=99
diff --git a/target/linux/qoriq/config-5.15 b/target/linux/qoriq/config-5.15
index 3f5fd63ad0..39796daf1d 100644
--- a/target/linux/qoriq/config-5.15
+++ b/target/linux/qoriq/config-5.15
@@ -351,7 +351,6 @@ CONFIG_SERIAL_FSL_LPUART=y
 CONFIG_SERIAL_FSL_LPUART_CONSOLE=y
 CONFIG_SERIAL_MCTRL_GPIO=y
 CONFIG_SG_POOL=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SOCK_RX_QUEUE_MAPPING=y
 CONFIG_SOC_BUS=y
diff --git a/target/linux/rockchip/armv8/config-5.15 
b/target/linux/rockchip/armv8/config-5.15
index 1fc2fcbfb3..54fad098dd 100644
--- a/target/linux/rockchip/armv8/config-5.15
+++ b/target/linux/rockchip/armv8/config-5.15
@@ -528,7 +528,6 @@ CONFIG_SERIO=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIO_LIBPS2=y
 CONFIG_SG_POOL=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SOCK_RX_QUEUE_MAPPING=y
 CONFIG_SPARSEMEM=y
diff --git a/target/linux/rockchip/armv8/config-6.1 
b/target/linux/rockchip/armv8/config-6.1
index 59b343b23b..0f9a89f596 100644
--- a/target/linux/rockchip/armv8/config-6.1
+++ b/target/linux/rockchip/armv8/config-6.1
@@ -570,7 +570,6 @@ CONFIG_SERIO=y
 CONFIG_SERIO_AMBAKMI=y
 CONFIG_SERIO_LIBPS2=y
 CONFIG_SG_POOL=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SOCK_RX_QUEUE_MAPPING=y
 CONFIG_SOFTIRQ_ON_OWN_STACK=y
@@ -594,7 +593,6 @@ CONFIG_SQUASHFS_FILE_CACHE=y
 # CONFIG_SQUASHFS_FILE_DIRECT is not set
 CONFIG_SRAM=y
 CONFIG_SRCU=y
-CONFIG_STACKDEPOT=y
 CONFIG_STACKPROTECTOR=y
 CONFIG_STACKPROTECTOR_PER_TASK=y
 CONFIG_STACKPROTECTOR_STRONG=y
diff --git a/target/linux/sifiveu/config-6.1 b/target/linux/sifiveu/config-6.1
index ee97677d78..2bcbcffeda 100644
--- a/target/linux/sifiveu/config-6.1
+++ b/target/linux/sifiveu/config-6.1
@@ -333,7 +333,6 @@ CONFIG_SERIO_SERPORT=y
 CONFIG_SG_POOL=y
 CONFIG_SIFIVE_CCACHE=y
 CONFIG_SIFIVE_PLIC=y
-CONFIG_SLUB_DEBUG=y
 CONFIG_SMP=y
 CONFIG_SOCK_RX_QUEUE_MAPPING=y
 # CONFIG_SOC_MICROCHIP_POLARFIRE is not set
@@ -348,7 +347,6 @@ CONFIG_SPI_MASTER=y
 CONFIG_SPI_MEM=y
 CONFIG_SPI_SIFIVE=y
 CONFIG_SRCU=y
-CONFIG_STACKDEPOT=y
 CONFIG_STACKTRACE=y
 CONFIG_SWIOTLB=y
 CONFIG_SWPHY=y
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] urngd: fixes compilation with glibc

2023-09-27 Thread Rafał Miłecki

On 16.09.2023 05:55, Chukun Pan wrote:

When compiling with glibc it will result in error:
1. #warning _FORTIFY_SOURCE requires compiling with optimization (-O) 
[-Werror=cpp]
Fix this by compiling with optimization (-O2) by default.

2. jitterentropy-base.c:(.text+0x39f8): undefined reference to `pthread_join'
Fix this by always linking pthread.


Others already said we can't switch to -O2, I'll just add some references.

At some point jitterentropy-library switched from -O0 to -O2:
3130cd99d7fa ("replace LSFR with SHA-3 256")
https://github.com/smuellerDD/jitterentropy-library/commit/3130cd99d7fa308c00cc2c4be6c5aa20c002be56

That was however explicitly changed back later with the:
20184e97af8f ("Compile Jitter RNG without optimizations")
https://github.com/smuellerDD/jitterentropy-library/commit/20184e97af8f227cc0787c4155ff4f3b2b7f1fe3

Also jitterentropy-rngd uses -O0:
f1bc39ae713a ("use -O0")
https://github.com/smuellerDD/jitterentropy-rngd/commit/f1bc39ae713a253077b0c47b4a1ad53f32bbfce0

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] bcm53xx: Unconditionally build U-Boot for DIR-890L

2023-09-04 Thread Rafał Miłecki

On 2023-09-02 18:33, Linus Walleij wrote:

Building the DIR-890L image requires U-Boot to be built
so list it as a device package.

Reported-by: Arınç ÜNAL 
Signed-off-by: Linus Walleij 
---
Missed to enforce U-Boot build. Mea Culpa.
---
 target/linux/bcm53xx/image/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/bcm53xx/image/Makefile
b/target/linux/bcm53xx/image/Makefile
index 39b7efbef789..9483812facca 100644
--- a/target/linux/bcm53xx/image/Makefile
+++ b/target/linux/bcm53xx/image/Makefile
@@ -283,7 +283,7 @@ TARGET_DEVICES += dlink_dir-885l
 define Device/dlink_dir-890l
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DIR-890L
-  DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB2_PACKAGES) 
$(USB3_PACKAGES)

+  DEVICE_PACKAGES := uboot-bcm53xx $(BRCMFMAC_43602A1)
$(USB2_PACKAGES) $(USB3_PACKAGES)
   # Layout: U-boot (128kb max) followed by kernel and appended DTB.
   # This is done because the boot loader will only read the first 2 MB
   # from the flash and decompress the LZMA it finds there after the


This may work as a workaround (I didn't try it) but it doesn't seem like
a proper solution. DEVICE_PACKAGES should be used for listing packages
to be included in device's rootfs.

I don't see anything incorrect with Linus's original patch. Maybe we
just have some dependency handling issue in u-boot generic .mk code?
Is this issue bcm53xx specific? I think other targets use U-Boot in a
similar way.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v3 1/5] bcm53xx: Fix kernel v6.1 config

2023-08-28 Thread Rafał Miłecki

On 19.06.2023 08:36, Linus Walleij wrote:

The v6.1 kernel does not build for me, building with -j1 V=s
reveals that it is prompting for a kernel config option.
I also needed to add CONFIG_MTD_SPLIT_FIRMWARE for splitting
to work.

This make the v6.1 config work nicely as a baseline for my
DIR-890L patches.

Signed-off-by: Linus Walleij 


I've dropped MTD_SPLIT_FIRMWARE for bcm53xx years ago in the commit
d3381b5a6401 ("bcm53xx: request Seama parser on DIR-885L directly").

Is is really needed? Can you explain why? What device needs that
semi-guess-based splitting of the "firmware" partition?

As for CONFIG_ARCH_FORCE_MAX_ORDER it's nice to have kernel refreshed
but I was never queried about it while compiling. Are you sure this was
the NEW symbol?

I had actual problem compiling 6.1 but it was another symbol:
IBM Operation Panel driver (INPUT_IBM_PANEL) [N/m/?] (NEW)

I've sent a fix for that:
[PATCH] kernel: add unset CONFIG_INPUT_IBM_PANEL symbol to config-6.1
https://patchwork.ozlabs.org/project/openwrt/patch/20230826160754.18880-1-zaj...@gmail.com/



---
ChangeLog ->v3:
- New patch to make kernel v6.1 work
---
  target/linux/bcm53xx/config-6.1 | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/target/linux/bcm53xx/config-6.1 b/target/linux/bcm53xx/config-6.1
index d96beb687df0..0ffd90b64d1c 100644
--- a/target/linux/bcm53xx/config-6.1
+++ b/target/linux/bcm53xx/config-6.1
@@ -5,6 +5,7 @@ CONFIG_ARCH_BCM_5301X=y
  CONFIG_ARCH_BCM_53573=y
  # CONFIG_ARCH_BCM_HR2 is not set
  CONFIG_ARCH_BCM_IPROC=y
+CONFIG_ARCH_FORCE_MAX_ORDER=11
  CONFIG_ARCH_HIBERNATION_POSSIBLE=y
  CONFIG_ARCH_KEEP_MEMBLOCK=y
  CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
@@ -207,6 +208,7 @@ CONFIG_MTD_PARSER_TPLINK_SAFELOADER=y
  CONFIG_MTD_PARSER_TRX=y
  CONFIG_MTD_RAW_NAND=y
  CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_SPLIT_FIRMWARE=y
  CONFIG_MTD_SPLIT_SEAMA_FW=y
  CONFIG_MTD_UBI=y
  CONFIG_MTD_UBI_BEB_LIMIT=20



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] kernel: add unset CONFIG_INPUT_IBM_PANEL symbol to config-6.1

2023-08-26 Thread Rafał Miłecki
From: Rafał Miłecki 

This symbol was added by commit 2e6f34faa7e0 ("Input: Add IBM Operation
Panel driver") to v6.1. It depends on I2C so it's available to limited
amount of targets. It needs to be specified thought to allow kernel
configuration.

For bcm53xx this fixes:
IBM Operation Panel driver (INPUT_IBM_PANEL) [N/m/?] (NEW)

Signed-off-by: Rafał Miłecki 
---
 target/linux/generic/config-6.1 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/linux/generic/config-6.1 b/target/linux/generic/config-6.1
index 29aa7292b8..5377c4a793 100644
--- a/target/linux/generic/config-6.1
+++ b/target/linux/generic/config-6.1
@@ -2821,6 +2821,7 @@ CONFIG_INOTIFY_USER=y
 # CONFIG_INPUT_GPIO_ROTARY_ENCODER is not set
 # CONFIG_INPUT_GPIO_TILT_POLLED is not set
 # CONFIG_INPUT_GPIO_VIBRA is not set
+# CONFIG_INPUT_IBM_PANEL is not set
 # CONFIG_INPUT_IDEAPAD_SLIDEBAR is not set
 # CONFIG_INPUT_IMS_PCU is not set
 # CONFIG_INPUT_IQS269A is not set
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] bcm53xx: add nand subtarget

2023-08-20 Thread Rafał Miłecki
niedz., 20 sie 2023 o 20:50 Arınç ÜNAL  napisał(a):
> On 20 August 2023 17:15:51 GMT+03:00, "Rafał Miłecki"  
> wrote:
> >sob., 19 sie 2023 o 17:12 Arınç ÜNAL  napisał(a):
> >> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
> >> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
> >> NAND devices and disable the driver on it.
> >>
> >> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
> >> MAC address without NVMEM_BRCM_NVRAM enabled.
> >
> >Adding a new subtarget just because one driver doesn't work correctly
> >is an overkill.
> >
> >I'll handle that in some simple solution after holidays.
>
> Rafał, you've been aware of this problem and reportedly working on at least 
> diagnosing it for the last 6 months. You did not come up with anything yet. 
> Forgive me if I find it hard to believe that you will come up with a solution 
> in a short amount of time, if that's what you mean by after holidays as I 
> don't know what holidays you're referring to.
>
> In the meantime, there is a good amount of users unable to use the newer 
> OpenWrt versions on the affected devices because of a driver that provides a 
> rather trivial feature. I would like these devices to work again as soon as 
> possible as we've already lost a lot of time.
>
> To have these devices work again, I see these solutions:
>
> - First and the most obvious, fix the driver. I do not know the NVMEM 
> subsystem well enough to do it and am currently not interested to spend time 
> studying it.
>
> - Prevent the driver to read from the flash if NAND flash is detected. Once 
> the underlying cause is fixed, this can then be reverted. Like I stated 
> above, I lack the knowledge to do this.
>
> - This patch. It can be easily reverted in the future when or should the 
> issue be fixed.
>
> - My other patch submitted here that disables the driver for the whole 
> target. Currently, only four devices do not have NAND flash and two of these 
> devices are not set to be compiled anyway. I'd rather prefer this than 
> convoluting OpenWrt with another subtarget. I'd much rather prefer two 
> devices not benefiting the future provided by this driver compared to a lot 
> more devices being unable to boot.
>
> I feel like writing this mail has been a waste of time as lately I've never 
> seen you reply or in any way acknowledge that you've read any of my 
> responses, yet I've done it anyway, at least for the mailing list.

I'm not going to argue I handled it properly. It looked at it once
then forgot it. My maintenance time is very limited and I'm not
denying this.

I assumed holidays end for most people with the end of August. I'm on
a 1-week holiday family trip and I don't have time for development or
hardware for testing.

In my very personal opinion I prefer to leave support for those
devices broken for another week (given it has been 6 months now)
rather than push a (in my opinion) pretty hacky workaround.

-- 
Rafał

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v3 4/5] bcm53xx: dir885/dir890: Tag both partitions as SEAMA

2023-08-20 Thread Rafał Miłecki
pon., 19 cze 2023 o 08:39 Linus Walleij  napisał(a):
> The newly added D-Link DIR-890L also needs to have a seama
> tag on its partition so that it will be split properly by
> mtdsplit.

I'm skipping this one thanks to the
[PATCH] ARM: dts: bcm5301x: Add SEAMA compatibles
(great work, thank you!)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH v3 5/5] bcm53xx: Add network configuration for DIR-890L

2023-08-20 Thread Rafał Miłecki
pon., 19 cze 2023 o 08:39 Linus Walleij  napisał(a):
> This adds the lan/wan default bridge config and also the MAC
> NVRAM read-out for et2.
>
> DIR-885L was missing a default bridge config so I just added
> that too while I was at it.

Why do you need to handle D-Link devices individually at all? Your
code seems to be identical to the default switch case "*)".

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] bcm53xx: add nand subtarget

2023-08-20 Thread Rafał Miłecki
sob., 19 sie 2023 o 17:12 Arınç ÜNAL  napisał(a):
> The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
> causes the devices with NVRAM in NAND to bootloop. Create a subtarget for
> NAND devices and disable the driver on it.
>
> Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve the
> MAC address without NVMEM_BRCM_NVRAM enabled.

Adding a new subtarget just because one driver doesn't work correctly
is an overkill.

I'll handle that in some simple solution after holidays.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [openwrt/openwrt] urngd: update to the latest master

2023-08-19 Thread Rafał Miłecki
pt., 18 sie 2023 o 22:33 Rafał Miłecki  napisał(a):
> I switched back to the latest openwrt-21.02 branch and I hit that random
> issue again. I didn't expect it as I use a pretty recent 5.4 stable
> kernel (5.4.238) which includes random subsystem changes.

It took 5+ hours:

# uname -r
5.4.238

# logread | grep crng
Tue Jun 20 03:20:04 2023 kern.notice kernel: [19818.051866] random:
crng init done

-- 
Rafał

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [openwrt/openwrt] urngd: update to the latest master

2023-08-18 Thread Rafał Miłecki

On 26.07.2023 10:45, Rafał Miłecki wrote:

On 2023-07-25 10:10, Etienne Champetier wrote:

commit c74b5e09e692839b39c8325b5f8dc5f2a3b3896c
Author: Rafał Miłecki 
AuthorDate: Tue Jul 25 09:51:35 2023 +0200

    urngd: update to the latest master


Is urngd still needed/relevant given the 'recent" improvements in
linux random generator ?


Good question. To be honest I hit urng failing to initialize issue while
resolving multiple years-old BCM53753 regressions over last 2-3 weeks.


So before kernel 5.19 I really needed urng for BCM53753. Without urng it
took over 1,5 hour to initialize crng and start dropbear:
[ 6095.816238] crng init done
or:
[ 6158.675813] crng init done

That was related to the 29e170dbaac0 ("dropbear: bump to 2020.79") as
dropbear started using getrandom().


In kernel 5.19 we've received following random subsystem changes:
ac2ab99072cc ("Merge tag 'random-5.19-rc1-for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/crng/random"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac2ab99072cce553c78f326ea22d72856f570d88

For BCM53753 the critical change was commit ff8a8f59c99f ("arm: use
fallback for random_get_entropy() instead of zero"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff8a8f59c99f6a7c656387addc4d9f2247d75077


Those random subsystem changes were later backported to stable kernel
releases (e.g. Linux 5.4.200). So for BCM53573 that may make urng
obsolete but I'm not sure about all other cases.


I switched back to the latest openwrt-21.02 branch and I hit that random
issue again. I didn't expect it as I use a pretty recent 5.4 stable
kernel (5.4.238) which includes random subsystem changes.

# uname -r
5.4.238

# logread | grep urngd
Mon Jun 19 21:50:01 2023 user.err kernel: [6.815077] urngd: jent-rng init 
failed, err: 2

# uptime
 01:24:57 up  3:35,  load average: 0.00, 0.00, 0.00

# ps ww | grep dropbear
 1291 root  1320 S/bin/sh /etc/rc.common /etc/rc.d/S19dropbear boot
 1333 root   912 S/usr/bin/dropbearkey -t ed25519 -f 
/tmp/tmp.lEDhIj/dropbear_ed25519_host_key
 1794 root  1168 Sgrep dropbear

So I say that urngd it still needed.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] bcm53xx: disable NVMEM driver

2023-08-01 Thread Rafał Miłecki

On 2023-08-01 12:42, Arınç ÜNAL wrote:

The NVMEM_BRCM_NVRAM driver won't work properly with NVRAM in NAND. It
causes the devices with NVRAM in NAND, such as ASUS RT-AC88U, to 
bootloop.

Until the driver is fixed, disable it.


Driver works and it useful for non-NAND devices. By disabling it you
regress those devices. Surely this can be handled better.


Disable NVMEM too as the bgmac_bcma driver will hang trying to retrieve 
the

MAC address without NVMEM_BRCM_NVRAM enabled.


This would be nice to fix instead hiding the bug.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] kernel: drop unneeded OpenWrt's fw_devlink hack

2023-07-29 Thread Rafał Miłecki
From: Rafał Miłecki 

It was used to workaround of_platform_populate()-caused issue with
probing devices. It's not needed anymore since we have a proper fix
(code setting OF_POPULATED).

Link: https://github.com/openwrt/openwrt/issues/10232
Ref: 3eebb91317c6 ("kernel: backport proper fix for mtd preventing devices 
probing")
Signed-off-by: Rafał Miłecki 
---
 ...vert-driver-core-Set-fw_devlink-on-b.patch | 30 ---
 ...vert-driver-core-Set-fw_devlink-on-b.patch | 30 ---
 2 files changed, 60 deletions(-)
 delete mode 100644 
target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
 delete mode 100644 
target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch

diff --git 
a/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
 
b/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
deleted file mode 100644
index 4f4d6c7509..00
--- 
a/target/linux/generic/hack-5.15/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
-Date: Tue, 19 Jul 2022 06:17:48 +0200
-Subject: [PATCH] Revert "Revert "Revert "driver core: Set fw_devlink=on by
- default"""
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This reverts commit ea718c699055c8566eb64432388a04974c43b2ea.
-
-With of_platform_populate() called for MTD partitions that commit breaks
-probing devices which reference MTD in device tree.
-
-Link: 
https://lore.kernel.org/all/696cb2da-20b9-b3dd-46d9-de4bf91a1...@gmail.com/T/#u
-Signed-off-by: Rafał Miłecki 

- drivers/base/core.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 a/drivers/base/core.c
-+++ b/drivers/base/core.c
-@@ -1562,7 +1562,7 @@ static void device_links_purge(struct de
- #define FW_DEVLINK_FLAGS_RPM  (FW_DEVLINK_FLAGS_ON | \
-DL_FLAG_PM_RUNTIME)
- 
--static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON;
-+static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
- static int __init fw_devlink_setup(char *arg)
- {
-   if (!arg)
diff --git 
a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
 
b/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
deleted file mode 100644
index 98081c4b64..00
--- 
a/target/linux/generic/hack-6.1/930-Revert-Revert-Revert-driver-core-Set-fw_devlink-on-b.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
-Date: Tue, 19 Jul 2022 06:17:48 +0200
-Subject: [PATCH] Revert "Revert "Revert "driver core: Set fw_devlink=on by
- default"""
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This reverts commit ea718c699055c8566eb64432388a04974c43b2ea.
-
-With of_platform_populate() called for MTD partitions that commit breaks
-probing devices which reference MTD in device tree.
-
-Link: 
https://lore.kernel.org/all/696cb2da-20b9-b3dd-46d9-de4bf91a1...@gmail.com/T/#u
-Signed-off-by: Rafał Miłecki 

- drivers/base/core.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
 a/drivers/base/core.c
-+++ b/drivers/base/core.c
-@@ -1700,7 +1700,7 @@ static void device_links_purge(struct de
- #define FW_DEVLINK_FLAGS_RPM  (FW_DEVLINK_FLAGS_ON | \
-DL_FLAG_PM_RUNTIME)
- 
--static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON;
-+static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_PERMISSIVE;
- static int __init fw_devlink_setup(char *arg)
- {
-   if (!arg)
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] mediatek: filogic: use fixed layout cell "mac-base" for Xiaomi WR30U

2023-07-28 Thread Rafał Miłecki
From: Rafał Miłecki 

Cc: Hank Moretti 
Cc: Hauke Mehrtens 
Signed-off-by: Rafał Miłecki 
---
Hank: can you runtime test this, please?
---
 .../dts/mt7981b-xiaomi-mi-router-wr30u.dtsi | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi 
b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
index 9467b18a7e..4f8c3046d2 100644
--- a/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
+++ b/target/linux/mediatek/dts/mt7981b-xiaomi-mi-router-wr30u.dtsi
@@ -73,9 +73,8 @@
reg = <0>;
phy-mode = "2500base-x";
 
-   nvmem-cells = <_factory_4>;
+   nvmem-cells = <_factory_4 (-1)>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(-1)>;
 
fixed-link {
speed = <2500>;
@@ -177,12 +176,16 @@
reg = <0x18 0x20>;
read-only;
 
-   compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
 
-   macaddr_factory_4: macaddr@4 {
-   reg = <0x4 0x6>;
+   macaddr_factory_4: macaddr@4 {
+   compatible = "mac-base";
+   reg = <0x4 0x6>;
+   #nvmem-cell-cells = <1>;
+   };
};
};
 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] ramips: replace "mac-address-ascii" with "mac-base"

2023-07-28 Thread Rafał Miłecki

On 2023-07-28 09:51, Arınç ÜNAL wrote:

I am late to this so I just wanted to say thanks for doing this. We're
one step closer to mainlining the DTs of the MT7621 SoC devices.


Thanks for kind words! :)

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [openwrt/openwrt] urngd: update to the latest master

2023-07-26 Thread Rafał Miłecki

On 2023-07-25 10:10, Etienne Champetier wrote:

commit c74b5e09e692839b39c8325b5f8dc5f2a3b3896c
Author: Rafał Miłecki 
AuthorDate: Tue Jul 25 09:51:35 2023 +0200

urngd: update to the latest master


Is urngd still needed/relevant given the 'recent" improvements in
linux random generator ?


Good question. To be honest I hit urng failing to initialize issue while
resolving multiple years-old BCM53753 regressions over last 2-3 weeks.


So before kernel 5.19 I really needed urng for BCM53753. Without urng it
took over 1,5 hour to initialize crng and start dropbear:
[ 6095.816238] crng init done
or:
[ 6158.675813] crng init done

That was related to the 29e170dbaac0 ("dropbear: bump to 2020.79") as
dropbear started using getrandom().


In kernel 5.19 we've received following random subsystem changes:
ac2ab99072cc ("Merge tag 'random-5.19-rc1-for-linus' of
git://git.kernel.org/pub/scm/linux/kernel/git/crng/random"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac2ab99072cce553c78f326ea22d72856f570d88

For BCM53753 the critical change was commit ff8a8f59c99f ("arm: use
fallback for random_get_entropy() instead of zero"):
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ff8a8f59c99f6a7c656387addc4d9f2247d75077


Those random subsystem changes were later backported to stable kernel
releases (e.g. Linux 5.4.200). So for BCM53573 that may make urng
obsolete but I'm not sure about all other cases.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] firmware-utils: add required PKG_BUILD_DEPENDS

2023-07-20 Thread Rafał Miłecki

On 1.06.2023 17:40, Rafał Miłecki wrote:

From: Rafał Miłecki 

This project provides a lot of independent utils. Most of them don't
depend on SSL (or zlib). Build process however compiles all of them
including those few that require SSL/ZLIB.

To make copmilation step always succeed it's needed to specify build
time dependencies.

Runtime dependencies will be handled per-package (if we ever package one
of those needing SSL/ZLIB).

This fixes:
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the 
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY 
OPENSSL_INCLUDE_DIR)
CMake Error at CMakeLists.txt:9 (MESSAGE):
   Unable to find zlib library.


While I like my own commit description a lot ;) this PATCH been
obsoleted by the

commit 6f607ba043cdc996cd113b8dc25b6965dc1d9a41
Author: Tianling Shen 
Date:   Thu Jun 1 17:35:16 2023 +0800

firmware-utils: add missing build dependencies

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH RESEND] ath79: replace "mac-address-ascii" with "mac-base"

2023-07-20 Thread Rafał Miłecki
From: Rafał Miłecki 

With upstream accepted "mac-base" binding there is no need for a
downstream "mac-address-ascii" workaround anymore.

Signed-off-by: Rafał Miłecki 
---
RESEND: I originally CC-ed 13 people and ML stopped my e-mail
---
 .../ath79/dts/ar7161_dlink_dir-825-b1.dts | 57 +++
 .../linux/ath79/dts/ar9331_hiwifi_hc6361.dts  | 37 ++--
 .../linux/ath79/dts/ar9342_zyxel_nwa11xx.dtsi | 28 +
 .../linux/ath79/dts/ar9344_dlink_dir-8x5.dtsi | 42 --
 .../ath79/dts/qca9558_dlink_dir-629-a1.dts| 32 +++
 .../ath79/dts/qca9563_dlink_dir-8x9-a1.dtsi   | 31 ++
 6 files changed, 134 insertions(+), 93 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts 
b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts
index 0e39be7d0b..bdb678298d 100644
--- a/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts
+++ b/target/linux/ath79/dts/ar7161_dlink_dir-825-b1.dts
@@ -139,8 +139,8 @@
ath9k0: wifi@0,11 {
compatible = "pci168c,0029";
reg = <0x8800 0 0 0 0>;
-   nvmem-cells = <_lan>, <_art_1000>;
-   nvmem-cell-names = "mac-address-ascii", "calibration";
+   nvmem-cells = <_lan 0>, <_art_1000>;
+   nvmem-cell-names = "mac-address", "calibration";
#gpio-cells = <2>;
gpio-controller;
};
@@ -148,9 +148,8 @@
ath9k1: wifi@0,12 {
compatible = "pci168c,0029";
reg = <0x9000 0 0 0 0>;
-   nvmem-cells = <_wan>, <_art_5000>;
-   nvmem-cell-names = "mac-address-ascii", "calibration";
-   mac-address-increment = <1>;
+   nvmem-cells = <_wan 1>, <_art_5000>;
+   nvmem-cell-names = "mac-address", "calibration";
#gpio-cells = <2>;
gpio-controller;
};
@@ -191,23 +190,31 @@
label = "caldata";
reg = <0x66 0x01>;
read-only;
-   #address-cells = <1>;
-   #size-cells = <1>;
 
-   cal_art_1000: cal@1000 {
-   reg = <0x1000 0xeb8>;
-   };
-
-   cal_art_5000: cal@5000 {
-   reg = <0x5000 0xeb8>;
-   };
-
-   macaddr_lan: macaddr@ffa0 {
-   reg = <0xffa0 0x11>;
-   };
-
-   macaddr_wan: macaddr@ffb4 {
-   reg = <0xffb4 0x11>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cal_art_1000: cal@1000 {
+   reg = <0x1000 0xeb8>;
+   };
+
+   cal_art_5000: cal@5000 {
+   reg = <0x5000 0xeb8>;
+   };
+
+   macaddr_lan: macaddr@ffa0 {
+   compatible = "mac-base";
+   reg = <0xffa0 0x11>;
+   #nvmem-cell-cells = <1>;
+   };
+
+   macaddr_wan: macaddr@ffb4 {
+   compatible = "mac-base";
+   reg = <0xffb4 0x11>;
+   #nvmem-cell-cells = <1>;
+   };
};
};
 
@@ -224,8 +231,8 @@
 
pll-data = <0x 0x1099 0x00991099>;
 
-   nvmem-cells = <_lan>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_lan 0>;
+   nvmem-cell-names = "mac-address";
 
fixed-link {
speed = <1000>;
@@ -238,8 +245,8 @@
 
pll-data = <0x 0x1099 0x00991099>;
 
-   nvmem-cells = <_wan>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_wan 0>;
+   nvmem-cell-names

[PATCH urngd] jitterentropy-rngd: update to the v1.2.0

2023-07-20 Thread Rafał Miłecki
From: Rafał Miłecki 

74104b2 update copyright date
1b5f34b integrate library v3.0.0
8a43ce4 Fix permissions set by systemd unit file
f995407 force the kernel to reseed the ChaCha20 DRNG
4104015 force reseed after 10 minutes
9d61de7 jitterentropy-rngd.1: spelling
739bcba Add Dockerfile and docker-compose.yaml for easy deployment.
cc8c38c Harden systemd service

Signed-off-by: Rafał Miłecki 
---
 3rdparty/jitterentropy-rngd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/3rdparty/jitterentropy-rngd b/3rdparty/jitterentropy-rngd
index cb13a8b..74104b2 16
--- a/3rdparty/jitterentropy-rngd
+++ b/3rdparty/jitterentropy-rngd
@@ -1 +1 @@
-Subproject commit cb13a8b136afe9e1ea1424e9e3fb50c87a6be729
+Subproject commit 74104b218442d9b9049249e6d1b132db564b77da
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] octeon: use fixed layout cell "mac-base" for Cisco vEdge 1000

2023-07-17 Thread Rafał Miłecki
From: Rafał Miłecki 

This drops a use of downstream "mac-address-increment".

Cc: Christian Svensson 
Cc: Tommy Nevtelen 
Cc: Viktor Ekmark 
Cc: Daniel Wennberg 
Signed-off-by: Rafał Miłecki 
---
I didn't have a chance to try "fixed-layout" with "atmel,24c512". This
is untested.

Can you guys verify if reading MAC still works with this patch, please?
---
 .../cavium-octeon/cn6130_cisco_vedge1000.dts  | 40 +--
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git 
a/target/linux/octeon/files/arch/mips/boot/dts/cavium-octeon/cn6130_cisco_vedge1000.dts
 
b/target/linux/octeon/files/arch/mips/boot/dts/cavium-octeon/cn6130_cisco_vedge1000.dts
index e1f308dd52..4680d6ea14 100644
--- 
a/target/linux/octeon/files/arch/mips/boot/dts/cavium-octeon/cn6130_cisco_vedge1000.dts
+++ 
b/target/linux/octeon/files/arch/mips/boot/dts/cavium-octeon/cn6130_cisco_vedge1000.dts
@@ -24,7 +24,7 @@
  <0x11800 0xe0002000 0x00 0x08>;
cell-index = <0x00>;
interrupts = <0x00 0x3e 0x01 0x2e>;
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 0>;
nvmem-cell-names = "mac-address";
phy-handle = <>;
};
@@ -32,25 +32,22 @@
pip: pip@11800a000 {
interface@0 {
ethernet@0 {
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 3>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(3)>;
label = "lan2";
/delete-property/ local-mac-address;
};
 
ethernet@1 {
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 4>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(4)>;
label = "lan3";
/delete-property/ local-mac-address;
};
 
ethernet@2 {
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 1>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(1)>;
label = "lan0";
/delete-property/ local-mac-address;
};
@@ -58,9 +55,8 @@
ethernet@3 {
compatible = 
"cavium,octeon-3860-pip-port";
reg = <0x3>;
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 2>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(2)>;
label = "lan1";
};
};
@@ -69,36 +65,32 @@
ethernet@0 {
compatible = 
"cavium,octeon-3860-pip-port";
reg = <0x0>;
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 7>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(7)>;
label = "lan6";
};
 
ethernet@1 {
compatible = 
"cavium,octeon-3860-pip-port";
reg = <0x1>;
-   nvmem-cells = <_eeprom>;
+   nvmem-cells = <_eeprom 8>;
nvmem-cell-names = "mac-address";
-   mac-address-increment = <(8)>;
label = "lan7";
};
 
et

Re: [PATCH] ramips: set Netgear R6220 MAC NVMEM cell directly in the part node

2023-07-14 Thread Rafał Miłecki

On 2023-07-14 11:57, Felix Baumann wrote:
Am 14. Juli 2023 10:26:33 MESZ schrieb "Rafał Miłecki" 
:

On 9.05.2023 18:21, Felix Baumann wrote:
Am 9. Mai 2023 15:29:48 MESZ schrieb "Rafał Miłecki" 
:

From: Rafał Miłecki 

There is no need to use reference if original node it specified in
exactly the same file. This is a minor cleanup simplifying DTS code.

Signed-off-by: Rafał Miłecki 
---
.../linux/ramips/dts/mt7621_netgear_r6220.dts  | 18 
--

1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/target/linux/ramips/dts/mt7621_netgear_r6220.dts 
b/target/linux/ramips/dts/mt7621_netgear_r6220.dts

index 0f476ef060..7bb49c15b4 100644
--- a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
+++ b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
@@ -42,9 +42,17 @@
};

factory: partition@2e0 {


The "factory" reference could be probably be dropped as well. 
Proposed changes look good to me.


Actually it can't be dropped. While it's a bit counter-intuitive, that
label is used in a *parent* DTS file mt7621_netgear_sercomm_ayx.dtsi .


Hello Rafał,

I was under the strong impression that dts(i) files could only get
reference from the same file or parents but not childs. I remember
reading a few exchanges by Ansuel, I think, that mentioned this.
I might be mixing two topics here, but was this (intended to be) fixed
by dynamic partitions or something like that?

Are you certain the eeprom is loaded successfully?

Aren't dts(i) files read from top to bottom?


I just verified that and it works.

First I decompiled .dtb from the latest "master" branch with:
dtc -I dtb -O dts -o r6220.dts 
build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/image-mt7621_netgear_r6220.dtb


Then I opened r6220.dts and analyzed it.

My MAC cell looks like this:

macaddr@4 {
compatible = "mac-base";
reg = <0x04 0x06>;
#nvmem-cell-cells = <0x01>;
phandle = <0x13>;
};


Then my Ethernet controller nodes look like that:

mac@0 {
compatible = "mediatek,eth-mac";
reg = <0x00>;
nvmem-cells = <0x13 0x00>;
nvmem-cell-names = "mac-address";
(...)
};

mac@1 {
compatible = "mediatek,eth-mac";
reg = <0x01>;
status = "okay";
nvmem-cells = <0x13 0x01>;
nvmem-cell-names = "mac-address";
(...)
};

As you can see both reference phandle 0x13 so that looks all good.

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] ramips: replace "mac-address-ascii" with "mac-base"

2023-07-14 Thread Rafał Miłecki
From: Rafał Miłecki 

With upstream accepted "mac-base" binding there is no need for a
downstream "mac-address-ascii" workaround anymore.

Signed-off-by: Rafał Miłecki 
---
 .../dts/mt7621_raisecom_msg1500-x-00.dts  | 32 ++---
 .../ramips/dts/mt7621_tplink_ec330-g5u-v1.dts | 34 +++
 2 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts 
b/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts
index 5d713c0098..07297df083 100644
--- a/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts
+++ b/target/linux/ramips/dts/mt7621_raisecom_msg1500-x-00.dts
@@ -82,15 +82,23 @@
read-only;
 
compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   macaddr_config_8014: macaddr@8014 {
-   reg = <0x8014 0x11>;
-   };
 
-   macaddr_config_8036: macaddr@8036 {
-   reg = <0x8036 0x11>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_config_8014: macaddr@8014 {
+   compatible = "mac-base";
+   reg = <0x8014 0x11>;
+   #nvmem-cell-cells = <1>;
+   };
+
+   macaddr_config_8036: macaddr@8036 {
+   compatible = "mac-base";
+   reg = <0x8036 0x11>;
+   #nvmem-cell-cells = <1>;
+   };
};
};
 
@@ -137,8 +145,8 @@
 };
 
  {
-   nvmem-cells = <_config_8014>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_config_8014 0>;
+   nvmem-cell-names = "mac-address";
 };
 
  {
@@ -146,8 +154,8 @@
label = "wan";
phy-handle = <>;
 
-   nvmem-cells = <_config_8036>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_config_8036 0>;
+   nvmem-cell-names = "mac-address";
 };
 
  {
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 6c9cc40701..537b6f70a7 100644
--- a/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts
+++ b/target/linux/ramips/dts/mt7621_tplink_ec330-g5u-v1.dts
@@ -230,12 +230,20 @@
read-only;
 
compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
 
-   macaddr_factory_165: macaddr@165 {
-   reg = <0x165 0x11>;
+   nvmem-layout {
+   compatible = "fixed-layout";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_factory_165: macaddr@165 {
+   compatible = "mac-base";
+   reg = <0x165 0x11>;
+   #nvmem-cell-cells = <1>;
+   };
};
+
+
};
 
partition@0_wholeflash {
@@ -257,8 +265,8 @@
mediatek,mtd-eeprom = < 0x8000>;
ieee80211-freq-limit = <240 250>;
 
-   nvmem-cells = <_factory_165>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_factory_165 0>;
+   nvmem-cell-names = "mac-address";
};
 };
 
@@ -269,15 +277,14 @@
mediatek,mtd-eeprom = < 0x14000>;
ieee80211-freq-limit = <500 600>;
 
-   nvmem-cells = <_factory_165>;
-   nvmem-cell-names = "mac-address-ascii";
-   mac-address-increment = <(2)>;
+   nvmem-cells = <_factory_165 2>;
+   nvmem-cell-names = "mac-address";
};
 };
 
  {
-   nvmem-cells = <_factory_165>;
-   nvmem-cell-names = "mac-address-ascii";
+   nvmem-cells = <_factory_165 0>;
+   nvmem-cell-names = "mac-address";
 };
 
  {
@@ -285,9 +292,8 @@
label = "wan";
phy-handle = <>;
 
-   nvmem-cells = <_factory_165>;
-   nvmem-cell-names = "mac-address-ascii";
-   mac-address-increment = <(1)>;
+   nvmem-cells = <_factory_165 1>;
+   nvmem-cell-names = "mac-address";
 };
 
  {
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] ramips: set Netgear R6220 MAC NVMEM cell directly in the part node

2023-07-14 Thread Rafał Miłecki

On 9.05.2023 18:21, Felix Baumann wrote:

Am 9. Mai 2023 15:29:48 MESZ schrieb "Rafał Miłecki" :

From: Rafał Miłecki 

There is no need to use reference if original node it specified in
exactly the same file. This is a minor cleanup simplifying DTS code.

Signed-off-by: Rafał Miłecki 
---
.../linux/ramips/dts/mt7621_netgear_r6220.dts  | 18 --
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/target/linux/ramips/dts/mt7621_netgear_r6220.dts 
b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
index 0f476ef060..7bb49c15b4 100644
--- a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
+++ b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
@@ -42,9 +42,17 @@
};

factory: partition@2e0 {


The "factory" reference could be probably be dropped as well. Proposed changes 
look good to me.


Actually it can't be dropped. While it's a bit counter-intuitive, that
label is used in a *parent* DTS file mt7621_netgear_sercomm_ayx.dtsi .



+   compatible = "nvmem-cells";
label = "factory";
reg = <0x2e0 0x10>;
read-only;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_factory_4: macaddr@4 {
+   reg = <0x4 0x6>;
+   };
};

partition@420 {
@@ -65,13 +73,3 @@
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
};
-
- {
-   compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   macaddr_factory_4: macaddr@4 {
-   reg = <0x4 0x6>;
-   };
-};
--
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH firmware-utils] bcmclm: new tool for reading Broadcom's CLM data

2023-06-21 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom developed CLM format for devices vendors to provide regulatory
configuration independently of executable firmware. They contain info
about countries, channels and rates.

CLM data can be packaged with chipset info as CLM BLOB and uploaded to
FullMAC firmware for complete channel support and maximum transmission
power.

CLM binary format is a bit tricky. It consists of a lot of binary
structs with all kind of numbers and flags. In-file addresses of those
structs and then stored in parent structs.

This tool provides initial support for reading CLM data content. It
parses the root struct and follows info lower level structs.

Signed-off-by: Rafał Miłecki 
---
 CMakeLists.txt |   1 +
 src/bcmclm.c   | 337 +
 2 files changed, 338 insertions(+)
 create mode 100644 src/bcmclm.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31e0a06..2d27227 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,7 @@ FW_UTIL(avm-wasp-checksum "" --std=gnu99 "")
 FW_UTIL(bcm4908asus "" "" "")
 FW_UTIL(bcm4908kernel "" "" "")
 FW_UTIL(bcmblob "" "" "")
+FW_UTIL(bcmclm "" "" "")
 FW_UTIL(buffalo-enc src/buffalo-lib.c "" "")
 FW_UTIL(buffalo-tag src/buffalo-lib.c "" "")
 FW_UTIL(buffalo-tftp src/buffalo-lib.c "" "")
diff --git a/src/bcmclm.c b/src/bcmclm.c
new file mode 100644
index 000..ac8eacf
--- /dev/null
+++ b/src/bcmclm.c
@@ -0,0 +1,337 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2023 Rafał Miłecki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if !defined(__BYTE_ORDER)
+#error "Unknown byte order"
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_to_le32(x) bswap_32(x)
+#define le32_to_cpu(x) bswap_32(x)
+#define cpu_to_be32(x) (x)
+#define be32_to_cpu(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define cpu_to_le32(x) (x)
+#define le32_to_cpu(x) (x)
+#define cpu_to_be32(x) bswap_32(x)
+#define be32_to_cpu(x) bswap_32(x)
+#else
+#error "Unsupported endianness"
+#endif
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
+#define BCMCLM_MAGIC   "CLM DATA"
+
+/* Raw data */
+
+struct bcmclm_header {
+   char magic[8];
+   uint32_t unk0;
+   uint8_t unk1[2];
+   char api[20];
+   char compiler[10];
+   uint32_t virtual_header_address;
+   uint32_t lookup_table_address;
+   char clm_import_ver[30];
+   char manufacturer[22];
+};
+
+struct bcmclm_lookup_table {
+   uint32_t offset0;
+   uint32_t offset1;
+   uint32_t offset2;
+   uint32_t offset3;
+   uint32_t offset4;
+   uint32_t offset5;
+   uint32_t offset6;
+   uint32_t offset7;
+   uint32_t offset8;
+   uint32_t offset9;
+   uint32_t offset10;
+   uint32_t offset11;
+   uint32_t offset12;
+   uint32_t offset13;
+   uint32_t offset14;
+   uint32_t offset15;
+   uint32_t offset16;
+   uint32_t offset17;
+   uint32_t offset18;
+   uint32_t offset19;
+   uint32_t offset20;
+   uint32_t offset21;
+   uint32_t offset22;
+   uint32_t offset23;
+   uint32_t offset_creation_date;
+   uint32_t offset25;
+   uint32_t offset26;
+   uint32_t offset27;
+   uint32_t offset28;
+   uint32_t offset29;
+   uint32_t offset30;
+   uint32_t offset31;
+   uint32_t offset32;
+   uint32_t offset33;
+   uint32_t offset34;
+   uint32_t offset35;
+   uint32_t offset36;
+   uint32_t offset37;
+   uint32_t offset38;
+   uint32_t offset39;
+   uint32_t offset40;
+   uint32_t offset41;
+   uint32_t offset42;
+   uint32_t offset43;
+   uint32_t offset44;
+   uint32_t offset45;
+   uint32_t offset46;
+   uint32_t offset47;
+};
+
+/* Parsed info */
+
+struct bcmclm_info {
+   struct bcmclm_header header;
+   struct bcmclm_lookup_table lookup_table;
+   size_t file_size;
+   size_t clm_offset;
+   size_t offsets_fixup;
+};
+
+static inline size_t bcmclm_min(size_t x, size_t y)
+{
+   return x < y ? x : y;
+}
+
+/**
+ * Helpers
+ **/
+
+static FILE *bcmclm_open(const char *pathname, const char *mode)
+{
+   struct stat st;
+
+   if (pathname)
+   return fopen(pathname, mode);
+
+   if (isatty(fileno(stdin))) {
+   fprintf(stderr, "Reading from TTY stdin is unsupported\n");
+   return NULL;
+   }
+
+   if (fstat(fileno(stdin), )) {
+   fprintf(stderr, "Failed to fstat stdin: %d\n", -errno);
+   return NULL;
+ 

[PATCH firmware-utils] bcmblob: new tool for reading Broadcom's BLOBs

2023-06-12 Thread Rafał Miłecki
From: Rafał Miłecki 

Broadcom designed its BLOB binary format for storing multiple binary
entries in a single file. It's mostly know from CLM BLOB files that are
used for storing regulatory data and chip model.

Signed-off-by: Rafał Miłecki 
---
 CMakeLists.txt |   1 +
 src/bcmblob.c  | 455 +
 2 files changed, 456 insertions(+)
 create mode 100644 src/bcmblob.c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b70226..31e0a06 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,7 @@ FW_UTIL(asustrx "" "" "")
 FW_UTIL(avm-wasp-checksum "" --std=gnu99 "")
 FW_UTIL(bcm4908asus "" "" "")
 FW_UTIL(bcm4908kernel "" "" "")
+FW_UTIL(bcmblob "" "" "")
 FW_UTIL(buffalo-enc src/buffalo-lib.c "" "")
 FW_UTIL(buffalo-tag src/buffalo-lib.c "" "")
 FW_UTIL(buffalo-tftp src/buffalo-lib.c "" "")
diff --git a/src/bcmblob.c b/src/bcmblob.c
new file mode 100644
index 000..f11a8a5
--- /dev/null
+++ b/src/bcmblob.c
@@ -0,0 +1,455 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2023 Rafał Miłecki 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if !defined(__BYTE_ORDER)
+#error "Unknown byte order"
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_to_le32(x) bswap_32(x)
+#define le32_to_cpu(x) bswap_32(x)
+#define cpu_to_be32(x) (x)
+#define be32_to_cpu(x) (x)
+#elif __BYTE_ORDER == __LITTLE_ENDIAN
+#define cpu_to_le32(x) (x)
+#define le32_to_cpu(x) (x)
+#define cpu_to_be32(x) bswap_32(x)
+#define be32_to_cpu(x) bswap_32(x)
+#else
+#error "Unsupported endianness"
+#endif
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+
+#define BCMBLOB_MAGIC  "BLOB"
+
+/* Raw data */
+
+struct bcmblob_entry {
+   uint32_t unk0;
+   uint32_t offset;
+   uint32_t size;
+   uint32_t crc32;
+   uint32_t unk1;
+};
+
+struct bcmblob_header {
+   char magic[4];
+   uint32_t hdr_len;
+   uint32_t crc32;
+   uint32_t unk0;
+   uint32_t unk1;
+   struct bcmblob_entry entries[2];
+};
+
+/* Parsed info */
+
+struct bcmblob_entry_info {
+   struct bcmblob_entry header;
+   size_t offset;
+   size_t size;
+   uint32_t crc32;
+};
+
+struct bcmblob_info {
+   struct bcmblob_header header;
+   struct bcmblob_entry_info entries[2];
+   size_t file_size;
+   uint32_t crc32;
+};
+
+static inline size_t bcmblob_min(size_t x, size_t y)
+{
+   return x < y ? x : y;
+}
+
+/**
+ * CRC32
+ **/
+
+static const uint32_t crc32_tbl[] = {
+   0x, 0x77073096, 0xee0e612c, 0x990951ba,
+   0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
+   0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+   0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+   0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
+   0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+   0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
+   0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
+   0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+   0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
+   0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
+   0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+   0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
+   0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+   0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+   0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
+   0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
+   0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+   0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+   0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
+   0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+   0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
+   0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
+   0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+   0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
+   0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
+   0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+   0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
+   0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+   0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+   0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
+   0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
+   0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+   0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+   0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
+   0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+   0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
+   0

[PATCH] firmware-utils: add required PKG_BUILD_DEPENDS

2023-06-01 Thread Rafał Miłecki
From: Rafał Miłecki 

This project provides a lot of independent utils. Most of them don't
depend on SSL (or zlib). Build process however compiles all of them
including those few that require SSL/ZLIB.

To make copmilation step always succeed it's needed to specify build
time dependencies.

Runtime dependencies will be handled per-package (if we ever package one
of those needing SSL/ZLIB).

This fixes:
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the 
system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY 
OPENSSL_INCLUDE_DIR)
CMake Error at CMakeLists.txt:9 (MESSAGE):
  Unable to find zlib library.

Reported-by: Hauke Mehrtens 
Signed-off-by: Rafał Miłecki 
---
 package/utils/firmware-utils/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/utils/firmware-utils/Makefile 
b/package/utils/firmware-utils/Makefile
index f49cca01bb..2f77d001ff 100644
--- a/package/utils/firmware-utils/Makefile
+++ b/package/utils/firmware-utils/Makefile
@@ -11,6 +11,8 @@ PKG_SOURCE_DATE:=2023-05-18
 PKG_SOURCE_VERSION:=02cdbc6a4d61605c008efef09162f772f553fcde
 
PKG_MIRROR_HASH:=f5188fc38bb03ddbcc34763ff049597e2d8af98c0854910dc87f10e5927096e2
 
+PKG_BUILD_DEPENDS:=openssl zlib
+
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] firmware-utils: package xiaomifw

2023-05-29 Thread Rafał Miłecki
From: Rafał Miłecki 

It's needed to revert back to Xiaomi original firmware.

Signed-off-by: Rafał Miłecki 
---
 package/utils/firmware-utils/Makefile | 8 
 1 file changed, 8 insertions(+)

diff --git a/package/utils/firmware-utils/Makefile 
b/package/utils/firmware-utils/Makefile
index f49cca01bb..644aa69274 100644
--- a/package/utils/firmware-utils/Makefile
+++ b/package/utils/firmware-utils/Makefile
@@ -35,5 +35,13 @@ define Package/otrx/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/
 endef
 
+Package/xiaomifw = $(call Package/default,xiaomifw,@TARGET_ramips)
+
+define Package/xiaomifw/install
+   $(INSTALL_DIR) $(1)/usr/bin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/xiaomifw $(1)/usr/bin/
+endef
+
 $(eval $(call BuildPackage,oseama))
 $(eval $(call BuildPackage,otrx))
+$(eval $(call BuildPackage,xiaomifw))
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 1/2] firmware-utils: new package replacing otrx

2023-05-22 Thread Rafał Miłecki
From: Rafał Miłecki 

Some of firmware utils may be required on target devices. It's useful
e.g. for dealing with some firmware formats. That is often required
(supporting specific format) to provide an option to revert to original
firmware.

So far we had packaged "otrx" util only for use on Broadcom targets.
Refactor that to package the whole firmware-utils project so we can
package any single util needed.

Signed-off-by: Rafał Miłecki 
---
 package/utils/firmware-utils/Makefile | 31 ++
 package/utils/otrx/Makefile   | 46 ---
 2 files changed, 31 insertions(+), 46 deletions(-)
 create mode 100644 package/utils/firmware-utils/Makefile
 delete mode 100644 package/utils/otrx/Makefile

diff --git a/package/utils/firmware-utils/Makefile 
b/package/utils/firmware-utils/Makefile
new file mode 100644
index 00..78cbea4bd1
--- /dev/null
+++ b/package/utils/firmware-utils/Makefile
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=firmware-utils
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git
+PKG_SOURCE_DATE:=2023-05-18
+PKG_SOURCE_VERSION:=02cdbc6a4d61605c008efef09162f772f553fcde
+PKG_MIRROR_HASH:=f5188fc38bb03ddbcc34763ff049597e2d8af98c0854910dc87f10e5927096e2
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/default
+  SECTION:=utils
+  CATEGORY:=Base system
+  TITLE:=Firmware utility $(1)
+  DEPENDS:=$(2)
+endef
+
+Package/otrx = $(call Package/default,otrx,@(TARGET_bcm47xx||TARGET_bcm53xx))
+
+define Package/otrx/install
+   $(INSTALL_DIR) $(1)/usr/bin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,otrx))
diff --git a/package/utils/otrx/Makefile b/package/utils/otrx/Makefile
deleted file mode 100644
index 35c59e2730..00
--- a/package/utils/otrx/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (C) 2015 Rafał Miłecki 
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=otrx
-PKG_RELEASE:=1
-
-PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git
-PKG_SOURCE_DATE:=2021-12-02
-PKG_SOURCE_VERSION:=56e8e19151743c923f48604c457850cf8eb52076
-PKG_MIRROR_HASH:=2a40ac73e8eab0a7a4474cb331b8e2fc972635314b0b5e02a9f2b9a32c5d5f3b
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/otrx
-  SECTION:=utils
-  CATEGORY:=Base system
-  TITLE:=Utility for opening (analyzing) TRX firmware images
-  MAINTAINER:=Rafał Miłecki 
-  DEPENDS:=@(TARGET_bcm47xx||TARGET_bcm53xx)
-endef
-
-define Package/otrx/description
- This package contains an utility that allows validating TRX images.
-endef
-
-TARGET_CFLAGS += -Wall
-
-define Build/Compile
-   $(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) \
-   -o $(PKG_BUILD_DIR)/otrx \
-   $(PKG_BUILD_DIR)/src/otrx.c
-endef
-
-define Package/otrx/install
-   $(INSTALL_DIR) $(1)/usr/bin
-   $(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/
-endef
-
-$(eval $(call BuildPackage,otrx))
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH 2/2] firmware-utils: package oseama

2023-05-22 Thread Rafał Miłecki
From: Rafał Miłecki 

It's required by bcm53xx. This allows dropping separated oseama package
and avoids some code duplication.

Signed-off-by: Rafał Miłecki 
---
 package/utils/firmware-utils/Makefile |   8 +
 package/utils/oseama/Makefile |  40 --
 package/utils/oseama/src/Makefile |   7 -
 package/utils/oseama/src/md5.c| 296 --
 package/utils/oseama/src/md5.h|  45 ---
 package/utils/oseama/src/oseama.c | 556 --
 6 files changed, 8 insertions(+), 944 deletions(-)
 delete mode 100644 package/utils/oseama/Makefile
 delete mode 100644 package/utils/oseama/src/Makefile
 delete mode 100644 package/utils/oseama/src/md5.c
 delete mode 100644 package/utils/oseama/src/md5.h
 delete mode 100644 package/utils/oseama/src/oseama.c

diff --git a/package/utils/firmware-utils/Makefile 
b/package/utils/firmware-utils/Makefile
index 78cbea4bd1..f49cca01bb 100644
--- a/package/utils/firmware-utils/Makefile
+++ b/package/utils/firmware-utils/Makefile
@@ -21,6 +21,13 @@ define Package/default
   DEPENDS:=$(2)
 endef
 
+Package/oseama = $(call Package/default,oseama,@TARGET_bcm53xx)
+
+define Package/oseama/install
+   $(INSTALL_DIR) $(1)/usr/bin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/oseama $(1)/usr/bin/
+endef
+
 Package/otrx = $(call Package/default,otrx,@(TARGET_bcm47xx||TARGET_bcm53xx))
 
 define Package/otrx/install
@@ -28,4 +35,5 @@ define Package/otrx/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/otrx $(1)/usr/bin/
 endef
 
+$(eval $(call BuildPackage,oseama))
 $(eval $(call BuildPackage,otrx))
diff --git a/package/utils/oseama/Makefile b/package/utils/oseama/Makefile
deleted file mode 100644
index 7d9303b92d..00
--- a/package/utils/oseama/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (C) 2016 Rafał Miłecki 
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=oseama
-PKG_RELEASE:=1
-
-PKG_FLAGS:=nonshared
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/oseama
-  SECTION:=utils
-  CATEGORY:=Base system
-  TITLE:=Utility for handling Seama firmware images
-  MAINTAINER:=Rafał Miłecki 
-  DEPENDS:=@TARGET_bcm53xx
-endef
-
-define Package/oseama/description
- This package contains an utility that allows handling Seama images.
-endef
-
-define Build/Compile
-   $(MAKE) -C $(PKG_BUILD_DIR) \
-   CC="$(TARGET_CC)" \
-   CFLAGS="$(TARGET_CFLAGS) -Wall"
-endef
-
-define Package/oseama/install
-   $(INSTALL_DIR) $(1)/usr/bin
-   $(INSTALL_BIN) $(PKG_BUILD_DIR)/oseama $(1)/usr/bin/
-endef
-
-$(eval $(call BuildPackage,oseama))
diff --git a/package/utils/oseama/src/Makefile 
b/package/utils/oseama/src/Makefile
deleted file mode 100644
index ca35e6ee99..00
--- a/package/utils/oseama/src/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all: oseama
-
-oseama:
-   $(CC) $(CFLAGS) -Wall oseama.c md5.c -o $@ $^
-
-clean:
-   rm -f oseama
diff --git a/package/utils/oseama/src/md5.c b/package/utils/oseama/src/md5.c
deleted file mode 100644
index 52d96accd3..00
--- a/package/utils/oseama/src/md5.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
- * MD5 Message-Digest Algorithm (RFC 1321).
- *
- * Homepage:
- * 
http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
- *
- * Author:
- * Alexander Peslyak, better known as Solar Designer 
- *
- * This software was written by Alexander Peslyak in 2001.  No copyright is
- * claimed, and the software is hereby placed in the public domain.
- * In case this attempt to disclaim copyright and place the software in the
- * public domain is deemed null and void, then the software is
- * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
- * general public under the following terms:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted.
- *
- * There's ABSOLUTELY NO WARRANTY, express or implied.
- *
- * (This is a heavily cut-down "BSD license".)
- *
- * This differs from Colin Plumb's older public domain implementation in that
- * no exactly 32-bit integer data type is required (any 32-bit or wider
- * unsigned integer data type will do), there's no compile-time endianness
- * configuration, and the function prototypes match OpenSSL's.  No code from
- * Colin Plumb's implementation has been reused; this comment merely compares
- * the properties of the two independent implementations.
- *
- * The primary goals of this implementation are portability and ease of use.
- * It is meant to be fast, but not as fast as possible.  Some known
- * optimizations are not included to reduce source code size and avoid
- * compile-time configuration.
- */
-
-#ifndef HAVE_OPENSSL
-
-#include 
-
-#include "md5.h"
-
-/*
- * The basic MD5 functions.
- *
- * F a

[PATCH] mac80211: brcm: drop brcmfmac patch waiting for register_wiphy()

2023-05-17 Thread Rafał Miłecki
From: Rafał Miłecki 

That was a workaround for OpenWrt generation of config files. This patch
was used to postpone returning from probe function until loading
firmware and calling register_wiphy().

All of that is not needed anymore thanks to the ieee80211 hotplug.d
script introduced in the commit 5f8f8a366136 ("base-files, mac80211,
broadcom-wl: wifi detection and configuration"). That takes care of
generating /etc/config/wireless entries even if wireless device appears
late in the booting process.

Signed-off-by: Rafał Miłecki 
---
 package/kernel/mac80211/Makefile  |  2 +-
 ...-register-wiphy-s-during-module_init.patch | 64 ---
 2 files changed, 1 insertion(+), 65 deletions(-)
 delete mode 100644 
package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch

diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index 02cf715d8e..077bc0cba6 100644
--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 PKG_NAME:=mac80211
 
 PKG_VERSION:=6.1.24
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 # PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/
 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
 PKG_HASH:=5d39aca7e34c33cb9b3e366117b2e86841b7bdd37933679d6b1e61be6b150648
diff --git 
a/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch
 
b/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch
deleted file mode 100644
index 9d0f3e20b1..00
--- 
a/package/kernel/mac80211/patches/brcm/860-brcmfmac-register-wiphy-s-during-module_init.patch
+++ /dev/null
@@ -1,64 +0,0 @@
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= 
-Date: Mon, 8 Jun 2015 16:11:40 +0200
-Subject: [PATCH] brcmfmac: register wiphy(s) during module_init
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This is needed by OpenWrt which expects all PHYs to be created after
-module loads successfully.
-
-Signed-off-by: Rafał Miłecki 

-
 a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
-+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
-@@ -459,6 +459,7 @@ struct brcmf_fw {
-   u32 curpos;
-   unsigned int board_index;
-   void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
-+  struct completion *completion;
- };
- 
- #ifdef CONFIG_EFI
-@@ -686,6 +687,8 @@ static void brcmf_fw_request_done(const
-   fwctx->req = NULL;
-   }
-   fwctx->done(fwctx->dev, ret, fwctx->req);
-+  if (fwctx->completion)
-+  complete(fwctx->completion);
-   kfree(fwctx);
- }
- 
-@@ -751,6 +754,8 @@ int brcmf_fw_get_firmwares(struct device
- {
-   struct brcmf_fw_item *first = >items[0];
-   struct brcmf_fw *fwctx;
-+  struct completion completion;
-+  unsigned long time_left;
-   char *alt_path = NULL;
-   int ret;
- 
-@@ -768,6 +773,9 @@ int brcmf_fw_get_firmwares(struct device
-   fwctx->dev = dev;
-   fwctx->req = req;
-   fwctx->done = fw_cb;
-+ 
-+  init_completion();
-+  fwctx->completion = 
- 
-   /* First try alternative board-specific path if any */
-   if (fwctx->req->board_types[0])
-@@ -787,6 +795,12 @@ int brcmf_fw_get_firmwares(struct device
-   if (ret < 0)
-   brcmf_fw_request_done(NULL, fwctx);
- 
-+
-+  time_left = wait_for_completion_timeout(,
-+  msecs_to_jiffies(5000));
-+  if (!time_left && fwctx)
-+  fwctx->completion = NULL;
-+
-   return 0;
- }
- 
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH 4/4] bcm53xx: Add network configuration for DIR-890L

2023-05-15 Thread Rafał Miłecki

On 2023-05-13 23:21, Linus Walleij wrote:

This adds the lan/wan default bridge config and also the MAC
NVRAM read-out for et2.

DIR-885L was missing a default bridge config so I just added
that too while I was at it.


It seems that D-Link DIR-890L in its DTS file already has "et0macaddr"
specified and "gmac2" referencing it. So I think bgmac should read MAC
on its own and no user space extra code should be needed.

That should work starting with the commit 4ab27bc6efee ("kernel:
backport NVMEM patch for Broadcom's NVRAM MAC cells").

Can you test that, please?



Signed-off-by: Linus Walleij 
---
 target/linux/bcm53xx/base-files/etc/board.d/02_network | 5 +
 1 file changed, 5 insertions(+)

diff --git a/target/linux/bcm53xx/base-files/etc/board.d/02_network
b/target/linux/bcm53xx/base-files/etc/board.d/02_network
index 6bec600540ea..35b1efc91323 100644
--- a/target/linux/bcm53xx/base-files/etc/board.d/02_network
+++ b/target/linux/bcm53xx/base-files/etc/board.d/02_network
@@ -16,6 +16,10 @@ bcm53xx_setup_interfaces()
asus,rt-ac88u)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 extsw" "wan"
;;
+   dlink,dir-885l | \
+   dlink,dir-890l)
+   ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
+   ;;
dlink,dwl-8610ap)
ucidef_set_interface_lan "eth0 eth1" "dhcp"
;;
@@ -50,6 +54,7 @@ bcm53xx_setup_macs()
offset=1
;;
dlink,dir-885l | \
+   dlink,dir-890l | \
linksys,panamera | \
netgear,r7900 | \
netgear,r8000 | \


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] ramips: set Netgear R6220 MAC NVMEM cell directly in the part node

2023-05-09 Thread Rafał Miłecki
From: Rafał Miłecki 

There is no need to use reference if original node it specified in
exactly the same file. This is a minor cleanup simplifying DTS code.

Signed-off-by: Rafał Miłecki 
---
 .../linux/ramips/dts/mt7621_netgear_r6220.dts  | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/target/linux/ramips/dts/mt7621_netgear_r6220.dts 
b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
index 0f476ef060..7bb49c15b4 100644
--- a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
+++ b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
@@ -42,9 +42,17 @@
};
 
factory: partition@2e0 {
+   compatible = "nvmem-cells";
label = "factory";
reg = <0x2e0 0x10>;
read-only;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   macaddr_factory_4: macaddr@4 {
+   reg = <0x4 0x6>;
+   };
};
 
partition@420 {
@@ -65,13 +73,3 @@
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
 };
-
- {
-   compatible = "nvmem-cells";
-   #address-cells = <1>;
-   #size-cells = <1>;
-
-   macaddr_factory_4: macaddr@4 {
-   reg = <0x4 0x6>;
-   };
-};
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] ramips: add NVMEM cells with Netgear R6220 wifi EEPROMs

2023-05-09 Thread Rafał Miłecki

On 2023-05-09 15:06, Sander Vanheule wrote:

Hi Rafał,

On Mon, 2023-05-08 at 18:02 +0200, Rafał Miłecki wrote:

From: Rafał Miłecki 

This allows reading EEPROMs using NVMEM interface.


OK, but why do you need to do that though? Some userspace application?


The main purpose of DTS files is to describe hardware. Bindings are
meant to be system agnostic. Each system can use them the way it needs.
So just because OpenWrt won't use those doesn't really matter.

Of course I'm happy to share my plans. In long term I mean to use those
NVMEM cells to let wireless devices reference it. So wireless drivers
can use them for reading EEPROM / calibration data.



Signed-off-by: Rafał Miłecki 
---
 target/linux/ramips/dts/mt7621_netgear_r6220.dts | 13 +
 1 file changed, 13 insertions(+)

diff --git a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
index 0f476ef060..2ebe58ca63 100644
--- a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
+++ b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
@@ -42,9 +42,22 @@
};
 
factory: partition@2e0 {
+   compatible = "nvmem-cells";
label = "factory";
reg = <0x2e0 0x10>;
read-only;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x2e0 0x10>;
+
+   eeprom0: eeprom@0 {
+   reg = <0x0 0x400>;
+   };
+
+   eeprom1: eeprom@8000 {
+   reg = <0x8000 0x200>;
+   };


You're adding labels to these new nodes, but there aren't any 
references.


Right, I should drop them.


This all seemed a bit off, so I also looked at the full DTS. There's 
already an
nvmem-cells 'extension' of  at the end of the file, with 
macaddr@4

overlapping with the new eeprom@0 node.


It's fishy indeed. There is no need to add anything to the
partition@2e0 node using its reference. It should be put directly
in that node.


Maybe I'm just missing some context here, but this patch doesn't make 
much sense

to me.


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[PATCH] ramips: add NVMEM cells with Netgear R6220 wifi EEPROMs

2023-05-08 Thread Rafał Miłecki
From: Rafał Miłecki 

This allows reading EEPROMs using NVMEM interface.

Signed-off-by: Rafał Miłecki 
---
 target/linux/ramips/dts/mt7621_netgear_r6220.dts | 13 +
 1 file changed, 13 insertions(+)

diff --git a/target/linux/ramips/dts/mt7621_netgear_r6220.dts 
b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
index 0f476ef060..2ebe58ca63 100644
--- a/target/linux/ramips/dts/mt7621_netgear_r6220.dts
+++ b/target/linux/ramips/dts/mt7621_netgear_r6220.dts
@@ -42,9 +42,22 @@
};
 
factory: partition@2e0 {
+   compatible = "nvmem-cells";
label = "factory";
reg = <0x2e0 0x10>;
read-only;
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x2e0 0x10>;
+
+   eeprom0: eeprom@0 {
+   reg = <0x0 0x400>;
+   };
+
+   eeprom1: eeprom@8000 {
+   reg = <0x8000 0x200>;
+   };
};
 
partition@420 {
-- 
2.35.3


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


  1   2   3   4   5   6   7   8   9   10   >