Re: [LEDE-DEV] [PATCH v3 3/4] base-files, mac80211, broadcom-wl: wifi detection and configuration

2016-10-18 Thread Christian Lamparter
On Tuesday, October 18, 2016 11:31:54 AM CEST Felix Fietkau wrote:
> On 2016-10-17 15:59, Christian Lamparter wrote:
> > 
> > Acked-by: Jo-Philipp Wich 
> > Signed-off-by: Mathias Kresin 
> > Signed-off-by: Christian Lamparter 
> Added to my staging tree with a small modification:
> I added a check for detect and made it no-op, just in case existing user
> scripts still use it, because the default case might trigger some
> unwanted actions.
Thanks! 

I know that Mathias has a extra change for ramips queued up as well [0].
As for these patches, does anyone have a brcm47xx and mvebu? Because I
think we can move the remaining scripts as well.

Regards,
Christian

[0] 

 


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH v3 3/4] base-files, mac80211, broadcom-wl: wifi detection and configuration

2016-10-18 Thread Felix Fietkau
On 2016-10-17 15:59, Christian Lamparter wrote:
> Currently, the wifi detection script is executed as part of
> the (early) boot process. Pluggable wifi USB devices, which
> are inserted at a later time are not automatically
> detected and therefore they don't show up in LuCI.
> 
> A user has to deal with wifi detection manually, or restart
> the router.
> 
> However, the current "sleep 1" window - which the boot
> process waits for wifi devices to "settle down" - is too
> short to detect wifi devices for some routers anyway.
> 
> For example, this can happen with USB WLAN devices on the
> WNDR4700. This is because the usb controller needs to load
> its firmware from UBI and initialize, before it can operate.
> 
> The issue can be seen on a BT HomeHub 5A as well as soon as
> the caldata are on an ubi volume. This is because the ath9k
> card has to be initialized by owl-loader first. Which has to
> wait for the firmware extraction script to retrieve the pci
> initialization values inside the caldata.
> 
> This patch moves the wifi configuration to hotplug scripts.
> For mac80211, the wifi configuration will now automatically
> run any time a "ieee80211" device is added. Likewise
> broadcom-wl's script checks for new "net" devices which
> have the "wl$NUMBER" moniker.
> 
> Issues with spawning multiple interface configuration - in
> case the detection script is run concurrently - have been
> resolved by using a named section for the initial
> configuration. Concurrent configuration scripts will now
> simply overwrite the same existing configuration.
> 
> A workaround which preserves the "sleep 1" window for just
> the first boot has been added. This allows the existing
> brcm47xx boot and mvebu uci-default scripts to correctly
> setup the initial mac addresses and regulatory domain.
> 
> And finally, the patch renames the "wifi detect" into
> "wifi config". As the script no longer produces any output
> that has to be redirected or appended to the configuration
> file.
> 
> Thanks to Martin Blumenstingl for helping with the implementation
> and testing of the patch.
> 
> Acked-by: Jo-Philipp Wich 
> Signed-off-by: Mathias Kresin 
> Signed-off-by: Christian Lamparter 
Added to my staging tree with a small modification:
I added a check for detect and made it no-op, just in case existing user
scripts still use it, because the default case might trigger some
unwanted actions.

- Felix

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v3 3/4] base-files, mac80211, broadcom-wl: wifi detection and configuration

2016-10-17 Thread Christian Lamparter
Currently, the wifi detection script is executed as part of
the (early) boot process. Pluggable wifi USB devices, which
are inserted at a later time are not automatically
detected and therefore they don't show up in LuCI.

A user has to deal with wifi detection manually, or restart
the router.

However, the current "sleep 1" window - which the boot
process waits for wifi devices to "settle down" - is too
short to detect wifi devices for some routers anyway.

For example, this can happen with USB WLAN devices on the
WNDR4700. This is because the usb controller needs to load
its firmware from UBI and initialize, before it can operate.

