| OLD | NEW |
| 1 //------------------------------------------------------------------------------ | 1 //------------------------------------------------------------------------------ |
| 2 // <copyright file="htc.c" company="Atheros"> | 2 // <copyright file="htc.c" company="Atheros"> |
| 3 // Copyright (c) 2007-2008 Atheros Corporation. All rights reserved. | 3 // Copyright (c) 2007-2010 Atheros Corporation. All rights reserved. |
| 4 // | 4 // |
| 5 // This program is free software; you can redistribute it and/or modify | |
| 6 // it under the terms of the GNU General Public License version 2 as | |
| 7 // published by the Free Software Foundation; | |
| 8 // | 5 // |
| 9 // Software distributed under the License is distributed on an "AS | 6 // Permission to use, copy, modify, and/or distribute this software for any |
| 10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | 7 // purpose with or without fee is hereby granted, provided that the above |
| 11 // implied. See the License for the specific language governing | 8 // copyright notice and this permission notice appear in all copies. |
| 12 // rights and limitations under the License. | 9 // |
| 10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 13 // | 17 // |
| 14 // | 18 // |
| 15 //------------------------------------------------------------------------------ | 19 //------------------------------------------------------------------------------ |
| 16 //============================================================================== | 20 //============================================================================== |
| 17 // Author(s): ="Atheros" | 21 // Author(s): ="Atheros" |
| 18 //============================================================================== | 22 //============================================================================== |
| 19 #include "htc_internal.h" | 23 #include "htc_internal.h" |
| 20 | 24 |
| 21 #ifdef DEBUG | 25 #ifdef ATH_DEBUG_MODULE |
| 22 static ATH_DEBUG_MASK_DESCRIPTION g_HTCDebugDescription[] = { | 26 static ATH_DEBUG_MASK_DESCRIPTION g_HTCDebugDescription[] = { |
| 23 { ATH_DEBUG_SEND , "Send"}, | 27 { ATH_DEBUG_SEND , "Send"}, |
| 24 { ATH_DEBUG_RECV , "Recv"}, | 28 { ATH_DEBUG_RECV , "Recv"}, |
| 25 { ATH_DEBUG_SYNC , "Sync"}, | 29 { ATH_DEBUG_SYNC , "Sync"}, |
| 26 { ATH_DEBUG_DUMP , "Dump Data (RX or TX)"}, | 30 { ATH_DEBUG_DUMP , "Dump Data (RX or TX)"}, |
| 27 { ATH_DEBUG_IRQ , "Interrupt Processing"} | 31 { ATH_DEBUG_IRQ , "Interrupt Processing"} |
| 28 }; | 32 }; |
| 29 | 33 |
| 30 ATH_DEBUG_INSTANTIATE_MODULE_VAR(htc, | 34 ATH_DEBUG_INSTANTIATE_MODULE_VAR(htc, |
| 31 "htc", | 35 "htc", |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 200 } |
| 197 | 201 |
| 198 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCCreate - Exit\n")); | 202 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCCreate - Exit\n")); |
| 199 | 203 |
| 200 return target; | 204 return target; |
| 201 } | 205 } |
| 202 | 206 |
| 203 void HTCDestroy(HTC_HANDLE HTCHandle) | 207 void HTCDestroy(HTC_HANDLE HTCHandle) |
| 204 { | 208 { |
| 205 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 209 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 206 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCDestroy .. Destroying :0x%X \n",(A_UIN
T32)target)); | 210 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("+HTCDestroy .. Destroying :0x%lX \n",(unsi
gned long)target)); |
| 207 HTCCleanup(target); | 211 HTCCleanup(target); |
| 208 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCDestroy \n")); | 212 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCDestroy \n")); |
| 209 } | 213 } |
| 210 | 214 |
| 211 /* get the low level HIF device for the caller , the caller may wish to do low l
evel | 215 /* get the low level HIF device for the caller , the caller may wish to do low l
evel |
| 212 * HIF requests */ | 216 * HIF requests */ |
| 213 void *HTCGetHifDevice(HTC_HANDLE HTCHandle) | 217 void *HTCGetHifDevice(HTC_HANDLE HTCHandle) |
| 214 { | 218 { |
| 215 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 219 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 216 return target->Device.HIFDevice; | 220 return target->Device.HIFDevice; |
| 217 } | 221 } |
| 218 | 222 |
| 219 /* wait for the target to arrive (sends HTC Ready message) | 223 /* wait for the target to arrive (sends HTC Ready message) |
| 220 * this operation is fully synchronous and the message is polled for */ | 224 * this operation is fully synchronous and the message is polled for */ |
| 221 A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) | 225 A_STATUS HTCWaitTarget(HTC_HANDLE HTCHandle) |
| 222 { | 226 { |
| 223 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 227 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 224 A_STATUS status; | 228 A_STATUS status; |
| 225 HTC_PACKET *pPacket = NULL; | 229 HTC_PACKET *pPacket = NULL; |
| 226 HTC_READY_EX_MSG *pRdyMsg; | 230 HTC_READY_EX_MSG *pRdyMsg; |
| 231 |
| 227 HTC_SERVICE_CONNECT_REQ connect; | 232 HTC_SERVICE_CONNECT_REQ connect; |
| 228 HTC_SERVICE_CONNECT_RESP resp; | 233 HTC_SERVICE_CONNECT_RESP resp; |
| 229 | 234 |
| 230 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%X) \n", (A
_UINT32)target)); | 235 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("HTCWaitTarget - Enter (target:0x%lX) \n", (
unsigned long)target)); |
| 231 | 236 |
| 232 do { | 237 do { |
| 233 | 238 |
| 234 #ifdef MBOXHW_UNIT_TEST | 239 #ifdef MBOXHW_UNIT_TEST |
| 235 | 240 |
| 236 status = DoMboxHWTest(&target->Device); | 241 status = DoMboxHWTest(&target->Device); |
| 237 | 242 |
| 238 if (status != A_OK) { | 243 if (status != A_OK) { |
| 239 break; | 244 break; |
| 240 } | 245 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 target->MaxMsgPerBundle = 0; | 310 target->MaxMsgPerBundle = 0; |
| 306 } else { | 311 } else { |
| 307 /* limit bundle what the device layer can handle */ | 312 /* limit bundle what the device layer can handle */ |
| 308 target->MaxMsgPerBundle = min(DEV_GET_MAX_MSG_PER_BUNDLE(&target
->Device), | 313 target->MaxMsgPerBundle = min(DEV_GET_MAX_MSG_PER_BUNDLE(&target
->Device), |
| 309 target->MaxMsgPerBundle); | 314 target->MaxMsgPerBundle); |
| 310 } | 315 } |
| 311 } | 316 } |
| 312 | 317 |
| 313 if (target->MaxMsgPerBundle > 0) { | 318 if (target->MaxMsgPerBundle > 0) { |
| 314 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, | 319 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, |
| 315 (" HTC bundling allowed. Max Msg Per HTC Bundle: %d\n", targ
et->MaxMsgPerBundle)); | 320 (" HTC bundling allowed. Max Msg Per HTC Bundle: %d\n", targ
et->MaxMsgPerBundle)); |
| 316 target->SendBundlingEnabled = TRUE; | 321 |
| 317 target->RecvBundlingEnabled = TRUE; | 322 if (DEV_GET_MAX_BUNDLE_SEND_LENGTH(&target->Device) != 0) {
|
| 323 target->SendBundlingEnabled = TRUE; |
| 324 } |
| 325 if (DEV_GET_MAX_BUNDLE_RECV_LENGTH(&target->Device) != 0) { |
| 326 target->RecvBundlingEnabled = TRUE; |
| 327 } |
| 328 |
| 318 if (!DEV_IS_LEN_BLOCK_ALIGNED(&target->Device,target->TargetCreditSi
ze)) { | 329 if (!DEV_IS_LEN_BLOCK_ALIGNED(&target->Device,target->TargetCreditSi
ze)) { |
| 319 AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("*** Credit size: %d is not blo
ck aligned! Disabling send bundling \n", | 330 AR_DEBUG_PRINTF(ATH_DEBUG_WARN, ("*** Credit size: %d is not blo
ck aligned! Disabling send bundling \n", |
| 320 target->TargetCreditSize)); | 331 target->TargetCreditSize)); |
| 321 /* disallow send bundling since the credit size is not align
ed to a block size | 332 /* disallow send bundling since the credit size is not align
ed to a block size |
| 322 * the I/O block padding will spill into the next credit buf
fer which is fatal */ | 333 * the I/O block padding will spill into the next credit buf
fer which is fatal */ |
| 323 target->SendBundlingEnabled = FALSE; | 334 target->SendBundlingEnabled = FALSE; |
| 324 } | 335 } |
| 325 } | 336 } |
| 326 | 337 |
| 327 /* setup our pseudo HTC control endpoint connection */ | 338 /* setup our pseudo HTC control endpoint connection */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL); | 401 AR_DEBUG_ASSERT(target->EpCreditDistributionListHead != NULL); |
| 391 AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL); | 402 AR_DEBUG_ASSERT(target->EpCreditDistributionListHead->pNext != NULL); |
| 392 | 403 |
| 393 /* call init credits callback to do the distribution , | 404 /* call init credits callback to do the distribution , |
| 394 * NOTE: the first entry in the distribution list is ENDPOINT_0, so | 405 * NOTE: the first entry in the distribution list is ENDPOINT_0, so |
| 395 * we pass the start of the list after this one. */ | 406 * we pass the start of the list after this one. */ |
| 396 target->InitCredits(target->pCredDistContext, | 407 target->InitCredits(target->pCredDistContext, |
| 397 target->EpCreditDistributionListHead->pNext, | 408 target->EpCreditDistributionListHead->pNext, |
| 398 target->TargetCredits); | 409 target->TargetCredits); |
| 399 | 410 |
| 411 #ifdef ATH_DEBUG_MODULE |
| 412 |
| 400 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) { | 413 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_TRC)) { |
| 401 DumpCreditDistStates(target); | 414 DumpCreditDistStates(target); |
| 402 } | 415 } |
| 416 #endif |
| 403 | 417 |
| 404 /* the caller is done connecting to services, so we can indicate to
the | 418 /* the caller is done connecting to services, so we can indicate to
the |
| 405 * target that the setup phase is complete */ | 419 * target that the setup phase is complete */ |
| 406 status = HTCSendSetupComplete(target); | 420 status = HTCSendSetupComplete(target); |
| 407 | 421 |
| 408 if (A_FAILED(status)) { | 422 if (A_FAILED(status)) { |
| 409 break; | 423 break; |
| 410 } | 424 } |
| 411 | 425 |
| 412 /* unmask interrupts */ | 426 /* unmask interrupts */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 468 |
| 455 LOCK_HTC(target); | 469 LOCK_HTC(target); |
| 456 /* mark that we are shutting down .. */ | 470 /* mark that we are shutting down .. */ |
| 457 target->OpStateFlags |= HTC_OP_STATE_STOPPING; | 471 target->OpStateFlags |= HTC_OP_STATE_STOPPING; |
| 458 UNLOCK_HTC(target); | 472 UNLOCK_HTC(target); |
| 459 | 473 |
| 460 /* Masking interrupts is a synchronous operation, when this function ret
urns | 474 /* Masking interrupts is a synchronous operation, when this function ret
urns |
| 461 * all pending HIF I/O has completed, we can safely flush the queues */ | 475 * all pending HIF I/O has completed, we can safely flush the queues */ |
| 462 DevMaskInterrupts(&target->Device); | 476 DevMaskInterrupts(&target->Device); |
| 463 | 477 |
| 478 #ifdef THREAD_X |
| 479 // |
| 480 // Is this delay required |
| 481 // |
| 482 A_MDELAY(200); // wait for IRQ process done |
| 483 #endif |
| 464 /* flush all send packets */ | 484 /* flush all send packets */ |
| 465 HTCFlushSendPkts(target); | 485 HTCFlushSendPkts(target); |
| 466 /* flush all recv buffers */ | 486 /* flush all recv buffers */ |
| 467 HTCFlushRecvBuffers(target); | 487 HTCFlushRecvBuffers(target); |
| 468 | 488 |
| 469 ResetEndpointStates(target); | 489 ResetEndpointStates(target); |
| 470 | 490 |
| 471 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n")); | 491 AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCStop \n")); |
| 472 } | 492 } |
| 473 | 493 |
| 494 #ifdef ATH_DEBUG_MODULE |
| 474 void HTCDumpCreditStates(HTC_HANDLE HTCHandle) | 495 void HTCDumpCreditStates(HTC_HANDLE HTCHandle) |
| 475 { | 496 { |
| 476 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 497 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 477 | 498 |
| 478 LOCK_HTC_TX(target); | 499 LOCK_HTC_TX(target); |
| 479 | 500 |
| 480 DumpCreditDistStates(target); | 501 DumpCreditDistStates(target); |
| 481 | 502 |
| 482 UNLOCK_HTC_TX(target); | 503 UNLOCK_HTC_TX(target); |
| 483 | 504 |
| 484 DumpAR6KDevState(&target->Device); | 505 DumpAR6KDevState(&target->Device); |
| 485 } | 506 } |
| 486 | 507 #endif |
| 487 /* report a target failure from the device, this is a callback from the device l
ayer | 508 /* report a target failure from the device, this is a callback from the device l
ayer |
| 488 * which uses a mechanism to report errors from the target (i.e. special interru
pts) */ | 509 * which uses a mechanism to report errors from the target (i.e. special interru
pts) */ |
| 489 static void HTCReportFailure(void *Context) | 510 static void HTCReportFailure(void *Context) |
| 490 { | 511 { |
| 491 HTC_TARGET *target = (HTC_TARGET *)Context; | 512 HTC_TARGET *target = (HTC_TARGET *)Context; |
| 492 | 513 |
| 493 target->TargetFailure = TRUE; | 514 target->TargetFailure = TRUE; |
| 494 | 515 |
| 495 if (target->HTCInitInfo.TargetFailure != NULL) { | 516 if (target->HTCInitInfo.TargetFailure != NULL) { |
| 496 /* let upper layer know, it needs to call HTCStop() */ | 517 /* let upper layer know, it needs to call HTCStop() */ |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 return FALSE; | 570 return FALSE; |
| 550 #endif | 571 #endif |
| 551 } | 572 } |
| 552 | 573 |
| 553 AR6K_DEVICE *HTCGetAR6KDevice(void *HTCHandle) | 574 AR6K_DEVICE *HTCGetAR6KDevice(void *HTCHandle) |
| 554 { | 575 { |
| 555 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 576 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 556 return &target->Device; | 577 return &target->Device; |
| 557 } | 578 } |
| 558 | 579 |
| OLD | NEW |