Browse Source

iwinfo: add 802.11ax HE rate information

This adds 802.11ax HE specific rate information to iwinfo.

Add fields for HE status of a STA as well as DCM and guard interval
fields specific to HE operation.

Signed-off-by: David Bauer <mail@david-bauer.net>
David Bauer 2 years ago
parent
commit
c45f0b584b
5 changed files with 58 additions and 4 deletions
  1. 12 0
      api/nl80211.h
  2. 3 0
      include/iwinfo.h
  3. 14 0
      iwinfo_cli.c
  4. 16 3
      iwinfo_lua.c
  5. 13 1
      iwinfo_nl80211.c

+ 12 - 0
api/nl80211.h

@@ -2353,6 +2353,13 @@ struct nl80211_sta_flag_update {
  * @NL80211_RATE_INFO_5_MHZ_WIDTH: 5 MHz width - note that this is
  *	a legacy rate and will be reported as the actual bitrate, i.e.
  *	a quarter of the base (20 MHz) rate
+ * @NL80211_RATE_INFO_HE_MCS: HE MCS index (u8, 0-11)
+ * @NL80211_RATE_INFO_HE_NSS: HE NSS value (u8, 1-8)
+ * @NL80211_RATE_INFO_HE_GI: HE guard interval identifier
+ *	(u8, see &enum nl80211_he_gi)
+ * @NL80211_RATE_INFO_HE_DCM: HE DCM value (u8, 0/1)
+ * @NL80211_RATE_INFO_RU_ALLOC: HE RU allocation, if not present then
+ *	non-OFDMA was used (u8, see &enum nl80211_he_ru_alloc)
  * @__NL80211_RATE_INFO_AFTER_LAST: internal use
  */
 enum nl80211_rate_info {
@@ -2369,6 +2376,11 @@ enum nl80211_rate_info {
 	NL80211_RATE_INFO_160_MHZ_WIDTH,
 	NL80211_RATE_INFO_10_MHZ_WIDTH,
 	NL80211_RATE_INFO_5_MHZ_WIDTH,
+	NL80211_RATE_INFO_HE_MCS,
+	NL80211_RATE_INFO_HE_NSS,
+	NL80211_RATE_INFO_HE_GI,
+	NL80211_RATE_INFO_HE_DCM,
+	NL80211_RATE_INFO_HE_RU_ALLOC,
 
 	/* keep last */
 	__NL80211_RATE_INFO_AFTER_LAST,

+ 3 - 0
include/iwinfo.h

@@ -110,6 +110,9 @@ struct iwinfo_rate_entry {
 	uint8_t is_short_gi:1;
 	uint8_t is_ht:1;
 	uint8_t is_vht:1;
+	uint8_t is_he:1;
+	uint8_t he_gi;
+	uint8_t he_dcm;
 	uint8_t mhz;
 	uint8_t nss;
 };

+ 14 - 0
iwinfo_cli.c

@@ -322,6 +322,20 @@ static char * format_assocrate(struct iwinfo_rate_entry *r)
 				l = sizeof(buf) - (p - buf);
 			}
 		}
+		else if (r->is_he)
+		{
+			p += snprintf(p, l, ", HE-MCS %d, %dMHz", r->mcs, r->mhz);
+			l = sizeof(buf) - (p - buf);
+
+			p += snprintf(p, l, ", HE-NSS %d", r->nss);
+			l = sizeof(buf) - (p - buf);
+
+			p += snprintf(p, l, ", HE-GI %d", r->he_gi);
+			l = sizeof(buf) - (p - buf);
+
+			p += snprintf(p, l, ", HE-DCM %d", r->he_dcm);
+			l = sizeof(buf) - (p - buf);
+		}
 	}
 
 	return buf;

+ 16 - 3
iwinfo_lua.c

@@ -268,6 +268,9 @@ static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
 	lua_pushboolean(L, r->is_vht);
 	lua_setfield(L, -2, rx ? "rx_vht" : "tx_vht");
 
+	lua_pushboolean(L, r->is_he);
+	lua_setfield(L, -2, rx ? "rx_he" : "tx_he");
+
 	lua_pushnumber(L, r->mhz);
 	lua_setfield(L, -2, rx ? "rx_mhz" : "tx_mhz");
 
@@ -282,7 +285,7 @@ static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
 		lua_pushboolean(L, r->is_short_gi);
 		lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
 	}
-	else if (r->is_vht)
+	else if (r->is_vht || r->is_he)
 	{
 		lua_pushnumber(L, r->mcs);
 		lua_setfield(L, -2, rx ? "rx_mcs" : "tx_mcs");
@@ -290,8 +293,18 @@ static void set_rateinfo(lua_State *L, struct iwinfo_rate_entry *r, bool rx)
 		lua_pushnumber(L, r->nss);
 		lua_setfield(L, -2, rx ? "rx_nss" : "tx_nss");
 
-		lua_pushboolean(L, r->is_short_gi);
-		lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
+		if (r->is_he) {
+			lua_pushnumber(L, r->he_gi);
+			lua_setfield(L, -2, rx ? "rx_he_gi" : "tx_he_gi");
+
+			lua_pushnumber(L, r->he_dcm);
+			lua_setfield(L, -2, rx ? "rx_he_dcm" : "tx_he_dcm");
+		}
+
+		if (r->is_vht) {
+			lua_pushboolean(L, r->is_short_gi);
+			lua_setfield(L, -2, rx ? "rx_short_gi" : "tx_short_gi");
+		}
 	}
 }
 

+ 13 - 1
iwinfo_nl80211.c

@@ -1869,7 +1869,19 @@ static void nl80211_parse_rateinfo(struct nlattr **ri,
 	else if (ri[NL80211_RATE_INFO_BITRATE])
 		re->rate = nla_get_u16(ri[NL80211_RATE_INFO_BITRATE]) * 100;
 
-	if (ri[NL80211_RATE_INFO_VHT_MCS])
+	if (ri[NL80211_RATE_INFO_HE_MCS])
+	{
+		re->is_he = 1;
+		re->mcs = nla_get_u8(ri[NL80211_RATE_INFO_HE_MCS]);
+
+		if (ri[NL80211_RATE_INFO_HE_NSS])
+			re->nss = nla_get_u8(ri[NL80211_RATE_INFO_HE_NSS]);
+		if (ri[NL80211_RATE_INFO_HE_GI])
+			re->he_gi = nla_get_u8(ri[NL80211_RATE_INFO_HE_GI]);
+		if (ri[NL80211_RATE_INFO_HE_DCM])
+			re->he_dcm = nla_get_u8(ri[NL80211_RATE_INFO_HE_DCM]);
+	}
+	else if (ri[NL80211_RATE_INFO_VHT_MCS])
 	{
 		re->is_vht = 1;
 		re->mcs = nla_get_u8(ri[NL80211_RATE_INFO_VHT_MCS]);