1 /* 2 * Copyright (c) 2014-2021 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 50 /* bytes */ 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 * @proto_priv_data: protocol private data 354 * can be stored in this. 355 */ 356 struct qdf_dp_trace_proto_buf { 357 struct qdf_mac_addr sa; 358 struct qdf_mac_addr da; 359 uint8_t vdev_id; 360 uint8_t type; 361 uint8_t subtype; 362 uint8_t dir; 363 /* for ICMP priv data is bit offset 38 to 42 364 * 38-40 ICMP_ICMP_ID and 365 * 40-42 ICMP_SEQ_NUM_OFFSET 366 */ 367 uint32_t proto_priv_data; 368 }; 369 370 /** 371 * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer 372 * @vdev_id : vdev id 373 * @type: packet type 374 * @subtype: packet subtype 375 */ 376 struct qdf_dp_trace_mgmt_buf { 377 uint8_t vdev_id; 378 uint8_t type; 379 uint8_t subtype; 380 }; 381 382 /** 383 * struct qdf_dp_trace_credit_record - tx credit record 384 * @source: credit record source 385 * @operation: credit operation 386 * @delta: delta of credit 387 * @total_credits: total credit 388 * @g0_credit: group 0 credit 389 * @g1_credit: group 1 credit 390 */ 391 struct qdf_dp_trace_credit_record { 392 enum QDF_CREDIT_UPDATE_SOURCE source; 393 enum QDF_CREDIT_OPERATION operation; 394 int delta; 395 int total_credits; 396 int g0_credit; 397 int g1_credit; 398 }; 399 400 /** 401 * struct qdf_dp_trace_event_buf - event buffer 402 * @vdev_id : vdev id 403 * @type: packet type 404 * @subtype: packet subtype 405 */ 406 struct qdf_dp_trace_event_buf { 407 uint8_t vdev_id; 408 uint8_t type; 409 uint8_t subtype; 410 }; 411 412 /** 413 * struct qdf_dp_trace_data_buf - nbuf data buffer 414 * @msdu_id : msdu id 415 */ 416 struct qdf_dp_trace_data_buf { 417 uint16_t msdu_id; 418 }; 419 420 /** 421 * struct qdf_dp_trace_record_s - Describes a record in DP trace 422 * @time: time when it got stored 423 * @code: Describes the particular event 424 * @data: buffer to store data 425 * @size: Length of the valid data stored in this record 426 * @pid : process id which stored the data in this record 427 */ 428 struct qdf_dp_trace_record_s { 429 uint64_t time; 430 uint8_t code; 431 uint8_t data[QDF_DP_TRACE_RECORD_SIZE]; 432 uint8_t size; 433 uint32_t pid; 434 uint8_t pdev_id; 435 }; 436 437 /** 438 * struct qdf_dp_trace_data - Parameters to configure/control DP trace 439 * @head: Position of first record 440 * @tail: Position of last record 441 * @num: Current index 442 * @proto_bitmap: defines which protocol to be traced 443 * @no_of_record: defines every nth packet to be traced 444 * @num_records_to_dump: defines number of records to be dumped 445 * @dump_counter: counter to track number of records dumped 446 * @verbosity : defines verbosity level 447 * @ini_conf_verbosity: Configured verbosity from INI 448 * @enable: enable/disable DP trace 449 * @count: current packet number 450 * @live_mode_config: configuration as received during initialization 451 * @live_mode: current live mode, enabled or disabled, can be throttled based 452 * on throughput 453 * @force_live_mode: flag to enable live mode all the time for all packets. 454 * This can be set/unset from userspace and overrides other 455 * live mode flags. 456 * @dynamic_verbosity_modify: Dynamic user configured verbosity overrides all 457 * @print_pkt_cnt: count of number of packets printed in live mode 458 * @high_tput_thresh: thresh beyond which live mode is turned off 459 * @thresh_time_limit: max time, in terms of BW timer intervals to wait, 460 * for determining if high_tput_thresh has been crossed. ~1s 461 * @arp_req: stats for arp reqs 462 * @arp_resp: stats for arp resps 463 * @icmp_req: stats for icmp reqs 464 * @icmp_resp: stats for icmp resps 465 * @dhcp_disc: stats for dhcp discover msgs 466 * @dhcp_req: stats for dhcp req msgs 467 * @dhcp_off: stats for dhcp offer msgs 468 * @dhcp_ack: stats for dhcp ack msgs 469 * @dhcp_nack: stats for dhcp nack msgs 470 * @dhcp_others: stats for other dhcp pkts types 471 * @eapol_m1: stats for eapol m1 472 * @eapol_m2: stats for eapol m2 473 * @eapol_m3: stats for eapol m3 474 * @eapol_m4: stats for eapol m4 475 * @eapol_others: stats for other eapol pkt types 476 * @icmpv6_req: stats for icmpv6 reqs 477 * @icmpv6_resp: stats for icmpv6 resps 478 * @icmpv6_ns: stats for icmpv6 nss 479 * @icmpv6_na: stats for icmpv6 nas 480 * @icmpv6_rs: stats for icmpv6 rss 481 * @icmpv6_ra: stats for icmpv6 ras 482 * @proto_event_bitmap: defines which protocol to be diag logged. 483 * refer QDF_NBUF_PKT_TRAC_TYPE_DNS to QDF_NBUF_PKT_TRAC_TYPE_ARP 484 * for bitmap. 485 */ 486 struct s_qdf_dp_trace_data { 487 uint32_t head; 488 uint32_t tail; 489 uint32_t num; 490 uint32_t proto_bitmap; 491 uint8_t no_of_record; 492 uint16_t num_records_to_dump; 493 uint16_t dump_counter; 494 uint8_t verbosity; 495 uint8_t ini_conf_verbosity; 496 bool enable; 497 bool live_mode_config; 498 bool live_mode; 499 uint32_t curr_pos; 500 uint32_t saved_tail; 501 bool force_live_mode; 502 bool dynamic_verbosity_modify; 503 uint8_t print_pkt_cnt; 504 uint8_t high_tput_thresh; 505 uint16_t thresh_time_limit; 506 /* Stats */ 507 uint32_t tx_count; 508 uint32_t rx_count; 509 u16 arp_req; 510 u16 arp_resp; 511 u16 dhcp_disc; 512 u16 dhcp_req; 513 u16 dhcp_off; 514 u16 dhcp_ack; 515 u16 dhcp_nack; 516 u16 dhcp_others; 517 u16 eapol_m1; 518 u16 eapol_m2; 519 u16 eapol_m3; 520 u16 eapol_m4; 521 u16 eapol_others; 522 u16 icmp_req; 523 u16 icmp_resp; 524 u16 icmpv6_req; 525 u16 icmpv6_resp; 526 u16 icmpv6_ns; 527 u16 icmpv6_na; 528 u16 icmpv6_rs; 529 u16 icmpv6_ra; 530 uint32_t proto_event_bitmap; 531 }; 532 533 /** 534 * struct qdf_dpt_debugfs_state - state to control read to debugfs file 535 * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID: invalid state 536 * @QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT: initial state 537 * @QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS: read is in progress 538 * @QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE: read complete 539 */ 540 541 enum qdf_dpt_debugfs_state { 542 QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INVALID, 543 QDF_DPT_DEBUGFS_STATE_SHOW_STATE_INIT, 544 QDF_DPT_DEBUGFS_STATE_SHOW_IN_PROGRESS, 545 QDF_DPT_DEBUGFS_STATE_SHOW_COMPLETE, 546 }; 547 548 #define QDF_WIFI_MODULE_PARAMS_FILE "wifi_module_param.ini" 549 550 typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t); 551 typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size); 552 #ifdef WLAN_FEATURE_MEMDUMP_ENABLE 553 void qdf_register_debugcb_init(void); 554 void qdf_register_debug_callback(QDF_MODULE_ID module_id, 555 tp_qdf_state_info_cb qdf_state_infocb); 556 QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size, 557 uint16_t *driver_dump_size); 558 #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ 559 static inline void qdf_register_debugcb_init(void) 560 { 561 } 562 #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ 563 564 #ifdef TRACE_RECORD 565 void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb); 566 void qdf_trace_init(void); 567 void qdf_trace_deinit(void); 568 void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data); 569 void qdf_trace_enable(uint32_t, uint8_t enable); 570 void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t); 571 QDF_STATUS qdf_trace_spin_lock_init(void); 572 #else 573 #ifndef QDF_TRACE_PRINT_ENABLE 574 static inline 575 void qdf_trace_init(void) 576 { 577 } 578 579 static inline 580 void qdf_trace_deinit(void) 581 { 582 } 583 584 static inline 585 void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable) 586 { 587 } 588 589 static inline 590 void qdf_trace(uint8_t module, uint16_t code, uint16_t session, uint32_t data) 591 { 592 } 593 594 static inline 595 void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session, 596 uint32_t count, uint32_t bitmask_of_module) 597 { 598 } 599 600 static inline 601 QDF_STATUS qdf_trace_spin_lock_init(void) 602 { 603 return QDF_STATUS_SUCCESS; 604 } 605 #endif 606 #endif 607 608 #ifdef WLAN_MAX_LOGS_PER_SEC 609 /** 610 * qdf_detected_excessive_logging() - Excessive logging detected 611 * 612 * Track logging count using a quasi-tumbling window. 613 * If the max logging count for a given window is exceeded, 614 * return true else fails. 615 * 616 * Return: true/false 617 */ 618 bool qdf_detected_excessive_logging(void); 619 620 /** 621 * qdf_rl_print_count_set() - set the ratelimiting print count 622 * @rl_print_time: ratelimiting print count 623 * 624 * Return: none 625 */ 626 void qdf_rl_print_count_set(uint32_t rl_print_count); 627 628 /** 629 * qdf_rl_print_time_set() - set the ratelimiting print time 630 * @rl_print_time: ratelimiting print time 631 * 632 * Return: none 633 */ 634 void qdf_rl_print_time_set(uint32_t rl_print_time); 635 636 /** 637 * qdf_rl_print_supressed_log() - print the supressed logs count 638 * 639 * Return: none 640 */ 641 void qdf_rl_print_supressed_log(void); 642 643 /** 644 * qdf_rl_print_supressed_inc() - increment the supressed logs count 645 * 646 * Return: none 647 */ 648 void qdf_rl_print_supressed_inc(void); 649 650 #else /* WLAN_MAX_LOGS_PER_SEC */ 651 static inline bool qdf_detected_excessive_logging(void) 652 { 653 return false; 654 } 655 static inline void qdf_rl_print_count_set(uint32_t rl_print_count) {} 656 static inline void qdf_rl_print_time_set(uint32_t rl_print_time) {} 657 static inline void qdf_rl_print_supressed_log(void) {} 658 static inline void qdf_rl_print_supressed_inc(void) {} 659 #endif /* WLAN_MAX_LOGS_PER_SEC */ 660 661 #ifdef ENABLE_MTRACE_LOG 662 /** 663 * qdf_mtrace_log() - Logs a message tracepoint to DIAG 664 * Infrastructure. 665 * @src_module: Enum of source module (basically module id) 666 * from where the message with message_id is posted. 667 * @dst_module: Enum of destination module (basically module id) 668 * to which the message with message_id is posted. 669 * @message_id: Id of the message to be posted 670 * @vdev_id: Vdev Id 671 * 672 * This function logs to the DIAG Infrastructure a tracepoint for a 673 * message being sent from a source module to a destination module 674 * with a specific ID for the benefit of a specific vdev. 675 * For non-vdev messages vdev_id will be NO_SESSION 676 * Return: None 677 */ 678 void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 679 uint16_t message_id, uint8_t vdev_id); 680 #else 681 static inline 682 void qdf_mtrace_log(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 683 uint16_t message_id, uint8_t vdev_id) 684 { 685 } 686 #endif 687 688 #ifdef TRACE_RECORD 689 /** 690 * qdf_mtrace() - puts the messages in to ring-buffer 691 * and logs a message tracepoint to DIAG Infrastructure. 692 * @src_module: Enum of source module (basically module id) 693 * from where the message with message_id is posted. 694 * @dst_module: Enum of destination module (basically module id) 695 * to which the message with message_id is posted. 696 * @message_id: Id of the message to be posted 697 * @vdev_id: Vdev Id 698 * @data: Actual message contents 699 * 700 * This function will be called from each module which wants to record the 701 * messages in circular queue. Before calling this function make sure you 702 * have registered your module with qdf through qdf_trace_register function. 703 * In addition of the recording the messages in circular queue this function 704 * will log the message tracepoint to the DIAG infrastructure. 705 * these logs will be later used by post processing script. 706 * 707 * Return: None 708 */ 709 void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 710 uint16_t message_id, uint8_t vdev_id, uint32_t data); 711 #else 712 static inline 713 void qdf_mtrace(QDF_MODULE_ID src_module, QDF_MODULE_ID dst_module, 714 uint16_t message_id, uint8_t vdev_id, uint32_t data) 715 { 716 } 717 #endif 718 719 #ifdef CONFIG_DP_TRACE 720 void qdf_dp_set_proto_bitmap(uint32_t val); 721 void qdf_dp_trace_set_verbosity(uint32_t val); 722 void qdf_dp_set_no_of_record(uint32_t val); 723 #define QDF_DP_TRACE_RECORD_INFO_LIVE (0x1) 724 #define QDF_DP_TRACE_RECORD_INFO_THROTTLED (0x1 << 1) 725 726 /** 727 * qdf_dp_trace_log_pkt() - log packet type enabled through iwpriv 728 * @vdev_id: vdev_id 729 * @skb: skb pointer 730 * @dir: direction 731 * @pdev_id: pdev_id 732 * 733 * Return: true: some protocol was logged, false: no protocol was logged. 734 */ 735 bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb, 736 enum qdf_proto_dir dir, uint8_t pdev_id); 737 738 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 739 uint16_t time_limit, uint8_t verbosity, 740 uint32_t proto_bitmap); 741 void qdf_dp_trace_deinit(void); 742 void qdf_dp_trace_spin_lock_init(void); 743 void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records, 744 uint8_t verbosity); 745 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir); 746 void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id, 747 uint8_t *data, uint8_t size, enum qdf_proto_dir dir); 748 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id); 749 750 /** 751 * qdf_dpt_get_curr_pos_debugfs() - get curr position to start read 752 * @file: debugfs file to read 753 * @state: state to control read to debugfs file 754 * 755 * Return: curr pos 756 */ 757 uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file, 758 enum qdf_dpt_debugfs_state state); 759 /** 760 * qdf_dpt_dump_stats_debugfs() - dump DP Trace stats to debugfs file 761 * @file: debugfs file to read 762 * @curr_pos: curr position to start read 763 * 764 * Return: QDF_STATUS 765 */ 766 QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file, 767 uint32_t curr_pos); 768 769 /** 770 * qdf_dpt_set_value_debugfs() - set value of DP Trace debugfs params 771 * @proto_bitmap: defines which protocol to be traced 772 * @no_of_record: defines every nth packet to be traced 773 * @verbosity : defines verbosity level 774 * @num_records_to_dump: defines number of records to be dumped 775 * 776 * Return: none 777 */ 778 void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record, 779 uint8_t verbosity, uint16_t num_records_to_dump); 780 781 782 /** 783 * qdf_dp_trace_dump_stats() - dump DP Trace stats 784 * 785 * Return: none 786 */ 787 void qdf_dp_trace_dump_stats(void); 788 typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*, 789 uint16_t, uint8_t, uint8_t info); 790 /** 791 * qdf_dp_display_record() - Displays a record in DP trace 792 * @record: pointer to a record in DP trace 793 * @index: record index 794 * @pdev_id: pdev id for the mgmt pkt 795 * @info: info used to display pkt (live mode, throttling) 796 * 797 * Return: None 798 */ 799 void qdf_dp_display_record(struct qdf_dp_trace_record_s *record, 800 uint16_t index, uint8_t pdev_id, 801 uint8_t info); 802 803 /** 804 * qdf_dp_display_ptr_record() - display record 805 * @record: dptrace record 806 * @rec_index: index 807 * @pdev_id: pdev id for the mgmt pkt 808 * @info: info used to display pkt (live mode, throttling) 809 * 810 * Return: none 811 */ 812 void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *record, 813 uint16_t rec_index, uint8_t pdev_id, 814 uint8_t info); 815 816 /** 817 * qdf_dp_display_proto_pkt() - display proto packet 818 * @record: dptrace record 819 * @index: index 820 * @pdev_id: pdev id for the mgmt pkt 821 * @info: info used to display pkt (live mode, throttling) 822 * 823 * Return: none 824 */ 825 void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record, 826 uint16_t index, uint8_t pdev_id, 827 uint8_t info); 828 /** 829 * qdf_dp_display_data_pkt_record() - Displays a data packet in DP trace 830 * @record: pointer to a record in DP trace 831 * @rec_index: record index 832 * @pdev_id: pdev id 833 * @info: display info regarding record 834 * 835 * Return: None 836 */ 837 void 838 qdf_dp_display_data_pkt_record(struct qdf_dp_trace_record_s *record, 839 uint16_t rec_index, uint8_t pdev_id, 840 uint8_t info); 841 842 /** 843 * qdf_dp_get_status_from_htt() - Convert htt tx status to qdf dp status 844 * @status : htt_tx_status which needs to be converted 845 * 846 * Return : the status that from qdf_dp_tx_rx_status 847 */ 848 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status); 849 /** 850 * qdf_dp_get_status_from_a_status() - Convert A_STATUS to qdf dp status 851 * @status : A_STATUS which needs to be converted 852 * 853 * Return : the status that from qdf_dp_tx_rx_status 854 */ 855 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status); 856 /** 857 * qdf_dp_trace_ptr() - record dptrace 858 * @code: dptrace code 859 * @pdev_id: pdev_id 860 * @data: data 861 * @size: size of data 862 * @msdu_id: msdu_id 863 * @status: return status 864 * @qdf_tx_status: qdf tx rx status 865 * 866 * Return: none 867 */ 868 void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, 869 uint8_t pdev_id, uint8_t *data, uint8_t size, 870 uint16_t msdu_id, uint16_t buf_arg_status, 871 enum qdf_dp_tx_rx_status qdf_tx_status); 872 void qdf_dp_trace_throttle_live_mode(bool high_bw_request); 873 874 /** 875 * qdf_dp_trace_tput_policy() - Change verbosity based on the TPUT 876 * @is_data_traffic: Is traffic more than low TPUT threashould 877 * 878 * Return: None 879 */ 880 void qdf_dp_trace_apply_tput_policy(bool is_data_traffic); 881 882 /** 883 * qdf_dp_trace_data_pkt() - trace data packet 884 * @nbuf: nbuf which needs to be traced 885 * @pdev_id: pdev_id 886 * @code: QDF_DP_TRACE_ID for the packet (TX or RX) 887 * @msdu_id: tx desc id for the nbuf (Only applies to TX packets) 888 * @dir: TX or RX packet direction 889 * 890 * Return: None 891 */ 892 void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id, 893 enum QDF_DP_TRACE_ID code, uint16_t msdu_id, 894 enum qdf_proto_dir dir); 895 896 uint32_t qdf_dp_get_proto_bitmap(void); 897 uint8_t qdf_dp_get_verbosity(void); 898 uint8_t qdf_dp_get_no_of_record(void); 899 900 /** 901 * qdf_dp_trace_proto_pkt() - record proto packet 902 * @code: dptrace code 903 * @vdev_id: vdev id 904 * @sa: source mac address 905 * @da: destination mac address 906 * @type: proto type 907 * @subtype: proto subtype 908 * @dir: direction 909 * @pdev_id: pdev id 910 * @print: to print this proto pkt or not 911 * @proto_priv_data: protocol specific private 912 * data. 913 * Return: none 914 */ 915 void 916 qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 917 uint8_t *sa, uint8_t *da, enum qdf_proto_type type, 918 enum qdf_proto_subtype subtype, enum qdf_proto_dir dir, 919 uint8_t pdev_id, bool print, uint32_t proto_priv_data); 920 921 void qdf_dp_trace_disable_live_mode(void); 922 void qdf_dp_trace_enable_live_mode(void); 923 void qdf_dp_trace_clear_buffer(void); 924 /** 925 * qdf_dp_trace_mgmt_pkt() - record mgmt packet 926 * @code: dptrace code 927 * @vdev_id: vdev id 928 * @pdev_id: pdev_id 929 * @type: proto type 930 * @subtype: proto subtype 931 * 932 * Return: none 933 */ 934 void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 935 uint8_t pdev_id, enum qdf_proto_type type, 936 enum qdf_proto_subtype subtype); 937 938 /** 939 * qdf_dp_trace_credit_record() - record credit update 940 * @source: source of record 941 * @operation: credit operation 942 * @delta: credit delta 943 * @total_credits: total credit 944 * @g0_credit: group 0 credit 945 * @g1_credit: group 1 credit 946 */ 947 void qdf_dp_trace_credit_record(enum QDF_CREDIT_UPDATE_SOURCE source, 948 enum QDF_CREDIT_OPERATION operation, 949 int delta, int total_credits, 950 int g0_credit, int g1_credit); 951 952 /** 953 * qdf_dp_display_mgmt_pkt() - display proto packet 954 * @record: dptrace record 955 * @index: index 956 * @pdev_id: pdev id for the mgmt pkt 957 * @info: info used to display pkt (live mode, throttling) 958 * 959 * Return: none 960 */ 961 void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record, 962 uint16_t index, uint8_t pdev_id, uint8_t info); 963 964 /** 965 * qdf_dp_display_credit_record() - display credit record 966 * @record: dptrace record 967 * @index: index 968 * @pdev_id: pdev id 969 * @info: metadeta info 970 */ 971 void qdf_dp_display_credit_record(struct qdf_dp_trace_record_s *record, 972 uint16_t index, uint8_t pdev_id, 973 uint8_t info); 974 975 /** 976 * qdf_dp_display_event_record() - display event records 977 * @record: dptrace record 978 * @index: index 979 * @pdev_id: pdev id for the mgmt pkt 980 * @info: info used to display pkt (live mode, throttling) 981 * 982 * Return: none 983 */ 984 void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record, 985 uint16_t index, uint8_t pdev_id, uint8_t info); 986 987 void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 988 uint8_t pdev_id, enum qdf_proto_type type, 989 enum qdf_proto_subtype subtype); 990 991 /** 992 * qdf_dp_set_proto_event_bitmap() - Set the protocol event bitmap 993 * @value: proto event bitmap value. 994 * 995 * QDF_NBUF_PKT_TRAC_TYPE_DNS 0x01 996 * QDF_NBUF_PKT_TRAC_TYPE_EAPOL 0x02 997 * QDF_NBUF_PKT_TRAC_TYPE_DHCP 0x04 998 * QDF_NBUF_PKT_TRAC_TYPE_ARP 0x10 999 * 1000 * Return: none 1001 */ 1002 void qdf_dp_set_proto_event_bitmap(uint32_t value); 1003 1004 /** 1005 * qdf_dp_log_proto_pkt_info() - Send diag log event 1006 * @sa: source MAC address 1007 * @da: destination MAC address 1008 * @type: pkt type 1009 * @subtype: pkt subtype 1010 * @dir: tx or rx 1011 * @msdu_id: msdu id 1012 * @status: status 1013 * 1014 * Return: none 1015 */ 1016 void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type, 1017 uint8_t subtype, uint8_t dir, uint16_t msdu_id, 1018 uint8_t status); 1019 1020 /** 1021 * qdf_dp_track_noack_check() - Check if no ack count should be tracked for 1022 * the configured protocol packet types 1023 * @nbuf: nbuf 1024 * @subtype: subtype of packet to be tracked 1025 * 1026 * Return: none 1027 */ 1028 void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype); 1029 #else 1030 static inline 1031 bool qdf_dp_trace_log_pkt(uint8_t vdev_id, struct sk_buff *skb, 1032 enum qdf_proto_dir dir, uint8_t pdev_id) 1033 { 1034 return false; 1035 } 1036 static inline 1037 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 1038 uint16_t time_limit, uint8_t verbosity, 1039 uint32_t proto_bitmap) 1040 { 1041 } 1042 1043 static inline 1044 void qdf_dp_trace_deinit(void) 1045 { 1046 } 1047 1048 static inline 1049 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir) 1050 { 1051 } 1052 static inline 1053 void qdf_dp_trace_set_value(uint32_t proto_bitmap, uint8_t no_of_records, 1054 uint8_t verbosity) 1055 { 1056 } 1057 1058 static inline 1059 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id) 1060 { 1061 } 1062 1063 static inline 1064 uint32_t qdf_dpt_get_curr_pos_debugfs(qdf_debugfs_file_t file, 1065 enum qdf_dpt_debugfs_state state) 1066 { 1067 return 0; 1068 } 1069 1070 static inline 1071 QDF_STATUS qdf_dpt_dump_stats_debugfs(qdf_debugfs_file_t file, 1072 uint32_t curr_pos) 1073 { 1074 return QDF_STATUS_SUCCESS; 1075 } 1076 1077 static inline 1078 void qdf_dpt_set_value_debugfs(uint8_t proto_bitmap, uint8_t no_of_record, 1079 uint8_t verbosity, uint16_t num_records_to_dump) 1080 { 1081 } 1082 1083 static inline void qdf_dp_trace_dump_stats(void) 1084 { 1085 } 1086 1087 static inline 1088 void qdf_dp_trace_disable_live_mode(void) 1089 { 1090 } 1091 1092 static inline 1093 void qdf_dp_trace_enable_live_mode(void) 1094 { 1095 } 1096 1097 static inline 1098 void qdf_dp_trace_throttle_live_mode(bool high_bw_request) 1099 { 1100 } 1101 1102 static inline 1103 void qdf_dp_trace_clear_buffer(void) 1104 { 1105 } 1106 1107 static inline 1108 void qdf_dp_trace_apply_tput_policy(bool is_data_traffic) 1109 { 1110 } 1111 1112 static inline 1113 void qdf_dp_trace_data_pkt(qdf_nbuf_t nbuf, uint8_t pdev_id, 1114 enum QDF_DP_TRACE_ID code, uint16_t msdu_id, 1115 enum qdf_proto_dir dir) 1116 { 1117 } 1118 1119 static inline 1120 void qdf_dp_log_proto_pkt_info(uint8_t *sa, uint8_t *da, uint8_t type, 1121 uint8_t subtype, uint8_t dir, uint16_t msdu_id, 1122 uint8_t status) 1123 { 1124 } 1125 1126 static inline 1127 void qdf_dp_track_noack_check(qdf_nbuf_t nbuf, enum qdf_proto_subtype *subtype) 1128 { 1129 } 1130 1131 static inline 1132 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_htt(uint8_t status) 1133 { 1134 return QDF_TX_RX_STATUS_OK; 1135 } 1136 1137 static inline 1138 enum qdf_dp_tx_rx_status qdf_dp_get_status_from_a_status(uint8_t status) 1139 { 1140 return QDF_TX_RX_STATUS_OK; 1141 } 1142 #endif 1143 1144 void qdf_trace_display(void); 1145 1146 int __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size, 1147 char *str_format, ...); 1148 1149 #define QDF_SNPRINTF qdf_snprintf 1150 1151 #ifdef TSOSEG_DEBUG 1152 1153 static inline void qdf_tso_seg_dbg_bug(char *msg) 1154 { 1155 qdf_print("%s", msg); 1156 QDF_BUG(0); 1157 }; 1158 1159 /** 1160 * qdf_tso_seg_dbg_init - initialize TSO segment debug structure 1161 * @tsoseg : structure to initialize 1162 * 1163 * TSO segment dbg structures are attached to qdf_tso_seg_elem_t 1164 * structures and are allocated only of TSOSEG_DEBUG is defined. 1165 * When allocated, at the time of the tso_seg_pool initialization, 1166 * which goes with tx_desc initialization (1:1), each structure holds 1167 * a number of (currently 16) history entries, basically describing 1168 * what operation has been performed on this particular tso_seg_elem. 1169 * This history buffer is a circular buffer and the current index is 1170 * held in an atomic variable called cur. It is incremented every 1171 * operation. Each of these operations are added with the function 1172 * qdf_tso_seg_dbg_record. 1173 * For each segment, this initialization function MUST be called PRIOR 1174 * TO any _dbg_record() function calls. 1175 * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero) 1176 * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element. 1177 * 1178 * Return: 1179 * None 1180 */ 1181 static inline 1182 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 1183 { 1184 tsoseg->dbg.txdesc = NULL; 1185 qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */ 1186 } 1187 1188 /** 1189 * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure 1190 * @tsoseg : structure to initialize 1191 * @id : operation ID (identifies the caller) 1192 * 1193 * Adds a history entry to the history circular buffer. Each entry 1194 * contains an operation id (caller, as currently each ID is used only 1195 * once in the source, so it directly identifies the src line that invoked 1196 * the recording. 1197 * 1198 * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized 1199 * by qdf_tso_seg_dbg_init. 1200 * 1201 * The entry to be added is written at the location pointed by the atomic 1202 * variable called cur. Cur is an ever increasing atomic variable. It is 1203 * masked so that only the lower 4 bits are used (16 history entries). 1204 * 1205 * Return: 1206 * int: the entry this record was recorded at 1207 */ 1208 static inline 1209 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 1210 { 1211 int rc = -1; 1212 unsigned int c; 1213 1214 qdf_assert(tsoseg); 1215 1216 if (id == TSOSEG_LOC_ALLOC) { 1217 c = qdf_atomic_read(&tsoseg->dbg.cur); 1218 /* dont crash on the very first alloc on the segment */ 1219 c &= 0x0f; 1220 /* allow only INIT and FREE ops before ALLOC */ 1221 if (tsoseg->dbg.h[c].id >= id) 1222 qdf_tso_seg_dbg_bug("Rogue TSO seg alloc"); 1223 } 1224 c = qdf_atomic_inc_return(&tsoseg->dbg.cur); 1225 1226 c &= 0x0f; 1227 tsoseg->dbg.h[c].ts = qdf_get_log_timestamp(); 1228 tsoseg->dbg.h[c].id = id; 1229 rc = c; 1230 1231 return rc; 1232 }; 1233 1234 static inline void 1235 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 1236 { 1237 if (tsoseg) 1238 tsoseg->dbg.txdesc = owner; 1239 }; 1240 1241 static inline void 1242 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 1243 { 1244 memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg)); 1245 return; 1246 }; 1247 1248 #else 1249 static inline 1250 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 1251 { 1252 }; 1253 static inline 1254 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 1255 { 1256 return 0; 1257 }; 1258 static inline void qdf_tso_seg_dbg_bug(char *msg) 1259 { 1260 }; 1261 static inline void 1262 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 1263 { 1264 }; 1265 static inline int 1266 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 1267 { 1268 memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t)); 1269 return 0; 1270 }; 1271 1272 #endif /* TSOSEG_DEBUG */ 1273 1274 /** 1275 * qdf_trace_hex_dump() - externally called hex dump function 1276 * @module: Module identifier a member of the QDF_MODULE_ID enumeration that 1277 * identifies the module issuing the trace message. 1278 * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating 1279 * the severity of the condition causing the trace message to be 1280 * issued. More severe conditions are more likely to be logged. 1281 * @data: The base address of the buffer to be logged. 1282 * @buf_len: The size of the buffer to be logged. 1283 * 1284 * Checks the level of severity and accordingly prints the trace messages 1285 * 1286 * Return: None 1287 */ 1288 void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 1289 void *data, int buf_len); 1290 1291 /** 1292 * qdf_trace_hex_ascii_dump() - externally called hex and ascii dump function 1293 * @module: Module identifier a member of the QDF_MODULE_ID enumeration that 1294 * identifies the module issuing the trace message. 1295 * @level: Trace level a member of the QDF_TRACE_LEVEL enumeration indicating 1296 * the severity of the condition causing the trace message to be 1297 * issued. More severe conditions are more likely to be logged. 1298 * @data: The base address of the buffer to be logged. 1299 * @buf_len: The size of the buffer to be logged. 1300 * 1301 * Checks the level of severity and accordingly prints the trace messages 1302 * 1303 * Return: None 1304 */ 1305 void qdf_trace_hex_ascii_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 1306 void *data, int buf_len); 1307 1308 #define ERROR_CODE -1 1309 #define QDF_MAX_NAME_SIZE 32 1310 #define MAX_PRINT_CONFIG_SUPPORTED 32 1311 1312 #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX 1313 1314 /** 1315 * qdf_set_pidx() - Sets the global qdf_pidx. 1316 * @pidx : Index of print control object assigned to the module 1317 * 1318 */ 1319 void qdf_set_pidx(int pidx); 1320 1321 /** 1322 * qdf_get_pidx() - Returns the global qdf_pidx. 1323 * 1324 * Return : Current qdf print index. 1325 */ 1326 int qdf_get_pidx(void); 1327 /* 1328 * Shared print control index 1329 * for converged debug framework 1330 */ 1331 1332 #define QDF_PRINT_IDX_SHARED -1 1333 1334 /** 1335 * QDF_PRINT_INFO() - Generic wrapper API for logging 1336 * @idx : Index of print control object 1337 * @module : Module identifier. A member of QDF_MODULE_ID enumeration that 1338 * identifies the module issuing the trace message 1339 * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating 1340 * the severity of the condition causing the trace message to be 1341 * issued. 1342 * @str_format : Format string that contains the message to be logged. 1343 * 1344 * 1345 * This wrapper will be used for any generic logging messages. Wrapper will 1346 * compile a call to converged QDF trace message API. 1347 * 1348 * Return : Nothing 1349 * 1350 */ 1351 void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module, 1352 QDF_TRACE_LEVEL level, 1353 char *str_format, ...); 1354 1355 /** 1356 * struct category_info : Category information structure 1357 * @category_verbose_mask: Embeds information about category's verbose level 1358 */ 1359 struct category_info { 1360 uint16_t category_verbose_mask; 1361 }; 1362 1363 /** 1364 * struct category_name_info : Category name information structure 1365 * @category_name_str: Embeds information about category name 1366 */ 1367 struct category_name_info { 1368 unsigned char category_name_str[QDF_MAX_NAME_SIZE]; 1369 }; 1370 1371 /** 1372 * qdf_trace_msg_cmn()- Converged logging API 1373 * @idx: Index of print control object assigned to the module 1374 * @category: Category identifier. A member of the QDF_MODULE_ID enumeration 1375 * that identifies the category issuing the trace message. 1376 * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration 1377 * indicating the severity of the condition causing the trace 1378 * message to be issued. More severe conditions are more likely 1379 * to be logged. 1380 * @str_format: Format string. The message to be logged. This format string 1381 * contains printf-like replacement parameters, which follow this 1382 * parameter in the variable argument list. 1383 * @val: Variable argument list part of the log message 1384 * 1385 * Return: nothing 1386 * 1387 */ 1388 void qdf_trace_msg_cmn(unsigned int idx, 1389 QDF_MODULE_ID category, 1390 QDF_TRACE_LEVEL verbose, 1391 const char *str_format, 1392 va_list val); 1393 1394 /** 1395 * struct qdf_print_ctrl: QDF Print Control structure 1396 * Statically allocated objects of print control 1397 * structure are declared that will support maximum of 1398 * 32 print control objects. Any module that needs to 1399 * register to the print control framework needs to 1400 * obtain a print control object using 1401 * qdf_print_ctrl_register API. It will have to pass 1402 * pointer to category info structure, name and 1403 * custom print function to be used if required. 1404 * @name : Optional name for the control object 1405 * @cat_info : Array of category_info struct 1406 * @custom_print : Custom print handler 1407 * @custom_ctxt : Custom print context 1408 * @dbglvlmac_on : Flag to enable/disable MAC level filtering 1409 * @in_use : Boolean to indicate if control object is in use 1410 */ 1411 struct qdf_print_ctrl { 1412 char name[QDF_MAX_NAME_SIZE]; 1413 struct category_info cat_info[MAX_SUPPORTED_CATEGORY]; 1414 void (*custom_print)(void *ctxt, const char *fmt, va_list args); 1415 void *custom_ctxt; 1416 #ifdef DBG_LVL_MAC_FILTERING 1417 unsigned char dbglvlmac_on; 1418 #endif 1419 bool in_use; 1420 }; 1421 1422 /** 1423 * qdf_print_ctrl_register() - Allocate QDF print control object, assign 1424 * pointer to category info or print control 1425 * structure and return the index to the callee 1426 * @cinfo : Pointer to array of category info structure 1427 * @custom_print_handler : Pointer to custom print handler 1428 * @custom_ctx : Pointer to custom context 1429 * @pctrl_name : Pointer to print control object name 1430 * 1431 * Return : Index of qdf_print_ctrl structure 1432 * 1433 */ 1434 int qdf_print_ctrl_register(const struct category_info *cinfo, 1435 void *custom_print_handler, 1436 void *custom_ctx, 1437 const char *pctrl_name); 1438 1439 #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI 1440 /** 1441 * qdf_update_module_param() - Update qdf module params 1442 * 1443 * 1444 * Read the file which has wifi module params, parse and update 1445 * qdf module params. 1446 * 1447 * Return: void 1448 */ 1449 void qdf_initialize_module_param_from_ini(void); 1450 #else 1451 static inline 1452 void qdf_initialize_module_param_from_ini(void) 1453 { 1454 } 1455 #endif 1456 1457 /** 1458 * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with 1459 * all categories set to the default level 1460 * 1461 * Return : void 1462 * 1463 */ 1464 void qdf_shared_print_ctrl_init(void); 1465 1466 /** 1467 * qdf_print_setup() - Setup default values to all the print control objects 1468 * 1469 * Register new print control object for the callee 1470 * 1471 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE 1472 * on failure 1473 */ 1474 QDF_STATUS qdf_print_setup(void); 1475 1476 /** 1477 * qdf_print_ctrl_cleanup() - Clean up a print control object 1478 * 1479 * Cleanup the print control object for the callee 1480 * 1481 * @pctrl : Index of print control object 1482 * 1483 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure 1484 */ 1485 QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx); 1486 1487 /** 1488 * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object 1489 * 1490 * Cleanup the shared print-ctrl-object 1491 * 1492 * Return : void 1493 */ 1494 void qdf_shared_print_ctrl_cleanup(void); 1495 1496 /** 1497 * qdf_print_set_category_verbose() - Enable/Disable category for a 1498 * print control object with 1499 * user provided verbose level 1500 * 1501 * @idx : Index of the print control object assigned to callee 1502 * @category : Category information 1503 * @verbose: Verbose information 1504 * @is_set: Flag indicating if verbose level needs to be enabled or disabled 1505 * 1506 * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure 1507 */ 1508 QDF_STATUS qdf_print_set_category_verbose(unsigned int idx, 1509 QDF_MODULE_ID category, 1510 QDF_TRACE_LEVEL verbose, 1511 bool is_set); 1512 1513 /** 1514 * qdf_log_dump_at_kernel_level() - Enable/Disable printk call 1515 * @enable: Indicates whether printk is enabled in QDF_TRACE 1516 * 1517 * Return: void 1518 */ 1519 void qdf_log_dump_at_kernel_level(bool enable); 1520 1521 /** 1522 * qdf_logging_set_flush_timer() - Set the time period in which host logs 1523 * should be flushed out to user-space 1524 * @milliseconds: milliseconds after which the logs should be flushed out to 1525 * user-space 1526 * 1527 * Return: QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure 1528 */ 1529 int qdf_logging_set_flush_timer(uint32_t milliseconds); 1530 1531 /** 1532 * qdf_logging_flush_logs() - Flush out the logs to user-space one time 1533 * 1534 * Return: void 1535 */ 1536 void qdf_logging_flush_logs(void); 1537 1538 /** 1539 * qdf_print_is_category_enabled() - Get category information for the 1540 * print control object 1541 * 1542 * @idx : Index of print control object 1543 * @category : Category information 1544 * 1545 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 1546 */ 1547 bool qdf_print_is_category_enabled(unsigned int idx, 1548 QDF_MODULE_ID category); 1549 1550 /** 1551 * qdf_print_is_verbose_enabled() - Get verbose information of a category for 1552 * the print control object 1553 * 1554 * @idx : Index of print control object 1555 * @category : Category information 1556 * @verbose : Verbose information 1557 * 1558 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 1559 */ 1560 bool qdf_print_is_verbose_enabled(unsigned int idx, 1561 QDF_MODULE_ID category, 1562 QDF_TRACE_LEVEL verbose); 1563 1564 /** 1565 * qdf_print_clean_node_flag() - Clean up node flag for print control object 1566 * 1567 * @idx : Index of print control object 1568 * 1569 * Return : None 1570 */ 1571 void qdf_print_clean_node_flag(unsigned int idx); 1572 1573 #ifdef DBG_LVL_MAC_FILTERING 1574 1575 /** 1576 * qdf_print_set_node_flag() - Set flag to enable MAC level filtering 1577 * 1578 * @idx : Index of print control object 1579 * @enable : Enable/Disable bit sent by callee 1580 * 1581 * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure 1582 */ 1583 QDF_STATUS qdf_print_set_node_flag(unsigned int idx, 1584 uint8_t enable); 1585 1586 /** 1587 * qdf_print_get_node_flag() - Get flag that controls MAC level filtering 1588 * 1589 * @idx : Index of print control object 1590 * 1591 * Return : Flag that indicates enable(1) or disable(0) or invalid(-1) 1592 */ 1593 bool qdf_print_get_node_flag(unsigned int idx); 1594 1595 #endif 1596 1597 #ifdef QCA_WIFI_MODULE_PARAMS_FROM_INI 1598 /** 1599 * qdf_module_param_handler() - Function to store module params 1600 * 1601 * @context : NULL, unused. 1602 * @key : Name of the module param 1603 * @value: Value of the module param 1604 * 1605 * Handler function to be called from qdf_ini_parse() 1606 * function when a valid parameter is found in a file. 1607 * 1608 * Return : QDF_STATUS_SUCCESS on Success 1609 */ 1610 QDF_STATUS qdf_module_param_handler(void *context, const char *key, 1611 const char *value); 1612 #else 1613 static inline 1614 QDF_STATUS qdf_module_param_handler(void *context, const char *key, 1615 const char *value) 1616 { 1617 return QDF_STATUS_SUCCESS; 1618 } 1619 #endif 1620 1621 /** 1622 * qdf_logging_init() - Initialize msg logging functionality 1623 * 1624 * 1625 * Return : void 1626 */ 1627 void qdf_logging_init(void); 1628 1629 /** 1630 * qdf_logging_exit() - Cleanup msg logging functionality 1631 * 1632 * 1633 * Return : void 1634 */ 1635 void qdf_logging_exit(void); 1636 1637 #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN 1638 1639 /** 1640 * qdf_sprint_symbol() - prints the name of a symbol into a string buffer 1641 * @buffer: the string buffer to print into 1642 * @addr: address of the symbol to lookup and print 1643 * 1644 * Return: number of characters printed 1645 */ 1646 int qdf_sprint_symbol(char *buffer, void *addr); 1647 1648 /** 1649 * qdf_minidump_log() - Log memory address to be included in minidump 1650 * @start_addr: Start address of the memory to be dumped 1651 * @size: Size in bytes 1652 * @name: String to identify this entry 1653 */ 1654 static inline 1655 void qdf_minidump_log(void *start_addr, 1656 const size_t size, const char *name) 1657 { 1658 __qdf_minidump_log(start_addr, size, name); 1659 } 1660 1661 /** 1662 * qdf_minidump_remove() - Remove memory address from minidump 1663 * @start_addr: Start address of the memory previously added 1664 * @size: Size in bytes 1665 * @name: String to identify this entry 1666 */ 1667 static inline 1668 void qdf_minidump_remove(void *start_addr, 1669 const size_t size, const char *name) 1670 { 1671 __qdf_minidump_remove(start_addr, size, name); 1672 } 1673 1674 #endif /* __QDF_TRACE_H */ 1675