OLD | NEW |
1 //------------------------------------------------------------------------------ | 1 //------------------------------------------------------------------------------ |
2 // <copyright file="htc_recv.c" company="Atheros"> | 2 // <copyright file="htc_recv.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 #define HTCIssueRecv(t, p) \ | 25 #define HTCIssueRecv(t, p) \ |
22 DevRecvPacket(&(t)->Device, \ | 26 DevRecvPacket(&(t)->Device, \ |
23 (p), \ | 27 (p), \ |
24 (p)->ActualLength) | 28 (p)->ActualLength) |
25 | 29 |
26 #define DO_RCV_COMPLETION(e,q) DoRecvCompletion(e,q) | 30 #define DO_RCV_COMPLETION(e,q) DoRecvCompletion(e,q) |
27 | 31 |
28 #define DUMP_RECV_PKT_INFO(pP) \ | 32 #define DUMP_RECV_PKT_INFO(pP) \ |
29 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC RECV packet 0x%X (%d bytes) (hdr:0x%X
) on ep : %d \n", \ | 33 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC RECV packet 0x%lX (%d bytes) (hdr:0x%
X) on ep : %d \n", \ |
30 (A_UINT32)(pP), \ | 34 (unsigned long)(pP), \ |
31 (pP)->ActualLength, \ | 35 (pP)->ActualLength, \ |
32 (pP)->PktInfo.AsRx.ExpectedHdr, \ | 36 (pP)->PktInfo.AsRx.ExpectedHdr, \ |
33 (pP)->Endpoint)) | 37 (pP)->Endpoint)) |
34 | 38 |
35 #ifdef HTC_EP_STAT_PROFILING | 39 #ifdef HTC_EP_STAT_PROFILING |
36 #define HTC_RX_STAT_PROFILE(t,ep,numLookAheads) \ | 40 #define HTC_RX_STAT_PROFILE(t,ep,numLookAheads) \ |
37 { \ | 41 { \ |
38 INC_HTC_EP_STAT((ep), RxReceived, 1); \ | 42 INC_HTC_EP_STAT((ep), RxReceived, 1); \ |
39 if ((numLookAheads) == 1) { \ | 43 if ((numLookAheads) == 1) { \ |
40 INC_HTC_EP_STAT((ep), RxLookAheads, 1); \ | 44 INC_HTC_EP_STAT((ep), RxLookAheads, 1); \ |
(...skipping 21 matching lines...) Expand all Loading... |
62 pEndpoint->Id, HTC_PACKET_QUEUE_DEPTH(pQueueToIndicate))); | 66 pEndpoint->Id, HTC_PACKET_QUEUE_DEPTH(pQueueToIndicate))); |
63 /* a recv multiple handler is being used, pass the queue to the
handler */ | 67 /* a recv multiple handler is being used, pass the queue to the
handler */ |
64 pEndpoint->EpCallBacks.EpRecvPktMultiple(pEndpoint->EpCallBacks.pCon
text, | 68 pEndpoint->EpCallBacks.EpRecvPktMultiple(pEndpoint->EpCallBacks.pCon
text, |
65 pQueueToIndicate); | 69 pQueueToIndicate); |
66 INIT_HTC_PACKET_QUEUE(pQueueToIndicate); | 70 INIT_HTC_PACKET_QUEUE(pQueueToIndicate); |
67 } else { | 71 } else { |
68 HTC_PACKET *pPacket; | 72 HTC_PACKET *pPacket; |
69 /* using legacy EpRecv */ | 73 /* using legacy EpRecv */ |
70 do { | 74 do { |
71 pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); | 75 pPacket = HTC_PACKET_DEQUEUE(pQueueToIndicate); |
72 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC calling ep %d recv callba
ck on packet 0x%X \n", \ | 76 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" HTC calling ep %d recv callba
ck on packet 0x%lX \n", \ |
73 pEndpoint->Id, (A_UINT32)(pPacket))); | 77 pEndpoint->Id, (unsigned long)(pPacket))); |
74 pEndpoint->EpCallBacks.EpRecv(pEndpoint->EpCallBacks.pContext, p
Packet); | 78 pEndpoint->EpCallBacks.EpRecv(pEndpoint->EpCallBacks.pContext, p
Packet); |
75 } while (!HTC_QUEUE_EMPTY(pQueueToIndicate));
| 79 } while (!HTC_QUEUE_EMPTY(pQueueToIndicate));
|
76 } | 80 } |
77 | 81 |
78 } while (FALSE); | 82 } while (FALSE); |
79 | 83 |
80 } | 84 } |
81 | 85 |
82 static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, | 86 static INLINE A_STATUS HTCProcessTrailer(HTC_TARGET *target, |
83 A_UINT8 *pBuffer, | 87 A_UINT8 *pBuffer, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 (" LookAhead Report Found (pre valid:0x%X, post
valid:0x%X) \n", | 147 (" LookAhead Report Found (pre valid:0x%X, post
valid:0x%X) \n", |
144 pLookAhead->PreValid, | 148 pLookAhead->PreValid, |
145 pLookAhead->PostValid)); | 149 pLookAhead->PostValid)); |
146 | 150 |
147 /* look ahead bytes are valid, copy them over */ | 151 /* look ahead bytes are valid, copy them over */ |
148 ((A_UINT8 *)(&pNextLookAheads[0]))[0] = pLookAhead->LookAhea
d[0]; | 152 ((A_UINT8 *)(&pNextLookAheads[0]))[0] = pLookAhead->LookAhea
d[0]; |
149 ((A_UINT8 *)(&pNextLookAheads[0]))[1] = pLookAhead->LookAhea
d[1]; | 153 ((A_UINT8 *)(&pNextLookAheads[0]))[1] = pLookAhead->LookAhea
d[1]; |
150 ((A_UINT8 *)(&pNextLookAheads[0]))[2] = pLookAhead->LookAhea
d[2]; | 154 ((A_UINT8 *)(&pNextLookAheads[0]))[2] = pLookAhead->LookAhea
d[2]; |
151 ((A_UINT8 *)(&pNextLookAheads[0]))[3] = pLookAhead->LookAhea
d[3]; | 155 ((A_UINT8 *)(&pNextLookAheads[0]))[3] = pLookAhead->LookAhea
d[3]; |
152 | 156 |
| 157 #ifdef ATH_DEBUG_MODULE |
153 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { | 158 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { |
154 DebugDumpBytes((A_UINT8 *)pNextLookAheads,4,"Next Look A
head"); | 159 DebugDumpBytes((A_UINT8 *)pNextLookAheads,4,"Next Look A
head"); |
155 } | 160 } |
| 161 #endif |
156 /* just one normal lookahead */ | 162 /* just one normal lookahead */ |
157 *pNumLookAheads = 1; | 163 *pNumLookAheads = 1; |
158 } | 164 } |
159 break; | 165 break; |
160 case HTC_RECORD_LOOKAHEAD_BUNDLE: | 166 case HTC_RECORD_LOOKAHEAD_BUNDLE: |
161 AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_
REPORT)); | 167 AR_DEBUG_ASSERT(pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_
REPORT)); |
162 if (pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT) && | 168 if (pRecord->Length >= sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT) && |
163 (pNextLookAheads != NULL)) { | 169 (pNextLookAheads != NULL)) { |
164 HTC_BUNDLED_LOOKAHEAD_REPORT *pBundledLookAheadRpt; | 170 HTC_BUNDLED_LOOKAHEAD_REPORT *pBundledLookAheadRpt; |
165 int i; | 171 int i; |
166 | 172 |
167 pBundledLookAheadRpt = (HTC_BUNDLED_LOOKAHEAD_REPORT *)pReco
rdBuf; | 173 pBundledLookAheadRpt = (HTC_BUNDLED_LOOKAHEAD_REPORT *)pReco
rdBuf; |
168 | 174 |
| 175 #ifdef ATH_DEBUG_MODULE |
169 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { | 176 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { |
170 DebugDumpBytes(pRecordBuf,pRecord->Length,"Bundle LookAh
ead"); | 177 DebugDumpBytes(pRecordBuf,pRecord->Length,"Bundle LookAh
ead"); |
171 } | 178 } |
| 179 #endif |
172 | 180 |
173 if ((pRecord->Length / (sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT)
)) > | 181 if ((pRecord->Length / (sizeof(HTC_BUNDLED_LOOKAHEAD_REPORT)
)) > |
174 HTC_HOST_MAX_MSG_PER_BUNDLE) { | 182 HTC_HOST_MAX_MSG_PER_BUNDLE) { |
175 /* this should never happen, the target restricts th
e number | 183 /* this should never happen, the target restricts th
e number |
176 * of messages per bundle configured by the host */
| 184 * of messages per bundle configured by the host */
|
177 A_ASSERT(FALSE); | 185 A_ASSERT(FALSE); |
178 status = A_EPROTO; | 186 status = A_EPROTO; |
179 break; | 187 break; |
180 } | 188 } |
181 | 189 |
(...skipping 16 matching lines...) Expand all Loading... |
198 | 206 |
199 if (A_FAILED(status)) { | 207 if (A_FAILED(status)) { |
200 break; | 208 break; |
201 } | 209 } |
202 | 210 |
203 /* advance buffer past this record for next time around */ | 211 /* advance buffer past this record for next time around */ |
204 pBuffer += pRecord->Length; | 212 pBuffer += pRecord->Length; |
205 Length -= pRecord->Length; | 213 Length -= pRecord->Length; |
206 } | 214 } |
207 | 215 |
| 216 #ifdef ATH_DEBUG_MODULE |
208 if (A_FAILED(status)) { | 217 if (A_FAILED(status)) { |
209 DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer"); | 218 DebugDumpBytes(pOrigBuffer,origLength,"BAD Recv Trailer"); |
210 } | 219 } |
| 220 #endif |
211 | 221 |
212 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessTrailer \n")); | 222 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-HTCProcessTrailer \n")); |
213 return status; | 223 return status; |
214 | 224 |
215 } | 225 } |
216 | 226 |
217 /* process a received message (i.e. strip off header, process any trailer data) | 227 /* process a received message (i.e. strip off header, process any trailer data) |
218 * note : locks must be released when this function is called */ | 228 * note : locks must be released when this function is called */ |
219 static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, | 229 static A_STATUS HTCProcessRecvHeader(HTC_TARGET *target, |
220 HTC_PACKET *pPacket, | 230 HTC_PACKET *pPacket, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, EndpointID), pPacket-
>Endpoint)); | 283 A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, EndpointID), pPacket-
>Endpoint)); |
274 status = A_EPROTO; | 284 status = A_EPROTO; |
275 break; | 285 break; |
276 } | 286 } |
277 } | 287 } |
278 | 288 |
279 if (lookAhead != pPacket->PktInfo.AsRx.ExpectedHdr) { | 289 if (lookAhead != pPacket->PktInfo.AsRx.ExpectedHdr) { |
280 /* somehow the lookahead that gave us the full read length did not | 290 /* somehow the lookahead that gave us the full read length did not |
281 * reflect the actual header in the pending message */ | 291 * reflect the actual header in the pending message */ |
282 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, | 292 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
283 ("HTCProcessRecvHeader, lookahead mismatch! (pPkt:0x%X flags
:0x%X) \n", | 293 ("HTCProcessRecvHeader, lookahead mismatch! (pPkt:0x%lX flag
s:0x%X) \n", |
284 (A_UINT32)pPacket, pPacket->PktInfo.AsRx.HTCRxFlags)); | 294 (unsigned long)pPacket, pPacket->PktInfo.AsRx.HTCRxFlags
)); |
| 295 #ifdef ATH_DEBUG_MODULE |
285 DebugDumpBytes((A_UINT8 *)&pPacket->PktInfo.AsRx.ExpectedHdr,4,"Exp
ected Message LookAhead"); | 296 DebugDumpBytes((A_UINT8 *)&pPacket->PktInfo.AsRx.ExpectedHdr,4,"Exp
ected Message LookAhead"); |
286 DebugDumpBytes(pBuf,sizeof(HTC_FRAME_HDR),"Current Frame Header"); | 297 DebugDumpBytes(pBuf,sizeof(HTC_FRAME_HDR),"Current Frame Header"); |
287 #ifdef HTC_CAPTURE_LAST_FRAME | 298 #ifdef HTC_CAPTURE_LAST_FRAME |
288 DebugDumpBytes((A_UINT8 *)&target->LastFrameHdr,sizeof(HTC_FRAME_HDR
),"Last Frame Header"); | 299 DebugDumpBytes((A_UINT8 *)&target->LastFrameHdr,sizeof(HTC_FRAME_HDR
),"Last Frame Header"); |
289 if (target->LastTrailerLength != 0) { | 300 if (target->LastTrailerLength != 0) { |
290 DebugDumpBytes(target->LastTrailer, | 301 DebugDumpBytes(target->LastTrailer, |
291 target->LastTrailerLength, | 302 target->LastTrailerLength, |
292 "Last trailer"); | 303 "Last trailer"); |
293 } | 304 } |
294 #endif | 305 #endif |
| 306 #endif |
295 status = A_EPROTO; | 307 status = A_EPROTO; |
296 break; | 308 break; |
297 } | 309 } |
298 | 310 |
299 /* get flags */ | 311 /* get flags */ |
300 temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, Flags); | 312 temp = A_GET_UINT8_FIELD(pBuf, HTC_FRAME_HDR, Flags); |
301 | 313 |
302 if (temp & HTC_FLAGS_RECV_TRAILER) { | 314 if (temp & HTC_FLAGS_RECV_TRAILER) { |
303 /* this packet has a trailer */ | 315 /* this packet has a trailer */ |
304 | 316 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 360 |
349 /* if we get to this point, the packet is good */ | 361 /* if we get to this point, the packet is good */ |
350 /* remove header and adjust length */ | 362 /* remove header and adjust length */ |
351 pPacket->pBuffer += HTC_HDR_LENGTH; | 363 pPacket->pBuffer += HTC_HDR_LENGTH; |
352 pPacket->ActualLength -= HTC_HDR_LENGTH; | 364 pPacket->ActualLength -= HTC_HDR_LENGTH; |
353 | 365 |
354 } while (FALSE); | 366 } while (FALSE); |
355 | 367 |
356 if (A_FAILED(status)) { | 368 if (A_FAILED(status)) { |
357 /* dump the whole packet */ | 369 /* dump the whole packet */ |
| 370 #ifdef ATH_DEBUG_MODULE |
358 DebugDumpBytes(pBuf,pPacket->ActualLength < 256 ? pPacket->ActualLength
: 256 ,"BAD HTC Recv PKT"); | 371 DebugDumpBytes(pBuf,pPacket->ActualLength < 256 ? pPacket->ActualLength
: 256 ,"BAD HTC Recv PKT"); |
| 372 #endif |
359 } else { | 373 } else { |
360 #ifdef HTC_CAPTURE_LAST_FRAME | 374 #ifdef HTC_CAPTURE_LAST_FRAME |
361 A_MEMCPY(&target->LastFrameHdr,pBuf,sizeof(HTC_FRAME_HDR)); | 375 A_MEMCPY(&target->LastFrameHdr,pBuf,sizeof(HTC_FRAME_HDR)); |
362 #endif | 376 #endif |
363 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { | 377 if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) { |
364 if (pPacket->ActualLength > 0) { | 378 if (pPacket->ActualLength > 0) { |
365 AR_DEBUG_PRINTBUF(pPacket->pBuffer,pPacket->ActualLength,"HTC -
Application Msg"); | 379 AR_DEBUG_PRINTBUF(pPacket->pBuffer,pPacket->ActualLength,"HTC -
Application Msg"); |
366 } | 380 } |
367 } | 381 } |
368 } | 382 } |
(...skipping 14 matching lines...) Expand all Loading... |
383 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, | 397 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, |
384 ("HTCAsyncRecvCheckMorePackets - num lookaheads were non
-zero : %d \n", | 398 ("HTCAsyncRecvCheckMorePackets - num lookaheads were non
-zero : %d \n", |
385 NumLookAheads)); | 399 NumLookAheads)); |
386 /* force status re-check */ | 400 /* force status re-check */ |
387 REF_IRQ_STATUS_RECHECK(&target->Device); | 401 REF_IRQ_STATUS_RECHECK(&target->Device); |
388 /* we have more packets, get the next packet fetch started */ | 402 /* we have more packets, get the next packet fetch started */ |
389 nextStatus = HTCRecvMessagePendingHandler(target, NextLookAheads, NumLoo
kAheads, NULL, &fetched); | 403 nextStatus = HTCRecvMessagePendingHandler(target, NextLookAheads, NumLoo
kAheads, NULL, &fetched); |
390 if (A_EPROTO == nextStatus) { | 404 if (A_EPROTO == nextStatus) { |
391 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, | 405 AR_DEBUG_PRINTF(ATH_DEBUG_ERR, |
392 ("Next look ahead from recv header was INVALID\n")); | 406 ("Next look ahead from recv header was INVALID\n")); |
| 407 #ifdef ATH_DEBUG_MODULE |
393 DebugDumpBytes((A_UINT8 *)NextLookAheads, | 408 DebugDumpBytes((A_UINT8 *)NextLookAheads, |
394 NumLookAheads * (sizeof(A_UINT32)), | 409 NumLookAheads * (sizeof(A_UINT32)), |
395 "BAD lookaheads from lookahead report"); | 410 "BAD lookaheads from lookahead report"); |
| 411 #endif |
396 } | 412 } |
397 if (A_SUCCESS(nextStatus) && !fetched) { | 413 if (A_SUCCESS(nextStatus) && !fetched) { |
398 /* we could not fetch any more packets due to resources */ | 414 /* we could not fetch any more packets due to resources */ |
399 DevAsyncIrqProcessComplete(&target->Device); | 415 DevAsyncIrqProcessComplete(&target->Device); |
400 } | 416 } |
401 } else { | 417 } else { |
402 if (CheckMoreMsgs) { | 418 if (CheckMoreMsgs) { |
403 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, | 419 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, |
404 ("HTCAsyncRecvCheckMorePackets - rechecking for more messages...
\n")); | 420 ("HTCAsyncRecvCheckMorePackets - rechecking for more messages...
\n")); |
405 /* if we did not get anything on the look-ahead, | 421 /* if we did not get anything on the look-ahead, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 * completes a read request, it will call this completion handler */ | 517 * completes a read request, it will call this completion handler */ |
502 void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) | 518 void HTCRecvCompleteHandler(void *Context, HTC_PACKET *pPacket) |
503 { | 519 { |
504 HTC_TARGET *target = (HTC_TARGET *)Context; | 520 HTC_TARGET *target = (HTC_TARGET *)Context; |
505 HTC_ENDPOINT *pEndpoint; | 521 HTC_ENDPOINT *pEndpoint; |
506 A_UINT32 nextLookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; | 522 A_UINT32 nextLookAheads[HTC_HOST_MAX_MSG_PER_BUNDLE]; |
507 int numLookAheads = 0; | 523 int numLookAheads = 0; |
508 A_STATUS status; | 524 A_STATUS status; |
509 A_BOOL checkMorePkts = TRUE; | 525 A_BOOL checkMorePkts = TRUE; |
510 | 526 |
511 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (pkt:0x%X, status:
%d, ep:%d) \n", | 527 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("+HTCRecvCompleteHandler (pkt:0x%lX, status
:%d, ep:%d) \n", |
512 (A_UINT32)pPacket, pPacket->Status, pPacket->Endpoint)); | 528 (unsigned long)pPacket, pPacket->Status, pPacket->Endpoint)); |
513 | 529 |
514 A_ASSERT(!IS_DEV_IRQ_PROC_SYNC_MODE(&target->Device)); | 530 A_ASSERT(!IS_DEV_IRQ_PROC_SYNC_MODE(&target->Device)); |
515 AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX); | 531 AR_DEBUG_ASSERT(pPacket->Endpoint < ENDPOINT_MAX); |
516 pEndpoint = &target->EndPoint[pPacket->Endpoint]; | 532 pEndpoint = &target->EndPoint[pPacket->Endpoint]; |
517 pPacket->Completion = NULL; | 533 pPacket->Completion = NULL; |
518 | 534 |
519 /* get completion status */ | 535 /* get completion status */ |
520 status = pPacket->Status; | 536 status = pPacket->Status; |
521 | 537 |
522 do { | 538 do { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 if (pHdr->EndpointID != pEndpoint->Id) { | 717 if (pHdr->EndpointID != pEndpoint->Id) { |
702 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d s
hould be : %d (index:%d)\n", | 718 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Invalid Endpoint in look-ahead: %d s
hould be : %d (index:%d)\n", |
703 pHdr->EndpointID, pEndpoint->Id, i)); | 719 pHdr->EndpointID, pEndpoint->Id, i)); |
704 /* invalid endpoint */ | 720 /* invalid endpoint */ |
705 status = A_EPROTO; | 721 status = A_EPROTO; |
706 break; | 722 break; |
707 } | 723 } |
708 | 724 |
709 if (pHdr->PayloadLen > HTC_MAX_PAYLOAD_LENGTH) { | 725 if (pHdr->PayloadLen > HTC_MAX_PAYLOAD_LENGTH) { |
710 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Payload length %d exceeds max HTC :
%d !\n", | 726 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Payload length %d exceeds max HTC :
%d !\n", |
711 pHdr->PayloadLen, HTC_MAX_PAYLOAD_LENGTH)); | 727 pHdr->PayloadLen, (A_UINT32)HTC_MAX_PAYLOAD_LENGTH)); |
712 status = A_EPROTO; | 728 status = A_EPROTO; |
713 break; | 729 break; |
714 } | 730 } |
715 | 731 |
716 if (0 == pEndpoint->ServiceID) { | 732 if (0 == pEndpoint->ServiceID) { |
717 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Endpoint %d is not connected !\n",pH
dr->EndpointID)); | 733 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Endpoint %d is not connected !\n",pH
dr->EndpointID)); |
718 /* endpoint isn't even connected */ | 734 /* endpoint isn't even connected */ |
719 status = A_EPROTO; | 735 status = A_EPROTO; |
720 break; | 736 break; |
721 } | 737 } |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 LOCK_HTC_RX(target); | 1494 LOCK_HTC_RX(target); |
1479 | 1495 |
1480 while (1) { | 1496 while (1) { |
1481 pPacket = HTC_PACKET_DEQUEUE(pQueue); | 1497 pPacket = HTC_PACKET_DEQUEUE(pQueue); |
1482 if (NULL == pPacket) { | 1498 if (NULL == pPacket) { |
1483 break; | 1499 break; |
1484 } | 1500 } |
1485 UNLOCK_HTC_RX(target); | 1501 UNLOCK_HTC_RX(target); |
1486 pPacket->Status = A_ECANCELED; | 1502 pPacket->Status = A_ECANCELED; |
1487 pPacket->ActualLength = 0; | 1503 pPacket->ActualLength = 0; |
1488 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" Flushing RX packet:0x%X, length:%d,
ep:%d \n", | 1504 AR_DEBUG_PRINTF(ATH_DEBUG_RECV, (" Flushing RX packet:0x%lX, length:%d,
ep:%d \n", |
1489 (A_UINT32)pPacket, pPacket->BufferLength, pPacket->Endpoint)); | 1505 (unsigned long)pPacket, pPacket->BufferLength, pPacket->Endpoint
)); |
1490 INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); | 1506 INIT_HTC_PACKET_QUEUE_AND_ADD(&container,pPacket); |
1491 /* give the packet back */ | 1507 /* give the packet back */ |
1492 DO_RCV_COMPLETION(pEndpoint,&container); | 1508 DO_RCV_COMPLETION(pEndpoint,&container); |
1493 LOCK_HTC_RX(target); | 1509 LOCK_HTC_RX(target); |
1494 } | 1510 } |
1495 | 1511 |
1496 UNLOCK_HTC_RX(target); | 1512 UNLOCK_HTC_RX(target); |
1497 } | 1513 } |
1498 | 1514 |
1499 static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) | 1515 static void HTCFlushEndpointRX(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 } | 1556 } |
1541 } | 1557 } |
1542 | 1558 |
1543 int HTCGetNumRecvBuffers(HTC_HANDLE HTCHandle, | 1559 int HTCGetNumRecvBuffers(HTC_HANDLE HTCHandle, |
1544 HTC_ENDPOINT_ID Endpoint) | 1560 HTC_ENDPOINT_ID Endpoint) |
1545 { | 1561 { |
1546 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); | 1562 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
1547 return HTC_PACKET_QUEUE_DEPTH(&(target->EndPoint[Endpoint].RxBuffers)); | 1563 return HTC_PACKET_QUEUE_DEPTH(&(target->EndPoint[Endpoint].RxBuffers)); |
1548 } | 1564 } |
1549 | 1565 |
| 1566 A_STATUS HTCWaitForPendingRecv(HTC_HANDLE HTCHandle, |
| 1567 A_UINT32 TimeoutInMs, |
| 1568 A_BOOL *pbIsRecvPending) |
| 1569 { |
| 1570 A_STATUS status = A_OK; |
| 1571 HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle); |
| 1572 |
| 1573 status = DevWaitForPendingRecv(&target->Device, |
| 1574 TimeoutInMs, |
| 1575 pbIsRecvPending); |
| 1576 |
| 1577 return status; |
| 1578 } |
OLD | NEW |