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 Descriptos Address
60 * MACvSetCurrTx0DescAddr - Set Tx0 Descriptos Address
61 * MACvSetCurrTx1DescAddr - Set Tx1 Descriptos 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 --------------------------*/
95 * Read All MAC Registers to buffer
99 * dwIoBase - Base Address for MAC
101 * pbyMacRegs - buffer to read
106 void MACvReadAllRegs (unsigned long dwIoBase
, unsigned char *pbyMacRegs
)
110 // read page0 register
111 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++) {
112 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
116 MACvSelectPage1(dwIoBase
);
118 // read page1 register
119 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
120 VNSvInPortB(dwIoBase
+ ii
, pbyMacRegs
);
124 MACvSelectPage0(dwIoBase
);
130 * Test if all test bits on
134 * dwIoBase - Base Address for MAC
135 * byRegOfs - Offset of MAC Register
136 * byTestBits - Test bits
140 * Return Value: true if all test bits On; otherwise false
143 bool MACbIsRegBitsOn (unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
145 unsigned char byData
;
147 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
148 return (byData
& byTestBits
) == byTestBits
;
153 * Test if all test bits off
157 * dwIoBase - Base Address for MAC
158 * byRegOfs - Offset of MAC Register
159 * byTestBits - Test bits
163 * Return Value: true if all test bits Off; otherwise false
166 bool MACbIsRegBitsOff (unsigned long dwIoBase
, unsigned char byRegOfs
, unsigned char byTestBits
)
168 unsigned char byData
;
170 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
171 return !(byData
& byTestBits
);
176 * Test if MAC interrupt disable
180 * dwIoBase - Base Address for MAC
184 * Return Value: true if interrupt is disable; otherwise false
187 bool MACbIsIntDisable (unsigned long dwIoBase
)
189 unsigned long dwData
;
191 VNSvInPortD(dwIoBase
+ MAC_REG_IMR
, &dwData
);
200 * Read MAC Multicast Address Mask
204 * dwIoBase - Base Address for MAC
205 * uByteidx - Index of Mask
209 * Return Value: Mask Value read
212 unsigned char MACbyReadMultiAddr (unsigned long dwIoBase
, unsigned int uByteIdx
)
214 unsigned char byData
;
216 MACvSelectPage1(dwIoBase
);
217 VNSvInPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, &byData
);
218 MACvSelectPage0(dwIoBase
);
224 * Write MAC Multicast Address Mask
228 * dwIoBase - Base Address for MAC
229 * uByteidx - Index of Mask
230 * byData - Mask Value to write
237 void MACvWriteMultiAddr (unsigned long dwIoBase
, unsigned int uByteIdx
, unsigned char byData
)
239 MACvSelectPage1(dwIoBase
);
240 VNSvOutPortB(dwIoBase
+ MAC_REG_MAR0
+ uByteIdx
, byData
);
241 MACvSelectPage0(dwIoBase
);
246 * Set this hash index into multicast address register bit
250 * dwIoBase - Base Address for MAC
251 * byHashIdx - Hash index to set
258 void MACvSetMultiAddrByHash (unsigned long dwIoBase
, unsigned char byHashIdx
)
260 unsigned int uByteIdx
;
261 unsigned char byBitMask
;
262 unsigned char byOrgValue
;
264 // calculate byte position
265 uByteIdx
= byHashIdx
/ 8;
266 ASSERT(uByteIdx
< 8);
267 // calculate bit position
269 byBitMask
<<= (byHashIdx
% 8);
271 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
272 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
| byBitMask
));
277 * Reset this hash index into multicast address register bit
281 * dwIoBase - Base Address for MAC
282 * byHashIdx - Hash index to clear
289 void MACvResetMultiAddrByHash (unsigned long dwIoBase
, unsigned char byHashIdx
)
291 unsigned int uByteIdx
;
292 unsigned char byBitMask
;
293 unsigned char byOrgValue
;
295 // calculate byte position
296 uByteIdx
= byHashIdx
/ 8;
297 ASSERT(uByteIdx
< 8);
298 // calculate bit position
300 byBitMask
<<= (byHashIdx
% 8);
302 byOrgValue
= MACbyReadMultiAddr(dwIoBase
, uByteIdx
);
303 MACvWriteMultiAddr(dwIoBase
, uByteIdx
, (unsigned char)(byOrgValue
& (~byBitMask
)));
312 * dwIoBase - Base Address for MAC
313 * byThreshold - Threshold Value
320 void MACvSetRxThreshold (unsigned long dwIoBase
, unsigned char byThreshold
)
322 unsigned char byOrgValue
;
324 ASSERT(byThreshold
< 4);
327 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
328 byOrgValue
= (byOrgValue
& 0xCF) | (byThreshold
<< 4);
329 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
338 * dwIoBase - Base Address for MAC
340 * pbyThreshold- Threshold Value Get
345 void MACvGetRxThreshold (unsigned long dwIoBase
, unsigned char *pbyThreshold
)
348 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
349 *pbyThreshold
= (*pbyThreshold
>> 4) & 0x03;
358 * dwIoBase - Base Address for MAC
359 * byThreshold - Threshold Value
366 void MACvSetTxThreshold (unsigned long dwIoBase
, unsigned char byThreshold
)
368 unsigned char byOrgValue
;
370 ASSERT(byThreshold
< 4);
373 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
374 byOrgValue
= (byOrgValue
& 0xF3) | (byThreshold
<< 2);
375 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
384 * dwIoBase - Base Address for MAC
386 * pbyThreshold- Threshold Value Get
391 void MACvGetTxThreshold (unsigned long dwIoBase
, unsigned char *pbyThreshold
)
394 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyThreshold
);
395 *pbyThreshold
= (*pbyThreshold
>> 2) & 0x03;
404 * dwIoBase - Base Address for MAC
405 * byDmaLength - Dma Length Value
412 void MACvSetDmaLength (unsigned long dwIoBase
, unsigned char byDmaLength
)
414 unsigned char byOrgValue
;
416 ASSERT(byDmaLength
< 4);
419 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, &byOrgValue
);
420 byOrgValue
= (byOrgValue
& 0xFC) | byDmaLength
;
421 VNSvOutPortB(dwIoBase
+ MAC_REG_FCR0
, byOrgValue
);
430 * dwIoBase - Base Address for MAC
432 * pbyDmaLength- Dma Length Value Get
437 void MACvGetDmaLength (unsigned long dwIoBase
, unsigned char *pbyDmaLength
)
440 VNSvInPortB(dwIoBase
+ MAC_REG_FCR0
, pbyDmaLength
);
441 *pbyDmaLength
&= 0x03;
446 * Set 802.11 Short Retry Limit
450 * dwIoBase - Base Address for MAC
451 * byRetryLimit- Retry Limit
458 void MACvSetShortRetryLimit (unsigned long dwIoBase
, unsigned char byRetryLimit
)
461 VNSvOutPortB(dwIoBase
+ MAC_REG_SRT
, byRetryLimit
);
466 * Get 802.11 Short Retry Limit
470 * dwIoBase - Base Address for MAC
472 * pbyRetryLimit - Retry Limit Get
477 void MACvGetShortRetryLimit (unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
480 VNSvInPortB(dwIoBase
+ MAC_REG_SRT
, pbyRetryLimit
);
485 * Set 802.11 Long Retry Limit
489 * dwIoBase - Base Address for MAC
490 * byRetryLimit- Retry Limit
497 void MACvSetLongRetryLimit (unsigned long dwIoBase
, unsigned char byRetryLimit
)
500 VNSvOutPortB(dwIoBase
+ MAC_REG_LRT
, byRetryLimit
);
505 * Get 802.11 Long Retry Limit
509 * dwIoBase - Base Address for MAC
511 * pbyRetryLimit - Retry Limit Get
516 void MACvGetLongRetryLimit (unsigned long dwIoBase
, unsigned char *pbyRetryLimit
)
519 VNSvInPortB(dwIoBase
+ MAC_REG_LRT
, pbyRetryLimit
);
524 * Set MAC Loopback mode
528 * dwIoBase - Base Address for MAC
529 * byLoopbackMode - Loopback Mode
536 void MACvSetLoopbackMode (unsigned long dwIoBase
, unsigned char byLoopbackMode
)
538 unsigned char byOrgValue
;
540 ASSERT(byLoopbackMode
< 3);
541 byLoopbackMode
<<= 6;
543 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
544 byOrgValue
= byOrgValue
& 0x3F;
545 byOrgValue
= byOrgValue
| byLoopbackMode
;
546 VNSvOutPortB(dwIoBase
+ MAC_REG_TEST
, byOrgValue
);
551 * Test if MAC in Loopback mode
555 * dwIoBase - Base Address for MAC
559 * Return Value: true if in Loopback mode; otherwise false
562 bool MACbIsInLoopbackMode (unsigned long dwIoBase
)
564 unsigned char byOrgValue
;
566 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
567 if (byOrgValue
& (TEST_LBINT
| TEST_LBEXT
))
574 * Set MAC Address filter
578 * dwIoBase - Base Address for MAC
579 * wFilterType - Filter Type
586 void MACvSetPacketFilter (unsigned long dwIoBase
, unsigned short wFilterType
)
588 unsigned char byOldRCR
;
589 unsigned char byNewRCR
= 0;
591 // if only in DIRECTED mode, multicast-address will set to zero,
592 // but if other mode exist (e.g. PROMISCUOUS), multicast-address
594 if (wFilterType
& PKT_TYPE_DIRECTED
) {
595 // set multicast address to accept none
596 MACvSelectPage1(dwIoBase
);
597 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0L);
598 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0L);
599 MACvSelectPage0(dwIoBase
);
602 if (wFilterType
& (PKT_TYPE_PROMISCUOUS
| PKT_TYPE_ALL_MULTICAST
)) {
603 // set multicast address to accept all
604 MACvSelectPage1(dwIoBase
);
605 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
, 0xFFFFFFFFL
);
606 VNSvOutPortD(dwIoBase
+ MAC_REG_MAR0
+ sizeof(unsigned long), 0xFFFFFFFFL
);
607 MACvSelectPage0(dwIoBase
);
610 if (wFilterType
& PKT_TYPE_PROMISCUOUS
) {
612 byNewRCR
|= (RCR_RXALLTYPE
| RCR_UNICAST
| RCR_MULTICAST
| RCR_BROADCAST
);
614 byNewRCR
&= ~RCR_BSSID
;
617 if (wFilterType
& (PKT_TYPE_ALL_MULTICAST
| PKT_TYPE_MULTICAST
))
618 byNewRCR
|= RCR_MULTICAST
;
620 if (wFilterType
& PKT_TYPE_BROADCAST
)
621 byNewRCR
|= RCR_BROADCAST
;
623 if (wFilterType
& PKT_TYPE_ERROR_CRC
)
624 byNewRCR
|= RCR_ERRCRC
;
626 VNSvInPortB(dwIoBase
+ MAC_REG_RCR
, &byOldRCR
);
627 if (byNewRCR
!= byOldRCR
) {
628 // Modify the Receive Command Register
629 VNSvOutPortB(dwIoBase
+ MAC_REG_RCR
, byNewRCR
);
635 * Save MAC registers to context buffer
639 * dwIoBase - Base Address for MAC
641 * pbyCxtBuf - Context buffer
646 void MACvSaveContext (unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
650 // read page0 register
651 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++) {
652 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ ii
));
655 MACvSelectPage1(dwIoBase
);
657 // read page1 register
658 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
659 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
662 MACvSelectPage0(dwIoBase
);
667 * Restore MAC registers from context buffer
671 * dwIoBase - Base Address for MAC
672 * pbyCxtBuf - Context buffer
679 void MACvRestoreContext (unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
683 MACvSelectPage1(dwIoBase
);
685 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++) {
686 VNSvOutPortB((dwIoBase
+ ii
), *(pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
688 MACvSelectPage0(dwIoBase
);
690 // restore RCR,TCR,IMR...
691 for (ii
= MAC_REG_RCR
; ii
< MAC_REG_ISR
; ii
++) {
692 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
694 // restore MAC Config.
695 for (ii
= MAC_REG_LRT
; ii
< MAC_REG_PAGE1SEL
; ii
++) {
696 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
698 VNSvOutPortB(dwIoBase
+ MAC_REG_CFG
, *(pbyCxtBuf
+ MAC_REG_CFG
));
700 // restore PS Config.
701 for (ii
= MAC_REG_PSCFG
; ii
< MAC_REG_BBREGCTL
; ii
++) {
702 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
705 // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
706 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
));
707 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
));
708 VNSvOutPortD(dwIoBase
+ MAC_REG_BCNDMAPTR
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_BCNDMAPTR
));
711 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
));
713 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
));
719 * Compare if MAC registers same as context buffer
723 * dwIoBase - Base Address for MAC
724 * pbyCxtBuf - Context buffer
728 * Return Value: true if all values are the same; otherwise false
731 bool MACbCompareContext (unsigned long dwIoBase
, unsigned char *pbyCxtBuf
)
733 unsigned long dwData
;
735 // compare MAC context to determine if this is a power lost init,
736 // return true for power remaining init, return false for power lost init
738 // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR
739 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, &dwData
);
740 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
)) {
744 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, &dwData
);
745 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
)) {
749 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, &dwData
);
750 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
)) {
754 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, &dwData
);
755 if (dwData
!= *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
)) {
769 * dwIoBase - Base Address for MAC
773 * Return Value: true if Reset Success; otherwise false
776 bool MACbSoftwareReset (unsigned long dwIoBase
)
778 unsigned char byData
;
781 // turn on HOSTCR_SOFTRST, just write 0x01 to reset
782 //MACvRegBitsOn(dwIoBase, MAC_REG_HOSTCR, HOSTCR_SOFTRST);
783 VNSvOutPortB(dwIoBase
+ MAC_REG_HOSTCR
, 0x01);
785 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
786 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
787 if ( !(byData
& HOSTCR_SOFTRST
))
790 if (ww
== W_MAX_TIMEOUT
)
798 * save some important register's value, then do reset, then restore register's value
802 * dwIoBase - Base Address for MAC
806 * Return Value: true if success; otherwise false
809 bool MACbSafeSoftwareReset (unsigned long dwIoBase
)
811 unsigned char abyTmpRegData
[MAC_MAX_CONTEXT_SIZE_PAGE0
+MAC_MAX_CONTEXT_SIZE_PAGE1
];
815 // save some important register's value, then do
816 // reset, then restore register's value
819 MACvSaveContext(dwIoBase
, abyTmpRegData
);
821 bRetVal
= MACbSoftwareReset(dwIoBase
);
822 //BBvSoftwareReset(pDevice->PortOffset);
823 // restore MAC context, except CR0
824 MACvRestoreContext(dwIoBase
, abyTmpRegData
);
835 * dwIoBase - Base Address for MAC
839 * Return Value: true if success; otherwise false
842 bool MACbSafeRxOff (unsigned long dwIoBase
)
845 unsigned long dwData
;
846 unsigned char byData
;
848 // turn off wow temp for turn off Rx safely
851 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_CLRRUN
);
852 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_CLRRUN
);
853 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
854 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, &dwData
);
855 if (!(dwData
& DMACTL_RUN
))
858 if (ww
== W_MAX_TIMEOUT
) {
860 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x10)\n");
863 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
864 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, &dwData
);
865 if ( !(dwData
& DMACTL_RUN
))
868 if (ww
== W_MAX_TIMEOUT
) {
870 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x11)\n");
874 // try to safe shutdown RX
875 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
876 // W_MAX_TIMEOUT is the timeout period
877 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
878 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
879 if ( !(byData
& HOSTCR_RXONST
))
882 if (ww
== W_MAX_TIMEOUT
) {
884 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x12)\n");
896 * dwIoBase - Base Address for MAC
900 * Return Value: true if success; otherwise false
903 bool MACbSafeTxOff (unsigned long dwIoBase
)
906 unsigned long dwData
;
907 unsigned char byData
;
911 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_CLRRUN
);
913 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_CLRRUN
);
916 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
917 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, &dwData
);
918 if ( !(dwData
& DMACTL_RUN
))
921 if (ww
== W_MAX_TIMEOUT
) {
923 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x20)\n");
926 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
927 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, &dwData
);
928 if ( !(dwData
& DMACTL_RUN
))
931 if (ww
== W_MAX_TIMEOUT
) {
933 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x21)\n");
937 // try to safe shutdown TX
938 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_TXON
);
940 // W_MAX_TIMEOUT is the timeout period
941 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
942 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
943 if ( !(byData
& HOSTCR_TXONST
))
946 if (ww
== W_MAX_TIMEOUT
) {
948 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x24)\n");
960 * dwIoBase - Base Address for MAC
964 * Return Value: true if success; otherwise false
967 bool MACbSafeStop (unsigned long dwIoBase
)
969 MACvRegBitsOff(dwIoBase
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
971 if (MACbSafeRxOff(dwIoBase
) == false) {
973 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeRxOff == false)\n");
974 MACbSafeSoftwareReset(dwIoBase
);
977 if (MACbSafeTxOff(dwIoBase
) == false) {
979 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" MACbSafeTxOff == false)\n");
980 MACbSafeSoftwareReset(dwIoBase
);
984 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_MACEN
);
995 * dwIoBase - Base Address for MAC
999 * Return Value: true if success; otherwise false
1002 bool MACbShutdown (unsigned long dwIoBase
)
1005 MACvIntDisable(dwIoBase
);
1006 MACvSetLoopbackMode(dwIoBase
, MAC_LB_INTERNAL
);
1008 if (!MACbSafeStop(dwIoBase
)) {
1009 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
1012 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
1022 * dwIoBase - Base Address for MAC
1026 * Return Value: none
1029 void MACvInitialize (unsigned long dwIoBase
)
1031 // clear sticky bits
1032 MACvClearStckDS(dwIoBase
);
1033 // disable force PME-enable
1034 VNSvOutPortB(dwIoBase
+ MAC_REG_PMC1
, PME_OVR
);
1037 MACvPwrEvntDisable(dwIoBase);
1038 // clear power status
1039 VNSvOutPortW(dwIoBase + MAC_REG_WAKEUPSR0, 0x0F0F);
1043 MACbSoftwareReset(dwIoBase
);
1045 // issue AUTOLD in EECSR to reload eeprom
1046 //MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD);
1047 // wait until EEPROM loading complete
1050 // VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &u8Data);
1051 // if ( !(u8Data & I2MCSR_AUTOLD))
1055 // reset TSF counter
1056 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTRST
);
1057 // enable TSF counter
1058 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
1061 // set packet filter
1062 // receive directed and broadcast address
1064 MACvSetPacketFilter(dwIoBase
, PKT_TYPE_DIRECTED
| PKT_TYPE_BROADCAST
);
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 MACvSetCurrRx0DescAddr (unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1085 unsigned char byData
;
1086 unsigned char byOrgDMACtl
;
1088 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byOrgDMACtl
);
1089 if (byOrgDMACtl
& DMACTL_RUN
) {
1090 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
+2, DMACTL_RUN
);
1092 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1093 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byData
);
1094 if ( !(byData
& DMACTL_RUN
))
1097 if (ww
== W_MAX_TIMEOUT
) {
1100 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, dwCurrDescAddr
);
1101 if (byOrgDMACtl
& DMACTL_RUN
) {
1102 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_RUN
);
1108 * Set the chip with current rx descriptor address
1112 * dwIoBase - Base Address for MAC
1113 * dwCurrDescAddr - Descriptor Address
1117 * Return Value: none
1120 void MACvSetCurrRx1DescAddr (unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1123 unsigned char byData
;
1124 unsigned char byOrgDMACtl
;
1126 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byOrgDMACtl
);
1127 if (byOrgDMACtl
& DMACTL_RUN
) {
1128 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
+2, DMACTL_RUN
);
1130 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1131 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byData
);
1132 if ( !(byData
& DMACTL_RUN
))
1135 if (ww
== W_MAX_TIMEOUT
) {
1138 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, dwCurrDescAddr
);
1139 if (byOrgDMACtl
& DMACTL_RUN
) {
1140 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_RUN
);
1146 * Set the chip with current tx0 descriptor address
1150 * dwIoBase - Base Address for MAC
1151 * dwCurrDescAddr - Descriptor Address
1155 * Return Value: none
1158 void MACvSetCurrTx0DescAddrEx (unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1161 unsigned char byData
;
1162 unsigned char byOrgDMACtl
;
1164 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byOrgDMACtl
);
1165 if (byOrgDMACtl
& DMACTL_RUN
) {
1166 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1168 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1169 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1170 if ( !(byData
& DMACTL_RUN
))
1173 if (ww
== W_MAX_TIMEOUT
) {
1176 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, dwCurrDescAddr
);
1177 if (byOrgDMACtl
& DMACTL_RUN
) {
1178 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_RUN
);
1184 * Set the chip with current AC0 descriptor address
1188 * dwIoBase - Base Address for MAC
1189 * dwCurrDescAddr - Descriptor Address
1193 * Return Value: none
1197 void MACvSetCurrAC0DescAddrEx (unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1200 unsigned char byData
;
1201 unsigned char byOrgDMACtl
;
1203 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byOrgDMACtl
);
1204 if (byOrgDMACtl
& DMACTL_RUN
) {
1205 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1207 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1208 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1209 if (!(byData
& DMACTL_RUN
))
1212 if (ww
== W_MAX_TIMEOUT
) {
1214 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x26)\n");
1216 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, dwCurrDescAddr
);
1217 if (byOrgDMACtl
& DMACTL_RUN
) {
1218 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_RUN
);
1224 void MACvSetCurrTXDescAddr (int iTxType
, unsigned long dwIoBase
, unsigned long dwCurrDescAddr
)
1226 if(iTxType
== TYPE_AC0DMA
){
1227 MACvSetCurrAC0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1228 }else if(iTxType
== TYPE_TXDMA0
){
1229 MACvSetCurrTx0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
1235 * Micro Second Delay via MAC
1239 * dwIoBase - Base Address for MAC
1240 * uDelay - Delay time (timer resolution is 4 us)
1244 * Return Value: none
1247 void MACvTimer0MicroSDelay (unsigned long dwIoBase
, unsigned int uDelay
)
1249 unsigned char byValue
;
1252 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1253 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelay
);
1254 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1255 for(ii
=0;ii
<66;ii
++) { // assume max PCI clock is 66Mhz
1256 for (uu
= 0; uu
< uDelay
; uu
++) {
1257 VNSvInPortB(dwIoBase
+ MAC_REG_TMCTL0
, &byValue
);
1258 if ((byValue
== 0) ||
1259 (byValue
& TMCTL_TSUSP
)) {
1260 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1265 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1271 * Micro Second One shot timer via MAC
1275 * dwIoBase - Base Address for MAC
1276 * uDelay - Delay time
1280 * Return Value: none
1283 void MACvOneShotTimer0MicroSec (unsigned long dwIoBase
, unsigned int uDelayTime
)
1285 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
1286 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelayTime
);
1287 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
1292 * Micro Second One shot timer via MAC
1296 * dwIoBase - Base Address for MAC
1297 * uDelay - Delay time
1301 * Return Value: none
1304 void MACvOneShotTimer1MicroSec (unsigned long dwIoBase
, unsigned int uDelayTime
)
1306 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, 0);
1307 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA1
, uDelayTime
);
1308 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, (TMCTL_TMD
| TMCTL_TE
));
1312 void MACvSetMISCFifo (unsigned long dwIoBase
, unsigned short wOffset
, unsigned long dwData
)
1316 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1317 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1318 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1322 bool MACbTxDMAOff (unsigned long dwIoBase
, unsigned int idx
)
1324 unsigned char byData
;
1325 unsigned int ww
= 0;
1327 if (idx
== TYPE_TXDMA0
) {
1328 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
1329 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1330 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
1331 if ( !(byData
& DMACTL_RUN
))
1334 } else if (idx
== TYPE_AC0DMA
) {
1335 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
1336 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1337 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
1338 if ( !(byData
& DMACTL_RUN
))
1342 if (ww
== W_MAX_TIMEOUT
) {
1344 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x29)\n");
1350 void MACvClearBusSusInd (unsigned long dwIoBase
)
1352 unsigned long dwOrgValue
;
1354 // check if BcnSusInd enabled
1355 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1356 if( !(dwOrgValue
& EnCFG_BcnSusInd
))
1359 dwOrgValue
= dwOrgValue
| EnCFG_BcnSusClr
;
1360 VNSvOutPortD(dwIoBase
+ MAC_REG_ENCFG
, dwOrgValue
);
1361 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1362 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1363 if( !(dwOrgValue
& EnCFG_BcnSusInd
))
1366 if (ww
== W_MAX_TIMEOUT
) {
1368 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1372 void MACvEnableBusSusEn (unsigned long dwIoBase
)
1374 unsigned char byOrgValue
;
1375 unsigned long dwOrgValue
;
1377 // check if BcnSusInd enabled
1378 VNSvInPortB(dwIoBase
+ MAC_REG_CFG
, &byOrgValue
);
1381 byOrgValue
= byOrgValue
| CFG_BCNSUSEN
;
1382 VNSvOutPortB(dwIoBase
+ MAC_REG_ENCFG
, byOrgValue
);
1383 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1384 VNSvInPortD(dwIoBase
+ MAC_REG_ENCFG
, &dwOrgValue
);
1385 if(dwOrgValue
& EnCFG_BcnSusInd
)
1388 if (ww
== W_MAX_TIMEOUT
) {
1390 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x34)\n");
1394 bool MACbFlushSYNCFifo (unsigned long dwIoBase
)
1396 unsigned char byOrgValue
;
1399 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1402 byOrgValue
= byOrgValue
| MACCR_SYNCFLUSH
;
1403 VNSvOutPortB(dwIoBase
+ MAC_REG_MACCR
, byOrgValue
);
1405 // Check if SyncFlushOK
1406 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1407 VNSvInPortB(dwIoBase
+ MAC_REG_MACCR
, &byOrgValue
);
1408 if(byOrgValue
& MACCR_SYNCFLUSHOK
)
1411 if (ww
== W_MAX_TIMEOUT
) {
1413 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1418 bool MACbPSWakeup (unsigned long dwIoBase
)
1420 unsigned char byOrgValue
;
1423 if (MACbIsRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PS
)) {
1427 MACvRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PSEN
);
1429 // Check if SyncFlushOK
1430 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
1431 VNSvInPortB(dwIoBase
+ MAC_REG_PSCTL
, &byOrgValue
);
1432 if(byOrgValue
& PSCTL_WAKEDONE
)
1435 if (ww
== W_MAX_TIMEOUT
) {
1437 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
" DBG_PORT80(0x33)\n");
1445 * Set the Key by MISCFIFO
1449 * dwIoBase - Base Address for MAC
1454 * Return Value: none
1458 void MACvSetKeyEntry (unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
,
1459 unsigned int uKeyIdx
, unsigned char *pbyAddr
, unsigned long *pdwKey
, unsigned char byLocalID
)
1461 unsigned short wOffset
;
1462 unsigned long dwData
;
1469 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1470 wOffset
= MISCFIFO_KEYETRY0
;
1471 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1476 dwData
|= MAKEWORD(*(pbyAddr
+4), *(pbyAddr
+5));
1477 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1479 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1480 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1481 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1485 dwData
|= *(pbyAddr
+3);
1487 dwData
|= *(pbyAddr
+2);
1489 dwData
|= *(pbyAddr
+1);
1491 dwData
|= *(pbyAddr
+0);
1492 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2. wOffset: %d, Data: %lX\n", wOffset
, dwData
);
1494 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1495 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1496 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1499 wOffset
+= (uKeyIdx
* 4);
1500 for (ii
=0;ii
<4;ii
++) {
1501 // alway push 128 bits
1502 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"3.(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1503 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1504 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1505 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1513 * Disable the Key Entry by MISCFIFO
1517 * dwIoBase - Base Address for MAC
1522 * Return Value: none
1525 void MACvDisableKeyEntry (unsigned long dwIoBase
, unsigned int uEntryIdx
)
1527 unsigned short wOffset
;
1529 wOffset
= MISCFIFO_KEYETRY0
;
1530 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1532 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1533 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, 0);
1534 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1540 * Set the default Key (KeyEntry[10]) by MISCFIFO
1544 * dwIoBase - Base Address for MAC
1549 * Return Value: none
1553 void MACvSetDefaultKeyEntry (unsigned long dwIoBase
, unsigned int uKeyLen
,
1554 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1556 unsigned short wOffset
;
1557 unsigned long dwData
;
1563 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultKeyEntry\n");
1564 wOffset
= MISCFIFO_KEYETRY0
;
1565 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1569 wOffset
+= (uKeyIdx
* 4);
1570 // alway push 128 bits
1571 for (ii
=0; ii
<3; ii
++) {
1572 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1573 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1574 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1575 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1578 if (uKeyLen
== WLAN_WEP104_KEYLEN
) {
1579 dwData
|= 0x80000000;
1581 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+3);
1582 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1583 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1584 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"End. wOffset: %d, Data: %lX\n", wOffset
+3, dwData
);
1591 * Enable default Key (KeyEntry[10]) by MISCFIFO
1595 * dwIoBase - Base Address for MAC
1600 * Return Value: none
1604 void MACvEnableDefaultKey (unsigned long dwIoBase, unsigned char byLocalID)
1606 unsigned short wOffset;
1607 unsigned long dwData;
1613 wOffset = MISCFIFO_KEYETRY0;
1614 wOffset += (10 * MISCFIFO_KEYENTRYSIZE);
1616 dwData = 0xC0440000;
1617 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFNDEX, wOffset);
1618 VNSvOutPortD(dwIoBase + MAC_REG_MISCFFDATA, dwData);
1619 VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
1620 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MACvEnableDefaultKey: wOffset: %d, Data: %lX\n", wOffset, dwData);
1627 * Disable default Key (KeyEntry[10]) by MISCFIFO
1631 * dwIoBase - Base Address for MAC
1636 * Return Value: none
1639 void MACvDisableDefaultKey (unsigned long dwIoBase
)
1641 unsigned short wOffset
;
1642 unsigned long dwData
;
1645 wOffset
= MISCFIFO_KEYETRY0
;
1646 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1649 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1650 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1651 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1652 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvDisableDefaultKey: wOffset: %d, Data: %lX\n", wOffset
, dwData
);
1657 * Set the default TKIP Group Key (KeyEntry[10]) by MISCFIFO
1661 * dwIoBase - Base Address for MAC
1666 * Return Value: none
1669 void MACvSetDefaultTKIPKeyEntry (unsigned long dwIoBase
, unsigned int uKeyLen
,
1670 unsigned int uKeyIdx
, unsigned long *pdwKey
, unsigned char byLocalID
)
1672 unsigned short wOffset
;
1673 unsigned long dwData
;
1680 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetDefaultTKIPKeyEntry\n");
1681 wOffset
= MISCFIFO_KEYETRY0
;
1682 // Kyle test : change offset from 10 -> 0
1683 wOffset
+= (10 * MISCFIFO_KEYENTRYSIZE
);
1685 dwData
= 0xC0660000;
1686 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1687 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1688 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1692 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1693 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1694 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1697 wOffset
+= (uKeyIdx
* 4);
1698 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, idx:%d\n", wOffset
, *pdwKey
, uKeyIdx
);
1699 // alway push 128 bits
1700 for (ii
=0; ii
<4; ii
++) {
1701 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2.(%d) wOffset: %d, Data: %lX\n", ii
, wOffset
+ii
, *pdwKey
);
1702 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
1703 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
1704 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
1713 * Set the Key Control by MISCFIFO
1717 * dwIoBase - Base Address for MAC
1722 * Return Value: none
1726 void MACvSetDefaultKeyCtl (unsigned long dwIoBase
, unsigned short wKeyCtl
, unsigned int uEntryIdx
, unsigned char byLocalID
)
1728 unsigned short wOffset
;
1729 unsigned long dwData
;
1735 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MACvSetKeyEntry\n");
1736 wOffset
= MISCFIFO_KEYETRY0
;
1737 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
1743 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset
, dwData
, wKeyCtl
);
1745 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
1746 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
1747 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);