tSirRetStatus
wdaPostCfgMsg(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
{
   tSirRetStatus rc = eSIR_SUCCESS;

   do
   {
#ifdef ANI_OS_TYPE_RTAI_LINUX

      // Posts message to the queue

      if (tx_queue_send(&pMac->sys.gSirMntMsgQ, pMsg,
                       TX_NO_WAIT) != TX_SUCCESS)
      {
         wdaLog(pMac, LOGP, FL("Queue send Failed! rc (%X)\n"),
                eSIR_SYS_TX_Q_SEND_FAILED);
         rc = eSIR_SYS_TX_Q_SEND_FAILED;
         break;
      }

#else
      // For Windows based MAC, instead of posting message to different
      // queues we will call the handler routines directly

      cfgProcessMbMsg(pMac, (tSirMbMsg*)pMsg->bodyptr);
      rc = eSIR_SUCCESS;
#endif
   } while (0);

   return rc;
} // halMntPostMsg()
tSirRetStatus
halNimPTTPostMsgApi(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
{
   tSirRetStatus rc = eSIR_SUCCESS;

   do
   {
#ifdef ANI_OS_TYPE_RTAI_LINUX

      // Posts message to the queue
      if (tx_queue_send(&pMac->sys.gSirNimRDMsgQ, pMsg,
                       TX_NO_WAIT) != TX_SUCCESS)
      {
         rc = eSIR_FAILURE;
         wdaLog(pMac, LOGP,
                FL("Posting a Msg to nimMsgQ failed!\n"));
         break;
      }
#else
      // For Windows based MAC, instead of posting message to different
      // queues, we will call the handler routines directly
      wdaLog(pMac, LOGE, "ERROR: Received PTT message in obsolete code path.\n");
      wdaLog(pMac, LOGP, "This indicates that the wrong OID is being used - clean registry and previous inf files.\n");
      /*
      tPttMsgbuffer *msgPtr = (tPttMsgbuffer *)(pMsg->body);  //for some reason, body is actually being used as if it were a void *
      pttProcessMsg(pMac, msgPtr);
      */

      //TODO: the resonse is now packaged in ((tPttMsgbuffer *)&pMsg->body)->msgResponse and needs to be sent back to the application

      rc = eSIR_SUCCESS;
#endif
   }
   while (0);

   return rc;
} // halNimPTTPostMsgApi()
/* ---------------------------------------------------------
 * FUNCTION:  wdaGetGlobalSystemRole()
 *
 * Get the global HAL system role.
 * ---------------------------------------------------------
 */
tBssSystemRole wdaGetGlobalSystemRole(tpAniSirGlobal pMac)
{
    v_VOID_t * pVosContext = vos_get_global_context(VOS_MODULE_ID_WDA, NULL);
    tWDA_CbContext *wdaContext =
        vos_get_context(VOS_MODULE_ID_WDA, pVosContext);
    if(NULL == wdaContext)
    {
        VOS_TRACE( VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ERROR,
                   "%s:WDA context is NULL", __func__);
        VOS_ASSERT(0);
        return eSYSTEM_UNKNOWN_ROLE;
    }
    WDALOG1( wdaLog(pMac, LOG1, FL(" returning  %d role\n"),
                    wdaContext->wdaGlobalSystemRole));
    return  wdaContext->wdaGlobalSystemRole;
}
tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb)
{
    tSirMsgQ msg;
    tpAniSirGlobal pMac = (tpAniSirGlobal)pSirGlobal;


    tSirMbMsg* pMbLocal;
    msg.type = pMb->type;
    msg.bodyval = 0;

    WDALOG3(wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d\n" ),
                   pMb->type, pMb->msgLen));

    // copy the message from host buffer to firmware buffer
    // this will make sure that firmware allocates, uses and frees
    // it's own buffers for mailbox message instead of working on
    // host buffer

    // second parameter, 'wait option', to palAllocateMemory is ignored on Windows
    if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMbLocal, pMb->msgLen))
    {
        WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n")));
        return eSIR_FAILURE;
    }

    palCopyMemory(pMac, (void *)pMbLocal, (void *)pMb, pMb->msgLen);
    msg.bodyptr = pMbLocal;

    switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK)
    {
    case WDA_MSG_TYPES_BEGIN:    // Posts a message to the HAL MsgQ
        wdaPostCtrlMsg(pMac, &msg);
        break;

    case SIR_LIM_MSG_TYPES_BEGIN:    // Posts a message to the LIM MsgQ
        limPostMsgApi(pMac, &msg);
        break;

    case SIR_CFG_MSG_TYPES_BEGIN:    // Posts a message to the CFG MsgQ
        wdaPostCfgMsg(pMac, &msg);
        break;

    case SIR_PMM_MSG_TYPES_BEGIN:    // Posts a message to the PMM MsgQ
        pmmPostMessage(pMac, &msg);
        break;

    case SIR_PTT_MSG_TYPES_BEGIN:
        WDALOGW( wdaLog(pMac, LOGW, FL("%s:%d: message type = 0x%X"),
                        __func__, __LINE__, msg.type));
        vos_mem_free(msg.bodyptr);
        break;


    default:
        WDALOGW( wdaLog(pMac, LOGW, FL("Unknown message type = "
                                       "0x%X\n"),
                        msg.type));

        // Release the memory.
        if (palFreeMemory( pMac->hHdd, (void*)(msg.bodyptr))
                != eHAL_STATUS_SUCCESS)
        {
            WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n")));
            return eSIR_FAILURE;
        }
        break;
    }

    return eSIR_SUCCESS;

} // uMacPostCtrlMsg()
tSirRetStatus uMacPostCtrlMsg(void* pSirGlobal, tSirMbMsg* pMb)
{
   tSirMsgQ msg;
   tpAniSirGlobal pMac = (tpAniSirGlobal)pSirGlobal;

#ifdef ANI_OS_TYPE_RTAI_LINUX

   msg.type = pMb->type;
   msg.bodyptr = pMb;
   msg.bodyval = 0;
   WDALOG3( wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d\n" ),
        pMb->type, pMb->msgLen));
