All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org,
	David Poole <dpoole@cradlepoint.com>,
	Ben Greear <greearb@candelatech.com>,
	John Crispin <john@phrozen.org>,
	Brian Norris <briannorris@chromium.org>
Subject: [PATCH 3/4] iw: scan: parse HE capabilities
Date: Tue, 17 Nov 2020 19:39:35 -0800	[thread overview]
Message-ID: <20201118033936.3667788-4-briannorris@chromium.org> (raw)
In-Reply-To: <20201118033936.3667788-1-briannorris@chromium.org>

Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 iw.h   |  1 +
 scan.c |  8 ++++++++
 util.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+)

diff --git a/iw.h b/iw.h
index 77ed097f229b..807adecd3b06 100644
--- a/iw.h
+++ b/iw.h
@@ -213,6 +213,7 @@ void print_ampdu_length(__u8 exponent);
 void print_ampdu_spacing(__u8 spacing);
 void print_ht_capability(__u16 cap);
 void print_vht_info(__u32 capa, const __u8 *mcs);
+void print_he_capability(const uint8_t *ie, int len);
 void print_he_info(struct nlattr *nl_iftype);
 
 char *channel_width_name(enum nl80211_chan_width width);
diff --git a/scan.c b/scan.c
index 58a09983c5c7..dfc136a3943e 100644
--- a/scan.c
+++ b/scan.c
@@ -2272,7 +2272,15 @@ static void print_vendor(unsigned char len, unsigned char *data,
 	printf("\n");
 }
 
+static void print_he_capa(const uint8_t type, uint8_t len, const uint8_t *data,
+			  const struct print_ies_data *ie_buffer)
+{
+	printf("\n");
+	print_he_capability(data, len);
+}
+
 static const struct ie_print ext_printers[] = {
+	[35] = { "HE capabilities", print_he_capa, 21, 54, BIT(PRINT_SCAN), },
 };
 
 static void print_extension(unsigned char len, unsigned char *ie,
diff --git a/util.c b/util.c
index 4591cbf77ec1..b09bcaf743fc 100644
--- a/util.c
+++ b/util.c
@@ -994,6 +994,7 @@ static void __print_he_capa(const __u16 *mac_cap,
 			    const __u16 *mcs_set, size_t mcs_len,
 			    const __u8 *ppet, int ppet_len)
 {
+	size_t mcs_used;
 	int i;
 
 	#define PRINT_HE_CAP(_var, _idx, _bit, _str) \
@@ -1124,6 +1125,7 @@ static void __print_he_capa(const __u16 *mac_cap,
 	PRINT_HE_PHY_CAP(5, 4, "RX Full BW SU Using HE MU PPDU with Compression SIGB");
 	PRINT_HE_PHY_CAP(5, 5, "RX Full BW SU Using HE MU PPDU with Non-Compression SIGB");
 
+	mcs_used = 0;
 	for (i = 0; i < 3; i++) {
 		__u8 phy_cap_support[] = { BIT(1) | BIT(2), BIT(3), BIT(4) };
 		char *bw[] = { "<= 80", "160", "80+80" };
@@ -1151,6 +1153,16 @@ static void __print_he_capa(const __u16 *mac_cap,
 			}
 
 		}
+		mcs_used += 2 * sizeof(mcs_set[0]);
+	}
+
+	/* Caller didn't provide ppet; infer it, if there's trailing space. */
+	if (!ppet) {
+		ppet = (const void *)(mcs_set + mcs_used);
+		if (mcs_used < mcs_len)
+			ppet_len = mcs_len - mcs_used;
+		else
+			ppet_len = 0;
 	}
 
 	if (ppet_len && (phy_cap[3] & BIT(15))) {
@@ -1236,6 +1248,24 @@ void print_he_info(struct nlattr *nl_iftype)
 	__print_he_capa(mac_cap, phy_cap, mcs_set, mcs_len, ppet, ppet_len);
 }
 
+void print_he_capability(const uint8_t *ie, int len)
+{
+	const void *mac_cap, *phy_cap, *mcs_set;
+	int mcs_len;
+	int i = 0;
+
+	mac_cap = &ie[i];
+	i += 6;
+
+	phy_cap = &ie[i];
+	i += 11;
+
+	mcs_set = &ie[i];
+	mcs_len = len - i;
+
+	__print_he_capa(mac_cap, phy_cap - 1, mcs_set, mcs_len, NULL, 0);
+}
+
 void iw_hexdump(const char *prefix, const __u8 *buf, size_t size)
 {
 	size_t i;
-- 
2.29.2.299.gdc1121823c-goog


  parent reply	other threads:[~2020-11-18  3:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-18  3:39 [PATCH 0/4] iw: add HE capabilities scan parsing Brian Norris
2020-11-18  3:39 ` [PATCH 1/4] iw: scan: add extension tag parsing Brian Norris
2020-11-18  3:39 ` [PATCH 2/4] iw: util: factor out HE capability parser Brian Norris
2020-11-18  3:39 ` Brian Norris [this message]
2020-11-18  3:39 ` [PATCH 4/4] iw: scan: fixup HE caps whitespace Brian Norris
2020-11-19 15:06 ` [PATCH 0/4] iw: add HE capabilities scan parsing David Poole
2020-11-19 19:20   ` Brian Norris

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=20201118033936.3667788-4-briannorris@chromium.org \
    --to=briannorris@chromium.org \
    --cc=dpoole@cradlepoint.com \
    --cc=greearb@candelatech.com \
    --cc=johannes@sipsolutions.net \
    --cc=john@phrozen.org \
    --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.