1 /* 2 * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved. 3 * 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 #include "qdf_mem.h" 21 #include "qdf_module.h" 22 #include "wlan_lmac_if_def.h" 23 #include "wlan_lmac_if_api.h" 24 #include "wlan_global_lmac_if_api.h" 25 #ifdef WLAN_CONV_SPECTRAL_ENABLE 26 #include <wlan_spectral_utils_api.h> 27 #endif 28 /* Function pointer to call DA/OL specific tx_ops registration function */ 29 QDF_STATUS (*wlan_global_lmac_if_tx_ops_register[MAX_DEV_TYPE]) 30 (struct wlan_lmac_if_tx_ops *tx_ops); 31 32 #ifdef WLAN_CONV_SPECTRAL_ENABLE 33 /* Function pointer for spectral rx_ops registration function */ 34 void (*wlan_lmac_if_sptrl_rx_ops)(struct wlan_lmac_if_rx_ops *rx_ops); 35 36 QDF_STATUS wlan_lmac_if_sptrl_set_rx_ops_register_cb(void (*handler) 37 (struct wlan_lmac_if_rx_ops *)) 38 { 39 wlan_lmac_if_sptrl_rx_ops = handler; 40 41 return QDF_STATUS_SUCCESS; 42 } 43 qdf_export_symbol(wlan_lmac_if_sptrl_set_rx_ops_register_cb); 44 #endif /* WLAN_CONV_SPECTRAL_ENABLE */ 45 46 /* 47 * spectral scan is built as separate .ko for WIN where 48 * MCL it is part of wlan.ko so the registration of 49 .* rx ops to global lmac if layer is different between WIN 50 * and MCL 51 */ 52 #ifdef WLAN_CONV_SPECTRAL_ENABLE 53 /** 54 * wlan_spectral_register_rx_ops() - Register spectral component RX OPS 55 * @rx_ops: lmac if receive ops 56 * 57 * Return: None 58 */ 59 #ifdef CONFIG_WIN 60 static void wlan_spectral_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) 61 { 62 wlan_lmac_if_sptrl_rx_ops(rx_ops); 63 } 64 #else 65 static void wlan_spectral_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) 66 { 67 wlan_lmac_if_sptrl_register_rx_ops(rx_ops); 68 } 69 #endif /*CONFIG_WIN*/ 70 #else 71 /** 72 * wlan_spectral_register_rx_ops() - Dummy api to register spectral RX OPS 73 * @rx_ops: lmac if receive ops 74 * 75 * Return: None 76 */ 77 static void wlan_spectral_register_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops) 78 { 79 } 80 #endif /*WLAN_CONV_SPECTRAL_ENABLE*/ 81 82 /** 83 * wlan_global_lmac_if_rx_ops_register() - Global lmac_if 84 * rx handler register 85 * @rx_ops: Pointer to rx_ops structure to be populated 86 * 87 * Register lmac_if RX callabacks which will be called by DA/OL/WMA/WMI 88 * 89 * Return: QDF_STATUS_SUCCESS - in case of success 90 */ 91 QDF_STATUS 92 wlan_global_lmac_if_rx_ops_register(struct wlan_lmac_if_rx_ops *rx_ops) 93 { 94 /* 95 * Component specific public api's to be called to register 96 * respective callbacks 97 * Ex: rx_ops->fp = function; 98 */ 99 if (!rx_ops) { 100 qdf_print("%s: lmac if rx ops pointer is NULL", __func__); 101 return QDF_STATUS_E_INVAL; 102 } 103 /* Registeration for UMAC componets */ 104 wlan_lmac_if_umac_rx_ops_register(rx_ops); 105 106 /* spectral rx_ops registration*/ 107 wlan_spectral_register_rx_ops(rx_ops); 108 109 return QDF_STATUS_SUCCESS; 110 } 111 112 /** 113 * wlan_global_lmac_if_open() - global lmac_if open 114 * @psoc: psoc context 115 * 116 * Opens up lmac_if southbound layer. This function calls OL,DA and UMAC 117 * modules to register respective tx and rx callbacks. 118 * 119 * Return: QDF_STATUS 120 */ 121 QDF_STATUS wlan_global_lmac_if_open(struct wlan_objmgr_psoc *psoc) 122 { 123 WLAN_DEV_TYPE dev_type; 124 125 dev_type = psoc->soc_nif.phy_type; 126 127 if (dev_type == WLAN_DEV_DA || dev_type == WLAN_DEV_OL) { 128 wlan_global_lmac_if_tx_ops_register[dev_type] 129 (&psoc->soc_cb.tx_ops); 130 } else { 131 /* Control should ideally not reach here */ 132 qdf_print("Invalid device type"); 133 return QDF_STATUS_E_INVAL; 134 } 135 136 /* Function call to register rx-ops handlers */ 137 wlan_global_lmac_if_rx_ops_register(&psoc->soc_cb.rx_ops); 138 139 return QDF_STATUS_SUCCESS; 140 } 141 qdf_export_symbol(wlan_global_lmac_if_open); 142 143 /** 144 * wlan_global_lmac_if_close() - Close global lmac_if 145 * @psoc: psoc context 146 * 147 * Deregister lmac_if TX and RX handlers 148 * 149 * Return: QDF_STATUS_SUCCESS - in case of success 150 */ 151 QDF_STATUS wlan_global_lmac_if_close(struct wlan_objmgr_psoc *psoc) 152 { 153 qdf_mem_zero(&psoc->soc_cb.tx_ops, sizeof(psoc->soc_cb.tx_ops)); 154 qdf_mem_zero(&psoc->soc_cb.rx_ops, sizeof(psoc->soc_cb.rx_ops)); 155 156 return QDF_STATUS_SUCCESS; 157 } 158 qdf_export_symbol(wlan_global_lmac_if_close); 159 160 /** 161 * wlan_global_lmac_if_set_txops_registration_cb() - tx 162 * registration callback assignment 163 * @dev_type: Dev type can be either Direct attach or Offload 164 * @handler: handler to be called for LMAC tx ops registration 165 * 166 * API to assign appropriate tx registration callback handler based on the 167 * device type(Offload or Direct attach) 168 * 169 * Return: QDF_STATUS_SUCCESS - in case of success 170 */ 171 QDF_STATUS wlan_global_lmac_if_set_txops_registration_cb(WLAN_DEV_TYPE dev_type, 172 QDF_STATUS (*handler)(struct wlan_lmac_if_tx_ops *)) 173 { 174 wlan_global_lmac_if_tx_ops_register[dev_type] = handler; 175 176 return QDF_STATUS_SUCCESS; 177 } 178 qdf_export_symbol(wlan_global_lmac_if_set_txops_registration_cb); 179