#else

   tSirMbMsg* pMbLocal;
   msg.type = pMb->type;
   msg.bodyval = 0;

   WDALOG3(wdaLog(pMac, LOG3, FL("msgType %d, msgLen %d\n" ),
        pMb->type, pMb->msgLen));

   // copy the message from host buffer to firmware buffer
   // this will make sure that firmware allocates, uses and frees
   // it's own buffers for mailbox message instead of working on
   // host buffer

   // second parameter, 'wait option', to palAllocateMemory is ignored on Windows
   if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pMbLocal, pMb->msgLen))
   {
      WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n")));
      return eSIR_FAILURE;
   }

   palCopyMemory(pMac, (void *)pMbLocal, (void *)pMb, pMb->msgLen);
   msg.bodyptr = pMbLocal;
#endif

   switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK)
   {
   case WDA_MSG_TYPES_BEGIN:    // Posts a message to the HAL MsgQ
      wdaPostCtrlMsg(pMac, &msg);
      break;

   case SIR_LIM_MSG_TYPES_BEGIN:    // Posts a message to the LIM MsgQ
      limPostMsgApi(pMac, &msg);
      break;

   case SIR_CFG_MSG_TYPES_BEGIN:    // Posts a message to the CFG MsgQ
      wdaPostCfgMsg(pMac, &msg);
      break;

   case SIR_PMM_MSG_TYPES_BEGIN:    // Posts a message to the PMM MsgQ
      pmmPostMessage(pMac, &msg);
      break;

#if defined(ANI_MANF_DIAG) || defined(ANI_PHY_DEBUG)
   case SIR_PTT_MSG_TYPES_BEGIN:
#ifndef FEATURE_WLAN_INTEGRATED_SOC
      halNimPTTPostMsgApi(pMac, &msg); // Posts a message to the NIM PTT MsgQ
#endif /* FEATURE_WLAN_INTEGRATED_SOC */
      break;

#endif

   default:
      WDALOGW( wdaLog(pMac, LOGW, FL("Unknown message type = "
             "0x%X\n"),
             msg.type));

      // Release the memory.
      if (palFreeMemory( pMac->hHdd, (void*)(msg.bodyptr))
            != eHAL_STATUS_SUCCESS)
      {
         WDALOGE( wdaLog(pMac, LOGE, FL("Buffer Allocation failed!\n")));
         return eSIR_FAILURE;
      }
      break;
   }

   return eSIR_SUCCESS;

} // uMacPostCtrlMsg()