blob: d9c63b71280c799605418d5b1e0318ea63efb880 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * 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 Lamaa8e15a2014-02-11 23:30:06 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
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 Johnson295189b2012-06-20 16:38:30 -070028/*============================================================================
29 FILE: vos_diag.c
30
31 OVERVIEW: This source file contains definitions for vOS diag APIs
32
Kiet Lam1ed83fc2014-02-19 01:15:45 -080033 DEPENDENCIES:
Jeff Johnson295189b2012-06-20 16:38:30 -070034============================================================================*/
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
54typedef 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
74void 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
97void 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
118void 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;
lukez3c809222013-05-03 10:23:02 -0700125 struct hdd_context_s *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 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 */
lukez3c809222013-05-03 10:23:02 -0700135 pHddCtx = ((VosContextType*)(pVosContext))->pHDDContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700136
Vinay Krishna Eranna0b112622014-04-21 20:17:57 +0530137 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 Chang9e646082013-08-02 11:20:21 -0700144#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 Johnson295189b2012-06-20 16:38:30 -0700152 /* Send the log data to the ptt app only if it is registered with the wlan driver*/
lukez3c809222013-05-03 10:23:02 -0700153 if(pHddCtx->ptt_pid)
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
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 Hussain02882402013-11-17 21:55:29 -0800163 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "vos_mem_malloc failed");
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 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 Prathipatiddbe2892014-07-01 18:57:16 +0530181 vos_mem_copy(pBuf, pHdr,data_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700182
lukez3c809222013-05-03 10:23:02 -0700183 if(pHddCtx->ptt_pid)
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 {
Hardik Kantilal Patel9a52d272014-04-29 14:24:55 +0530185 if( ptt_sock_send_msg_to_app(wmsg, 0,
186 ANI_NL_MSG_PUMAC, pHddCtx->ptt_pid, MSG_DONTWAIT) < 0) {
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
Wilson Yang00256342013-10-10 23:13:38 -0700188 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800189 ("Ptt Socket error sending message to the app!!"));
Wilson Yang00256342013-10-10 23:13:38 -0700190 vos_mem_free((v_VOID_t *)wmsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 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
212void 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;
lukez3c809222013-05-03 10:23:02 -0700218 struct hdd_context_s *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 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 */
lukez3c809222013-05-03 10:23:02 -0700227 pHddCtx = ((VosContextType*)(pVosContext))->pHDDContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700228
Leo Chang9e646082013-08-02 11:20:21 -0700229#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 Johnson295189b2012-06-20 16:38:30 -0700236
237 /* Send the log data to the ptt app only if it is registered with the wlan driver*/
lukez3c809222013-05-03 10:23:02 -0700238 if(pHddCtx->ptt_pid)
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
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 Hussain02882402013-11-17 21:55:29 -0800246 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR, "vos_mem_malloc failed");
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 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 Prathipatiddbe2892014-07-01 18:57:16 +0530262 vos_mem_copy(pBuf, pPayload,length);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263
Hardik Kantilal Patel9a52d272014-04-29 14:24:55 +0530264 if( ptt_sock_send_msg_to_app(wmsg, 0,
265 ANI_NL_MSG_PUMAC, pHddCtx->ptt_pid, MSG_DONTWAIT) < 0) {
Wilson Yang00256342013-10-10 23:13:38 -0700266 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain02882402013-11-17 21:55:29 -0800267 ("Ptt Socket error sending message to the app!!"));
Wilson Yang00256342013-10-10 23:13:38 -0700268 vos_mem_free((v_VOID_t*)wmsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 return;
270 }
271
272 vos_mem_free((v_VOID_t*)wmsg);
273 }
274
275 return;
276
277}