1 /* 2 * Copyright (c) 2016-2018, 2020 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 #ifndef _WLAN_LMAC_IF_API_H_ 21 #define _WLAN_LMAC_IF_API_H_ 22 23 #include "wlan_objmgr_cmn.h" 24 #include "wlan_objmgr_psoc_obj.h" 25 #include "wlan_objmgr_pdev_obj.h" 26 27 /** 28 * wlan_lmac_if_umac_rx_ops_register() - UMAC rx handler register 29 * @rx_ops: Pointer to rx_ops structure to be populated 30 * 31 * Register umac RX callabacks which will be called by DA/OL/WMA/WMI 32 * 33 * Return: QDF_STATUS_SUCCESS - in case of success 34 */ 35 QDF_STATUS wlan_lmac_if_umac_rx_ops_register 36 (struct wlan_lmac_if_rx_ops *rx_ops); 37 38 /** 39 * wlan_lmac_if_set_umac_txops_registration_cb() - tx registration 40 * callback assignment 41 * @dev_type: Dev type can be either Direct attach or Offload 42 * @handler: handler to be called for LMAC tx ops registration 43 * 44 * API to assign appropriate tx registration callback handler based on the 45 * device type(Offload or Direct attach) 46 * 47 * Return: QDF_STATUS_SUCCESS - in case of success 48 */ 49 QDF_STATUS wlan_lmac_if_set_umac_txops_registration_cb 50 (QDF_STATUS (*handler)(struct wlan_lmac_if_tx_ops *)); 51 52 53 /** 54 * wlan_lmac_if_get_mgmt_txrx_rx_ops() - retrieve the mgmt rx_ops 55 * @psoc: psoc context 56 * 57 * API to retrieve the mgmt rx_ops from the psoc context 58 * 59 * Return: mgmt_rx_ops pointer 60 */ 61 static inline struct wlan_lmac_if_mgmt_txrx_rx_ops * 62 wlan_lmac_if_get_mgmt_txrx_rx_ops(struct wlan_objmgr_psoc *psoc) 63 { 64 struct wlan_lmac_if_rx_ops *rx_ops; 65 66 if (!psoc) 67 return NULL; 68 69 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 70 if (!rx_ops) { 71 qdf_err("rx_ops is NULL"); 72 return NULL; 73 } 74 75 return &rx_ops->mgmt_txrx_rx_ops; 76 } 77 78 /** 79 * wlan_lmac_if_get_dfs_rx_ops() - retrieve the dfs rx_ops 80 * @psoc: psoc context 81 * 82 * API to retrieve the dfs rx_ops from the psoc context 83 * 84 * Return: dfs_rx_ops pointer 85 */ 86 static inline struct wlan_lmac_if_dfs_rx_ops * 87 wlan_lmac_if_get_dfs_rx_ops(struct wlan_objmgr_psoc *psoc) 88 { 89 struct wlan_lmac_if_rx_ops *rx_ops; 90 91 if (!psoc) 92 return NULL; 93 94 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 95 if (!rx_ops) { 96 qdf_err("rx_ops is NULL"); 97 return NULL; 98 } 99 100 return &rx_ops->dfs_rx_ops; 101 } 102 103 /** 104 * wlan_lmac_if_get_reg_rx_ops() - retrieve the reg rx_ops 105 * @psoc: psoc context 106 * 107 * API to retrieve the reg rx_ops from the psoc context 108 * 109 * Return: reg_rx_ops pointer 110 */ 111 static inline struct wlan_lmac_if_reg_rx_ops * 112 wlan_lmac_if_get_reg_rx_ops(struct wlan_objmgr_psoc *psoc) 113 { 114 struct wlan_lmac_if_rx_ops *rx_ops; 115 116 if (!psoc) 117 return NULL; 118 119 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 120 if (!rx_ops) { 121 qdf_err("rx_ops is NULL"); 122 return NULL; 123 } 124 125 return &rx_ops->reg_rx_ops; 126 } 127 128 #ifdef WLAN_SUPPORT_GREEN_AP 129 /** 130 * wlan_lmac_if_get_green_ap_rx_ops() - retrieve the green ap rx_ops 131 * @psoc: psoc context 132 * 133 * API to retrieve the dfs rx_ops from the psoc context 134 * 135 * Return: green_ap_rx_ops pointer 136 */ 137 static inline struct wlan_lmac_if_green_ap_rx_ops * 138 wlan_lmac_if_get_green_ap_rx_ops(struct wlan_objmgr_psoc *psoc) 139 { 140 struct wlan_lmac_if_rx_ops *rx_ops; 141 142 if (!psoc) 143 return NULL; 144 145 rx_ops = wlan_psoc_get_lmac_if_rxops(psoc); 146 if (!rx_ops) { 147 qdf_err("rx_ops is NULL"); 148 return NULL; 149 } 150 151 return &rx_ops->green_ap_rx_ops; 152 } 153 #endif 154 155 /** 156 * mgmt_txrx_get_nbuf() - retrieve nbuf from mgmt desc_id 157 * @pdev: pdev context 158 * @desc_id: mgmt desc_id 159 * 160 * API to retrieve the nbuf from mgmt desc_id 161 * 162 * Return: nbuf 163 */ 164 static inline qdf_nbuf_t 165 mgmt_txrx_get_nbuf(struct wlan_objmgr_pdev *pdev, uint32_t desc_id) 166 { 167 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 168 struct wlan_objmgr_psoc *psoc; 169 170 psoc = wlan_pdev_get_psoc(pdev); 171 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 172 173 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_txrx_get_nbuf_from_desc_id) 174 return mgmt_rx_ops->mgmt_txrx_get_nbuf_from_desc_id(pdev, 175 desc_id); 176 177 return NULL; 178 } 179 180 /** 181 * mgmt_txrx_tx_completion_handler() - mgmt tx completion handler 182 * @pdev: pdev context 183 * @desc_id: mgmt desc_id 184 * @status: tx status 185 * @params: tx params 186 * 187 * API to handle the tx completion for mgmt frames 188 * 189 * Return: QDF_STATUS_SUCCESS - in case of success 190 */ 191 static inline QDF_STATUS 192 mgmt_txrx_tx_completion_handler(struct wlan_objmgr_pdev *pdev, 193 uint32_t desc_id, uint32_t status, 194 void *params) 195 { 196 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 197 struct wlan_objmgr_psoc *psoc; 198 qdf_nbuf_t nbuf; 199 200 psoc = wlan_pdev_get_psoc(pdev); 201 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 202 203 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_tx_completion_handler) 204 return mgmt_rx_ops->mgmt_tx_completion_handler(pdev, desc_id, 205 status, params); 206 207 nbuf = mgmt_txrx_get_nbuf(pdev, desc_id); 208 if (nbuf) 209 qdf_nbuf_free(nbuf); 210 211 return QDF_STATUS_E_NULL_VALUE; 212 } 213 214 /** 215 * mgmt_txrx_rx_handler() - mgmt rx frame handler 216 * @psoc: psoc context 217 * @nbuf: nbuf 218 * @params: rx params 219 * 220 * API to receive mgmt frames 221 * 222 * Return: QDF_STATUS_SUCCESS - in case of success 223 */ 224 static inline QDF_STATUS 225 mgmt_txrx_rx_handler(struct wlan_objmgr_psoc *psoc, qdf_nbuf_t nbuf, 226 void *params) 227 { 228 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 229 230 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 231 232 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_rx_frame_handler) 233 return mgmt_rx_ops->mgmt_rx_frame_handler(psoc, nbuf, params); 234 235 if (nbuf) 236 qdf_nbuf_free(nbuf); 237 238 return QDF_STATUS_E_NULL_VALUE; 239 } 240 241 /** 242 * mgmt_txrx_get_peer() - retrieve peer from mgmt desc_id 243 * @pdev: pdev context 244 * @desc_id: mgmt desc_id 245 * 246 * API to retrieve the peer from mgmt desc_id 247 * 248 * Return: objmgr peer pointer 249 */ 250 static inline struct wlan_objmgr_peer * 251 mgmt_txrx_get_peer(struct wlan_objmgr_pdev *pdev, uint32_t desc_id) 252 { 253 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 254 struct wlan_objmgr_psoc *psoc; 255 256 psoc = wlan_pdev_get_psoc(pdev); 257 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 258 259 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_txrx_get_peer_from_desc_id) 260 return mgmt_rx_ops->mgmt_txrx_get_peer_from_desc_id(pdev, 261 desc_id); 262 263 return NULL; 264 } 265 266 /** 267 * mgmt_txrx_get_vdev_id() - retrieve vdev_id from mgmt desc_id 268 * @pdev: pdev context 269 * @desc_id: mgmt desc_id 270 * 271 * API to retrieve the vdev_id from mgmt desc_id 272 * 273 * Return: vdev_id 274 */ 275 static inline uint8_t 276 mgmt_txrx_get_vdev_id(struct wlan_objmgr_pdev *pdev, uint32_t desc_id) 277 { 278 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 279 struct wlan_objmgr_psoc *psoc; 280 281 psoc = wlan_pdev_get_psoc(pdev); 282 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 283 284 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_txrx_get_vdev_id_from_desc_id) 285 return mgmt_rx_ops->mgmt_txrx_get_vdev_id_from_desc_id(pdev, 286 desc_id); 287 288 return WLAN_UMAC_VDEV_ID_MAX; 289 } 290 /** 291 * mgmt_txrx_get_free_desc_count() - retrieve vdev_id from mgmt desc_id 292 * @pdev: pdev context 293 * 294 * API to get the free desc count mgmt desc pool 295 * 296 * Return: free_desc_count 297 */ 298 static inline uint32_t 299 mgmt_txrx_get_free_desc_count(struct wlan_objmgr_pdev *pdev) 300 { 301 struct wlan_lmac_if_mgmt_txrx_rx_ops *mgmt_rx_ops; 302 struct wlan_objmgr_psoc *psoc; 303 uint32_t free_desc_count = WLAN_INVALID_MGMT_DESC_COUNT; 304 305 psoc = wlan_pdev_get_psoc(pdev); 306 mgmt_rx_ops = wlan_lmac_if_get_mgmt_txrx_rx_ops(psoc); 307 308 if (mgmt_rx_ops && mgmt_rx_ops->mgmt_txrx_get_free_desc_pool_count) 309 free_desc_count = mgmt_rx_ops->mgmt_txrx_get_free_desc_pool_count( 310 pdev); 311 312 return free_desc_count; 313 } 314 #endif /* _WLAN_LMAC_IF_API_H */ 315