Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 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 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * This file contains TSPEC and STA admit control related functions |
| 30 | * NOTE: applies only to AP builds |
| 31 | * |
| 32 | * Author: Sandesh Goel |
| 33 | * Date: 02/25/02 |
| 34 | * History:- |
| 35 | * Date Modified by Modification Information |
| 36 | * -------------------------------------------------------------------- |
| 37 | * |
| 38 | */ |
| 39 | #include "lim_debug.h" |
| 40 | #include "sys_def.h" |
| 41 | #include "lim_api.h" |
| 42 | #include "cfg_api.h" /* wlan_cfg_get_int() */ |
| 43 | #include "lim_trace.h" |
| 44 | #include "lim_send_sme_rsp_messages.h" |
| 45 | #include "lim_types.h" |
| 46 | |
| 47 | #define ADMIT_CONTROL_LOGLEVEL LOG1 |
| 48 | #define ADMIT_CONTROL_POLICY_LOGLEVEL LOG1 |
| 49 | |
| 50 | /* total available bandwidth in bps in each phy mode |
| 51 | * these should be defined in hal or dph - replace these later |
| 52 | */ |
| 53 | #define LIM_TOTAL_BW_11A 54000000 |
| 54 | #define LIM_MIN_BW_11A 6000000 |
| 55 | #define LIM_TOTAL_BW_11B 11000000 |
| 56 | #define LIM_MIN_BW_11B 1000000 |
| 57 | #define LIM_TOTAL_BW_11G LIM_TOTAL_BW_11A |
| 58 | #define LIM_MIN_BW_11G LIM_MIN_BW_11B |
| 59 | |
| 60 | /* conversion factors */ |
| 61 | #define LIM_CONVERT_SIZE_BITS(numBytes) ((numBytes) * 8) |
| 62 | #define LIM_CONVERT_RATE_MBPS(rate) ((rate)/1000000) |
| 63 | |
| 64 | /* ------------------------------------------------------------------------------ */ |
| 65 | /* local protos */ |
| 66 | |
| 67 | static tSirRetStatus |
| 68 | lim_calculate_svc_int(tpAniSirGlobal, tSirMacTspecIE *, uint32_t *); |
| 69 | static tSirRetStatus |
| 70 | lim_validate_tspec_edca(tpAniSirGlobal, tSirMacTspecIE *, tpPESession); |
| 71 | static tSirRetStatus |
| 72 | lim_validate_tspec(tpAniSirGlobal, tSirMacTspecIE *, tpPESession); |
| 73 | static void |
| 74 | lim_compute_mean_bw_used(tpAniSirGlobal, uint32_t *, uint32_t, tpLimTspecInfo, |
| 75 | tpPESession); |
| 76 | static void lim_get_available_bw(tpAniSirGlobal, uint32_t *, uint32_t *, uint32_t, |
| 77 | uint32_t); |
| 78 | static tSirRetStatus lim_admit_policy_oversubscription(tpAniSirGlobal, |
| 79 | tSirMacTspecIE *, |
| 80 | tpLimAdmitPolicyInfo, |
| 81 | tpLimTspecInfo, |
| 82 | tpPESession); |
| 83 | static tSirRetStatus lim_tspec_find_by_sta_addr(tpAniSirGlobal, uint8_t *, |
| 84 | tSirMacTspecIE *, tpLimTspecInfo, |
| 85 | tpLimTspecInfo *); |
| 86 | static tSirRetStatus lim_validate_access_policy(tpAniSirGlobal, uint8_t, uint16_t, |
| 87 | tpPESession); |
| 88 | |
| 89 | /** ------------------------------------------------------------- |
| 90 | \fn lim_calculate_svc_int |
| 91 | \brief TSPEC validation and servcie interval determination |
| 92 | \param tpAniSirGlobal pMac |
| 93 | \param tSirMacTspecIE *pTspec |
| 94 | \param uint32_t *pSvcInt |
| 95 | \return eSirRetStatus - status of the comparison |
| 96 | -------------------------------------------------------------*/ |
| 97 | |
| 98 | static tSirRetStatus |
| 99 | lim_calculate_svc_int(tpAniSirGlobal pMac, |
| 100 | tSirMacTspecIE *pTspec, uint32_t *pSvcInt) |
| 101 | { |
| 102 | uint32_t msduSz, dataRate; |
| 103 | *pSvcInt = 0; |
| 104 | |
| 105 | /* if a service interval is already specified, we are done */ |
| 106 | if ((pTspec->minSvcInterval != 0) || (pTspec->maxSvcInterval != 0)) { |
| 107 | *pSvcInt = (pTspec->maxSvcInterval != 0) |
| 108 | ? pTspec->maxSvcInterval : pTspec->minSvcInterval; |
| 109 | return eSIR_SUCCESS; |
| 110 | } |
| 111 | |
| 112 | /* Masking off the fixed bits according to definition of MSDU size |
| 113 | * in IEEE 802.11-2007 spec (section 7.3.2.30). Nominal MSDU size |
| 114 | * is defined as: Bit[0:14]=Size, Bit[15]=Fixed |
| 115 | */ |
| 116 | if (pTspec->nomMsduSz != 0) |
| 117 | msduSz = (pTspec->nomMsduSz & 0x7fff); |
| 118 | else if (pTspec->maxMsduSz != 0) |
| 119 | msduSz = pTspec->maxMsduSz; |
| 120 | else { |
| 121 | PELOGE(lim_log(pMac, LOGE, FL("MsduSize not specified"));) |
| 122 | return eSIR_FAILURE; |
| 123 | } |
| 124 | |
| 125 | /* need to calculate a reasonable service interval |
| 126 | * this is simply the msduSz/meanDataRate |
| 127 | */ |
| 128 | if (pTspec->meanDataRate != 0) |
| 129 | dataRate = pTspec->meanDataRate; |
| 130 | else if (pTspec->peakDataRate != 0) |
| 131 | dataRate = pTspec->peakDataRate; |
| 132 | else if (pTspec->minDataRate != 0) |
| 133 | dataRate = pTspec->minDataRate; |
| 134 | else { |
| 135 | PELOGE(lim_log(pMac, LOGE, FL("DataRate not specified"));) |
| 136 | return eSIR_FAILURE; |
| 137 | } |
| 138 | |
| 139 | *pSvcInt = |
| 140 | LIM_CONVERT_SIZE_BITS(msduSz) / LIM_CONVERT_RATE_MBPS(dataRate); |
| 141 | return eSIR_FAILURE; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * lim_validate_tspec_edca() - Validate the parameters |
| 146 | * @mac_ctx: Global MAC context |
| 147 | * @tspec: Pointer to the TSPEC |
| 148 | * @session_entry: Session Entry |
| 149 | * |
| 150 | * validate the parameters in the edca tspec |
| 151 | * mandatory fields are derived from 11e Annex I (Table I.1) |
| 152 | * |
| 153 | * Return: Status |
| 154 | **/ |
| 155 | static tSirRetStatus |
| 156 | lim_validate_tspec_edca(tpAniSirGlobal mac_ctx, |
| 157 | tSirMacTspecIE *tspec, tpPESession session_entry) |
| 158 | { |
| 159 | uint32_t max_phy_rate, min_phy_rate; |
| 160 | uint32_t phy_mode; |
| 161 | tSirRetStatus retval = eSIR_SUCCESS; |
| 162 | |
| 163 | lim_get_phy_mode(mac_ctx, &phy_mode, session_entry); |
| 164 | |
| 165 | lim_get_available_bw(mac_ctx, &max_phy_rate, &min_phy_rate, phy_mode, |
| 166 | 1 /* bandwidth mult factor */); |
| 167 | /* mandatory fields are derived from 11e Annex I (Table I.1) */ |
| 168 | if ((tspec->nomMsduSz == 0) || |
| 169 | (tspec->meanDataRate == 0) || |
| 170 | (tspec->surplusBw == 0) || |
| 171 | (tspec->minPhyRate == 0) || |
| 172 | (tspec->minPhyRate > max_phy_rate)) { |
| 173 | lim_log(mac_ctx, LOGW, |
| 174 | FL |
| 175 | ("Invalid EDCA Tspec: NomMsdu %d, meanDataRate %d, surplusBw %d, min_phy_rate %d"), |
| 176 | tspec->nomMsduSz, tspec->meanDataRate, |
| 177 | tspec->surplusBw, tspec->minPhyRate); |
| 178 | retval = eSIR_FAILURE; |
| 179 | } |
| 180 | |
| 181 | lim_log(mac_ctx, ADMIT_CONTROL_LOGLEVEL, |
| 182 | FL("return status %d"), retval); |
| 183 | return retval; |
| 184 | } |
| 185 | |
| 186 | /** ------------------------------------------------------------- |
| 187 | \fn lim_validate_tspec |
| 188 | \brief validate the offered tspec |
| 189 | \param tpAniSirGlobal pMac |
| 190 | \param tSirMacTspecIE *pTspec |
| 191 | \return eSirRetStatus - status |
| 192 | -------------------------------------------------------------*/ |
| 193 | |
| 194 | static tSirRetStatus |
| 195 | lim_validate_tspec(tpAniSirGlobal pMac, |
| 196 | tSirMacTspecIE *pTspec, tpPESession psessionEntry) |
| 197 | { |
| 198 | tSirRetStatus retval = eSIR_SUCCESS; |
| 199 | switch (pTspec->tsinfo.traffic.accessPolicy) { |
| 200 | case SIR_MAC_ACCESSPOLICY_EDCA: |
| 201 | retval = lim_validate_tspec_edca(pMac, pTspec, psessionEntry); |
| 202 | if (retval != eSIR_SUCCESS) |
| 203 | PELOGW(lim_log(pMac, LOGW, FL("EDCA tspec invalid"));) |
| 204 | break; |
| 205 | |
| 206 | case SIR_MAC_ACCESSPOLICY_HCCA: |
| 207 | case SIR_MAC_ACCESSPOLICY_BOTH: |
| 208 | /* TBD: should we support hybrid tspec as well?? for now, just fall through */ |
| 209 | default: |
| 210 | lim_log(pMac, LOGW, FL("AccessType %d not supported"), |
| 211 | pTspec->tsinfo.traffic.accessPolicy); |
| 212 | retval = eSIR_FAILURE; |
| 213 | break; |
| 214 | } |
| 215 | return retval; |
| 216 | } |
| 217 | |
| 218 | /* ----------------------------------------------------------------------------- */ |
| 219 | /* Admit Control Policy */ |
| 220 | |
| 221 | /** ------------------------------------------------------------- |
| 222 | \fn lim_compute_mean_bw_used |
| 223 | \brief determime the used/allocated bandwidth |
| 224 | \param tpAniSirGlobal pMac |
| 225 | \param uint32_t *pBw |
| 226 | \param uint32_t phyMode |
| 227 | \param tpLimTspecInfo pTspecInfo |
| 228 | \return eSirRetStatus - status |
| 229 | -------------------------------------------------------------*/ |
| 230 | |
| 231 | static void |
| 232 | lim_compute_mean_bw_used(tpAniSirGlobal pMac, |
| 233 | uint32_t *pBw, |
| 234 | uint32_t phyMode, |
| 235 | tpLimTspecInfo pTspecInfo, tpPESession psessionEntry) |
| 236 | { |
| 237 | uint32_t ctspec; |
| 238 | *pBw = 0; |
| 239 | for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecInfo++) { |
| 240 | if (pTspecInfo->inuse) { |
| 241 | tpDphHashNode pSta = |
| 242 | dph_get_hash_entry(pMac, pTspecInfo->assocId, |
| 243 | &psessionEntry->dph.dphHashTable); |
| 244 | if (pSta == NULL) { |
| 245 | /* maybe we should delete the tspec?? */ |
| 246 | lim_log(pMac, LOGE, |
| 247 | FL |
| 248 | ("Tspec %d (assocId %d): dphNode not found"), |
| 249 | ctspec, pTspecInfo->assocId); |
| 250 | continue; |
| 251 | } |
| 252 | *pBw += pTspecInfo->tspec.meanDataRate; |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /** ------------------------------------------------------------- |
| 258 | \fn lim_get_available_bw |
| 259 | \brief based on the phy mode and the bw_factor, determine the total bandwidth that |
| 260 | can be supported |
| 261 | \param tpAniSirGlobal pMac |
| 262 | \param uint32_t *pMaxBw |
| 263 | \param uint32_t *pMinBw |
| 264 | \param uint32_t phyMode |
| 265 | \param uint32_t bw_factor |
| 266 | \return eSirRetStatus - status |
| 267 | -------------------------------------------------------------*/ |
| 268 | |
| 269 | static void |
| 270 | lim_get_available_bw(tpAniSirGlobal pMac, |
| 271 | uint32_t *pMaxBw, |
| 272 | uint32_t *pMinBw, uint32_t phyMode, uint32_t bw_factor) |
| 273 | { |
| 274 | switch (phyMode) { |
| 275 | case WNI_CFG_PHY_MODE_11B: |
| 276 | *pMaxBw = LIM_TOTAL_BW_11B; |
| 277 | *pMinBw = LIM_MIN_BW_11B; |
| 278 | break; |
| 279 | |
| 280 | case WNI_CFG_PHY_MODE_11A: |
| 281 | *pMaxBw = LIM_TOTAL_BW_11A; |
| 282 | *pMinBw = LIM_MIN_BW_11A; |
| 283 | break; |
| 284 | |
| 285 | case WNI_CFG_PHY_MODE_11G: |
| 286 | case WNI_CFG_PHY_MODE_NONE: |
| 287 | default: |
| 288 | *pMaxBw = LIM_TOTAL_BW_11G; |
| 289 | *pMinBw = LIM_MIN_BW_11G; |
| 290 | break; |
| 291 | } |
| 292 | *pMaxBw *= bw_factor; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * lim_admit_policy_oversubscription() - Admission control policy |
| 297 | * @mac_ctx: Global MAC Context |
| 298 | * @tspec: Pointer to the tspec |
| 299 | * @admit_policy: Admission policy |
| 300 | * @tspec_info: TSPEC information |
| 301 | * @session_entry: Session Entry |
| 302 | * |
| 303 | * simple admission control policy based on oversubscription |
| 304 | * if the total bandwidth of all admitted tspec's exceeds (factor * phy-bw) then |
| 305 | * reject the tspec, else admit it. The phy-bw is the peak available bw in the |
| 306 | * current phy mode. The 'factor' is the configured oversubscription factor. |
| 307 | * |
| 308 | * Return: Status |
| 309 | **/ |
| 310 | static tSirRetStatus |
| 311 | lim_admit_policy_oversubscription(tpAniSirGlobal mac_ctx, |
| 312 | tSirMacTspecIE *tspec, |
| 313 | tpLimAdmitPolicyInfo admit_policy, |
| 314 | tpLimTspecInfo tspec_info, |
| 315 | tpPESession session_entry) |
| 316 | { |
| 317 | uint32_t totalbw, minbw, usedbw; |
| 318 | uint32_t phy_mode; |
| 319 | |
| 320 | /* determine total bandwidth used so far */ |
| 321 | lim_get_phy_mode(mac_ctx, &phy_mode, session_entry); |
| 322 | |
| 323 | lim_compute_mean_bw_used(mac_ctx, &usedbw, phy_mode, |
| 324 | tspec_info, session_entry); |
| 325 | |
| 326 | /* determine how much bw is available based on the current phy mode */ |
| 327 | lim_get_available_bw(mac_ctx, &totalbw, &minbw, phy_mode, |
| 328 | admit_policy->bw_factor); |
| 329 | |
| 330 | if (usedbw > totalbw) /* this can't possibly happen */ |
| 331 | return eSIR_FAILURE; |
| 332 | |
| 333 | if ((totalbw - usedbw) < tspec->meanDataRate) { |
| 334 | lim_log(mac_ctx, ADMIT_CONTROL_POLICY_LOGLEVEL, |
| 335 | FL |
| 336 | ("Total BW %d, Used %d, Tspec request %d not possible"), |
| 337 | totalbw, usedbw, tspec->meanDataRate); |
| 338 | return eSIR_FAILURE; |
| 339 | } |
| 340 | return eSIR_SUCCESS; |
| 341 | } |
| 342 | |
| 343 | /** ------------------------------------------------------------- |
| 344 | \fn lim_admit_policy |
| 345 | \brief determine the current admit control policy and apply it for the offered tspec |
| 346 | \param tpAniSirGlobal pMac |
| 347 | \param tSirMacTspecIE *pTspec |
| 348 | \return eSirRetStatus - status |
| 349 | -------------------------------------------------------------*/ |
| 350 | |
| 351 | tSirRetStatus lim_admit_policy(tpAniSirGlobal pMac, |
| 352 | tSirMacTspecIE *pTspec, tpPESession psessionEntry) |
| 353 | { |
| 354 | tSirRetStatus retval = eSIR_FAILURE; |
| 355 | tpLimAdmitPolicyInfo pAdmitPolicy = &pMac->lim.admitPolicyInfo; |
| 356 | |
| 357 | switch (pAdmitPolicy->type) { |
| 358 | case WNI_CFG_ADMIT_POLICY_ADMIT_ALL: |
| 359 | retval = eSIR_SUCCESS; |
| 360 | break; |
| 361 | |
| 362 | case WNI_CFG_ADMIT_POLICY_BW_FACTOR: |
| 363 | retval = lim_admit_policy_oversubscription(pMac, pTspec, |
| 364 | &pMac->lim. |
| 365 | admitPolicyInfo, |
| 366 | &pMac->lim.tspecInfo[0], |
| 367 | psessionEntry); |
| 368 | if (retval != eSIR_SUCCESS) |
| 369 | PELOGE(lim_log |
| 370 | (pMac, LOGE, FL("rejected by BWFactor policy")); |
| 371 | ) |
| 372 | break; |
| 373 | |
| 374 | case WNI_CFG_ADMIT_POLICY_REJECT_ALL: |
| 375 | retval = eSIR_FAILURE; |
| 376 | break; |
| 377 | |
| 378 | default: |
| 379 | retval = eSIR_SUCCESS; |
| 380 | lim_log(pMac, LOGE, |
| 381 | FL("Admit Policy %d unknown, admitting all traffic"), |
| 382 | pAdmitPolicy->type); |
| 383 | break; |
| 384 | } |
| 385 | return retval; |
| 386 | } |
| 387 | |
| 388 | /** ------------------------------------------------------------- |
| 389 | \fn lim_tspec_delete |
| 390 | \brief delete the specified tspec |
| 391 | \param tpAniSirGlobal pMac |
| 392 | \param tpLimTspecInfo pInfo |
| 393 | \return eSirRetStatus - status |
| 394 | -------------------------------------------------------------*/ |
| 395 | |
| 396 | /* ----------------------------------------------------------------------------- */ |
| 397 | /* delete the specified tspec */ |
| 398 | void lim_tspec_delete(tpAniSirGlobal pMac, tpLimTspecInfo pInfo) |
| 399 | { |
| 400 | if (pInfo == NULL) |
| 401 | return; |
| 402 | /* pierre */ |
| 403 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, FL("tspec entry = %d"), |
| 404 | pInfo->idx); |
| 405 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, FL("delete tspec %p"), pInfo); |
| 406 | pInfo->inuse = 0; |
| 407 | |
| 408 | return; |
| 409 | } |
| 410 | |
| 411 | /** ------------------------------------------------------------- |
| 412 | \fn lim_tspec_find_by_sta_addr |
| 413 | \brief Send halMsg_AddTs to HAL |
| 414 | \param tpAniSirGlobal pMac |
| 415 | \param \param uint8_t *pAddr |
| 416 | \param tSirMacTspecIE *pTspecIE |
| 417 | \param tpLimTspecInfo pTspecList |
| 418 | \param tpLimTspecInfo *ppInfo |
| 419 | \return eSirRetStatus - status |
| 420 | -------------------------------------------------------------*/ |
| 421 | |
| 422 | /* find the specified tspec in the list */ |
| 423 | static tSirRetStatus |
| 424 | lim_tspec_find_by_sta_addr(tpAniSirGlobal pMac, |
| 425 | uint8_t *pAddr, |
| 426 | tSirMacTspecIE *pTspecIE, |
| 427 | tpLimTspecInfo pTspecList, tpLimTspecInfo *ppInfo) |
| 428 | { |
| 429 | int ctspec; |
| 430 | |
| 431 | *ppInfo = NULL; |
| 432 | |
| 433 | for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++) { |
| 434 | if ((pTspecList->inuse) |
| 435 | && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 436 | (!qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 437 | (pAddr, pTspecList->staAddr, sizeof(pTspecList->staAddr))) |
| 438 | && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 439 | (!qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 440 | ((uint8_t *) pTspecIE, (uint8_t *) &pTspecList->tspec, |
| 441 | sizeof(tSirMacTspecIE)))) { |
| 442 | *ppInfo = pTspecList; |
| 443 | return eSIR_SUCCESS; |
| 444 | } |
| 445 | } |
| 446 | return eSIR_FAILURE; |
| 447 | } |
| 448 | |
| 449 | /** ------------------------------------------------------------- |
| 450 | \fn lim_tspec_find_by_assoc_id |
| 451 | \brief find tspec with matchin staid and Tspec |
| 452 | \param tpAniSirGlobal pMac |
| 453 | \param uint32_t staid |
| 454 | \param tSirMacTspecIE *pTspecIE |
| 455 | \param tpLimTspecInfo pTspecList |
| 456 | \param tpLimTspecInfo *ppInfo |
| 457 | \return eSirRetStatus - status |
| 458 | -------------------------------------------------------------*/ |
| 459 | |
| 460 | tSirRetStatus |
| 461 | lim_tspec_find_by_assoc_id(tpAniSirGlobal pMac, |
| 462 | uint16_t assocId, |
| 463 | tSirMacTspecIE *pTspecIE, |
| 464 | tpLimTspecInfo pTspecList, tpLimTspecInfo *ppInfo) |
| 465 | { |
| 466 | int ctspec; |
| 467 | |
| 468 | *ppInfo = NULL; |
| 469 | |
| 470 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 471 | FL("Trying to find tspec entry for assocId = %d"), assocId); |
| 472 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 473 | FL |
| 474 | ("pTsInfo->traffic.direction = %d, pTsInfo->traffic.tsid = %d"), |
| 475 | pTspecIE->tsinfo.traffic.direction, |
| 476 | pTspecIE->tsinfo.traffic.tsid); |
| 477 | |
| 478 | for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++) { |
| 479 | if ((pTspecList->inuse) |
| 480 | && (assocId == pTspecList->assocId) |
| 481 | && |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 482 | (!qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 483 | ((uint8_t *) pTspecIE, (uint8_t *) &pTspecList->tspec, |
| 484 | sizeof(tSirMacTspecIE)))) { |
| 485 | *ppInfo = pTspecList; |
| 486 | return eSIR_SUCCESS; |
| 487 | } |
| 488 | } |
| 489 | return eSIR_FAILURE; |
| 490 | } |
| 491 | |
| 492 | /** ------------------------------------------------------------- |
| 493 | \fn lim_find_tspec |
| 494 | \brief finding a TSPEC entry with assocId, tsinfo.direction and tsinfo.tsid |
| 495 | \param uint16_t assocId |
| 496 | \param tpAniSirGlobal pMac |
| 497 | \param tSirMacTSInfo *pTsInfo |
| 498 | \param tpLimTspecInfo pTspecList |
| 499 | \param tpLimTspecInfo *ppInfo |
| 500 | \return eSirRetStatus - status of the comparison |
| 501 | -------------------------------------------------------------*/ |
| 502 | |
| 503 | tSirRetStatus |
| 504 | lim_find_tspec(tpAniSirGlobal pMac, |
| 505 | uint16_t assocId, |
| 506 | tSirMacTSInfo *pTsInfo, |
| 507 | tpLimTspecInfo pTspecList, tpLimTspecInfo *ppInfo) |
| 508 | { |
| 509 | int ctspec; |
| 510 | |
| 511 | *ppInfo = NULL; |
| 512 | |
| 513 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 514 | FL("Trying to find tspec entry for assocId = %d"), assocId); |
| 515 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 516 | FL |
| 517 | ("pTsInfo->traffic.direction = %d, pTsInfo->traffic.tsid = %d"), |
| 518 | pTsInfo->traffic.direction, pTsInfo->traffic.tsid); |
| 519 | |
| 520 | for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecList++) { |
| 521 | if ((pTspecList->inuse) |
| 522 | && (assocId == pTspecList->assocId) |
| 523 | && (pTsInfo->traffic.direction == |
| 524 | pTspecList->tspec.tsinfo.traffic.direction) |
| 525 | && (pTsInfo->traffic.tsid == |
| 526 | pTspecList->tspec.tsinfo.traffic.tsid)) { |
| 527 | *ppInfo = pTspecList; |
| 528 | return eSIR_SUCCESS; |
| 529 | } |
| 530 | } |
| 531 | return eSIR_FAILURE; |
| 532 | } |
| 533 | |
| 534 | /** ------------------------------------------------------------- |
| 535 | \fn lim_tspec_add |
| 536 | \brief add or update the specified tspec to the tspec list |
| 537 | \param tpAniSirGlobal pMac |
| 538 | \param uint8_t *pAddr |
| 539 | \param uint16_t assocId |
| 540 | \param tSirMacTspecIE *pTspec |
| 541 | \param uint32_t interval |
| 542 | \param tpLimTspecInfo *ppInfo |
| 543 | |
| 544 | \return eSirRetStatus - status of the comparison |
| 545 | -------------------------------------------------------------*/ |
| 546 | |
| 547 | tSirRetStatus lim_tspec_add(tpAniSirGlobal pMac, |
| 548 | uint8_t *pAddr, |
| 549 | uint16_t assocId, |
| 550 | tSirMacTspecIE *pTspec, |
| 551 | uint32_t interval, tpLimTspecInfo *ppInfo) |
| 552 | { |
| 553 | tpLimTspecInfo pTspecList = &pMac->lim.tspecInfo[0]; |
| 554 | *ppInfo = NULL; |
| 555 | |
| 556 | /* validate the assocId */ |
| 557 | if (assocId >= pMac->lim.maxStation) { |
| 558 | PELOGE(lim_log(pMac, LOGE, FL("Invalid assocId 0x%x"), assocId);) |
| 559 | return eSIR_FAILURE; |
| 560 | } |
| 561 | /* decide whether to add/update */ |
| 562 | { |
| 563 | *ppInfo = NULL; |
| 564 | |
| 565 | if (eSIR_SUCCESS == |
| 566 | lim_find_tspec(pMac, assocId, &pTspec->tsinfo, pTspecList, |
| 567 | ppInfo)) { |
| 568 | /* update this entry. */ |
| 569 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 570 | FL("updating TSPEC table entry = %d"), |
| 571 | (*ppInfo)->idx); |
| 572 | } else { |
| 573 | /* We didn't find one to update. So find a free slot in the |
| 574 | * LIM TSPEC list and add this new entry |
| 575 | */ |
| 576 | uint8_t ctspec = 0; |
| 577 | for (ctspec = 0, pTspecList = &pMac->lim.tspecInfo[0]; |
| 578 | ctspec < LIM_NUM_TSPEC_MAX; |
| 579 | ctspec++, pTspecList++) { |
| 580 | if (!pTspecList->inuse) { |
| 581 | lim_log(pMac, LOG1, |
| 582 | FL |
| 583 | ("Found free slot in TSPEC list. Add to TSPEC table entry %d"), |
| 584 | ctspec); |
| 585 | break; |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | if (ctspec >= LIM_NUM_TSPEC_MAX) |
| 590 | return eSIR_FAILURE; |
| 591 | |
| 592 | /* Record the new index entry */ |
| 593 | pTspecList->idx = ctspec; |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | /* update the tspec info */ |
| 598 | pTspecList->tspec = *pTspec; |
| 599 | pTspecList->assocId = assocId; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 600 | qdf_mem_copy(pTspecList->staAddr, pAddr, sizeof(pTspecList->staAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 601 | |
| 602 | /* for edca tspec's, we are all done */ |
| 603 | if (pTspec->tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) { |
| 604 | pTspecList->inuse = 1; |
| 605 | *ppInfo = pTspecList; |
| 606 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 607 | FL("added entry for EDCA AccessPolicy")); |
| 608 | return eSIR_SUCCESS; |
| 609 | } |
| 610 | |
| 611 | /* |
| 612 | * for hcca tspec's, must set the parameterized bit in the queues |
| 613 | * the 'ts' bit in the queue data structure indicates that the queue is |
| 614 | * parameterized (hcca). When the schedule is written this bit is used |
| 615 | * in the tsid field (bit 3) and the other three bits (0-2) are simply |
| 616 | * filled in as the user priority (or qid). This applies only to uplink |
| 617 | * polls where the qos control field must contain the tsid specified in the |
| 618 | * tspec. |
| 619 | */ |
| 620 | pTspecList->inuse = 1; |
| 621 | *ppInfo = pTspecList; |
| 622 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 623 | FL("added entry for HCCA AccessPolicy")); |
| 624 | return eSIR_SUCCESS; |
| 625 | } |
| 626 | |
| 627 | /** ------------------------------------------------------------- |
| 628 | \fn lim_validate_access_policy |
| 629 | \brief Validates Access policy |
| 630 | \param tpAniSirGlobal pMac |
| 631 | \param uint8_t accessPolicy |
| 632 | \param uint16_t assocId |
| 633 | \return eSirRetStatus - status |
| 634 | -------------------------------------------------------------*/ |
| 635 | |
| 636 | static tSirRetStatus |
| 637 | lim_validate_access_policy(tpAniSirGlobal pMac, |
| 638 | uint8_t accessPolicy, |
| 639 | uint16_t assocId, tpPESession psessionEntry) |
| 640 | { |
| 641 | tSirRetStatus retval = eSIR_FAILURE; |
| 642 | tpDphHashNode pSta = |
| 643 | dph_get_hash_entry(pMac, assocId, &psessionEntry->dph.dphHashTable); |
| 644 | |
| 645 | if ((pSta == NULL) || (!pSta->valid)) { |
| 646 | PELOGE(lim_log(pMac, LOGE, FL("invalid station address passed"));) |
| 647 | return eSIR_FAILURE; |
| 648 | } |
| 649 | |
| 650 | switch (accessPolicy) { |
| 651 | case SIR_MAC_ACCESSPOLICY_EDCA: |
| 652 | if (pSta->wmeEnabled || pSta->lleEnabled) |
| 653 | retval = eSIR_SUCCESS; |
| 654 | break; |
| 655 | |
| 656 | case SIR_MAC_ACCESSPOLICY_HCCA: |
| 657 | case SIR_MAC_ACCESSPOLICY_BOTH: |
| 658 | default: |
| 659 | PELOGE(lim_log |
| 660 | (pMac, LOGE, FL("Invalid accessPolicy %d"), |
| 661 | accessPolicy); |
| 662 | ) |
| 663 | break; |
| 664 | } |
| 665 | |
| 666 | if (retval != eSIR_SUCCESS) |
| 667 | lim_log(pMac, LOGW, |
| 668 | FL |
| 669 | ("failed (accPol %d, staId %d, lle %d, wme %d, wsm %d)"), |
| 670 | accessPolicy, pSta->staIndex, pSta->lleEnabled, |
| 671 | pSta->wmeEnabled, pSta->wsmEnabled); |
| 672 | |
| 673 | return retval; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * lim_admit_control_add_ts() - Check if STA can be admitted |
| 678 | * @pMac: Global MAC context |
| 679 | * @pAddr: Address |
| 680 | * @pAddts: ADD TS |
| 681 | * @pQos: QOS fields |
| 682 | * @assocId: Association ID |
| 683 | * @alloc: Allocate bandwidth for this tspec |
| 684 | * @pSch: Schedule IE |
| 685 | * @pTspecIdx: TSPEC index |
| 686 | * @psessionEntry: PE Session Entry |
| 687 | * |
| 688 | * Determine if STA with the specified TSPEC can be admitted. If it can, |
| 689 | * a schedule element is provided |
| 690 | * |
| 691 | * Return: status |
| 692 | **/ |
| 693 | tSirRetStatus lim_admit_control_add_ts(tpAniSirGlobal pMac, uint8_t *pAddr, |
| 694 | tSirAddtsReqInfo *pAddts, tSirMacQosCapabilityStaIE *pQos, |
| 695 | uint16_t assocId, uint8_t alloc, tSirMacScheduleIE *pSch, |
| 696 | uint8_t *pTspecIdx, tpPESession psessionEntry) |
| 697 | { |
| 698 | tpLimTspecInfo pTspecInfo; |
| 699 | tSirRetStatus retval; |
| 700 | uint32_t svcInterval; |
| 701 | (void)pQos; |
| 702 | |
| 703 | /* TBD: modify tspec as needed */ |
| 704 | /* EDCA: need to fill in the medium time and the minimum phy rate */ |
| 705 | /* to be consistent with the desired traffic parameters. */ |
| 706 | |
| 707 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 708 | FL |
| 709 | ("tsid %d, directn %d, start %d, intvl %d, accPolicy %d, up %d"), |
| 710 | pAddts->tspec.tsinfo.traffic.tsid, |
| 711 | pAddts->tspec.tsinfo.traffic.direction, |
| 712 | pAddts->tspec.svcStartTime, pAddts->tspec.minSvcInterval, |
| 713 | pAddts->tspec.tsinfo.traffic.accessPolicy, |
| 714 | pAddts->tspec.tsinfo.traffic.userPrio); |
| 715 | |
| 716 | /* check for duplicate tspec */ |
| 717 | retval = (alloc) |
| 718 | ? lim_tspec_find_by_assoc_id(pMac, assocId, &pAddts->tspec, |
| 719 | &pMac->lim.tspecInfo[0], &pTspecInfo) |
| 720 | : lim_tspec_find_by_sta_addr(pMac, pAddr, &pAddts->tspec, |
| 721 | &pMac->lim.tspecInfo[0], &pTspecInfo); |
| 722 | |
| 723 | if (retval == eSIR_SUCCESS) { |
| 724 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 725 | FL("duplicate tspec (index %d)!"), pTspecInfo->idx); |
| 726 | return eSIR_FAILURE; |
| 727 | } |
| 728 | /* check that the tspec's are well formed and acceptable */ |
| 729 | if (lim_validate_tspec(pMac, &pAddts->tspec, psessionEntry) != |
| 730 | eSIR_SUCCESS) { |
| 731 | PELOGW(lim_log(pMac, LOGW, FL("tspec validation failed"));) |
| 732 | return eSIR_FAILURE; |
| 733 | } |
| 734 | /* determine a service interval for the tspec */ |
| 735 | if (lim_calculate_svc_int(pMac, &pAddts->tspec, &svcInterval) != |
| 736 | eSIR_SUCCESS) { |
| 737 | PELOGW(lim_log(pMac, LOGW, FL("SvcInt calculate failed"));) |
| 738 | return eSIR_FAILURE; |
| 739 | } |
| 740 | /* determine if the tspec can be admitted or not based on current policy */ |
| 741 | if (lim_admit_policy(pMac, &pAddts->tspec, psessionEntry) != eSIR_SUCCESS) { |
| 742 | PELOGW(lim_log |
| 743 | (pMac, LOGW, |
| 744 | FL("tspec rejected by admit control policy")); |
| 745 | ) |
| 746 | return eSIR_FAILURE; |
| 747 | } |
| 748 | /* fill in a schedule if requested */ |
| 749 | if (pSch != NULL) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 750 | qdf_mem_set((uint8_t *) pSch, sizeof(*pSch), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | pSch->svcStartTime = pAddts->tspec.svcStartTime; |
| 752 | pSch->svcInterval = svcInterval; |
| 753 | pSch->maxSvcDuration = (uint16_t) pSch->svcInterval; /* use SP = SI */ |
| 754 | pSch->specInterval = 0x1000; /* fixed for now: TBD */ |
| 755 | |
| 756 | pSch->info.direction = pAddts->tspec.tsinfo.traffic.direction; |
| 757 | pSch->info.tsid = pAddts->tspec.tsinfo.traffic.tsid; |
| 758 | pSch->info.aggregation = 0; /* no support for aggregation for now: TBD */ |
| 759 | } |
| 760 | /* if no allocation is requested, done */ |
| 761 | if (!alloc) |
| 762 | return eSIR_SUCCESS; |
| 763 | |
| 764 | /* check that we are in the proper mode to deal with the tspec type */ |
| 765 | if (lim_validate_access_policy |
| 766 | (pMac, (uint8_t) pAddts->tspec.tsinfo.traffic.accessPolicy, assocId, |
| 767 | psessionEntry) != eSIR_SUCCESS) { |
| 768 | lim_log(pMac, LOGW, |
| 769 | FL("AccessPolicy %d is not valid in current mode"), |
| 770 | pAddts->tspec.tsinfo.traffic.accessPolicy); |
| 771 | return eSIR_FAILURE; |
| 772 | } |
| 773 | /* add tspec to list */ |
| 774 | if (lim_tspec_add |
| 775 | (pMac, pAddr, assocId, &pAddts->tspec, svcInterval, &pTspecInfo) |
| 776 | != eSIR_SUCCESS) { |
| 777 | PELOGE(lim_log(pMac, LOGE, FL("no space in tspec list"));) |
| 778 | return eSIR_FAILURE; |
| 779 | } |
| 780 | /* passing lim tspec table index to the caller */ |
| 781 | *pTspecIdx = pTspecInfo->idx; |
| 782 | |
| 783 | return eSIR_SUCCESS; |
| 784 | } |
| 785 | |
| 786 | /** ------------------------------------------------------------- |
| 787 | \fn lim_admit_control_delete_ts |
| 788 | \brief Delete the specified Tspec for the specified STA |
| 789 | \param tpAniSirGlobal pMac |
| 790 | \param uint16_t assocId |
| 791 | \param tSirMacTSInfo *pTsInfo |
| 792 | \param uint8_t *pTsStatus |
| 793 | \param uint8_t *ptspecIdx |
| 794 | \return eSirRetStatus - status |
| 795 | -------------------------------------------------------------*/ |
| 796 | |
| 797 | tSirRetStatus |
| 798 | lim_admit_control_delete_ts(tpAniSirGlobal pMac, |
| 799 | uint16_t assocId, |
| 800 | tSirMacTSInfo *pTsInfo, |
| 801 | uint8_t *pTsStatus, uint8_t *ptspecIdx) |
| 802 | { |
| 803 | tpLimTspecInfo pTspecInfo = NULL; |
| 804 | |
| 805 | if (pTsStatus != NULL) |
| 806 | *pTsStatus = 0; |
| 807 | |
| 808 | if (lim_find_tspec |
| 809 | (pMac, assocId, pTsInfo, &pMac->lim.tspecInfo[0], |
| 810 | &pTspecInfo) == eSIR_SUCCESS) { |
| 811 | if (pTspecInfo != NULL) { |
| 812 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 813 | FL("Tspec entry %d found"), pTspecInfo->idx); |
| 814 | |
| 815 | *ptspecIdx = pTspecInfo->idx; |
| 816 | lim_tspec_delete(pMac, pTspecInfo); |
| 817 | return eSIR_SUCCESS; |
| 818 | } |
| 819 | } |
| 820 | return eSIR_FAILURE; |
| 821 | } |
| 822 | |
| 823 | /** ------------------------------------------------------------- |
| 824 | \fn lim_admit_control_delete_sta |
| 825 | \brief Delete all TSPEC for the specified STA |
| 826 | \param tpAniSirGlobal pMac |
| 827 | \param uint16_t assocId |
| 828 | \return eSirRetStatus - status |
| 829 | -------------------------------------------------------------*/ |
| 830 | |
| 831 | tSirRetStatus lim_admit_control_delete_sta(tpAniSirGlobal pMac, uint16_t assocId) |
| 832 | { |
| 833 | tpLimTspecInfo pTspecInfo = &pMac->lim.tspecInfo[0]; |
| 834 | int ctspec; |
| 835 | |
| 836 | for (ctspec = 0; ctspec < LIM_NUM_TSPEC_MAX; ctspec++, pTspecInfo++) { |
| 837 | if (assocId == pTspecInfo->assocId) { |
| 838 | lim_tspec_delete(pMac, pTspecInfo); |
| 839 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, |
| 840 | FL("Deleting TSPEC %d for assocId %d"), ctspec, |
| 841 | assocId); |
| 842 | } |
| 843 | } |
| 844 | lim_log(pMac, ADMIT_CONTROL_LOGLEVEL, FL("assocId %d done"), assocId); |
| 845 | |
| 846 | return eSIR_SUCCESS; |
| 847 | } |
| 848 | |
| 849 | /** ------------------------------------------------------------- |
| 850 | \fn lim_admit_control_init |
| 851 | \brief init tspec table |
| 852 | \param tpAniSirGlobal pMac |
| 853 | \return eSirRetStatus - status |
| 854 | -------------------------------------------------------------*/ |
| 855 | tSirRetStatus lim_admit_control_init(tpAniSirGlobal pMac) |
| 856 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 857 | qdf_mem_set(pMac->lim.tspecInfo, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | LIM_NUM_TSPEC_MAX * sizeof(tLimTspecInfo), 0); |
| 859 | return eSIR_SUCCESS; |
| 860 | } |
| 861 | |
| 862 | /** ------------------------------------------------------------- |
| 863 | \fn lim_update_admit_policy |
| 864 | \brief Set the admit control policy based on CFG parameters |
| 865 | \param tpAniSirGlobal pMac |
| 866 | \return eSirRetStatus - status |
| 867 | -------------------------------------------------------------*/ |
| 868 | |
| 869 | tSirRetStatus lim_update_admit_policy(tpAniSirGlobal pMac) |
| 870 | { |
| 871 | uint32_t val; |
| 872 | if (wlan_cfg_get_int(pMac, WNI_CFG_ADMIT_POLICY, &val) != eSIR_SUCCESS) { |
| 873 | lim_log(pMac, LOGP, FL("Unable to get CFG_ADMIT_POLICY")); |
| 874 | return eSIR_FAILURE; |
| 875 | } |
| 876 | pMac->lim.admitPolicyInfo.type = (uint8_t) val; |
| 877 | if (wlan_cfg_get_int(pMac, WNI_CFG_ADMIT_BWFACTOR, &val) != eSIR_SUCCESS) { |
| 878 | lim_log(pMac, LOGP, FL("Unable to get CFG_ADMIT_BWFACTOR")); |
| 879 | return eSIR_FAILURE; |
| 880 | } |
| 881 | pMac->lim.admitPolicyInfo.bw_factor = (uint8_t) val; |
| 882 | |
| 883 | PELOG1(lim_log(pMac, LOG1, FL("LIM: AdmitPolicy %d, bw_factor %d"), |
| 884 | pMac->lim.admitPolicyInfo.type, |
| 885 | pMac->lim.admitPolicyInfo.bw_factor); |
| 886 | ) |
| 887 | |
| 888 | return eSIR_SUCCESS; |
| 889 | } |
| 890 | |
| 891 | /** ------------------------------------------------------------- |
| 892 | \fn lim_send_hal_msg_add_ts |
| 893 | \brief Send halMsg_AddTs to HAL |
| 894 | \param tpAniSirGlobal pMac |
| 895 | \param uint16_t staIdx |
| 896 | \param uint8_t tspecIdx |
| 897 | \param tSirMacTspecIE tspecIE |
| 898 | \param tSirTclasInfo *tclasInfo |
| 899 | \param uint8_t tclasProc |
| 900 | \param uint16_t tsm_interval |
| 901 | \return eSirRetStatus - status |
| 902 | -------------------------------------------------------------*/ |
| 903 | #ifdef FEATURE_WLAN_ESE |
| 904 | tSirRetStatus |
| 905 | lim_send_hal_msg_add_ts(tpAniSirGlobal pMac, |
| 906 | uint16_t staIdx, |
| 907 | uint8_t tspecIdx, |
| 908 | tSirMacTspecIE tspecIE, |
| 909 | uint8_t sessionId, uint16_t tsm_interval) |
| 910 | #else |
| 911 | tSirRetStatus |
| 912 | lim_send_hal_msg_add_ts(tpAniSirGlobal pMac, |
| 913 | uint16_t staIdx, |
| 914 | uint8_t tspecIdx, tSirMacTspecIE tspecIE, uint8_t sessionId) |
| 915 | #endif |
| 916 | { |
| 917 | tSirMsgQ msg; |
| 918 | tpAddTsParams pAddTsParam; |
| 919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | tpPESession psessionEntry = pe_find_session_by_session_id(pMac, sessionId); |
| 921 | if (psessionEntry == NULL) { |
| 922 | lim_log(pMac, LOGP, |
| 923 | FL("Unable to get Session for session Id %d"), |
| 924 | sessionId); |
| 925 | return eSIR_FAILURE; |
| 926 | } |
Prashanth Bhatta | bfc2529 | 2015-11-05 11:16:21 -0800 | [diff] [blame] | 927 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 928 | pAddTsParam = qdf_mem_malloc(sizeof(tAddTsParams)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 929 | if (NULL == pAddTsParam) { |
| 930 | PELOGW(lim_log(pMac, LOGW, FL("AllocateMemory() failed"));) |
| 931 | return eSIR_MEM_ALLOC_FAILED; |
| 932 | } |
| 933 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 934 | qdf_mem_set((uint8_t *) pAddTsParam, sizeof(tAddTsParams), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 935 | pAddTsParam->staIdx = staIdx; |
| 936 | pAddTsParam->tspecIdx = tspecIdx; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 937 | qdf_mem_copy(&pAddTsParam->tspec, &tspecIE, sizeof(tSirMacTspecIE)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 938 | pAddTsParam->sessionId = sessionId; |
| 939 | pAddTsParam->sme_session_id = psessionEntry->smeSessionId; |
| 940 | |
| 941 | #ifdef FEATURE_WLAN_ESE |
| 942 | pAddTsParam->tsm_interval = tsm_interval; |
| 943 | #endif |
| 944 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 945 | if (pMac->roam.configParam.isRoamOffloadEnabled && |
| 946 | psessionEntry->is11Rconnection) |
| 947 | pAddTsParam->setRICparams = 1; |
| 948 | #endif |
| 949 | |
| 950 | msg.type = WMA_ADD_TS_REQ; |
| 951 | msg.bodyptr = pAddTsParam; |
| 952 | msg.bodyval = 0; |
| 953 | |
| 954 | /* We need to defer any incoming messages until we get a |
| 955 | * WMA_ADD_TS_RSP from HAL. |
| 956 | */ |
| 957 | SET_LIM_PROCESS_DEFD_MESGS(pMac, false); |
| 958 | MTRACE(mac_trace_msg_tx(pMac, sessionId, msg.type)); |
| 959 | |
| 960 | if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) { |
| 961 | lim_log(pMac, LOGW, FL("wma_post_ctrl_msg() failed")); |
| 962 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 963 | qdf_mem_free(pAddTsParam); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | return eSIR_FAILURE; |
| 965 | } |
| 966 | return eSIR_SUCCESS; |
| 967 | } |
| 968 | |
| 969 | /** ------------------------------------------------------------- |
| 970 | \fn lim_send_hal_msg_del_ts |
| 971 | \brief Send halMsg_AddTs to HAL |
| 972 | \param tpAniSirGlobal pMac |
| 973 | \param uint16_t staIdx |
| 974 | \param uint8_t tspecIdx |
| 975 | \param tSirAddtsReqInfo addts |
| 976 | \return eSirRetStatus - status |
| 977 | -------------------------------------------------------------*/ |
| 978 | |
| 979 | tSirRetStatus |
| 980 | lim_send_hal_msg_del_ts(tpAniSirGlobal pMac, |
| 981 | uint16_t staIdx, |
| 982 | uint8_t tspecIdx, |
| 983 | tSirDeltsReqInfo delts, uint8_t sessionId, uint8_t *bssId) |
| 984 | { |
| 985 | tSirMsgQ msg; |
| 986 | tpDelTsParams pDelTsParam; |
| 987 | tpPESession psessionEntry = NULL; |
| 988 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 989 | pDelTsParam = qdf_mem_malloc(sizeof(tDelTsParams)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | if (NULL == pDelTsParam) { |
| 991 | lim_log(pMac, LOGP, FL("AllocateMemory() failed")); |
| 992 | return eSIR_MEM_ALLOC_FAILED; |
| 993 | } |
| 994 | |
| 995 | msg.type = WMA_DEL_TS_REQ; |
| 996 | msg.bodyptr = pDelTsParam; |
| 997 | msg.bodyval = 0; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 998 | qdf_mem_set((uint8_t *) pDelTsParam, sizeof(tDelTsParams), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | |
| 1000 | /* filling message parameters. */ |
| 1001 | pDelTsParam->staIdx = staIdx; |
| 1002 | pDelTsParam->tspecIdx = tspecIdx; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 1003 | qdf_mem_copy(&pDelTsParam->bssId, bssId, sizeof(tSirMacAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | |
| 1005 | psessionEntry = pe_find_session_by_session_id(pMac, sessionId); |
| 1006 | if (psessionEntry == NULL) { |
| 1007 | PELOGE(lim_log(pMac, LOGE, |
| 1008 | FL |
| 1009 | ("Session does Not exist with given sessionId :%d "), |
| 1010 | sessionId); |
| 1011 | ) |
| 1012 | goto err; |
| 1013 | } |
| 1014 | pDelTsParam->sessionId = psessionEntry->smeSessionId; |
| 1015 | pDelTsParam->userPrio = delts.wmeTspecPresent ? |
| 1016 | delts.tspec.tsinfo.traffic.userPrio : |
| 1017 | delts.tsinfo.traffic.userPrio; |
| 1018 | |
| 1019 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1020 | if (pMac->roam.configParam.isRoamOffloadEnabled && |
| 1021 | psessionEntry->is11Rconnection) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 1022 | qdf_mem_copy(&pDelTsParam->delTsInfo, &delts, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1023 | sizeof(tSirDeltsReqInfo)); |
| 1024 | pDelTsParam->setRICparams = 1; |
| 1025 | } |
| 1026 | #endif |
| 1027 | |
| 1028 | lim_log(pMac, LOGW, FL("calling wma_post_ctrl_msg()")); |
| 1029 | MTRACE(mac_trace_msg_tx(pMac, sessionId, msg.type)); |
| 1030 | |
| 1031 | if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) { |
| 1032 | lim_log(pMac, LOGW, FL("wma_post_ctrl_msg() failed")); |
| 1033 | goto err; |
| 1034 | } |
| 1035 | return eSIR_SUCCESS; |
| 1036 | |
| 1037 | err: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 1038 | qdf_mem_free(pDelTsParam); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1039 | return eSIR_FAILURE; |
| 1040 | } |
| 1041 | |
| 1042 | /** ------------------------------------------------------------- |
| 1043 | \fn lim_process_hal_add_ts_rsp |
| 1044 | \brief This function process the WMA_ADD_TS_RSP from HAL. |
| 1045 | \ If response is successful, then send back SME_ADDTS_RSP. |
| 1046 | \ Otherwise, send DELTS action frame to peer and then |
| 1047 | \ then send back SME_ADDTS_RSP. |
| 1048 | \ |
| 1049 | \param tpAniSirGlobal pMac |
| 1050 | \param tpSirMsgQ limMsg |
| 1051 | -------------------------------------------------------------*/ |
| 1052 | void lim_process_hal_add_ts_rsp(tpAniSirGlobal pMac, tpSirMsgQ limMsg) |
| 1053 | { |
| 1054 | tpAddTsParams pAddTsRspMsg = NULL; |
| 1055 | tpDphHashNode pSta = NULL; |
| 1056 | uint16_t assocId = 0; |
| 1057 | tSirMacAddr peerMacAddr; |
| 1058 | uint8_t rspReqd = 1; |
| 1059 | tpPESession psessionEntry = NULL; |
| 1060 | |
| 1061 | /* Need to process all the deferred messages enqueued |
| 1062 | * since sending the WMA_ADD_TS_REQ. |
| 1063 | */ |
| 1064 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
| 1065 | |
| 1066 | if (NULL == limMsg->bodyptr) { |
| 1067 | lim_log(pMac, LOGP, FL("Received WMA_ADD_TS_RSP with NULL ")); |
| 1068 | goto end; |
| 1069 | } |
| 1070 | |
| 1071 | pAddTsRspMsg = (tpAddTsParams) (limMsg->bodyptr); |
| 1072 | |
| 1073 | /* 090803: Use pe_find_session_by_session_id() to obtain the PE session context */ |
| 1074 | /* from the sessionId in the Rsp Msg from HAL */ |
| 1075 | psessionEntry = pe_find_session_by_session_id(pMac, pAddTsRspMsg->sessionId); |
| 1076 | |
| 1077 | if (psessionEntry == NULL) { |
| 1078 | PELOGE(lim_log |
| 1079 | (pMac, LOGE, |
| 1080 | FL("Session does Not exist with given sessionId :%d "), |
| 1081 | pAddTsRspMsg->sessionId); |
| 1082 | ) |
| 1083 | lim_send_sme_addts_rsp(pMac, rspReqd, eSIR_SME_ADDTS_RSP_FAILED, |
| 1084 | psessionEntry, pAddTsRspMsg->tspec, |
| 1085 | pMac->lim.gLimAddtsReq.sessionId, |
| 1086 | pMac->lim.gLimAddtsReq.transactionId); |
| 1087 | goto end; |
| 1088 | } |
| 1089 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1090 | if (pAddTsRspMsg->status == QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1091 | PELOG1(lim_log |
| 1092 | (pMac, LOG1, |
| 1093 | FL("Received successful ADDTS response from HAL ")); |
| 1094 | ) |
| 1095 | /* Use the smesessionId and smetransactionId from the PE session context */ |
| 1096 | lim_send_sme_addts_rsp(pMac, rspReqd, eSIR_SME_SUCCESS, |
| 1097 | psessionEntry, pAddTsRspMsg->tspec, |
| 1098 | psessionEntry->smeSessionId, |
| 1099 | psessionEntry->transactionId); |
| 1100 | goto end; |
| 1101 | } else { |
| 1102 | PELOG1(lim_log |
| 1103 | (pMac, LOG1, |
| 1104 | FL("Received failure ADDTS response from HAL ")); |
| 1105 | ) |
| 1106 | /* Send DELTS action frame to AP */ |
| 1107 | /* 090803: Get peer MAC addr from session */ |
| 1108 | sir_copy_mac_addr(peerMacAddr, psessionEntry->bssId); |
| 1109 | |
| 1110 | /* 090803: Add the SME Session ID */ |
| 1111 | lim_send_delts_req_action_frame(pMac, peerMacAddr, rspReqd, |
| 1112 | &pAddTsRspMsg->tspec.tsinfo, |
| 1113 | &pAddTsRspMsg->tspec, psessionEntry); |
| 1114 | |
| 1115 | /* Delete TSPEC */ |
| 1116 | /* 090803: Pull the hash table from the session */ |
| 1117 | pSta = dph_lookup_assoc_id(pMac, pAddTsRspMsg->staIdx, &assocId, |
| 1118 | &psessionEntry->dph.dphHashTable); |
| 1119 | if (pSta != NULL) |
| 1120 | lim_admit_control_delete_ts(pMac, assocId, |
| 1121 | &pAddTsRspMsg->tspec.tsinfo, |
| 1122 | NULL, |
| 1123 | (uint8_t *) &pAddTsRspMsg-> |
| 1124 | tspecIdx); |
| 1125 | |
| 1126 | /* Send SME_ADDTS_RSP */ |
| 1127 | /* 090803: Use the smesessionId and smetransactionId from the PE session context */ |
| 1128 | lim_send_sme_addts_rsp(pMac, rspReqd, eSIR_SME_ADDTS_RSP_FAILED, |
| 1129 | psessionEntry, pAddTsRspMsg->tspec, |
| 1130 | psessionEntry->smeSessionId, |
| 1131 | psessionEntry->transactionId); |
| 1132 | goto end; |
| 1133 | } |
| 1134 | |
| 1135 | end: |
| 1136 | if (pAddTsRspMsg != NULL) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame^] | 1137 | qdf_mem_free(pAddTsRspMsg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | return; |
| 1139 | } |