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