1 /* 2 * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _WLAN_MGMT_TXRX_MAIN_I_H_ 20 #define _WLAN_MGMT_TXRX_MAIN_I_H_ 21 22 /** 23 * DOC: wlan_mgmt_txrx_main_i.h 24 * 25 * management tx/rx layer private API and structures 26 * 27 */ 28 29 #include "wlan_mgmt_txrx_utils_api.h" 30 #include "wlan_objmgr_cmn.h" 31 #include "wlan_objmgr_psoc_obj.h" 32 #include "wlan_lmac_if_def.h" 33 #include "qdf_list.h" 34 #ifdef WLAN_MGMT_RX_REO_SUPPORT 35 #include "wlan_mgmt_txrx_rx_reo_i.h" 36 #endif 37 38 39 #define IEEE80211_FC0_TYPE_MASK 0x0c 40 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 41 #define IEEE80211_FC0_TYPE_MGT 0x00 42 #define IEEE80211_FC0_TYPE_CTL 0x04 43 44 /* for TYPE_MGT */ 45 #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 46 #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 47 #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 48 #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 49 #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 50 #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 51 #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 52 #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 53 #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 54 #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 55 #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 56 #define IEEE80211_FC0_SUBTYPE_ACTION 0xd0 57 #define IEEE80211_FCO_SUBTYPE_ACTION_NO_ACK 0xe0 58 59 /** 60 * mgmt_wakelock_reason - reasons mgmt_txrx might hold a wakelock 61 * @MGMT_TXRX_WAKELOCK_REASON_TX_CMP - wait for mgmt_tx_complete event 62 */ 63 enum mgmt_txrx_wakelock_reason { 64 MGMT_TXRX_WAKELOCK_REASON_TX_CMP 65 }; 66 67 /* timeout to wait for management_tx_complete event from firmware */ 68 #define MGMT_TXRX_WAKELOCK_TIMEOUT_TX_CMP 300 69 70 /* 71 * generic definitions for IEEE 802.11 frames 72 */ 73 struct ieee80211_frame { 74 uint8_t i_fc[2]; 75 uint8_t i_dur[2]; 76 union { 77 struct { 78 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 79 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 80 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 81 }; 82 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 83 }; 84 uint8_t i_seq[2]; 85 /* possibly followed by addr4[QDF_MAC_ADDR_SIZE]; */ 86 /* see below */ 87 } __packed; 88 89 90 /** 91 * struct mgmt_txrx_desc_elem_t - element in mgmt desc pool linked list 92 * @entry: list entry 93 * @tx_dwnld_cmpl_cb: dma completion callback function pointer 94 * @tx_ota_cmpl_cb: ota completion callback function pointer 95 * @nbuf: frame buffer 96 * @desc_id: descriptor id 97 * @peer: peer who wants to send this frame 98 * @context: caller component specific context 99 * @vdev_id: vdev id 100 * @in_use: flag to denote whether desc is in use 101 */ 102 struct mgmt_txrx_desc_elem_t { 103 qdf_list_node_t entry; 104 mgmt_tx_download_comp_cb tx_dwnld_cmpl_cb; 105 mgmt_ota_comp_cb tx_ota_cmpl_cb; 106 qdf_nbuf_t nbuf; 107 uint32_t desc_id; 108 struct wlan_objmgr_peer *peer; 109 void *context; 110 uint8_t vdev_id; 111 bool in_use; 112 }; 113 114 /** 115 * struct mgmt_desc_pool_t - linked list mgmt desc pool 116 * @free_list: linked list of free descriptors 117 * @pool: pool of descriptors in use 118 * @desc_pool_lock: mgmt. descriptor free pool spinlock 119 */ 120 struct mgmt_desc_pool_t { 121 qdf_list_t free_list; 122 struct mgmt_txrx_desc_elem_t *pool; 123 qdf_spinlock_t desc_pool_lock; 124 }; 125 126 /** 127 * struct mgmt_rx_handler - structure for storing rx cb 128 * @comp_id: component id 129 * @rx_cb: rx callback for the mgmt. frame 130 * @next: pointer to next rx cb structure 131 */ 132 struct mgmt_rx_handler { 133 enum wlan_umac_comp_id comp_id; 134 mgmt_frame_rx_callback rx_cb; 135 struct mgmt_rx_handler *next; 136 }; 137 138 /** 139 * struct txrx_stats - txrx stats for mgmt frames 140 * @pkts_success: no. of packets successfully txed/rcvd 141 * @pkts_fail: no. of packets unsuccessfully txed/rcvd 142 * @bytes_success: no. of bytes successfully txed/rcvd 143 * @bytes_fail: no. of bytes successfully txed/rcvd 144 * @assoc_req_rcvd: no. of assoc requests rcvd 145 * @assoc_rsp_rcvd: no. of assoc responses rcvd 146 * @reassoc_req_rcvd: no. of reassoc requests rcvd 147 * @reassoc_rsp_rcvd: no. of reassoc responses rcvd 148 * @probe_req_rcvd: no. of probe requests rcvd 149 * @prob_resp_rcvd: no. of probe responses rcvd 150 * @beacon_rcvd: no. of beacons rcvd 151 * @atim_rcvd: no. of ATIMs rcvd 152 * @disassoc_rcvd: no. of disassocs rcvd 153 * @auth_rcvd: no. of auths rcvd 154 * @deauth_rcvd: no. of deauths rcvd 155 * @action_rcvd: no. of action frames rcvd 156 * @action_no_ack_rcvd: no. of action frames with no ack rcvd 157 */ 158 struct txrx_stats { 159 uint64_t pkts_success; 160 uint64_t pkts_fail; 161 uint64_t bytes_success; 162 uint64_t bytes_fail; 163 uint64_t assoc_req_rcvd; 164 uint64_t assoc_rsp_rcvd; 165 uint64_t reassoc_req_rcvd; 166 uint64_t reassoc_rsp_rcvd; 167 uint64_t probe_req_rcvd; 168 uint64_t prob_resp_rcvd; 169 uint64_t beacon_rcvd; 170 uint64_t atim_rcvd; 171 uint64_t disassoc_rcvd; 172 uint64_t auth_rcvd; 173 uint64_t deauth_rcvd; 174 uint64_t action_rcvd; 175 uint64_t action_no_ack_rcvd; 176 }; 177 178 /** 179 * struct mgmt_txrx_stats_t - mgmt txrx stats 180 * @mgmt_tx_stats: mgmt tx stats 181 * @mgmt_rx_stats: mgmt rx stats 182 * @ota_comp: no. of ota completions rcvd 183 * @dma_comp: no. of dma completions rcvd 184 */ 185 struct mgmt_txrx_stats_t { 186 struct txrx_stats mgmt_tx_stats; 187 struct txrx_stats mgmt_rx_stats; 188 uint64_t ota_comp; 189 uint64_t dma_comp; 190 }; 191 192 /** 193 * struct mgmt_txrx_priv_psoc_context - mgmt txrx private psoc context 194 * @psoc: psoc context 195 * @mgmt_rx_comp_cb: array of pointers of mgmt rx cbs 196 * @mgmt_txrx_psoc_ctx_lock: mgmt txrx psoc ctx lock 197 */ 198 struct mgmt_txrx_priv_psoc_context { 199 struct wlan_objmgr_psoc *psoc; 200 struct mgmt_rx_handler *mgmt_rx_comp_cb[MGMT_MAX_FRAME_TYPE]; 201 qdf_spinlock_t mgmt_txrx_psoc_ctx_lock; 202 }; 203 204 /** 205 * struct mgmt_txrx_priv_context_dev - mgmt txrx private context 206 * @pdev: pdev context 207 * @mgmt_desc_pool: pointer to mgmt desc. pool 208 * @mgmt_txrx_stats: pointer to mgmt txrx stats 209 * @wakelock_tx_cmp: mgmt tx complete wake lock 210 * @wakelock_tx_runtime_cmp: mgmt tx runtime complete wake lock 211 * @mgmt_rx_reo_pdev_ctx: pointer to pdev object of MGMT Rx REO module 212 */ 213 struct mgmt_txrx_priv_pdev_context { 214 struct wlan_objmgr_pdev *pdev; 215 struct mgmt_desc_pool_t mgmt_desc_pool; 216 struct mgmt_txrx_stats_t *mgmt_txrx_stats; 217 qdf_wake_lock_t wakelock_tx_cmp; 218 qdf_runtime_lock_t wakelock_tx_runtime_cmp; 219 #ifdef WLAN_MGMT_RX_REO_SUPPORT 220 struct mgmt_rx_reo_pdev_info *mgmt_rx_reo_pdev_ctx; 221 #endif 222 }; 223 224 225 /** 226 * wlan_mgmt_txrx_desc_pool_init() - initializes mgmt. desc. pool 227 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 228 * 229 * This function initializes the mgmt descriptor pool. 230 * 231 * Return: QDF_STATUS_SUCCESS - in case of success 232 */ 233 QDF_STATUS wlan_mgmt_txrx_desc_pool_init( 234 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 235 236 /** 237 * wlan_mgmt_txrx_desc_pool_deinit() - deinitializes mgmt. desc. pool 238 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 239 * 240 * This function deinitializes the mgmt descriptor pool. 241 * 242 * Return: void 243 */ 244 void wlan_mgmt_txrx_desc_pool_deinit( 245 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 246 247 /** 248 * wlan_mgmt_txrx_desc_get() - gets mgmt. descriptor from freelist 249 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 250 * 251 * This function retrieves the mgmt. descriptor for mgmt. tx frames 252 * from the mgmt. descriptor freelist. 253 * 254 * Return: mgmt. descriptor retrieved. 255 */ 256 struct mgmt_txrx_desc_elem_t *wlan_mgmt_txrx_desc_get( 257 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 258 259 /** 260 * wlan_mgmt_txrx_desc_put() - puts mgmt. descriptor back in freelist 261 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 262 * @desc_id: mgmt txrx descriptor id 263 * 264 * This function puts the mgmt. descriptor back in to the freelist. 265 * 266 * Return: void 267 */ 268 void wlan_mgmt_txrx_desc_put( 269 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx, 270 uint32_t desc_id); 271 272 /** 273 * iot_sim_mgmt_tx_update - invokes iot_sim callback to modify the frame 274 * @psoc: psoc common object 275 * @vdev: vdev object 276 * @buf: frame buffer 277 * 278 * This function puts invokes iot_sim callback to modify the frame. 279 * 280 * Return: QDF_STATUS 281 */ 282 QDF_STATUS iot_sim_mgmt_tx_update(struct wlan_objmgr_psoc *psoc, 283 struct wlan_objmgr_vdev *vdev, 284 qdf_nbuf_t buf); 285 #endif 286