1 /* 2 * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 /** 21 * DOC: wlan_qct_wma_legacy.c 22 * 23 * This software unit holds the implementation of the WLAN Device Adaptation 24 * Layer for the legacy functionalities that were part of the old HAL. 25 * 26 * The functions externalized by this module are to be called ONLY by other 27 * WLAN modules that properly register with the Transport Layer initially. 28 * 29 */ 30 31 /* Standard include files */ 32 /* Application Specific include files */ 33 #include "lim_api.h" 34 #include "wma.h" 35 #include "sme_power_save_api.h" 36 /* Locally used Defines */ 37 38 #define HAL_MMH_MB_MSG_TYPE_MASK 0xFF00 39 40 /** 41 * wma_post_ctrl_msg() - Posts WMA messages to MC thread 42 * @mac: MAC parameters structure 43 * @pMsg: pointer with message 44 * 45 * Return: Success or Failure 46 */ 47 wma_post_ctrl_msg(struct mac_context * mac,struct scheduler_msg * pMsg)48 QDF_STATUS wma_post_ctrl_msg(struct mac_context *mac, struct scheduler_msg *pMsg) 49 { 50 if (QDF_STATUS_SUCCESS != 51 scheduler_post_message(QDF_MODULE_ID_WMA, 52 QDF_MODULE_ID_WMA, 53 QDF_MODULE_ID_WMA, pMsg)) 54 return QDF_STATUS_E_FAILURE; 55 else 56 return QDF_STATUS_SUCCESS; 57 } 58 59 /** 60 * u_mac_post_ctrl_msg() - post ctrl msg 61 * @pMb: A pointer to the mailbox message 62 * 63 * Forwards the completely received message to the respective 64 * modules for further processing. 65 * 66 * NOTE: 67 * This function has been moved to the API file because for MAC running 68 * on Windows host, the host module will call this routine directly to 69 * send any mailbox messages. Making this function an API makes sure that 70 * outside world (any module outside MMH) only calls APIs to use MMH 71 * services and not an internal function. 72 * 73 * Return: success/error code 74 */ 75 u_mac_post_ctrl_msg(void * pSirGlobal,tSirMbMsg * pMb)76 QDF_STATUS u_mac_post_ctrl_msg(void *pSirGlobal, tSirMbMsg *pMb) 77 { 78 struct scheduler_msg msg = {0}; 79 QDF_STATUS status = QDF_STATUS_SUCCESS; 80 struct mac_context *mac = (struct mac_context *) pSirGlobal; 81 82 msg.type = pMb->type; 83 msg.bodyval = 0; 84 msg.bodyptr = pMb; 85 86 switch (msg.type & HAL_MMH_MB_MSG_TYPE_MASK) { 87 case WMA_MSG_TYPES_BEGIN: /* Posts a message to the HAL MsgQ */ 88 status = wma_post_ctrl_msg(mac, &msg); 89 break; 90 91 case SIR_LIM_MSG_TYPES_BEGIN: /* Posts a message to the LIM MsgQ */ 92 status = lim_post_msg_api(mac, &msg); 93 break; 94 95 case SIR_SME_MSG_TYPES_BEGIN: /* Posts a message to the LIM MsgQ */ 96 status = sme_post_pe_message(mac, &msg); 97 break; 98 99 default: 100 wma_debug("Unknown message type = 0x%X", msg.type); 101 qdf_mem_free(msg.bodyptr); 102 return QDF_STATUS_E_FAILURE; 103 } 104 105 if (status != QDF_STATUS_SUCCESS) 106 qdf_mem_free(msg.bodyptr); 107 108 return status; 109 110 } /* u_mac_post_ctrl_msg() */ 111 umac_send_mb_message_to_mac(void * msg)112 QDF_STATUS umac_send_mb_message_to_mac(void *msg) 113 { 114 void *mac_handle = cds_get_context(QDF_MODULE_ID_SME); 115 116 if (!mac_handle) { 117 qdf_mem_free(msg); 118 return QDF_STATUS_E_FAILURE; 119 } 120 121 return u_mac_post_ctrl_msg(mac_handle, msg); 122 } 123