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.
22 * Purpose: MAC routines
29 * MACvReadAllRegs - Read All MAC Registers to buffer
30 * MACbIsRegBitsOn - Test if All test Bits On
31 * MACbIsRegBitsOff - Test if All test Bits Off
32 * MACbIsIntDisable - Test if MAC interrupt disable
33 * MACbyReadMultiAddr - Read Multicast Address Mask Pattern
34 * MACvWriteMultiAddr - Write Multicast Address Mask Pattern
35 * MACvSetMultiAddrByHash - Set Multicast Address Mask by Hash value
36 * MACvResetMultiAddrByHash - Clear Multicast Address Mask by Hash value
37 * MACvSetRxThreshold - Set Rx Threshold value
38 * MACvGetRxThreshold - Get Rx Threshold value
39 * MACvSetTxThreshold - Set Tx Threshold value
40 * MACvGetTxThreshold - Get Tx Threshold value
41 * MACvSetDmaLength - Set Dma Length value
42 * MACvGetDmaLength - Get Dma Length value
43 * MACvSetShortRetryLimit - Set 802.11 Short Retry limit
44 * MACvGetShortRetryLimit - Get 802.11 Short Retry limit
45 * MACvSetLongRetryLimit - Set 802.11 Long Retry limit
46 * MACvGetLongRetryLimit - Get 802.11 Long Retry limit
47 * MACvSetLoopbackMode - Set MAC Loopback Mode
48 * MACbIsInLoopbackMode - Test if MAC in Loopback mode
49 * MACvSetPacketFilter - Set MAC Address Filter
50 * MACvSaveContext - Save Context of MAC Registers
51 * MACvRestoreContext - Restore Context of MAC Registers
52 * MACbCompareContext - Compare if values of MAC Registers same as Context
53 * MACbSoftwareReset - Software Reset MAC
54 * MACbSafeRxOff - Turn Off MAC Rx
55 * MACbSafeTxOff - Turn Off MAC Tx
56 * MACbSafeStop - Stop MAC function
57 * MACbShutdown - Shut down MAC
58 * MACvInitialize - Initialize MAC
59 * MACvSetCurrRxDescAddr - Set Rx Descriptors Address
60 * MACvSetCurrTx0DescAddr - Set Tx0 Descriptors Address
61 * MACvSetCurrTx1DescAddr - Set Tx1 Descriptors Address
62 * MACvTimer0MicroSDelay - Micro Second Delay Loop by MAC
65 * 08-22-2003 Kyle Hsu : Porting MAC functions from sim53
66 * 09-03-2003 Bryan YC Fan : Add MACvClearBusSusInd()& MACvEnableBusSusEn()
67 * 09-18-2003 Jerry Chen : Add MACvSetKeyEntry & MACvDisableKeyEntry
75 unsigned short TxRate_iwconfig
;//2008-5-8 <add> by chester
76 /*--------------------- Static Definitions -------------------------*/
77 //static int msglevel =MSG_LEVEL_DEBUG;
78 static int msglevel
= MSG_LEVEL_INFO
;
79 /*--------------------- Static Classes ----------------------------*/
81 /*--------------------- Static Variables --------------------------*/
83 /*--------------------- Static Functions --------------------------*/
85 /*--------------------- Export Variables --------------------------*/
87 /*--------------------- Export Functions --------------------------*/
91 * Read All MAC Registers to buffer
95 * dwIoBase - Base Address for MAC
97 * pbyMacRegs - buffer to read
102 void MACvReadAllRegs(unsigned long dwIoBase
, unsigned char *pbyMacRegs
)
106 // read page0 register
107 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++) {
108 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
112 MACvSelectPage1(dwIoBase
);
114 // read page1 register
115 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
116 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
120 MACvSelectPage0(dwIoBase
);
125 * Test if all test bits on
129 * dwIoBase - Base Address for MAC
130 * byRegOfs - Offset of MAC Register
131 * byTestBits - Test bits
135 * Return Value: true if all test bits On; otherwise false
138 bool MACbIsRegBitsOn(unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
140 unsigned char byData
;
142 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
143 return (byData
& byTestBits
) == byTestBits
;
148 * Test if all test bits off
152 * dwIoBase - Base Address for MAC
153 * byRegOfs - Offset of MAC Register
154 * byTestBits - Test bits
158 * Return Value: true if all test bits Off; otherwise false
161 bool MACbIsRegBitsOff(unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
163 unsigned char byData
;
165 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
166 return !(byData
& byTestBits
);
171 * Test if MAC interrupt disable
175 * dwIoBase - Base Address for MAC
179 * Return Value: true if interrupt is disable; otherwise false
182 bool MACbIsIntDisable(unsigned long dwIoBase
)
184 unsigned long dwData
;
186 VNSvInPortD(dwIoBase
+ MAC_REG_IMR
, &dwData
);
195 * Read MAC Multicast Address Mask
199 * dwIoBase - Base Address for MAC
200 * uByteidx - Index of Mask
204 * Return Value: Mask Value read
207 unsigned char MACbyReadMultiAddr(unsigned long dwIoBase
, unsigned int uByteIdx
)
209 unsigned char byData
;
211 MACvSelectPage1(dwIoBase
);
212 VNSvInPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, &byData
);
213 MACvSelectPage0(dwIoBase
);
219 * Write MAC Multicast Address Mask
223 * dwIoBase - Base Address for MAC
224 * uByteidx - Index of Mask
225 * byData - Mask Value to write
232 void MACvWriteMultiAddr(unsigned long dwIoBase
, unsigned int uByteIdx
, unsigned char byData
)
234 MACvSelectPage1(dwIoBase
);
235 VNSvOutPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, byData
);
236 MACvSelectPage0(dwIoBase
);
241 * Set this hash index into multicast address register bit
245 * dwIoBase - Base Address for MAC
246 * byHashIdx - Hash index to set
253 void MACvSetMultiAddrByHash(unsigned long dwIoBase
, unsigned char byHashIdx
)
255 unsigned int uByteIdx
;
256 unsigned char byBitMask
;
257 unsigned char byOrgValue
;
259 // calculate byte position
260 uByteIdx
= byHashIdx
/ 8;
261 ASSERT(uByteIdx
< 8);
262 // calculate bit position
264 byBitMask
<<= (byHashIdx
% 8);
266 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
267 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
| byBitMask
));
272 * Reset this hash index into multicast address register bit
276 * dwIoBase - Base Address for MAC
277 * byHashIdx - Hash index to clear
284 void MACvResetMultiAddrByHash(unsigned long dwIoBase
, unsigned char byHashIdx
)
286 unsigned int uByteIdx
;
287 unsigned char byBitMask
;
288 unsigned char byOrgValue
;
290 // calculate byte position
291 uByteIdx
= byHashIdx
/ 8;
292 ASSERT(uByteIdx
< 8);
293 // calculate bit position
295 byBitMask
<<= (byHashIdx
% 8);
297 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
298 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
& (~byBitMask
)));
307 * dwIoBase - Base Address for MAC
308 * byThreshold - Threshold Value
315 void MACvSetRxThreshold(unsigned long dwIoBase
, unsigned char byThreshold
)
317 unsigned char byOrgValue
;
319 ASSERT(byThreshold
< 4);
322 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
323 byOrgValue
= (byOrgValue
& 0xCF) | (byThreshold
<< 4);
324 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
333 * dwIoBase - Base Address for MAC
335 * pbyThreshold- Threshold Value Get
340 void MACvGetRxThreshold(unsigned long dwIoBase
, unsigned char *pbyThreshold
)
343 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
344 *pbyThreshold
= (*pbyThreshold
>> 4) & 0x03;
353 * dwIoBase - Base Address for MAC
354 * byThreshold - Threshold Value
361 void MACvSetTxThreshold(unsigned long dwIoBase
, unsigned char byThreshold
)
363 unsigned char byOrgValue
;
365 ASSERT(byThreshold
< 4);
368 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
369 byOrgValue
= (byOrgValue
& 0xF3) | (byThreshold
<< 2);
370 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
379 * dwIoBase - Base Address for MAC
381 * pbyThreshold- Threshold Value Get
386 void MACvGetTxThreshold(unsigned long dwIoBase
, unsigned char *pbyThreshold
)
389 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
390 *pbyThreshold
= (*pbyThreshold
>> 2) & 0x03;
399 * dwIoBase - Base Address for MAC
400 * byDmaLength - Dma Length Value
407 void MACvSetDmaLength(unsigned long dwIoBase
, unsigned char byDmaLength
)
409 unsigned char byOrgValue
;
411 ASSERT(byDmaLength
< 4);
414 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
415 byOrgValue
= (byOrgValue
& 0xFC) | byDmaLength
;
416 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
425 * dwIoBase - Base Address for MAC
427 * pbyDmaLength- Dma Length Value Get
432 void MACvGetDmaLength(unsigned long dwIoBase
, unsigned char *pbyDmaLength
)
435 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyDmaLength
);
436 *pbyDmaLength
&= 0x03;
441 * Set 802.11 Short Retry Limit
445 * dwIoBase - Base Address for MAC
446 * byRetryLimit- Retry Limit
453 void MACvSetShortRetryLimit(unsigned long dwIoBase
, unsigned char byRetryLimit
)
456 VNSvOutPortB(dwIoBase
+ MAC_REG_SRT
, byRetryLimit
);
461 * Get 802.11 Short Retry Limit
465 * dwIoBase - Base Address for MAC
467 * pbyRetryLimit - Retry Limit Get
472 void MACvGetShortRetryLimit(unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
475 VNSvInPortB(dwIoBase
+ MAC_REG_SRT
, pbyRetryLimit
);
480 * Set 802.11 Long Retry Limit
484 * dwIoBase - Base Address for MAC
485 * byRetryLimit- Retry Limit
492 void MACvSetLongRetryLimit(unsigned long dwIoBase
, unsigned char byRetryLimit
)
495 VNSvOutPortB(dwIoBase
+ MAC_REG_LRT
, byRetryLimit
);
500 * Get 802.11 Long Retry Limit
504 * dwIoBase - Base Address for MAC
506 * pbyRetryLimit - Retry Limit Get
511 void MACvGetLongRetryLimit(unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
514 VNSvInPortB(dwIoBase
+ MAC_REG_LRT
, pbyRetryLimit
);
519 * Set MAC Loopback mode
523 * dwIoBase - Base Address for MAC
524 * byLoopbackMode - Loopback Mode
531 void MACvSetLoopbackMode(unsigned long dwIoBase
, unsigned char byLoopbackMode
)
533 unsigned char byOrgValue
;
535 ASSERT(byLoopbackMode
< 3);
536 byLoopbackMode
<<= 6;
538 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
539 byOrgValue
= byOrgValue
& 0x3F;
540 byOrgValue
= byOrgValue
| byLoopbackMode
;
541 VNSvOutPortB(dwIoBase
+ MAC_REG_TEST
, byOrgValue
);
546 * Test if MAC in Loopback mode
550 * dwIoBase - Base Address for MAC
554 * Return Value: true if in Loopback mode; otherwise false
557 bool MACbIsInLoopbackMode(unsigned long dwIoBase
)
559 unsigned char byOrgValue
;
561 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
562 if (byOrgValue
& (TEST_LBINT
| TEST_LBEXT
))
569 * Set MAC Address filter
573 * dwIoBase - Base Address for MAC
574 * wFilterType - Filter Type
581 void MACvSetPacketFilter(unsigned long dwIoBase
, unsigned short wFilterType
)
583 unsigned char byOldRCR
;
584 unsigned char byNewRCR
= 0;
586 // if only in DIRECTED mode, multicast-address will set to zero,
587 // but if other mode exist (e.g. PROMISCUOUS), multicast-address
589 if (wFilterType
& PKT_TYPE_DIRECTED
) {
590 // set multicast address to accept none
591 MACvSelectPage1(dwIoBase
);
592 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0L);
593 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0L);
594 MACvSelectPage0(dwIoBase
);
597 if (wFilterType
& (PKT_TYPE_PROMISCUOUS
| PKT_TYPE_ALL_MULTICAST
)) {
598 // set multicast address to accept all
599 MACvSelectPage1(dwIoBase
);
600 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0xFFFFFFFFL
);
601 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0xFFFFFFFFL
);
602 MACvSelectPage0(dwIoBase
);
605 if (wFilterType
& PKT_TYPE_PROMISCUOUS
) {
606 byNewRCR
|= (RCR_RXALLTYPE
| RCR_UNICAST
| RCR_MULTICAST
| RCR_BROADCAST
);
608 byNewRCR
&= ~RCR_BSSID
;
611 if (wFilterType
& (PKT_TYPE_ALL_MULTICAST
| PKT_TYPE_MULTICAST
))
612 byNewRCR
|= RCR_MULTICAST
;
614 if (wFilterType
& PKT_TYPE_BROADCAST
)
615 byNewRCR
|= RCR_BROADCAST
;
617 if (wFilterType
& PKT_TYPE_ERROR_CRC
)
618 byNewRCR
|= RCR_ERRCRC
;
620 VNSvInPortB(dwIoBase
+ MAC_REG_RCR
, &byOldRCR
);
621 if (byNewRCR
!= byOldRCR
) {
622 // Modify the Receive Command Register
623 VNSvOutPortB(dwIoBase
+ MAC_REG_RCR
, byNewRCR
);
629 * Save MAC registers to context buffer
633 * dwIoBase - Base Address for MAC
635 * pbyCxtBuf - Context buffer
640 void MACvSaveContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
644 // read page0 register
645 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++) {
646 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ ii
));
649 MACvSelectPage1(dwIoBase
);
651 // read page1 register
652 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
653 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
656 MACvSelectPage0(dwIoBase
);
661 * Restore MAC registers from context buffer
665 * dwIoBase - Base Address for MAC
666 * pbyCxtBuf - Context buffer
673 void MACvRestoreContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
677 MACvSelectPage1(dwIoBase
);
679 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
680 VNSvOutPortB((dwIoBase
+ ii
), *(pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
682 MACvSelectPage0(dwIoBase
);
684 // restore RCR,TCR,IMR...
685 for (ii
= MAC_REG_RCR
; ii
< MAC_REG_ISR
; ii
++) {
686 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
688 // restore MAC Config.
689 for (ii
= MAC_REG_LRT
; ii
< MAC_REG_PAGE1SEL
; ii
++) {
690 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
692 VNSvOutPortB(dwIoBase
+ MAC_REG_CFG
, *(pbyCxtBuf
+ MAC_REG_CFG
));
694 // restore PS Config.
695 for (ii
= MAC_REG_PSCFG
; ii
< MAC_REG_BBREGCTL
; ii
++) {
696 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
699 // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
700 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
));
701 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
));
702 VNSvOutPortD(dwIoBase
+ MAC_REG_BCNDMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_BCNDMAPTR
));
704 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
));
706 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
));
711 * Compare if MAC registers same as context buffer
715 * dwIoBase - Base Address for MAC
716 * pbyCxtBuf - Context buffer
720 * Return Value: true if all values are the same; otherwise false
723 bool MACbCompareContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
725 unsigned long dwData
;
727 // compare MAC context to determine if this is a power lost init,
728 // return true for power remaining init, return false for power lost init
730 // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
731 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, &dwData
);
732 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
)) {
736 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, &dwData
);
737 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
)) {
741 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, &dwData
);
742 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
)) {
746 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, &dwData
);
747 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
)) {
760 * dwIoBase - Base Address for MAC
764 * Return Value: true if Reset Success; otherwise false
767 bool MACbSoftwareReset(unsigned long dwIoBase
)
769 unsigned char byData
;
772 // turn on HOSTCR_SOFTRST, just write 0x01 to reset
773 //MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_SOFTRST);
774 VNSvOutPortB(dwIoBase
+ MAC_REG_HOSTCR
, 0x01);
776 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
777 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
778 if (!(byData
& HOSTCR_SOFTRST
))
781 if (ww
== W_MAX_TIMEOUT
)
788 * save some important register's value, then do reset, then restore register's value
792 * dwIoBase - Base Address for MAC
796 * Return Value: true if success; otherwise false
799 bool MACbSafeSoftwareReset(unsigned long dwIoBase
)
801 unsigned char abyTmpRegData
[MAC_MAX_CONTEXT_SIZE_PAGE0
+MAC_MAX_CONTEXT_SIZE_PAGE1
];
805 // save some important register's value, then do
806 // reset, then restore register's value
809 MACvSaveContext(dwIoBase
, abyTmpRegData
);
811 bRetVal
= MACbSoftwareReset(dwIoBase
);
812 //BBvSoftwareReset(pDevice->PortOffset);
813 // restore MAC context, except CR0
814 MACvRestoreContext(dwIoBase
, abyTmpRegData
);
825 * dwIoBase - Base Address for MAC
829 * Return Value: true if success; otherwise false
832 bool MACbSafeRxOff(unsigned long dwIoBase
)
835 unsigned long dwData
;
836 unsigned char byData
;
838 // turn off wow temp for turn off Rx safely
841 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_CLRRUN
);
842 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_CLRRUN
);
843 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
844 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, &dwData
);
845 if (!(dwData
& DMACTL_RUN
))
848 if (ww
== W_MAX_TIMEOUT
) {
850 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x10)\n");
853 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
854 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, &dwData
);
855 if (!(dwData
& DMACTL_RUN
))
858 if (ww
== W_MAX_TIMEOUT
) {
860 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x11)\n");
864 // try to safe shutdown RX
865 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
866 // W_MAX_TIMEOUT is the timeout period
867 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
868 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
869 if (!(byData
& HOSTCR_RXONST
))
872 if (ww
== W_MAX_TIMEOUT
) {
874 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x12)\n");
886 * dwIoBase - Base Address for MAC
890 * Return Value: true if success; otherwise false
893 bool MACbSafeTxOff(unsigned long dwIoBase
)
896 unsigned long dwData
;
897 unsigned char byData
;
901 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_CLRRUN
);
903 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_CLRRUN
);
905 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
906 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, &dwData
);
907 if (!(dwData
& DMACTL_RUN
))
910 if (ww
== W_MAX_TIMEOUT
) {
912 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x20)\n");
915 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
916 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, &dwData
);
917 if (!(dwData
& DMACTL_RUN
))
920 if (ww
== W_MAX_TIMEOUT
) {
922 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x21)\n");
926 // try to safe shutdown TX
927 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_TXON
);
929 // W_MAX_TIMEOUT is the timeout period
930 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
931 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
932 if (!(byData
& HOSTCR_TXONST
))
935 if (ww
== W_MAX_TIMEOUT
) {
937 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x24)\n");
949 * dwIoBase - Base Address for MAC
953 * Return Value: true if success; otherwise false
956 bool MACbSafeStop(unsigned long dwIoBase
)
958 MACvRegBitsOff(dwIoBase
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
960 if (MACbSafeRxOff(dwIoBase
) == false) {
962 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeRxOff == false)\n");
963 MACbSafeSoftwareReset(dwIoBase
);
966 if (MACbSafeTxOff(dwIoBase
) == false) {
968 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeTxOff == false)\n");
969 MACbSafeSoftwareReset(dwIoBase
);
973 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_MACEN
);
984 * dwIoBase - Base Address for MAC
988 * Return Value: true if success; otherwise false
991 bool MACbShutdown(unsigned long dwIoBase
)
994 MACvIntDisable(dwIoBase
);
995 MACvSetLoopbackMode(dwIoBase
, MAC_LB_INTERNAL
);
997 if (!MACbSafeStop(dwIoBase
)) {
998 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
1001 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
1011 * dwIoBase - Base Address for MAC
1015 * Return Value: none
1018 void MACvInitialize(unsigned long dwIoBase
)
1020 // clear sticky bits
1021 MACvClearStckDS(dwIoBase
);
1022 // disable force PME-enable
1023 VNSvOutPortB(dwIoBase
+ MAC_REG_PMC1
, PME_OVR
);
1026 MACvPwrEvntDisable(dwIoBase);
1027 // clear power status
1028 VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPSR0, 0x0F0F);
1032 MACbSoftwareReset(dwIoBase
);
1034 // reset TSF counter
1035 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTRST
);
1036 // enable TSF counter
1037 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
1039 // set packet filter
1040 // receive directed and broadcast address
1042 MACvSetPacketFilter(dwIoBase
, PKT_TYPE_DIRECTED
| PKT_TYPE_BROADCAST
);
1047 * Set the chip with current rx descriptor address
1051 * dwIoBase - Base Address for MAC
1052 * dwCurrDescAddr - Descriptor Address
1056 * Return Value: none
1059 void MACvSetCurrRx0DescAddr(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1062 unsigned char byData
;
1063 unsigned char byOrgDMACtl
;
1065 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byOrgDMACtl
);
1066 if (byOrgDMACtl
& DMACTL_RUN
) {
1067 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
+2, DMACTL_RUN
);
1069 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1070 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byData
);
1071 if (!(byData
& DMACTL_RUN
))
1074 if (ww
== W_MAX_TIMEOUT
) {
1077 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, dwCurrDescAddr
);
1078 if (byOrgDMACtl
& DMACTL_RUN
) {
1079 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_RUN
);
1085 * Set the chip with current rx descriptor address
1089 * dwIoBase - Base Address for MAC
1090 * dwCurrDescAddr - Descriptor Address
1094 * Return Value: none
1097 void MACvSetCurrRx1DescAddr(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1100 unsigned char byData
;
1101 unsigned char byOrgDMACtl
;
1103 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byOrgDMACtl
);
1104 if (byOrgDMACtl
& DMACTL_RUN
) {
1105 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
+2, DMACTL_RUN
);
1107 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1108 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byData
);
1109 if (!(byData
& DMACTL_RUN
))
1112 if (ww
== W_MAX_TIMEOUT
) {
1115 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, dwCurrDescAddr
);
1116 if (byOrgDMACtl
& DMACTL_RUN
) {
1117 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_RUN
);
1123 * Set the chip with current tx0 descriptor address
1127 * dwIoBase - Base Address for MAC
1128 * dwCurrDescAddr - Descriptor Address
1132 * Return Value: none
1135 void MACvSetCurrTx0DescAddrEx(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1138 unsigned char byData
;
1139 unsigned char byOrgDMACtl
;
1141 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byOrgDMACtl
);
1142 if (byOrgDMACtl
& DMACTL_RUN
) {
1143 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1145 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1146 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1147 if (!(byData
& DMACTL_RUN
))
1150 if (ww
== W_MAX_TIMEOUT
) {
1153 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, dwCurrDescAddr
);
1154 if (byOrgDMACtl
& DMACTL_RUN
) {
1155 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_RUN
);
1161 * Set the chip with current AC0 descriptor address
1165 * dwIoBase - Base Address for MAC
1166 * dwCurrDescAddr - Descriptor Address
1170 * Return Value: none
1174 void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1177 unsigned char byData
;
1178 unsigned char byOrgDMACtl
;
1180 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byOrgDMACtl
);
1181 if (byOrgDMACtl
& DMACTL_RUN
) {
1182 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1184 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1185 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1186 if (!(byData
& DMACTL_RUN
))
1189 if (ww
== W_MAX_TIMEOUT
) {
1191 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x26)\n");
1193 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, dwCurrDescAddr
);
1194 if (byOrgDMACtl
& DMACTL_RUN
) {
1195 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_RUN
);
1199 void MACvSetCurrTXDescAddr(int iTxType
, unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1201 if (iTxType
== TYPE_AC0DMA
) {
1202 MACvSetCurrAC0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1203 } else if (iTxType
== TYPE_TXDMA0
) {
1204 MACvSetCurrTx0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1210 * Micro Second Delay via MAC
1214 * dwIoBase - Base Address for MAC
1215 * uDelay - Delay time (timer resolution is 4 us)
1219 * Return Value: none
1222 void MACvTimer0MicroSDelay(unsigned long dwIoBase
, unsigned int uDelay
)
1224 unsigned char byValue
;
1225 unsigned int uu
, ii
;
1227 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1228 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelay
);
1229 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1230 for (ii
= 0; ii
< 66; ii
++) { // assume max PCI clock is 66Mhz
1231 for (uu
= 0; uu
< uDelay
; uu
++) {
1232 VNSvInPortB(dwIoBase
+ MAC_REG_TMCTL0
, &byValue
);
1233 if ((byValue
== 0) ||
1234 (byValue
& TMCTL_TSUSP
)) {
1235 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1240 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1245 * Micro Second One shot timer via MAC
1249 * dwIoBase - Base Address for MAC
1250 * uDelay - Delay time
1254 * Return Value: none
1257 void MACvOneShotTimer0MicroSec(unsigned long dwIoBase
, unsigned int uDelayTime
)
1259 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1260 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelayTime
);
1261 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1266 * Micro Second One shot timer via MAC
1270 * dwIoBase - Base Address for MAC
1271 * uDelay - Delay time
1275 * Return Value: none
1278 void MACvOneShotTimer1MicroSec(unsigned long dwIoBase
, unsigned int uDelayTime
)
1280 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, 0);
1281 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA1
, uDelayTime
);
1282 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, (TMCTL_TMD
| TMCTL_TE
));
1285 void MACvSetMISCFifo(unsigned long dwIoBase
, unsigned short wOffset
, unsigned long dwData
)
1289 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1290 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1291 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1294 bool MACbTxDMAOff(unsigned long dwIoBase
, unsigned int idx
)
1296 unsigned char byData
;
1297 unsigned int ww
= 0;
1299 if (idx
== TYPE_TXDMA0
) {
1300 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1301 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1302 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1303 if (!(byData
& DMACTL_RUN
))
1306 } else if (idx
== TYPE_AC0DMA
) {
1307 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1308 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1309 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1310 if (!(byData
& DMACTL_RUN
))
1314 if (ww
== W_MAX_TIMEOUT
) {
1316 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x29)\n");
1322 void MACvClearBusSusInd(unsigned long dwIoBase
)
1324 unsigned long dwOrgValue
;
1326 // check if BcnSusInd enabled
1327 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1328 if (!(dwOrgValue
& EnCFG_BcnSusInd
))
1331 dwOrgValue
= dwOrgValue
| EnCFG_BcnSusClr
;
1332 VNSvOutPortD(dwIoBase
+ MAC_REG_ENCFG
, dwOrgValue
);
1333 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1334 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1335 if (!(dwOrgValue
& EnCFG_BcnSusInd
))
1338 if (ww
== W_MAX_TIMEOUT
) {
1340 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1344 void MACvEnableBusSusEn(unsigned long dwIoBase
)
1346 unsigned char byOrgValue
;
1347 unsigned long dwOrgValue
;
1349 // check if BcnSusInd enabled
1350 VNSvInPortB(dwIoBase
+ MAC_REG_CFG
, &byOrgValue
);
1353 byOrgValue
= byOrgValue
| CFG_BCNSUSEN
;
1354 VNSvOutPortB(dwIoBase
+ MAC_REG_ENCFG
, byOrgValue
);
1355 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1356 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1357 if (dwOrgValue
& EnCFG_BcnSusInd
)
1360 if (ww
== W_MAX_TIMEOUT
) {
1362 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x34)\n");
1366 bool MACbFlushSYNCFifo(unsigned long dwIoBase
)
1368 unsigned char byOrgValue
;
1371 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1374 byOrgValue
= byOrgValue
| MACCR_SYNCFLUSH
;
1375 VNSvOutPortB(dwIoBase
+ MAC_REG_MACCR
, byOrgValue
);
1377 // Check if SyncFlushOK
1378 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1379 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1380 if (byOrgValue
& MACCR_SYNCFLUSHOK
)
1383 if (ww
== W_MAX_TIMEOUT
) {
1385 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1390 bool MACbPSWakeup(unsigned long dwIoBase
)
1392 unsigned char byOrgValue
;
1395 if (MACbIsRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PS
)) {
1399 MACvRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PSEN
);
1401 // Check if SyncFlushOK
1402 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1403 VNSvInPortB(dwIoBase
+ MAC_REG_PSCTL
, &byOrgValue
);
1404 if (byOrgValue
& PSCTL_WAKEDONE
)
1407 if (ww
== W_MAX_TIMEOUT
) {
1409 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1417 * Set the Key by MISCFIFO
1421 * dwIoBase - Base Address for MAC
1426 * Return Value: none
1430 void MACvSetKeyEntry(unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
,
1431 unsigned int uKeyIdx
, unsigned char *pbyAddr
, unsigned long *pdwKey
, unsigned char byLocalID
)
1433 unsigned short wOffset
;
1434 unsigned long dwData
;
1440 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1441 wOffset
= MISCFIFO_KEYETRY0
;
1442 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1447 dwData
|= MAKEWORD(*(pbyAddr
+4), *(pbyAddr
+5));
1448 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1450 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1451 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1452 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1456 dwData
|= *(pbyAddr
+3);
1458 dwData
|= *(pbyAddr
+2);
1460 dwData
|= *(pbyAddr
+1);
1462 dwData
|= *(pbyAddr
+0);
1463 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2. wOffset: %d, Data: %lX\n", wOffset
, dwData
);
1465 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1466 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1467 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1470 wOffset
+= (uKeyIdx
* 4);
1471 for (ii
= 0; ii
< 4; ii
++) {
1472 // always push 128 bits
1473 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"3.(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1474 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1475 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1476 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1482 * Disable the Key Entry by MISCFIFO
1486 * dwIoBase - Base Address for MAC
1491 * Return Value: none
1494 void MACvDisableKeyEntry(unsigned long dwIoBase
, unsigned int uEntryIdx
)
1496 unsigned short wOffset
;
1498 wOffset
= MISCFIFO_KEYETRY0
;
1499 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1501 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1502 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, 0);
1503 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1508 * Set the default Key (KeyEntry[10]) by MISCFIFO
1512 * dwIoBase - Base Address for MAC
1517 * Return Value: none
1521 void MACvSetDefaultKeyEntry(unsigned long dwIoBase
, unsigned int uKeyLen
,
1522 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1524 unsigned short wOffset
;
1525 unsigned long dwData
;
1531 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultKeyEntry\n");
1532 wOffset
= MISCFIFO_KEYETRY0
;
1533 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1537 wOffset
+= (uKeyIdx
* 4);
1538 // always push 128 bits
1539 for (ii
= 0; ii
< 3; ii
++) {
1540 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1541 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1542 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1543 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1546 if (uKeyLen
== WLAN_WEP104_KEYLEN
) {
1547 dwData
|= 0x80000000;
1549 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+3);
1550 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1551 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1552 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End. wOffset: %d, Data: %lX\n", wOffset
+3, dwData
);
1557 * Enable default Key (KeyEntry[10]) by MISCFIFO
1561 * dwIoBase - Base Address for MAC
1566 * Return Value: none
1570 void MACvEnableDefaultKey(unsigned long dwIoBase, unsigned char byLocalID)
1572 unsigned short wOffset;
1573 unsigned long dwData;
1578 wOffset = MISCFIFO_KEYETRY0;
1579 wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
1581 dwData = 0xC0440000;
1582 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
1583 VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
1584 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
1585 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MACvEnableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData);
1592 * Disable default Key (KeyEntry[10]) by MISCFIFO
1596 * dwIoBase - Base Address for MAC
1601 * Return Value: none
1604 void MACvDisableDefaultKey(unsigned long dwIoBase
)
1606 unsigned short wOffset
;
1607 unsigned long dwData
;
1609 wOffset
= MISCFIFO_KEYETRY0
;
1610 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1613 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1614 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1615 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1616 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvDisableDefaultKey: wOffset: %d, Data: %lX\n", wOffset
, dwData
);
1621 * Set the default TKIP Group Key (KeyEntry[10]) by MISCFIFO
1625 * dwIoBase - Base Address for MAC
1630 * Return Value: none
1633 void MACvSetDefaultTKIPKeyEntry(unsigned long dwIoBase
, unsigned int uKeyLen
,
1634 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1636 unsigned short wOffset
;
1637 unsigned long dwData
;
1643 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultTKIPKeyEntry\n");
1644 wOffset
= MISCFIFO_KEYETRY0
;
1645 // Kyle test : change offset from 10 -> 0
1646 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1648 dwData
= 0xC0660000;
1649 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1650 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1651 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1655 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1656 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1657 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1660 wOffset
+= (uKeyIdx
* 4);
1661 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, idx:%d\n", wOffset
, *pdwKey
, uKeyIdx
);
1662 // always push 128 bits
1663 for (ii
= 0; ii
< 4; ii
++) {
1664 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2.(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1665 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1666 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1667 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1673 * Set the Key Control by MISCFIFO
1677 * dwIoBase - Base Address for MAC
1682 * Return Value: none
1686 void MACvSetDefaultKeyCtl(unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
, unsigned char byLocalID
)
1688 unsigned short wOffset
;
1689 unsigned long dwData
;
1694 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1695 wOffset
= MISCFIFO_KEYETRY0
;
1696 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1702 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1704 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1705 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1706 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);