1 /* 2 * Copyright (c) 2012-2015, 2020-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: osif_cm_util.h 20 * 21 * This header file maintains declarations of connect, disconnect, roam 22 * common apis. 23 */ 24 25 #ifndef __OSIF_CM_UTIL_H 26 #define __OSIF_CM_UTIL_H 27 28 #include <qca_vendor.h> 29 #include "wlan_cm_ucfg_api.h" 30 #include "wlan_cm_public_struct.h" 31 #ifdef CONN_MGR_ADV_FEATURE 32 #include <cdp_txrx_mob_def.h> 33 #endif 34 35 /** 36 * osif_cm_mac_to_qca_connect_fail_reason() - Convert to qca internal connect 37 * fail reason 38 * @internal_reason: Mac reason code of type @wlan_status_code 39 * 40 * Check if it is internal status code and convert it to the 41 * enum qca_sta_connect_fail_reason_codes. 42 * 43 * Return: Reason code of type enum qca_sta_connect_fail_reason_codes 44 */ 45 enum qca_sta_connect_fail_reason_codes 46 osif_cm_mac_to_qca_connect_fail_reason(enum wlan_status_code internal_reason); 47 48 /** 49 * osif_cm_qca_reason_to_str() - return string conversion of qca reason code 50 * @reason: enum qca_disconnect_reason_codes 51 * 52 * This utility function helps log string conversion of qca reason code. 53 * 54 * Return: string conversion of reason code, if match found; 55 * "Unknown" otherwise. 56 */ 57 const char * 58 osif_cm_qca_reason_to_str(enum qca_disconnect_reason_codes reason); 59 60 /** 61 * osif_cm_mac_to_qca_reason() - Convert to qca internal disconnect reason 62 * @internal_reason: Mac reason code of type @wlan_reason_code 63 * 64 * Check if it is internal reason code and convert it to the 65 * enum qca_disconnect_reason_codes. 66 * 67 * Return: Reason code of type enum qca_disconnect_reason_codes 68 */ 69 enum qca_disconnect_reason_codes 70 osif_cm_mac_to_qca_reason(enum wlan_reason_code internal_reason); 71 72 /** 73 * osif_cm_register_cb() - API to register connection manager 74 * callbacks. 75 * 76 * Return: QDF_STATUS 77 */ 78 QDF_STATUS osif_cm_register_cb(void); 79 80 /** 81 * osif_cm_osif_priv_init() - API to init osif priv data for connection manager 82 * @vdev: vdev pointer 83 * 84 * Return: QDF_STATUS 85 */ 86 QDF_STATUS osif_cm_osif_priv_init(struct wlan_objmgr_vdev *vdev); 87 88 /** 89 * osif_cm_osif_priv_deinit() - API to deinit osif priv data for connection 90 * manager 91 * @vdev: vdev pointer 92 * 93 * Return: QDF_STATUS 94 */ 95 QDF_STATUS osif_cm_osif_priv_deinit(struct wlan_objmgr_vdev *vdev); 96 97 /** 98 * osif_cm_reset_id_and_src_no_lock() - Function to resets last 99 * connection manager command id and source in osif 100 * @osif_priv: Pointer to vdev osif priv 101 * 102 * This function resets the last connection manager command id 103 * and source. 104 * 105 * Context: Any context. This function should be called by holding 106 * cmd id spinlock 107 * Return: None 108 */ 109 110 void osif_cm_reset_id_and_src_no_lock(struct vdev_osif_priv *osif_priv); 111 112 /** 113 * osif_cm_reset_id_and_src() - Function to resets last 114 * connection manager command id and source in osif 115 * @vdev: vdev pointer 116 * 117 * This function resets the last connection manager command id 118 * and source. 119 * 120 * Context: Any context. Takes and release cmd id spinlock 121 * Return: None 122 */ 123 QDF_STATUS osif_cm_reset_id_and_src(struct wlan_objmgr_vdev *vdev); 124 125 /** 126 * enum osif_cb_type - Type of the update from osif to legacy module 127 * @OSIF_POST_USERSPACE_UPDATE: Indicates that when this update is received 128 * userspace is already updated. 129 * @OSIF_PRE_USERSPACE_UPDATE: Indicates that when this update is received 130 * userspace is not yet updated. 131 * @OSIF_NOT_HANDLED: Indicates that last command is not handled 132 */ 133 134 enum osif_cb_type { 135 OSIF_POST_USERSPACE_UPDATE, 136 OSIF_PRE_USERSPACE_UPDATE, 137 OSIF_NOT_HANDLED, 138 }; 139 140 /** 141 * typedef osif_cm_connect_comp_cb - Connect complete callback 142 * @vdev: vdev pointer 143 * @rsp: connect response 144 * @type: indicates update type 145 * 146 * This callback indicates connect complete to the legacy module 147 * 148 * Context: Any context. 149 * Return: QDF_STATUS 150 */ 151 typedef QDF_STATUS 152 (*osif_cm_connect_comp_cb)(struct wlan_objmgr_vdev *vdev, 153 struct wlan_cm_connect_resp *rsp, 154 enum osif_cb_type type); 155 156 #ifdef WLAN_VENDOR_HANDOFF_CONTROL 157 /** 158 * typedef osif_cm_get_vendor_handoff_params_cb - process vendor handoff cb 159 * @psoc: psoc pointer 160 * @rsp: vendor handoff response 161 * @vendor_handoff_context: vendor handoff context 162 * 163 * return: none 164 */ 165 typedef QDF_STATUS 166 (*osif_cm_get_vendor_handoff_params_cb)(struct wlan_objmgr_psoc *psoc, 167 void *vendor_handoff_context); 168 #endif 169 170 #ifdef WLAN_FEATURE_FILS_SK 171 /** 172 * typedef osif_cm_save_gtk_cb - save gtk callback 173 * @vdev: vdev pointer 174 * @rsp: connect response 175 * 176 * this callback save gtk to the legacy module 177 * 178 * context: any context. 179 * return: qdf_status 180 */ 181 typedef QDF_STATUS (*osif_cm_save_gtk_cb)(struct wlan_objmgr_vdev *vdev, 182 struct wlan_cm_connect_resp *rsp); 183 184 /** 185 * typedef osif_cm_set_hlp_data_cb - set hlp data for dhcp callback 186 * @dev: pointer to net device 187 * @vdev: vdev pointer 188 * @rsp: connect response 189 * 190 * this callback sets hlp data for dhcp to the legacy module 191 * 192 * context: any context. 193 * return: qdf_status 194 */ 195 typedef QDF_STATUS (*osif_cm_set_hlp_data_cb)(struct net_device *dev, 196 struct wlan_objmgr_vdev *vdev, 197 struct wlan_cm_connect_resp *rsp); 198 #endif 199 200 /** 201 * typedef osif_cm_disconnect_comp_cb: Disconnect complete callback 202 * @vdev: vdev pointer 203 * @rsp: disconnect response 204 * @type: indicates update type 205 * 206 * This callback indicates disconnect complete to the legacy module 207 * 208 * Context: Any context. 209 * Return: QDF_STATUS 210 */ 211 typedef QDF_STATUS 212 (*osif_cm_disconnect_comp_cb)(struct wlan_objmgr_vdev *vdev, 213 struct wlan_cm_discon_rsp *rsp, 214 enum osif_cb_type type); 215 216 #ifdef CONN_MGR_ADV_FEATURE 217 /** 218 * typedef osif_cm_get_scan_ie_params_cb - get scan ie params cb 219 * @vdev: vdev pointer 220 * @scan_ie: pointer to scan ie element struct 221 * @dot11mode_filter: Pointer to dot11mode_filter enum 222 * 223 * Return: QDF_STATUS 224 */ 225 typedef QDF_STATUS 226 (*osif_cm_get_scan_ie_params_cb)(struct wlan_objmgr_vdev *vdev, 227 struct element_info *scan_ie, 228 enum dot11_mode_filter *dot11mode_filter); 229 230 /** 231 * typedef osif_cm_netif_queue_ctrl_cb: Callback to update netif queue 232 * @vdev: vdev pointer 233 * @action: Action to take on netif queue 234 * @reason: netif reason type 235 * 236 * This callback indicates legacy modules to take the actions related to netif 237 * queue 238 * 239 * Context: Any context. 240 * Return: QDF_STATUS 241 */ 242 typedef QDF_STATUS 243 (*osif_cm_netif_queue_ctrl_cb)(struct wlan_objmgr_vdev *vdev, 244 enum netif_action_type action, 245 enum netif_reason_type reason); 246 247 /** 248 * typedef os_if_cm_napi_serialize_ctrl_cb: Callback to update 249 * NAPI serialization 250 * @action: bool action to take on napi serialization 251 * 252 * This callback indicates legacy modules to take the actions 253 * related to napi serialization 254 * 255 * Context: Any context. 256 * Return: QDF_STATUS 257 */ 258 typedef QDF_STATUS 259 (*os_if_cm_napi_serialize_ctrl_cb)(bool action); 260 261 /** 262 * typedef osif_cm_send_vdev_keys_cb - send vdev keys cb 263 * @vdev: vdev pointer 264 * @key_index: key index value 265 * @pairwise: pairwise boolean value 266 * @cipher_type: cipher type enum value 267 * 268 * return: none 269 */ 270 typedef QDF_STATUS 271 (*osif_cm_send_vdev_keys_cb)(struct wlan_objmgr_vdev *vdev, 272 uint8_t key_index, 273 bool pairwise, 274 enum wlan_crypto_cipher_type cipher_type); 275 276 /** 277 * osif_cm_unlink_bss() - function to unlink bss from kernel and scan database 278 * on connect timeouts reasons 279 * @vdev: vdev pointer 280 * @osif_priv: Pointer to vdev osif priv 281 * @bssid: bssid to flush 282 * @ssid: optional ssid to flush 283 * @ssid_len: optional ssid length 284 * 285 * This function flush the bss from scan db of kernel and driver matching the 286 * bssid. ssid is optional to pass to match the bss. 287 * 288 * Return: void 289 */ 290 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 291 struct vdev_osif_priv *osif_priv, 292 struct qdf_mac_addr *bssid, 293 uint8_t *ssid, uint8_t ssid_len); 294 #else 295 static inline 296 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 297 struct vdev_osif_priv *osif_priv, 298 struct qdf_mac_addr *bssid, 299 uint8_t *ssid, uint8_t ssid_len) {} 300 #endif 301 302 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 303 /** 304 * typedef osif_cm_ft_preauth_complete_cb: Callback to send fast 305 * transition event 306 * @vdev: vdev pointer 307 * @rsp: preauth response pointer 308 * 309 * This callback indicates legacy modules to send fast transition event 310 * 311 * Context: Any context. 312 * Return: QDF_STATUS 313 */ 314 typedef QDF_STATUS 315 (*osif_cm_ft_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 316 struct wlan_preauth_rsp *rsp); 317 #ifdef FEATURE_WLAN_ESE 318 /** 319 * typedef osif_cm_cckm_preauth_complete_cb: Callback to send cckm preauth 320 * indication to the supplicant via wireless custom event 321 * @vdev: vdev pointer 322 * @rsp: preauth response pointer 323 * 324 * This callback indicates legacy modules to send cckm preauth indication 325 * to the supplicant via wireless custom event 326 * 327 * Context: Any context. 328 * Return: QDF_STATUS 329 */ 330 typedef QDF_STATUS 331 (*osif_cm_cckm_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 332 struct wlan_preauth_rsp *rsp); 333 #endif 334 #endif 335 336 /** 337 * struct osif_cm_ops - connection manager legacy callbacks 338 * @connect_complete_cb: callback for connect complete to legacy 339 * modules 340 * @disconnect_complete_cb: callback for disconnect complete to 341 * legacy modules 342 * @netif_queue_control_cb: callback to legacy module to take 343 * actions on netif queue 344 * @napi_serialize_control_cb: callback to legacy module to take 345 * actions on napi serialization 346 * @save_gtk_cb : callback to legacy module to save gtk 347 * @send_vdev_keys_cb: callback to send vdev keys 348 * @get_scan_ie_params_cb: callback to get scan ie params 349 * @set_hlp_data_cb: callback to legacy module to save hlp data 350 * @ft_preauth_complete_cb: callback to legacy module to send fast 351 * transition event 352 * @cckm_preauth_complete_cb: callback to legacy module to send cckm 353 * preauth indication to the supplicant via wireless custom event. 354 * @vendor_handoff_params_cb: callback to legacy module to send vendor handoff 355 * parameters to upper layer 356 */ 357 struct osif_cm_ops { 358 osif_cm_connect_comp_cb connect_complete_cb; 359 osif_cm_disconnect_comp_cb disconnect_complete_cb; 360 #ifdef CONN_MGR_ADV_FEATURE 361 osif_cm_netif_queue_ctrl_cb netif_queue_control_cb; 362 os_if_cm_napi_serialize_ctrl_cb napi_serialize_control_cb; 363 osif_cm_save_gtk_cb save_gtk_cb; 364 osif_cm_send_vdev_keys_cb send_vdev_keys_cb; 365 osif_cm_get_scan_ie_params_cb get_scan_ie_params_cb; 366 #endif 367 #ifdef WLAN_FEATURE_FILS_SK 368 osif_cm_set_hlp_data_cb set_hlp_data_cb; 369 #endif 370 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 371 osif_cm_ft_preauth_complete_cb ft_preauth_complete_cb; 372 #ifdef FEATURE_WLAN_ESE 373 osif_cm_cckm_preauth_complete_cb cckm_preauth_complete_cb; 374 #endif 375 #endif 376 #ifdef WLAN_VENDOR_HANDOFF_CONTROL 377 osif_cm_get_vendor_handoff_params_cb vendor_handoff_params_cb; 378 #endif 379 }; 380 381 /** 382 * osif_cm_connect_comp_ind() - Function to indicate connect 383 * complete to legacy module 384 * @vdev: vdev pointer 385 * @rsp: connect response 386 * @type: indicates update type 387 * 388 * This function indicates connect complete to the legacy module 389 * 390 * Context: Any context. 391 * Return: QDF_STATUS 392 */ 393 QDF_STATUS osif_cm_connect_comp_ind(struct wlan_objmgr_vdev *vdev, 394 struct wlan_cm_connect_resp *rsp, 395 enum osif_cb_type type); 396 397 #ifdef WLAN_VENDOR_HANDOFF_CONTROL 398 /** 399 * osif_cm_vendor_handoff_params_cb() - Function to process vendor handoff 400 * event callback 401 * @psoc: psoc object pointer 402 * @vendor_handoff_context: vendor handoff context 403 * 404 * Return: QDF_STATUS 405 */ 406 QDF_STATUS osif_cm_vendor_handoff_params_cb(struct wlan_objmgr_psoc *psoc, 407 void *vendor_handoff_context); 408 #endif 409 410 /** 411 * osif_cm_disconnect_comp_ind() - Function to indicate disconnect 412 * complete to legacy module 413 * @vdev: vdev pointer 414 * @rsp: disconnect response 415 * @type: indicates update type 416 * 417 * This function indicates disconnect complete to the legacy module 418 * 419 * Context: Any context. 420 * Return: QDF_STATUS 421 */ 422 QDF_STATUS osif_cm_disconnect_comp_ind(struct wlan_objmgr_vdev *vdev, 423 struct wlan_cm_discon_rsp *rsp, 424 enum osif_cb_type type); 425 426 #ifdef CONN_MGR_ADV_FEATURE 427 /** 428 * osif_cm_netif_queue_ind() - Function to indicate netif queue update 429 * complete to legacy module 430 * @vdev: vdev pointer 431 * @action: Action to take on netif queue 432 * @reason: netif reason type 433 * 434 * This function indicates to take the actions related to netif queue 435 * 436 * Context: Any context. 437 * Return: QDF_STATUS 438 */ 439 QDF_STATUS osif_cm_netif_queue_ind(struct wlan_objmgr_vdev *vdev, 440 enum netif_action_type action, 441 enum netif_reason_type reason); 442 443 /** 444 * osif_cm_napi_serialize() - Function to indicate napi serialize 445 * action to legacy module 446 * @action: Action to take on napi serialization 447 * 448 * This function indicates to take the actions related to napi activities 449 * 450 * Context: Any context. 451 * Return: QDF_STATUS 452 */ 453 QDF_STATUS osif_cm_napi_serialize(bool action); 454 455 /** 456 * osif_cm_save_gtk() - Function to save gtk in legacy module 457 * @vdev: vdev pointer 458 * @rsp: Pointer to connect response 459 * 460 * This function saves gtk in legacy module 461 * 462 * Context: Any context. 463 * Return: QDF_STATUS 464 */ 465 QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 466 struct wlan_cm_connect_resp *rsp); 467 468 /** 469 * osif_cm_send_vdev_keys() - Function to send vdev keys 470 * @vdev: vdev pointer 471 * @key_index: key index value 472 * @pairwise: pairwise bool value 473 * @cipher_type: cipher type value 474 * 475 * This function to send vdev keys 476 * 477 * Context: Any context. 478 * Return: QDF_STATUS 479 */ 480 QDF_STATUS 481 osif_cm_send_vdev_keys(struct wlan_objmgr_vdev *vdev, 482 uint8_t key_index, 483 bool pairwise, 484 enum wlan_crypto_cipher_type cipher_type); 485 #else 486 static inline QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 487 struct wlan_cm_connect_resp *rsp) 488 { 489 return QDF_STATUS_SUCCESS; 490 } 491 #endif 492 493 #ifdef WLAN_FEATURE_FILS_SK 494 /** 495 * osif_cm_set_hlp_data() - Function to set hlp data for dhcp in legacy module 496 * @dev: Pointer to net device 497 * @vdev: vdev pointer 498 * @rsp: Pointer to connect response 499 * 500 * This function sets hlp data for dhcp in legacy module 501 * 502 * Context: Any context. 503 * Return: QDF_STATUS 504 */ 505 QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 506 struct wlan_objmgr_vdev *vdev, 507 struct wlan_cm_connect_resp *rsp); 508 #else 509 static inline QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 510 struct wlan_objmgr_vdev *vdev, 511 struct wlan_cm_connect_resp *rsp) 512 { 513 return QDF_STATUS_SUCCESS; 514 } 515 #endif 516 517 /** 518 * osif_cm_set_legacy_cb() - Sets legacy callbacks to osif 519 * @osif_legacy_ops: Function pointer to legacy ops structure 520 * 521 * API to set legacy callbacks to osif 522 * Context: Any context. 523 * 524 * Return: void 525 */ 526 void osif_cm_set_legacy_cb(struct osif_cm_ops *osif_legacy_ops); 527 528 /** 529 * osif_cm_reset_legacy_cb() - Resets legacy callbacks to osif 530 * 531 * API to reset legacy callbacks to osif 532 * Context: Any context. 533 * 534 * Return: void 535 */ 536 void osif_cm_reset_legacy_cb(void); 537 #endif /* __OSIF_CM_UTIL_H */ 538