Browse Source

add support for expected throughput

cfg80211 allows drivers to announce the to-be-expected layer-2 datarate
using the NL80211_STA_INFO_EXPECTED_THROUGHPUT field.
This information is useful as a metric for user-space routing daemons,
so grab it via nl80211 and make it available in both C and Lua APIs,
and show expected throughput on CLI interface assoclist.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 6 years ago
parent
commit
223e09bf3f
4 changed files with 14 additions and 1 deletions
  1. 1 0
      include/iwinfo.h
  2. 4 1
      iwinfo_cli.c
  3. 5 0
      iwinfo_lua.c
  4. 4 0
      iwinfo_nl80211.c

+ 1 - 0
include/iwinfo.h

@@ -122,6 +122,7 @@ struct iwinfo_assoclist_entry {
 	uint8_t is_wme:1;
 	uint8_t is_mfp:1;
 	uint8_t is_tdls:1;
+	uint32_t thr;
 };
 
 struct iwinfo_txpwrlist_entry {

+ 4 - 1
iwinfo_cli.c

@@ -700,10 +700,13 @@ static void print_assoclist(const struct iwinfo_ops *iw, const char *ifname)
 			e->rx_packets
 		);
 
-		printf("	TX: %-38s  %8d Pkts.\n\n",
+		printf("	TX: %-38s  %8d Pkts.\n",
 			format_assocrate(&e->tx_rate),
 			e->tx_packets
 		);
+
+		printf("	expected throughput: %s\n\n",
+			format_rate(e->thr));
 	}
 }
 

+ 5 - 0
iwinfo_lua.c

@@ -328,6 +328,11 @@ static int iwinfo_L_assoclist(lua_State *L, int (*func)(const char *, char *, in
 			set_rateinfo(L, &e->rx_rate, true);
 			set_rateinfo(L, &e->tx_rate, false);
 
+			if (e->thr) {
+				lua_pushnumber(L, e->thr);
+				lua_setfield(L, -2, "expected_throughput");
+			}
+
 			lua_setfield(L, -2, macstr);
 		}
 	}

+ 4 - 0
iwinfo_nl80211.c

@@ -1701,6 +1701,7 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
 		[NL80211_STA_INFO_T_OFFSET]      = { .type = NLA_U64    },
 		[NL80211_STA_INFO_STA_FLAGS] =
 			{ .minlen = sizeof(struct nl80211_sta_flag_update) },
+		[NL80211_STA_INFO_EXPECTED_THROUGHPUT]   = { .type = NLA_U32    },
 	};
 
 	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
@@ -1758,6 +1759,9 @@ static int nl80211_get_assoclist_cb(struct nl_msg *msg, void *arg)
 		if (sinfo[NL80211_STA_INFO_T_OFFSET])
 			e->t_offset = nla_get_u64(sinfo[NL80211_STA_INFO_T_OFFSET]);
 
+		if (sinfo[NL80211_STA_INFO_EXPECTED_THROUGHPUT])
+			e->thr = nla_get_u32(sinfo[NL80211_STA_INFO_EXPECTED_THROUGHPUT]);
+
 		/* Station flags */
 		if (sinfo[NL80211_STA_INFO_STA_FLAGS])
 		{