From: Daniel Golle Date: Wed, 14 Feb 2018 20:37:44 +0000 (+0100) Subject: add support for expected throughput X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fiwinfo.git;a=commitdiff_plain;h=223e09bf3f180797aeea0f6dc1721e5a55215e66;ds=sidebyside 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 --- diff --git a/include/iwinfo.h b/include/iwinfo.h index a5cafa9..929f697 100644 --- a/include/iwinfo.h +++ b/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 { diff --git a/iwinfo_cli.c b/iwinfo_cli.c index aab6ae6..49c9035 100644 --- a/iwinfo_cli.c +++ b/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)); } } diff --git a/iwinfo_lua.c b/iwinfo_lua.c index 1421111..eebab8e 100644 --- a/iwinfo_lua.c +++ b/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); } } diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c index 99177e7..738e2f5 100644 --- a/iwinfo_nl80211.c +++ b/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]) {