add support for expected throughput
authorDaniel Golle <daniel@makrotopia.org>
Wed, 14 Feb 2018 20:37:44 +0000 (21:37 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 15 Feb 2018 03:50:28 +0000 (04:50 +0100)
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>
include/iwinfo.h
iwinfo_cli.c
iwinfo_lua.c
iwinfo_nl80211.c

index a5cafa929f7039536dc39a672307230153c612ca..929f6974f0eb215629a2048f8c834d748f9fd6d3 100644 (file)
@@ -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 {
index aab6ae6598b9f828ddc02512dded5173045ac56e..49c9035664c9ceb6657f299d9952520da4ccde1f 100644 (file)
@@ -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));
        }
 }
 
index 14211115c9881873b5a91e930a348876ffcf2bb5..eebab8e8987d2f95ecae8d85d5f494854261875a 100644 (file)
@@ -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);
                }
        }
index 99177e7a8ae5f6e84e0178998bed1714009a0f5b..738e2f5ed9f4526af49caecbdc2a425e9cc8ac46 100644 (file)
@@ -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])
                {