Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2011, 2014-2015 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 | #ifndef _DBGLOG_COMMON_H_ |
| 29 | #define _DBGLOG_COMMON_H_ |
| 30 | |
| 31 | #ifdef __cplusplus |
| 32 | extern "C" { |
| 33 | #endif |
| 34 | |
| 35 | #include "dbglog_id.h" |
| 36 | #include "dbglog.h" |
| 37 | |
| 38 | #define MAX_DBG_MSGS 256 |
| 39 | |
| 40 | #define ATH6KL_FWLOG_PAYLOAD_SIZE 1500 |
| 41 | |
| 42 | #define DBGLOG_PRINT_PREFIX "FWLOG: " |
| 43 | |
| 44 | /* Handy Macros to read data length and type from FW */ |
| 45 | #define WLAN_DIAG_0_TYPE_S 0 |
| 46 | #define WLAN_DIAG_0_TYPE 0x000000ff |
| 47 | #define WLAN_DIAG_0_TYPE_GET(x) WMI_F_MS(x, WLAN_DIAG_0_TYPE) |
| 48 | #define WLAN_DIAG_0_TYPE_SET(x, y) WMI_F_RMW(x, y, WLAN_DIAG_0_TYPE) |
| 49 | /* bits 8-15 reserved */ |
| 50 | |
| 51 | /* length includes the size of wlan_diag_data */ |
| 52 | #define WLAN_DIAG_0_LEN_S 16 |
| 53 | #define WLAN_DIAG_0_LEN 0xffff0000 |
| 54 | #define WLAN_DIAG_0_LEN_GET(x) WMI_F_MS(x, WLAN_DIAG_0_LEN) |
| 55 | #define WLAN_DIAG_0_LEN_SET(x, y) WMI_F_RMW(x, y, WLAN_DIAG_0_LEN) |
| 56 | |
| 57 | #define CNSS_DIAG_SLEEP_INTERVAL 5 /* In secs */ |
| 58 | |
| 59 | #define ATH6KL_FWLOG_MAX_ENTRIES 20 |
| 60 | #define ATH6KL_FWLOG_PAYLOAD_SIZE 1500 |
| 61 | |
| 62 | #define DIAG_WLAN_DRIVER_UNLOADED 6 |
| 63 | #define DIAG_WLAN_DRIVER_LOADED 7 |
| 64 | #define DIAG_TYPE_LOGS 1 |
| 65 | #define DIAG_TYPE_EVENTS 2 |
| 66 | |
| 67 | typedef enum { |
| 68 | DBGLOG_PROCESS_DEFAULT = 0, |
| 69 | DBGLOG_PROCESS_PRINT_RAW, /* print them in debug view */ |
| 70 | DBGLOG_PROCESS_POOL_RAW, /* user buffer pool to save them */ |
| 71 | DBGLOG_PROCESS_NET_RAW, /* user buffer pool to save them */ |
| 72 | DBGLOG_PROCESS_MAX, |
| 73 | } dbglog_process_t; |
| 74 | |
| 75 | enum cnss_diag_type { |
| 76 | DIAG_TYPE_FW_EVENT, /* send fw event- to diag */ |
| 77 | DIAG_TYPE_FW_LOG, /* send log event- to diag */ |
| 78 | DIAG_TYPE_FW_DEBUG_MSG, /* send dbg message- to diag */ |
| 79 | DIAG_TYPE_INIT_REQ, /* cnss_diag initialization- from diag */ |
| 80 | DIAG_TYPE_FW_MSG, /* fw msg command-to diag */ |
| 81 | DIAG_TYPE_HOST_MSG, /* host command-to diag */ |
| 82 | DIAG_TYPE_CRASH_INJECT, /*crash inject-from diag */ |
| 83 | DIAG_TYPE_DBG_LEVEL, /* DBG LEVEL-from diag */ |
| 84 | }; |
| 85 | |
| 86 | enum wlan_diag_config_type { |
| 87 | DIAG_VERSION_INFO, |
| 88 | }; |
| 89 | |
| 90 | enum wlan_diag_frame_type { |
| 91 | WLAN_DIAG_TYPE_CONFIG, |
| 92 | WLAN_DIAG_TYPE_EVENT, |
| 93 | WLAN_DIAG_TYPE_LOG, |
| 94 | WLAN_DIAG_TYPE_MSG, |
| 95 | WLAN_DIAG_TYPE_LEGACY_MSG, |
| 96 | }; |
| 97 | |
| 98 | /* log/event are always 32-bit aligned. Padding is inserted after |
| 99 | * optional payload to satisify this requirement */ |
| 100 | struct wlan_diag_data { |
| 101 | unsigned int word0; /* type, length */ |
| 102 | unsigned int target_time; |
| 103 | unsigned int code; /* Diag log or event Code */ |
| 104 | uint8_t payload[0]; |
| 105 | }; |
| 106 | |
| 107 | struct dbglog_slot { |
| 108 | unsigned int diag_type; |
| 109 | unsigned int timestamp; |
| 110 | unsigned int length; |
| 111 | unsigned int dropped; |
| 112 | /* max ATH6KL_FWLOG_PAYLOAD_SIZE bytes */ |
| 113 | uint8_t payload[0]; |
| 114 | } __packed; |
| 115 | |
| 116 | typedef struct event_report_s { |
| 117 | unsigned int diag_type; |
| 118 | unsigned short event_id; |
| 119 | unsigned short length; |
| 120 | } event_report_t; |
| 121 | |
| 122 | /* |
| 123 | * Custom debug_print handlers |
| 124 | * Args: |
| 125 | * module Id |
| 126 | * vap id |
| 127 | * debug msg id |
| 128 | * Time stamp |
| 129 | * no of arguments |
| 130 | * pointer to the buffer holding the args |
| 131 | */ |
| 132 | typedef A_BOOL (*module_dbg_print)(A_UINT32, A_UINT16, A_UINT32, |
| 133 | A_UINT32, A_UINT16, A_UINT32 *); |
| 134 | |
| 135 | /** Register module specific dbg print*/ |
| 136 | void dbglog_reg_modprint(A_UINT32 mod_id, module_dbg_print printfn); |
| 137 | |
| 138 | #ifdef __cplusplus |
| 139 | } |
| 140 | #endif |
| 141 | |
| 142 | #endif /* _DBGLOG_COMMON_H_ */ |