1 /* 2 * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 28 #if !defined(__QDF_TRACE_H) 29 #define __QDF_TRACE_H 30 31 /** 32 * DOC: qdf_trace 33 * QCA driver framework trace APIs 34 * Trace, logging, and debugging definitions and APIs 35 */ 36 37 /* Include Files */ 38 #include <qdf_types.h> /* For QDF_MODULE_ID... */ 39 #include <stdarg.h> /* For va_list... */ 40 #include <qdf_status.h> 41 #include <qdf_nbuf.h> 42 #include <i_qdf_types.h> 43 44 /* Type declarations */ 45 46 #define FL(x) "%s: %d: " x, __func__, __LINE__ 47 #define QDF_TRACE_BUFFER_SIZE (512) 48 49 #ifdef CONFIG_MCL 50 #define QDF_DEFAULT_TRACE_LEVEL \ 51 ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR)) 52 #else 53 #define QDF_DEFAULT_TRACE_LEVEL (1 << QDF_TRACE_LEVEL_INFO) 54 #endif 55 56 #define QDF_CATEGORY_INFO_U16(val) (((val >> 16) & 0x0000FFFF)) 57 #define QDF_TRACE_LEVEL_INFO_L16(val) (val & 0x0000FFFF) 58 59 typedef int (qdf_abstract_print)(void *priv, const char *fmt, ...); 60 61 /* 62 * Log levels 63 */ 64 #define QDF_DEBUG_FUNCTRACE 0x01 65 #define QDF_DEBUG_LEVEL0 0x02 66 #define QDF_DEBUG_LEVEL1 0x04 67 #define QDF_DEBUG_LEVEL2 0x08 68 #define QDF_DEBUG_LEVEL3 0x10 69 #define QDF_DEBUG_ERROR 0x20 70 #define QDF_DEBUG_CFG 0x40 71 72 73 /* DP Trace Implementation */ 74 #ifdef CONFIG_DP_TRACE 75 #define DPTRACE(p) p 76 #else 77 #define DPTRACE(p) 78 #endif 79 80 /* By default Data Path module will have all log levels enabled, except debug 81 * log level. Debug level will be left up to the framework or user space modules 82 * to be enabled when issue is detected 83 */ 84 #define QDF_DATA_PATH_TRACE_LEVEL \ 85 ((1 << QDF_TRACE_LEVEL_FATAL) | (1 << QDF_TRACE_LEVEL_ERROR) | \ 86 (1 << QDF_TRACE_LEVEL_WARN) | (1 << QDF_TRACE_LEVEL_INFO) | \ 87 (1 << QDF_TRACE_LEVEL_INFO_HIGH) | (1 << QDF_TRACE_LEVEL_INFO_MED) | \ 88 (1 << QDF_TRACE_LEVEL_INFO_LOW)) 89 90 /* Preprocessor definitions and constants */ 91 #define ASSERT_BUFFER_SIZE (512) 92 93 #define QDF_TRACE_DEFAULT_PDEV_ID 0xff 94 #define MAX_QDF_TRACE_RECORDS 4000 95 #define INVALID_QDF_TRACE_ADDR 0xffffffff 96 #define DEFAULT_QDF_TRACE_DUMP_COUNT 0 97 98 /* 99 * first parameter to iwpriv command - dump_dp_trace 100 * iwpriv wlan0 dump_dp_trace 0 0 -> dump full buffer 101 * iwpriv wlan0 dump_dp_trace 1 0 -> enable live view mode 102 * iwpriv wlan0 dump_dp_trace 2 0 -> clear dp trace buffer 103 * iwpriv wlan0 dump_dp_trace 3 0 -> disable live view mode 104 */ 105 #define DUMP_DP_TRACE 0 106 #define ENABLE_DP_TRACE_LIVE_MODE 1 107 #define CLEAR_DP_TRACE_BUFFER 2 108 #define DISABLE_DP_TRACE_LIVE_MODE 3 109 110 111 #ifdef TRACE_RECORD 112 113 #define MTRACE(p) p 114 115 #else 116 #define MTRACE(p) do { } while (0) 117 118 #endif 119 #define NO_SESSION 0xFF 120 121 /** 122 * typedef struct qdf_trace_record_s - keep trace record 123 * @qtime: qtimer ticks 124 * @time: user timestamp 125 * @module: module name 126 * @code: hold record of code 127 * @session: hold record of session 128 * @data: hold data 129 * @pid: hold pid of the process 130 */ 131 typedef struct qdf_trace_record_s { 132 uint64_t qtime; 133 char time[18]; 134 uint8_t module; 135 uint8_t code; 136 uint16_t session; 137 uint32_t data; 138 uint32_t pid; 139 } qdf_trace_record_t, *tp_qdf_trace_record; 140 141 /** 142 * typedef struct s_qdf_trace_data - MTRACE logs are stored in ring buffer 143 * @head: position of first record 144 * @tail: position of last record 145 * @num: count of total record 146 * @num_since_last_dump: count from last dump 147 * @enable: config for controlling the trace 148 * @dump_count: Dump after number of records reach this number 149 */ 150 typedef struct s_qdf_trace_data { 151 uint32_t head; 152 uint32_t tail; 153 uint32_t num; 154 uint16_t num_since_last_dump; 155 uint8_t enable; 156 uint16_t dump_count; 157 } t_qdf_trace_data; 158 159 #define CASE_RETURN_STRING(str) case ((str)): return (uint8_t *)(# str); 160 161 162 #define MAX_QDF_DP_TRACE_RECORDS 4000 163 #define QDF_DP_TRACE_RECORD_SIZE 16 164 #define INVALID_QDF_DP_TRACE_ADDR 0xffffffff 165 #define QDF_DP_TRACE_VERBOSITY_HIGH 3 166 #define QDF_DP_TRACE_VERBOSITY_MEDIUM 2 167 #define QDF_DP_TRACE_VERBOSITY_LOW 1 168 #define QDF_DP_TRACE_VERBOSITY_BASE 0 169 170 /** 171 * enum QDF_DP_TRACE_ID - Generic ID to identify various events in data path 172 * @QDF_DP_TRACE_INVALID - invalid 173 * @QDF_DP_TRACE_DROP_PACKET_RECORD - record drop packet 174 * @QDF_DP_TRACE_EAPOL_PACKET_RECORD - record EAPOL packet 175 * @QDF_DP_TRACE_DHCP_PACKET_RECORD - record DHCP packet 176 * @QDF_DP_TRACE_ARP_PACKET_RECORD - record ARP packet 177 * @QDF_DP_TRACE_MGMT_PACKET_RECORD - record MGMT pacekt 178 * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packet 179 * @QDF_DP_TRACE_ICMPv6_PACKET_RECORD - record ICMPv6 packet 180 * QDF_DP_TRACE_EVENT_RECORD - record events 181 * @QDF_DP_TRACE_BASE_VERBOSITY - below this are part of base verbosity 182 * @QDF_DP_TRACE_ICMP_PACKET_RECORD - record ICMP packets 183 * @QDF_DP_TRACE_HDD_TX_PACKET_RECORD - record 32 bytes of tx pkt at HDD 184 * @QDF_DP_TRACE_HDD_RX_PACKET_RECORD - record 32 bytes of rx pkt at HDD 185 * @QDF_DP_TRACE_HDD_TX_TIMEOUT - HDD tx timeout 186 * @QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT- SOFTAP HDD tx timeout 187 * @QDF_DP_TRACE_FREE_PACKET_PTR_RECORD - tx completion ptr record 188 * @QDF_DP_TRACE_LOW_VERBOSITY - below this are part of low verbosity 189 * @QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD - HDD layer ptr record 190 * @QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD - Lithium DP layer ptr record 191 * @QDF_DP_TRACE_CE_PACKET_PTR_RECORD - CE layer ptr record 192 * @QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD- CE fastpath ptr record 193 * @QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD- CE fastpath error record 194 * @QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD - HTT RX record 195 * @QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD- HTT RX offload record 196 * @QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD - HDD RX record 197 * @QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD - Lithium DP RX record 198 * @QDF_DP_TRACE_MED_VERBOSITY - below this are part of med verbosity 199 * @QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD -tx queue ptr record 200 * @QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD - txrx packet ptr record 201 * @QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD - txrx fast path record 202 * @QDF_DP_TRACE_HTT_PACKET_PTR_RECORD - htt packet ptr record 203 * @QDF_DP_TRACE_HTC_PACKET_PTR_RECORD - htc packet ptr record 204 * @QDF_DP_TRACE_HIF_PACKET_PTR_RECORD - hif packet ptr record 205 * @QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD - txrx packet ptr record 206 * @QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD - record 32 bytes of tx pkt at LI_DP 207 * @QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD - record 32 bytes of rx pkt at LI_DP 208 * @QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD 209 * - record 32 bytes of rx null_queue pkt at LI_DP 210 * @QDF_DP_TRACE_HIGH_VERBOSITY - below this are part of high verbosity 211 */ 212 enum QDF_DP_TRACE_ID { 213 QDF_DP_TRACE_INVALID, 214 QDF_DP_TRACE_DROP_PACKET_RECORD, 215 QDF_DP_TRACE_EAPOL_PACKET_RECORD, 216 QDF_DP_TRACE_DHCP_PACKET_RECORD, 217 QDF_DP_TRACE_ARP_PACKET_RECORD, 218 QDF_DP_TRACE_MGMT_PACKET_RECORD, 219 QDF_DP_TRACE_EVENT_RECORD, 220 QDF_DP_TRACE_BASE_VERBOSITY, 221 QDF_DP_TRACE_ICMP_PACKET_RECORD, 222 QDF_DP_TRACE_ICMPv6_PACKET_RECORD, 223 QDF_DP_TRACE_HDD_TX_PACKET_RECORD, 224 QDF_DP_TRACE_HDD_RX_PACKET_RECORD, 225 QDF_DP_TRACE_HDD_TX_TIMEOUT, 226 QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT, 227 QDF_DP_TRACE_FREE_PACKET_PTR_RECORD, 228 QDF_DP_TRACE_LOW_VERBOSITY, 229 QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD, 230 QDF_DP_TRACE_LI_DP_TX_PACKET_PTR_RECORD, 231 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD, 232 QDF_DP_TRACE_CE_PACKET_PTR_RECORD, 233 QDF_DP_TRACE_CE_FAST_PACKET_PTR_RECORD, 234 QDF_DP_TRACE_CE_FAST_PACKET_ERR_RECORD, 235 QDF_DP_TRACE_RX_HTT_PACKET_PTR_RECORD, 236 QDF_DP_TRACE_RX_OFFLOAD_HTT_PACKET_PTR_RECORD, 237 QDF_DP_TRACE_RX_LI_DP_PACKET_PTR_RECORD, 238 QDF_DP_TRACE_MED_VERBOSITY, 239 QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD, 240 QDF_DP_TRACE_TXRX_PACKET_PTR_RECORD, 241 QDF_DP_TRACE_TXRX_FAST_PACKET_PTR_RECORD, 242 QDF_DP_TRACE_HTT_PACKET_PTR_RECORD, 243 QDF_DP_TRACE_HTC_PACKET_PTR_RECORD, 244 QDF_DP_TRACE_HIF_PACKET_PTR_RECORD, 245 QDF_DP_TRACE_RX_TXRX_PACKET_PTR_RECORD, 246 QDF_DP_TRACE_LI_DP_TX_PACKET_RECORD, 247 QDF_DP_TRACE_LI_DP_RX_PACKET_RECORD, 248 QDF_DP_TRACE_LI_DP_NULL_RX_PACKET_RECORD, 249 QDF_DP_TRACE_HIGH_VERBOSITY, 250 QDF_DP_TRACE_MAX 251 }; 252 253 /** 254 * qdf_proto_dir - direction 255 * @QDF_TX: TX direction 256 * @QDF_RX: RX direction 257 * @QDF_NA: not applicable 258 */ 259 enum qdf_proto_dir { 260 QDF_TX, 261 QDF_RX, 262 QDF_NA 263 }; 264 265 /** 266 * struct qdf_dp_trace_ptr_buf - pointer record buffer 267 * @cookie: cookie value 268 * @msdu_id: msdu_id 269 * @status: completion status 270 */ 271 struct qdf_dp_trace_ptr_buf { 272 uint64_t cookie; 273 uint16_t msdu_id; 274 uint16_t status; 275 }; 276 277 /** 278 * struct qdf_dp_trace_proto_buf - proto packet buffer 279 * @sa: source address 280 * @da: destination address 281 * @vdev_id : vdev id 282 * @type: packet type 283 * @subtype: packet subtype 284 * @dir: direction 285 */ 286 struct qdf_dp_trace_proto_buf { 287 struct qdf_mac_addr sa; 288 struct qdf_mac_addr da; 289 uint8_t vdev_id; 290 uint8_t type; 291 uint8_t subtype; 292 uint8_t dir; 293 }; 294 295 /** 296 * struct qdf_dp_trace_mgmt_buf - mgmt packet buffer 297 * @vdev_id : vdev id 298 * @type: packet type 299 * @subtype: packet subtype 300 */ 301 struct qdf_dp_trace_mgmt_buf { 302 uint8_t vdev_id; 303 uint8_t type; 304 uint8_t subtype; 305 }; 306 307 /** 308 * struct qdf_dp_trace_event_buf - event buffer 309 * @vdev_id : vdev id 310 * @type: packet type 311 * @subtype: packet subtype 312 */ 313 struct qdf_dp_trace_event_buf { 314 uint8_t vdev_id; 315 uint8_t type; 316 uint8_t subtype; 317 }; 318 319 /** 320 * struct qdf_dp_trace_record_s - Describes a record in DP trace 321 * @time: time when it got stored 322 * @code: Describes the particular event 323 * @data: buffer to store data 324 * @size: Length of the valid data stored in this record 325 * @pid : process id which stored the data in this record 326 */ 327 struct qdf_dp_trace_record_s { 328 char time[20]; 329 uint8_t code; 330 uint8_t data[QDF_DP_TRACE_RECORD_SIZE]; 331 uint8_t size; 332 uint32_t pid; 333 uint8_t pdev_id; 334 }; 335 336 /** 337 * struct qdf_dp_trace_data - Parameters to configure/control DP trace 338 * @head: Position of first record 339 * @tail: Position of last record 340 * @num: Current index 341 * @proto_bitmap: defines which protocol to be traced 342 * @no_of_record: defines every nth packet to be traced 343 * @verbosity : defines verbosity level 344 * @enable: enable/disable DP trace 345 * @count: current packet number 346 * @live_mode_config: configuration as received during initialization 347 * @live_mode: current live mode, enabled or disabled. 348 * @print_pkt_cnt: count of number of packets printed in live mode 349 * @high_tput_thresh: thresh beyond which live mode is turned off 350 * @thresh_time_limit: max time, in terms of BW timer intervals to wait, 351 * for determining if high_tput_thresh has been crossed. ~1s 352 * @arp_req: stats for arp reqs 353 * @arp_resp: stats for arp resps 354 * @icmp_req: stats for icmp reqs 355 * @icmp_resp: stats for icmp resps 356 * @dhcp_disc: stats for dhcp discover msgs 357 * @dhcp_req: stats for dhcp req msgs 358 * @dhcp_off: stats for dhcp offer msgs 359 * @dhcp_ack: stats for dhcp ack msgs 360 * @dhcp_nack: stats for dhcp nack msgs 361 * @dhcp_others: stats for other dhcp pkts types 362 * @eapol_m1: stats for eapol m1 363 * @eapol_m2: stats for eapol m2 364 * @eapol_m3: stats for eapol m3 365 * @eapol_m4: stats for eapol m4 366 * @eapol_others: stats for other eapol pkt types 367 * @icmpv6_req: stats for icmpv6 reqs 368 * @icmpv6_resp: stats for icmpv6 resps 369 * @icmpv6_ns: stats for icmpv6 nss 370 * @icmpv6_na: stats for icmpv6 nas 371 * @icmpv6_rs: stats for icmpv6 rss 372 * @icmpv6_ra: stats for icmpv6 ras 373 */ 374 struct s_qdf_dp_trace_data { 375 uint32_t head; 376 uint32_t tail; 377 uint32_t num; 378 uint8_t proto_bitmap; 379 uint8_t no_of_record; 380 uint8_t verbosity; 381 bool enable; 382 bool live_mode_config; 383 bool live_mode; 384 uint8_t print_pkt_cnt; 385 uint8_t high_tput_thresh; 386 uint16_t thresh_time_limit; 387 /* Stats */ 388 uint32_t tx_count; 389 uint32_t rx_count; 390 u16 arp_req; 391 u16 arp_resp; 392 u16 dhcp_disc; 393 u16 dhcp_req; 394 u16 dhcp_off; 395 u16 dhcp_ack; 396 u16 dhcp_nack; 397 u16 dhcp_others; 398 u16 eapol_m1; 399 u16 eapol_m2; 400 u16 eapol_m3; 401 u16 eapol_m4; 402 u16 eapol_others; 403 u16 icmp_req; 404 u16 icmp_resp; 405 u16 icmpv6_req; 406 u16 icmpv6_resp; 407 u16 icmpv6_ns; 408 u16 icmpv6_na; 409 u16 icmpv6_rs; 410 u16 icmpv6_ra; 411 }; 412 413 414 /* Function declarations and documenation */ 415 416 /** 417 * qdf_trace_set_level() - Set the trace level for a particular module 418 * @level : trace level 419 * 420 * Trace level is a member of the QDF_TRACE_LEVEL enumeration indicating 421 * the severity of the condition causing the trace message to be issued. 422 * More severe conditions are more likely to be logged. 423 * 424 * This is an external API that allows trace levels to be set for each module. 425 * 426 * Return: nothing 427 */ 428 void qdf_trace_set_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level); 429 430 /** 431 * qdf_trace_get_level() - get the trace level 432 * @level : trace level 433 * 434 * This is an external API that returns a bool value to signify if a 435 * particular trace level is set for the specified module. 436 * A member of the QDF_TRACE_LEVEL enumeration indicating the severity 437 * of the condition causing the trace message to be issued. 438 * 439 * Note that individual trace levels are the only valid values 440 * for this API. QDF_TRACE_LEVEL_NONE and QDF_TRACE_LEVEL_ALL 441 * are not valid input and will return false 442 * 443 * Return: 444 * false - the specified trace level for the specified module is OFF 445 * true - the specified trace level for the specified module is ON 446 */ 447 bool qdf_trace_get_level(QDF_MODULE_ID module, QDF_TRACE_LEVEL level); 448 449 typedef void (*tp_qdf_trace_cb)(void *p_mac, tp_qdf_trace_record, uint16_t); 450 typedef void (*tp_qdf_state_info_cb) (char **buf, uint16_t *size); 451 void qdf_register_debugcb_init(void); 452 void qdf_register_debug_callback(QDF_MODULE_ID module_id, 453 tp_qdf_state_info_cb qdf_state_infocb); 454 QDF_STATUS qdf_state_info_dump_all(char *buf, uint16_t size, 455 uint16_t *driver_dump_size); 456 #ifdef TRACE_RECORD 457 void qdf_trace_register(QDF_MODULE_ID, tp_qdf_trace_cb); 458 void qdf_trace_init(void); 459 void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data); 460 void qdf_trace_enable(uint32_t, uint8_t enable); 461 void qdf_trace_dump_all(void *, uint8_t, uint8_t, uint32_t, uint32_t); 462 QDF_STATUS qdf_trace_spin_lock_init(void); 463 #else 464 #ifdef CONFIG_MCL 465 static inline 466 void qdf_trace_init(void) 467 { 468 } 469 470 static inline 471 void qdf_trace_enable(uint32_t bitmask_of_module_id, uint8_t enable) 472 { 473 } 474 static inline 475 void qdf_trace(uint8_t module, uint8_t code, uint16_t session, uint32_t data) 476 { 477 } 478 479 static inline 480 void qdf_trace_dump_all(void *p_mac, uint8_t code, uint8_t session, 481 uint32_t count, uint32_t bitmask_of_module) 482 { 483 } 484 485 static inline 486 QDF_STATUS qdf_trace_spin_lock_init(void) 487 { 488 return QDF_STATUS_E_INVAL; 489 } 490 #endif 491 #endif 492 493 #ifdef CONFIG_DP_TRACE 494 void qdf_dp_set_proto_bitmap(uint32_t val); 495 void qdf_dp_trace_set_verbosity(uint32_t val); 496 void qdf_dp_set_no_of_record(uint32_t val); 497 bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb, 498 enum qdf_proto_dir dir, uint8_t pdev_id); 499 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 500 uint16_t time_limit, uint8_t verbosity, 501 uint8_t proto_bitmap); 502 void qdf_dp_trace_spin_lock_init(void); 503 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records, 504 uint8_t verbosity); 505 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir); 506 void qdf_dp_trace(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, uint8_t pdev_id, 507 uint8_t *data, uint8_t size, enum qdf_proto_dir dir); 508 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id); 509 /** 510 * qdf_dp_trace_dump_stats() - dump DP Trace stats 511 * 512 * Return: none 513 */ 514 void qdf_dp_trace_dump_stats(void); 515 typedef void (*tp_qdf_dp_trace_cb)(struct qdf_dp_trace_record_s*, 516 uint16_t, uint8_t, bool live); 517 void qdf_dp_display_record(struct qdf_dp_trace_record_s *record, 518 uint16_t index, uint8_t pdev_id, bool live); 519 void qdf_dp_trace_ptr(qdf_nbuf_t nbuf, enum QDF_DP_TRACE_ID code, 520 uint8_t pdev_id, uint8_t *data, uint8_t size, uint16_t msdu_id, 521 uint16_t status); 522 void qdf_dp_trace_throttle_live_mode(bool high_bw_request); 523 void qdf_dp_display_ptr_record(struct qdf_dp_trace_record_s *pRecord, 524 uint16_t recIndex, uint8_t pdev_id, bool live); 525 void qdf_dp_display_proto_pkt(struct qdf_dp_trace_record_s *record, 526 uint16_t index, uint8_t pdev_id, bool live); 527 uint8_t qdf_dp_get_proto_bitmap(void); 528 uint8_t qdf_dp_get_verbosity(void); 529 uint8_t qdf_dp_get_no_of_record(void); 530 void 531 qdf_dp_trace_proto_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 532 uint8_t *sa, uint8_t *da, enum qdf_proto_type type, 533 enum qdf_proto_subtype subtype, enum qdf_proto_dir dir, 534 uint8_t pdev_id, bool print); 535 void qdf_dp_trace_disable_live_mode(void); 536 void qdf_dp_trace_enable_live_mode(void); 537 void qdf_dp_trace_clear_buffer(void); 538 void qdf_dp_trace_mgmt_pkt(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 539 uint8_t pdev_id, enum qdf_proto_type type, 540 enum qdf_proto_subtype subtype); 541 void qdf_dp_display_mgmt_pkt(struct qdf_dp_trace_record_s *record, 542 uint16_t index, uint8_t pdev_id, bool live); 543 void qdf_dp_display_event_record(struct qdf_dp_trace_record_s *record, 544 uint16_t index, uint8_t pdev_id, bool live); 545 void qdf_dp_trace_record_event(enum QDF_DP_TRACE_ID code, uint8_t vdev_id, 546 uint8_t pdev_id, enum qdf_proto_type type, 547 enum qdf_proto_subtype subtype); 548 #else 549 static inline 550 bool qdf_dp_trace_log_pkt(uint8_t session_id, struct sk_buff *skb, 551 enum qdf_proto_dir dir, uint8_t pdev_id) 552 { 553 return false; 554 } 555 static inline 556 void qdf_dp_trace_init(bool live_mode_config, uint8_t thresh, 557 uint16_t time_limit, uint8_t verbosity, 558 uint8_t proto_bitmap) 559 { 560 } 561 static inline 562 void qdf_dp_trace_set_track(qdf_nbuf_t nbuf, enum qdf_proto_dir dir) 563 { 564 } 565 static inline 566 void qdf_dp_trace_set_value(uint8_t proto_bitmap, uint8_t no_of_records, 567 uint8_t verbosity) 568 { 569 } 570 static inline 571 void qdf_dp_trace_dump_all(uint32_t count, uint8_t pdev_id) 572 { 573 } 574 575 static inline void qdf_dp_trace_dump_stats(void) 576 { 577 } 578 579 static inline 580 void qdf_dp_trace_disable_live_mode(void) 581 { 582 } 583 584 static inline 585 void qdf_dp_trace_enable_live_mode(void) 586 { 587 } 588 589 static inline 590 void qdf_dp_trace_throttle_live_mode(bool high_bw_request) 591 { 592 } 593 594 static inline 595 void qdf_dp_trace_clear_buffer(void) 596 { 597 } 598 599 #endif 600 601 602 603 void qdf_trace_display(void); 604 605 void qdf_trace_set_value(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 606 uint8_t on); 607 608 void qdf_trace_set_module_trace_level(QDF_MODULE_ID module, uint32_t level); 609 610 void __printf(3, 4) qdf_snprintf(char *str_buffer, unsigned int size, 611 char *str_format, ...); 612 613 #define QDF_SNPRINTF qdf_snprintf 614 615 #ifdef TSOSEG_DEBUG 616 617 static inline void qdf_tso_seg_dbg_bug(char *msg) 618 { 619 qdf_print("%s", msg); 620 QDF_BUG(0); 621 }; 622 623 /** 624 * qdf_tso_seg_dbg_init - initialize TSO segment debug structure 625 * @tsoseg : structure to initialize 626 * 627 * TSO segment dbg structures are attached to qdf_tso_seg_elem_t 628 * structures and are allocated only of TSOSEG_DEBUG is defined. 629 * When allocated, at the time of the tso_seg_pool initialization, 630 * which goes with tx_desc initialization (1:1), each structure holds 631 * a number of (currently 16) history entries, basically describing 632 * what operation has been performed on this particular tso_seg_elem. 633 * This history buffer is a circular buffer and the current index is 634 * held in an atomic variable called cur. It is incremented every 635 * operation. Each of these operations are added with the function 636 * qdf_tso_seg_dbg_record. 637 * For each segment, this initialization function MUST be called PRIOR 638 * TO any _dbg_record() function calls. 639 * On free, qdf_tso_seg_elem structure is cleared (using qdf_tso_seg_dbg_zero) 640 * which clears the tso_desc, BUT DOES NOT CLEAR THE HISTORY element. 641 * 642 * Return: 643 * None 644 */ 645 static inline 646 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 647 { 648 tsoseg->dbg.txdesc = NULL; 649 qdf_atomic_init(&tsoseg->dbg.cur); /* history empty */ 650 } 651 652 /** 653 * qdf_tso_seg_dbg_record - add a history entry to TSO debug structure 654 * @tsoseg : structure to initialize 655 * @id : operation ID (identifies the caller) 656 * 657 * Adds a history entry to the history circular buffer. Each entry 658 * contains an operation id (caller, as currently each ID is used only 659 * once in the source, so it directly identifies the src line that invoked 660 * the recording. 661 * 662 * qdf_tso_seg_dbg_record CAN ONLY BE CALLED AFTER the entry is initialized 663 * by qdf_tso_seg_dbg_init. 664 * 665 * The entry to be added is written at the location pointed by the atomic 666 * variable called cur. Cur is an ever increasing atomic variable. It is 667 * masked so that only the lower 4 bits are used (16 history entries). 668 * 669 * Return: 670 * int: the entry this record was recorded at 671 */ 672 static inline 673 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 674 { 675 int rc = -1; 676 unsigned int c; 677 678 qdf_assert(tsoseg); 679 680 if (id == TSOSEG_LOC_ALLOC) { 681 c = qdf_atomic_read(&tsoseg->dbg.cur); 682 /* dont crash on the very first alloc on the segment */ 683 c &= 0x0f; 684 /* allow only INIT and FREE ops before ALLOC */ 685 if (tsoseg->dbg.h[c].id >= id) 686 qdf_tso_seg_dbg_bug("Rogue TSO seg alloc"); 687 } 688 c = qdf_atomic_inc_return(&tsoseg->dbg.cur); 689 690 c &= 0x0f; 691 tsoseg->dbg.h[c].ts = qdf_get_log_timestamp(); 692 tsoseg->dbg.h[c].id = id; 693 rc = c; 694 695 return rc; 696 }; 697 698 static inline void 699 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 700 { 701 if (tsoseg) 702 tsoseg->dbg.txdesc = owner; 703 }; 704 705 static inline void 706 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 707 { 708 memset(tsoseg, 0, offsetof(struct qdf_tso_seg_elem_t, dbg)); 709 return; 710 }; 711 712 #else 713 static inline 714 void qdf_tso_seg_dbg_init(struct qdf_tso_seg_elem_t *tsoseg) 715 { 716 }; 717 static inline 718 int qdf_tso_seg_dbg_record(struct qdf_tso_seg_elem_t *tsoseg, short id) 719 { 720 return 0; 721 }; 722 static inline void qdf_tso_seg_dbg_bug(char *msg) 723 { 724 }; 725 static inline void 726 qdf_tso_seg_dbg_setowner(struct qdf_tso_seg_elem_t *tsoseg, void *owner) 727 { 728 }; 729 static inline int 730 qdf_tso_seg_dbg_zero(struct qdf_tso_seg_elem_t *tsoseg) 731 { 732 memset(tsoseg, 0, sizeof(struct qdf_tso_seg_elem_t)); 733 return 0; 734 }; 735 736 #endif /* TSOSEG_DEBUG */ 737 738 void qdf_trace_hex_dump(QDF_MODULE_ID module, QDF_TRACE_LEVEL level, 739 void *data, int buf_len); 740 741 #define ERROR_CODE -1 742 #define QDF_MAX_NAME_SIZE 32 743 #define MAX_PRINT_CONFIG_SUPPORTED 32 744 745 #define MAX_SUPPORTED_CATEGORY QDF_MODULE_ID_MAX 746 747 /** 748 * qdf_set_pidx() - Sets the global qdf_pidx. 749 * @pidx : Index of print control object assigned to the module 750 * 751 */ 752 void qdf_set_pidx(int pidx); 753 754 /** 755 * qdf_get_pidx() - Returns the global qdf_pidx. 756 * 757 * Return : Current qdf print index. 758 */ 759 int qdf_get_pidx(void); 760 /* 761 * Shared print control index 762 * for converged debug framework 763 */ 764 765 #define QDF_PRINT_IDX_SHARED -1 766 767 /** 768 * QDF_PRINT_INFO() - Generic wrapper API for logging 769 * @idx : Index of print control object 770 * @module : Module identifier. A member of QDF_MODULE_ID enumeration that 771 * identifies the module issuing the trace message 772 * @level : Trace level. A member of QDF_TRACE_LEVEL enumeration indicating 773 * the severity of the condition causing the trace message to be 774 * issued. 775 * @str_format : Format string that contains the message to be logged. 776 * 777 * 778 * This wrapper will be used for any generic logging messages. Wrapper will 779 * compile a call to converged QDF trace message API. 780 * 781 * Return : Nothing 782 * 783 */ 784 void QDF_PRINT_INFO(unsigned int idx, QDF_MODULE_ID module, 785 QDF_TRACE_LEVEL level, 786 char *str_format, ...); 787 788 /** 789 * struct category_info : Category information structure 790 * @category_verbose_mask: Embeds information about category's verbose level 791 */ 792 struct category_info { 793 uint16_t category_verbose_mask; 794 }; 795 796 /** 797 * struct category_name_info : Category name information structure 798 * @category_name_str: Embeds information about category name 799 */ 800 struct category_name_info { 801 unsigned char category_name_str[QDF_MAX_NAME_SIZE]; 802 }; 803 804 /** 805 * qdf_trace_msg_cmn()- Converged logging API 806 * @idx: Index of print control object assigned to the module 807 * @category: Category identifier. A member of the QDF_MODULE_ID enumeration 808 * that identifies the category issuing the trace message. 809 * @verbose: Verbose level. A member of the QDF_TRACE_LEVEL enumeration 810 * indicating the severity of the condition causing the trace 811 * message to be issued. More severe conditions are more likely 812 * to be logged. 813 * @str_format: Format string. The message to be logged. This format string 814 * contains printf-like replacement parameters, which follow this 815 * parameter in the variable argument list. 816 * @val: Variable argument list part of the log message 817 * 818 * Return: nothing 819 * 820 */ 821 void qdf_trace_msg_cmn(unsigned int idx, 822 QDF_MODULE_ID category, 823 QDF_TRACE_LEVEL verbose, 824 const char *str_format, 825 va_list val); 826 827 /** 828 * struct qdf_print_ctrl: QDF Print Control structure 829 * Statically allocated objects of print control 830 * structure are declared that will support maximum of 831 * 32 print control objects. Any module that needs to 832 * register to the print control framework needs to 833 * obtain a print control object using 834 * qdf_print_ctrl_register API. It will have to pass 835 * pointer to category info structure, name and 836 * custom print function to be used if required. 837 * @name : Optional name for the control object 838 * @cat_info : Array of category_info struct 839 * @custom_print : Custom print handler 840 * @custom_ctxt : Custom print context 841 * @dbglvlmac_on : Flag to enable/disable MAC level filtering 842 * @in_use : Boolean to indicate if control object is in use 843 */ 844 struct qdf_print_ctrl { 845 char name[QDF_MAX_NAME_SIZE]; 846 struct category_info cat_info[MAX_SUPPORTED_CATEGORY]; 847 void (*custom_print)(void *ctxt, const char *fmt, va_list args); 848 void *custom_ctxt; 849 #ifdef DBG_LVL_MAC_FILTERING 850 unsigned char dbglvlmac_on; 851 #endif 852 bool in_use; 853 }; 854 855 /** 856 * qdf_print_ctrl_register() - Allocate QDF print control object, assign 857 * pointer to category info or print control 858 * structure and return the index to the callee 859 * @cinfo : Pointer to array of category info structure 860 * @custom_print_handler : Pointer to custom print handler 861 * @custom_ctx : Pointer to custom context 862 * @pctrl_name : Pointer to print control object name 863 * 864 * Return : Index of qdf_print_ctrl structure 865 * 866 */ 867 int qdf_print_ctrl_register(const struct category_info *cinfo, 868 void *custom_print_handler, 869 void *custom_ctx, 870 const char *pctrl_name); 871 872 /** 873 * qdf_shared_print_ctrl_init() - Initialize the shared print ctrl obj with 874 * all categories set to the default level 875 * 876 * Return : void 877 * 878 */ 879 void qdf_shared_print_ctrl_init(void); 880 881 /** 882 * qdf_print_setup() - Setup default values to all the print control objects 883 * 884 * Register new print control object for the callee 885 * 886 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE 887 * on failure 888 */ 889 QDF_STATUS qdf_print_setup(void); 890 891 /** 892 * qdf_print_ctrl_cleanup() - Clean up a print control object 893 * 894 * Cleanup the print control object for the callee 895 * 896 * @pctrl : Index of print control object 897 * 898 * Return : QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE on failure 899 */ 900 QDF_STATUS qdf_print_ctrl_cleanup(unsigned int idx); 901 902 /** 903 * qdf_print_ctrl_shared_cleanup() - Clean up of the shared object 904 * 905 * Cleanup the shared print-ctrl-object 906 * 907 * Return : void 908 */ 909 void qdf_shared_print_ctrl_cleanup(void); 910 911 /** 912 * qdf_print_set_category_verbose() - Enable/Disable category for a 913 * print control object with 914 * user provided verbose level 915 * 916 * @idx : Index of the print control object assigned to callee 917 * @category : Category information 918 * @verbose: Verbose information 919 * @is_set: Flag indicating if verbose level needs to be enabled or disabled 920 * 921 * Return : QDF_STATUS_SUCCESS for success and QDF_STATUS_E_FAILURE for failure 922 */ 923 QDF_STATUS qdf_print_set_category_verbose(unsigned int idx, 924 QDF_MODULE_ID category, 925 QDF_TRACE_LEVEL verbose, 926 bool is_set); 927 928 /** 929 * qdf_print_is_category_enabled() - Get category information for the 930 * print control object 931 * 932 * @idx : Index of print control object 933 * @category : Category information 934 * 935 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 936 */ 937 bool qdf_print_is_category_enabled(unsigned int idx, 938 QDF_MODULE_ID category); 939 940 /** 941 * qdf_print_is_verbose_enabled() - Get verbose information of a category for 942 * the print control object 943 * 944 * @idx : Index of print control object 945 * @category : Category information 946 * @verbose : Verbose information 947 * 948 * Return : Verbose enabled(true) or disabled(false) or invalid input (false) 949 */ 950 bool qdf_print_is_verbose_enabled(unsigned int idx, 951 QDF_MODULE_ID category, 952 QDF_TRACE_LEVEL verbose); 953 954 /** 955 * qdf_print_clean_node_flag() - Clean up node flag for print control object 956 * 957 * @idx : Index of print control object 958 * 959 * Return : None 960 */ 961 void qdf_print_clean_node_flag(unsigned int idx); 962 963 #ifdef DBG_LVL_MAC_FILTERING 964 965 /** 966 * qdf_print_set_node_flag() - Set flag to enable MAC level filtering 967 * 968 * @idx : Index of print control object 969 * @enable : Enable/Disable bit sent by callee 970 * 971 * Return : QDF_STATUS_SUCCESS on Success and QDF_STATUS_E_FAILURE on Failure 972 */ 973 QDF_STATUS qdf_print_set_node_flag(unsigned int idx, 974 uint8_t enable); 975 976 /** 977 * qdf_print_get_node_flag() - Get flag that controls MAC level filtering 978 * 979 * @idx : Index of print control object 980 * 981 * Return : Flag that indicates enable(1) or disable(0) or invalid(-1) 982 */ 983 bool qdf_print_get_node_flag(unsigned int idx); 984 985 #endif 986 987 /** 988 * qdf_logging_init() - Initialize msg logging functionality 989 * 990 * 991 * Return : void 992 */ 993 void qdf_logging_init(void); 994 995 /** 996 * qdf_logging_exit() - Cleanup msg logging functionality 997 * 998 * 999 * Return : void 1000 */ 1001 void qdf_logging_exit(void); 1002 1003 #define QDF_SYMBOL_LEN __QDF_SYMBOL_LEN 1004 1005 /** 1006 * qdf_sprint_symbol() - prints the name of a symbol into a string buffer 1007 * @buffer: the string buffer to print into 1008 * @addr: address of the symbol to lookup and print 1009 * 1010 * Return: number of characters printed 1011 */ 1012 int qdf_sprint_symbol(char *buffer, void *addr); 1013 1014 #endif /* __QDF_TRACE_H */ 1015