Search Linux Wireless

[PATCH 2/2] iw: prefer 64-bit byte counters for sta_info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Vladimir Kondratiev <qca_vkondrat@xxxxxxxxxxxxxxxx>
---
 link.c    |   14 ++++++++++++--
 station.c |   12 ++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/link.c b/link.c
index 3470c4d..3a6b15a 100644
--- a/link.c
+++ b/link.c
@@ -121,6 +121,8 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
 		[NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 },
+		[NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 },
 		[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
@@ -159,11 +161,19 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
 		return NL_SKIP;
 	}
 
-	if (sinfo[NL80211_STA_INFO_RX_BYTES] && sinfo[NL80211_STA_INFO_RX_PACKETS])
+	if (sinfo[NL80211_STA_INFO_RX_BYTES64] && sinfo[NL80211_STA_INFO_RX_PACKETS])
+		printf("\tRX: %llu bytes (%u packets)\n",
+			(unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]),
+			nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]));
+	else if (sinfo[NL80211_STA_INFO_RX_BYTES] && sinfo[NL80211_STA_INFO_RX_PACKETS])
 		printf("\tRX: %u bytes (%u packets)\n",
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]),
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]));
-	if (sinfo[NL80211_STA_INFO_TX_BYTES] && sinfo[NL80211_STA_INFO_TX_PACKETS])
+	if (sinfo[NL80211_STA_INFO_TX_BYTES64] && sinfo[NL80211_STA_INFO_TX_PACKETS])
+		printf("\tTX: %llu bytes (%u packets)\n",
+			(unsigned long long)nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]),
+			nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]));
+	else if (sinfo[NL80211_STA_INFO_TX_BYTES] && sinfo[NL80211_STA_INFO_TX_PACKETS])
 		printf("\tTX: %u bytes (%u packets)\n",
 			nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]),
 			nla_get_u32(sinfo[NL80211_STA_INFO_TX_PACKETS]));
diff --git a/station.c b/station.c
index 247f445..5b132d9 100644
--- a/station.c
+++ b/station.c
@@ -42,6 +42,8 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 		[NL80211_STA_INFO_INACTIVE_TIME] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_RX_BYTES] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_TX_BYTES] = { .type = NLA_U32 },
+		[NL80211_STA_INFO_RX_BYTES64] = { .type = NLA_U64 },
+		[NL80211_STA_INFO_TX_BYTES64] = { .type = NLA_U64 },
 		[NL80211_STA_INFO_RX_PACKETS] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
 		[NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
@@ -91,13 +93,19 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 	if (sinfo[NL80211_STA_INFO_INACTIVE_TIME])
 		printf("\n\tinactive time:\t%u ms",
 			nla_get_u32(sinfo[NL80211_STA_INFO_INACTIVE_TIME]));
-	if (sinfo[NL80211_STA_INFO_RX_BYTES])
+	if (sinfo[NL80211_STA_INFO_RX_BYTES64])
+		printf("\n\trx bytes:\t%llu", (unsigned long long)
+			nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]));
+	else if (sinfo[NL80211_STA_INFO_RX_BYTES])
 		printf("\n\trx bytes:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_BYTES]));
 	if (sinfo[NL80211_STA_INFO_RX_PACKETS])
 		printf("\n\trx packets:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_RX_PACKETS]));
-	if (sinfo[NL80211_STA_INFO_TX_BYTES])
+	if (sinfo[NL80211_STA_INFO_TX_BYTES64])
+		printf("\n\ttx bytes:\t%llu", (unsigned long long)
+			nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]));
+	else if (sinfo[NL80211_STA_INFO_TX_BYTES])
 		printf("\n\ttx bytes:\t%u",
 			nla_get_u32(sinfo[NL80211_STA_INFO_TX_BYTES]));
 	if (sinfo[NL80211_STA_INFO_TX_PACKETS])
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux