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