Search Linux Wireless

[PATCH 2/4] Prefer 32-bit bitrate

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

 



If 32-bit bitrate reported, use it. Otherwise, use 16-bit one.

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

diff --git a/link.c b/link.c
index 11ee0aa..9b5ad02 100644
--- a/link.c
+++ b/link.c
@@ -131,6 +131,7 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
 
 	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
 		[NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+		[NL80211_RATE_INFO_BITRATE_HT] = { .type = NLA_U32 },
 		[NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
 		[NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
 		[NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
@@ -174,11 +175,14 @@ static int print_link_sta(struct nl_msg *msg, void *arg)
 				     sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
 			fprintf(stderr, "failed to parse nested rate attributes!\n");
 		} else {
+			int rate = 0;
 			printf("\ttx bitrate: ");
-			if (rinfo[NL80211_RATE_INFO_BITRATE]) {
-				int rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+			if (rinfo[NL80211_RATE_INFO_BITRATE_HT])
+				rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE_HT]);
+			else if (rinfo[NL80211_RATE_INFO_BITRATE])
+				rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+			if (rate > 0)
 				printf("%d.%d MBit/s", rate / 10, rate % 10);
-			}
 
 			if (rinfo[NL80211_RATE_INFO_MCS])
 				printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
diff --git a/station.c b/station.c
index ac73e48..07e9ec3 100644
--- a/station.c
+++ b/station.c
@@ -58,6 +58,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 
 	static struct nla_policy rate_policy[NL80211_RATE_INFO_MAX + 1] = {
 		[NL80211_RATE_INFO_BITRATE] = { .type = NLA_U16 },
+		[NL80211_RATE_INFO_BITRATE_HT] = { .type = NLA_U32 },
 		[NL80211_RATE_INFO_MCS] = { .type = NLA_U8 },
 		[NL80211_RATE_INFO_40_MHZ_WIDTH] = { .type = NLA_FLAG },
 		[NL80211_RATE_INFO_SHORT_GI] = { .type = NLA_FLAG },
@@ -123,11 +124,14 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
 				     sinfo[NL80211_STA_INFO_TX_BITRATE], rate_policy)) {
 			fprintf(stderr, "failed to parse nested rate attributes!\n");
 		} else {
+			int rate = 0;
 			printf("\n\ttx bitrate:\t");
-			if (rinfo[NL80211_RATE_INFO_BITRATE]) {
-				int rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+			if (rinfo[NL80211_RATE_INFO_BITRATE_HT])
+				rate = nla_get_u32(rinfo[NL80211_RATE_INFO_BITRATE_HT]);
+			else if (rinfo[NL80211_RATE_INFO_BITRATE])
+				rate = nla_get_u16(rinfo[NL80211_RATE_INFO_BITRATE]);
+			if (rate > 0)
 				printf("%d.%d MBit/s", rate / 10, rate % 10);
-			}
 
 			if (rinfo[NL80211_RATE_INFO_MCS])
 				printf(" MCS %d", nla_get_u8(rinfo[NL80211_RATE_INFO_MCS]));
-- 
1.7.9.5

--
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