1 /* 2 * Copyright (c) 2012-2015, 2020-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022 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_netif_queue_ctrl_cb: Callback to update netif queue 219 * @vdev: vdev pointer 220 * @action: Action to take on netif queue 221 * @reason: netif reason type 222 * 223 * This callback indicates legacy modules to take the actions related to netif 224 * queue 225 * 226 * Context: Any context. 227 * Return: QDF_STATUS 228 */ 229 typedef QDF_STATUS 230 (*osif_cm_netif_queue_ctrl_cb)(struct wlan_objmgr_vdev *vdev, 231 enum netif_action_type action, 232 enum netif_reason_type reason); 233 234 /** 235 * typedef os_if_cm_napi_serialize_ctrl_cb: Callback to update 236 * NAPI serialization 237 * @action: bool action to take on napi serialization 238 * 239 * This callback indicates legacy modules to take the actions 240 * related to napi serialization 241 * 242 * Context: Any context. 243 * Return: QDF_STATUS 244 */ 245 typedef QDF_STATUS 246 (*os_if_cm_napi_serialize_ctrl_cb)(bool action); 247 248 /** 249 * typedef osif_cm_send_vdev_keys_cb - send vdev keys cb 250 * @vdev: vdev pointer 251 * @key_index: key index value 252 * @pairwise: pairwise boolean value 253 * @cipher_type: cipher type enum value 254 * 255 * return: none 256 */ 257 typedef QDF_STATUS 258 (*osif_cm_send_vdev_keys_cb)(struct wlan_objmgr_vdev *vdev, 259 uint8_t key_index, 260 bool pairwise, 261 enum wlan_crypto_cipher_type cipher_type); 262 263 /** 264 * osif_cm_unlink_bss() - function to unlink bss from kernel and scan database 265 * on connect timeouts reasons 266 * @vdev: vdev pointer 267 * @osif_priv: Pointer to vdev osif priv 268 * @bssid: bssid to flush 269 * @ssid: optional ssid to flush 270 * @ssid_len: optional ssid length 271 * 272 * This function flush the bss from scan db of kernel and driver matching the 273 * bssid. ssid is optional to pass to match the bss. 274 * 275 * Return: void 276 */ 277 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 278 struct vdev_osif_priv *osif_priv, 279 struct qdf_mac_addr *bssid, 280 uint8_t *ssid, uint8_t ssid_len); 281 #else 282 static inline 283 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 284 struct vdev_osif_priv *osif_priv, 285 struct qdf_mac_addr *bssid, 286 uint8_t *ssid, uint8_t ssid_len) {} 287 #endif 288 289 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 290 /** 291 * typedef osif_cm_ft_preauth_complete_cb: Callback to send fast 292 * transition event 293 * @vdev: vdev pointer 294 * @rsp: preauth response pointer 295 * 296 * This callback indicates legacy modules to send fast transition event 297 * 298 * Context: Any context. 299 * Return: QDF_STATUS 300 */ 301 typedef QDF_STATUS 302 (*osif_cm_ft_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 303 struct wlan_preauth_rsp *rsp); 304 #ifdef FEATURE_WLAN_ESE 305 /** 306 * typedef osif_cm_cckm_preauth_complete_cb: Callback to send cckm preauth 307 * indication to the supplicant via wireless custom event 308 * @vdev: vdev pointer 309 * @rsp: preauth response pointer 310 * 311 * This callback indicates legacy modules to send cckm preauth indication 312 * to the supplicant via wireless custom event 313 * 314 * Context: Any context. 315 * Return: QDF_STATUS 316 */ 317 typedef QDF_STATUS 318 (*osif_cm_cckm_preauth_complete_cb)(struct wlan_objmgr_vdev *vdev, 319 struct wlan_preauth_rsp *rsp); 320 #endif 321 #endif 322 323 /** 324 * osif_cm_ops: connection manager legacy callbacks 325 * @osif_cm_connect_comp_cb: callback for connect complete to legacy 326 * modules 327 * @osif_cm_disconnect_comp_cb: callback for disconnect complete to 328 * legacy modules 329 * @osif_cm_netif_queue_ctrl_cb: callback to legacy module to take 330 * actions on netif queue 331 * @os_if_cm_napi_serialize_ctrl_cb: callback to legacy module to take 332 * actions on napi serialization 333 * @save_gtk_cb : callback to legacy module to save gtk 334 * @send_vdev_keys_cb: callback to send vdev keys 335 * @set_hlp_data_cb: callback to legacy module to save hlp data 336 * @ft_preauth_complete_cb: callback to legacy module to send fast 337 * transition event 338 * @cckm_preauth_complete_cb: callback to legacy module to send cckm 339 * preauth indication to the supplicant via wireless custom event. 340 * @vendor_handoff_params_cb: callback to legacy module to send vendor handoff 341 * parameters to upper layer 342 */ 343 struct osif_cm_ops { 344 osif_cm_connect_comp_cb connect_complete_cb; 345 osif_cm_disconnect_comp_cb disconnect_complete_cb; 346 #ifdef CONN_MGR_ADV_FEATURE 347 osif_cm_netif_queue_ctrl_cb netif_queue_control_cb; 348 os_if_cm_napi_serialize_ctrl_cb napi_serialize_control_cb; 349 osif_cm_save_gtk_cb save_gtk_cb; 350 osif_cm_send_vdev_keys_cb send_vdev_keys_cb; 351 #endif 352 #ifdef WLAN_FEATURE_FILS_SK 353 osif_cm_set_hlp_data_cb set_hlp_data_cb; 354 #endif 355 #ifdef WLAN_FEATURE_PREAUTH_ENABLE 356 osif_cm_ft_preauth_complete_cb ft_preauth_complete_cb; 357 #ifdef FEATURE_WLAN_ESE 358 osif_cm_cckm_preauth_complete_cb cckm_preauth_complete_cb; 359 #endif 360 #endif 361 #ifdef WLAN_VENDOR_HANDOFF_CONTROL 362 osif_cm_get_vendor_handoff_params_cb vendor_handoff_params_cb; 363 #endif 364 }; 365 366 /** 367 * osif_cm_connect_comp_ind() - Function to indicate connect 368 * complete to legacy module 369 * @vdev: vdev pointer 370 * @rsp: connect response 371 * @type: indicates update type 372 * 373 * This function indicates connect complete to the legacy module 374 * 375 * Context: Any context. 376 * Return: QDF_STATUS 377 */ 378 QDF_STATUS osif_cm_connect_comp_ind(struct wlan_objmgr_vdev *vdev, 379 struct wlan_cm_connect_resp *rsp, 380 enum osif_cb_type type); 381 382 #ifdef WLAN_VENDOR_HANDOFF_CONTROL 383 /** 384 * osif_cm_vendor_handoff_params_cb() - Function to process vendor handoff 385 * event callback 386 * @psoc: psoc object pointer 387 * @vendor_handoff_context: vendor handoff context 388 * 389 * Return: QDF_STATUS 390 */ 391 QDF_STATUS osif_cm_vendor_handoff_params_cb(struct wlan_objmgr_psoc *psoc, 392 void *vendor_handoff_context); 393 #endif 394 395 /** 396 * osif_cm_disconnect_comp_ind() - Function to indicate disconnect 397 * complete to legacy module 398 * @vdev: vdev pointer 399 * @rsp: disconnect response 400 * @type: indicates update type 401 * 402 * This function indicates disconnect complete to the legacy module 403 * 404 * Context: Any context. 405 * Return: QDF_STATUS 406 */ 407 QDF_STATUS osif_cm_disconnect_comp_ind(struct wlan_objmgr_vdev *vdev, 408 struct wlan_cm_discon_rsp *rsp, 409 enum osif_cb_type type); 410 411 #ifdef CONN_MGR_ADV_FEATURE 412 /** 413 * osif_cm_netif_queue_ind() - Function to indicate netif queue update 414 * complete to legacy module 415 * @vdev: vdev pointer 416 * @action: Action to take on netif queue 417 * @reason: netif reason type 418 * 419 * This function indicates to take the actions related to netif queue 420 * 421 * Context: Any context. 422 * Return: QDF_STATUS 423 */ 424 QDF_STATUS osif_cm_netif_queue_ind(struct wlan_objmgr_vdev *vdev, 425 enum netif_action_type action, 426 enum netif_reason_type reason); 427 428 /** 429 * osif_cm_napi_serialize() - Function to indicate napi serialize 430 * action to legacy module 431 * @action: Action to take on napi serialization 432 * 433 * This function indicates to take the actions related to napi activities 434 * 435 * Context: Any context. 436 * Return: QDF_STATUS 437 */ 438 QDF_STATUS osif_cm_napi_serialize(bool action); 439 440 /** 441 * osif_cm_save_gtk() - Function to save gtk in legacy module 442 * @vdev: vdev pointer 443 * @rsp: Pointer to connect response 444 * 445 * This function saves gtk in legacy module 446 * 447 * Context: Any context. 448 * Return: QDF_STATUS 449 */ 450 QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 451 struct wlan_cm_connect_resp *rsp); 452 453 /** 454 * osif_cm_send_vdev_keys() - Function to send vdev keys 455 * @vdev: vdev pointer 456 * @key_index: key index value 457 * @pairwise: pairwise bool value 458 * @cipher_type: cipher type value 459 * 460 * This function to send vdev keys 461 * 462 * Context: Any context. 463 * Return: QDF_STATUS 464 */ 465 QDF_STATUS 466 osif_cm_send_vdev_keys(struct wlan_objmgr_vdev *vdev, 467 uint8_t key_index, 468 bool pairwise, 469 enum wlan_crypto_cipher_type cipher_type); 470 #else 471 static inline QDF_STATUS osif_cm_save_gtk(struct wlan_objmgr_vdev *vdev, 472 struct wlan_cm_connect_resp *rsp) 473 { 474 return QDF_STATUS_SUCCESS; 475 } 476 #endif 477 478 #ifdef WLAN_FEATURE_FILS_SK 479 /** 480 * osif_cm_set_hlp_data() - Function to set hlp data for dhcp in legacy module 481 * @dev: Pointer to net device 482 * @vdev: vdev pointer 483 * @rsp: Pointer to connect response 484 * 485 * This function sets hlp data for dhcp in legacy module 486 * 487 * Context: Any context. 488 * Return: QDF_STATUS 489 */ 490 QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 491 struct wlan_objmgr_vdev *vdev, 492 struct wlan_cm_connect_resp *rsp); 493 #else 494 static inline QDF_STATUS osif_cm_set_hlp_data(struct net_device *dev, 495 struct wlan_objmgr_vdev *vdev, 496 struct wlan_cm_connect_resp *rsp) 497 { 498 return QDF_STATUS_SUCCESS; 499 } 500 #endif 501 502 /** 503 * osif_cm_set_legacy_cb() - Sets legacy callbacks to osif 504 * @osif_legacy_ops: Function pointer to legacy ops structure 505 * 506 * API to set legacy callbacks to osif 507 * Context: Any context. 508 * 509 * Return: void 510 */ 511 void osif_cm_set_legacy_cb(struct osif_cm_ops *osif_legacy_ops); 512 513 /** 514 * osif_cm_reset_legacy_cb() - Resets legacy callbacks to osif 515 * 516 * API to reset legacy callbacks to osif 517 * Context: Any context. 518 * 519 * Return: void 520 */ 521 void osif_cm_reset_legacy_cb(void); 522 523 #endif /* __OSIF_CM_UTIL_H */ 524