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