blob: aff9a729ac2c33c703cded31b847ceb21f05922f [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 8857b2c2e18abe3b00ed6aa11d821ece68f6c468 Mon Sep 17 00:00:00 2001
2From: Peter Chiu <chui-hao.chiu@mediatek.com>
3Date: Tue, 11 Jun 2024 11:18:41 +0800
4Subject: [PATCH 11/13] mtk: wifi: iw: dump links information in station dump
5
6Parse and show the following link information
71. link address
82. Rssi
93. Tx rate
104. Rx rate
115. dtim period
124. beacon interval
13
14Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com>
15---
16 station.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
17 1 file changed, 100 insertions(+)
18
19diff --git a/station.c b/station.c
20index bf7c0f5..8e4f67d 100644
21--- a/station.c
22+++ b/station.c
23@@ -329,6 +329,7 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
24 [NL80211_STA_INFO_TX_PACKETS] = { .type = NLA_U32 },
25 [NL80211_STA_INFO_BEACON_RX] = { .type = NLA_U64},
26 [NL80211_STA_INFO_SIGNAL] = { .type = NLA_U8 },
27+ [NL80211_STA_INFO_SIGNAL_AVG] = { .type = NLA_U8 },
28 [NL80211_STA_INFO_T_OFFSET] = { .type = NLA_U64 },
29 [NL80211_STA_INFO_TX_BITRATE] = { .type = NLA_NESTED },
30 [NL80211_STA_INFO_RX_BITRATE] = { .type = NLA_NESTED },
31@@ -636,6 +637,105 @@ static int print_sta_handler(struct nl_msg *msg, void *arg)
32 }
33
34 printf("\n\tcurrent time:\t%llu ms\n", now_ms);
35+
36+ printf("\t*** MLD Information ***");
37+ if (tb[NL80211_ATTR_MLO_LINK_ID])
38+ printf("\n\tSetup link = %d", nla_get_u8(tb[NL80211_ATTR_MLO_LINK_ID]));
39+
40+ if (tb[NL80211_ATTR_MLD_ADDR]) {
41+ mac_addr_n2a(mac_addr, nla_data(tb[NL80211_ATTR_MLD_ADDR]));
42+ printf("\n\tMLD Address: %s", mac_addr);
43+ }
44+
45+ if (tb[NL80211_ATTR_MLO_LINKS]) {
46+ struct nlattr *link;
47+ char buf[100];
48+ int rem;
49+
50+ nla_for_each_nested(link, tb[NL80211_ATTR_MLO_LINKS], rem) {
51+ struct nlattr *tb_link[NL80211_ATTR_MAX + 1];
52+
53+ nla_parse_nested(tb_link, NL80211_ATTR_MAX, link, NULL);
54+
55+ if (tb_link[NL80211_ATTR_MLO_LINK_ID])
56+ printf("\n\t***** Link ID: %2d *****",
57+ nla_get_u32(tb_link[NL80211_ATTR_MLO_LINK_ID]));
58+ if (tb_link[NL80211_ATTR_MAC]) {
59+ mac_addr_n2a(buf, nla_data(tb_link[NL80211_ATTR_MAC]));
60+ printf("\n\tLink addr: %s", buf);
61+ }
62+ if (nla_parse_nested(sinfo, NL80211_STA_INFO_MAX,
63+ tb_link[NL80211_ATTR_STA_INFO],
64+ stats_policy)) {
65+ fprintf(stderr, "failed to parse nested attributes!\n");
66+ return NL_SKIP;
67+ }
68+
69+ if (sinfo[NL80211_STA_INFO_RX_BYTES64])
70+ printf("\n\trx bytes:\t%llu",
71+ nla_get_u64(sinfo[NL80211_STA_INFO_RX_BYTES64]));
72+ if (sinfo[NL80211_STA_INFO_RX_MPDUS])
73+ printf("\n\trx mpdus:\t%u",
74+ nla_get_u32(sinfo[NL80211_STA_INFO_RX_MPDUS]));
75+ if (sinfo[NL80211_STA_INFO_FCS_ERROR_COUNT])
76+ printf("\n\trx fcs errors:\t%u",
77+ nla_get_u32(sinfo[NL80211_STA_INFO_FCS_ERROR_COUNT]));
78+
79+ if (sinfo[NL80211_STA_INFO_TX_BYTES64])
80+ printf("\n\ttx bytes:\t%llu",
81+ nla_get_u64(sinfo[NL80211_STA_INFO_TX_BYTES64]));
82+ if (sinfo[NL80211_STA_INFO_TX_RETRIES])
83+ printf("\n\ttx retries:\t%u",
84+ nla_get_u32(sinfo[NL80211_STA_INFO_TX_RETRIES]));
85+ if (sinfo[NL80211_STA_INFO_TX_FAILED])
86+ printf("\n\ttx failed:\t%u",
87+ nla_get_u32(sinfo[NL80211_STA_INFO_TX_FAILED]));
88+
89+ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL]);
90+ if (sinfo[NL80211_STA_INFO_SIGNAL])
91+ printf("\n\tsignal: \t%d %sdBm",
92+ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL]),
93+ chain);
94+
95+ chain = get_chain_signal(sinfo[NL80211_STA_INFO_CHAIN_SIGNAL_AVG]);
96+ if (sinfo[NL80211_STA_INFO_SIGNAL_AVG])
97+ printf("\n\tsignal avg:\t%d %sdBm",
98+ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_SIGNAL_AVG]),
99+ chain);
100+
101+ if (sinfo[NL80211_STA_INFO_TX_BITRATE]) {
102+ parse_bitrate(sinfo[NL80211_STA_INFO_TX_BITRATE],
103+ buf, sizeof(buf));
104+ printf("\n\ttx bitrate:\t%s", buf);
105+ }
106+
107+ if (sinfo[NL80211_STA_INFO_TX_DURATION])
108+ printf("\n\ttx duration:\t%llu us",
109+ nla_get_u64(sinfo[NL80211_STA_INFO_TX_DURATION]));
110+
111+ if (sinfo[NL80211_STA_INFO_RX_BITRATE]) {
112+ parse_bitrate(sinfo[NL80211_STA_INFO_RX_BITRATE],
113+ buf, sizeof(buf));
114+ printf("\n\trx bitrate:\t%s", buf);
115+ }
116+
117+ if (sinfo[NL80211_STA_INFO_RX_DURATION])
118+ printf("\n\trx duration:\t%llu us",
119+ nla_get_u64(sinfo[NL80211_STA_INFO_RX_DURATION]));
120+
121+ if (sinfo[NL80211_STA_INFO_ACK_SIGNAL])
122+ printf("\n\tlast ack signal:%d dBm",
123+ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_ACK_SIGNAL]));
124+
125+ if (sinfo[NL80211_STA_INFO_ACK_SIGNAL_AVG])
126+ printf("\n\tavg ack signal:\t%d dBm",
127+ (int8_t)nla_get_u8(sinfo[NL80211_STA_INFO_ACK_SIGNAL_AVG]));
128+
129+ if (sinfo[NL80211_STA_INFO_BSS_PARAM])
130+ parse_bss_param(sinfo[NL80211_STA_INFO_BSS_PARAM]);
131+ }
132+ }
133+ printf("\n");
134 return NL_SKIP;
135 }
136
137--
1382.18.0
139