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
41 //static int msglevel =MSG_LEVEL_DEBUG;
42 static int msglevel
=MSG_LEVEL_INFO
;
46 * Write MAC Multicast Address Mask
50 * uByteidx - Index of Mask
51 * byData - Mask Value to write
58 void MACvWriteMultiAddr(struct vnt_private
*pDevice
, u32 uByteIdx
, u8 byData
)
63 CONTROLnsRequestOut(pDevice
,
65 (u16
) (MAC_REG_MAR0
+ uByteIdx
),
66 MESSAGE_REQUEST_MACREG
,
82 void MACbShutdown(struct vnt_private
*pDevice
)
84 CONTROLnsRequestOutAsyn(pDevice
,
85 MESSAGE_TYPE_MACSHUTDOWN
,
93 void MACvSetBBType(struct vnt_private
*pDevice
, u8 byType
)
98 pbyData
[1] = EnCFG_BBType_MASK
;
100 CONTROLnsRequestOut(pDevice
,
101 MESSAGE_TYPE_WRITE_MASK
,
103 MESSAGE_REQUEST_MACREG
,
111 * Disable the Key Entry by MISCFIFO
115 * dwIoBase - Base Address for MAC
123 void MACvDisableKeyEntry(struct vnt_private
*pDevice
, u32 uEntryIdx
)
127 byData
= (u8
) uEntryIdx
;
129 //issue write misc fifo command to device
130 CONTROLnsRequestOut(pDevice
,
131 MESSAGE_TYPE_CLRKEYENTRY
,
141 * Set the Key by MISCFIFO
145 * dwIoBase - Base Address for MAC
153 void MACvSetKeyEntry(struct vnt_private
*pDevice
, u16 wKeyCtl
, u32 uEntryIdx
,
154 u32 uKeyIdx
, u8
*pbyAddr
, u32
*pdwKey
)
158 u32 dwData1
, dwData2
;
162 if (pDevice
->byLocalID
<= MAC_REVISION_A1
)
163 if (pDevice
->vnt_mgmt
.byCSSPK
== KEY_CTL_CCMP
)
166 wOffset
= MISCFIFO_KEYETRY0
;
167 wOffset
+= (uEntryIdx
* MISCFIFO_KEYENTRYSIZE
);
172 dwData1
|= MAKEWORD(*(pbyAddr
+4), *(pbyAddr
+5));
174 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"1. wOffset: %d, Data: %X,"\
175 " KeyCtl:%X\n", wOffset
, dwData1
, wKeyCtl
);
178 dwData2
|= *(pbyAddr
+3);
180 dwData2
|= *(pbyAddr
+2);
182 dwData2
|= *(pbyAddr
+1);
184 dwData2
|= *(pbyAddr
+0);
186 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"2. wOffset: %d, Data: %X\n",
189 pbyKey
= (u8
*)pdwKey
;
191 pbyData
[0] = (u8
)dwData1
;
192 pbyData
[1] = (u8
)(dwData1
>>8);
193 pbyData
[2] = (u8
)(dwData1
>>16);
194 pbyData
[3] = (u8
)(dwData1
>>24);
195 pbyData
[4] = (u8
)dwData2
;
196 pbyData
[5] = (u8
)(dwData2
>>8);
197 pbyData
[6] = (u8
)(dwData2
>>16);
198 pbyData
[7] = (u8
)(dwData2
>>24);
199 for (ii
= 8; ii
< 24; ii
++)
200 pbyData
[ii
] = *pbyKey
++;
202 CONTROLnsRequestOut(pDevice
,
212 void MACvRegBitsOff(struct vnt_private
*pDevice
, u8 byRegOfs
, u8 byBits
)
219 CONTROLnsRequestOut(pDevice
,
220 MESSAGE_TYPE_WRITE_MASK
,
222 MESSAGE_REQUEST_MACREG
,
228 void MACvRegBitsOn(struct vnt_private
*pDevice
, u8 byRegOfs
, u8 byBits
)
235 CONTROLnsRequestOut(pDevice
,
236 MESSAGE_TYPE_WRITE_MASK
,
238 MESSAGE_REQUEST_MACREG
,
244 void MACvWriteWord(struct vnt_private
*pDevice
, u8 byRegOfs
, u16 wData
)
248 pbyData
[0] = (u8
)(wData
& 0xff);
249 pbyData
[1] = (u8
)(wData
>> 8);
251 CONTROLnsRequestOut(pDevice
,
254 MESSAGE_REQUEST_MACREG
,
261 void MACvWriteBSSIDAddress(struct vnt_private
*pDevice
, u8
*pbyEtherAddr
)
265 pbyData
[0] = *((u8
*)pbyEtherAddr
);
266 pbyData
[1] = *((u8
*)pbyEtherAddr
+1);
267 pbyData
[2] = *((u8
*)pbyEtherAddr
+2);
268 pbyData
[3] = *((u8
*)pbyEtherAddr
+3);
269 pbyData
[4] = *((u8
*)pbyEtherAddr
+4);
270 pbyData
[5] = *((u8
*)pbyEtherAddr
+5);
272 CONTROLnsRequestOut(pDevice
,
275 MESSAGE_REQUEST_MACREG
,
281 void MACvEnableProtectMD(struct vnt_private
*pDevice
)
285 pbyData
[0] = EnCFG_ProtectMd
;
286 pbyData
[1] = EnCFG_ProtectMd
;
288 CONTROLnsRequestOut(pDevice
,
289 MESSAGE_TYPE_WRITE_MASK
,
291 MESSAGE_REQUEST_MACREG
,
297 void MACvDisableProtectMD(struct vnt_private
*pDevice
)
302 pbyData
[1] = EnCFG_ProtectMd
;
304 CONTROLnsRequestOut(pDevice
,
305 MESSAGE_TYPE_WRITE_MASK
,
307 MESSAGE_REQUEST_MACREG
,
313 void MACvEnableBarkerPreambleMd(struct vnt_private
*pDevice
)
317 pbyData
[0] = EnCFG_BarkerPream
;
318 pbyData
[1] = EnCFG_BarkerPream
;
320 CONTROLnsRequestOut(pDevice
,
321 MESSAGE_TYPE_WRITE_MASK
,
323 MESSAGE_REQUEST_MACREG
,
329 void MACvDisableBarkerPreambleMd(struct vnt_private
*pDevice
)
334 pbyData
[1] = EnCFG_BarkerPream
;
336 CONTROLnsRequestOut(pDevice
,
337 MESSAGE_TYPE_WRITE_MASK
,
339 MESSAGE_REQUEST_MACREG
,
345 void MACvWriteBeaconInterval(struct vnt_private
*pDevice
, u16 wInterval
)
349 pbyData
[0] = (u8
)(wInterval
& 0xff);
350 pbyData
[1] = (u8
)(wInterval
>> 8);
352 CONTROLnsRequestOut(pDevice
,
355 MESSAGE_REQUEST_MACREG
,