Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [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 | * 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 | |
| 28 | /** |
| 29 | * DOC: wlan_qct_wma_legacy.c |
| 30 | * |
| 31 | * This software unit holds the implementation of the WLAN Device Adaptation |
| 32 | * Layer for the legacy functionalities that were part of the old HAL. |
| 33 | * |
| 34 | * The functions externalized by this module are to be called ONLY by other |
| 35 | * WLAN modules that properly register with the Transport Layer initially. |
| 36 | * |
| 37 | */ |
| 38 | |
| 39 | /* Standard include files */ |
| 40 | /* Application Specific include files */ |
| 41 | #include "lim_api.h" |
| 42 | #include "cfg_api.h" |
| 43 | #include "wma.h" |
| 44 | #include "sme_power_save_api.h" |
| 45 | /* Locally used Defines */ |
| 46 | |
| 47 | #define HAL_MMH_MB_MSG_TYPE_MASK 0xFF00 |
| 48 | |
| 49 | /** |
| 50 | * wma_post_ctrl_msg() - Posts WMA messages to MC thread |
| 51 | * @pMac: MAC parameters structure |
| 52 | * @pMsg: pointer with message |
| 53 | * |
| 54 | * Return: Success or Failure |
| 55 | */ |
| 56 | |
| 57 | tSirRetStatus wma_post_ctrl_msg(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 58 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 59 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 60 | cds_mq_post_message(CDS_MQ_ID_WMA, (cds_msg_t *) pMsg)) |
| 61 | return eSIR_FAILURE; |
| 62 | else |
| 63 | return eSIR_SUCCESS; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * wma_post_cfg_msg() - Posts MNT messages to gSirMntMsgQ |
| 68 | * @pMac: MAC parameters structure |
| 69 | * @pMsg: A pointer to the msg |
| 70 | * |
| 71 | * Return: Success or Failure |
| 72 | */ |
| 73 | |
| 74 | tSirRetStatus wma_post_cfg_msg(tpAniSirGlobal pMac, tSirMsgQ *pMsg) |
| 75 | { |
| 76 | tSirRetStatus rc = eSIR_SUCCESS; |
| 77 | |
| 78 | do { |
| 79 | /* |
| 80 | *For Windows based MAC, instead of posting message to different |
| 81 | * queues we will call the handler routines directly |
| 82 | */ |
| 83 | |
| 84 | cfg_process_mb_msg(pMac, (tSirMbMsg *) pMsg->bodyptr); |
| 85 | rc = eSIR_SUCCESS; |
| 86 | } while (0); |
| 87 | |
| 88 | return rc; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * u_mac_post_ctrl_msg() - post ctrl msg |
| 93 | * @pMb: A pointer to the maibox message |
| 94 | * |
| 95 | * Forwards the completely received message to the respective |
| 96 | * modules for further processing. |
| 97 | * |
| 98 | * NOTE: |
| 99 | * This function has been moved to the API file because for MAC running |
| 100 | * on Windows host, the host module will call this routine directly to |
| 101 | * send any mailbox messages. Making this function an API makes sure that |
| 102 | * outside world (any module outside MMH) only calls APIs to use MMH |
| 103 | * services and not an internal function. |
| 104 | * |
| 105 | * Return: success/error code |
| 106 | */ |
| 107 | |
| 108 | tSirRetStatus u_mac_post_ctrl_msg(void *pSirGlobal, tSirMbMsg *pMb) |
| 109 | { |
| 110 | tSirMsgQ msg; |
| 111 | tpAniSirGlobal pMac = (tpAniSirGlobal) pSirGlobal; |
| 112 | |
| 113 | tSirMbMsg *pMbLocal; |
| 114 | msg.type = pMb->type; |
| 115 | msg.bodyval = 0; |
| 116 | |
| 117 | pMbLocal = cdf_mem_malloc(pMb->msgLen); |
| 118 | if (!pMbLocal) { |
| 119 | WMA_LOGE("Memory allocation failed! Can't send 0x%x\n", |
| 120 | msg.type); |
| 121 | return eSIR_MEM_ALLOC_FAILED; |
| 122 | } |
| 123 | |
| 124 | cdf_mem_copy((void *)pMbLocal, (void *)pMb, pMb->msgLen); |
| 125 | msg.bodyptr = pMbLocal; |
| 126 | |
| 127 | switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK) { |
| 128 | case WMA_MSG_TYPES_BEGIN: /* Posts a message to the HAL MsgQ */ |
| 129 | wma_post_ctrl_msg(pMac, &msg); |
| 130 | break; |
| 131 | |
| 132 | case SIR_LIM_MSG_TYPES_BEGIN: /* Posts a message to the LIM MsgQ */ |
| 133 | lim_post_msg_api(pMac, &msg); |
| 134 | break; |
| 135 | |
| 136 | case SIR_CFG_MSG_TYPES_BEGIN: /* Posts a message to the CFG MsgQ */ |
| 137 | wma_post_cfg_msg(pMac, &msg); |
| 138 | break; |
| 139 | |
| 140 | case SIR_PMM_MSG_TYPES_BEGIN: /* Posts a message to the LIM MsgQ */ |
| 141 | sme_post_pe_message(pMac, &msg); |
| 142 | break; |
| 143 | |
| 144 | case SIR_PTT_MSG_TYPES_BEGIN: |
| 145 | cdf_mem_free(msg.bodyptr); |
| 146 | break; |
| 147 | |
| 148 | default: |
| 149 | WMA_LOGD("Unknown message type = 0x%X\n", msg.type); |
| 150 | cdf_mem_free(msg.bodyptr); |
| 151 | return eSIR_FAILURE; |
| 152 | } |
| 153 | |
| 154 | return eSIR_SUCCESS; |
| 155 | |
| 156 | } /* u_mac_post_ctrl_msg() */ |
| 157 | |