x86/xen: resume timer irqs early
[linux/fpc-iii.git] / drivers / staging / vt6656 / mac.c
blob54414ed27191710a788e3d3ce610c5718a16e483
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
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.
20 * File: mac.c
22 * Purpose: MAC routines
24 * Author: Tevin Chen
26 * Date: May 21, 1996
28 * Functions:
30 * Revision History:
33 #include "tmacro.h"
34 #include "tether.h"
35 #include "desc.h"
36 #include "mac.h"
37 #include "80211hdr.h"
38 #include "rndis.h"
39 #include "control.h"
41 //static int msglevel =MSG_LEVEL_DEBUG;
42 static int msglevel =MSG_LEVEL_INFO;
45 * Description:
46 * Write MAC Multicast Address Mask
48 * Parameters:
49 * In:
50 * uByteidx - Index of Mask
51 * byData - Mask Value to write
52 * Out:
53 * none
55 * Return Value: none
58 void MACvWriteMultiAddr(struct vnt_private *pDevice, u32 uByteIdx, u8 byData)
60 u8 byData1;
62 byData1 = byData;
63 CONTROLnsRequestOut(pDevice,
64 MESSAGE_TYPE_WRITE,
65 (u16) (MAC_REG_MAR0 + uByteIdx),
66 MESSAGE_REQUEST_MACREG,
68 &byData1);
72 * Description:
73 * Shut Down MAC
75 * Parameters:
76 * In:
77 * Out:
78 * none
82 void MACbShutdown(struct vnt_private *pDevice)
84 CONTROLnsRequestOutAsyn(pDevice,
85 MESSAGE_TYPE_MACSHUTDOWN,
89 NULL
93 void MACvSetBBType(struct vnt_private *pDevice, u8 byType)
95 u8 pbyData[2];
97 pbyData[0] = byType;
98 pbyData[1] = EnCFG_BBType_MASK;
100 CONTROLnsRequestOut(pDevice,
101 MESSAGE_TYPE_WRITE_MASK,
102 MAC_REG_ENCFG0,
103 MESSAGE_REQUEST_MACREG,
104 ARRAY_SIZE(pbyData),
105 pbyData
110 * Description:
111 * Disable the Key Entry by MISCFIFO
113 * Parameters:
114 * In:
115 * dwIoBase - Base Address for MAC
117 * Out:
118 * none
120 * Return Value: none
123 void MACvDisableKeyEntry(struct vnt_private *pDevice, u32 uEntryIdx)
125 u8 byData;
127 byData = (u8) uEntryIdx;
129 //issue write misc fifo command to device
130 CONTROLnsRequestOut(pDevice,
131 MESSAGE_TYPE_CLRKEYENTRY,
135 &byData
140 * Description:
141 * Set the Key by MISCFIFO
143 * Parameters:
144 * In:
145 * dwIoBase - Base Address for MAC
147 * Out:
148 * none
150 * Return Value: none
153 void MACvSetKeyEntry(struct vnt_private *pDevice, u16 wKeyCtl, u32 uEntryIdx,
154 u32 uKeyIdx, u8 *pbyAddr, u32 *pdwKey)
156 u8 *pbyKey;
157 u16 wOffset;
158 u32 dwData1, dwData2;
159 int ii;
160 u8 pbyData[24];
162 if (pDevice->byLocalID <= MAC_REVISION_A1)
163 if (pDevice->vnt_mgmt.byCSSPK == KEY_CTL_CCMP)
164 return;
166 wOffset = MISCFIFO_KEYETRY0;
167 wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
169 dwData1 = 0;
170 dwData1 |= wKeyCtl;
171 dwData1 <<= 16;
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);
177 dwData2 = 0;
178 dwData2 |= *(pbyAddr+3);
179 dwData2 <<= 8;
180 dwData2 |= *(pbyAddr+2);
181 dwData2 <<= 8;
182 dwData2 |= *(pbyAddr+1);
183 dwData2 <<= 8;
184 dwData2 |= *(pbyAddr+0);
186 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %X\n",
187 wOffset, dwData2);
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,
203 MESSAGE_TYPE_SETKEY,
204 wOffset,
205 (u16)uKeyIdx,
206 ARRAY_SIZE(pbyData),
207 pbyData
212 void MACvRegBitsOff(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits)
214 u8 pbyData[2];
216 pbyData[0] = 0;
217 pbyData[1] = byBits;
219 CONTROLnsRequestOut(pDevice,
220 MESSAGE_TYPE_WRITE_MASK,
221 byRegOfs,
222 MESSAGE_REQUEST_MACREG,
223 ARRAY_SIZE(pbyData),
224 pbyData
228 void MACvRegBitsOn(struct vnt_private *pDevice, u8 byRegOfs, u8 byBits)
230 u8 pbyData[2];
232 pbyData[0] = byBits;
233 pbyData[1] = byBits;
235 CONTROLnsRequestOut(pDevice,
236 MESSAGE_TYPE_WRITE_MASK,
237 byRegOfs,
238 MESSAGE_REQUEST_MACREG,
239 ARRAY_SIZE(pbyData),
240 pbyData
244 void MACvWriteWord(struct vnt_private *pDevice, u8 byRegOfs, u16 wData)
246 u8 pbyData[2];
248 pbyData[0] = (u8)(wData & 0xff);
249 pbyData[1] = (u8)(wData >> 8);
251 CONTROLnsRequestOut(pDevice,
252 MESSAGE_TYPE_WRITE,
253 byRegOfs,
254 MESSAGE_REQUEST_MACREG,
255 ARRAY_SIZE(pbyData),
256 pbyData
261 void MACvWriteBSSIDAddress(struct vnt_private *pDevice, u8 *pbyEtherAddr)
263 u8 pbyData[6];
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,
273 MESSAGE_TYPE_WRITE,
274 MAC_REG_BSSID0,
275 MESSAGE_REQUEST_MACREG,
276 ARRAY_SIZE(pbyData),
277 pbyData
281 void MACvEnableProtectMD(struct vnt_private *pDevice)
283 u8 pbyData[2];
285 pbyData[0] = EnCFG_ProtectMd;
286 pbyData[1] = EnCFG_ProtectMd;
288 CONTROLnsRequestOut(pDevice,
289 MESSAGE_TYPE_WRITE_MASK,
290 MAC_REG_ENCFG0,
291 MESSAGE_REQUEST_MACREG,
292 ARRAY_SIZE(pbyData),
293 pbyData
297 void MACvDisableProtectMD(struct vnt_private *pDevice)
299 u8 pbyData[2];
301 pbyData[0] = 0;
302 pbyData[1] = EnCFG_ProtectMd;
304 CONTROLnsRequestOut(pDevice,
305 MESSAGE_TYPE_WRITE_MASK,
306 MAC_REG_ENCFG0,
307 MESSAGE_REQUEST_MACREG,
308 ARRAY_SIZE(pbyData),
309 pbyData
313 void MACvEnableBarkerPreambleMd(struct vnt_private *pDevice)
315 u8 pbyData[2];
317 pbyData[0] = EnCFG_BarkerPream;
318 pbyData[1] = EnCFG_BarkerPream;
320 CONTROLnsRequestOut(pDevice,
321 MESSAGE_TYPE_WRITE_MASK,
322 MAC_REG_ENCFG2,
323 MESSAGE_REQUEST_MACREG,
324 ARRAY_SIZE(pbyData),
325 pbyData
329 void MACvDisableBarkerPreambleMd(struct vnt_private *pDevice)
331 u8 pbyData[2];
333 pbyData[0] = 0;
334 pbyData[1] = EnCFG_BarkerPream;
336 CONTROLnsRequestOut(pDevice,
337 MESSAGE_TYPE_WRITE_MASK,
338 MAC_REG_ENCFG2,
339 MESSAGE_REQUEST_MACREG,
340 ARRAY_SIZE(pbyData),
341 pbyData
345 void MACvWriteBeaconInterval(struct vnt_private *pDevice, u16 wInterval)
347 u8 pbyData[2];
349 pbyData[0] = (u8)(wInterval & 0xff);
350 pbyData[1] = (u8)(wInterval >> 8);
352 CONTROLnsRequestOut(pDevice,
353 MESSAGE_TYPE_WRITE,
354 MAC_REG_BI,
355 MESSAGE_REQUEST_MACREG,
356 ARRAY_SIZE(pbyData),
357 pbyData