1 /* 2 * Copyright (c) 2012-2015, 2020 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 #ifdef FEATURE_CM_ENABLE 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 /** 157 * typedef osif_cm_disconnect_comp_cb: Disonnect complete callback 158 * @vdev: vdev pointer 159 * @rsp: disconnect response 160 * @type: indicates update type 161 * 162 * This callback indicates disconnect complete to the legacy module 163 * 164 * Context: Any context. 165 * Return: QDF_STATUS 166 */ 167 typedef QDF_STATUS 168 (*osif_cm_disconnect_comp_cb)(struct wlan_objmgr_vdev *vdev, 169 struct wlan_cm_discon_rsp *rsp, 170 enum osif_cb_type type); 171 172 #ifdef CONN_MGR_ADV_FEATURE 173 /** 174 * typedef osif_cm_netif_queue_ctrl_cb: Callback to update netif queue 175 * @vdev: vdev pointer 176 * @action: Action to take on netif queue 177 * @reason: netif reason type 178 * 179 * This callback indicates legacy modules to take the actions related to netif 180 * queue 181 * 182 * Context: Any context. 183 * Return: QDF_STATUS 184 */ 185 typedef QDF_STATUS 186 (*osif_cm_netif_queue_ctrl_cb)(struct wlan_objmgr_vdev *vdev, 187 enum netif_action_type action, 188 enum netif_reason_type reason); 189 190 /** 191 * osif_cm_unlink_bss() - function to unlink bss from kernel and scan database 192 * on connect timeouts reasons 193 * @vdev: vdev pointer 194 * @osif_priv: Pointer to vdev osif priv 195 * @bssid: bssid to flush 196 * @ssid: optional ssid to flush 197 * @ssid_len: optional ssid length 198 * 199 * This function flush the bss from scan db of kernel and driver matching the 200 * bssid. ssid is optional to pass to match the bss. 201 * 202 * Return: void 203 */ 204 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 205 struct vdev_osif_priv *osif_priv, 206 struct qdf_mac_addr *bssid, 207 uint8_t *ssid, uint8_t ssid_len); 208 #else 209 static inline 210 void osif_cm_unlink_bss(struct wlan_objmgr_vdev *vdev, 211 struct vdev_osif_priv *osif_priv, 212 struct qdf_mac_addr *bssid, 213 uint8_t *ssid, uint8_t ssid_len) {} 214 #endif 215 216 /** 217 * osif_cm_ops: connection manager legacy callbacks 218 * osif_cm_connect_comp_cb: callback for connect complete to legacy 219 * modules 220 * osif_cm_disconnect_comp_cb: callback for disconnect complete to 221 * legacy modules 222 * osif_cm_netif_queue_ctrl_cb: callback to legacy module to take 223 * actions on netif queue 224 */ 225 struct osif_cm_ops { 226 osif_cm_connect_comp_cb connect_complete_cb; 227 osif_cm_disconnect_comp_cb disconnect_complete_cb; 228 #ifdef CONN_MGR_ADV_FEATURE 229 osif_cm_netif_queue_ctrl_cb netif_queue_control_cb; 230 #endif 231 }; 232 233 /** 234 * osif_cm_connect_comp_ind() - Function to indicate connect 235 * complete to legacy module 236 * @vdev: vdev pointer 237 * @rsp: connect response 238 * @type: indicates update type 239 * 240 * This function indicates connect complete to the legacy module 241 * 242 * Context: Any context. 243 * Return: QDF_STATUS 244 */ 245 QDF_STATUS osif_cm_connect_comp_ind(struct wlan_objmgr_vdev *vdev, 246 struct wlan_cm_connect_resp *rsp, 247 enum osif_cb_type type); 248 249 /** 250 * osif_cm_disconnect_comp_ind() - Function to indicate disconnect 251 * complete to legacy module 252 * @vdev: vdev pointer 253 * @rsp: disconnect response 254 * @type: indicates update type 255 * 256 * This function indicates disconnect complete to the legacy module 257 * 258 * Context: Any context. 259 * Return: QDF_STATUS 260 */ 261 QDF_STATUS osif_cm_disconnect_comp_ind(struct wlan_objmgr_vdev *vdev, 262 struct wlan_cm_discon_rsp *rsp, 263 enum osif_cb_type type); 264 265 #ifdef CONN_MGR_ADV_FEATURE 266 /** 267 * osif_cm_netif_queue_ind() - Function to indicate netif queue update 268 * complete to legacy module 269 * @vdev: vdev pointer 270 * @action: Action to take on netif queue 271 * @reason: netif reason type 272 * 273 * This function indicates to take the actions related to netif queue 274 * 275 * Context: Any context. 276 * Return: QDF_STATUS 277 */ 278 QDF_STATUS osif_cm_netif_queue_ind(struct wlan_objmgr_vdev *vdev, 279 enum netif_action_type action, 280 enum netif_reason_type reason); 281 #endif 282 /** 283 * osif_cm_set_legacy_cb() - Sets legacy callbacks to osif 284 * @osif_legacy_ops: Function pointer to legacy ops structure 285 * 286 * API to set legacy callbacks to osif 287 * Context: Any context. 288 * 289 * Return: void 290 */ 291 void osif_cm_set_legacy_cb(struct osif_cm_ops *osif_legacy_ops); 292 293 /** 294 * osif_cm_reset_legacy_cb() - Resets legacy callbacks to osif 295 * 296 * API to reset legacy callbacks to osif 297 * Context: Any context. 298 * 299 * Return: void 300 */ 301 void osif_cm_reset_legacy_cb(void); 302 303 #else 304 static inline QDF_STATUS osif_cm_osif_priv_init(struct wlan_objmgr_vdev *vdev) 305 { 306 return QDF_STATUS_SUCCESS; 307 } 308 309 static inline QDF_STATUS osif_cm_osif_priv_deinit(struct wlan_objmgr_vdev *vdev) 310 { 311 return QDF_STATUS_SUCCESS; 312 } 313 314 static inline QDF_STATUS osif_cm_register_cb(void) 315 { 316 return QDF_STATUS_SUCCESS; 317 } 318 #endif 319 320 #endif /* __OSIF_CM_UTIL_H */ 321