]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: S1G: add 802.11ah support for link command display
authorBassem Dawood <bassem@morsemicro.com>
Thu, 19 Oct 2023 07:40:19 +0000 (18:40 +1100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 Nov 2023 17:25:05 +0000 (18:25 +0100)
Amending the link command which depends on kernal changes for
802.11ah bandwidths/MCS/NSS NL80211_RATE_INFO_ attributes.

S1G frequency offset being used as well for the MHz units print.

Signed-off-by: Bassem Dawood <bassem@morsemicro.com>
Link: https://lore.kernel.org/r/20231019074019.2246629-1-bassem@morsemicro.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
link.c
station.c

diff --git a/link.c b/link.c
index a0901009b18eeff2340540849b7f3360031fd320..a7ee9636af2f0d3da0b2ad426b5ee7b7e0d0a57b 100644 (file)
--- a/link.c
+++ b/link.c
@@ -29,6 +29,7 @@ static int link_bss_handler(struct nl_msg *msg, void *arg)
        static struct nla_policy bss_policy[NL80211_BSS_MAX + 1] = {
                [NL80211_BSS_TSF] = { .type = NLA_U64 },
                [NL80211_BSS_FREQUENCY] = { .type = NLA_U32 },
+               [NL80211_BSS_FREQUENCY_OFFSET] = { .type = NLA_U32 },
                [NL80211_BSS_BSSID] = { },
                [NL80211_BSS_BEACON_INTERVAL] = { .type = NLA_U16 },
                [NL80211_BSS_CAPABILITY] = { .type = NLA_U16 },
@@ -41,6 +42,7 @@ static int link_bss_handler(struct nl_msg *msg, void *arg)
        char mac_addr[20], dev[20], link_addr[20];
        int link_id = -1;
        const char *indent = "\t";
+       int freq_offset = 0;
 
        nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
                  genlmsg_attrlen(gnlh, 0), NULL);
@@ -121,9 +123,12 @@ static int link_bss_handler(struct nl_msg *msg, void *arg)
                          nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]),
                          false, result->mld ? PRINT_LINK_MLO_LINK : PRINT_LINK);
 
+       if (bss[NL80211_BSS_FREQUENCY_OFFSET])
+               freq_offset = nla_get_u32(bss[NL80211_BSS_FREQUENCY_OFFSET]);
+
        if (bss[NL80211_BSS_FREQUENCY])
-               printf("%sfreq: %d\n", indent,
-                       nla_get_u32(bss[NL80211_BSS_FREQUENCY]));
+               printf("%sfreq: %d.%d\n", indent,
+                       nla_get_u32(bss[NL80211_BSS_FREQUENCY]), freq_offset);
 
        if (nla_get_u32(bss[NL80211_BSS_STATUS]) != NL80211_BSS_STATUS_ASSOCIATED)
                return NL_SKIP;
index da1feaeb2708b1740260b75edfb5d5201ec7b3c9..bf7c0f581ef72f26a1a7392d743b5cafa8e7b9e5 100644 (file)
--- a/station.c
+++ b/station.c
@@ -241,6 +241,16 @@ void parse_bitrate(struct nlattr *bitrate_attr, char *buf, int buflen)
                pos += snprintf(pos, buflen - (pos - buf), " 160MHz");
        if (rinfo[NL80211_RATE_INFO_320_MHZ_WIDTH])
                pos += snprintf(pos, buflen - (pos - buf), " 320MHz");
+       if (rinfo[NL80211_RATE_INFO_1_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 1MHz");
+       if (rinfo[NL80211_RATE_INFO_2_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 2MHz");
+       if (rinfo[NL80211_RATE_INFO_4_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 4MHz");
+       if (rinfo[NL80211_RATE_INFO_8_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 8MHz");
+       if (rinfo[NL80211_RATE_INFO_16_MHZ_WIDTH])
+               pos += snprintf(pos, buflen - (pos - buf), " 16MHz");
        if (rinfo[NL80211_RATE_INFO_SHORT_GI])
                pos += snprintf(pos, buflen - (pos - buf), " short GI");
        if (rinfo[NL80211_RATE_INFO_VHT_NSS])