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