1 /* 2 * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #if !defined(__QDF_TRACE_H) 20 #define __QDF_TRACE_H 21 22 /** 23 * DOC: qdf_trace 24 * QCA driver framework trace APIs 25 * Trace, logging, and debugging definitions and APIs 26 */ 27 28 /* Include Files */ 29 #include <qdf_types.h> /* For QDF_MODULE_ID... */ 30 #include <stdarg.h> /* For va_list... */ 31 #include <qdf_status.h> 32 #include <qdf_nbuf.h> 33 #include <i_qdf_types.h> 34 #include <qdf_debugfs.h> 35 36 37 /* Type declarations */ 38 39 #ifdef LOG_LINE_NUMBER 40 #define FL(x) "%s: %d: " x, __func__, __LINE__ 41 #else 42 #define FL(x) "%s: " x, __func__ 43 #endif 44 45 #define QDF_TRACE_BUFFER_SIZE (512) 46 47 /* 48 * Extracts the 8-bit group id from the wmi command id by performing the 49 * reverse operation of WMI_CMD_GRP_START_ID 50 */ 51 #define QDF_WMI_MTRACE_GRP_ID(message_id) (((message_id) >> 12) & 0xFF) 52 /* 53 * Number of bits reserved for WMI mtrace command id 54 */ 55 #define QDF_WMI_MTRACE_CMD_NUM_BITS 7 56 /* 57 * Extracts the 7-bit group specific command id from the wmi command id 58 */ 59 #define QDF_WMI_MTRACE_CMD_ID(message_id) ((message_id) & 0x7F) 60 61 #ifdef QDF_TRACE_PRINT_ENABLE 62 #define QDF_DEFAULT_TRACE_LEVEL (1 << QDF_TRACE_LEVEL_INFO) 63 #endif 64 65 #define QDF_CATEGORY_INFO_U16(val) (((val >> 16) & 0x0000FFFF)) 66 #define QDF_TRACE_LEVEL_INFO_L16(val) (val & 0x0000FFFF) 67 68 typedef int (qdf_abstract_print)(void *priv, const char *fmt, ...); 69 70 /* 71 * Log levels 72 */ 73 #define QDF_DEBUG_FUNCTRACE 0x01 74 #define QDF_DEBUG_LEVEL0 0x02 75 #define QDF_DEBUG_LEVEL1 0x04 76 #define QDF_DEBUG_LEVEL2 0x08 77 #define QDF_DEBUG_LEVEL3 0x10 78 #define QDF_DEBUG_ERROR 0x20 79 #define QDF_DEBUG_CFG 0x40 80 81 /* 82 * Rate limit based on pkt prototype 83 */ 84 #define QDF_MAX_DHCP_PKTS_PER_SEC (20) 85 #define QDF_MAX_EAPOL_PKTS_PER_SEC (50) 86 #define QDF_MAX_ARP_PKTS_PER_SEC (5) 87 #define QDF_MAX_DNS_PKTS_PER_SEC (5) 88 #define QDF_MAX_OTHER_PKTS_PER_SEC (1) 89 90 /* DP Trace Implementation */ 91 #ifdef CONFIG_DP_TRACE 92 #define DPTRACE(p) p 93 #define DPTRACE_PRINT(args...) \ 94 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG, args) 95 #else 96 #define DPTRACE(p) 97 #define DPTRACE_PRINT(args...) 98 #endif 99 100 /* By default Data Path module will have all log levels enabled, except debug 101 * log level. Debug level will be left up to the framework or user space modules 102 * to be enabled when issue is detected 103 */ 104 #define QDF_DATA_PATH_TRACE_LEVEL \ 105 ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \ 106 (1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \ 107 (1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \ 108 (1 << QDF_TRACE_LEVEL_INFO_LOW)) 109 110 /* Preprocessor definitions and constants */ 111 #define ASSERT_BUFFER_SIZE (512) 112 113 #ifndef MAX_QDF_TRACE_RECORDS 114 #define MAX_QDF_TRACE_RECORDS 4000 115 #endif 116 117 #define QDF_TRACE_DEFAULT_PDEV_ID 0xff 118 #define INVALID_QDF_TRACE_ADDR 0xffffffff 119 #define DEFAULT_QDF_TRACE_DUMP_COUNT 0 120 #define QDF_TRACE_DEFAULT_MSDU_ID 0 121 122 /* 123 * first parameter to iwpriv command - dump_dp_trace 124 * iwpriv wlan0 dump_dp_trace 0 0 -> dump full buffer 125 * iwpriv wlan0 dump_dp_trace 1 0 -> enable live view mode 126 * iwpriv wlan0 dump_dp_trace 2 0 -> clear dp trace buffer 127 * iwpriv wlan0 dump_dp_trace 3 0 -> disable live view mode 128 */ 129 #define DUMP_DP_TRACE 0 130 #define ENABLE_DP_TRACE_LIVE_MODE 1 131 #define CLEAR_DP_TRACE_BUFFER 2 132 #define DISABLE_DP_TRACE_LIVE_MODE 3 133 134 135 #ifdef TRACE_RECORD 136 137 #define MTRACE(p) p 138 139 #else 140 #define MTRACE(p) do { } while (0) 141 142 #endif 143 #define NO_SESSION 0xFF 144 145 /** 146 * typedef struct qdf_trace_record_s - keep trace record 147 * @qtime: qtimer ticks 148 * @time: user timestamp 149 * @module: module name 150 * @code: hold record of code 151 * @session: hold record of session 152 * @data: hold data 153 * @pid: hold pid of the process 154 */ 155 typedef struct qdf_trace_record_s { 156 uint64_t qtime; 157 char time[18]; 158 uint8_t module; 159 uint16_t code; 160 uint16_t session; 161 uint32_t data; 162 uint32_t pid; 163 } qdf_trace_record_t, *tp_qdf_trace_record; 164 165 /** 166 * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer 167 * @head: position of first record 168 * @tail: position of last record 169 * @num: count of total record 170 * @num_since_last_dump: count from last dump 171 * @enable: config for controlling the trace 172 * @dump_count: Dump after number of records reach this number 173 */ 174 typedef struct s_qdf_trace_data { 175 uint32_t head; 176 uint32_t tail; 177 uint32_t num; 178 uint16_t num_since_last_dump; 179 uint8_t enable; 180 uint16_t dump_count; 181 } t_qdf_trace_data; 182 183 #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str); 184 185 #ifndef MAX_QDF_DP_TRACE_RECORDS 186 #define MAX_QDF_DP_TRACE_RECORDS 2000 187 #endif 188 189 #define QDF_DP_TRACE_RECORD_SIZE 40 190 #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff 191 #define QDF_DP_TRACE_VERBOSITY_HIGH 4 192 #define QDF_DP_TRACE_VERBOSITY_MEDIUM 3 193 #define QDF_DP_TRACE_VERBOSITY_LOW 2 194 #define QDF_DP_TRACE_VERBOSITY_ULTRA_LOW 1 195 #define QDF_DP_TRACE_VERBOSITY_BASE 0 196 197 /** 198 * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path 199 * @QDF_DP_TRACE_INVALID - invalid 200 * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet 201 * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet 202 * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet 203 * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet 204 * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt 205 * @QDF_DP_TRACE_EVENT_RECORD - record events 206 * @QDF_DP_TRACE_BASE_VERBOSITY - below this are part of base verbosity 207 * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packet 208 * @QDF_DP_TRACE_ICMPv6_PACKET_RECORD - record ICMPv6 packet 209 * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout 210 * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout 211 * @QDF_DP_TRACE_TX_CREDIT_RECORD - credit update record 212 * @QDF_DP_TRACE_ULTRA_LOW_VERBOSITY - Below this is not logged for >4PPS 213 * @QDF_DP_TRACE_TX_PACKET_RECORD - record 32 bytes of tx pkt at any layer 214 * @QDF_DP_TRACE_RX_PACKET_RECORD - record 32 bytes of rx pkt at any layer 215 * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD 216 * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD 217 * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record data bytes of tx pkt at LI_DP 218 * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record data bytes of rx pkt at LI_DP 219 * @QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD - tx completion ptr record for 220 * lithium 221 * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record 222 * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity 223 * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record 224 * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record 225 * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record 226 * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record 227 * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record 228 * @QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD- CE fastpath error record 229 * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record 230 * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record 231 * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record 232 * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity 233 * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record 234 * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record 235 * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record 236 * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record 237 * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record 238 * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record 239 * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record 240 * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD 241 * - record data bytes of rx null_queue pkt at LI_DP 242 * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity 243 */ 244 245 enum QDF_DP_TRACE_ID { 246 QDF_DP_TRACE_INVALID, 247 QDF_DP_TRACE_DROP_PACKET_RECORD, 248 QDF_DP_TRACE_EAPOL_PACKET_RECORD, 249 QDF_DP_TRACE_DHCP_PACKET_RECORD, 250 QDF_DP_TRACE_ARP_PACKET_RECORD, 251 QDF_DP_TRACE_MGMT_PACKET_RECORD, 252 QDF_DP_TRACE_EVENT_RECORD, 253 QDF_DP_TRACE_BASE_VERBOSITY, 254 QDF_DP_TRACE_ICMP_PACKET_RECORD, 255 QDF_DP_TRACE_ICMPv6_PACKET_RECORD, 256 QDF_DP_TRACE_HDD_TX_TIMEOUT, 257 QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT, 258 QDF_DP_TRACE_TX_CREDIT_RECORD, 259 QDF_DP_TRACE_ULTRA_LOW_VERBOSITY, 260 QDF_DP_TRACE_TX_PACKET_RECORD, 261 QDF_DP_TRACE_RX_PACKET_RECORD, 262 QDF_DP_TRACE_HDD_TX_PACKET_RECORD, 263 QDF_DP_TRACE_HDD_RX_PACKET_RECORD, 264 QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD, 265 QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD, 266 QDF_DP_TRACE_LI_DP_FREE_PACKET_PTR_RECORD, 267 QDF_DP_TRACE_FREE_PACKET_PTR_RECORD, 268 QDF_DP_TRACE_LOW_VERBOSITY, 269 QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD, 270 QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD, 271 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD, 272 QDF_DP_TRACE_CE_PACKET_PTR_RECORD, 273 QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD, 274 QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD, 275 QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD, 276 QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD, 277 QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD, 278 QDF_DP_TRACE_MED_VERBOSITY, 279 QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD, 280 QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD, 281 QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD, 282 QDF_DP_TRACE_HTT_PACKET_PTR_RECORD, 283 QDF_DP_TRACE_HTC_PACKET_PTR_RECORD, 284 QDF_DP_TRACE_HIF_PACKET_PTR_RECORD, 285 QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD, 286 QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD, 287 QDF_DP_TRACE_HIGH_VERBOSITY, 288 QDF_DP_TRACE_MAX 289 }; 290 291 /** 292 * qdf_proto_dir - direction 293 * @QDF_TX: TX direction 294 * @QDF_RX: RX direction 295 * @QDF_NA: not applicable 296 */ 297 enum qdf_proto_dir { 298 QDF_TX, 299 QDF_RX, 300 QDF_NA 301 }; 302 303 /** 304 * QDF_CREDIT_UPDATE_SOURCE - source of credit record 305 * @QDF_TX_SCHED: Tx scheduler 306 * @QDF_TX_COMP: TX completion 307 * @QDF_TX_CREDIT_UPDATE: credit update indication 308 * @QDF_HTT_ATTACH: HTT attach 309 * @QDF_TX_HTT_MSG: HTT TX message 310 */ 311 enum QDF_CREDIT_UPDATE_SOURCE { 312 QDF_TX_SCHED, 313 QDF_TX_COMP, 314 QDF_TX_CREDIT_UPDATE, 315 QDF_HTT_ATTACH, 316 QDF_TX_HTT_MSG 317 }; 318 319 /** 320 * QDF_CREDIT_OPERATION - operation on credit 321 * @QDF_CREDIT_INC: credit increment 322 * @QDF_CREDIT_DEC: credit decrement 323 * @QDF_CREDIT_ABS: Abosolute credit 324 * @QDF_OP_NA: Not applicable 325 */ 326 enum QDF_CREDIT_OPERATION { 327 QDF_CREDIT_INC, 328 QDF_CREDIT_DEC, 329 QDF_CREDIT_ABS, 330 QDF_OP_NA 331 }; 332 333 /** 334 * struct qdf_dp_trace_ptr_buf - pointer record buffer 335 * @cookie: cookie value 336 * @msdu_id: msdu_id 337 * @status: completion status 338 */ 339 struct qdf_dp_trace_ptr_buf { 340 uint64_t cookie; 341 uint16_t msdu_id; 342 uint16_t status; 343 }; 344 345 /** 346 * struct qdf_dp_trace_proto_buf - proto packet buffer 347 * @sa: source address 348 * @da: destination address 349 * @vdev_id : vdev id 350 * @type: packet type 351 * @subtype: packet subtype 352 * @dir: direction 353 */ 354 struct qdf_dp_trace_proto_buf { 355 struct qdf_mac_addr sa; 356 struct qdf_mac_addr da; 357 uint8_t vdev_id; 358 uint8_t type; 359 uint8_t subtype; 360 uint8_t dir; 361 }; 362 363 /** 364 * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer 365 * @vdev_id : vdev id 366 * @type: packet type 367 * @subtype: packet subtype 368 */ 369 struct qdf_dp_trace_mgmt_buf { 370 uint8_t vdev_id; 371 uint8_t type; 372 uint8_t subtype; 373 }; 374 375 /** 376 * struct qdf_dp_trace_credit_record - tx credit record 377 * @source: credit record source 378 * @operation: credit operation 379 * @delta: delta of credit 380 * @total_credits: total credit 381 * @g0_credit: group 0 credit 382 * @g1_credit: group 1 credit 383 */ 384 struct qdf_dp_trace_credit_record { 385 enum QDF_CREDIT_UPDATE_SOURCE source; 386 enum QDF_CREDIT_OPERATION operation; 387 int delta; 388 int total_credits; 389 int g0_credit; 390 int g1_credit; 391 }; 392 393 /** 394 * struct qdf_dp_trace_event_buf - event buffer 395 * @vdev_id : vdev id 396 * @type: packet type 397 * @subtype: packet subtype 398 */ 399 struct qdf_dp_trace_event_buf { 400 uint8_t vdev_id; 401 uint8_t type; 402 uint8_t subtype; 403 }; 404 405 /** 406 * struct qdf_dp_trace_data_buf - nbuf data buffer 407 * @msdu_id : msdu id 408 */ 409 struct qdf_dp_trace_data_buf { 410 uint16_t msdu_id; 411 }; 412 413 /** 414 * struct qdf_dp_trace_record_s - Describes a record in DP trace 415 * @time: time when it got stored 416 * @code: Describes the particular event 417 * @data: buffer to store data 418 * @size: Length of the valid data stored in this record 419 * @pid : process id which stored the data in this record 420 */ 421 struct qdf_dp_trace_record_s { 422 uint64_t time; 423 uint8_t code; 424 uint8_t data[QDF_DP_TRACE_RECORD_SIZE]; 425 uint8_t size; 426 uint32_t pid; 427 uint8_t pdev_id; 428 }; 429 430 /** 431 * struct qdf_dp_trace_data - Parameters to configure/control DP trace 432 * @head: Position of first record 433 * @tail: Position of last record 434 * @num: Current index 435 * @proto_bitmap: defines which protocol to be traced 436 * @no_of_record: defines every nth packet to be traced 437 * @num_records_to_dump: defines number of records to be dumped 438 * @dump_counter: counter to track number of records dumped 439 * @verbosity : defines verbosity level 440 * @ini_conf_verbosity: Configured verbosity from INI 441 * @enable: enable/disable DP trace 442 * @count: current packet number 443 * @live_mode_config: configuration as received during initialization 444 * @live_mode: current live mode, enabled or disabled, can be throttled based 445 * on throughput 446 * @force_live_mode: flag to enable live mode all the time for all packets. 447 * This can be set/unset from userspace and overrides other 448 * live mode flags. 449 * @dynamic_verbosity_modify: Dynamic user configured verbosity overrides all 450 * @print_pkt_cnt: count of number of packets printed in live mode 451 * @high_tput_thresh: thresh beyond which live mode is turned off 452 * @thresh_time_limit: max time, in terms of BW timer intervals to wait, 453 * for determining if high_tput_thresh has been crossed. ~1s 454 * @arp_req: stats for arp reqs 455 * @arp_resp: stats for arp resps 456 * @icmp_req: stats for icmp reqs 457 * @icmp_resp: stats for icmp resps 458 * @dhcp_disc: stats for dhcp discover msgs 459 * @dhcp_req: stats for dhcp req msgs 460 * @dhcp_off: stats for dhcp offer msgs 461 * @dhcp_ack: stats for dhcp ack msgs 462 * @dhcp_nack: stats for dhcp nack msgs 463 * @dhcp_others: stats for other dhcp pkts types 464 * @eapol_m1: stats for eapol m1 465 * @eapol_m2: stats for eapol m2 466 * @eapol_m3: stats for eapol m3 467 * @eapol_m4: stats for eapol m4 468 * @eapol_others: stats for other eapol pkt types 469 * @icmpv6_req: stats for icmpv6 reqs 470 * @icmpv6_resp: stats for icmpv6 resps 471 * @icmpv6_ns: stats for icmpv6 nss 472 * @icmpv6_na: stats for icmpv6 nas 473 * @icmpv6_rs: stats for icmpv6 rss 474 * @icmpv6_ra: stats for icmpv6 ras 475 * @proto_event_bitmap: defines which protocol to be diag logged. 476 * refer QDF_NBUF_PKT_TRAC_TYPE_DNS to QDF_NBUF_PKT_TRAC_TYPE_ARP 477 * for bitmap. 478 */ 479 struct s_qdf_dp_trace_data { 480 uint32_t head; 481 uint32_t tail; 482 uint32_t num; 483 uint32_t proto_bitmap; 484 uint8_t no_of_record; 485 uint16_t num_records_to_dump; 486 uint16_t dump_counter; 487 uint8_t verbosity; 488 uint8_t ini_conf_verbosity; 489 bool enable; 490 bool live_mode_config; 491 bool live_mode; 492 uint32_t curr_pos; 493 uint32_t saved_tail; 494 bool force_live_mode; 495 bool dynamic_verbosity_modify; 496 uint8_t print_pkt_cnt; 497 uint8_t high_tput_thresh; 498 uint16_t thresh_time_limit; 499 /* Stats */ 500 uint32_t tx_count; 501 uint32_t rx_count; 502 u16 arp_req; 503 u16 arp_resp; 504 u16 dhcp_disc; 505 u16 dhcp_req; 506 u16 dhcp_off; 507 u16 dhcp_ack; 508 u16 dhcp_nack; 509 u16 dhcp_others; 510 u16 eapol_m1; 511 u16 eapol_m2; 512 u16 eapol_m3; 513 u16 eapol_m4; 514 u16 eapol_others; 515 u16 icmp_req; 516 u16 icmp_resp; 517 u16 icmpv6_req; 518 u16 icmpv6_resp; 519 u16 icmpv6_ns; 520 u16 icmpv6_na; 521 u16 icmpv6_rs; 522 u16 icmpv6_ra; 523 uint32_t proto_event_bitmap; 524 }; 525 526 /** 527 * struct qdf_dpt_debugfs_state - state to control read to debugfs file 528 * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID: invalid state 529 * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT: initial state 530 * @QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS: read is in progress 531 * @QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE: read complete 532 */ 533 534 enum qdf_dpt_debugfs_state { 535 QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID, 536 QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT, 537 QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS, 538 QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE, 539 }; 540 541 typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t); 542 typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size); 543 #ifdef WLAN_FEATURE_MEMDUMP_ENABLE 544 void qdf_register_debugcb_init(void); 545 void qdf_register_debug_callback(QDF_MODULE_ID module_id, 546 tp_qdf_state_info_cb qdf_state_infocb); 547 QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size, 548 uint16_t *driver_dump_size); 549 #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ 550 static inline void qdf_register_debugcb_init(void) 551 { 552 } 553 #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ 554 555 #ifdef TRACE_RECORD 556 void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb); 557 void qdf_trace_init(void); 558 void qdf_trace_deinit(void); 559 void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data); 560 void qdf_trace_enable(uint32_t, uint8_t enable); 561 void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t); 562 QDF_STATUS qdf_trace_spin_lock_init(void); 563 #else 564 #ifndef QDF_TRACE_PRINT_ENABLE 565 static inline 566 void qdf_trace_init(void) 567 { 568 } 569 570 static inline 571 void qdf_trace_deinit(void) 572 { 573 } 574 575 static inline 576 void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable) 577 { 578 } 579 580 static inline 581 void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data) 582 { 583 } 584 585 static inline 586 void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session, 587 uint32_t count, uint32_t bitmask_of_module) 588 { 589 } 590 591 static inline 592 QDF_STATUS qdf_trace_spin_lock_init(void) 593 { 594 return QDF_STATUS_SUCCESS; 595 } 596 #endif 597 #endif 598 599 #ifdef WLAN_MAX_LOGS_PER_SEC 600 /** 601 * qdf_detected_excessive_logging() - Excessive logging detected 602 * 603 * Track logging count using a quasi-tumbling window. 604 * If the max logging count for a given window is exceeded, 605 * return true else fails. 606 * 607 * Return: true/false 608 */ 609 bool qdf_detected_excessive_logging(void); 610 611 /** 612 * qdf_rl_print_count_set() - set the ratelimiting print count 613 * @rl_print_time: ratelimiting print count 614 * 615 * Return: none 616 */ 617 void qdf_rl_print_count_set(uint32_t rl_print_count); 618 619 /** 620 * qdf_rl_print_time_set() - set the ratelimiting print time 621 * @rl_print_time: ratelimiting print time 622 * 623 * Return: none 624 */ 625 void qdf_rl_print_time_set(uint32_t rl_print_time); 626 627 #else /* WLAN_MAX_LOGS_PER_SEC */ 628 static inline bool qdf_detected_excessive_logging(void) 629 { 630 return false; 631 } 632 static inline void qdf_rl_print_count_set(uint32_t rl_print_count) {} 633 static inline void qdf_rl_print_time_set(uint32_t rl_print_time) {} 634 #endif /* WLAN_MAX_LOGS_PER_SEC */ 635 636 #ifdef ENABLE_MTRACE_LOG 637 /** 638 * qdf_mtrace_log() - Logs a message tracepoint to DIAG 639 * Infrastructure. 640 * @src_module: Enum of source module (basically module id) 641 * from where the message with message_id is posted. 642 * @dst_module: Enum of destination module (basically module id) 643 * to which the message with message_id is posted. 644 * @message_id: Id of the message to be posted 645 * @vdev_id: Vdev Id 646 * 647 * This function logs to the DIAG Infrastructure a tracepoint for a 648 * message being sent from a source module to a destination module 649 * with a specific ID for the benefit of a specific vdev. 650 * For non-vdev messages vdev_id will be NO_SESSION 651 * Return: None 652 */ 653 void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 654 uint16_t message_id, uint8_t vdev_id); 655 #else 656 static inline 657 void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 658 uint16_t message_id, uint8_t vdev_id) 659 { 660 } 661 #endif 662 663 #ifdef TRACE_RECORD 664 /** 665 * qdf_mtrace() - puts the messages in to ring-buffer 666 * and logs a message tracepoint to DIAG Infrastructure. 667 * @src_module: Enum of source module (basically module id) 668 * from where the message with message_id is posted. 669 * @dst_module: Enum of destination module (basically module id) 670 * to which the message with message_id is posted. 671 * @message_id: Id of the message to be posted 672 * @vdev_id: Vdev Id 673 * @data: Actual message contents 674 * 675 * This function will be called from each module which wants to record the 676 * messages in circular queue. Before calling this function make sure you 677 * have registered your module with qdf through qdf_trace_register function. 678 * In addition of the recording the messages in circular queue this function 679 * will log the message tracepoint to the DIAG infrastructure. 680 * these logs will be later used by post processing script. 681 * 682 * Return: None 683 */ 684 void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 685 uint16_t message_id, uint8_t vdev_id, uint32_t data); 686 #else 687 static inline 688 void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 689 uint16_t message_id, uint8_t vdev_id, uint32_t data) 690 { 691 } 692 #endif 693 694 #ifdef CONFIG_DP_TRACE 695 void qdf_dp_set_proto_bitmap(uint32_t val); 696 void qdf_dp_trace_set_verbosity(uint32_t val); 697 void qdf_dp_set_no_of_record(uint32_t val); 698 #define QDF_DP_TRACE_RECORD_INFO_LIVE (0x1) 699 #define QDF_DP_TRACE_RECORD_INFO_THROTTLED (0x1 << 1) 700 701 /** 702 * qdf_dp_trace_log_pkt() - log packet type enabled through iwpriv 703 * @vdev_id: vdev_id 704 * @skb: skb pointer 705 * @dir: direction 706 * @pdev_id: pdev_id 707 * 708 * Return: true: some protocol was logged, false: no protocol was logged. 709 */ 710 bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb, 711 enum qdf_proto_dir dir, uint8_t pdev_id); 712 713 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 714 uint16_t time_limit, uint8_t verbosity, 715 uint32_t proto_bitmap); 716 void qdf_dp_trace_deinit(void); 717 void qdf_dp_trace_spin_lock_init(void); 718 void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records, 719 uint8_t verbosity); 720 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir); 721 void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id, 722 uint8_t *data, uint8_t size, enum qdf_proto_dir dir); 723 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id); 724 725 /** 726 * qdf_dpt_get_curr_pos_debugfs() - get curr position to start read 727 * @file: debugfs file to read 728 * @state: state to control read to debugfs file 729 * 730 * Return: curr pos 731 */ 732 uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file, 733 enum qdf_dpt_debugfs_state state); 734 /** 735 * qdf_dpt_dump_stats_debugfs() - dump DP Trace stats to debugfs file 736 * @file: debugfs file to read 737 * @curr_pos: curr position to start read 738 * 739 * Return: QDF_STATUS 740 */ 741 QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file, 742 uint32_t curr_pos); 743 744 /** 745 * qdf_dpt_set_value_debugfs() - set value of DP Trace debugfs params 746 * @proto_bitmap: defines which protocol to be traced 747 * @no_of_record: defines every nth packet to be traced 748 * @verbosity : defines verbosity level 749 * @num_records_to_dump: defines number of records to be dumped 750 * 751 * Return: none 752 */ 753 void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record, 754 uint8_t verbosity, uint16_t num_records_to_dump); 755 756 757 /** 758 * qdf_dp_trace_dump_stats() - dump DP Trace stats 759 * 760 * Return: none 761 */ 762 void qdf_dp_trace_dump_stats(void); 763 typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*, 764 uint16_t, uint8_t, uint8_t info); 765 /** 766 * qdf_dp_display_record() - Displays a record in DP trace 767 * @record: pointer to a record in DP trace 768 * @index: record index 769 * @pdev_id: pdev id for the mgmt pkt 770 * @info: info used to display pkt (live mode, throttling) 771 * 772 * Return: None 773 */ 774 void qdf_dp_display_record(struct qdf_dp_trace_record_s *record, 775 uint16_t index, uint8_t pdev_id, 776 uint8_t info); 777 778 /** 779 * qdf_dp_display_ptr_record() - display record 780 * @record: dptrace record 781 * @rec_index: index 782 * @pdev_id: pdev id for the mgmt pkt 783 * @info: info used to display pkt (live mode, throttling) 784 * 785 * Return: none 786 */ 787 void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record, 788 uint16_t rec_index, uint8_t pdev_id, 789 uint8_t info); 790 791 /** 792 * qdf_dp_display_proto_pkt() - display proto packet 793 * @record: dptrace record 794 * @index: index 795 * @pdev_id: pdev id for the mgmt pkt 796 * @info: info used to display pkt (live mode, throttling) 797 * 798 * Return: none 799 */ 800 void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record, 801 uint16_t index, uint8_t pdev_id, 802 uint8_t info); 803 /** 804 * qdf_dp_display_data_pkt_record() - Displays a data packet in DP trace 805 * @record: pointer to a record in DP trace 806 * @rec_index: record index 807 * @pdev_id: pdev id 808 * @info: display info regarding record 809 * 810 * Return: None 811 */ 812 void 813 qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record, 814 uint16_t rec_index, uint8_t pdev_id, 815 uint8_t info); 816 817 /** 818 * qdf_dp_get_status_from_htt() - Convert htt tx status to qdf dp status 819 * @status : htt_tx_status which needs to be converted 820 * 821 * Return : the status that from qdf_dp_tx_rx_status 822 */ 823 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status); 824 /** 825 * qdf_dp_get_status_from_a_status() - Convert A_STATUS to qdf dp status 826 * @status : A_STATUS which needs to be converted 827 * 828 * Return : the status that from qdf_dp_tx_rx_status 829 */ 830 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status); 831 /** 832 * qdf_dp_trace_ptr() - record dptrace 833 * @code: dptrace code 834 * @pdev_id: pdev_id 835 * @data: data 836 * @size: size of data 837 * @msdu_id: msdu_id 838 * @status: return status 839 * @qdf_tx_status: qdf tx rx status 840 * 841 * Return: none 842 */ 843 void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, 844 uint8_t pdev_id, uint8_t *data, uint8_t size, 845 uint16_t msdu_id, uint16_t buf_arg_status, 846 enum qdf_dp_tx_rx_status qdf_tx_status); 847 void qdf_dp_trace_throttle_live_mode(bool high_bw_request); 848 849 /** 850 * qdf_dp_trace_tput_policy() - Change verbosity based on the TPUT 851 * @is_data_traffic: Is traffic more than low TPUT threashould 852 * 853 * Return: None 854 */ 855 void qdf_dp_trace_apply_tput_policy(bool is_data_traffic); 856 857 /** 858 * qdf_dp_trace_data_pkt() - trace data packet 859 * @nbuf: nbuf which needs to be traced 860 * @pdev_id: pdev_id 861 * @code: QDF_DP_TRACE_ID for the packet (TX or RX) 862 * @msdu_id: tx desc id for the nbuf (Only applies to TX packets) 863 * @dir: TX or RX packet direction 864 * 865 * Return: None 866 */ 867 void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id, 868 enum QDF_DP_TRACE_ID code, uint16_t msdu_id, 869 enum qdf_proto_dir dir); 870 871 uint32_t qdf_dp_get_proto_bitmap(void); 872 uint8_t qdf_dp_get_verbosity(void); 873 uint8_t qdf_dp_get_no_of_record(void); 874 875 /** 876 * qdf_dp_trace_proto_pkt() - record proto packet 877 * @code: dptrace code 878 * @vdev_id: vdev id 879 * @sa: source mac address 880 * @da: destination mac address 881 * @type: proto type 882 * @subtype: proto subtype 883 * @dir: direction 884 * @pdev_id: pdev id 885 * @print: to print this proto pkt or not 886 * 887 * Return: none 888 */ 889 void 890 qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 891 uint8_t *sa, uint8_t *da, enum qdf_proto_type type, 892 enum qdf_proto_subtype subtype, enum qdf_proto_dir dir, 893 uint8_t pdev_id, bool print); 894 895 void qdf_dp_trace_disable_live_mode(void); 896 void qdf_dp_trace_enable_live_mode(void); 897 void qdf_dp_trace_clear_buffer(void); 898 /** 899 * qdf_dp_trace_mgmt_pkt() - record mgmt packet 900 * @code: dptrace code 901 * @vdev_id: vdev id 902 * @pdev_id: pdev_id 903 * @type: proto type 904 * @subtype: proto subtype 905 * 906 * Return: none 907 */ 908 void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 909 uint8_t pdev_id, enum qdf_proto_type type, 910 enum qdf_proto_subtype subtype); 911 912 /** 913 * qdf_dp_trace_credit_record() - record credit update 914 * @source: source of record 915 * @operation: credit operation 916 * @delta: credit delta 917 * @total_credits: total credit 918 * @g0_credit: group 0 credit 919 * @g1_credit: group 1 credit 920 */ 921 void qdf_dp_trace_credit_record(enum QDF_CREDIT_UPDATE_SOURCE source, 922 enum QDF_CREDIT_OPERATION operation, 923 int delta, int total_credits, 924 int g0_credit, int g1_credit); 925 926 /** 927 * qdf_dp_display_mgmt_pkt() - display proto packet 928 * @record: dptrace record 929 * @index: index 930 * @pdev_id: pdev id for the mgmt pkt 931 * @info: info used to display pkt (live mode, throttling) 932 * 933 * Return: none 934 */ 935 void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record, 936 uint16_t index, uint8_t pdev_id, uint8_t info); 937 938 /** 939 * qdf_dp_display_credit_record() - display credit record 940 * @record: dptrace record 941 * @index: index 942 * @pdev_id: pdev id 943 * @info: metadeta info 944 */ 945 void qdf_dp_display_credit_record(struct qdf_dp_trace_record_s *record, 946 uint16_t index, uint8_t pdev_id, 947 uint8_t info); 948 949 /** 950 * qdf_dp_display_event_record() - display event records 951 * @record: dptrace record 952 * @index: index 953 * @pdev_id: pdev id for the mgmt pkt 954 * @info: info used to display pkt (live mode, throttling) 955 * 956 * Return: none 957 */ 958 void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record, 959 uint16_t index, uint8_t pdev_id, uint8_t info); 960 961 void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 962 uint8_t pdev_id, enum qdf_proto_type type, 963 enum qdf_proto_subtype subtype); 964 965 /** 966 * qdf_dp_set_proto_event_bitmap() - Set the protocol event bitmap 967 * @value: proto event bitmap value. 968 * 969 * QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01 970 * QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02 971 * QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04 972 * QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10 973 * 974 * Return: none 975 */ 976 void qdf_dp_set_proto_event_bitmap(uint32_t value); 977 978 /** 979 * qdf_dp_log_proto_pkt_info() - Send diag log event 980 * @sa: source MAC address 981 * @da: destination MAC address 982 * @type: pkt type 983 * @subtype: pkt subtype 984 * @dir: tx or rx 985 * @msdu_id: msdu id 986 * @status: status 987 * 988 * Return: none 989 */ 990 void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type, 991 uint8_t subtype, uint8_t dir, uint16_t msdu_id, 992 uint8_t status); 993 994 /** 995 * qdf_dp_track_noack_check() - Check if no ack count should be tracked for 996 * the configured protocol packet types 997 * @nbuf: nbuf 998 * @subtype: subtype of packet to be tracked 999 * 1000 * Return: none 1001 */ 1002 void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype); 1003 #else 1004 static inline 1005 bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb, 1006 enum qdf_proto_dir dir, uint8_t pdev_id) 1007 { 1008 return false; 1009 } 1010 static inline 1011 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 1012 uint16_t time_limit, uint8_t verbosity, 1013 uint32_t proto_bitmap) 1014 { 1015 } 1016 1017 static inline 1018 void qdf_dp_trace_deinit(void) 1019 { 1020 } 1021 1022 static inline 1023 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir) 1024 { 1025 } 1026 static inline 1027 void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records, 1028 uint8_t verbosity) 1029 { 1030 } 1031 1032 static inline 1033 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id) 1034 { 1035 } 1036 1037 static inline 1038 uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file, 1039 enum qdf_dpt_debugfs_state state) 1040 { 1041 return 0; 1042 } 1043 1044 static inline 1045 QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file, 1046 uint32_t curr_pos) 1047 { 1048 return QDF_STATUS_SUCCESS; 1049 } 1050 1051 static inline 1052 void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record, 1053 uint8_t verbosity, uint16_t num_records_to_dump) 1054 { 1055 } 1056 1057 static inline void qdf_dp_trace_dump_stats(void) 1058 { 1059 } 1060 1061 static inline 1062 void qdf_dp_trace_disable_live_mode(void) 1063 { 1064 } 1065 1066 static inline 1067 void qdf_dp_trace_enable_live_mode(void) 1068 { 1069 } 1070 1071 static inline 1072 void qdf_dp_trace_throttle_live_mode(bool high_bw_request) 1073 { 1074 } 1075 1076 static inline 1077 void qdf_dp_trace_clear_buffer(void) 1078 { 1079 } 1080 1081 static inline 1082 void qdf_dp_trace_apply_tput_policy(bool is_data_traffic) 1083 { 1084 } 1085 1086 static inline 1087 void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id, 1088 enum QDF_DP_TRACE_ID code, uint16_t msdu_id, 1089 enum qdf_proto_dir dir) 1090 { 1091 } 1092 1093 static inline 1094 void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type, 1095 uint8_t subtype, uint8_t dir, uint16_t msdu_id, 1096 uint8_t status) 1097 { 1098 } 1099 1100 static inline 1101 void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype) 1102 { 1103 } 1104 1105 static inline 1106 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status) 1107 { 1108 return QDF_TX_RX_STATUS_OK; 1109 } 1110 1111 static inline 1112 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status) 1113 { 1114 return QDF_TX_RX_STATUS_OK; 1115 } 1116 #endif 1117 1118 void qdf_trace_display(void); 1119 1120 void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size, 1121 char *str_format, ...); 1122 1123 #define QDF_SNPRINTF qdf_snprintf 1124 1125 #ifdef TSOSEG_DEBUG 1126 1127 static inline void qdf_tso_seg_dbg_bug(char *msg) 1128 { 1129 qdf_print("%s", msg); 1130 QDF_BUG(0); 1131 }; 1132 1133 /** 1134 * qdf_tso_seg_dbg_init - initialize TSO segment debug structure 1135 * @tsoseg : structure to initialize 1136 * 1137 * TSO segment dbg structures are attached to qdf_tso_seg_elem_t 1138 * structures and are allocated only of TSOSEG_DEBUG is defined. 1139 * When allocated, at the time of the tso_seg_pool initialization, 1140 * which goes with tx_desc initialization (1:1), each structure holds 1141 * a number of (currently 16) history entries, basically describing 1142 * what operation has been performed on this particular tso_seg_elem. 1143 * This history buffer is a circular buffer and the current index is 1144 * held in an atomic variable called cur. It is incremented every 1145 * operation. Each of these operations are added with the function 1146 * qdf_tso_seg_dbg_record. 1147 * For each segment, this initialization function MUST be called PRIOR 1148 * TO any _dbg_record() function calls. 1149 * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero) 1150 * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element. 1151 * 1152 * Return: 1153 * None 1154 */ 1155 static inline 1156 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 1157 { 1158 tsoseg->dbg.txdesc = NULL; 1159 qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */ 1160 } 1161 1162 /** 1163 * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure 1164 * @tsoseg : structure to initialize 1165 * @id : operation ID (identifies the caller) 1166 * 1167 * Adds a history entry to the history circular buffer. Each entry 1168 * contains an operation id (caller, as currently each ID is used only 1169 * once in the source, so it directly identifies the src line that invoked 1170 * the recording. 1171 * 1172 * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized 1173 * by qdf_tso_seg_dbg_init. 1174 * 1175 * The entry to be added is written at the location pointed by the atomic 1176 * variable called cur. Cur is an ever increasing atomic variable. It is 1177 * masked so that only the lower 4 bits are used (16 history entries). 1178 * 1179 * Return: 1180 * int: the entry this record was recorded at 1181 */ 1182 static inline 1183 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 1184 { 1185 int rc = -1; 1186 unsigned int c; 1187 1188 qdf_assert(tsoseg); 1189 1190 if (id == TSOSEG_LOC_ALLOC) { 1191 c = qdf_atomic_read(&tsoseg->dbg.cur); 1192 /* dont crash on the very first alloc on the segment */ 1193 c &= 0x0f; 1194 /* allow only INIT and FREE ops before ALLOC */ 1195 if (tsoseg->dbg.h[c].id >= id) 1196 qdf_tso_seg_dbg_bug("Rogue TSO seg alloc"); 1197 } 1198 c = qdf_atomic_inc_return(&tsoseg->dbg.cur); 1199 1200 c &= 0x0f; 1201 tsoseg->dbg.h[c].ts = qdf_get_log_timestamp(); 1202 tsoseg->dbg.h[c].id = id; 1203 rc = c; 1204 1205 return rc; 1206 }; 1207 1208 static inline void 1209 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 1210 { 1211 if (tsoseg) 1212 tsoseg->dbg.txdesc = owner; 1213 }; 1214 1215 static inline void 1216 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 1217 { 1218 memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg)); 1219 return; 1220 }; 1221 1222 #else 1223 static inline 1224 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 1225 { 1226 }; 1227 static inline 1228 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 1229 { 1230 return 0; 1231 }; 1232 static inline void qdf_tso_seg_dbg_bug(char *msg) 1233 { 1234 }; 1235 static inline void 1236 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 1237 { 1238 }; 1239 static inline int 1240 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 1241 { 1242 memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t)); 1243 return 0; 1244 }; 1245 1246 #endif /* TSOSEG_DEBUG */ 1247 1248 /** 1249 * qdf_trace_hex_dump() - externally called hex dump function 1250 * @module: Module identifier a member of the QDF_MODULE_ID enumeration that 1251 * identifies the module issuing the trace message. 1252 * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating 1253 * the severity of the condition causing the trace message to be 1254 * issued. More severe conditions are more likely to be logged. 1255 * @data: The base address of the buffer to be logged. 1256 * @buf_len: The size of the buffer to be logged. 1257 * 1258 * Checks the level of severity and accordingly prints the trace messages 1259 * 1260 * Return: None 1261 */ 1262 void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 1263 void *data, int buf_len); 1264 1265 /** 1266 * qdf_trace_hex_ascii_dump() - externally called hex and ascii dump function 1267 * @module: Module identifier a member of the QDF_MODULE_ID enumeration that 1268 * identifies the module issuing the trace message. 1269 * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating 1270 * the severity of the condition causing the trace message to be 1271 * issued. More severe conditions are more likely to be logged. 1272 * @data: The base address of the buffer to be logged. 1273 * @buf_len: The size of the buffer to be logged. 1274 * 1275 * Checks the level of severity and accordingly prints the trace messages 1276 * 1277 * Return: None 1278 */ 1279 void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 1280 void *data, int buf_len); 1281 1282 #define ERROR_CODE -1 1283 #define QDF_MAX_NAME_SIZE 32 1284 #define MAX_PRINT_CONFIG_SUPPORTED 32 1285 1286 #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX 1287 1288 /** 1289 * qdf_set_pidx() - Sets the global qdf_pidx. 1290 * @pidx : Index of print control object assigned to the module 1291 * 1292 */ 1293 void qdf_set_pidx(int pidx); 1294 1295 /** 1296 * qdf_get_pidx() - Returns the global qdf_pidx. 1297 * 1298 * Return : Current qdf print index. 1299 */ 1300 int qdf_get_pidx(void); 1301 /* 1302 * Shared print control index 1303 * for converged debug framework 1304 */ 1305 1306 #define QDF_PRINT_IDX_SHARED -1 1307 1308 /** 1309 * QDF_PRINT_INFO() - Generic wrapper API for logging 1310 * @idx : Index of print control object 1311 * @module : Module identifier. A member of QDF_MODULE_ID enumeration that 1312 * identifies the module issuing the trace message 1313 * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating 1314 * the severity of the condition causing the trace message to be 1315 * issued. 1316 * @str_format : Format string that contains the message to be logged. 1317 * 1318 * 1319 * This wrapper will be used for any generic logging messages. Wrapper will 1320 * compile a call to converged QDF trace message API. 1321 * 1322 * Return : Nothing 1323 * 1324 */ 1325 void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module, 1326 QDF_TRACE_LEVEL level, 1327 char *str_format, ...); 1328 1329 /** 1330 * struct category_info : Category information structure 1331 * @category_verbose_mask: Embeds information about category's verbose level 1332 */ 1333 struct category_info { 1334 uint16_t category_verbose_mask; 1335 }; 1336 1337 /** 1338 * struct category_name_info : Category name information structure 1339 * @category_name_str: Embeds information about category name 1340 */ 1341 struct category_name_info { 1342 unsigned char category_name_str[QDF_MAX_NAME_SIZE]; 1343 }; 1344 1345 /** 1346 * qdf_trace_msg_cmn()- Converged logging API 1347 * @idx: Index of print control object assigned to the module 1348 * @category: Category identifier. A member of the QDF_MODULE_ID enumeration 1349 * that identifies the category issuing the trace message. 1350 * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration 1351 * indicating the severity of the condition causing the trace 1352 * message to be issued. More severe conditions are more likely 1353 * to be logged. 1354 * @str_format: Format string. The message to be logged. This format string 1355 * contains printf-like replacement parameters, which follow this 1356 * parameter in the variable argument list. 1357 * @val: Variable argument list part of the log message 1358 * 1359 * Return: nothing 1360 * 1361 */ 1362 void qdf_trace_msg_cmn(unsigned int idx, 1363 QDF_MODULE_ID category, 1364 QDF_TRACE_LEVEL verbose, 1365 const char *str_format, 1366 va_list val); 1367 1368 /** 1369 * struct qdf_print_ctrl: QDF Print Control structure 1370 * Statically allocated objects of print control 1371 * structure are declared that will support maximum of 1372 * 32 print control objects. Any module that needs to 1373 * register to the print control framework needs to 1374 * obtain a print control object using 1375 * qdf_print_ctrl_register API. It will have to pass 1376 * pointer to category info structure, name and 1377 * custom print function to be used if required. 1378 * @name : Optional name for the control object 1379 * @cat_info : Array of category_info struct 1380 * @custom_print : Custom print handler 1381 * @custom_ctxt : Custom print context 1382 * @dbglvlmac_on : Flag to enable/disable MAC level filtering 1383 * @in_use : Boolean to indicate if control object is in use 1384 */ 1385 struct qdf_print_ctrl { 1386 char name[QDF_MAX_NAME_SIZE]; 1387 struct category_info cat_info[MAX_SUPPORTED_CATEGORY]; 1388 void (*custom_print)(void *ctxt, const char *fmt, va_list args); 1389 void *custom_ctxt; 1390 #ifdef DBG_LVL_MAC_FILTERING 1391 unsigned char dbglvlmac_on; 1392 #endif 1393 bool in_use; 1394 }; 1395 1396 /** 1397 * qdf_print_ctrl_register() - Allocate QDF print control object, assign 1398 * pointer to category info or print control 1399 * structure and return the index to the callee 1400 * @cinfo : Pointer to array of category info structure 1401 * @custom_print_handler : Pointer to custom print handler 1402 * @custom_ctx : Pointer to custom context 1403 * @pctrl_name : Pointer to print control object name 1404 * 1405 * Return : Index of qdf_print_ctrl structure 1406 * 1407 */ 1408 int qdf_print_ctrl_register(const struct category_info *cinfo, 1409 void *custom_print_handler, 1410 void *custom_ctx, 1411 const char *pctrl_name); 1412 1413 /** 1414 * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with 1415 * all categories set to the default level 1416 * 1417 * Return : void 1418 * 1419 */ 1420 void qdf_shared_print_ctrl_init(void); 1421 1422 /** 1423 * qdf_print_setup() - Setup default values to all the print control objects 1424 * 1425 * Register new print control object for the callee 1426 * 1427 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE 1428 * on failure 1429 */ 1430 QDF_STATUS qdf_print_setup(void); 1431 1432 /** 1433 * qdf_print_ctrl_cleanup() - Clean up a print control object 1434 * 1435 * Cleanup the print control object for the callee 1436 * 1437 * @pctrl : Index of print control object 1438 * 1439 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure 1440 */ 1441 QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx); 1442 1443 /** 1444 * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object 1445 * 1446 * Cleanup the shared print-ctrl-object 1447 * 1448 * Return : void 1449 */ 1450 void qdf_shared_print_ctrl_cleanup(void); 1451 1452 /** 1453 * qdf_print_set_category_verbose() - Enable/Disable category for a 1454 * print control object with 1455 * user provided verbose level 1456 * 1457 * @idx : Index of the print control object assigned to callee 1458 * @category : Category information 1459 * @verbose: Verbose information 1460 * @is_set: Flag indicating if verbose level needs to be enabled or disabled 1461 * 1462 * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure 1463 */ 1464 QDF_STATUS qdf_print_set_category_verbose(unsigned int idx, 1465 QDF_MODULE_ID category, 1466 QDF_TRACE_LEVEL verbose, 1467 bool is_set); 1468 1469 /** 1470 * qdf_log_dump_at_kernel_level() - Enable/Disable printk call 1471 * @enable: Indicates whether printk is enabled in QDF_TRACE 1472 * 1473 * Return: void 1474 */ 1475 void qdf_log_dump_at_kernel_level(bool enable); 1476 1477 /** 1478 * qdf_logging_set_flush_timer() - Set the time period in which host logs 1479 * should be flushed out to user-space 1480 * @milliseconds: milliseconds after which the logs should be flushed out to 1481 * user-space 1482 * 1483 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure 1484 */ 1485 int qdf_logging_set_flush_timer(uint32_t milliseconds); 1486 1487 /** 1488 * qdf_logging_flush_logs() - Flush out the logs to user-space one time 1489 * 1490 * Return: void 1491 */ 1492 void qdf_logging_flush_logs(void); 1493 1494 /** 1495 * qdf_print_is_category_enabled() - Get category information for the 1496 * print control object 1497 * 1498 * @idx : Index of print control object 1499 * @category : Category information 1500 * 1501 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 1502 */ 1503 bool qdf_print_is_category_enabled(unsigned int idx, 1504 QDF_MODULE_ID category); 1505 1506 /** 1507 * qdf_print_is_verbose_enabled() - Get verbose information of a category for 1508 * the print control object 1509 * 1510 * @idx : Index of print control object 1511 * @category : Category information 1512 * @verbose : Verbose information 1513 * 1514 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 1515 */ 1516 bool qdf_print_is_verbose_enabled(unsigned int idx, 1517 QDF_MODULE_ID category, 1518 QDF_TRACE_LEVEL verbose); 1519 1520 /** 1521 * qdf_print_clean_node_flag() - Clean up node flag for print control object 1522 * 1523 * @idx : Index of print control object 1524 * 1525 * Return : None 1526 */ 1527 void qdf_print_clean_node_flag(unsigned int idx); 1528 1529 #ifdef DBG_LVL_MAC_FILTERING 1530 1531 /** 1532 * qdf_print_set_node_flag() - Set flag to enable MAC level filtering 1533 * 1534 * @idx : Index of print control object 1535 * @enable : Enable/Disable bit sent by callee 1536 * 1537 * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure 1538 */ 1539 QDF_STATUS qdf_print_set_node_flag(unsigned int idx, 1540 uint8_t enable); 1541 1542 /** 1543 * qdf_print_get_node_flag() - Get flag that controls MAC level filtering 1544 * 1545 * @idx : Index of print control object 1546 * 1547 * Return : Flag that indicates enable(1) or disable(0) or invalid(-1) 1548 */ 1549 bool qdf_print_get_node_flag(unsigned int idx); 1550 1551 #endif 1552 1553 /** 1554 * qdf_logging_init() - Initialize msg logging functionality 1555 * 1556 * 1557 * Return : void 1558 */ 1559 void qdf_logging_init(void); 1560 1561 /** 1562 * qdf_logging_exit() - Cleanup msg logging functionality 1563 * 1564 * 1565 * Return : void 1566 */ 1567 void qdf_logging_exit(void); 1568 1569 #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN 1570 1571 /** 1572 * qdf_sprint_symbol() - prints the name of a symbol into a string buffer 1573 * @buffer: the string buffer to print into 1574 * @addr: address of the symbol to lookup and print 1575 * 1576 * Return: number of characters printed 1577 */ 1578 int qdf_sprint_symbol(char *buffer, void *addr); 1579 1580 /** 1581 * qdf_minidump_log() - Log memory address to be included in minidump 1582 * @start_addr: Start address of the memory to be dumped 1583 * @size: Size in bytes 1584 * @name: String to identify this entry 1585 */ 1586 static inline 1587 void qdf_minidump_log(void *start_addr, size_t size, const char *name) 1588 { 1589 __qdf_minidump_log(start_addr, size, name); 1590 } 1591 1592 /** 1593 * qdf_minidump_remove() - Remove memory address from minidump 1594 * @addr: Start address of the memory previously added 1595 */ 1596 static inline 1597 void qdf_minidump_remove(void *addr) 1598 { 1599 __qdf_minidump_remove(addr); 1600 } 1601 1602 #endif /* __QDF_TRACE_H */ 1603