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