Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Kiet Lam | aa8e15a | 2014-02-11 23:30:06 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2012-2013 Qualcomm Atheros, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * Qualcomm Atheros Confidential and Proprietary. |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 5 | */ |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 6 | /*=========================================================================== |
| 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 | |
| 58 | tSirRetStatus |
| 59 | wdaPostCtrlMsg(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 | |
| 85 | tSirRetStatus |
| 86 | wdaPostCfgMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 87 | { |
| 88 | tSirRetStatus rc = eSIR_SUCCESS; |
| 89 | |
| 90 | do |
| 91 | { |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 92 | // 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 97 | } while (0); |
| 98 | |
| 99 | return rc; |
| 100 | } // halMntPostMsg() |
| 101 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 102 | |
| 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 | |
| 127 | tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb) |
| 128 | { |
| 129 | tSirMsgQ msg; |
| 130 | tpAniSirGlobal pMac = (tpAniSirGlobal)pSirGlobal; |
| 131 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 132 | |
| 133 | tSirMbMsg* pMbLocal; |
| 134 | msg.type = pMb->type; |
| 135 | msg.bodyval = 0; |
| 136 | |
Arif Hussain | f9587ab | 2013-11-17 22:01:22 -0800 | [diff] [blame] | 137 | WDALOG3(wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d" ), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 138 | 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 Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 146 | pMbLocal = vos_mem_malloc(pMb->msgLen); |
| 147 | if ( NULL == pMbLocal ) |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 148 | { |
Arif Hussain | f9587ab | 2013-11-17 22:01:22 -0800 | [diff] [blame] | 149 | WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!"))); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 150 | return eSIR_FAILURE; |
| 151 | } |
| 152 | |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 153 | vos_mem_copy((void *)pMbLocal, (void *)pMb, pMb->msgLen); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 154 | msg.bodyptr = pMbLocal; |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 155 | |
| 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 Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 174 | case SIR_PTT_MSG_TYPES_BEGIN: |
Arif Hussain | 850b943 | 2014-01-02 12:52:22 -0800 | [diff] [blame] | 175 | WDALOGW( wdaLog(pMac, LOGW, FL("%s:%d: message type = 0x%X"), |
| 176 | __func__, __LINE__, msg.type)); |
| 177 | vos_mem_free(msg.bodyptr); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 178 | break; |
| 179 | |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 180 | |
| 181 | default: |
| 182 | WDALOGW( wdaLog(pMac, LOGW, FL("Unknown message type = " |
Arif Hussain | f9587ab | 2013-11-17 22:01:22 -0800 | [diff] [blame] | 183 | "0x%X"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 184 | msg.type)); |
| 185 | |
| 186 | // Release the memory. |
Bansidhar Gopalachari | 0a96a38 | 2013-07-24 16:55:34 +0530 | [diff] [blame] | 187 | vos_mem_free(msg.bodyptr); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 188 | 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 | */ |
| 202 | tBssSystemRole 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 Koyyalamudi | 87054ba | 2012-11-02 13:24:12 -0700 | [diff] [blame] | 210 | "%s:WDA context is NULL", __func__); |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 211 | VOS_ASSERT(0); |
| 212 | return eSYSTEM_UNKNOWN_ROLE; |
| 213 | } |
Arif Hussain | f9587ab | 2013-11-17 22:01:22 -0800 | [diff] [blame] | 214 | WDALOG1( wdaLog(pMac, LOG1, FL(" returning %d role"), |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 215 | wdaContext->wdaGlobalSystemRole)); |
| 216 | return wdaContext->wdaGlobalSystemRole; |
| 217 | } |
| 218 | |