1 #ifndef __ZDPMFILTER_C__
2 #define __ZDPMFILTER_C__
7 extern struct net_device
*g_dev
;
9 #define DBG_USE_SERIAL_WRITE 0
11 BOOLEAN
TxSend(Signal_t
*signal
, FrmDesc_t
*pfrmDesc
);
12 #define write_str(a,b)
14 U8 TimBitMap
[(MAX_AID
/8)+2];
15 Signal_t
*txRequest
[BURST_NUM
] = { NULL
};
16 static BOOLEAN mcBuffered
= FALSE
;
18 //make tim for beacon frame
19 void mkTim(Element
*tim
, TrafficMap_t
*trf
, U8 dtc
, U8 dtp
, U16 aidLo
, U16 aidHi
, BOOLEAN bc
)
22 U8
*map
= (U8
*)trf
->t
;
27 tim
->buf
[0] = EID_TIM
;
32 for (i
=0; i
<=(aidHi
/8); i
++){
39 // N1 is the largest even number
40 N1
= (U16
)(i
& ~0x01);
44 for (i
=(aidHi
/8); i
>=0; i
--){
62 for (i
=N1
; i
<=N2
; i
++){
63 tim
->buf
[5+index
++] = map
[i
];
65 tim
->buf
[1] = N2
-N1
+4;
74 void TxCompleted(U32 result
, U8 retID
, U16 aid
) //in isr routine
84 if ((result
!= ZD_TX_CONFIRM
) && (retID
== 0xff)){
85 pHash
= sstByAid
[aid
];
89 pHash
->FailedFrames
++;
95 signal
= txRequest
[retID
];
98 printk(KERN_ERR
"TxCompleted: input signal is NULL\n");
101 pfrmInfo
= &signal
->frmInfo
;
102 pfrmDesc
= pfrmInfo
->frmDesc
;
106 bIntraBss
= (pfrmDesc
->ConfigSet
& INTRA_BSS_SET
);
110 pHash
= sstByAid
[aid
];
114 if (result
== ZD_TX_CONFIRM
){
116 pHash
->SuccessFrames
++;
119 pHash
->FailedFrames
++;
127 pdot11Obj
->ReleaseBuffer(buf
);
129 txRequest
[retID
] = NULL
;
131 if ((buf
) && (!bIntraBss
)){ //upper layer data
132 pdot11Obj
->TxCompleted();
137 char DbgStr1
[]="Tx ProbReq";
138 char DbgStr2
[]="Tx Auth";
139 char DbgStr3
[]="Tx Data";
140 char DbgStr4
[]="msg4";
141 char DbgStr5
[]="msg5";
142 char DbgStr6
[]="msg6";
143 char DbgStr7
[]="msg7";
144 char DbgStr8
[]="msg8";
145 char DbgStr9
[]="msg9";
146 char DbgStr10
[]="msg10";
147 char DbgStr11
[]="msg11";
149 char DbgStr12
[]="msg12";
150 BOOLEAN
TxSend(Signal_t
*signal
, FrmDesc_t
*pfrmDesc
)
161 Hash_t
*pHash
= NULL
;
164 //U8 *pWepKey = NULL;
169 BOOLEAN bExtIV
= FALSE
;
171 BOOLEAN bGroupAddr
= FALSE
;
175 U8 bDataFrm
= signal
->bDataFrm
;
176 //U8 KeyInstalled = 0;
181 //txRequest[usedID] = signal;
182 memcpy(fragInfo
.CalSwMic
, pfrmDesc
->CalMIC
, MIC_LNG
+1);
183 pfrmInfo
= &signal
->frmInfo
;
184 bIntraBss
= (pfrmDesc
->ConfigSet
& INTRA_BSS_SET
);
188 //for PS-POLL handling
189 if (pfrmDesc
->ConfigSet
& PS_POLL_SET
){
190 if(mMacMode
!= PURE_A_MODE
) {
191 fragInfo
.rate
= RATE_1M
;
192 fragInfo
.preamble
= mPreambleType
;
194 else if(mMacMode
== PURE_A_MODE
) {
195 fragInfo
.rate
= RATE_6M
;
196 fragInfo
.preamble
= SHORT_PREAMBLE
; //802.11A frame must
200 fragInfo
.macHdr
[0] = &pf
->header
[0];
201 fragInfo
.macBody
[0] = pf
->body
;
202 fragInfo
.bodyLen
[0] = 0;
203 fragInfo
.nextBodyLen
[0] = 0;
204 //fragInfo.msgID = usedID;
205 fragInfo
.totalFrag
= 1;
206 fragInfo
.hdrLen
= pf
->HdrLen
;
207 fragInfo
.encryType
= WEP_NOT_USED
;
208 fragInfo
.vapId
= vapId
;
209 fragInfo
.bIntraBss
= bIntraBss
;
210 fragInfo
.buf
= signal
->buf
;
214 pHash
= pfrmDesc
->pHash
;
216 EncryType
= mKeyFormat
;
218 /* if ((pf->header[0] & 0xFC) == 0x40)
219 { //Probe Req, for debugging purpose.
222 if (pf->body[1] == 0)
223 printk(KERN_ERR "Probe Request with Broadcase ssid\n");
225 printk(KERN_ERR "Probe Request with ssid=%s",&pf->body[2]);
228 else if ((pf->header[0] & 0xFC) == 0xB0)
230 //printk(KERN_ERR "Tx Auth\n");
231 //serial_printf(" Tx Auth\n");
233 else if ((pf->header[0] & 0xFC) == 0x08)
235 //printk(KERN_ERR "Tx Data,keyMode=%d\n",mDynKeyMode);
236 //serial_printf("Tx Data,keyMode=%d\n",mDynKeyMode);
238 if (isGroup(addr1(pf
))){
240 fragInfo
.rate
= pdot11Obj
->BasicRate
;
242 if(PURE_A_MODE
!= mMacMode
)
243 fragInfo
.preamble
= 0;
245 fragInfo
.preamble
= 1;
247 /*if ((mSwCipher) && (bWep)){
248 if ((mDynKeyMode == DYN_KEY_WEP64) || (mDynKeyMode == DYN_KEY_WEP128)){
249 WepKeyLen = mBcKeyLen;
250 pWepKey = &mBcKeyVector[0];
253 tmpiv = (U32 *)mBcIv;
255 }*/ /* The software encryption is always disabled.*/
257 if (bWep
){// For 802.1x dynamic key mode
258 if ((mDynKeyMode
== DYN_KEY_WEP64
) || (mDynKeyMode
== DYN_KEY_WEP128
)){
259 if (mDynKeyMode
== DYN_KEY_WEP64
)
260 EncryType
= WEP64_USED
;
262 EncryType
= WEP128_USED
;
265 tmpiv
= (U32
*)mBcIv
;
270 else{ // unicast frame
272 // Should be Probe Response frame
273 fragInfo
.rate
= pdot11Obj
->BasicRate
;
274 //FPRINT_V("pHash = 0; fragInfo.rate", fragInfo.rate);
276 if(mMacMode
!= PURE_A_MODE
)
277 fragInfo
.preamble
= 0;
279 fragInfo
.preamble
= 1;
283 fragInfo
.rate
= pHash
->CurrTxRate
;
285 //FPRINT_V("pHash != 0 fragInfo.rate", fragInfo.rate);
286 fragInfo
.aid
= (U16
)pHash
->aid
;
287 fragInfo
.preamble
= pHash
->Preamble
;
289 //if (mBssType == AP_BSS)
291 EncryType
= pHash
->encryMode
;
297 if ((mDynKeyMode
== DYN_KEY_WEP64
) || (mDynKeyMode
== DYN_KEY_WEP128
)){
298 pIv
= &pHash
->wepIv
[1];
299 KeyId
= pHash
->KeyId
;
300 tmpiv
= (U32
*)pHash
->wepIv
;
307 if (mDynKeyMode
== 0){ // static 4 keys, wep64, 128 or 256
310 tmpiv
= (U32
*)mWepIv
;
311 EncryType
= mKeyFormat
;
315 Num
= pfrmInfo
->fTot
;
316 //FPRINT_V("Tx fTot", pfrmInfo->fTot);
317 for (i
=0; i
<Num
; i
++){
318 pf
= &pfrmDesc
->mpdu
[i
];
325 if (frmType(pf
) == ST_PROBE_RSP
)
329 HW_GetTsf(pdot11Obj
, &loTm
, &hiTm
);
330 setTs(pf
, loTm
, hiTm
);
338 nextPf
= &pfrmDesc
->mpdu
[i
+1];
339 nextBodyLen
= nextPf
->bodyLen
;
347 //prepare frag information
348 fragInfo
.macHdr
[i
] = &pf
->header
[0];
349 fragInfo
.macBody
[i
] = pf
->body
;
350 fragInfo
.bodyLen
[i
] = pf
->bodyLen
;
351 fragInfo
.nextBodyLen
[i
] = nextBodyLen
;
354 {// Encryption is needed.
355 if ((mDynKeyMode
== DYN_KEY_TKIP
) || (mDynKeyMode
== DYN_KEY_AES
))
356 {// WPA encryption mode.
363 case 32:// Group TKIP
368 pIv
[1] = (Hi8(mIv16
) | 0x20) & 0x7f;
373 EncryType
= TKIP_USED
;
375 case 5: // Group WEP64
378 tmpiv
= (U32
*)mBcIv
;
379 EncryType
= WEP64_USED
;
381 case 13: // Group WEP128
384 tmpiv
= (U32
*)mBcIv
;
385 EncryType
= WEP128_USED
;
397 EncryType
= AES_USED
;
399 default: // Group key Len error
401 fragInfo
.macHdr
[i
][1] &= ~WEP_BIT
;
406 {// Group key was not installed yet.
408 fragInfo
.macHdr
[i
][1] &= ~WEP_BIT
;
410 }//endof group frame.
413 //printk(KERN_ERR "send unicast packet,pkeyinstalled:%d\n",pHash->pkInstalled);
414 //KeyInstalled = pHash->pkInstalled;
415 if ((pHash
) && (pHash
->pkInstalled
))
418 if (pHash
->iv16
== 0)
420 if (EncryType
== TKIP_USED
)
422 pIv
[0] = Hi8(pHash
->iv16
);
423 pIv
[1] = (Hi8(pHash
->iv16
) | 0x20) & 0x7f;
424 pIv
[2] = Lo8(pHash
->iv16
);
426 else if (EncryType
== AES_USED
)
428 pIv
[0] = Lo8(pHash
->iv16
);
429 pIv
[1] = Hi8(pHash
->iv16
);
432 KeyId
= pHash
->KeyId
;
437 {// No key has been installed before.
439 fragInfo
.macHdr
[i
][1] &= ~WEP_BIT
;
442 } // end of ((mDynKeyMode == DYN_KEY_TKIP) || (mDynKeyMode == DYN_KEY_AES))
443 fragInfo
.macHdr
[i
][MAC_HDR_LNG
] = pIv
[0];
444 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+1] = pIv
[1];
445 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+2] = pIv
[2];
446 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+3] = KeyId
<< 6;
447 //if (mDynKeyMode != DYN_KEY_TKIP && mDynKeyMode != DYN_KEY_AES)
448 if (EncryType
== WEP64_USED
|| EncryType
== WEP128_USED
)
449 *tmpiv
= (((*tmpiv
) & 0x00FFFFFF) + 1) | ((*tmpiv
) & 0xFF000000);
452 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+3] |= 0x20;
453 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+4] = (U8
)(iv32
);
454 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+5] = (U8
)(iv32
>> 8);
455 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+6] = (U8
)(iv32
>> 16);
456 fragInfo
.macHdr
[i
][MAC_HDR_LNG
+7] = (U8
)(iv32
>> 24);
462 //fragInfo.msgID = usedID;
463 fragInfo
.bIntraBss
= bIntraBss
;
464 fragInfo
.buf
= signal
->buf
;
465 fragInfo
.totalFrag
= Num
;
466 fragInfo
.hdrLen
= MAC_HDR_LNG
;
470 fragInfo
.hdrLen
+= IV_LNG
;
472 fragInfo
.hdrLen
+= EIV_LNG
;
474 fragInfo
.encryType
= EncryType
;
477 fragInfo
.encryType
=WEP_NOT_USED
;
480 //FPRINT_V("EncryType", fragInfo.encryType);
481 //fragInfo.vapId = vapId;
483 //if (fragInfo.encryType == TKIP)
485 //fragInfo.bWaitingMIC = pfrmDesc->bWaitingMIC;
486 //fragInfo.bSwCalcMIC = pfrmDesc->bSwCalcMIC;
487 //fragInfo.HwMicPhys = (U32)pfrmDesc->HwMicPhys;
491 flags
= pdot11Obj
->EnterCS();
492 // The following 5 lines must be protected by a critical section.
493 fragInfo
.msgID
= usedID
;
494 txRequest
[usedID
] = signal
;
495 #if ZDCONF_LP_SUPPORT == 1
496 memcpy(fragInfo
.EthHdr
, signal
->EthHdr
,14);
498 pdot11Obj
->SetupNextSend(&fragInfo
);
504 if (usedID
> (BURST_NUM
-1))
506 if(XCount
> 1000) break;
507 }while(txRequest
[usedID
] != NULL
);
509 if(XCount
> 1000 && freeSignalCount
!= 0 )
511 for(;XCount
> 0;XCount
--)
512 printk("XCount!!!!\n");
515 pdot11Obj
->ExitCS(flags
);
520 void FlushQ(SignalQ_t
*Q
)
527 while((signal
= sigDeque(Q
)) != NULL
){
528 // General loop check only. for future hidden bug
529 if(loopCheck
++ > 100)
531 printk("infinite loop occurs in %s\n", __FUNCTION__
);
535 pfrmInfo
= &signal
->frmInfo
;
536 pfrmDesc
= pfrmInfo
->frmDesc
;
537 pdot11Obj
->ReleaseBuffer(signal
->buf
);
544 void TimMapSet(U8
*map
, U16 aid
, BOOLEAN flag
)
549 if ((aid
== 0) || (aid
> MAX_AID
))
553 mask
= 0x01 << (aid
% 8);
563 BOOLEAN
CleanupTxQ(void)
569 //PSDEBUG("CleanupTxQ");
571 signal
= pTxQ
->first
;
575 pfrmInfo
= &signal
->frmInfo
;
576 pfrmDesc
= pfrmInfo
->frmDesc
;
578 if (!pdot11Obj
->CheckTCBAvail(pfrmInfo
->fTot
))
581 signal
= sigDeque(pTxQ
);
589 TxSend(signal
, pfrmDesc
);
595 BOOLEAN
CleanupAwakeQ(void)
601 //PSDEBUG("CleanupAwakeQ");
602 if (pAwakeQ
->cnt
> 0){
603 signal
= pAwakeQ
->first
;
607 pfrmInfo
= &signal
->frmInfo
;
609 pfrmDesc
= pfrmInfo
->frmDesc
;
610 if (!pdot11Obj
->CheckTCBAvail(pfrmInfo
->fTot
))
613 signal
= sigDeque(pAwakeQ
);
614 //PSDEBUG("===== Queue out awakeQ");
615 //PSDEBUG_V("pAwakeQ->cnt", pAwakeQ->cnt);
623 TxSend(signal
, pfrmDesc
);
637 if ((aid
== 0) || (aid
> MAX_AID
)) //Invalid AID
641 while (pPsQ
[aid
]->cnt
){
642 // General Loop Check only. For future hidden bug
643 if(loopCheck
++ > 100)
645 printk("infinite loop occurs in %s\n", __FUNCTION__
);
650 interval
= sstByAid
[aid
]->lsInterval
;
654 psSignal
= pPsQ
[aid
]->first
;
659 pfrmInfo
= &psSignal
->frmInfo
;
662 if ((HW_GetNow(pdot11Obj
) - eol
) < (2*interval
*mBeaconPeriod
*1024)) //us
665 if ((HW_GetNow(pdot11Obj
) - eol
) < (1024*1024)) //us
668 if ((HW_GetNow(pdot11Obj
) - eol
) < (2*interval
*mBeaconPeriod
/10)) //10ms
671 if ((HW_GetNow(pdot11Obj
) - eol
) < (100)) //10ms
675 psSignal
= sigDeque(pPsQ
[aid
]);
679 PSDEBUG_V("*****Data life time-out, AID", aid
);
680 pfrmDesc
= pfrmInfo
->frmDesc
;
683 pdot11Obj
->ReleaseBuffer(psSignal
->buf
);
684 freeSignal(psSignal
);
689 TimMapSet(TimBitMap
, aid
, FALSE
);
695 void PsPolled(MacAddr_t
*sta
, U16 aid
)
704 //PSDEBUG("PsPolled");
706 signal
= sigDeque(pPsQ
[aid
]);
708 PSDEBUG("No Queue data for PS-POLL!!!");
709 TimMapSet(TimBitMap
, aid
, FALSE
);
714 PSDEBUG_V("Queue out psQ, AID ", aid
);
715 PSDEBUG_V("cnt ", pPsQ
[aid
]->cnt
);
716 pfrmInfo
= &signal
->frmInfo
;
717 pfrmDesc
= pfrmInfo
->frmDesc
;
719 Num
= pfrmInfo
->fTot
;
720 for (i
=0; i
<Num
; i
++){
721 frame
= &pfrmDesc
->mpdu
[i
];
722 //PSDEBUG_V("pfrmInfo ", (U32)pfrmInfo);
723 //PSDEBUG_V("eol ", (U32)pfrmInfo->eol);
724 PSDEBUG_V("pfrmDesc ", (U32
)pfrmDesc
);
725 //PSDEBUG_V("frame ", (U32)frame);
726 if (!pPsQ
[aid
]->cnt
){
727 frame
->header
[1] &= ~MORE_DATA_BIT
;
728 PSDEBUG("More bit 0");
731 frame
->header
[1] |= MORE_DATA_BIT
;
732 PSDEBUG("More bit 1");
735 PSDEBUG_V("bodyLen ", frame
->bodyLen
);
739 if (!pdot11Obj
->CheckTCBAvail(Num
)){
740 PSDEBUG("*****Fail to send out!!!");
741 PSDEBUG_V("Queue in psQ, AID", aid
);
742 sigEnqueFirst(pPsQ
[aid
], signal
);
746 sigEnque(pTxQ
, signal
);
752 void StaWakeup(MacAddr_t
*sta
)
758 aid
= AIdLookup(sta
);
759 if ((aid
== 0) || (aid
> MAX_AID
))
762 while((signal
= sigDeque(pPsQ
[aid
])) != NULL
){
763 // General Loop Check only. For future hidden bug
764 if(loopCheck
++ > 100)
766 printk("infinite loop occurs in %s\n", __FUNCTION__
);
771 sigEnque(pTxQ
, signal
);
776 void InitPMFilterQ(void)
779 static BOOLEAN bFirstTime
= TRUE
;
783 for (i
=0; i
< MAX_RECORD
; i
++){
793 for (i
=0; i
< MAX_RECORD
; i
++)
799 memset(TimBitMap
, 0, sizeof(TimBitMap
));
803 void ConfigBcnFIFO(void)
806 BOOLEAN bcst
= FALSE
;
807 struct zd1205_private
*macp
=g_dev
->priv
;
814 static int reCheck
= 0;
816 //FPRINT("ConfigBcnFIFO");
818 if(test_and_set_bit(0, &reCheck
))
823 if (mBssType
== AP_BSS
){
825 HW_SetSTA_PS(pdot11Obj
, 1);
826 for (i
=1; i
< (MAX_AID
+1); i
++){
829 TimMapSet(TimBitMap
, i
, TRUE
);
830 PSDEBUG_V("TimMapSet Aid", i
);
835 HW_SetSTA_PS(pdot11Obj
, 0);
838 //General loop check only. For future hidden bug
840 if(loopCheck
++ > 100)
842 printk("infinite loop occurs in %s\n", __FUNCTION__
);
847 signal
= sigDeque(pPsQ
[0]);
851 sigEnque(pTxQ
, signal
);
857 /* make beacon frame */
859 Beacon
[BcnIndex
++] = 0x80;
860 Beacon
[BcnIndex
++] = 0x00;
862 /* Duration HMAC will fill this field */
863 Beacon
[BcnIndex
++] = 0x00;
864 Beacon
[BcnIndex
++] = 0x00;
867 Beacon
[BcnIndex
++] = 0xff;
868 Beacon
[BcnIndex
++] = 0xff;
869 Beacon
[BcnIndex
++] = 0xff;
870 Beacon
[BcnIndex
++] = 0xff;
871 Beacon
[BcnIndex
++] = 0xff;
872 Beacon
[BcnIndex
++] = 0xff;
876 //Beacon[BcnIndex++] = mBssId.mac[j];
877 Beacon
[BcnIndex
++] = dot11MacAddress
.mac
[j
];
882 Beacon
[BcnIndex
++] = mBssId
.mac
[j
];
884 /* Sequence control HMAC will fill this field */
885 //Beacon[BcnIndex++] = 0x00;
886 //Beacon[BcnIndex++] = 0x00;
889 /* Timestamp HMAC will fill this field */
890 //for (j=0; j<8; j++)
891 //Beacon[BcnIndex++] = 0x00;
895 Beacon
[BcnIndex
++] = mBeaconPeriod
;
896 Beacon
[BcnIndex
++] = mBeaconPeriod
>> 8;
898 /* Display the Capability */
899 if(pdot11Obj
->dbg_cmd
& DBG_CMD_BEACON
)
900 printk(KERN_ERR
"mCap: 0x%04x\n", mCap
);
903 Beacon
[BcnIndex
++] = mCap
;
904 Beacon
[BcnIndex
++] = mCap
>> 8;
907 Len
= eLen(&mSsid
)+2;
908 for (j
=0; j
<Len
; j
++)
909 Beacon
[BcnIndex
++] = mSsid
.buf
[j
];
911 /* Supported rates */
912 Len
= eLen(&mBrates
)+2;
913 for (j
=0; j
<Len
; j
++)
914 Beacon
[BcnIndex
++] = mBrates
.buf
[j
];
917 Beacon
[BcnIndex
++] = mPhpm
.buf
[0];
918 Beacon
[BcnIndex
++] = mPhpm
.buf
[1];
919 Beacon
[BcnIndex
++] = mPhpm
.buf
[2];
921 if (mBssType
== INDEPENDENT_BSS
){
922 Beacon
[BcnIndex
++] = EID_IBPARMS
;
923 Beacon
[BcnIndex
++] = 0x2;
924 Beacon
[BcnIndex
++] = mATIMWindow
;
925 Beacon
[BcnIndex
++] = mATIMWindow
>> 8;
929 //if ((mDtimCount == 0) && (pPsQ[0]->cnt > 0)){ //dtim and buffer for mc
930 if (mBssType
== AP_BSS
){
931 if ((mDtimCount
== 0) && mcBuffered
){
935 mkTim((Element
*)tim
, (TrafficMap_t
*)&TimBitMap
, mDtimCount
, mDtimPeriod
, 1, MAX_AID
, bcst
);
937 for (j
=0; j
<Len
; j
++)
938 Beacon
[BcnIndex
++] = tim
[j
];
942 if (mMacMode
!= PURE_B_MODE
&& mMacMode
!= PURE_A_MODE
)
947 Beacon
[BcnIndex
++] = mErp
.buf
[0];
948 Beacon
[BcnIndex
++] = mErp
.buf
[1];
949 Beacon
[BcnIndex
] = mErp
.buf
[2];
950 /*if (pdot11Obj->bDisProtection==1)
951 {//Disable protection
952 Beacon[BcnIndex] &= ~USE_PROTECTION;
956 //Extended supported rates
957 Len
= mExtRates
.buf
[1]+2;;
958 for (j
=0; j
<Len
; j
++)
959 Beacon
[BcnIndex
++] = mExtRates
.buf
[j
];
964 /* if ((mDynKeyMode == DYN_KEY_TKIP) || (mDynKeyMode == DYN_KEY_AES)){
965 Len = mWPAIe.buf[1]+2;
966 for (j=0; j<Len; j++)
967 Beacon[BcnIndex++] = mWPAIe.buf[j];
969 Len
= macp
->cardSetting
.WPAIeLen
;
972 memcpy(&Beacon
[BcnIndex
], &mWPAIe
, Len
);
976 /* CRC32 HMAC will calucate this value */
977 //for (j=0; j<4; j++)
978 // Beacon[BcnIndex++] = 0x00;
982 HW_SetBeaconFIFO(pdot11Obj
, &Beacon
[0], BcnIndex
);
984 memset(TimBitMap
, 0, sizeof(TimBitMap
));
985 clear_bit(0, &reCheck
);
994 while(pPsQ
[0]->cnt
> 0){
995 //General loop check only. For future hidden bug check
996 if(loopCheck
++ > 100)
998 printk("infinite loop occurs in %s\n", __FUNCTION__
);
1003 signal
= pPsQ
[0]->first
;
1007 signal
= sigDeque(pPsQ
[0]);
1008 //PSDEBUG("Queue in awakeQ");
1009 sigEnque(pAwakeQ
, signal
);
1010 //PSDEBUG_V("pAwakeQ->cnt", pAwakeQ->cnt);
1013 if (pAwakeQ
->cnt
> 0){
1021 void ResetPMFilter(void)
1025 for (i
=0; i
<BURST_NUM
; i
++)
1026 txRequest
[i
] = NULL
;
1032 BOOLEAN
SendPkt(Signal_t
* signal
, FrmDesc_t
*pfrmDesc
, BOOLEAN bImmediate
)
1034 FrmInfo_t
*pfrmInfo
;
1040 //PSDEBUG("SendPkt");
1041 pfrmInfo
= &signal
->frmInfo
;
1042 frame
= pfrmDesc
->mpdu
;
1043 pHash
= pfrmDesc
->pHash
;
1044 Num
= pfrmInfo
->fTot
;
1046 if (!signal
->bDataFrm
) {
1047 //if (!pfrmDesc->bDataFrm){
1051 if (!isGroup(addr1(frame
))) { //unicast
1055 if (mBssType
!= AP_BSS
)
1058 //PsInquiry(addr1(frame), &dpsm, &aid);
1062 if ((dpsm
== PSMODE_POWER_SAVE
) && (aid
> 0) && (aid
<(MAX_AID
+1))) {
1065 if (zd_CheckTotalQueCnt() > TXQ_THRESHOLD
) {
1066 PSDEBUG("*****Drop PS packet*****");
1067 freeFdesc(pfrmDesc
);
1068 pdot11Obj
->ReleaseBuffer(signal
->buf
);
1073 //for (i=0; i<Num; i++){
1074 // setMoreData((&pfrmDesc->mpdu[i]), 1);
1075 // pfrmDesc->mpdu[i].header[i] |= MORE_DATA_BIT;
1077 pfrmInfo
->eol
= HW_GetNow(pdot11Obj
); //Set timestamp
1079 sigEnque(pPsQ
[aid
], signal
); //Queue in PS Queue
1080 PSDEBUG_V("Queue in PS Queue, AID ", aid
);
1081 PSDEBUG_V("cnt ", pPsQ
[aid
]->cnt
);
1082 //PSDEBUG_V("pfrmInfo ", (U32)pfrmInfo);
1083 //PSDEBUG_V("eol ", (U32)pfrmInfo->eol);
1084 PSDEBUG_V("pfrmDesc ", (U32
)pfrmDesc
);
1085 //PSDEBUG_V("frame ", (U32)frame);
1086 PSDEBUG_V("bodyLen ", frame
->bodyLen
);
1087 TimMapSet(TimBitMap
, aid
, TRUE
);
1095 else{ //group address
1096 if ((orderBit(frame
) == 0) && (mPsStaCnt
> 0)){
1097 if ((zd_CheckTotalQueCnt() > TXQ_THRESHOLD
) || (pPsQ
[0]->cnt
> MCQ_THRESHOLD
)){
1098 PSDEBUG("*****Drop MC packet*****");
1099 freeFdesc(pfrmDesc
);
1100 pdot11Obj
->ReleaseBuffer(signal
->buf
);
1105 for (i
=0; i
<Num
; i
++){
1106 pfrmDesc
->mpdu
[i
].header
[1] |= MORE_DATA_BIT
;
1109 sigEnque(pPsQ
[0], signal
); // psQ[0] is for mcQ
1110 //PSDEBUG("+++++ Queue in mcQ");
1111 //PSDEBUG_V("mcQ->cnt", pPsQ[0]->cnt);
1123 sigEnque(pTxQ
, signal
);
1127 if (!pdot11Obj
->CheckTCBAvail(Num
)){
1130 freeFdesc(pfrmDesc
);
1133 sigEnque(pTxQ
, signal
);
1136 //PSDEBUG("Queue in TxQ");
1137 //PSDEBUG_V("Cnt of TxQ", pTxQ->cnt);
1139 return TxSend(signal
, pfrmDesc
); //14 us