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