patches: carry forward Morse Micro iwinfo support (0053)

Adds iwinfo support for Morse Micro wireless chipsets.

Renumbered from patches/0089.

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2025-10-19 00:00:00 +02:00
parent 24eaf6da9e
commit b21b7c5bb9

View File

@@ -1,22 +1,22 @@
From 67adfbc5b4831ecb62a169370c102e0939ae884e Mon Sep 17 00:00:00 2001
From 40196b0604ffa46ae2df3741a9737695273d6c79 Mon Sep 17 00:00:00 2001
From: ian77_chen <ian77_chen@accton.com>
Date: Mon, 10 Mar 2025 15:21:57 +0800
Subject: [PATCH] patch for Morse Micro iwinfo
Subject: [PATCH 53/55] patch for Morse Micro iwinfo
Adds Morse Micro HaLow (802.11ah) support to iwinfo library, including S1G channel mapping and device information reporting.
Signed-off-by: Ian Chen <ian77_chen@accton.com>
---
.../utils/iwinfo/patches/MMiwinfo.patch | 1976 +++++++++++++++++
1 file changed, 1976 insertions(+)
.../utils/iwinfo/patches/MMiwinfo.patch | 1943 +++++++++++++++++
1 file changed, 1943 insertions(+)
create mode 100644 package/network/utils/iwinfo/patches/MMiwinfo.patch
diff --git a/package/network/utils/iwinfo/patches/MMiwinfo.patch b/package/network/utils/iwinfo/patches/MMiwinfo.patch
new file mode 100644
index 0000000000..c10d4bf881
index 0000000000..301687f0c0
--- /dev/null
+++ b/package/network/utils/iwinfo/patches/MMiwinfo.patch
@@ -0,0 +1,1976 @@
+diff --git a/.gitignore b/.gitignore
+new file mode 100644
+index 0000000..7f4922f
@@ -0,0 +1,1943 @@
+--- /dev/null
++++ b/.gitignore
+@@ -0,0 +1,17 @@
@@ -37,11 +37,9 @@ index 0000000000..c10d4bf881
++*.o
++
++.vscode/
+diff --git a/Makefile b/Makefile
+index adb9e73..fac0abf 100644
+--- a/Makefile
++++ b/Makefile
+@@ -37,6 +37,7 @@ ifneq ($(filter nl80211,$(IWINFO_BACKENDS)),)
+@@ -37,6 +37,7 @@ ifneq ($(filter nl80211,$(IWINFO_BACKEND
+ IWINFO_CLI_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_LDFLAGS += -lnl-tiny
+ IWINFO_LIB_OBJ += iwinfo_nl80211.o
@@ -49,11 +47,9 @@ index 0000000000..c10d4bf881
+ endif
+
+
+diff --git a/devices.txt b/devices.txt
+index eded184..397a1cf 100644
+--- a/devices.txt
++++ b/devices.txt
+@@ -192,6 +192,9 @@
+@@ -196,6 +196,9 @@
+ 0x02d0 0xa9a6 0x0000 0x0000 0 0 "Cypress" "CYW43455"
+ 0x02d0 0x4345 0x0000 0x0000 0 0 "Cypress" "CYW43455"
+ 0x1ae9 0x0310 0x1ae9 0x0000 0 0 "Wilocity" "Wil6210"
@@ -63,14 +59,11 @@ index 0000000000..c10d4bf881
+
+ # USB devices
+ # 0x0000 | 0x0000 | vendor id | product id | ...
+@@ -263,3 +266,4 @@
+@@ -267,3 +270,4 @@
+ "ralink,rt3883-wmac" 0 0 "Ralink" "Rt3883"
+ "ralink,rt5350-wmac" 0 0 "Ralink" "Rt5350"
+ "ralink,rt7620-wmac" 0 0 "MediaTek" "MT7620"
++"morse,mm610x-spi" 0 0 "Morse Micro" "HaLow WiFi"
+diff --git a/dot11ah_channel.c b/dot11ah_channel.c
+new file mode 100644
+index 0000000..24dfb0e
+--- /dev/null
++++ b/dot11ah_channel.c
+@@ -0,0 +1,444 @@
@@ -519,9 +512,6 @@ index 0000000000..c10d4bf881
++ return rate_kbps;
++}
+\ No newline at end of file
+diff --git a/dot11ah_channel.h b/dot11ah_channel.h
+new file mode 100644
+index 0000000..676906d
+--- /dev/null
++++ b/dot11ah_channel.h
+@@ -0,0 +1,105 @@
@@ -630,29 +620,27 @@ index 0000000000..c10d4bf881
++int get_mmrc_throughput(const char* phyname);
++
++#endif /* __DOT11AH_CHANNELS__ */
+diff --git a/include/iwinfo.h b/include/iwinfo.h
+index b50de69..0a9f157 100644
+--- a/include/iwinfo.h
++++ b/include/iwinfo.h
+@@ -31,6 +31,7 @@ enum iwinfo_80211 {
+ IWINFO_80211_AC,
+@@ -32,6 +32,7 @@ enum iwinfo_80211 {
+ IWINFO_80211_AD,
+ IWINFO_80211_AX,
+ IWINFO_80211_BE,
++ IWINFO_80211_AH,
+
+ /* keep last */
+ IWINFO_80211_COUNT
+@@ -43,6 +44,9 @@ enum iwinfo_80211 {
+ #define IWINFO_80211_AC (1 << IWINFO_80211_AC)
+@@ -45,6 +46,9 @@ enum iwinfo_80211 {
+ #define IWINFO_80211_AD (1 << IWINFO_80211_AD)
+ #define IWINFO_80211_AX (1 << IWINFO_80211_AX)
++#define IWINFO_80211_AH (1 << IWINFO_80211_AH)
+ #define IWINFO_80211_BE (1 << IWINFO_80211_BE)
++#define IWINFO_80211_AH (1 << IWINFO_80211_AH)
++
++#define S1G_CHAN_WIDTH_OFFSET (2)
+
+ extern const char * const IWINFO_80211_NAMES[IWINFO_80211_COUNT];
+
+@@ -52,7 +56,7 @@ enum iwinfo_band {
+@@ -54,7 +58,7 @@ enum iwinfo_band {
+ IWINFO_BAND_5,
+ IWINFO_BAND_6,
+ IWINFO_BAND_60,
@@ -661,7 +649,7 @@ index 0000000000..c10d4bf881
+ /* keep last */
+ IWINFO_BAND_COUNT
+ };
+@@ -61,6 +65,7 @@ enum iwinfo_band {
+@@ -63,6 +67,7 @@ enum iwinfo_band {
+ #define IWINFO_BAND_5 (1 << IWINFO_BAND_5)
+ #define IWINFO_BAND_6 (1 << IWINFO_BAND_6)
+ #define IWINFO_BAND_60 (1 << IWINFO_BAND_60)
@@ -669,7 +657,7 @@ index 0000000000..c10d4bf881
+
+ extern const char * const IWINFO_BAND_NAMES[IWINFO_BAND_COUNT];
+
+@@ -290,6 +295,15 @@ struct iwinfo_crypto_entry {
+@@ -307,6 +312,15 @@ struct iwinfo_crypto_entry {
+ uint16_t pair_ciphers;
+ uint8_t auth_suites;
+ uint8_t auth_algs;
@@ -685,7 +673,7 @@ index 0000000000..c10d4bf881
+ };
+
+ struct iwinfo_scanlist_ht_chan_entry {
+@@ -304,6 +318,19 @@ struct iwinfo_scanlist_vht_chan_entry {
+@@ -321,6 +335,19 @@ struct iwinfo_scanlist_vht_chan_entry {
+ uint8_t center_chan_2;
+ };
+
@@ -705,7 +693,7 @@ index 0000000000..c10d4bf881
+ extern const char * const ht_secondary_offset[4];
+ /* 0 = 20 MHz
+ 1 = 40 MHz or higher (refer to vht if supported) */
+@@ -327,6 +354,7 @@ struct iwinfo_scanlist_entry {
+@@ -344,6 +371,7 @@ struct iwinfo_scanlist_entry {
+ struct iwinfo_crypto_entry crypto;
+ struct iwinfo_scanlist_ht_chan_entry ht_chan_info;
+ struct iwinfo_scanlist_vht_chan_entry vht_chan_info;
@@ -713,7 +701,7 @@ index 0000000000..c10d4bf881
+ };
+
+ struct iwinfo_country_entry {
+@@ -412,6 +440,7 @@ extern const struct iwinfo_ops wext_ops;
+@@ -429,6 +457,7 @@ extern const struct iwinfo_ops wext_ops;
+ extern const struct iwinfo_ops madwifi_ops;
+ extern const struct iwinfo_ops nl80211_ops;
+ extern const struct iwinfo_ops wl_ops;
@@ -721,11 +709,9 @@ index 0000000000..c10d4bf881
+
+ #include "iwinfo/utils.h"
+
+diff --git a/include/iwinfo/utils.h b/include/iwinfo/utils.h
+index 7b8ceea..d2a2788 100644
+--- a/include/iwinfo/utils.h
++++ b/include/iwinfo/utils.h
+@@ -66,6 +66,7 @@ int iwinfo_hardware_id_from_mtd(struct iwinfo_hardware_id *id);
+@@ -67,6 +67,7 @@ int iwinfo_hardware_id_from_mtd(struct i
+
+ void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+ uint16_t defcipher, uint8_t defauth);
@@ -733,8 +719,6 @@ index 0000000000..c10d4bf881
+
+ struct uci_section *iwinfo_uci_get_radio(const char *name, const char *type);
+ void iwinfo_uci_free(void);
+diff --git a/iwinfo_cli.c b/iwinfo_cli.c
+index 5dcee9a..790803c 100644
+--- a/iwinfo_cli.c
++++ b/iwinfo_cli.c
+@@ -69,12 +69,12 @@ static char * format_channel(int ch)
@@ -752,7 +736,7 @@ index 0000000000..c10d4bf881
+
+ return buf;
+ }
+@@ -351,6 +351,19 @@ static const char* format_chan_width(bool vht, uint8_t width)
+@@ -362,6 +362,19 @@ static const char* format_chan_width(boo
+ return "unknown";
+ }
+
@@ -772,7 +756,7 @@ index 0000000000..c10d4bf881
+
+ static const char * print_type(const struct iwinfo_ops *iw, const char *ifname)
+ {
+@@ -689,13 +702,16 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
+@@ -700,13 +713,16 @@ static void print_scanlist(const struct
+ format_quality_max(e->quality_max));
+ printf(" Encryption: %s\n",
+ format_encryption(&e->crypto));
@@ -796,7 +780,7 @@ index 0000000000..c10d4bf881
+
+ if (e->vht_chan_info.center_chan_1) {
+ printf(" VHT Operation:\n");
+@@ -707,6 +723,14 @@ static void print_scanlist(const struct iwinfo_ops *iw, const char *ifname)
+@@ -718,6 +734,14 @@ static void print_scanlist(const struct
+ format_chan_width(true, e->vht_chan_info.chan_width));
+ }
+
@@ -811,7 +795,7 @@ index 0000000000..c10d4bf881
+ printf("\n");
+ }
+ }
+@@ -912,7 +936,7 @@ int main(int argc, char **argv)
+@@ -923,7 +947,7 @@ int main(int argc, char **argv)
+ char *p;
+ const struct iwinfo_ops *iw;
+ glob_t globbuf;
@@ -820,7 +804,7 @@ index 0000000000..c10d4bf881
+ if (argc > 1 && argc < 3)
+ {
+ fprintf(stderr,
+@@ -1031,7 +1055,6 @@ int main(int argc, char **argv)
+@@ -1042,7 +1066,6 @@ int main(int argc, char **argv)
+ }
+ }
+ }
@@ -828,19 +812,17 @@ index 0000000000..c10d4bf881
+ iwinfo_finish();
+
+ return rv;
+diff --git a/iwinfo_lib.c b/iwinfo_lib.c
+index 579efc4..02fbd9c 100644
+--- a/iwinfo_lib.c
++++ b/iwinfo_lib.c
+@@ -30,6 +30,7 @@ const char * const IWINFO_80211_NAMES[IWINFO_80211_COUNT] = {
+ "ac",
+@@ -31,6 +31,7 @@ const char * const IWINFO_80211_NAMES[IW
+ "ad",
+ "ax",
+ "be",
++ "ah",
+ };
+
+ const char * const IWINFO_BAND_NAMES[IWINFO_BAND_COUNT] = {
+@@ -37,6 +38,7 @@ const char * const IWINFO_BAND_NAMES[IWINFO_BAND_COUNT] = {
+@@ -38,6 +39,7 @@ const char * const IWINFO_BAND_NAMES[IWI
+ "5 GHz",
+ "6 GHz",
+ "60 GHz",
@@ -848,7 +830,7 @@ index 0000000000..c10d4bf881
+ };
+
+ const char * const IWINFO_CIPHER_NAMES[IWINFO_CIPHER_COUNT] = {
+@@ -383,6 +385,7 @@ const struct iwinfo_iso3166_label IWINFO_ISO3166_NAMES[] = {
+@@ -390,6 +392,7 @@ const struct iwinfo_iso3166_label IWINFO
+
+ static const struct iwinfo_ops *backends[] = {
+ #ifdef USE_NL80211
@@ -856,13 +838,11 @@ index 0000000000..c10d4bf881
+ &nl80211_ops,
+ #endif
+ #ifdef USE_MADWIFI
+diff --git a/iwinfo_lua.c b/iwinfo_lua.c
+index ecf257d..9def386 100644
+--- a/iwinfo_lua.c
++++ b/iwinfo_lua.c
+@@ -554,6 +554,9 @@ static int iwinfo_L_hwmodelist(lua_State *L, int (*func)(const char *, int *))
+ lua_pushboolean(L, hwmodes & IWINFO_80211_AX);
+ lua_setfield(L, -2, "ax");
+@@ -565,6 +565,9 @@ static int iwinfo_L_hwmodelist(lua_State
+ lua_pushboolean(L, hwmodes & IWINFO_80211_BE);
+ lua_setfield(L, -2, "be");
+
++ lua_pushboolean(L, hwmodes & IWINFO_80211_AH);
++ lua_setfield(L, -2, "ah");
@@ -870,9 +850,6 @@ index 0000000000..c10d4bf881
+ return 1;
+ }
+
+diff --git a/iwinfo_morsecli.c b/iwinfo_morsecli.c
+new file mode 100644
+index 0000000..7156bd8
+--- /dev/null
++++ b/iwinfo_morsecli.c
+@@ -0,0 +1,122 @@
@@ -999,9 +976,6 @@ index 0000000000..c10d4bf881
++ return found;
++}
+\ No newline at end of file
+diff --git a/iwinfo_morsecli.h b/iwinfo_morsecli.h
+new file mode 100644
+index 0000000..320f433
+--- /dev/null
++++ b/iwinfo_morsecli.h
+@@ -0,0 +1,27 @@
@@ -1033,8 +1007,6 @@ index 0000000000..c10d4bf881
++
++#endif
+\ No newline at end of file
+diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
+index 2200249..dcb29b3 100644
+--- a/iwinfo_nl80211.c
++++ b/iwinfo_nl80211.c
+@@ -2,6 +2,7 @@
@@ -1053,7 +1025,7 @@ index 0000000000..c10d4bf881
+
+ #define min(x, y) ((x) < (y)) ? (x) : (y)
+
+@@ -408,8 +410,11 @@ static int nl80211_phy_idx_from_uci(const char *name)
+@@ -413,8 +415,11 @@ static int nl80211_phy_idx_from_uci(cons
+ int idx = -1;
+
+ s = iwinfo_uci_get_radio(name, "mac80211");
@@ -1067,7 +1039,7 @@ index 0000000000..c10d4bf881
+
+ opt = uci_lookup_option_string(uci_ctx, s, "path");
+ idx = nl80211_phy_idx_from_path(opt);
+@@ -1331,15 +1336,16 @@ static int nl80211_get_bssid(const char *ifname, char *buf)
+@@ -1359,15 +1364,16 @@ static int nl80211_get_bssid(const char
+
+ res = nl80211_phy2ifname(ifname);
+
@@ -1091,7 +1063,7 @@ index 0000000000..c10d4bf881
+
+ /* failed, try to find mac from hostapd info */
+ if ((sb.bssid[0] == 0) &&
+@@ -1771,7 +1777,8 @@ static const struct {
+@@ -1799,7 +1805,8 @@ static const struct {
+ { "EAP-SUITE-B-192", 4, IWINFO_KMGMT_8021x },
+ { "EAP-SUITE-B", 4, IWINFO_KMGMT_8021x },
+ { "EAP-SHA384", 4, IWINFO_KMGMT_8021x },
@@ -1101,7 +1073,7 @@ index 0000000000..c10d4bf881
+ { "PSK-SHA256", 0, IWINFO_KMGMT_PSK },
+ { "NONE", 0, IWINFO_KMGMT_NONE },
+ { "None", 0, IWINFO_KMGMT_NONE },
+@@ -1782,7 +1789,7 @@ static const struct {
+@@ -1810,7 +1817,7 @@ static const struct {
+ };
+
+ static void parse_wpa_suites(const char *str, int defversion,
@@ -1110,7 +1082,7 @@ index 0000000000..c10d4bf881
+ {
+ size_t l;
+ int i, version;
+@@ -1817,6 +1824,35 @@ static void parse_wpa_suites(const char *str, int defversion,
+@@ -1845,6 +1852,35 @@ static void parse_wpa_suites(const char
+
+ p = q + strspn(q, sep);
+ }
@@ -1146,7 +1118,7 @@ index 0000000000..c10d4bf881
+ }
+
+ static const struct {
+@@ -1871,6 +1907,7 @@ static int nl80211_get_encryption(const char *ifname, char *buf)
+@@ -1899,6 +1935,7 @@ static int nl80211_get_encryption(const
+ uint8_t wpa_version = 0;
+ char wpa[2], wpa_key_mgmt[64], wpa_pairwise[16], wpa_groupwise[16];
+ char auth_algs[2], wep_key0[27], wep_key1[27], wep_key2[27], wep_key3[27];
@@ -1154,7 +1126,7 @@ index 0000000000..c10d4bf881
+ char mode[16];
+
+ struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf;
+@@ -1880,6 +1917,7 @@ static int nl80211_get_encryption(const char *ifname, char *buf)
+@@ -1908,6 +1945,7 @@ static int nl80211_get_encryption(const
+ "pairwise_cipher", wpa_pairwise, sizeof(wpa_pairwise),
+ "group_cipher", wpa_groupwise, sizeof(wpa_groupwise),
+ "key_mgmt", wpa_key_mgmt, sizeof(wpa_key_mgmt),
@@ -1162,7 +1134,7 @@ index 0000000000..c10d4bf881
+ "mode", mode, sizeof(mode)))
+ {
+ /* WEP or Open */
+@@ -1928,7 +1966,7 @@ static int nl80211_get_encryption(const char *ifname, char *buf)
+@@ -1956,7 +1994,7 @@ static int nl80211_get_encryption(const
+ wpa_version = 1;
+ }
+
@@ -1171,7 +1143,7 @@ index 0000000000..c10d4bf881
+
+ c->enabled = !!(c->wpa_version && c->auth_suites);
+ }
+@@ -1941,6 +1979,7 @@ static int nl80211_get_encryption(const char *ifname, char *buf)
+@@ -1969,6 +2007,7 @@ static int nl80211_get_encryption(const
+ "wpa", wpa, sizeof(wpa),
+ "wpa_key_mgmt", wpa_key_mgmt, sizeof(wpa_key_mgmt),
+ "wpa_pairwise", wpa_pairwise, sizeof(wpa_pairwise),
@@ -1179,7 +1151,7 @@ index 0000000000..c10d4bf881
+ "auth_algs", auth_algs, sizeof(auth_algs),
+ "wep_key0", wep_key0, sizeof(wep_key0),
+ "wep_key1", wep_key1, sizeof(wep_key1),
+@@ -1959,7 +1998,7 @@ static int nl80211_get_encryption(const char *ifname, char *buf)
+@@ -1987,7 +2026,7 @@ static int nl80211_get_encryption(const
+ if (!strncmp(p, "FT-", 3))
+ p += 3;
+
@@ -1188,7 +1160,7 @@ index 0000000000..c10d4bf881
+ }
+
+ c->enabled = c->wpa_version ? 1 : 0;
+@@ -2531,7 +2570,7 @@ static void nl80211_get_scancrypto(char *spec, struct iwinfo_crypto_entry *c)
+@@ -2571,7 +2610,7 @@ static void nl80211_get_scancrypto(char
+
+ c->enabled = 1;
+
@@ -1197,7 +1169,7 @@ index 0000000000..c10d4bf881
+ parse_wpa_ciphers(suites, &c->pair_ciphers);
+ }
+ }
+@@ -2588,6 +2627,9 @@ static void nl80211_get_scanlist_ie(struct nlattr **bss,
+@@ -2628,6 +2667,9 @@ static void nl80211_get_scanlist_ie(stru
+ e->vht_chan_info.center_chan_2 = ie[4];
+ }
+ break;
@@ -1207,7 +1179,7 @@ index 0000000000..c10d4bf881
+ }
+
+ ielen -= ie[1] + 2;
+@@ -3634,7 +3676,7 @@ const struct iwinfo_ops nl80211_ops = {
+@@ -3723,7 +3765,7 @@ const struct iwinfo_ops nl80211_ops = {
+ .mbssid_support = nl80211_get_mbssid_support,
+ .hwmodelist = nl80211_get_hwmodelist,
+ .htmodelist = nl80211_get_htmodelist,
@@ -1216,7 +1188,7 @@ index 0000000000..c10d4bf881
+ .mode = nl80211_get_mode,
+ .ssid = nl80211_get_ssid,
+ .bssid = nl80211_get_bssid,
+@@ -3653,3 +3695,723 @@ const struct iwinfo_ops nl80211_ops = {
+@@ -3742,3 +3784,723 @@ const struct iwinfo_ops nl80211_ops = {
+ .phy_path = nl80211_phy_path,
+ .close = nl80211_close
+ };
@@ -1941,8 +1913,6 @@ index 0000000000..c10d4bf881
++ .close = nl80211_close
++};
+\ No newline at end of file
+diff --git a/iwinfo_utils.c b/iwinfo_utils.c
+index d96cbb3..a7c8abe 100644
+--- a/iwinfo_utils.c
++++ b/iwinfo_utils.c
+@@ -2,6 +2,7 @@
@@ -1957,14 +1927,14 @@ index 0000000000..c10d4bf881
+
+ size_t iwinfo_format_hwmodes(int modes, char *buf, size_t len)
+ {
+- // bit numbers as per IWINFO_80211_*: ad ac ax a b g n
+- const int order[IWINFO_80211_COUNT] = { 5, 4, 6, 0, 1, 2, 3 };
++ // bit numbers as per IWINFO_80211_*: ad ac ax ah a b g n
++ const int order[IWINFO_80211_COUNT] = { 5, 4, 6, 7, 0, 1, 2, 3 };
+- // bit numbers as per IWINFO_80211_*: ad ac ax a b be g n
+- const int order[IWINFO_80211_COUNT] = { 5, 4, 6, 0, 1, 7, 2, 3 };
++ // bit numbers as per IWINFO_80211_*: ad ac ax ah a b be g n
++ const int order[IWINFO_80211_COUNT] = { 5, 4, 6, 8, 0, 1, 7, 2, 3 };
+ size_t res = 0;
+ int i;
+
+@@ -599,6 +600,25 @@ void iwinfo_parse_rsn(struct iwinfo_crypto_entry *c, uint8_t *data, uint8_t len,
+@@ -615,6 +616,25 @@ void iwinfo_parse_rsn(struct iwinfo_cryp
+ len -= 2 + (count * 4);
+ }
+