omap4: l2x0: enable instruction and data prefetching
[pandora-kernel.git] / drivers / staging / winbond / mds.c
1 #include "mds_f.h"
2 #include "mlmetxrx_f.h"
3 #include "mto.h"
4 #include "sysdef.h"
5 #include "wbhal_f.h"
6 #include "wblinux_f.h"
7
8 unsigned char
9 Mds_initial(struct wbsoft_priv *adapter)
10 {
11         struct wb35_mds *pMds = &adapter->Mds;
12
13         pMds->TxPause = false;
14         pMds->TxRTSThreshold = DEFAULT_RTSThreshold;
15         pMds->TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
16
17         return hal_get_tx_buffer(&adapter->sHwData, &pMds->pTxBuffer);
18 }
19
20 void
21 Mds_Destroy(struct wbsoft_priv *adapter)
22 {
23 }
24
25 static void Mds_DurationSet(struct wbsoft_priv *adapter,  struct wb35_descriptor *pDes,  u8 *buffer)
26 {
27         struct T00_descriptor *pT00;
28         struct T01_descriptor *pT01;
29         u16     Duration, NextBodyLen, OffsetSize;
30         u8      Rate, i;
31         unsigned char   CTS_on = false, RTS_on = false;
32         struct T00_descriptor *pNextT00;
33         u16 BodyLen = 0;
34         unsigned char boGroupAddr = false;
35
36         OffsetSize = pDes->FragmentThreshold + 32 + 3;
37         OffsetSize &= ~0x03;
38         Rate = pDes->TxRate >> 1;
39         if (!Rate)
40                 Rate = 1;
41
42         pT00 = (struct T00_descriptor *)buffer;
43         pT01 = (struct T01_descriptor *)(buffer+4);
44         pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize);
45
46         if (buffer[DOT_11_DA_OFFSET+8] & 0x1) /* +8 for USB hdr */
47                 boGroupAddr = true;
48
49         /******************************************
50          * Set RTS/CTS mechanism
51          ******************************************/
52         if (!boGroupAddr) {
53                 /* NOTE : If the protection mode is enabled and the MSDU will be fragmented,
54                  *               the tx rates of MPDUs will all be DSSS rates. So it will not use
55                  *               CTS-to-self in this case. CTS-To-self will only be used when without
56                  *               fragmentation. -- 20050112 */
57                 BodyLen = (u16)pT00->T00_frame_length;  /* include 802.11 header */
58                 BodyLen += 4;   /* CRC */
59
60                 if (BodyLen >= CURRENT_RTS_THRESHOLD)
61                         RTS_on = true; /* Using RTS */
62                 else {
63                         if (pT01->T01_modulation_type) { /* Is using OFDM */
64                                 if (CURRENT_PROTECT_MECHANISM) /* Is using protect */
65                                         CTS_on = true; /* Using CTS */
66                         }
67                 }
68         }
69
70         if (RTS_on || CTS_on) {
71                 if (pT01->T01_modulation_type) { /* Is using OFDM */
72                         /* CTS duration
73                          *  2 SIFS + DATA transmit time + 1 ACK
74                          *  ACK Rate : 24 Mega bps
75                          *  ACK frame length = 14 bytes */
76                         Duration = 2*DEFAULT_SIFSTIME +
77                                            2*PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION +
78                                            ((BodyLen*8 + 22 + Rate*4 - 1)/(Rate*4))*Tsym +
79                                            ((112 + 22 + 95)/96)*Tsym;
80                 } else  { /* DSSS */
81                         /* CTS duration
82                          *  2 SIFS + DATA transmit time + 1 ACK
83                          *  Rate : ?? Mega bps
84                          *  ACK frame length = 14 bytes */
85                         if (pT01->T01_plcp_header_length) /* long preamble */
86                                 Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*2;
87                         else
88                                 Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*2;
89
90                         Duration += (((BodyLen + 14)*8 + Rate-1) / Rate +
91                                                 DEFAULT_SIFSTIME*2);
92                 }
93
94                 if (RTS_on) {
95                         if (pT01->T01_modulation_type) { /* Is using OFDM */
96                                 /* CTS + 1 SIFS + CTS duration
97                                  * CTS Rate : 24 Mega bps
98                                  * CTS frame length = 14 bytes */
99                                 Duration += (DEFAULT_SIFSTIME +
100                                                                 PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION +
101                                                                 ((112 + 22 + 95)/96)*Tsym);
102                         } else {
103                                 /* CTS + 1 SIFS + CTS duration
104                                  * CTS Rate : ?? Mega bps
105                                  * CTS frame length = 14 bytes */
106                                 if (pT01->T01_plcp_header_length) /* long preamble */
107                                         Duration += LONG_PREAMBLE_PLUS_PLCPHEADER_TIME;
108                                 else
109                                         Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME;
110
111                                 Duration += (((112 + Rate-1) / Rate) + DEFAULT_SIFSTIME);
112                         }
113                 }
114
115                 /* Set the value into USB descriptor */
116                 pT01->T01_add_rts = RTS_on ? 1 : 0;
117                 pT01->T01_add_cts = CTS_on ? 1 : 0;
118                 pT01->T01_rts_cts_duration = Duration;
119         }
120
121         /******************************************
122          * Fill the more fragment descriptor
123          ******************************************/
124         if (boGroupAddr)
125                 Duration = 0;
126         else {
127                 for (i = pDes->FragmentCount-1; i > 0; i--) {
128                         NextBodyLen = (u16)pNextT00->T00_frame_length;
129                         NextBodyLen += 4;       /* CRC */
130
131                         if (pT01->T01_modulation_type) {
132                                 /* OFDM
133                                  *  data transmit time + 3 SIFS + 2 ACK
134                                  *  Rate : ??Mega bps
135                                  *  ACK frame length = 14 bytes, tx rate = 24M */
136                                 Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3;
137                                 Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym +
138                                                         (((2*14)*8 + 22 + 95)/96)*Tsym +
139                                                         DEFAULT_SIFSTIME*3);
140                         } else {
141                                 /* DSSS
142                                  *  data transmit time + 2 ACK + 3 SIFS
143                                  *  Rate : ??Mega bps
144                                  *  ACK frame length = 14 bytes
145                                  * TODO : */
146                                 if (pT01->T01_plcp_header_length) /* long preamble */
147                                         Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*3;
148                                 else
149                                         Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3;
150
151                                 Duration += (((NextBodyLen + (2*14))*8 + Rate-1) / Rate +
152                                                         DEFAULT_SIFSTIME*3);
153                         }
154
155                         ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */
156
157                         /* ----20061009 add by anson's endian */
158                         pNextT00->value = cpu_to_le32(pNextT00->value);
159                         pT01->value = cpu_to_le32(pT01->value);
160                         /* ----end 20061009 add by anson's endian */
161
162                         buffer += OffsetSize;
163                         pT01 = (struct T01_descriptor *)(buffer+4);
164                         if (i != 1)     /* The last fragment will not have the next fragment */
165                                 pNextT00 = (struct T00_descriptor *)(buffer+OffsetSize);
166                 }
167
168                 /*******************************************
169                  * Fill the last fragment descriptor
170                  *******************************************/
171                 if (pT01->T01_modulation_type) {
172                         /* OFDM
173                          *  1 SIFS + 1 ACK
174                          *  Rate : 24 Mega bps
175                          * ACK frame length = 14 bytes */
176                         Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION;
177                         /* The Tx rate of ACK use 24M */
178                         Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME);
179                 } else {
180                         /* DSSS
181                          * 1 ACK + 1 SIFS
182                          * Rate : ?? Mega bps
183                          * ACK frame length = 14 bytes(112 bits) */
184                         if (pT01->T01_plcp_header_length) /* long preamble */
185                                 Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME;
186                         else
187                                 Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME;
188
189                         Duration += ((112 + Rate-1)/Rate + DEFAULT_SIFSTIME);
190                 }
191         }
192
193         ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */
194         pT00->value = cpu_to_le32(pT00->value);
195         pT01->value = cpu_to_le32(pT01->value);
196         /* --end 20061009 add */
197
198 }
199
200 /* The function return the 4n size of usb pk */
201 static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer)
202 {
203         struct T00_descriptor *pT00;
204         struct wb35_mds *pMds = &adapter->Mds;
205         u8      *buffer;
206         u8      *src_buffer;
207         u8      *pctmp;
208         u16     Size = 0;
209         u16     SizeLeft, CopySize, CopyLeft, stmp;
210         u8      buf_index, FragmentCount = 0;
211
212
213         /* Copy fragment body */
214         buffer = TargetBuffer; /* shift 8B usb + 24B 802.11 */
215         SizeLeft = pDes->buffer_total_size;
216         buf_index = pDes->buffer_start_index;
217
218         pT00 = (struct T00_descriptor *)buffer;
219         while (SizeLeft) {
220                 pT00 = (struct T00_descriptor *)buffer;
221                 CopySize = SizeLeft;
222                 if (SizeLeft > pDes->FragmentThreshold) {
223                         CopySize = pDes->FragmentThreshold;
224                         pT00->T00_frame_length = 24 + CopySize; /* Set USB length */
225                 } else
226                         pT00->T00_frame_length = 24 + SizeLeft; /* Set USB length */
227
228                 SizeLeft -= CopySize;
229
230                 /* 1 Byte operation */
231                 pctmp = (u8 *)(buffer + 8 + DOT_11_SEQUENCE_OFFSET);
232                 *pctmp &= 0xf0;
233                 *pctmp |= FragmentCount; /* 931130.5.m */
234                 if (!FragmentCount)
235                         pT00->T00_first_mpdu = 1;
236
237                 buffer += 32; /* 8B usb + 24B 802.11 header */
238                 Size += 32;
239
240                 /* Copy into buffer */
241                 stmp = CopySize + 3;
242                 stmp &= ~0x03; /* 4n Alignment */
243                 Size += stmp; /* Current 4n offset of mpdu */
244
245                 while (CopySize) {
246                         /* Copy body */
247                         src_buffer = pDes->buffer_address[buf_index];
248                         CopyLeft = CopySize;
249                         if (CopySize >= pDes->buffer_size[buf_index]) {
250                                 CopyLeft = pDes->buffer_size[buf_index];
251
252                                 /* Get the next buffer of descriptor */
253                                 buf_index++;
254                                 buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX;
255                         } else {
256                                 u8      *pctmp = pDes->buffer_address[buf_index];
257                                 pctmp += CopySize;
258                                 pDes->buffer_address[buf_index] = pctmp;
259                                 pDes->buffer_size[buf_index] -= CopySize;
260                         }
261
262                         memcpy(buffer, src_buffer, CopyLeft);
263                         buffer += CopyLeft;
264                         CopySize -= CopyLeft;
265                 }
266
267                 /* 931130.5.n */
268                 if (pMds->MicAdd) {
269                         if (!SizeLeft) {
270                                 pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - pMds->MicAdd;
271                                 pMds->MicWriteSize[pMds->MicWriteIndex] = pMds->MicAdd;
272                                 pMds->MicAdd = 0;
273                         } else if (SizeLeft < 8) { /* 931130.5.p */
274                                 pMds->MicAdd = SizeLeft;
275                                 pMds->MicWriteAddress[pMds->MicWriteIndex] = buffer - (8 - SizeLeft);
276                                 pMds->MicWriteSize[pMds->MicWriteIndex] = 8 - SizeLeft;
277                                 pMds->MicWriteIndex++;
278                         }
279                 }
280
281                 /* Does it need to generate the new header for next mpdu? */
282                 if (SizeLeft) {
283                         buffer = TargetBuffer + Size; /* Get the next 4n start address */
284                         memcpy(buffer, TargetBuffer, 32); /* Copy 8B USB +24B 802.11 */
285                         pT00 = (struct T00_descriptor *)buffer;
286                         pT00->T00_first_mpdu = 0;
287                 }
288
289                 FragmentCount++;
290         }
291
292         pT00->T00_last_mpdu = 1;
293         pT00->T00_IsLastMpdu = 1;
294         buffer = (u8 *)pT00 + 8; /* +8 for USB hdr */
295         buffer[1] &= ~0x04; /* Clear more frag bit of 802.11 frame control */
296         pDes->FragmentCount = FragmentCount; /* Update the correct fragment number */
297         return Size;
298 }
299
300 static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer)
301 {
302         struct wb35_mds *pMds = &adapter->Mds;
303         u8      *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */
304         struct T00_descriptor *pT00;
305         struct T01_descriptor *pT01;
306         u16     stmp;
307         u8      i, ctmp1, ctmp2, ctmpf;
308         u16     FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
309
310
311         stmp = pDes->buffer_total_size;
312         /*
313          * Set USB header 8 byte
314          */
315         pT00 = (struct T00_descriptor *)TargetBuffer;
316         TargetBuffer += 4;
317         pT01 = (struct T01_descriptor *)TargetBuffer;
318         TargetBuffer += 4;
319
320         pT00->value = 0; /* Clear */
321         pT01->value = 0; /* Clear */
322
323         pT00->T00_tx_packet_id = pDes->Descriptor_ID; /* Set packet ID */
324         pT00->T00_header_length = 24; /* Set header length */
325         pT01->T01_retry_abort_ebable = 1; /* 921013 931130.5.h */
326
327         /* Key ID setup */
328         pT01->T01_wep_id = 0;
329
330         FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; /* Do not fragment */
331         /* Copy full data, the 1'st buffer contain all the data 931130.5.j */
332         memcpy(TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE); /* Copy header */
333         pDes->buffer_address[0] = src_buffer + DOT_11_MAC_HEADER_SIZE;
334         pDes->buffer_total_size -= DOT_11_MAC_HEADER_SIZE;
335         pDes->buffer_size[0] = pDes->buffer_total_size;
336
337         /* Set fragment threshold */
338         FragmentThreshold -= (DOT_11_MAC_HEADER_SIZE + 4);
339         pDes->FragmentThreshold = FragmentThreshold;
340
341         /* Set more frag bit */
342         TargetBuffer[1] |= 0x04; /* Set more frag bit */
343
344         /*
345          * Set tx rate
346          */
347         stmp = *(u16 *)(TargetBuffer+30); /* 2n alignment address */
348
349         /* Use basic rate */
350         ctmp1 = ctmpf = CURRENT_TX_RATE_FOR_MNG;
351
352         pDes->TxRate = ctmp1;
353         #ifdef _PE_TX_DUMP_
354         printk("Tx rate =%x\n", ctmp1);
355         #endif
356
357         pT01->T01_modulation_type = (ctmp1%3) ? 0 : 1;
358
359         for (i = 0; i < 2; i++) {
360                 if (i == 1)
361                         ctmp1 = ctmpf;
362
363                 pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; /* backup the ta rate and fall back rate */
364
365                 if (ctmp1 == 108)
366                         ctmp2 = 7;
367                 else if (ctmp1 == 96)
368                         ctmp2 = 6; /* Rate convert for USB */
369                 else if (ctmp1 == 72)
370                         ctmp2 = 5;
371                 else if (ctmp1 == 48)
372                         ctmp2 = 4;
373                 else if (ctmp1 == 36)
374                         ctmp2 = 3;
375                 else if (ctmp1 == 24)
376                         ctmp2 = 2;
377                 else if (ctmp1 == 18)
378                         ctmp2 = 1;
379                 else if (ctmp1 == 12)
380                         ctmp2 = 0;
381                 else if (ctmp1 == 22)
382                         ctmp2 = 3;
383                 else if (ctmp1 == 11)
384                         ctmp2 = 2;
385                 else if (ctmp1 == 4)
386                         ctmp2 = 1;
387                 else
388                         ctmp2 = 0; /* if( ctmp1 == 2  ) or default */
389
390                 if (i == 0)
391                         pT01->T01_transmit_rate = ctmp2;
392                 else
393                         pT01->T01_fall_back_rate = ctmp2;
394         }
395
396         /*
397          * Set preamble type
398          */
399         if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) /* RATE_1M */
400                 pDes->PreambleMode =  WLAN_PREAMBLE_TYPE_LONG;
401         else
402                 pDes->PreambleMode =  CURRENT_PREAMBLE_MODE;
403         pT01->T01_plcp_header_length = pDes->PreambleMode;      /* Set preamble */
404
405 }
406
407 void
408 Mds_Tx(struct wbsoft_priv *adapter)
409 {
410         struct hw_data *pHwData = &adapter->sHwData;
411         struct wb35_mds *pMds = &adapter->Mds;
412         struct wb35_descriptor  TxDes;
413         struct wb35_descriptor *pTxDes = &TxDes;
414         u8              *XmitBufAddress;
415         u16             XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold;
416         u8              FillIndex, TxDesIndex, FragmentCount, FillCount;
417         unsigned char   BufferFilled = false;
418
419
420         if (pMds->TxPause)
421                 return;
422         if (!hal_driver_init_OK(pHwData))
423                 return;
424
425         /* Only one thread can be run here */
426         if (atomic_inc_return(&pMds->TxThreadCount) != 1)
427                 goto cleanup;
428
429         /* Start to fill the data */
430         do {
431                 FillIndex = pMds->TxFillIndex;
432                 if (pMds->TxOwner[FillIndex]) { /* Is owned by software 0:Yes 1:No */
433 #ifdef _PE_TX_DUMP_
434                         printk("[Mds_Tx] Tx Owner is H/W.\n");
435 #endif
436                         break;
437                 }
438
439                 XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /* Get buffer */
440                 XmitBufSize = 0;
441                 FillCount = 0;
442                 do {
443                         PacketSize = adapter->sMlmeFrame.len;
444                         if (!PacketSize)
445                                 break;
446
447                         /* For Check the buffer resource */
448                         FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD;
449                         /* 931130.5.b */
450                         FragmentCount = PacketSize/FragmentThreshold + 1;
451                         stmp = PacketSize + FragmentCount*32 + 8; /* 931130.5.c 8:MIC */
452                         if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) {
453                                 printk("[Mds_Tx] Excess max tx buffer.\n");
454                                 break; /* buffer is not enough */
455                         }
456
457
458                         /*
459                          * Start transmitting
460                          */
461                         BufferFilled = true;
462
463                         /* Leaves first u8 intact */
464                         memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1);
465
466                         TxDesIndex = pMds->TxDesIndex; /* Get the current ID */
467                         pTxDes->Descriptor_ID = TxDesIndex;
468                         pMds->TxDesFrom[TxDesIndex] = 2; /* Storing the information of source comming from */
469                         pMds->TxDesIndex++;
470                         pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR;
471
472                         MLME_GetNextPacket(adapter, pTxDes);
473
474                         /* Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type */
475                         Mds_HeaderCopy(adapter, pTxDes, XmitBufAddress);
476
477                         /* For speed up Key setting */
478                         if (pTxDes->EapFix) {
479 #ifdef _PE_TX_DUMP_
480                                 printk("35: EPA 4th frame detected. Size = %d\n", PacketSize);
481 #endif
482                                 pHwData->IsKeyPreSet = 1;
483                         }
484
485                         /* Copy (fragment) frame body, and set USB, 802.11 hdr flag */
486                         CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress);
487
488                         /* Set RTS/CTS and Normal duration field into buffer */
489                         Mds_DurationSet(adapter, pTxDes, XmitBufAddress);
490
491                         /* Shift to the next address */
492                         XmitBufSize += CurrentSize;
493                         XmitBufAddress += CurrentSize;
494
495 #ifdef _IBSS_BEACON_SEQ_STICK_
496                         if ((XmitBufAddress[DOT_11_DA_OFFSET+8] & 0xfc) != MAC_SUBTYPE_MNGMNT_PROBE_REQUEST) /* +8 for USB hdr */
497 #endif
498                                 pMds->TxToggle = true;
499
500                         /* Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data */
501                         MLME_SendComplete(adapter, 0, true);
502
503                         /* Software TSC count 20060214 */
504                         pMds->TxTsc++;
505                         if (pMds->TxTsc == 0)
506                                 pMds->TxTsc_2++;
507
508                         FillCount++; /* 20060928 */
509                 } while (HAL_USB_MODE_BURST(pHwData)); /* End of multiple MSDU copy loop. false = single true = multiple sending  */
510
511                 /* Move to the next one, if necessary */
512                 if (BufferFilled) {
513                         /* size setting */
514                         pMds->TxBufferSize[FillIndex] = XmitBufSize;
515
516                         /* 20060928 set Tx count */
517                         pMds->TxCountInBuffer[FillIndex] = FillCount;
518
519                         /* Set owner flag */
520                         pMds->TxOwner[FillIndex] = 1;
521
522                         pMds->TxFillIndex++;
523                         pMds->TxFillIndex %= MAX_USB_TX_BUFFER_NUMBER;
524                         BufferFilled = false;
525                 } else
526                         break;
527
528                 if (!PacketSize) /* No more pk for transmitting */
529                         break;
530
531         } while (true);
532
533         /*
534          * Start to send by lower module
535          */
536         if (!pHwData->IsKeyPreSet)
537                 Wb35Tx_start(adapter);
538
539 cleanup:
540                 atomic_dec(&pMds->TxThreadCount);
541 }
542
543 void
544 Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pT02)
545 {
546         struct wb35_mds *pMds = &adapter->Mds;
547         struct hw_data *pHwData = &adapter->sHwData;
548         u8      PacketId = (u8)pT02->T02_Tx_PktID;
549         unsigned char   SendOK = true;
550         u8      RetryCount, TxRate;
551
552         if (pT02->T02_IgnoreResult) /* Don't care the result */
553                 return;
554         if (pT02->T02_IsLastMpdu) {
555                 /* TODO: DTO -- get the retry count and fragment count */
556                 /* Tx rate */
557                 TxRate = pMds->TxRate[PacketId][0];
558                 RetryCount = (u8)pT02->T02_MPDU_Cnt;
559                 if (pT02->value & FLAG_ERROR_TX_MASK) {
560                         SendOK = false;
561
562                         if (pT02->T02_transmit_abort || pT02->T02_out_of_MaxTxMSDULiftTime) {
563                                 /* retry error */
564                                 pHwData->dto_tx_retry_count += (RetryCount+1);
565                                 /* [for tx debug] */
566                                 if (RetryCount < 7)
567                                         pHwData->tx_retry_count[RetryCount] += RetryCount;
568                                 else
569                                         pHwData->tx_retry_count[7] += RetryCount;
570                                 #ifdef _PE_STATE_DUMP_
571                                 printk("dto_tx_retry_count =%d\n", pHwData->dto_tx_retry_count);
572                                 #endif
573                                 MTO_SetTxCount(adapter, TxRate, RetryCount);
574                         }
575                         pHwData->dto_tx_frag_count += (RetryCount+1);
576
577                         /* [for tx debug] */
578                         if (pT02->T02_transmit_abort_due_to_TBTT)
579                                 pHwData->tx_TBTT_start_count++;
580                         if (pT02->T02_transmit_without_encryption_due_to_wep_on_false)
581                                 pHwData->tx_WepOn_false_count++;
582                         if (pT02->T02_discard_due_to_null_wep_key)
583                                 pHwData->tx_Null_key_count++;
584                 } else {
585                         if (pT02->T02_effective_transmission_rate)
586                                 pHwData->tx_ETR_count++;
587                         MTO_SetTxCount(adapter, TxRate, RetryCount);
588                 }
589
590                 /* Clear send result buffer */
591                 pMds->TxResult[PacketId] = 0;
592         } else
593                 pMds->TxResult[PacketId] |= ((u16)(pT02->value & 0x0ffff));
594 }