80 #define CRITICAL_PACKET_LEN 256 // if packet size < 256 -> in-direct send
84 {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23},
85 {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23},
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
121 unsigned char *pbyBuf,
122 unsigned char *pbyIVHead,
124 unsigned char *pbyHdrBuf,
125 unsigned short wPayloadLen,
126 unsigned char *pMICHDR
135 unsigned char byPktType,
137 unsigned int cbFrameLength,
141 unsigned short wCurrentRate,
142 unsigned char byFBOption
147 s_vGenerateTxParameter(
149 unsigned char byPktType,
154 unsigned int cbFrameSize,
156 unsigned int uDMAIdx,
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,
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
205 unsigned char *pbyBuf,
206 unsigned char *pbyIVHead,
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);
217 unsigned long dwRevIVCounter;
218 unsigned char byKeyIndex = 0;
223 if (pTransmitKey ==
NULL)
232 memcpy(pDevice->
abyPRNG, (
unsigned char *)&(dwRevIVCounter), 3);
235 memcpy(pbyBuf, (
unsigned char *)&(dwRevIVCounter), 3);
238 memcpy(pbyBuf+8, (
unsigned char *)&(dwRevIVCounter), 3);
245 *pdwIV |= (byKeyIndex << 30);
262 *(pbyIVHead+3) = (
unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20);
276 *(pbyIVHead+3) = (
unsigned char)(((byKeyIndex << 6) & 0xc0) | 0x20);
283 *((
unsigned char *)(pMICHDR+1)) = 0;
284 memcpy(pMICHDR+2, &(pMACHeader->abyAddr2[0]), 6);
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;
297 *((
unsigned char *)(pMICHDR+17)) = 28;
299 *((
unsigned char *)(pMICHDR+17)) = 22;
301 wValue =
cpu_to_le16(pMACHeader->wFrameCtl & 0xC78F);
302 memcpy(pMICHDR+18, (
unsigned char *)&wValue, 2);
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;
311 memcpy(pMICHDR+38, (
unsigned char *)&wValue, 2);
313 memcpy(pMICHDR+40, &(pMACHeader->abyAddr4[0]), 6);
324 unsigned char *pbyPayloadHead,
325 unsigned short wPayloadSize
328 unsigned int cbICVlen = 4;
329 unsigned long dwICV = 0xFFFFFFFF
L;
330 unsigned long *pdwICV;
332 if (pTransmitKey ==
NULL)
339 pdwICV = (
unsigned long *)(pbyPayloadHead + wPayloadSize);
344 rc4_encrypt(&pDevice->
SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
350 pdwICV = (
unsigned long *)(pbyPayloadHead + wPayloadSize);
355 rc4_encrypt(&pDevice->
SBox, pbyPayloadHead, pbyPayloadHead, wPayloadSize+cbICVlen);
372 unsigned char byPktType,
373 unsigned int cbFrameLength,
374 unsigned short wRate,
378 unsigned int uDataTime, uAckTime;
391 return (uDataTime + pDevice->
uSIFS + uAckTime);
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;
415 if (byRTSRsvType == 0) {
419 else if (byRTSRsvType == 1){
424 else if (byRTSRsvType == 2) {
428 else if (byRTSRsvType == 3) {
431 uRrvTime = uCTSTime + uAckTime + uDataTime + 2*pDevice->
uSIFS;
436 uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->
uSIFS;
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)) {
469 if (((uMACfragNum == 1)) || (bLastFrag == 1)) {
472 return (pDevice->
uSIFS + uAckTime);
478 if (uFragIdx == (uMACfragNum-2)) {
479 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
481 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
485 return (pDevice->
uSIFS + uAckTime + uNextPktTime);
487 return (pDevice->
uSIFS + uNextPktTime);
493 if (((uMACfragNum==1)) || (bLastFrag==1)) {
496 return (pDevice->
uSIFS + uAckTime);
502 if(uFragIdx == (uMACfragNum-2)){
503 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck);
505 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
509 return (pDevice->
uSIFS + uAckTime + uNextPktTime);
511 return (pDevice->
uSIFS + uNextPktTime);
517 if (((uMACfragNum==1)) || (bLastFrag==1)) {
520 return (pDevice->
uSIFS + uAckTime);
532 if(uFragIdx == (uMACfragNum-2)){
533 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize,
wFB_Opt0[
FB_RATE0][wRate-
RATE_18M], bNeedAck);
543 if(uFragIdx == (uMACfragNum-2)){
544 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize,
wFB_Opt1[
FB_RATE0][wRate-
RATE_18M], bNeedAck);
552 return (pDevice->
uSIFS + uAckTime + uNextPktTime);
554 return (pDevice->
uSIFS + uNextPktTime);
560 if (((uMACfragNum==1)) || (bLastFrag==1)) {
563 return (pDevice->
uSIFS + uAckTime);
575 if(uFragIdx == (uMACfragNum-2)){
576 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize,
wFB_Opt0[
FB_RATE1][wRate-
RATE_18M], bNeedAck);
587 if(uFragIdx == (uMACfragNum-2)){
588 uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize,
wFB_Opt1[
FB_RATE1][wRate-
RATE_18M], bNeedAck);
595 return (pDevice->
uSIFS + uAckTime + uNextPktTime);
597 return (pDevice->
uSIFS + uNextPktTime);
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;
631 uDurTime = uCTSTime + 2*pDevice->
uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
636 uDurTime = uCTSTime + 2*pDevice->
uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
641 uDurTime = uCTSTime + 2*pDevice->
uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck);
645 uDurTime = pDevice->
uSIFS + s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, 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) {
737 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_a), (
unsigned char *)&(pBuf->bySignalField_a)
741 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
745 pBuf->wDuration_a =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A, cbFrameLength,
746 byPktType, wCurrentRate, bNeedAck, uFragIdx,
747 cbLastFragmentSize, uMACfragNum,
749 pBuf->wDuration_b =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_B, cbFrameLength,
751 bNeedAck, uFragIdx, cbLastFragmentSize,
752 uMACfragNum, byFBOption));
757 return (pBuf->wDuration_a);
763 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_a), (
unsigned char *)&(pBuf->bySignalField_a)
767 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
771 pBuf->wDuration_a =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A, cbFrameLength, byPktType,
772 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
774 pDevice->
byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
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));
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));
783 return (pBuf->wDuration_a);
792 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
797 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A, cbFrameLength, byPktType,
798 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
799 pBuf->wDuration_f0 =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A_F0, cbFrameLength, byPktType,
800 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
801 pBuf->wDuration_f1 =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A_F1, cbFrameLength, byPktType,
802 wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption));
804 return (pBuf->wDuration);
809 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
814 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A, cbFrameLength, byPktType,
815 wCurrentRate, bNeedAck, uFragIdx,
816 cbLastFragmentSize, uMACfragNum,
820 return (pBuf->wDuration);
827 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
831 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_B, cbFrameLength, byPktType,
832 wCurrentRate, bNeedAck, uFragIdx,
833 cbLastFragmentSize, uMACfragNum,
836 return (pBuf->wDuration);
846 unsigned char byPktType,
848 unsigned int cbFrameLength,
852 unsigned short wCurrentRate,
853 unsigned char byFBOption
856 unsigned int uRTSFrameLen = 20;
857 unsigned short wLen = 0x0000;
875 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
879 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_a), (
unsigned char *)&(pBuf->bySignalField_a)
884 pBuf->wDuration_aa =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
885 pBuf->wDuration_ba =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
887 pBuf->Data.wDurationID = pBuf->wDuration_aa;
892 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
901 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
908 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
912 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_a), (
unsigned char *)&(pBuf->bySignalField_a)
918 pBuf->wDuration_aa =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
919 pBuf->wDuration_ba =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
920 pBuf->wRTSDuration_ba_f0 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
921 pBuf->wRTSDuration_aa_f0 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
922 pBuf->wRTSDuration_ba_f1 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
923 pBuf->wRTSDuration_aa_f1 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
924 pBuf->Data.wDurationID = pBuf->wDuration_aa;
930 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
940 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
950 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
954 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
955 pBuf->Data.wDurationID = pBuf->wDuration;
961 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
971 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
979 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
983 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
984 pBuf->wRTSDuration_f0 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
985 pBuf->wRTSDuration_f1 =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
986 pBuf->Data.wDurationID = pBuf->wDuration;
992 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
1001 memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
1009 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField), (
unsigned char *)&(pBuf->bySignalField)
1013 pBuf->wDuration =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
1014 pBuf->Data.wDurationID = pBuf->wDuration;
1021 memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[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) {
1069 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
1075 pBuf->wDuration_ba = (
unsigned short)s_uGetRTSCTSDuration(pDevice,
CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption);
1077 pBuf->wDuration_ba =
cpu_to_le16(pBuf->wDuration_ba);
1079 pBuf->wCTSDuration_ba_f0 = (
unsigned short)s_uGetRTSCTSDuration(pDevice,
CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption);
1081 pBuf->wCTSDuration_ba_f0 =
cpu_to_le16(pBuf->wCTSDuration_ba_f0);
1083 pBuf->wCTSDuration_ba_f1 = (
unsigned short)s_uGetRTSCTSDuration(pDevice,
CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption);
1085 pBuf->wCTSDuration_ba_f1 =
cpu_to_le16(pBuf->wCTSDuration_ba_f1);
1087 pBuf->Data.wDurationID = pBuf->wDuration_ba;
1089 pBuf->Data.wReserved = 0x0000;
1096 (
unsigned short *)&(wLen), (
unsigned char *)&(pBuf->byServiceField_b), (
unsigned char *)&(pBuf->bySignalField_b)
1100 pBuf->wDuration_ba =
cpu_to_le16((
unsigned short)s_uGetRTSCTSDuration(pDevice,
CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption));
1102 pBuf->wDuration_ba =
cpu_to_le16(pBuf->wDuration_ba);
1105 pBuf->Data.wDurationID = pBuf->wDuration_ba;
1107 pBuf->Data.wReserved = 0x0000;
1143 s_vGenerateTxParameter (
1145 unsigned char byPktType,
1150 unsigned int cbFrameSize,
1152 unsigned int uDMAIdx,
1154 unsigned short wCurrentRate
1158 unsigned short wFifoCtl;
1159 bool bDisCRC =
false;
1165 pFifoHead->wReserved = wCurrentRate;
1166 wFifoCtl = pFifoHead->wFIFOCtl;
1184 if (pvRTS !=
NULL) {
1188 pBuf->wRTSTxRrvTime_aa =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));
1189 pBuf->wRTSTxRrvTime_ba =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate));
1190 pBuf->wRTSTxRrvTime_bb =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));
1191 pBuf->wTxRrvTime_a =
cpu_to_le16((
unsigned short) s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));
1195 s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
1202 pBuf->wTxRrvTime_a =
cpu_to_le16((
unsigned short)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));
1204 pBuf->wCTSTxRrvTime_ba =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate));
1209 s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption);
1214 if (pvRTS !=
NULL) {
1218 pBuf->wRTSTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));
1219 pBuf->wTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));
1222 s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
1224 else if (pvRTS ==
NULL) {
1228 pBuf->wTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetTxRsvTime(pDevice,
PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK));
1234 if ((pvRTS !=
NULL)) {
1238 pBuf->wRTSTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));
1239 pBuf->wTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetTxRsvTime(pDevice,
PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));
1242 s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption);
1248 pBuf->wTxRrvTime =
cpu_to_le16((
unsigned short)s_uGetTxRsvTime(pDevice,
PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));
1261 s_vFillFragParameter(
1263 unsigned char *pbyBuffer,
1264 unsigned int uTxType,
1266 unsigned short wFragType,
1267 unsigned int cbReqCount
1278 ptdCurr->m_wFIFOCtl = pTxBufHead->wFIFOCtl;
1279 ptdCurr->m_wTimeStamp = pTxBufHead->wTimeStamp;
1281 ptdCurr->m_td1TD1.wReqCount =
cpu_to_le16((
unsigned short)(cbReqCount));
1293 ptdCurr->m_td1TD1.wReqCount =
cpu_to_le16((
unsigned short)(cbReqCount));
1302 pTxBufHead->wFragCtl |= (
unsigned short)wFragType;
1308 s_cbFillTxBufHead(
PSDevice pDevice,
unsigned char byPktType,
unsigned char *pbyTxBufferAddr,
1309 unsigned int cbFrameBodySize,
unsigned int uDMAIdx,
PSTxDesc pHeadTD,
1311 PSKeyItem pTransmitKey,
unsigned int uNodeIndex,
unsigned int *puMACfragNum)
1313 unsigned int cbMACHdLen;
1314 unsigned int cbFrameSize;
1315 unsigned int cbFragmentSize;
1316 unsigned int cbFragPayloadSize;
1317 unsigned int cbLastFragmentSize;
1318 unsigned int cbLastFragPayloadSize;
1319 unsigned int uFragIdx;
1320 unsigned char *pbyPayloadHead;
1321 unsigned char *pbyIVHead;
1322 unsigned char *pbyMacHdr;
1323 unsigned short wFragType;
1324 unsigned int uDuration;
1325 unsigned char *pbyBuffer;
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;
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;
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;
1356 unsigned int cbHeaderLength = 0;
1362 unsigned short wTxBufSize;
1363 unsigned int uTotalCopyLength = 0;
1365 bool bIsWEP256 =
false;
1369 pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd =
NULL;
1375 if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
1393 if ((bNeedEncrypt ==
true) && (pTransmitKey !=
NULL)) {
1409 cbMICHDR =
sizeof(SMICHDRHead);
1413 uPadding = 4 - (cbMACHdLen%4);
1419 cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
1421 if ((bNeedACK ==
false) ||
1434 if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_0) {
1437 else if (psTxBufHd->wFIFOCtl & FIFOCTL_AUTO_FB_1) {
1443 wTxBufSize =
sizeof(STxBufHead);
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);
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);
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);
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);
1487 pvRrvTime = (
PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize);
1488 pMICHDR = (
PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize +
sizeof(SRrvTime_ab));
1489 pvRTS = (
PSRTS_ab) (pbyTxBufferAddr + wTxBufSize +
sizeof(SRrvTime_ab) + cbMICHDR);
1492 cbHeaderLength = wTxBufSize +
sizeof(
PSRrvTime_ab) + cbMICHDR +
sizeof(SRTS_ab) +
sizeof(STxDataHead_ab);
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);
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);
1510 cbHeaderLength = wTxBufSize +
sizeof(
PSRrvTime_ab) + cbMICHDR +
sizeof(SRTS_a_FB) +
sizeof(STxDataHead_a_FB);
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));
1527 dwMICKey0 = *(
unsigned long *)(&pTransmitKey->
abyKey[16]);
1528 dwMICKey1 = *(
unsigned long *)(&pTransmitKey->
abyKey[20]);
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]);
1540 MIC_vAppend((
unsigned char *)&(psEthHeader->abyDstAddr[0]), 12);
1548 pbyMacHdr = (
unsigned char *)(pbyTxBufferAddr + cbHeaderLength);
1549 pbyPayloadHead = (
unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen);
1550 pbyIVHead = (
unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding);
1556 cbFragPayloadSize = cbFragmentSize - cbMACHdLen - cbIVlen - cbICVlen - cbFCSlen;
1558 uMACfragNum = (
unsigned short) ((cbFrameBodySize + cbMIClen) / cbFragPayloadSize);
1559 cbLastFragPayloadSize = (cbFrameBodySize + cbMIClen) % cbFragPayloadSize;
1560 if (cbLastFragPayloadSize == 0) {
1561 cbLastFragPayloadSize = cbFragPayloadSize;
1566 cbLastFragmentSize = cbMACHdLen + cbLastFragPayloadSize + cbIVlen + cbICVlen + cbFCSlen;
1568 for (uFragIdx = 0; uFragIdx < uMACfragNum; uFragIdx ++) {
1569 if (uFragIdx == 0) {
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);
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);
1592 if (pDevice->bEnableHostWEP) {
1608 pbyType = (
unsigned char *) (pbyPayloadHead + 6);
1609 memcpy(pbyType, &(psEthHeader->wType),
sizeof(
unsigned short));
1613 cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
1627 pbyBuffer = (
unsigned char *)pHeadTD->pTDInfo->buf;
1629 uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
1631 memcpy(pbyBuffer, (
void *)psTxBufHd, uLength);
1634 memcpy((pbyBuffer + uLength), (pPacket + 14), (cbFragPayloadSize - cb802_1_H_len));
1637 uTotalCopyLength += cbFragPayloadSize - cb802_1_H_len;
1641 MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFragPayloadSize);
1650 s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len), (
unsigned short)cbFragPayloadSize);
1651 cbReqCount += cbICVlen;
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);
1670 pHeadTD = ptdCurr->next;
1672 else if (uFragIdx == (uMACfragNum-1)) {
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);
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) {
1705 cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbLastFragPayloadSize;
1712 pbyBuffer = (
unsigned char *)pHeadTD->pTDInfo->buf;
1715 uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
1718 memcpy(pbyBuffer, (
void *)psTxBufHd, uLength);
1721 if (bMIC2Frag ==
false) {
1723 memcpy((pbyBuffer + uLength),
1724 (pPacket + 14 + uTotalCopyLength),
1725 (cbLastFragPayloadSize - cbMIClen)
1728 uTmpLen = cbLastFragPayloadSize - cbMIClen;
1733 uMICFragLen, cbLastFragPayloadSize, uTmpLen);
1735 if (bMIC2Frag ==
false) {
1738 pdwMIC_L = (
unsigned long *)(pbyBuffer + uLength + uTmpLen);
1739 pdwMIC_R = (
unsigned long *)(pbyBuffer + uLength + uTmpLen + 4);
1743 if (uMICFragLen >= 4) {
1744 memcpy((pbyBuffer + uLength), ((
unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)),
1745 (cbMIClen - uMICFragLen));
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);
1755 *(
unsigned char *)((
unsigned char *)&dwSafeMIC_R + uMICFragLen - 4),
1756 (cbMIClen - uMICFragLen));
1767 ASSERT(uTmpLen == (cbLastFragPayloadSize - cbMIClen));
1776 s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (
unsigned short)cbLastFragPayloadSize);
1777 cbReqCount += cbICVlen;
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);
1799 pHeadTD = ptdCurr->next;
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);
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) {
1834 cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cbFragPayloadSize;
1846 pbyBuffer = (
unsigned char *)pHeadTD->pTDInfo->buf;
1850 uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen;
1853 memcpy(pbyBuffer, (
void *)psTxBufHd, uLength);
1856 memcpy((pbyBuffer + uLength),
1857 (pPacket + 14 + uTotalCopyLength),
1860 uTmpLen = cbFragPayloadSize;
1862 uTotalCopyLength += 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);
1876 dwSafeMIC_L = *pdwMIC_L;
1877 dwSafeMIC_R = *pdwMIC_R;
1880 uMICFragLen, cbFragPayloadSize, uTmpLen);
1899 ASSERT(uTmpLen == (cbFragPayloadSize));
1904 s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength), (
unsigned short)cbFragPayloadSize);
1905 cbReqCount += cbICVlen;
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);
1926 pHeadTD = ptdCurr->next;
1939 psTxBufHd->wFragCtl |= (
unsigned short)wFragType;
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,
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) {
1972 pbyType = (
unsigned char *) (pbyPayloadHead + 6);
1973 memcpy(pbyType, &(psEthHeader->wType),
sizeof(
unsigned short));
1977 cbReqCount = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen);
1987 pbyBuffer = (
unsigned char *)pHeadTD->pTDInfo->buf;
1990 uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len;
1993 memcpy(pbyBuffer, (
void *)psTxBufHd, uLength);
1996 memcpy((pbyBuffer + uLength),
1998 cbFrameBodySize - cb802_1_H_len
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);
2041 s_vSWencryption(pDevice, pTransmitKey, (pbyBuffer + uLength - cb802_1_H_len),
2042 (
unsigned short)(cbFrameBodySize + cbMIClen));
2043 cbReqCount += cbICVlen;
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);
2056 ptdCurr->m_td1TD1.wReqCount =
cpu_to_le16((
unsigned short)(cbReqCount));
2065 *puMACfragNum = uMACfragNum;
2067 return cbHeaderLength;
2073 bool bNeedEncrypt,
unsigned int cbPayloadSize,
unsigned int uDMAIdx,
2075 PSKeyItem pTransmitKey,
unsigned int uNodeIndex,
unsigned int *puMACfragNum,
2076 unsigned int *pcbHeaderSize)
2078 unsigned int wTxBufSize;
2081 unsigned short cbMacHdLen;
2084 wTxBufSize =
sizeof(STxBufHead);
2086 memset(pTxBufHead, 0, wTxBufSize);
2091 if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0]))) {
2132 pTxBufHead->wFragCtl |=
cpu_to_le16((
unsigned short)(cbMacHdLen << 10));
2162 pDevice->
bAES =
false;
2166 if ((bNeedEncrypt) && (pTransmitKey !=
NULL)) {
2193 pTxBufHead->byTxPower = pDevice->
byCurPwr;
2202 *pcbHeaderSize = s_cbFillTxBufHead(pDevice, byPktType, pbyTxBufferAddr, cbPayloadSize,
2203 uDMAIdx, pHeadTD, psEthHeader, pPacket, bNeedEncrypt,
2204 pTransmitKey, uNodeIndex, puMACfragNum);
2234 unsigned char *pbyBufferAddr,
2238 unsigned short wFragType,
2239 unsigned int uDMAIdx,
2240 unsigned int uFragIdx
2245 memset(pMACHeader, 0, (
sizeof(S802_11Header)));
2254 memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
2256 memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
2261 memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
2262 memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
2266 memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]),
ETH_ALEN);
2267 memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]),
ETH_ALEN);
2269 pMACHeader->wFrameCtl |=
FC_TODS;
2286 pMACHeader->wSeqCtl |=
cpu_to_le16((
unsigned short)uFragIdx);
2307 unsigned char byPktType;
2308 unsigned char *pbyTxBufferAddr;
2312 unsigned int uDuration;
2313 unsigned int cbReqCount;
2315 unsigned int cbHeaderSize;
2316 unsigned int cbFrameBodySize;
2318 bool bIsPSPOLL =
false;
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;
2332 unsigned short wCurrentRate =
RATE_1M;
2340 pbyTxBufferAddr = (
unsigned char *)pFrstTD->pTDInfo->buf;
2343 wTxBufSize =
sizeof(STxBufHead);
2344 memset(pTxBufHead, 0, wTxBufSize);
2364 pTxBufHead->byTxPower = pDevice->
byCurPwr;
2375 pTxBufHead->wFIFOCtl = 0;
2391 if (is_multicast_ether_addr(&(pPacket->
p80211Header->
sA3.abyAddr1[0])))
2421 pTxBufHead->wFragCtl |=
cpu_to_le16((
unsigned short)(cbMacHdLen << 10));
2426 pDevice->
bAES =
false;
2447 pDevice->
bAES =
true;
2450 uPadding = 4 - (cbMacHdLen%4);
2454 cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen;
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);
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));
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,
2501 cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize;
2504 unsigned char *pbyIVHead;
2505 unsigned char *pbyPayloadHead;
2506 unsigned char *pbyBSSID;
2509 pbyIVHead = (
unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding);
2510 pbyPayloadHead = (
unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen);
2544 pTransmitKey =
NULL;
2551 s_vFillTxKey(pDevice, (
unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
2552 (
unsigned char *)pMACHeader, (
unsigned short)cbFrameBodySize,
NULL);
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;
2626 unsigned char byPktType;
2627 unsigned char *pbyBuffer = (
unsigned char *)pDevice->
tx_beacon_bufs;
2629 unsigned int cbHeaderSize = 0;
2630 unsigned short wTxBufSize =
sizeof(STxShortBufHead);
2634 unsigned short wCurrentRate;
2635 unsigned short wLen = 0x0000;
2638 memset(pTxBufHead, 0, wTxBufSize);
2658 pTxDataHead->wDuration =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_A, cbFrameSize, byPktType,
2663 pTxDataHead->wDuration =
cpu_to_le16((
unsigned short)s_uGetDataDuration(pDevice,
DATADUR_B, cbFrameSize, byPktType,
2668 (
unsigned short *)&(wLen), (
unsigned char *)&(pTxDataHead->byServiceField), (
unsigned char *)&(pTxDataHead->bySignalField)
2673 cbHeaderSize = wTxBufSize +
sizeof(STxDataHead_ab);
2679 pMACHeader->wDurationID = 0;
2705 unsigned int cbFrameBodySize,
2709 unsigned int cbMACHdLen;
2710 unsigned int cbFrameSize;
2711 unsigned int cbFragmentSize;
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;
2725 if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])))
2743 if (pTransmitKey ==
NULL) {
2769 cbFrameSize = cbMACHdLen + cbIVlen + (cbFrameBodySize + cbMIClen) + cbICVlen + cbFCSlen;
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;
2791 unsigned char byPktType;
2792 unsigned char *pbyTxBufferAddr;
2796 unsigned int uDuration;
2797 unsigned int cbReqCount;
2799 unsigned int cbHeaderSize;
2800 unsigned int cbFrameBodySize;
2802 bool bIsPSPOLL =
false;
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;
2822 unsigned short wCurrentRate =
RATE_1M;
2824 unsigned int uNodeIndex = 0;
2825 bool bNodeExist =
false;
2828 unsigned char *pbyIVHead;
2829 unsigned char *pbyPayloadHead;
2830 unsigned char *pbyMacHdr;
2832 unsigned int cbExtSuppRate = 0;
2836 pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd =
NULL;
2839 cbFrameBodySize = 0;
2848 pbyTxBufferAddr = (
unsigned char *)pFrstTD->pTDInfo->buf;
2850 wTxBufSize =
sizeof(STxBufHead);
2851 memset(pTxBufHead, 0, wTxBufSize);
2870 pTxBufHead->byTxPower = pDevice->
byCurPwr;
2884 pTxBufHead->wFIFOCtl = 0;
2900 if (is_multicast_ether_addr(&(p80211Header->
sA3.abyAddr1[0]))) {
2902 if (pDevice->bEnableHostWEP) {
2908 if (pDevice->bEnableHostWEP) {
2950 if (cbExtSuppRate >0) {
2957 pTxBufHead->wFragCtl |=
cpu_to_le16((
unsigned short)cbMacHdLen << 10);
2962 pDevice->
bAES =
false;
2983 cbMICHDR =
sizeof(SMICHDRHead);
2985 pDevice->
bAES =
true;
2988 uPadding = 4 - (cbMacHdLen%4);
2992 cbFrameSize = cbMacHdLen + cbFrameBodySize + cbIVlen + cbMIClen + cbICVlen + cbFCSlen + cbExtSuppRate;
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);
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);
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,
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);
3048 memcpy(pbyMacHdr, pbMPDU, cbMacHdLen);
3052 memcpy(pbyPayloadHead, (pbMPDU + cbMacHdLen), cbFrameBodySize);
3056 if (cbExtSuppRate != 0) {
3058 memcpy((pbyPayloadHead + cbFrameBodySize),
3073 if (pDevice->bEnableHostWEP) {
3074 pTransmitKey = &STempKey;
3088 dwMICKey0 = *(
unsigned long *)(&pTransmitKey->
abyKey[16]);
3089 dwMICKey1 = *(
unsigned long *)(&pTransmitKey->
abyKey[20]);
3093 MIC_vAppend((
unsigned char *)&(sEthHeader.abyDstAddr[0]), 12);
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);
3121 s_vFillTxKey(pDevice, (
unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey,
3122 pbyMacHdr, (
unsigned short)cbFrameBodySize, (
unsigned char *)pMICHDR);
3124 if (pDevice->bEnableHostWEP) {
3130 s_vSWencryption(pDevice, pTransmitKey, pbyPayloadHead, (
unsigned short)(cbFrameBodySize + cbMIClen));
3157 pFrstTD->pTDInfo->skb =
skb;
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;