Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 2 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 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 | /*=========================================================================== |
| 24 | |
| 25 | wlan_qct_wda_legacy.c |
| 26 | |
| 27 | OVERVIEW: |
| 28 | |
| 29 | This software unit holds the implementation of the WLAN Device Adaptation |
| 30 | Layer for the legacy functionalities that were part of the old HAL. |
| 31 | |
| 32 | The functions externalized by this module are to be called ONLY by other |
| 33 | WLAN modules that properly register with the Transport Layer initially. |
| 34 | |
| 35 | DEPENDENCIES: |
| 36 | |
| 37 | Are listed for each API below. |
| 38 | |
| 39 | |
| 40 | Copyright (c) 2008 QUALCOMM Incorporated. |
| 41 | All Rights Reserved. |
| 42 | Qualcomm Confidential and Proprietary |
| 43 | ===========================================================================*/ |
| 44 | |
| 45 | /* Standard include files */ |
| 46 | /* Application Specific include files */ |
| 47 | #include "limApi.h" |
| 48 | #include "pmmApi.h" |
| 49 | #include "cfgApi.h" |
| 50 | #include "wlan_qct_wda_debug.h" |
| 51 | |
| 52 | /* Locally used Defines */ |
| 53 | |
| 54 | #define HAL_MMH_MB_MSG_TYPE_MASK 0xFF00 |
| 55 | |
| 56 | // ------------------------------------------------------------- |
| 57 | /** |
| 58 | * wdaPostCtrlMsg |
| 59 | * |
| 60 | * FUNCTION: |
| 61 | * Posts WDA messages to MC thread |
| 62 | * |
| 63 | * LOGIC: |
| 64 | * |
| 65 | * ASSUMPTIONS:pl |
| 66 | * |
| 67 | * |
| 68 | * NOTE: |
| 69 | * |
| 70 | * @param tpAniSirGlobal MAC parameters structure |
| 71 | * @param pMsg pointer with message |
| 72 | * @return Success or Failure |
| 73 | */ |
| 74 | |
| 75 | tSirRetStatus |
| 76 | wdaPostCtrlMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 77 | { |
| 78 | if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_WDA, (vos_msg_t *) pMsg)) |
| 79 | return eSIR_FAILURE; |
| 80 | else |
| 81 | return eSIR_SUCCESS; |
| 82 | } // halPostMsg() |
| 83 | |
| 84 | /** |
| 85 | * wdaPostCfgMsg |
| 86 | * |
| 87 | * FUNCTION: |
| 88 | * Posts MNT messages to gSirMntMsgQ |
| 89 | * |
| 90 | * LOGIC: |
| 91 | * |
| 92 | * ASSUMPTIONS: |
| 93 | * |
| 94 | * |
| 95 | * NOTE: |
| 96 | * |
| 97 | * @param tpAniSirGlobal MAC parameters structure |
| 98 | * @param pMsg A pointer to the msg |
| 99 | * @return Success or Failure |
| 100 | */ |
| 101 | |
| 102 | tSirRetStatus |
| 103 | wdaPostCfgMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 104 | { |
| 105 | tSirRetStatus rc = eSIR_SUCCESS; |
| 106 | |
| 107 | do |
| 108 | { |
| 109 | #ifdef ANI_OS_TYPE_RTAI_LINUX |
| 110 | |
| 111 | // Posts message to the queue |
| 112 | |
| 113 | if (tx_queue_send(&pMac->sys.gSirMntMsgQ, pMsg, |
| 114 | TX_NO_WAIT) != TX_SUCCESS) |
| 115 | { |
| 116 | wdaLog(pMac, LOGP, FL("Queue send Failed! rc (%X)\n"), |
| 117 | eSIR_SYS_TX_Q_SEND_FAILED); |
| 118 | rc = eSIR_SYS_TX_Q_SEND_FAILED; |
| 119 | break; |
| 120 | } |
| 121 | |
| 122 | #else |
| 123 | // For Windows based MAC, instead of posting message to different |
| 124 | // queues we will call the handler routines directly |
| 125 | |
| 126 | cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr); |
| 127 | rc = eSIR_SUCCESS; |
| 128 | #endif |
| 129 | } while (0); |
| 130 | |
| 131 | return rc; |
| 132 | } // halMntPostMsg() |
| 133 | |
| 134 | #ifndef FEATURE_WLAN_INTEGRATED_SOC |
| 135 | #if defined(ANI_MANF_DIAG) || defined(ANI_PHY_DEBUG) |
| 136 | #include "pttModuleApi.h" |
| 137 | // ------------------------------------------------------------- |
| 138 | /** |
| 139 | * halNimPTTPostMsgApi |
| 140 | * |
| 141 | * FUNCTION: |
| 142 | * Posts NIM messages to gNIM thread |
| 143 | * |
| 144 | * LOGIC: |
| 145 | * |
| 146 | * ASSUMPTIONS:pl |
| 147 | * |
| 148 | * |
| 149 | * NOTE: |
| 150 | * |
| 151 | * @param tpAniSirGlobal MAC parameters structure |
| 152 | * @param pMsg pointer with message |
| 153 | * @return Success or Failure |
| 154 | */ |
| 155 | |
| 156 | tSirRetStatus |
| 157 | halNimPTTPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 158 | { |
| 159 | tSirRetStatus rc = eSIR_SUCCESS; |
| 160 | |
| 161 | do |
| 162 | { |
| 163 | #ifdef ANI_OS_TYPE_RTAI_LINUX |
| 164 | |
| 165 | // Posts message to the queue |
| 166 | if (tx_queue_send(&pMac->sys.gSirNimRDMsgQ, pMsg, |
| 167 | TX_NO_WAIT) != TX_SUCCESS) |
| 168 | { |
| 169 | rc = eSIR_FAILURE; |
| 170 | wdaLog(pMac, LOGP, |
| 171 | FL("Posting a Msg to nimMsgQ failed!\n")); |
| 172 | break; |
| 173 | } |
| 174 | #else |
| 175 | // For Windows based MAC, instead of posting message to different |
| 176 | // queues, we will call the handler routines directly |
| 177 | wdaLog(pMac, LOGE, "ERROR: Received PTT message in obsolete code path.\n"); |
| 178 | wdaLog(pMac, LOGP, "This indicates that the wrong OID is being used - clean registry and previous inf files.\n"); |
| 179 | /* |
| 180 | tPttMsgbuffer *msgPtr = (tPttMsgbuffer *)(pMsg->body); //for some reason, body is actually being used as if it were a void * |
| 181 | pttProcessMsg(pMac, msgPtr); |
| 182 | */ |
| 183 | |
| 184 | //TODO: the resonse is now packaged in ((tPttMsgbuffer *)&pMsg->body)->msgResponse and needs to be sent back to the application |
| 185 | |
| 186 | rc = eSIR_SUCCESS; |
| 187 | #endif |
| 188 | } |
| 189 | while (0); |
| 190 | |
| 191 | return rc; |
| 192 | } // halNimPTTPostMsgApi() |
| 193 | |
| 194 | |
| 195 | #endif //ANI_MANF_DIAG |
| 196 | #endif //FEATURE_WLAN_INTEGRATED_SOC |
| 197 | |
| 198 | // ------------------------------------------------------------- |
| 199 | /** |
| 200 | * uMacPostCtrlMsg |
| 201 | * |
| 202 | * FUNCTION: |
| 203 | * Forwards the completely received message to the respective |
| 204 | * modules for further processing. |
| 205 | * |
| 206 | * LOGIC: |
| 207 | * |
| 208 | * ASSUMPTIONS: |
| 209 | * Freeing up of the message buffer is left to the destination module. |
| 210 | * |
| 211 | * NOTE: |
| 212 | * This function has been moved to the API file because for MAC running |
| 213 | * on Windows host, the host module will call this routine directly to |
| 214 | * send any mailbox messages. Making this function an API makes sure that |
| 215 | * outside world (any module outside MMH) only calls APIs to use MMH |
| 216 | * services and not an internal function. |
| 217 | * |
| 218 | * @param pMb A pointer to the maibox message |
| 219 | * @return NONE |
| 220 | */ |
| 221 | |
| 222 | tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb) |
| 223 | { |
| 224 | tSirMsgQ msg; |
| 225 | tpAniSirGlobal pMac = (tpAniSirGlobal)pSirGlobal; |
| 226 | |
| 227 | #ifdef ANI_OS_TYPE_RTAI_LINUX |
| 228 | |
| 229 | msg.type = pMb->type; |
| 230 | msg.bodyptr = pMb; |
| 231 | msg.bodyval = 0; |
| 232 | WDALOG3( wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d\n" ), |
| 233 | pMb->type, pMb->msgLen)); |
| 234 | #else |
| 235 | |
| 236 | tSirMbMsg* pMbLocal; |
| 237 | msg.type = pMb->type; |
| 238 | msg.bodyval = 0; |
| 239 | |
| 240 | WDALOG3(wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d\n" ), |
| 241 | pMb->type, pMb->msgLen)); |
| 242 | |
| 243 | // copy the message from host buffer to firmware buffer |
| 244 | // this will make sure that firmware allocates, uses and frees |
| 245 | // it's own buffers for mailbox message instead of working on |
| 246 | // host buffer |
| 247 | |
| 248 | // second parameter, 'wait option', to palAllocateMemory is ignored on Windows |
| 249 | if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMbLocal, pMb->msgLen)) |
| 250 | { |
| 251 | WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n"))); |
| 252 | return eSIR_FAILURE; |
| 253 | } |
| 254 | |
| 255 | palCopyMemory(pMac, (void *)pMbLocal, (void *)pMb, pMb->msgLen); |
| 256 | msg.bodyptr = pMbLocal; |
| 257 | #endif |
| 258 | |
| 259 | switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK) |
| 260 | { |
| 261 | case WDA_MSG_TYPES_BEGIN: // Posts a message to the HAL MsgQ |
| 262 | wdaPostCtrlMsg(pMac, &msg); |
| 263 | break; |
| 264 | |
| 265 | case SIR_LIM_MSG_TYPES_BEGIN: // Posts a message to the LIM MsgQ |
| 266 | limPostMsgApi(pMac, &msg); |
| 267 | break; |
| 268 | |
| 269 | case SIR_CFG_MSG_TYPES_BEGIN: // Posts a message to the CFG MsgQ |
| 270 | wdaPostCfgMsg(pMac, &msg); |
| 271 | break; |
| 272 | |
| 273 | case SIR_PMM_MSG_TYPES_BEGIN: // Posts a message to the PMM MsgQ |
| 274 | pmmPostMessage(pMac, &msg); |
| 275 | break; |
| 276 | |
| 277 | #if defined(ANI_MANF_DIAG) || defined(ANI_PHY_DEBUG) |
| 278 | case SIR_PTT_MSG_TYPES_BEGIN: |
| 279 | #ifndef FEATURE_WLAN_INTEGRATED_SOC |
| 280 | halNimPTTPostMsgApi(pMac, &msg); // Posts a message to the NIM PTT MsgQ |
| 281 | #endif /* FEATURE_WLAN_INTEGRATED_SOC */ |
| 282 | break; |
| 283 | |
| 284 | #endif |
| 285 | |
| 286 | default: |
| 287 | WDALOGW( wdaLog(pMac, LOGW, FL("Unknown message type = " |
| 288 | "0x%X\n"), |
| 289 | msg.type)); |
| 290 | |
| 291 | // Release the memory. |
Jeff Johnson | 43971f5 | 2012-07-17 12:26:56 -0700 | [diff] [blame] | 292 | if (palFreeMemory( pMac->hHdd, (void*)(msg.bodyptr)) |
| 293 | != eHAL_STATUS_SUCCESS) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 294 | { |
| 295 | WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n"))); |
| 296 | return eSIR_FAILURE; |
| 297 | } |
| 298 | break; |
| 299 | } |
| 300 | |
| 301 | return eSIR_SUCCESS; |
| 302 | |
| 303 | } // uMacPostCtrlMsg() |
| 304 | |
| 305 | |
| 306 | /* --------------------------------------------------------- |
| 307 | * FUNCTION: wdaGetGlobalSystemRole() |
| 308 | * |
| 309 | * Get the global HAL system role. |
| 310 | * --------------------------------------------------------- |
| 311 | */ |
| 312 | tBssSystemRole wdaGetGlobalSystemRole(tpAniSirGlobal pMac) |
| 313 | { |
| 314 | v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_WDA, NULL); |
| 315 | tWDA_CbContext *wdaContext = |
| 316 | vos_get_context(VOS_MODULE_ID_WDA, pVosContext); |
| 317 | if(NULL == wdaContext) |
| 318 | { |
| 319 | VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ERROR, |
Madan Mohan Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame^] | 320 | "%s:WDA context is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 321 | VOS_ASSERT(0); |
| 322 | return eSYSTEM_UNKNOWN_ROLE; |
| 323 | } |
| 324 | WDALOG1( wdaLog(pMac, LOG1, FL(" returning %d role\n"), |
| 325 | wdaContext->wdaGlobalSystemRole)); |
| 326 | return wdaContext->wdaGlobalSystemRole; |
| 327 | } |
| 328 | |