ucentral: development update

* make BTLE work on several devices
* update ucentral-schema
* update ucentral-client
* make cBPF work
* update mac80211
* update usteer

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-07-08 11:05:23 +02:00
parent 8d8af8c59a
commit 670bc9d2e2
15 changed files with 782 additions and 22 deletions

View File

@@ -0,0 +1,45 @@
From 6c7e11cccbd28224a9a473a36df1102b4257d356 Mon Sep 17 00:00:00 2001
From: DENG Qingfang <dqfext@gmail.com>
Date: Fri, 9 Apr 2021 12:25:08 +0800
Subject: [PATCH 5/6] kernel/modules: move act_gact into kmod-sched-core
As the name suggests, act_gact has the generic actions such as dropping
and accepting packets, so move it into kmod-sched-core.
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
package/kernel/linux/modules/netsupport.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk
index 9fd49c1392..4343e850e9 100644
--- a/package/kernel/linux/modules/netsupport.mk
+++ b/package/kernel/linux/modules/netsupport.mk
@@ -721,7 +721,7 @@ $(eval $(call KernelPackage,mppe))
SCHED_MODULES = $(patsubst $(LINUX_DIR)/net/sched/%.ko,%,$(wildcard $(LINUX_DIR)/net/sched/*.ko))
-SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc sch_htb sch_tbf cls_basic cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_mirred act_skbedit cls_matchall
+SCHED_MODULES_CORE = sch_ingress sch_fq_codel sch_hfsc sch_htb sch_tbf cls_basic cls_fw cls_route cls_flow cls_tcindex cls_u32 em_u32 act_gact act_mirred act_skbedit cls_matchall
SCHED_MODULES_FILTER = $(SCHED_MODULES_CORE) act_connmark act_ctinfo sch_cake sch_netem sch_mqprio em_ipset cls_bpf cls_flower act_bpf act_vlan
SCHED_MODULES_EXTRA = $(filter-out $(SCHED_MODULES_FILTER),$(SCHED_MODULES))
SCHED_FILES = $(patsubst %,$(LINUX_DIR)/net/sched/%.ko,$(filter $(SCHED_MODULES_CORE),$(SCHED_MODULES)))
@@ -745,6 +745,7 @@ define KernelPackage/sched-core
CONFIG_NET_CLS_ROUTE4 \
CONFIG_NET_CLS_TCINDEX \
CONFIG_NET_CLS_U32 \
+ CONFIG_NET_ACT_GACT \
CONFIG_NET_ACT_MIRRED \
CONFIG_NET_ACT_SKBEDIT \
CONFIG_NET_CLS_MATCHALL \
@@ -899,7 +900,6 @@ define KernelPackage/sched
CONFIG_NET_SCH_FQ \
CONFIG_NET_SCH_PIE \
CONFIG_NET_ACT_POLICE \
- CONFIG_NET_ACT_GACT \
CONFIG_NET_ACT_IPT \
CONFIG_NET_ACT_PEDIT \
CONFIG_NET_ACT_SIMP \
--
2.25.1

View File

@@ -1,7 +1,7 @@
From 943d9c1ac5834d572273eef7db8fcec474943e91 Mon Sep 17 00:00:00 2001
From ac6ed6e4e7ddaf831347530f12631ad6aaf058fe Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Thu, 27 May 2021 13:25:03 +0200
Subject: [PATCH 02/36] mac80211: update to latest HEAD
Subject: [PATCH 01/40] mac80211: update to latest HEAD
Signed-off-by: John Crispin <john@phrozen.org>
---
@@ -74,6 +74,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
...port-to-configure-SAE-PWE-value-to-d.patch | 74 ++
...-get_default_func-move-default-flow-.patch | 2 +-
...add-rx-decapsulation-offload-support.patch | 26 +-
...le-QoS-support-for-nl80211-ctrl-port.patch | 116 +++
...320-mac80211_hwsim-add-6GHz-channels.patch | 123 +++
...211_hwsim-make-6-GHz-channels-usable.patch | 74 ++
...-remove-legacy-minstrel-rate-control.patch | 2 +-
@@ -86,8 +87,9 @@ Signed-off-by: John Crispin <john@phrozen.org>
...te-control-support-for-encap-offload.patch | 119 +++
...11-minstrel_ht-fix-sample-time-check.patch | 23 +
...iwlwifi-specific-workaround-that-bro.patch | 51 ++
...rting-aggregation-sessions-on-mesh-i.patch | 112 +++
.../500-mac80211_configure_antenna_gain.patch | 24 +-
82 files changed, 1546 insertions(+), 1338 deletions(-)
84 files changed, 1774 insertions(+), 1338 deletions(-)
delete mode 100644 package/kernel/mac80211/files/lib/netifd/mac80211.sh
create mode 100644 package/kernel/mac80211/mac80211.sh.diff
delete mode 100644 package/kernel/mac80211/patches/ath/560-ath9k-fix-transmitting-to-stations-in-dynamic-SMPS-m.patch
@@ -140,6 +142,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
delete mode 100644 package/kernel/mac80211/patches/subsys/131-Revert-mac80211-aes-cmac-switch-to-shash-CMAC-driver.patch
delete mode 100644 package/kernel/mac80211/patches/subsys/132-mac80211-remove-cmac-dependency.patch
create mode 100644 package/kernel/mac80211/patches/subsys/302-cfg80211-Add-support-to-configure-SAE-PWE-value-to-d.patch
create mode 100644 package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch
create mode 100644 package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch
create mode 100644 package/kernel/mac80211/patches/subsys/321-mac80211_hwsim-make-6-GHz-channels-usable.patch
create mode 100644 package/kernel/mac80211/patches/subsys/353-mac80211-minstrel_ht-fix-MINSTREL_FRAC-macro.patch
@@ -150,6 +153,7 @@ Signed-off-by: John Crispin <john@phrozen.org>
create mode 100644 package/kernel/mac80211/patches/subsys/376-mac80211-add-rate-control-support-for-encap-offload.patch
create mode 100644 package/kernel/mac80211/patches/subsys/377-mac80211-minstrel_ht-fix-sample-time-check.patch
create mode 100644 package/kernel/mac80211/patches/subsys/378-mac80211-remove-iwlwifi-specific-workaround-that-bro.patch
create mode 100644 package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch
diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index f6ad06452f..dd39c2d069 100644
@@ -3411,6 +3415,128 @@ index 09407f3b1d..b8bb2930f5 100644
* if it was previously present.
* Also, frames with less than 16 bytes are dropped.
*/
diff --git a/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch b/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch
new file mode 100644
index 0000000000..4be011ffec
--- /dev/null
+++ b/package/kernel/mac80211/patches/subsys/316-mac80211-enable-QoS-support-for-nl80211-ctrl-port.patch
@@ -0,0 +1,116 @@
+From: Markus Theil <markus.theil@tu-ilmenau.de>
+Date: Sat, 6 Feb 2021 12:51:12 +0100
+Subject: [PATCH] mac80211: enable QoS support for nl80211 ctrl port
+
+This patch unifies sending control port frames
+over nl80211 and AF_PACKET sockets a little more.
+
+Before this patch, EAPOL frames got QoS prioritization
+only when using AF_PACKET sockets.
+
+__ieee80211_select_queue only selects a QoS-enabled queue
+for control port frames, when the control port protocol
+is set correctly on the skb. For the AF_PACKET path this
+works, but the nl80211 path used ETH_P_802_3.
+
+Another check for injected frames in wme.c then prevented
+the QoS TID to be copied in the frame.
+
+In order to fix this, get rid of the frame injection marking
+for nl80211 ctrl port and set the correct ethernet protocol.
+
+Please note:
+An erlier version of this path tried to prevent
+frame aggregation for control port frames in order to speed up
+the initial connection setup a little. This seemed to cause
+issues on my older Intel dvm-based hardware, and was therefore
+removed again. Future commits which try to reintroduce this
+have to check carefully how hw behaves with aggregated and
+non-aggregated traffic for the same TID.
+My NIC: Intel(R) Centrino(R) Ultimate-N 6300 AGN, REV=0x74
+
+Reported-by: kernel test robot <lkp@intel.com>
+Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
+Link: https://lore.kernel.org/r/20210206115112.567881-1-markus.theil@tu-ilmenau.de
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+---
+
+--- a/net/mac80211/status.c
++++ b/net/mac80211/status.c
+@@ -628,16 +628,12 @@ static void ieee80211_report_ack_skb(str
+ u64 cookie = IEEE80211_SKB_CB(skb)->ack.cookie;
+ struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_hdr *hdr = (void *)skb->data;
+- __be16 ethertype = 0;
+-
+- if (skb->len >= ETH_HLEN && skb->protocol == cpu_to_be16(ETH_P_802_3))
+- skb_copy_bits(skb, 2 * ETH_ALEN, &ethertype, ETH_TLEN);
+
+ rcu_read_lock();
+ sdata = ieee80211_sdata_from_skb(local, skb);
+ if (sdata) {
+- if (ethertype == sdata->control_port_protocol ||
+- ethertype == cpu_to_be16(ETH_P_PREAUTH))
++ if (skb->protocol == sdata->control_port_protocol ||
++ skb->protocol == cpu_to_be16(ETH_P_PREAUTH))
+ cfg80211_control_port_tx_status(&sdata->wdev,
+ cookie,
+ skb->data,
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1195,9 +1195,7 @@ ieee80211_tx_prepare(struct ieee80211_su
+ tx->sta = rcu_dereference(sdata->u.vlan.sta);
+ if (!tx->sta && sdata->wdev.use_4addr)
+ return TX_DROP;
+- } else if (info->flags & (IEEE80211_TX_INTFL_NL80211_FRAME_TX |
+- IEEE80211_TX_CTL_INJECTED) ||
+- tx->sdata->control_port_protocol == tx->skb->protocol) {
++ } else if (tx->sdata->control_port_protocol == tx->skb->protocol) {
+ tx->sta = sta_info_get_bss(sdata, hdr->addr1);
+ }
+ if (!tx->sta && !is_multicast_ether_addr(hdr->addr1))
+@@ -5421,6 +5419,7 @@ int ieee80211_tx_control_port(struct wip
+ {
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ieee80211_local *local = sdata->local;
++ struct sta_info *sta;
+ struct sk_buff *skb;
+ struct ethhdr *ehdr;
+ u32 ctrl_flags = 0;
+@@ -5443,8 +5442,7 @@ int ieee80211_tx_control_port(struct wip
+ if (cookie)
+ ctrl_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;
+
+- flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX |
+- IEEE80211_TX_CTL_INJECTED;
++ flags |= IEEE80211_TX_INTFL_NL80211_FRAME_TX;
+
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom +
+ sizeof(struct ethhdr) + len);
+@@ -5461,10 +5459,25 @@ int ieee80211_tx_control_port(struct wip
+ ehdr->h_proto = proto;
+
+ skb->dev = dev;
+- skb->protocol = htons(ETH_P_802_3);
++ skb->protocol = proto;
+ skb_reset_network_header(skb);
+ skb_reset_mac_header(skb);
+
++ /* update QoS header to prioritize control port frames if possible,
++ * priorization also happens for control port frames send over
++ * AF_PACKET
++ */
++ rcu_read_lock();
++
++ if (ieee80211_lookup_ra_sta(sdata, skb, &sta) == 0 && !IS_ERR(sta)) {
++ u16 queue = __ieee80211_select_queue(sdata, sta, skb);
++
++ skb_set_queue_mapping(skb, queue);
++ skb_get_hash(skb);
++ }
++
++ rcu_read_unlock();
++
+ /* mutex lock is only needed for incrementing the cookie counter */
+ mutex_lock(&local->mtx);
+
diff --git a/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch b/package/kernel/mac80211/patches/subsys/320-mac80211_hwsim-add-6GHz-channels.patch
new file mode 100644
index 0000000000..a7c09f00bc
@@ -4240,6 +4366,124 @@ index 0000000000..a5ad377e6f
+ skb = dev_alloc_skb(local->hw.extra_tx_headroom + 30);
+ if (!skb)
+ return;
diff --git a/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch b/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch
new file mode 100644
index 0000000000..2ad083f150
--- /dev/null
+++ b/package/kernel/mac80211/patches/subsys/379-mac80211-fix-starting-aggregation-sessions-on-mesh-i.patch
@@ -0,0 +1,112 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Tue, 29 Jun 2021 13:25:09 +0200
+Subject: [PATCH] mac80211: fix starting aggregation sessions on mesh
+ interfaces
+
+The logic for starting aggregation sessions was recently moved from minstrel_ht
+to mac80211, into the subif tx handler just after the sta lookup.
+Unfortunately this didn't work for mesh interfaces, since the sta lookup is
+deferred until a much later point in time on those.
+Fix this by also calling the aggregation check right after the deferred sta
+lookup.
+
+Fixes: 08a46c642001 ("mac80211: move A-MPDU session check from minstrel_ht to mac80211")
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/net/mac80211/tx.c
++++ b/net/mac80211/tx.c
+@@ -1159,6 +1159,29 @@ static bool ieee80211_tx_prep_agg(struct
+ return queued;
+ }
+
++static void
++ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata,
++ struct sta_info *sta,
++ struct sk_buff *skb)
++{
++ struct rate_control_ref *ref = sdata->local->rate_ctrl;
++ u16 tid;
++
++ if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER))
++ return;
++
++ if (!sta || !sta->sta.ht_cap.ht_supported ||
++ !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO ||
++ skb->protocol == sdata->control_port_protocol)
++ return;
++
++ tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
++ if (likely(sta->ampdu_mlme.tid_tx[tid]))
++ return;
++
++ ieee80211_start_tx_ba_session(&sta->sta, tid, 0);
++}
++
+ /*
+ * initialises @tx
+ * pass %NULL for the station if unknown, a valid pointer if known
+@@ -1172,6 +1195,7 @@ ieee80211_tx_prepare(struct ieee80211_su
+ struct ieee80211_local *local = sdata->local;
+ struct ieee80211_hdr *hdr;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
++ bool aggr_check = false;
+ int tid;
+
+ memset(tx, 0, sizeof(*tx));
+@@ -1200,8 +1224,10 @@ ieee80211_tx_prepare(struct ieee80211_su
+ } else if (tx->sdata->control_port_protocol == tx->skb->protocol) {
+ tx->sta = sta_info_get_bss(sdata, hdr->addr1);
+ }
+- if (!tx->sta && !is_multicast_ether_addr(hdr->addr1))
++ if (!tx->sta && !is_multicast_ether_addr(hdr->addr1)) {
+ tx->sta = sta_info_get(sdata, hdr->addr1);
++ aggr_check = true;
++ }
+ }
+
+ if (tx->sta && ieee80211_is_data_qos(hdr->frame_control) &&
+@@ -1211,8 +1237,12 @@ ieee80211_tx_prepare(struct ieee80211_su
+ struct tid_ampdu_tx *tid_tx;
+
+ tid = ieee80211_get_tid(hdr);
+-
+ tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]);
++ if (!tid_tx && aggr_check) {
++ ieee80211_aggr_check(sdata, tx->sta, skb);
++ tid_tx = rcu_dereference(tx->sta->ampdu_mlme.tid_tx[tid]);
++ }
++
+ if (tid_tx) {
+ bool queued;
+
+@@ -3947,29 +3977,6 @@ void ieee80211_txq_schedule_start(struct
+ }
+ EXPORT_SYMBOL(ieee80211_txq_schedule_start);
+
+-static void
+-ieee80211_aggr_check(struct ieee80211_sub_if_data *sdata,
+- struct sta_info *sta,
+- struct sk_buff *skb)
+-{
+- struct rate_control_ref *ref = sdata->local->rate_ctrl;
+- u16 tid;
+-
+- if (!ref || !(ref->ops->capa & RATE_CTRL_CAPA_AMPDU_TRIGGER))
+- return;
+-
+- if (!sta || !sta->sta.ht_cap.ht_supported ||
+- !sta->sta.wme || skb_get_queue_mapping(skb) == IEEE80211_AC_VO ||
+- skb->protocol == sdata->control_port_protocol)
+- return;
+-
+- tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
+- if (likely(sta->ampdu_mlme.tid_tx[tid]))
+- return;
+-
+- ieee80211_start_tx_ba_session(&sta->sta, tid, 0);
+-}
+-
+ void __ieee80211_subif_start_xmit(struct sk_buff *skb,
+ struct net_device *dev,
+ u32 info_flags,
diff --git a/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch b/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch
index 3d1bb3d6c8..febe42eb9d 100644
--- a/package/kernel/mac80211/patches/subsys/500-mac80211_configure_antenna_gain.patch

View File

@@ -6,7 +6,7 @@ PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/ucentral-client.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2021-02-15
PKG_SOURCE_VERSION:=b8106894ee912aa71cf673ecdd9599797ec09255
PKG_SOURCE_VERSION:=aafa1147034ae62cdc5dbed357ef8ad7e26cba4c
PKG_LICENSE:=BSD-3-Clause
PKG_MAINTAINER:=John Crispin <john@phrozen.org>

View File

@@ -6,7 +6,7 @@ PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/ucentral-schema.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2021-02-15
PKG_SOURCE_VERSION:=1c6efe8d91a429eb24683357145531093de240d4
PKG_SOURCE_VERSION:=f9eae1b43f470814e11c1264821eeec7e512bf5b
PKG_MAINTAINER:=John Crispin <john@phrozen.org>
PKG_LICENSE:=BSD-3-Clause

View File

@@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
PROG=/usr/bin/ucode
start_service() {
local interval=$(uci get onlinecheck.@config.check_interval)
procd_open_instance
procd_set_param command "$PROG" -m uci -m fs -i /usr/share/ucentral/onlinecheck.uc
procd_set_param respawn 1 $interval 0
procd_close_instance
}

View File

@@ -0,0 +1,110 @@
{
"uuid": 2,
"radios": [
{
"band": "2G",
"country": "CA",
"channel-mode": "HE",
"channel-width": 80,
"channel": 32
}
],
"interfaces": [
{
"name": "WAN",
"role": "upstream",
"services": [ "lldp" ],
"ethernet": [
{
"select-ports": [
"WAN*"
]
}
],
"ipv4": {
"addressing": "dynamic"
},
"ssids": [
{
"name": "OpenWifi",
"wifi-bands": [
"2G"
],
"bss-mode": "ap",
"encryption": {
"proto": "psk2",
"key": "OpenWifi",
"ieee80211w": "optional"
}
}
]
},
{
"name": "LAN",
"role": "downstream",
"services": [ "ssh", "lldp" ],
"ethernet": [
{
"select-ports": [
"LAN*"
]
}
],
"ipv4": {
"addressing": "static",
"subnet": "192.168.1.1/24",
"dhcp": {
"lease-first": 10,
"lease-count": 100,
"lease-time": "6h"
}
},
"ssids": [
{
"name": "OpenWifi",
"wifi-bands": [
"2G"
],
"bss-mode": "ap",
"encryption": {
"proto": "psk2",
"key": "OpenWifi",
"ieee80211w": "optional"
}
}
]
}
],
"metrics": {
"statistics": {
"interval": 120,
"types": [ "ssids", "lldp", "clients" ]
},
"health": {
"interval": 120
}
},
"services": {
"lldp": {
"describe": "uCentral",
"location": "universe"
},
"ssh": {
"port": 22
},
"online-check": {
"ping-hosts": [
"192.168.178.1",
"uecntral.io"
],
"download-hosts": [
"ucentral.io"
],
"check-interval": 30,
"check-threshold": 3,
"action": [ "wifi", "leds" ]
}
}
}

View File

@@ -6,7 +6,7 @@ PKG_RELEASE:=1
PKG_SOURCE_URL=https://github.com/blogic/ucentral-wifi.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2021-04-13
PKG_SOURCE_VERSION:=d3e4d762cae98500068d63b3bee550b3e9f37542
PKG_SOURCE_VERSION:=b17d2ca01663bbae82e4c05a845b7c9b0a4d23e3
#PKG_MIRROR_HASH:=a8000b3cf43ce9ebfa7305661475fec98ec1dba2dc7b062028c2e17d7c2ec50b
PKG_MAINTAINER:=John Crispin <john@phrozen.org>

View File

@@ -6,7 +6,7 @@ PKG_RELEASE:=1
PKG_SOURCE_URL=https://git.openwrt.org/project/usteer.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2021-04-19
PKG_SOURCE_VERSION:=dc383d43610cf441f865aa14d7e8ccd16301d53c
PKG_SOURCE_VERSION:=07a2f767e5a72ac9677ca91195d8a7d2d3c687b7
PKG_BUILD_PARALLEL:=1

View File

@@ -127,10 +127,19 @@ start_service()
local network="$(uci -q get usteer.@usteer[-1].network)"
ENABLED="$(uci -q get usteer.@usteer[-1].enabled)"
ENABLED="${ENABLED:-1}"
CHANNEL="$(uci -q get usteer.@usteer[-1].autochannel)"
CHANNEL="${CHANNEL:-0}"
[ "$ENABLED" -gt 0 ] || return
procd_open_instance
procd_set_param command "$PROG"
procd_close_instance
[ "$CHANNEL" -gt 0 ] || return
procd_open_instance
procd_set_param command "/usr/libexec/uchannel.uc"
procd_set_param respawn 1 300 0
procd_close_instance
}

View File

@@ -0,0 +1,333 @@
#!/usr/bin/ucode
{%
let fs = require("fs");
let ubus = require("ubus");
let conn = ubus.connect();
let phys = [];
let block_list = {
"2G": {},
"5G": {}
};
let channel_masks = {
/* DFS "40": [ 5180, 5220, 5260, 5300, 5500, 5540, 5580, 5620, 5660, 5700, 5745, 5785, 5825 ],
"80": [ 5180, 5260, 5500, 5580, 5660, 5745 ],
"160": [ 5180, 5500, ],
*/
"40": [ 5180, 5220, 5745, 5785, 5825 ],
"80": [ 5180, 5745 ],
};
function uptime_get() {
let info = conn.call("system", "info");
return info.uptime;
}
function remote_info() {
let info = conn.call("usteer", "remote_info");
return info || {};
}
function local_info() {
let info = conn.call("usteer", "local_info");
return info || {};
}
function remote_hosts() {
let hosts = conn.call("usteer", "remote_hosts");
return hosts || {};
}
let uptime = uptime_get();
let info = local_info();
let remote = remote_info();
let hosts = remote_hosts();
function state_get() {
let file = fs.open("/tmp/uchannel.json", "r");
let state = file ? json(file.read("all")) : {};
if (file)
file.close();
return state;
}
function state_set(state) {
let file = fs.open("/tmp/uchannel.json", "w");
state.uptime = uptime;
file.write(state);
file.close();
conn.call("usteer", "set_node_data", {
node: "*",
data: {
status: state.status,
uptime: state.uptime,
}
});
printf("entering %s state\n", state.status);
}
function freq2chan(freq) {
if (freq == 2484)
return 14;
else if (freq < 2484)
return (freq - 2407) / 5;
else if (freq >= 4910 && freq <= 4980)
return (freq - 4000) / 5;
else if(freq >= 56160 + 2160 * 1 && freq <= 56160 + 2160 * 6)
return (freq - 56160) / 2160;
else
return (freq - 5000) / 5;
}
function freq2band(freq) {
if (freq < 2500)
return "2G";
return "5G";
}
function chan2freq(band, channel) {
if (band == '2G' && channel >= 1 && channel <= 13)
return 2407 + channel * 5;
else if (band == '2G' && channel == 14)
return 2484;
else if (band == '5G' && channel >= 36 && channel <= 177)
return 5000 + channel * 5;
else if (band == '5G' && channel >= 183 && channel <= 196)
return 4000 + channel * 5;
else if (band == '60G' && channel >= 1 && channel <= 6)
return 56160 + channel * 2160;
return null;
}
function center_freq(freq, bandwidth) {
if (bandwidth == 40)
return +freq + 10;
if (bandwidth == 80)
return +freq + 30;
if (bandwidth == 160)
return +freq + 70;
return +freq;
}
function channel_overlap() {
let overlap = {};
let peers = {
"local": {}
};
for (let node, r in remote)
peers[split(node, "#")] = {};
for (let id, i in info) {
peers.local[i.freq] = true;
block_list[freq2band(freq)][i.freq] = 0;
}
for (let node, r in remote) {
peers[split(node, "#")][r.freq] = true;
block_list[freq2band(freq)][r.freq] = 0;
}
for (let id, peer in peers)
for (let freq, val in peer)
block_list[freq2band(freq)][freq]++;
for (let id, i in info)
for (let node, r in remote)
if (i.freq == r.freq) {
overlap[i.freq] = id;
break;
}
return overlap;
}
function phy_lookup() {
let status = conn.call("network.wireless", "status");
for (let id, radio in status) {
let htmode = match(radio.config.htmode, /^([A-Z]+)(.+)$/);
let phy = {
path: radio.config.path,
htmode: lc(htmode[1]),
bandwidth: htmode[2],
iface: [],
sta: false,
};
for (let i, iface in radio.interfaces) {
push(phy.iface, iface.ifname);
if (iface.config.mode != 'ap')
phy.sta = true;
}
push(phys, phy);
}
}
function phy_find(iface) {
for (let idx, phy in phys)
if (index(phy.iface, iface) >= 0)
return phy;
return {};
}
function channel_mask(band, bandwidth) {
if (band == "2G")
return [ 2412, 2437, 2462 ];
return channel_masks[bandwidth];
}
function channel_scan(band) {
conn.call("wifi", "scan", { band });
sleep(5000);
let survey_data = conn.call("wifi", "survey", { band });
let scan_data = conn.call("wifi", "scan_dump", { band });
let channels = {};
for (let survey in survey_data.survey) {
channels[survey.channel] = survey;
channels[survey.channel].bss = 0;
}
for (let scan in scan_data.scan)
channels[scan.channel].bss++;
return channels;
}
function channel_new(band, channels, mask) {
let new = [];
for (let chan, data in channels) {
if (data.in_use)
continue;
let freq = chan2freq(band, chan);
if (length(mask) && index(mask, freq) < 0)
continue;
if (block_list[band][freq])
continue;
push(new, {
freq,
bss: data.bss,
airtime: data.busy_ms * 100 / data.active_ms,
});
}
print("available free channels :" + new + "\n");
let best;
for (let id, data in new) {
if (!length(best))
best = data;
if (best.bss > data.bss)
best = data;
else if (best.bss == data.bss &&
best.airtime > data.airtime)
best = data;
}
return best || {};
}
function channel_balance(band, mask) {
let lowest = {
freq: mask[0],
count: 1000,
};
let highest = {
freq: mask[0],
count: 0,
};
for (let freq, count in block_list[band]) {
if (lowest.count > count)
lowest = { freq, count };
if (highest.count < count)
highest = { freq, count };
}
if (highest.count - lowest.cont >= 2)
return lowest;
return {};
}
function youngest() {
for (let ip, host in hosts) {
if (host.host_info.status == "overlap" &&
host.host_info.uptime < uptime) {
print("Found a younger host\n");
return 1;
}
}
print("We are the youngest host\n");
return 0;
}
let state = state_get();
if (state.status == "waiting" &&
(uptime - state.uptime < (12 * 60 * 60))) {
state_set(state);
return;
}
phy_lookup();
print("discovered devices: " + phys + "\n");
let overlap = channel_overlap();
print("list of blocked channels: " + block_list + "\n");
print("list of overlapping channels: " + overlap + "\n");
if (!length(overlap)) {
state.status = "happy";
state_set(state);
return;
}
if (state.status != "overlap" || youngest()) {
state.status = "overlap";
state_set(state);
return;
}
for (let freq, obj in overlap) {
let phy = phy_find(split(obj, ".")[1]);
let band = freq2band(freq);
let channels = channel_scan(band);
let mask = channel_mask(band, phy.bandwidth);
let new;
if (phy.sta) {
print("phy has a STA interface cannot change channel\n");
return;
}
new = channel_new(band, channels, mask);
if (!length(new))
new = channel_balance(band, mask);
if (!length(new)) {
print("no alternative channel found\n");
continue;
}
printf("selected channel: " + new + " for %s\n", obj);
conn.call(obj, "switch_chan", {
freq: +new.freq,
center_freq1: center_freq(new.freq, phy.bandwidth),
bcn_count: 10,
});
}
state.status = "waiting";
state.changed = uptime;
state_set(state);
%}

View File

@@ -186,21 +186,6 @@ index 0000000000..6c429f1852
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0
diff --git a/package/network/services/hostapd/files/hostapd.sh b/package/network/services/hostapd/files/hostapd.sh
index 7d035a299b..986c74dc4d 100644
--- a/package/network/services/hostapd/files/hostapd.sh
+++ b/package/network/services/hostapd/files/hostapd.sh
@@ -365,8 +365,8 @@ hostapd_set_vlan_file() {
local ifname="$1"
local vlan="$2"
json_get_vars name vid
- echo "${vid} ${ifname}-${name}" >> /var/run/hostapd-${ifname}.vlan
- wireless_add_vlan "${vlan}" "${ifname}-${name}"
+ echo "${vid} ${ifname}.${name}" >> /var/run/hostapd-${ifname}.vlan
+ wireless_add_vlan "${vlan}" "${ifname}.${name}"
}
hostapd_set_vlan() {
diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index c4d9dd78e3..6670d310db 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata

View File

@@ -10,3 +10,9 @@ feeds:
include:
- wifi-ax
- ucentral-ap
packages:
- kmod-bluetooth
- bluez-libs
- bluez-daemon
- bluez-utils
- usbutils

View File

@@ -10,3 +10,10 @@ feeds:
include:
- wifi-ax
- ucentral-ap
packages:
- kmod-bluetooth
- kmod-bluetooth_6lowpan
- bluez-libs
- bluez-daemon
- bluez-utils
- usbutils

View File

@@ -10,6 +10,13 @@ packages:
- ath10k-firmware-qca4019-ct-htt
- ath10k-firmware-qca9888-ct-htt
- ath10k-firmware-qca9984-ct-htt
- kmod-bluetooth
- kmod-usb-serial
- kmod-usb-serial-option
- bluez-libs
- bluez-daemon
- bluez-utils
- usbutils
diffconfig: |
# CONFIG_PACKAGE_ath10k-firmware-qca4019-ct is not set
# CONFIG_PACKAGE_ath10k-firmware-qca9888-ct is not set