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