1 /* 2 * Copyright (c) 2016-2020 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 35 36 #define IEEE80211_FC0_TYPE_MASK 0x0c 37 #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 38 #define IEEE80211_FC0_TYPE_MGT 0x00 39 40 /** 41 * mgmt_wakelock_reason - reasons mgmt_txrx might hold a wakelock 42 * @MGMT_TXRX_WAKELOCK_REASON_TX_CMP - wait for mgmt_tx_complete event 43 */ 44 enum mgmt_txrx_wakelock_reason { 45 MGMT_TXRX_WAKELOCK_REASON_TX_CMP 46 }; 47 48 /* timeout to wait for management_tx_complete event from firmware */ 49 #define MGMT_TXRX_WAKELOCK_TIMEOUT_TX_CMP 300 50 51 /* 52 * generic definitions for IEEE 802.11 frames 53 */ 54 struct ieee80211_frame { 55 uint8_t i_fc[2]; 56 uint8_t i_dur[2]; 57 union { 58 struct { 59 uint8_t i_addr1[QDF_MAC_ADDR_SIZE]; 60 uint8_t i_addr2[QDF_MAC_ADDR_SIZE]; 61 uint8_t i_addr3[QDF_MAC_ADDR_SIZE]; 62 }; 63 uint8_t i_addr_all[3 * QDF_MAC_ADDR_SIZE]; 64 }; 65 uint8_t i_seq[2]; 66 /* possibly followed by addr4[QDF_MAC_ADDR_SIZE]; */ 67 /* see below */ 68 } __packed; 69 70 71 /** 72 * struct mgmt_txrx_desc_elem_t - element in mgmt desc pool linked list 73 * @entry: list entry 74 * @tx_dwnld_cmpl_cb: dma completion callback function pointer 75 * @tx_ota_cmpl_cb: ota completion callback function pointer 76 * @nbuf: frame buffer 77 * @desc_id: descriptor id 78 * @peer: peer who wants to send this frame 79 * @context: caller component specific context 80 * @vdev_id: vdev id 81 * @in_use: flag to denote whether desc is in use 82 */ 83 struct mgmt_txrx_desc_elem_t { 84 qdf_list_node_t entry; 85 mgmt_tx_download_comp_cb tx_dwnld_cmpl_cb; 86 mgmt_ota_comp_cb tx_ota_cmpl_cb; 87 qdf_nbuf_t nbuf; 88 uint32_t desc_id; 89 struct wlan_objmgr_peer *peer; 90 void *context; 91 uint8_t vdev_id; 92 bool in_use; 93 }; 94 95 /** 96 * struct mgmt_desc_pool_t - linked list mgmt desc pool 97 * @free_list: linked list of free descriptors 98 * @pool: pool of descriptors in use 99 * @desc_pool_lock: mgmt. descriptor free pool spinlock 100 */ 101 struct mgmt_desc_pool_t { 102 qdf_list_t free_list; 103 struct mgmt_txrx_desc_elem_t *pool; 104 qdf_spinlock_t desc_pool_lock; 105 }; 106 107 /** 108 * struct mgmt_rx_handler - structure for storing rx cb 109 * @comp_id: component id 110 * @rx_cb: rx callback for the mgmt. frame 111 * @next: pointer to next rx cb structure 112 */ 113 struct mgmt_rx_handler { 114 enum wlan_umac_comp_id comp_id; 115 mgmt_frame_rx_callback rx_cb; 116 struct mgmt_rx_handler *next; 117 }; 118 119 /** 120 * struct txrx_stats - txrx stats for mgmt frames 121 * @pkts_success: no. of packets successfully txed/rcvd 122 * @pkts_fail: no. of packets unsuccessfully txed/rcvd 123 * @bytes_success: no. of bytes successfully txed/rcvd 124 * @bytes_fail: no. of bytes successfully txed/rcvd 125 * @assoc_req_rcvd: no. of assoc requests rcvd 126 * @assoc_rsp_rcvd: no. of assoc responses rcvd 127 * @reassoc_req_rcvd: no. of reassoc requests rcvd 128 * @reassoc_rsp_rcvd: no. of reassoc responses rcvd 129 * @probe_req_rcvd: no. of probe requests rcvd 130 * @prob_resp_rcvd: no. of probe responses rcvd 131 * @beacon_rcvd: no. of beacons rcvd 132 * @atim_rcvd: no. of ATIMs rcvd 133 * @disassoc_rcvd: no. of disassocs rcvd 134 * @auth_rcvd: no. of auths rcvd 135 * @deauth_rcvd: no. of deauths rcvd 136 * @action_rcvd: no. of action frames rcvd 137 * @action_no_ack_rcvd: no. of action frames with no ack rcvd 138 */ 139 struct txrx_stats { 140 uint64_t pkts_success; 141 uint64_t pkts_fail; 142 uint64_t bytes_success; 143 uint64_t bytes_fail; 144 uint64_t assoc_req_rcvd; 145 uint64_t assoc_rsp_rcvd; 146 uint64_t reassoc_req_rcvd; 147 uint64_t reassoc_rsp_rcvd; 148 uint64_t probe_req_rcvd; 149 uint64_t prob_resp_rcvd; 150 uint64_t beacon_rcvd; 151 uint64_t atim_rcvd; 152 uint64_t disassoc_rcvd; 153 uint64_t auth_rcvd; 154 uint64_t deauth_rcvd; 155 uint64_t action_rcvd; 156 uint64_t action_no_ack_rcvd; 157 }; 158 159 /** 160 * struct mgmt_txrx_stats_t - mgmt txrx stats 161 * @mgmt_tx_stats: mgmt tx stats 162 * @mgmt_rx_stats: mgmt rx stats 163 * @ota_comp: no. of ota completions rcvd 164 * @dma_comp: no. of dma completions rcvd 165 */ 166 struct mgmt_txrx_stats_t { 167 struct txrx_stats mgmt_tx_stats; 168 struct txrx_stats mgmt_rx_stats; 169 uint64_t ota_comp; 170 uint64_t dma_comp; 171 }; 172 173 /** 174 * struct mgmt_txrx_priv_psoc_context - mgmt txrx private psoc context 175 * @psoc: psoc context 176 * @mgmt_rx_comp_cb: array of pointers of mgmt rx cbs 177 * @mgmt_txrx_psoc_ctx_lock: mgmt txrx psoc ctx lock 178 */ 179 struct mgmt_txrx_priv_psoc_context { 180 struct wlan_objmgr_psoc *psoc; 181 struct mgmt_rx_handler *mgmt_rx_comp_cb[MGMT_MAX_FRAME_TYPE]; 182 qdf_spinlock_t mgmt_txrx_psoc_ctx_lock; 183 }; 184 185 /** 186 * struct mgmt_txrx_priv_context_dev - mgmt txrx private context 187 * @pdev: pdev context 188 * @mgmt_desc_pool: pointer to mgmt desc. pool 189 * @mgmt_txrx_stats: pointer to mgmt txrx stats 190 * @wakelock_tx_cmp: mgmt tx complete wake lock 191 * @wakelock_tx_runtime_cmp: mgmt tx runtime complete wake lock 192 */ 193 struct mgmt_txrx_priv_pdev_context { 194 struct wlan_objmgr_pdev *pdev; 195 struct mgmt_desc_pool_t mgmt_desc_pool; 196 struct mgmt_txrx_stats_t *mgmt_txrx_stats; 197 qdf_wake_lock_t wakelock_tx_cmp; 198 qdf_runtime_lock_t wakelock_tx_runtime_cmp; 199 }; 200 201 202 /** 203 * wlan_mgmt_txrx_desc_pool_init() - initializes mgmt. desc. pool 204 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 205 * 206 * This function initializes the mgmt descriptor pool. 207 * 208 * Return: QDF_STATUS_SUCCESS - in case of success 209 */ 210 QDF_STATUS wlan_mgmt_txrx_desc_pool_init( 211 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 212 213 /** 214 * wlan_mgmt_txrx_desc_pool_deinit() - deinitializes mgmt. desc. pool 215 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 216 * 217 * This function deinitializes the mgmt descriptor pool. 218 * 219 * Return: void 220 */ 221 void wlan_mgmt_txrx_desc_pool_deinit( 222 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 223 224 /** 225 * wlan_mgmt_txrx_desc_get() - gets mgmt. descriptor from freelist 226 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 227 * 228 * This function retrieves the mgmt. descriptor for mgmt. tx frames 229 * from the mgmt. descriptor freelist. 230 * 231 * Return: mgmt. descriptor retrieved. 232 */ 233 struct mgmt_txrx_desc_elem_t *wlan_mgmt_txrx_desc_get( 234 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx); 235 236 /** 237 * wlan_mgmt_txrx_desc_put() - puts mgmt. descriptor back in freelist 238 * @mgmt_txrx_pdev_ctx: mgmt txrx pdev context 239 * @desc_id: mgmt txrx descriptor id 240 * 241 * This function puts the mgmt. descriptor back in to the freelist. 242 * 243 * Return: void 244 */ 245 void wlan_mgmt_txrx_desc_put( 246 struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx, 247 uint32_t desc_id); 248 249 /** 250 * iot_sim_mgmt_tx_update - invokes iot_sim callback to modify the frame 251 * @psoc: psoc common object 252 * @vdev: vdev object 253 * @buf: frame buffer 254 * 255 * This function puts invokes iot_sim callback to modify the frame. 256 * 257 * Return: QDF_STATUS 258 */ 259 QDF_STATUS iot_sim_mgmt_tx_update(struct wlan_objmgr_psoc *psoc, 260 struct wlan_objmgr_vdev *vdev, 261 qdf_nbuf_t buf); 262 #endif 263