Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 1 | /* |
Gopichand Nakkala | 92f07d8 | 2013-01-08 21:16:34 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | /* |
Jeff Johnson | 32d95a3 | 2012-09-10 13:15:23 -0700 | [diff] [blame] | 22 | * Copyright (c) 2012, The Linux Foundation. All rights reserved. |
Jeff Johnson | 295189b | 2012-06-20 16:38:30 -0700 | [diff] [blame] | 23 | * |
| 24 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 25 | * |
| 26 | * |
| 27 | * Permission to use, copy, modify, and/or distribute this software for |
| 28 | * any purpose with or without fee is hereby granted, provided that the |
| 29 | * above copyright notice and this permission notice appear in all |
| 30 | * copies. |
| 31 | * |
| 32 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 33 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 35 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 36 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 37 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 38 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 39 | * PERFORMANCE OF THIS SOFTWARE. |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | * */ |
| 44 | #ifndef _WLAN_HDD_WMM_H |
| 45 | #define _WLAN_HDD_WMM_H |
| 46 | /*============================================================================ |
| 47 | @file wlan_hdd_wmm.h |
| 48 | |
| 49 | This module (wlan_hdd_wmm.h interface + wlan_hdd_wmm.c implementation) |
| 50 | houses all the logic for WMM in HDD. |
| 51 | |
| 52 | On the control path, it has the logic to setup QoS, modify QoS and delete |
| 53 | QoS (QoS here refers to a TSPEC). The setup QoS comes in two flavors: an |
| 54 | explicit application invoked and an internal HDD invoked. The implicit QoS |
| 55 | is for applications that do NOT call the custom QCT WLAN OIDs for QoS but |
| 56 | which DO mark their traffic for priortization. It also has logic to start, |
| 57 | update and stop the U-APSD trigger frame generation. It also has logic to |
| 58 | read WMM related config parameters from the registry. |
| 59 | |
| 60 | On the data path, it has the logic to figure out the WMM AC of an egress |
| 61 | packet and when to signal TL to serve a particular AC queue. It also has the |
| 62 | logic to retrieve a packet based on WMM priority in response to a fetch from |
| 63 | TL. |
| 64 | |
| 65 | The remaining functions are utility functions for information hiding. |
| 66 | |
| 67 | |
| 68 | Copyright (c) 2008-9 QUALCOMM Incorporated. |
| 69 | All Rights Reserved. |
| 70 | Qualcomm Confidential and Proprietary |
| 71 | ============================================================================*/ |
| 72 | /* $Header$ */ |
| 73 | |
| 74 | /*---------------------------------------------------------------------------- |
| 75 | * Include Files |
| 76 | * -------------------------------------------------------------------------*/ |
| 77 | #include <linux/workqueue.h> |
| 78 | #include <linux/list.h> |
| 79 | #include <wlan_hdd_main.h> |
| 80 | #include <wlan_hdd_wext.h> |
| 81 | #include <wlan_qct_tl.h> |
| 82 | #include <sme_QosApi.h> |
| 83 | |
| 84 | /*---------------------------------------------------------------------------- |
| 85 | * Preprocessor Definitions and Constants |
| 86 | * -------------------------------------------------------------------------*/ |
| 87 | |
| 88 | // #define HDD_WMM_DEBUG 1 |
| 89 | |
| 90 | #define HDD_WMM_CTX_MAGIC 0x574d4d58 // "WMMX" |
| 91 | |
| 92 | #define HDD_WMM_HANDLE_IMPLICIT 0xFFFFFFFF |
| 93 | |
| 94 | #define HDD_WLAN_INVALID_STA_ID 0xFF |
| 95 | |
| 96 | /*---------------------------------------------------------------------------- |
| 97 | * Type Declarations |
| 98 | * -------------------------------------------------------------------------*/ |
| 99 | /*! @brief AC/Queue Index values for Linux Qdisc to operate on different traffic. |
| 100 | */ |
| 101 | typedef enum |
| 102 | { |
| 103 | HDD_LINUX_AC_VO = 0, |
| 104 | HDD_LINUX_AC_VI = 1, |
| 105 | HDD_LINUX_AC_BE = 2, |
| 106 | HDD_LINUX_AC_BK = 3 |
| 107 | |
| 108 | } hdd_wmm_linuxac_t; |
| 109 | |
| 110 | /*! @brief types of classification supported |
| 111 | */ |
| 112 | typedef enum |
| 113 | { |
| 114 | HDD_WMM_CLASSIFICATION_DSCP = 0, |
| 115 | HDD_WMM_CLASSIFICATION_802_1Q = 1 |
| 116 | |
| 117 | } hdd_wmm_classification_t; |
| 118 | |
| 119 | /*! @brief UAPSD state |
| 120 | */ |
| 121 | typedef enum |
| 122 | { |
| 123 | HDD_WMM_NON_UAPSD = 0, |
| 124 | HDD_WMM_UAPSD = 1 |
| 125 | |
| 126 | } hdd_wmm_uapsd_state_t; |
| 127 | |
| 128 | |
| 129 | typedef enum |
| 130 | { |
| 131 | //STA can associate with any AP, & HDD looks at the SME notification after |
| 132 | // association to find out if associated with QAP and acts accordingly |
| 133 | HDD_WMM_USER_MODE_AUTO = 0, |
| 134 | //SME will add the extra logic to make sure STA associates with a QAP only |
| 135 | HDD_WMM_USER_MODE_QBSS_ONLY = 1, |
| 136 | //SME will not join a QoS AP, unless the phy mode setting says "Auto". In |
| 137 | // that case, STA is free to join 11n AP. Although from HDD point of view, |
| 138 | // it will not be doing any packet classifications |
| 139 | HDD_WMM_USER_MODE_NO_QOS = 2, |
| 140 | |
| 141 | } hdd_wmm_user_mode_t; |
| 142 | |
| 143 | |
| 144 | /*! @brief WMM Qos instance control block |
| 145 | */ |
| 146 | typedef struct |
| 147 | { |
| 148 | struct list_head node; |
| 149 | v_U32_t handle; |
| 150 | v_U32_t qosFlowId; |
| 151 | hdd_adapter_t* pAdapter; |
| 152 | WLANTL_ACEnumType acType; |
| 153 | hdd_wlan_wmm_status_e lastStatus; |
| 154 | struct work_struct wmmAcSetupImplicitQos; |
| 155 | v_U32_t magic; |
| 156 | } hdd_wmm_qos_context_t; |
| 157 | |
| 158 | /*! @brief WMM related per-AC state & status info |
| 159 | */ |
| 160 | typedef struct |
| 161 | { |
| 162 | // does the AP require access to this AC? |
| 163 | v_BOOL_t wmmAcAccessRequired; |
| 164 | |
| 165 | // does the worker thread need to acquire access to this AC? |
| 166 | v_BOOL_t wmmAcAccessNeeded; |
| 167 | |
| 168 | // is implicit QoS negotiation currently taking place? |
| 169 | v_BOOL_t wmmAcAccessPending; |
| 170 | |
| 171 | // has implicit QoS negotiation already failed? |
| 172 | v_BOOL_t wmmAcAccessFailed; |
| 173 | |
| 174 | // has implicit QoS negotiation already succeeded? |
| 175 | v_BOOL_t wmmAcAccessGranted; |
| 176 | |
| 177 | // is access to this AC allowed, either because we are not doing |
| 178 | // WMM, we are not doing implicit QoS, implict QoS has completed, |
| 179 | // or explicit QoS has completed? |
| 180 | v_BOOL_t wmmAcAccessAllowed; |
| 181 | |
| 182 | // is the wmmAcTspecInfo valid? |
| 183 | v_BOOL_t wmmAcTspecValid; |
| 184 | |
| 185 | // are the wmmAcUapsd* fields valid? |
| 186 | v_BOOL_t wmmAcUapsdInfoValid; |
| 187 | |
| 188 | // current (possibly aggregate) Tspec for this AC |
| 189 | sme_QosWmmTspecInfo wmmAcTspecInfo; |
| 190 | |
| 191 | // current U-APSD parameters |
| 192 | v_U32_t wmmAcUapsdServiceInterval; |
| 193 | v_U32_t wmmAcUapsdSuspensionInterval; |
| 194 | sme_QosWmmDirType wmmAcUapsdDirection; |
| 195 | |
| 196 | #ifdef FEATURE_WLAN_CCX |
| 197 | // Inactivity time parameters for TSPEC |
| 198 | v_U32_t wmmInactivityTime; |
| 199 | v_U32_t wmmPrevTrafficCnt; |
| 200 | vos_timer_t wmmInactivityTimer; |
| 201 | #endif |
| 202 | |
| 203 | } hdd_wmm_ac_status_t; |
| 204 | |
| 205 | /*! @brief WMM state & status info |
| 206 | */ |
| 207 | typedef struct |
| 208 | { |
| 209 | struct list_head wmmContextList; |
| 210 | struct mutex wmmLock; |
| 211 | hdd_wmm_ac_status_t wmmAcStatus[WLANTL_MAX_AC]; |
| 212 | v_BOOL_t wmmQap; |
| 213 | v_BOOL_t wmmQosConnection; |
| 214 | } hdd_wmm_status_t; |
| 215 | |
| 216 | extern const v_U8_t hdd_QdiscAcToTlAC[]; |
| 217 | extern const v_U8_t hddWmmUpToAcMap[]; |
| 218 | extern const v_U8_t hddLinuxUpToAcMap[]; |
| 219 | |
| 220 | /**============================================================================ |
| 221 | @brief hdd_wmm_init() - Function which will initialize the WMM configuation |
| 222 | and status to an initial state. The configuration can later be overwritten |
| 223 | via application APIs |
| 224 | |
| 225 | @param pHddCtx : [in] pointer to HDD context |
| 226 | |
| 227 | @return : VOS_STATUS_SUCCESS if succssful |
| 228 | : other values if failure |
| 229 | |
| 230 | ===========================================================================*/ |
| 231 | VOS_STATUS hdd_wmm_init ( hdd_context_t* pHddCtx ); |
| 232 | |
| 233 | /**============================================================================ |
| 234 | @brief hdd_wmm_adapter_init() - Function which will initialize the WMM configuation |
| 235 | and status to an initial state. The configuration can later be overwritten |
| 236 | via application APIs |
| 237 | |
| 238 | @param pAdapter : [in] pointer to Adapter context |
| 239 | |
| 240 | @return : VOS_STATUS_SUCCESS if succssful |
| 241 | : other values if failure |
| 242 | |
| 243 | ===========================================================================*/ |
| 244 | VOS_STATUS hdd_wmm_adapter_init( hdd_adapter_t *pAdapter ); |
| 245 | |
| 246 | /**============================================================================ |
| 247 | @brief hdd_wmm_adapter_close() - Function which will perform any necessary work to |
| 248 | to clean up the WMM functionality prior to the kernel module unload |
| 249 | |
| 250 | @param pAdapter : [in] pointer to adapter context |
| 251 | |
| 252 | @return : VOS_STATUS_SUCCESS if succssful |
| 253 | : other values if failure |
| 254 | |
| 255 | ===========================================================================*/ |
| 256 | VOS_STATUS hdd_wmm_adapter_close ( hdd_adapter_t* pAdapter ); |
| 257 | |
| 258 | /**============================================================================ |
| 259 | @brief hdd_wmm_select_queue() - Function which will classify an OS packet |
| 260 | into linux Qdisc expectation |
| 261 | |
| 262 | @param dev : [in] pointer to net_device structure |
| 263 | @param skb : [in] pointer to OS packet (sk_buff) |
| 264 | |
| 265 | @return : queue_index/linux AC value. |
| 266 | ===========================================================================*/ |
| 267 | v_U16_t hdd_wmm_select_queue(struct net_device * dev, struct sk_buff *skb); |
| 268 | |
| 269 | /**============================================================================ |
| 270 | @brief hdd_hostapd_select_queue() - Function which will classify the packet |
| 271 | according to linux qdisc expectation. |
| 272 | |
| 273 | |
| 274 | @param dev : [in] pointer to net_device structure |
| 275 | @param skb : [in] pointer to os packet |
| 276 | |
| 277 | @return : Qdisc queue index |
| 278 | ===========================================================================*/ |
| 279 | |
| 280 | v_U16_t hdd_hostapd_select_queue(struct net_device * dev, struct sk_buff *skb); |
| 281 | |
| 282 | |
| 283 | |
| 284 | /**============================================================================ |
| 285 | @brief hdd_wmm_classify_pkt() - Function which will classify an OS packet |
| 286 | into a WMM AC based on either 802.1Q or DSCP |
| 287 | |
| 288 | @param pAdapter : [in] pointer to adapter context |
| 289 | @param skb : [in] pointer to OS packet (sk_buff) |
| 290 | @param pAcType : [out] pointer to WMM AC type of OS packet |
| 291 | |
| 292 | @return : None |
| 293 | ===========================================================================*/ |
| 294 | v_VOID_t hdd_wmm_classify_pkt ( hdd_adapter_t* pAdapter, |
| 295 | struct sk_buff *skb, |
| 296 | WLANTL_ACEnumType* pAcType, |
| 297 | sme_QosWmmUpType* pUserPri); |
| 298 | |
| 299 | |
| 300 | /**============================================================================ |
| 301 | @brief hdd_wmm_acquire_access() - Function which will attempt to acquire |
| 302 | admittance for a WMM AC |
| 303 | |
| 304 | @param pAdapter : [in] pointer to adapter context |
| 305 | @param acType : [in] WMM AC type of OS packet |
| 306 | @param pGranted : [out] pointer to boolean flag when indicates if access |
| 307 | has been granted or not |
| 308 | |
| 309 | @return : VOS_STATUS_SUCCESS if succssful |
| 310 | : other values if failure |
| 311 | ===========================================================================*/ |
| 312 | VOS_STATUS hdd_wmm_acquire_access( hdd_adapter_t* pAdapter, |
| 313 | WLANTL_ACEnumType acType, |
| 314 | v_BOOL_t * pGranted ); |
| 315 | |
| 316 | /**============================================================================ |
| 317 | @brief hdd_wmm_assoc() - Function which will handle the housekeeping |
| 318 | required by WMM when association takes place |
| 319 | |
| 320 | @param pAdapter : [in] pointer to adapter context |
| 321 | @param pRoamInfo: [in] pointer to roam information |
| 322 | @param eBssType : [in] type of BSS |
| 323 | |
| 324 | @return : VOS_STATUS_SUCCESS if succssful |
| 325 | : other values if failure |
| 326 | ===========================================================================*/ |
| 327 | VOS_STATUS hdd_wmm_assoc( hdd_adapter_t* pAdapter, |
| 328 | tCsrRoamInfo *pRoamInfo, |
| 329 | eCsrRoamBssType eBssType ); |
| 330 | |
| 331 | /**============================================================================ |
| 332 | @brief hdd_wmm_connect() - Function which will handle the housekeeping |
| 333 | required by WMM when a connection is established |
| 334 | |
| 335 | @param pAdapter : [in] pointer to adapter context |
| 336 | @param pRoamInfo: [in] pointer to roam information |
| 337 | @param eBssType : [in] type of BSS |
| 338 | |
| 339 | @return : VOS_STATUS_SUCCESS if succssful |
| 340 | : other values if failure |
| 341 | ===========================================================================*/ |
| 342 | VOS_STATUS hdd_wmm_connect( hdd_adapter_t* pAdapter, |
| 343 | tCsrRoamInfo *pRoamInfo, |
| 344 | eCsrRoamBssType eBssType ); |
| 345 | |
| 346 | /**============================================================================ |
| 347 | @brief hdd_wmm_get_uapsd_mask() - Function which will calculate the |
| 348 | initial value of the UAPSD mask based upon the device configuration |
| 349 | |
| 350 | @param pAdapter : [in] pointer to adapter context |
| 351 | @param pUapsdMask: [in] pointer to where the UAPSD Mask is to be stored |
| 352 | |
| 353 | @return : VOS_STATUS_SUCCESS if succssful |
| 354 | : other values if failure |
| 355 | ===========================================================================*/ |
| 356 | VOS_STATUS hdd_wmm_get_uapsd_mask( hdd_adapter_t* pAdapter, |
| 357 | tANI_U8 *pUapsdMask ); |
| 358 | |
| 359 | /**============================================================================ |
| 360 | @brief hdd_wmm_is_active() - Function which will determine if WMM is |
| 361 | active on the current connection |
| 362 | |
| 363 | @param pAdapter : [in] pointer to adapter context |
| 364 | |
| 365 | @return : VOS_TRUE if WMM is enabled |
| 366 | : VOS_FALSE if WMM is not enabled |
| 367 | ===========================================================================*/ |
| 368 | v_BOOL_t hdd_wmm_is_active( hdd_adapter_t* pAdapter ); |
| 369 | |
| 370 | /**============================================================================ |
| 371 | @brief hdd_wmm_addts() - Function which will add a traffic spec at the |
| 372 | request of an application |
| 373 | |
| 374 | @param pAdapter : [in] pointer to adapter context |
| 375 | @param handle : [in] handle to uniquely identify a TS |
| 376 | @param pTspec : [in] pointer to the traffic spec |
| 377 | |
| 378 | @return : HDD_WLAN_WMM_STATUS_* |
| 379 | ===========================================================================*/ |
| 380 | hdd_wlan_wmm_status_e hdd_wmm_addts( hdd_adapter_t* pAdapter, |
| 381 | v_U32_t handle, |
| 382 | sme_QosWmmTspecInfo* pTspec ); |
| 383 | |
| 384 | /**============================================================================ |
| 385 | @brief hdd_wmm_delts() - Function which will delete a traffic spec at the |
| 386 | request of an application |
| 387 | |
| 388 | @param pAdapter : [in] pointer to adapter context |
| 389 | @param handle : [in] handle to uniquely identify a TS |
| 390 | |
| 391 | @return : HDD_WLAN_WMM_STATUS_* |
| 392 | ===========================================================================*/ |
| 393 | hdd_wlan_wmm_status_e hdd_wmm_delts( hdd_adapter_t* pAdapter, |
| 394 | v_U32_t handle ); |
| 395 | |
| 396 | /**============================================================================ |
| 397 | @brief hdd_wmm_checkts() - Function which will return the status of a traffic |
| 398 | spec at the request of an application |
| 399 | |
| 400 | @param pAdapter : [in] pointer to adapter context |
| 401 | @param handle : [in] handle to uniquely identify a TS |
| 402 | |
| 403 | @return : HDD_WLAN_WMM_STATUS_* |
| 404 | ===========================================================================*/ |
| 405 | hdd_wlan_wmm_status_e hdd_wmm_checkts( hdd_adapter_t* pAdapter, |
| 406 | v_U32_t handle ); |
| 407 | |
| 408 | #endif /* #ifndef _WLAN_HDD_WMM_H */ |