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