1 /* 2 * trafficAdmControl.c 3 * 4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name Texas Instruments nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 35 /***************************************************************************/ 36 /* */ 37 /* MODULE: admCtrlQos.c */ 38 /* PURPOSE: WSM/WME admission Control */ 39 /* */ 40 /***************************************************************************/ 41 42 #define __FILE_ID__ FILE_ID_89 43 #include "osApi.h" 44 45 #include "paramOut.h" 46 47 #include "timer.h" 48 #include "fsm.h" 49 #include "report.h" 50 51 #include "DataCtrl_Api.h" 52 53 #include "trafficAdmControl.h" 54 #include "qosMngr_API.h" 55 #include "TWDriver.h" 56 #ifdef XCC_MODULE_INCLUDED 57 #include "XCCMngr.h" 58 #endif 59 /* Constants */ 60 61 /** number of states in the state machine */ 62 #define TRAFFIC_ADM_CTRL_SM_NUM_STATES 2 63 64 /** number of events in the state machine */ 65 #define TRAFFIC_ADM_CTRL_SM_NUM_EVENTS 5 66 67 extern int WMEQosTagToACTable[MAX_NUM_OF_802_1d_TAGS]; 68 69 typedef struct 70 { 71 TI_HANDLE hTrafficAdmCtrl; 72 tspecInfo_t *pTSpecInfo; 73 TI_UINT8 acID; 74 75 }fsmTSpecInfo_t; 76 77 78 /* Timer functions */ 79 void trafficAdmCtrl_timeoutAcBE(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured); 80 void trafficAdmCtrl_timeoutAcBK(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured); 81 void trafficAdmCtrl_timeoutAcVI(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured); 82 void trafficAdmCtrl_timeoutAcVO(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured); 83 84 85 /* SM Functions */ 86 TI_STATUS trafficAdmCtrl_smEvent(trafficAdmCtrl_t *pAdmCtrlQos, TI_UINT8 event, void *pData); 87 88 TI_STATUS trafficAdmCtrl_smActionUnexpectedTspecResponse(fsmTSpecInfo_t *fsmTSpecInfo); /*unxcepted*/ 89 TI_STATUS trafficAdmCtrl_smActionUnexpected(fsmTSpecInfo_t *fsmTSpecInfo); /*unxcepted*/ 90 TI_STATUS trafficAdmCtrl_smActionNop(fsmTSpecInfo_t *fsmTSpecInfo); /*NOP*/ 91 TI_STATUS trafficAdmCtrl_smStart(fsmTSpecInfo_t *fsmTSpecInfo); /*EVENT_START*/ 92 TI_STATUS trafficAdmCtrl_smWaitStop(fsmTSpecInfo_t *fsmTSpecInfo); /*EVENT_STOP*/ 93 TI_STATUS trafficAdmCtrl_smWaitAccept(fsmTSpecInfo_t *fsmTSpecInfo); /*EVENT_ACCEPT*/ 94 TI_STATUS trafficAdmCtrl_smWaitReject(fsmTSpecInfo_t *fsmTSpecInfo); /*EVENT_REJECT*/ 95 TI_STATUS trafficAdmCtrl_smWaitTimeout(fsmTSpecInfo_t *fsmTSpecInfo); /*EVENT_TIMEOUT*/ 96 97 98 99 TI_STATUS trafficAdmCtrl_sendAdmissionReq(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo); 100 TI_STATUS trafficAdmCtrl_startTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, TI_UINT8 acID); 101 TI_STATUS trafficAdmCtrl_stopTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, TI_UINT8 acID); 102 103 104 TI_STATUS trafficAdmCtrl_buildFrameHeader(trafficAdmCtrl_t *pTrafficAdmCtrl, TTxCtrlBlk *pPktCtrlBlk); 105 106 static TI_STATUS trafficAdmCtrl_tokenToAc (TI_HANDLE hTrafficAdmCtrl, TI_UINT8 token, TI_UINT8 *acID); 107 108 /******************************************************************************** 109 * trafficAdmCtrl_create * 110 ******************************************************************************** 111 DESCRIPTION: trafficAdmCtrl module creation function 112 113 INPUT: hOs - Handle to OS 114 115 116 OUTPUT: 117 118 RETURN: Handle to the trafficAdmCtrl module on success, NULL otherwise 119 120 ************************************************************************/ 121 122 TI_HANDLE trafficAdmCtrl_create(TI_HANDLE hOs) 123 { 124 trafficAdmCtrl_t *pTrafficAdmCtrl; 125 TI_STATUS status; 126 127 /* allocate admission control context memory */ 128 pTrafficAdmCtrl = (trafficAdmCtrl_t*)os_memoryAlloc(hOs, sizeof(trafficAdmCtrl_t)); 129 if (pTrafficAdmCtrl == NULL) 130 { 131 return NULL; 132 } 133 134 os_memoryZero(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t)); 135 136 pTrafficAdmCtrl->hOs = hOs; 137 138 /* allocate memory for admCtrlQos state machine */ 139 status = fsm_Create(hOs, &pTrafficAdmCtrl->pTrafficAdmCtrlSm, TRAFFIC_ADM_CTRL_SM_NUM_STATES, TRAFFIC_ADM_CTRL_SM_NUM_EVENTS); 140 if (status != TI_OK) 141 { 142 os_memoryFree(hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t)); 143 return NULL; 144 } 145 146 return pTrafficAdmCtrl; 147 } 148 /************************************************************************ 149 * trafficAdmCtrl_unload * 150 ************************************************************************ 151 DESCRIPTION: trafficAdmCtrl module destroy function, 152 - Free all memory alocated by the module 153 154 INPUT: hTrafficAdmCtrl - trafficAdmCtrl handle. 155 156 OUTPUT: 157 158 RETURN: TI_OK on success, TI_NOK otherwise 159 160 ************************************************************************/ 161 TI_STATUS trafficAdmCtrl_unload(TI_HANDLE hTrafficAdmCtrl) 162 { 163 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 164 TI_UINT32 uAcId; 165 166 if (pTrafficAdmCtrl->pTrafficAdmCtrlSm) 167 { 168 fsm_Unload (pTrafficAdmCtrl->hOs, pTrafficAdmCtrl->pTrafficAdmCtrlSm); 169 } 170 171 /* free timers */ 172 for (uAcId = 0; uAcId < MAX_NUM_OF_AC; uAcId++) 173 { 174 if (pTrafficAdmCtrl->hAdmCtrlTimer[uAcId]) 175 { 176 tmr_DestroyTimer (pTrafficAdmCtrl->hAdmCtrlTimer[uAcId]); 177 } 178 } 179 180 os_memoryFree(pTrafficAdmCtrl->hOs, pTrafficAdmCtrl, sizeof(trafficAdmCtrl_t)); 181 182 return TI_OK; 183 } 184 185 /************************************************************************ 186 * trafficAdmCtrl_config * 187 ************************************************************************ 188 DESCRIPTION: trafficAdmCtrl module configuration function, 189 performs the following: 190 - Reset & initiailzes local variables 191 - Init the handles to be used by the module 192 193 INPUT: hTrafficAdmCtrl - trafficAdmCtrl handle. 194 List of handles to be used by the module 195 pTrafficAdmCtrlInitParams - init parameters. 196 197 OUTPUT: 198 199 RETURN: TI_OK on success, TI_NOK otherwise 200 ************************************************************************/ 201 TI_STATUS trafficAdmCtrl_config (TI_HANDLE hTrafficAdmCtrl, 202 TI_HANDLE hTxMgmtQ, 203 TI_HANDLE hReport, 204 TI_HANDLE hOs, 205 TI_HANDLE hQosMngr, 206 TI_HANDLE hCtrlData, 207 TI_HANDLE hXCCMgr, 208 TI_HANDLE hTimer, 209 TI_HANDLE hTWD, 210 TI_HANDLE hTxCtrl, 211 trafficAdmCtrlInitParams_t *pTrafficAdmCtrlInitParams) 212 { 213 trafficAdmCtrl_t *pTrafficAdmCtrl; 214 TI_STATUS status; 215 TI_UINT32 uAcId; 216 217 fsm_actionCell_t trafficAdmCtrl_smMatrix[TRAFFIC_ADM_CTRL_SM_NUM_STATES][TRAFFIC_ADM_CTRL_SM_NUM_EVENTS] = 218 { 219 /* next state and actions for IDLE state */ 220 {{TRAFFIC_ADM_CTRL_SM_STATE_WAIT, (fsm_Action_t)trafficAdmCtrl_smStart}, /*EVENT_START*/ 221 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionNop}, /*EVENT_STOP*/ 222 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpectedTspecResponse}, /*EVENT_ACCEPT*/ 223 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpectedTspecResponse}, /*EVENT_REJECT*/ 224 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smActionUnexpected}, /*EVENT_TIMEOUT*/ 225 }, 226 /* next state and actions for WAIT state */ 227 {{TRAFFIC_ADM_CTRL_SM_STATE_WAIT, (fsm_Action_t)trafficAdmCtrl_smActionUnexpected}, /*EVENT_START*/ 228 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitStop}, /*EVENT_STOP*/ 229 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitAccept}, /*EVENT_ACCEPT*/ 230 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitReject}, /*EVENT_REJECT*/ 231 {TRAFFIC_ADM_CTRL_SM_STATE_IDLE, (fsm_Action_t)trafficAdmCtrl_smWaitTimeout}, /*EVENT_TIMEOUT*/ 232 }, 233 }; 234 235 pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 236 237 pTrafficAdmCtrl->hTxMgmtQ = hTxMgmtQ; 238 pTrafficAdmCtrl->hReport = hReport; 239 pTrafficAdmCtrl->hOs = hOs; 240 pTrafficAdmCtrl->hQosMngr = hQosMngr; 241 pTrafficAdmCtrl->hCtrlData = hCtrlData; 242 pTrafficAdmCtrl->hXCCMgr = hXCCMgr; 243 pTrafficAdmCtrl->hTimer = hTimer; 244 pTrafficAdmCtrl->hTWD = hTWD; 245 pTrafficAdmCtrl->hTxCtrl = hTxCtrl; 246 247 for (uAcId = 0; uAcId < MAX_NUM_OF_AC; uAcId++) 248 { 249 pTrafficAdmCtrl->dialogToken[uAcId] = 0; 250 251 /* Create per AC timers */ 252 pTrafficAdmCtrl->hAdmCtrlTimer[uAcId] = tmr_CreateTimer (pTrafficAdmCtrl->hTimer); 253 if (pTrafficAdmCtrl->hAdmCtrlTimer[uAcId] == NULL) 254 { 255 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, "trafficAdmCtrl_config(): Failed to create hAssocSmTimer!\n"); 256 return TI_NOK; 257 } 258 } 259 260 /* configure state machine */ 261 status = fsm_Config(pTrafficAdmCtrl->pTrafficAdmCtrlSm, &trafficAdmCtrl_smMatrix[0][0], 262 TRAFFIC_ADM_CTRL_SM_NUM_STATES, TRAFFIC_ADM_CTRL_SM_NUM_EVENTS, NULL, hOs); 263 if (status != TI_OK) 264 { 265 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, "TRAFFIC_ADM_CTRL_SM: fsm_Config - Error \n"); 266 267 return TI_NOK; 268 } 269 270 pTrafficAdmCtrl->timeout = pTrafficAdmCtrlInitParams->trafficAdmCtrlResponseTimeout; 271 pTrafficAdmCtrl->useFixedMsduSize = pTrafficAdmCtrlInitParams->trafficAdmCtrlUseFixedMsduSize; 272 273 pTrafficAdmCtrl->dialogTokenCounter = INITIAL_DIALOG_TOKEN; 274 275 276 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "TRAFFIC ADM CTRL - configuration completed ..... \n"); 277 278 return TI_OK; 279 } 280 281 282 /************************************************************************ 283 * trafficAdmCtrl_smEvent * 284 ************************************************************************ 285 DESCRIPTION: trafficAdmCtrl SM general function 286 287 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 288 event - the event to the SM. 289 pData - handle to passing parameter 290 OUTPUT: 291 292 RETURN: TI_OK on success, TI_NOK otherwise 293 ************************************************************************/ 294 295 TI_STATUS trafficAdmCtrl_smEvent(trafficAdmCtrl_t *pTrafficAdmCtrl, TI_UINT8 event, void *pData) 296 { 297 TI_STATUS status; 298 TI_UINT8 nextState; 299 fsmTSpecInfo_t *fsmTSpecInfo = (fsmTSpecInfo_t*)pData; 300 TI_UINT8 acID = fsmTSpecInfo->acID; 301 302 /* It looks like it never happens. Anyway decided to check */ 303 if ( acID >= MAX_NUM_OF_AC ) 304 { 305 TRACE2( pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, 306 "trafficAdmCtrl_smEvent. fsmTSpecInfo->acID=%d exceeds the limit %d\n", 307 acID, MAX_NUM_OF_AC-1); 308 handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION); 309 return TI_NOK; 310 } 311 312 status = fsm_GetNextState(pTrafficAdmCtrl->pTrafficAdmCtrlSm, pTrafficAdmCtrl->currentState[acID], event, &nextState); 313 if (status != TI_OK) 314 { 315 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, "ADM_CTRL: ERROR - failed getting next state \n"); 316 317 return(TI_NOK); 318 } 319 320 TRACE3(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "trafficAdmCtrl_smEvent: <currentState = %d, event = %d> --> nextState = %d\n", pTrafficAdmCtrl->currentState[acID], event, nextState); 321 322 status = fsm_Event(pTrafficAdmCtrl->pTrafficAdmCtrlSm, &pTrafficAdmCtrl->currentState[acID], event, pData); 323 324 return(status); 325 } 326 327 328 /************************************************************************ 329 * state machine functions * 330 ************************************************************************/ 331 /************************************************************************ 332 * trafficAdmCtrl_smStart * 333 ************************************************************************ 334 DESCRIPTION: the action function when event start ocuured on idle state 335 performs the following: 336 - send admision requestReset 337 - start timer for the response. 338 339 INPUT: fsmTSpecInfo - parameters for the request 340 341 OUTPUT: 342 343 RETURN: TI_OK on success, TI_NOK otherwise 344 ************************************************************************/ 345 346 TI_STATUS trafficAdmCtrl_smStart(fsmTSpecInfo_t *fsmTSpecInfo) 347 { 348 TI_STATUS status; 349 trafficAdmCtrl_t *pTrafficAdmCtrl; 350 tspecInfo_t *pTSpecInfo; 351 352 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 353 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 354 355 /* send adm request frame */ 356 status = trafficAdmCtrl_sendAdmissionReq(pTrafficAdmCtrl, pTSpecInfo); 357 if(status != TI_OK) 358 return status; 359 360 /* init timer */ 361 trafficAdmCtrl_startTimer(pTrafficAdmCtrl, pTSpecInfo->AC); 362 363 return TI_OK; 364 } 365 /************************************************************************ 366 * trafficAdmCtrl_smWaitStop * 367 ************************************************************************ 368 DESCRIPTION: the action function when event stop ocuured on wait state 369 performs the following: 370 - stop timer. 371 372 INPUT: fsmTSpecInfo - parameters of the request 373 374 OUTPUT: 375 376 RETURN: TI_OK on success, TI_NOK otherwise 377 ************************************************************************/ 378 379 TI_STATUS trafficAdmCtrl_smWaitStop(fsmTSpecInfo_t *fsmTSpecInfo) 380 { 381 trafficAdmCtrl_t *pTrafficAdmCtrl; 382 tspecInfo_t *pTSpecInfo; 383 384 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 385 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 386 387 /* stop timer */ 388 trafficAdmCtrl_stopTimer(pTrafficAdmCtrl,fsmTSpecInfo->pTSpecInfo->AC); 389 390 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "TRAFFIC ADM CTRL - AC = %d, Stoped ..... \n", pTSpecInfo->AC); 391 392 393 return TI_OK; 394 } 395 /************************************************************************ 396 * trafficAdmCtrl_smWaitAccept * 397 ************************************************************************ 398 DESCRIPTION: the action function when event accept ocuured on wait state 399 performs the following: 400 - update the Qos Mngr of the status and the parameters 401 402 INPUT: fsmTSpecInfo - parameters of the response 403 404 OUTPUT: 405 406 RETURN: TI_OK on success, TI_NOK otherwise 407 ************************************************************************/ 408 409 TI_STATUS trafficAdmCtrl_smWaitAccept(fsmTSpecInfo_t *fsmTSpecInfo) 410 { 411 trafficAdmCtrl_t *pTrafficAdmCtrl; 412 tspecInfo_t *pTSpecInfo; 413 414 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 415 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 416 417 /* update the QosMngr */ 418 qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, pTSpecInfo->AC, pTSpecInfo, STATUS_TRAFFIC_ADM_REQUEST_ACCEPT); 419 420 return TI_OK; 421 } 422 /************************************************************************ 423 * trafficAdmCtrl_smWaitReject * 424 ************************************************************************ 425 DESCRIPTION: the action function when event reject ocuured on wait state 426 performs the following: 427 - update the Qos Mngr of the status and the parameters 428 429 INPUT: fsmTSpecInfo - parameters of the response 430 431 OUTPUT: 432 433 RETURN: TI_OK on success, TI_NOK otherwise 434 ************************************************************************/ 435 TI_STATUS trafficAdmCtrl_smWaitReject(fsmTSpecInfo_t *fsmTSpecInfo) 436 { 437 trafficAdmCtrl_t *pTrafficAdmCtrl; 438 tspecInfo_t *pTSpecInfo; 439 440 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 441 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 442 443 /* update the QosMngr */ 444 qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, pTSpecInfo->AC, pTSpecInfo, STATUS_TRAFFIC_ADM_REQUEST_REJECT); 445 446 return TI_OK; 447 } 448 /************************************************************************ 449 * trafficAdmCtrl_smWaitTimeout * 450 ************************************************************************ 451 DESCRIPTION: the action function when event timeout ocuured on wait state 452 performs the following: 453 - update the Qos Mngr of the status and the parameters 454 455 INPUT: fsmTSpecInfo - parameters of the request 456 457 OUTPUT: 458 459 RETURN: TI_OK on success, TI_NOK otherwise 460 ************************************************************************/ 461 462 TI_STATUS trafficAdmCtrl_smWaitTimeout(fsmTSpecInfo_t *fsmTSpecInfo) 463 { 464 trafficAdmCtrl_t *pTrafficAdmCtrl; 465 466 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 467 468 /* update the QosMngr */ 469 qosMngr_setAdmissionInfo(pTrafficAdmCtrl->hQosMngr, fsmTSpecInfo->acID, NULL, STATUS_TRAFFIC_ADM_REQUEST_TIMEOUT); 470 471 return TI_OK; 472 } 473 /************************************************************************ 474 * trafficAdmCtrl_smActionUnexpected * 475 ************************************************************************ 476 DESCRIPTION: 477 INPUT: fsmTSpecInfo - tspec parameters 478 479 OUTPUT: 480 481 RETURN: TI_OK on success, TI_NOK otherwise 482 ************************************************************************/ 483 484 TI_STATUS trafficAdmCtrl_smActionUnexpected(fsmTSpecInfo_t *fsmTSpecInfo) 485 { 486 trafficAdmCtrl_t *pTrafficAdmCtrl; 487 488 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 489 490 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, "TRAFFIC ADM CTRL - AC = %d, ActionUnexpected ..... \n", fsmTSpecInfo->acID); 491 492 return TI_OK; 493 } 494 495 /************************************************************************ 496 * trafficAdmCtrl_smActionUnexpectedTspecResponse * 497 ************************************************************************ 498 DESCRIPTION: 499 INPUT: fsmTSpecInfo - tspec parameters 500 OUTPUT: 501 RETURN: TI_OK on success, TI_NOK otherwise 502 ************************************************************************/ 503 504 TI_STATUS trafficAdmCtrl_smActionUnexpectedTspecResponse(fsmTSpecInfo_t *fsmTSpecInfo) 505 { 506 trafficAdmCtrl_t *pTrafficAdmCtrl; 507 tspecInfo_t *pTSpecInfo; 508 509 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 510 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 511 512 /* Send event to user application - how come TSPEC response arrives without request ? */ 513 qosMngr_sendUnexpectedTSPECResponseEvent (pTrafficAdmCtrl->hQosMngr,pTSpecInfo); 514 515 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_WARNING, "TRAFFIC ADM CTRL - AC = %d, ActionUnexpected ..... \n", fsmTSpecInfo->acID); 516 517 return TI_OK; 518 } 519 520 521 /************************************************************************ 522 * trafficAdmCtrl_smActionNop * 523 ************************************************************************ 524 DESCRIPTION: 525 INPUT: fsmTSpecInfo - tspec parameters 526 527 OUTPUT: 528 529 RETURN: TI_OK on success, TI_NOK otherwise 530 ************************************************************************/ 531 532 TI_STATUS trafficAdmCtrl_smActionNop(fsmTSpecInfo_t *fsmTSpecInfo) 533 { 534 trafficAdmCtrl_t *pTrafficAdmCtrl; 535 tspecInfo_t *pTSpecInfo; 536 537 pTrafficAdmCtrl = (trafficAdmCtrl_t*)(fsmTSpecInfo->hTrafficAdmCtrl); 538 pTSpecInfo = fsmTSpecInfo->pTSpecInfo; 539 540 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "TRAFFIC ADM CTRL - AC = %d, Action NOP..... \n", pTSpecInfo->AC); 541 542 return TI_OK; 543 } 544 /************************************************************************ 545 * API FUNCTIONS * 546 ************************************************************************ 547 ************************************************************************/ 548 549 /************************************************************************ 550 * trafficAdmCtrl_startAdmRequest * 551 ************************************************************************ 552 DESCRIPTION: start TSPEC signaling 553 554 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 555 pTSpecInfo - the TSPEC parameters 556 557 OUTPUT: 558 559 RETURN: TI_OK on success, TI_NOK otherwise 560 561 ************************************************************************/ 562 563 TI_STATUS trafficAdmCtrl_startAdmRequest(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo) 564 { 565 TI_STATUS status; 566 fsmTSpecInfo_t fsmTSpecInfo; 567 568 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 569 570 if (pTrafficAdmCtrl == NULL) 571 return TI_NOK; 572 573 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 574 fsmTSpecInfo.pTSpecInfo = pTSpecInfo; 575 fsmTSpecInfo.acID = pTSpecInfo->AC; 576 577 /* send event START to SM */ 578 status = trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_START, &fsmTSpecInfo); 579 580 return status; 581 582 } 583 /************************************************************************ 584 * trafficAdmCtrl_stopAdmRequest * 585 ************************************************************************ 586 DESCRIPTION: stop specific tspec signaling 587 588 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 589 acID - the AC of the tspec to stop 590 591 OUTPUT: 592 593 RETURN: TI_OK on success, TI_NOK otherwise 594 595 ************************************************************************/ 596 597 TI_STATUS trafficAdmCtrl_stopAdmRequest(TI_HANDLE hTrafficAdmCtrl, TI_UINT8 acID) 598 { 599 TI_STATUS status; 600 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 601 602 tspecInfo_t pTSpecInfo; 603 fsmTSpecInfo_t fsmTSpecInfo; 604 605 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 606 fsmTSpecInfo.pTSpecInfo = &pTSpecInfo; 607 608 fsmTSpecInfo.pTSpecInfo->AC = (EAcTrfcType)acID; 609 fsmTSpecInfo.acID = acID; 610 611 /* send event STOP to SM */ 612 status = trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_STOP, &fsmTSpecInfo); 613 614 return status; 615 616 } 617 /************************************************************************ 618 * trafficAdmCtrl_stop * 619 ************************************************************************ 620 DESCRIPTION: stop all tspecs and reset SM 621 called on disconnect 622 623 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 624 625 OUTPUT: 626 627 RETURN: TI_OK on success, TI_NOK otherwise 628 629 ************************************************************************/ 630 TI_STATUS trafficAdmCtrl_stop(TI_HANDLE hTrafficAdmCtrl) 631 { 632 TI_UINT32 uAcId; 633 634 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 635 636 tspecInfo_t pTSpecInfo; 637 fsmTSpecInfo_t fsmTSpecInfo; 638 639 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 640 fsmTSpecInfo.pTSpecInfo = &pTSpecInfo; 641 642 /* clean all AC SM */ 643 for (uAcId = 0; uAcId < MAX_NUM_OF_AC; uAcId++) 644 { 645 fsmTSpecInfo.pTSpecInfo->AC = (EAcTrfcType)uAcId; 646 fsmTSpecInfo.acID = uAcId; 647 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_STOP, &fsmTSpecInfo); 648 649 pTrafficAdmCtrl->dialogToken[uAcId] = 0; 650 } 651 652 pTrafficAdmCtrl->dialogTokenCounter = INITIAL_DIALOG_TOKEN; 653 654 return TI_OK; 655 } 656 657 /************************************************************************ 658 * trafficAdmCtrl_recv * 659 ************************************************************************ 660 DESCRIPTION: 661 662 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 663 664 OUTPUT: 665 666 RETURN: TI_OK on success, TI_NOK otherwise 667 668 ************************************************************************/ 669 670 TI_STATUS trafficAdmCtrl_recv(TI_HANDLE hTrafficAdmCtrl, TI_UINT8* pData, TI_UINT8 action) 671 { 672 TI_STATUS status = TI_OK; 673 TI_UINT8 statusCode; 674 TI_UINT8 dialogToken; 675 TI_UINT8 tacID; 676 tspecInfo_t tspecInfo; 677 fsmTSpecInfo_t fsmTSpecInfo; 678 679 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 680 681 if (action == ADDTS_RESPONSE_ACTION) 682 { 683 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "action = 1 - ADDTS RESPONSE ACTION........!! \n"); 684 685 /* parsing the dialog token */ 686 dialogToken = *pData; 687 pData++; 688 689 /* in WME status code is 1 byte, in WSM is 2 bytes */ 690 statusCode = *pData; 691 pData++; 692 693 tspecInfo.statusCode = statusCode; 694 695 TRACE2(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "dialogToken = %d , statusCode = %d \n",dialogToken, statusCode); 696 697 trafficAdmCtrl_parseTspecIE(&tspecInfo, pData); 698 699 if (trafficAdmCtrl_tokenToAc (pTrafficAdmCtrl, dialogToken, &tacID) == TI_NOK) 700 { 701 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_WARNING, "dialog token Not found, dialogToken = %d , \n",dialogToken); 702 703 qosMngr_sendUnexpectedTSPECResponseEvent(pTrafficAdmCtrl->hQosMngr, &tspecInfo); 704 705 return TI_NOK; 706 } 707 708 /* validate dialog token matching */ 709 if(pTrafficAdmCtrl->dialogToken[tspecInfo.AC] != dialogToken) 710 { 711 TRACE2(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_WARNING, "dialog token mismatch, dialogToken = %d , acID = %d \n",dialogToken, tspecInfo.AC); 712 713 qosMngr_sendUnexpectedTSPECResponseEvent(pTrafficAdmCtrl->hQosMngr, &tspecInfo); 714 715 return TI_NOK; 716 } 717 718 /* Stop the relevant Timer */ 719 trafficAdmCtrl_stopTimer(pTrafficAdmCtrl, tspecInfo.AC); 720 721 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 722 fsmTSpecInfo.pTSpecInfo = &tspecInfo; 723 724 fsmTSpecInfo.acID = tspecInfo.AC; 725 726 if(statusCode != ADDTS_STATUS_CODE_SUCCESS) 727 { 728 /* admission reject */ 729 /********************/ 730 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "***** admCtrlQos_recv: admission reject [ statusCode = %d ]\n",statusCode); 731 732 733 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "ADDTS Response (reject) userPriority = %d , \n", tspecInfo.userPriority); 734 735 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_REJECT, &fsmTSpecInfo); 736 737 } 738 else 739 { 740 /* admission accept */ 741 /********************/ 742 743 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "***** admCtrlQos_recv: admission accept [ statusCode = %d ]\n",statusCode); 744 745 746 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "ADDTS Response (accepted) userPriority = %d , \n", tspecInfo.userPriority); 747 748 TRACE2(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "mediumTime = %d , surplusBandwidthAllowance = %d \n", tspecInfo.mediumTime, tspecInfo.surplausBwAllowance); 749 750 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_ACCEPT, &fsmTSpecInfo); 751 } 752 } 753 else 754 { 755 status = TI_NOK; 756 TRACE1(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "trafficAdmCtrl_recv: unknown action code = %d , \n",action); 757 758 } 759 return status; 760 } 761 762 763 /************************************************************************ 764 * trafficAdmCtrl_sendDeltsFrame * 765 ************************************************************************ 766 DESCRIPTION: 767 768 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 769 770 OUTPUT: 771 772 RETURN: TI_OK on success, TI_NOK otherwise 773 774 ************************************************************************/ 775 TI_STATUS trafficAdmCtrl_sendDeltsFrame(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo, TI_UINT8 reasonCode) 776 { 777 TI_STATUS status = TI_OK; 778 TTxCtrlBlk *pPktCtrlBlk; 779 TI_UINT8 *pPktBuffer; 780 TI_UINT32 totalLen = 0; 781 tsInfo_t tsInfo; 782 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t *)hTrafficAdmCtrl; 783 784 785 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "admCtrlQos_sendDeltsFrame: Enter....!! \n"); 786 787 /* Allocate a TxCtrlBlk and data buffer (large enough for the max packet) */ 788 pPktCtrlBlk = TWD_txCtrlBlk_Alloc (pTrafficAdmCtrl->hTWD); 789 pPktBuffer = txCtrl_AllocPacketBuffer (pTrafficAdmCtrl->hTxCtrl, pPktCtrlBlk, 2000); 790 if (pPktBuffer == NULL) 791 { 792 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR , ": No memory\n"); 793 TWD_txCtrlBlk_Free (pTrafficAdmCtrl->hTWD, pPktCtrlBlk); 794 return TI_NOK; 795 } 796 797 status = trafficAdmCtrl_buildFrameHeader (pTrafficAdmCtrl, pPktCtrlBlk); 798 if (status != TI_OK) 799 { 800 TWD_txCtrlBlk_Free (pTrafficAdmCtrl->hTWD, pPktCtrlBlk); 801 return TI_NOK; 802 } 803 804 *(pPktBuffer + totalLen) = WME_CATAGORY_QOS; /* CATEGORY_QOS in WME = 17*/ 805 totalLen++; 806 *(pPktBuffer + totalLen) = DELTS_ACTION; /* DELTS ACTION */ 807 totalLen++; 808 *(pPktBuffer + totalLen) = 0; /* DIALOG_TOKEN is 0 in DELTS */ 809 totalLen++; 810 *(pPktBuffer + totalLen) = 0; /* STATUS CODE is 0 in DELTS */ 811 totalLen++; 812 813 /* 814 * Build tsInfo fields 815 */ 816 817 tsInfo.tsInfoArr[0] = 0; 818 tsInfo.tsInfoArr[1] = 0; 819 tsInfo.tsInfoArr[2] = 0; 820 821 tsInfo.tsInfoArr[0] |= ( (pTSpecInfo->userPriority) << TSID_SHIFT); 822 823 tsInfo.tsInfoArr[0] |= (BI_DIRECTIONAL << DIRECTION_SHIFT); /* bidirectional */ 824 tsInfo.tsInfoArr[0] |= (TS_INFO_0_ACCESS_POLICY_EDCA << ACCESS_POLICY_SHIFT); /* EDCA */ 825 826 tsInfo.tsInfoArr[1] |= (0 << AGGREGATION_SHIFT); 827 828 tsInfo.tsInfoArr[1] |= (pTSpecInfo->UPSDFlag << APSD_SHIFT); 829 830 tsInfo.tsInfoArr[1] |= (pTSpecInfo->userPriority << USER_PRIORITY_SHIFT); 831 tsInfo.tsInfoArr[1] |= (NORMAL_ACKNOWLEDGEMENT << TSINFO_ACK_POLICY_SHIFT); 832 833 tsInfo.tsInfoArr[2] |= (NO_SCHEDULE << SCHEDULE_SHIFT); 834 835 /* 836 * Build TSpec IE for DELTS 837 */ 838 839 *(pPktBuffer + totalLen ) = WME_TSPEC_IE_ID; 840 *(pPktBuffer + totalLen + 1) = WME_TSPEC_IE_TSINFO_LEN; 841 842 *(pPktBuffer + totalLen + 2) = 0x00; 843 *(pPktBuffer + totalLen + 3) = 0x50; 844 *(pPktBuffer + totalLen + 4) = 0xf2; 845 *(pPktBuffer + totalLen + 5) = WME_TSPEC_IE_OUI_TYPE; 846 *(pPktBuffer + totalLen + 6) = WME_TSPEC_IE_OUI_SUB_TYPE; 847 *(pPktBuffer + totalLen + 7) = WME_TSPEC_IE_VERSION; 848 849 *(pPktBuffer + totalLen + 8) = tsInfo.tsInfoArr[0]; 850 *(pPktBuffer + totalLen + 9) = tsInfo.tsInfoArr[1]; 851 *(pPktBuffer + totalLen +10) = tsInfo.tsInfoArr[2]; 852 853 totalLen += WME_TSPEC_IE_TSINFO_LEN + 2; 854 855 /* Update packet parameters (start-time, pkt-type and BDL) */ 856 pPktCtrlBlk->tTxDescriptor.startTime = os_timeStampMs (pTrafficAdmCtrl->hOs); 857 pPktCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_MGMT; 858 BUILD_TX_TWO_BUF_PKT_BDL (pPktCtrlBlk, pPktCtrlBlk->aPktHdr, WLAN_HDR_LEN, pPktBuffer, totalLen) 859 860 /* Enqueue packet in the mgmt-queues and run the scheduler. */ 861 status = txMgmtQ_Xmit (pTrafficAdmCtrl->hTxMgmtQ, pPktCtrlBlk, TI_FALSE); 862 863 return TI_OK; 864 } 865 866 867 /************************************************************************ 868 * INTERNAL FUNCTIONS * 869 ************************************************************************/ 870 /************************************************************************ 871 * trafficAdmCtrl_startTimer * 872 ************************************************************************ 873 DESCRIPTION: start a specific ac timer 874 875 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 876 acID - the AC of the timer 877 878 OUTPUT: 879 880 RETURN: TI_OK on success, TI_NOK otherwise 881 882 ************************************************************************/ 883 884 TI_STATUS trafficAdmCtrl_startTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, TI_UINT8 acID) 885 { 886 TTimerCbFunc fTimerExpiryFunc = NULL; 887 888 if (pTrafficAdmCtrl == NULL) 889 { 890 return TI_NOK; 891 } 892 893 switch (acID) 894 { 895 case QOS_AC_BE: fTimerExpiryFunc = trafficAdmCtrl_timeoutAcBE; break; 896 case QOS_AC_BK: fTimerExpiryFunc = trafficAdmCtrl_timeoutAcBK; break; 897 case QOS_AC_VI: fTimerExpiryFunc = trafficAdmCtrl_timeoutAcVI; break; 898 case QOS_AC_VO: fTimerExpiryFunc = trafficAdmCtrl_timeoutAcVO; break; 899 } 900 901 tmr_StartTimer (pTrafficAdmCtrl->hAdmCtrlTimer[acID], 902 fTimerExpiryFunc, 903 (TI_HANDLE)pTrafficAdmCtrl, 904 pTrafficAdmCtrl->timeout, 905 TI_FALSE); 906 907 return TI_OK; 908 } 909 /************************************************************************ 910 * trafficAdmCtrl_stopTimer * 911 ************************************************************************ 912 DESCRIPTION: stop a specific ac timer 913 914 INPUT: pTrafficAdmCtrl - trafficAdmCtr handle. 915 acID - the AC of the timer 916 917 OUTPUT: 918 919 RETURN: TI_OK on success, TI_NOK otherwise 920 921 ************************************************************************/ 922 923 TI_STATUS trafficAdmCtrl_stopTimer(trafficAdmCtrl_t* pTrafficAdmCtrl, TI_UINT8 acID) 924 { 925 if (pTrafficAdmCtrl == NULL) 926 return TI_NOK; 927 928 tmr_StopTimer (pTrafficAdmCtrl->hAdmCtrlTimer[acID]); 929 930 return TI_OK; 931 } 932 933 /************************************************************************ 934 * AC timers functionc * 935 ************************************************************************/ 936 937 /* QOS_AC_BE */ 938 /*********/ 939 void trafficAdmCtrl_timeoutAcBE (TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured) 940 { 941 fsmTSpecInfo_t fsmTSpecInfo; 942 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 943 944 945 /* FSM Tspec Info Structure */ 946 fsmTSpecInfo.acID = QOS_AC_BE; 947 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 948 fsmTSpecInfo.pTSpecInfo = NULL; 949 950 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo); 951 } 952 953 /* QOS_AC_BK */ 954 /*********/ 955 void trafficAdmCtrl_timeoutAcBK(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured) 956 { 957 fsmTSpecInfo_t fsmTSpecInfo; 958 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 959 960 961 /* FSM Tspec Info Structure */ 962 fsmTSpecInfo.acID = QOS_AC_BK; 963 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 964 fsmTSpecInfo.pTSpecInfo = NULL; 965 966 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo); 967 968 } 969 /* QOS_AC_VI */ 970 /*********/ 971 void trafficAdmCtrl_timeoutAcVI(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured) 972 { 973 fsmTSpecInfo_t fsmTSpecInfo; 974 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 975 976 977 /* FSM Tspec Info Structure */ 978 fsmTSpecInfo.acID = QOS_AC_VI; 979 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 980 fsmTSpecInfo.pTSpecInfo = NULL; 981 982 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo); 983 984 } 985 /* QOS_AC_VO */ 986 /*********/ 987 void trafficAdmCtrl_timeoutAcVO(TI_HANDLE hTrafficAdmCtrl, TI_BOOL bTwdInitOccured) 988 { 989 fsmTSpecInfo_t fsmTSpecInfo; 990 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 991 992 993 /* FSM Tspec Info Structure */ 994 fsmTSpecInfo.acID = QOS_AC_VO; 995 fsmTSpecInfo.hTrafficAdmCtrl = hTrafficAdmCtrl; 996 fsmTSpecInfo.pTSpecInfo = NULL; 997 998 trafficAdmCtrl_smEvent(pTrafficAdmCtrl, TRAFFIC_ADM_CTRL_SM_EVENT_TIMEOUT, &fsmTSpecInfo); 999 1000 } 1001 1002 1003 static TI_STATUS trafficAdmCtrl_tokenToAc (TI_HANDLE hTrafficAdmCtrl, TI_UINT8 token, TI_UINT8 *acID) 1004 { 1005 TI_UINT8 idx; 1006 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 1007 1008 for (idx=0; idx<MAX_NUM_OF_AC; idx++) 1009 { 1010 if (pTrafficAdmCtrl->dialogToken[idx] == token) 1011 { 1012 *acID = idx; 1013 return (TI_OK); 1014 } 1015 } 1016 1017 return (TI_NOK); 1018 1019 } 1020 1021 1022 1023 /************************************************************************ 1024 * trafficAdmCtrl_buildFrameHeader * 1025 ************************************************************************ 1026 DESCRIPTION: build frame header 1027 1028 INPUT: 1029 1030 OUTPUT: 1031 1032 RETURN: TI_OK on success, TI_NOK otherwise 1033 ************************************************************************/ 1034 TI_STATUS trafficAdmCtrl_buildFrameHeader(trafficAdmCtrl_t *pTrafficAdmCtrl, TTxCtrlBlk *pPktCtrlBlk) 1035 { 1036 TI_STATUS status; 1037 TMacAddr daBssid, saBssid; 1038 dot11_mgmtHeader_t *pdot11Header; 1039 ScanBssType_e currBssType; 1040 TMacAddr currBssId; 1041 1042 pdot11Header = (dot11_mgmtHeader_t *)(pPktCtrlBlk->aPktHdr); 1043 1044 /* Get the Destination MAC address */ 1045 status = ctrlData_getParamBssid(pTrafficAdmCtrl->hCtrlData, CTRL_DATA_CURRENT_BSSID_PARAM, daBssid); 1046 if (status != TI_OK) 1047 { 1048 return TI_NOK; 1049 } 1050 1051 /* Get the Source MAC address */ 1052 status = ctrlData_getParamBssid(pTrafficAdmCtrl->hCtrlData, CTRL_DATA_MAC_ADDRESS, saBssid); 1053 if (status != TI_OK) 1054 { 1055 return TI_NOK; 1056 } 1057 1058 /* receive BssId and Bss Type from control module */ 1059 ctrlData_getCurrBssTypeAndCurrBssId(pTrafficAdmCtrl->hCtrlData, &currBssId, &currBssType); 1060 if (currBssType != BSS_INFRASTRUCTURE) 1061 { 1062 /* report failure but don't stop... */ 1063 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR, "trafficAdmCtrl_buildFrameHeader: Error !! currBssType = BSS_INFRASTRUCTURE \n"); 1064 1065 return TI_NOK; 1066 } 1067 /* infrastructure BSS */ 1068 1069 /* copy BSSID */ 1070 MAC_COPY (pdot11Header->BSSID, currBssId); 1071 /* copy source mac address */ 1072 MAC_COPY (pdot11Header->SA, saBssid); 1073 /* copy destination mac address */ 1074 MAC_COPY (pdot11Header->DA, daBssid); 1075 1076 /* set frame ctrl to mgmt action frame an to DS */ 1077 pdot11Header->fc = ENDIAN_HANDLE_WORD(DOT11_FC_ACTION | DOT11_FC_TO_DS); 1078 1079 return TI_OK; 1080 } 1081 1082 /************************************************************************ 1083 * trafficAdmCtrl_sendAdmissionReq * 1084 ************************************************************************ 1085 DESCRIPTION: send admision request frame 1086 1087 INPUT: hTrafficAdmCtrl - Qos Manager handle. 1088 pTSpecInfo - tspec parameters 1089 1090 OUTPUT: 1091 1092 RETURN: TI_OK on success, TI_NOK otherwise 1093 ************************************************************************/ 1094 1095 TI_STATUS trafficAdmCtrl_sendAdmissionReq(TI_HANDLE hTrafficAdmCtrl, tspecInfo_t *pTSpecInfo) 1096 { 1097 TI_STATUS status = TI_OK; 1098 TTxCtrlBlk *pPktCtrlBlk; 1099 TI_UINT8 *pPktBuffer; 1100 TI_UINT32 len; 1101 TI_UINT32 totalLen = 0; 1102 trafficAdmCtrl_t *pTrafficAdmCtrl = (trafficAdmCtrl_t*)hTrafficAdmCtrl; 1103 1104 1105 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "admCtrlQos_smAdmissionReq: Enter....!! \n"); 1106 1107 /* Allocate a TxCtrlBlk and data buffer (large enough for the max packet) */ 1108 pPktCtrlBlk = TWD_txCtrlBlk_Alloc (pTrafficAdmCtrl->hTWD); 1109 pPktBuffer = txCtrl_AllocPacketBuffer (pTrafficAdmCtrl->hTxCtrl, pPktCtrlBlk, 2000); 1110 if (pPktBuffer == NULL) 1111 { 1112 TRACE0(pTrafficAdmCtrl->hReport, REPORT_SEVERITY_ERROR , ": No memory\n"); 1113 TWD_txCtrlBlk_Free (pTrafficAdmCtrl->hTWD, pPktCtrlBlk); 1114 return TI_NOK; 1115 } 1116 1117 status = trafficAdmCtrl_buildFrameHeader (pTrafficAdmCtrl, pPktCtrlBlk); 1118 if (status != TI_OK) 1119 { 1120 TWD_txCtrlBlk_Free (pTrafficAdmCtrl->hTWD, pPktCtrlBlk); 1121 return TI_NOK; 1122 } 1123 1124 *(pPktBuffer + totalLen) = WME_CATAGORY_QOS; /* CATEGORY_QOS WME = 17*/ 1125 totalLen++; 1126 *(pPktBuffer + totalLen) = ADDTS_REQUEST_ACTION; /* ADDTS request ACTION */ 1127 totalLen++; 1128 1129 /* storing the dialog token for response validation */ 1130 pTrafficAdmCtrl->dialogToken[pTSpecInfo->AC] = pTrafficAdmCtrl->dialogTokenCounter++; /* DIALOG_TOKEN */ 1131 *(pPktBuffer + totalLen) = pTrafficAdmCtrl->dialogToken[pTSpecInfo->AC]; 1132 totalLen++; 1133 1134 *(pPktBuffer + totalLen) = 0; /* STATUS CODE is 0 for ADDTS */ 1135 totalLen++; 1136 1137 trafficAdmCtrl_buildTSPec (pTrafficAdmCtrl, pTSpecInfo, pPktBuffer + totalLen, (TI_UINT32*)&len); 1138 totalLen += len; 1139 1140 /* Update packet parameters (start-time, length, pkt-type) */ 1141 pPktCtrlBlk->tTxDescriptor.startTime = os_timeStampMs (pTrafficAdmCtrl->hOs); 1142 pPktCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_MGMT; 1143 BUILD_TX_TWO_BUF_PKT_BDL (pPktCtrlBlk, pPktCtrlBlk->aPktHdr, WLAN_HDR_LEN, pPktBuffer, totalLen) 1144 1145 /* Enqueue packet in the mgmt-queues and run the scheduler. */ 1146 status = txMgmtQ_Xmit (pTrafficAdmCtrl->hTxMgmtQ, pPktCtrlBlk, TI_FALSE); 1147 1148 return TI_OK; 1149 } 1150 /************************************************************************ 1151 * trafficAdmCtrl_buildTSPec * 1152 ************************************************************************ 1153 DESCRIPTION: build a tspec according to the tspec parameters 1154 1155 INPUT: hTrafficAdmCtrl - Qos Manager handle. 1156 pTSpecInfo - tspec parameters 1157 1158 OUTPUT: pPktBuffer - the Tspec IE to send 1159 len - the tspec frame len 1160 1161 RETURN: TI_OK on success, TI_NOK otherwise 1162 ************************************************************************/ 1163 1164 void trafficAdmCtrl_buildTSPec(trafficAdmCtrl_t *pTrafficAdmCtrl, 1165 tspecInfo_t *pTSpecInfo, 1166 TI_UINT8 *pDataBuf, 1167 TI_UINT32 *len) 1168 { 1169 tsInfo_t tsInfo; 1170 TI_UINT16 nominalMSDUSize, maxMSDUSize; 1171 TI_UINT32 suspensionInterval = 0; /* disable */ 1172 1173 1174 os_memoryZero(pTrafficAdmCtrl->hOs, (void *)pDataBuf, WME_TSPEC_IE_LEN + 2); 1175 1176 *pDataBuf = WME_TSPEC_IE_ID; 1177 *(pDataBuf + 1) = WME_TSPEC_IE_LEN; 1178 1179 *(pDataBuf + 2) = 0x00; 1180 *(pDataBuf + 3) = 0x50; 1181 *(pDataBuf + 4) = 0xf2; 1182 *(pDataBuf + 5) = WME_TSPEC_IE_OUI_TYPE; 1183 *(pDataBuf + 6) = WME_TSPEC_IE_OUI_SUB_TYPE; 1184 *(pDataBuf + 7) = WME_TSPEC_IE_VERSION; 1185 1186 /* 1187 * Build tsInfo fields 1188 */ 1189 1190 tsInfo.tsInfoArr[0] = 0; 1191 tsInfo.tsInfoArr[1] = 0; 1192 tsInfo.tsInfoArr[2] = 0; 1193 1194 tsInfo.tsInfoArr[0] |= ( (pTSpecInfo->userPriority) << TSID_SHIFT); 1195 tsInfo.tsInfoArr[0] |= (pTSpecInfo->streamDirection << DIRECTION_SHIFT); /* bidirectional */ 1196 1197 tsInfo.tsInfoArr[0] |= (TS_INFO_0_ACCESS_POLICY_EDCA << ACCESS_POLICY_SHIFT); /* EDCA */ 1198 1199 tsInfo.tsInfoArr[1] |= (0 << AGGREGATION_SHIFT); 1200 1201 tsInfo.tsInfoArr[1] |= (pTSpecInfo->UPSDFlag << APSD_SHIFT); 1202 1203 tsInfo.tsInfoArr[1] |= (pTSpecInfo->userPriority << USER_PRIORITY_SHIFT); 1204 tsInfo.tsInfoArr[1] |= (NORMAL_ACKNOWLEDGEMENT << TSINFO_ACK_POLICY_SHIFT); 1205 1206 tsInfo.tsInfoArr[2] |= (NO_SCHEDULE << SCHEDULE_SHIFT); 1207 1208 *(pDataBuf + 8) = tsInfo.tsInfoArr[0]; 1209 *(pDataBuf + 9) = tsInfo.tsInfoArr[1]; 1210 *(pDataBuf +10) = tsInfo.tsInfoArr[2]; 1211 1212 pDataBuf += 11; /* Progress the data pointer to the next IE parameters. */ 1213 1214 /* 1215 * Set all remained parameters 1216 */ 1217 1218 nominalMSDUSize = pTSpecInfo->nominalMsduSize; 1219 if (pTrafficAdmCtrl->useFixedMsduSize) 1220 nominalMSDUSize |= FIX_MSDU_SIZE; 1221 1222 maxMSDUSize = (nominalMSDUSize & (~FIX_MSDU_SIZE)); 1223 1224 COPY_WLAN_WORD(pDataBuf, &nominalMSDUSize); /* Nominal-MSDU-size. */ 1225 COPY_WLAN_WORD(pDataBuf + 2, &maxMSDUSize); /* Maximum-MSDU-size. */ 1226 COPY_WLAN_LONG(pDataBuf + 4, &pTSpecInfo->uMinimumServiceInterval); /* Minimum service interval */ 1227 COPY_WLAN_LONG(pDataBuf + 8, &pTSpecInfo->uMaximumServiceInterval); /* Maximum service interval */ 1228 COPY_WLAN_LONG(pDataBuf + 16, &suspensionInterval); 1229 COPY_WLAN_LONG(pDataBuf + 24, &pTSpecInfo->meanDataRate); /* Minimum-data-rate. */ 1230 COPY_WLAN_LONG(pDataBuf + 28, &pTSpecInfo->meanDataRate); /* Mean-data-rate. */ 1231 COPY_WLAN_LONG(pDataBuf + 32, &pTSpecInfo->meanDataRate); /* Peak-data-rate. */ 1232 COPY_WLAN_LONG(pDataBuf + 44, &pTSpecInfo->minimumPHYRate); 1233 COPY_WLAN_WORD(pDataBuf + 48, &pTSpecInfo->surplausBwAllowance); 1234 1235 *len = WME_TSPEC_IE_LEN + 2; 1236 } 1237 1238 1239 1240 /************************************************************************ 1241 * trafficAdmCtrl_parseTspecIE * 1242 ************************************************************************ 1243 DESCRIPTION: parses a tspec IE according to the tspec parameters 1244 1245 INPUT: pData - tspec IE from received frame 1246 1247 OUTPUT: pTSpecInfo - parsed tspec parameters 1248 1249 RETURN: None 1250 ************************************************************************/ 1251 void trafficAdmCtrl_parseTspecIE(tspecInfo_t *pTSpecInfo, TI_UINT8 *pData) 1252 { 1253 tsInfo_t tsInfo; 1254 TI_UINT8 userPriority; 1255 TI_UINT8 acID; 1256 TI_UINT8 tid; 1257 TI_UINT8 direction; 1258 TI_UINT8 APSDbit; 1259 1260 pData += 8; /* Skip the WME_TSPEC_IE header */ 1261 1262 /* Get the TS-Info (3 bytes) and parse its fields */ 1263 tsInfo.tsInfoArr[0] = *pData; 1264 tsInfo.tsInfoArr[1] = *(pData + 1); 1265 tsInfo.tsInfoArr[2] = *(pData + 2); 1266 pData += 3; 1267 1268 userPriority = (((tsInfo.tsInfoArr[1]) & TS_INFO_1_USER_PRIORITY_MASK) >> USER_PRIORITY_SHIFT); 1269 1270 acID = WMEQosTagToACTable[userPriority]; 1271 1272 tid = (((tsInfo.tsInfoArr[0]) & TS_INFO_0_TSID_MASK) >> TSID_SHIFT); 1273 APSDbit = (((tsInfo.tsInfoArr[1]) & TS_INFO_1_APSD_MASK) >> APSD_SHIFT); 1274 direction = (((tsInfo.tsInfoArr[0]) & TS_INFO_0_DIRECTION_MASK) >> DIRECTION_SHIFT); 1275 1276 1277 pTSpecInfo->AC = (EAcTrfcType)acID; 1278 pTSpecInfo->userPriority = userPriority; 1279 pTSpecInfo->UPSDFlag = APSDbit; 1280 pTSpecInfo->streamDirection = (EStreamDirection)direction; 1281 pTSpecInfo->tid = tid; 1282 1283 /* Get the other Tspec IE parameters (handle WLAN fram endianess if required) */ 1284 COPY_WLAN_WORD(&pTSpecInfo->nominalMsduSize, pData); 1285 COPY_WLAN_LONG(&pTSpecInfo->uMinimumServiceInterval, pData + 4); 1286 COPY_WLAN_LONG(&pTSpecInfo->uMaximumServiceInterval, pData + 8); 1287 COPY_WLAN_LONG(&pTSpecInfo->meanDataRate, pData + 28); 1288 COPY_WLAN_LONG(&pTSpecInfo->minimumPHYRate, pData + 44); 1289 COPY_WLAN_WORD(&pTSpecInfo->surplausBwAllowance, pData + 48); 1290 pTSpecInfo->surplausBwAllowance >>= SURPLUS_BANDWIDTH_ALLOW; /* Surplus is in 3 MSBits of TI_UINT16 */ 1291 COPY_WLAN_WORD(&pTSpecInfo->mediumTime, pData + 50); 1292 } 1293 1294 1295 1296 /************************************************************************* 1297 * * 1298 * DEBUG FUNCTIONS * 1299 * * 1300 *************************************************************************/ 1301 void trafficAdmCtrl_print(trafficAdmCtrl_t *pTrafficAdmCtr) 1302 { 1303 TI_UINT32 acID; 1304 1305 WLAN_OS_REPORT((" traffic Adm Ctrl \n")); 1306 WLAN_OS_REPORT(("-----------------------------------\n\n")); 1307 WLAN_OS_REPORT(("timeout = %d\n",pTrafficAdmCtr->timeout)); 1308 WLAN_OS_REPORT(("dialogTokenCounter = %d\n",pTrafficAdmCtr->dialogTokenCounter)); 1309 1310 for (acID = 0 ; acID < MAX_NUM_OF_AC ; acID++) 1311 { 1312 WLAN_OS_REPORT((" AC = %d \n",acID)); 1313 WLAN_OS_REPORT(("----------------------\n")); 1314 WLAN_OS_REPORT(("currentState = %d \n",pTrafficAdmCtr->currentState[acID])); 1315 WLAN_OS_REPORT(("dialogToken = %d \n",pTrafficAdmCtr->dialogToken[acID])); 1316 } 1317 } 1318 1319