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 * MACbIsRegBitsOn - Test if All test Bits On
30 * MACbIsRegBitsOff - Test if All test Bits Off
31 * MACbIsIntDisable - Test if MAC interrupt disable
32 * MACvSetShortRetryLimit - Set 802.11 Short Retry limit
33 * MACvSetLongRetryLimit - Set 802.11 Long Retry limit
34 * MACvSetLoopbackMode - Set MAC Loopback Mode
35 * MACvSaveContext - Save Context of MAC Registers
36 * MACvRestoreContext - Restore Context of MAC Registers
37 * MACbSoftwareReset - Software Reset MAC
38 * MACbSafeRxOff - Turn Off MAC Rx
39 * MACbSafeTxOff - Turn Off MAC Tx
40 * MACbSafeStop - Stop MAC function
41 * MACbShutdown - Shut down MAC
42 * MACvInitialize - Initialize MAC
43 * MACvSetCurrRxDescAddr - Set Rx Descriptors Address
44 * MACvSetCurrTx0DescAddr - Set Tx0 Descriptors Address
45 * MACvSetCurrTx1DescAddr - Set Tx1 Descriptors Address
46 * MACvTimer0MicroSDelay - Micro Second Delay Loop by MAC
49 * 08-22-2003 Kyle Hsu : Porting MAC functions from sim53
50 * 09-03-2003 Bryan YC Fan : Add MACvClearBusSusInd()& MACvEnableBusSusEn()
51 * 09-18-2003 Jerry Chen : Add MACvSetKeyEntry & MACvDisableKeyEntry
60 * Test if all test bits on
64 * dwIoBase - Base Address for MAC
65 * byRegOfs - Offset of MAC Register
66 * byTestBits - Test bits
70 * Return Value: true if all test bits On; otherwise false
73 bool MACbIsRegBitsOn(void __iomem
*dwIoBase
, unsigned char byRegOfs
,
74 unsigned char byTestBits
)
78 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
79 return (byData
& byTestBits
) == byTestBits
;
84 * Test if all test bits off
88 * dwIoBase - Base Address for MAC
89 * byRegOfs - Offset of MAC Register
90 * byTestBits - Test bits
94 * Return Value: true if all test bits Off; otherwise false
97 bool MACbIsRegBitsOff(void __iomem
*dwIoBase
, unsigned char byRegOfs
,
98 unsigned char byTestBits
)
100 unsigned char byData
;
102 VNSvInPortB(dwIoBase
+ byRegOfs
, &byData
);
103 return !(byData
& byTestBits
);
108 * Test if MAC interrupt disable
112 * dwIoBase - Base Address for MAC
116 * Return Value: true if interrupt is disable; otherwise false
119 bool MACbIsIntDisable(void __iomem
*dwIoBase
)
121 unsigned long dwData
;
123 VNSvInPortD(dwIoBase
+ MAC_REG_IMR
, &dwData
);
132 * Set 802.11 Short Retry Limit
136 * dwIoBase - Base Address for MAC
137 * byRetryLimit- Retry Limit
144 void MACvSetShortRetryLimit(void __iomem
*dwIoBase
, unsigned char byRetryLimit
)
147 VNSvOutPortB(dwIoBase
+ MAC_REG_SRT
, byRetryLimit
);
153 * Set 802.11 Long Retry Limit
157 * dwIoBase - Base Address for MAC
158 * byRetryLimit- Retry Limit
165 void MACvSetLongRetryLimit(void __iomem
*dwIoBase
, unsigned char byRetryLimit
)
168 VNSvOutPortB(dwIoBase
+ MAC_REG_LRT
, byRetryLimit
);
173 * Set MAC Loopback mode
177 * dwIoBase - Base Address for MAC
178 * byLoopbackMode - Loopback Mode
185 void MACvSetLoopbackMode(void __iomem
*dwIoBase
, unsigned char byLoopbackMode
)
187 unsigned char byOrgValue
;
189 byLoopbackMode
<<= 6;
191 VNSvInPortB(dwIoBase
+ MAC_REG_TEST
, &byOrgValue
);
192 byOrgValue
= byOrgValue
& 0x3F;
193 byOrgValue
= byOrgValue
| byLoopbackMode
;
194 VNSvOutPortB(dwIoBase
+ MAC_REG_TEST
, byOrgValue
);
199 * Save MAC registers to context buffer
203 * dwIoBase - Base Address for MAC
205 * pbyCxtBuf - Context buffer
210 void MACvSaveContext(void __iomem
*dwIoBase
, unsigned char *pbyCxtBuf
)
214 /* read page0 register */
215 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE0
; ii
++)
216 VNSvInPortB((dwIoBase
+ ii
), (pbyCxtBuf
+ ii
));
218 MACvSelectPage1(dwIoBase
);
220 /* read page1 register */
221 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++)
222 VNSvInPortB((dwIoBase
+ ii
),
223 (pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
225 MACvSelectPage0(dwIoBase
);
230 * Restore MAC registers from context buffer
234 * dwIoBase - Base Address for MAC
235 * pbyCxtBuf - Context buffer
242 void MACvRestoreContext(void __iomem
*dwIoBase
, unsigned char *pbyCxtBuf
)
246 MACvSelectPage1(dwIoBase
);
248 for (ii
= 0; ii
< MAC_MAX_CONTEXT_SIZE_PAGE1
; ii
++)
249 VNSvOutPortB((dwIoBase
+ ii
),
250 *(pbyCxtBuf
+ MAC_MAX_CONTEXT_SIZE_PAGE0
+ ii
));
252 MACvSelectPage0(dwIoBase
);
254 /* restore RCR,TCR,IMR... */
255 for (ii
= MAC_REG_RCR
; ii
< MAC_REG_ISR
; ii
++)
256 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
258 /* restore MAC Config. */
259 for (ii
= MAC_REG_LRT
; ii
< MAC_REG_PAGE1SEL
; ii
++)
260 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
262 VNSvOutPortB(dwIoBase
+ MAC_REG_CFG
, *(pbyCxtBuf
+ MAC_REG_CFG
));
264 /* restore PS Config. */
265 for (ii
= MAC_REG_PSCFG
; ii
< MAC_REG_BBREGCTL
; ii
++)
266 VNSvOutPortB(dwIoBase
+ ii
, *(pbyCxtBuf
+ ii
));
268 /* restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR */
269 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
,
270 *(unsigned long *)(pbyCxtBuf
+ MAC_REG_TXDMAPTR0
));
271 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
,
272 *(unsigned long *)(pbyCxtBuf
+ MAC_REG_AC0DMAPTR
));
273 VNSvOutPortD(dwIoBase
+ MAC_REG_BCNDMAPTR
,
274 *(unsigned long *)(pbyCxtBuf
+ MAC_REG_BCNDMAPTR
));
276 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
,
277 *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR0
));
279 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
,
280 *(unsigned long *)(pbyCxtBuf
+ MAC_REG_RXDMAPTR1
));
289 * dwIoBase - Base Address for MAC
293 * Return Value: true if Reset Success; otherwise false
296 bool MACbSoftwareReset(void __iomem
*dwIoBase
)
298 unsigned char byData
;
301 /* turn on HOSTCR_SOFTRST, just write 0x01 to reset */
302 VNSvOutPortB(dwIoBase
+ MAC_REG_HOSTCR
, 0x01);
304 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
305 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
306 if (!(byData
& HOSTCR_SOFTRST
))
309 if (ww
== W_MAX_TIMEOUT
)
316 * save some important register's value, then do reset, then restore register's value
320 * dwIoBase - Base Address for MAC
324 * Return Value: true if success; otherwise false
327 bool MACbSafeSoftwareReset(void __iomem
*dwIoBase
)
329 unsigned char abyTmpRegData
[MAC_MAX_CONTEXT_SIZE_PAGE0
+MAC_MAX_CONTEXT_SIZE_PAGE1
];
333 * save some important register's value, then do
334 * reset, then restore register's value
336 /* save MAC context */
337 MACvSaveContext(dwIoBase
, abyTmpRegData
);
339 bRetVal
= MACbSoftwareReset(dwIoBase
);
340 /* restore MAC context, except CR0 */
341 MACvRestoreContext(dwIoBase
, abyTmpRegData
);
352 * dwIoBase - Base Address for MAC
356 * Return Value: true if success; otherwise false
359 bool MACbSafeRxOff(void __iomem
*dwIoBase
)
362 unsigned long dwData
;
363 unsigned char byData
;
365 /* turn off wow temp for turn off Rx safely */
367 /* Clear RX DMA0,1 */
368 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_CLRRUN
);
369 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_CLRRUN
);
370 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
371 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL0
, &dwData
);
372 if (!(dwData
& DMACTL_RUN
))
375 if (ww
== W_MAX_TIMEOUT
) {
376 pr_debug(" DBG_PORT80(0x10)\n");
379 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
380 VNSvInPortD(dwIoBase
+ MAC_REG_RXDMACTL1
, &dwData
);
381 if (!(dwData
& DMACTL_RUN
))
384 if (ww
== W_MAX_TIMEOUT
) {
385 pr_debug(" DBG_PORT80(0x11)\n");
389 /* try to safe shutdown RX */
390 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_RXON
);
391 /* W_MAX_TIMEOUT is the timeout period */
392 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
393 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
394 if (!(byData
& HOSTCR_RXONST
))
397 if (ww
== W_MAX_TIMEOUT
) {
398 pr_debug(" DBG_PORT80(0x12)\n");
410 * dwIoBase - Base Address for MAC
414 * Return Value: true if success; otherwise false
417 bool MACbSafeTxOff(void __iomem
*dwIoBase
)
420 unsigned long dwData
;
421 unsigned char byData
;
425 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_CLRRUN
);
427 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_CLRRUN
);
429 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
430 VNSvInPortD(dwIoBase
+ MAC_REG_TXDMACTL0
, &dwData
);
431 if (!(dwData
& DMACTL_RUN
))
434 if (ww
== W_MAX_TIMEOUT
) {
435 pr_debug(" DBG_PORT80(0x20)\n");
438 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
439 VNSvInPortD(dwIoBase
+ MAC_REG_AC0DMACTL
, &dwData
);
440 if (!(dwData
& DMACTL_RUN
))
443 if (ww
== W_MAX_TIMEOUT
) {
444 pr_debug(" DBG_PORT80(0x21)\n");
448 /* try to safe shutdown TX */
449 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_TXON
);
451 /* W_MAX_TIMEOUT is the timeout period */
452 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
453 VNSvInPortB(dwIoBase
+ MAC_REG_HOSTCR
, &byData
);
454 if (!(byData
& HOSTCR_TXONST
))
457 if (ww
== W_MAX_TIMEOUT
) {
458 pr_debug(" DBG_PORT80(0x24)\n");
470 * dwIoBase - Base Address for MAC
474 * Return Value: true if success; otherwise false
477 bool MACbSafeStop(void __iomem
*dwIoBase
)
479 MACvRegBitsOff(dwIoBase
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
481 if (!MACbSafeRxOff(dwIoBase
)) {
482 pr_debug(" MACbSafeRxOff == false)\n");
483 MACbSafeSoftwareReset(dwIoBase
);
486 if (!MACbSafeTxOff(dwIoBase
)) {
487 pr_debug(" MACbSafeTxOff == false)\n");
488 MACbSafeSoftwareReset(dwIoBase
);
492 MACvRegBitsOff(dwIoBase
, MAC_REG_HOSTCR
, HOSTCR_MACEN
);
503 * dwIoBase - Base Address for MAC
507 * Return Value: true if success; otherwise false
510 bool MACbShutdown(void __iomem
*dwIoBase
)
512 /* disable MAC IMR */
513 MACvIntDisable(dwIoBase
);
514 MACvSetLoopbackMode(dwIoBase
, MAC_LB_INTERNAL
);
515 /* stop the adapter */
516 if (!MACbSafeStop(dwIoBase
)) {
517 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
520 MACvSetLoopbackMode(dwIoBase
, MAC_LB_NONE
);
530 * dwIoBase - Base Address for MAC
537 void MACvInitialize(void __iomem
*dwIoBase
)
539 /* clear sticky bits */
540 MACvClearStckDS(dwIoBase
);
541 /* disable force PME-enable */
542 VNSvOutPortB(dwIoBase
+ MAC_REG_PMC1
, PME_OVR
);
546 MACbSoftwareReset(dwIoBase
);
548 /* reset TSF counter */
549 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTRST
);
550 /* enable TSF counter */
551 VNSvOutPortB(dwIoBase
+ MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
556 * Set the chip with current rx descriptor address
560 * dwIoBase - Base Address for MAC
561 * dwCurrDescAddr - Descriptor Address
568 void MACvSetCurrRx0DescAddr(void __iomem
*dwIoBase
, unsigned long dwCurrDescAddr
)
571 unsigned char byData
;
572 unsigned char byOrgDMACtl
;
574 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byOrgDMACtl
);
575 if (byOrgDMACtl
& DMACTL_RUN
)
576 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
+2, DMACTL_RUN
);
578 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
579 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, &byData
);
580 if (!(byData
& DMACTL_RUN
))
584 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR0
, dwCurrDescAddr
);
585 if (byOrgDMACtl
& DMACTL_RUN
)
586 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL0
, DMACTL_RUN
);
591 * Set the chip with current rx descriptor address
595 * dwIoBase - Base Address for MAC
596 * dwCurrDescAddr - Descriptor Address
603 void MACvSetCurrRx1DescAddr(void __iomem
*dwIoBase
, unsigned long dwCurrDescAddr
)
606 unsigned char byData
;
607 unsigned char byOrgDMACtl
;
609 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byOrgDMACtl
);
610 if (byOrgDMACtl
& DMACTL_RUN
)
611 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
+2, DMACTL_RUN
);
613 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
614 VNSvInPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, &byData
);
615 if (!(byData
& DMACTL_RUN
))
619 VNSvOutPortD(dwIoBase
+ MAC_REG_RXDMAPTR1
, dwCurrDescAddr
);
620 if (byOrgDMACtl
& DMACTL_RUN
)
621 VNSvOutPortB(dwIoBase
+ MAC_REG_RXDMACTL1
, DMACTL_RUN
);
627 * Set the chip with current tx0 descriptor address
631 * dwIoBase - Base Address for MAC
632 * dwCurrDescAddr - Descriptor Address
639 void MACvSetCurrTx0DescAddrEx(void __iomem
*dwIoBase
,
640 unsigned long dwCurrDescAddr
)
643 unsigned char byData
;
644 unsigned char byOrgDMACtl
;
646 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byOrgDMACtl
);
647 if (byOrgDMACtl
& DMACTL_RUN
)
648 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
+2, DMACTL_RUN
);
650 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
651 VNSvInPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, &byData
);
652 if (!(byData
& DMACTL_RUN
))
656 VNSvOutPortD(dwIoBase
+ MAC_REG_TXDMAPTR0
, dwCurrDescAddr
);
657 if (byOrgDMACtl
& DMACTL_RUN
)
658 VNSvOutPortB(dwIoBase
+ MAC_REG_TXDMACTL0
, DMACTL_RUN
);
663 * Set the chip with current AC0 descriptor address
667 * dwIoBase - Base Address for MAC
668 * dwCurrDescAddr - Descriptor Address
675 /* TxDMA1 = AC0DMA */
676 void MACvSetCurrAC0DescAddrEx(void __iomem
*dwIoBase
,
677 unsigned long dwCurrDescAddr
)
680 unsigned char byData
;
681 unsigned char byOrgDMACtl
;
683 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byOrgDMACtl
);
684 if (byOrgDMACtl
& DMACTL_RUN
)
685 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
+2, DMACTL_RUN
);
687 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
688 VNSvInPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, &byData
);
689 if (!(byData
& DMACTL_RUN
))
692 if (ww
== W_MAX_TIMEOUT
)
693 pr_debug(" DBG_PORT80(0x26)\n");
694 VNSvOutPortD(dwIoBase
+ MAC_REG_AC0DMAPTR
, dwCurrDescAddr
);
695 if (byOrgDMACtl
& DMACTL_RUN
)
696 VNSvOutPortB(dwIoBase
+ MAC_REG_AC0DMACTL
, DMACTL_RUN
);
699 void MACvSetCurrTXDescAddr(int iTxType
, void __iomem
*dwIoBase
,
700 unsigned long dwCurrDescAddr
)
702 if (iTxType
== TYPE_AC0DMA
)
703 MACvSetCurrAC0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
704 else if (iTxType
== TYPE_TXDMA0
)
705 MACvSetCurrTx0DescAddrEx(dwIoBase
, dwCurrDescAddr
);
710 * Micro Second Delay via MAC
714 * dwIoBase - Base Address for MAC
715 * uDelay - Delay time (timer resolution is 4 us)
722 void MACvTimer0MicroSDelay(void __iomem
*dwIoBase
, unsigned int uDelay
)
724 unsigned char byValue
;
727 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
728 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA0
, uDelay
);
729 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, (TMCTL_TMD
| TMCTL_TE
));
730 for (ii
= 0; ii
< 66; ii
++) { /* assume max PCI clock is 66Mhz */
731 for (uu
= 0; uu
< uDelay
; uu
++) {
732 VNSvInPortB(dwIoBase
+ MAC_REG_TMCTL0
, &byValue
);
733 if ((byValue
== 0) ||
734 (byValue
& TMCTL_TSUSP
)) {
735 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
740 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL0
, 0);
745 * Micro Second One shot timer via MAC
749 * dwIoBase - Base Address for MAC
750 * uDelay - Delay time
757 void MACvOneShotTimer1MicroSec(void __iomem
*dwIoBase
, unsigned int uDelayTime
)
759 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, 0);
760 VNSvOutPortD(dwIoBase
+ MAC_REG_TMDATA1
, uDelayTime
);
761 VNSvOutPortB(dwIoBase
+ MAC_REG_TMCTL1
, (TMCTL_TMD
| TMCTL_TE
));
764 void MACvSetMISCFifo(void __iomem
*dwIoBase
, unsigned short wOffset
,
765 unsigned long dwData
)
769 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
770 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
771 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
774 bool MACbPSWakeup(void __iomem
*dwIoBase
)
776 unsigned char byOrgValue
;
779 if (MACbIsRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PS
))
783 MACvRegBitsOff(dwIoBase
, MAC_REG_PSCTL
, PSCTL_PSEN
);
785 /* Check if SyncFlushOK */
786 for (ww
= 0; ww
< W_MAX_TIMEOUT
; ww
++) {
787 VNSvInPortB(dwIoBase
+ MAC_REG_PSCTL
, &byOrgValue
);
788 if (byOrgValue
& PSCTL_WAKEDONE
)
791 if (ww
== W_MAX_TIMEOUT
) {
792 pr_debug(" DBG_PORT80(0x33)\n");
800 * Set the Key by MISCFIFO
804 * dwIoBase - Base Address for MAC
813 void MACvSetKeyEntry(void __iomem
*dwIoBase
, unsigned short wKeyCtl
,
814 unsigned int uEntryIdx
, unsigned int uKeyIdx
,
815 unsigned char *pbyAddr
, u32
*pdwKey
,
816 unsigned char byLocalID
)
818 unsigned short wOffset
;
825 pr_debug("MACvSetKeyEntry\n");
826 wOffset
= MISCFIFO_KEYETRY0
;
827 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
832 dwData
|= MAKEWORD(*(pbyAddr
+4), *(pbyAddr
+5));
833 pr_debug("1. wOffset: %d, Data: %X, KeyCtl:%X\n",
834 wOffset
, dwData
, wKeyCtl
);
836 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
837 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
838 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
842 dwData
|= *(pbyAddr
+3);
844 dwData
|= *(pbyAddr
+2);
846 dwData
|= *(pbyAddr
+1);
848 dwData
|= *(pbyAddr
+0);
849 pr_debug("2. wOffset: %d, Data: %X\n", wOffset
, dwData
);
851 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
852 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, dwData
);
853 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
856 wOffset
+= (uKeyIdx
* 4);
857 for (ii
= 0; ii
< 4; ii
++) {
858 /* always push 128 bits */
859 pr_debug("3.(%d) wOffset: %d, Data: %X\n",
860 ii
, wOffset
+ii
, *pdwKey
);
861 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
+ii
);
862 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, *pdwKey
++);
863 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);
869 * Disable the Key Entry by MISCFIFO
873 * dwIoBase - Base Address for MAC
881 void MACvDisableKeyEntry(void __iomem
*dwIoBase
, unsigned int uEntryIdx
)
883 unsigned short wOffset
;
885 wOffset
= MISCFIFO_KEYETRY0
;
886 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
888 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFNDEX
, wOffset
);
889 VNSvOutPortD(dwIoBase
+ MAC_REG_MISCFFDATA
, 0);
890 VNSvOutPortW(dwIoBase
+ MAC_REG_MISCFFCTL
, MISCFFCTL_WRITE
);