1 /*
2  * Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 /**
21  * DOC: wlan_hdd_sta_info.h
22  *
23  * Store and manage station info structure.
24  *
25  */
26 #if !defined(__WLAN_HDD_STA_INFO_H)
27 #define __WLAN_HDD_STA_INFO_H
28 
29 #include <wlan_hdd_main.h>
30 #include "qdf_lock.h"
31 #include "qdf_types.h"
32 #include "qdf_list.h"
33 #include "sap_api.h"
34 #include "cdp_txrx_cmn_struct.h"
35 #include "sir_mac_prot_def.h"
36 #include <linux/ieee80211.h>
37 #include <wlan_mlme_public_struct.h>
38 
39 /* Opaque handle for abstraction */
40 #define hdd_sta_info_entry qdf_list_node_t
41 
42 /**
43  * enum dhcp_phase - Per Peer DHCP Phases
44  * @DHCP_PHASE_ACK: upon receiving DHCP_ACK/NAK message in REQUEST phase or
45  *         DHCP_DELINE message in OFFER phase
46  * @DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase
47  * @DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase
48  * @DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase or
49  *         ACK phase (Renewal process)
50  */
51 enum dhcp_phase {
52 	DHCP_PHASE_ACK,
53 	DHCP_PHASE_DISCOVER,
54 	DHCP_PHASE_OFFER,
55 	DHCP_PHASE_REQUEST
56 };
57 
58 /**
59  * enum dhcp_nego_status - Per Peer DHCP Negotiation Status
60  * @DHCP_NEGO_STOP: when the peer is in ACK phase or client disassociated
61  * @DHCP_NEGO_IN_PROGRESS: when the peer is in DISCOVER or REQUEST
62  *         (Renewal process) phase
63  */
64 enum dhcp_nego_status {
65 	DHCP_NEGO_STOP,
66 	DHCP_NEGO_IN_PROGRESS
67 };
68 
69 /*
70  * Pending frame type of EAP_FAILURE, bit number used in "pending_eap_frm_type"
71  * of sta_info.
72  */
73 #define PENDING_TYPE_EAP_FAILURE  0
74 
75 /**
76  * enum wlan_sta_info_dbgid - sta info put/get debug id
77  * @STA_INFO_ID_RESERVED:   Reserved
78  * @STA_INFO_CFG80211_GET_LINK_PROPERTIES: Get link properties
79  * @STA_INFO_SOFTAP_INSPECT_TX_EAP_PKT:    Inspect the EAP-Failure
80  * @STA_INFO_SOFTAP_CHECK_WAIT_FOR_TX_EAP_PKT: Check and wait for eap failure
81  *                                             pkt tx completion
82  * @STA_INFO_SOFTAP_INSPECT_DHCP_PACKET:  Inspect DHCP packet
83  * @STA_INFO_SOFTAP_HARD_START_XMIT:    Transmit a frame
84  * @STA_INFO_SOFTAP_INIT_TX_RX_STA:     Initialize Tx/Rx for a softap station
85  * @STA_INFO_SOFTAP_RX_PACKET_CBK:      Receive packet handler
86  * @STA_INFO_SOFTAP_REGISTER_STA:       Register a SoftAP STA
87  * @STA_INFO_GET_CACHED_STATION_REMOTE: Get cached peer's info
88  * @STA_INFO_HDD_GET_STATION_REMOTE:    Get remote peer's info
89  * @STA_INFO_WLAN_HDD_CFG80211_GET_STATION: NL80211_CMD_GET_STATION handler for
90  *                                          SoftAP
91  * @STA_INFO_SOFTAP_DEAUTH_CURRENT_STA: Deauth current sta
92  * @STA_INFO_SOFTAP_DEAUTH_ALL_STA:     Deauth all sta in the sta list
93  * @STA_INFO_CFG80211_DEL_STATION:      CFG80211 del station handler
94  * @STA_INFO_HDD_CLEAR_ALL_STA:         Clear all stations
95  * @STA_INFO_FILL_STATION_INFO:         Fill stainfo for connected station
96  * @STA_INFO_HOSTAPD_SAP_EVENT_CB:      SAP event handler
97  * @STA_INFO_SAP_INDICATE_DISCONNECT_FOR_STA: Indicating disconnect indication
98  *                                            to the supplicant
99  * @STA_INFO_IS_PEER_ASSOCIATED:       Is peer connected to softap
100  * @STA_INFO_SAP_SET_TWO_INTS_GETNONE: Generic "set two integer" ioctl handler
101  * @STA_INFO_SAP_GETASSOC_STAMACADDR:  Handler to get assoc station mac address
102  * @STA_INFO_SOFTAP_GET_STA_INFO:      Get station info handler
103  * @STA_INFO_GET_SOFTAP_LINKSPEED:     Get link speed handler
104  * @STA_INFO_CONNECTION_IN_PROGRESS_ITERATOR: Check adapter connection based on
105  *                                            device mode
106  * @STA_INFO_SOFTAP_STOP_BSS:           Stop BSS
107  * @STA_INFO_SOFTAP_CHANGE_STA_STATE:   Change the state of a SoftAP station
108  * @STA_INFO_CLEAR_CACHED_STA_INFO:     Clear the cached sta info
109  * @STA_INFO_ATTACH_DETACH:             Station info attach/detach
110  * @STA_INFO_SHOW:     Station info show
111  * @STA_INFO_SOFTAP_IPA_RX_PKT_CALLBACK: Update rx mcbc stats for IPA case
112  * @STA_INFO_WLAN_HDD_CFG80211_DUMP_STATION: NL80211_CMD_GET_STATION dumpit
113  *                                           handler for SoftAP
114  * @STA_INFO_SON_GET_DATRATE_INFO: gets datarate info for a SON node
115  * @STA_INFO_ID_MAX: Number of enumerators
116  */
117 /*
118  * New value added to the enum must also be reflected in function
119  *  sta_info_string_from_dbgid()
120  */
121 typedef enum {
122 	STA_INFO_ID_RESERVED   = 0,
123 	STA_INFO_CFG80211_GET_LINK_PROPERTIES = 1,
124 	STA_INFO_SOFTAP_INSPECT_TX_EAP_PKT = 2,
125 	STA_INFO_SOFTAP_CHECK_WAIT_FOR_TX_EAP_PKT = 3,
126 	STA_INFO_SOFTAP_INSPECT_DHCP_PACKET = 4,
127 	STA_INFO_SOFTAP_HARD_START_XMIT = 5,
128 	STA_INFO_SOFTAP_INIT_TX_RX_STA = 6,
129 	STA_INFO_SOFTAP_RX_PACKET_CBK = 7,
130 	STA_INFO_SOFTAP_REGISTER_STA = 8,
131 	STA_INFO_GET_CACHED_STATION_REMOTE = 9,
132 	STA_INFO_HDD_GET_STATION_REMOTE = 10,
133 	STA_INFO_WLAN_HDD_CFG80211_GET_STATION = 11,
134 	STA_INFO_SOFTAP_DEAUTH_CURRENT_STA = 12,
135 	STA_INFO_SOFTAP_DEAUTH_ALL_STA = 13,
136 	STA_INFO_CFG80211_DEL_STATION = 14,
137 	STA_INFO_HDD_CLEAR_ALL_STA = 15,
138 	STA_INFO_FILL_STATION_INFO = 16,
139 	STA_INFO_HOSTAPD_SAP_EVENT_CB = 17,
140 	STA_INFO_SAP_INDICATE_DISCONNECT_FOR_STA = 18,
141 	STA_INFO_IS_PEER_ASSOCIATED = 19,
142 	STA_INFO_SAP_SET_TWO_INTS_GETNONE = 20,
143 	STA_INFO_SAP_GETASSOC_STAMACADDR = 21,
144 	STA_INFO_SOFTAP_GET_STA_INFO = 22,
145 	STA_INFO_GET_SOFTAP_LINKSPEED = 23,
146 	STA_INFO_CONNECTION_IN_PROGRESS_ITERATOR = 24,
147 	STA_INFO_SOFTAP_STOP_BSS = 25,
148 	STA_INFO_SOFTAP_CHANGE_STA_STATE = 26,
149 	STA_INFO_CLEAR_CACHED_STA_INFO = 27,
150 	STA_INFO_ATTACH_DETACH = 28,
151 	STA_INFO_SHOW = 29,
152 	STA_INFO_SOFTAP_IPA_RX_PKT_CALLBACK = 30,
153 	STA_INFO_WLAN_HDD_CFG80211_DUMP_STATION = 31,
154 	STA_INFO_SON_GET_DATRATE_INFO = 32,
155 	STA_INFO_ID_MAX,
156 } wlan_sta_info_dbgid;
157 
158 /**
159  * sta_info_string_from_dbgid() - Convert dbgid to respective string
160  * @id: debug id
161  *
162  * Debug support function to convert  dbgid to string.
163  * Please note to add new string in the array at index equal to
164  * its enum value in wlan_sta_info_dbgid.
165  */
166 char *sta_info_string_from_dbgid(wlan_sta_info_dbgid id);
167 
168 /**
169  * struct hdd_station_info - Per station structure kept in HDD for
170  *                                     multiple station support for SoftAP
171  * @sta_node: The sta_info node for the station info list maintained in adapter
172  * @in_use: Is the station entry in use?
173  * @sta_id: Station ID reported back from HAL (through SAP).
174  *           Broadcast uses station ID zero by default.
175  * @sta_type: Type of station i.e. p2p client or infrastructure station
176  * @sta_mac: MAC address of the station
177  * @mld_addr: MLD address of the station
178  * @peer_state: Current Station state so HDD knows how to deal with packet
179  *              queue. Most recent states used to change TLSHIM STA state.
180  * @is_qos_enabled: Track QoS status of station
181  * @is_deauth_in_progress: The station entry for which Deauth is in progress
182  * @nss: Number of spatial streams supported
183  * @rate_flags: Rate Flags for this connection
184  * @ecsa_capable: Extended CSA capabilities
185  * @ext_cap: The first 4 bytes of Extended capabilities IE
186  * @supported_band: sta band capabilities bitmap from supporting opclass
187  * @max_phy_rate: Calcuated maximum phy rate based on mode, nss, mcs etc.
188  * @tx_packets: The number of frames from host to firmware
189  * @tx_bytes: Bytes send to current station
190  * @rx_packets: Packets received from current station
191  * @rx_bytes: Bytes received from current station
192  * @last_tx_rx_ts: Last tx/rx timestamp with current station
193  * @assoc_ts: Current station association timestamp
194  * @disassoc_ts: Current station disassociation timestamp
195  * @tx_rate: Tx rate with current station reported from F/W
196  * @rx_rate: Rx rate with current station reported from F/W
197  * @ampdu: Ampdu enable or not of the station
198  * @sgi_enable: Short GI enable or not of the station
199  * @guard_interval: Guard interval
200  * @tx_stbc: Tx Space-time block coding enable/disable
201  * @rx_stbc: Rx Space-time block coding enable/disable
202  * @ch_width: Channel Width of the connection
203  * @mode: Mode of the connection
204  * @max_supp_idx: Max supported rate index of the station
205  * @max_ext_idx: Max extended supported rate index of the station
206  * @max_mcs_idx: Max supported mcs index from ht cap of the station
207  * @max_real_mcs_idx: Max supported mcs index from biggest cap of the station.
208  *                    For example, if station supports HE , first check he cap,
209  *                    then vht cap and so on.
210  * @rx_mcs_map: VHT Rx mcs map
211  * @tx_mcs_map: VHT Tx mcs map
212  * @freq : Frequency of the current station
213  * @dot11_mode: 802.11 Mode of the connection
214  * @ht_present: HT caps present or not in the current station
215  * @vht_present: VHT caps present or not in the current station
216  * @ht_caps: HT capabilities of current station
217  * @vht_caps: VHT capabilities of current station
218  * @reason_code: Disconnection reason code for current station
219  * @rssi: RSSI of the current station reported from F/W
220  * @dhcp_phase: Current phase of DHCP
221  * @dhcp_nego_status: Status of DHCP negotiation
222  * @capability: Capability information of current station
223  * @support_mode: Max supported mode of a station currently
224  * connected to sap
225  * @rx_retry_cnt: Number of rx retries received from current station
226  *                Currently this feature is not supported from FW
227  * @rx_mc_bc_cnt: Multicast broadcast packet count received from
228  *                current station
229  * MSB of rx_mc_bc_cnt indicates whether FW supports rx_mc_bc_cnt
230  * feature or not, if first bit is 1 it indicates that FW supports this
231  * feature, if it is 0 it indicates FW doesn't support this feature
232  * @tx_retry_succeed: the number of frames retried but successfully transmit
233  * @tx_retry_exhaust: the number of frames retried but finally failed
234  *                    from host to firmware
235  * @tx_total_fw: the number of all frames from firmware to remote station
236  * @tx_retry_fw: the number of retried frames from firmware to remote station
237  * @tx_retry_exhaust_fw: the number of frames retried but finally failed from
238  *                    firmware to remote station
239  * @rx_fcs_count: the number of frames received with fcs error
240  * @assoc_req_ies: Assoc request IEs of the peer station
241  * @ref_cnt: Reference count to synchronize sta_info access
242  * @ref_cnt_dbgid: Reference count to debug sta_info synchronization issues
243  * @pending_eap_frm_type: EAP frame type in tx queue without tx completion
244  * @is_attached: Flag to check if the stainfo is attached/detached
245  * @peer_rssi_per_chain: Average value of RSSI (dbm) per chain
246  * @num_tx_rate_count: Num tx rate count for current peer
247  * @num_rx_rate_count: Num rx rate count for current peer
248  * @tx_pkt_per_mcs: Number of tx rate counts for each MCS
249  * @rx_pkt_per_mcs: Number of rx rate counts for each MCS
250  * @vlan_id: VLAN id
251  */
252 struct hdd_station_info {
253 	qdf_list_node_t sta_node;
254 	bool in_use;
255 	uint8_t sta_id;
256 	eStationType sta_type;
257 	struct qdf_mac_addr sta_mac;
258 	struct qdf_mac_addr mld_addr;
259 	enum ol_txrx_peer_state peer_state;
260 	bool is_qos_enabled;
261 	bool is_deauth_in_progress;
262 	uint8_t   nss;
263 	uint32_t  rate_flags;
264 	uint8_t   ecsa_capable;
265 	uint32_t ext_cap;
266 	uint8_t supported_band;
267 	uint32_t max_phy_rate;
268 	uint32_t tx_packets;
269 	uint64_t tx_bytes;
270 	uint32_t rx_packets;
271 	uint64_t rx_bytes;
272 	qdf_time_t last_tx_rx_ts;
273 	qdf_time_t assoc_ts;
274 	qdf_time_t disassoc_ts;
275 	uint32_t tx_rate;
276 	uint32_t rx_rate;
277 	bool ampdu;
278 	bool sgi_enable;
279 	enum txrate_gi guard_interval;
280 	bool tx_stbc;
281 	bool rx_stbc;
282 	tSirMacHTChannelWidth ch_width;
283 	uint8_t mode;
284 	uint8_t max_supp_idx;
285 	uint8_t max_ext_idx;
286 	uint8_t max_mcs_idx;
287 	uint8_t max_real_mcs_idx;
288 	uint8_t rx_mcs_map;
289 	uint8_t tx_mcs_map;
290 	uint32_t freq;
291 	uint8_t dot11_mode;
292 	bool ht_present;
293 	bool vht_present;
294 	struct ieee80211_ht_cap ht_caps;
295 	struct ieee80211_vht_cap vht_caps;
296 	uint32_t reason_code;
297 	int8_t rssi;
298 	enum dhcp_phase dhcp_phase;
299 	enum dhcp_nego_status dhcp_nego_status;
300 	uint16_t capability;
301 	uint8_t support_mode;
302 	uint32_t rx_retry_cnt;
303 	uint32_t rx_mc_bc_cnt;
304 	uint32_t tx_retry_succeed;
305 	uint32_t tx_retry_exhaust;
306 	uint32_t tx_total_fw;
307 	uint32_t tx_retry_fw;
308 	uint32_t tx_retry_exhaust_fw;
309 	uint32_t rx_fcs_count;
310 	struct element_info assoc_req_ies;
311 	qdf_atomic_t ref_cnt;
312 	qdf_atomic_t ref_cnt_dbgid[STA_INFO_ID_MAX];
313 	unsigned long pending_eap_frm_type;
314 	bool is_attached;
315 	int32_t peer_rssi_per_chain[WMI_MAX_CHAINS];
316 	uint32_t num_tx_rate_count;
317 	uint32_t num_rx_rate_count;
318 	uint32_t *tx_pkt_per_mcs;
319 	uint32_t *rx_pkt_per_mcs;
320 	uint16_t vlan_id;
321 };
322 
323 /**
324  * struct hdd_sta_info_obj - Station info container structure
325  * @sta_obj: The sta info object that stores the sta_info
326  * @sta_obj_lock: Lock to protect the sta_obj read/write access
327  */
328 struct hdd_sta_info_obj {
329 	qdf_list_t sta_obj;
330 	qdf_spinlock_t sta_obj_lock;
331 };
332 
333 /**
334  * hdd_put_sta_info_ref() - Release sta_info ref for synchronization
335  * @sta_info_container: The station info container obj that stores and maintains
336  *                      the sta_info obj.
337  * @sta_info: Station info structure to be released.
338  * @lock_required: Flag to acquire lock or not
339  * @sta_info_dbgid: Debug ID of the caller API
340  *
341  * Return: None
342  */
343 void hdd_put_sta_info_ref(struct hdd_sta_info_obj *sta_info_container,
344 			  struct hdd_station_info **sta_info,
345 			  bool lock_required,
346 			  wlan_sta_info_dbgid sta_info_dbgid);
347 
348 /**
349  * hdd_take_sta_info_ref() - Increment sta info ref.
350  * @sta_info_container: The station info container obj that stores and maintains
351  *                      the sta_info obj.
352  * @sta_info: Station info structure to be released.
353  * @lock_required: Flag to acquire lock or not
354  * @sta_info_dbgid: Debug ID of the caller API
355  *
356  * This function has to be accompanied by hdd_put_sta_info when the work with
357  * the sta info is done. Failure to do so will result in a mem leak.
358  *
359  * Return: None
360  */
361 void hdd_take_sta_info_ref(struct hdd_sta_info_obj *sta_info_container,
362 			   struct hdd_station_info *sta_info,
363 			   bool lock_required,
364 			   wlan_sta_info_dbgid sta_info_dbgid);
365 
366 /**
367  * hdd_get_front_sta_info_no_lock() - Get the first sta_info from the sta list
368  * This API does not use any lock in it's implementation. It is the caller's
369  * directive to ensure concurrency safety.
370  *
371  * @sta_info_container: The station info container obj that stores and maintains
372  *                      the sta_info obj.
373  * @out_sta_info: The station info structure that acts as the container object.
374  *
375  * Return: QDF_STATUS
376  */
377 QDF_STATUS
378 hdd_get_front_sta_info_no_lock(struct hdd_sta_info_obj *sta_info_container,
379 			       struct hdd_station_info **out_sta_info);
380 
381 /**
382  * hdd_get_next_sta_info_no_lock() - Get the next sta_info from the sta list
383  * This API does not use any lock in it's implementation. It is the caller's
384  * directive to ensure concurrency safety.
385  *
386  * @sta_info_container: The station info container obj that stores and maintains
387  *                      the sta_info obj.
388  * @current_sta_info: The station that was previously retrieved
389  * @out_sta_info: The station info structure that acts as the container object.
390  *
391  * Return: QDF_STATUS
392  */
393 QDF_STATUS
394 hdd_get_next_sta_info_no_lock(struct hdd_sta_info_obj *sta_info_container,
395 			      struct hdd_station_info *current_sta_info,
396 			      struct hdd_station_info **out_sta_info);
397 
398 /* Abstract wrapper to check sta_info validity */
399 #define __hdd_is_station_valid(sta_info) sta_info
400 
401 /**
402  * __hdd_take_ref_and_fetch_front_sta_info_safe - Helper macro to lock, fetch
403  * front sta_info, take ref and unlock in a delete safe manner.
404  * @sta_info_container: The station info container obj that stores and maintains
405  *			the sta_info obj.
406  * @sta_info: The station info structure that acts as the iterator object.
407  * @next_sta_info: A temporary node for maintaining del safe.
408  * @sta_info_dbgid: Debug ID of the caller API
409  */
410 #define __hdd_take_ref_and_fetch_front_sta_info_safe(sta_info_container, \
411 						     sta_info, next_sta_info, \
412 						     sta_info_dbgid) \
413 	qdf_spin_lock_bh(&sta_info_container.sta_obj_lock), \
414 	hdd_get_front_sta_info_no_lock(&sta_info_container, &sta_info), \
415 	(sta_info) ? hdd_take_sta_info_ref(&sta_info_container, \
416 					   sta_info, false, sta_info_dbgid) : \
417 					(false), \
418 	hdd_get_next_sta_info_no_lock(&sta_info_container, sta_info, \
419 				      &next_sta_info), \
420 	(next_sta_info) ? hdd_take_sta_info_ref(&sta_info_container, \
421 						next_sta_info, false, \
422 						sta_info_dbgid) : \
423 						(false), \
424 	qdf_spin_unlock_bh(&sta_info_container.sta_obj_lock)
425 
426 /**
427  * __hdd_take_ref_and_fetch_next_sta_info_safe - Helper macro to lock, fetch
428  * next sta_info, take ref and unlock.
429  * @sta_info_container: The station info container obj that stores and maintains
430  *			the sta_info obj.
431  * @sta_info: The station info structure that acts as the iterator object.
432  * @next_sta_info: A temporary node for maintaining del safe.
433  * @sta_info_dbgid: Debug ID of the caller API
434  */
435 #define __hdd_take_ref_and_fetch_next_sta_info_safe(sta_info_container, \
436 						    sta_info, next_sta_info, \
437 						    sta_info_dbgid) \
438 	qdf_spin_lock_bh(&sta_info_container.sta_obj_lock), \
439 	sta_info = next_sta_info, \
440 	hdd_get_next_sta_info_no_lock(&sta_info_container, sta_info, \
441 				      &next_sta_info), \
442 	(next_sta_info) ? hdd_take_sta_info_ref(&sta_info_container, \
443 					     next_sta_info, false, \
444 					     sta_info_dbgid) : \
445 					(false), \
446 	qdf_spin_unlock_bh(&sta_info_container.sta_obj_lock)
447 
448 /**
449  * hdd_for_each_sta_ref_safe - Iterate over each station stored in the sta info
450  *                             container in a delete safe manner
451  * @sta_info_container: The station info container obj that stores and maintains
452  *                      the sta_info obj.
453  * @sta_info: The station info structure that acts as the iterator object.
454  * @next_sta_info: A temporary node for maintaining del safe.
455  * @sta_info_dbgid: Debug ID of the caller API
456  *
457  * The sta_info will contain the structure that is fetched for that particular
458  * iteration. The next_sta_info is used to store the next station before the
459  * current station is deleted so as to provide a safe way to iterate the list
460  * while deletion is undergoing.
461  *
462  *			     ***** NOTE *****
463  * Before the end of each iteration, hdd_put_sta_info_ref must be
464  * called. Not calling this will keep hold of a reference, thus preventing
465  * deletion of the station info
466  *
467  * Usage example:
468  *	hdd_for_each_sta_ref_safe(sta_info_container, sta_info, next_sta_info,
469  *				  sta_info_dbgid) {
470  *		<work involving station>
471  *		<some more work>
472  *		hdd_put_sta_info_ref(sta_info_container, sta_info, true,
473  *				     sta_info_dbgid)
474  *	}
475  */
476 #define hdd_for_each_sta_ref_safe(sta_info_container, sta_info, next_sta_info, \
477 				  sta_info_dbgid) \
478 	for (__hdd_take_ref_and_fetch_front_sta_info_safe(sta_info_container, \
479 							  sta_info, \
480 							  next_sta_info, \
481 							  sta_info_dbgid); \
482 	     __hdd_is_station_valid(sta_info); \
483 	     __hdd_take_ref_and_fetch_next_sta_info_safe(sta_info_container, \
484 							 sta_info, \
485 							 next_sta_info, \
486 							 sta_info_dbgid))
487 
488 /**
489  * hdd_sta_info_init() - Initialise the wlan hdd station info container obj
490  * @sta_info_container: The station info container obj that stores and maintains
491  *                      the sta_info obj.
492  *
493  * Return: QDF_STATUS_SUCCESS on success, failure code otherwise
494  */
495 QDF_STATUS hdd_sta_info_init(struct hdd_sta_info_obj *sta_info_container);
496 
497 /**
498  * hdd_sta_info_deinit() - Deinit the wlan hdd station info container obj
499  * @sta_info_container: The station info container obj that stores and maintains
500  *                      the sta_info obj.
501  *
502  * Return: None
503  */
504 void hdd_sta_info_deinit(struct hdd_sta_info_obj *sta_info_container);
505 
506 /**
507  * hdd_sta_info_detach() - Detach the station info structure from the list
508  * @sta_info_container: The station info container obj that stores and maintains
509  *                      the sta_info obj.
510  * @sta_info: The station info structure that has to be detached from the
511  *            container object.
512  *
513  * Return: None
514  */
515 void hdd_sta_info_detach(struct hdd_sta_info_obj *sta_info_container,
516 			 struct hdd_station_info **sta_info);
517 
518 /**
519  * hdd_sta_info_attach() - Attach the station info structure into the list
520  * @sta_info_container: The station info container obj that stores and maintains
521  *                      the sta_info obj.
522  * @sta_info: The station info structure that is to be attached to the
523  *            container object.
524  *
525  * Return: QDF STATUS SUCCESS on successful attach, error code otherwise
526  */
527 QDF_STATUS hdd_sta_info_attach(struct hdd_sta_info_obj *sta_info_container,
528 			       struct hdd_station_info *sta_info);
529 
530 /**
531  * hdd_get_sta_info_by_id() - Find the sta_info structure by index
532  * @sta_info_container: The station info container obj that stores and maintains
533  *                      the sta_info obj.
534  * @idx: The index which the sta_info has to be fetched.
535  * @sta_info_dbgid: Debug ID of the caller API
536  *
537  * Return: Reference-counted Pointer to the hdd_station_info structure which
538  *         contains the mac address passed
539  */
540 struct hdd_station_info *hdd_get_sta_info_by_id(
541 				struct hdd_sta_info_obj *sta_info_container,
542 				const int idx,
543 				wlan_sta_info_dbgid sta_info_dbgid);
544 
545 /**
546  * hdd_get_sta_info_by_mac() - Find the sta_info structure by mac addr
547  * @sta_info_container: The station info container obj that stores and maintains
548  *                      the sta_info obj.
549  * @mac_addr: The mac addr by which the sta_info has to be fetched.
550  * @sta_info_dbgid: Debug ID of the caller API
551  *
552  * Return: Pointer to the hdd_station_info structure which contains the mac
553  *         address passed
554  */
555 struct hdd_station_info *hdd_get_sta_info_by_mac(
556 				struct hdd_sta_info_obj *sta_info_container,
557 				const uint8_t *mac_addr,
558 				wlan_sta_info_dbgid sta_info_dbgid);
559 
560 /**
561  * hdd_clear_cached_sta_info() - Clear the cached sta info from the container
562  * @hdd_adapter: The adapter containing the station info container obj that
563  *               stores and maintains the sta_info obj.
564  *
565  * Return: None
566  */
567 void hdd_clear_cached_sta_info(struct hdd_adapter *hdd_adapter);
568 
569 #endif /* __WLAN_HDD_STA_INFO_H */
570