blob: 574655c6d69f7a58d633b4d4a3c0290eae186eab [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lamaa8e15a2014-02-11 23:30:06 -08002 * Copyright (c) 2012-2013 Qualcomm Atheros, Inc.
3 * All Rights Reserved.
4 * Qualcomm Atheros Confidential and Proprietary.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08005 */
Jeff Johnson295189b2012-06-20 16:38:30 -07006/*===========================================================================
7
8 wlan_qct_wda_legacy.c
9
10 OVERVIEW:
11
12 This software unit holds the implementation of the WLAN Device Adaptation
13 Layer for the legacy functionalities that were part of the old HAL.
14
15 The functions externalized by this module are to be called ONLY by other
16 WLAN modules that properly register with the Transport Layer initially.
17
18 DEPENDENCIES:
19
20 Are listed for each API below.
21
22
23 Copyright (c) 2008 QUALCOMM Incorporated.
24 All Rights Reserved.
25 Qualcomm Confidential and Proprietary
26===========================================================================*/
27
28/* Standard include files */
29/* Application Specific include files */
30#include "limApi.h"
31#include "pmmApi.h"
32#include "cfgApi.h"
33#include "wlan_qct_wda_debug.h"
34
35/* Locally used Defines */
36
37#define HAL_MMH_MB_MSG_TYPE_MASK 0xFF00
38
39// -------------------------------------------------------------
40/**
41 * wdaPostCtrlMsg
42 *
43 * FUNCTION:
44 * Posts WDA messages to MC thread
45 *
46 * LOGIC:
47 *
48 * ASSUMPTIONS:pl
49 *
50 *
51 * NOTE:
52 *
53 * @param tpAniSirGlobal MAC parameters structure
54 * @param pMsg pointer with message
55 * @return Success or Failure
56 */
57
58tSirRetStatus
59wdaPostCtrlMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
60{
61 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, (vos_msg_t *) pMsg))
62 return eSIR_FAILURE;
63 else
64 return eSIR_SUCCESS;
65} // halPostMsg()
66
67/**
68 * wdaPostCfgMsg
69 *
70 * FUNCTION:
71 * Posts MNT messages to gSirMntMsgQ
72 *
73 * LOGIC:
74 *
75 * ASSUMPTIONS:
76 *
77 *
78 * NOTE:
79 *
80 * @param tpAniSirGlobal MAC parameters structure
81 * @param pMsg A pointer to the msg
82 * @return Success or Failure
83 */
84
85tSirRetStatus
86wdaPostCfgMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
87{
88 tSirRetStatus rc = eSIR_SUCCESS;
89
90 do
91 {
Jeff Johnson295189b2012-06-20 16:38:30 -070092 // For Windows based MAC, instead of posting message to different
93 // queues we will call the handler routines directly
94
95 cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
96 rc = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070097 } while (0);
98
99 return rc;
100} // halMntPostMsg()
101
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
103// -------------------------------------------------------------
104/**
105 * uMacPostCtrlMsg
106 *
107 * FUNCTION:
108 * Forwards the completely received message to the respective
109 * modules for further processing.
110 *
111 * LOGIC:
112 *
113 * ASSUMPTIONS:
114 * Freeing up of the message buffer is left to the destination module.
115 *
116 * NOTE:
117 * This function has been moved to the API file because for MAC running
118 * on Windows host, the host module will call this routine directly to
119 * send any mailbox messages. Making this function an API makes sure that
120 * outside world (any module outside MMH) only calls APIs to use MMH
121 * services and not an internal function.
122 *
123 * @param pMb A pointer to the maibox message
124 * @return NONE
125 */
126
127tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb)
128{
129 tSirMsgQ msg;
130 tpAniSirGlobal pMac = (tpAniSirGlobal)pSirGlobal;
131
Jeff Johnson295189b2012-06-20 16:38:30 -0700132
133 tSirMbMsg* pMbLocal;
134 msg.type = pMb->type;
135 msg.bodyval = 0;
136
Arif Hussainf9587ab2013-11-17 22:01:22 -0800137 WDALOG3(wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 pMb->type, pMb->msgLen));
139
140 // copy the message from host buffer to firmware buffer
141 // this will make sure that firmware allocates, uses and frees
142 // it's own buffers for mailbox message instead of working on
143 // host buffer
144
145 // second parameter, 'wait option', to palAllocateMemory is ignored on Windows
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530146 pMbLocal = vos_mem_malloc(pMb->msgLen);
147 if ( NULL == pMbLocal )
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 {
Arif Hussainf9587ab2013-11-17 22:01:22 -0800149 WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!")));
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 return eSIR_FAILURE;
151 }
152
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530153 vos_mem_copy((void *)pMbLocal, (void *)pMb, pMb->msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 msg.bodyptr = pMbLocal;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155
156 switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK)
157 {
158 case WDA_MSG_TYPES_BEGIN: // Posts a message to the HAL MsgQ
159 wdaPostCtrlMsg(pMac, &msg);
160 break;
161
162 case SIR_LIM_MSG_TYPES_BEGIN: // Posts a message to the LIM MsgQ
163 limPostMsgApi(pMac, &msg);
164 break;
165
166 case SIR_CFG_MSG_TYPES_BEGIN: // Posts a message to the CFG MsgQ
167 wdaPostCfgMsg(pMac, &msg);
168 break;
169
170 case SIR_PMM_MSG_TYPES_BEGIN: // Posts a message to the PMM MsgQ
171 pmmPostMessage(pMac, &msg);
172 break;
173
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 case SIR_PTT_MSG_TYPES_BEGIN:
Arif Hussain850b9432014-01-02 12:52:22 -0800175 WDALOGW( wdaLog(pMac, LOGW, FL("%s:%d: message type = 0x%X"),
176 __func__, __LINE__, msg.type));
177 vos_mem_free(msg.bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700178 break;
179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
181 default:
182 WDALOGW( wdaLog(pMac, LOGW, FL("Unknown message type = "
Arif Hussainf9587ab2013-11-17 22:01:22 -0800183 "0x%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 msg.type));
185
186 // Release the memory.
Bansidhar Gopalachari0a96a382013-07-24 16:55:34 +0530187 vos_mem_free(msg.bodyptr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700188 break;
189 }
190
191 return eSIR_SUCCESS;
192
193} // uMacPostCtrlMsg()
194
195
196/* ---------------------------------------------------------
197 * FUNCTION: wdaGetGlobalSystemRole()
198 *
199 * Get the global HAL system role.
200 * ---------------------------------------------------------
201 */
202tBssSystemRole wdaGetGlobalSystemRole(tpAniSirGlobal pMac)
203{
204 v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_WDA, NULL);
205 tWDA_CbContext *wdaContext =
206 vos_get_context(VOS_MODULE_ID_WDA, pVosContext);
207 if(NULL == wdaContext)
208 {
209 VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700210 "%s:WDA context is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 VOS_ASSERT(0);
212 return eSYSTEM_UNKNOWN_ROLE;
213 }
Arif Hussainf9587ab2013-11-17 22:01:22 -0800214 WDALOG1( wdaLog(pMac, LOG1, FL(" returning %d role"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 wdaContext->wdaGlobalSystemRole));
216 return wdaContext->wdaGlobalSystemRole;
217}
218