1 /* 2 * Copyright (c) 2012-2015, 2020-2021 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 /** 18 * DOC: osif_cm_util.h 19 * 20 * This header file maintains declarations of connect, disconnect, roam 21 * common apis. 22 */ 23 24 #ifndef __OSIF_CM_UTIL_H 25 #define __OSIF_CM_UTIL_H 26 27 #include <qca_vendor.h> 28 #include "wlan_cm_ucfg_api.h" 29 #include "wlan_cm_public_struct.h" 30 #ifdef CONN_MGR_ADV_FEATURE 31 #include <cdp_txrx_mob_def.h> 32 #endif 33 34 /** 35 * osif_cm_mac_to_qca_connect_fail_reason() - Convert to qca internal connect 36 * fail reason 37 * @internal_reason: Mac reason code of type @wlan_status_code 38 * 39 * Check if it is internal status code and convert it to the 40 * enum qca_sta_connect_fail_reason_codes. 41 * 42 * Return: Reason code of type enum qca_sta_connect_fail_reason_codes 43 */ 44 enum qca_sta_connect_fail_reason_codes 45 osif_cm_mac_to_qca_connect_fail_reason(enum wlan_status_code internal_reason); 46 47 /** 48 * osif_cm_qca_reason_to_str() - return string conversion of qca reason code 49 * @reason: enum qca_disconnect_reason_codes 50 * 51 * This utility function helps log string conversion of qca reason code. 52 * 53 * Return: string conversion of reason code, if match found; 54 * "Unknown" otherwise. 55 */ 56 const char * 57 osif_cm_qca_reason_to_str(enum qca_disconnect_reason_codes reason); 58 59 /** 60 * osif_cm_mac_to_qca_reason() - Convert to qca internal disconnect reason 61 * @internal_reason: Mac reason code of type @wlan_reason_code 62 * 63 * Check if it is internal reason code and convert it to the 64 * enum qca_disconnect_reason_codes. 65 * 66 * Return: Reason code of type enum qca_disconnect_reason_codes 67 */ 68 enum qca_disconnect_reason_codes 69 osif_cm_mac_to_qca_reason(enum wlan_reason_code internal_reason); 70 71 /** 72 * osif_cm_register_cb() - API to register connection manager 73 * callbacks. 74 * 75 * Return: QDF_STATUS 76 */ 77 QDF_STATUS osif_cm_register_cb(void); 78 79 /** 80 * osif_cm_osif_priv_init() - API to init osif priv data for connection manager 81 * @vdev: vdev pointer 82 * 83 * Return: QDF_STATUS 84 */ 85 QDF_STATUS osif_cm_osif_priv_init(struct wlan_objmgr_vdev *vdev); 86 87 /** 88 * osif_cm_osif_priv_deinit() - API to deinit osif priv data for connection 89 * manager 90 * @vdev: vdev pointer 91 * 92 * Return: QDF_STATUS 93 */ 94 QDF_STATUS osif_cm_osif_priv_deinit(struct wlan_objmgr_vdev *vdev); 95 96 /** 97 * osif_cm_reset_id_and_src_no_lock() - Function to resets last 98 * connection manager command id and source in osif 99 * @osif_priv: Pointer to vdev osif priv 100 * 101 * This function resets the last connection manager command id 102 * and source. 103 * 104 * Context: Any context. This function should be called by holding 105 * cmd id spinlock 106 * Return: None 107 */ 108 109 void osif_cm_reset_id_and_src_no_lock(struct vdev_osif_priv *osif_priv); 110 111 /** 112 * osif_cm_reset_id_and_src() - Function to resets last 113 * connection manager command id and source in osif 114 * @vdev: vdev pointer 115 * 116 * This function resets the last connection manager command id 117 * and source. 118 * 119 * Context: Any context. Takes and release cmd id spinlock 120 * Return: None 121 */ 122 QDF_STATUS osif_cm_reset_id_and_src(struct wlan_objmgr_vdev *vdev); 123 124 /** 125 * enum osif_cb_type - Type of the update from osif to legacy module 126 * @OSIF_POST_USERSPACE_UPDATE: Indicates that when this update is received 127 * userspace is already updated. 128 * @OSIF_PRE_USERSPACE_UPDATE: Indicates that when this update is received 129 * userspace is not yet updated. 130 * @OSIF_NOT_HANDLED: Indicates that last command is not handled 131 */ 132 133 enum osif_cb_type { 134 OSIF_POST_USERSPACE_UPDATE, 135 OSIF_PRE_USERSPACE_UPDATE, 136 OSIF_NOT_HANDLED, 137 }; 138 139 /** 140 * typedef osif_cm_connect_comp_cb - Connect complete callback 141 * @vdev: vdev pointer 142 * @rsp: connect response 143 * @type: indicates update type 144 * 145 * This callback indicates connect complete to the legacy module 146 * 147 * Context: Any context. 148 * Return: QDF_STATUS 149 */ 150 typedef QDF_STATUS 151 (*osif_cm_connect_comp_cb)(struct wlan_objmgr_vdev *vdev, 152 struct wlan_cm_connect_resp *rsp, 153 enum osif_cb_type type); 154 155 #ifdef WLAN_FEATURE_FILS_SK 156 /** 157 * typedef osif_cm_save_gtk_cb - save gtk callback 158 * @vdev: vdev pointer 159 * @rsp: connect response 160 * 161 * this callback save gtk to the legacy module 162 * 163 * context: any context. 164 * return: qdf_status 165 */ 166 typedef QDF_STATUS (*osif_cm_save_gtk_cb)(struct wlan_objmgr_vdev *vdev, 167 struct wlan_cm_connect_resp *rsp); 168 169 /** 170 * typedef osif_cm_set_hlp_data_cb - set hlp data for dhcp callback 171 * @dev: pointer to net device 172 * @vdev: vdev pointer 173 * @rsp: connect response 174 * 175 * this callback sets hlp data for dhcp to the legacy module 176 * 177 * context: any context. 178 * return: qdf_status 179 */ 180 typedef QDF_STATUS (*osif_cm_set_hlp_data_cb)(struct net_device *dev, 181 struct wlan_objmgr_vdev *vdev, 182 struct wlan_cm_connect_resp *rsp); 183 #endif 184 185 /** 186 * typedef osif_cm_disconnect_comp_cb: Disonnect complete callback 187 * @vdev: vdev pointer 188 * @rsp: disconnect response 189 * @type: indicates update type 190 * 191 * This callback indicates disconnect complete to the legacy module 192 * 193 * Context: Any context. 194 * Return: QDF_STATUS 195 */ 196 typedef QDF_STATUS 197 (*osif_cm_disconnect_comp_cb)(struct wlan_objmgr_vdev *vdev, 198 struct wlan_cm_discon_rsp *rsp, 199 enum osif_cb_type type); 200 201 #ifdef CONN_MGR_ADV_FEATURE 202 /** 203 * typedef osif_cm_netif_queue_ctrl_cb: Callback to update netif queue 204 * @vdev: vdev pointer 205 * @action: Action to take on netif queue 206 * @reason: netif reason type 207 * 208 * This callback indicates legacy modules to take the actions related to netif 209 * queue 210 * 211 * Context: Any context. 212 * Return: QDF_STATUS 213 */ 214 typedef QDF_STATUS 215 (*osif_cm_netif_queue_ctrl_cb)(struct wlan_objmgr_vdev *vdev, 216 enum netif_action_type action, 217 enum netif_reason_type reason); 218 219 /** 220 * typedef os_if_cm_napi_serialize_ctrl_cb: Callback to update 221 * NAPI serialization 222 * @action: bool action to take on napi serialization 223 * 224 * This callback indicates legacy modules to take the actions 225 * related to napi serialization 226 * 227 * Context: Any context. 228 * Return: QDF_STATUS 229 */ 230 typedef QDF_STATUS 231 (*os_if_cm_napi_serialize_ctrl_cb)(bool action); 232 233 /** 234 * osif_cm_unlink_bss() - function to unlink bss from kernel and scan database 235 * on connect timeouts reasons 236 * @vdev: vdev pointer 237 * @osif_priv: Pointer to vdev osif priv 238 * @bssid: bssid to flush 239 * @ssid: optional ssid to flush 240 * @ssid_len: optional ssid length 241 * 242 * This function flush the bss from scan db of kernel and driver matching the 243 * bssid. ssid is optional to pass to match the bss. 244 * 245 * Return: void 246 */ 247 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 248 struct vdev_osif_priv *osif_priv, 249 struct qdf_mac_addr *bssid, 250 uint8_t *ssid, uint8_t ssid_len); 251 #else 252 static inline 253 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 254 struct vdev_osif_priv *osif_priv, 255 struct qdf_mac_addr *bssid, 256 uint8_t *ssid, uint8_t ssid_len) {} 257 #endif 258 259 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 260 /** 261 * typedef osif_cm_ft_preauth_complete_cb: Callback to send fast 262 * transition event 263 * @vdev: vdev pointer 264 * @rsp: preauth response pointer 265 * 266 * This callback indicates legacy modules to send fast transition event 267 * 268 * Context: Any context. 269 * Return: QDF_STATUS 270 */ 271 typedef QDF_STATUS 272 (*osif_cm_ft_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 273 struct wlan_preauth_rsp *rsp); 274 #ifdef FEATURE_WLAN_ESE 275 /** 276 * typedef osif_cm_cckm_preauth_complete_cb: Callback to send cckm preauth 277 * indication to the supplicant via wireless custom event 278 * @vdev: vdev pointer 279 * @rsp: preauth response pointer 280 * 281 * This callback indicates legacy modules to send cckm preauth indication 282 * to the supplicant via wireless custom event 283 * 284 * Context: Any context. 285 * Return: QDF_STATUS 286 */ 287 typedef QDF_STATUS 288 (*osif_cm_cckm_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 289 struct wlan_preauth_rsp *rsp); 290 #endif 291 #endif 292 293 /** 294 * osif_cm_ops: connection manager legacy callbacks 295 * @osif_cm_connect_comp_cb: callback for connect complete to legacy 296 * modules 297 * @osif_cm_disconnect_comp_cb: callback for disconnect complete to 298 * legacy modules 299 * @osif_cm_netif_queue_ctrl_cb: callback to legacy module to take 300 * actions on netif queue 301 * @os_if_cm_napi_serialize_ctrl_cb: callback to legacy module to take 302 * actions on napi serialization 303 * @save_gtk_cb : callback to legacy module to save gtk 304 * @set_hlp_data_cb: callback to legacy module to save hlp data 305 * @ft_preauth_complete_cb: callback to legacy module to send fast 306 * transition event 307 * @cckm_preauth_complete_cb: callback to legacy module to send cckm 308 * preauth indication to the supplicant via wireless custom event. 309 */ 310 struct osif_cm_ops { 311 osif_cm_connect_comp_cb connect_complete_cb; 312 osif_cm_disconnect_comp_cb disconnect_complete_cb; 313 #ifdef CONN_MGR_ADV_FEATURE 314 osif_cm_netif_queue_ctrl_cb netif_queue_control_cb; 315 os_if_cm_napi_serialize_ctrl_cb napi_serialize_control_cb; 316 osif_cm_save_gtk_cb save_gtk_cb; 317 #endif 318 #ifdef WLAN_FEATURE_FILS_SK 319 osif_cm_set_hlp_data_cb set_hlp_data_cb; 320 #endif 321 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 322 osif_cm_ft_preauth_complete_cb ft_preauth_complete_cb; 323 #ifdef FEATURE_WLAN_ESE 324 osif_cm_cckm_preauth_complete_cb cckm_preauth_complete_cb; 325 #endif 326 #endif 327 }; 328 329 /** 330 * osif_cm_connect_comp_ind() - Function to indicate connect 331 * complete to legacy module 332 * @vdev: vdev pointer 333 * @rsp: connect response 334 * @type: indicates update type 335 * 336 * This function indicates connect complete to the legacy module 337 * 338 * Context: Any context. 339 * Return: QDF_STATUS 340 */ 341 QDF_STATUS osif_cm_connect_comp_ind(struct wlan_objmgr_vdev *vdev, 342 struct wlan_cm_connect_resp *rsp, 343 enum osif_cb_type type); 344 345 /** 346 * osif_cm_disconnect_comp_ind() - Function to indicate disconnect 347 * complete to legacy module 348 * @vdev: vdev pointer 349 * @rsp: disconnect response 350 * @type: indicates update type 351 * 352 * This function indicates disconnect complete to the legacy module 353 * 354 * Context: Any context. 355 * Return: QDF_STATUS 356 */ 357 QDF_STATUS osif_cm_disconnect_comp_ind(struct wlan_objmgr_vdev *vdev, 358 struct wlan_cm_discon_rsp *rsp, 359 enum osif_cb_type type); 360 361 #ifdef CONN_MGR_ADV_FEATURE 362 /** 363 * osif_cm_netif_queue_ind() - Function to indicate netif queue update 364 * complete to legacy module 365 * @vdev: vdev pointer 366 * @action: Action to take on netif queue 367 * @reason: netif reason type 368 * 369 * This function indicates to take the actions related to netif queue 370 * 371 * Context: Any context. 372 * Return: QDF_STATUS 373 */ 374 QDF_STATUS osif_cm_netif_queue_ind(struct wlan_objmgr_vdev *vdev, 375 enum netif_action_type action, 376 enum netif_reason_type reason); 377 378 /** 379 * osif_cm_napi_serialize() - Function to indicate napi serialize 380 * action to legacy module 381 * @action: Action to take on napi serialization 382 * 383 * This function indicates to take the actions related to napi activities 384 * 385 * Context: Any context. 386 * Return: QDF_STATUS 387 */ 388 QDF_STATUS osif_cm_napi_serialize(bool action); 389 390 /** 391 * osif_cm_save_gtk() - Function to save gtk in legacy module 392 * @vdev: vdev pointer 393 * @rsp: Pointer to connect response 394 * 395 * This function saves gtk in legacy module 396 * 397 * Context: Any context. 398 * Return: QDF_STATUS 399 */ 400 QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 401 struct wlan_cm_connect_resp *rsp); 402 #endif 403 404 #ifdef WLAN_FEATURE_FILS_SK 405 /** 406 * osif_cm_set_hlp_data() - Function to set hlp data for dhcp in legacy module 407 * @dev: Pointer to net device 408 * @vdev: vdev pointer 409 * @rsp: Pointer to connect response 410 * 411 * This function sets hlp data for dhcp in legacy module 412 * 413 * Context: Any context. 414 * Return: QDF_STATUS 415 */ 416 QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 417 struct wlan_objmgr_vdev *vdev, 418 struct wlan_cm_connect_resp *rsp); 419 #endif 420 421 /** 422 * osif_cm_set_legacy_cb() - Sets legacy callbacks to osif 423 * @osif_legacy_ops: Function pointer to legacy ops structure 424 * 425 * API to set legacy callbacks to osif 426 * Context: Any context. 427 * 428 * Return: void 429 */ 430 void osif_cm_set_legacy_cb(struct osif_cm_ops *osif_legacy_ops); 431 432 /** 433 * osif_cm_reset_legacy_cb() - Resets legacy callbacks to osif 434 * 435 * API to reset legacy callbacks to osif 436 * Context: Any context. 437 * 438 * Return: void 439 */ 440 void osif_cm_reset_legacy_cb(void); 441 442 #endif /* __OSIF_CM_UTIL_H */ 443