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_INFO
;
78 /*--------------------- Static Classes ----------------------------*/
80 /*--------------------- Static Variables --------------------------*/
82 /*--------------------- Static Functions --------------------------*/
84 /*--------------------- Export Variables --------------------------*/
86 /*--------------------- Export Functions --------------------------*/
90 * Read All MAC Registers to buffer
94 * dwIoBase - Base Address for MAC
96 * pbyMacRegs - buffer to read
101 void MACvReadAllRegs(unsigned long dwIoBase
, unsigned char *pbyMacRegs
)
105 // read page0 register
106 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++) {
107 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
111 MACvSelectPage1(dwIoBase
);
113 // read page1 register
114 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
115 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
119 MACvSelectPage0(dwIoBase
);
124 * Test if all test bits on
128 * dwIoBase - Base Address for MAC
129 * byRegOfs - Offset of MAC Register
130 * byTestBits - Test bits
134 * Return Value: true if all test bits On; otherwise false
137 bool MACbIsRegBitsOn(unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
139 unsigned char byData
;
141 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
142 return (byData
& byTestBits
) == byTestBits
;
147 * Test if all test bits off
151 * dwIoBase - Base Address for MAC
152 * byRegOfs - Offset of MAC Register
153 * byTestBits - Test bits
157 * Return Value: true if all test bits Off; otherwise false
160 bool MACbIsRegBitsOff(unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
162 unsigned char byData
;
164 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
165 return !(byData
& byTestBits
);
170 * Test if MAC interrupt disable
174 * dwIoBase - Base Address for MAC
178 * Return Value: true if interrupt is disable; otherwise false
181 bool MACbIsIntDisable(unsigned long dwIoBase
)
183 unsigned long dwData
;
185 VNSvInPortD(dwIoBase
+ MAC_REG_IMR
, &dwData
);
194 * Read MAC Multicast Address Mask
198 * dwIoBase - Base Address for MAC
199 * uByteidx - Index of Mask
203 * Return Value: Mask Value read
206 unsigned char MACbyReadMultiAddr(unsigned long dwIoBase
, unsigned int uByteIdx
)
208 unsigned char byData
;
210 MACvSelectPage1(dwIoBase
);
211 VNSvInPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, &byData
);
212 MACvSelectPage0(dwIoBase
);
218 * Write MAC Multicast Address Mask
222 * dwIoBase - Base Address for MAC
223 * uByteidx - Index of Mask
224 * byData - Mask Value to write
231 void MACvWriteMultiAddr(unsigned long dwIoBase
, unsigned int uByteIdx
, unsigned char byData
)
233 MACvSelectPage1(dwIoBase
);
234 VNSvOutPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, byData
);
235 MACvSelectPage0(dwIoBase
);
240 * Set this hash index into multicast address register bit
244 * dwIoBase - Base Address for MAC
245 * byHashIdx - Hash index to set
252 void MACvSetMultiAddrByHash(unsigned long dwIoBase
, unsigned char byHashIdx
)
254 unsigned int uByteIdx
;
255 unsigned char byBitMask
;
256 unsigned char byOrgValue
;
258 // calculate byte position
259 uByteIdx
= byHashIdx
/ 8;
260 ASSERT(uByteIdx
< 8);
261 // calculate bit position
263 byBitMask
<<= (byHashIdx
% 8);
265 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
266 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
| byBitMask
));
271 * Reset this hash index into multicast address register bit
275 * dwIoBase - Base Address for MAC
276 * byHashIdx - Hash index to clear
283 void MACvResetMultiAddrByHash(unsigned long dwIoBase
, unsigned char byHashIdx
)
285 unsigned int uByteIdx
;
286 unsigned char byBitMask
;
287 unsigned char byOrgValue
;
289 // calculate byte position
290 uByteIdx
= byHashIdx
/ 8;
291 ASSERT(uByteIdx
< 8);
292 // calculate bit position
294 byBitMask
<<= (byHashIdx
% 8);
296 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
297 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
& (~byBitMask
)));
306 * dwIoBase - Base Address for MAC
307 * byThreshold - Threshold Value
314 void MACvSetRxThreshold(unsigned long dwIoBase
, unsigned char byThreshold
)
316 unsigned char byOrgValue
;
318 ASSERT(byThreshold
< 4);
321 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
322 byOrgValue
= (byOrgValue
& 0xCF) | (byThreshold
<< 4);
323 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
332 * dwIoBase - Base Address for MAC
334 * pbyThreshold- Threshold Value Get
339 void MACvGetRxThreshold(unsigned long dwIoBase
, unsigned char *pbyThreshold
)
342 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
343 *pbyThreshold
= (*pbyThreshold
>> 4) & 0x03;
352 * dwIoBase - Base Address for MAC
353 * byThreshold - Threshold Value
360 void MACvSetTxThreshold(unsigned long dwIoBase
, unsigned char byThreshold
)
362 unsigned char byOrgValue
;
364 ASSERT(byThreshold
< 4);
367 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
368 byOrgValue
= (byOrgValue
& 0xF3) | (byThreshold
<< 2);
369 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
378 * dwIoBase - Base Address for MAC
380 * pbyThreshold- Threshold Value Get
385 void MACvGetTxThreshold(unsigned long dwIoBase
, unsigned char *pbyThreshold
)
388 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
389 *pbyThreshold
= (*pbyThreshold
>> 2) & 0x03;
398 * dwIoBase - Base Address for MAC
399 * byDmaLength - Dma Length Value
406 void MACvSetDmaLength(unsigned long dwIoBase
, unsigned char byDmaLength
)
408 unsigned char byOrgValue
;
410 ASSERT(byDmaLength
< 4);
413 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
414 byOrgValue
= (byOrgValue
& 0xFC) | byDmaLength
;
415 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
424 * dwIoBase - Base Address for MAC
426 * pbyDmaLength- Dma Length Value Get
431 void MACvGetDmaLength(unsigned long dwIoBase
, unsigned char *pbyDmaLength
)
434 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyDmaLength
);
435 *pbyDmaLength
&= 0x03;
440 * Set 802.11 Short Retry Limit
444 * dwIoBase - Base Address for MAC
445 * byRetryLimit- Retry Limit
452 void MACvSetShortRetryLimit(unsigned long dwIoBase
, unsigned char byRetryLimit
)
455 VNSvOutPortB(dwIoBase
+ MAC_REG_SRT
, byRetryLimit
);
460 * Get 802.11 Short Retry Limit
464 * dwIoBase - Base Address for MAC
466 * pbyRetryLimit - Retry Limit Get
471 void MACvGetShortRetryLimit(unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
474 VNSvInPortB(dwIoBase
+ MAC_REG_SRT
, pbyRetryLimit
);
479 * Set 802.11 Long Retry Limit
483 * dwIoBase - Base Address for MAC
484 * byRetryLimit- Retry Limit
491 void MACvSetLongRetryLimit(unsigned long dwIoBase
, unsigned char byRetryLimit
)
494 VNSvOutPortB(dwIoBase
+ MAC_REG_LRT
, byRetryLimit
);
499 * Get 802.11 Long Retry Limit
503 * dwIoBase - Base Address for MAC
505 * pbyRetryLimit - Retry Limit Get
510 void MACvGetLongRetryLimit(unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
513 VNSvInPortB(dwIoBase
+ MAC_REG_LRT
, pbyRetryLimit
);
518 * Set MAC Loopback mode
522 * dwIoBase - Base Address for MAC
523 * byLoopbackMode - Loopback Mode
530 void MACvSetLoopbackMode(unsigned long dwIoBase
, unsigned char byLoopbackMode
)
532 unsigned char byOrgValue
;
534 ASSERT(byLoopbackMode
< 3);
535 byLoopbackMode
<<= 6;
537 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
538 byOrgValue
= byOrgValue
& 0x3F;
539 byOrgValue
= byOrgValue
| byLoopbackMode
;
540 VNSvOutPortB(dwIoBase
+ MAC_REG_TEST
, byOrgValue
);
545 * Test if MAC in Loopback mode
549 * dwIoBase - Base Address for MAC
553 * Return Value: true if in Loopback mode; otherwise false
556 bool MACbIsInLoopbackMode(unsigned long dwIoBase
)
558 unsigned char byOrgValue
;
560 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
561 if (byOrgValue
& (TEST_LBINT
| TEST_LBEXT
))
568 * Set MAC Address filter
572 * dwIoBase - Base Address for MAC
573 * wFilterType - Filter Type
580 void MACvSetPacketFilter(unsigned long dwIoBase
, unsigned short wFilterType
)
582 unsigned char byOldRCR
;
583 unsigned char byNewRCR
= 0;
585 // if only in DIRECTED mode, multicast-address will set to zero,
586 // but if other mode exist (e.g. PROMISCUOUS), multicast-address
588 if (wFilterType
& PKT_TYPE_DIRECTED
) {
589 // set multicast address to accept none
590 MACvSelectPage1(dwIoBase
);
591 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0L);
592 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0L);
593 MACvSelectPage0(dwIoBase
);
596 if (wFilterType
& (PKT_TYPE_PROMISCUOUS
| PKT_TYPE_ALL_MULTICAST
)) {
597 // set multicast address to accept all
598 MACvSelectPage1(dwIoBase
);
599 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0xFFFFFFFFL
);
600 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0xFFFFFFFFL
);
601 MACvSelectPage0(dwIoBase
);
604 if (wFilterType
& PKT_TYPE_PROMISCUOUS
) {
605 byNewRCR
|= (RCR_RXALLTYPE
| RCR_UNICAST
| RCR_MULTICAST
| RCR_BROADCAST
);
607 byNewRCR
&= ~RCR_BSSID
;
610 if (wFilterType
& (PKT_TYPE_ALL_MULTICAST
| PKT_TYPE_MULTICAST
))
611 byNewRCR
|= RCR_MULTICAST
;
613 if (wFilterType
& PKT_TYPE_BROADCAST
)
614 byNewRCR
|= RCR_BROADCAST
;
616 if (wFilterType
& PKT_TYPE_ERROR_CRC
)
617 byNewRCR
|= RCR_ERRCRC
;
619 VNSvInPortB(dwIoBase
+ MAC_REG_RCR
, &byOldRCR
);
620 if (byNewRCR
!= byOldRCR
) {
621 // Modify the Receive Command Register
622 VNSvOutPortB(dwIoBase
+ MAC_REG_RCR
, byNewRCR
);
628 * Save MAC registers to context buffer
632 * dwIoBase - Base Address for MAC
634 * pbyCxtBuf - Context buffer
639 void MACvSaveContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
643 // read page0 register
644 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++)
645 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ ii
));
647 MACvSelectPage1(dwIoBase
);
649 // read page1 register
650 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++)
651 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
653 MACvSelectPage0(dwIoBase
);
658 * Restore MAC registers from context buffer
662 * dwIoBase - Base Address for MAC
663 * pbyCxtBuf - Context buffer
670 void MACvRestoreContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
674 MACvSelectPage1(dwIoBase
);
676 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++)
677 VNSvOutPortB((dwIoBase
+ ii
), *(pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
679 MACvSelectPage0(dwIoBase
);
681 // restore RCR,TCR,IMR...
682 for (ii
= MAC_REG_RCR
; ii
< MAC_REG_ISR
; ii
++)
683 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
685 // restore MAC Config.
686 for (ii
= MAC_REG_LRT
; ii
< MAC_REG_PAGE1SEL
; ii
++)
687 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
689 VNSvOutPortB(dwIoBase
+ MAC_REG_CFG
, *(pbyCxtBuf
+ MAC_REG_CFG
));
691 // restore PS Config.
692 for (ii
= MAC_REG_PSCFG
; ii
< MAC_REG_BBREGCTL
; ii
++)
693 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
695 // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
696 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
));
697 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
));
698 VNSvOutPortD(dwIoBase
+ MAC_REG_BCNDMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_BCNDMAPTR
));
700 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
));
702 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
));
707 * Compare if MAC registers same as context buffer
711 * dwIoBase - Base Address for MAC
712 * pbyCxtBuf - Context buffer
716 * Return Value: true if all values are the same; otherwise false
719 bool MACbCompareContext(unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
721 unsigned long dwData
;
723 // compare MAC context to determine if this is a power lost init,
724 // return true for power remaining init, return false for power lost init
726 // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
727 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, &dwData
);
728 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
))
731 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, &dwData
);
732 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
))
735 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, &dwData
);
736 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
))
739 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, &dwData
);
740 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
))
752 * dwIoBase - Base Address for MAC
756 * Return Value: true if Reset Success; otherwise false
759 bool MACbSoftwareReset(unsigned long dwIoBase
)
761 unsigned char byData
;
764 // turn on HOSTCR_SOFTRST, just write 0x01 to reset
765 VNSvOutPortB(dwIoBase
+ MAC_REG_HOSTCR
, 0x01);
767 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
768 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
769 if (!(byData
& HOSTCR_SOFTRST
))
772 if (ww
== W_MAX_TIMEOUT
)
779 * save some important register's value, then do reset, then restore register's value
783 * dwIoBase - Base Address for MAC
787 * Return Value: true if success; otherwise false
790 bool MACbSafeSoftwareReset(unsigned long dwIoBase
)
792 unsigned char abyTmpRegData
[MAC_MAX_CONTEXT_SIZE_PAGE0
+MAC_MAX_CONTEXT_SIZE_PAGE1
];
796 // save some important register's value, then do
797 // reset, then restore register's value
800 MACvSaveContext(dwIoBase
, abyTmpRegData
);
802 bRetVal
= MACbSoftwareReset(dwIoBase
);
803 // restore MAC context, except CR0
804 MACvRestoreContext(dwIoBase
, abyTmpRegData
);
815 * dwIoBase - Base Address for MAC
819 * Return Value: true if success; otherwise false
822 bool MACbSafeRxOff(unsigned long dwIoBase
)
825 unsigned long dwData
;
826 unsigned char byData
;
828 // turn off wow temp for turn off Rx safely
831 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_CLRRUN
);
832 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_CLRRUN
);
833 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
834 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, &dwData
);
835 if (!(dwData
& DMACTL_RUN
))
838 if (ww
== W_MAX_TIMEOUT
) {
840 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x10)\n");
843 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
844 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, &dwData
);
845 if (!(dwData
& DMACTL_RUN
))
848 if (ww
== W_MAX_TIMEOUT
) {
850 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x11)\n");
854 // try to safe shutdown RX
855 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
856 // W_MAX_TIMEOUT is the timeout period
857 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
858 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
859 if (!(byData
& HOSTCR_RXONST
))
862 if (ww
== W_MAX_TIMEOUT
) {
864 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x12)\n");
876 * dwIoBase - Base Address for MAC
880 * Return Value: true if success; otherwise false
883 bool MACbSafeTxOff(unsigned long dwIoBase
)
886 unsigned long dwData
;
887 unsigned char byData
;
891 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_CLRRUN
);
893 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_CLRRUN
);
895 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
896 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, &dwData
);
897 if (!(dwData
& DMACTL_RUN
))
900 if (ww
== W_MAX_TIMEOUT
) {
902 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x20)\n");
905 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
906 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, &dwData
);
907 if (!(dwData
& DMACTL_RUN
))
910 if (ww
== W_MAX_TIMEOUT
) {
912 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x21)\n");
916 // try to safe shutdown TX
917 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_TXON
);
919 // W_MAX_TIMEOUT is the timeout period
920 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
921 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
922 if (!(byData
& HOSTCR_TXONST
))
925 if (ww
== W_MAX_TIMEOUT
) {
927 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x24)\n");
939 * dwIoBase - Base Address for MAC
943 * Return Value: true if success; otherwise false
946 bool MACbSafeStop(unsigned long dwIoBase
)
948 MACvRegBitsOff(dwIoBase
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
950 if (!MACbSafeRxOff(dwIoBase
)) {
952 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeRxOff == false)\n");
953 MACbSafeSoftwareReset(dwIoBase
);
956 if (!MACbSafeTxOff(dwIoBase
)) {
958 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeTxOff == false)\n");
959 MACbSafeSoftwareReset(dwIoBase
);
963 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_MACEN
);
974 * dwIoBase - Base Address for MAC
978 * Return Value: true if success; otherwise false
981 bool MACbShutdown(unsigned long dwIoBase
)
984 MACvIntDisable(dwIoBase
);
985 MACvSetLoopbackMode(dwIoBase
, MAC_LB_INTERNAL
);
987 if (!MACbSafeStop(dwIoBase
)) {
988 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
991 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
1001 * dwIoBase - Base Address for MAC
1005 * Return Value: none
1008 void MACvInitialize(unsigned long dwIoBase
)
1010 // clear sticky bits
1011 MACvClearStckDS(dwIoBase
);
1012 // disable force PME-enable
1013 VNSvOutPortB(dwIoBase
+ MAC_REG_PMC1
, PME_OVR
);
1017 MACbSoftwareReset(dwIoBase
);
1019 // reset TSF counter
1020 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTRST
);
1021 // enable TSF counter
1022 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
1024 // set packet filter
1025 // receive directed and broadcast address
1027 MACvSetPacketFilter(dwIoBase
, PKT_TYPE_DIRECTED
| PKT_TYPE_BROADCAST
);
1032 * Set the chip with current rx descriptor address
1036 * dwIoBase - Base Address for MAC
1037 * dwCurrDescAddr - Descriptor Address
1041 * Return Value: none
1044 void MACvSetCurrRx0DescAddr(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1047 unsigned char byData
;
1048 unsigned char byOrgDMACtl
;
1050 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byOrgDMACtl
);
1051 if (byOrgDMACtl
& DMACTL_RUN
)
1052 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
+2, DMACTL_RUN
);
1054 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1055 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byData
);
1056 if (!(byData
& DMACTL_RUN
))
1060 if (ww
== W_MAX_TIMEOUT
)
1063 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, dwCurrDescAddr
);
1064 if (byOrgDMACtl
& DMACTL_RUN
)
1065 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_RUN
);
1070 * Set the chip with current rx descriptor address
1074 * dwIoBase - Base Address for MAC
1075 * dwCurrDescAddr - Descriptor Address
1079 * Return Value: none
1082 void MACvSetCurrRx1DescAddr(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1085 unsigned char byData
;
1086 unsigned char byOrgDMACtl
;
1088 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byOrgDMACtl
);
1089 if (byOrgDMACtl
& DMACTL_RUN
)
1090 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
+2, DMACTL_RUN
);
1092 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1093 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byData
);
1094 if (!(byData
& DMACTL_RUN
))
1097 if (ww
== W_MAX_TIMEOUT
)
1100 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, dwCurrDescAddr
);
1101 if (byOrgDMACtl
& DMACTL_RUN
)
1102 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_RUN
);
1108 * Set the chip with current tx0 descriptor address
1112 * dwIoBase - Base Address for MAC
1113 * dwCurrDescAddr - Descriptor Address
1117 * Return Value: none
1120 void MACvSetCurrTx0DescAddrEx(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1123 unsigned char byData
;
1124 unsigned char byOrgDMACtl
;
1126 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byOrgDMACtl
);
1127 if (byOrgDMACtl
& DMACTL_RUN
)
1128 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1130 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1131 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1132 if (!(byData
& DMACTL_RUN
))
1135 if (ww
== W_MAX_TIMEOUT
)
1138 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, dwCurrDescAddr
);
1139 if (byOrgDMACtl
& DMACTL_RUN
)
1140 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_RUN
);
1145 * Set the chip with current AC0 descriptor address
1149 * dwIoBase - Base Address for MAC
1150 * dwCurrDescAddr - Descriptor Address
1154 * Return Value: none
1158 void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1161 unsigned char byData
;
1162 unsigned char byOrgDMACtl
;
1164 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byOrgDMACtl
);
1165 if (byOrgDMACtl
& DMACTL_RUN
)
1166 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1168 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1169 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1170 if (!(byData
& DMACTL_RUN
))
1173 if (ww
== W_MAX_TIMEOUT
) {
1175 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x26)\n");
1177 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, dwCurrDescAddr
);
1178 if (byOrgDMACtl
& DMACTL_RUN
)
1179 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_RUN
);
1182 void MACvSetCurrTXDescAddr(int iTxType
, unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1184 if (iTxType
== TYPE_AC0DMA
)
1185 MACvSetCurrAC0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1186 else if (iTxType
== TYPE_TXDMA0
)
1187 MACvSetCurrTx0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1192 * Micro Second Delay via MAC
1196 * dwIoBase - Base Address for MAC
1197 * uDelay - Delay time (timer resolution is 4 us)
1201 * Return Value: none
1204 void MACvTimer0MicroSDelay(unsigned long dwIoBase
, unsigned int uDelay
)
1206 unsigned char byValue
;
1207 unsigned int uu
, ii
;
1209 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1210 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelay
);
1211 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1212 for (ii
= 0; ii
< 66; ii
++) { // assume max PCI clock is 66Mhz
1213 for (uu
= 0; uu
< uDelay
; uu
++) {
1214 VNSvInPortB(dwIoBase
+ MAC_REG_TMCTL0
, &byValue
);
1215 if ((byValue
== 0) ||
1216 (byValue
& TMCTL_TSUSP
)) {
1217 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1222 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1227 * Micro Second One shot timer via MAC
1231 * dwIoBase - Base Address for MAC
1232 * uDelay - Delay time
1236 * Return Value: none
1239 void MACvOneShotTimer0MicroSec(unsigned long dwIoBase
, unsigned int uDelayTime
)
1241 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1242 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelayTime
);
1243 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1248 * Micro Second One shot timer via MAC
1252 * dwIoBase - Base Address for MAC
1253 * uDelay - Delay time
1257 * Return Value: none
1260 void MACvOneShotTimer1MicroSec(unsigned long dwIoBase
, unsigned int uDelayTime
)
1262 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, 0);
1263 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA1
, uDelayTime
);
1264 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, (TMCTL_TMD
| TMCTL_TE
));
1267 void MACvSetMISCFifo(unsigned long dwIoBase
, unsigned short wOffset
, unsigned long dwData
)
1271 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1272 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1273 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1276 bool MACbTxDMAOff(unsigned long dwIoBase
, unsigned int idx
)
1278 unsigned char byData
;
1279 unsigned int ww
= 0;
1281 if (idx
== TYPE_TXDMA0
) {
1282 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1283 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1284 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1285 if (!(byData
& DMACTL_RUN
))
1288 } else if (idx
== TYPE_AC0DMA
) {
1289 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1290 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1291 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1292 if (!(byData
& DMACTL_RUN
))
1296 if (ww
== W_MAX_TIMEOUT
) {
1298 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x29)\n");
1304 void MACvClearBusSusInd(unsigned long dwIoBase
)
1306 unsigned long dwOrgValue
;
1308 // check if BcnSusInd enabled
1309 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1310 if (!(dwOrgValue
& EnCFG_BcnSusInd
))
1313 dwOrgValue
= dwOrgValue
| EnCFG_BcnSusClr
;
1314 VNSvOutPortD(dwIoBase
+ MAC_REG_ENCFG
, dwOrgValue
);
1315 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1316 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1317 if (!(dwOrgValue
& EnCFG_BcnSusInd
))
1320 if (ww
== W_MAX_TIMEOUT
) {
1322 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1326 void MACvEnableBusSusEn(unsigned long dwIoBase
)
1328 unsigned char byOrgValue
;
1329 unsigned long dwOrgValue
;
1331 // check if BcnSusInd enabled
1332 VNSvInPortB(dwIoBase
+ MAC_REG_CFG
, &byOrgValue
);
1335 byOrgValue
= byOrgValue
| CFG_BCNSUSEN
;
1336 VNSvOutPortB(dwIoBase
+ MAC_REG_ENCFG
, byOrgValue
);
1337 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1338 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1339 if (dwOrgValue
& EnCFG_BcnSusInd
)
1342 if (ww
== W_MAX_TIMEOUT
) {
1344 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x34)\n");
1348 bool MACbFlushSYNCFifo(unsigned long dwIoBase
)
1350 unsigned char byOrgValue
;
1353 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1356 byOrgValue
= byOrgValue
| MACCR_SYNCFLUSH
;
1357 VNSvOutPortB(dwIoBase
+ MAC_REG_MACCR
, byOrgValue
);
1359 // Check if SyncFlushOK
1360 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1361 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1362 if (byOrgValue
& MACCR_SYNCFLUSHOK
)
1365 if (ww
== W_MAX_TIMEOUT
) {
1367 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1372 bool MACbPSWakeup(unsigned long dwIoBase
)
1374 unsigned char byOrgValue
;
1377 if (MACbIsRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PS
))
1381 MACvRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PSEN
);
1383 // Check if SyncFlushOK
1384 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1385 VNSvInPortB(dwIoBase
+ MAC_REG_PSCTL
, &byOrgValue
);
1386 if (byOrgValue
& PSCTL_WAKEDONE
)
1389 if (ww
== W_MAX_TIMEOUT
) {
1391 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1399 * Set the Key by MISCFIFO
1403 * dwIoBase - Base Address for MAC
1408 * Return Value: none
1412 void MACvSetKeyEntry(unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
,
1413 unsigned int uKeyIdx
, unsigned char *pbyAddr
, u32
*pdwKey
, unsigned char byLocalID
)
1415 unsigned short wOffset
;
1422 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1423 wOffset
= MISCFIFO_KEYETRY0
;
1424 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1429 dwData
|= MAKEWORD(*(pbyAddr
+4), *(pbyAddr
+5));
1430 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %X, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1432 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1433 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1434 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1438 dwData
|= *(pbyAddr
+3);
1440 dwData
|= *(pbyAddr
+2);
1442 dwData
|= *(pbyAddr
+1);
1444 dwData
|= *(pbyAddr
+0);
1445 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2. wOffset: %d, Data: %X\n", wOffset
, dwData
);
1447 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1448 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1449 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1452 wOffset
+= (uKeyIdx
* 4);
1453 for (ii
= 0; ii
< 4; ii
++) {
1454 // always push 128 bits
1455 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"3.(%d) wOffset: %d, Data: %X\n", ii
, wOffset
+ii
, *pdwKey
);
1456 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1457 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1458 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1464 * Disable the Key Entry by MISCFIFO
1468 * dwIoBase - Base Address for MAC
1473 * Return Value: none
1476 void MACvDisableKeyEntry(unsigned long dwIoBase
, unsigned int uEntryIdx
)
1478 unsigned short wOffset
;
1480 wOffset
= MISCFIFO_KEYETRY0
;
1481 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1483 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1484 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, 0);
1485 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1490 * Set the default Key (KeyEntry[10]) by MISCFIFO
1494 * dwIoBase - Base Address for MAC
1499 * Return Value: none
1503 void MACvSetDefaultKeyEntry(unsigned long dwIoBase
, unsigned int uKeyLen
,
1504 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1506 unsigned short wOffset
;
1507 unsigned long dwData
;
1513 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultKeyEntry\n");
1514 wOffset
= MISCFIFO_KEYETRY0
;
1515 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1519 wOffset
+= (uKeyIdx
* 4);
1520 // always push 128 bits
1521 for (ii
= 0; ii
< 3; ii
++) {
1522 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1523 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1524 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1525 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1528 if (uKeyLen
== WLAN_WEP104_KEYLEN
)
1529 dwData
|= 0x80000000;
1531 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+3);
1532 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1533 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1534 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End. wOffset: %d, Data: %lX\n", wOffset
+3, dwData
);
1539 * Enable default Key (KeyEntry[10]) by MISCFIFO
1543 * dwIoBase - Base Address for MAC
1548 * Return Value: none
1552 void MACvEnableDefaultKey(unsigned long dwIoBase, unsigned char byLocalID)
1554 unsigned short wOffset;
1555 unsigned long dwData;
1560 wOffset = MISCFIFO_KEYETRY0;
1561 wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
1563 dwData = 0xC0440000;
1564 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
1565 VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
1566 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
1567 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "MACvEnableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData);
1574 * Disable default Key (KeyEntry[10]) by MISCFIFO
1578 * dwIoBase - Base Address for MAC
1583 * Return Value: none
1586 void MACvDisableDefaultKey(unsigned long dwIoBase
)
1588 unsigned short wOffset
;
1589 unsigned long dwData
;
1591 wOffset
= MISCFIFO_KEYETRY0
;
1592 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1595 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1596 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1597 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1598 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvDisableDefaultKey: wOffset: %d, Data: %lX\n", wOffset
, dwData
);
1603 * Set the default TKIP Group Key (KeyEntry[10]) by MISCFIFO
1607 * dwIoBase - Base Address for MAC
1612 * Return Value: none
1615 void MACvSetDefaultTKIPKeyEntry(unsigned long dwIoBase
, unsigned int uKeyLen
,
1616 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1618 unsigned short wOffset
;
1619 unsigned long dwData
;
1625 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultTKIPKeyEntry\n");
1626 wOffset
= MISCFIFO_KEYETRY0
;
1627 // Kyle test : change offset from 10 -> 0
1628 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1630 dwData
= 0xC0660000;
1631 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1632 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1633 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1637 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1638 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1639 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1642 wOffset
+= (uKeyIdx
* 4);
1643 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, idx:%d\n", wOffset
, *pdwKey
, uKeyIdx
);
1644 // always push 128 bits
1645 for (ii
= 0; ii
< 4; ii
++) {
1646 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2.(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1647 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1648 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1649 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1655 * Set the Key Control by MISCFIFO
1659 * dwIoBase - Base Address for MAC
1664 * Return Value: none
1668 void MACvSetDefaultKeyCtl(unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
, unsigned char byLocalID
)
1670 unsigned short wOffset
;
1671 unsigned long dwData
;
1676 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1677 wOffset
= MISCFIFO_KEYETRY0
;
1678 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1684 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1686 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1687 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1688 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);