2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: handle WMAC/802.3/802.11 rx & tx functions
28 * s_vGenerateTxParameter - Generate tx dma required parameter.
29 * vGenerateMACHeader - Translate 802.3 to 802.11 header
30 * cbGetFragCount - Caculate fragment number count
31 * csBeacon_xmit - beacon tx function
32 * csMgmt_xmit - management tx function
33 * s_cbFillTxBufHead - fulfill tx dma buffer header
34 * s_uGetDataDuration - get tx data required duration
35 * s_uFillDataHead- fulfill tx data duration header
36 * s_uGetRTSCTSDuration- get rtx/cts required duration
37 * s_uGetRTSCTSRsvTime- get rts/cts reserved time
38 * s_uGetTxRsvTime- get frame reserved time
39 * s_vFillCTSHead- fulfill CTS ctl header
40 * s_vFillFragParameter- Set fragment ctl parameter.
41 * s_vFillRTSHead- fulfill RTS ctl header
42 * s_vFillTxKey- fulfill tx encrypt key
43 * s_vSWencryption- Software encrypt header
44 * vDMA0_tx_80211- tx 802.11 frame via dma0
45 * vGenerateFIFOHeader- Generate tx FIFO ctl header
66 /*--------------------- Static Definitions -------------------------*/
68 /*--------------------- Static Classes ----------------------------*/
70 /*--------------------- Static Variables --------------------------*/
71 //static int msglevel =MSG_LEVEL_DEBUG;
72 static int msglevel
=MSG_LEVEL_INFO
;
77 /*--------------------- Static Functions --------------------------*/
79 /*--------------------- Static Definitions -------------------------*/
80 #define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send
81 // packet size >= 256 -> direct send
83 const unsigned short wTimeStampOff
[2][MAX_RATE
] = {
84 {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
85 {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble
88 const unsigned short wFB_Opt0
[2][5] = {
89 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
, RATE_48M
}, // fallback_rate0
90 {RATE_12M
, RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
}, // fallback_rate1
92 const unsigned short wFB_Opt1
[2][5] = {
93 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_24M
, RATE_36M
}, // fallback_rate0
94 {RATE_6M
, RATE_6M
, RATE_12M
, RATE_12M
, RATE_18M
}, // fallback_rate1
102 #define RTSDUR_BA_F0 4
103 #define RTSDUR_AA_F0 5
104 #define RTSDUR_BA_F1 6
105 #define RTSDUR_AA_F1 7
106 #define CTSDUR_BA_F0 8
107 #define CTSDUR_BA_F1 9
110 #define DATADUR_A_F0 12
111 #define DATADUR_A_F1 13
113 /*--------------------- Static Functions --------------------------*/
121 unsigned char *pbyBuf
,
122 unsigned char *pbyIVHead
,
123 PSKeyItem pTransmitKey
,
124 unsigned char *pbyHdrBuf
,
125 unsigned short wPayloadLen
,
126 unsigned char *pMICHDR
135 unsigned char byPktType
,
137 unsigned int cbFrameLength
,
140 PSEthernetHeader psEthHeader
,
141 unsigned short wCurrentRate
,
142 unsigned char byFBOption
147 s_vGenerateTxParameter(
149 unsigned char byPktType
,
154 unsigned int cbFrameSize
,
156 unsigned int uDMAIdx
,
157 PSEthernetHeader psEthHeader
,
158 unsigned short wCurrentRate
163 static void s_vFillFragParameter(
165 unsigned char *pbyBuffer
,
166 unsigned int uTxType
,
168 unsigned short wFragType
,
169 unsigned int cbReqCount
174 s_cbFillTxBufHead(PSDevice pDevice
, unsigned char byPktType
, unsigned char *pbyTxBufferAddr
,
175 unsigned int cbFrameBodySize
, unsigned int uDMAIdx
, PSTxDesc pHeadTD
,
176 PSEthernetHeader psEthHeader
, unsigned char *pPacket
, bool bNeedEncrypt
,
177 PSKeyItem pTransmitKey
, unsigned int uNodeIndex
, unsigned int *puMACfragNum
);
184 unsigned char byPktType
,
186 unsigned int cbFrameLength
,
187 unsigned int uDMAIdx
,
189 unsigned int uFragIdx
,
190 unsigned int cbLastFragmentSize
,
191 unsigned int uMACfragNum
,
192 unsigned char byFBOption
,
193 unsigned short wCurrentRate
197 /*--------------------- Export Variables --------------------------*/
205 unsigned char *pbyBuf
,
206 unsigned char *pbyIVHead
,
207 PSKeyItem pTransmitKey
,
208 unsigned char *pbyHdrBuf
,
209 unsigned short wPayloadLen
,
210 unsigned char *pMICHDR
213 unsigned long *pdwIV
= (unsigned long *) pbyIVHead
;
214 unsigned long *pdwExtIV
= (unsigned long *) ((unsigned char *)pbyIVHead
+4);
215 unsigned short wValue
;
216 PS802_11Header pMACHeader
= (PS802_11Header
)pbyHdrBuf
;
217 unsigned long dwRevIVCounter
;
218 unsigned char byKeyIndex
= 0;
223 if (pTransmitKey
== NULL
)
226 dwRevIVCounter
= cpu_to_le32(pDevice
->dwIVCounter
);
227 *pdwIV
= pDevice
->dwIVCounter
;
228 byKeyIndex
= pTransmitKey
->dwKeyIndex
& 0xf;
230 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
231 if (pTransmitKey
->uKeyLength
== WLAN_WEP232_KEYLEN
){
232 memcpy(pDevice
->abyPRNG
, (unsigned char *)&(dwRevIVCounter
), 3);
233 memcpy(pDevice
->abyPRNG
+3, pTransmitKey
->abyKey
, pTransmitKey
->uKeyLength
);
235 memcpy(pbyBuf
, (unsigned char *)&(dwRevIVCounter
), 3);
236 memcpy(pbyBuf
+3, pTransmitKey
->abyKey
, pTransmitKey
->uKeyLength
);
237 if(pTransmitKey
->uKeyLength
== WLAN_WEP40_KEYLEN
) {
238 memcpy(pbyBuf
+8, (unsigned char *)&(dwRevIVCounter
), 3);
239 memcpy(pbyBuf
+11, pTransmitKey
->abyKey
, pTransmitKey
->uKeyLength
);
241 memcpy(pDevice
->abyPRNG
, pbyBuf
, 16);
243 // Append IV after Mac Header
244 *pdwIV
&= WEP_IV_MASK
;//00000000 11111111 11111111 11111111
245 *pdwIV
|= (byKeyIndex
<< 30);
246 *pdwIV
= cpu_to_le32(*pdwIV
);
247 pDevice
->dwIVCounter
++;
248 if (pDevice
->dwIVCounter
> WEP_IV_MASK
) {
249 pDevice
->dwIVCounter
= 0;
251 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
252 pTransmitKey
->wTSC15_0
++;
253 if (pTransmitKey
->wTSC15_0
== 0) {
254 pTransmitKey
->dwTSC47_16
++;
256 TKIPvMixKey(pTransmitKey
->abyKey
, pDevice
->abyCurrentNetAddr
,
257 pTransmitKey
->wTSC15_0
, pTransmitKey
->dwTSC47_16
, pDevice
->abyPRNG
);
258 memcpy(pbyBuf
, pDevice
->abyPRNG
, 16);
260 memcpy(pdwIV
, pDevice
->abyPRNG
, 3);
262 *(pbyIVHead
+3) = (unsigned char)(((byKeyIndex
<< 6) & 0xc0) | 0x20); // 0x20 is ExtIV
263 // Append IV&ExtIV after Mac Header
264 *pdwExtIV
= cpu_to_le32(pTransmitKey
->dwTSC47_16
);
265 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vFillTxKey()---- pdwExtIV: %lx\n", *pdwExtIV
);
267 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) {
268 pTransmitKey
->wTSC15_0
++;
269 if (pTransmitKey
->wTSC15_0
== 0) {
270 pTransmitKey
->dwTSC47_16
++;
272 memcpy(pbyBuf
, pTransmitKey
->abyKey
, 16);
276 *(pbyIVHead
+3) = (unsigned char)(((byKeyIndex
<< 6) & 0xc0) | 0x20); // 0x20 is ExtIV
277 *pdwIV
|= cpu_to_le16((unsigned short)(pTransmitKey
->wTSC15_0
));
278 //Append IV&ExtIV after Mac Header
279 *pdwExtIV
= cpu_to_le32(pTransmitKey
->dwTSC47_16
);
283 *((unsigned char *)(pMICHDR
+1)) = 0; // TxPriority
284 memcpy(pMICHDR
+2, &(pMACHeader
->abyAddr2
[0]), 6);
285 *((unsigned char *)(pMICHDR
+8)) = HIBYTE(HIWORD(pTransmitKey
->dwTSC47_16
));
286 *((unsigned char *)(pMICHDR
+9)) = LOBYTE(HIWORD(pTransmitKey
->dwTSC47_16
));
287 *((unsigned char *)(pMICHDR
+10)) = HIBYTE(LOWORD(pTransmitKey
->dwTSC47_16
));
288 *((unsigned char *)(pMICHDR
+11)) = LOBYTE(LOWORD(pTransmitKey
->dwTSC47_16
));
289 *((unsigned char *)(pMICHDR
+12)) = HIBYTE(pTransmitKey
->wTSC15_0
);
290 *((unsigned char *)(pMICHDR
+13)) = LOBYTE(pTransmitKey
->wTSC15_0
);
291 *((unsigned char *)(pMICHDR
+14)) = HIBYTE(wPayloadLen
);
292 *((unsigned char *)(pMICHDR
+15)) = LOBYTE(wPayloadLen
);
295 *((unsigned char *)(pMICHDR
+16)) = 0; // HLEN[15:8]
296 if (pDevice
->bLongHeader
) {
297 *((unsigned char *)(pMICHDR
+17)) = 28; // HLEN[7:0]
299 *((unsigned char *)(pMICHDR
+17)) = 22; // HLEN[7:0]
301 wValue
= cpu_to_le16(pMACHeader
->wFrameCtl
& 0xC78F);
302 memcpy(pMICHDR
+18, (unsigned char *)&wValue
, 2); // MSKFRACTL
303 memcpy(pMICHDR
+20, &(pMACHeader
->abyAddr1
[0]), 6);
304 memcpy(pMICHDR
+26, &(pMACHeader
->abyAddr2
[0]), 6);
307 memcpy(pMICHDR
+32, &(pMACHeader
->abyAddr3
[0]), 6);
308 wValue
= pMACHeader
->wSeqCtl
;
310 wValue
= cpu_to_le16(wValue
);
311 memcpy(pMICHDR
+38, (unsigned char *)&wValue
, 2); // MSKSEQCTL
312 if (pDevice
->bLongHeader
) {
313 memcpy(pMICHDR
+40, &(pMACHeader
->abyAddr4
[0]), 6);
323 PSKeyItem pTransmitKey
,
324 unsigned char *pbyPayloadHead
,
325 unsigned short wPayloadSize
328 unsigned int cbICVlen
= 4;
329 unsigned long dwICV
= 0xFFFFFFFFL
;
330 unsigned long *pdwICV
;
332 if (pTransmitKey
== NULL
)
335 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
336 //=======================================================================
337 // Append ICV after payload
338 dwICV
= CRCdwGetCrc32Ex(pbyPayloadHead
, wPayloadSize
, dwICV
);//ICV(Payload)
339 pdwICV
= (unsigned long *)(pbyPayloadHead
+ wPayloadSize
);
340 // finally, we must invert dwCRC to get the correct answer
341 *pdwICV
= cpu_to_le32(~dwICV
);
343 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+ 3);
344 rc4_encrypt(&pDevice
->SBox
, pbyPayloadHead
, pbyPayloadHead
, wPayloadSize
+cbICVlen
);
345 //=======================================================================
346 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
347 //=======================================================================
348 //Append ICV after payload
349 dwICV
= CRCdwGetCrc32Ex(pbyPayloadHead
, wPayloadSize
, dwICV
);//ICV(Payload)
350 pdwICV
= (unsigned long *)(pbyPayloadHead
+ wPayloadSize
);
351 // finally, we must invert dwCRC to get the correct answer
352 *pdwICV
= cpu_to_le32(~dwICV
);
354 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, TKIP_KEY_LEN
);
355 rc4_encrypt(&pDevice
->SBox
, pbyPayloadHead
, pbyPayloadHead
, wPayloadSize
+cbICVlen
);
356 //=======================================================================
363 /*byPktType : PK_TYPE_11A 0
372 unsigned char byPktType
,
373 unsigned int cbFrameLength
,
374 unsigned short wRate
,
378 unsigned int uDataTime
, uAckTime
;
380 uDataTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, cbFrameLength
, wRate
);
382 //printk("s_uGetTxRsvTime is %d\n",uDataTime);
384 if (byPktType
== PK_TYPE_11B
) {//llb,CCK mode
385 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, (unsigned short)pDevice
->byTopCCKBasicRate
);
386 } else {//11g 2.4G OFDM mode & 11a 5G OFDM mode
387 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, (unsigned short)pDevice
->byTopOFDMBasicRate
);
391 return (uDataTime
+ pDevice
->uSIFS
+ uAckTime
);
398 //byFreqType: 0=>5GHZ 1=>2.4GHZ
401 s_uGetRTSCTSRsvTime (
403 unsigned char byRTSRsvType
,
404 unsigned char byPktType
,
405 unsigned int cbFrameLength
,
406 unsigned short wCurrentRate
409 unsigned int uRrvTime
, uRTSTime
, uCTSTime
, uAckTime
, uDataTime
;
411 uRrvTime
= uRTSTime
= uCTSTime
= uAckTime
= uDataTime
= 0;
414 uDataTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, cbFrameLength
, wCurrentRate
);
415 if (byRTSRsvType
== 0) { //RTSTxRrvTime_bb
416 uRTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 20, pDevice
->byTopCCKBasicRate
);
417 uCTSTime
= uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
419 else if (byRTSRsvType
== 1){ //RTSTxRrvTime_ba, only in 2.4GHZ
420 uRTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 20, pDevice
->byTopCCKBasicRate
);
421 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
422 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
424 else if (byRTSRsvType
== 2) { //RTSTxRrvTime_aa
425 uRTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 20, pDevice
->byTopOFDMBasicRate
);
426 uCTSTime
= uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
428 else if (byRTSRsvType
== 3) { //CTSTxRrvTime_ba, only in 2.4GHZ
429 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
430 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
431 uRrvTime
= uCTSTime
+ uAckTime
+ uDataTime
+ 2*pDevice
->uSIFS
;
436 uRrvTime
= uRTSTime
+ uCTSTime
+ uAckTime
+ uDataTime
+ 3*pDevice
->uSIFS
;
440 //byFreqType 0: 5GHz, 1:2.4Ghz
445 unsigned char byDurType
,
446 unsigned int cbFrameLength
,
447 unsigned char byPktType
,
448 unsigned short wRate
,
450 unsigned int uFragIdx
,
451 unsigned int cbLastFragmentSize
,
452 unsigned int uMACfragNum
,
453 unsigned char byFBOption
457 unsigned int uAckTime
=0, uNextPktTime
= 0;
461 if (uFragIdx
== (uMACfragNum
-1)) {
468 case DATADUR_B
: //DATADUR_B
469 if (((uMACfragNum
== 1)) || (bLastFrag
== 1)) {//Non Frag or Last Frag
471 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
472 return (pDevice
->uSIFS
+ uAckTime
);
477 else {//First Frag or Mid Frag
478 if (uFragIdx
== (uMACfragNum
-2)) {
479 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wRate
, bNeedAck
);
481 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
484 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
485 return (pDevice
->uSIFS
+ uAckTime
+ uNextPktTime
);
487 return (pDevice
->uSIFS
+ uNextPktTime
);
492 case DATADUR_A
: //DATADUR_A
493 if (((uMACfragNum
==1)) || (bLastFrag
==1)) {//Non Frag or Last Frag
495 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
496 return (pDevice
->uSIFS
+ uAckTime
);
501 else {//First Frag or Mid Frag
502 if(uFragIdx
== (uMACfragNum
-2)){
503 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wRate
, bNeedAck
);
505 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
508 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
509 return (pDevice
->uSIFS
+ uAckTime
+ uNextPktTime
);
511 return (pDevice
->uSIFS
+ uNextPktTime
);
516 case DATADUR_A_F0
: //DATADUR_A_F0
517 if (((uMACfragNum
==1)) || (bLastFrag
==1)) {//Non Frag or Last Frag
519 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
520 return (pDevice
->uSIFS
+ uAckTime
);
525 else { //First Frag or Mid Frag
526 if (byFBOption
== AUTO_FB_0
) {
527 if (wRate
< RATE_18M
)
529 else if (wRate
> RATE_54M
)
532 if(uFragIdx
== (uMACfragNum
-2)){
533 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wFB_Opt0
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
535 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
537 } else { // (byFBOption == AUTO_FB_1)
538 if (wRate
< RATE_18M
)
540 else if (wRate
> RATE_54M
)
543 if(uFragIdx
== (uMACfragNum
-2)){
544 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wFB_Opt1
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
546 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
551 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
552 return (pDevice
->uSIFS
+ uAckTime
+ uNextPktTime
);
554 return (pDevice
->uSIFS
+ uNextPktTime
);
559 case DATADUR_A_F1
: //DATADUR_A_F1
560 if (((uMACfragNum
==1)) || (bLastFrag
==1)) {//Non Frag or Last Frag
562 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
563 return (pDevice
->uSIFS
+ uAckTime
);
568 else { //First Frag or Mid Frag
569 if (byFBOption
== AUTO_FB_0
) {
570 if (wRate
< RATE_18M
)
572 else if (wRate
> RATE_54M
)
575 if(uFragIdx
== (uMACfragNum
-2)){
576 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wFB_Opt0
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
578 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
581 } else { // (byFBOption == AUTO_FB_1)
582 if (wRate
< RATE_18M
)
584 else if (wRate
> RATE_54M
)
587 if(uFragIdx
== (uMACfragNum
-2)){
588 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbLastFragmentSize
, wFB_Opt1
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
590 uNextPktTime
= s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
594 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
595 return (pDevice
->uSIFS
+ uAckTime
+ uNextPktTime
);
597 return (pDevice
->uSIFS
+ uNextPktTime
);
611 //byFreqType: 0=>5GHZ 1=>2.4GHZ
614 s_uGetRTSCTSDuration (
616 unsigned char byDurType
,
617 unsigned int cbFrameLength
,
618 unsigned char byPktType
,
619 unsigned short wRate
,
621 unsigned char byFBOption
624 unsigned int uCTSTime
= 0, uDurTime
= 0;
629 case RTSDUR_BB
: //RTSDuration_bb
630 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
631 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
634 case RTSDUR_BA
: //RTSDuration_ba
635 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
636 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
639 case RTSDUR_AA
: //RTSDuration_aa
640 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
641 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
644 case CTSDUR_BA
: //CTSDuration_ba
645 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wRate
, bNeedAck
);
648 case RTSDUR_BA_F0
: //RTSDuration_ba_f0
649 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
650 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
651 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
652 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
653 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
657 case RTSDUR_AA_F0
: //RTSDuration_aa_f0
658 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
659 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
660 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
661 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
662 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
666 case RTSDUR_BA_F1
: //RTSDuration_ba_f1
667 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopCCKBasicRate
);
668 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
669 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
670 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
671 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
675 case RTSDUR_AA_F1
: //RTSDuration_aa_f1
676 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
677 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
678 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
679 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
680 uDurTime
= uCTSTime
+ 2*pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
684 case CTSDUR_BA_F0
: //CTSDuration_ba_f0
685 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
686 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
687 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
688 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE0
][wRate
-RATE_18M
], bNeedAck
);
692 case CTSDUR_BA_F1
: //CTSDuration_ba_f1
693 if ((byFBOption
== AUTO_FB_0
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
694 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt0
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
695 } else if ((byFBOption
== AUTO_FB_1
) && (wRate
>= RATE_18M
) && (wRate
<=RATE_54M
)) {
696 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameLength
, wFB_Opt1
[FB_RATE1
][wRate
-RATE_18M
], bNeedAck
);
714 unsigned char byPktType
,
716 unsigned int cbFrameLength
,
717 unsigned int uDMAIdx
,
719 unsigned int uFragIdx
,
720 unsigned int cbLastFragmentSize
,
721 unsigned int uMACfragNum
,
722 unsigned char byFBOption
,
723 unsigned short wCurrentRate
726 unsigned short wLen
= 0x0000;
728 if (pTxDataHead
== NULL
) {
732 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
733 if (byFBOption
== AUTO_FB_NONE
) {
734 PSTxDataHead_g pBuf
= (PSTxDataHead_g
)pTxDataHead
;
735 //Get SignalField,ServiceField,Length
736 BBvCaculateParameter(pDevice
, cbFrameLength
, wCurrentRate
, byPktType
,
737 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_a
), (unsigned char *)&(pBuf
->bySignalField_a
)
739 pBuf
->wTransmitLength_a
= cpu_to_le16(wLen
);
740 BBvCaculateParameter(pDevice
, cbFrameLength
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
741 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
743 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
744 //Get Duration and TimeStamp
745 pBuf
->wDuration_a
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A
, cbFrameLength
,
746 byPktType
, wCurrentRate
, bNeedAck
, uFragIdx
,
747 cbLastFragmentSize
, uMACfragNum
,
748 byFBOption
)); //1: 2.4GHz
749 pBuf
->wDuration_b
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_B
, cbFrameLength
,
750 PK_TYPE_11B
, pDevice
->byTopCCKBasicRate
,
751 bNeedAck
, uFragIdx
, cbLastFragmentSize
,
752 uMACfragNum
, byFBOption
)); //1: 2.4
754 pBuf
->wTimeStampOff_a
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
755 pBuf
->wTimeStampOff_b
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][pDevice
->byTopCCKBasicRate
%MAX_RATE
]);
757 return (pBuf
->wDuration_a
);
760 PSTxDataHead_g_FB pBuf
= (PSTxDataHead_g_FB
)pTxDataHead
;
761 //Get SignalField,ServiceField,Length
762 BBvCaculateParameter(pDevice
, cbFrameLength
, wCurrentRate
, byPktType
,
763 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_a
), (unsigned char *)&(pBuf
->bySignalField_a
)
765 pBuf
->wTransmitLength_a
= cpu_to_le16(wLen
);
766 BBvCaculateParameter(pDevice
, cbFrameLength
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
767 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
769 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
770 //Get Duration and TimeStamp
771 pBuf
->wDuration_a
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A
, cbFrameLength
, byPktType
,
772 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //1: 2.4GHz
773 pBuf
->wDuration_b
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_B
, cbFrameLength
, PK_TYPE_11B
,
774 pDevice
->byTopCCKBasicRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //1: 2.4GHz
775 pBuf
->wDuration_a_f0
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A_F0
, cbFrameLength
, byPktType
,
776 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //1: 2.4GHz
777 pBuf
->wDuration_a_f1
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A_F1
, cbFrameLength
, byPktType
,
778 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //1: 2.4GHz
780 pBuf
->wTimeStampOff_a
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
781 pBuf
->wTimeStampOff_b
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][pDevice
->byTopCCKBasicRate
%MAX_RATE
]);
783 return (pBuf
->wDuration_a
);
784 } //if (byFBOption == AUTO_FB_NONE)
786 else if (byPktType
== PK_TYPE_11A
) {
787 if ((byFBOption
!= AUTO_FB_NONE
)) {
789 PSTxDataHead_a_FB pBuf
= (PSTxDataHead_a_FB
)pTxDataHead
;
790 //Get SignalField,ServiceField,Length
791 BBvCaculateParameter(pDevice
, cbFrameLength
, wCurrentRate
, byPktType
,
792 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
794 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
795 //Get Duration and TimeStampOff
797 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A
, cbFrameLength
, byPktType
,
798 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //0: 5GHz
799 pBuf
->wDuration_f0
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A_F0
, cbFrameLength
, byPktType
,
800 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //0: 5GHz
801 pBuf
->wDuration_f1
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A_F1
, cbFrameLength
, byPktType
,
802 wCurrentRate
, bNeedAck
, uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
)); //0: 5GHz
803 pBuf
->wTimeStampOff
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
804 return (pBuf
->wDuration
);
806 PSTxDataHead_ab pBuf
= (PSTxDataHead_ab
)pTxDataHead
;
807 //Get SignalField,ServiceField,Length
808 BBvCaculateParameter(pDevice
, cbFrameLength
, wCurrentRate
, byPktType
,
809 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
811 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
812 //Get Duration and TimeStampOff
814 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A
, cbFrameLength
, byPktType
,
815 wCurrentRate
, bNeedAck
, uFragIdx
,
816 cbLastFragmentSize
, uMACfragNum
,
819 pBuf
->wTimeStampOff
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
820 return (pBuf
->wDuration
);
824 PSTxDataHead_ab pBuf
= (PSTxDataHead_ab
)pTxDataHead
;
825 //Get SignalField,ServiceField,Length
826 BBvCaculateParameter(pDevice
, cbFrameLength
, wCurrentRate
, byPktType
,
827 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
829 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
830 //Get Duration and TimeStampOff
831 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_B
, cbFrameLength
, byPktType
,
832 wCurrentRate
, bNeedAck
, uFragIdx
,
833 cbLastFragmentSize
, uMACfragNum
,
835 pBuf
->wTimeStampOff
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
836 return (pBuf
->wDuration
);
846 unsigned char byPktType
,
848 unsigned int cbFrameLength
,
851 PSEthernetHeader psEthHeader
,
852 unsigned short wCurrentRate
,
853 unsigned char byFBOption
856 unsigned int uRTSFrameLen
= 20;
857 unsigned short wLen
= 0x0000;
863 // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame,
864 // in this case we need to decrease its length by 4.
868 // Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
869 // Otherwise, we need to modify codes for them.
870 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
871 if (byFBOption
== AUTO_FB_NONE
) {
872 PSRTS_g pBuf
= (PSRTS_g
)pvRTS
;
873 //Get SignalField,ServiceField,Length
874 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
875 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
877 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
878 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopOFDMBasicRate
, byPktType
,
879 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_a
), (unsigned char *)&(pBuf
->bySignalField_a
)
881 pBuf
->wTransmitLength_a
= cpu_to_le16(wLen
);
883 pBuf
->wDuration_bb
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BB
, cbFrameLength
, PK_TYPE_11B
, pDevice
->byTopCCKBasicRate
, bNeedAck
, byFBOption
)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
884 pBuf
->wDuration_aa
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData
885 pBuf
->wDuration_ba
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
887 pBuf
->Data
.wDurationID
= pBuf
->wDuration_aa
;
889 pBuf
->Data
.wFrameControl
= TYPE_CTL_RTS
;//0x00B4
890 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
891 (pDevice
->eOPMode
== OP_MODE_AP
)) {
892 memcpy(&(pBuf
->Data
.abyRA
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
895 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
897 if (pDevice
->eOPMode
== OP_MODE_AP
) {
898 memcpy(&(pBuf
->Data
.abyTA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
901 memcpy(&(pBuf
->Data
.abyTA
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
905 PSRTS_g_FB pBuf
= (PSRTS_g_FB
)pvRTS
;
906 //Get SignalField,ServiceField,Length
907 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
908 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
910 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
911 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopOFDMBasicRate
, byPktType
,
912 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_a
), (unsigned char *)&(pBuf
->bySignalField_a
)
914 pBuf
->wTransmitLength_a
= cpu_to_le16(wLen
);
917 pBuf
->wDuration_bb
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BB
, cbFrameLength
, PK_TYPE_11B
, pDevice
->byTopCCKBasicRate
, bNeedAck
, byFBOption
)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
918 pBuf
->wDuration_aa
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //2:RTSDuration_aa, 1:2.4G, 2,3:2.4G OFDMData
919 pBuf
->wDuration_ba
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDMData
920 pBuf
->wRTSDuration_ba_f0
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BA_F0
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //4:wRTSDuration_ba_f0, 1:2.4G, 1:CCKData
921 pBuf
->wRTSDuration_aa_f0
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA_F0
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData
922 pBuf
->wRTSDuration_ba_f1
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BA_F1
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData
923 pBuf
->wRTSDuration_aa_f1
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA_F1
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData
924 pBuf
->Data
.wDurationID
= pBuf
->wDuration_aa
;
926 pBuf
->Data
.wFrameControl
= TYPE_CTL_RTS
;//0x00B4
928 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
929 (pDevice
->eOPMode
== OP_MODE_AP
)) {
930 memcpy(&(pBuf
->Data
.abyRA
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
933 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
936 if (pDevice
->eOPMode
== OP_MODE_AP
) {
937 memcpy(&(pBuf
->Data
.abyTA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
940 memcpy(&(pBuf
->Data
.abyTA
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
943 } // if (byFBOption == AUTO_FB_NONE)
945 else if (byPktType
== PK_TYPE_11A
) {
946 if (byFBOption
== AUTO_FB_NONE
) {
947 PSRTS_ab pBuf
= (PSRTS_ab
)pvRTS
;
948 //Get SignalField,ServiceField,Length
949 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopOFDMBasicRate
, byPktType
,
950 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
952 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
954 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
955 pBuf
->Data
.wDurationID
= pBuf
->wDuration
;
957 pBuf
->Data
.wFrameControl
= TYPE_CTL_RTS
;//0x00B4
959 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
960 (pDevice
->eOPMode
== OP_MODE_AP
)) {
961 memcpy(&(pBuf
->Data
.abyRA
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
964 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
967 if (pDevice
->eOPMode
== OP_MODE_AP
) {
968 memcpy(&(pBuf
->Data
.abyTA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
971 memcpy(&(pBuf
->Data
.abyTA
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
976 PSRTS_a_FB pBuf
= (PSRTS_a_FB
)pvRTS
;
977 //Get SignalField,ServiceField,Length
978 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopOFDMBasicRate
, byPktType
,
979 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
981 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
983 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData
984 pBuf
->wRTSDuration_f0
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA_F0
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData
985 pBuf
->wRTSDuration_f1
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_AA_F1
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //7:RTSDuration_aa_f1, 0:5G, 0:
986 pBuf
->Data
.wDurationID
= pBuf
->wDuration
;
988 pBuf
->Data
.wFrameControl
= TYPE_CTL_RTS
;//0x00B4
990 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
991 (pDevice
->eOPMode
== OP_MODE_AP
)) {
992 memcpy(&(pBuf
->Data
.abyRA
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
995 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
997 if (pDevice
->eOPMode
== OP_MODE_AP
) {
998 memcpy(&(pBuf
->Data
.abyTA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
1001 memcpy(&(pBuf
->Data
.abyTA
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
1005 else if (byPktType
== PK_TYPE_11B
) {
1006 PSRTS_ab pBuf
= (PSRTS_ab
)pvRTS
;
1007 //Get SignalField,ServiceField,Length
1008 BBvCaculateParameter(pDevice
, uRTSFrameLen
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
1009 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField
), (unsigned char *)&(pBuf
->bySignalField
)
1011 pBuf
->wTransmitLength
= cpu_to_le16(wLen
);
1013 pBuf
->wDuration
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, RTSDUR_BB
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData
1014 pBuf
->Data
.wDurationID
= pBuf
->wDuration
;
1015 //Get RTS Frame body
1016 pBuf
->Data
.wFrameControl
= TYPE_CTL_RTS
;//0x00B4
1019 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
1020 (pDevice
->eOPMode
== OP_MODE_AP
)) {
1021 memcpy(&(pBuf
->Data
.abyRA
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
1024 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
1027 if (pDevice
->eOPMode
== OP_MODE_AP
) {
1028 memcpy(&(pBuf
->Data
.abyTA
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
1031 memcpy(&(pBuf
->Data
.abyTA
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
1040 unsigned int uDMAIdx
,
1041 unsigned char byPktType
,
1043 unsigned int cbFrameLength
,
1046 unsigned short wCurrentRate
,
1047 unsigned char byFBOption
1050 unsigned int uCTSFrameLen
= 14;
1051 unsigned short wLen
= 0x0000;
1053 if (pvCTS
== NULL
) {
1058 // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame,
1059 // in this case we need to decrease its length by 4.
1063 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
1064 if (byFBOption
!= AUTO_FB_NONE
&& uDMAIdx
!= TYPE_ATIMDMA
&& uDMAIdx
!= TYPE_BEACONDMA
) {
1066 PSCTS_FB pBuf
= (PSCTS_FB
)pvCTS
;
1067 //Get SignalField,ServiceField,Length
1068 BBvCaculateParameter(pDevice
, uCTSFrameLen
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
1069 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
1073 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
1075 pBuf
->wDuration_ba
= (unsigned short)s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
1076 pBuf
->wDuration_ba
+= pDevice
->wCTSDuration
;
1077 pBuf
->wDuration_ba
= cpu_to_le16(pBuf
->wDuration_ba
);
1078 //Get CTSDuration_ba_f0
1079 pBuf
->wCTSDuration_ba_f0
= (unsigned short)s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA_F0
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
); //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data
1080 pBuf
->wCTSDuration_ba_f0
+= pDevice
->wCTSDuration
;
1081 pBuf
->wCTSDuration_ba_f0
= cpu_to_le16(pBuf
->wCTSDuration_ba_f0
);
1082 //Get CTSDuration_ba_f1
1083 pBuf
->wCTSDuration_ba_f1
= (unsigned short)s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA_F1
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data
1084 pBuf
->wCTSDuration_ba_f1
+= pDevice
->wCTSDuration
;
1085 pBuf
->wCTSDuration_ba_f1
= cpu_to_le16(pBuf
->wCTSDuration_ba_f1
);
1086 //Get CTS Frame body
1087 pBuf
->Data
.wDurationID
= pBuf
->wDuration_ba
;
1088 pBuf
->Data
.wFrameControl
= TYPE_CTL_CTS
;//0x00C4
1089 pBuf
->Data
.wReserved
= 0x0000;
1090 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyCurrentNetAddr
[0]), ETH_ALEN
);
1092 } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA)
1093 PSCTS pBuf
= (PSCTS
)pvCTS
;
1094 //Get SignalField,ServiceField,Length
1095 BBvCaculateParameter(pDevice
, uCTSFrameLen
, pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
,
1096 (unsigned short *)&(wLen
), (unsigned char *)&(pBuf
->byServiceField_b
), (unsigned char *)&(pBuf
->bySignalField_b
)
1098 pBuf
->wTransmitLength_b
= cpu_to_le16(wLen
);
1099 //Get CTSDuration_ba
1100 pBuf
->wDuration_ba
= cpu_to_le16((unsigned short)s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA
, cbFrameLength
, byPktType
, wCurrentRate
, bNeedAck
, byFBOption
)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data
1101 pBuf
->wDuration_ba
+= pDevice
->wCTSDuration
;
1102 pBuf
->wDuration_ba
= cpu_to_le16(pBuf
->wDuration_ba
);
1104 //Get CTS Frame body
1105 pBuf
->Data
.wDurationID
= pBuf
->wDuration_ba
;
1106 pBuf
->Data
.wFrameControl
= TYPE_CTL_CTS
;//0x00C4
1107 pBuf
->Data
.wReserved
= 0x0000;
1108 memcpy(&(pBuf
->Data
.abyRA
[0]), &(pDevice
->abyCurrentNetAddr
[0]), ETH_ALEN
);
1121 * Generate FIFO control for MAC & Baseband controller
1125 * pDevice - Pointer to adapter
1126 * pTxDataHead - Transmit Data Buffer
1127 * pTxBufHead - pTxBufHead
1128 * pvRrvTime - pvRrvTime
1129 * pvRTS - RTS Buffer
1131 * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS)
1132 * bNeedACK - If need ACK
1133 * uDescIdx - Desc Index
1137 * Return Value: none
1140 // unsigned int cbFrameSize,//Hdr+Payload+FCS
1143 s_vGenerateTxParameter (
1145 unsigned char byPktType
,
1150 unsigned int cbFrameSize
,
1152 unsigned int uDMAIdx
,
1153 PSEthernetHeader psEthHeader
,
1154 unsigned short wCurrentRate
1157 unsigned int cbMACHdLen
= WLAN_HDR_ADDR3_LEN
; //24
1158 unsigned short wFifoCtl
;
1159 bool bDisCRC
= false;
1160 unsigned char byFBOption
= AUTO_FB_NONE
;
1161 // unsigned short wCurrentRate = pDevice->wCurrentRate;
1163 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n");
1164 PSTxBufHead pFifoHead
= (PSTxBufHead
)pTxBufHead
;
1165 pFifoHead
->wReserved
= wCurrentRate
;
1166 wFifoCtl
= pFifoHead
->wFIFOCtl
;
1168 if (wFifoCtl
& FIFOCTL_CRCDIS
) {
1172 if (wFifoCtl
& FIFOCTL_AUTO_FB_0
) {
1173 byFBOption
= AUTO_FB_0
;
1175 else if (wFifoCtl
& FIFOCTL_AUTO_FB_1
) {
1176 byFBOption
= AUTO_FB_1
;
1179 if (pDevice
->bLongHeader
)
1180 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
+ 6;
1182 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
1184 if (pvRTS
!= NULL
) { //RTS_need
1187 PSRrvTime_gRTS pBuf
= (PSRrvTime_gRTS
)pvRrvTime
;
1188 pBuf
->wRTSTxRrvTime_aa
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 2, byPktType
, cbFrameSize
, wCurrentRate
));//2:RTSTxRrvTime_aa, 1:2.4GHz
1189 pBuf
->wRTSTxRrvTime_ba
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 1, byPktType
, cbFrameSize
, wCurrentRate
));//1:RTSTxRrvTime_ba, 1:2.4GHz
1190 pBuf
->wRTSTxRrvTime_bb
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 0, byPktType
, cbFrameSize
, wCurrentRate
));//0:RTSTxRrvTime_bb, 1:2.4GHz
1191 pBuf
->wTxRrvTime_a
= cpu_to_le16((unsigned short) s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
));//2.4G OFDM
1192 pBuf
->wTxRrvTime_b
= cpu_to_le16((unsigned short) s_uGetTxRsvTime(pDevice
, PK_TYPE_11B
, cbFrameSize
, pDevice
->byTopCCKBasicRate
, bNeedACK
));//1:CCK
1195 s_vFillRTSHead(pDevice
, byPktType
, pvRTS
, cbFrameSize
, bNeedACK
, bDisCRC
, psEthHeader
, wCurrentRate
, byFBOption
);
1197 else {//RTS_needless, PCF mode
1201 PSRrvTime_gCTS pBuf
= (PSRrvTime_gCTS
)pvRrvTime
;
1202 pBuf
->wTxRrvTime_a
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
));//2.4G OFDM
1203 pBuf
->wTxRrvTime_b
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, PK_TYPE_11B
, cbFrameSize
, pDevice
->byTopCCKBasicRate
, bNeedACK
));//1:CCK
1204 pBuf
->wCTSTxRrvTime_ba
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 3, byPktType
, cbFrameSize
, wCurrentRate
));//3:CTSTxRrvTime_Ba, 1:2.4GHz
1209 s_vFillCTSHead(pDevice
, uDMAIdx
, byPktType
, pvCTS
, cbFrameSize
, bNeedACK
, bDisCRC
, wCurrentRate
, byFBOption
);
1212 else if (byPktType
== PK_TYPE_11A
) {
1214 if (pvRTS
!= NULL
) {//RTS_need, non PCF mode
1217 PSRrvTime_ab pBuf
= (PSRrvTime_ab
)pvRrvTime
;
1218 pBuf
->wRTSTxRrvTime
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 2, byPktType
, cbFrameSize
, wCurrentRate
));//2:RTSTxRrvTime_aa, 0:5GHz
1219 pBuf
->wTxRrvTime
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
));//0:OFDM
1222 s_vFillRTSHead(pDevice
, byPktType
, pvRTS
, cbFrameSize
, bNeedACK
, bDisCRC
, psEthHeader
, wCurrentRate
, byFBOption
);
1224 else if (pvRTS
== NULL
) {//RTS_needless, non PCF mode
1227 PSRrvTime_ab pBuf
= (PSRrvTime_ab
)pvRrvTime
;
1228 pBuf
->wTxRrvTime
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, PK_TYPE_11A
, cbFrameSize
, wCurrentRate
, bNeedACK
)); //0:OFDM
1232 else if (byPktType
== PK_TYPE_11B
) {
1234 if ((pvRTS
!= NULL
)) {//RTS_need, non PCF mode
1237 PSRrvTime_ab pBuf
= (PSRrvTime_ab
)pvRrvTime
;
1238 pBuf
->wRTSTxRrvTime
= cpu_to_le16((unsigned short)s_uGetRTSCTSRsvTime(pDevice
, 0, byPktType
, cbFrameSize
, wCurrentRate
));//0:RTSTxRrvTime_bb, 1:2.4GHz
1239 pBuf
->wTxRrvTime
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, PK_TYPE_11B
, cbFrameSize
, wCurrentRate
, bNeedACK
));//1:CCK
1242 s_vFillRTSHead(pDevice
, byPktType
, pvRTS
, cbFrameSize
, bNeedACK
, bDisCRC
, psEthHeader
, wCurrentRate
, byFBOption
);
1244 else { //RTS_needless, non PCF mode
1247 PSRrvTime_ab pBuf
= (PSRrvTime_ab
)pvRrvTime
;
1248 pBuf
->wTxRrvTime
= cpu_to_le16((unsigned short)s_uGetTxRsvTime(pDevice
, PK_TYPE_11B
, cbFrameSize
, wCurrentRate
, bNeedACK
)); //1:CCK
1252 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n");
1255 unsigned char *pbyBuffer,//point to pTxBufHead
1256 unsigned short wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last
1257 unsigned int cbFragmentSize,//Hdr+payoad+FCS
1261 s_vFillFragParameter(
1263 unsigned char *pbyBuffer
,
1264 unsigned int uTxType
,
1266 unsigned short wFragType
,
1267 unsigned int cbReqCount
1270 PSTxBufHead pTxBufHead
= (PSTxBufHead
) pbyBuffer
;
1271 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter...\n");
1273 if (uTxType
== TYPE_SYNCDMA
) {
1274 //PSTxSyncDesc ptdCurr = (PSTxSyncDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
1275 PSTxSyncDesc ptdCurr
= (PSTxSyncDesc
)pvtdCurr
;
1277 //Set FIFOCtl & TimeStamp in TxSyncDesc
1278 ptdCurr
->m_wFIFOCtl
= pTxBufHead
->wFIFOCtl
;
1279 ptdCurr
->m_wTimeStamp
= pTxBufHead
->wTimeStamp
;
1280 //Set TSR1 & ReqCount in TxDescHead
1281 ptdCurr
->m_td1TD1
.wReqCount
= cpu_to_le16((unsigned short)(cbReqCount
));
1282 if (wFragType
== FRAGCTL_ENDFRAG
) { //Last Fragmentation
1283 ptdCurr
->m_td1TD1
.byTCR
|= (TCR_STP
| TCR_EDP
| EDMSDU
);
1286 ptdCurr
->m_td1TD1
.byTCR
|= (TCR_STP
| TCR_EDP
);
1290 //PSTxDesc ptdCurr = (PSTxDesc)s_pvGetTxDescHead(pDevice, uTxType, uCurIdx);
1291 PSTxDesc ptdCurr
= (PSTxDesc
)pvtdCurr
;
1292 //Set TSR1 & ReqCount in TxDescHead
1293 ptdCurr
->m_td1TD1
.wReqCount
= cpu_to_le16((unsigned short)(cbReqCount
));
1294 if (wFragType
== FRAGCTL_ENDFRAG
) { //Last Fragmentation
1295 ptdCurr
->m_td1TD1
.byTCR
|= (TCR_STP
| TCR_EDP
| EDMSDU
);
1298 ptdCurr
->m_td1TD1
.byTCR
|= (TCR_STP
| TCR_EDP
);
1302 pTxBufHead
->wFragCtl
|= (unsigned short)wFragType
;//0x0001; //0000 0000 0000 0001
1304 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vFillFragParameter END\n");
1308 s_cbFillTxBufHead(PSDevice pDevice
, unsigned char byPktType
, unsigned char *pbyTxBufferAddr
,
1309 unsigned int cbFrameBodySize
, unsigned int uDMAIdx
, PSTxDesc pHeadTD
,
1310 PSEthernetHeader psEthHeader
, unsigned char *pPacket
, bool bNeedEncrypt
,
1311 PSKeyItem pTransmitKey
, unsigned int uNodeIndex
, unsigned int *puMACfragNum
)
1313 unsigned int cbMACHdLen
;
1314 unsigned int cbFrameSize
;
1315 unsigned int cbFragmentSize
; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
1316 unsigned int cbFragPayloadSize
;
1317 unsigned int cbLastFragmentSize
; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
1318 unsigned int cbLastFragPayloadSize
;
1319 unsigned int uFragIdx
;
1320 unsigned char *pbyPayloadHead
;
1321 unsigned char *pbyIVHead
;
1322 unsigned char *pbyMacHdr
;
1323 unsigned short wFragType
; //00:Non-Frag, 01:Start, 10:Mid, 11:Last
1324 unsigned int uDuration
;
1325 unsigned char *pbyBuffer
;
1326 // unsigned int uKeyEntryIdx = NUM_KEY_ENTRY+1;
1327 // unsigned char byKeySel = 0xFF;
1328 unsigned int cbIVlen
= 0;
1329 unsigned int cbICVlen
= 0;
1330 unsigned int cbMIClen
= 0;
1331 unsigned int cbFCSlen
= 4;
1332 unsigned int cb802_1_H_len
= 0;
1333 unsigned int uLength
= 0;
1334 unsigned int uTmpLen
= 0;
1335 // unsigned char abyTmp[8];
1336 // unsigned long dwCRC;
1337 unsigned int cbMICHDR
= 0;
1338 unsigned long dwMICKey0
, dwMICKey1
;
1339 unsigned long dwMIC_Priority
;
1340 unsigned long *pdwMIC_L
;
1341 unsigned long *pdwMIC_R
;
1342 unsigned long dwSafeMIC_L
, dwSafeMIC_R
; //Fix "Last Frag Size" < "MIC length".
1343 bool bMIC2Frag
= false;
1344 unsigned int uMICFragLen
= 0;
1345 unsigned int uMACfragNum
= 1;
1346 unsigned int uPadding
= 0;
1347 unsigned int cbReqCount
= 0;
1352 unsigned char *pbyType
;
1354 PSTxBufHead psTxBufHd
= (PSTxBufHead
) pbyTxBufferAddr
;
1355 // unsigned int tmpDescIdx;
1356 unsigned int cbHeaderLength
= 0;
1358 PSMICHDRHead pMICHDR
;
1362 unsigned short wTxBufSize
; // FFinfo size
1363 unsigned int uTotalCopyLength
= 0;
1364 unsigned char byFBOption
= AUTO_FB_NONE
;
1365 bool bIsWEP256
= false;
1366 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
1369 pvRrvTime
= pMICHDR
= pvRTS
= pvCTS
= pvTxDataHd
= NULL
;
1371 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_cbFillTxBufHead...\n");
1372 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
1373 (pDevice
->eOPMode
== OP_MODE_AP
)) {
1375 if (is_multicast_ether_addr(&(psEthHeader
->abyDstAddr
[0])))
1382 // MSDUs in Infra mode always need ACK
1387 if (pDevice
->bLongHeader
)
1388 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
+ 6;
1390 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
;
1393 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
)) {
1394 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
1397 if (pTransmitKey
->uKeyLength
== WLAN_WEP232_KEYLEN
) {
1401 if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
1402 cbIVlen
= 8;//IV+ExtIV
1406 if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) {
1407 cbIVlen
= 8;//RSN Header
1409 cbMICHDR
= sizeof(SMICHDRHead
);
1411 if (pDevice
->byLocalID
> REV_ID_VT3253_A1
) {
1412 //MAC Header should be padding 0 to DW alignment.
1413 uPadding
= 4 - (cbMACHdLen
%4);
1419 cbFrameSize
= cbMACHdLen
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbICVlen
+ cbFCSlen
;
1421 if ((bNeedACK
== false) ||
1422 (cbFrameSize
< pDevice
->wRTSThreshold
) ||
1423 ((cbFrameSize
>= pDevice
->wFragmentationThreshold
) && (pDevice
->wFragmentationThreshold
<= pDevice
->wRTSThreshold
))
1429 psTxBufHd
->wFIFOCtl
|= (FIFOCTL_RTS
| FIFOCTL_LRETRY
);
1432 // Use for AUTO FALL BACK
1434 if (psTxBufHd
->wFIFOCtl
& FIFOCTL_AUTO_FB_0
) {
1435 byFBOption
= AUTO_FB_0
;
1437 else if (psTxBufHd
->wFIFOCtl
& FIFOCTL_AUTO_FB_1
) {
1438 byFBOption
= AUTO_FB_1
;
1441 //////////////////////////////////////////////////////
1442 //Set RrvTime/RTS/CTS Buffer
1443 wTxBufSize
= sizeof(STxBufHead
);
1444 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1446 if (byFBOption
== AUTO_FB_NONE
) {
1447 if (bRTS
== true) {//RTS_need
1448 pvRrvTime
= (PSRrvTime_gRTS
) (pbyTxBufferAddr
+ wTxBufSize
);
1449 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
));
1450 pvRTS
= (PSRTS_g
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
);
1452 pvTxDataHd
= (PSTxDataHead_g
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
+ sizeof(SRTS_g
));
1453 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
+ sizeof(SRTS_g
) + sizeof(STxDataHead_g
);
1455 else { //RTS_needless
1456 pvRrvTime
= (PSRrvTime_gCTS
) (pbyTxBufferAddr
+ wTxBufSize
);
1457 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
));
1459 pvCTS
= (PSCTS
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
);
1460 pvTxDataHd
= (PSTxDataHead_g
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS
));
1461 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS
) + sizeof(STxDataHead_g
);
1465 if (bRTS
== true) {//RTS_need
1466 pvRrvTime
= (PSRrvTime_gRTS
) (pbyTxBufferAddr
+ wTxBufSize
);
1467 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
));
1468 pvRTS
= (PSRTS_g_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
);
1470 pvTxDataHd
= (PSTxDataHead_g_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
+ sizeof(SRTS_g_FB
));
1471 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_gRTS
) + cbMICHDR
+ sizeof(SRTS_g_FB
) + sizeof(STxDataHead_g_FB
);
1473 else { //RTS_needless
1474 pvRrvTime
= (PSRrvTime_gCTS
) (pbyTxBufferAddr
+ wTxBufSize
);
1475 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
));
1477 pvCTS
= (PSCTS_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
);
1478 pvTxDataHd
= (PSTxDataHead_g_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS_FB
));
1479 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS_FB
) + sizeof(STxDataHead_g_FB
);
1483 else {//802.11a/b packet
1485 if (byFBOption
== AUTO_FB_NONE
) {
1487 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
1488 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
1489 pvRTS
= (PSRTS_ab
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
);
1491 pvTxDataHd
= (PSTxDataHead_ab
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(PSRrvTime_ab
) + cbMICHDR
+ sizeof(SRTS_ab
));
1492 cbHeaderLength
= wTxBufSize
+ sizeof(PSRrvTime_ab
) + cbMICHDR
+ sizeof(SRTS_ab
) + sizeof(STxDataHead_ab
);
1494 else { //RTS_needless, need MICHDR
1495 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
1496 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
1499 pvTxDataHd
= (PSTxDataHead_ab
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
);
1500 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
+ sizeof(STxDataHead_ab
);
1504 if (bRTS
== true) {//RTS_need
1505 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
1506 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
1507 pvRTS
= (PSRTS_a_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
);
1509 pvTxDataHd
= (PSTxDataHead_a_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(PSRrvTime_ab
) + cbMICHDR
+ sizeof(SRTS_a_FB
));
1510 cbHeaderLength
= wTxBufSize
+ sizeof(PSRrvTime_ab
) + cbMICHDR
+ sizeof(SRTS_a_FB
) + sizeof(STxDataHead_a_FB
);
1512 else { //RTS_needless
1513 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
1514 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
1517 pvTxDataHd
= (PSTxDataHead_a_FB
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
);
1518 cbHeaderLength
= wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
+ sizeof(STxDataHead_a_FB
);
1522 memset((void *)(pbyTxBufferAddr
+ wTxBufSize
), 0, (cbHeaderLength
- wTxBufSize
));
1524 //////////////////////////////////////////////////////////////////
1525 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1526 if (pDevice
->pMgmt
->eAuthenMode
== WMAC_AUTH_WPANONE
) {
1527 dwMICKey0
= *(unsigned long *)(&pTransmitKey
->abyKey
[16]);
1528 dwMICKey1
= *(unsigned long *)(&pTransmitKey
->abyKey
[20]);
1530 else if ((pTransmitKey
->dwKeyIndex
& AUTHENTICATOR_KEY
) != 0) {
1531 dwMICKey0
= *(unsigned long *)(&pTransmitKey
->abyKey
[16]);
1532 dwMICKey1
= *(unsigned long *)(&pTransmitKey
->abyKey
[20]);
1535 dwMICKey0
= *(unsigned long *)(&pTransmitKey
->abyKey
[24]);
1536 dwMICKey1
= *(unsigned long *)(&pTransmitKey
->abyKey
[28]);
1538 // DO Software Michael
1539 MIC_vInit(dwMICKey0
, dwMICKey1
);
1540 MIC_vAppend((unsigned char *)&(psEthHeader
->abyDstAddr
[0]), 12);
1542 MIC_vAppend((unsigned char *)&dwMIC_Priority
, 4);
1543 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC KEY: %lX, %lX\n", dwMICKey0
, dwMICKey1
);
1546 ///////////////////////////////////////////////////////////////////
1548 pbyMacHdr
= (unsigned char *)(pbyTxBufferAddr
+ cbHeaderLength
);
1549 pbyPayloadHead
= (unsigned char *)(pbyMacHdr
+ cbMACHdLen
+ uPadding
+ cbIVlen
);
1550 pbyIVHead
= (unsigned char *)(pbyMacHdr
+ cbMACHdLen
+ uPadding
);
1552 if ((cbFrameSize
> pDevice
->wFragmentationThreshold
) && (bNeedACK
== true) && (bIsWEP256
== false)) {
1554 // FragThreshold = Fragment size(Hdr+(IV)+fragment payload+(MIC)+(ICV)+FCS)
1555 cbFragmentSize
= pDevice
->wFragmentationThreshold
;
1556 cbFragPayloadSize
= cbFragmentSize
- cbMACHdLen
- cbIVlen
- cbICVlen
- cbFCSlen
;
1557 //FragNum = (FrameSize-(Hdr+FCS))/(Fragment Size -(Hrd+FCS)))
1558 uMACfragNum
= (unsigned short) ((cbFrameBodySize
+ cbMIClen
) / cbFragPayloadSize
);
1559 cbLastFragPayloadSize
= (cbFrameBodySize
+ cbMIClen
) % cbFragPayloadSize
;
1560 if (cbLastFragPayloadSize
== 0) {
1561 cbLastFragPayloadSize
= cbFragPayloadSize
;
1565 //[Hdr+(IV)+last fragment payload+(MIC)+(ICV)+FCS]
1566 cbLastFragmentSize
= cbMACHdLen
+ cbLastFragPayloadSize
+ cbIVlen
+ cbICVlen
+ cbFCSlen
;
1568 for (uFragIdx
= 0; uFragIdx
< uMACfragNum
; uFragIdx
++) {
1569 if (uFragIdx
== 0) {
1570 //=========================
1571 // Start Fragmentation
1572 //=========================
1573 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Start Fragmentation...\n");
1574 wFragType
= FRAGCTL_STAFRAG
;
1577 //Fill FIFO,RrvTime,RTS,and CTS
1578 s_vGenerateTxParameter(pDevice
, byPktType
, (void *)psTxBufHd
, pvRrvTime
, pvRTS
, pvCTS
,
1579 cbFragmentSize
, bNeedACK
, uDMAIdx
, psEthHeader
, pDevice
->wCurrentRate
);
1581 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbFragmentSize
, uDMAIdx
, bNeedACK
,
1582 uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
, pDevice
->wCurrentRate
);
1583 // Generate TX MAC Header
1584 vGenerateMACHeader(pDevice
, pbyMacHdr
, (unsigned short)uDuration
, psEthHeader
, bNeedEncrypt
,
1585 wFragType
, uDMAIdx
, uFragIdx
);
1587 if (bNeedEncrypt
== true) {
1589 s_vFillTxKey(pDevice
, (unsigned char *)(psTxBufHd
->adwTxKey
), pbyIVHead
, pTransmitKey
,
1590 pbyMacHdr
, (unsigned short)cbFragPayloadSize
, (unsigned char *)pMICHDR
);
1591 //Fill IV(ExtIV,RSNHDR)
1592 if (pDevice
->bEnableHostWEP
) {
1593 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1594 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1600 if (ntohs(psEthHeader
->wType
) > ETH_DATA_LEN
) {
1601 if ((psEthHeader
->wType
== TYPE_PKT_IPX
) ||
1602 (psEthHeader
->wType
== cpu_to_le16(0xF380))) {
1603 memcpy((unsigned char *) (pbyPayloadHead
), &pDevice
->abySNAP_Bridgetunnel
[0], 6);
1606 memcpy((unsigned char *) (pbyPayloadHead
), &pDevice
->abySNAP_RFC1042
[0], 6);
1608 pbyType
= (unsigned char *) (pbyPayloadHead
+ 6);
1609 memcpy(pbyType
, &(psEthHeader
->wType
), sizeof(unsigned short));
1613 cbReqCount
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ cbFragPayloadSize
;
1614 //---------------------------
1615 // S/W or H/W Encryption
1616 //---------------------------
1618 //if (pDevice->bAES) {
1619 // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFragPayloadSize);
1621 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
1622 // pbyPayloadHead, (unsigned short)cbFragPayloadSize, uDMAIdx);
1626 //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
1627 pbyBuffer
= (unsigned char *)pHeadTD
->pTDInfo
->buf
;
1629 uLength
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ cb802_1_H_len
;
1630 //copy TxBufferHeader + MacHeader to desc
1631 memcpy(pbyBuffer
, (void *)psTxBufHd
, uLength
);
1633 // Copy the Packet into a tx Buffer
1634 memcpy((pbyBuffer
+ uLength
), (pPacket
+ 14), (cbFragPayloadSize
- cb802_1_H_len
));
1637 uTotalCopyLength
+= cbFragPayloadSize
- cb802_1_H_len
;
1639 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1640 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Start MIC: %d\n", cbFragPayloadSize
);
1641 MIC_vAppend((pbyBuffer
+ uLength
- cb802_1_H_len
), cbFragPayloadSize
);
1645 //---------------------------
1647 //---------------------------
1648 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
1650 s_vSWencryption(pDevice
, pTransmitKey
, (pbyBuffer
+ uLength
- cb802_1_H_len
), (unsigned short)cbFragPayloadSize
);
1651 cbReqCount
+= cbICVlen
;
1655 ptdCurr
= (PSTxDesc
)pHeadTD
;
1656 //--------------------
1657 //1.Set TSR1 & ReqCount in TxDescHead
1658 //2.Set FragCtl in TxBufferHead
1659 //3.Set Frame Control
1660 //4.Set Sequence Control
1661 //5.Get S/W generate FCS
1662 //--------------------
1663 s_vFillFragParameter(pDevice
, pbyBuffer
, uDMAIdx
, (void *)ptdCurr
, wFragType
, cbReqCount
);
1665 ptdCurr
->pTDInfo
->dwReqCount
= cbReqCount
- uPadding
;
1666 ptdCurr
->pTDInfo
->dwHeaderLength
= cbHeaderLength
;
1667 ptdCurr
->pTDInfo
->skb_dma
= ptdCurr
->pTDInfo
->buf_dma
;
1668 ptdCurr
->buff_addr
= cpu_to_le32(ptdCurr
->pTDInfo
->skb_dma
);
1669 pDevice
->iTDUsed
[uDMAIdx
]++;
1670 pHeadTD
= ptdCurr
->next
;
1672 else if (uFragIdx
== (uMACfragNum
-1)) {
1673 //=========================
1674 // Last Fragmentation
1675 //=========================
1676 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Last Fragmentation...\n");
1677 //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
1679 wFragType
= FRAGCTL_ENDFRAG
;
1681 //Fill FIFO,RrvTime,RTS,and CTS
1682 s_vGenerateTxParameter(pDevice
, byPktType
, (void *)psTxBufHd
, pvRrvTime
, pvRTS
, pvCTS
,
1683 cbLastFragmentSize
, bNeedACK
, uDMAIdx
, psEthHeader
, pDevice
->wCurrentRate
);
1685 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbLastFragmentSize
, uDMAIdx
, bNeedACK
,
1686 uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
, pDevice
->wCurrentRate
);
1688 // Generate TX MAC Header
1689 vGenerateMACHeader(pDevice
, pbyMacHdr
, (unsigned short)uDuration
, psEthHeader
, bNeedEncrypt
,
1690 wFragType
, uDMAIdx
, uFragIdx
);
1692 if (bNeedEncrypt
== true) {
1694 s_vFillTxKey(pDevice
, (unsigned char *)(psTxBufHd
->adwTxKey
), pbyIVHead
, pTransmitKey
,
1695 pbyMacHdr
, (unsigned short)cbLastFragPayloadSize
, (unsigned char *)pMICHDR
);
1697 if (pDevice
->bEnableHostWEP
) {
1698 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1699 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1705 cbReqCount
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ cbLastFragPayloadSize
;
1706 //---------------------------
1707 // S/W or H/W Encryption
1708 //---------------------------
1712 pbyBuffer
= (unsigned char *)pHeadTD
->pTDInfo
->buf
;
1713 //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
1715 uLength
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
;
1717 //copy TxBufferHeader + MacHeader to desc
1718 memcpy(pbyBuffer
, (void *)psTxBufHd
, uLength
);
1720 // Copy the Packet into a tx Buffer
1721 if (bMIC2Frag
== false) {
1723 memcpy((pbyBuffer
+ uLength
),
1724 (pPacket
+ 14 + uTotalCopyLength
),
1725 (cbLastFragPayloadSize
- cbMIClen
)
1727 //TODO check uTmpLen !
1728 uTmpLen
= cbLastFragPayloadSize
- cbMIClen
;
1731 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1732 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"LAST: uMICFragLen:%d, cbLastFragPayloadSize:%d, uTmpLen:%d\n",
1733 uMICFragLen
, cbLastFragPayloadSize
, uTmpLen
);
1735 if (bMIC2Frag
== false) {
1737 MIC_vAppend((pbyBuffer
+ uLength
), uTmpLen
);
1738 pdwMIC_L
= (unsigned long *)(pbyBuffer
+ uLength
+ uTmpLen
);
1739 pdwMIC_R
= (unsigned long *)(pbyBuffer
+ uLength
+ uTmpLen
+ 4);
1740 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1741 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Last MIC:%lX, %lX\n", *pdwMIC_L
, *pdwMIC_R
);
1743 if (uMICFragLen
>= 4) {
1744 memcpy((pbyBuffer
+ uLength
), ((unsigned char *)&dwSafeMIC_R
+ (uMICFragLen
- 4)),
1745 (cbMIClen
- uMICFragLen
));
1746 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"LAST: uMICFragLen >= 4: %X, %d\n",
1747 *(unsigned char *)((unsigned char *)&dwSafeMIC_R
+ (uMICFragLen
- 4)),
1748 (cbMIClen
- uMICFragLen
));
1751 memcpy((pbyBuffer
+ uLength
), ((unsigned char *)&dwSafeMIC_L
+ uMICFragLen
),
1753 memcpy((pbyBuffer
+ uLength
+ (4 - uMICFragLen
)), &dwSafeMIC_R
, 4);
1754 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"LAST: uMICFragLen < 4: %X, %d\n",
1755 *(unsigned char *)((unsigned char *)&dwSafeMIC_R
+ uMICFragLen
- 4),
1756 (cbMIClen
- uMICFragLen
));
1759 for (ii = 0; ii < cbLastFragPayloadSize + 8 + 24; ii++) {
1760 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii - 8 - 24)));
1762 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n");
1767 ASSERT(uTmpLen
== (cbLastFragPayloadSize
- cbMIClen
));
1771 //---------------------------
1773 //---------------------------
1774 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
1776 s_vSWencryption(pDevice
, pTransmitKey
, (pbyBuffer
+ uLength
), (unsigned short)cbLastFragPayloadSize
);
1777 cbReqCount
+= cbICVlen
;
1781 ptdCurr
= (PSTxDesc
)pHeadTD
;
1783 //--------------------
1784 //1.Set TSR1 & ReqCount in TxDescHead
1785 //2.Set FragCtl in TxBufferHead
1786 //3.Set Frame Control
1787 //4.Set Sequence Control
1788 //5.Get S/W generate FCS
1789 //--------------------
1792 s_vFillFragParameter(pDevice
, pbyBuffer
, uDMAIdx
, (void *)ptdCurr
, wFragType
, cbReqCount
);
1794 ptdCurr
->pTDInfo
->dwReqCount
= cbReqCount
- uPadding
;
1795 ptdCurr
->pTDInfo
->dwHeaderLength
= cbHeaderLength
;
1796 ptdCurr
->pTDInfo
->skb_dma
= ptdCurr
->pTDInfo
->buf_dma
;
1797 ptdCurr
->buff_addr
= cpu_to_le32(ptdCurr
->pTDInfo
->skb_dma
);
1798 pDevice
->iTDUsed
[uDMAIdx
]++;
1799 pHeadTD
= ptdCurr
->next
;
1803 //=========================
1804 // Middle Fragmentation
1805 //=========================
1806 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Middle Fragmentation...\n");
1807 //tmpDescIdx = (uDescIdx + uFragIdx) % pDevice->cbTD[uDMAIdx];
1809 wFragType
= FRAGCTL_MIDFRAG
;
1811 //Fill FIFO,RrvTime,RTS,and CTS
1812 s_vGenerateTxParameter(pDevice
, byPktType
, (void *)psTxBufHd
, pvRrvTime
, pvRTS
, pvCTS
,
1813 cbFragmentSize
, bNeedACK
, uDMAIdx
, psEthHeader
, pDevice
->wCurrentRate
);
1815 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbFragmentSize
, uDMAIdx
, bNeedACK
,
1816 uFragIdx
, cbLastFragmentSize
, uMACfragNum
, byFBOption
, pDevice
->wCurrentRate
);
1818 // Generate TX MAC Header
1819 vGenerateMACHeader(pDevice
, pbyMacHdr
, (unsigned short)uDuration
, psEthHeader
, bNeedEncrypt
,
1820 wFragType
, uDMAIdx
, uFragIdx
);
1823 if (bNeedEncrypt
== true) {
1825 s_vFillTxKey(pDevice
, (unsigned char *)(psTxBufHd
->adwTxKey
), pbyIVHead
, pTransmitKey
,
1826 pbyMacHdr
, (unsigned short)cbFragPayloadSize
, (unsigned char *)pMICHDR
);
1828 if (pDevice
->bEnableHostWEP
) {
1829 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1830 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1834 cbReqCount
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ cbFragPayloadSize
;
1835 //---------------------------
1836 // S/W or H/W Encryption
1837 //---------------------------
1839 //if (pDevice->bAES) {
1840 // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFragPayloadSize);
1842 //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel,
1843 // pbyPayloadHead, (unsigned short)cbFragPayloadSize, uDMAIdx);
1846 pbyBuffer
= (unsigned char *)pHeadTD
->pTDInfo
->buf
;
1847 //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr;
1850 uLength
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
;
1852 //copy TxBufferHeader + MacHeader to desc
1853 memcpy(pbyBuffer
, (void *)psTxBufHd
, uLength
);
1855 // Copy the Packet into a tx Buffer
1856 memcpy((pbyBuffer
+ uLength
),
1857 (pPacket
+ 14 + uTotalCopyLength
),
1860 uTmpLen
= cbFragPayloadSize
;
1862 uTotalCopyLength
+= uTmpLen
;
1864 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1866 MIC_vAppend((pbyBuffer
+ uLength
), uTmpLen
);
1868 if (uTmpLen
< cbFragPayloadSize
) {
1870 uMICFragLen
= cbFragPayloadSize
- uTmpLen
;
1871 ASSERT(uMICFragLen
< cbMIClen
);
1873 pdwMIC_L
= (unsigned long *)(pbyBuffer
+ uLength
+ uTmpLen
);
1874 pdwMIC_R
= (unsigned long *)(pbyBuffer
+ uLength
+ uTmpLen
+ 4);
1875 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1876 dwSafeMIC_L
= *pdwMIC_L
;
1877 dwSafeMIC_R
= *pdwMIC_R
;
1879 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIDDLE: uMICFragLen:%d, cbFragPayloadSize:%d, uTmpLen:%d\n",
1880 uMICFragLen
, cbFragPayloadSize
, uTmpLen
);
1881 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Fill MIC in Middle frag [%d]\n", uMICFragLen
);
1883 for (ii = 0; ii < uMICFragLen; ii++) {
1884 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength + uTmpLen) + ii)));
1886 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
1888 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get MIC:%lX, %lX\n", *pdwMIC_L
, *pdwMIC_R
);
1890 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Middle frag len: %d\n", uTmpLen
);
1892 for (ii = 0; ii < uTmpLen; ii++) {
1893 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii)));
1895 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n");
1899 ASSERT(uTmpLen
== (cbFragPayloadSize
));
1902 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
1904 s_vSWencryption(pDevice
, pTransmitKey
, (pbyBuffer
+ uLength
), (unsigned short)cbFragPayloadSize
);
1905 cbReqCount
+= cbICVlen
;
1909 ptdCurr
= (PSTxDesc
)pHeadTD
;
1911 //--------------------
1912 //1.Set TSR1 & ReqCount in TxDescHead
1913 //2.Set FragCtl in TxBufferHead
1914 //3.Set Frame Control
1915 //4.Set Sequence Control
1916 //5.Get S/W generate FCS
1917 //--------------------
1919 s_vFillFragParameter(pDevice
, pbyBuffer
, uDMAIdx
, (void *)ptdCurr
, wFragType
, cbReqCount
);
1921 ptdCurr
->pTDInfo
->dwReqCount
= cbReqCount
- uPadding
;
1922 ptdCurr
->pTDInfo
->dwHeaderLength
= cbHeaderLength
;
1923 ptdCurr
->pTDInfo
->skb_dma
= ptdCurr
->pTDInfo
->buf_dma
;
1924 ptdCurr
->buff_addr
= cpu_to_le32(ptdCurr
->pTDInfo
->skb_dma
);
1925 pDevice
->iTDUsed
[uDMAIdx
]++;
1926 pHeadTD
= ptdCurr
->next
;
1928 } // for (uMACfragNum)
1931 //=========================
1933 //=========================
1934 //DBG_PRTGRP03(("No Fragmentation...\n"));
1935 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"No Fragmentation...\n");
1936 wFragType
= FRAGCTL_NONFRAG
;
1938 //Set FragCtl in TxBufferHead
1939 psTxBufHd
->wFragCtl
|= (unsigned short)wFragType
;
1941 //Fill FIFO,RrvTime,RTS,and CTS
1942 s_vGenerateTxParameter(pDevice
, byPktType
, (void *)psTxBufHd
, pvRrvTime
, pvRTS
, pvCTS
,
1943 cbFrameSize
, bNeedACK
, uDMAIdx
, psEthHeader
, pDevice
->wCurrentRate
);
1945 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbFrameSize
, uDMAIdx
, bNeedACK
,
1946 0, 0, uMACfragNum
, byFBOption
, pDevice
->wCurrentRate
);
1948 // Generate TX MAC Header
1949 vGenerateMACHeader(pDevice
, pbyMacHdr
, (unsigned short)uDuration
, psEthHeader
, bNeedEncrypt
,
1950 wFragType
, uDMAIdx
, 0);
1952 if (bNeedEncrypt
== true) {
1954 s_vFillTxKey(pDevice
, (unsigned char *)(psTxBufHd
->adwTxKey
), pbyIVHead
, pTransmitKey
,
1955 pbyMacHdr
, (unsigned short)cbFrameBodySize
, (unsigned char *)pMICHDR
);
1957 if (pDevice
->bEnableHostWEP
) {
1958 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1959 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1964 if (ntohs(psEthHeader
->wType
) > ETH_DATA_LEN
) {
1965 if ((psEthHeader
->wType
== TYPE_PKT_IPX
) ||
1966 (psEthHeader
->wType
== cpu_to_le16(0xF380))) {
1967 memcpy((unsigned char *) (pbyPayloadHead
), &pDevice
->abySNAP_Bridgetunnel
[0], 6);
1970 memcpy((unsigned char *) (pbyPayloadHead
), &pDevice
->abySNAP_RFC1042
[0], 6);
1972 pbyType
= (unsigned char *) (pbyPayloadHead
+ 6);
1973 memcpy(pbyType
, &(psEthHeader
->wType
), sizeof(unsigned short));
1977 cbReqCount
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
);
1978 //---------------------------
1979 // S/W or H/W Encryption
1980 //---------------------------
1982 //if (pDevice->bAES) {
1983 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MICHDR...\n");
1984 // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (unsigned short)cbFrameBodySize);
1987 pbyBuffer
= (unsigned char *)pHeadTD
->pTDInfo
->buf
;
1988 //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr;
1990 uLength
= cbHeaderLength
+ cbMACHdLen
+ uPadding
+ cbIVlen
+ cb802_1_H_len
;
1992 //copy TxBufferHeader + MacHeader to desc
1993 memcpy(pbyBuffer
, (void *)psTxBufHd
, uLength
);
1995 // Copy the Packet into a tx Buffer
1996 memcpy((pbyBuffer
+ uLength
),
1998 cbFrameBodySize
- cb802_1_H_len
2001 if ((bNeedEncrypt
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)){
2003 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Length:%d, %d\n", cbFrameBodySize
- cb802_1_H_len
, uLength
);
2005 for (ii = 0; ii < (cbFrameBodySize - cb802_1_H_len); ii++) {
2006 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii)));
2008 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
2011 MIC_vAppend((pbyBuffer
+ uLength
- cb802_1_H_len
), cbFrameBodySize
);
2013 pdwMIC_L
= (unsigned long *)(pbyBuffer
+ uLength
- cb802_1_H_len
+ cbFrameBodySize
);
2014 pdwMIC_R
= (unsigned long *)(pbyBuffer
+ uLength
- cb802_1_H_len
+ cbFrameBodySize
+ 4);
2016 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
2020 if (pDevice
->bTxMICFail
== true) {
2023 pDevice
->bTxMICFail
= false;
2026 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"uLength: %d, %d\n", uLength
, cbFrameBodySize
);
2027 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"cbReqCount:%d, %d, %d, %d\n", cbReqCount
, cbHeaderLength
, uPadding
, cbIVlen
);
2028 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC:%lx, %lx\n", *pdwMIC_L
, *pdwMIC_R
);
2030 for (ii = 0; ii < 8; ii++) {
2031 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(((unsigned char *)(pdwMIC_L) + ii)));
2033 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n");
2039 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)){
2041 s_vSWencryption(pDevice
, pTransmitKey
, (pbyBuffer
+ uLength
- cb802_1_H_len
),
2042 (unsigned short)(cbFrameBodySize
+ cbMIClen
));
2043 cbReqCount
+= cbICVlen
;
2048 ptdCurr
= (PSTxDesc
)pHeadTD
;
2050 ptdCurr
->pTDInfo
->dwReqCount
= cbReqCount
- uPadding
;
2051 ptdCurr
->pTDInfo
->dwHeaderLength
= cbHeaderLength
;
2052 ptdCurr
->pTDInfo
->skb_dma
= ptdCurr
->pTDInfo
->buf_dma
;
2053 ptdCurr
->buff_addr
= cpu_to_le32(ptdCurr
->pTDInfo
->skb_dma
);
2054 //Set TSR1 & ReqCount in TxDescHead
2055 ptdCurr
->m_td1TD1
.byTCR
|= (TCR_STP
| TCR_EDP
| EDMSDU
);
2056 ptdCurr
->m_td1TD1
.wReqCount
= cpu_to_le16((unsigned short)(cbReqCount
));
2058 pDevice
->iTDUsed
[uDMAIdx
]++;
2061 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ptdCurr->m_dwReserved0[%d] ptdCurr->m_dwReserved1[%d].\n", ptdCurr->pTDInfo->dwReqCount, ptdCurr->pTDInfo->dwHeaderLength);
2062 // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" cbHeaderLength[%d]\n", cbHeaderLength);
2065 *puMACfragNum
= uMACfragNum
;
2066 //DBG_PRTGRP03(("s_cbFillTxBufHead END\n"));
2067 return cbHeaderLength
;
2072 vGenerateFIFOHeader(PSDevice pDevice
, unsigned char byPktType
, unsigned char *pbyTxBufferAddr
,
2073 bool bNeedEncrypt
, unsigned int cbPayloadSize
, unsigned int uDMAIdx
,
2074 PSTxDesc pHeadTD
, PSEthernetHeader psEthHeader
, unsigned char *pPacket
,
2075 PSKeyItem pTransmitKey
, unsigned int uNodeIndex
, unsigned int *puMACfragNum
,
2076 unsigned int *pcbHeaderSize
)
2078 unsigned int wTxBufSize
; // FFinfo size
2081 unsigned short cbMacHdLen
;
2082 PSTxBufHead pTxBufHead
= (PSTxBufHead
) pbyTxBufferAddr
;
2084 wTxBufSize
= sizeof(STxBufHead
);
2086 memset(pTxBufHead
, 0, wTxBufSize
);
2087 //Set FIFOCTL_NEEDACK
2089 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
2090 (pDevice
->eOPMode
== OP_MODE_AP
)) {
2091 if (is_multicast_ether_addr(&(psEthHeader
->abyDstAddr
[0]))) {
2093 pTxBufHead
->wFIFOCtl
= pTxBufHead
->wFIFOCtl
& (~FIFOCTL_NEEDACK
);
2097 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
2102 // MSDUs in Infra mode always need ACK
2104 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
2109 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
2110 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us
);
2113 if (pDevice
->bLongHeader
)
2114 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LHEAD
;
2116 //Set FIFOCTL_GENINT
2118 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GENINT
;
2121 //Set FIFOCTL_ISDMA0
2122 if (TYPE_TXDMA0
== uDMAIdx
) {
2123 pTxBufHead
->wFIFOCtl
|= FIFOCTL_ISDMA0
;
2126 //Set FRAGCTL_MACHDCNT
2127 if (pDevice
->bLongHeader
) {
2128 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
+ 6;
2130 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
2132 pTxBufHead
->wFragCtl
|= cpu_to_le16((unsigned short)(cbMacHdLen
<< 10));
2135 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
2138 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
2139 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
2141 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
2142 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
2144 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
2145 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
2147 //Set FIFOCTL_GrpAckPolicy
2148 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
2149 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
2152 //Set Auto Fallback Ctl
2153 if (pDevice
->wCurrentRate
>= RATE_18M
) {
2154 if (pDevice
->byAutoFBCtrl
== AUTO_FB_0
) {
2155 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_0
;
2156 } else if (pDevice
->byAutoFBCtrl
== AUTO_FB_1
) {
2157 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_1
;
2161 //Set FRAGCTL_WEPTYP
2162 pDevice
->bAES
= false;
2164 //Set FRAGCTL_WEPTYP
2165 if (pDevice
->byLocalID
> REV_ID_VT3253_A1
) {
2166 if ((bNeedEncrypt
) && (pTransmitKey
!= NULL
)) { //WEP enabled
2167 if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
2168 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
2170 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) { //WEP40 or WEP104
2171 if (pTransmitKey
->uKeyLength
!= WLAN_WEP232_KEYLEN
)
2172 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
2174 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) { //CCMP
2175 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
2181 //printk("Func:vGenerateFIFOHeader:TxDataRate is %d,TxPower is %d\n",pDevice->wCurrentRate,pDevice->byCurPwr);
2183 //if (pDevice->wCurrentRate <= 3)
2185 // RFbRawSetPower(pDevice,36,pDevice->wCurrentRate);
2189 RFbSetPower(pDevice
, pDevice
->wCurrentRate
, pDevice
->byCurrentCh
);
2191 //if (pDevice->wCurrentRate == 3)
2192 //pDevice->byCurPwr = 46;
2193 pTxBufHead
->byTxPower
= pDevice
->byCurPwr
;
2199 if(pDevice->bEnableHostWEP)
2200 pTxBufHead->wFragCtl &= ~(FRAGCTL_TKIP | FRAGCTL_LEGACY |FRAGCTL_AES);
2202 *pcbHeaderSize
= s_cbFillTxBufHead(pDevice
, byPktType
, pbyTxBufferAddr
, cbPayloadSize
,
2203 uDMAIdx
, pHeadTD
, psEthHeader
, pPacket
, bNeedEncrypt
,
2204 pTransmitKey
, uNodeIndex
, puMACfragNum
);
2215 * Translate 802.3 to 802.11 header
2219 * pDevice - Pointer to adapter
2220 * dwTxBufferAddr - Transmit Buffer
2221 * pPacket - Packet from upper layer
2222 * cbPacketSize - Transmit Data Length
2224 * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header
2225 * pcbAppendPayload - size of append payload for 802.1H translation
2227 * Return Value: none
2232 vGenerateMACHeader (
2234 unsigned char *pbyBufferAddr
,
2235 unsigned short wDuration
,
2236 PSEthernetHeader psEthHeader
,
2238 unsigned short wFragType
,
2239 unsigned int uDMAIdx
,
2240 unsigned int uFragIdx
2243 PS802_11Header pMACHeader
= (PS802_11Header
)pbyBufferAddr
;
2245 memset(pMACHeader
, 0, (sizeof(S802_11Header
))); //- sizeof(pMACHeader->dwIV)));
2247 if (uDMAIdx
== TYPE_ATIMDMA
) {
2248 pMACHeader
->wFrameCtl
= TYPE_802_11_ATIM
;
2250 pMACHeader
->wFrameCtl
= TYPE_802_11_DATA
;
2253 if (pDevice
->eOPMode
== OP_MODE_AP
) {
2254 memcpy(&(pMACHeader
->abyAddr1
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
2255 memcpy(&(pMACHeader
->abyAddr2
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
2256 memcpy(&(pMACHeader
->abyAddr3
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
2257 pMACHeader
->wFrameCtl
|= FC_FROMDS
;
2260 if (pDevice
->eOPMode
== OP_MODE_ADHOC
) {
2261 memcpy(&(pMACHeader
->abyAddr1
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
2262 memcpy(&(pMACHeader
->abyAddr2
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
2263 memcpy(&(pMACHeader
->abyAddr3
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
2266 memcpy(&(pMACHeader
->abyAddr3
[0]), &(psEthHeader
->abyDstAddr
[0]), ETH_ALEN
);
2267 memcpy(&(pMACHeader
->abyAddr2
[0]), &(psEthHeader
->abySrcAddr
[0]), ETH_ALEN
);
2268 memcpy(&(pMACHeader
->abyAddr1
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
2269 pMACHeader
->wFrameCtl
|= FC_TODS
;
2274 pMACHeader
->wFrameCtl
|= cpu_to_le16((unsigned short)WLAN_SET_FC_ISWEP(1));
2276 pMACHeader
->wDurationID
= cpu_to_le16(wDuration
);
2278 if (pDevice
->bLongHeader
) {
2279 PWLAN_80211HDR_A4 pMACA4Header
= (PWLAN_80211HDR_A4
) pbyBufferAddr
;
2280 pMACHeader
->wFrameCtl
|= (FC_TODS
| FC_FROMDS
);
2281 memcpy(pMACA4Header
->abyAddr4
, pDevice
->abyBSSID
, WLAN_ADDR_LEN
);
2283 pMACHeader
->wSeqCtl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
2285 //Set FragNumber in Sequence Control
2286 pMACHeader
->wSeqCtl
|= cpu_to_le16((unsigned short)uFragIdx
);
2288 if ((wFragType
== FRAGCTL_ENDFRAG
) || (wFragType
== FRAGCTL_NONFRAG
)) {
2289 pDevice
->wSeqCounter
++;
2290 if (pDevice
->wSeqCounter
> 0x0fff)
2291 pDevice
->wSeqCounter
= 0;
2294 if ((wFragType
== FRAGCTL_STAFRAG
) || (wFragType
== FRAGCTL_MIDFRAG
)) { //StartFrag or MidFrag
2295 pMACHeader
->wFrameCtl
|= FC_MOREFRAG
;
2304 CMD_STATUS
csMgmt_xmit(PSDevice pDevice
, PSTxMgmtPacket pPacket
) {
2307 unsigned char byPktType
;
2308 unsigned char *pbyTxBufferAddr
;
2312 unsigned int uDuration
;
2313 unsigned int cbReqCount
;
2314 PS802_11Header pMACHeader
;
2315 unsigned int cbHeaderSize
;
2316 unsigned int cbFrameBodySize
;
2318 bool bIsPSPOLL
= false;
2319 PSTxBufHead pTxBufHead
;
2320 unsigned int cbFrameSize
;
2321 unsigned int cbIVlen
= 0;
2322 unsigned int cbICVlen
= 0;
2323 unsigned int cbMIClen
= 0;
2324 unsigned int cbFCSlen
= 4;
2325 unsigned int uPadding
= 0;
2326 unsigned short wTxBufSize
;
2327 unsigned int cbMacHdLen
;
2328 SEthernetHeader sEthHeader
;
2331 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
2332 unsigned short wCurrentRate
= RATE_1M
;
2335 if (AVAIL_TD(pDevice
, TYPE_TXDMA0
) <= 0) {
2336 return CMD_STATUS_RESOURCES
;
2339 pFrstTD
= pDevice
->apCurrTD
[TYPE_TXDMA0
];
2340 pbyTxBufferAddr
= (unsigned char *)pFrstTD
->pTDInfo
->buf
;
2341 cbFrameBodySize
= pPacket
->cbPayloadLen
;
2342 pTxBufHead
= (PSTxBufHead
) pbyTxBufferAddr
;
2343 wTxBufSize
= sizeof(STxBufHead
);
2344 memset(pTxBufHead
, 0, wTxBufSize
);
2346 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11A
) {
2347 wCurrentRate
= RATE_6M
;
2348 byPktType
= PK_TYPE_11A
;
2350 wCurrentRate
= RATE_1M
;
2351 byPktType
= PK_TYPE_11B
;
2354 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
2355 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
2356 // And cmd timer will wait data pkt TX finish before scanning so it's OK
2357 // to set power here.
2358 if (pDevice
->pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
2360 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
2362 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
2364 pTxBufHead
->byTxPower
= pDevice
->byCurPwr
;
2365 //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
2366 if (pDevice
->byFOETuning
) {
2367 if ((pPacket
->p80211Header
->sA3
.wFrameCtl
& TYPE_DATE_NULL
) == TYPE_DATE_NULL
) {
2368 wCurrentRate
= RATE_24M
;
2369 byPktType
= PK_TYPE_11GA
;
2374 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
2375 pTxBufHead
->wFIFOCtl
= 0;
2377 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
2378 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
2380 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
2381 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
2383 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
2384 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
2387 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
2388 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
2391 if (is_multicast_ether_addr(&(pPacket
->p80211Header
->sA3
.abyAddr1
[0])))
2395 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
2398 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
2399 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
2401 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
2402 //Set Preamble type always long
2403 //pDevice->byPreambleType = PREAMBLE_LONG;
2404 // probe-response don't retry
2405 //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
2406 // bNeedACK = false;
2407 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
2411 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
2413 if ((pPacket
->p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
2415 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
2417 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
2420 //Set FRAGCTL_MACHDCNT
2421 pTxBufHead
->wFragCtl
|= cpu_to_le16((unsigned short)(cbMacHdLen
<< 10));
2424 // Although spec says MMPDU can be fragmented; In most case,
2425 // no one will send a MMPDU under fragmentation. With RTS may occur.
2426 pDevice
->bAES
= false; //Set FRAGCTL_WEPTYP
2428 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
2429 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
2432 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
2434 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2435 cbIVlen
= 8;//IV+ExtIV
2438 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
2439 //We need to get seed here for filling TxKey entry.
2440 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
2441 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
2443 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2444 cbIVlen
= 8;//RSN Header
2446 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
2447 pDevice
->bAES
= true;
2449 //MAC Header should be padding 0 to DW alignment.
2450 uPadding
= 4 - (cbMacHdLen
%4);
2454 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
;
2456 //Set FIFOCTL_GrpAckPolicy
2457 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
2458 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
2460 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
2462 //Set RrvTime/RTS/CTS Buffer
2463 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
2465 pvRrvTime
= (PSRrvTime_gCTS
) (pbyTxBufferAddr
+ wTxBufSize
);
2468 pCTS
= (PSCTS
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
));
2469 pvTxDataHd
= (PSTxDataHead_g
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + sizeof(SCTS
));
2470 cbHeaderSize
= wTxBufSize
+ sizeof(SRrvTime_gCTS
) + sizeof(SCTS
) + sizeof(STxDataHead_g
);
2472 else { // 802.11a/b packet
2473 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
2477 pvTxDataHd
= (PSTxDataHead_ab
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
2478 cbHeaderSize
= wTxBufSize
+ sizeof(SRrvTime_ab
) + sizeof(STxDataHead_ab
);
2481 memset((void *)(pbyTxBufferAddr
+ wTxBufSize
), 0, (cbHeaderSize
- wTxBufSize
));
2483 memcpy(&(sEthHeader
.abyDstAddr
[0]), &(pPacket
->p80211Header
->sA3
.abyAddr1
[0]), ETH_ALEN
);
2484 memcpy(&(sEthHeader
.abySrcAddr
[0]), &(pPacket
->p80211Header
->sA3
.abyAddr2
[0]), ETH_ALEN
);
2485 //=========================
2487 //=========================
2488 pTxBufHead
->wFragCtl
|= (unsigned short)FRAGCTL_NONFRAG
;
2491 //Fill FIFO,RrvTime,RTS,and CTS
2492 s_vGenerateTxParameter(pDevice
, byPktType
, pbyTxBufferAddr
, pvRrvTime
, pvRTS
, pCTS
,
2493 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, wCurrentRate
);
2496 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbFrameSize
, TYPE_TXDMA0
, bNeedACK
,
2497 0, 0, 1, AUTO_FB_NONE
, wCurrentRate
);
2499 pMACHeader
= (PS802_11Header
) (pbyTxBufferAddr
+ cbHeaderSize
);
2501 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ cbFrameBodySize
;
2503 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
2504 unsigned char *pbyIVHead
;
2505 unsigned char *pbyPayloadHead
;
2506 unsigned char *pbyBSSID
;
2507 PSKeyItem pTransmitKey
= NULL
;
2509 pbyIVHead
= (unsigned char *)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
);
2510 pbyPayloadHead
= (unsigned char *)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
2513 //Kyle: Need fix: TKIP and AES did't encryt Mnt Packet.
2514 //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL);
2516 //Fill IV(ExtIV,RSNHDR)
2517 //s_vFillPrePayload(pDevice, pbyIVHead, NULL);
2518 //---------------------------
2519 // S/W or H/W Encryption
2520 //---------------------------
2522 //if (pDevice->bAES) {
2523 // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, (unsigned char *)pMACHeader, (unsigned short)cbFrameBodySize);
2526 if ((pDevice
->eOPMode
== OP_MODE_INFRASTRUCTURE
) &&
2527 (pDevice
->bLinkPass
== true)) {
2528 pbyBSSID
= pDevice
->abyBSSID
;
2530 if (KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == false) {
2532 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == true) {
2533 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
2537 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get PTK.\n");
2542 pbyBSSID
= pDevice
->abyBroadcastAddr
;
2543 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
2544 pTransmitKey
= NULL
;
2545 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"KEY is NULL. OP Mode[%d]\n", pDevice
->eOPMode
);
2547 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
2551 s_vFillTxKey(pDevice
, (unsigned char *)(pTxBufHead
->adwTxKey
), pbyIVHead
, pTransmitKey
,
2552 (unsigned char *)pMACHeader
, (unsigned short)cbFrameBodySize
, NULL
);
2554 memcpy(pMACHeader
, pPacket
->p80211Header
, cbMacHdLen
);
2555 memcpy(pbyPayloadHead
, ((unsigned char *)(pPacket
->p80211Header
) + cbMacHdLen
),
2559 // Copy the Packet into a tx Buffer
2560 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
2563 pMACHeader
->wSeqCtl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
2564 pDevice
->wSeqCounter
++ ;
2565 if (pDevice
->wSeqCounter
> 0x0fff)
2566 pDevice
->wSeqCounter
= 0;
2569 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
2570 // of FIFO control header.
2571 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
2572 // in the same place of other packet's Duration-field).
2573 // And it will cause Cisco-AP to issue Disassociation-packet
2574 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
2575 ((PSTxDataHead_g
)pvTxDataHd
)->wDuration_a
= cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
2576 ((PSTxDataHead_g
)pvTxDataHd
)->wDuration_b
= cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
2578 ((PSTxDataHead_ab
)pvTxDataHd
)->wDuration
= cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
2583 // first TD is the only TD
2584 //Set TSR1 & ReqCount in TxDescHead
2585 pFrstTD
->m_td1TD1
.byTCR
= (TCR_STP
| TCR_EDP
| EDMSDU
);
2586 pFrstTD
->pTDInfo
->skb_dma
= pFrstTD
->pTDInfo
->buf_dma
;
2587 pFrstTD
->m_td1TD1
.wReqCount
= cpu_to_le16((unsigned short)(cbReqCount
));
2588 pFrstTD
->buff_addr
= cpu_to_le32(pFrstTD
->pTDInfo
->skb_dma
);
2589 pFrstTD
->pTDInfo
->byFlags
= 0;
2591 if (MACbIsRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PS
)) {
2593 MACbPSWakeup(pDevice
->PortOffset
);
2595 pDevice
->bPWBitOn
= false;
2598 pFrstTD
->m_td0TD0
.f1Owner
= OWNED_BY_NIC
;
2601 pDevice
->iTDUsed
[TYPE_TXDMA0
]++;
2603 if (AVAIL_TD(pDevice
, TYPE_TXDMA0
) <= 1) {
2604 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" available td0 <= 1\n");
2607 pDevice
->apCurrTD
[TYPE_TXDMA0
] = pFrstTD
->next
;
2609 //printk("SCAN:CurrentRate is %d,TxPower is %d\n",wCurrentRate,pTxBufHead->byTxPower);
2613 pDevice
->nTxDataTimeCout
=0; //2008-8-21 chester <add> for send null packet
2616 // Poll Transmit the adapter
2617 MACvTransmit0(pDevice
->PortOffset
);
2619 return CMD_STATUS_PENDING
;
2624 CMD_STATUS
csBeacon_xmit(PSDevice pDevice
, PSTxMgmtPacket pPacket
) {
2626 unsigned char byPktType
;
2627 unsigned char *pbyBuffer
= (unsigned char *)pDevice
->tx_beacon_bufs
;
2628 unsigned int cbFrameSize
= pPacket
->cbMPDULen
+ WLAN_FCS_LEN
;
2629 unsigned int cbHeaderSize
= 0;
2630 unsigned short wTxBufSize
= sizeof(STxShortBufHead
);
2631 PSTxShortBufHead pTxBufHead
= (PSTxShortBufHead
) pbyBuffer
;
2632 PSTxDataHead_ab pTxDataHead
= (PSTxDataHead_ab
) (pbyBuffer
+ wTxBufSize
);
2633 PS802_11Header pMACHeader
;
2634 unsigned short wCurrentRate
;
2635 unsigned short wLen
= 0x0000;
2638 memset(pTxBufHead
, 0, wTxBufSize
);
2640 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11A
) {
2641 wCurrentRate
= RATE_6M
;
2642 byPktType
= PK_TYPE_11A
;
2644 wCurrentRate
= RATE_2M
;
2645 byPktType
= PK_TYPE_11B
;
2648 //Set Preamble type always long
2649 pDevice
->byPreambleType
= PREAMBLE_LONG
;
2651 //Set FIFOCTL_GENINT
2653 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GENINT
;
2656 //Set packet type & Get Duration
2657 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
2658 pTxDataHead
->wDuration
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_A
, cbFrameSize
, byPktType
,
2659 wCurrentRate
, false, 0, 0, 1, AUTO_FB_NONE
));
2661 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
2662 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
2663 pTxDataHead
->wDuration
= cpu_to_le16((unsigned short)s_uGetDataDuration(pDevice
, DATADUR_B
, cbFrameSize
, byPktType
,
2664 wCurrentRate
, false, 0, 0, 1, AUTO_FB_NONE
));
2667 BBvCaculateParameter(pDevice
, cbFrameSize
, wCurrentRate
, byPktType
,
2668 (unsigned short *)&(wLen
), (unsigned char *)&(pTxDataHead
->byServiceField
), (unsigned char *)&(pTxDataHead
->bySignalField
)
2670 pTxDataHead
->wTransmitLength
= cpu_to_le16(wLen
);
2672 pTxDataHead
->wTimeStampOff
= cpu_to_le16(wTimeStampOff
[pDevice
->byPreambleType
%2][wCurrentRate
%MAX_RATE
]);
2673 cbHeaderSize
= wTxBufSize
+ sizeof(STxDataHead_ab
);
2675 //Generate Beacon Header
2676 pMACHeader
= (PS802_11Header
)(pbyBuffer
+ cbHeaderSize
);
2677 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
2679 pMACHeader
->wDurationID
= 0;
2680 pMACHeader
->wSeqCtl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
2681 pDevice
->wSeqCounter
++ ;
2682 if (pDevice
->wSeqCounter
> 0x0fff)
2683 pDevice
->wSeqCounter
= 0;
2685 // Set Beacon buffer length
2686 pDevice
->wBCNBufLen
= pPacket
->cbMPDULen
+ cbHeaderSize
;
2688 MACvSetCurrBCNTxDescAddr(pDevice
->PortOffset
, (pDevice
->tx_beacon_dma
));
2690 MACvSetCurrBCNLength(pDevice
->PortOffset
, pDevice
->wBCNBufLen
);
2691 // Set auto Transmit on
2692 MACvRegBitsOn(pDevice
->PortOffset
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
2693 // Poll Transmit the adapter
2694 MACvTransmitBCN(pDevice
->PortOffset
);
2696 return CMD_STATUS_PENDING
;
2704 PSKeyItem pTransmitKey
,
2705 unsigned int cbFrameBodySize
,
2706 PSEthernetHeader psEthHeader
2709 unsigned int cbMACHdLen
;
2710 unsigned int cbFrameSize
;
2711 unsigned int cbFragmentSize
; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS
2712 unsigned int cbFragPayloadSize
;
2713 unsigned int cbLastFragPayloadSize
;
2714 unsigned int cbIVlen
= 0;
2715 unsigned int cbICVlen
= 0;
2716 unsigned int cbMIClen
= 0;
2717 unsigned int cbFCSlen
= 4;
2718 unsigned int uMACfragNum
= 1;
2723 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
2724 (pDevice
->eOPMode
== OP_MODE_AP
)) {
2725 if (is_multicast_ether_addr(&(psEthHeader
->abyDstAddr
[0])))
2731 // MSDUs in Infra mode always need ACK
2735 if (pDevice
->bLongHeader
)
2736 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
+ 6;
2738 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
;
2741 if (pDevice
->bEncryptionEnable
== true) {
2743 if (pTransmitKey
== NULL
) {
2744 if ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) ||
2745 (pDevice
->pMgmt
->eAuthenMode
< WMAC_AUTH_WPA
)) {
2748 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2749 cbIVlen
= 8;//IV+ExtIV
2752 } else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2753 cbIVlen
= 8;//RSN Header
2756 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
2759 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
2760 cbIVlen
= 8;//IV+ExtIV
2763 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) {
2764 cbIVlen
= 8;//RSN Header
2769 cbFrameSize
= cbMACHdLen
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbICVlen
+ cbFCSlen
;
2771 if ((cbFrameSize
> pDevice
->wFragmentationThreshold
) && (bNeedACK
== true)) {
2773 cbFragmentSize
= pDevice
->wFragmentationThreshold
;
2774 cbFragPayloadSize
= cbFragmentSize
- cbMACHdLen
- cbIVlen
- cbICVlen
- cbFCSlen
;
2775 uMACfragNum
= (unsigned short) ((cbFrameBodySize
+ cbMIClen
) / cbFragPayloadSize
);
2776 cbLastFragPayloadSize
= (cbFrameBodySize
+ cbMIClen
) % cbFragPayloadSize
;
2777 if (cbLastFragPayloadSize
== 0) {
2778 cbLastFragPayloadSize
= cbFragPayloadSize
;
2788 vDMA0_tx_80211(PSDevice pDevice
, struct sk_buff
*skb
, unsigned char *pbMPDU
, unsigned int cbMPDULen
) {
2791 unsigned char byPktType
;
2792 unsigned char *pbyTxBufferAddr
;
2796 unsigned int uDuration
;
2797 unsigned int cbReqCount
;
2798 PS802_11Header pMACHeader
;
2799 unsigned int cbHeaderSize
;
2800 unsigned int cbFrameBodySize
;
2802 bool bIsPSPOLL
= false;
2803 PSTxBufHead pTxBufHead
;
2804 unsigned int cbFrameSize
;
2805 unsigned int cbIVlen
= 0;
2806 unsigned int cbICVlen
= 0;
2807 unsigned int cbMIClen
= 0;
2808 unsigned int cbFCSlen
= 4;
2809 unsigned int uPadding
= 0;
2810 unsigned int cbMICHDR
= 0;
2811 unsigned int uLength
= 0;
2812 unsigned long dwMICKey0
, dwMICKey1
;
2813 unsigned long dwMIC_Priority
;
2814 unsigned long *pdwMIC_L
;
2815 unsigned long *pdwMIC_R
;
2816 unsigned short wTxBufSize
;
2817 unsigned int cbMacHdLen
;
2818 SEthernetHeader sEthHeader
;
2821 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
2822 unsigned short wCurrentRate
= RATE_1M
;
2823 PUWLAN_80211HDR p80211Header
;
2824 unsigned int uNodeIndex
= 0;
2825 bool bNodeExist
= false;
2827 PSKeyItem pTransmitKey
= NULL
;
2828 unsigned char *pbyIVHead
;
2829 unsigned char *pbyPayloadHead
;
2830 unsigned char *pbyMacHdr
;
2832 unsigned int cbExtSuppRate
= 0;
2836 pvRrvTime
= pMICHDR
= pvRTS
= pvCTS
= pvTxDataHd
= NULL
;
2838 if(cbMPDULen
<= WLAN_HDR_ADDR3_LEN
) {
2839 cbFrameBodySize
= 0;
2842 cbFrameBodySize
= cbMPDULen
- WLAN_HDR_ADDR3_LEN
;
2844 p80211Header
= (PUWLAN_80211HDR
)pbMPDU
;
2847 pFrstTD
= pDevice
->apCurrTD
[TYPE_TXDMA0
];
2848 pbyTxBufferAddr
= (unsigned char *)pFrstTD
->pTDInfo
->buf
;
2849 pTxBufHead
= (PSTxBufHead
) pbyTxBufferAddr
;
2850 wTxBufSize
= sizeof(STxBufHead
);
2851 memset(pTxBufHead
, 0, wTxBufSize
);
2853 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11A
) {
2854 wCurrentRate
= RATE_6M
;
2855 byPktType
= PK_TYPE_11A
;
2857 wCurrentRate
= RATE_1M
;
2858 byPktType
= PK_TYPE_11B
;
2861 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
2862 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
2863 // And cmd timer will wait data pkt TX finish before scanning so it's OK
2864 // to set power here.
2865 if (pDevice
->pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
2866 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
2868 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
2870 pTxBufHead
->byTxPower
= pDevice
->byCurPwr
;
2872 //+++++++++++++++++++++ Patch VT3253 A1 performance +++++++++++++++++++++++++++
2873 if (pDevice
->byFOETuning
) {
2874 if ((p80211Header
->sA3
.wFrameCtl
& TYPE_DATE_NULL
) == TYPE_DATE_NULL
) {
2875 wCurrentRate
= RATE_24M
;
2876 byPktType
= PK_TYPE_11GA
;
2880 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header
->sA3
.wFrameCtl
);
2883 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
2884 pTxBufHead
->wFIFOCtl
= 0;
2886 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
2887 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
2889 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
2890 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
2892 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
2893 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
2896 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
2897 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
2900 if (is_multicast_ether_addr(&(p80211Header
->sA3
.abyAddr1
[0]))) {
2902 if (pDevice
->bEnableHostWEP
) {
2908 if (pDevice
->bEnableHostWEP
) {
2909 if (BSSDBbIsSTAInNodeDB(pDevice
->pMgmt
, (unsigned char *)(p80211Header
->sA3
.abyAddr1
), &uNodeIndex
))
2913 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
2916 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
2917 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
2919 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
2920 //Set Preamble type always long
2921 //pDevice->byPreambleType = PREAMBLE_LONG;
2923 // probe-response don't retry
2924 //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
2925 // bNeedACK = false;
2926 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
2930 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
2932 if ((p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
2934 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
2936 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
2939 // hostapd deamon ext support rate patch
2940 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
2942 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0) {
2943 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2946 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0) {
2947 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
2950 if (cbExtSuppRate
>0) {
2951 cbFrameBodySize
= WLAN_ASSOCRESP_OFF_SUPP_RATES
;
2956 //Set FRAGCTL_MACHDCNT
2957 pTxBufHead
->wFragCtl
|= cpu_to_le16((unsigned short)cbMacHdLen
<< 10);
2960 // Although spec says MMPDU can be fragmented; In most case,
2961 // no one will send a MMPDU under fragmentation. With RTS may occur.
2962 pDevice
->bAES
= false; //Set FRAGCTL_WEPTYP
2965 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
2966 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
2969 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
2971 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
2972 cbIVlen
= 8;//IV+ExtIV
2975 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
2976 //We need to get seed here for filling TxKey entry.
2977 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
2978 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
2980 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
2981 cbIVlen
= 8;//RSN Header
2983 cbMICHDR
= sizeof(SMICHDRHead
);
2984 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
2985 pDevice
->bAES
= true;
2987 //MAC Header should be padding 0 to DW alignment.
2988 uPadding
= 4 - (cbMacHdLen
%4);
2992 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
+ cbExtSuppRate
;
2994 //Set FIFOCTL_GrpAckPolicy
2995 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
2996 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
2998 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
3001 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
3003 pvRrvTime
= (PSRrvTime_gCTS
) (pbyTxBufferAddr
+ wTxBufSize
);
3004 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
));
3006 pvCTS
= (PSCTS
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
);
3007 pvTxDataHd
= (PSTxDataHead_g
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS
));
3008 cbHeaderSize
= wTxBufSize
+ sizeof(SRrvTime_gCTS
) + cbMICHDR
+ sizeof(SCTS
) + sizeof(STxDataHead_g
);
3011 else {//802.11a/b packet
3013 pvRrvTime
= (PSRrvTime_ab
) (pbyTxBufferAddr
+ wTxBufSize
);
3014 pMICHDR
= (PSMICHDRHead
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
));
3017 pvTxDataHd
= (PSTxDataHead_ab
) (pbyTxBufferAddr
+ wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
);
3018 cbHeaderSize
= wTxBufSize
+ sizeof(SRrvTime_ab
) + cbMICHDR
+ sizeof(STxDataHead_ab
);
3022 memset((void *)(pbyTxBufferAddr
+ wTxBufSize
), 0, (cbHeaderSize
- wTxBufSize
));
3023 memcpy(&(sEthHeader
.abyDstAddr
[0]), &(p80211Header
->sA3
.abyAddr1
[0]), ETH_ALEN
);
3024 memcpy(&(sEthHeader
.abySrcAddr
[0]), &(p80211Header
->sA3
.abyAddr2
[0]), ETH_ALEN
);
3025 //=========================
3027 //=========================
3028 pTxBufHead
->wFragCtl
|= (unsigned short)FRAGCTL_NONFRAG
;
3031 //Fill FIFO,RrvTime,RTS,and CTS
3032 s_vGenerateTxParameter(pDevice
, byPktType
, pbyTxBufferAddr
, pvRrvTime
, pvRTS
, pvCTS
,
3033 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, wCurrentRate
);
3036 uDuration
= s_uFillDataHead(pDevice
, byPktType
, pvTxDataHd
, cbFrameSize
, TYPE_TXDMA0
, bNeedACK
,
3037 0, 0, 1, AUTO_FB_NONE
, wCurrentRate
);
3039 pMACHeader
= (PS802_11Header
) (pbyTxBufferAddr
+ cbHeaderSize
);
3041 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbExtSuppRate
;
3043 pbyMacHdr
= (unsigned char *)(pbyTxBufferAddr
+ cbHeaderSize
);
3044 pbyPayloadHead
= (unsigned char *)(pbyMacHdr
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
3045 pbyIVHead
= (unsigned char *)(pbyMacHdr
+ cbMacHdLen
+ uPadding
);
3047 // Copy the Packet into a tx Buffer
3048 memcpy(pbyMacHdr
, pbMPDU
, cbMacHdLen
);
3050 // version set to 0, patch for hostapd deamon
3051 pMACHeader
->wFrameCtl
&= cpu_to_le16(0xfffc);
3052 memcpy(pbyPayloadHead
, (pbMPDU
+ cbMacHdLen
), cbFrameBodySize
);
3054 // replace support rate, patch for hostapd deamon( only support 11M)
3055 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
3056 if (cbExtSuppRate
!= 0) {
3057 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0)
3058 memcpy((pbyPayloadHead
+ cbFrameBodySize
),
3059 pMgmt
->abyCurrSuppRates
,
3060 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
3062 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0)
3063 memcpy((pbyPayloadHead
+ cbFrameBodySize
) + ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
,
3064 pMgmt
->abyCurrExtSuppRates
,
3065 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
3071 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
3073 if (pDevice
->bEnableHostWEP
) {
3074 pTransmitKey
= &STempKey
;
3075 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
3076 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
3077 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
3078 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
3079 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
3080 memcpy(pTransmitKey
->abyKey
,
3081 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
3082 pTransmitKey
->uKeyLength
3086 if ((pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
3088 dwMICKey0
= *(unsigned long *)(&pTransmitKey
->abyKey
[16]);
3089 dwMICKey1
= *(unsigned long *)(&pTransmitKey
->abyKey
[20]);
3091 // DO Software Michael
3092 MIC_vInit(dwMICKey0
, dwMICKey1
);
3093 MIC_vAppend((unsigned char *)&(sEthHeader
.abyDstAddr
[0]), 12);
3095 MIC_vAppend((unsigned char *)&dwMIC_Priority
, 4);
3096 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"DMA0_tx_8021:MIC KEY: %lX, %lX\n", dwMICKey0
, dwMICKey1
);
3098 uLength
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
;
3100 MIC_vAppend((pbyTxBufferAddr
+ uLength
), cbFrameBodySize
);
3102 pdwMIC_L
= (unsigned long *)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
);
3103 pdwMIC_R
= (unsigned long *)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
+ 4);
3105 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
3108 if (pDevice
->bTxMICFail
== true) {
3111 pDevice
->bTxMICFail
= false;
3114 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"uLength: %d, %d\n", uLength
, cbFrameBodySize
);
3115 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"cbReqCount:%d, %d, %d, %d\n", cbReqCount
, cbHeaderSize
, uPadding
, cbIVlen
);
3116 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC:%lx, %lx\n", *pdwMIC_L
, *pdwMIC_R
);
3121 s_vFillTxKey(pDevice
, (unsigned char *)(pTxBufHead
->adwTxKey
), pbyIVHead
, pTransmitKey
,
3122 pbyMacHdr
, (unsigned short)cbFrameBodySize
, (unsigned char *)pMICHDR
);
3124 if (pDevice
->bEnableHostWEP
) {
3125 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
3126 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
3129 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
3130 s_vSWencryption(pDevice
, pTransmitKey
, pbyPayloadHead
, (unsigned short)(cbFrameBodySize
+ cbMIClen
));
3134 pMACHeader
->wSeqCtl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
3135 pDevice
->wSeqCounter
++ ;
3136 if (pDevice
->wSeqCounter
> 0x0fff)
3137 pDevice
->wSeqCounter
= 0;
3141 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
3142 // of FIFO control header.
3143 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
3144 // in the same place of other packet's Duration-field).
3145 // And it will cause Cisco-AP to issue Disassociation-packet
3146 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
3147 ((PSTxDataHead_g
)pvTxDataHd
)->wDuration_a
= cpu_to_le16(p80211Header
->sA2
.wDurationID
);
3148 ((PSTxDataHead_g
)pvTxDataHd
)->wDuration_b
= cpu_to_le16(p80211Header
->sA2
.wDurationID
);
3150 ((PSTxDataHead_ab
)pvTxDataHd
)->wDuration
= cpu_to_le16(p80211Header
->sA2
.wDurationID
);
3155 // first TD is the only TD
3156 //Set TSR1 & ReqCount in TxDescHead
3157 pFrstTD
->pTDInfo
->skb
= skb
;
3158 pFrstTD
->m_td1TD1
.byTCR
= (TCR_STP
| TCR_EDP
| EDMSDU
);
3159 pFrstTD
->pTDInfo
->skb_dma
= pFrstTD
->pTDInfo
->buf_dma
;
3160 pFrstTD
->m_td1TD1
.wReqCount
= cpu_to_le16(cbReqCount
);
3161 pFrstTD
->buff_addr
= cpu_to_le32(pFrstTD
->pTDInfo
->skb_dma
);
3162 pFrstTD
->pTDInfo
->byFlags
= 0;
3163 pFrstTD
->pTDInfo
->byFlags
|= TD_FLAGS_PRIV_SKB
;
3165 if (MACbIsRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PS
)) {
3167 MACbPSWakeup(pDevice
->PortOffset
);
3169 pDevice
->bPWBitOn
= false;
3172 pFrstTD
->m_td0TD0
.f1Owner
= OWNED_BY_NIC
;
3175 pDevice
->iTDUsed
[TYPE_TXDMA0
]++;
3177 if (AVAIL_TD(pDevice
, TYPE_TXDMA0
) <= 1) {
3178 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" available td0 <= 1\n");
3181 pDevice
->apCurrTD
[TYPE_TXDMA0
] = pFrstTD
->next
;
3183 // Poll Transmit the adapter
3184 MACvTransmit0(pDevice
->PortOffset
);