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