Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1 | /* |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 2 | * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: qdf_trace |
| 30 | * QCA driver framework (QDF) trace APIs |
| 31 | * Trace, logging, and debugging definitions and APIs |
| 32 | */ |
| 33 | |
| 34 | /* Include Files */ |
| 35 | #include <qdf_trace.h> |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 36 | #include <linux/export.h> |
| 37 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 38 | /* macro to map qdf trace levels into the bitmask */ |
| 39 | #define QDF_TRACE_LEVEL_TO_MODULE_BITMASK(_level) ((1 << (_level))) |
| 40 | |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 41 | #include <wlan_logging_sock_svc.h> |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 42 | #include <qdf_module.h> |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 43 | static int qdf_pidx = -1; |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 44 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 45 | #include "qdf_time.h" |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 46 | #include "qdf_mc_timer.h" |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 47 | |
| 48 | /* Global qdf print id */ |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 49 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 50 | /* Preprocessor definitions and constants */ |
| 51 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 52 | enum qdf_timestamp_unit qdf_log_timestamp_type = QDF_LOG_TIMESTAMP_UNIT; |
| 53 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 54 | /** |
| 55 | * typedef struct module_trace_info - Trace level for a module, as a bitmask. |
| 56 | * The bits in this mask are ordered by QDF_TRACE_LEVEL. For example, |
| 57 | * each bit represents one of the bits in QDF_TRACE_LEVEL that may be turned |
| 58 | * on to have traces at that level logged, i.e. if QDF_TRACE_LEVEL_ERROR is |
| 59 | * == 2, then if bit 2 (low order) is turned ON, then ERROR traces will be |
| 60 | * printed to the trace log. Note that all bits turned OFF means no traces |
| 61 | * @module_trace_level: trace level |
| 62 | * @module_name_str: 3 character string name for the module |
| 63 | */ |
| 64 | typedef struct { |
| 65 | uint16_t module_trace_level; |
| 66 | unsigned char module_name_str[4]; |
| 67 | } module_trace_info; |
| 68 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 69 | /* Array of static data that contains all of the per module trace |
| 70 | * information. This includes the trace level for the module and |
| 71 | * the 3 character 'name' of the module for marking the trace logs |
| 72 | */ |
| 73 | module_trace_info g_qdf_trace_info[QDF_MODULE_ID_MAX] = { |
| 74 | [QDF_MODULE_ID_TLSHIM] = {QDF_DEFAULT_TRACE_LEVEL, "DP"}, |
| 75 | [QDF_MODULE_ID_WMI] = {QDF_DEFAULT_TRACE_LEVEL, "WMI"}, |
| 76 | [QDF_MODULE_ID_HDD] = {QDF_DEFAULT_TRACE_LEVEL, "HDD"}, |
| 77 | [QDF_MODULE_ID_SME] = {QDF_DEFAULT_TRACE_LEVEL, "SME"}, |
| 78 | [QDF_MODULE_ID_PE] = {QDF_DEFAULT_TRACE_LEVEL, "PE "}, |
| 79 | [QDF_MODULE_ID_WMA] = {QDF_DEFAULT_TRACE_LEVEL, "WMA"}, |
| 80 | [QDF_MODULE_ID_SYS] = {QDF_DEFAULT_TRACE_LEVEL, "SYS"}, |
| 81 | [QDF_MODULE_ID_QDF] = {QDF_DEFAULT_TRACE_LEVEL, "QDF"}, |
| 82 | [QDF_MODULE_ID_SAP] = {QDF_DEFAULT_TRACE_LEVEL, "SAP"}, |
| 83 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_DEFAULT_TRACE_LEVEL, "HSP"}, |
| 84 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DEFAULT_TRACE_LEVEL, "HDP"}, |
| 85 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DEFAULT_TRACE_LEVEL, "SDP"}, |
| 86 | [QDF_MODULE_ID_BMI] = {QDF_DEFAULT_TRACE_LEVEL, "BMI"}, |
| 87 | [QDF_MODULE_ID_HIF] = {QDF_DEFAULT_TRACE_LEVEL, "HIF"}, |
| 88 | [QDF_MODULE_ID_TXRX] = {QDF_DEFAULT_TRACE_LEVEL, "TRX"}, |
| 89 | [QDF_MODULE_ID_HTT] = {QDF_DEFAULT_TRACE_LEVEL, "HTT"}, |
Krunal Soni | c4e3592 | 2017-02-01 14:59:01 -0800 | [diff] [blame] | 90 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_DEFAULT_TRACE_LEVEL, "SER"}, |
Kiran Kumar Lokere | 43568a9 | 2017-03-31 15:50:26 -0700 | [diff] [blame] | 91 | [QDF_MODULE_ID_REGULATORY] = {QDF_DEFAULT_TRACE_LEVEL, "REG"}, |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | /* Static and Global variables */ |
| 95 | static spinlock_t ltrace_lock; |
| 96 | |
| 97 | static qdf_trace_record_t g_qdf_trace_tbl[MAX_QDF_TRACE_RECORDS]; |
| 98 | /* global qdf trace data */ |
| 99 | static t_qdf_trace_data g_qdf_trace_data; |
| 100 | /* |
| 101 | * all the call back functions for dumping MTRACE messages from ring buffer |
| 102 | * are stored in qdf_trace_cb_table,these callbacks are initialized during init |
| 103 | * only so, we will make a copy of these call back functions and maintain in to |
| 104 | * qdf_trace_restore_cb_table. Incase if we make modifications to |
| 105 | * qdf_trace_cb_table, we can certainly retrieve all the call back functions |
| 106 | * back from Restore Table |
| 107 | */ |
| 108 | static tp_qdf_trace_cb qdf_trace_cb_table[QDF_MODULE_ID_MAX]; |
| 109 | static tp_qdf_trace_cb qdf_trace_restore_cb_table[QDF_MODULE_ID_MAX]; |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 110 | static tp_qdf_state_info_cb qdf_state_info_table[QDF_MODULE_ID_MAX]; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 111 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 112 | #ifdef CONFIG_DP_TRACE |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 113 | /* Static and Global variables */ |
| 114 | static spinlock_t l_dp_trace_lock; |
| 115 | |
| 116 | static struct qdf_dp_trace_record_s |
| 117 | g_qdf_dp_trace_tbl[MAX_QDF_DP_TRACE_RECORDS]; |
| 118 | |
| 119 | /* |
| 120 | * all the options to configure/control DP trace are |
| 121 | * defined in this structure |
| 122 | */ |
| 123 | static struct s_qdf_dp_trace_data g_qdf_dp_trace_data; |
| 124 | /* |
| 125 | * all the call back functions for dumping DPTRACE messages from ring buffer |
| 126 | * are stored in qdf_dp_trace_cb_table, callbacks are initialized during init |
| 127 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 128 | 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] | 129 | #endif |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 130 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 131 | /** |
| 132 | * qdf_trace_set_level() - Set the trace level for a particular module |
| 133 | * @module: Module id |
| 134 | * @level : trace level |
| 135 | * |
| 136 | * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating |
| 137 | * the severity of the condition causing the trace message to be issued. |
| 138 | * More severe conditions are more likely to be logged. |
| 139 | * |
| 140 | * This is an external API that allows trace levels to be set for each module. |
| 141 | * |
| 142 | * Return: None |
| 143 | */ |
| 144 | void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level) |
| 145 | { |
| 146 | /* make sure the caller is passing in a valid LEVEL */ |
| 147 | if (level >= QDF_TRACE_LEVEL_MAX) { |
| 148 | pr_err("%s: Invalid trace level %d passed in!\n", __func__, |
| 149 | level); |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | /* Treat 'none' differently. NONE means we have to run off all |
| 154 | * the bits in the bit mask so none of the traces appear. Anything |
| 155 | * other than 'none' means we need to turn ON a bit in the bitmask |
| 156 | */ |
| 157 | if (QDF_TRACE_LEVEL_NONE == level) |
| 158 | g_qdf_trace_info[module].module_trace_level = |
| 159 | QDF_TRACE_LEVEL_NONE; |
| 160 | else |
| 161 | /* set the desired bit in the bit mask for the module trace |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 162 | * level |
| 163 | */ |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 164 | g_qdf_trace_info[module].module_trace_level |= |
| 165 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(level); |
| 166 | } |
| 167 | EXPORT_SYMBOL(qdf_trace_set_level); |
| 168 | |
| 169 | /** |
| 170 | * qdf_trace_set_module_trace_level() - Set module trace level |
| 171 | * @module: Module id |
| 172 | * @level: Trace level for a module, as a bitmask as per 'module_trace_info' |
| 173 | * |
| 174 | * Sets the module trace level where the trace level is given as a bit mask |
| 175 | * |
| 176 | * Return: None |
| 177 | */ |
| 178 | void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level) |
| 179 | { |
| 180 | if (module < 0 || module >= QDF_MODULE_ID_MAX) { |
| 181 | pr_err("%s: Invalid module id %d passed\n", __func__, module); |
| 182 | return; |
| 183 | } |
| 184 | g_qdf_trace_info[module].module_trace_level = level; |
| 185 | } |
| 186 | EXPORT_SYMBOL(qdf_trace_set_module_trace_level); |
| 187 | |
| 188 | /** |
| 189 | * qdf_trace_set_value() - Set module trace value |
| 190 | * @module: Module id |
| 191 | * @level: Trace level for a module, as a bitmask as per 'module_trace_info' |
| 192 | * @on: set/clear the desired bit in the bit mask |
| 193 | * |
| 194 | * Return: None |
| 195 | */ |
| 196 | void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 197 | uint8_t on) |
| 198 | { |
| 199 | /* make sure the caller is passing in a valid LEVEL */ |
| 200 | if (level < 0 || level >= QDF_TRACE_LEVEL_MAX) { |
| 201 | pr_err("%s: Invalid trace level %d passed in!\n", __func__, |
| 202 | level); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | /* make sure the caller is passing in a valid module */ |
| 207 | if (module < 0 || module >= QDF_MODULE_ID_MAX) { |
| 208 | pr_err("%s: Invalid module id %d passed in!\n", __func__, |
| 209 | module); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | /* Treat 'none' differently. NONE means we have to turn off all |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 214 | * the bits in the bit mask so none of the traces appear |
| 215 | */ |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 216 | if (QDF_TRACE_LEVEL_NONE == level) { |
| 217 | g_qdf_trace_info[module].module_trace_level = |
| 218 | QDF_TRACE_LEVEL_NONE; |
| 219 | } |
| 220 | /* Treat 'All' differently. All means we have to turn on all |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 221 | * the bits in the bit mask so all of the traces appear |
| 222 | */ |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 223 | else if (QDF_TRACE_LEVEL_ALL == level) { |
| 224 | g_qdf_trace_info[module].module_trace_level = 0xFFFF; |
| 225 | } else { |
| 226 | if (on) |
| 227 | /* set the desired bit in the bit mask for the module |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 228 | * trace level |
| 229 | */ |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 230 | g_qdf_trace_info[module].module_trace_level |= |
| 231 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(level); |
| 232 | else |
| 233 | /* clear the desired bit in the bit mask for the module |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 234 | * trace level |
| 235 | */ |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 236 | g_qdf_trace_info[module].module_trace_level &= |
| 237 | ~(QDF_TRACE_LEVEL_TO_MODULE_BITMASK(level)); |
| 238 | } |
| 239 | } |
| 240 | EXPORT_SYMBOL(qdf_trace_set_value); |
| 241 | |
| 242 | /** |
| 243 | * qdf_trace_get_level() - get the trace level |
| 244 | * @module: module Id |
| 245 | * @level: trace level |
| 246 | * |
| 247 | * This is an external API that returns a bool value to signify if a |
| 248 | * particular trace level is set for the specified module. |
| 249 | * A member of the QDF_TRACE_LEVEL enumeration indicating the severity |
| 250 | * of the condition causing the trace message to be issued. |
| 251 | * |
| 252 | * Note that individual trace levels are the only valid values |
| 253 | * for this API. QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL |
| 254 | * are not valid input and will return false |
| 255 | * |
| 256 | * Return: |
| 257 | * false - the specified trace level for the specified module is OFF |
| 258 | * true - the specified trace level for the specified module is ON |
| 259 | */ |
| 260 | bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level) |
| 261 | { |
| 262 | bool trace_on = false; |
| 263 | |
| 264 | if ((QDF_TRACE_LEVEL_NONE == level) || |
| 265 | (QDF_TRACE_LEVEL_ALL == level) || (level >= QDF_TRACE_LEVEL_MAX)) { |
| 266 | trace_on = false; |
| 267 | } else { |
| 268 | trace_on = (level & g_qdf_trace_info[module].module_trace_level) |
| 269 | ? true : false; |
| 270 | } |
| 271 | |
| 272 | return trace_on; |
| 273 | } |
| 274 | EXPORT_SYMBOL(qdf_trace_get_level); |
| 275 | |
| 276 | /** |
| 277 | * qdf_snprintf() - wrapper function to snprintf |
| 278 | * @str_buffer: string Buffer |
| 279 | * @size: defines the size of the data record |
| 280 | * @str_format: Format string in which the message to be logged. This format |
| 281 | * string contains printf-like replacement parameters, which follow |
| 282 | * this parameter in the variable argument list. |
| 283 | * |
| 284 | * Return: None |
| 285 | */ |
| 286 | void qdf_snprintf(char *str_buffer, unsigned int size, char *str_format, ...) |
| 287 | { |
| 288 | va_list val; |
| 289 | |
| 290 | va_start(val, str_format); |
| 291 | snprintf(str_buffer, size, str_format, val); |
| 292 | va_end(val); |
| 293 | } |
| 294 | EXPORT_SYMBOL(qdf_snprintf); |
| 295 | |
| 296 | #ifdef QDF_ENABLE_TRACING |
| 297 | |
| 298 | /** |
| 299 | * qdf_trace_msg() - externally called trace function |
| 300 | * @module: Module identifier a member of the QDF_MODULE_ID |
| 301 | * enumeration that identifies the module issuing the trace message. |
| 302 | * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration |
| 303 | * indicating the severity of the condition causing the trace message |
| 304 | * to be issued. More severe conditions are more likely to be logged. |
| 305 | * @str_format: Format string in which the message to be logged. This format |
| 306 | * string contains printf-like replacement parameters, which follow |
| 307 | * this parameter in the variable argument list. |
| 308 | * |
| 309 | * Checks the level of severity and accordingly prints the trace messages |
| 310 | * |
| 311 | * Return: None |
| 312 | */ |
| 313 | void qdf_trace_msg(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 314 | char *str_format, ...) |
| 315 | { |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 316 | va_list val; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 317 | |
Sathish Kumar | febd4b7 | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 318 | va_start(val, str_format); |
| 319 | qdf_trace_msg_cmn(qdf_pidx, module, level, str_format, val); |
| 320 | va_end(val); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 321 | } |
| 322 | EXPORT_SYMBOL(qdf_trace_msg); |
| 323 | |
Dustin Brown | 013400c | 2017-11-16 13:29:24 -0800 | [diff] [blame] | 324 | void qdf_vtrace_msg(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 325 | char *str_format, va_list val) |
| 326 | { |
| 327 | qdf_trace_msg_cmn(qdf_pidx, module, level, str_format, val); |
| 328 | } |
| 329 | EXPORT_SYMBOL(qdf_vtrace_msg); |
| 330 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 331 | #define ROW_SIZE 16 |
| 332 | /* Buffer size = data bytes(2 hex chars plus space) + NULL */ |
| 333 | #define BUFFER_SIZE ((ROW_SIZE * 3) + 1) |
| 334 | |
| 335 | /** |
| 336 | * qdf_trace_hex_dump() - externally called hex dump function |
| 337 | * @module: Module identifier a member of the QDF_MODULE_ID enumeration that |
| 338 | * identifies the module issuing the trace message. |
| 339 | * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating |
| 340 | * the severity of the condition causing the trace message to be |
| 341 | * issued. More severe conditions are more likely to be logged. |
| 342 | * @data: The base address of the buffer to be logged. |
| 343 | * @buf_len: The size of the buffer to be logged. |
| 344 | * |
| 345 | * Checks the level of severity and accordingly prints the trace messages |
| 346 | * |
| 347 | * Return: None |
| 348 | */ |
| 349 | void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, |
| 350 | void *data, int buf_len) |
| 351 | { |
| 352 | const u8 *ptr = data; |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 353 | int i = 0; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 354 | |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 355 | if (!qdf_print_is_verbose_enabled(qdf_pidx, module, level)) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 356 | return; |
| 357 | |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 358 | while (buf_len > 0) { |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 359 | unsigned char linebuf[BUFFER_SIZE]; |
| 360 | int linelen = min(buf_len, ROW_SIZE); |
| 361 | |
| 362 | buf_len -= ROW_SIZE; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 363 | |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 364 | hex_dump_to_buffer(ptr, linelen, ROW_SIZE, 1, |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 365 | linebuf, sizeof(linebuf), false); |
| 366 | |
| 367 | qdf_trace_msg(module, level, "%.8x: %s", i, linebuf); |
Adil Saeed Musthafa | fe36663 | 2017-08-14 13:09:20 -0700 | [diff] [blame] | 368 | ptr += ROW_SIZE; |
| 369 | i += ROW_SIZE; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 370 | } |
| 371 | } |
Nandha Kishore Easwaran | 7249f0d | 2017-06-08 15:11:45 +0530 | [diff] [blame] | 372 | EXPORT_SYMBOL(qdf_trace_hex_dump); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 373 | |
| 374 | #endif |
| 375 | |
| 376 | /** |
| 377 | * qdf_trace_enable() - Enable MTRACE for specific modules |
| 378 | * @bitmask_of_module_id: Bitmask according to enum of the modules. |
| 379 | * 32[dec] = 0010 0000 [bin] <enum of HDD is 5> |
| 380 | * 64[dec] = 0100 0000 [bin] <enum of SME is 6> |
| 381 | * 128[dec] = 1000 0000 [bin] <enum of PE is 7> |
| 382 | * @enable: can be true or false true implies enabling MTRACE false implies |
| 383 | * disabling MTRACE. |
| 384 | * |
| 385 | * Enable MTRACE for specific modules whose bits are set in bitmask and enable |
| 386 | * is true. if enable is false it disables MTRACE for that module. set the |
| 387 | * bitmask according to enum value of the modules. |
| 388 | * This functions will be called when you issue ioctl as mentioned following |
| 389 | * [iwpriv wlan0 setdumplog <value> <enable>]. |
| 390 | * <value> - Decimal number, i.e. 64 decimal value shows only SME module, |
| 391 | * 128 decimal value shows only PE module, 192 decimal value shows PE and SME. |
| 392 | * |
| 393 | * Return: None |
| 394 | */ |
| 395 | void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable) |
| 396 | { |
| 397 | int i; |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 398 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 399 | if (bitmask_of_module_id) { |
| 400 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 401 | if (((bitmask_of_module_id >> i) & 1)) { |
| 402 | if (enable) { |
| 403 | if (NULL != |
| 404 | qdf_trace_restore_cb_table[i]) { |
| 405 | qdf_trace_cb_table[i] = |
| 406 | qdf_trace_restore_cb_table[i]; |
| 407 | } |
| 408 | } else { |
| 409 | qdf_trace_restore_cb_table[i] = |
| 410 | qdf_trace_cb_table[i]; |
| 411 | qdf_trace_cb_table[i] = NULL; |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | } else { |
| 416 | if (enable) { |
| 417 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 418 | if (NULL != qdf_trace_restore_cb_table[i]) { |
| 419 | qdf_trace_cb_table[i] = |
| 420 | qdf_trace_restore_cb_table[i]; |
| 421 | } |
| 422 | } |
| 423 | } else { |
| 424 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 425 | qdf_trace_restore_cb_table[i] = |
| 426 | qdf_trace_cb_table[i]; |
| 427 | qdf_trace_cb_table[i] = NULL; |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | EXPORT_SYMBOL(qdf_trace_enable); |
| 433 | |
| 434 | /** |
| 435 | * qdf_trace_init() - initializes qdf trace structures and variables |
| 436 | * |
| 437 | * Called immediately after cds_preopen, so that we can start recording HDD |
| 438 | * events ASAP. |
| 439 | * |
| 440 | * Return: None |
| 441 | */ |
| 442 | void qdf_trace_init(void) |
| 443 | { |
| 444 | uint8_t i; |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 445 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 446 | g_qdf_trace_data.head = INVALID_QDF_TRACE_ADDR; |
| 447 | g_qdf_trace_data.tail = INVALID_QDF_TRACE_ADDR; |
| 448 | g_qdf_trace_data.num = 0; |
| 449 | g_qdf_trace_data.enable = true; |
| 450 | g_qdf_trace_data.dump_count = DEFAULT_QDF_TRACE_DUMP_COUNT; |
| 451 | g_qdf_trace_data.num_since_last_dump = 0; |
| 452 | |
| 453 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) { |
| 454 | qdf_trace_cb_table[i] = NULL; |
| 455 | qdf_trace_restore_cb_table[i] = NULL; |
| 456 | } |
| 457 | } |
| 458 | EXPORT_SYMBOL(qdf_trace_init); |
| 459 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 460 | #ifdef CONFIG_MCL |
| 461 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 462 | /** |
| 463 | * qdf_trace() - puts the messages in to ring-buffer |
| 464 | * @module: Enum of module, basically module id. |
| 465 | * @param: Code to be recorded |
| 466 | * @session: Session ID of the log |
| 467 | * @data: Actual message contents |
| 468 | * |
| 469 | * This function will be called from each module who wants record the messages |
| 470 | * in circular queue. Before calling this functions make sure you have |
| 471 | * registered your module with qdf through qdf_trace_register function. |
| 472 | * |
| 473 | * Return: None |
| 474 | */ |
| 475 | void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data) |
| 476 | { |
| 477 | tp_qdf_trace_record rec = NULL; |
| 478 | unsigned long flags; |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 479 | char time[18]; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 480 | |
| 481 | if (!g_qdf_trace_data.enable) |
| 482 | return; |
| 483 | |
| 484 | /* if module is not registered, don't record for that module */ |
| 485 | if (NULL == qdf_trace_cb_table[module]) |
| 486 | return; |
| 487 | |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 488 | 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] | 489 | /* Aquire the lock so that only one thread at a time can fill the ring |
| 490 | * buffer |
| 491 | */ |
| 492 | spin_lock_irqsave(<race_lock, flags); |
| 493 | |
| 494 | g_qdf_trace_data.num++; |
| 495 | |
| 496 | if (g_qdf_trace_data.num > MAX_QDF_TRACE_RECORDS) |
| 497 | g_qdf_trace_data.num = MAX_QDF_TRACE_RECORDS; |
| 498 | |
| 499 | if (INVALID_QDF_TRACE_ADDR == g_qdf_trace_data.head) { |
| 500 | /* first record */ |
| 501 | g_qdf_trace_data.head = 0; |
| 502 | g_qdf_trace_data.tail = 0; |
| 503 | } else { |
| 504 | /* queue is not empty */ |
| 505 | uint32_t tail = g_qdf_trace_data.tail + 1; |
| 506 | |
| 507 | if (MAX_QDF_TRACE_RECORDS == tail) |
| 508 | tail = 0; |
| 509 | |
| 510 | if (g_qdf_trace_data.head == tail) { |
| 511 | /* full */ |
| 512 | if (MAX_QDF_TRACE_RECORDS == ++g_qdf_trace_data.head) |
| 513 | g_qdf_trace_data.head = 0; |
| 514 | } |
| 515 | g_qdf_trace_data.tail = tail; |
| 516 | } |
| 517 | |
| 518 | rec = &g_qdf_trace_tbl[g_qdf_trace_data.tail]; |
| 519 | rec->code = code; |
| 520 | rec->session = session; |
| 521 | rec->data = data; |
Sreelakshmi Konamki | e2e3135 | 2016-10-27 15:00:57 +0530 | [diff] [blame] | 522 | rec->qtime = qdf_get_log_timestamp(); |
| 523 | scnprintf(rec->time, sizeof(rec->time), "%s", time); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 524 | rec->module = module; |
| 525 | rec->pid = (in_interrupt() ? 0 : current->pid); |
| 526 | g_qdf_trace_data.num_since_last_dump++; |
| 527 | spin_unlock_irqrestore(<race_lock, flags); |
| 528 | } |
| 529 | EXPORT_SYMBOL(qdf_trace); |
| 530 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 531 | #endif |
| 532 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 533 | /** |
| 534 | * qdf_trace_spin_lock_init() - initializes the lock variable before use |
| 535 | * |
| 536 | * This function will be called from cds_alloc_global_context, we will have lock |
| 537 | * available to use ASAP |
| 538 | * |
| 539 | * Return: None |
| 540 | */ |
| 541 | QDF_STATUS qdf_trace_spin_lock_init(void) |
| 542 | { |
| 543 | spin_lock_init(<race_lock); |
| 544 | |
| 545 | return QDF_STATUS_SUCCESS; |
| 546 | } |
| 547 | EXPORT_SYMBOL(qdf_trace_spin_lock_init); |
| 548 | |
| 549 | /** |
| 550 | * qdf_trace_register() - registers the call back functions |
| 551 | * @module_iD: enum value of module |
| 552 | * @qdf_trace_callback: call back functions to display the messages in |
| 553 | * particular format. |
| 554 | * |
| 555 | * Registers the call back functions to display the messages in particular |
| 556 | * format mentioned in these call back functions. This functions should be |
| 557 | * called by interested module in their init part as we will be ready to |
| 558 | * register as soon as modules are up. |
| 559 | * |
| 560 | * Return: None |
| 561 | */ |
| 562 | void qdf_trace_register(QDF_MODULE_ID module_iD, |
| 563 | tp_qdf_trace_cb qdf_trace_callback) |
| 564 | { |
| 565 | qdf_trace_cb_table[module_iD] = qdf_trace_callback; |
| 566 | } |
| 567 | EXPORT_SYMBOL(qdf_trace_register); |
| 568 | |
| 569 | /** |
| 570 | * qdf_trace_dump_all() - Dump data from ring buffer via call back functions |
| 571 | * registered with QDF |
| 572 | * @p_mac: Context of particular module |
| 573 | * @code: Reason code |
| 574 | * @session: Session id of log |
| 575 | * @count: Number of lines to dump starting from tail to head |
| 576 | * |
| 577 | * This function will be called up on issueing ioctl call as mentioned following |
| 578 | * [iwpriv wlan0 dumplog 0 0 <n> <bitmask_of_module>] |
| 579 | * |
| 580 | * <n> - number lines to dump starting from tail to head. |
| 581 | * |
| 582 | * <bitmask_of_module> - if anybody wants to know how many messages were |
| 583 | * recorded for particular module/s mentioned by setbit in bitmask from last |
| 584 | * <n> messages. It is optional, if you don't provide then it will dump |
| 585 | * everything from buffer. |
| 586 | * |
| 587 | * Return: None |
| 588 | */ |
| 589 | 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] | 590 | uint32_t count, uint32_t bitmask_of_module) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 591 | { |
| 592 | qdf_trace_record_t p_record; |
| 593 | int32_t i, tail; |
| 594 | |
| 595 | if (!g_qdf_trace_data.enable) { |
| 596 | QDF_TRACE(QDF_MODULE_ID_SYS, |
| 597 | QDF_TRACE_LEVEL_ERROR, "Tracing Disabled"); |
| 598 | return; |
| 599 | } |
| 600 | |
| 601 | QDF_TRACE(QDF_MODULE_ID_SYS, QDF_TRACE_LEVEL_INFO, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 602 | "DPT: Total Records: %d, Head: %d, Tail: %d", |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 603 | g_qdf_trace_data.num, g_qdf_trace_data.head, |
| 604 | g_qdf_trace_data.tail); |
| 605 | |
| 606 | /* aquire the lock so that only one thread at a time can read |
| 607 | * the ring buffer |
| 608 | */ |
| 609 | spin_lock(<race_lock); |
| 610 | |
| 611 | if (g_qdf_trace_data.head != INVALID_QDF_TRACE_ADDR) { |
| 612 | i = g_qdf_trace_data.head; |
| 613 | tail = g_qdf_trace_data.tail; |
| 614 | |
| 615 | if (count) { |
| 616 | if (count > g_qdf_trace_data.num) |
| 617 | count = g_qdf_trace_data.num; |
| 618 | if (tail >= (count - 1)) |
| 619 | i = tail - count + 1; |
| 620 | else if (count != MAX_QDF_TRACE_RECORDS) |
| 621 | i = MAX_QDF_TRACE_RECORDS - ((count - 1) - |
| 622 | tail); |
| 623 | } |
| 624 | |
| 625 | p_record = g_qdf_trace_tbl[i]; |
| 626 | /* right now we are not using num_since_last_dump member but |
| 627 | * in future we might re-visit and use this member to track |
| 628 | * how many latest messages got added while we were dumping |
| 629 | * from ring buffer |
| 630 | */ |
| 631 | g_qdf_trace_data.num_since_last_dump = 0; |
| 632 | spin_unlock(<race_lock); |
| 633 | for (;; ) { |
| 634 | if ((code == 0 || (code == p_record.code)) && |
| 635 | (qdf_trace_cb_table[p_record.module] != NULL)) { |
| 636 | if (0 == bitmask_of_module) { |
| 637 | qdf_trace_cb_table[p_record. |
| 638 | module] (p_mac, |
| 639 | &p_record, |
| 640 | (uint16_t) |
| 641 | i); |
| 642 | } else { |
| 643 | if (bitmask_of_module & |
| 644 | (1 << p_record.module)) { |
| 645 | qdf_trace_cb_table[p_record. |
| 646 | module] |
| 647 | (p_mac, &p_record, |
| 648 | (uint16_t) i); |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | if (i == tail) |
| 654 | break; |
| 655 | i += 1; |
| 656 | |
| 657 | spin_lock(<race_lock); |
| 658 | if (MAX_QDF_TRACE_RECORDS == i) { |
| 659 | i = 0; |
| 660 | p_record = g_qdf_trace_tbl[0]; |
| 661 | } else { |
| 662 | p_record = g_qdf_trace_tbl[i]; |
| 663 | } |
| 664 | spin_unlock(<race_lock); |
| 665 | } |
| 666 | } else { |
| 667 | spin_unlock(<race_lock); |
| 668 | } |
| 669 | } |
| 670 | EXPORT_SYMBOL(qdf_trace_dump_all); |
| 671 | |
Padma, Santhosh Kumar | 75394d6 | 2016-08-11 16:33:03 +0530 | [diff] [blame] | 672 | /** |
| 673 | * qdf_register_debugcb_init() - initializes debug callbacks |
| 674 | * to NULL |
| 675 | * |
| 676 | * Return: None |
| 677 | */ |
| 678 | void qdf_register_debugcb_init(void) |
| 679 | { |
| 680 | uint8_t i; |
| 681 | |
| 682 | for (i = 0; i < QDF_MODULE_ID_MAX; i++) |
| 683 | qdf_state_info_table[i] = NULL; |
| 684 | } |
| 685 | EXPORT_SYMBOL(qdf_register_debugcb_init); |
| 686 | |
| 687 | /** |
| 688 | * qdf_register_debug_callback() - stores callback handlers to print |
| 689 | * state information |
| 690 | * @module_id: module id of layer |
| 691 | * @qdf_state_infocb: callback to be registered |
| 692 | * |
| 693 | * This function is used to store callback handlers to print |
| 694 | * state information |
| 695 | * |
| 696 | * Return: None |
| 697 | */ |
| 698 | void qdf_register_debug_callback(QDF_MODULE_ID module_id, |
| 699 | tp_qdf_state_info_cb qdf_state_infocb) |
| 700 | { |
| 701 | qdf_state_info_table[module_id] = qdf_state_infocb; |
| 702 | } |
| 703 | EXPORT_SYMBOL(qdf_register_debug_callback); |
| 704 | |
| 705 | /** |
| 706 | * qdf_state_info_dump_all() - it invokes callback of layer which registered |
| 707 | * its callback to print its state information. |
| 708 | * @buf: buffer pointer to be passed |
| 709 | * @size: size of buffer to be filled |
| 710 | * @driver_dump_size: actual size of buffer used |
| 711 | * |
| 712 | * Return: QDF_STATUS_SUCCESS on success |
| 713 | */ |
| 714 | QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size, |
| 715 | uint16_t *driver_dump_size) |
| 716 | { |
| 717 | uint8_t module, ret = QDF_STATUS_SUCCESS; |
| 718 | uint16_t buf_len = size; |
| 719 | char *buf_ptr = buf; |
| 720 | |
| 721 | for (module = 0; module < QDF_MODULE_ID_MAX; module++) { |
| 722 | if (NULL != qdf_state_info_table[module]) { |
| 723 | qdf_state_info_table[module](&buf_ptr, &buf_len); |
| 724 | if (!buf_len) { |
| 725 | ret = QDF_STATUS_E_NOMEM; |
| 726 | break; |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | *driver_dump_size = size - buf_len; |
| 732 | return ret; |
| 733 | } |
| 734 | EXPORT_SYMBOL(qdf_state_info_dump_all); |
| 735 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 736 | #ifdef CONFIG_DP_TRACE |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 737 | static void qdf_dp_unused(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 738 | uint16_t index, uint8_t pdev_id, bool live) |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 739 | { |
| 740 | qdf_print("%s: QDF_DP_TRACE_MAX event should not be generated", |
| 741 | __func__); |
| 742 | } |
| 743 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 744 | /** |
| 745 | * qdf_dp_trace_init() - enables the DP trace |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 746 | * @live_mode_config: live mode configuration |
| 747 | * @thresh: high throughput threshold for disabling live mode |
| 748 | * @thresh_time_limit: max time to wait before deciding if thresh is crossed |
| 749 | * @verbosity: dptrace verbosity level |
| 750 | * @proto_bitmap: bitmap to enable/disable specific protocols |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 751 | * |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 752 | * Called during driver load to init dptrace |
| 753 | * |
| 754 | * A brief note on the 'thresh' param - |
| 755 | * Total # of packets received in a bandwidth timer interval beyond which |
| 756 | * DP Trace logging for data packets (including ICMP) will be disabled. |
| 757 | * In memory logging will still continue for these packets. Other packets for |
| 758 | * which proto.bitmap is set will continue to be recorded in logs and in memory. |
| 759 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 760 | * Return: None |
| 761 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 762 | void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, |
| 763 | uint16_t time_limit, uint8_t verbosity, |
| 764 | uint8_t proto_bitmap) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 765 | { |
| 766 | uint8_t i; |
| 767 | |
| 768 | qdf_dp_trace_spin_lock_init(); |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 769 | qdf_dp_trace_clear_buffer(); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 770 | g_qdf_dp_trace_data.enable = true; |
| 771 | g_qdf_dp_trace_data.no_of_record = 1; |
| 772 | |
| 773 | g_qdf_dp_trace_data.live_mode_config = live_mode_config; |
| 774 | g_qdf_dp_trace_data.live_mode = live_mode_config; |
| 775 | g_qdf_dp_trace_data.high_tput_thresh = thresh; |
| 776 | g_qdf_dp_trace_data.thresh_time_limit = time_limit; |
| 777 | g_qdf_dp_trace_data.proto_bitmap = proto_bitmap; |
| 778 | g_qdf_dp_trace_data.verbosity = verbosity; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 779 | |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 780 | for (i = 0; i < ARRAY_SIZE(qdf_dp_trace_cb_table); i++) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 781 | qdf_dp_trace_cb_table[i] = qdf_dp_display_record; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 782 | |
| 783 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD] = |
| 784 | qdf_dp_trace_cb_table[QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD] = |
| 785 | qdf_dp_trace_cb_table[QDF_DP_TRACE_FREE_PACKET_PTR_RECORD] = |
| 786 | qdf_dp_display_ptr_record; |
| 787 | qdf_dp_trace_cb_table[QDF_DP_TRACE_EAPOL_PACKET_RECORD] = |
| 788 | qdf_dp_trace_cb_table[QDF_DP_TRACE_DHCP_PACKET_RECORD] = |
| 789 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ARP_PACKET_RECORD] = |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 790 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ICMP_PACKET_RECORD] = |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 791 | qdf_dp_trace_cb_table[QDF_DP_TRACE_ICMPv6_PACKET_RECORD] = |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 792 | qdf_dp_display_proto_pkt; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 793 | qdf_dp_trace_cb_table[QDF_DP_TRACE_MGMT_PACKET_RECORD] = |
| 794 | qdf_dp_display_mgmt_pkt; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 795 | qdf_dp_trace_cb_table[QDF_DP_TRACE_EVENT_RECORD] = |
| 796 | qdf_dp_display_event_record; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 797 | |
Houston Hoffman | 125423f | 2016-09-27 23:39:17 -0700 | [diff] [blame] | 798 | qdf_dp_trace_cb_table[QDF_DP_TRACE_MAX] = qdf_dp_unused; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 799 | } |
| 800 | EXPORT_SYMBOL(qdf_dp_trace_init); |
| 801 | |
| 802 | /** |
| 803 | * qdf_dp_trace_set_value() - Configure the value to control DP trace |
| 804 | * @proto_bitmap: defines the protocol to be tracked |
| 805 | * @no_of_records: defines the nth packet which is traced |
| 806 | * @verbosity: defines the verbosity level |
| 807 | * |
| 808 | * Return: None |
| 809 | */ |
| 810 | void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_record, |
| 811 | uint8_t verbosity) |
| 812 | { |
| 813 | g_qdf_dp_trace_data.proto_bitmap = proto_bitmap; |
| 814 | g_qdf_dp_trace_data.no_of_record = no_of_record; |
| 815 | g_qdf_dp_trace_data.verbosity = verbosity; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 816 | } |
| 817 | EXPORT_SYMBOL(qdf_dp_trace_set_value); |
| 818 | |
| 819 | /** |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 820 | * qdf_dp_trace_set_verbosity() - set verbosity value |
| 821 | * |
| 822 | * @val: Value to set |
| 823 | * |
| 824 | * Return: Null |
| 825 | */ |
| 826 | void qdf_dp_trace_set_verbosity(uint32_t val) |
| 827 | { |
| 828 | g_qdf_dp_trace_data.verbosity = val; |
| 829 | } |
| 830 | EXPORT_SYMBOL(qdf_dp_trace_set_verbosity); |
| 831 | |
| 832 | /** |
| 833 | * qdf_dp_get_verbosity) - get verbosity value |
| 834 | * |
| 835 | * Return: int |
| 836 | */ |
| 837 | uint8_t qdf_dp_get_verbosity(void) |
| 838 | { |
| 839 | return g_qdf_dp_trace_data.verbosity; |
| 840 | } |
| 841 | EXPORT_SYMBOL(qdf_dp_get_verbosity); |
| 842 | |
| 843 | /** |
| 844 | * qdf_dp_set_proto_bitmap() - set dp trace proto bitmap |
| 845 | * |
| 846 | * @val : unsigned bitmap to set |
| 847 | * |
| 848 | * Return: proto bitmap |
| 849 | */ |
| 850 | void qdf_dp_set_proto_bitmap(uint32_t val) |
| 851 | { |
| 852 | g_qdf_dp_trace_data.proto_bitmap = val; |
| 853 | } |
| 854 | EXPORT_SYMBOL(qdf_dp_set_proto_bitmap); |
| 855 | |
| 856 | /** |
| 857 | * qdf_dp_set_no_of_record() - set dp trace no_of_record |
| 858 | * |
| 859 | * @val : unsigned no_of_record to set |
| 860 | * |
| 861 | * Return: null |
| 862 | */ |
| 863 | void qdf_dp_set_no_of_record(uint32_t val) |
| 864 | { |
| 865 | g_qdf_dp_trace_data.no_of_record = val; |
| 866 | } |
| 867 | EXPORT_SYMBOL(qdf_dp_set_no_of_record); |
| 868 | |
| 869 | /** |
| 870 | * qdf_dp_get_no_of_record() - get dp trace no_of_record |
| 871 | * |
| 872 | * Return: number of records |
| 873 | */ |
| 874 | uint8_t qdf_dp_get_no_of_record(void) |
| 875 | { |
| 876 | return g_qdf_dp_trace_data.no_of_record; |
| 877 | } |
| 878 | EXPORT_SYMBOL(qdf_dp_get_no_of_record); |
| 879 | |
| 880 | |
| 881 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 882 | * qdf_dp_trace_enable_track() - enable the tracing for netbuf |
| 883 | * @code: defines the event |
| 884 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 885 | * In High verbosity all codes are logged. |
| 886 | * For Med/Low and Default case code which has |
| 887 | * less value than corresponding verbosity codes |
| 888 | * are logged. |
| 889 | * |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 890 | * Return: true or false depends on whether tracing enabled |
| 891 | */ |
| 892 | static bool qdf_dp_trace_enable_track(enum QDF_DP_TRACE_ID code) |
| 893 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 894 | switch (g_qdf_dp_trace_data.verbosity) { |
| 895 | case QDF_DP_TRACE_VERBOSITY_HIGH: |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 896 | return true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 897 | case QDF_DP_TRACE_VERBOSITY_MEDIUM: |
| 898 | if (code <= QDF_DP_TRACE_MED_VERBOSITY) |
| 899 | return true; |
| 900 | return false; |
| 901 | case QDF_DP_TRACE_VERBOSITY_LOW: |
| 902 | if (code <= QDF_DP_TRACE_LOW_VERBOSITY) |
| 903 | return true; |
| 904 | return false; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 905 | case QDF_DP_TRACE_VERBOSITY_BASE: |
| 906 | if (code <= QDF_DP_TRACE_BASE_VERBOSITY) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 907 | return true; |
| 908 | return false; |
| 909 | default: |
| 910 | return false; |
| 911 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 912 | } |
| 913 | EXPORT_SYMBOL(qdf_dp_trace_enable_track); |
| 914 | |
| 915 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 916 | * qdf_dp_get_proto_bitmap() - get dp trace proto bitmap |
| 917 | * |
| 918 | * Return: proto bitmap |
| 919 | */ |
| 920 | uint8_t qdf_dp_get_proto_bitmap(void) |
| 921 | { |
| 922 | if (g_qdf_dp_trace_data.enable) |
| 923 | return g_qdf_dp_trace_data.proto_bitmap; |
| 924 | else |
| 925 | return 0; |
| 926 | } |
| 927 | |
| 928 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 929 | * qdf_dp_trace_set_track() - Marks whether the packet needs to be traced |
| 930 | * @nbuf: defines the netbuf |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 931 | * @dir: direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 932 | * |
| 933 | * Return: None |
| 934 | */ |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 935 | 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] | 936 | { |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 937 | uint32_t count = 0; |
| 938 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 939 | if (!g_qdf_dp_trace_data.enable) |
| 940 | return; |
| 941 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 942 | spin_lock_bh(&l_dp_trace_lock); |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 943 | if (QDF_TX == dir) |
| 944 | count = ++g_qdf_dp_trace_data.tx_count; |
| 945 | else if (QDF_RX == dir) |
| 946 | count = ++g_qdf_dp_trace_data.rx_count; |
| 947 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 948 | if ((g_qdf_dp_trace_data.no_of_record != 0) && |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 949 | (count % g_qdf_dp_trace_data.no_of_record == 0)) { |
| 950 | if (QDF_TX == dir) |
| 951 | QDF_NBUF_CB_TX_DP_TRACE(nbuf) = 1; |
| 952 | else if (QDF_RX == dir) |
| 953 | QDF_NBUF_CB_RX_DP_TRACE(nbuf) = 1; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 954 | } |
| 955 | spin_unlock_bh(&l_dp_trace_lock); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 956 | } |
| 957 | EXPORT_SYMBOL(qdf_dp_trace_set_track); |
Nandha Kishore Easwaran | 403b085 | 2017-07-14 17:27:53 +0530 | [diff] [blame] | 958 | |
Houston Hoffman | bba5ca6 | 2016-11-12 14:24:58 -0800 | [diff] [blame] | 959 | #define DPTRACE_PRINT(args...) \ |
Himanshu Agarwal | 26cfe7e | 2017-05-08 15:01:07 +0530 | [diff] [blame] | 960 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG, ## args) |
Houston Hoffman | bba5ca6 | 2016-11-12 14:24:58 -0800 | [diff] [blame] | 961 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 962 | /** |
| 963 | * dump_hex_trace() - Display the data in buffer |
Houston Hoffman | 8a35393 | 2016-11-14 12:58:22 -0800 | [diff] [blame] | 964 | * @str: string to prepend the hexdump with. |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 965 | * @buf: buffer which contains data to be displayed |
| 966 | * @buf_len: defines the size of the data to be displayed |
| 967 | * |
| 968 | * Return: None |
| 969 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 970 | static void dump_dp_hex_trace(char *str, uint8_t *buf, uint8_t buf_len) |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 971 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 972 | unsigned char linebuf[BUFFER_SIZE]; |
| 973 | const u8 *ptr = buf; |
| 974 | int i, linelen, remaining = buf_len; |
| 975 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 976 | /* Dump the bytes in the last line */ |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 977 | for (i = 0; i < buf_len; i += ROW_SIZE) { |
| 978 | linelen = min(remaining, ROW_SIZE); |
| 979 | remaining -= ROW_SIZE; |
| 980 | |
| 981 | hex_dump_to_buffer(ptr + i, linelen, ROW_SIZE, 1, |
| 982 | linebuf, sizeof(linebuf), false); |
| 983 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 984 | DPTRACE_PRINT("DPT: %s %s", str, linebuf); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 985 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 986 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 987 | |
| 988 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 989 | * qdf_dp_code_to_string() - convert dptrace code to string |
| 990 | * @code: dptrace code |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 991 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 992 | * Return: string version of code |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 993 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 994 | static |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 995 | 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] | 996 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 997 | switch (code) { |
| 998 | case QDF_DP_TRACE_DROP_PACKET_RECORD: |
| 999 | return "DROP:"; |
| 1000 | case QDF_DP_TRACE_EAPOL_PACKET_RECORD: |
| 1001 | return "EAPOL:"; |
| 1002 | case QDF_DP_TRACE_DHCP_PACKET_RECORD: |
| 1003 | return "DHCP:"; |
| 1004 | case QDF_DP_TRACE_ARP_PACKET_RECORD: |
| 1005 | return "ARP:"; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1006 | case QDF_DP_TRACE_ICMP_PACKET_RECORD: |
| 1007 | return "ICMP:"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1008 | case QDF_DP_TRACE_ICMPv6_PACKET_RECORD: |
| 1009 | return "ICMPv6:"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1010 | case QDF_DP_TRACE_MGMT_PACKET_RECORD: |
| 1011 | return "MGMT:"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1012 | case QDF_DP_TRACE_EVENT_RECORD: |
| 1013 | return "EVENT:"; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1014 | case QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD: |
| 1015 | return "HDD: TX: PTR:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1016 | case QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD: |
| 1017 | return "LI_DP: TX: PTR:"; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1018 | case QDF_DP_TRACE_HDD_TX_PACKET_RECORD: |
| 1019 | return "HDD: TX: DATA:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1020 | case QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD: |
| 1021 | return "LI_DP: TX: DATA:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1022 | case QDF_DP_TRACE_CE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1023 | return "CE: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1024 | case QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1025 | return "CE: TX: FAST: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1026 | case QDF_DP_TRACE_FREE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1027 | return "FREE: TX: PTR:"; |
| 1028 | case QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD: |
| 1029 | return "HTT: RX: PTR:"; |
| 1030 | case QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD: |
| 1031 | return "HTT: RX: OF: PTR:"; |
| 1032 | case QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD: |
| 1033 | return "HDD: RX: PTR:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1034 | case QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD: |
| 1035 | return "LI_DP: RX: PTR:"; |
Himanshu Agarwal | f30a9e9 | 2017-01-31 12:57:48 +0530 | [diff] [blame] | 1036 | case QDF_DP_TRACE_HDD_RX_PACKET_RECORD: |
| 1037 | return "HDD: RX: DATA:"; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1038 | case QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD: |
| 1039 | return "LI_DP: RX: DATA:"; |
| 1040 | case QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD: |
| 1041 | return "LI_DP_NULL: RX: DATA:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1042 | case QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1043 | return "TXRX: TX: Q: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1044 | case QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1045 | return "TXRX: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1046 | case QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1047 | return "TXRX: TX: FAST: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1048 | case QDF_DP_TRACE_HTT_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1049 | return "HTT: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1050 | case QDF_DP_TRACE_HTC_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1051 | return "HTC: TX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1052 | case QDF_DP_TRACE_HIF_PACKET_PTR_RECORD: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1053 | return "HIF: TX: PTR:"; |
| 1054 | case QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD: |
| 1055 | return "TXRX: RX: PTR:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1056 | case QDF_DP_TRACE_HDD_TX_TIMEOUT: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1057 | return "HDD: STA: TO:"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1058 | case QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1059 | return "HDD: SAP: TO:"; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1060 | default: |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1061 | return "Invalid"; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1062 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1063 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1064 | |
| 1065 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1066 | * qdf_dp_dir_to_str() - convert direction to string |
| 1067 | * @dir: direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1068 | * |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1069 | * Return: string version of direction |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1070 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1071 | 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] | 1072 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1073 | switch (dir) { |
| 1074 | case QDF_TX: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1075 | return " --> "; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1076 | case QDF_RX: |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1077 | return " <-- "; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1078 | default: |
| 1079 | return "invalid"; |
| 1080 | } |
| 1081 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1082 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1083 | /** |
| 1084 | * qdf_dp_type_to_str() - convert packet type to string |
| 1085 | * @type: type |
| 1086 | * |
| 1087 | * Return: string version of packet type |
| 1088 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1089 | 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] | 1090 | { |
| 1091 | switch (type) { |
| 1092 | case QDF_PROTO_TYPE_DHCP: |
| 1093 | return "DHCP"; |
| 1094 | case QDF_PROTO_TYPE_EAPOL: |
| 1095 | return "EAPOL"; |
| 1096 | case QDF_PROTO_TYPE_ARP: |
| 1097 | return "ARP"; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1098 | case QDF_PROTO_TYPE_ICMP: |
| 1099 | return "ICMP"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1100 | case QDF_PROTO_TYPE_ICMPv6: |
| 1101 | return "ICMPv6"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1102 | case QDF_PROTO_TYPE_MGMT: |
| 1103 | return "MGMT"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1104 | case QDF_PROTO_TYPE_EVENT: |
| 1105 | return "EVENT"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1106 | default: |
| 1107 | return "invalid"; |
| 1108 | } |
| 1109 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1110 | |
| 1111 | /** |
| 1112 | * qdf_dp_subtype_to_str() - convert packet subtype to string |
| 1113 | * @type: type |
| 1114 | * |
| 1115 | * Return: string version of packet subtype |
| 1116 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1117 | 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] | 1118 | { |
| 1119 | switch (subtype) { |
| 1120 | case QDF_PROTO_EAPOL_M1: |
| 1121 | return "M1"; |
| 1122 | case QDF_PROTO_EAPOL_M2: |
| 1123 | return "M2"; |
| 1124 | case QDF_PROTO_EAPOL_M3: |
| 1125 | return "M3"; |
| 1126 | case QDF_PROTO_EAPOL_M4: |
| 1127 | return "M4"; |
| 1128 | case QDF_PROTO_DHCP_DISCOVER: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1129 | return "DISC"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1130 | case QDF_PROTO_DHCP_REQUEST: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1131 | return "REQ"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1132 | case QDF_PROTO_DHCP_OFFER: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1133 | return "OFF"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1134 | case QDF_PROTO_DHCP_ACK: |
| 1135 | return "ACK"; |
| 1136 | case QDF_PROTO_DHCP_NACK: |
| 1137 | return "NACK"; |
| 1138 | case QDF_PROTO_DHCP_RELEASE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1139 | return "REL"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1140 | case QDF_PROTO_DHCP_INFORM: |
| 1141 | return "INFORM"; |
| 1142 | case QDF_PROTO_DHCP_DECLINE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1143 | return "DECL"; |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1144 | case QDF_PROTO_ARP_REQ: |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1145 | case QDF_PROTO_ICMP_REQ: |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1146 | case QDF_PROTO_ICMPV6_REQ: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1147 | return "REQ"; |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1148 | case QDF_PROTO_ARP_RES: |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1149 | case QDF_PROTO_ICMP_RES: |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1150 | case QDF_PROTO_ICMPV6_RES: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1151 | return "RSP"; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1152 | case QDF_PROTO_ICMPV6_RS: |
| 1153 | return "RS"; |
| 1154 | case QDF_PROTO_ICMPV6_RA: |
| 1155 | return "RA"; |
| 1156 | case QDF_PROTO_ICMPV6_NS: |
| 1157 | return "NS"; |
| 1158 | case QDF_PROTO_ICMPV6_NA: |
| 1159 | return "NA"; |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1160 | case QDF_PROTO_MGMT_ASSOC: |
| 1161 | return "ASSOC"; |
| 1162 | case QDF_PROTO_MGMT_DISASSOC: |
| 1163 | return "DISASSOC"; |
| 1164 | case QDF_PROTO_MGMT_AUTH: |
| 1165 | return "AUTH"; |
| 1166 | case QDF_PROTO_MGMT_DEAUTH: |
| 1167 | return "DEAUTH"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1168 | case QDF_ROAM_SYNCH: |
| 1169 | return "ROAM SYNCH"; |
| 1170 | case QDF_ROAM_COMPLETE: |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1171 | return "ROAM COMP"; |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1172 | case QDF_ROAM_EVENTID: |
| 1173 | return "ROAM EVENTID"; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1174 | default: |
| 1175 | return "invalid"; |
| 1176 | } |
| 1177 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1178 | |
| 1179 | /** |
| 1180 | * qdf_dp_enable_check() - check if dptrace is enable or not |
| 1181 | * @nbuf: nbuf |
| 1182 | * @code: dptrace code |
| 1183 | * |
| 1184 | * Return: true/false |
| 1185 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1186 | static bool qdf_dp_enable_check(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, |
| 1187 | enum qdf_proto_dir dir) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1188 | { |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1189 | /* Return when Dp trace is not enabled */ |
| 1190 | if (!g_qdf_dp_trace_data.enable) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1191 | return false; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1192 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1193 | if (qdf_dp_trace_enable_track(code) == false) |
| 1194 | return false; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1195 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1196 | if ((nbuf) && ((QDF_NBUF_CB_TX_PACKET_TRACK(nbuf) != |
| 1197 | QDF_NBUF_TX_PKT_DATA_TRACK) || |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1198 | ((dir == QDF_TX) && (QDF_NBUF_CB_TX_DP_TRACE(nbuf) == 0)) || |
| 1199 | ((dir == QDF_RX) && (QDF_NBUF_CB_RX_DP_TRACE(nbuf) == 0)))) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1200 | return false; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1201 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1202 | return true; |
| 1203 | } |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1204 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1205 | /** |
| 1206 | * qdf_dp_add_record() - add dp trace record |
| 1207 | * @code: dptrace code |
| 1208 | * @data: data pointer |
| 1209 | * @size: size of buffer |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1210 | * @pdev_id: pdev_id |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1211 | * @print: true to print it in kmsg |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1212 | * |
| 1213 | * Return: none |
| 1214 | */ |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1215 | static void qdf_dp_add_record(enum QDF_DP_TRACE_ID code, uint8_t *data, |
| 1216 | uint8_t size, uint8_t pdev_id, bool print) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1217 | { |
| 1218 | struct qdf_dp_trace_record_s *rec = NULL; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1219 | int index; |
Srinivas Girigowda | 43977f7 | 2017-04-03 09:17:46 -0700 | [diff] [blame] | 1220 | |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1221 | spin_lock_bh(&l_dp_trace_lock); |
| 1222 | |
| 1223 | g_qdf_dp_trace_data.num++; |
| 1224 | |
| 1225 | if (g_qdf_dp_trace_data.num > MAX_QDF_DP_TRACE_RECORDS) |
| 1226 | g_qdf_dp_trace_data.num = MAX_QDF_DP_TRACE_RECORDS; |
| 1227 | |
| 1228 | if (INVALID_QDF_DP_TRACE_ADDR == g_qdf_dp_trace_data.head) { |
| 1229 | /* first record */ |
| 1230 | g_qdf_dp_trace_data.head = 0; |
| 1231 | g_qdf_dp_trace_data.tail = 0; |
| 1232 | } else { |
| 1233 | /* queue is not empty */ |
| 1234 | g_qdf_dp_trace_data.tail++; |
| 1235 | |
| 1236 | if (MAX_QDF_DP_TRACE_RECORDS == g_qdf_dp_trace_data.tail) |
| 1237 | g_qdf_dp_trace_data.tail = 0; |
| 1238 | |
| 1239 | if (g_qdf_dp_trace_data.head == g_qdf_dp_trace_data.tail) { |
| 1240 | /* full */ |
| 1241 | if (MAX_QDF_DP_TRACE_RECORDS == |
| 1242 | ++g_qdf_dp_trace_data.head) |
| 1243 | g_qdf_dp_trace_data.head = 0; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | rec = &g_qdf_dp_trace_tbl[g_qdf_dp_trace_data.tail]; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1248 | index = g_qdf_dp_trace_data.tail; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1249 | rec->code = code; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1250 | rec->pdev_id = pdev_id; |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1251 | rec->size = 0; |
| 1252 | if (data != NULL && size > 0) { |
| 1253 | if (size > QDF_DP_TRACE_RECORD_SIZE) |
| 1254 | size = QDF_DP_TRACE_RECORD_SIZE; |
| 1255 | |
| 1256 | rec->size = size; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1257 | qdf_mem_copy(rec->data, data, size); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1258 | } |
Himanshu Agarwal | c61fdf6 | 2016-12-08 15:28:33 +0530 | [diff] [blame] | 1259 | qdf_get_time_of_the_day_in_hr_min_sec_usec(rec->time, |
| 1260 | sizeof(rec->time)); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1261 | rec->pid = (in_interrupt() ? 0 : current->pid); |
| 1262 | spin_unlock_bh(&l_dp_trace_lock); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1263 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1264 | |
| 1265 | if (rec->code >= QDF_DP_TRACE_MAX) { |
| 1266 | QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, |
| 1267 | "invalid record code %u, max code %u", rec->code, |
| 1268 | QDF_DP_TRACE_MAX); |
| 1269 | return; |
| 1270 | } |
| 1271 | |
| 1272 | if (print == true) { |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1273 | qdf_dp_trace_cb_table[rec->code] (rec, index, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1274 | QDF_TRACE_DEFAULT_PDEV_ID, true); |
| 1275 | return; |
| 1276 | } |
| 1277 | |
| 1278 | if (g_qdf_dp_trace_data.live_mode_config) { |
| 1279 | spin_lock_bh(&l_dp_trace_lock); |
| 1280 | g_qdf_dp_trace_data.print_pkt_cnt++; |
| 1281 | if ((g_qdf_dp_trace_data.live_mode == 1) && |
| 1282 | (g_qdf_dp_trace_data.print_pkt_cnt > |
| 1283 | g_qdf_dp_trace_data.high_tput_thresh)) |
| 1284 | g_qdf_dp_trace_data.live_mode = 0; |
| 1285 | spin_unlock_bh(&l_dp_trace_lock); |
| 1286 | } |
| 1287 | |
| 1288 | if (g_qdf_dp_trace_data.live_mode == true) { |
| 1289 | qdf_dp_trace_cb_table[rec->code] (rec, index, |
| 1290 | QDF_TRACE_DEFAULT_PDEV_ID, true); |
| 1291 | return; |
| 1292 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1293 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1294 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1295 | |
| 1296 | /** |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1297 | * qdf_log_icmpv6_pkt() - log ICMPv6 packet |
| 1298 | * @session_id: vdev_id |
| 1299 | * @skb: skb pointer |
| 1300 | * @dir: direction |
| 1301 | * |
| 1302 | * Return: true/false |
| 1303 | */ |
| 1304 | static bool qdf_log_icmpv6_pkt(uint8_t session_id, struct sk_buff *skb, |
| 1305 | enum qdf_proto_dir dir, uint8_t pdev_id) |
| 1306 | { |
| 1307 | enum qdf_proto_subtype subtype; |
| 1308 | |
| 1309 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ICMPv6) && |
| 1310 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_ICMPv6 == |
| 1311 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1312 | (dir == QDF_RX && qdf_nbuf_is_icmpv6_pkt(skb) == true))) { |
| 1313 | |
| 1314 | subtype = qdf_nbuf_get_icmpv6_subtype(skb); |
| 1315 | DPTRACE(qdf_dp_trace_proto_pkt( |
| 1316 | QDF_DP_TRACE_ICMPv6_PACKET_RECORD, |
| 1317 | session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
| 1318 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
| 1319 | QDF_PROTO_TYPE_ICMPv6, subtype, dir, pdev_id, false)); |
| 1320 | if (dir == QDF_TX) |
| 1321 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1322 | else if (dir == QDF_RX) |
| 1323 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
| 1324 | |
| 1325 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = false; |
| 1326 | |
| 1327 | switch (subtype) { |
| 1328 | case QDF_PROTO_ICMPV6_REQ: |
| 1329 | g_qdf_dp_trace_data.icmpv6_req++; |
| 1330 | break; |
| 1331 | case QDF_PROTO_ICMPV6_RES: |
| 1332 | g_qdf_dp_trace_data.icmpv6_resp++; |
| 1333 | break; |
| 1334 | case QDF_PROTO_ICMPV6_RS: |
| 1335 | g_qdf_dp_trace_data.icmpv6_rs++; |
| 1336 | break; |
| 1337 | case QDF_PROTO_ICMPV6_RA: |
| 1338 | g_qdf_dp_trace_data.icmpv6_ra++; |
| 1339 | break; |
| 1340 | case QDF_PROTO_ICMPV6_NS: |
| 1341 | g_qdf_dp_trace_data.icmpv6_ns++; |
| 1342 | break; |
| 1343 | case QDF_PROTO_ICMPV6_NA: |
| 1344 | g_qdf_dp_trace_data.icmpv6_na++; |
| 1345 | break; |
| 1346 | default: |
| 1347 | break; |
| 1348 | } |
| 1349 | return true; |
| 1350 | } |
| 1351 | |
| 1352 | return false; |
| 1353 | } |
| 1354 | |
| 1355 | /** |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1356 | * qdf_log_icmp_pkt() - log ICMP packet |
| 1357 | * @session_id: vdev_id |
| 1358 | * @skb: skb pointer |
| 1359 | * @dir: direction |
| 1360 | * |
| 1361 | * Return: true/false |
| 1362 | */ |
| 1363 | static bool qdf_log_icmp_pkt(uint8_t session_id, struct sk_buff *skb, |
| 1364 | enum qdf_proto_dir dir, uint8_t pdev_id) |
| 1365 | { |
| 1366 | enum qdf_proto_subtype proto_subtype; |
| 1367 | |
| 1368 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ICMP) && |
| 1369 | (qdf_nbuf_is_icmp_pkt(skb) == true)) { |
| 1370 | |
| 1371 | proto_subtype = qdf_nbuf_get_icmp_subtype(skb); |
| 1372 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_ICMP_PACKET_RECORD, |
| 1373 | session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
| 1374 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
| 1375 | QDF_PROTO_TYPE_ICMP, proto_subtype, dir, pdev_id, false)); |
| 1376 | if (QDF_TX == dir) |
| 1377 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1378 | else if (QDF_RX == dir) |
| 1379 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
| 1380 | |
| 1381 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = false; |
| 1382 | |
| 1383 | if (proto_subtype == QDF_PROTO_ICMP_REQ) |
| 1384 | g_qdf_dp_trace_data.icmp_req++; |
| 1385 | else |
| 1386 | g_qdf_dp_trace_data.icmp_resp++; |
| 1387 | |
| 1388 | return true; |
| 1389 | } |
| 1390 | return false; |
| 1391 | } |
| 1392 | |
| 1393 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1394 | * qdf_log_eapol_pkt() - log EAPOL packet |
| 1395 | * @session_id: vdev_id |
| 1396 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1397 | * @dir: direction |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1398 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1399 | * |
| 1400 | * Return: true/false |
| 1401 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1402 | static bool qdf_log_eapol_pkt(uint8_t session_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1403 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1404 | { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1405 | enum qdf_proto_subtype subtype; |
| 1406 | |
| 1407 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_EAPOL) && |
Nirav Shah | 9c3b3fe | 2016-07-20 16:05:06 +0530 | [diff] [blame] | 1408 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_EAPOL == |
| 1409 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1410 | (dir == QDF_RX && qdf_nbuf_is_ipv4_eapol_pkt(skb) == true))) { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1411 | |
Himanshu Agarwal | fcd64e9 | 2016-07-20 17:45:58 +0530 | [diff] [blame] | 1412 | subtype = qdf_nbuf_get_eapol_subtype(skb); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1413 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_EAPOL_PACKET_RECORD, |
| 1414 | session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
| 1415 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1416 | QDF_PROTO_TYPE_EAPOL, subtype, dir, pdev_id, true)); |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1417 | if (QDF_TX == dir) |
| 1418 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1419 | else if (QDF_RX == dir) |
| 1420 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1421 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1422 | switch (subtype) { |
| 1423 | case QDF_PROTO_EAPOL_M1: |
| 1424 | g_qdf_dp_trace_data.eapol_m1++; |
| 1425 | break; |
| 1426 | case QDF_PROTO_EAPOL_M2: |
| 1427 | g_qdf_dp_trace_data.eapol_m2++; |
| 1428 | break; |
| 1429 | case QDF_PROTO_EAPOL_M3: |
| 1430 | g_qdf_dp_trace_data.eapol_m3++; |
| 1431 | break; |
| 1432 | case QDF_PROTO_EAPOL_M4: |
| 1433 | g_qdf_dp_trace_data.eapol_m4++; |
| 1434 | break; |
| 1435 | default: |
| 1436 | g_qdf_dp_trace_data.eapol_others++; |
| 1437 | break; |
| 1438 | } |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1439 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1440 | return true; |
| 1441 | } |
| 1442 | return false; |
| 1443 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1444 | |
| 1445 | /** |
| 1446 | * qdf_log_dhcp_pkt() - log DHCP packet |
| 1447 | * @session_id: vdev_id |
| 1448 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1449 | * @dir: direction |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1450 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1451 | * |
| 1452 | * Return: true/false |
| 1453 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1454 | static bool qdf_log_dhcp_pkt(uint8_t session_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1455 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1456 | { |
| 1457 | enum qdf_proto_subtype subtype = QDF_PROTO_INVALID; |
| 1458 | |
| 1459 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_DHCP) && |
Nirav Shah | 9c3b3fe | 2016-07-20 16:05:06 +0530 | [diff] [blame] | 1460 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP == |
| 1461 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1462 | (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) { |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1463 | |
Himanshu Agarwal | fcd64e9 | 2016-07-20 17:45:58 +0530 | [diff] [blame] | 1464 | subtype = qdf_nbuf_get_dhcp_subtype(skb); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1465 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_DHCP_PACKET_RECORD, |
| 1466 | session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
| 1467 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1468 | QDF_PROTO_TYPE_DHCP, subtype, dir, pdev_id, true)); |
| 1469 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1470 | if (QDF_TX == dir) |
| 1471 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1472 | else if (QDF_RX == dir) |
| 1473 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1474 | |
| 1475 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1476 | switch (subtype) { |
| 1477 | case QDF_PROTO_DHCP_DISCOVER: |
| 1478 | g_qdf_dp_trace_data.dhcp_disc++; |
| 1479 | break; |
| 1480 | case QDF_PROTO_DHCP_OFFER: |
| 1481 | g_qdf_dp_trace_data.dhcp_off++; |
| 1482 | break; |
| 1483 | case QDF_PROTO_DHCP_REQUEST: |
| 1484 | g_qdf_dp_trace_data.dhcp_req++; |
| 1485 | break; |
| 1486 | case QDF_PROTO_DHCP_ACK: |
| 1487 | g_qdf_dp_trace_data.dhcp_ack++; |
| 1488 | break; |
| 1489 | case QDF_PROTO_DHCP_NACK: |
| 1490 | g_qdf_dp_trace_data.dhcp_nack++; |
| 1491 | break; |
| 1492 | default: |
| 1493 | g_qdf_dp_trace_data.eapol_others++; |
| 1494 | break; |
| 1495 | } |
| 1496 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1497 | return true; |
| 1498 | } |
| 1499 | return false; |
| 1500 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1501 | |
| 1502 | /** |
| 1503 | * qdf_log_arp_pkt() - log ARP packet |
| 1504 | * @session_id: vdev_id |
| 1505 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1506 | * @dir: direction |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1507 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1508 | * |
| 1509 | * Return: true/false |
| 1510 | */ |
Jeff Johnson | 4729b6f | 2016-10-07 13:02:43 -0700 | [diff] [blame] | 1511 | static bool qdf_log_arp_pkt(uint8_t session_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1512 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1513 | { |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1514 | enum qdf_proto_subtype proto_subtype; |
| 1515 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1516 | if ((qdf_dp_get_proto_bitmap() & QDF_NBUF_PKT_TRAC_TYPE_ARP) && |
Nirav Shah | 9c3b3fe | 2016-07-20 16:05:06 +0530 | [diff] [blame] | 1517 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_ARP == |
| 1518 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 1519 | (dir == QDF_RX && qdf_nbuf_is_ipv4_arp_pkt(skb) == true))) { |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1520 | |
Himanshu Agarwal | fcd64e9 | 2016-07-20 17:45:58 +0530 | [diff] [blame] | 1521 | proto_subtype = qdf_nbuf_get_arp_subtype(skb); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1522 | DPTRACE(qdf_dp_trace_proto_pkt(QDF_DP_TRACE_ARP_PACKET_RECORD, |
| 1523 | session_id, (skb->data + QDF_NBUF_SRC_MAC_OFFSET), |
| 1524 | (skb->data + QDF_NBUF_DEST_MAC_OFFSET), |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1525 | QDF_PROTO_TYPE_ARP, proto_subtype, dir, pdev_id, true)); |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1526 | if (QDF_TX == dir) |
| 1527 | QDF_NBUF_CB_TX_DP_TRACE(skb) = 1; |
| 1528 | else if (QDF_RX == dir) |
| 1529 | QDF_NBUF_CB_RX_DP_TRACE(skb) = 1; |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1530 | |
| 1531 | QDF_NBUF_CB_DP_TRACE_PRINT(skb) = true; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1532 | |
| 1533 | if (QDF_PROTO_ARP_REQ == proto_subtype) |
| 1534 | g_qdf_dp_trace_data.arp_req++; |
| 1535 | else |
| 1536 | g_qdf_dp_trace_data.arp_resp++; |
| 1537 | |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1538 | return true; |
| 1539 | } |
| 1540 | return false; |
| 1541 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1542 | |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1543 | |
| 1544 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1545 | * qdf_dp_trace_log_pkt() - log packet type enabled through iwpriv |
| 1546 | * @session_id: vdev_id |
| 1547 | * @skb: skb pointer |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1548 | * @dir: direction |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1549 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1550 | * |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1551 | * Return: true: some protocol was logged, false: no protocol was logged. |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1552 | */ |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1553 | bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1554 | enum qdf_proto_dir dir, uint8_t pdev_id) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1555 | { |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1556 | if (!qdf_dp_get_proto_bitmap()) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1557 | return false; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1558 | if (qdf_log_arp_pkt(session_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1559 | return true; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1560 | if (qdf_log_dhcp_pkt(session_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1561 | return true; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1562 | if (qdf_log_eapol_pkt(session_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1563 | return true; |
Zhu Jianmin | af3420a | 2017-06-12 17:55:43 +0800 | [diff] [blame] | 1564 | if (qdf_log_icmp_pkt(session_id, skb, dir, pdev_id)) |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1565 | return true; |
Poddar, Siddarth | bf4231b | 2017-07-10 16:27:01 +0530 | [diff] [blame] | 1566 | if (qdf_log_icmpv6_pkt(session_id, skb, dir, pdev_id)) |
| 1567 | return true; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1568 | return false; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1569 | } |
| 1570 | EXPORT_SYMBOL(qdf_dp_trace_log_pkt); |
| 1571 | |
| 1572 | /** |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1573 | * qdf_dp_display_mgmt_pkt() - display proto packet |
| 1574 | * @record: dptrace record |
| 1575 | * @index: index |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1576 | * @live : live mode or dump mode |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1577 | * |
| 1578 | * Return: none |
| 1579 | */ |
| 1580 | void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1581 | uint16_t index, uint8_t pdev_id, bool live) |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1582 | { |
| 1583 | struct qdf_dp_trace_mgmt_buf *buf = |
| 1584 | (struct qdf_dp_trace_mgmt_buf *)record->data; |
| 1585 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1586 | DPTRACE_PRINT("DPT: %04d: %s [%d] [%s %s %s]", |
| 1587 | index, |
| 1588 | (live == true) ? " " : record->time, |
| 1589 | buf->vdev_id, |
| 1590 | qdf_dp_code_to_string(record->code), |
| 1591 | qdf_dp_type_to_str(buf->type), |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1592 | qdf_dp_subtype_to_str(buf->subtype)); |
| 1593 | } |
| 1594 | EXPORT_SYMBOL(qdf_dp_display_mgmt_pkt); |
| 1595 | |
| 1596 | /** |
| 1597 | * qdf_dp_trace_mgmt_pkt() - record mgmt packet |
| 1598 | * @code: dptrace code |
| 1599 | * @vdev_id: vdev id |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1600 | * @pdev_id: pdev_id |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1601 | * @type: proto type |
| 1602 | * @subtype: proto subtype |
| 1603 | * |
| 1604 | * Return: none |
| 1605 | */ |
| 1606 | 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] | 1607 | uint8_t pdev_id, enum qdf_proto_type type, |
| 1608 | enum qdf_proto_subtype subtype) |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1609 | { |
| 1610 | struct qdf_dp_trace_mgmt_buf buf; |
| 1611 | int buf_size = sizeof(struct qdf_dp_trace_mgmt_buf); |
| 1612 | |
| 1613 | if (qdf_dp_enable_check(NULL, code, QDF_NA) == false) |
| 1614 | return; |
| 1615 | |
| 1616 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1617 | QDF_BUG(0); |
| 1618 | |
| 1619 | buf.type = type; |
| 1620 | buf.subtype = subtype; |
| 1621 | buf.vdev_id = vdev_id; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1622 | qdf_dp_add_record(code, (uint8_t *)&buf, buf_size, pdev_id, true); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1623 | } |
| 1624 | EXPORT_SYMBOL(qdf_dp_trace_mgmt_pkt); |
| 1625 | |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1626 | /** |
| 1627 | * qdf_dp_display_event_record() - display event records |
| 1628 | * @record: dptrace record |
| 1629 | * @index: index |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1630 | * @live : live mode or dump mode |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1631 | * |
| 1632 | * Return: none |
| 1633 | */ |
| 1634 | void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1635 | uint16_t index, uint8_t pdev_id, bool live) |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1636 | { |
| 1637 | struct qdf_dp_trace_event_buf *buf = |
| 1638 | (struct qdf_dp_trace_event_buf *)record->data; |
| 1639 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1640 | DPTRACE_PRINT("DPT: %04d: %s [%d] [%s %s %s]", |
| 1641 | index, |
| 1642 | (live == true) ? "" : record->time, |
| 1643 | buf->vdev_id, |
| 1644 | qdf_dp_code_to_string(record->code), |
| 1645 | qdf_dp_type_to_str(buf->type), |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1646 | qdf_dp_subtype_to_str(buf->subtype)); |
| 1647 | } |
| 1648 | EXPORT_SYMBOL(qdf_dp_display_event_record); |
| 1649 | |
| 1650 | /** |
| 1651 | * qdf_dp_trace_record_event() - record events |
| 1652 | * @code: dptrace code |
| 1653 | * @vdev_id: vdev id |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1654 | * @pdev_id: pdev_id |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1655 | * @type: proto type |
| 1656 | * @subtype: proto subtype |
| 1657 | * |
| 1658 | * Return: none |
| 1659 | */ |
| 1660 | 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] | 1661 | uint8_t pdev_id, enum qdf_proto_type type, |
| 1662 | enum qdf_proto_subtype subtype) |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1663 | { |
| 1664 | struct qdf_dp_trace_event_buf buf; |
| 1665 | int buf_size = sizeof(struct qdf_dp_trace_event_buf); |
| 1666 | |
| 1667 | if (qdf_dp_enable_check(NULL, code, QDF_NA) == false) |
| 1668 | return; |
| 1669 | |
| 1670 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1671 | QDF_BUG(0); |
| 1672 | |
| 1673 | buf.type = type; |
| 1674 | buf.subtype = subtype; |
| 1675 | buf.vdev_id = vdev_id; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1676 | qdf_dp_add_record(code, (uint8_t *)&buf, buf_size, pdev_id, true); |
Himanshu Agarwal | c0b7145 | 2016-09-20 15:10:55 +0530 | [diff] [blame] | 1677 | } |
| 1678 | EXPORT_SYMBOL(qdf_dp_trace_record_event); |
Nirav Shah | 31d694b | 2016-05-03 20:18:22 +0530 | [diff] [blame] | 1679 | |
| 1680 | /** |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1681 | * qdf_dp_display_proto_pkt() - display proto packet |
| 1682 | * @record: dptrace record |
| 1683 | * @index: index |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1684 | * @live : live mode or dump mode |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1685 | * |
| 1686 | * Return: none |
| 1687 | */ |
| 1688 | void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1689 | uint16_t index, uint8_t pdev_id, bool live) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1690 | { |
| 1691 | struct qdf_dp_trace_proto_buf *buf = |
| 1692 | (struct qdf_dp_trace_proto_buf *)record->data; |
| 1693 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1694 | DPTRACE_PRINT("DPT: %04d: %s [%d] [%s%s] SA: " |
| 1695 | QDF_MAC_ADDRESS_STR " %s DA: " |
| 1696 | QDF_MAC_ADDRESS_STR, |
| 1697 | index, |
| 1698 | (live == true) ? "" : record->time, |
| 1699 | buf->vdev_id, |
| 1700 | qdf_dp_code_to_string(record->code), |
| 1701 | qdf_dp_subtype_to_str(buf->subtype), |
| 1702 | QDF_MAC_ADDR_ARRAY(buf->sa.bytes), |
| 1703 | qdf_dp_dir_to_str(buf->dir), QDF_MAC_ADDR_ARRAY(buf->da.bytes)); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1704 | } |
| 1705 | EXPORT_SYMBOL(qdf_dp_display_proto_pkt); |
| 1706 | |
| 1707 | /** |
| 1708 | * qdf_dp_trace_proto_pkt() - record proto packet |
| 1709 | * @code: dptrace code |
| 1710 | * @vdev_id: vdev id |
| 1711 | * @sa: source mac address |
| 1712 | * @da: destination mac address |
| 1713 | * @type: proto type |
| 1714 | * @subtype: proto subtype |
| 1715 | * @dir: direction |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1716 | * @pdev_id: pdev id |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1717 | * @print: to print this proto pkt or not |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1718 | * |
| 1719 | * Return: none |
| 1720 | */ |
| 1721 | void qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, |
| 1722 | uint8_t *sa, uint8_t *da, enum qdf_proto_type type, |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1723 | enum qdf_proto_subtype subtype, enum qdf_proto_dir dir, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1724 | uint8_t pdev_id, bool print) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1725 | { |
| 1726 | struct qdf_dp_trace_proto_buf buf; |
| 1727 | int buf_size = sizeof(struct qdf_dp_trace_ptr_buf); |
| 1728 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1729 | if (qdf_dp_enable_check(NULL, code, dir) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1730 | return; |
| 1731 | |
| 1732 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1733 | QDF_BUG(0); |
| 1734 | |
| 1735 | memcpy(&buf.sa, sa, QDF_NET_ETH_LEN); |
| 1736 | memcpy(&buf.da, da, QDF_NET_ETH_LEN); |
| 1737 | buf.dir = dir; |
| 1738 | buf.type = type; |
| 1739 | buf.subtype = subtype; |
| 1740 | buf.vdev_id = vdev_id; |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1741 | qdf_dp_add_record(code, (uint8_t *)&buf, buf_size, pdev_id, print); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1742 | } |
| 1743 | EXPORT_SYMBOL(qdf_dp_trace_proto_pkt); |
| 1744 | |
| 1745 | /** |
| 1746 | * qdf_dp_display_ptr_record() - display record |
| 1747 | * @record: dptrace record |
| 1748 | * @index: index |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1749 | * @live : live mode or dump mode |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1750 | * |
| 1751 | * Return: none |
| 1752 | */ |
| 1753 | void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1754 | uint16_t index, uint8_t pdev_id, bool live) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1755 | { |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1756 | char prepend_str[100] = {'\0'}; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1757 | struct qdf_dp_trace_ptr_buf *buf = |
| 1758 | (struct qdf_dp_trace_ptr_buf *)record->data; |
| 1759 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1760 | snprintf(prepend_str, sizeof(prepend_str), |
| 1761 | "%04d: %s [%s] [msdu id %d %s %d]", |
| 1762 | index, |
| 1763 | (live == true) ? "" : record->time, |
| 1764 | qdf_dp_code_to_string(record->code), buf->msdu_id, |
| 1765 | (record->code == QDF_DP_TRACE_FREE_PACKET_PTR_RECORD) ? |
| 1766 | "status" : "vdev_id", |
| 1767 | buf->status); |
| 1768 | |
| 1769 | if (live == true) { |
| 1770 | /* In live mode donot dump the contents of the cookie */ |
| 1771 | DPTRACE_PRINT("DPT: %s", prepend_str); |
| 1772 | } else { |
| 1773 | dump_dp_hex_trace(prepend_str, (uint8_t *)&buf->cookie, |
| 1774 | sizeof(buf->cookie)); |
| 1775 | } |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1776 | } |
| 1777 | EXPORT_SYMBOL(qdf_dp_display_ptr_record); |
| 1778 | |
| 1779 | /** |
| 1780 | * qdf_dp_trace_ptr() - record dptrace |
| 1781 | * @code: dptrace code |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1782 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1783 | * @data: data |
| 1784 | * @size: size of data |
| 1785 | * @msdu_id: msdu_id |
| 1786 | * @status: return status |
| 1787 | * |
| 1788 | * Return: none |
| 1789 | */ |
| 1790 | 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] | 1791 | uint8_t pdev_id, uint8_t *data, uint8_t size, |
| 1792 | uint16_t msdu_id, uint16_t status) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1793 | { |
| 1794 | struct qdf_dp_trace_ptr_buf buf; |
| 1795 | int buf_size = sizeof(struct qdf_dp_trace_ptr_buf); |
| 1796 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1797 | if (qdf_dp_enable_check(nbuf, code, QDF_TX) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1798 | return; |
| 1799 | |
| 1800 | if (buf_size > QDF_DP_TRACE_RECORD_SIZE) |
| 1801 | QDF_BUG(0); |
| 1802 | |
| 1803 | qdf_mem_copy(&buf.cookie, data, size); |
| 1804 | buf.msdu_id = msdu_id; |
| 1805 | buf.status = status; |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1806 | qdf_dp_add_record(code, (uint8_t *)&buf, buf_size, pdev_id, |
Himanshu Agarwal | 3f54962 | 2016-10-27 15:16:25 +0530 | [diff] [blame] | 1807 | QDF_NBUF_CB_DP_TRACE_PRINT(nbuf)); |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1808 | } |
| 1809 | EXPORT_SYMBOL(qdf_dp_trace_ptr); |
| 1810 | |
| 1811 | /** |
| 1812 | * qdf_dp_display_trace() - Displays a record in DP trace |
| 1813 | * @pRecord : pointer to a record in DP trace |
| 1814 | * @recIndex : record index |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1815 | * @live : live mode or dump mode |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1816 | * |
| 1817 | * Return: None |
| 1818 | */ |
| 1819 | void qdf_dp_display_record(struct qdf_dp_trace_record_s *pRecord, |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1820 | uint16_t recIndex, uint8_t pdev_id, bool live) |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1821 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1822 | { |
| 1823 | char prepend_str[50] = {'\0'}; |
| 1824 | |
| 1825 | if (!(pdev_id == QDF_TRACE_DEFAULT_PDEV_ID || |
| 1826 | pdev_id == pRecord->pdev_id)) |
| 1827 | return; |
| 1828 | |
| 1829 | snprintf(prepend_str, sizeof(prepend_str), |
| 1830 | "%04d PDEV_ID = %02d: %s %s", |
| 1831 | recIndex, |
| 1832 | pRecord->pdev_id, |
| 1833 | (live == true) ? "" : pRecord->time, |
| 1834 | qdf_dp_code_to_string(pRecord->code)); |
| 1835 | |
| 1836 | switch (pRecord->code) { |
| 1837 | case QDF_DP_TRACE_HDD_TX_TIMEOUT: |
| 1838 | DPTRACE_PRINT(" %s: HDD TX Timeout", prepend_str); |
| 1839 | break; |
| 1840 | case QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT: |
| 1841 | DPTRACE_PRINT(" %s: HDD SoftAP TX Timeout", prepend_str); |
| 1842 | break; |
| 1843 | case QDF_DP_TRACE_HDD_TX_PACKET_RECORD: |
| 1844 | case QDF_DP_TRACE_HDD_RX_PACKET_RECORD: |
| 1845 | case QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD: |
| 1846 | case QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD: |
| 1847 | case QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD: |
| 1848 | default: |
| 1849 | dump_dp_hex_trace(prepend_str, pRecord->data, pRecord->size); |
| 1850 | break; |
| 1851 | }; |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1852 | } |
| 1853 | EXPORT_SYMBOL(qdf_dp_display_record); |
| 1854 | |
| 1855 | |
| 1856 | /** |
| 1857 | * qdf_dp_trace() - Stores the data in buffer |
| 1858 | * @nbuf : defines the netbuf |
| 1859 | * @code : defines the event |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1860 | * @pdev_id: pdev_id |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1861 | * @data : defines the data to be stored |
| 1862 | * @size : defines the size of the data record |
| 1863 | * |
| 1864 | * Return: None |
| 1865 | */ |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1866 | void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id, |
| 1867 | uint8_t *data, uint8_t size, enum qdf_proto_dir dir) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1868 | { |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1869 | |
| 1870 | if (qdf_dp_enable_check(nbuf, code, dir) == false) |
Nirav Shah | eaa20d8 | 2016-04-25 18:01:05 +0530 | [diff] [blame] | 1871 | return; |
| 1872 | |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1873 | qdf_dp_add_record(code, data, size, pdev_id, |
Mohit Khanna | 6e1de59 | 2016-10-31 19:26:08 -0700 | [diff] [blame] | 1874 | (nbuf != NULL) ? QDF_NBUF_CB_DP_TRACE_PRINT(nbuf) : false); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1875 | } |
| 1876 | EXPORT_SYMBOL(qdf_dp_trace); |
| 1877 | |
| 1878 | /** |
| 1879 | * qdf_dp_trace_spin_lock_init() - initializes the lock variable before use |
| 1880 | * This function will be called from cds_alloc_global_context, we will have lock |
| 1881 | * available to use ASAP |
| 1882 | * |
| 1883 | * Return: None |
| 1884 | */ |
| 1885 | void qdf_dp_trace_spin_lock_init(void) |
| 1886 | { |
| 1887 | spin_lock_init(&l_dp_trace_lock); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1888 | } |
| 1889 | EXPORT_SYMBOL(qdf_dp_trace_spin_lock_init); |
| 1890 | |
| 1891 | /** |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1892 | * qdf_dp_trace_disable_live_mode - disable live mode for dptrace |
| 1893 | * |
| 1894 | * Return: none |
| 1895 | */ |
| 1896 | void qdf_dp_trace_disable_live_mode(void) |
| 1897 | { |
| 1898 | g_qdf_dp_trace_data.live_mode = 0; |
| 1899 | } |
| 1900 | EXPORT_SYMBOL(qdf_dp_trace_disable_live_mode); |
| 1901 | |
| 1902 | /** |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1903 | * qdf_dp_trace_enable_live_mode() - enable live mode for dptrace |
| 1904 | * |
| 1905 | * Return: none |
| 1906 | */ |
| 1907 | void qdf_dp_trace_enable_live_mode(void) |
| 1908 | { |
| 1909 | g_qdf_dp_trace_data.live_mode = 1; |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1910 | } |
| 1911 | EXPORT_SYMBOL(qdf_dp_trace_enable_live_mode); |
| 1912 | |
Nirav Shah | 29beae0 | 2016-04-26 22:58:54 +0530 | [diff] [blame] | 1913 | /** |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1914 | * qdf_dp_trace_clear_buffer() - clear dp trace buffer |
| 1915 | * |
| 1916 | * Return: none |
| 1917 | */ |
| 1918 | void qdf_dp_trace_clear_buffer(void) |
| 1919 | { |
| 1920 | g_qdf_dp_trace_data.head = INVALID_QDF_DP_TRACE_ADDR; |
| 1921 | g_qdf_dp_trace_data.tail = INVALID_QDF_DP_TRACE_ADDR; |
| 1922 | g_qdf_dp_trace_data.num = 0; |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1923 | memset(g_qdf_dp_trace_tbl, 0, |
| 1924 | MAX_QDF_DP_TRACE_RECORDS * sizeof(struct qdf_dp_trace_record_s)); |
| 1925 | } |
| 1926 | EXPORT_SYMBOL(qdf_dp_trace_clear_buffer); |
| 1927 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1928 | void qdf_dp_trace_dump_stats(void) |
| 1929 | { |
| 1930 | DPTRACE_PRINT("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)", |
| 1931 | g_qdf_dp_trace_data.icmp_req, |
| 1932 | g_qdf_dp_trace_data.icmp_resp, |
| 1933 | g_qdf_dp_trace_data.arp_req, |
| 1934 | g_qdf_dp_trace_data.arp_resp, |
| 1935 | g_qdf_dp_trace_data.icmpv6_req, |
| 1936 | g_qdf_dp_trace_data.icmpv6_resp, |
| 1937 | g_qdf_dp_trace_data.icmpv6_ns, |
| 1938 | g_qdf_dp_trace_data.icmpv6_na, |
| 1939 | g_qdf_dp_trace_data.icmpv6_rs, |
| 1940 | g_qdf_dp_trace_data.icmpv6_ra, |
| 1941 | g_qdf_dp_trace_data.dhcp_disc, |
| 1942 | g_qdf_dp_trace_data.dhcp_off, |
| 1943 | g_qdf_dp_trace_data.dhcp_req, |
| 1944 | g_qdf_dp_trace_data.dhcp_ack, |
| 1945 | g_qdf_dp_trace_data.dhcp_nack, |
| 1946 | g_qdf_dp_trace_data.dhcp_others, |
| 1947 | g_qdf_dp_trace_data.eapol_m1, |
| 1948 | g_qdf_dp_trace_data.eapol_m2, |
| 1949 | g_qdf_dp_trace_data.eapol_m3, |
| 1950 | g_qdf_dp_trace_data.eapol_m4, |
| 1951 | g_qdf_dp_trace_data.eapol_others); |
| 1952 | } |
| 1953 | |
Nirav Shah | cede289 | 2016-05-19 12:41:15 +0530 | [diff] [blame] | 1954 | /** |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1955 | * qdf_dp_trace_dump_all() - Dump data from ring buffer via call back functions |
| 1956 | * registered with QDF |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1957 | * @count: Number of lines to dump starting from tail to head |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1958 | * @pdev_id: pdev_id |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1959 | * |
| 1960 | * Return: None |
| 1961 | */ |
Nandha Kishore Easwaran | e43583f | 2017-05-15 21:01:13 +0530 | [diff] [blame] | 1962 | 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] | 1963 | { |
| 1964 | struct qdf_dp_trace_record_s p_record; |
| 1965 | int32_t i, tail; |
| 1966 | |
| 1967 | if (!g_qdf_dp_trace_data.enable) { |
Himanshu Agarwal | 26cfe7e | 2017-05-08 15:01:07 +0530 | [diff] [blame] | 1968 | DPTRACE_PRINT("Tracing Disabled"); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1969 | return; |
| 1970 | } |
| 1971 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1972 | DPTRACE_PRINT( |
| 1973 | "DPT: config - bitmap 0x%x verb %u #rec %u live_config %u thresh %u time_limit %u", |
| 1974 | g_qdf_dp_trace_data.proto_bitmap, |
| 1975 | g_qdf_dp_trace_data.verbosity, |
| 1976 | g_qdf_dp_trace_data.no_of_record, |
| 1977 | g_qdf_dp_trace_data.live_mode_config, |
| 1978 | g_qdf_dp_trace_data.high_tput_thresh, |
| 1979 | g_qdf_dp_trace_data.thresh_time_limit); |
| 1980 | |
Mohit Khanna | 90d7ebd | 2017-09-12 21:54:21 -0700 | [diff] [blame] | 1981 | qdf_dp_trace_dump_stats(); |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 1982 | |
| 1983 | DPTRACE_PRINT("DPT: Total Records: %d, Head: %d, Tail: %d", |
Himanshu Agarwal | 26cfe7e | 2017-05-08 15:01:07 +0530 | [diff] [blame] | 1984 | g_qdf_dp_trace_data.num, g_qdf_dp_trace_data.head, |
| 1985 | g_qdf_dp_trace_data.tail); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 1986 | |
| 1987 | /* aquire the lock so that only one thread at a time can read |
| 1988 | * the ring buffer |
| 1989 | */ |
| 1990 | spin_lock_bh(&l_dp_trace_lock); |
| 1991 | |
| 1992 | if (g_qdf_dp_trace_data.head != INVALID_QDF_DP_TRACE_ADDR) { |
| 1993 | i = g_qdf_dp_trace_data.head; |
| 1994 | tail = g_qdf_dp_trace_data.tail; |
| 1995 | |
| 1996 | if (count) { |
| 1997 | if (count > g_qdf_dp_trace_data.num) |
| 1998 | count = g_qdf_dp_trace_data.num; |
| 1999 | if (tail >= (count - 1)) |
| 2000 | i = tail - count + 1; |
| 2001 | else if (count != MAX_QDF_DP_TRACE_RECORDS) |
| 2002 | i = MAX_QDF_DP_TRACE_RECORDS - ((count - 1) - |
| 2003 | tail); |
| 2004 | } |
| 2005 | |
| 2006 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2007 | spin_unlock_bh(&l_dp_trace_lock); |
| 2008 | for (;; ) { |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2009 | qdf_dp_trace_cb_table[p_record.code](&p_record, |
| 2010 | (uint16_t)i, pdev_id, false); |
Chouhan, Anurag | 5776318 | 2016-03-03 18:57:27 +0530 | [diff] [blame] | 2011 | if (i == tail) |
| 2012 | break; |
| 2013 | i += 1; |
| 2014 | |
| 2015 | spin_lock_bh(&l_dp_trace_lock); |
| 2016 | if (MAX_QDF_DP_TRACE_RECORDS == i) |
| 2017 | i = 0; |
| 2018 | |
| 2019 | p_record = g_qdf_dp_trace_tbl[i]; |
| 2020 | spin_unlock_bh(&l_dp_trace_lock); |
| 2021 | } |
| 2022 | } else { |
| 2023 | spin_unlock_bh(&l_dp_trace_lock); |
| 2024 | } |
| 2025 | } |
| 2026 | EXPORT_SYMBOL(qdf_dp_trace_dump_all); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2027 | |
Nirav Shah | ae6a0b3 | 2016-04-26 11:44:42 +0530 | [diff] [blame] | 2028 | #endif |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 2029 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2030 | struct qdf_print_ctrl print_ctrl_obj[MAX_PRINT_CONFIG_SUPPORTED]; |
| 2031 | |
| 2032 | struct category_name_info g_qdf_category_name[MAX_SUPPORTED_CATEGORY] = { |
| 2033 | [QDF_MODULE_ID_TDLS] = {"tdls"}, |
| 2034 | [QDF_MODULE_ID_ACS] = {"ACS"}, |
| 2035 | [QDF_MODULE_ID_SCAN_SM] = {"scan state machine"}, |
| 2036 | [QDF_MODULE_ID_SCANENTRY] = {"scan entry"}, |
| 2037 | [QDF_MODULE_ID_WDS] = {"WDS"}, |
| 2038 | [QDF_MODULE_ID_ACTION] = {"action"}, |
| 2039 | [QDF_MODULE_ID_ROAM] = {"STA roaming"}, |
| 2040 | [QDF_MODULE_ID_INACT] = {"inactivity"}, |
| 2041 | [QDF_MODULE_ID_DOTH] = {"11h"}, |
| 2042 | [QDF_MODULE_ID_IQUE] = {"IQUE"}, |
| 2043 | [QDF_MODULE_ID_WME] = {"WME"}, |
| 2044 | [QDF_MODULE_ID_ACL] = {"ACL"}, |
| 2045 | [QDF_MODULE_ID_WPA] = {"WPA/RSN"}, |
| 2046 | [QDF_MODULE_ID_RADKEYS] = {"dump 802.1x keys"}, |
| 2047 | [QDF_MODULE_ID_RADDUMP] = {"dump radius packet"}, |
| 2048 | [QDF_MODULE_ID_RADIUS] = {"802.1x radius client"}, |
| 2049 | [QDF_MODULE_ID_DOT1XSM] = {"802.1x state machine"}, |
| 2050 | [QDF_MODULE_ID_DOT1X] = {"802.1x authenticator"}, |
| 2051 | [QDF_MODULE_ID_POWER] = {"power save"}, |
| 2052 | [QDF_MODULE_ID_STATE] = {"state"}, |
| 2053 | [QDF_MODULE_ID_OUTPUT] = {"output"}, |
| 2054 | [QDF_MODULE_ID_SCAN] = {"scan"}, |
| 2055 | [QDF_MODULE_ID_AUTH] = {"authentication"}, |
| 2056 | [QDF_MODULE_ID_ASSOC] = {"association"}, |
| 2057 | [QDF_MODULE_ID_NODE] = {"node"}, |
| 2058 | [QDF_MODULE_ID_ELEMID] = {"element ID"}, |
| 2059 | [QDF_MODULE_ID_XRATE] = {"rate"}, |
| 2060 | [QDF_MODULE_ID_INPUT] = {"input"}, |
| 2061 | [QDF_MODULE_ID_CRYPTO] = {"crypto"}, |
| 2062 | [QDF_MODULE_ID_DUMPPKTS] = {"dump packet"}, |
| 2063 | [QDF_MODULE_ID_DEBUG] = {"debug"}, |
| 2064 | [QDF_MODULE_ID_MLME] = {"mlme"}, |
| 2065 | [QDF_MODULE_ID_RRM] = {"rrm"}, |
| 2066 | [QDF_MODULE_ID_WNM] = {"wnm"}, |
| 2067 | [QDF_MODULE_ID_P2P_PROT] = {"p2p_prot"}, |
| 2068 | [QDF_MODULE_ID_PROXYARP] = {"proxyarp"}, |
| 2069 | [QDF_MODULE_ID_L2TIF] = {"l2tif"}, |
| 2070 | [QDF_MODULE_ID_WIFIPOS] = {"wifipos"}, |
| 2071 | [QDF_MODULE_ID_WRAP] = {"wrap"}, |
| 2072 | [QDF_MODULE_ID_DFS] = {"dfs"}, |
| 2073 | [QDF_MODULE_ID_ATF] = {"atf"}, |
| 2074 | [QDF_MODULE_ID_SPLITMAC] = {"splitmac"}, |
| 2075 | [QDF_MODULE_ID_IOCTL] = {"ioctl"}, |
| 2076 | [QDF_MODULE_ID_NAC] = {"nac"}, |
| 2077 | [QDF_MODULE_ID_MESH] = {"mesh"}, |
| 2078 | [QDF_MODULE_ID_MBO] = {"mbo"}, |
| 2079 | [QDF_MODULE_ID_EXTIOCTL_CHANSWITCH] = {"extchanswitch"}, |
| 2080 | [QDF_MODULE_ID_EXTIOCTL_CHANSSCAN] = {"extchanscan"}, |
| 2081 | [QDF_MODULE_ID_TLSHIM] = {"tlshim"}, |
| 2082 | [QDF_MODULE_ID_WMI] = {"WMI"}, |
| 2083 | [QDF_MODULE_ID_HTT] = {"HTT"}, |
| 2084 | [QDF_MODULE_ID_HDD] = {"HDD"}, |
| 2085 | [QDF_MODULE_ID_SME] = {"SME"}, |
| 2086 | [QDF_MODULE_ID_PE] = {"PE"}, |
| 2087 | [QDF_MODULE_ID_WMA] = {"WMA"}, |
| 2088 | [QDF_MODULE_ID_SYS] = {"SYS"}, |
| 2089 | [QDF_MODULE_ID_QDF] = {"QDF"}, |
| 2090 | [QDF_MODULE_ID_SAP] = {"SAP"}, |
| 2091 | [QDF_MODULE_ID_HDD_SOFTAP] = {"HDD_SAP"}, |
| 2092 | [QDF_MODULE_ID_HDD_DATA] = {"DATA"}, |
| 2093 | [QDF_MODULE_ID_HDD_SAP_DATA] = {"SAP_DATA"}, |
| 2094 | [QDF_MODULE_ID_HIF] = {"HIF"}, |
| 2095 | [QDF_MODULE_ID_HTC] = {"HTC"}, |
| 2096 | [QDF_MODULE_ID_TXRX] = {"TXRX"}, |
| 2097 | [QDF_MODULE_ID_QDF_DEVICE] = {"QDF_DEV"}, |
| 2098 | [QDF_MODULE_ID_CFG] = {"CFG"}, |
| 2099 | [QDF_MODULE_ID_BMI] = {"BMI"}, |
| 2100 | [QDF_MODULE_ID_EPPING] = {"EPPING"}, |
| 2101 | [QDF_MODULE_ID_QVIT] = {"QVIT"}, |
Ashish Kumar Dhanotiya | d199fcb | 2017-02-06 20:53:04 +0530 | [diff] [blame] | 2102 | [QDF_MODULE_ID_DP] = {"DP"}, |
| 2103 | [QDF_MODULE_ID_SOC] = {"SOC"}, |
| 2104 | [QDF_MODULE_ID_OS_IF] = {"OSIF"}, |
| 2105 | [QDF_MODULE_ID_TARGET_IF] = {"TIF"}, |
| 2106 | [QDF_MODULE_ID_SCHEDULER] = {"SCH"}, |
| 2107 | [QDF_MODULE_ID_MGMT_TXRX] = {"MGMT_TXRX"}, |
Mukul Sharma | d8fd144 | 2017-02-03 11:27:17 +0530 | [diff] [blame] | 2108 | [QDF_MODULE_ID_PMO] = {"PMO"}, |
Tushnim Bhattacharyya | e4449d3 | 2017-03-17 11:01:49 -0700 | [diff] [blame] | 2109 | [QDF_MODULE_ID_POLICY_MGR] = {"POLICY_MGR"}, |
Naveen Rawat | 5154273 | 2017-03-21 15:09:34 -0700 | [diff] [blame] | 2110 | [QDF_MODULE_ID_NAN] = {"NAN"}, |
Edayilliam Jayadev | 642201f | 2017-04-05 14:29:18 +0530 | [diff] [blame] | 2111 | [QDF_MODULE_ID_SPECTRAL] = {"SPECTRAL"}, |
Wu Gao | 849fd2c | 2017-03-23 10:14:39 +0800 | [diff] [blame] | 2112 | [QDF_MODULE_ID_P2P] = {"P2P"}, |
Kiran Venkatappa | 3453674 | 2017-04-04 00:09:10 +0530 | [diff] [blame] | 2113 | [QDF_MODULE_ID_OFFCHAN_TXRX] = {"OFFCHAN"}, |
Kiran Kumar Lokere | a843634 | 2017-04-24 00:56:03 -0700 | [diff] [blame] | 2114 | [QDF_MODULE_ID_REGULATORY] = {"REGULATORY"}, |
Vivek | 2c86b21 | 2017-06-05 00:02:11 +0530 | [diff] [blame] | 2115 | [QDF_MODULE_ID_OBJ_MGR] = {"OBJMGR"}, |
Varun Reddy Yeturu | 2576425 | 2017-08-10 13:53:01 -0700 | [diff] [blame] | 2116 | [QDF_MODULE_ID_SERIALIZATION] = {"SER"}, |
Aniruddha Paul | b2f7ab6 | 2017-10-09 14:40:04 +0530 | [diff] [blame] | 2117 | [QDF_MODULE_ID_NSS] = {"NSS"}, |
Deepak Dhamdhere | 7e0b8ba | 2017-07-03 00:33:26 -0700 | [diff] [blame] | 2118 | [QDF_MODULE_ID_ROAM_DEBUG] = {"roam debug"}, |
Sathish Kumar | a9a42eb | 2017-11-17 17:26:39 +0530 | [diff] [blame^] | 2119 | [QDF_MODULE_ID_DIRECT_BUF_RX] = {"DIRECT_BUF_RX"}, |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2120 | [QDF_MODULE_ID_ANY] = {"ANY"}, |
| 2121 | }; |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 2122 | EXPORT_SYMBOL(g_qdf_category_name); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2123 | |
Dustin Brown | d7cfa49 | 2017-05-11 14:21:06 -0700 | [diff] [blame] | 2124 | /** |
| 2125 | * qdf_trace_display() - Display trace |
| 2126 | * |
| 2127 | * Return: None |
| 2128 | */ |
| 2129 | void qdf_trace_display(void) |
| 2130 | { |
| 2131 | QDF_MODULE_ID module_id; |
| 2132 | |
| 2133 | pr_err(" 1)FATAL 2)ERROR 3)WARN 4)INFO 5)INFO_H 6)INFO_M 7)INFO_L 8)DEBUG\n"); |
| 2134 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; ++module_id) { |
| 2135 | pr_err("%2d)%s %s %s %s %s %s %s %s %s\n", |
| 2136 | (int)module_id, |
| 2137 | g_qdf_category_name[module_id].category_name_str, |
| 2138 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2139 | QDF_TRACE_LEVEL_FATAL) ? "X" : " ", |
| 2140 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2141 | QDF_TRACE_LEVEL_ERROR) ? "X" : " ", |
| 2142 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2143 | QDF_TRACE_LEVEL_WARN) ? "X" : " ", |
| 2144 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2145 | QDF_TRACE_LEVEL_INFO) ? "X" : " ", |
| 2146 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2147 | QDF_TRACE_LEVEL_INFO_HIGH) ? "X" : " ", |
| 2148 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2149 | QDF_TRACE_LEVEL_INFO_MED) ? "X" : " ", |
| 2150 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2151 | QDF_TRACE_LEVEL_INFO_LOW) ? "X" : " ", |
| 2152 | qdf_print_is_verbose_enabled(qdf_pidx, module_id, |
| 2153 | QDF_TRACE_LEVEL_DEBUG) ? "X" : " "); |
| 2154 | } |
| 2155 | } |
| 2156 | EXPORT_SYMBOL(qdf_trace_display); |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2157 | |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2158 | #ifdef CONFIG_MCL |
| 2159 | #define print_to_console(str) |
| 2160 | #else |
| 2161 | static inline void print_to_console(char *str_buffer) |
| 2162 | { |
| 2163 | pr_err("%s\n", str_buffer); |
| 2164 | } |
| 2165 | #endif |
| 2166 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2167 | void qdf_trace_msg_cmn(unsigned int idx, |
| 2168 | QDF_MODULE_ID category, |
| 2169 | QDF_TRACE_LEVEL verbose, |
| 2170 | const char *str_format, va_list val) |
| 2171 | { |
| 2172 | char str_buffer[QDF_TRACE_BUFFER_SIZE]; |
| 2173 | int n; |
| 2174 | |
| 2175 | /* Check if index passed is valid */ |
| 2176 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2177 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2178 | return; |
| 2179 | } |
| 2180 | |
| 2181 | /* Check if print control object is in use */ |
| 2182 | if (!print_ctrl_obj[idx].in_use) { |
| 2183 | pr_info("%s: Invalid print control object\n", __func__); |
| 2184 | return; |
| 2185 | } |
| 2186 | |
| 2187 | /* Check if category passed is valid */ |
| 2188 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 2189 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 2190 | return; |
| 2191 | } |
| 2192 | |
| 2193 | /* Check if verbose mask is valid */ |
| 2194 | if (verbose < 0 || verbose >= QDF_TRACE_LEVEL_MAX) { |
| 2195 | pr_info("%s: Invalid verbose level %d\n", __func__, verbose); |
| 2196 | return; |
| 2197 | } |
| 2198 | |
| 2199 | /* |
| 2200 | * Print the trace message when the desired verbose level is set in |
| 2201 | * the desired category for the print control object |
| 2202 | */ |
| 2203 | if (print_ctrl_obj[idx].cat_info[category].category_verbose_mask & |
| 2204 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) { |
| 2205 | /* |
| 2206 | * The verbose strings are in an array. These are ordered in |
| 2207 | * the same order as the verbose levels are defined in the enum |
| 2208 | * (see QDF_TRACE_LEVEL) so we can index into this array with |
| 2209 | * the level and get the right string. The qdf verbose |
| 2210 | * are... Off, Fatal, Error, Warning, Info, Info_high, |
| 2211 | * Info_med, Info_low, Debug |
| 2212 | */ |
| 2213 | static const char * const VERBOSE_STR[] = { " ", "F", "E", "W", |
| 2214 | "I", "IH", "IM", "IL", |
| 2215 | "D" }; |
| 2216 | |
| 2217 | /* print the prefix string into the string buffer... */ |
| 2218 | n = scnprintf(str_buffer, QDF_TRACE_BUFFER_SIZE, |
| 2219 | "wlan: [%d:%2s:%s] ", |
| 2220 | in_interrupt() ? 0 : current->pid, |
| 2221 | VERBOSE_STR[verbose], |
| 2222 | g_qdf_category_name[category].category_name_str); |
| 2223 | |
| 2224 | /* print the formatted log message after the prefix string */ |
| 2225 | vscnprintf(str_buffer + n, QDF_TRACE_BUFFER_SIZE - n, |
| 2226 | str_format, val); |
| 2227 | #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) |
| 2228 | wlan_log_to_user(verbose, (char *)str_buffer, |
| 2229 | strlen(str_buffer)); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2230 | print_to_console(str_buffer); |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2231 | #else |
| 2232 | pr_err("%s\n", str_buffer); |
| 2233 | #endif |
| 2234 | va_end(val); |
| 2235 | } |
| 2236 | } |
| 2237 | EXPORT_SYMBOL(qdf_trace_msg_cmn); |
| 2238 | |
Mohit Khanna | 7750a17 | 2017-05-15 15:53:33 -0700 | [diff] [blame] | 2239 | /** |
| 2240 | * qdf_dp_trace_throttle_live_mode() - Throttle DP Trace live mode |
| 2241 | * @high_bw_request: whether this is a high BW req or not |
| 2242 | * |
| 2243 | * The function tries to prevent excessive logging into the live buffer by |
| 2244 | * having an upper limit on number of packets that can be logged per second. |
| 2245 | * |
| 2246 | * The intention is to allow occasional pings and data packets and really low |
| 2247 | * throughput levels while suppressing bursts and higher throughput levels so |
| 2248 | * that we donot hog the live buffer. |
| 2249 | * |
| 2250 | * If the number of packets printed in a particular second exceeds the thresh, |
| 2251 | * disable printing in the next second. |
| 2252 | * |
| 2253 | * Return: None |
| 2254 | */ |
| 2255 | void qdf_dp_trace_throttle_live_mode(bool high_bw_request) |
| 2256 | { |
| 2257 | static int bw_interval_counter; |
| 2258 | |
| 2259 | if (g_qdf_dp_trace_data.enable == false || |
| 2260 | g_qdf_dp_trace_data.live_mode_config == false) |
| 2261 | return; |
| 2262 | |
| 2263 | if (high_bw_request) { |
| 2264 | g_qdf_dp_trace_data.live_mode = 0; |
| 2265 | bw_interval_counter = 0; |
| 2266 | return; |
| 2267 | } |
| 2268 | |
| 2269 | bw_interval_counter++; |
| 2270 | |
| 2271 | if (0 == (bw_interval_counter % |
| 2272 | g_qdf_dp_trace_data.thresh_time_limit)) { |
| 2273 | |
| 2274 | spin_lock_bh(&l_dp_trace_lock); |
| 2275 | if (g_qdf_dp_trace_data.print_pkt_cnt <= |
| 2276 | g_qdf_dp_trace_data.high_tput_thresh) |
| 2277 | g_qdf_dp_trace_data.live_mode = 1; |
| 2278 | |
| 2279 | g_qdf_dp_trace_data.print_pkt_cnt = 0; |
| 2280 | spin_unlock_bh(&l_dp_trace_lock); |
| 2281 | } |
| 2282 | |
| 2283 | } |
| 2284 | EXPORT_SYMBOL(qdf_dp_trace_throttle_live_mode); |
| 2285 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2286 | QDF_STATUS qdf_print_setup(void) |
| 2287 | { |
| 2288 | int i; |
| 2289 | |
| 2290 | /* Loop through all print ctrl objects */ |
| 2291 | for (i = 0; i < MAX_PRINT_CONFIG_SUPPORTED; i++) { |
| 2292 | if (qdf_print_ctrl_cleanup(i)) |
| 2293 | return QDF_STATUS_E_FAILURE; |
| 2294 | } |
| 2295 | return QDF_STATUS_SUCCESS; |
| 2296 | } |
| 2297 | EXPORT_SYMBOL(qdf_print_setup); |
| 2298 | |
| 2299 | QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx) |
| 2300 | { |
| 2301 | int i = 0; |
| 2302 | |
| 2303 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2304 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2305 | return QDF_STATUS_E_FAILURE; |
| 2306 | } |
| 2307 | |
| 2308 | /* Clean up the print control object corresponding to that index |
| 2309 | * If success, callee to change print control index to -1 |
| 2310 | */ |
| 2311 | |
| 2312 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 2313 | print_ctrl_obj[idx].cat_info[i].category_verbose_mask = |
| 2314 | QDF_TRACE_LEVEL_NONE; |
| 2315 | } |
| 2316 | print_ctrl_obj[idx].custom_print = NULL; |
| 2317 | print_ctrl_obj[idx].custom_ctxt = NULL; |
| 2318 | qdf_print_clean_node_flag(idx); |
| 2319 | print_ctrl_obj[idx].in_use = false; |
| 2320 | |
| 2321 | pr_info("%s: Print control object %d cleaned up\n", __func__, idx); |
| 2322 | |
| 2323 | return QDF_STATUS_SUCCESS; |
| 2324 | } |
| 2325 | EXPORT_SYMBOL(qdf_print_ctrl_cleanup); |
| 2326 | |
| 2327 | int qdf_print_ctrl_register(const struct category_info *cinfo, |
| 2328 | void *custom_print_handler, |
| 2329 | void *custom_ctx, |
| 2330 | const char *pctrl_name) |
| 2331 | { |
| 2332 | int idx = -1; |
| 2333 | int i = 0; |
| 2334 | |
| 2335 | for (i = 0; i < MAX_PRINT_CONFIG_SUPPORTED; i++) { |
| 2336 | if (!print_ctrl_obj[i].in_use) { |
| 2337 | idx = i; |
| 2338 | break; |
| 2339 | } |
| 2340 | } |
| 2341 | |
| 2342 | /* Callee to handle idx -1 appropriately */ |
| 2343 | if (idx == -1) { |
| 2344 | pr_info("%s: Allocation failed! No print control object free\n", |
| 2345 | __func__); |
| 2346 | return idx; |
| 2347 | } |
| 2348 | |
| 2349 | print_ctrl_obj[idx].in_use = true; |
| 2350 | |
| 2351 | /* |
| 2352 | * In case callee does not pass category info, |
| 2353 | * custom print handler, custom context and print control name, |
| 2354 | * we do not set any value here. Clean up for the print control |
| 2355 | * getting allocated would have taken care of initializing |
| 2356 | * default values. |
| 2357 | * |
| 2358 | * We need to only set in_use to 1 in such a case |
| 2359 | */ |
| 2360 | |
| 2361 | if (pctrl_name) { |
| 2362 | qdf_str_lcopy(print_ctrl_obj[idx].name, pctrl_name, |
| 2363 | qdf_str_len(pctrl_name) + 1); |
| 2364 | } |
| 2365 | |
| 2366 | if (custom_print_handler) |
| 2367 | print_ctrl_obj[idx].custom_print = custom_print_handler; |
| 2368 | |
| 2369 | if (custom_ctx) |
| 2370 | print_ctrl_obj[idx].custom_ctxt = custom_ctx; |
| 2371 | |
| 2372 | if (cinfo) { |
| 2373 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 2374 | if (cinfo[i].category_verbose_mask == |
| 2375 | QDF_TRACE_LEVEL_ALL) { |
| 2376 | print_ctrl_obj[idx].cat_info[i] |
| 2377 | .category_verbose_mask = 0xFFFF; |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 2378 | } else if ((cinfo[i].category_verbose_mask == |
| 2379 | QDF_TRACE_LEVEL_NONE) || |
| 2380 | (cinfo[i].category_verbose_mask == |
| 2381 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK( |
| 2382 | QDF_TRACE_LEVEL_NONE))) { |
| 2383 | print_ctrl_obj[idx].cat_info[i] |
| 2384 | .category_verbose_mask = 0; |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2385 | } else { |
| 2386 | print_ctrl_obj[idx].cat_info[i] |
| 2387 | .category_verbose_mask = |
| 2388 | cinfo[i].category_verbose_mask; |
| 2389 | } |
| 2390 | } |
| 2391 | } |
| 2392 | |
| 2393 | pr_info("%s: Allocated print control object %d\n", |
| 2394 | __func__, idx); |
| 2395 | return idx; |
| 2396 | } |
| 2397 | EXPORT_SYMBOL(qdf_print_ctrl_register); |
| 2398 | |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2399 | #ifndef CONFIG_MCL |
| 2400 | void qdf_shared_print_ctrl_cleanup(void) |
| 2401 | { |
| 2402 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 2403 | } |
| 2404 | EXPORT_SYMBOL(qdf_shared_print_ctrl_cleanup); |
| 2405 | |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2406 | /* |
| 2407 | * Set this to invalid value to differentiate with user-provided |
| 2408 | * value. |
| 2409 | */ |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 2410 | int qdf_dbg_mask = 0; |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2411 | EXPORT_SYMBOL(qdf_dbg_mask); |
| 2412 | qdf_declare_param(qdf_dbg_mask, int); |
| 2413 | |
| 2414 | /* |
| 2415 | * QDF can be passed parameters which indicate the |
| 2416 | * debug level for each module. |
| 2417 | * an array of string values are passed, each string hold the following form |
| 2418 | * |
| 2419 | * <module name string>=<integer debug level value> |
| 2420 | * |
| 2421 | * The array qdf_dbg_arr will hold these module-string=value strings |
| 2422 | * The variable qdf_dbg_arr_cnt will have the count of how many such |
| 2423 | * string values were passed. |
| 2424 | */ |
| 2425 | static char *qdf_dbg_arr[QDF_MODULE_ID_MAX]; |
| 2426 | static int qdf_dbg_arr_cnt; |
| 2427 | qdf_declare_param_array(qdf_dbg_arr, charp, &qdf_dbg_arr_cnt); |
| 2428 | |
| 2429 | static uint16_t set_cumulative_verbose_mask(QDF_TRACE_LEVEL max_level) |
| 2430 | { |
| 2431 | uint16_t category_verbose_mask = 0; |
| 2432 | QDF_TRACE_LEVEL level; |
| 2433 | |
| 2434 | for (level = QDF_TRACE_LEVEL_FATAL; level <= max_level; level++) { |
| 2435 | category_verbose_mask |= |
| 2436 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(level); |
| 2437 | } |
| 2438 | return category_verbose_mask; |
| 2439 | } |
| 2440 | |
| 2441 | static QDF_MODULE_ID find_qdf_module_from_string(char *str) |
| 2442 | { |
| 2443 | QDF_MODULE_ID mod_id; |
| 2444 | |
| 2445 | for (mod_id = 0; mod_id < QDF_MODULE_ID_MAX; mod_id++) { |
| 2446 | if (strcasecmp(str, |
| 2447 | g_qdf_category_name[mod_id].category_name_str) |
| 2448 | == 0) { |
| 2449 | break; |
| 2450 | } |
| 2451 | } |
| 2452 | return mod_id; |
| 2453 | } |
| 2454 | |
| 2455 | static void process_qdf_dbg_arr_param(struct category_info *cinfo, |
| 2456 | int array_index) |
| 2457 | { |
| 2458 | char *mod_val_str, *mod_str, *val_str; |
| 2459 | unsigned long dbg_level; |
| 2460 | QDF_MODULE_ID mod_id; |
| 2461 | |
| 2462 | mod_val_str = qdf_dbg_arr[array_index]; |
| 2463 | mod_str = strsep(&mod_val_str, "="); |
| 2464 | val_str = mod_val_str; |
| 2465 | if (val_str == NULL) { |
| 2466 | pr_info("qdf_dbg_arr: %s not in the <mod>=<val> form\n", |
| 2467 | mod_str); |
| 2468 | return; |
| 2469 | } |
| 2470 | |
| 2471 | mod_id = find_qdf_module_from_string(mod_str); |
| 2472 | if (mod_id >= QDF_MODULE_ID_MAX) { |
| 2473 | pr_info("ERROR!!Module name %s not in the list of modules\n", |
| 2474 | mod_str); |
| 2475 | return; |
| 2476 | } |
| 2477 | |
| 2478 | if (kstrtol(val_str, 10, &dbg_level) < 0) { |
| 2479 | pr_info("ERROR!!Invalid debug level for module: %s\n", |
| 2480 | mod_str); |
| 2481 | return; |
| 2482 | } |
| 2483 | |
| 2484 | if (dbg_level >= QDF_TRACE_LEVEL_MAX) { |
| 2485 | pr_info("ERROR!!Debug level for %s too high", mod_str); |
| 2486 | pr_info("max: %d given %lu\n", QDF_TRACE_LEVEL_MAX, |
| 2487 | dbg_level); |
| 2488 | return; |
| 2489 | } |
| 2490 | |
| 2491 | pr_info("User passed setting module %s(%d) to level %lu\n", |
| 2492 | mod_str, |
| 2493 | mod_id, |
| 2494 | dbg_level); |
| 2495 | cinfo[mod_id].category_verbose_mask = |
| 2496 | set_cumulative_verbose_mask((QDF_TRACE_LEVEL)dbg_level); |
| 2497 | } |
| 2498 | |
| 2499 | static void set_default_trace_levels(struct category_info *cinfo) |
| 2500 | { |
| 2501 | int i; |
| 2502 | static QDF_TRACE_LEVEL module_trace_default_level[QDF_MODULE_ID_MAX] = { |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 2503 | [QDF_MODULE_ID_TDLS] = QDF_TRACE_LEVEL_NONE, |
| 2504 | [QDF_MODULE_ID_ACS] = QDF_TRACE_LEVEL_NONE, |
| 2505 | [QDF_MODULE_ID_SCAN_SM] = QDF_TRACE_LEVEL_NONE, |
| 2506 | [QDF_MODULE_ID_SCANENTRY] = QDF_TRACE_LEVEL_NONE, |
| 2507 | [QDF_MODULE_ID_WDS] = QDF_TRACE_LEVEL_NONE, |
| 2508 | [QDF_MODULE_ID_ACTION] = QDF_TRACE_LEVEL_NONE, |
| 2509 | [QDF_MODULE_ID_ROAM] = QDF_TRACE_LEVEL_NONE, |
| 2510 | [QDF_MODULE_ID_INACT] = QDF_TRACE_LEVEL_NONE, |
| 2511 | [QDF_MODULE_ID_DOTH] = QDF_TRACE_LEVEL_NONE, |
| 2512 | [QDF_MODULE_ID_IQUE] = QDF_TRACE_LEVEL_NONE, |
| 2513 | [QDF_MODULE_ID_WME] = QDF_TRACE_LEVEL_NONE, |
| 2514 | [QDF_MODULE_ID_ACL] = QDF_TRACE_LEVEL_NONE, |
| 2515 | [QDF_MODULE_ID_WPA] = QDF_TRACE_LEVEL_NONE, |
| 2516 | [QDF_MODULE_ID_RADKEYS] = QDF_TRACE_LEVEL_NONE, |
| 2517 | [QDF_MODULE_ID_RADDUMP] = QDF_TRACE_LEVEL_NONE, |
| 2518 | [QDF_MODULE_ID_RADIUS] = QDF_TRACE_LEVEL_NONE, |
| 2519 | [QDF_MODULE_ID_DOT1XSM] = QDF_TRACE_LEVEL_NONE, |
| 2520 | [QDF_MODULE_ID_DOT1X] = QDF_TRACE_LEVEL_NONE, |
| 2521 | [QDF_MODULE_ID_POWER] = QDF_TRACE_LEVEL_NONE, |
| 2522 | [QDF_MODULE_ID_STATE] = QDF_TRACE_LEVEL_NONE, |
| 2523 | [QDF_MODULE_ID_OUTPUT] = QDF_TRACE_LEVEL_NONE, |
| 2524 | [QDF_MODULE_ID_SCAN] = QDF_TRACE_LEVEL_NONE, |
| 2525 | [QDF_MODULE_ID_AUTH] = QDF_TRACE_LEVEL_NONE, |
| 2526 | [QDF_MODULE_ID_ASSOC] = QDF_TRACE_LEVEL_NONE, |
| 2527 | [QDF_MODULE_ID_NODE] = QDF_TRACE_LEVEL_NONE, |
| 2528 | [QDF_MODULE_ID_ELEMID] = QDF_TRACE_LEVEL_NONE, |
| 2529 | [QDF_MODULE_ID_XRATE] = QDF_TRACE_LEVEL_NONE, |
| 2530 | [QDF_MODULE_ID_INPUT] = QDF_TRACE_LEVEL_NONE, |
| 2531 | [QDF_MODULE_ID_CRYPTO] = QDF_TRACE_LEVEL_NONE, |
| 2532 | [QDF_MODULE_ID_DUMPPKTS] = QDF_TRACE_LEVEL_NONE, |
| 2533 | [QDF_MODULE_ID_DEBUG] = QDF_TRACE_LEVEL_NONE, |
| 2534 | [QDF_MODULE_ID_MLME] = QDF_TRACE_LEVEL_NONE, |
| 2535 | [QDF_MODULE_ID_RRM] = QDF_TRACE_LEVEL_NONE, |
| 2536 | [QDF_MODULE_ID_WNM] = QDF_TRACE_LEVEL_NONE, |
| 2537 | [QDF_MODULE_ID_P2P_PROT] = QDF_TRACE_LEVEL_NONE, |
| 2538 | [QDF_MODULE_ID_PROXYARP] = QDF_TRACE_LEVEL_NONE, |
| 2539 | [QDF_MODULE_ID_L2TIF] = QDF_TRACE_LEVEL_NONE, |
| 2540 | [QDF_MODULE_ID_WIFIPOS] = QDF_TRACE_LEVEL_NONE, |
| 2541 | [QDF_MODULE_ID_WRAP] = QDF_TRACE_LEVEL_NONE, |
| 2542 | [QDF_MODULE_ID_DFS] = QDF_TRACE_LEVEL_NONE, |
| 2543 | [QDF_MODULE_ID_ATF] = QDF_TRACE_LEVEL_NONE, |
| 2544 | [QDF_MODULE_ID_SPLITMAC] = QDF_TRACE_LEVEL_NONE, |
| 2545 | [QDF_MODULE_ID_IOCTL] = QDF_TRACE_LEVEL_NONE, |
| 2546 | [QDF_MODULE_ID_NAC] = QDF_TRACE_LEVEL_NONE, |
| 2547 | [QDF_MODULE_ID_MESH] = QDF_TRACE_LEVEL_NONE, |
| 2548 | [QDF_MODULE_ID_MBO] = QDF_TRACE_LEVEL_NONE, |
| 2549 | [QDF_MODULE_ID_EXTIOCTL_CHANSWITCH] = QDF_TRACE_LEVEL_NONE, |
| 2550 | [QDF_MODULE_ID_EXTIOCTL_CHANSSCAN] = QDF_TRACE_LEVEL_NONE, |
| 2551 | [QDF_MODULE_ID_TLSHIM] = QDF_TRACE_LEVEL_NONE, |
| 2552 | [QDF_MODULE_ID_WMI] = QDF_TRACE_LEVEL_NONE, |
| 2553 | [QDF_MODULE_ID_HTT] = QDF_TRACE_LEVEL_NONE, |
| 2554 | [QDF_MODULE_ID_HDD] = QDF_TRACE_LEVEL_NONE, |
| 2555 | [QDF_MODULE_ID_SME] = QDF_TRACE_LEVEL_NONE, |
| 2556 | [QDF_MODULE_ID_PE] = QDF_TRACE_LEVEL_NONE, |
| 2557 | [QDF_MODULE_ID_WMA] = QDF_TRACE_LEVEL_NONE, |
| 2558 | [QDF_MODULE_ID_SYS] = QDF_TRACE_LEVEL_NONE, |
| 2559 | [QDF_MODULE_ID_QDF] = QDF_TRACE_LEVEL_NONE, |
| 2560 | [QDF_MODULE_ID_SAP] = QDF_TRACE_LEVEL_NONE, |
| 2561 | [QDF_MODULE_ID_HDD_SOFTAP] = QDF_TRACE_LEVEL_NONE, |
| 2562 | [QDF_MODULE_ID_HDD_DATA] = QDF_TRACE_LEVEL_NONE, |
| 2563 | [QDF_MODULE_ID_HDD_SAP_DATA] = QDF_TRACE_LEVEL_NONE, |
| 2564 | [QDF_MODULE_ID_HIF] = QDF_TRACE_LEVEL_NONE, |
| 2565 | [QDF_MODULE_ID_HTC] = QDF_TRACE_LEVEL_NONE, |
| 2566 | [QDF_MODULE_ID_TXRX] = QDF_TRACE_LEVEL_NONE, |
| 2567 | [QDF_MODULE_ID_QDF_DEVICE] = QDF_TRACE_LEVEL_NONE, |
| 2568 | [QDF_MODULE_ID_CFG] = QDF_TRACE_LEVEL_NONE, |
| 2569 | [QDF_MODULE_ID_BMI] = QDF_TRACE_LEVEL_NONE, |
| 2570 | [QDF_MODULE_ID_EPPING] = QDF_TRACE_LEVEL_NONE, |
| 2571 | [QDF_MODULE_ID_QVIT] = QDF_TRACE_LEVEL_NONE, |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 2572 | [QDF_MODULE_ID_DP] = QDF_TRACE_LEVEL_FATAL, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 2573 | [QDF_MODULE_ID_SOC] = QDF_TRACE_LEVEL_NONE, |
| 2574 | [QDF_MODULE_ID_OS_IF] = QDF_TRACE_LEVEL_NONE, |
| 2575 | [QDF_MODULE_ID_TARGET_IF] = QDF_TRACE_LEVEL_NONE, |
| 2576 | [QDF_MODULE_ID_SCHEDULER] = QDF_TRACE_LEVEL_NONE, |
| 2577 | [QDF_MODULE_ID_MGMT_TXRX] = QDF_TRACE_LEVEL_NONE, |
| 2578 | [QDF_MODULE_ID_PMO] = QDF_TRACE_LEVEL_NONE, |
| 2579 | [QDF_MODULE_ID_POLICY_MGR] = QDF_TRACE_LEVEL_NONE, |
| 2580 | [QDF_MODULE_ID_NAN] = QDF_TRACE_LEVEL_NONE, |
| 2581 | [QDF_MODULE_ID_P2P] = QDF_TRACE_LEVEL_NONE, |
| 2582 | [QDF_MODULE_ID_OFFCHAN_TXRX] = QDF_TRACE_LEVEL_NONE, |
Vivek | 2c86b21 | 2017-06-05 00:02:11 +0530 | [diff] [blame] | 2583 | [QDF_MODULE_ID_OBJ_MGR] = QDF_TRACE_LEVEL_INFO, |
Varun Reddy Yeturu | 2576425 | 2017-08-10 13:53:01 -0700 | [diff] [blame] | 2584 | [QDF_MODULE_ID_SERIALIZATION] = QDF_TRACE_LEVEL_NONE, |
Aniruddha Paul | b2f7ab6 | 2017-10-09 14:40:04 +0530 | [diff] [blame] | 2585 | [QDF_MODULE_ID_NSS] = QDF_TRACE_LEVEL_ERROR, |
Deepak Dhamdhere | 7e0b8ba | 2017-07-03 00:33:26 -0700 | [diff] [blame] | 2586 | [QDF_MODULE_ID_ROAM_DEBUG] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | a9a42eb | 2017-11-17 17:26:39 +0530 | [diff] [blame^] | 2587 | [QDF_MODULE_ID_DIRECT_BUF_RX] = QDF_TRACE_LEVEL_ERROR, |
Sathish Kumar | adeb66e | 2017-05-18 11:29:05 +0530 | [diff] [blame] | 2588 | [QDF_MODULE_ID_ANY] = QDF_TRACE_LEVEL_NONE, |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2589 | }; |
| 2590 | |
| 2591 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 2592 | cinfo[i].category_verbose_mask = set_cumulative_verbose_mask( |
| 2593 | module_trace_default_level[i]); |
| 2594 | } |
| 2595 | } |
| 2596 | |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2597 | void qdf_shared_print_ctrl_init(void) |
| 2598 | { |
| 2599 | int i; |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2600 | struct category_info *cinfo = qdf_mem_malloc((sizeof(*cinfo))* |
| 2601 | MAX_SUPPORTED_CATEGORY); |
| 2602 | if (cinfo == NULL) { |
| 2603 | pr_info("ERROR!! qdf_mem_malloc failed. \ |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2604 | Shared Print Ctrl object not initialized \ |
| 2605 | \nQDF_TRACE messages may not be logged/displayed"); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2606 | return; |
| 2607 | } |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2608 | |
| 2609 | set_default_trace_levels(cinfo); |
| 2610 | |
| 2611 | /* |
| 2612 | * User specified across-module single debug level |
| 2613 | */ |
Adil Saeed Musthafa | 03e2ac2 | 2017-05-19 16:55:23 -0700 | [diff] [blame] | 2614 | 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] | 2615 | pr_info("User specified module debug level of %d\n", |
| 2616 | qdf_dbg_mask); |
| 2617 | for (i = 0; i < MAX_SUPPORTED_CATEGORY; i++) { |
| 2618 | cinfo[i].category_verbose_mask = |
| 2619 | set_cumulative_verbose_mask(qdf_dbg_mask); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2620 | } |
Adil Saeed Musthafa | 2ef2787 | 2017-05-02 16:40:45 -0700 | [diff] [blame] | 2621 | } else { |
| 2622 | pr_info("qdf_dbg_mask value is invalid\n"); |
| 2623 | pr_info("Using the default module debug levels instead\n"); |
| 2624 | } |
| 2625 | |
| 2626 | /* |
| 2627 | * Module ID-Level specified as array during module load |
| 2628 | */ |
| 2629 | for (i = 0; i < qdf_dbg_arr_cnt; i++) { |
| 2630 | process_qdf_dbg_arr_param(cinfo, i); |
Adil Saeed Musthafa | 3318807 | 2017-03-13 12:13:47 -0700 | [diff] [blame] | 2631 | } |
| 2632 | qdf_pidx = qdf_print_ctrl_register(cinfo, NULL, NULL, |
| 2633 | "LOG_SHARED_OBJ"); |
| 2634 | qdf_mem_free(cinfo); |
| 2635 | } |
| 2636 | EXPORT_SYMBOL(qdf_shared_print_ctrl_init); |
| 2637 | #endif |
| 2638 | |
Sathish Kumar | fc93b2d | 2017-01-10 12:19:19 +0530 | [diff] [blame] | 2639 | QDF_STATUS qdf_print_set_category_verbose(unsigned int idx, |
| 2640 | QDF_MODULE_ID category, |
| 2641 | QDF_TRACE_LEVEL verbose, |
| 2642 | bool is_set) |
| 2643 | { |
| 2644 | /* Check if index passed is valid */ |
| 2645 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2646 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2647 | return QDF_STATUS_E_FAILURE; |
| 2648 | } |
| 2649 | |
| 2650 | /* Check if print control object is in use */ |
| 2651 | if (!print_ctrl_obj[idx].in_use) { |
| 2652 | pr_info("%s: Invalid print control object\n", __func__); |
| 2653 | return QDF_STATUS_E_FAILURE; |
| 2654 | } |
| 2655 | |
| 2656 | /* Check if category passed is valid */ |
| 2657 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 2658 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 2659 | return QDF_STATUS_E_FAILURE; |
| 2660 | } |
| 2661 | |
| 2662 | /* Check if verbose mask is valid */ |
| 2663 | if (verbose < 0 || verbose >= QDF_TRACE_LEVEL_MAX) { |
| 2664 | pr_info("%s: Invalid verbose level %d\n", __func__, verbose); |
| 2665 | return QDF_STATUS_E_FAILURE; |
| 2666 | } |
| 2667 | |
| 2668 | if (verbose == QDF_TRACE_LEVEL_ALL) { |
| 2669 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask = |
| 2670 | 0xFFFF; |
| 2671 | return QDF_STATUS_SUCCESS; |
| 2672 | } |
| 2673 | |
| 2674 | if (verbose == QDF_TRACE_LEVEL_NONE) { |
| 2675 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask = |
| 2676 | QDF_TRACE_LEVEL_NONE; |
| 2677 | return QDF_STATUS_SUCCESS; |
| 2678 | } |
| 2679 | |
| 2680 | if (!is_set) { |
| 2681 | if (print_ctrl_obj[idx].cat_info[category].category_verbose_mask |
| 2682 | & QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) { |
| 2683 | print_ctrl_obj[idx].cat_info[category] |
| 2684 | .category_verbose_mask &= |
| 2685 | ~QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose); |
| 2686 | } |
| 2687 | } else { |
| 2688 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask |= |
| 2689 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose); |
| 2690 | } |
| 2691 | |
| 2692 | pr_info("%s: Print control object %d, Category %d, Verbose level %d\n", |
| 2693 | __func__, |
| 2694 | idx, |
| 2695 | category, |
| 2696 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask); |
| 2697 | |
| 2698 | return QDF_STATUS_SUCCESS; |
| 2699 | } |
| 2700 | EXPORT_SYMBOL(qdf_print_set_category_verbose); |
| 2701 | |
| 2702 | bool qdf_print_is_category_enabled(unsigned int idx, QDF_MODULE_ID category) |
| 2703 | { |
| 2704 | QDF_TRACE_LEVEL verbose_mask; |
| 2705 | |
| 2706 | /* Check if index passed is valid */ |
| 2707 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2708 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2709 | return false; |
| 2710 | } |
| 2711 | |
| 2712 | /* Check if print control object is in use */ |
| 2713 | if (!print_ctrl_obj[idx].in_use) { |
| 2714 | pr_info("%s: Invalid print control object\n", __func__); |
| 2715 | return false; |
| 2716 | } |
| 2717 | |
| 2718 | /* Check if category passed is valid */ |
| 2719 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 2720 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 2721 | return false; |
| 2722 | } |
| 2723 | |
| 2724 | verbose_mask = |
| 2725 | print_ctrl_obj[idx].cat_info[category].category_verbose_mask; |
| 2726 | |
| 2727 | if (verbose_mask == QDF_TRACE_LEVEL_NONE) |
| 2728 | return false; |
| 2729 | else |
| 2730 | return true; |
| 2731 | } |
| 2732 | EXPORT_SYMBOL(qdf_print_is_category_enabled); |
| 2733 | |
| 2734 | bool qdf_print_is_verbose_enabled(unsigned int idx, QDF_MODULE_ID category, |
| 2735 | QDF_TRACE_LEVEL verbose) |
| 2736 | { |
| 2737 | bool verbose_enabled = false; |
| 2738 | |
| 2739 | /* Check if index passed is valid */ |
| 2740 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2741 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2742 | return verbose_enabled; |
| 2743 | } |
| 2744 | |
| 2745 | /* Check if print control object is in use */ |
| 2746 | if (!print_ctrl_obj[idx].in_use) { |
| 2747 | pr_info("%s: Invalid print control object\n", __func__); |
| 2748 | return verbose_enabled; |
| 2749 | } |
| 2750 | |
| 2751 | /* Check if category passed is valid */ |
| 2752 | if (category < 0 || category >= MAX_SUPPORTED_CATEGORY) { |
| 2753 | pr_info("%s: Invalid category: %d\n", __func__, category); |
| 2754 | return verbose_enabled; |
| 2755 | } |
| 2756 | |
| 2757 | if ((verbose == QDF_TRACE_LEVEL_NONE) || |
| 2758 | (verbose >= QDF_TRACE_LEVEL_MAX)) { |
| 2759 | verbose_enabled = false; |
| 2760 | } else if (verbose == QDF_TRACE_LEVEL_ALL) { |
| 2761 | if (print_ctrl_obj[idx].cat_info[category] |
| 2762 | .category_verbose_mask == 0xFFFF) |
| 2763 | verbose_enabled = true; |
| 2764 | } else { |
| 2765 | verbose_enabled = |
| 2766 | (print_ctrl_obj[idx].cat_info[category].category_verbose_mask & |
| 2767 | QDF_TRACE_LEVEL_TO_MODULE_BITMASK(verbose)) ? true : false; |
| 2768 | } |
| 2769 | |
| 2770 | return verbose_enabled; |
| 2771 | } |
| 2772 | EXPORT_SYMBOL(qdf_print_is_verbose_enabled); |
| 2773 | |
| 2774 | #ifdef DBG_LVL_MAC_FILTERING |
| 2775 | |
| 2776 | QDF_STATUS qdf_print_set_node_flag(unsigned int idx, uint8_t enable) |
| 2777 | { |
| 2778 | /* Check if index passed is valid */ |
| 2779 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2780 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2781 | return QDF_STATUS_E_FAILURE; |
| 2782 | } |
| 2783 | |
| 2784 | /* Check if print control object is in use */ |
| 2785 | if (!print_ctrl_obj[idx].in_use) { |
| 2786 | pr_info("%s: Invalid print control object\n", __func__); |
| 2787 | return QDF_STATUS_E_FAILURE; |
| 2788 | } |
| 2789 | |
| 2790 | if (enable > 1) { |
| 2791 | pr_info("%s: Incorrect input: Use 1 or 0 to enable or disable\n", |
| 2792 | __func__); |
| 2793 | return QDF_STATUS_E_FAILURE; |
| 2794 | } |
| 2795 | |
| 2796 | print_ctrl_obj[idx].dbglvlmac_on = enable; |
| 2797 | pr_info("%s: DbgLVLmac feature %s\n", |
| 2798 | __func__, |
| 2799 | ((enable) ? "enabled" : "disabled")); |
| 2800 | |
| 2801 | return QDF_STATUS_SUCCESS; |
| 2802 | } |
| 2803 | EXPORT_SYMBOL(qdf_print_set_node_flag); |
| 2804 | |
| 2805 | bool qdf_print_get_node_flag(unsigned int idx) |
| 2806 | { |
| 2807 | bool node_flag = false; |
| 2808 | |
| 2809 | /* Check if index passed is valid */ |
| 2810 | if (idx < 0 || idx >= MAX_PRINT_CONFIG_SUPPORTED) { |
| 2811 | pr_info("%s: Invalid index - %d\n", __func__, idx); |
| 2812 | return node_flag; |
| 2813 | } |
| 2814 | |
| 2815 | /* Check if print control object is in use */ |
| 2816 | if (!print_ctrl_obj[idx].in_use) { |
| 2817 | pr_info("%s: Invalid print control object\n", __func__); |
| 2818 | return node_flag; |
| 2819 | } |
| 2820 | |
| 2821 | if (print_ctrl_obj[idx].dbglvlmac_on) |
| 2822 | node_flag = true; |
| 2823 | |
| 2824 | return node_flag; |
| 2825 | } |
| 2826 | EXPORT_SYMBOL(qdf_print_get_node_flag); |
| 2827 | |
| 2828 | void qdf_print_clean_node_flag(unsigned int idx) |
| 2829 | { |
| 2830 | /* Disable dbglvlmac_on during cleanup */ |
| 2831 | print_ctrl_obj[idx].dbglvlmac_on = 0; |
| 2832 | } |
| 2833 | |
| 2834 | #else |
| 2835 | |
| 2836 | void qdf_print_clean_node_flag(unsigned int idx) |
| 2837 | { |
| 2838 | /* No operation in case of no support for DBG_LVL_MAC_FILTERING */ |
| 2839 | return; |
| 2840 | } |
| 2841 | #endif |
| 2842 | |
Sathish Kumar | 59113a4 | 2017-01-04 12:02:24 +0530 | [diff] [blame] | 2843 | void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module, |
| 2844 | QDF_TRACE_LEVEL level, |
| 2845 | char *str_format, ...) |
| 2846 | { |
| 2847 | va_list args; |
| 2848 | |
| 2849 | /* Generic wrapper API will compile qdf_vprint in order to |
| 2850 | * log the message. Once QDF converged debug framework is in |
| 2851 | * place, this will be changed to adapt to the framework, compiling |
| 2852 | * call to converged tracing API |
| 2853 | */ |
| 2854 | va_start(args, str_format); |
| 2855 | qdf_vprint(str_format, args); |
| 2856 | va_end(args); |
| 2857 | } |
| 2858 | EXPORT_SYMBOL(QDF_PRINT_INFO); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 2859 | |
| 2860 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 2861 | void qdf_logging_init(void) |
| 2862 | { |
| 2863 | wlan_logging_sock_init_svc(); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 2864 | nl_srv_init(NULL); |
| 2865 | } |
| 2866 | |
| 2867 | void qdf_logging_exit(void) |
| 2868 | { |
| 2869 | nl_srv_exit(); |
Adil Saeed Musthafa | bcf62ed | 2017-02-20 16:22:39 -0800 | [diff] [blame] | 2870 | wlan_logging_sock_deinit_svc(); |
| 2871 | } |
| 2872 | #else |
| 2873 | void qdf_logging_init(void) |
| 2874 | { |
| 2875 | } |
| 2876 | |
| 2877 | void qdf_logging_exit(void) |
| 2878 | { |
| 2879 | } |
| 2880 | #endif |
| 2881 | |
Dustin Brown | e226ceb | 2017-04-21 13:22:14 -0700 | [diff] [blame] | 2882 | #ifdef CONFIG_KALLSYMS |
| 2883 | inline int qdf_sprint_symbol(char *buffer, void *addr) |
| 2884 | { |
| 2885 | return sprint_symbol(buffer, (unsigned long)addr); |
| 2886 | } |
| 2887 | #else |
| 2888 | int qdf_sprint_symbol(char *buffer, void *addr) |
| 2889 | { |
| 2890 | if (!buffer) |
| 2891 | return 0; |
| 2892 | |
| 2893 | buffer[0] = '\0'; |
| 2894 | return 1; |
| 2895 | } |
| 2896 | #endif |
Dustin Brown | dd16c1b | 2017-04-27 15:34:39 -0700 | [diff] [blame] | 2897 | EXPORT_SYMBOL(qdf_sprint_symbol); |
Sathish Kumar | 470c620 | 2017-05-10 19:56:48 +0530 | [diff] [blame] | 2898 | |
| 2899 | void qdf_set_pidx(int pidx) |
| 2900 | { |
| 2901 | qdf_pidx = pidx; |
| 2902 | } |
| 2903 | EXPORT_SYMBOL(qdf_set_pidx); |
| 2904 | |
| 2905 | int qdf_get_pidx(void) |
| 2906 | { |
| 2907 | return qdf_pidx; |
| 2908 | } |
| 2909 | EXPORT_SYMBOL(qdf_get_pidx); |