All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org,
	Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
Subject: [PATCH] iw: S1G: add list command support for 802.11ah
Date: Tue, 28 Feb 2023 12:11:24 +1300	[thread overview]
Message-ID: <20230227231124.711053-1-gilad.itzkovitch@virscient.com> (raw)

From: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>

In this changeset S1G frequencies are displayed for any S1G band
with their relevant properties.

Signed-off-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
---
 info.c | 15 ++++++++++++++-
 util.c |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/info.c b/info.c
index 5229d44..7d649b8 100644
--- a/info.c
+++ b/info.c
@@ -297,6 +297,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1];
 	static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = {
 		[NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 },
+		[NL80211_FREQUENCY_ATTR_OFFSET] = { .type = NLA_U32 },
 		[NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG },
 		[NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG },
 		[__NL80211_FREQUENCY_ATTR_NO_IBSS] = { .type = NLA_FLAG },
@@ -392,12 +393,24 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 				}
 				nla_for_each_nested(nl_freq, tb_band[NL80211_BAND_ATTR_FREQS], rem_freq) {
 					uint32_t freq;
+					uint32_t offset = 0;
+
 					nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, nla_data(nl_freq),
 						  nla_len(nl_freq), freq_policy);
 					if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ])
 						continue;
 					freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]);
-					printf("\t\t\t* %d MHz [%d]", freq, ieee80211_frequency_to_channel(freq));
+					if (tb_freq[NL80211_FREQUENCY_ATTR_OFFSET])
+						offset = nla_get_u32(
+							tb_freq[NL80211_FREQUENCY_ATTR_OFFSET]);
+
+					if (tb_freq[NL80211_FREQUENCY_ATTR_OFFSET])
+						printf("\t\t\t* %d.%d MHz", freq, offset);
+					else
+						printf("\t\t\t* %d MHz", freq);
+
+					if (ieee80211_frequency_to_channel(freq))
+						printf(" [%d]", ieee80211_frequency_to_channel(freq));
 
 					if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
 					    !tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
diff --git a/util.c b/util.c
index 8a2ba10..ba7dc26 100644
--- a/util.c
+++ b/util.c
@@ -199,6 +199,8 @@ int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
 
 int ieee80211_frequency_to_channel(int freq)
 {
+	if (freq < 1000)
+		return 0;
 	/* see 802.11-2007 17.3.8.3.2 and Annex J */
 	if (freq == 2484)
 		return 14;

base-commit: d6fd2757f7aab638022ffa635e32e21594ec382d
-- 
2.25.1


                 reply	other threads:[~2023-02-27 23:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230227231124.711053-1-gilad.itzkovitch@virscient.com \
    --to=gilad.itzkovitch@morsemicro.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.