Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013 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. |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame] | 20 | */ |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 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 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 28 | /*============================================================================ |
| 29 | FILE: vos_diag.c |
| 30 | |
| 31 | OVERVIEW: This source file contains definitions for vOS diag APIs |
| 32 | |
Kiet Lam | 1ed83fc | 2014-02-19 01:15:45 -0800 | [diff] [blame] | 33 | DEPENDENCIES: |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 34 | ============================================================================*/ |
| 35 | |
| 36 | #include "vos_types.h" |
| 37 | #include "i_vos_diag_core_log.h" |
| 38 | #include "i_vos_diag_core_event.h" |
| 39 | #include "wlan_hdd_main.h" |
| 40 | #include "wlan_nlink_common.h" |
| 41 | #include "vos_sched.h" |
| 42 | #include "wlan_ptt_sock_svc.h" |
| 43 | |
| 44 | |
| 45 | #define PTT_MSG_DIAG_CMDS_TYPE 0x5050 |
| 46 | |
| 47 | #define DIAG_TYPE_LOGS 1 |
| 48 | #define DIAG_TYPE_EVENTS 2 |
| 49 | |
| 50 | #define DIAG_SWAP16(A) ((((tANI_U16)(A) & 0xff00) >> 8) | (((tANI_U16)(A) & 0x00ff) << 8)) |
| 51 | |
| 52 | |
| 53 | |
| 54 | typedef struct event_report_s |
| 55 | { |
| 56 | v_U32_t diag_type; |
| 57 | v_U16_t event_id; |
| 58 | v_U16_t length; |
| 59 | } event_report_t; |
| 60 | |
| 61 | |
| 62 | /**--------------------------------------------------------------------------- |
| 63 | |
| 64 | \brief vos_log_set_code() - |
| 65 | |
| 66 | This function sets the logging code in the given log record. |
| 67 | |
| 68 | \param - ptr - Pointer to the log header type. |
| 69 | - code - log code. |
| 70 | \return - None |
| 71 | |
| 72 | --------------------------------------------------------------------------*/ |
| 73 | |
| 74 | void vos_log_set_code (v_VOID_t *ptr, v_U16_t code) |
| 75 | { |
| 76 | if (ptr) |
| 77 | { |
| 78 | /* All log packets are required to start with 'log_header_type'. */ |
| 79 | ((log_hdr_type *) ptr)->code = code; |
| 80 | } |
| 81 | |
| 82 | } |
| 83 | |
| 84 | /**--------------------------------------------------------------------------- |
| 85 | |
| 86 | \brief vos_log_set_length() - |
| 87 | |
| 88 | This function sets the length field in the given log record. |
| 89 | |
| 90 | \param - ptr - Pointer to the log header type. |
| 91 | - length - log length. |
| 92 | |
| 93 | \return - None |
| 94 | |
| 95 | --------------------------------------------------------------------------*/ |
| 96 | |
| 97 | void vos_log_set_length (v_VOID_t *ptr, v_U16_t length) |
| 98 | { |
| 99 | if(ptr) |
| 100 | { |
| 101 | /* All log packets are required to start with 'log_header_type'. */ |
| 102 | ((log_hdr_type *) ptr)->len = (v_U16_t) length; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /**--------------------------------------------------------------------------- |
| 107 | |
| 108 | \brief vos_log_submit() - |
| 109 | |
| 110 | This function sends the log data to the ptt socket app only if it is registered with the driver. |
| 111 | |
| 112 | \param - ptr - Pointer to the log header type. |
| 113 | |
| 114 | \return - None |
| 115 | |
| 116 | --------------------------------------------------------------------------*/ |
| 117 | |
| 118 | void vos_log_submit(v_VOID_t *plog_hdr_ptr) |
| 119 | { |
| 120 | |
| 121 | log_hdr_type *pHdr = (log_hdr_type*) plog_hdr_ptr; |
| 122 | |
| 123 | tAniHdr *wmsg = NULL; |
| 124 | v_U8_t *pBuf; |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 125 | struct hdd_context_s *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 126 | v_CONTEXT_t pVosContext= NULL; |
| 127 | v_U16_t data_len; |
| 128 | v_U16_t total_len; |
| 129 | |
| 130 | |
| 131 | /*Get the global context */ |
| 132 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 133 | |
| 134 | /*Get the Hdd Context */ |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 135 | pHddCtx = ((VosContextType*)(pVosContext))->pHDDContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 136 | |
Vinay Krishna Eranna | 0b11262 | 2014-04-21 20:17:57 +0530 | [diff] [blame] | 137 | if (WLAN_HDD_IS_LOAD_UNLOAD_IN_PROGRESS(pHddCtx)) |
| 138 | { |
| 139 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, |
| 140 | "%s: Unloading/Loading in Progress. Ignore!!!", __func__); |
| 141 | return; |
| 142 | } |
| 143 | |
Leo Chang | 9e64608 | 2013-08-02 11:20:21 -0700 | [diff] [blame] | 144 | #ifdef WLAN_KD_READY_NOTIFIER |
| 145 | /* NL is not ready yet, WLAN KO started first */ |
| 146 | if ((pHddCtx->kd_nl_init) && (!pHddCtx->ptt_pid)) |
| 147 | { |
| 148 | nl_srv_nl_ready_indication(); |
| 149 | } |
| 150 | #endif /* WLAN_KD_READY_NOTIFIER */ |
| 151 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 152 | /* Send the log data to the ptt app only if it is registered with the wlan driver*/ |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 153 | if(pHddCtx->ptt_pid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | { |
| 155 | data_len = pHdr->len; |
| 156 | |
| 157 | total_len = sizeof(tAniHdr)+sizeof(v_U32_t)+data_len; |
| 158 | |
| 159 | pBuf = (v_U8_t*)vos_mem_malloc(total_len); |
| 160 | |
| 161 | if(!pBuf) |
| 162 | { |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 163 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "vos_mem_malloc failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 164 | return; |
| 165 | } |
| 166 | |
| 167 | vos_mem_zero((v_VOID_t*)pBuf,total_len); |
| 168 | |
| 169 | wmsg = (tAniHdr*)pBuf; |
| 170 | wmsg->type = PTT_MSG_DIAG_CMDS_TYPE; |
| 171 | wmsg->length = total_len; |
| 172 | wmsg->length = DIAG_SWAP16(wmsg->length); |
| 173 | pBuf += sizeof(tAniHdr); |
| 174 | |
| 175 | |
| 176 | /* Diag Type events or log */ |
| 177 | *(v_U32_t*)pBuf = DIAG_TYPE_LOGS; |
| 178 | pBuf += sizeof(v_U32_t); |
| 179 | |
| 180 | |
Rajesh Babu Prathipati | ddbe289 | 2014-07-01 18:57:16 +0530 | [diff] [blame^] | 181 | vos_mem_copy(pBuf, pHdr,data_len); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 182 | |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 183 | if(pHddCtx->ptt_pid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 184 | { |
Hardik Kantilal Patel | 9a52d27 | 2014-04-29 14:24:55 +0530 | [diff] [blame] | 185 | if( ptt_sock_send_msg_to_app(wmsg, 0, |
| 186 | ANI_NL_MSG_PUMAC, pHddCtx->ptt_pid, MSG_DONTWAIT) < 0) { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 187 | |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 188 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 189 | ("Ptt Socket error sending message to the app!!")); |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 190 | vos_mem_free((v_VOID_t *)wmsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 191 | return; |
| 192 | } |
| 193 | |
| 194 | } |
| 195 | vos_mem_free((v_VOID_t*)wmsg); |
| 196 | } |
| 197 | return; |
| 198 | } |
| 199 | |
| 200 | /**--------------------------------------------------------------------------- |
| 201 | |
| 202 | \brief vos_event_report_payload() - |
| 203 | |
| 204 | This function sends the event data to the ptt socket app only if it is registered with the driver. |
| 205 | |
| 206 | \param - ptr - Pointer to the log header type. |
| 207 | |
| 208 | \return - None |
| 209 | |
| 210 | --------------------------------------------------------------------------*/ |
| 211 | |
| 212 | void vos_event_report_payload(v_U16_t event_Id, v_U16_t length, v_VOID_t *pPayload) |
| 213 | { |
| 214 | |
| 215 | |
| 216 | tAniHdr *wmsg = NULL; |
| 217 | v_U8_t *pBuf; |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 218 | struct hdd_context_s *pHddCtx; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 219 | v_CONTEXT_t pVosContext= NULL; |
| 220 | event_report_t *pEvent_report; |
| 221 | v_U16_t total_len; |
| 222 | |
| 223 | /*Get the global context */ |
| 224 | pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL); |
| 225 | |
| 226 | /*Get the Hdd Context */ |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 227 | pHddCtx = ((VosContextType*)(pVosContext))->pHDDContext; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 228 | |
Leo Chang | 9e64608 | 2013-08-02 11:20:21 -0700 | [diff] [blame] | 229 | #ifdef WLAN_KD_READY_NOTIFIER |
| 230 | /* NL is not ready yet, WLAN KO started first */ |
| 231 | if ((pHddCtx->kd_nl_init) && (!pHddCtx->ptt_pid)) |
| 232 | { |
| 233 | nl_srv_nl_ready_indication(); |
| 234 | } |
| 235 | #endif /* WLAN_KD_READY_NOTIFIER */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 236 | |
| 237 | /* Send the log data to the ptt app only if it is registered with the wlan driver*/ |
lukez | 3c80922 | 2013-05-03 10:23:02 -0700 | [diff] [blame] | 238 | if(pHddCtx->ptt_pid) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 239 | { |
| 240 | total_len = sizeof(tAniHdr)+sizeof(event_report_t)+length; |
| 241 | |
| 242 | pBuf = (v_U8_t*)vos_mem_malloc(total_len); |
| 243 | |
| 244 | if(!pBuf) |
| 245 | { |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 246 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "vos_mem_malloc failed"); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 247 | return; |
| 248 | } |
| 249 | wmsg = (tAniHdr*)pBuf; |
| 250 | wmsg->type = PTT_MSG_DIAG_CMDS_TYPE; |
| 251 | wmsg->length = total_len; |
| 252 | wmsg->length = DIAG_SWAP16(wmsg->length); |
| 253 | pBuf += sizeof(tAniHdr); |
| 254 | |
| 255 | pEvent_report = (event_report_t*)pBuf; |
| 256 | pEvent_report->diag_type = DIAG_TYPE_EVENTS; |
| 257 | pEvent_report->event_id = event_Id; |
| 258 | pEvent_report->length = length; |
| 259 | |
| 260 | pBuf += sizeof(event_report_t); |
| 261 | |
Rajesh Babu Prathipati | ddbe289 | 2014-07-01 18:57:16 +0530 | [diff] [blame^] | 262 | vos_mem_copy(pBuf, pPayload,length); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 263 | |
Hardik Kantilal Patel | 9a52d27 | 2014-04-29 14:24:55 +0530 | [diff] [blame] | 264 | if( ptt_sock_send_msg_to_app(wmsg, 0, |
| 265 | ANI_NL_MSG_PUMAC, pHddCtx->ptt_pid, MSG_DONTWAIT) < 0) { |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 266 | VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, |
Arif Hussain | 0288240 | 2013-11-17 21:55:29 -0800 | [diff] [blame] | 267 | ("Ptt Socket error sending message to the app!!")); |
Wilson Yang | 0025634 | 2013-10-10 23:13:38 -0700 | [diff] [blame] | 268 | vos_mem_free((v_VOID_t*)wmsg); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 269 | return; |
| 270 | } |
| 271 | |
| 272 | vos_mem_free((v_VOID_t*)wmsg); |
| 273 | } |
| 274 | |
| 275 | return; |
| 276 | |
| 277 | } |