From patchwork Mon Oct 17 13:59:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 682988 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syKdc4cbYz9sQw for ; Tue, 18 Oct 2016 01:02:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=Atvixb1p; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bw8SR-0005j4-2R; Mon, 17 Oct 2016 14:00:03 +0000 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bw8S6-0005MI-29 for lede-dev@lists.infradead.org; Mon, 17 Oct 2016 13:59:45 +0000 Received: by mail-qt0-x241.google.com with SMTP id g49so6271168qtc.2 for ; Mon, 17 Oct 2016 06:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6YslnITisgimtl6eoSlzEr6UPdDxbgcz0XxemxINojM=; b=Atvixb1pRsymbnsFsfjmF3tw6eW6c+BQWMEnEaZrSkzHu5p4uQV81yPKLKWNn3HoPw utG2vhHQLuDHoRiyGwaP2DEkuho38iIMjBxXzYD4AzKLdbrG3NlFL1e6j3jmqmT6OqBf U+zCNxXfiLw0wCkGyHimowAG52MJCeXRwBXEGwLfsImQhSamcUy6mZ+zTyCiFW2V07+i WPF3nxJaxCSjazJqu67vH0dJlOZQdwojHFzNhq7piwWSIqswJLdvaed9Ly6uHvBQtpzC 7SOiDGtmriPJy92EFPikqufz6uPOZDCyp0acR2SytH2SRkcrtN7uz46fFdYSej2SpwPv ZTiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=6YslnITisgimtl6eoSlzEr6UPdDxbgcz0XxemxINojM=; b=M+E42hAIJqVGxGO7KS9JFuZM5HGRw60R0QhzpAaY2tnH9oCpS7KFTzORKSBUCKbP2t vvLnGhy4AkMZtdcBT5oRUm6B783o5QGMZiC31d9yo42sl0yykIOzYJyPkQIeuLBgzMgM 1llDqBS+StqH41ClnqEuKBjvO9QO7k4pFtjcaLoWaA1h3JLLcvC3lvM2nWWJq8N59XIm eUq14yDkqjBcbVAJtR2EbzDipsu/hmEehYCAtLr9TmgPWsClMgBmJjuemgDrD+MRfCpz IPyoyiTX+McUwq9ea2GNUH2kA/+ShAvGYcOomHvET3fWLl6wdPyvD5G4NqQa+DxLNokR 2CJw== X-Gm-Message-State: AA6/9RmG3LpfPkIv90hmAFCGLEdP8IE0OR8l2iX/QIYuPdfHOYTy+Kwz8t7jhrmPgTggCw== X-Received: by 10.28.207.3 with SMTP id f3mr8681045wmg.15.1476712758944; Mon, 17 Oct 2016 06:59:18 -0700 (PDT) Received: from debian64.daheim (pD9F882B9.dip0.t-ipconnect.de. [217.248.130.185]) by smtp.gmail.com with ESMTPSA id o1sm53433753wjh.9.2016.10.17.06.59.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Oct 2016 06:59:18 -0700 (PDT) From: Christian Lamparter X-Google-Original-From: Christian Lamparter Received: from chuck by debian64.daheim with local (Exim 4.87) (envelope-from ) id 1bw8Rg-00047p-UH; Mon, 17 Oct 2016 15:59:16 +0200 To: lede-dev@lists.infradead.org Date: Mon, 17 Oct 2016 15:59:14 +0200 Message-Id: <69d9e911ac3b6230bc88d2cd05ed759d243a0aca.1476631806.git.chunkeey@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <4f69ed95593be50265c586c8f4be50ca3eca885c.1476631806.git.chunkeey@gmail.com> References: <4f69ed95593be50265c586c8f4be50ca3eca885c.1476631806.git.chunkeey@gmail.com> In-Reply-To: <4f69ed95593be50265c586c8f4be50ca3eca885c.1476631806.git.chunkeey@gmail.com> References: <4f69ed95593be50265c586c8f4be50ca3eca885c.1476631806.git.chunkeey@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161017_065942_335178_2430221C X-CRM114-Status: GOOD ( 19.81 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400d:c0d:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (chunkeey[at]googlemail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [PATCH v3 3/4] base-files, mac80211, broadcom-wl: wifi detection and configuration X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , Jo-Philipp Wich , Matthias Schiffer , Mathias Kresin , Jonas Gorski MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 0000000..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" ] && { + /sbin/wifi config +} diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile index f9f5093..25adbfb 100644 --- a/package/kernel/mac80211/Makefile +++ b/package/kernel/mac80211/Makefile @@ -1732,6 +1732,8 @@ define KernelPackage/cfg80211/install $(INSTALL_DIR) $(1)/lib/wifi $(1)/lib/netifd/wireless $(INSTALL_DATA) ./files/lib/wifi/mac80211.sh $(1)/lib/wifi $(INSTALL_BIN) ./files/lib/netifd/wireless/mac80211.sh $(1)/lib/netifd/wireless + $(INSTALL_DIR) $(1)/etc/hotplug.d/ieee80211 + $(INSTALL_DATA) ./files/mac80211.hotplug $(1)/etc/hotplug.d/ieee80211/00-wifi-detect endef define KernelPackage/ipw2100/install diff --git a/package/kernel/mac80211/files/mac80211.hotplug b/package/kernel/mac80211/files/mac80211.hotplug new file mode 100644 index 0000000..b865552 --- /dev/null +++ b/package/kernel/mac80211/files/mac80211.hotplug @@ -0,0 +1,5 @@ +#!/bin/sh + +[ "${ACTION}" = "add" ] && { + /sbin/wifi config +}