1 /** @file wifi-debug.c
2 *
3 * @brief This file provides WIFI debug APIs.
4 *
5 * Copyright 2008-2024 NXP
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10 #include <osa.h>
11
12 #include <wifi-debug.h>
13
14 #if CONFIG_WIFI_EXTRA_DEBUG
15 static const char *const status_table[] = {
16 [0] = "Successful",
17 [1] = "Unspecified failure",
18 [10] = "Information field does not support all requested capabilities.",
19 [11] = "Could not confirm existing assiciation. Denied reassociation.",
20 [12] = "Denied Association. Reason beyond scope of Standard.",
21 [13] = "Auth Algo not supported by responding station.",
22 [14] = "Transaction sequence number of received authentication frame is out of expected sequence.",
23 [15] = "Challenge failure. Rejected Auth.",
24 [16] = "Timeout waiting for next frame in sequence. Rejected Auth.",
25 [17] = "Failure at AP to to handle additional associated STA. Rejected Assoc.",
26 [18] = "Requesting STA does not support all BSSBasicRateSet data rated. Denied Assoc.",
27 [19] = "Requesting STA does not support short preamble option. Denied Assoc.",
28 [20] = "Requesting STA does not support PBCC modulation option. Denied Assoc.",
29 [21] = "Requesting STA does not support channel agility option. Denied Assoc.",
30 [22] = "Spectrum Management capability needed. Rejected Assoc.",
31 [23] = "Power Capability element info is unacceptable. Rejected Assoc.",
32 [24] = "Supported Channels element info is unacceptable. Rejected Assoc.",
33 [25] = "Requesting STA does not support short slot time option. Rejected Assoc.",
34 [26] = "Requesting STA does not support ER-PBCC modulation option. Rejected Assoc.",
35 [27] = "Requesting STA does not support HT features. Denied Assoc.",
36 [28] = "Unreachable R0KH",
37 [29] = "AP needs PCO transition support. Requesting STA does not support it. Denied Assoc.",
38 [30] = "Try again later. Temporarily Rejected Assoc.",
39 [31] = "Violation of policy for Robust Management frame",
40 [32] = "Unspecified, QoS related failure",
41 [33] = "Insufficient bandwidth with QAP to handle another QSTA. Denied Assoc.",
42 [34] = "Poor channel conditions resulting in Assoic Denied.",
43 [35] = "Requesting STA does not support QoS facility. Denied Assoc (with QBSS).",
44 [37] = "The request has been declined",
45 [38] = "The failed. One or more parameters have invalid values",
46 [39] =
47 "The TS has not been created because the request cannot be "
48 "honored. However, a suggested Tspec is provided so that the "
49 "initiating QSTA may attempt to send another TS with the suggested "
50 "changes to the TSpec",
51 [40] = "Information Element is Invalid",
52 [41] = "Invalid Group Cipher",
53 [42] = "Invalid Pairwise Cipher",
54 [43] = "Invalid AKMP",
55 [44] = "RSN IE version unsupported ",
56 [45] = "RSN IE Capabilities are invalid ",
57 [46] = "Security policy does not allows rejected Cipher suite",
58 [47] =
59 "The TS has not been created. However, the HC may be capable "
60 "of creating a TS, in response to a request, after the time "
61 "indicated in the TS Delay element",
62 [48] = "By policy BSS not allow Direct link",
63 [49] = "QBSS does not include Destination STA",
64 [50] = "The destination STA is not a QSTA",
65 [51] = "Listen Interval is too large. Assoc Denied",
66 [52] = "Fast BSS Transition Action Frame Count Invalid",
67 [53] = "PMKID Invalid",
68 [54] = "MDIE Invalid",
69 [55] = "FTIE Invalid",
70 };
71
get_status_str(uint16_t status)72 const char *get_status_str(uint16_t status)
73 {
74 if (status < sizeof(status_table) / sizeof(status_table[0]) && status_table[status])
75 return status_table[status];
76 return "<unknown>";
77 }
78 #endif /* CONFIG_WIFI_EXTRA_DEBUG */
79
wifi_show_assoc_fail_reason(int status)80 void wifi_show_assoc_fail_reason(int status)
81 {
82 #if CONFIG_WIFI_EXTRA_DEBUG
83 (void)PRINTF("[wifi] Assoc Status: %s\n\r", get_status_str(status));
84
85 switch (status)
86 {
87 case 13:
88 (void)PRINTF("Assoc failed: Network not found.\n\r");
89 break;
90 case 18:
91 (void)PRINTF("(11n disabled ?)\n\r");
92 break;
93 }
94 #endif /* CONFIG_WIFI_EXTRA_DEBUG */
95 }
96
97 #ifdef DUMP_PACKET_MAC
dump_mac_addr(const char * msg,unsigned char * addr)98 void dump_mac_addr(const char *msg, unsigned char *addr)
99 {
100 if (msg)
101 (void)PRINTF("%s: ", msg);
102 else
103 (void)PRINTF("mac: ", msg);
104
105 int i;
106 for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++)
107 {
108 (void)PRINTF("%x", addr[i]);
109 if (i != (MLAN_MAC_ADDR_LENGTH - 1))
110 (void)PRINTF(":");
111 }
112
113 (void)PRINTF("\n\r");
114 }
115 #endif /* DUMP_PACKET_MAC */
116
117 #ifdef DEBUG_11N_AGGR
dump_packet_header(const HostCmd_DS_COMMAND * cmd)118 void dump_packet_header(const HostCmd_DS_COMMAND *cmd)
119 {
120 (void)PRINTF("Command ----- : %x\n\r", cmd->command);
121 (void)PRINTF("Size -------- : %d\n\r", cmd->size);
122 (void)PRINTF("Sequence ---- : %d\n\r", cmd->seq_num);
123 (void)PRINTF("Result ------ : %x\n\r", cmd->result);
124 }
125 #endif /* DEBUG_11N_AGGR */
126
127 #ifdef DEBUG_11N_AGGR
dump_addba_req_rsp_packet(const HostCmd_DS_COMMAND * cmd)128 void dump_addba_req_rsp_packet(const HostCmd_DS_COMMAND *cmd)
129 {
130 dump_packet_header(cmd);
131
132 HostCmd_DS_11N_ADDBA_RSP *padd_ba_rsp = (HostCmd_DS_11N_ADDBA_RSP *)&cmd->params.add_ba_rsp;
133 (void)PRINTF("add_rsp_result: %x\n\r", padd_ba_rsp->add_rsp_result);
134 (void)PRINTF("peer mac address: ");
135 int i;
136 for (i = 0; i < MLAN_MAC_ADDR_LENGTH; i++)
137 (void)PRINTF("%x ", padd_ba_rsp->peer_mac_addr[i]);
138 (void)PRINTF("\n\r");
139 (void)PRINTF("Dialog token: %x\n\r", padd_ba_rsp->dialog_token);
140 (void)PRINTF("Status code: %x\n\r", padd_ba_rsp->status_code);
141 (void)PRINTF("block_ack_param_set: %x\n\r", padd_ba_rsp->block_ack_param_set);
142 if (padd_ba_rsp->block_ack_param_set & 0x1)
143 (void)PRINTF(" AMSDU supported\n\r");
144 else
145 (void)PRINTF(" AMSDU _NOT_ supported\n\r");
146 if (padd_ba_rsp->block_ack_param_set & 0x2)
147 (void)PRINTF(" Immediate block ack\n\r");
148 else
149 (void)PRINTF(" Delayed block ack\n\r");
150 (void)PRINTF(" TID: %d\n\r", (padd_ba_rsp->block_ack_param_set & 0x3C) >> 2);
151 (void)PRINTF(" Buffer size: %d\n\r", (padd_ba_rsp->block_ack_param_set & 0xFFC) >> 6);
152 (void)PRINTF("block_ack_tmo: %x\n\r", padd_ba_rsp->block_ack_tmo);
153 (void)PRINTF("ssn: %x\n\r", padd_ba_rsp->ssn);
154 (void)PRINTF("*************************\n\r");
155 }
156 #endif /* DEBUG_11N_AGGR */
157
158 #ifdef DEBUG_11N_ASSOC
dump_htcap_info(const MrvlIETypes_HTCap_t * htcap)159 void dump_htcap_info(const MrvlIETypes_HTCap_t *htcap)
160 {
161 (void)PRINTF("******* HT Cap ******\n\r");
162 (void)PRINTF("Type: %d\n\r", htcap->header.type);
163 (void)PRINTF("Len: %d\n\r", htcap->header.len);
164 (void)PRINTF("ht cap info: 0%x\n\r", htcap->ht_cap.ht_cap_info);
165 (void)PRINTF("ampdu_param: 0%x\n\r", htcap->ht_cap.ampdu_param);
166 (void)PRINTF("supported_mcs_set: ");
167 int i;
168 for (i = 0; i < 16; i++)
169 (void)PRINTF("0x%x ", htcap->ht_cap.supported_mcs_set[i]);
170 (void)PRINTF("\n\r");
171 (void)PRINTF("ht_ext_cap: 0%x\n\r", htcap->ht_cap.ht_ext_cap);
172 (void)PRINTF("tx_bf_cap: 0x%x\n\r", htcap->ht_cap.tx_bf_cap);
173 (void)PRINTF("asel: 0x%x\n\r", htcap->ht_cap.asel);
174 }
175
dump_ht_info(const MrvlIETypes_HTInfo_t * htinfo)176 void dump_ht_info(const MrvlIETypes_HTInfo_t *htinfo)
177 {
178 (void)PRINTF("******* HT Info ******\n\r");
179 (void)PRINTF("Type: %d\n\r", htinfo->header.type);
180 (void)PRINTF("Len: %d\n\r", htinfo->header.len);
181 (void)PRINTF("pri_chan: %d\n\r", htinfo->ht_info.pri_chan);
182 (void)PRINTF("field2: 0%x\n\r", htinfo->ht_info.field2);
183 (void)PRINTF("field3: 0%x\n\r", htinfo->ht_info.field3);
184 (void)PRINTF("field4: 0%x\n\r", htinfo->ht_info.field4);
185 (void)PRINTF("basic_mcs_set: ");
186 int i;
187 for (i = 0; i < 16; i++)
188 (void)PRINTF("0x%x ", htinfo->ht_info.basic_mcs_set[i]);
189 (void)PRINTF("\n\r");
190 }
191 #endif /* DEBUG_11N_ASSOC */
192