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