From: Toke Høiland-Jørgensen Date: Wed, 20 Mar 2019 14:58:52 +0000 (+0100) Subject: nl80211: Fetch STA TX/RX duration statistics X-Git-Tag: hostap_2_9~308 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=58d4c236153a5a949d0b87865d8d6f1899f3e85e;p=thirdparty%2Fhostap.git nl80211: Fetch STA TX/RX duration statistics This makes per-STA TX/RX duration statistics available for airtime policy configuration. Signed-off-by: Toke Høiland-Jørgensen --- diff --git a/src/drivers/driver.h b/src/drivers/driver.h index fdf9d197b..351622afc 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -1759,6 +1759,7 @@ struct hostapd_data; struct hostap_sta_driver_data { unsigned long rx_packets, tx_packets; unsigned long long rx_bytes, tx_bytes; + unsigned long long rx_airtime, tx_airtime; int bytes_64bit; /* whether 64-bit byte counters are supported */ unsigned long current_tx_rate; unsigned long current_rx_rate; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index ff97720b2..090f74ecc 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6309,6 +6309,8 @@ static int get_sta_handler(struct nl_msg *msg, void *arg) [NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 }, [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 }, [NL80211_STA_INFO_ACK_SIGNAL] = { .type = NLA_U8 }, + [NL80211_STA_INFO_RX_DURATION] = { .type = NLA_U64 }, + [NL80211_STA_INFO_TX_DURATION] = { .type = NLA_U64 }, }; struct nlattr *rate[NL80211_RATE_INFO_MAX + 1]; static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = { @@ -6366,6 +6368,12 @@ static int get_sta_handler(struct nl_msg *msg, void *arg) if (stats[NL80211_STA_INFO_TX_PACKETS]) data->tx_packets = nla_get_u32(stats[NL80211_STA_INFO_TX_PACKETS]); + if (stats[NL80211_STA_INFO_RX_DURATION]) + data->rx_airtime = + nla_get_u64(stats[NL80211_STA_INFO_RX_DURATION]); + if (stats[NL80211_STA_INFO_TX_DURATION]) + data->tx_airtime = + nla_get_u64(stats[NL80211_STA_INFO_TX_DURATION]); if (stats[NL80211_STA_INFO_TX_FAILED]) data->tx_retry_failed = nla_get_u32(stats[NL80211_STA_INFO_TX_FAILED]);