Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1 | /* |
Vivek | bea437e | 2020-01-07 19:22:44 +0530 | [diff] [blame] | 2 | * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 3 | * |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 19 | /** |
| 20 | * DOC: qdf_trace |
| 21 | * QCA driver framework (QDF) trace APIs |
| 22 | * Trace, logging, and debugging definitions and APIs |
| 23 | */ |
| 24 | |
| 25 | /* Include Files */ |
Dustin Brown | 2cd4bfb | 2018-02-26 13:00:20 -0800 | [diff] [blame] | 26 | #include "qdf_str.h" |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 27 | #include <qdf_trace.h> |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 28 | #include <qdf_module.h> |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 29 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 30 | /* macro to map qdf trace levels into the bitmask */ |
| 31 | #define QDF_TRACE_LEVEL_TO_MODULE_BITMASK(_level) ((1 << (_level))) |
| 32 | |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 33 | #include <wlan_logging_sock_svc.h> |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 34 | #include <qdf_module.h> |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 35 | static int qdf_pidx = -1; |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 36 | static bool qdf_log_dump_at_kernel_enable = true; |
| 37 | qdf_declare_param(qdf_log_dump_at_kernel_enable, bool); |
| 38 | |
| 39 | /* This value of 0 will disable the timer by default. */ |
| 40 | static uint32_t qdf_log_flush_timer_period; |
| 41 | qdf_declare_param(qdf_log_flush_timer_period, uint); |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 42 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 43 | #include "qdf_time.h" |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 44 | #include "qdf_mc_timer.h" |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 45 | #include <host_diag_core_log.h> |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 46 | |
| 47 | /* Global qdf print id */ |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 48 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 49 | /* Preprocessor definitions and constants */ |
| 50 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 51 | enum qdf_timestamp_unit qdf_log_timestamp_type = QDF_LOG_TIMESTAMP_UNIT; |
| 52 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 53 | #define DP_TRACE_META_DATA_STRLEN 50 |
| 54 | |
Rachit Kankane | 9cc217a | 2018-01-19 15:15:14 +0530 | [diff] [blame] | 55 | #ifdef TRACE_RECORD |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 56 | /* Static and Global variables */ |
| 57 | static spinlock_t ltrace_lock; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 58 | /* global qdf trace data */ |
| 59 | static t_qdf_trace_data g_qdf_trace_data; |
| 60 | /* |
| 61 | * all the call back functions for dumping MTRACE messages from ring buffer |
| 62 | * are stored in qdf_trace_cb_table,these callbacks are initialized during init |
| 63 | * only so, we will make a copy of these call back functions and maintain in to |
| 64 | * qdf_trace_restore_cb_table. Incase if we make modifications to |
| 65 | * qdf_trace_cb_table, we can certainly retrieve all the call back functions |
| 66 | * back from Restore Table |
| 67 | */ |
| 68 | static tp_qdf_trace_cb qdf_trace_cb_table[QDF_MODULE_ID_MAX]; |
| 69 | static tp_qdf_trace_cb qdf_trace_restore_cb_table[QDF_MODULE_ID_MAX]; |
Rachit Kankane | 371fce2 | 2018-06-26 19:20:05 +0530 | [diff] [blame] | 70 | |
| 71 | #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY |
| 72 | static qdf_trace_record_t *g_qdf_trace_tbl; |
| 73 | #else |
| 74 | static qdf_trace_record_t g_qdf_trace_tbl[MAX_QDF_TRACE_RECORDS]; |
| 75 | #endif |
| 76 | |
Rachit Kankane | 9cc217a | 2018-01-19 15:15:14 +0530 | [diff] [blame] | 77 | #endif |
Wen Gong | a5dfb6d | 2018-04-26 16:35:19 +0800 | [diff] [blame] | 78 | |
| 79 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 80 | static tp_qdf_state_info_cb qdf_state_info_table[QDF_MODULE_ID_MAX]; |
Wen Gong | a5dfb6d | 2018-04-26 16:35:19 +0800 | [diff] [blame] | 81 | #endif |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 82 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 83 | #ifdef CONFIG_DP_TRACE |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 84 | /* Static and Global variables */ |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 85 | #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY |
| 86 | static struct qdf_dp_trace_record_s *g_qdf_dp_trace_tbl; |
| 87 | #else |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 88 | static struct qdf_dp_trace_record_s |
| 89 | g_qdf_dp_trace_tbl[MAX_QDF_DP_TRACE_RECORDS]; |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 90 | #endif |
| 91 | static spinlock_t l_dp_trace_lock; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 92 | |
| 93 | /* |
| 94 | * all the options to configure/control DP trace are |
| 95 | * defined in this structure |
| 96 | */ |
| 97 | static struct s_qdf_dp_trace_data g_qdf_dp_trace_data; |
| 98 | /* |
| 99 | * all the call back functions for dumping DPTRACE messages from ring buffer |
| 100 | * are stored in qdf_dp_trace_cb_table, callbacks are initialized during init |
| 101 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 102 | static tp_qdf_dp_trace_cb qdf_dp_trace_cb_table[QDF_DP_TRACE_MAX + 1]; |
Nirav Shah | ae6a0b3 | 2016-04-26 11:44:42 +0530 | [diff] [blame] | 103 | #endif |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 104 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 105 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 106 | * qdf_snprintf() - wrapper function to snprintf |
| 107 | * @str_buffer: string Buffer |
| 108 | * @size: defines the size of the data record |
| 109 | * @str_format: Format string in which the message to be logged. This format |
| 110 | * string contains printf-like replacement parameters, which follow |
| 111 | * this parameter in the variable argument list. |
| 112 | * |
| 113 | * Return: None |
| 114 | */ |
| 115 | void qdf_snprintf(char *str_buffer, unsigned int size, char *str_format, ...) |
| 116 | { |
Dundi Raviteja | ddf4501 | 2018-09-28 18:17:14 +0530 | [diff] [blame] | 117 | snprintf(str_buffer, size, str_format); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 118 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 119 | qdf_export_symbol(qdf_snprintf); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 120 | |
| 121 | #ifdef QDF_ENABLE_TRACING |
| 122 | |
| 123 | /** |
| 124 | * qdf_trace_msg() - externally called trace function |
| 125 | * @module: Module identifier a member of the QDF_MODULE_ID |
| 126 | * enumeration that identifies the module issuing the trace message. |
| 127 | * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration |
| 128 | * indicating the severity of the condition causing the trace message |
| 129 | * to be issued. More severe conditions are more likely to be logged. |
| 130 | * @str_format: Format string in which the message to be logged. This format |
| 131 | * string contains printf-like replacement parameters, which follow |
| 132 | * this parameter in the variable argument list. |
| 133 | * |
| 134 | * Checks the level of severity and accordingly prints the trace messages |
| 135 | * |
| 136 | * Return: None |
| 137 | */ |
| 138 | void qdf_trace_msg(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
Dustin Brown | 9c62f7d | 2019-02-19 16:31:37 -0800 | [diff] [blame] | 139 | const char *str_format, ...) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 140 | { |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 141 | va_list val; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 142 | |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 143 | va_start(val, str_format); |
| 144 | qdf_trace_msg_cmn(qdf_pidx, module, level, str_format, val); |
| 145 | va_end(val); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 146 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 147 | qdf_export_symbol(qdf_trace_msg); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 148 | |
Dustin Brown | 013400c | 2017-11-16 13:29:24 -0800 | [diff] [blame] | 149 | void qdf_vtrace_msg(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
Dustin Brown | 9c62f7d | 2019-02-19 16:31:37 -0800 | [diff] [blame] | 150 | const char *str_format, va_list val) |
Dustin Brown | 013400c | 2017-11-16 13:29:24 -0800 | [diff] [blame] | 151 | { |
| 152 | qdf_trace_msg_cmn(qdf_pidx, module, level, str_format, val); |
| 153 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 154 | qdf_export_symbol(qdf_vtrace_msg); |
Dustin Brown | 013400c | 2017-11-16 13:29:24 -0800 | [diff] [blame] | 155 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 156 | #define ROW_SIZE 16 |
| 157 | /* Buffer size = data bytes(2 hex chars plus space) + NULL */ |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 158 | #define BUFFER_SIZE ((QDF_DP_TRACE_RECORD_SIZE * 3) + 1) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 159 | |
Himanshu Batra | bcb10e6 | 2019-06-17 18:19:18 +0530 | [diff] [blame] | 160 | static void __qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 161 | void *data, int buf_len, bool print_ascii) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 162 | { |
| 163 | const u8 *ptr = data; |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 164 | int i = 0; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 165 | |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 166 | if (!qdf_print_is_verbose_enabled(qdf_pidx, module, level)) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 167 | return; |
| 168 | |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 169 | while (buf_len > 0) { |
Dundi Raviteja | dd1d8ba | 2018-05-15 14:16:21 +0530 | [diff] [blame] | 170 | unsigned char linebuf[BUFFER_SIZE] = {0}; |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 171 | int linelen = min(buf_len, ROW_SIZE); |
| 172 | |
| 173 | buf_len -= ROW_SIZE; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 174 | |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 175 | hex_dump_to_buffer(ptr, linelen, ROW_SIZE, 1, |
Himanshu Batra | bcb10e6 | 2019-06-17 18:19:18 +0530 | [diff] [blame] | 176 | linebuf, sizeof(linebuf), print_ascii); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 177 | |
| 178 | qdf_trace_msg(module, level, "%.8x: %s", i, linebuf); |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 179 | ptr += ROW_SIZE; |
| 180 | i += ROW_SIZE; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 181 | } |
| 182 | } |
Himanshu Batra | bcb10e6 | 2019-06-17 18:19:18 +0530 | [diff] [blame] | 183 | |
| 184 | void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 185 | void *data, int buf_len) |
| 186 | { |
| 187 | __qdf_trace_hex_dump(module, level, data, buf_len, false); |
| 188 | } |
| 189 | |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 190 | qdf_export_symbol(qdf_trace_hex_dump); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 191 | |
Himanshu Batra | bcb10e6 | 2019-06-17 18:19:18 +0530 | [diff] [blame] | 192 | void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 193 | void *data, int buf_len) |
| 194 | { |
| 195 | __qdf_trace_hex_dump(module, level, data, buf_len, true); |
| 196 | } |
| 197 | |
| 198 | qdf_export_symbol(qdf_trace_hex_ascii_dump); |
| 199 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 200 | #endif |
| 201 | |
Rachit Kankane | 9cc217a | 2018-01-19 15:15:14 +0530 | [diff] [blame] | 202 | #ifdef TRACE_RECORD |
Rachit Kankane | 371fce2 | 2018-06-26 19:20:05 +0530 | [diff] [blame] | 203 | |
| 204 | #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY |
| 205 | static inline QDF_STATUS allocate_g_qdf_trace_tbl_buffer(void) |
| 206 | { |
| 207 | g_qdf_trace_tbl = vzalloc(MAX_QDF_TRACE_RECORDS * |
| 208 | sizeof(*g_qdf_trace_tbl)); |
| 209 | QDF_BUG(g_qdf_trace_tbl); |
| 210 | return g_qdf_trace_tbl ? QDF_STATUS_SUCCESS : QDF_STATUS_E_NOMEM; |
| 211 | } |
| 212 | |
| 213 | static inline void free_g_qdf_trace_tbl_buffer(void) |
| 214 | { |
| 215 | vfree(g_qdf_trace_tbl); |
| 216 | g_qdf_trace_tbl = NULL; |
| 217 | } |
| 218 | #else |
| 219 | static inline QDF_STATUS allocate_g_qdf_trace_tbl_buffer(void) |
| 220 | { |
| 221 | return QDF_STATUS_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | static inline void free_g_qdf_trace_tbl_buffer(void) |
| 225 | { } |
| 226 | #endif |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 227 | /** |
| 228 | * qdf_trace_enable() - Enable MTRACE for specific modules |
| 229 | * @bitmask_of_module_id: Bitmask according to enum of the modules. |
| 230 | * 32[dec] = 0010 0000 [bin] <enum of HDD is 5> |
| 231 | * 64[dec] = 0100 0000 [bin] <enum of SME is 6> |
| 232 | * 128[dec] = 1000 0000 [bin] <enum of PE is 7> |
| 233 | * @enable: can be true or false true implies enabling MTRACE false implies |
| 234 | * disabling MTRACE. |
| 235 | * |
| 236 | * Enable MTRACE for specific modules whose bits are set in bitmask and enable |
| 237 | * is true. if enable is false it disables MTRACE for that module. set the |
| 238 | * bitmask according to enum value of the modules. |
| 239 | * This functions will be called when you issue ioctl as mentioned following |
| 240 | * [iwpriv wlan0 setdumplog <value> <enable>]. |
| 241 | * <value> - Decimal number, i.e. 64 decimal value shows only SME module, |
| 242 | * 128 decimal value shows only PE module, 192 decimal value shows PE and SME. |
| 243 | * |
| 244 | * Return: None |
| 245 | */ |
| 246 | void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable) |
| 247 | { |
| 248 | int i; |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 249 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 250 | if (bitmask_of_module_id) { |
| 251 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 252 | if (((bitmask_of_module_id >> i) & 1)) { |
| 253 | if (enable) { |
| 254 | if (NULL != |
| 255 | qdf_trace_restore_cb_table[i]) { |
| 256 | qdf_trace_cb_table[i] = |
| 257 | qdf_trace_restore_cb_table[i]; |
| 258 | } |
| 259 | } else { |
| 260 | qdf_trace_restore_cb_table[i] = |
| 261 | qdf_trace_cb_table[i]; |
| 262 | qdf_trace_cb_table[i] = NULL; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | } else { |
| 267 | if (enable) { |
| 268 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
Jeff Johnson | 2831229 | 2019-03-18 09:49:07 -0700 | [diff] [blame] | 269 | if (qdf_trace_restore_cb_table[i]) { |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 270 | qdf_trace_cb_table[i] = |
| 271 | qdf_trace_restore_cb_table[i]; |
| 272 | } |
| 273 | } |
| 274 | } else { |
| 275 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 276 | qdf_trace_restore_cb_table[i] = |
| 277 | qdf_trace_cb_table[i]; |
| 278 | qdf_trace_cb_table[i] = NULL; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 283 | qdf_export_symbol(qdf_trace_enable); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 284 | |
| 285 | /** |
| 286 | * qdf_trace_init() - initializes qdf trace structures and variables |
| 287 | * |
| 288 | * Called immediately after cds_preopen, so that we can start recording HDD |
| 289 | * events ASAP. |
| 290 | * |
| 291 | * Return: None |
| 292 | */ |
| 293 | void qdf_trace_init(void) |
| 294 | { |
| 295 | uint8_t i; |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 296 | |
Rachit Kankane | 371fce2 | 2018-06-26 19:20:05 +0530 | [diff] [blame] | 297 | if (allocate_g_qdf_trace_tbl_buffer() != QDF_STATUS_SUCCESS) |
| 298 | return; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 299 | g_qdf_trace_data.head = INVALID_QDF_TRACE_ADDR; |
| 300 | g_qdf_trace_data.tail = INVALID_QDF_TRACE_ADDR; |
| 301 | g_qdf_trace_data.num = 0; |
| 302 | g_qdf_trace_data.enable = true; |
| 303 | g_qdf_trace_data.dump_count = DEFAULT_QDF_TRACE_DUMP_COUNT; |
| 304 | g_qdf_trace_data.num_since_last_dump = 0; |
| 305 | |
| 306 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 307 | qdf_trace_cb_table[i] = NULL; |
| 308 | qdf_trace_restore_cb_table[i] = NULL; |
| 309 | } |
| 310 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 311 | qdf_export_symbol(qdf_trace_init); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 312 | |
| 313 | /** |
Rachit Kankane | 371fce2 | 2018-06-26 19:20:05 +0530 | [diff] [blame] | 314 | * qdf_trace_deinit() - frees memory allocated dynamically |
| 315 | * |
| 316 | * Called from cds_deinit, so that we can free the memory and resets |
| 317 | * the variables |
| 318 | * |
| 319 | * Return: None |
| 320 | */ |
| 321 | void qdf_trace_deinit(void) |
| 322 | { |
| 323 | g_qdf_trace_data.enable = false; |
| 324 | g_qdf_trace_data.num = 0; |
| 325 | g_qdf_trace_data.head = INVALID_QDF_TRACE_ADDR; |
| 326 | g_qdf_trace_data.tail = INVALID_QDF_TRACE_ADDR; |
| 327 | |
| 328 | free_g_qdf_trace_tbl_buffer(); |
| 329 | } |
| 330 | |
| 331 | qdf_export_symbol(qdf_trace_deinit); |
| 332 | |
| 333 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 334 | * qdf_trace() - puts the messages in to ring-buffer |
| 335 | * @module: Enum of module, basically module id. |
Ashish Kumar Dhanotiya | 27bcaf8 | 2018-06-26 16:57:40 +0530 | [diff] [blame] | 336 | * @code: Code to be recorded |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 337 | * @session: Session ID of the log |
| 338 | * @data: Actual message contents |
| 339 | * |
| 340 | * This function will be called from each module who wants record the messages |
| 341 | * in circular queue. Before calling this functions make sure you have |
| 342 | * registered your module with qdf through qdf_trace_register function. |
| 343 | * |
| 344 | * Return: None |
| 345 | */ |
| 346 | void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data) |
| 347 | { |
| 348 | tp_qdf_trace_record rec = NULL; |
| 349 | unsigned long flags; |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 350 | char time[18]; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 351 | |
| 352 | if (!g_qdf_trace_data.enable) |
| 353 | return; |
| 354 | |
| 355 | /* if module is not registered, don't record for that module */ |
Jeff Johnson | 2831229 | 2019-03-18 09:49:07 -0700 | [diff] [blame] | 356 | if (!qdf_trace_cb_table[module]) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 357 | return; |
| 358 | |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 359 | qdf_get_time_of_the_day_in_hr_min_sec_usec(time, sizeof(time)); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 360 | /* Aquire the lock so that only one thread at a time can fill the ring |
| 361 | * buffer |
| 362 | */ |
| 363 | spin_lock_irqsave(<race_lock, flags); |
| 364 | |
| 365 | g_qdf_trace_data.num++; |
| 366 | |
| 367 | if (g_qdf_trace_data.num > MAX_QDF_TRACE_RECORDS) |
| 368 | g_qdf_trace_data.num = MAX_QDF_TRACE_RECORDS; |
| 369 | |
| 370 | if (INVALID_QDF_TRACE_ADDR == g_qdf_trace_data.head) { |
| 371 | /* first record */ |
| 372 | g_qdf_trace_data.head = 0; |
| 373 | g_qdf_trace_data.tail = 0; |
| 374 | } else { |
| 375 | /* queue is not empty */ |
| 376 | uint32_t tail = g_qdf_trace_data.tail + 1; |
| 377 | |
| 378 | if (MAX_QDF_TRACE_RECORDS == tail) |
| 379 | tail = 0; |
| 380 | |
| 381 | if (g_qdf_trace_data.head == tail) { |
| 382 | /* full */ |
| 383 | if (MAX_QDF_TRACE_RECORDS == ++g_qdf_trace_data.head) |
| 384 | g_qdf_trace_data.head = 0; |
| 385 | } |
| 386 | g_qdf_trace_data.tail = tail; |
| 387 | } |
| 388 | |
| 389 | rec = &g_qdf_trace_tbl[g_qdf_trace_data.tail]; |
| 390 | rec->code = code; |
| 391 | rec->session = session; |
| 392 | rec->data = data; |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 393 | rec->qtime = qdf_get_log_timestamp(); |
| 394 | scnprintf(rec->time, sizeof(rec->time), "%s", time); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 395 | rec->module = module; |
| 396 | rec->pid = (in_interrupt() ? 0 : current->pid); |
| 397 | g_qdf_trace_data.num_since_last_dump++; |
| 398 | spin_unlock_irqrestore(<race_lock, flags); |
| 399 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 400 | qdf_export_symbol(qdf_trace); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 401 | |
Ashish Kumar Dhanotiya | 27bcaf8 | 2018-06-26 16:57:40 +0530 | [diff] [blame] | 402 | #ifdef ENABLE_MTRACE_LOG |
| 403 | void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, |
| 404 | uint16_t message_id, uint8_t vdev_id) |
| 405 | { |
| 406 | uint32_t trace_log, payload; |
| 407 | static uint16_t counter; |
| 408 | |
| 409 | trace_log = (src_module << 23) | (dst_module << 15) | message_id; |
| 410 | payload = (vdev_id << 16) | counter++; |
| 411 | |
| 412 | QDF_TRACE(src_module, QDF_TRACE_LEVEL_TRACE, "%x %x", |
| 413 | trace_log, payload); |
| 414 | } |
| 415 | |
| 416 | qdf_export_symbol(qdf_mtrace_log); |
| 417 | #endif |
| 418 | |
| 419 | void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, |
| 420 | uint16_t message_id, uint8_t vdev_id, uint32_t data) |
| 421 | { |
| 422 | qdf_trace(src_module, message_id, vdev_id, data); |
| 423 | qdf_mtrace_log(src_module, dst_module, message_id, vdev_id); |
| 424 | } |
| 425 | |
| 426 | qdf_export_symbol(qdf_mtrace); |
| 427 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 428 | /** |
| 429 | * qdf_trace_spin_lock_init() - initializes the lock variable before use |
| 430 | * |
| 431 | * This function will be called from cds_alloc_global_context, we will have lock |
| 432 | * available to use ASAP |
| 433 | * |
| 434 | * Return: None |
| 435 | */ |
| 436 | QDF_STATUS qdf_trace_spin_lock_init(void) |
| 437 | { |
| 438 | spin_lock_init(<race_lock); |
| 439 | |
| 440 | return QDF_STATUS_SUCCESS; |
| 441 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 442 | qdf_export_symbol(qdf_trace_spin_lock_init); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 443 | |
| 444 | /** |
| 445 | * qdf_trace_register() - registers the call back functions |
| 446 | * @module_iD: enum value of module |
| 447 | * @qdf_trace_callback: call back functions to display the messages in |
| 448 | * particular format. |
| 449 | * |
| 450 | * Registers the call back functions to display the messages in particular |
| 451 | * format mentioned in these call back functions. This functions should be |
| 452 | * called by interested module in their init part as we will be ready to |
| 453 | * register as soon as modules are up. |
| 454 | * |
| 455 | * Return: None |
| 456 | */ |
Jeff Johnson | 5a0302c | 2018-05-19 09:40:57 -0700 | [diff] [blame] | 457 | void qdf_trace_register(QDF_MODULE_ID module_id, |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 458 | tp_qdf_trace_cb qdf_trace_callback) |
| 459 | { |
Jeff Johnson | 5a0302c | 2018-05-19 09:40:57 -0700 | [diff] [blame] | 460 | qdf_trace_cb_table[module_id] = qdf_trace_callback; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 461 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 462 | qdf_export_symbol(qdf_trace_register); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * qdf_trace_dump_all() - Dump data from ring buffer via call back functions |
| 466 | * registered with QDF |
| 467 | * @p_mac: Context of particular module |
| 468 | * @code: Reason code |
| 469 | * @session: Session id of log |
| 470 | * @count: Number of lines to dump starting from tail to head |
| 471 | * |
| 472 | * This function will be called up on issueing ioctl call as mentioned following |
| 473 | * [iwpriv wlan0 dumplog 0 0 <n> <bitmask_of_module>] |
| 474 | * |
| 475 | * <n> - number lines to dump starting from tail to head. |
| 476 | * |
| 477 | * <bitmask_of_module> - if anybody wants to know how many messages were |
| 478 | * recorded for particular module/s mentioned by setbit in bitmask from last |
| 479 | * <n> messages. It is optional, if you don't provide then it will dump |
| 480 | * everything from buffer. |
| 481 | * |
| 482 | * Return: None |
| 483 | */ |
| 484 | void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 485 | uint32_t count, uint32_t bitmask_of_module) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 486 | { |
| 487 | qdf_trace_record_t p_record; |
| 488 | int32_t i, tail; |
| 489 | |
| 490 | if (!g_qdf_trace_data.enable) { |
| 491 | QDF_TRACE(QDF_MODULE_ID_SYS, |
| 492 | QDF_TRACE_LEVEL_ERROR, "Tracing Disabled"); |
| 493 | return; |
| 494 | } |
| 495 | |
| 496 | QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_INFO, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 497 | "DPT: Total Records: %d, Head: %d, Tail: %d", |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 498 | g_qdf_trace_data.num, g_qdf_trace_data.head, |
| 499 | g_qdf_trace_data.tail); |
| 500 | |
| 501 | /* aquire the lock so that only one thread at a time can read |
| 502 | * the ring buffer |
| 503 | */ |
| 504 | spin_lock(<race_lock); |
| 505 | |
| 506 | if (g_qdf_trace_data.head != INVALID_QDF_TRACE_ADDR) { |
| 507 | i = g_qdf_trace_data.head; |
| 508 | tail = g_qdf_trace_data.tail; |
| 509 | |
| 510 | if (count) { |
| 511 | if (count > g_qdf_trace_data.num) |
| 512 | count = g_qdf_trace_data.num; |
| 513 | if (tail >= (count - 1)) |
| 514 | i = tail - count + 1; |
| 515 | else if (count != MAX_QDF_TRACE_RECORDS) |
| 516 | i = MAX_QDF_TRACE_RECORDS - ((count - 1) - |
| 517 | tail); |
| 518 | } |
| 519 | |
| 520 | p_record = g_qdf_trace_tbl[i]; |
| 521 | /* right now we are not using num_since_last_dump member but |
| 522 | * in future we might re-visit and use this member to track |
| 523 | * how many latest messages got added while we were dumping |
| 524 | * from ring buffer |
| 525 | */ |
| 526 | g_qdf_trace_data.num_since_last_dump = 0; |
| 527 | spin_unlock(<race_lock); |
| 528 | for (;; ) { |
| 529 | if ((code == 0 || (code == p_record.code)) && |
Jeff Johnson | 2831229 | 2019-03-18 09:49:07 -0700 | [diff] [blame] | 530 | (qdf_trace_cb_table[p_record.module])) { |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 531 | if (0 == bitmask_of_module) { |
| 532 | qdf_trace_cb_table[p_record. |
| 533 | module] (p_mac, |
| 534 | &p_record, |
| 535 | (uint16_t) |
| 536 | i); |
| 537 | } else { |
| 538 | if (bitmask_of_module & |
| 539 | (1 << p_record.module)) { |
| 540 | qdf_trace_cb_table[p_record. |
| 541 | module] |
| 542 | (p_mac, &p_record, |
| 543 | (uint16_t) i); |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | |
| 548 | if (i == tail) |
| 549 | break; |
| 550 | i += 1; |
| 551 | |
| 552 | spin_lock(<race_lock); |
| 553 | if (MAX_QDF_TRACE_RECORDS == i) { |
| 554 | i = 0; |
| 555 | p_record = g_qdf_trace_tbl[0]; |
| 556 | } else { |
| 557 | p_record = g_qdf_trace_tbl[i]; |
| 558 | } |
| 559 | spin_unlock(<race_lock); |
| 560 | } |
| 561 | } else { |
| 562 | spin_unlock(<race_lock); |
| 563 | } |
| 564 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 565 | qdf_export_symbol(qdf_trace_dump_all); |
Rachit Kankane | 9cc217a | 2018-01-19 15:15:14 +0530 | [diff] [blame] | 566 | #endif |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 567 | |
Wen Gong | a5dfb6d | 2018-04-26 16:35:19 +0800 | [diff] [blame] | 568 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 569 | /** |
| 570 | * qdf_register_debugcb_init() - initializes debug callbacks |
| 571 | * to NULL |
| 572 | * |
| 573 | * Return: None |
| 574 | */ |
| 575 | void qdf_register_debugcb_init(void) |
| 576 | { |
| 577 | uint8_t i; |
| 578 | |
| 579 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) |
| 580 | qdf_state_info_table[i] = NULL; |
| 581 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 582 | qdf_export_symbol(qdf_register_debugcb_init); |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 583 | |
| 584 | /** |
| 585 | * qdf_register_debug_callback() - stores callback handlers to print |
| 586 | * state information |
| 587 | * @module_id: module id of layer |
| 588 | * @qdf_state_infocb: callback to be registered |
| 589 | * |
| 590 | * This function is used to store callback handlers to print |
| 591 | * state information |
| 592 | * |
| 593 | * Return: None |
| 594 | */ |
| 595 | void qdf_register_debug_callback(QDF_MODULE_ID module_id, |
| 596 | tp_qdf_state_info_cb qdf_state_infocb) |
| 597 | { |
| 598 | qdf_state_info_table[module_id] = qdf_state_infocb; |
| 599 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 600 | qdf_export_symbol(qdf_register_debug_callback); |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 601 | |
| 602 | /** |
| 603 | * qdf_state_info_dump_all() - it invokes callback of layer which registered |
| 604 | * its callback to print its state information. |
| 605 | * @buf: buffer pointer to be passed |
| 606 | * @size: size of buffer to be filled |
| 607 | * @driver_dump_size: actual size of buffer used |
| 608 | * |
| 609 | * Return: QDF_STATUS_SUCCESS on success |
| 610 | */ |
| 611 | QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size, |
| 612 | uint16_t *driver_dump_size) |
| 613 | { |
| 614 | uint8_t module, ret = QDF_STATUS_SUCCESS; |
| 615 | uint16_t buf_len = size; |
| 616 | char *buf_ptr = buf; |
| 617 | |
| 618 | for (module = 0; module < QDF_MODULE_ID_MAX; module++) { |
Jeff Johnson | 2831229 | 2019-03-18 09:49:07 -0700 | [diff] [blame] | 619 | if (qdf_state_info_table[module]) { |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 620 | qdf_state_info_table[module](&buf_ptr, &buf_len); |
| 621 | if (!buf_len) { |
| 622 | ret = QDF_STATUS_E_NOMEM; |
| 623 | break; |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | *driver_dump_size = size - buf_len; |
| 629 | return ret; |
| 630 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 631 | qdf_export_symbol(qdf_state_info_dump_all); |
Wen Gong | a5dfb6d | 2018-04-26 16:35:19 +0800 | [diff] [blame] | 632 | #endif |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 633 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 634 | #ifdef CONFIG_DP_TRACE |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 635 | |
| 636 | #ifdef WLAN_LOGGING_BUFFERS_DYNAMICALLY |
| 637 | static inline QDF_STATUS allocate_g_qdf_dp_trace_tbl_buffer(void) |
| 638 | { |
| 639 | g_qdf_dp_trace_tbl = vzalloc(MAX_QDF_DP_TRACE_RECORDS * |
| 640 | sizeof(*g_qdf_dp_trace_tbl)); |
| 641 | QDF_BUG(g_qdf_dp_trace_tbl); |
| 642 | return g_qdf_dp_trace_tbl ? QDF_STATUS_SUCCESS : QDF_STATUS_E_NOMEM; |
| 643 | } |
| 644 | |
| 645 | static inline void free_g_qdf_dp_trace_tbl_buffer(void) |
| 646 | { |
| 647 | vfree(g_qdf_dp_trace_tbl); |
| 648 | g_qdf_dp_trace_tbl = NULL; |
| 649 | } |
| 650 | #else |
| 651 | static inline QDF_STATUS allocate_g_qdf_dp_trace_tbl_buffer(void) |
| 652 | { |
| 653 | return QDF_STATUS_SUCCESS; |
| 654 | } |
| 655 | |
| 656 | static inline void free_g_qdf_dp_trace_tbl_buffer(void) |
| 657 | { } |
| 658 | #endif |
| 659 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 660 | #define QDF_DP_TRACE_PREPEND_STR_SIZE 100 |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 661 | /* |
| 662 | * one dp trace record can't be greater than 300 bytes. |
| 663 | * Max Size will be QDF_DP_TRACE_PREPEND_STR_SIZE(100) + BUFFER_SIZE(121). |
| 664 | * Always make sure to change this QDF_DP_TRACE_MAX_RECORD_SIZE |
| 665 | * value accordingly whenever above two mentioned MACRO value changes. |
| 666 | */ |
| 667 | #define QDF_DP_TRACE_MAX_RECORD_SIZE 300 |
| 668 | |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 669 | static void qdf_dp_unused(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 670 | uint16_t index, uint8_t pdev_id, uint8_t info) |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 671 | { |
| 672 | qdf_print("%s: QDF_DP_TRACE_MAX event should not be generated", |
| 673 | __func__); |
| 674 | } |
| 675 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 676 | /** |
| 677 | * qdf_dp_trace_init() - enables the DP trace |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 678 | * @live_mode_config: live mode configuration |
| 679 | * @thresh: high throughput threshold for disabling live mode |
| 680 | * @thresh_time_limit: max time to wait before deciding if thresh is crossed |
| 681 | * @verbosity: dptrace verbosity level |
| 682 | * @proto_bitmap: bitmap to enable/disable specific protocols |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 683 | * |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 684 | * Called during driver load to init dptrace |
| 685 | * |
| 686 | * A brief note on the 'thresh' param - |
| 687 | * Total # of packets received in a bandwidth timer interval beyond which |
| 688 | * DP Trace logging for data packets (including ICMP) will be disabled. |
| 689 | * In memory logging will still continue for these packets. Other packets for |
| 690 | * which proto.bitmap is set will continue to be recorded in logs and in memory. |
| 691 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 692 | * Return: None |
| 693 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 694 | void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, |
| 695 | uint16_t time_limit, uint8_t verbosity, |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 696 | uint32_t proto_bitmap) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 697 | { |
| 698 | uint8_t i; |
| 699 | |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 700 | if (allocate_g_qdf_dp_trace_tbl_buffer() != QDF_STATUS_SUCCESS) { |
| 701 | QDF_TRACE_ERROR(QDF_MODULE_ID_QDF, |
| 702 | "Failed!!! DP Trace buffer allocation"); |
| 703 | return; |
| 704 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 705 | qdf_dp_trace_spin_lock_init(); |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 706 | qdf_dp_trace_clear_buffer(); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 707 | g_qdf_dp_trace_data.enable = true; |
| 708 | g_qdf_dp_trace_data.no_of_record = 1; |
| 709 | |
| 710 | g_qdf_dp_trace_data.live_mode_config = live_mode_config; |
| 711 | g_qdf_dp_trace_data.live_mode = live_mode_config; |
| 712 | g_qdf_dp_trace_data.high_tput_thresh = thresh; |
| 713 | g_qdf_dp_trace_data.thresh_time_limit = time_limit; |
| 714 | g_qdf_dp_trace_data.proto_bitmap = proto_bitmap; |
| 715 | g_qdf_dp_trace_data.verbosity = verbosity; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 716 | g_qdf_dp_trace_data.ini_conf_verbosity = verbosity; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 717 | |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 718 | for (i = 0; i < ARRAY_SIZE(qdf_dp_trace_cb_table); i++) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 719 | qdf_dp_trace_cb_table[i] = qdf_dp_display_record; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 720 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 721 | qdf_dp_trace_cb_table[QDF_DP_TRACE_HDD_TX_PACKET_RECORD] = |
| 722 | qdf_dp_trace_cb_table[QDF_DP_TRACE_HDD_RX_PACKET_RECORD] = |
| 723 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TX_PACKET_RECORD] = |
| 724 | qdf_dp_trace_cb_table[QDF_DP_TRACE_RX_PACKET_RECORD] = |
| 725 | qdf_dp_trace_cb_table[QDF_DP_TRACE_DROP_PACKET_RECORD] = |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 726 | qdf_dp_trace_cb_table[QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD] = |
| 727 | qdf_dp_trace_cb_table[QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD] = |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 728 | qdf_dp_display_data_pkt_record; |
| 729 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 730 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD] = |
| 731 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD] = |
| 732 | qdf_dp_trace_cb_table[QDF_DP_TRACE_FREE_PACKET_PTR_RECORD] = |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 733 | qdf_dp_trace_cb_table[QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD] = |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 734 | qdf_dp_display_ptr_record; |
| 735 | qdf_dp_trace_cb_table[QDF_DP_TRACE_EAPOL_PACKET_RECORD] = |
| 736 | qdf_dp_trace_cb_table[QDF_DP_TRACE_DHCP_PACKET_RECORD] = |
| 737 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ARP_PACKET_RECORD] = |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 738 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ICMP_PACKET_RECORD] = |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 739 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ICMPv6_PACKET_RECORD] = |
Saket Jha | d8d9d99 | 2019-09-30 17:27:51 -0700 | [diff] [blame] | 740 | qdf_dp_display_proto_pkt; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 741 | qdf_dp_trace_cb_table[QDF_DP_TRACE_MGMT_PACKET_RECORD] = |
| 742 | qdf_dp_display_mgmt_pkt; |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 743 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TX_CREDIT_RECORD] = |
| 744 | qdf_dp_display_credit_record; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 745 | qdf_dp_trace_cb_table[QDF_DP_TRACE_EVENT_RECORD] = |
| 746 | qdf_dp_display_event_record; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 747 | |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 748 | qdf_dp_trace_cb_table[QDF_DP_TRACE_MAX] = qdf_dp_unused; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 749 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 750 | qdf_export_symbol(qdf_dp_trace_init); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 751 | |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 752 | void qdf_dp_trace_deinit(void) |
| 753 | { |
| 754 | if (!g_qdf_dp_trace_data.enable) |
| 755 | return; |
| 756 | spin_lock_bh(&l_dp_trace_lock); |
| 757 | g_qdf_dp_trace_data.enable = false; |
| 758 | g_qdf_dp_trace_data.no_of_record = 0; |
Rachit Kankane | dfd97f3 | 2018-07-05 18:10:36 +0530 | [diff] [blame] | 759 | spin_unlock_bh(&l_dp_trace_lock); |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 760 | |
| 761 | free_g_qdf_dp_trace_tbl_buffer(); |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 762 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 763 | /** |
| 764 | * qdf_dp_trace_set_value() - Configure the value to control DP trace |
| 765 | * @proto_bitmap: defines the protocol to be tracked |
| 766 | * @no_of_records: defines the nth packet which is traced |
| 767 | * @verbosity: defines the verbosity level |
| 768 | * |
| 769 | * Return: None |
| 770 | */ |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 771 | void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_record, |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 772 | uint8_t verbosity) |
| 773 | { |
| 774 | g_qdf_dp_trace_data.proto_bitmap = proto_bitmap; |
| 775 | g_qdf_dp_trace_data.no_of_record = no_of_record; |
| 776 | g_qdf_dp_trace_data.verbosity = verbosity; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 777 | g_qdf_dp_trace_data.dynamic_verbosity_modify = true; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 778 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 779 | qdf_export_symbol(qdf_dp_trace_set_value); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 780 | |
| 781 | /** |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 782 | * qdf_dp_trace_set_verbosity() - set verbosity value |
| 783 | * |
| 784 | * @val: Value to set |
| 785 | * |
| 786 | * Return: Null |
| 787 | */ |
| 788 | void qdf_dp_trace_set_verbosity(uint32_t val) |
| 789 | { |
| 790 | g_qdf_dp_trace_data.verbosity = val; |
| 791 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 792 | qdf_export_symbol(qdf_dp_trace_set_verbosity); |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 793 | |
| 794 | /** |
| 795 | * qdf_dp_get_verbosity) - get verbosity value |
| 796 | * |
| 797 | * Return: int |
| 798 | */ |
| 799 | uint8_t qdf_dp_get_verbosity(void) |
| 800 | { |
| 801 | return g_qdf_dp_trace_data.verbosity; |
| 802 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 803 | qdf_export_symbol(qdf_dp_get_verbosity); |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 804 | |
| 805 | /** |
| 806 | * qdf_dp_set_proto_bitmap() - set dp trace proto bitmap |
| 807 | * |
| 808 | * @val : unsigned bitmap to set |
| 809 | * |
| 810 | * Return: proto bitmap |
| 811 | */ |
| 812 | void qdf_dp_set_proto_bitmap(uint32_t val) |
| 813 | { |
| 814 | g_qdf_dp_trace_data.proto_bitmap = val; |
| 815 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 816 | qdf_export_symbol(qdf_dp_set_proto_bitmap); |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 817 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 818 | void qdf_dp_set_proto_event_bitmap(uint32_t value) |
| 819 | { |
| 820 | g_qdf_dp_trace_data.proto_event_bitmap = value; |
| 821 | } |
| 822 | |
| 823 | qdf_export_symbol(qdf_dp_set_proto_event_bitmap); |
| 824 | |
| 825 | static uint32_t qdf_dp_get_proto_event_bitmap(void) |
| 826 | { |
| 827 | return g_qdf_dp_trace_data.proto_event_bitmap; |
| 828 | } |
| 829 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 830 | /** |
| 831 | * qdf_dp_set_no_of_record() - set dp trace no_of_record |
| 832 | * |
| 833 | * @val : unsigned no_of_record to set |
| 834 | * |
| 835 | * Return: null |
| 836 | */ |
| 837 | void qdf_dp_set_no_of_record(uint32_t val) |
| 838 | { |
| 839 | g_qdf_dp_trace_data.no_of_record = val; |
| 840 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 841 | qdf_export_symbol(qdf_dp_set_no_of_record); |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 842 | |
| 843 | /** |
| 844 | * qdf_dp_get_no_of_record() - get dp trace no_of_record |
| 845 | * |
| 846 | * Return: number of records |
| 847 | */ |
| 848 | uint8_t qdf_dp_get_no_of_record(void) |
| 849 | { |
| 850 | return g_qdf_dp_trace_data.no_of_record; |
| 851 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 852 | qdf_export_symbol(qdf_dp_get_no_of_record); |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 853 | |
| 854 | |
| 855 | /** |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 856 | * qdf_dp_trace_verbosity_check() - check whether verbosity level is enabled |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 857 | * @code: defines the event |
| 858 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 859 | * In High verbosity all codes are logged. |
| 860 | * For Med/Low and Default case code which has |
| 861 | * less value than corresponding verbosity codes |
| 862 | * are logged. |
| 863 | * |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 864 | * Return: true or false depends on whether tracing enabled |
| 865 | */ |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 866 | static bool qdf_dp_trace_verbosity_check(enum QDF_DP_TRACE_ID code) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 867 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 868 | switch (g_qdf_dp_trace_data.verbosity) { |
| 869 | case QDF_DP_TRACE_VERBOSITY_HIGH: |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 870 | return true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 871 | case QDF_DP_TRACE_VERBOSITY_MEDIUM: |
| 872 | if (code <= QDF_DP_TRACE_MED_VERBOSITY) |
| 873 | return true; |
| 874 | return false; |
| 875 | case QDF_DP_TRACE_VERBOSITY_LOW: |
| 876 | if (code <= QDF_DP_TRACE_LOW_VERBOSITY) |
| 877 | return true; |
| 878 | return false; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 879 | case QDF_DP_TRACE_VERBOSITY_ULTRA_LOW: |
| 880 | if (code <= QDF_DP_TRACE_ULTRA_LOW_VERBOSITY) |
| 881 | return true; |
| 882 | return false; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 883 | case QDF_DP_TRACE_VERBOSITY_BASE: |
| 884 | if (code <= QDF_DP_TRACE_BASE_VERBOSITY) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 885 | return true; |
| 886 | return false; |
| 887 | default: |
| 888 | return false; |
| 889 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 890 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 891 | |
| 892 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 893 | * qdf_dp_get_proto_bitmap() - get dp trace proto bitmap |
| 894 | * |
| 895 | * Return: proto bitmap |
| 896 | */ |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 897 | uint32_t qdf_dp_get_proto_bitmap(void) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 898 | { |
| 899 | if (g_qdf_dp_trace_data.enable) |
| 900 | return g_qdf_dp_trace_data.proto_bitmap; |
| 901 | else |
| 902 | return 0; |
| 903 | } |
| 904 | |
| 905 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 906 | * qdf_dp_trace_set_track() - Marks whether the packet needs to be traced |
| 907 | * @nbuf: defines the netbuf |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 908 | * @dir: direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 909 | * |
| 910 | * Return: None |
| 911 | */ |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 912 | void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 913 | { |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 914 | uint32_t count = 0; |
| 915 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 916 | if (!g_qdf_dp_trace_data.enable) |
| 917 | return; |
| 918 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 919 | spin_lock_bh(&l_dp_trace_lock); |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 920 | if (QDF_TX == dir) |
| 921 | count = ++g_qdf_dp_trace_data.tx_count; |
| 922 | else if (QDF_RX == dir) |
| 923 | count = ++g_qdf_dp_trace_data.rx_count; |
| 924 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 925 | if ((g_qdf_dp_trace_data.no_of_record != 0) && |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 926 | (count % g_qdf_dp_trace_data.no_of_record == 0)) { |
| 927 | if (QDF_TX == dir) |
| 928 | QDF_NBUF_CB_TX_DP_TRACE(nbuf) = 1; |
| 929 | else if (QDF_RX == dir) |
| 930 | QDF_NBUF_CB_RX_DP_TRACE(nbuf) = 1; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 931 | } |
| 932 | spin_unlock_bh(&l_dp_trace_lock); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 933 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 934 | qdf_export_symbol(qdf_dp_trace_set_track); |
Nandha Kishore Easwaran | 403b085 | 2017-07-14 17:27:53 +0530 | [diff] [blame] | 935 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 936 | /* Number of bytes to be grouped together while printing DP-Trace data */ |
| 937 | #define QDF_DUMP_DP_GROUP_SIZE 6 |
Houston Hoffman | bba5ca6 | 2016-11-12 14:24:58 -0800 | [diff] [blame] | 938 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 939 | /** |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 940 | * dump_dp_hex_trace() - Display the data in buffer |
| 941 | * @prepend_str: string to prepend the hexdump with. |
| 942 | * @inbuf: buffer which contains data to be displayed |
| 943 | * @inbuf_len: defines the size of the data to be displayed |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 944 | * |
| 945 | * Return: None |
| 946 | */ |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 947 | static void |
| 948 | dump_dp_hex_trace(char *prepend_str, uint8_t *inbuf, uint8_t inbuf_len) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 949 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 950 | unsigned char outbuf[BUFFER_SIZE]; |
| 951 | const uint8_t *inbuf_ptr = inbuf; |
| 952 | char *outbuf_ptr = outbuf; |
| 953 | int outbytes_written = 0; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 954 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 955 | qdf_mem_zero(outbuf, sizeof(outbuf)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 956 | do { |
| 957 | outbytes_written += scnprintf(outbuf_ptr, |
| 958 | BUFFER_SIZE - outbytes_written, |
| 959 | "%02x", *inbuf_ptr); |
| 960 | outbuf_ptr = outbuf + outbytes_written; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 961 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 962 | if ((inbuf_ptr - inbuf) && |
| 963 | (inbuf_ptr - inbuf + 1) % QDF_DUMP_DP_GROUP_SIZE == 0) { |
| 964 | outbytes_written += scnprintf(outbuf_ptr, |
| 965 | BUFFER_SIZE - outbytes_written, |
| 966 | " "); |
| 967 | outbuf_ptr = outbuf + outbytes_written; |
| 968 | } |
| 969 | inbuf_ptr++; |
| 970 | } while (inbuf_ptr < (inbuf + inbuf_len)); |
| 971 | DPTRACE_PRINT("%s %s", prepend_str, outbuf); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 972 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 973 | |
| 974 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 975 | * qdf_dp_code_to_string() - convert dptrace code to string |
| 976 | * @code: dptrace code |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 977 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 978 | * Return: string version of code |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 979 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 980 | static |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 981 | const char *qdf_dp_code_to_string(enum QDF_DP_TRACE_ID code) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 982 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 983 | switch (code) { |
| 984 | case QDF_DP_TRACE_DROP_PACKET_RECORD: |
| 985 | return "DROP:"; |
| 986 | case QDF_DP_TRACE_EAPOL_PACKET_RECORD: |
| 987 | return "EAPOL:"; |
| 988 | case QDF_DP_TRACE_DHCP_PACKET_RECORD: |
| 989 | return "DHCP:"; |
| 990 | case QDF_DP_TRACE_ARP_PACKET_RECORD: |
| 991 | return "ARP:"; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 992 | case QDF_DP_TRACE_ICMP_PACKET_RECORD: |
| 993 | return "ICMP:"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 994 | case QDF_DP_TRACE_ICMPv6_PACKET_RECORD: |
| 995 | return "ICMPv6:"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 996 | case QDF_DP_TRACE_MGMT_PACKET_RECORD: |
| 997 | return "MGMT:"; |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 998 | case QDF_DP_TRACE_TX_CREDIT_RECORD: |
| 999 | return "CREDIT:"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1000 | case QDF_DP_TRACE_EVENT_RECORD: |
| 1001 | return "EVENT:"; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1002 | case QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD: |
| 1003 | return "HDD: TX: PTR:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1004 | case QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD: |
| 1005 | return "LI_DP: TX: PTR:"; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1006 | case QDF_DP_TRACE_HDD_TX_PACKET_RECORD: |
| 1007 | return "HDD: TX: DATA:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1008 | case QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD: |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1009 | case QDF_DP_TRACE_TX_PACKET_RECORD: |
| 1010 | return "TX:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1011 | case QDF_DP_TRACE_CE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1012 | return "CE: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1013 | case QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1014 | return "CE: TX: FAST: PTR:"; |
Yun Park | c60a22b | 2017-08-15 12:04:11 -0700 | [diff] [blame] | 1015 | case QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD: |
| 1016 | return "CE: TX: FAST: ERR:"; |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1017 | case QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD: |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1018 | case QDF_DP_TRACE_FREE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1019 | return "FREE: TX: PTR:"; |
| 1020 | case QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD: |
| 1021 | return "HTT: RX: PTR:"; |
| 1022 | case QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD: |
| 1023 | return "HTT: RX: OF: PTR:"; |
| 1024 | case QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD: |
| 1025 | return "HDD: RX: PTR:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1026 | case QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD: |
| 1027 | return "LI_DP: RX: PTR:"; |
Himanshu Agarwal | f30a9e9 | 2017-01-31 12:57:48 +0530 | [diff] [blame] | 1028 | case QDF_DP_TRACE_HDD_RX_PACKET_RECORD: |
| 1029 | return "HDD: RX: DATA:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1030 | case QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD: |
| 1031 | return "LI_DP_NULL: RX: DATA:"; |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1032 | case QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD: |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1033 | case QDF_DP_TRACE_RX_PACKET_RECORD: |
| 1034 | return "RX:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1035 | case QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1036 | return "TXRX: TX: Q: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1037 | case QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1038 | return "TXRX: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1039 | case QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1040 | return "TXRX: TX: FAST: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1041 | case QDF_DP_TRACE_HTT_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1042 | return "HTT: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1043 | case QDF_DP_TRACE_HTC_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1044 | return "HTC: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1045 | case QDF_DP_TRACE_HIF_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1046 | return "HIF: TX: PTR:"; |
| 1047 | case QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD: |
| 1048 | return "TXRX: RX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1049 | case QDF_DP_TRACE_HDD_TX_TIMEOUT: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1050 | return "HDD: STA: TO:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1051 | case QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1052 | return "HDD: SAP: TO:"; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1053 | default: |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1054 | return "Invalid"; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1055 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1056 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1057 | |
| 1058 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1059 | * qdf_dp_dir_to_str() - convert direction to string |
| 1060 | * @dir: direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1061 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1062 | * Return: string version of direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1063 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1064 | static const char *qdf_dp_dir_to_str(enum qdf_proto_dir dir) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1065 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1066 | switch (dir) { |
| 1067 | case QDF_TX: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1068 | return " --> "; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1069 | case QDF_RX: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1070 | return " <-- "; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1071 | default: |
| 1072 | return "invalid"; |
| 1073 | } |
| 1074 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1075 | |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 1076 | static const char *qdf_dp_credit_source_to_str( |
| 1077 | enum QDF_CREDIT_UPDATE_SOURCE source) |
| 1078 | { |
| 1079 | switch (source) { |
| 1080 | case QDF_TX_SCHED: |
| 1081 | return "TX SCHED"; |
| 1082 | case QDF_TX_COMP: |
| 1083 | return "TX COMP"; |
| 1084 | case QDF_TX_CREDIT_UPDATE: |
| 1085 | return "CREDIT UP"; |
| 1086 | case QDF_TX_HTT_MSG: |
| 1087 | return "HTT TX MSG"; |
| 1088 | case QDF_HTT_ATTACH: |
| 1089 | return "HTT ATTACH"; |
| 1090 | default: |
| 1091 | return "invalid"; |
| 1092 | } |
| 1093 | } |
| 1094 | |
| 1095 | static const char *qdf_dp_operation_to_str(enum QDF_CREDIT_OPERATION op) |
| 1096 | { |
| 1097 | switch (op) { |
| 1098 | case QDF_CREDIT_INC: |
| 1099 | return "+"; |
| 1100 | case QDF_CREDIT_DEC: |
| 1101 | return "-"; |
| 1102 | case QDF_CREDIT_ABS: |
| 1103 | return "ABS"; |
| 1104 | default: |
| 1105 | return "invalid"; |
| 1106 | } |
| 1107 | } |
| 1108 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1109 | /** |
| 1110 | * qdf_dp_type_to_str() - convert packet type to string |
| 1111 | * @type: type |
| 1112 | * |
| 1113 | * Return: string version of packet type |
| 1114 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1115 | static const char *qdf_dp_type_to_str(enum qdf_proto_type type) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1116 | { |
| 1117 | switch (type) { |
| 1118 | case QDF_PROTO_TYPE_DHCP: |
| 1119 | return "DHCP"; |
| 1120 | case QDF_PROTO_TYPE_EAPOL: |
| 1121 | return "EAPOL"; |
| 1122 | case QDF_PROTO_TYPE_ARP: |
| 1123 | return "ARP"; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1124 | case QDF_PROTO_TYPE_ICMP: |
| 1125 | return "ICMP"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1126 | case QDF_PROTO_TYPE_ICMPv6: |
| 1127 | return "ICMPv6"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1128 | case QDF_PROTO_TYPE_MGMT: |
| 1129 | return "MGMT"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1130 | case QDF_PROTO_TYPE_EVENT: |
| 1131 | return "EVENT"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1132 | default: |
| 1133 | return "invalid"; |
| 1134 | } |
| 1135 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1136 | |
| 1137 | /** |
| 1138 | * qdf_dp_subtype_to_str() - convert packet subtype to string |
| 1139 | * @type: type |
| 1140 | * |
| 1141 | * Return: string version of packet subtype |
| 1142 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1143 | static const char *qdf_dp_subtype_to_str(enum qdf_proto_subtype subtype) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1144 | { |
| 1145 | switch (subtype) { |
| 1146 | case QDF_PROTO_EAPOL_M1: |
| 1147 | return "M1"; |
| 1148 | case QDF_PROTO_EAPOL_M2: |
| 1149 | return "M2"; |
| 1150 | case QDF_PROTO_EAPOL_M3: |
| 1151 | return "M3"; |
| 1152 | case QDF_PROTO_EAPOL_M4: |
| 1153 | return "M4"; |
| 1154 | case QDF_PROTO_DHCP_DISCOVER: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1155 | return "DISC"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1156 | case QDF_PROTO_DHCP_REQUEST: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1157 | return "REQ"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1158 | case QDF_PROTO_DHCP_OFFER: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1159 | return "OFF"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1160 | case QDF_PROTO_DHCP_ACK: |
| 1161 | return "ACK"; |
| 1162 | case QDF_PROTO_DHCP_NACK: |
| 1163 | return "NACK"; |
| 1164 | case QDF_PROTO_DHCP_RELEASE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1165 | return "REL"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1166 | case QDF_PROTO_DHCP_INFORM: |
| 1167 | return "INFORM"; |
| 1168 | case QDF_PROTO_DHCP_DECLINE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1169 | return "DECL"; |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1170 | case QDF_PROTO_ARP_REQ: |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1171 | case QDF_PROTO_ICMP_REQ: |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1172 | case QDF_PROTO_ICMPV6_REQ: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1173 | return "REQ"; |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1174 | case QDF_PROTO_ARP_RES: |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1175 | case QDF_PROTO_ICMP_RES: |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1176 | case QDF_PROTO_ICMPV6_RES: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1177 | return "RSP"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1178 | case QDF_PROTO_ICMPV6_RS: |
| 1179 | return "RS"; |
| 1180 | case QDF_PROTO_ICMPV6_RA: |
| 1181 | return "RA"; |
| 1182 | case QDF_PROTO_ICMPV6_NS: |
| 1183 | return "NS"; |
| 1184 | case QDF_PROTO_ICMPV6_NA: |
| 1185 | return "NA"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1186 | case QDF_PROTO_MGMT_ASSOC: |
| 1187 | return "ASSOC"; |
| 1188 | case QDF_PROTO_MGMT_DISASSOC: |
| 1189 | return "DISASSOC"; |
| 1190 | case QDF_PROTO_MGMT_AUTH: |
| 1191 | return "AUTH"; |
| 1192 | case QDF_PROTO_MGMT_DEAUTH: |
| 1193 | return "DEAUTH"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1194 | case QDF_ROAM_SYNCH: |
| 1195 | return "ROAM SYNCH"; |
| 1196 | case QDF_ROAM_COMPLETE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1197 | return "ROAM COMP"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1198 | case QDF_ROAM_EVENTID: |
| 1199 | return "ROAM EVENTID"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1200 | default: |
| 1201 | return "invalid"; |
| 1202 | } |
| 1203 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1204 | |
| 1205 | /** |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1206 | * qdf_dp_enable_check() - check if dptrace, TX/RX tracing is enabled |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1207 | * @nbuf: nbuf |
| 1208 | * @code: dptrace code |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1209 | * @dir: TX or RX direction |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1210 | * |
| 1211 | * Return: true/false |
| 1212 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1213 | static bool qdf_dp_enable_check(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, |
| 1214 | enum qdf_proto_dir dir) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1215 | { |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1216 | /* Return when Dp trace is not enabled */ |
| 1217 | if (!g_qdf_dp_trace_data.enable) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1218 | return false; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1219 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1220 | if (qdf_dp_trace_verbosity_check(code) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1221 | return false; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1222 | |
Manjunathappa Prakash | ed42ca3 | 2018-10-17 20:24:21 -0700 | [diff] [blame] | 1223 | if (nbuf && (dir == QDF_TX && ((QDF_NBUF_CB_TX_DP_TRACE(nbuf) == 0) || |
| 1224 | (QDF_NBUF_CB_TX_PACKET_TRACK(nbuf) != |
| 1225 | QDF_NBUF_TX_PKT_DATA_TRACK)))) |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1226 | return false; |
| 1227 | |
Manjunathappa Prakash | ed42ca3 | 2018-10-17 20:24:21 -0700 | [diff] [blame] | 1228 | if (nbuf && (dir == QDF_RX && (QDF_NBUF_CB_RX_DP_TRACE(nbuf) == 0))) |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1229 | return false; |
| 1230 | |
Manjunathappa Prakash | ed42ca3 | 2018-10-17 20:24:21 -0700 | [diff] [blame] | 1231 | /* |
| 1232 | * Special packets called with NULL nbuf and this API is expected to |
| 1233 | * return true |
| 1234 | */ |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1235 | return true; |
| 1236 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1237 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1238 | /** |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1239 | * qdf_dp_trace_fill_meta_str() - fill up a common meta string |
| 1240 | * @prepend_str: pointer to string |
| 1241 | * @size: size of prepend_str |
| 1242 | * @rec_index: index of record |
| 1243 | * @info: info related to the record |
| 1244 | * @record: pointer to the record |
| 1245 | * |
| 1246 | * Return: ret value from scnprintf |
| 1247 | */ |
| 1248 | static inline |
| 1249 | int qdf_dp_trace_fill_meta_str(char *prepend_str, int size, |
| 1250 | int rec_index, uint8_t info, |
| 1251 | struct qdf_dp_trace_record_s *record) |
| 1252 | { |
| 1253 | char buffer[20]; |
| 1254 | int ret = 0; |
| 1255 | bool live = info & QDF_DP_TRACE_RECORD_INFO_LIVE ? true : false; |
| 1256 | bool throttled = info & QDF_DP_TRACE_RECORD_INFO_THROTTLED ? |
| 1257 | true : false; |
| 1258 | |
| 1259 | scnprintf(buffer, sizeof(buffer), "%llu", record->time); |
| 1260 | ret = scnprintf(prepend_str, size, |
| 1261 | "%s DPT: %04d:%02d%s %s", |
| 1262 | throttled ? "*" : "", |
| 1263 | rec_index, |
| 1264 | record->pdev_id, |
| 1265 | live ? "" : buffer, |
| 1266 | qdf_dp_code_to_string(record->code)); |
| 1267 | |
| 1268 | return ret; |
| 1269 | } |
| 1270 | |
| 1271 | /** |
| 1272 | * qdf_dp_fill_record_data() - fill meta data and data into the record |
| 1273 | * @rec: pointer to record data |
| 1274 | * @data: pointer to data |
| 1275 | * @data_size: size of the data |
| 1276 | * @meta_data: pointer to metadata |
| 1277 | * @metadata_size: size of metadata |
| 1278 | * |
| 1279 | * Should be called from within a spin_lock for the qdf record. |
| 1280 | * Fills up rec->data with |metadata|data| |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1281 | * |
| 1282 | * Return: none |
| 1283 | */ |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1284 | static void qdf_dp_fill_record_data |
| 1285 | (struct qdf_dp_trace_record_s *rec, |
| 1286 | uint8_t *data, uint8_t data_size, |
| 1287 | uint8_t *meta_data, uint8_t metadata_size) |
| 1288 | { |
| 1289 | int32_t available = QDF_DP_TRACE_RECORD_SIZE; |
| 1290 | uint8_t *rec_data = rec->data; |
| 1291 | uint8_t data_to_copy = 0; |
| 1292 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 1293 | qdf_mem_zero(rec_data, QDF_DP_TRACE_RECORD_SIZE); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1294 | |
| 1295 | /* copy meta data */ |
| 1296 | if (meta_data) { |
| 1297 | if (metadata_size > available) { |
| 1298 | QDF_TRACE_WARN(QDF_MODULE_ID_QDF, |
| 1299 | "%s: meta data does not fit into the record", |
| 1300 | __func__); |
| 1301 | goto end; |
| 1302 | } |
| 1303 | qdf_mem_copy(rec_data, meta_data, metadata_size); |
| 1304 | available = available - metadata_size; |
| 1305 | } else { |
| 1306 | metadata_size = 0; |
| 1307 | } |
| 1308 | |
| 1309 | /* copy data */ |
| 1310 | if (data && (data_size > 0) && (available > 0)) { |
| 1311 | data_to_copy = data_size; |
| 1312 | if (data_size > available) |
| 1313 | data_to_copy = available; |
| 1314 | qdf_mem_copy(&rec_data[metadata_size], data, data_to_copy); |
| 1315 | } |
| 1316 | end: |
| 1317 | rec->size = data_to_copy; |
| 1318 | } |
| 1319 | |
| 1320 | /** |
| 1321 | * qdf_dp_add_record() - add dp trace record |
| 1322 | * @code: dptrace code |
| 1323 | * @pdev_id: pdev_id |
| 1324 | * @print: true to print it in kmsg |
| 1325 | * @data: data pointer |
| 1326 | * @data_size: size of data to be copied |
| 1327 | * @meta_data: meta data to be prepended to data |
| 1328 | * @metadata_size: sizeof meta data |
| 1329 | * @print: whether to print record |
| 1330 | * |
| 1331 | * Return: none |
| 1332 | */ |
| 1333 | static void qdf_dp_add_record(enum QDF_DP_TRACE_ID code, uint8_t pdev_id, |
| 1334 | uint8_t *data, uint8_t data_size, |
| 1335 | uint8_t *meta_data, uint8_t metadata_size, |
| 1336 | bool print) |
| 1337 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1338 | { |
| 1339 | struct qdf_dp_trace_record_s *rec = NULL; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1340 | int index; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1341 | bool print_this_record = false; |
| 1342 | u8 info = 0; |
| 1343 | |
| 1344 | if (code >= QDF_DP_TRACE_MAX) { |
| 1345 | QDF_TRACE_ERROR(QDF_MODULE_ID_QDF, |
| 1346 | "invalid record code %u, max code %u", |
| 1347 | code, QDF_DP_TRACE_MAX); |
| 1348 | return; |
| 1349 | } |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 1350 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1351 | spin_lock_bh(&l_dp_trace_lock); |
| 1352 | |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 1353 | if (print || g_qdf_dp_trace_data.force_live_mode) { |
| 1354 | print_this_record = true; |
| 1355 | } else if (g_qdf_dp_trace_data.live_mode == 1) { |
| 1356 | print_this_record = true; |
| 1357 | g_qdf_dp_trace_data.print_pkt_cnt++; |
| 1358 | if (g_qdf_dp_trace_data.print_pkt_cnt > |
| 1359 | g_qdf_dp_trace_data.high_tput_thresh) { |
| 1360 | g_qdf_dp_trace_data.live_mode = 0; |
| 1361 | g_qdf_dp_trace_data.verbosity = |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1362 | QDF_DP_TRACE_VERBOSITY_ULTRA_LOW; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 1363 | info |= QDF_DP_TRACE_RECORD_INFO_THROTTLED; |
| 1364 | } |
| 1365 | } |
| 1366 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1367 | g_qdf_dp_trace_data.num++; |
| 1368 | |
| 1369 | if (g_qdf_dp_trace_data.num > MAX_QDF_DP_TRACE_RECORDS) |
| 1370 | g_qdf_dp_trace_data.num = MAX_QDF_DP_TRACE_RECORDS; |
| 1371 | |
| 1372 | if (INVALID_QDF_DP_TRACE_ADDR == g_qdf_dp_trace_data.head) { |
| 1373 | /* first record */ |
| 1374 | g_qdf_dp_trace_data.head = 0; |
| 1375 | g_qdf_dp_trace_data.tail = 0; |
| 1376 | } else { |
| 1377 | /* queue is not empty */ |
| 1378 | g_qdf_dp_trace_data.tail++; |
| 1379 | |
| 1380 | if (MAX_QDF_DP_TRACE_RECORDS == g_qdf_dp_trace_data.tail) |
| 1381 | g_qdf_dp_trace_data.tail = 0; |
| 1382 | |
| 1383 | if (g_qdf_dp_trace_data.head == g_qdf_dp_trace_data.tail) { |
| 1384 | /* full */ |
| 1385 | if (MAX_QDF_DP_TRACE_RECORDS == |
| 1386 | ++g_qdf_dp_trace_data.head) |
| 1387 | g_qdf_dp_trace_data.head = 0; |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | rec = &g_qdf_dp_trace_tbl[g_qdf_dp_trace_data.tail]; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1392 | index = g_qdf_dp_trace_data.tail; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1393 | rec->code = code; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1394 | rec->pdev_id = pdev_id; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1395 | rec->size = 0; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1396 | qdf_dp_fill_record_data(rec, data, data_size, |
| 1397 | meta_data, metadata_size); |
| 1398 | rec->time = qdf_get_log_timestamp(); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1399 | rec->pid = (in_interrupt() ? 0 : current->pid); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1400 | |
| 1401 | if (rec->code >= QDF_DP_TRACE_MAX) { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1402 | QDF_TRACE_ERROR(QDF_MODULE_ID_QDF, |
| 1403 | "invalid record code %u, max code %u", |
| 1404 | rec->code, QDF_DP_TRACE_MAX); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1405 | return; |
| 1406 | } |
| 1407 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1408 | spin_unlock_bh(&l_dp_trace_lock); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1409 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1410 | info |= QDF_DP_TRACE_RECORD_INFO_LIVE; |
| 1411 | if (print_this_record) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1412 | qdf_dp_trace_cb_table[rec->code] (rec, index, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1413 | QDF_TRACE_DEFAULT_PDEV_ID, info); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1414 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1415 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1416 | /** |
| 1417 | * qdf_get_rate_limit_by_type() - Get the rate limit by pkt type |
| 1418 | * @type: packet type |
| 1419 | * |
| 1420 | * Return: Rate limit value for a particular packet type |
| 1421 | */ |
| 1422 | static inline |
| 1423 | uint8_t qdf_get_rate_limit_by_type(uint8_t type) |
| 1424 | { |
| 1425 | switch (type) { |
| 1426 | case QDF_PROTO_TYPE_DHCP: |
| 1427 | return QDF_MAX_DHCP_PKTS_PER_SEC; |
| 1428 | case QDF_PROTO_TYPE_EAPOL: |
| 1429 | return QDF_MAX_EAPOL_PKTS_PER_SEC; |
| 1430 | case QDF_PROTO_TYPE_ARP: |
| 1431 | return QDF_MAX_ARP_PKTS_PER_SEC; |
| 1432 | case QDF_PROTO_TYPE_DNS: |
| 1433 | return QDF_MAX_DNS_PKTS_PER_SEC; |
| 1434 | default: |
| 1435 | return QDF_MAX_OTHER_PKTS_PER_SEC; |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | /** |
| 1440 | * qdf_get_pkt_type_string() - Get the string based on pkt type |
| 1441 | * @subtype: packet type |
| 1442 | * |
| 1443 | * Return: String based on pkt type |
| 1444 | */ |
| 1445 | static |
| 1446 | uint8_t *qdf_get_pkt_type_string(uint8_t subtype) |
| 1447 | { |
| 1448 | switch (subtype) { |
| 1449 | case QDF_PROTO_EAPOL_M1: |
| 1450 | return "EAPOL-1"; |
| 1451 | case QDF_PROTO_EAPOL_M2: |
| 1452 | return "EAPOL-2"; |
| 1453 | case QDF_PROTO_EAPOL_M3: |
| 1454 | return "EAPOL-3"; |
| 1455 | case QDF_PROTO_EAPOL_M4: |
| 1456 | return "EAPOL-4"; |
| 1457 | case QDF_PROTO_DHCP_DISCOVER: |
| 1458 | return "DHCP-D"; |
| 1459 | case QDF_PROTO_DHCP_REQUEST: |
| 1460 | return "DHCP-R"; |
| 1461 | case QDF_PROTO_DHCP_OFFER: |
| 1462 | return "DHCP-O"; |
| 1463 | case QDF_PROTO_DHCP_ACK: |
| 1464 | return "DHCP-A"; |
| 1465 | case QDF_PROTO_DHCP_NACK: |
| 1466 | return "DHCP-NA"; |
| 1467 | case QDF_PROTO_ARP_REQ: |
| 1468 | return "ARP-RQ"; |
| 1469 | case QDF_PROTO_ARP_RES: |
| 1470 | return "ARP-RS"; |
| 1471 | case QDF_PROTO_DNS_QUERY: |
| 1472 | return "DNS_Q"; |
| 1473 | case QDF_PROTO_DNS_RES: |
| 1474 | return "DNS_RS"; |
| 1475 | default: |
| 1476 | return "UNKNOWN"; |
| 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | /** |
| 1481 | * qdf_get_pkt_status_string() - Get the string based on pkt status |
| 1482 | * @status: packet status |
| 1483 | * |
| 1484 | * Return: String based on pkt status |
| 1485 | */ |
| 1486 | static |
| 1487 | uint8_t *qdf_get_pkt_status_string(uint8_t status) |
| 1488 | { |
| 1489 | switch (status) { |
| 1490 | case QDF_TX_RX_STATUS_INVALID: |
| 1491 | return "inv"; |
| 1492 | case QDF_TX_RX_STATUS_OK: |
| 1493 | return "succ"; |
| 1494 | case QDF_TX_RX_STATUS_FW_DISCARD: |
| 1495 | return "disc"; |
| 1496 | case QDF_TX_RX_STATUS_NO_ACK: |
| 1497 | return "nack"; |
| 1498 | case QDF_TX_RX_STATUS_DROP: |
| 1499 | return "drop"; |
| 1500 | default: |
| 1501 | return "unknown"; |
| 1502 | } |
| 1503 | } |
| 1504 | |
| 1505 | /** |
| 1506 | * qdf_dp_log_proto_pkt_info() - Send diag log with pkt info |
| 1507 | * @sa: Source MAC address |
| 1508 | * @da: Destination MAC address |
| 1509 | * @type: packet type |
| 1510 | * @subtype: packet subtype |
| 1511 | * @dir: tx or rx |
| 1512 | * @msdu_id: MSDU id |
| 1513 | * @status: status code |
| 1514 | * |
| 1515 | * Return: none |
| 1516 | */ |
| 1517 | void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type, |
| 1518 | uint8_t subtype, uint8_t dir, uint8_t msdu_id, |
| 1519 | uint8_t status) |
| 1520 | { |
| 1521 | uint8_t pkt_rate_limit; |
| 1522 | static ulong last_ticks[QDF_PROTO_SUBTYPE_MAX] = {0}; |
| 1523 | ulong curr_ticks = jiffies; |
| 1524 | |
| 1525 | pkt_rate_limit = qdf_get_rate_limit_by_type(type); |
| 1526 | |
| 1527 | if (!time_after(curr_ticks, last_ticks[subtype] + HZ / pkt_rate_limit)) |
| 1528 | return; |
| 1529 | |
| 1530 | last_ticks[subtype] = curr_ticks; |
| 1531 | |
| 1532 | if (status == QDF_TX_RX_STATUS_INVALID) |
| 1533 | qdf_nofl_info("%s %s: SA:%pM DA:%pM", |
| 1534 | qdf_get_pkt_type_string(subtype), dir ? "RX":"TX", |
| 1535 | sa, da); |
| 1536 | else |
| 1537 | qdf_nofl_info("%s %s: SA:%pM DA:%pM msdu_id:%d status: %s", |
| 1538 | qdf_get_pkt_type_string(subtype), dir ? "RX":"TX", |
| 1539 | sa, da, msdu_id, |
| 1540 | qdf_get_pkt_status_string(status)); |
| 1541 | } |
| 1542 | |
| 1543 | qdf_export_symbol(qdf_dp_log_proto_pkt_info); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1544 | |
| 1545 | /** |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1546 | * qdf_log_icmpv6_pkt() - log ICMPv6 packet |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1547 | * @vdev_id: ID of the vdev |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1548 | * @skb: skb pointer |
| 1549 | * @dir: direction |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1550 | * @pdev_id: ID of the pdev |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1551 | * |
| 1552 | * Return: true/false |
| 1553 | */ |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1554 | static bool qdf_log_icmpv6_pkt(uint8_t vdev_id, struct sk_buff *skb, |
| 1555 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1556 | { |
| 1557 | enum qdf_proto_subtype subtype; |
| 1558 | |
| 1559 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ICMPv6) && |
| 1560 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_ICMPv6 == |
| 1561 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1562 | (dir == QDF_RX && qdf_nbuf_is_icmpv6_pkt(skb) == true))) { |
| 1563 | |
| 1564 | subtype = qdf_nbuf_get_icmpv6_subtype(skb); |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1565 | |
| 1566 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = false; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1567 | if (dir == QDF_TX) |
| 1568 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1569 | else if (dir == QDF_RX) |
| 1570 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
| 1571 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1572 | DPTRACE(qdf_dp_trace_proto_pkt( |
| 1573 | QDF_DP_TRACE_ICMPv6_PACKET_RECORD, |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1574 | vdev_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1575 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
| 1576 | QDF_PROTO_TYPE_ICMPv6, subtype, dir, pdev_id, false)); |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1577 | |
| 1578 | switch (subtype) { |
| 1579 | case QDF_PROTO_ICMPV6_REQ: |
| 1580 | g_qdf_dp_trace_data.icmpv6_req++; |
| 1581 | break; |
| 1582 | case QDF_PROTO_ICMPV6_RES: |
| 1583 | g_qdf_dp_trace_data.icmpv6_resp++; |
| 1584 | break; |
| 1585 | case QDF_PROTO_ICMPV6_RS: |
| 1586 | g_qdf_dp_trace_data.icmpv6_rs++; |
| 1587 | break; |
| 1588 | case QDF_PROTO_ICMPV6_RA: |
| 1589 | g_qdf_dp_trace_data.icmpv6_ra++; |
| 1590 | break; |
| 1591 | case QDF_PROTO_ICMPV6_NS: |
| 1592 | g_qdf_dp_trace_data.icmpv6_ns++; |
| 1593 | break; |
| 1594 | case QDF_PROTO_ICMPV6_NA: |
| 1595 | g_qdf_dp_trace_data.icmpv6_na++; |
| 1596 | break; |
| 1597 | default: |
| 1598 | break; |
| 1599 | } |
| 1600 | return true; |
| 1601 | } |
| 1602 | |
| 1603 | return false; |
| 1604 | } |
| 1605 | |
| 1606 | /** |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1607 | * qdf_log_icmp_pkt() - log ICMP packet |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1608 | * @vdev_id: ID of the vdev |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1609 | * @skb: skb pointer |
| 1610 | * @dir: direction |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1611 | * @pdev_id: ID of the pdev |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1612 | * |
| 1613 | * Return: true/false |
| 1614 | */ |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1615 | static bool qdf_log_icmp_pkt(uint8_t vdev_id, struct sk_buff *skb, |
| 1616 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1617 | { |
| 1618 | enum qdf_proto_subtype proto_subtype; |
| 1619 | |
| 1620 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ICMP) && |
| 1621 | (qdf_nbuf_is_icmp_pkt(skb) == true)) { |
| 1622 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1623 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = false; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1624 | proto_subtype = qdf_nbuf_get_icmp_subtype(skb); |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1625 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1626 | if (QDF_TX == dir) |
| 1627 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1628 | else if (QDF_RX == dir) |
| 1629 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
| 1630 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1631 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_ICMP_PACKET_RECORD, |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1632 | vdev_id, |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1633 | skb->data + |
| 1634 | QDF_NBUF_SRC_MAC_OFFSET, |
| 1635 | skb->data + |
| 1636 | QDF_NBUF_DEST_MAC_OFFSET, |
| 1637 | QDF_PROTO_TYPE_ICMP, |
| 1638 | proto_subtype, dir, pdev_id, |
| 1639 | false)); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1640 | |
| 1641 | if (proto_subtype == QDF_PROTO_ICMP_REQ) |
| 1642 | g_qdf_dp_trace_data.icmp_req++; |
| 1643 | else |
| 1644 | g_qdf_dp_trace_data.icmp_resp++; |
| 1645 | |
| 1646 | return true; |
| 1647 | } |
| 1648 | return false; |
| 1649 | } |
| 1650 | |
| 1651 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1652 | * qdf_log_eapol_pkt() - log EAPOL packet |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1653 | * @vdev_id: ID of the vdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1654 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1655 | * @dir: direction |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1656 | * @pdev_id: ID of the pdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1657 | * |
| 1658 | * Return: true/false |
| 1659 | */ |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1660 | static bool qdf_log_eapol_pkt(uint8_t vdev_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1661 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1662 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1663 | enum qdf_proto_subtype subtype; |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1664 | uint32_t dp_eap_trace; |
| 1665 | uint32_t dp_eap_event; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1666 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1667 | dp_eap_trace = qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_EAPOL; |
| 1668 | dp_eap_event = qdf_dp_get_proto_event_bitmap() & |
| 1669 | QDF_NBUF_PKT_TRAC_TYPE_EAPOL; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1670 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1671 | if (!dp_eap_trace && !dp_eap_event) |
| 1672 | return false; |
| 1673 | |
| 1674 | if (!((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_EAPOL == |
| 1675 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1676 | (dir == QDF_RX && qdf_nbuf_is_ipv4_eapol_pkt(skb) == true))) |
| 1677 | return false; |
| 1678 | |
| 1679 | subtype = qdf_nbuf_get_eapol_subtype(skb); |
| 1680 | |
| 1681 | if (dp_eap_event && dir == QDF_RX) |
| 1682 | qdf_dp_log_proto_pkt_info(skb->data + QDF_NBUF_SRC_MAC_OFFSET, |
| 1683 | skb->data + QDF_NBUF_DEST_MAC_OFFSET, |
| 1684 | QDF_PROTO_TYPE_EAPOL, subtype, dir, |
| 1685 | QDF_TRACE_DEFAULT_MSDU_ID, |
| 1686 | QDF_TX_RX_STATUS_INVALID); |
| 1687 | |
| 1688 | if (dp_eap_trace) { |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1689 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1690 | if (QDF_TX == dir) |
| 1691 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1692 | else if (QDF_RX == dir) |
| 1693 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1694 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1695 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_EAPOL_PACKET_RECORD, |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1696 | vdev_id, |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1697 | skb->data + |
| 1698 | QDF_NBUF_SRC_MAC_OFFSET, |
| 1699 | skb->data + |
| 1700 | QDF_NBUF_DEST_MAC_OFFSET, |
| 1701 | QDF_PROTO_TYPE_EAPOL, subtype, |
| 1702 | dir, pdev_id, true)); |
| 1703 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1704 | switch (subtype) { |
| 1705 | case QDF_PROTO_EAPOL_M1: |
| 1706 | g_qdf_dp_trace_data.eapol_m1++; |
| 1707 | break; |
| 1708 | case QDF_PROTO_EAPOL_M2: |
| 1709 | g_qdf_dp_trace_data.eapol_m2++; |
| 1710 | break; |
| 1711 | case QDF_PROTO_EAPOL_M3: |
| 1712 | g_qdf_dp_trace_data.eapol_m3++; |
| 1713 | break; |
| 1714 | case QDF_PROTO_EAPOL_M4: |
| 1715 | g_qdf_dp_trace_data.eapol_m4++; |
| 1716 | break; |
| 1717 | default: |
| 1718 | g_qdf_dp_trace_data.eapol_others++; |
| 1719 | break; |
| 1720 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1721 | } |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1722 | |
| 1723 | return true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1724 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1725 | |
| 1726 | /** |
| 1727 | * qdf_log_dhcp_pkt() - log DHCP packet |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1728 | * @vdev_id: ID of the vdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1729 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1730 | * @dir: direction |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1731 | * @pdev_id: ID of the pdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1732 | * |
| 1733 | * Return: true/false |
| 1734 | */ |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1735 | static bool qdf_log_dhcp_pkt(uint8_t vdev_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1736 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1737 | { |
| 1738 | enum qdf_proto_subtype subtype = QDF_PROTO_INVALID; |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1739 | uint32_t dp_dhcp_trace; |
| 1740 | uint32_t dp_dhcp_event; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1741 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1742 | dp_dhcp_trace = qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_DHCP; |
| 1743 | dp_dhcp_event = qdf_dp_get_proto_event_bitmap() & |
| 1744 | QDF_NBUF_PKT_TRAC_TYPE_DHCP; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1745 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1746 | if (!dp_dhcp_trace && !dp_dhcp_event) |
| 1747 | return false; |
| 1748 | |
| 1749 | if (!((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP == |
| 1750 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1751 | (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) |
| 1752 | return false; |
| 1753 | |
| 1754 | subtype = qdf_nbuf_get_dhcp_subtype(skb); |
| 1755 | |
| 1756 | if (dp_dhcp_event && dir == QDF_RX) |
| 1757 | qdf_dp_log_proto_pkt_info(skb->data + QDF_NBUF_SRC_MAC_OFFSET, |
| 1758 | skb->data + QDF_NBUF_DEST_MAC_OFFSET, |
| 1759 | QDF_PROTO_TYPE_DHCP, subtype, dir, |
| 1760 | QDF_TRACE_DEFAULT_MSDU_ID, |
| 1761 | QDF_TX_RX_STATUS_INVALID); |
| 1762 | |
| 1763 | if (dp_dhcp_trace) { |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1764 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1765 | if (QDF_TX == dir) |
| 1766 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1767 | else if (QDF_RX == dir) |
| 1768 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1769 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1770 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_DHCP_PACKET_RECORD, |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1771 | vdev_id, |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1772 | skb->data + |
| 1773 | QDF_NBUF_SRC_MAC_OFFSET, |
| 1774 | skb->data + |
| 1775 | QDF_NBUF_DEST_MAC_OFFSET, |
| 1776 | QDF_PROTO_TYPE_DHCP, subtype, |
| 1777 | dir, pdev_id, true)); |
| 1778 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1779 | switch (subtype) { |
| 1780 | case QDF_PROTO_DHCP_DISCOVER: |
| 1781 | g_qdf_dp_trace_data.dhcp_disc++; |
| 1782 | break; |
| 1783 | case QDF_PROTO_DHCP_OFFER: |
| 1784 | g_qdf_dp_trace_data.dhcp_off++; |
| 1785 | break; |
| 1786 | case QDF_PROTO_DHCP_REQUEST: |
| 1787 | g_qdf_dp_trace_data.dhcp_req++; |
| 1788 | break; |
| 1789 | case QDF_PROTO_DHCP_ACK: |
| 1790 | g_qdf_dp_trace_data.dhcp_ack++; |
| 1791 | break; |
| 1792 | case QDF_PROTO_DHCP_NACK: |
| 1793 | g_qdf_dp_trace_data.dhcp_nack++; |
| 1794 | break; |
| 1795 | default: |
| 1796 | g_qdf_dp_trace_data.eapol_others++; |
| 1797 | break; |
| 1798 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1799 | } |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1800 | |
| 1801 | return true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1802 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1803 | |
| 1804 | /** |
| 1805 | * qdf_log_arp_pkt() - log ARP packet |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1806 | * @vdev_id: ID of the vdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1807 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1808 | * @dir: direction |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1809 | * @pdev_id: ID of the pdev |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1810 | * |
| 1811 | * Return: true/false |
| 1812 | */ |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1813 | static bool qdf_log_arp_pkt(uint8_t vdev_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1814 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1815 | { |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1816 | enum qdf_proto_subtype proto_subtype; |
| 1817 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1818 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ARP) && |
Nirav Shah | 9c3b3fe | 2016-07-20 16:05:06 +0530 | [diff] [blame] | 1819 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_ARP == |
| 1820 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1821 | (dir == QDF_RX && qdf_nbuf_is_ipv4_arp_pkt(skb) == true))) { |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1822 | |
Himanshu Agarwal | fcd64e9 | 2016-07-20 17:45:58 +0530 | [diff] [blame] | 1823 | proto_subtype = qdf_nbuf_get_arp_subtype(skb); |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1824 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1825 | if (QDF_TX == dir) |
| 1826 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1827 | else if (QDF_RX == dir) |
| 1828 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1829 | |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1830 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_ARP_PACKET_RECORD, |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1831 | vdev_id, |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 1832 | skb->data + |
| 1833 | QDF_NBUF_SRC_MAC_OFFSET, |
| 1834 | skb->data + |
| 1835 | QDF_NBUF_DEST_MAC_OFFSET, |
| 1836 | QDF_PROTO_TYPE_ARP, |
| 1837 | proto_subtype, dir, pdev_id, |
| 1838 | true)); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1839 | |
| 1840 | if (QDF_PROTO_ARP_REQ == proto_subtype) |
| 1841 | g_qdf_dp_trace_data.arp_req++; |
| 1842 | else |
| 1843 | g_qdf_dp_trace_data.arp_resp++; |
| 1844 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1845 | return true; |
| 1846 | } |
| 1847 | return false; |
| 1848 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1849 | |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1850 | |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1851 | bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1852 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1853 | { |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 1854 | if (!qdf_dp_get_proto_bitmap() && !qdf_dp_get_proto_event_bitmap()) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1855 | return false; |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1856 | if (qdf_log_arp_pkt(vdev_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1857 | return true; |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1858 | if (qdf_log_dhcp_pkt(vdev_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1859 | return true; |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1860 | if (qdf_log_eapol_pkt(vdev_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1861 | return true; |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1862 | if (qdf_log_icmp_pkt(vdev_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1863 | return true; |
Jeff Johnson | 5b92ee0 | 2019-01-15 14:40:56 -0800 | [diff] [blame] | 1864 | if (qdf_log_icmpv6_pkt(vdev_id, skb, dir, pdev_id)) |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1865 | return true; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1866 | return false; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1867 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 1868 | qdf_export_symbol(qdf_dp_trace_log_pkt); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1869 | |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1870 | void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1871 | uint16_t index, uint8_t pdev_id, uint8_t info) |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1872 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1873 | int loc; |
| 1874 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1875 | struct qdf_dp_trace_mgmt_buf *buf = |
| 1876 | (struct qdf_dp_trace_mgmt_buf *)record->data; |
| 1877 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 1878 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1879 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 1880 | index, info, record); |
| 1881 | |
| 1882 | DPTRACE_PRINT("%s [%d] [%s %s]", |
| 1883 | prepend_str, |
| 1884 | buf->vdev_id, |
| 1885 | qdf_dp_type_to_str(buf->type), |
| 1886 | qdf_dp_subtype_to_str(buf->subtype)); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1887 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 1888 | qdf_export_symbol(qdf_dp_display_mgmt_pkt); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1889 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1890 | |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1891 | void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1892 | uint8_t pdev_id, enum qdf_proto_type type, |
| 1893 | enum qdf_proto_subtype subtype) |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1894 | { |
| 1895 | struct qdf_dp_trace_mgmt_buf buf; |
| 1896 | int buf_size = sizeof(struct qdf_dp_trace_mgmt_buf); |
| 1897 | |
| 1898 | if (qdf_dp_enable_check(NULL, code, QDF_NA) == false) |
| 1899 | return; |
| 1900 | |
| 1901 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1902 | QDF_BUG(0); |
| 1903 | |
| 1904 | buf.type = type; |
| 1905 | buf.subtype = subtype; |
| 1906 | buf.vdev_id = vdev_id; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1907 | qdf_dp_add_record(code, pdev_id, (uint8_t *)&buf, buf_size, |
| 1908 | NULL, 0, true); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1909 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 1910 | qdf_export_symbol(qdf_dp_trace_mgmt_pkt); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1911 | |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 1912 | static void |
| 1913 | qdf_dpt_display_credit_record_debugfs(qdf_debugfs_file_t file, |
| 1914 | struct qdf_dp_trace_record_s *record, |
| 1915 | uint32_t index) |
| 1916 | { |
| 1917 | int loc; |
| 1918 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
| 1919 | struct qdf_dp_trace_credit_record *buf = |
| 1920 | (struct qdf_dp_trace_credit_record *)record->data; |
| 1921 | |
| 1922 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 1923 | index, 0, record); |
| 1924 | if (buf->operation == QDF_OP_NA) |
| 1925 | qdf_debugfs_printf(file, "%s [%s] [T: %d G0: %d G1: %d]\n", |
| 1926 | prepend_str, |
| 1927 | qdf_dp_credit_source_to_str(buf->source), |
| 1928 | buf->total_credits, buf->g0_credit, |
| 1929 | buf->g1_credit); |
| 1930 | else |
| 1931 | qdf_debugfs_printf(file, |
| 1932 | "%s [%s] [T: %d G0: %d G1: %d] [%s %d]\n", |
| 1933 | prepend_str, |
| 1934 | qdf_dp_credit_source_to_str(buf->source), |
| 1935 | buf->total_credits, buf->g0_credit, |
| 1936 | buf->g1_credit, |
| 1937 | qdf_dp_operation_to_str(buf->operation), |
| 1938 | buf->delta); |
| 1939 | } |
| 1940 | |
| 1941 | void qdf_dp_display_credit_record(struct qdf_dp_trace_record_s *record, |
| 1942 | uint16_t index, uint8_t pdev_id, uint8_t info) |
| 1943 | { |
| 1944 | int loc; |
| 1945 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
| 1946 | struct qdf_dp_trace_credit_record *buf = |
| 1947 | (struct qdf_dp_trace_credit_record *)record->data; |
| 1948 | |
| 1949 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 1950 | index, info, record); |
| 1951 | if (buf->operation == QDF_OP_NA) |
| 1952 | DPTRACE_PRINT("%s [%s] [T: %d G0: %d G1: %d]", |
| 1953 | prepend_str, |
| 1954 | qdf_dp_credit_source_to_str(buf->source), |
| 1955 | buf->total_credits, buf->g0_credit, |
| 1956 | buf->g1_credit); |
| 1957 | else |
| 1958 | DPTRACE_PRINT("%s [%s] [T: %d G0: %d G1: %d] [%s %d]", |
| 1959 | prepend_str, |
| 1960 | qdf_dp_credit_source_to_str(buf->source), |
| 1961 | buf->total_credits, buf->g0_credit, |
| 1962 | buf->g1_credit, |
| 1963 | qdf_dp_operation_to_str(buf->operation), |
| 1964 | buf->delta); |
| 1965 | } |
| 1966 | |
| 1967 | void qdf_dp_trace_credit_record(enum QDF_CREDIT_UPDATE_SOURCE source, |
| 1968 | enum QDF_CREDIT_OPERATION operation, |
| 1969 | int delta, int total_credits, |
| 1970 | int g0_credit, int g1_credit) |
| 1971 | { |
| 1972 | struct qdf_dp_trace_credit_record buf; |
| 1973 | int buf_size = sizeof(struct qdf_dp_trace_credit_record); |
| 1974 | enum QDF_DP_TRACE_ID code = QDF_DP_TRACE_TX_CREDIT_RECORD; |
| 1975 | |
| 1976 | if (qdf_dp_enable_check(NULL, code, QDF_NA) == false) |
| 1977 | return; |
| 1978 | |
| 1979 | if (!(qdf_dp_get_proto_bitmap() & QDF_HL_CREDIT_TRACKING)) |
| 1980 | return; |
| 1981 | |
| 1982 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1983 | QDF_BUG(0); |
| 1984 | |
| 1985 | buf.source = source; |
| 1986 | buf.operation = operation; |
| 1987 | buf.delta = delta; |
| 1988 | buf.total_credits = total_credits; |
| 1989 | buf.g0_credit = g0_credit; |
| 1990 | buf.g1_credit = g1_credit; |
| 1991 | |
| 1992 | qdf_dp_add_record(code, QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)&buf, |
| 1993 | buf_size, NULL, 0, false); |
| 1994 | } |
| 1995 | qdf_export_symbol(qdf_dp_trace_credit_record); |
| 1996 | |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1997 | void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 1998 | uint16_t index, uint8_t pdev_id, uint8_t info) |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1999 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2000 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2001 | struct qdf_dp_trace_event_buf *buf = |
| 2002 | (struct qdf_dp_trace_event_buf *)record->data; |
| 2003 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 2004 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2005 | qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2006 | index, info, record); |
| 2007 | |
| 2008 | DPTRACE_PRINT("%s [%d] [%s %s]", |
| 2009 | prepend_str, |
| 2010 | buf->vdev_id, |
| 2011 | qdf_dp_type_to_str(buf->type), |
| 2012 | qdf_dp_subtype_to_str(buf->subtype)); |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2013 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2014 | qdf_export_symbol(qdf_dp_display_event_record); |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2015 | |
| 2016 | /** |
| 2017 | * qdf_dp_trace_record_event() - record events |
| 2018 | * @code: dptrace code |
| 2019 | * @vdev_id: vdev id |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2020 | * @pdev_id: pdev_id |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2021 | * @type: proto type |
| 2022 | * @subtype: proto subtype |
| 2023 | * |
| 2024 | * Return: none |
| 2025 | */ |
| 2026 | void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2027 | uint8_t pdev_id, enum qdf_proto_type type, |
| 2028 | enum qdf_proto_subtype subtype) |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2029 | { |
| 2030 | struct qdf_dp_trace_event_buf buf; |
| 2031 | int buf_size = sizeof(struct qdf_dp_trace_event_buf); |
| 2032 | |
| 2033 | if (qdf_dp_enable_check(NULL, code, QDF_NA) == false) |
| 2034 | return; |
| 2035 | |
| 2036 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 2037 | QDF_BUG(0); |
| 2038 | |
| 2039 | buf.type = type; |
| 2040 | buf.subtype = subtype; |
| 2041 | buf.vdev_id = vdev_id; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2042 | qdf_dp_add_record(code, pdev_id, |
| 2043 | (uint8_t *)&buf, buf_size, NULL, 0, true); |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 2044 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2045 | qdf_export_symbol(qdf_dp_trace_record_event); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 2046 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2047 | |
Saket Jha | d8d9d99 | 2019-09-30 17:27:51 -0700 | [diff] [blame] | 2048 | void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record, |
| 2049 | uint16_t index, uint8_t pdev_id, uint8_t info) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2050 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2051 | int loc; |
| 2052 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2053 | struct qdf_dp_trace_proto_buf *buf = |
| 2054 | (struct qdf_dp_trace_proto_buf *)record->data; |
| 2055 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 2056 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2057 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2058 | index, info, record); |
| 2059 | DPTRACE_PRINT("%s [%d] [%s] SA: " |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2060 | QDF_MAC_ADDR_STR " %s DA: " |
| 2061 | QDF_MAC_ADDR_STR, |
| 2062 | prepend_str, |
| 2063 | buf->vdev_id, |
| 2064 | qdf_dp_subtype_to_str(buf->subtype), |
| 2065 | QDF_MAC_ADDR_ARRAY(buf->sa.bytes), |
| 2066 | qdf_dp_dir_to_str(buf->dir), |
| 2067 | QDF_MAC_ADDR_ARRAY(buf->da.bytes)); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2068 | } |
Saket Jha | d8d9d99 | 2019-09-30 17:27:51 -0700 | [diff] [blame] | 2069 | qdf_export_symbol(qdf_dp_display_proto_pkt); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2070 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2071 | void qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, |
| 2072 | uint8_t *sa, uint8_t *da, enum qdf_proto_type type, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2073 | enum qdf_proto_subtype subtype, enum qdf_proto_dir dir, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2074 | uint8_t pdev_id, bool print) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2075 | { |
| 2076 | struct qdf_dp_trace_proto_buf buf; |
| 2077 | int buf_size = sizeof(struct qdf_dp_trace_ptr_buf); |
| 2078 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2079 | if (qdf_dp_enable_check(NULL, code, dir) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2080 | return; |
| 2081 | |
| 2082 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 2083 | QDF_BUG(0); |
| 2084 | |
| 2085 | memcpy(&buf.sa, sa, QDF_NET_ETH_LEN); |
| 2086 | memcpy(&buf.da, da, QDF_NET_ETH_LEN); |
| 2087 | buf.dir = dir; |
| 2088 | buf.type = type; |
| 2089 | buf.subtype = subtype; |
| 2090 | buf.vdev_id = vdev_id; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2091 | qdf_dp_add_record(code, pdev_id, |
| 2092 | (uint8_t *)&buf, buf_size, NULL, 0, print); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2093 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2094 | qdf_export_symbol(qdf_dp_trace_proto_pkt); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2095 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2096 | void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2097 | uint16_t index, uint8_t pdev_id, uint8_t info) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2098 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2099 | int loc; |
| 2100 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2101 | struct qdf_dp_trace_ptr_buf *buf = |
| 2102 | (struct qdf_dp_trace_ptr_buf *)record->data; |
Amar Singhal | 413f3e2 | 2018-09-12 15:51:35 -0700 | [diff] [blame] | 2103 | bool is_free_pkt_ptr_record = false; |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2104 | |
| 2105 | if ((record->code == QDF_DP_TRACE_FREE_PACKET_PTR_RECORD) || |
| 2106 | (record->code == QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD)) |
| 2107 | is_free_pkt_ptr_record = true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2108 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 2109 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2110 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2111 | index, info, record); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2112 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2113 | if (loc < sizeof(prepend_str)) |
| 2114 | scnprintf(&prepend_str[loc], sizeof(prepend_str) - loc, |
| 2115 | "[msdu id %d %s %d]", |
| 2116 | buf->msdu_id, |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2117 | is_free_pkt_ptr_record ? "status" : "vdev_id", |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2118 | buf->status); |
| 2119 | |
| 2120 | if (info & QDF_DP_TRACE_RECORD_INFO_LIVE) { |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2121 | /* In live mode donot dump the contents of the cookie */ |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2122 | DPTRACE_PRINT("%s", prepend_str); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2123 | } else { |
| 2124 | dump_dp_hex_trace(prepend_str, (uint8_t *)&buf->cookie, |
| 2125 | sizeof(buf->cookie)); |
| 2126 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2127 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2128 | qdf_export_symbol(qdf_dp_display_ptr_record); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2129 | |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 2130 | static |
| 2131 | enum qdf_proto_type qdf_dp_get_pkt_proto_type(qdf_nbuf_t nbuf) |
| 2132 | { |
| 2133 | uint8_t pkt_type; |
| 2134 | |
| 2135 | if (!nbuf) |
| 2136 | return QDF_PROTO_TYPE_MAX; |
| 2137 | |
| 2138 | if (qdf_nbuf_data_is_dns_query(nbuf) || |
| 2139 | qdf_nbuf_data_is_dns_response(nbuf)) |
| 2140 | return QDF_PROTO_TYPE_DNS; |
| 2141 | |
| 2142 | pkt_type = QDF_NBUF_CB_GET_PACKET_TYPE(nbuf); |
| 2143 | |
| 2144 | switch (pkt_type) { |
| 2145 | case QDF_NBUF_CB_PACKET_TYPE_EAPOL: |
| 2146 | return QDF_PROTO_TYPE_EAPOL; |
| 2147 | case QDF_NBUF_CB_PACKET_TYPE_ARP: |
| 2148 | return QDF_PROTO_TYPE_ARP; |
| 2149 | case QDF_NBUF_CB_PACKET_TYPE_DHCP: |
| 2150 | return QDF_PROTO_TYPE_DHCP; |
| 2151 | default: |
| 2152 | return QDF_PROTO_TYPE_MAX; |
| 2153 | } |
| 2154 | } |
| 2155 | |
| 2156 | static |
| 2157 | enum qdf_proto_subtype qdf_dp_get_pkt_subtype(qdf_nbuf_t nbuf, |
| 2158 | enum qdf_proto_type pkt_type) |
| 2159 | { |
| 2160 | switch (pkt_type) { |
| 2161 | case QDF_PROTO_TYPE_EAPOL: |
| 2162 | return qdf_nbuf_get_eapol_subtype(nbuf); |
| 2163 | case QDF_PROTO_TYPE_ARP: |
| 2164 | return qdf_nbuf_get_arp_subtype(nbuf); |
| 2165 | case QDF_PROTO_TYPE_DHCP: |
| 2166 | return qdf_nbuf_get_dhcp_subtype(nbuf); |
| 2167 | case QDF_PROTO_TYPE_DNS: |
| 2168 | return (qdf_nbuf_data_is_dns_query(nbuf)) ? |
| 2169 | QDF_PROTO_DNS_QUERY : QDF_PROTO_DNS_RES; |
| 2170 | default: |
| 2171 | return QDF_PROTO_INVALID; |
| 2172 | } |
| 2173 | } |
| 2174 | |
| 2175 | static |
| 2176 | bool qdf_dp_proto_log_enable_check(enum qdf_proto_type pkt_type, |
| 2177 | uint16_t status) |
| 2178 | { |
| 2179 | if (pkt_type == QDF_PROTO_TYPE_MAX) |
| 2180 | return false; |
| 2181 | |
| 2182 | switch (pkt_type) { |
| 2183 | case QDF_PROTO_TYPE_EAPOL: |
| 2184 | return qdf_dp_get_proto_event_bitmap() & |
| 2185 | QDF_NBUF_PKT_TRAC_TYPE_EAPOL; |
| 2186 | case QDF_PROTO_TYPE_DHCP: |
| 2187 | return qdf_dp_get_proto_event_bitmap() & |
| 2188 | QDF_NBUF_PKT_TRAC_TYPE_DHCP; |
| 2189 | case QDF_PROTO_TYPE_ARP: |
| 2190 | if (status == QDF_TX_RX_STATUS_OK) |
| 2191 | return false; |
| 2192 | else |
| 2193 | return qdf_dp_get_proto_event_bitmap() & |
| 2194 | QDF_NBUF_PKT_TRAC_TYPE_ARP; |
| 2195 | case QDF_PROTO_TYPE_DNS: |
| 2196 | if (status == QDF_TX_RX_STATUS_OK) |
| 2197 | return false; |
| 2198 | else |
| 2199 | return qdf_dp_get_proto_event_bitmap() & |
| 2200 | QDF_NBUF_PKT_TRAC_TYPE_DNS; |
| 2201 | default: |
| 2202 | return false; |
| 2203 | } |
| 2204 | } |
| 2205 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2206 | /** |
| 2207 | * qdf_dp_trace_ptr() - record dptrace |
| 2208 | * @code: dptrace code |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2209 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2210 | * @data: data |
| 2211 | * @size: size of data |
| 2212 | * @msdu_id: msdu_id |
| 2213 | * @status: return status |
| 2214 | * |
| 2215 | * Return: none |
| 2216 | */ |
| 2217 | void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2218 | uint8_t pdev_id, uint8_t *data, uint8_t size, |
| 2219 | uint16_t msdu_id, uint16_t status) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2220 | { |
| 2221 | struct qdf_dp_trace_ptr_buf buf; |
| 2222 | int buf_size = sizeof(struct qdf_dp_trace_ptr_buf); |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 2223 | enum qdf_proto_type pkt_type; |
| 2224 | |
| 2225 | pkt_type = qdf_dp_get_pkt_proto_type(nbuf); |
| 2226 | if ((code == QDF_DP_TRACE_FREE_PACKET_PTR_RECORD || |
| 2227 | code == QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD) && |
| 2228 | qdf_dp_proto_log_enable_check(pkt_type, status + 1)) |
| 2229 | qdf_dp_log_proto_pkt_info(nbuf->data + QDF_NBUF_SRC_MAC_OFFSET, |
| 2230 | nbuf->data + QDF_NBUF_DEST_MAC_OFFSET, |
| 2231 | pkt_type, |
| 2232 | qdf_dp_get_pkt_subtype(nbuf, pkt_type), |
| 2233 | QDF_TX, msdu_id, status + 1); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2234 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2235 | if (qdf_dp_enable_check(nbuf, code, QDF_TX) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2236 | return; |
| 2237 | |
| 2238 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 2239 | QDF_BUG(0); |
| 2240 | |
| 2241 | qdf_mem_copy(&buf.cookie, data, size); |
| 2242 | buf.msdu_id = msdu_id; |
| 2243 | buf.status = status; |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2244 | qdf_dp_add_record(code, pdev_id, (uint8_t *)&buf, buf_size, NULL, 0, |
| 2245 | QDF_NBUF_CB_DP_TRACE_PRINT(nbuf)); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2246 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2247 | qdf_export_symbol(qdf_dp_trace_ptr); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2248 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2249 | void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id, |
| 2250 | enum QDF_DP_TRACE_ID code, uint16_t msdu_id, |
| 2251 | enum qdf_proto_dir dir) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2252 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2253 | struct qdf_dp_trace_data_buf buf; |
Yeshwanth Sriram Guntuka | 70ea6af | 2020-01-10 14:47:35 +0530 | [diff] [blame] | 2254 | enum qdf_proto_type pkt_type; |
| 2255 | |
| 2256 | pkt_type = qdf_dp_get_pkt_proto_type(nbuf); |
| 2257 | if (code == QDF_DP_TRACE_DROP_PACKET_RECORD && |
| 2258 | qdf_dp_proto_log_enable_check(pkt_type, QDF_TX_RX_STATUS_DROP)) |
| 2259 | qdf_dp_log_proto_pkt_info(nbuf->data + QDF_NBUF_SRC_MAC_OFFSET, |
| 2260 | nbuf->data + QDF_NBUF_DEST_MAC_OFFSET, |
| 2261 | pkt_type, |
| 2262 | qdf_dp_get_pkt_subtype(nbuf, pkt_type), |
| 2263 | QDF_TX, msdu_id, |
| 2264 | QDF_TX_RX_STATUS_DROP); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2265 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2266 | buf.msdu_id = msdu_id; |
| 2267 | if (!qdf_dp_enable_check(nbuf, code, dir)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2268 | return; |
| 2269 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2270 | qdf_dp_add_record(code, pdev_id, |
Amar Singhal | f98d926 | 2018-05-18 16:09:47 -0700 | [diff] [blame] | 2271 | nbuf ? qdf_nbuf_data(nbuf) : NULL, |
| 2272 | nbuf ? nbuf->len - nbuf->data_len : 0, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2273 | (uint8_t *)&buf, sizeof(struct qdf_dp_trace_data_buf), |
| 2274 | (nbuf) ? QDF_NBUF_CB_DP_TRACE_PRINT(nbuf) : false); |
| 2275 | } |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2276 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2277 | qdf_export_symbol(qdf_dp_trace_data_pkt); |
| 2278 | |
| 2279 | void qdf_dp_display_record(struct qdf_dp_trace_record_s *record, |
| 2280 | uint16_t index, uint8_t pdev_id, uint8_t info) |
| 2281 | { |
| 2282 | int loc; |
| 2283 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
| 2284 | |
| 2285 | if (!(pdev_id == QDF_TRACE_DEFAULT_PDEV_ID || |
| 2286 | pdev_id == record->pdev_id)) |
| 2287 | return; |
| 2288 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 2289 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2290 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2291 | index, info, record); |
| 2292 | |
| 2293 | switch (record->code) { |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2294 | case QDF_DP_TRACE_HDD_TX_TIMEOUT: |
| 2295 | DPTRACE_PRINT(" %s: HDD TX Timeout", prepend_str); |
| 2296 | break; |
| 2297 | case QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: |
| 2298 | DPTRACE_PRINT(" %s: HDD SoftAP TX Timeout", prepend_str); |
| 2299 | break; |
Yun Park | c60a22b | 2017-08-15 12:04:11 -0700 | [diff] [blame] | 2300 | case QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD: |
| 2301 | DPTRACE_PRINT(" %s: CE Fast Packet Error", prepend_str); |
| 2302 | break; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2303 | case QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD: |
| 2304 | default: |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2305 | dump_dp_hex_trace(prepend_str, record->data, record->size); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2306 | break; |
| 2307 | }; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2308 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2309 | qdf_export_symbol(qdf_dp_display_record); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2310 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2311 | void |
| 2312 | qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record, |
| 2313 | uint16_t rec_index, uint8_t pdev_id, |
| 2314 | uint8_t info) |
| 2315 | { |
| 2316 | int loc; |
| 2317 | char prepend_str[DP_TRACE_META_DATA_STRLEN + 10]; |
| 2318 | struct qdf_dp_trace_data_buf *buf = |
| 2319 | (struct qdf_dp_trace_data_buf *)record->data; |
| 2320 | |
hangtian | 67ebc3d | 2019-01-16 17:36:51 +0800 | [diff] [blame] | 2321 | qdf_mem_zero(prepend_str, sizeof(prepend_str)); |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2322 | |
| 2323 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2324 | rec_index, info, record); |
| 2325 | if (loc < sizeof(prepend_str)) |
| 2326 | loc += snprintf(&prepend_str[loc], sizeof(prepend_str) - loc, |
| 2327 | "[%d]", buf->msdu_id); |
| 2328 | dump_dp_hex_trace(prepend_str, |
| 2329 | &record->data[sizeof(struct qdf_dp_trace_data_buf)], |
| 2330 | record->size); |
| 2331 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2332 | |
| 2333 | /** |
| 2334 | * qdf_dp_trace() - Stores the data in buffer |
| 2335 | * @nbuf : defines the netbuf |
| 2336 | * @code : defines the event |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2337 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2338 | * @data : defines the data to be stored |
| 2339 | * @size : defines the size of the data record |
| 2340 | * |
| 2341 | * Return: None |
| 2342 | */ |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2343 | void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id, |
| 2344 | uint8_t *data, uint8_t size, enum qdf_proto_dir dir) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2345 | { |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2346 | |
| 2347 | if (qdf_dp_enable_check(nbuf, code, dir) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 2348 | return; |
| 2349 | |
Zhang Qian | 3c72425 | 2018-05-21 11:24:04 +0800 | [diff] [blame] | 2350 | qdf_dp_add_record(code, pdev_id, nbuf ? qdf_nbuf_data(nbuf) : NULL, |
| 2351 | size, NULL, 0, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2352 | (nbuf) ? QDF_NBUF_CB_DP_TRACE_PRINT(nbuf) : false); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2353 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2354 | qdf_export_symbol(qdf_dp_trace); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2355 | |
| 2356 | /** |
| 2357 | * qdf_dp_trace_spin_lock_init() - initializes the lock variable before use |
| 2358 | * This function will be called from cds_alloc_global_context, we will have lock |
| 2359 | * available to use ASAP |
| 2360 | * |
| 2361 | * Return: None |
| 2362 | */ |
| 2363 | void qdf_dp_trace_spin_lock_init(void) |
| 2364 | { |
| 2365 | spin_lock_init(&l_dp_trace_lock); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2366 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2367 | qdf_export_symbol(qdf_dp_trace_spin_lock_init); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2368 | |
| 2369 | /** |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2370 | * qdf_dp_trace_disable_live_mode - disable live mode for dptrace |
| 2371 | * |
| 2372 | * Return: none |
| 2373 | */ |
| 2374 | void qdf_dp_trace_disable_live_mode(void) |
| 2375 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2376 | g_qdf_dp_trace_data.force_live_mode = 0; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2377 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2378 | qdf_export_symbol(qdf_dp_trace_disable_live_mode); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2379 | |
| 2380 | /** |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2381 | * qdf_dp_trace_enable_live_mode() - enable live mode for dptrace |
| 2382 | * |
| 2383 | * Return: none |
| 2384 | */ |
| 2385 | void qdf_dp_trace_enable_live_mode(void) |
| 2386 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2387 | g_qdf_dp_trace_data.force_live_mode = 1; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2388 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2389 | qdf_export_symbol(qdf_dp_trace_enable_live_mode); |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2390 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 2391 | /** |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 2392 | * qdf_dp_trace_clear_buffer() - clear dp trace buffer |
| 2393 | * |
| 2394 | * Return: none |
| 2395 | */ |
| 2396 | void qdf_dp_trace_clear_buffer(void) |
| 2397 | { |
| 2398 | g_qdf_dp_trace_data.head = INVALID_QDF_DP_TRACE_ADDR; |
| 2399 | g_qdf_dp_trace_data.tail = INVALID_QDF_DP_TRACE_ADDR; |
| 2400 | g_qdf_dp_trace_data.num = 0; |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2401 | g_qdf_dp_trace_data.dump_counter = 0; |
| 2402 | g_qdf_dp_trace_data.num_records_to_dump = MAX_QDF_DP_TRACE_RECORDS; |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 2403 | if (g_qdf_dp_trace_data.enable) |
| 2404 | memset(g_qdf_dp_trace_tbl, 0, |
| 2405 | MAX_QDF_DP_TRACE_RECORDS * |
| 2406 | sizeof(struct qdf_dp_trace_record_s)); |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 2407 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2408 | qdf_export_symbol(qdf_dp_trace_clear_buffer); |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 2409 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 2410 | void qdf_dp_trace_dump_stats(void) |
| 2411 | { |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2412 | DPTRACE_PRINT("STATS |DPT: tx %u rx %u icmp(%u %u) arp(%u %u) icmpv6(%u %u %u %u %u %u) dhcp(%u %u %u %u %u %u) eapol(%u %u %u %u %u)", |
| 2413 | g_qdf_dp_trace_data.tx_count, |
| 2414 | g_qdf_dp_trace_data.rx_count, |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 2415 | g_qdf_dp_trace_data.icmp_req, |
| 2416 | g_qdf_dp_trace_data.icmp_resp, |
| 2417 | g_qdf_dp_trace_data.arp_req, |
| 2418 | g_qdf_dp_trace_data.arp_resp, |
| 2419 | g_qdf_dp_trace_data.icmpv6_req, |
| 2420 | g_qdf_dp_trace_data.icmpv6_resp, |
| 2421 | g_qdf_dp_trace_data.icmpv6_ns, |
| 2422 | g_qdf_dp_trace_data.icmpv6_na, |
| 2423 | g_qdf_dp_trace_data.icmpv6_rs, |
| 2424 | g_qdf_dp_trace_data.icmpv6_ra, |
| 2425 | g_qdf_dp_trace_data.dhcp_disc, |
| 2426 | g_qdf_dp_trace_data.dhcp_off, |
| 2427 | g_qdf_dp_trace_data.dhcp_req, |
| 2428 | g_qdf_dp_trace_data.dhcp_ack, |
| 2429 | g_qdf_dp_trace_data.dhcp_nack, |
| 2430 | g_qdf_dp_trace_data.dhcp_others, |
| 2431 | g_qdf_dp_trace_data.eapol_m1, |
| 2432 | g_qdf_dp_trace_data.eapol_m2, |
| 2433 | g_qdf_dp_trace_data.eapol_m3, |
| 2434 | g_qdf_dp_trace_data.eapol_m4, |
| 2435 | g_qdf_dp_trace_data.eapol_others); |
| 2436 | } |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2437 | qdf_export_symbol(qdf_dp_trace_dump_stats); |
| 2438 | |
| 2439 | /** |
| 2440 | * qdf_dpt_dump_hex_trace_debugfs() - read data in file |
| 2441 | * @file: file to read |
| 2442 | * @str: string to prepend the hexdump with. |
| 2443 | * @buf: buffer which contains data to be written |
| 2444 | * @buf_len: defines the size of the data to be written |
| 2445 | * |
| 2446 | * Return: None |
| 2447 | */ |
| 2448 | static void qdf_dpt_dump_hex_trace_debugfs(qdf_debugfs_file_t file, |
| 2449 | char *str, uint8_t *buf, uint8_t buf_len) |
| 2450 | { |
| 2451 | unsigned char linebuf[BUFFER_SIZE]; |
| 2452 | const u8 *ptr = buf; |
| 2453 | int i, linelen, remaining = buf_len; |
| 2454 | |
| 2455 | /* Dump the bytes in the last line */ |
| 2456 | for (i = 0; i < buf_len; i += ROW_SIZE) { |
| 2457 | linelen = min(remaining, ROW_SIZE); |
| 2458 | remaining -= ROW_SIZE; |
| 2459 | |
| 2460 | hex_dump_to_buffer(ptr + i, linelen, ROW_SIZE, 1, |
| 2461 | linebuf, sizeof(linebuf), false); |
| 2462 | |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2463 | qdf_debugfs_printf(file, "%s %s\n", str, linebuf); |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2464 | } |
| 2465 | } |
| 2466 | |
| 2467 | /** |
| 2468 | * qdf_dpt_display_proto_pkt_debugfs() - display proto packet |
| 2469 | * @file: file to read |
| 2470 | * @record: dptrace record |
| 2471 | * @index: index |
| 2472 | * |
| 2473 | * Return: none |
| 2474 | */ |
| 2475 | static void qdf_dpt_display_proto_pkt_debugfs(qdf_debugfs_file_t file, |
| 2476 | struct qdf_dp_trace_record_s *record, |
| 2477 | uint32_t index) |
| 2478 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2479 | int loc; |
| 2480 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2481 | struct qdf_dp_trace_proto_buf *buf = |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2482 | (struct qdf_dp_trace_proto_buf *)record->data; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2483 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2484 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2485 | index, 0, record); |
| 2486 | qdf_debugfs_printf(file, "%s [%d] [%s] SA: " |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2487 | QDF_MAC_ADDR_STR " %s DA: " |
| 2488 | QDF_MAC_ADDR_STR, |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2489 | prepend_str, |
| 2490 | buf->vdev_id, |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2491 | qdf_dp_subtype_to_str(buf->subtype), |
| 2492 | QDF_MAC_ADDR_ARRAY(buf->sa.bytes), |
| 2493 | qdf_dp_dir_to_str(buf->dir), |
| 2494 | QDF_MAC_ADDR_ARRAY(buf->da.bytes)); |
| 2495 | qdf_debugfs_printf(file, "\n"); |
| 2496 | } |
| 2497 | |
| 2498 | /** |
| 2499 | * qdf_dpt_display_mgmt_pkt_debugfs() - display mgmt packet |
| 2500 | * @file: file to read |
| 2501 | * @record: dptrace record |
| 2502 | * @index: index |
| 2503 | * |
| 2504 | * Return: none |
| 2505 | */ |
| 2506 | static void qdf_dpt_display_mgmt_pkt_debugfs(qdf_debugfs_file_t file, |
| 2507 | struct qdf_dp_trace_record_s *record, |
| 2508 | uint32_t index) |
| 2509 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2510 | |
| 2511 | int loc; |
| 2512 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2513 | struct qdf_dp_trace_mgmt_buf *buf = |
| 2514 | (struct qdf_dp_trace_mgmt_buf *)record->data; |
| 2515 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2516 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2517 | index, 0, record); |
| 2518 | |
| 2519 | qdf_debugfs_printf(file, "%s [%d] [%s %s]\n", |
| 2520 | prepend_str, |
| 2521 | buf->vdev_id, |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2522 | qdf_dp_type_to_str(buf->type), |
| 2523 | qdf_dp_subtype_to_str(buf->subtype)); |
| 2524 | } |
| 2525 | |
| 2526 | /** |
| 2527 | * qdf_dpt_display_event_record_debugfs() - display event records |
| 2528 | * @file: file to read |
| 2529 | * @record: dptrace record |
| 2530 | * @index: index |
| 2531 | * |
| 2532 | * Return: none |
| 2533 | */ |
| 2534 | static void qdf_dpt_display_event_record_debugfs(qdf_debugfs_file_t file, |
| 2535 | struct qdf_dp_trace_record_s *record, |
| 2536 | uint32_t index) |
| 2537 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2538 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2539 | struct qdf_dp_trace_event_buf *buf = |
| 2540 | (struct qdf_dp_trace_event_buf *)record->data; |
| 2541 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2542 | qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2543 | index, 0, record); |
| 2544 | qdf_debugfs_printf(file, "%s [%d] [%s %s]\n", |
| 2545 | prepend_str, |
| 2546 | buf->vdev_id, |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2547 | qdf_dp_type_to_str(buf->type), |
| 2548 | qdf_dp_subtype_to_str(buf->subtype)); |
| 2549 | } |
| 2550 | |
| 2551 | /** |
| 2552 | * qdf_dpt_display_ptr_record_debugfs() - display record ptr |
| 2553 | * @file: file to read |
| 2554 | * @record: dptrace record |
| 2555 | * @index: index |
| 2556 | * |
| 2557 | * Return: none |
| 2558 | */ |
| 2559 | static void qdf_dpt_display_ptr_record_debugfs(qdf_debugfs_file_t file, |
| 2560 | struct qdf_dp_trace_record_s *record, |
| 2561 | uint32_t index) |
| 2562 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2563 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
| 2564 | int loc; |
| 2565 | struct qdf_dp_trace_ptr_buf *buf = |
| 2566 | (struct qdf_dp_trace_ptr_buf *)record->data; |
| 2567 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2568 | index, 0, record); |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2569 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2570 | if (loc < sizeof(prepend_str)) |
| 2571 | scnprintf(&prepend_str[loc], sizeof(prepend_str) - loc, |
| 2572 | "[msdu id %d %s %d]", |
| 2573 | buf->msdu_id, |
| 2574 | (record->code == |
| 2575 | QDF_DP_TRACE_FREE_PACKET_PTR_RECORD) ? |
| 2576 | "status" : "vdev_id", |
| 2577 | buf->status); |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2578 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2579 | qdf_dpt_dump_hex_trace_debugfs(file, prepend_str, |
| 2580 | (uint8_t *)&buf->cookie, |
| 2581 | sizeof(buf->cookie)); |
| 2582 | } |
| 2583 | |
| 2584 | /** |
| 2585 | * qdf_dpt_display_ptr_record_debugfs() - display record |
| 2586 | * @file: file to read |
| 2587 | * @record: dptrace record |
| 2588 | * @index: index |
| 2589 | * |
| 2590 | * Return: none |
| 2591 | */ |
| 2592 | static void qdf_dpt_display_record_debugfs(qdf_debugfs_file_t file, |
| 2593 | struct qdf_dp_trace_record_s *record, |
| 2594 | uint32_t index) |
| 2595 | { |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2596 | int loc; |
| 2597 | char prepend_str[QDF_DP_TRACE_PREPEND_STR_SIZE]; |
jitiphil | cfb1452 | 2018-05-15 13:28:44 +0530 | [diff] [blame] | 2598 | struct qdf_dp_trace_data_buf *buf = |
| 2599 | (struct qdf_dp_trace_data_buf *)record->data; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2600 | |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2601 | loc = qdf_dp_trace_fill_meta_str(prepend_str, sizeof(prepend_str), |
| 2602 | index, 0, record); |
jitiphil | cfb1452 | 2018-05-15 13:28:44 +0530 | [diff] [blame] | 2603 | if (loc < sizeof(prepend_str)) |
| 2604 | loc += snprintf(&prepend_str[loc], sizeof(prepend_str) - loc, |
| 2605 | "[%d]", buf->msdu_id); |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2606 | qdf_dpt_dump_hex_trace_debugfs(file, prepend_str, |
| 2607 | record->data, record->size); |
| 2608 | } |
| 2609 | |
| 2610 | uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file, |
| 2611 | enum qdf_dpt_debugfs_state state) |
| 2612 | { |
| 2613 | uint32_t i = 0; |
| 2614 | uint32_t tail; |
| 2615 | uint32_t count = g_qdf_dp_trace_data.num; |
| 2616 | |
| 2617 | if (!g_qdf_dp_trace_data.enable) { |
| 2618 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG, |
| 2619 | "%s: Tracing Disabled", __func__); |
| 2620 | return QDF_STATUS_E_EMPTY; |
| 2621 | } |
| 2622 | |
| 2623 | if (!count) { |
| 2624 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG, |
| 2625 | "%s: no packets", __func__); |
| 2626 | return QDF_STATUS_E_EMPTY; |
| 2627 | } |
| 2628 | |
| 2629 | if (state == QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS) |
| 2630 | return g_qdf_dp_trace_data.curr_pos; |
| 2631 | |
| 2632 | qdf_debugfs_printf(file, |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2633 | "DPT: config - bitmap 0x%x verb %u #rec %u rec_requested %u live_config %u thresh %u time_limit %u\n", |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2634 | g_qdf_dp_trace_data.proto_bitmap, |
| 2635 | g_qdf_dp_trace_data.verbosity, |
| 2636 | g_qdf_dp_trace_data.no_of_record, |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2637 | g_qdf_dp_trace_data.num_records_to_dump, |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2638 | g_qdf_dp_trace_data.live_mode_config, |
| 2639 | g_qdf_dp_trace_data.high_tput_thresh, |
| 2640 | g_qdf_dp_trace_data.thresh_time_limit); |
| 2641 | |
| 2642 | qdf_debugfs_printf(file, |
| 2643 | "STATS |DPT: icmp(%u %u) arp(%u %u) icmpv6(%u %u %u %u %u %u) dhcp(%u %u %u %u %u %u) eapol(%u %u %u %u %u)\n", |
| 2644 | g_qdf_dp_trace_data.icmp_req, |
| 2645 | g_qdf_dp_trace_data.icmp_resp, |
| 2646 | g_qdf_dp_trace_data.arp_req, |
| 2647 | g_qdf_dp_trace_data.arp_resp, |
| 2648 | g_qdf_dp_trace_data.icmpv6_req, |
| 2649 | g_qdf_dp_trace_data.icmpv6_resp, |
| 2650 | g_qdf_dp_trace_data.icmpv6_ns, |
| 2651 | g_qdf_dp_trace_data.icmpv6_na, |
| 2652 | g_qdf_dp_trace_data.icmpv6_rs, |
| 2653 | g_qdf_dp_trace_data.icmpv6_ra, |
| 2654 | g_qdf_dp_trace_data.dhcp_disc, |
| 2655 | g_qdf_dp_trace_data.dhcp_off, |
| 2656 | g_qdf_dp_trace_data.dhcp_req, |
| 2657 | g_qdf_dp_trace_data.dhcp_ack, |
| 2658 | g_qdf_dp_trace_data.dhcp_nack, |
| 2659 | g_qdf_dp_trace_data.dhcp_others, |
| 2660 | g_qdf_dp_trace_data.eapol_m1, |
| 2661 | g_qdf_dp_trace_data.eapol_m2, |
| 2662 | g_qdf_dp_trace_data.eapol_m3, |
| 2663 | g_qdf_dp_trace_data.eapol_m4, |
| 2664 | g_qdf_dp_trace_data.eapol_others); |
| 2665 | |
| 2666 | qdf_debugfs_printf(file, |
| 2667 | "DPT: Total Records: %d, Head: %d, Tail: %d\n", |
| 2668 | g_qdf_dp_trace_data.num, g_qdf_dp_trace_data.head, |
| 2669 | g_qdf_dp_trace_data.tail); |
| 2670 | |
| 2671 | spin_lock_bh(&l_dp_trace_lock); |
| 2672 | if (g_qdf_dp_trace_data.head != INVALID_QDF_DP_TRACE_ADDR) { |
| 2673 | i = g_qdf_dp_trace_data.head; |
| 2674 | tail = g_qdf_dp_trace_data.tail; |
| 2675 | |
| 2676 | if (count > g_qdf_dp_trace_data.num) |
| 2677 | count = g_qdf_dp_trace_data.num; |
| 2678 | |
| 2679 | if (tail >= (count - 1)) |
| 2680 | i = tail - count + 1; |
| 2681 | else if (count != MAX_QDF_DP_TRACE_RECORDS) |
| 2682 | i = MAX_QDF_DP_TRACE_RECORDS - ((count - 1) - |
| 2683 | tail); |
| 2684 | g_qdf_dp_trace_data.curr_pos = 0; |
| 2685 | g_qdf_dp_trace_data.saved_tail = tail; |
| 2686 | } |
| 2687 | spin_unlock_bh(&l_dp_trace_lock); |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2688 | |
| 2689 | return g_qdf_dp_trace_data.saved_tail; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2690 | } |
| 2691 | qdf_export_symbol(qdf_dpt_get_curr_pos_debugfs); |
| 2692 | |
| 2693 | QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file, |
| 2694 | uint32_t curr_pos) |
| 2695 | { |
| 2696 | struct qdf_dp_trace_record_s p_record; |
| 2697 | uint32_t i = curr_pos; |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2698 | uint16_t num_records_to_dump = g_qdf_dp_trace_data.num_records_to_dump; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2699 | |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2700 | if (!g_qdf_dp_trace_data.enable) { |
| 2701 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, |
| 2702 | "%s: Tracing Disabled", __func__); |
| 2703 | return QDF_STATUS_E_FAILURE; |
| 2704 | } |
| 2705 | |
| 2706 | if (num_records_to_dump > g_qdf_dp_trace_data.num) |
| 2707 | num_records_to_dump = g_qdf_dp_trace_data.num; |
| 2708 | |
| 2709 | /* |
| 2710 | * Max dp trace record size should always be less than |
| 2711 | * QDF_DP_TRACE_PREPEND_STR_SIZE(100) + BUFFER_SIZE(121). |
| 2712 | */ |
| 2713 | if (WARN_ON(QDF_DP_TRACE_MAX_RECORD_SIZE < |
| 2714 | QDF_DP_TRACE_PREPEND_STR_SIZE + BUFFER_SIZE)) |
Rachit Kankane | b3ba769 | 2018-06-27 18:42:34 +0530 | [diff] [blame] | 2715 | return QDF_STATUS_E_FAILURE; |
| 2716 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2717 | spin_lock_bh(&l_dp_trace_lock); |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2718 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2719 | spin_unlock_bh(&l_dp_trace_lock); |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2720 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2721 | for (;; ) { |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2722 | /* |
| 2723 | * Initially we get file as 1 page size, and |
| 2724 | * if remaining size in file is less than one record max size, |
| 2725 | * then return so that it gets an extra page. |
| 2726 | */ |
| 2727 | if ((file->size - file->count) < QDF_DP_TRACE_MAX_RECORD_SIZE) { |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2728 | spin_lock_bh(&l_dp_trace_lock); |
| 2729 | g_qdf_dp_trace_data.curr_pos = i; |
| 2730 | spin_unlock_bh(&l_dp_trace_lock); |
| 2731 | return QDF_STATUS_E_FAILURE; |
| 2732 | } |
| 2733 | |
| 2734 | switch (p_record.code) { |
| 2735 | case QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD: |
| 2736 | case QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD: |
| 2737 | case QDF_DP_TRACE_FREE_PACKET_PTR_RECORD: |
| 2738 | qdf_dpt_display_ptr_record_debugfs(file, &p_record, i); |
| 2739 | break; |
| 2740 | |
| 2741 | case QDF_DP_TRACE_EAPOL_PACKET_RECORD: |
| 2742 | case QDF_DP_TRACE_DHCP_PACKET_RECORD: |
| 2743 | case QDF_DP_TRACE_ARP_PACKET_RECORD: |
| 2744 | case QDF_DP_TRACE_ICMP_PACKET_RECORD: |
| 2745 | case QDF_DP_TRACE_ICMPv6_PACKET_RECORD: |
| 2746 | qdf_dpt_display_proto_pkt_debugfs(file, &p_record, i); |
| 2747 | break; |
| 2748 | |
Nirav Shah | 8f44a7e | 2019-11-05 08:38:47 +0530 | [diff] [blame] | 2749 | case QDF_DP_TRACE_TX_CREDIT_RECORD: |
| 2750 | qdf_dpt_display_credit_record_debugfs(file, &p_record, |
| 2751 | i); |
| 2752 | break; |
| 2753 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2754 | case QDF_DP_TRACE_MGMT_PACKET_RECORD: |
| 2755 | qdf_dpt_display_mgmt_pkt_debugfs(file, &p_record, i); |
| 2756 | break; |
| 2757 | |
| 2758 | case QDF_DP_TRACE_EVENT_RECORD: |
| 2759 | qdf_dpt_display_event_record_debugfs(file, &p_record, |
| 2760 | i); |
| 2761 | break; |
| 2762 | |
| 2763 | case QDF_DP_TRACE_HDD_TX_TIMEOUT: |
| 2764 | qdf_debugfs_printf(file, "DPT: %04d: %s %s\n", |
| 2765 | i, p_record.time, |
| 2766 | qdf_dp_code_to_string(p_record.code)); |
| 2767 | qdf_debugfs_printf(file, "%s: HDD TX Timeout\n"); |
| 2768 | break; |
| 2769 | |
| 2770 | case QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: |
| 2771 | qdf_debugfs_printf(file, "%04d: %s %s\n", |
| 2772 | i, p_record.time, |
| 2773 | qdf_dp_code_to_string(p_record.code)); |
| 2774 | qdf_debugfs_printf(file, |
| 2775 | "%s: HDD SoftAP TX Timeout\n"); |
| 2776 | break; |
| 2777 | |
| 2778 | case QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD: |
| 2779 | qdf_debugfs_printf(file, "DPT: %04d: %s %s\n", |
| 2780 | i, p_record.time, |
| 2781 | qdf_dp_code_to_string(p_record.code)); |
| 2782 | qdf_debugfs_printf(file, |
| 2783 | "%s: CE Fast Packet Error\n"); |
| 2784 | break; |
| 2785 | |
| 2786 | case QDF_DP_TRACE_MAX: |
| 2787 | qdf_debugfs_printf(file, |
| 2788 | "%s: QDF_DP_TRACE_MAX event should not be generated\n", |
| 2789 | __func__); |
| 2790 | break; |
| 2791 | |
| 2792 | case QDF_DP_TRACE_HDD_TX_PACKET_RECORD: |
| 2793 | case QDF_DP_TRACE_HDD_RX_PACKET_RECORD: |
Mohit Khanna | 0425280 | 2017-08-27 09:43:43 -0700 | [diff] [blame] | 2794 | case QDF_DP_TRACE_TX_PACKET_RECORD: |
| 2795 | case QDF_DP_TRACE_RX_PACKET_RECORD: |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2796 | case QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD: |
| 2797 | case QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD: |
| 2798 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2799 | default: |
| 2800 | qdf_dpt_display_record_debugfs(file, &p_record, i); |
| 2801 | break; |
| 2802 | } |
| 2803 | |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2804 | if (++g_qdf_dp_trace_data.dump_counter == num_records_to_dump) |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2805 | break; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2806 | |
| 2807 | spin_lock_bh(&l_dp_trace_lock); |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2808 | if (i == 0) |
| 2809 | i = MAX_QDF_DP_TRACE_RECORDS; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2810 | |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2811 | i -= 1; |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2812 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2813 | spin_unlock_bh(&l_dp_trace_lock); |
| 2814 | } |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2815 | |
| 2816 | g_qdf_dp_trace_data.dump_counter = 0; |
| 2817 | |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2818 | return QDF_STATUS_SUCCESS; |
| 2819 | } |
| 2820 | qdf_export_symbol(qdf_dpt_dump_stats_debugfs); |
| 2821 | |
| 2822 | /** |
| 2823 | * qdf_dpt_set_value_debugfs() - Configure the value to control DP trace |
| 2824 | * @proto_bitmap: defines the protocol to be tracked |
| 2825 | * @no_of_records: defines the nth packet which is traced |
| 2826 | * @verbosity: defines the verbosity level |
| 2827 | * |
| 2828 | * Return: None |
| 2829 | */ |
| 2830 | void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record, |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2831 | uint8_t verbosity, uint16_t num_records_to_dump) |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2832 | { |
Rakshith Suresh Patkar | e105ac1 | 2018-12-06 20:40:49 +0530 | [diff] [blame] | 2833 | if (g_qdf_dp_trace_data.enable) { |
| 2834 | g_qdf_dp_trace_data.proto_bitmap = proto_bitmap; |
| 2835 | g_qdf_dp_trace_data.no_of_record = no_of_record; |
| 2836 | g_qdf_dp_trace_data.verbosity = verbosity; |
| 2837 | g_qdf_dp_trace_data.num_records_to_dump = num_records_to_dump; |
| 2838 | } |
Rakshith Suresh Patkar | dcd0733 | 2018-04-20 12:52:08 +0530 | [diff] [blame] | 2839 | } |
| 2840 | qdf_export_symbol(qdf_dpt_set_value_debugfs); |
| 2841 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 2842 | |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 2843 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2844 | * qdf_dp_trace_dump_all() - Dump data from ring buffer via call back functions |
| 2845 | * registered with QDF |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2846 | * @count: Number of lines to dump starting from tail to head |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2847 | * @pdev_id: pdev_id |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2848 | * |
| 2849 | * Return: None |
| 2850 | */ |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 2851 | void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2852 | { |
| 2853 | struct qdf_dp_trace_record_s p_record; |
| 2854 | int32_t i, tail; |
| 2855 | |
| 2856 | if (!g_qdf_dp_trace_data.enable) { |
Himanshu Agarwal | 26cfe7e | 2017-05-08 15:01:07 +0530 | [diff] [blame] | 2857 | DPTRACE_PRINT("Tracing Disabled"); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2858 | return; |
| 2859 | } |
| 2860 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2861 | DPTRACE_PRINT( |
| 2862 | "DPT: config - bitmap 0x%x verb %u #rec %u live_config %u thresh %u time_limit %u", |
| 2863 | g_qdf_dp_trace_data.proto_bitmap, |
| 2864 | g_qdf_dp_trace_data.verbosity, |
| 2865 | g_qdf_dp_trace_data.no_of_record, |
| 2866 | g_qdf_dp_trace_data.live_mode_config, |
| 2867 | g_qdf_dp_trace_data.high_tput_thresh, |
| 2868 | g_qdf_dp_trace_data.thresh_time_limit); |
| 2869 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 2870 | qdf_dp_trace_dump_stats(); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2871 | |
| 2872 | DPTRACE_PRINT("DPT: Total Records: %d, Head: %d, Tail: %d", |
Himanshu Agarwal | 26cfe7e | 2017-05-08 15:01:07 +0530 | [diff] [blame] | 2873 | g_qdf_dp_trace_data.num, g_qdf_dp_trace_data.head, |
| 2874 | g_qdf_dp_trace_data.tail); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2875 | |
| 2876 | /* aquire the lock so that only one thread at a time can read |
| 2877 | * the ring buffer |
| 2878 | */ |
| 2879 | spin_lock_bh(&l_dp_trace_lock); |
| 2880 | |
| 2881 | if (g_qdf_dp_trace_data.head != INVALID_QDF_DP_TRACE_ADDR) { |
| 2882 | i = g_qdf_dp_trace_data.head; |
| 2883 | tail = g_qdf_dp_trace_data.tail; |
| 2884 | |
| 2885 | if (count) { |
| 2886 | if (count > g_qdf_dp_trace_data.num) |
| 2887 | count = g_qdf_dp_trace_data.num; |
| 2888 | if (tail >= (count - 1)) |
| 2889 | i = tail - count + 1; |
| 2890 | else if (count != MAX_QDF_DP_TRACE_RECORDS) |
| 2891 | i = MAX_QDF_DP_TRACE_RECORDS - ((count - 1) - |
| 2892 | tail); |
| 2893 | } |
| 2894 | |
| 2895 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2896 | spin_unlock_bh(&l_dp_trace_lock); |
| 2897 | for (;; ) { |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2898 | qdf_dp_trace_cb_table[p_record.code](&p_record, |
| 2899 | (uint16_t)i, pdev_id, false); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2900 | if (i == tail) |
| 2901 | break; |
| 2902 | i += 1; |
| 2903 | |
| 2904 | spin_lock_bh(&l_dp_trace_lock); |
| 2905 | if (MAX_QDF_DP_TRACE_RECORDS == i) |
| 2906 | i = 0; |
| 2907 | |
| 2908 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2909 | spin_unlock_bh(&l_dp_trace_lock); |
| 2910 | } |
| 2911 | } else { |
| 2912 | spin_unlock_bh(&l_dp_trace_lock); |
| 2913 | } |
| 2914 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 2915 | qdf_export_symbol(qdf_dp_trace_dump_all); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2916 | |
Nirav Shah | 9106902 | 2018-04-19 17:25:10 +0530 | [diff] [blame] | 2917 | /** |
| 2918 | * qdf_dp_trace_throttle_live_mode() - Throttle DP Trace live mode |
| 2919 | * @high_bw_request: whether this is a high BW req or not |
| 2920 | * |
| 2921 | * The function tries to prevent excessive logging into the live buffer by |
| 2922 | * having an upper limit on number of packets that can be logged per second. |
| 2923 | * |
| 2924 | * The intention is to allow occasional pings and data packets and really low |
| 2925 | * throughput levels while suppressing bursts and higher throughput levels so |
| 2926 | * that we donot hog the live buffer. |
| 2927 | * |
| 2928 | * If the number of packets printed in a particular second exceeds the thresh, |
| 2929 | * disable printing in the next second. |
| 2930 | * |
| 2931 | * Return: None |
| 2932 | */ |
| 2933 | void qdf_dp_trace_throttle_live_mode(bool high_bw_request) |
| 2934 | { |
| 2935 | static int bw_interval_counter; |
| 2936 | |
| 2937 | if (g_qdf_dp_trace_data.enable == false || |
| 2938 | g_qdf_dp_trace_data.live_mode_config == false) |
| 2939 | return; |
| 2940 | |
| 2941 | if (high_bw_request) { |
| 2942 | g_qdf_dp_trace_data.live_mode = 0; |
| 2943 | bw_interval_counter = 0; |
| 2944 | return; |
| 2945 | } |
| 2946 | |
| 2947 | bw_interval_counter++; |
| 2948 | |
| 2949 | if (0 == (bw_interval_counter % |
| 2950 | g_qdf_dp_trace_data.thresh_time_limit)) { |
| 2951 | |
| 2952 | spin_lock_bh(&l_dp_trace_lock); |
| 2953 | if (g_qdf_dp_trace_data.print_pkt_cnt <= |
| 2954 | g_qdf_dp_trace_data.high_tput_thresh) |
| 2955 | g_qdf_dp_trace_data.live_mode = 1; |
| 2956 | |
| 2957 | g_qdf_dp_trace_data.print_pkt_cnt = 0; |
| 2958 | spin_unlock_bh(&l_dp_trace_lock); |
| 2959 | } |
Nirav Shah | 9106902 | 2018-04-19 17:25:10 +0530 | [diff] [blame] | 2960 | } |
| 2961 | qdf_export_symbol(qdf_dp_trace_throttle_live_mode); |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2962 | |
| 2963 | void qdf_dp_trace_apply_tput_policy(bool is_data_traffic) |
| 2964 | { |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2965 | if (g_qdf_dp_trace_data.dynamic_verbosity_modify) { |
| 2966 | goto check_live_mode; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2967 | return; |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2968 | } |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2969 | |
| 2970 | if (is_data_traffic) { |
| 2971 | g_qdf_dp_trace_data.verbosity = |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2972 | QDF_DP_TRACE_VERBOSITY_ULTRA_LOW; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2973 | } else { |
| 2974 | g_qdf_dp_trace_data.verbosity = |
| 2975 | g_qdf_dp_trace_data.ini_conf_verbosity; |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2976 | } |
Mohit Khanna | 163c317 | 2018-06-27 01:34:02 -0700 | [diff] [blame] | 2977 | check_live_mode: |
| 2978 | qdf_dp_trace_throttle_live_mode(is_data_traffic); |
Manjunathappa Prakash | cf4286b | 2018-06-05 20:46:20 -0700 | [diff] [blame] | 2979 | } |
Nirav Shah | ae6a0b3 | 2016-04-26 11:44:42 +0530 | [diff] [blame] | 2980 | #endif |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 2981 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2982 | struct qdf_print_ctrl print_ctrl_obj[MAX_PRINT_CONFIG_SUPPORTED]; |
| 2983 | |
| 2984 | struct category_name_info g_qdf_category_name[MAX_SUPPORTED_CATEGORY] = { |
| 2985 | [QDF_MODULE_ID_TDLS] = {"tdls"}, |
| 2986 | [QDF_MODULE_ID_ACS] = {"ACS"}, |
| 2987 | [QDF_MODULE_ID_SCAN_SM] = {"scan state machine"}, |
| 2988 | [QDF_MODULE_ID_SCANENTRY] = {"scan entry"}, |
| 2989 | [QDF_MODULE_ID_WDS] = {"WDS"}, |
| 2990 | [QDF_MODULE_ID_ACTION] = {"action"}, |
| 2991 | [QDF_MODULE_ID_ROAM] = {"STA roaming"}, |
| 2992 | [QDF_MODULE_ID_INACT] = {"inactivity"}, |
| 2993 | [QDF_MODULE_ID_DOTH] = {"11h"}, |
| 2994 | [QDF_MODULE_ID_IQUE] = {"IQUE"}, |
| 2995 | [QDF_MODULE_ID_WME] = {"WME"}, |
| 2996 | [QDF_MODULE_ID_ACL] = {"ACL"}, |
| 2997 | [QDF_MODULE_ID_WPA] = {"WPA/RSN"}, |
| 2998 | [QDF_MODULE_ID_RADKEYS] = {"dump 802.1x keys"}, |
| 2999 | [QDF_MODULE_ID_RADDUMP] = {"dump radius packet"}, |
| 3000 | [QDF_MODULE_ID_RADIUS] = {"802.1x radius client"}, |
| 3001 | [QDF_MODULE_ID_DOT1XSM] = {"802.1x state machine"}, |
| 3002 | [QDF_MODULE_ID_DOT1X] = {"802.1x authenticator"}, |
| 3003 | [QDF_MODULE_ID_POWER] = {"power save"}, |
| 3004 | [QDF_MODULE_ID_STATE] = {"state"}, |
| 3005 | [QDF_MODULE_ID_OUTPUT] = {"output"}, |
| 3006 | [QDF_MODULE_ID_SCAN] = {"scan"}, |
| 3007 | [QDF_MODULE_ID_AUTH] = {"authentication"}, |
| 3008 | [QDF_MODULE_ID_ASSOC] = {"association"}, |
| 3009 | [QDF_MODULE_ID_NODE] = {"node"}, |
| 3010 | [QDF_MODULE_ID_ELEMID] = {"element ID"}, |
| 3011 | [QDF_MODULE_ID_XRATE] = {"rate"}, |
| 3012 | [QDF_MODULE_ID_INPUT] = {"input"}, |
| 3013 | [QDF_MODULE_ID_CRYPTO] = {"crypto"}, |
| 3014 | [QDF_MODULE_ID_DUMPPKTS] = {"dump packet"}, |
| 3015 | [QDF_MODULE_ID_DEBUG] = {"debug"}, |
| 3016 | [QDF_MODULE_ID_MLME] = {"mlme"}, |
| 3017 | [QDF_MODULE_ID_RRM] = {"rrm"}, |
| 3018 | [QDF_MODULE_ID_WNM] = {"wnm"}, |
| 3019 | [QDF_MODULE_ID_P2P_PROT] = {"p2p_prot"}, |
| 3020 | [QDF_MODULE_ID_PROXYARP] = {"proxyarp"}, |
| 3021 | [QDF_MODULE_ID_L2TIF] = {"l2tif"}, |
| 3022 | [QDF_MODULE_ID_WIFIPOS] = {"wifipos"}, |
| 3023 | [QDF_MODULE_ID_WRAP] = {"wrap"}, |
| 3024 | [QDF_MODULE_ID_DFS] = {"dfs"}, |
| 3025 | [QDF_MODULE_ID_ATF] = {"atf"}, |
| 3026 | [QDF_MODULE_ID_SPLITMAC] = {"splitmac"}, |
| 3027 | [QDF_MODULE_ID_IOCTL] = {"ioctl"}, |
| 3028 | [QDF_MODULE_ID_NAC] = {"nac"}, |
| 3029 | [QDF_MODULE_ID_MESH] = {"mesh"}, |
| 3030 | [QDF_MODULE_ID_MBO] = {"mbo"}, |
| 3031 | [QDF_MODULE_ID_EXTIOCTL_CHANSWITCH] = {"extchanswitch"}, |
| 3032 | [QDF_MODULE_ID_EXTIOCTL_CHANSSCAN] = {"extchanscan"}, |
| 3033 | [QDF_MODULE_ID_TLSHIM] = {"tlshim"}, |
| 3034 | [QDF_MODULE_ID_WMI] = {"WMI"}, |
| 3035 | [QDF_MODULE_ID_HTT] = {"HTT"}, |
| 3036 | [QDF_MODULE_ID_HDD] = {"HDD"}, |
| 3037 | [QDF_MODULE_ID_SME] = {"SME"}, |
| 3038 | [QDF_MODULE_ID_PE] = {"PE"}, |
| 3039 | [QDF_MODULE_ID_WMA] = {"WMA"}, |
| 3040 | [QDF_MODULE_ID_SYS] = {"SYS"}, |
| 3041 | [QDF_MODULE_ID_QDF] = {"QDF"}, |
| 3042 | [QDF_MODULE_ID_SAP] = {"SAP"}, |
| 3043 | [QDF_MODULE_ID_HDD_SOFTAP] = {"HDD_SAP"}, |
| 3044 | [QDF_MODULE_ID_HDD_DATA] = {"DATA"}, |
| 3045 | [QDF_MODULE_ID_HDD_SAP_DATA] = {"SAP_DATA"}, |
| 3046 | [QDF_MODULE_ID_HIF] = {"HIF"}, |
| 3047 | [QDF_MODULE_ID_HTC] = {"HTC"}, |
| 3048 | [QDF_MODULE_ID_TXRX] = {"TXRX"}, |
| 3049 | [QDF_MODULE_ID_QDF_DEVICE] = {"QDF_DEV"}, |
| 3050 | [QDF_MODULE_ID_CFG] = {"CFG"}, |
| 3051 | [QDF_MODULE_ID_BMI] = {"BMI"}, |
| 3052 | [QDF_MODULE_ID_EPPING] = {"EPPING"}, |
| 3053 | [QDF_MODULE_ID_QVIT] = {"QVIT"}, |
Ashish Kumar Dhanotiya | d199fcb | 2017-02-06 20:53:04 +0530 | [diff] [blame] | 3054 | [QDF_MODULE_ID_DP] = {"DP"}, |
Venkata Sharath Chandra Manchala | 443b9b4 | 2018-10-10 12:04:54 -0700 | [diff] [blame] | 3055 | [QDF_MODULE_ID_HAL] = {"HAL"}, |
Ashish Kumar Dhanotiya | d199fcb | 2017-02-06 20:53:04 +0530 | [diff] [blame] | 3056 | [QDF_MODULE_ID_SOC] = {"SOC"}, |
| 3057 | [QDF_MODULE_ID_OS_IF] = {"OSIF"}, |
| 3058 | [QDF_MODULE_ID_TARGET_IF] = {"TIF"}, |
| 3059 | [QDF_MODULE_ID_SCHEDULER] = {"SCH"}, |
| 3060 | [QDF_MODULE_ID_MGMT_TXRX] = {"MGMT_TXRX"}, |
Mukul Sharma | d8fd144 | 2017-02-03 11:27:17 +0530 | [diff] [blame] | 3061 | [QDF_MODULE_ID_PMO] = {"PMO"}, |
Tushnim Bhattacharyya | e4449d3 | 2017-03-17 11:01:49 -0700 | [diff] [blame] | 3062 | [QDF_MODULE_ID_POLICY_MGR] = {"POLICY_MGR"}, |
Aditya Sathish | 1c42c27 | 2018-07-20 14:52:05 +0530 | [diff] [blame] | 3063 | [QDF_MODULE_ID_SA_API] = {"SA_API"}, |
Naveen Rawat | 5154273 | 2017-03-21 15:09:34 -0700 | [diff] [blame] | 3064 | [QDF_MODULE_ID_NAN] = {"NAN"}, |
Edayilliam Jayadev | 642201f | 2017-04-05 14:29:18 +0530 | [diff] [blame] | 3065 | [QDF_MODULE_ID_SPECTRAL] = {"SPECTRAL"}, |
Wu Gao | 849fd2c | 2017-03-23 10:14:39 +0800 | [diff] [blame] | 3066 | [QDF_MODULE_ID_P2P] = {"P2P"}, |
Kiran Venkatappa | 3453674 | 2017-04-04 00:09:10 +0530 | [diff] [blame] | 3067 | [QDF_MODULE_ID_OFFCHAN_TXRX] = {"OFFCHAN"}, |
Kiran Kumar Lokere | a843634 | 2017-04-24 00:56:03 -0700 | [diff] [blame] | 3068 | [QDF_MODULE_ID_REGULATORY] = {"REGULATORY"}, |
Vivek | 2c86b21 | 2017-06-05 00:02:11 +0530 | [diff] [blame] | 3069 | [QDF_MODULE_ID_OBJ_MGR] = {"OBJMGR"}, |
Varun Reddy Yeturu | 2576425 | 2017-08-10 13:53:01 -0700 | [diff] [blame] | 3070 | [QDF_MODULE_ID_SERIALIZATION] = {"SER"}, |
Aniruddha Paul | b2f7ab6 | 2017-10-09 14:40:04 +0530 | [diff] [blame] | 3071 | [QDF_MODULE_ID_NSS] = {"NSS"}, |
Deepak Dhamdhere | 7e0b8ba | 2017-07-03 00:33:26 -0700 | [diff] [blame] | 3072 | [QDF_MODULE_ID_ROAM_DEBUG] = {"roam debug"}, |
Sathish Kumar | a9a42eb | 2017-11-17 17:26:39 +0530 | [diff] [blame] | 3073 | [QDF_MODULE_ID_DIRECT_BUF_RX] = {"DIRECT_BUF_RX"}, |
Nachiket Kukade | 88ae853 | 2017-12-15 12:36:58 +0530 | [diff] [blame] | 3074 | [QDF_MODULE_ID_DISA] = {"disa"}, |
Himanshu Agarwal | b3c81ac | 2018-01-10 14:21:53 +0530 | [diff] [blame] | 3075 | [QDF_MODULE_ID_GREEN_AP] = {"GREEN_AP"}, |
Santosh Anbu | d5fdfac | 2018-01-03 22:33:58 +0530 | [diff] [blame] | 3076 | [QDF_MODULE_ID_EXTAP] = {"EXTAP"}, |
Subrat Mishra | bf12587 | 2017-09-27 14:41:20 +0530 | [diff] [blame] | 3077 | [QDF_MODULE_ID_FD] = {"FILS discovery"}, |
Akshay Kosigi | 8139413 | 2018-01-18 11:41:13 +0530 | [diff] [blame] | 3078 | [QDF_MODULE_ID_FTM] = {"FTM"}, |
Zhang Qian | 82377ce | 2018-01-04 12:15:29 +0800 | [diff] [blame] | 3079 | [QDF_MODULE_ID_OCB] = {"OCB"}, |
Dustin Brown | 61cabef | 2018-02-22 15:51:31 -0800 | [diff] [blame] | 3080 | [QDF_MODULE_ID_CONFIG] = {"CONFIG"}, |
Sravan Kumar Kairam | 376e5f1 | 2018-03-07 15:56:21 +0530 | [diff] [blame] | 3081 | [QDF_MODULE_ID_IPA] = {"IPA"}, |
Naga | 6d06baa | 2018-02-21 15:17:55 +0530 | [diff] [blame] | 3082 | [QDF_MODULE_ID_CP_STATS] = {"CP_STATS"}, |
Rajeev Kumar Sirasanagandla | 6697085 | 2017-09-18 16:47:52 +0530 | [diff] [blame] | 3083 | [QDF_MODULE_ID_ACTION_OUI] = {"action_oui"}, |
Ashish Kumar Dhanotiya | 14e2249 | 2018-06-24 17:13:39 +0530 | [diff] [blame] | 3084 | [QDF_MODULE_ID_TARGET] = {"TARGET"}, |
Manoj Ekbote | b8de937 | 2018-06-06 16:52:39 -0700 | [diff] [blame] | 3085 | [QDF_MODULE_ID_MBSSIE] = {"MBSSIE"}, |
Sourav Mohapatra | 474c614 | 2018-08-29 15:23:26 +0530 | [diff] [blame] | 3086 | [QDF_MODULE_ID_FWOL] = {"fwol"}, |
Santosh Anbu | cdf3813 | 2019-01-14 17:12:54 +0530 | [diff] [blame] | 3087 | [QDF_MODULE_ID_SM_ENGINE] = {"SM_ENG"}, |
Srinivas Pitla | be8dac4 | 2018-06-14 16:05:03 +0530 | [diff] [blame] | 3088 | [QDF_MODULE_ID_CMN_MLME] = {"CMN_MLME"}, |
Gyanranjan Hazarika | 2c54581 | 2018-10-04 12:11:46 -0700 | [diff] [blame] | 3089 | [QDF_MODULE_ID_BSSCOLOR] = {"BSSCOLOR"}, |
Abhiram Jogadenu | c528145 | 2019-02-14 16:21:09 +0530 | [diff] [blame] | 3090 | [QDF_MODULE_ID_CFR] = {"CFR"}, |
nobelj | debe2b3 | 2019-04-23 11:18:47 -0700 | [diff] [blame] | 3091 | [QDF_MODULE_ID_TX_CAPTURE] = {"TX_CAPTURE_ENHANCE"}, |
Paul Zhang | 5ea0a91 | 2019-05-14 11:33:31 +0800 | [diff] [blame] | 3092 | [QDF_MODULE_ID_INTEROP_ISSUES_AP] = {"INTEROP_ISSUES_AP"}, |
gaurank kathpalia | 9f525cb | 2019-05-28 18:21:18 +0530 | [diff] [blame] | 3093 | [QDF_MODULE_ID_BLACKLIST_MGR] = {"blm"}, |
Uraj Sasan | 37b2c4d | 2019-06-13 18:21:24 +0530 | [diff] [blame] | 3094 | [QDF_MODULE_ID_QLD] = {"QLD"}, |
Gyanranjan Hazarika | 8e0ae99 | 2019-06-05 00:43:38 -0700 | [diff] [blame] | 3095 | [QDF_MODULE_ID_DYNAMIC_MODE_CHG] = {"Dynamic Mode Change"}, |
Yu Wang | e7f177a | 2019-12-18 08:59:49 +0800 | [diff] [blame] | 3096 | [QDF_MODULE_ID_COEX] = {"COEX"}, |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3097 | [QDF_MODULE_ID_ANY] = {"ANY"}, |
Vulupala Shashank Reddy | 3b6d1f2 | 2020-01-26 12:42:50 +0530 | [diff] [blame^] | 3098 | [QDF_MODULE_ID_PKT_CAPTURE] = {"pkt_capture"}, |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3099 | }; |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3100 | qdf_export_symbol(g_qdf_category_name); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3101 | |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 3102 | /** |
| 3103 | * qdf_trace_display() - Display trace |
| 3104 | * |
| 3105 | * Return: None |
| 3106 | */ |
| 3107 | void qdf_trace_display(void) |
| 3108 | { |
| 3109 | QDF_MODULE_ID module_id; |
| 3110 | |
| 3111 | pr_err(" 1)FATAL 2)ERROR 3)WARN 4)INFO 5)INFO_H 6)INFO_M 7)INFO_L 8)DEBUG\n"); |
| 3112 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; ++module_id) { |
| 3113 | pr_err("%2d)%s %s %s %s %s %s %s %s %s\n", |
| 3114 | (int)module_id, |
| 3115 | g_qdf_category_name[module_id].category_name_str, |
| 3116 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3117 | QDF_TRACE_LEVEL_FATAL) ? "X" : " ", |
| 3118 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3119 | QDF_TRACE_LEVEL_ERROR) ? "X" : " ", |
| 3120 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3121 | QDF_TRACE_LEVEL_WARN) ? "X" : " ", |
| 3122 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3123 | QDF_TRACE_LEVEL_INFO) ? "X" : " ", |
| 3124 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3125 | QDF_TRACE_LEVEL_INFO_HIGH) ? "X" : " ", |
| 3126 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3127 | QDF_TRACE_LEVEL_INFO_MED) ? "X" : " ", |
| 3128 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3129 | QDF_TRACE_LEVEL_INFO_LOW) ? "X" : " ", |
| 3130 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 3131 | QDF_TRACE_LEVEL_DEBUG) ? "X" : " "); |
| 3132 | } |
| 3133 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3134 | qdf_export_symbol(qdf_trace_display); |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3135 | |
Ashish Kumar Dhanotiya | affc485 | 2019-03-01 20:40:22 +0530 | [diff] [blame] | 3136 | #ifdef QDF_TRACE_PRINT_ENABLE |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3137 | static inline void print_to_console(char *str_buffer) |
| 3138 | { |
| 3139 | pr_err("%s\n", str_buffer); |
| 3140 | } |
Ashish Kumar Dhanotiya | affc485 | 2019-03-01 20:40:22 +0530 | [diff] [blame] | 3141 | #else |
| 3142 | |
| 3143 | #define print_to_console(str) |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3144 | #endif |
| 3145 | |
Manikandan Mohan | eb61d7e | 2018-03-05 16:23:21 -0800 | [diff] [blame] | 3146 | #ifdef MULTI_IF_NAME |
| 3147 | static const char *qdf_trace_wlan_modname(void) |
| 3148 | { |
| 3149 | return MULTI_IF_NAME; |
| 3150 | } |
| 3151 | #else |
| 3152 | static const char *qdf_trace_wlan_modname(void) |
| 3153 | { |
| 3154 | return "wlan"; |
| 3155 | } |
| 3156 | #endif |
| 3157 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3158 | void qdf_trace_msg_cmn(unsigned int idx, |
| 3159 | QDF_MODULE_ID category, |
| 3160 | QDF_TRACE_LEVEL verbose, |
| 3161 | const char *str_format, va_list val) |
| 3162 | { |
| 3163 | char str_buffer[QDF_TRACE_BUFFER_SIZE]; |
| 3164 | int n; |
| 3165 | |
| 3166 | /* Check if index passed is valid */ |
| 3167 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3168 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3169 | return; |
| 3170 | } |
| 3171 | |
| 3172 | /* Check if print control object is in use */ |
| 3173 | if (!print_ctrl_obj[idx].in_use) { |
| 3174 | pr_info("%s: Invalid print control object\n", __func__); |
| 3175 | return; |
| 3176 | } |
| 3177 | |
| 3178 | /* Check if category passed is valid */ |
| 3179 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 3180 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 3181 | return; |
| 3182 | } |
| 3183 | |
| 3184 | /* Check if verbose mask is valid */ |
| 3185 | if (verbose < 0 || verbose >= QDF_TRACE_LEVEL_MAX) { |
| 3186 | pr_info("%s: Invalid verbose level %d\n", __func__, verbose); |
| 3187 | return; |
| 3188 | } |
| 3189 | |
| 3190 | /* |
| 3191 | * Print the trace message when the desired verbose level is set in |
| 3192 | * the desired category for the print control object |
| 3193 | */ |
| 3194 | if (print_ctrl_obj[idx].cat_info[category].category_verbose_mask & |
| 3195 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) { |
Jeff Johnson | 49dd1d9 | 2018-04-28 12:06:59 -0700 | [diff] [blame] | 3196 | static const char * const VERBOSE_STR[] = { |
| 3197 | [QDF_TRACE_LEVEL_NONE] = "", |
| 3198 | [QDF_TRACE_LEVEL_FATAL] = "F", |
| 3199 | [QDF_TRACE_LEVEL_ERROR] = "E", |
| 3200 | [QDF_TRACE_LEVEL_WARN] = "W", |
| 3201 | [QDF_TRACE_LEVEL_INFO] = "I", |
| 3202 | [QDF_TRACE_LEVEL_INFO_HIGH] = "IH", |
| 3203 | [QDF_TRACE_LEVEL_INFO_MED] = "IM", |
| 3204 | [QDF_TRACE_LEVEL_INFO_LOW] = "IL", |
| 3205 | [QDF_TRACE_LEVEL_DEBUG] = "D", |
Ashish Kumar Dhanotiya | 9d0ed25 | 2018-06-24 18:01:58 +0530 | [diff] [blame] | 3206 | [QDF_TRACE_LEVEL_TRACE] = "T", |
Jeff Johnson | 49dd1d9 | 2018-04-28 12:06:59 -0700 | [diff] [blame] | 3207 | [QDF_TRACE_LEVEL_ALL] = "" }; |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3208 | |
| 3209 | /* print the prefix string into the string buffer... */ |
| 3210 | n = scnprintf(str_buffer, QDF_TRACE_BUFFER_SIZE, |
Ashish Kumar Dhanotiya | 9d0ed25 | 2018-06-24 18:01:58 +0530 | [diff] [blame] | 3211 | "%s: [%d:%s:%s] ", qdf_trace_wlan_modname(), |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3212 | in_interrupt() ? 0 : current->pid, |
| 3213 | VERBOSE_STR[verbose], |
| 3214 | g_qdf_category_name[category].category_name_str); |
| 3215 | |
| 3216 | /* print the formatted log message after the prefix string */ |
| 3217 | vscnprintf(str_buffer + n, QDF_TRACE_BUFFER_SIZE - n, |
| 3218 | str_format, val); |
| 3219 | #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) |
| 3220 | wlan_log_to_user(verbose, (char *)str_buffer, |
| 3221 | strlen(str_buffer)); |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3222 | if (qdf_likely(qdf_log_dump_at_kernel_enable)) |
| 3223 | print_to_console(str_buffer); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3224 | #else |
| 3225 | pr_err("%s\n", str_buffer); |
| 3226 | #endif |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3227 | } |
| 3228 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3229 | qdf_export_symbol(qdf_trace_msg_cmn); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3230 | |
| 3231 | QDF_STATUS qdf_print_setup(void) |
| 3232 | { |
| 3233 | int i; |
| 3234 | |
| 3235 | /* Loop through all print ctrl objects */ |
| 3236 | for (i = 0; i < MAX_PRINT_CONFIG_SUPPORTED; i++) { |
| 3237 | if (qdf_print_ctrl_cleanup(i)) |
| 3238 | return QDF_STATUS_E_FAILURE; |
| 3239 | } |
| 3240 | return QDF_STATUS_SUCCESS; |
| 3241 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3242 | qdf_export_symbol(qdf_print_setup); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3243 | |
| 3244 | QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx) |
| 3245 | { |
| 3246 | int i = 0; |
| 3247 | |
| 3248 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3249 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3250 | return QDF_STATUS_E_FAILURE; |
| 3251 | } |
| 3252 | |
| 3253 | /* Clean up the print control object corresponding to that index |
| 3254 | * If success, callee to change print control index to -1 |
| 3255 | */ |
| 3256 | |
| 3257 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 3258 | print_ctrl_obj[idx].cat_info[i].category_verbose_mask = |
| 3259 | QDF_TRACE_LEVEL_NONE; |
| 3260 | } |
| 3261 | print_ctrl_obj[idx].custom_print = NULL; |
| 3262 | print_ctrl_obj[idx].custom_ctxt = NULL; |
| 3263 | qdf_print_clean_node_flag(idx); |
| 3264 | print_ctrl_obj[idx].in_use = false; |
| 3265 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3266 | return QDF_STATUS_SUCCESS; |
| 3267 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3268 | qdf_export_symbol(qdf_print_ctrl_cleanup); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3269 | |
| 3270 | int qdf_print_ctrl_register(const struct category_info *cinfo, |
| 3271 | void *custom_print_handler, |
| 3272 | void *custom_ctx, |
| 3273 | const char *pctrl_name) |
| 3274 | { |
| 3275 | int idx = -1; |
| 3276 | int i = 0; |
| 3277 | |
| 3278 | for (i = 0; i < MAX_PRINT_CONFIG_SUPPORTED; i++) { |
| 3279 | if (!print_ctrl_obj[i].in_use) { |
| 3280 | idx = i; |
| 3281 | break; |
| 3282 | } |
| 3283 | } |
| 3284 | |
| 3285 | /* Callee to handle idx -1 appropriately */ |
| 3286 | if (idx == -1) { |
| 3287 | pr_info("%s: Allocation failed! No print control object free\n", |
| 3288 | __func__); |
| 3289 | return idx; |
| 3290 | } |
| 3291 | |
| 3292 | print_ctrl_obj[idx].in_use = true; |
| 3293 | |
| 3294 | /* |
| 3295 | * In case callee does not pass category info, |
| 3296 | * custom print handler, custom context and print control name, |
| 3297 | * we do not set any value here. Clean up for the print control |
| 3298 | * getting allocated would have taken care of initializing |
| 3299 | * default values. |
| 3300 | * |
| 3301 | * We need to only set in_use to 1 in such a case |
| 3302 | */ |
| 3303 | |
| 3304 | if (pctrl_name) { |
| 3305 | qdf_str_lcopy(print_ctrl_obj[idx].name, pctrl_name, |
Dustin Brown | 26e61b5 | 2018-02-26 12:28:31 -0800 | [diff] [blame] | 3306 | sizeof(print_ctrl_obj[idx].name)); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3307 | } |
| 3308 | |
| 3309 | if (custom_print_handler) |
| 3310 | print_ctrl_obj[idx].custom_print = custom_print_handler; |
| 3311 | |
| 3312 | if (custom_ctx) |
| 3313 | print_ctrl_obj[idx].custom_ctxt = custom_ctx; |
| 3314 | |
| 3315 | if (cinfo) { |
| 3316 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 3317 | if (cinfo[i].category_verbose_mask == |
| 3318 | QDF_TRACE_LEVEL_ALL) { |
| 3319 | print_ctrl_obj[idx].cat_info[i] |
| 3320 | .category_verbose_mask = 0xFFFF; |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 3321 | } else if ((cinfo[i].category_verbose_mask == |
| 3322 | QDF_TRACE_LEVEL_NONE) || |
| 3323 | (cinfo[i].category_verbose_mask == |
| 3324 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK( |
| 3325 | QDF_TRACE_LEVEL_NONE))) { |
| 3326 | print_ctrl_obj[idx].cat_info[i] |
| 3327 | .category_verbose_mask = 0; |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3328 | } else { |
| 3329 | print_ctrl_obj[idx].cat_info[i] |
| 3330 | .category_verbose_mask = |
| 3331 | cinfo[i].category_verbose_mask; |
| 3332 | } |
| 3333 | } |
| 3334 | } |
| 3335 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3336 | return idx; |
| 3337 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3338 | qdf_export_symbol(qdf_print_ctrl_register); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3339 | |
Ashish Kumar Dhanotiya | f38970b | 2019-04-29 12:23:55 +0530 | [diff] [blame] | 3340 | #ifdef QDF_TRACE_PRINT_ENABLE |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3341 | void qdf_shared_print_ctrl_cleanup(void) |
| 3342 | { |
| 3343 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 3344 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3345 | qdf_export_symbol(qdf_shared_print_ctrl_cleanup); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3346 | |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3347 | /* |
| 3348 | * Set this to invalid value to differentiate with user-provided |
| 3349 | * value. |
| 3350 | */ |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 3351 | int qdf_dbg_mask = 0; |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3352 | qdf_export_symbol(qdf_dbg_mask); |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3353 | qdf_declare_param(qdf_dbg_mask, int); |
| 3354 | |
| 3355 | /* |
| 3356 | * QDF can be passed parameters which indicate the |
| 3357 | * debug level for each module. |
| 3358 | * an array of string values are passed, each string hold the following form |
| 3359 | * |
| 3360 | * <module name string>=<integer debug level value> |
| 3361 | * |
| 3362 | * The array qdf_dbg_arr will hold these module-string=value strings |
| 3363 | * The variable qdf_dbg_arr_cnt will have the count of how many such |
| 3364 | * string values were passed. |
| 3365 | */ |
| 3366 | static char *qdf_dbg_arr[QDF_MODULE_ID_MAX]; |
| 3367 | static int qdf_dbg_arr_cnt; |
| 3368 | qdf_declare_param_array(qdf_dbg_arr, charp, &qdf_dbg_arr_cnt); |
| 3369 | |
| 3370 | static uint16_t set_cumulative_verbose_mask(QDF_TRACE_LEVEL max_level) |
| 3371 | { |
| 3372 | uint16_t category_verbose_mask = 0; |
| 3373 | QDF_TRACE_LEVEL level; |
| 3374 | |
| 3375 | for (level = QDF_TRACE_LEVEL_FATAL; level <= max_level; level++) { |
| 3376 | category_verbose_mask |= |
| 3377 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(level); |
| 3378 | } |
| 3379 | return category_verbose_mask; |
| 3380 | } |
| 3381 | |
| 3382 | static QDF_MODULE_ID find_qdf_module_from_string(char *str) |
| 3383 | { |
| 3384 | QDF_MODULE_ID mod_id; |
| 3385 | |
| 3386 | for (mod_id = 0; mod_id < QDF_MODULE_ID_MAX; mod_id++) { |
| 3387 | if (strcasecmp(str, |
| 3388 | g_qdf_category_name[mod_id].category_name_str) |
| 3389 | == 0) { |
| 3390 | break; |
| 3391 | } |
| 3392 | } |
| 3393 | return mod_id; |
| 3394 | } |
| 3395 | |
| 3396 | static void process_qdf_dbg_arr_param(struct category_info *cinfo, |
| 3397 | int array_index) |
| 3398 | { |
| 3399 | char *mod_val_str, *mod_str, *val_str; |
| 3400 | unsigned long dbg_level; |
| 3401 | QDF_MODULE_ID mod_id; |
| 3402 | |
| 3403 | mod_val_str = qdf_dbg_arr[array_index]; |
| 3404 | mod_str = strsep(&mod_val_str, "="); |
| 3405 | val_str = mod_val_str; |
Jeff Johnson | 2831229 | 2019-03-18 09:49:07 -0700 | [diff] [blame] | 3406 | if (!val_str) { |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3407 | pr_info("qdf_dbg_arr: %s not in the <mod>=<val> form\n", |
| 3408 | mod_str); |
| 3409 | return; |
| 3410 | } |
| 3411 | |
| 3412 | mod_id = find_qdf_module_from_string(mod_str); |
| 3413 | if (mod_id >= QDF_MODULE_ID_MAX) { |
| 3414 | pr_info("ERROR!!Module name %s not in the list of modules\n", |
| 3415 | mod_str); |
| 3416 | return; |
| 3417 | } |
| 3418 | |
| 3419 | if (kstrtol(val_str, 10, &dbg_level) < 0) { |
| 3420 | pr_info("ERROR!!Invalid debug level for module: %s\n", |
| 3421 | mod_str); |
| 3422 | return; |
| 3423 | } |
| 3424 | |
| 3425 | if (dbg_level >= QDF_TRACE_LEVEL_MAX) { |
| 3426 | pr_info("ERROR!!Debug level for %s too high", mod_str); |
| 3427 | pr_info("max: %d given %lu\n", QDF_TRACE_LEVEL_MAX, |
| 3428 | dbg_level); |
| 3429 | return; |
| 3430 | } |
| 3431 | |
| 3432 | pr_info("User passed setting module %s(%d) to level %lu\n", |
| 3433 | mod_str, |
| 3434 | mod_id, |
| 3435 | dbg_level); |
| 3436 | cinfo[mod_id].category_verbose_mask = |
| 3437 | set_cumulative_verbose_mask((QDF_TRACE_LEVEL)dbg_level); |
| 3438 | } |
| 3439 | |
| 3440 | static void set_default_trace_levels(struct category_info *cinfo) |
| 3441 | { |
| 3442 | int i; |
| 3443 | static QDF_TRACE_LEVEL module_trace_default_level[QDF_MODULE_ID_MAX] = { |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3444 | [QDF_MODULE_ID_TDLS] = QDF_TRACE_LEVEL_NONE, |
| 3445 | [QDF_MODULE_ID_ACS] = QDF_TRACE_LEVEL_NONE, |
| 3446 | [QDF_MODULE_ID_SCAN_SM] = QDF_TRACE_LEVEL_NONE, |
| 3447 | [QDF_MODULE_ID_SCANENTRY] = QDF_TRACE_LEVEL_NONE, |
| 3448 | [QDF_MODULE_ID_WDS] = QDF_TRACE_LEVEL_NONE, |
| 3449 | [QDF_MODULE_ID_ACTION] = QDF_TRACE_LEVEL_NONE, |
| 3450 | [QDF_MODULE_ID_ROAM] = QDF_TRACE_LEVEL_NONE, |
| 3451 | [QDF_MODULE_ID_INACT] = QDF_TRACE_LEVEL_NONE, |
| 3452 | [QDF_MODULE_ID_DOTH] = QDF_TRACE_LEVEL_NONE, |
| 3453 | [QDF_MODULE_ID_IQUE] = QDF_TRACE_LEVEL_NONE, |
| 3454 | [QDF_MODULE_ID_WME] = QDF_TRACE_LEVEL_NONE, |
| 3455 | [QDF_MODULE_ID_ACL] = QDF_TRACE_LEVEL_NONE, |
| 3456 | [QDF_MODULE_ID_WPA] = QDF_TRACE_LEVEL_NONE, |
| 3457 | [QDF_MODULE_ID_RADKEYS] = QDF_TRACE_LEVEL_NONE, |
| 3458 | [QDF_MODULE_ID_RADDUMP] = QDF_TRACE_LEVEL_NONE, |
| 3459 | [QDF_MODULE_ID_RADIUS] = QDF_TRACE_LEVEL_NONE, |
| 3460 | [QDF_MODULE_ID_DOT1XSM] = QDF_TRACE_LEVEL_NONE, |
| 3461 | [QDF_MODULE_ID_DOT1X] = QDF_TRACE_LEVEL_NONE, |
| 3462 | [QDF_MODULE_ID_POWER] = QDF_TRACE_LEVEL_NONE, |
| 3463 | [QDF_MODULE_ID_STATE] = QDF_TRACE_LEVEL_NONE, |
| 3464 | [QDF_MODULE_ID_OUTPUT] = QDF_TRACE_LEVEL_NONE, |
Akshay Kosigi | 41da247 | 2018-04-12 15:31:44 +0530 | [diff] [blame] | 3465 | [QDF_MODULE_ID_SCAN] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3466 | [QDF_MODULE_ID_AUTH] = QDF_TRACE_LEVEL_NONE, |
| 3467 | [QDF_MODULE_ID_ASSOC] = QDF_TRACE_LEVEL_NONE, |
| 3468 | [QDF_MODULE_ID_NODE] = QDF_TRACE_LEVEL_NONE, |
| 3469 | [QDF_MODULE_ID_ELEMID] = QDF_TRACE_LEVEL_NONE, |
| 3470 | [QDF_MODULE_ID_XRATE] = QDF_TRACE_LEVEL_NONE, |
| 3471 | [QDF_MODULE_ID_INPUT] = QDF_TRACE_LEVEL_NONE, |
| 3472 | [QDF_MODULE_ID_CRYPTO] = QDF_TRACE_LEVEL_NONE, |
| 3473 | [QDF_MODULE_ID_DUMPPKTS] = QDF_TRACE_LEVEL_NONE, |
| 3474 | [QDF_MODULE_ID_DEBUG] = QDF_TRACE_LEVEL_NONE, |
Santosh Anbu | 6e2fed8 | 2018-11-30 15:26:30 +0530 | [diff] [blame] | 3475 | [QDF_MODULE_ID_MLME] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3476 | [QDF_MODULE_ID_RRM] = QDF_TRACE_LEVEL_NONE, |
| 3477 | [QDF_MODULE_ID_WNM] = QDF_TRACE_LEVEL_NONE, |
| 3478 | [QDF_MODULE_ID_P2P_PROT] = QDF_TRACE_LEVEL_NONE, |
| 3479 | [QDF_MODULE_ID_PROXYARP] = QDF_TRACE_LEVEL_NONE, |
| 3480 | [QDF_MODULE_ID_L2TIF] = QDF_TRACE_LEVEL_NONE, |
| 3481 | [QDF_MODULE_ID_WIFIPOS] = QDF_TRACE_LEVEL_NONE, |
| 3482 | [QDF_MODULE_ID_WRAP] = QDF_TRACE_LEVEL_NONE, |
| 3483 | [QDF_MODULE_ID_DFS] = QDF_TRACE_LEVEL_NONE, |
Subrat Mishra | 2a06b23 | 2018-03-08 12:55:58 +0530 | [diff] [blame] | 3484 | [QDF_MODULE_ID_ATF] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3485 | [QDF_MODULE_ID_SPLITMAC] = QDF_TRACE_LEVEL_NONE, |
| 3486 | [QDF_MODULE_ID_IOCTL] = QDF_TRACE_LEVEL_NONE, |
| 3487 | [QDF_MODULE_ID_NAC] = QDF_TRACE_LEVEL_NONE, |
| 3488 | [QDF_MODULE_ID_MESH] = QDF_TRACE_LEVEL_NONE, |
| 3489 | [QDF_MODULE_ID_MBO] = QDF_TRACE_LEVEL_NONE, |
| 3490 | [QDF_MODULE_ID_EXTIOCTL_CHANSWITCH] = QDF_TRACE_LEVEL_NONE, |
| 3491 | [QDF_MODULE_ID_EXTIOCTL_CHANSSCAN] = QDF_TRACE_LEVEL_NONE, |
| 3492 | [QDF_MODULE_ID_TLSHIM] = QDF_TRACE_LEVEL_NONE, |
Surya Prakash | 27fba32 | 2019-01-31 14:16:27 +0530 | [diff] [blame] | 3493 | [QDF_MODULE_ID_WMI] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3494 | [QDF_MODULE_ID_HTT] = QDF_TRACE_LEVEL_NONE, |
| 3495 | [QDF_MODULE_ID_HDD] = QDF_TRACE_LEVEL_NONE, |
| 3496 | [QDF_MODULE_ID_SME] = QDF_TRACE_LEVEL_NONE, |
| 3497 | [QDF_MODULE_ID_PE] = QDF_TRACE_LEVEL_NONE, |
| 3498 | [QDF_MODULE_ID_WMA] = QDF_TRACE_LEVEL_NONE, |
| 3499 | [QDF_MODULE_ID_SYS] = QDF_TRACE_LEVEL_NONE, |
Shiva Krishna Pittala | b155431 | 2018-04-02 17:23:42 +0530 | [diff] [blame] | 3500 | [QDF_MODULE_ID_QDF] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3501 | [QDF_MODULE_ID_SAP] = QDF_TRACE_LEVEL_NONE, |
| 3502 | [QDF_MODULE_ID_HDD_SOFTAP] = QDF_TRACE_LEVEL_NONE, |
| 3503 | [QDF_MODULE_ID_HDD_DATA] = QDF_TRACE_LEVEL_NONE, |
| 3504 | [QDF_MODULE_ID_HDD_SAP_DATA] = QDF_TRACE_LEVEL_NONE, |
Santosh Anbu | efe6c5a | 2018-03-14 15:30:36 +0530 | [diff] [blame] | 3505 | [QDF_MODULE_ID_HIF] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3506 | [QDF_MODULE_ID_HTC] = QDF_TRACE_LEVEL_NONE, |
| 3507 | [QDF_MODULE_ID_TXRX] = QDF_TRACE_LEVEL_NONE, |
| 3508 | [QDF_MODULE_ID_QDF_DEVICE] = QDF_TRACE_LEVEL_NONE, |
| 3509 | [QDF_MODULE_ID_CFG] = QDF_TRACE_LEVEL_NONE, |
| 3510 | [QDF_MODULE_ID_BMI] = QDF_TRACE_LEVEL_NONE, |
| 3511 | [QDF_MODULE_ID_EPPING] = QDF_TRACE_LEVEL_NONE, |
| 3512 | [QDF_MODULE_ID_QVIT] = QDF_TRACE_LEVEL_NONE, |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 3513 | [QDF_MODULE_ID_DP] = QDF_TRACE_LEVEL_FATAL, |
Venkata Sharath Chandra Manchala | 443b9b4 | 2018-10-10 12:04:54 -0700 | [diff] [blame] | 3514 | [QDF_MODULE_ID_HAL] = QDF_TRACE_LEVEL_NONE, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3515 | [QDF_MODULE_ID_SOC] = QDF_TRACE_LEVEL_NONE, |
| 3516 | [QDF_MODULE_ID_OS_IF] = QDF_TRACE_LEVEL_NONE, |
Srinivas Pitla | c4bdc7a | 2018-01-08 16:53:37 +0530 | [diff] [blame] | 3517 | [QDF_MODULE_ID_TARGET_IF] = QDF_TRACE_LEVEL_INFO, |
Vivek | bea437e | 2020-01-07 19:22:44 +0530 | [diff] [blame] | 3518 | [QDF_MODULE_ID_SCHEDULER] = QDF_TRACE_LEVEL_FATAL, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 3519 | [QDF_MODULE_ID_MGMT_TXRX] = QDF_TRACE_LEVEL_NONE, |
Vivek | d34b7d0 | 2019-01-25 13:55:29 +0530 | [diff] [blame] | 3520 | [QDF_MODULE_ID_SERIALIZATION] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | abdf9af | 2018-03-01 00:07:36 +0530 | [diff] [blame] | 3521 | [QDF_MODULE_ID_PMO] = QDF_TRACE_LEVEL_NONE, |
| 3522 | [QDF_MODULE_ID_P2P] = QDF_TRACE_LEVEL_NONE, |
| 3523 | [QDF_MODULE_ID_POLICY_MGR] = QDF_TRACE_LEVEL_NONE, |
| 3524 | [QDF_MODULE_ID_CONFIG] = QDF_TRACE_LEVEL_ERROR, |
| 3525 | [QDF_MODULE_ID_REGULATORY] = QDF_TRACE_LEVEL_NONE, |
| 3526 | [QDF_MODULE_ID_SA_API] = QDF_TRACE_LEVEL_NONE, |
| 3527 | [QDF_MODULE_ID_NAN] = QDF_TRACE_LEVEL_NONE, |
| 3528 | [QDF_MODULE_ID_OFFCHAN_TXRX] = QDF_TRACE_LEVEL_NONE, |
| 3529 | [QDF_MODULE_ID_SON] = QDF_TRACE_LEVEL_NONE, |
Shiva Krishna Pittala | 1345233 | 2019-01-21 14:51:17 +0530 | [diff] [blame] | 3530 | [QDF_MODULE_ID_SPECTRAL] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | 41da247 | 2018-04-12 15:31:44 +0530 | [diff] [blame] | 3531 | [QDF_MODULE_ID_OBJ_MGR] = QDF_TRACE_LEVEL_FATAL, |
Aniruddha Paul | b2f7ab6 | 2017-10-09 14:40:04 +0530 | [diff] [blame] | 3532 | [QDF_MODULE_ID_NSS] = QDF_TRACE_LEVEL_ERROR, |
Deepak Dhamdhere | 7e0b8ba | 2017-07-03 00:33:26 -0700 | [diff] [blame] | 3533 | [QDF_MODULE_ID_ROAM_DEBUG] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | abdf9af | 2018-03-01 00:07:36 +0530 | [diff] [blame] | 3534 | [QDF_MODULE_ID_CDP] = QDF_TRACE_LEVEL_NONE, |
Sathish Kumar | a9a42eb | 2017-11-17 17:26:39 +0530 | [diff] [blame] | 3535 | [QDF_MODULE_ID_DIRECT_BUF_RX] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | abdf9af | 2018-03-01 00:07:36 +0530 | [diff] [blame] | 3536 | [QDF_MODULE_ID_DISA] = QDF_TRACE_LEVEL_NONE, |
Himanshu Agarwal | b3c81ac | 2018-01-10 14:21:53 +0530 | [diff] [blame] | 3537 | [QDF_MODULE_ID_GREEN_AP] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | abdf9af | 2018-03-01 00:07:36 +0530 | [diff] [blame] | 3538 | [QDF_MODULE_ID_FTM] = QDF_TRACE_LEVEL_ERROR, |
Santosh Anbu | d5fdfac | 2018-01-03 22:33:58 +0530 | [diff] [blame] | 3539 | [QDF_MODULE_ID_EXTAP] = QDF_TRACE_LEVEL_NONE, |
Subrat Mishra | bf12587 | 2017-09-27 14:41:20 +0530 | [diff] [blame] | 3540 | [QDF_MODULE_ID_FD] = QDF_TRACE_LEVEL_ERROR, |
Zhang Qian | 82377ce | 2018-01-04 12:15:29 +0800 | [diff] [blame] | 3541 | [QDF_MODULE_ID_OCB] = QDF_TRACE_LEVEL_ERROR, |
Akshay Kosigi | 41da247 | 2018-04-12 15:31:44 +0530 | [diff] [blame] | 3542 | [QDF_MODULE_ID_IPA] = QDF_TRACE_LEVEL_NONE, |
Rajeev Kumar Sirasanagandla | 6697085 | 2017-09-18 16:47:52 +0530 | [diff] [blame] | 3543 | [QDF_MODULE_ID_ACTION_OUI] = QDF_TRACE_LEVEL_NONE, |
Naga | 6d06baa | 2018-02-21 15:17:55 +0530 | [diff] [blame] | 3544 | [QDF_MODULE_ID_CP_STATS] = QDF_TRACE_LEVEL_ERROR, |
Manoj Ekbote | b8de937 | 2018-06-06 16:52:39 -0700 | [diff] [blame] | 3545 | [QDF_MODULE_ID_MBSSIE] = QDF_TRACE_LEVEL_INFO, |
Sourav Mohapatra | 474c614 | 2018-08-29 15:23:26 +0530 | [diff] [blame] | 3546 | [QDF_MODULE_ID_FWOL] = QDF_TRACE_LEVEL_NONE, |
Srinivas Pitla | 8d19efa | 2019-02-22 15:55:05 +0530 | [diff] [blame] | 3547 | [QDF_MODULE_ID_SM_ENGINE] = QDF_TRACE_LEVEL_ERROR, |
Srinivas Pitla | be8dac4 | 2018-06-14 16:05:03 +0530 | [diff] [blame] | 3548 | [QDF_MODULE_ID_CMN_MLME] = QDF_TRACE_LEVEL_INFO, |
Gyanranjan Hazarika | 2c54581 | 2018-10-04 12:11:46 -0700 | [diff] [blame] | 3549 | [QDF_MODULE_ID_BSSCOLOR] = QDF_TRACE_LEVEL_ERROR, |
Abhiram Jogadenu | c528145 | 2019-02-14 16:21:09 +0530 | [diff] [blame] | 3550 | [QDF_MODULE_ID_CFR] = QDF_TRACE_LEVEL_ERROR, |
nobelj | debe2b3 | 2019-04-23 11:18:47 -0700 | [diff] [blame] | 3551 | [QDF_MODULE_ID_TX_CAPTURE] = QDF_TRACE_LEVEL_NONE, |
Paul Zhang | 5ea0a91 | 2019-05-14 11:33:31 +0800 | [diff] [blame] | 3552 | [QDF_MODULE_ID_INTEROP_ISSUES_AP] = QDF_TRACE_LEVEL_NONE, |
gaurank kathpalia | 9f525cb | 2019-05-28 18:21:18 +0530 | [diff] [blame] | 3553 | [QDF_MODULE_ID_BLACKLIST_MGR] = QDF_TRACE_LEVEL_NONE, |
Uraj Sasan | 37b2c4d | 2019-06-13 18:21:24 +0530 | [diff] [blame] | 3554 | [QDF_MODULE_ID_QLD] = QDF_TRACE_LEVEL_ERROR, |
Gyanranjan Hazarika | 8e0ae99 | 2019-06-05 00:43:38 -0700 | [diff] [blame] | 3555 | [QDF_MODULE_ID_DYNAMIC_MODE_CHG] = QDF_TRACE_LEVEL_INFO, |
Yu Wang | e7f177a | 2019-12-18 08:59:49 +0800 | [diff] [blame] | 3556 | [QDF_MODULE_ID_COEX] = QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | 1c42c27 | 2018-07-20 14:52:05 +0530 | [diff] [blame] | 3557 | [QDF_MODULE_ID_ANY] = QDF_TRACE_LEVEL_INFO, |
Vulupala Shashank Reddy | 3b6d1f2 | 2020-01-26 12:42:50 +0530 | [diff] [blame^] | 3558 | [QDF_MODULE_ID_PKT_CAPTURE] = QDF_TRACE_LEVEL_NONE, |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3559 | }; |
| 3560 | |
| 3561 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 3562 | cinfo[i].category_verbose_mask = set_cumulative_verbose_mask( |
| 3563 | module_trace_default_level[i]); |
| 3564 | } |
| 3565 | } |
| 3566 | |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3567 | void qdf_shared_print_ctrl_init(void) |
| 3568 | { |
| 3569 | int i; |
Shiva Krishna Pittala | b155431 | 2018-04-02 17:23:42 +0530 | [diff] [blame] | 3570 | struct category_info cinfo[MAX_SUPPORTED_CATEGORY]; |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3571 | |
| 3572 | set_default_trace_levels(cinfo); |
| 3573 | |
| 3574 | /* |
| 3575 | * User specified across-module single debug level |
| 3576 | */ |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 3577 | if ((qdf_dbg_mask > 0) && (qdf_dbg_mask <= QDF_TRACE_LEVEL_MAX)) { |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3578 | pr_info("User specified module debug level of %d\n", |
| 3579 | qdf_dbg_mask); |
| 3580 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 3581 | cinfo[i].category_verbose_mask = |
| 3582 | set_cumulative_verbose_mask(qdf_dbg_mask); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3583 | } |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 3584 | } else { |
| 3585 | pr_info("qdf_dbg_mask value is invalid\n"); |
| 3586 | pr_info("Using the default module debug levels instead\n"); |
| 3587 | } |
| 3588 | |
| 3589 | /* |
| 3590 | * Module ID-Level specified as array during module load |
| 3591 | */ |
| 3592 | for (i = 0; i < qdf_dbg_arr_cnt; i++) { |
| 3593 | process_qdf_dbg_arr_param(cinfo, i); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3594 | } |
| 3595 | qdf_pidx = qdf_print_ctrl_register(cinfo, NULL, NULL, |
| 3596 | "LOG_SHARED_OBJ"); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3597 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3598 | qdf_export_symbol(qdf_shared_print_ctrl_init); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 3599 | #endif |
| 3600 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3601 | QDF_STATUS qdf_print_set_category_verbose(unsigned int idx, |
| 3602 | QDF_MODULE_ID category, |
| 3603 | QDF_TRACE_LEVEL verbose, |
| 3604 | bool is_set) |
| 3605 | { |
| 3606 | /* Check if index passed is valid */ |
| 3607 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
Rajeev Kumar | 1803278 | 2018-10-31 13:14:40 -0700 | [diff] [blame] | 3608 | pr_err("%s: Invalid index - %d\n", __func__, idx); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3609 | return QDF_STATUS_E_FAILURE; |
| 3610 | } |
| 3611 | |
| 3612 | /* Check if print control object is in use */ |
| 3613 | if (!print_ctrl_obj[idx].in_use) { |
Rajeev Kumar | 1803278 | 2018-10-31 13:14:40 -0700 | [diff] [blame] | 3614 | pr_err("%s: Invalid print control object\n", __func__); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3615 | return QDF_STATUS_E_FAILURE; |
| 3616 | } |
| 3617 | |
| 3618 | /* Check if category passed is valid */ |
| 3619 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
Rajeev Kumar | 1803278 | 2018-10-31 13:14:40 -0700 | [diff] [blame] | 3620 | pr_err("%s: Invalid category: %d\n", __func__, category); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3621 | return QDF_STATUS_E_FAILURE; |
| 3622 | } |
| 3623 | |
| 3624 | /* Check if verbose mask is valid */ |
| 3625 | if (verbose < 0 || verbose >= QDF_TRACE_LEVEL_MAX) { |
Rajeev Kumar | 1803278 | 2018-10-31 13:14:40 -0700 | [diff] [blame] | 3626 | pr_err("%s: Invalid verbose level %d\n", __func__, verbose); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3627 | return QDF_STATUS_E_FAILURE; |
| 3628 | } |
| 3629 | |
| 3630 | if (verbose == QDF_TRACE_LEVEL_ALL) { |
| 3631 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask = |
| 3632 | 0xFFFF; |
| 3633 | return QDF_STATUS_SUCCESS; |
| 3634 | } |
| 3635 | |
| 3636 | if (verbose == QDF_TRACE_LEVEL_NONE) { |
| 3637 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask = |
| 3638 | QDF_TRACE_LEVEL_NONE; |
| 3639 | return QDF_STATUS_SUCCESS; |
| 3640 | } |
| 3641 | |
| 3642 | if (!is_set) { |
| 3643 | if (print_ctrl_obj[idx].cat_info[category].category_verbose_mask |
| 3644 | & QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) { |
| 3645 | print_ctrl_obj[idx].cat_info[category] |
| 3646 | .category_verbose_mask &= |
| 3647 | ~QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose); |
| 3648 | } |
| 3649 | } else { |
| 3650 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask |= |
| 3651 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose); |
| 3652 | } |
| 3653 | |
Rajeev Kumar | 1803278 | 2018-10-31 13:14:40 -0700 | [diff] [blame] | 3654 | pr_debug("%s: Print control object %d, Category %d, Verbose level %d\n", |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3655 | __func__, |
| 3656 | idx, |
| 3657 | category, |
| 3658 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask); |
| 3659 | |
| 3660 | return QDF_STATUS_SUCCESS; |
| 3661 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3662 | qdf_export_symbol(qdf_print_set_category_verbose); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3663 | |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3664 | void qdf_log_dump_at_kernel_level(bool enable) |
| 3665 | { |
| 3666 | if (qdf_log_dump_at_kernel_enable == enable) { |
| 3667 | QDF_TRACE_INFO(QDF_MODULE_ID_QDF, |
| 3668 | "qdf_log_dump_at_kernel_enable is already %d\n", |
| 3669 | enable); |
| 3670 | } |
| 3671 | qdf_log_dump_at_kernel_enable = enable; |
| 3672 | } |
| 3673 | |
| 3674 | qdf_export_symbol(qdf_log_dump_at_kernel_level); |
| 3675 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3676 | bool qdf_print_is_category_enabled(unsigned int idx, QDF_MODULE_ID category) |
| 3677 | { |
| 3678 | QDF_TRACE_LEVEL verbose_mask; |
| 3679 | |
| 3680 | /* Check if index passed is valid */ |
| 3681 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3682 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3683 | return false; |
| 3684 | } |
| 3685 | |
| 3686 | /* Check if print control object is in use */ |
| 3687 | if (!print_ctrl_obj[idx].in_use) { |
| 3688 | pr_info("%s: Invalid print control object\n", __func__); |
| 3689 | return false; |
| 3690 | } |
| 3691 | |
| 3692 | /* Check if category passed is valid */ |
| 3693 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 3694 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 3695 | return false; |
| 3696 | } |
| 3697 | |
| 3698 | verbose_mask = |
| 3699 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask; |
| 3700 | |
| 3701 | if (verbose_mask == QDF_TRACE_LEVEL_NONE) |
| 3702 | return false; |
| 3703 | else |
| 3704 | return true; |
| 3705 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3706 | qdf_export_symbol(qdf_print_is_category_enabled); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3707 | |
| 3708 | bool qdf_print_is_verbose_enabled(unsigned int idx, QDF_MODULE_ID category, |
| 3709 | QDF_TRACE_LEVEL verbose) |
| 3710 | { |
| 3711 | bool verbose_enabled = false; |
| 3712 | |
| 3713 | /* Check if index passed is valid */ |
| 3714 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3715 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3716 | return verbose_enabled; |
| 3717 | } |
| 3718 | |
| 3719 | /* Check if print control object is in use */ |
| 3720 | if (!print_ctrl_obj[idx].in_use) { |
| 3721 | pr_info("%s: Invalid print control object\n", __func__); |
| 3722 | return verbose_enabled; |
| 3723 | } |
| 3724 | |
| 3725 | /* Check if category passed is valid */ |
| 3726 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 3727 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 3728 | return verbose_enabled; |
| 3729 | } |
| 3730 | |
| 3731 | if ((verbose == QDF_TRACE_LEVEL_NONE) || |
| 3732 | (verbose >= QDF_TRACE_LEVEL_MAX)) { |
| 3733 | verbose_enabled = false; |
| 3734 | } else if (verbose == QDF_TRACE_LEVEL_ALL) { |
| 3735 | if (print_ctrl_obj[idx].cat_info[category] |
| 3736 | .category_verbose_mask == 0xFFFF) |
| 3737 | verbose_enabled = true; |
| 3738 | } else { |
| 3739 | verbose_enabled = |
| 3740 | (print_ctrl_obj[idx].cat_info[category].category_verbose_mask & |
| 3741 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) ? true : false; |
| 3742 | } |
| 3743 | |
| 3744 | return verbose_enabled; |
| 3745 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3746 | qdf_export_symbol(qdf_print_is_verbose_enabled); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3747 | |
| 3748 | #ifdef DBG_LVL_MAC_FILTERING |
| 3749 | |
| 3750 | QDF_STATUS qdf_print_set_node_flag(unsigned int idx, uint8_t enable) |
| 3751 | { |
| 3752 | /* Check if index passed is valid */ |
| 3753 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3754 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3755 | return QDF_STATUS_E_FAILURE; |
| 3756 | } |
| 3757 | |
| 3758 | /* Check if print control object is in use */ |
| 3759 | if (!print_ctrl_obj[idx].in_use) { |
| 3760 | pr_info("%s: Invalid print control object\n", __func__); |
| 3761 | return QDF_STATUS_E_FAILURE; |
| 3762 | } |
| 3763 | |
| 3764 | if (enable > 1) { |
| 3765 | pr_info("%s: Incorrect input: Use 1 or 0 to enable or disable\n", |
| 3766 | __func__); |
| 3767 | return QDF_STATUS_E_FAILURE; |
| 3768 | } |
| 3769 | |
| 3770 | print_ctrl_obj[idx].dbglvlmac_on = enable; |
| 3771 | pr_info("%s: DbgLVLmac feature %s\n", |
| 3772 | __func__, |
| 3773 | ((enable) ? "enabled" : "disabled")); |
| 3774 | |
| 3775 | return QDF_STATUS_SUCCESS; |
| 3776 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3777 | qdf_export_symbol(qdf_print_set_node_flag); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3778 | |
| 3779 | bool qdf_print_get_node_flag(unsigned int idx) |
| 3780 | { |
| 3781 | bool node_flag = false; |
| 3782 | |
| 3783 | /* Check if index passed is valid */ |
| 3784 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 3785 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 3786 | return node_flag; |
| 3787 | } |
| 3788 | |
| 3789 | /* Check if print control object is in use */ |
| 3790 | if (!print_ctrl_obj[idx].in_use) { |
| 3791 | pr_info("%s: Invalid print control object\n", __func__); |
| 3792 | return node_flag; |
| 3793 | } |
| 3794 | |
| 3795 | if (print_ctrl_obj[idx].dbglvlmac_on) |
| 3796 | node_flag = true; |
| 3797 | |
| 3798 | return node_flag; |
| 3799 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3800 | qdf_export_symbol(qdf_print_get_node_flag); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 3801 | |
| 3802 | void qdf_print_clean_node_flag(unsigned int idx) |
| 3803 | { |
| 3804 | /* Disable dbglvlmac_on during cleanup */ |
| 3805 | print_ctrl_obj[idx].dbglvlmac_on = 0; |
| 3806 | } |
| 3807 | |
| 3808 | #else |
| 3809 | |
| 3810 | void qdf_print_clean_node_flag(unsigned int idx) |
| 3811 | { |
| 3812 | /* No operation in case of no support for DBG_LVL_MAC_FILTERING */ |
| 3813 | return; |
| 3814 | } |
| 3815 | #endif |
| 3816 | |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 3817 | void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module, |
| 3818 | QDF_TRACE_LEVEL level, |
| 3819 | char *str_format, ...) |
| 3820 | { |
| 3821 | va_list args; |
| 3822 | |
| 3823 | /* Generic wrapper API will compile qdf_vprint in order to |
| 3824 | * log the message. Once QDF converged debug framework is in |
| 3825 | * place, this will be changed to adapt to the framework, compiling |
| 3826 | * call to converged tracing API |
| 3827 | */ |
| 3828 | va_start(args, str_format); |
| 3829 | qdf_vprint(str_format, args); |
| 3830 | va_end(args); |
| 3831 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3832 | qdf_export_symbol(QDF_PRINT_INFO); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3833 | |
| 3834 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 3835 | void qdf_logging_init(void) |
| 3836 | { |
| 3837 | wlan_logging_sock_init_svc(); |
Hangtian Zhu | 24dab77 | 2019-09-11 17:53:40 +0800 | [diff] [blame] | 3838 | nl_srv_init(NULL, WLAN_NLINK_PROTO_FAMILY); |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3839 | wlan_logging_set_flush_timer(qdf_log_flush_timer_period); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3840 | } |
| 3841 | |
| 3842 | void qdf_logging_exit(void) |
| 3843 | { |
| 3844 | nl_srv_exit(); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3845 | wlan_logging_sock_deinit_svc(); |
| 3846 | } |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3847 | |
| 3848 | int qdf_logging_set_flush_timer(uint32_t milliseconds) |
| 3849 | { |
| 3850 | if (wlan_logging_set_flush_timer(milliseconds) == 0) |
| 3851 | return QDF_STATUS_SUCCESS; |
| 3852 | else |
| 3853 | return QDF_STATUS_E_FAILURE; |
| 3854 | } |
| 3855 | |
| 3856 | void qdf_logging_flush_logs(void) |
| 3857 | { |
| 3858 | wlan_flush_host_logs_for_fatal(); |
| 3859 | } |
| 3860 | |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3861 | #else |
| 3862 | void qdf_logging_init(void) |
| 3863 | { |
Hangtian Zhu | 24dab77 | 2019-09-11 17:53:40 +0800 | [diff] [blame] | 3864 | nl_srv_init(NULL, WLAN_NLINK_PROTO_FAMILY); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3865 | } |
| 3866 | |
| 3867 | void qdf_logging_exit(void) |
| 3868 | { |
Sathish Kumar | 18617b8 | 2018-06-20 17:57:24 +0530 | [diff] [blame] | 3869 | nl_srv_exit(); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3870 | } |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3871 | |
| 3872 | int qdf_logging_set_flush_timer(uint32_t milliseconds) |
| 3873 | { |
| 3874 | return QDF_STATUS_E_FAILURE; |
| 3875 | } |
| 3876 | |
| 3877 | void qdf_logging_flush_logs(void) |
| 3878 | { |
| 3879 | } |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 3880 | #endif |
| 3881 | |
Adil Saeed Musthafa | 12205b5 | 2018-08-07 09:39:20 -0700 | [diff] [blame] | 3882 | qdf_export_symbol(qdf_logging_set_flush_timer); |
| 3883 | qdf_export_symbol(qdf_logging_flush_logs); |
| 3884 | |
Dustin Brown | e226ceb | 2017-04-21 13:22:14 -0700 | [diff] [blame] | 3885 | #ifdef CONFIG_KALLSYMS |
| 3886 | inline int qdf_sprint_symbol(char *buffer, void *addr) |
| 3887 | { |
| 3888 | return sprint_symbol(buffer, (unsigned long)addr); |
| 3889 | } |
| 3890 | #else |
| 3891 | int qdf_sprint_symbol(char *buffer, void *addr) |
| 3892 | { |
| 3893 | if (!buffer) |
| 3894 | return 0; |
| 3895 | |
| 3896 | buffer[0] = '\0'; |
| 3897 | return 1; |
| 3898 | } |
| 3899 | #endif |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3900 | qdf_export_symbol(qdf_sprint_symbol); |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 3901 | |
| 3902 | void qdf_set_pidx(int pidx) |
| 3903 | { |
| 3904 | qdf_pidx = pidx; |
| 3905 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3906 | qdf_export_symbol(qdf_set_pidx); |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 3907 | |
| 3908 | int qdf_get_pidx(void) |
| 3909 | { |
| 3910 | return qdf_pidx; |
| 3911 | } |
Manikandan Mohan | a18b864 | 2018-03-01 16:17:23 -0800 | [diff] [blame] | 3912 | qdf_export_symbol(qdf_get_pidx); |
Dustin Brown | 1723d45 | 2018-03-07 17:22:34 -0800 | [diff] [blame] | 3913 | |
| 3914 | #ifdef PANIC_ON_BUG |
| 3915 | #ifdef CONFIG_SLUB_DEBUG |
Dustin Brown | ce28cb1 | 2018-06-27 14:27:34 -0700 | [diff] [blame] | 3916 | void __qdf_bug(void) |
Dustin Brown | 1723d45 | 2018-03-07 17:22:34 -0800 | [diff] [blame] | 3917 | { |
| 3918 | BUG(); |
| 3919 | } |
Dustin Brown | ce28cb1 | 2018-06-27 14:27:34 -0700 | [diff] [blame] | 3920 | qdf_export_symbol(__qdf_bug); |
Dustin Brown | 1723d45 | 2018-03-07 17:22:34 -0800 | [diff] [blame] | 3921 | #endif /* CONFIG_SLUB_DEBUG */ |
| 3922 | #endif /* PANIC_ON_BUG */ |
| 3923 | |