xref: /wlan-dirver/qcacld-3.0/core/hdd/src/wlan_hdd_cm_api.h (revision dc882e4dd9e61bd77cf492e38eb95e049c61d2a7)
1 /*
2  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  * DOC: wlan_hdd_cm_api.h
20  *
21  * WLAN host device driver connect/disconnect functions declaration
22  */
23 
24 #ifndef __WLAN_HDD_CM_API_H
25 #define __WLAN_HDD_CM_API_H
26 
27 #include <net/cfg80211.h>
28 #include "wlan_cm_public_struct.h"
29 #include "osif_cm_util.h"
30 #include "wlan_cm_roam_ucfg_api.h"
31 
32 /**
33  * wlan_hdd_cm_connect() - cfg80211 connect api
34  * @wiphy: Pointer to wiphy
35  * @ndev: Pointer to network device
36  * @req: Pointer to cfg80211 connect request
37  *
38  * This function is used to issue connect request to connection manager
39  *
40  * Context: Any context.
41  * Return: 0 for success, non-zero for failure
42  */
43 int wlan_hdd_cm_connect(struct wiphy *wiphy,
44 			struct net_device *ndev,
45 			struct cfg80211_connect_params *req);
46 
47 /**
48  * wlan_hdd_cm_issue_disconnect() - initiate disconnect from osif
49  * @link_info: Link info pointer in HDD adapter
50  * @reason: Disconnect reason code
51  * @sync: true if wait for disconnect to complete is required. for the
52  *        supplicant initiated disconnect or during vdev delete/change interface
53  *        sync should be true.
54  *
55  * This function is used to issue disconnect request to connection manager
56  *
57  * Return: QDF_STATUS
58  */
59 QDF_STATUS
60 wlan_hdd_cm_issue_disconnect(struct wlan_hdd_link_info *link_info,
61 			     enum wlan_reason_code reason, bool sync);
62 
63 /**
64  * wlan_hdd_cm_disconnect() - cfg80211 disconnect api
65  * @wiphy: Pointer to wiphy
66  * @dev: Pointer to network device
67  * @reason: Disconnect reason code
68  *
69  * This function is used to issue disconnect request to connection manager
70  *
71  * Return: 0 for success, non-zero for failure
72  */
73 int wlan_hdd_cm_disconnect(struct wiphy *wiphy,
74 			   struct net_device *dev, u16 reason);
75 
76 QDF_STATUS hdd_cm_disconnect_complete(struct wlan_objmgr_vdev *vdev,
77 				      struct wlan_cm_discon_rsp *rsp,
78 				      enum osif_cb_type type);
79 
80 QDF_STATUS hdd_cm_netif_queue_control(struct wlan_objmgr_vdev *vdev,
81 				      enum netif_action_type action,
82 				      enum netif_reason_type reason);
83 
84 QDF_STATUS hdd_cm_connect_complete(struct wlan_objmgr_vdev *vdev,
85 				   struct wlan_cm_connect_resp *rsp,
86 				   enum osif_cb_type type);
87 
88 /**
89  * hdd_cm_send_vdev_keys() - send vdev keys
90  * @vdev: Pointer to vdev
91  * @key_index: key index value
92  * @pairwise: pairwise boolean value
93  * @cipher_type: cipher type enum value
94  *
95  * This function is used to send vdev keys
96  *
97  * Context: Any context.
98  * Return: QDF_STATUS
99  */
100 QDF_STATUS hdd_cm_send_vdev_keys(struct wlan_objmgr_vdev *vdev,
101 				 u8 key_index, bool pairwise,
102 				 enum wlan_crypto_cipher_type cipher_type);
103 
104 #ifdef WLAN_VENDOR_HANDOFF_CONTROL
105 /**
106  * hdd_cm_get_vendor_handoff_params() - to get vendor handoff params from fw
107  * @psoc: Pointer to psoc object
108  * @vendor_handoff_context: Pointer to vendor handoff event rsp
109  *
110  * Return: QDF_STATUS
111  */
112 QDF_STATUS
113 hdd_cm_get_vendor_handoff_params(struct wlan_objmgr_psoc *psoc,
114 				 void *vendor_handoff_context);
115 
116 /**
117  * hdd_cm_get_handoff_param() - send get vendor handoff param request to fw
118  * @psoc: psoc common object
119  * @vdev_id: vdev id
120  * @param_id: param id from enum vendor_control_roam_param
121  *
122  * Return: QDF_STATUS
123  */
124 QDF_STATUS hdd_cm_get_handoff_param(struct wlan_objmgr_psoc *psoc,
125 				    uint8_t vdev_id,
126 				    enum vendor_control_roam_param param_id);
127 #endif
128 
129 /**
130  * hdd_cm_napi_serialize_control() - NAPI serialize hdd cb
131  * @action: serialize or de-serialize NAPI activities
132  *
133  * This function is for napi serialize
134  *
135  * Return: qdf status
136  */
137 QDF_STATUS hdd_cm_napi_serialize_control(bool action);
138 
139 #ifdef WLAN_BOOST_CPU_FREQ_IN_ROAM
140 /**
141  * hdd_cm_perfd_set_cpufreq() - API to set CPU min freq
142  * @action: set or reset the CPU freq
143  *
144  * This function sets/resets the CPU min frequency
145  * by sending netlink msg to cnss-daemon, which will
146  * communicate to perf daemon to set/reset CPU freq.
147  *
148  * Return: qdf status
149  */
150 QDF_STATUS hdd_cm_perfd_set_cpufreq(bool action);
151 #else
152 static inline
153 QDF_STATUS hdd_cm_perfd_set_cpufreq(bool action)
154 {
155 	return QDF_STATUS_SUCCESS;
156 }
157 #endif
158 
159 #ifdef WLAN_FEATURE_FILS_SK
160 /**
161  * hdd_cm_save_gtk() - save gtk api
162  * @vdev: Pointer to vdev
163  * @rsp: Pointer to connect rsp
164  *
165  * This function is used to save gtk in legacy mode
166  *
167  * Return: QDF_STATUS
168  */
169 QDF_STATUS hdd_cm_save_gtk(struct wlan_objmgr_vdev *vdev,
170 			   struct wlan_cm_connect_resp *rsp);
171 
172 /**
173  * hdd_cm_set_hlp_data() - api to set hlp data for dhcp
174  * @dev: pointer to net device
175  * @vdev: Pointer to vdev
176  * @rsp: Pointer to connect rsp
177  *
178  * This function is used to set hlp data for dhcp in legacy mode
179  *
180  * Return: QDF_STATUS
181  */
182 QDF_STATUS hdd_cm_set_hlp_data(struct net_device *dev,
183 			       struct wlan_objmgr_vdev *vdev,
184 			       struct wlan_cm_connect_resp *rsp);
185 #endif
186 
187 #ifdef WLAN_FEATURE_PREAUTH_ENABLE
188 /**
189  * hdd_cm_ft_preauth_complete() - send fast transition event
190  * @vdev: Pointer to vdev
191  * @rsp: Pointer to preauth rsp
192  *
193  * This function is used to send fast transition event in legacy mode
194  *
195  * Return: QDF_STATUS
196  */
197 QDF_STATUS hdd_cm_ft_preauth_complete(struct wlan_objmgr_vdev *vdev,
198 				      struct wlan_preauth_rsp *rsp);
199 
200 #ifdef FEATURE_WLAN_ESE
201 /**
202  * hdd_cm_cckm_preauth_complete() - send cckm preauth indication to
203  * the supplicant via wireless custom event
204  * @vdev: Pointer to vdev
205  * @rsp: Pointer to preauth rsp
206  *
207  * This function is used to send cckm preauth indication to
208  * the supplicant via wireless custom event in legacy mode
209  *
210  * Return: QDF_STATUS
211  */
212 QDF_STATUS hdd_cm_cckm_preauth_complete(struct wlan_objmgr_vdev *vdev,
213 					struct wlan_preauth_rsp *rsp);
214 #endif
215 #endif
216 
217 #ifdef WLAN_FEATURE_MSCS
218 /**
219  * reset_mscs_params() - Reset mscs parameters
220  * @link_info: pointer to link_info struct in adapter
221  *
222  * Reset mscs parameters whils disconnection
223  *
224  * Return: None
225  */
226 void reset_mscs_params(struct wlan_hdd_link_info *link_info);
227 #else
228 static inline
229 void reset_mscs_params(struct wlan_hdd_link_info *link_info)
230 {
231 	return;
232 }
233 #endif
234 
235 /**
236  * hdd_handle_disassociation_event() - Handle disassociation event
237  * @link_info: Link info pointer in HDD adapter
238  * @peer_macaddr: Pointer to peer mac address
239  *
240  * Return: None
241  */
242 void hdd_handle_disassociation_event(struct wlan_hdd_link_info *link_info,
243 				     struct qdf_mac_addr *peer_macaddr);
244 
245 /**
246  * __hdd_cm_disconnect_handler_pre_user_update() - Handle disconnect indication
247  * before updating to user space
248  * @link_info: Link info pointer in HDD adapter
249  *
250  * Return: None
251  */
252 void
253 __hdd_cm_disconnect_handler_pre_user_update(struct wlan_hdd_link_info *link_info);
254 
255 /**
256  * __hdd_cm_disconnect_handler_post_user_update() - Handle disconnect indication
257  * after updating to user space
258  * @link_info: Link info pointer in HDD adapter
259  * @vdev: vdev ptr
260  *
261  * Return: None
262  */
263 void
264 __hdd_cm_disconnect_handler_post_user_update(struct wlan_hdd_link_info *link_info,
265 					     struct wlan_objmgr_vdev *vdev);
266 
267 /**
268  * hdd_cm_set_peer_authenticate() - set peer as authenticated
269  * @link_info: Link info pointer in HDD adapter
270  * @bssid: bssid of the connection
271  * @is_auth_required: is upper layer authenticatoin required
272  *
273  * Return: QDF_STATUS enumeration
274  */
275 void hdd_cm_set_peer_authenticate(struct wlan_hdd_link_info *link_info,
276 				  struct qdf_mac_addr *bssid,
277 				  bool is_auth_required);
278 
279 /**
280  * hdd_cm_update_rssi_snr_by_bssid() - update rsi and snr into adapter
281  * @link_info: Link info pointer in HDD adapter
282  *
283  * Return: None
284  */
285 void hdd_cm_update_rssi_snr_by_bssid(struct wlan_hdd_link_info *link_info);
286 
287 /**
288  *  hdd_cm_handle_assoc_event() - Send disassociation indication to oem
289  * app
290  * @vdev: Pointer to adapter
291  * @peer_mac: Pointer to peer mac address
292  *
293  * Return: None
294  */
295 void hdd_cm_handle_assoc_event(struct wlan_objmgr_vdev *vdev,
296 			       uint8_t *peer_mac);
297 
298 /**
299  * hdd_cm_netif_queue_enable() - Enable the network queue for a
300  *			      particular adapter.
301  * @adapter: pointer to the adapter structure
302  *
303  * This function schedules a work to update the netdev features
304  * and enable the network queue if the feature "disable checksum/tso
305  * for legacy connections" is enabled via INI. If not, it will
306  * retain the existing behavior by just enabling the network queues.
307  *
308  * Returns: none
309  */
310 void hdd_cm_netif_queue_enable(struct hdd_adapter *adapter);
311 
312 /**
313  * hdd_cm_clear_pmf_stats() - Clear pmf stats
314  * @adapter: pointer to the adapter structure
315  *
316  * Returns: None
317  */
318 void hdd_cm_clear_pmf_stats(struct hdd_adapter *adapter);
319 
320 /**
321  * hdd_cm_save_connect_status() - Save connect status
322  * @link_info: Link info pointer in HDD adapter
323  * @reason_code: IEE80211 wlan status code
324  *
325  * Returns: None
326  */
327 void hdd_cm_save_connect_status(struct wlan_hdd_link_info *link_info,
328 				uint32_t reason_code);
329 
330 /**
331  * hdd_cm_is_vdev_associated() - Checks if vdev is associated or not
332  * @link_info: pointer to the link info structure
333  *
334  * Returns: True if vdev is associated else false
335  */
336 bool hdd_cm_is_vdev_associated(struct wlan_hdd_link_info *link_info);
337 
338 /**
339  * hdd_cm_is_vdev_connected() - Checks if vdev is connected or not
340  * @link_info: pointer to the link_info structure
341  *
342  * Returns: True if vdev is connected else false
343  */
344 bool hdd_cm_is_vdev_connected(struct wlan_hdd_link_info *link_info);
345 
346 /**
347  * hdd_cm_is_connecting() - Function to check connection in progress
348  * @link_info: pointer to the link_info structure
349  *
350  * Return: true if connecting, false otherwise
351  */
352 bool hdd_cm_is_connecting(struct wlan_hdd_link_info *link_info);
353 
354 /**
355  * hdd_cm_is_disconnected() - Function to check if vdev is disconnected or not
356  * @link_info: pointer to the link_info structure
357  *
358  * Return: true if disconnected, false otherwise
359  */
360 bool hdd_cm_is_disconnected(struct wlan_hdd_link_info *link_info);
361 
362 /**
363  * hdd_cm_is_vdev_roaming() - Function to check roaming in progress
364  * @link_info: pointer to the link_info structure
365  *
366  * Return: true if roaming, false otherwise
367  */
368 bool hdd_cm_is_vdev_roaming(struct wlan_hdd_link_info *link_info);
369 
370 /**
371  * hdd_cm_get_scan_ie_params() - to get scan ie params
372  * @vdev: Pointer to vdev object
373  * @scan_ie: pointer to scan ie element struct
374  * @dot11mode_filter: Pointer to dot11mode_filter enum
375  *
376  * Return: QDF_STATUS
377  */
378 QDF_STATUS
379 hdd_cm_get_scan_ie_params(struct wlan_objmgr_vdev *vdev,
380 			  struct element_info *scan_ie,
381 			  enum dot11_mode_filter *dot11mode_filter);
382 
383 #ifdef WLAN_FEATURE_11BE_MLO
384 /**
385  * hdd_cm_save_connected_links_info() - Update connection info to station
386  * context.
387  * @self_mac: Self MAC address.
388  * @bssid: BSSID of link.
389  * @link_id: IEEE link id.
390  *
391  * It searches for link info pointer matching with @self_mac and updates
392  * the BSSID and link ID fields in station context's connection info.
393  * This will help to retrieve the link information using IEEE link ID or
394  * BSSID thereafter.
395  *
396  * Return: QDF_STATUS
397  */
398 QDF_STATUS hdd_cm_save_connected_links_info(struct qdf_mac_addr *self_mac,
399 					    struct qdf_mac_addr *bssid,
400 					    int32_t link_id);
401 
402 /**
403  * hdd_cm_set_ieee_link_id() - Set IEEE link ID in station context conn info.
404  * @link_info: Link info pointer in HDD adapter
405  * @link_id: IEEE link ID
406  *
407  * Sets IEEE link ID in connection info of @link_info's station context.
408  *
409  * Return: void
410  */
411 void
412 hdd_cm_set_ieee_link_id(struct wlan_hdd_link_info *link_info, uint8_t link_id);
413 
414 /**
415  * hdd_cm_clear_ieee_link_id() - Clear IEEE link ID in station context
416  * conn info.
417  * @link_info: Link info pointer in HDD adapter
418  *
419  * Clear IEEE link ID in connection info of @link_info's station context.
420  *
421  * Return: void
422  */
423 void hdd_cm_clear_ieee_link_id(struct wlan_hdd_link_info *link_info);
424 #else
425 static inline void
426 hdd_cm_set_ieee_link_id(struct wlan_hdd_link_info *link_info, uint8_t link_id)
427 {
428 }
429 
430 static inline void
431 hdd_cm_clear_ieee_link_id(struct wlan_hdd_link_info *link_info)
432 {
433 }
434 
435 static inline
436 QDF_STATUS hdd_cm_save_connected_links_info(struct qdf_mac_addr *self_mac,
437 					    struct qdf_mac_addr *bssid,
438 					    int32_t link_id)
439 {
440 	return QDF_STATUS_SUCCESS;
441 }
442 #endif /* WLAN_FEATURE_11BE_MLO */
443 #endif /* __WLAN_HDD_CM_API_H */
444