xref: /wlan-driver/qcacld-3.0/core/sme/src/common/sme_trace.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * DOC: smeTrace.c
22  *  Implementation for trace related APIs
23  *
24  * Author Kiran Kumar Reddy CH L V
25  */
26 #include "ani_global.h"          /* for struct mac_context **/
27 #include "mac_trace.h"
28 #include "sme_trace.h"
29 #include "sme_internal.h"
30 #ifndef SME_TRACE_RECORD
sme_trace_init(struct mac_context * mac)31 void sme_trace_init(struct mac_context *mac)
32 {
33 
34 }
35 #endif
36 #ifdef SME_TRACE_RECORD
37 
sme_trace_get_rx_msg_string(uint32_t code)38 static uint8_t *sme_trace_get_rx_msg_string(uint32_t code)
39 {
40 	switch (code) {
41 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_SCAN_REQ);
42 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_SCAN_GET_RESULTS);
43 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_CONNECT);
44 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_SET_11DINFO);
45 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_GET_SOFTAP_DOMAIN);
46 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_SET_REGINFO);
47 		CASE_RETURN_STRING
48 			(TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CHANNEL_CONFIG);
49 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_UPDATE_CONFIG);
50 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_HDDREADYIND);
51 		CASE_RETURN_STRING
52 			(TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_RESULTS);
53 		CASE_RETURN_STRING
54 			(TRACE_CODE_SME_RX_HDD_MSG_SCAN_FLUSH_P2PRESULTS);
55 		CASE_RETURN_STRING
56 			(TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETFIRST);
57 		CASE_RETURN_STRING
58 			(TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_GETNEXT);
59 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_SCAN_RESULT_PURGE);
60 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ROAM_REASSOC);
61 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ROAM_DISCONNECT);
62 		CASE_RETURN_STRING
63 			(TRACE_CODE_SME_RX_HDD_ROAM_GET_CONNECTPROFILE);
64 		CASE_RETURN_STRING
65 			(TRACE_CODE_SME_RX_HDD_ROAM_FREE_CONNECTPROFILE);
66 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ROAM_SET_PMKIDCACHE);
67 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ROAM_DEL_PMKIDCACHE);
68 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ROAM_GET_PMKIDCACHE);
69 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_CONFIGPARAM);
70 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_MODPROFFIELDS);
71 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_CONFIG_PWRSAVE);
72 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_CONFIG_PWRSAVE);
73 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ENABLE_PWRSAVE);
74 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DISABLE_PWRSAVE);
75 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SIGNAL_POWER_EVENT);
76 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_START_AUTO_BMPSTIMER);
77 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_STOP_AUTO_BMPSTIMER);
78 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_IS_PWRSAVE_ENABLED);
79 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REQUEST_FULLPOWER);
80 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REQUEST_BMPS);
81 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_DHCP_FLAG);
82 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REQUEST_STANDBY);
83 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_WOWL_ADDBCAST_PATTERN);
84 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_WOWL_DELBCAST_PATTERN);
85 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ENTER_WOWL);
86 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_EXIT_WOWL);
87 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_KEY);
88 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REMOVE_KEY);
89 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_CNTRYCODE);
90 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_CNTRYCODE);
91 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_CFGPRIVACY);
92 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_NEIGHBOR_REPORTREQ);
93 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DBG_READREG);
94 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DBG_WRITEREG);
95 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DBG_READMEM);
96 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DBG_WRITEMEM);
97 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_OPEN_SESSION);
98 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CLOSE_SESSION);
99 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_HOSTOFFLOAD);
100 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_GTKOFFLOAD);
101 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_GTKOFFLOAD);
102 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ABORT_MACSCAN);
103 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REGISTER_MGMTFR);
104 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DEREGISTER_MGMTFR);
105 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_REMAIN_ONCHAN);
106 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SEND_ACTION);
107 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CANCEL_REMAIN_ONCHAN);
108 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_RXPFIL);
109 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_SUSPENDIND);
110 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_RESUMEREQ);
111 #ifdef WLAN_FEATURE_EXTWOW_SUPPORT
112 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_EXTWOW);
113 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE1);
114 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CONFIG_APP_TYPE2);
115 #endif
116 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_MAXTXPOW);
117 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_TXPOW);
118 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_TMLEVEL);
119 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CAPS_EXCH);
120 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_DISABLE_CAP);
121 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_DEFCCNV);
122 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_GET_CURCC);
123 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_RESET_PW5G);
124 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_RP5G);
125 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_ROAMIBAND);
126 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_RSSIDIFF);
127 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_IMMRSSIDIFF);
128 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_FTENABLED);
129 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_WESMODE);
130 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_SET_SCANCTRL);
131 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_UPDATE_P2P_IE);
132 		CASE_RETURN_STRING
133 			(TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_N_PROBES);
134 		CASE_RETURN_STRING
135 			(TRACE_CODE_SME_RX_HDD_UPDATE_ROAM_SCAN_HOME_AWAY_TIME);
136 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_STORE_JOIN_REQ);
137 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_CLEAR_JOIN_REQ);
138 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_ISSUE_JOIN_REQ);
139 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_MSG_DEAUTH_STA);
140 #ifdef FEATURE_WLAN_TDLS
141 		CASE_RETURN_STRING
142 			(TRACE_CODE_SME_RX_HDD_TDLS_LINK_ESTABLISH_PARAM);
143 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_TDLS_CHAN_SWITCH_REQ);
144 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_TDLS_SEND_MGMT_FRAME);
145 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_TDLS_CHANGE_PEER_STA);
146 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_TDLS_ADD_PEER_STA);
147 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_TDLS_DEL_PEER_STA);
148 #endif
149 		CASE_RETURN_STRING(TRACE_CODE_SME_RX_HDD_PREF_NET_LIST);
150 	default:
151 		return "UNKNOWN";
152 	}
153 }
154 
sme_trace_get_command_string(uint32_t command)155 static uint8_t *sme_trace_get_command_string(uint32_t command)
156 {
157 	switch (command) {
158 		CASE_RETURN_STRING(eSmeNoCommand);
159 		CASE_RETURN_STRING(eSmeCsrCommandMask);
160 		CASE_RETURN_STRING(eSmeCommandRoam);
161 		CASE_RETURN_STRING(eSmeCommandWmStatusChange);
162 		CASE_RETURN_STRING(eSmeQosCommandMask);
163 		CASE_RETURN_STRING(eSmeCommandAddTs);
164 		CASE_RETURN_STRING(eSmeCommandDelTs);
165 		CASE_RETURN_STRING(e_sme_command_set_hw_mode);
166 		CASE_RETURN_STRING(e_sme_command_nss_update);
167 		CASE_RETURN_STRING(e_sme_command_set_dual_mac_config);
168 		CASE_RETURN_STRING(e_sme_command_set_antenna_mode);
169 		CASE_RETURN_STRING(e_sme_command_sap_ch_width_update);
170 	default:
171 		return "UNKNOWN";
172 	}
173 }
174 
sme_trace_dump(void * mac_ctx,tp_qdf_trace_record record,uint16_t rec_index)175 static void sme_trace_dump(void *mac_ctx, tp_qdf_trace_record record,
176 			   uint16_t rec_index)
177 {
178 	switch (record->code) {
179 	case TRACE_CODE_SME_COMMAND:
180 		sme_nofl_debug("%04d %012llu %s S%d %-14s %-30s(0x%x)",
181 			       rec_index, record->qtime, record->time,
182 			       record->session, "SME COMMAND:",
183 				sme_trace_get_command_string(record->data),
184 				record->data);
185 		break;
186 	case TRACE_CODE_SME_TX_WMA_MSG:
187 		sme_nofl_debug("%04d %012llu %s S%d %-14s %-30s(0x%x)",
188 			       rec_index, record->qtime, record->time,
189 			       record->session, "TX WMA Msg:",
190 			       mac_trace_get_wma_msg_string((uint16_t)record->data),
191 			       record->data);
192 		break;
193 	case TRACE_CODE_SME_RX_WMA_MSG:
194 		sme_nofl_debug("%04d %012llu %s S%d %-14s %-30s(0x%x)",
195 			       rec_index, record->qtime, record->time, record->session,
196 			       "RX WMA Msg:",
197 			       mac_trace_get_sme_msg_string((uint16_t)record->data),
198 			       record->data);
199 		break;
200 	default:
201 		sme_nofl_debug("%04d %012llu %s S%d %-14s %-30s(0x%x)",
202 			       rec_index, record->qtime, record->time, record->session,
203 			       "RX HDD MSG:",
204 			       sme_trace_get_rx_msg_string(record->code),
205 			       record->data);
206 		break;
207 	}
208 }
209 
sme_trace_init(struct mac_context * mac)210 void sme_trace_init(struct mac_context *mac)
211 {
212 	qdf_trace_register(QDF_MODULE_ID_SME, &sme_trace_dump);
213 }
214 #endif
215