The issue can be seen on a BT HomeHub 5A as well as soon as
the caldata are on an ubi volume. This is because the ath9k
card has to be initialized by owl-loader first. Which has to
wait for the firmware extraction script to retrieve the pci
initialization values inside the caldata.

This patch moves the wifi configuration to hotplug scripts.
For mac80211, the wifi configuration will now automatically
run any time a "ieee80211" device is added. Likewise
broadcom-wl's script checks for new "net" devices which
have the "wl$NUMBER" moniker.

Issues with spawning multiple interface configuration - in
case the detection script is run concurrently - have been
resolved by using a named section for the initial
configuration. Concurrent configuration scripts will now
simply overwrite the same existing configuration.

A workaround which preserves the "sleep 1" window for just
the first boot has been added. This allows the existing
brcm47xx boot and mvebu uci-default scripts to correctly
setup the initial mac addresses and regulatory domain.

And finally, the patch renames the "wifi detect" into
"wifi config". As the script no longer produces any output
that has to be redirected or appended to the configuration
file.

Thanks to Martin Blumenstingl for helping with the implementation
and testing of the patch.

Acked-by: Jo-Philipp Wich 
Signed-off-by: Mathias Kresin 
Signed-off-by: Christian Lamparter 

---
All changes to base-files, mac80211 and broadcom-wl packages
have been integrated into a single patch to play nice with
git bisect.

v1 -> v2:
- filter for broadcom devices (Mathias)
- integrate uci changes (no more /tmp/wireless.tmp)
- move locking to detect_mac80211 and detect_broadcom

v2 -> v3:
- used another method to add a new wifi-iface instance,
  that doesn't need any additional locking.
- renamed "wifi detect" into "wifi config".
  The documentation (uci_wireless.html) is updated in
  a separate patch to web.git.
- wait on first boot for the wireless configuration to
  be in place for brcm47xx and mvebu.
---
 package/base-files/files/etc/init.d/boot  | 8 
 package/base-files/files/sbin/wifi| 4 ++--
 .../broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect   | 5 +
 package/kernel/mac80211/Makefile  | 2 ++
 package/kernel/mac80211/files/mac80211.hotplug| 5 +
 5 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 
package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect
 create mode 100644 package/kernel/mac80211/files/mac80211.hotplug

diff --git a/package/base-files/files/etc/init.d/boot 
b/package/base-files/files/etc/init.d/boot
index 03b0fa0..31f245f 100755
--- a/package/base-files/files/etc/init.d/boot
+++ b/package/base-files/files/etc/init.d/boot
@@ -38,10 +38,10 @@ boot() {
 
/sbin/kmodloader
 
-   # allow wifi modules time to settle
-   sleep 1
-
-   /sbin/wifi detect
+   [ ! -f /etc/config/wireless ] && {
+   # compat for brcm47xx and mvebu
+   sleep 1
+   }
 
/bin/config_generate
uci_apply_defaults
diff --git a/package/base-files/files/sbin/wifi 
b/package/base-files/files/sbin/wifi
index 2ef333a..c41058f 100755
--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -145,7 +145,7 @@ wifi_reload() {
wifi_reload_legacy
 }
 
-wifi_detect() {
+wifi_config() {
[ ! -f /etc/config/wireless ] && touch /etc/config/wireless
 
for driver in $DRIVERS; do (
@@ -229,7 +229,7 @@ scan_wifi
 
 case "$1" in
down) wifi_updown "disable" "$2";;
-   detect) wifi_detect ;;
+   config) wifi_config ;;
status) ubus_wifi_cmd "status" "$2";;
reload) wifi_reload "$2";;
reload_legacy) wifi_reload_legacy "$2";;
diff --git 
a/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect 
b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect
new file mode 100644
index 000..ba011dc
--- /dev/null
+++ b/package/kernel/broadcom-wl/files/etc/hotplug.d/net/00-broadcom-wifi-detect
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+[ "${ACTION}" = "add" ] && [ "${INTERFACE%%[0-9]}" = "wl" ]