1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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"
40
41
42
43static int msglevel =MSG_LEVEL_INFO;
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx)
72{
73 unsigned int uByteIdx;
74 BYTE byBitMask;
75 BYTE pbyData[2];
76
77
78
79 uByteIdx = byHashIdx / 8;
80
81
82 byBitMask = 1;
83 byBitMask <<= (byHashIdx % 8);
84
85
86 pbyData[0] = byBitMask;
87 pbyData[1] = byBitMask;
88
89 CONTROLnsRequestOut(pDevice,
90 MESSAGE_TYPE_WRITE_MASK,
91 (WORD) (MAC_REG_MAR0 + uByteIdx),
92 MESSAGE_REQUEST_MACREG,
93 2,
94 pbyData);
95}
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData)
114{
115 BYTE byData1;
116
117 byData1 = byData;
118 CONTROLnsRequestOut(pDevice,
119 MESSAGE_TYPE_WRITE,
120 (WORD) (MAC_REG_MAR0 + uByteIdx),
121 MESSAGE_REQUEST_MACREG,
122 1,
123 &byData1);
124}
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139BOOL MACbShutdown (PSDevice pDevice)
140{
141 CONTROLnsRequestOutAsyn(pDevice,
142 MESSAGE_TYPE_MACSHUTDOWN,
143 0,
144 0,
145 0,
146 NULL
147 );
148 return TRUE;
149}
150
151void MACvSetBBType(PSDevice pDevice,BYTE byType)
152{
153BYTE pbyData[2];
154
155
156 pbyData[0] = byType;
157 pbyData[1] = EnCFG_BBType_MASK;
158
159 CONTROLnsRequestOut(pDevice,
160 MESSAGE_TYPE_WRITE_MASK,
161 MAC_REG_ENCFG0,
162 MESSAGE_REQUEST_MACREG,
163 2,
164 pbyData
165 );
166}
167
168void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData)
169{
170BYTE pbyData[4];
171
172 if (wOffset > 273)
173 return;
174 pbyData[0] = (BYTE)dwData;
175 pbyData[1] = (BYTE)(dwData>>8);
176 pbyData[2] = (BYTE)(dwData>>16);
177 pbyData[3] = (BYTE)(dwData>>24);
178
179 CONTROLnsRequestOut(pDevice,
180 MESSAGE_TYPE_WRITE_MISCFF,
181 wOffset,
182 0,
183 4,
184 pbyData
185 );
186}
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx)
203{
204WORD wOffset;
205BYTE byData;
206
207
208 byData = (BYTE) uEntryIdx;
209
210 wOffset = MISCFIFO_KEYETRY0;
211 wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
212
213
214
215
216
217
218 CONTROLnsRequestOut(pDevice,
219 MESSAGE_TYPE_CLRKEYENTRY,
220 0,
221 0,
222 1,
223 &byData
224 );
225}
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl,
243 unsigned int uEntryIdx, unsigned int uKeyIdx,
244 PBYTE pbyAddr, PDWORD pdwKey)
245{
246PBYTE pbyKey;
247WORD wOffset;
248DWORD dwData1,dwData2;
249int ii;
250BYTE pbyData[24];
251
252 if ( pDevice->byLocalID <= MAC_REVISION_A1 ) {
253 if ( pDevice->sMgmtObj.byCSSPK == KEY_CTL_CCMP )
254 return;
255 }
256
257 wOffset = MISCFIFO_KEYETRY0;
258 wOffset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE);
259
260 dwData1 = 0;
261 dwData1 |= wKeyCtl;
262 dwData1 <<= 16;
263 dwData1 |= MAKEWORD(*(pbyAddr+4), *(pbyAddr+5));
264
265 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"1. wOffset: %d, Data: %lX, KeyCtl:%X\n", wOffset, dwData1, wKeyCtl);
266
267
268
269
270
271
272
273 dwData2 = 0;
274 dwData2 |= *(pbyAddr+3);
275 dwData2 <<= 8;
276 dwData2 |= *(pbyAddr+2);
277 dwData2 <<= 8;
278 dwData2 |= *(pbyAddr+1);
279 dwData2 <<= 8;
280 dwData2 |= *(pbyAddr+0);
281
282 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"2. wOffset: %d, Data: %lX\n", wOffset, dwData2);
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299 pbyKey = (PBYTE)pdwKey;
300
301 pbyData[0] = (BYTE)dwData1;
302 pbyData[1] = (BYTE)(dwData1>>8);
303 pbyData[2] = (BYTE)(dwData1>>16);
304 pbyData[3] = (BYTE)(dwData1>>24);
305 pbyData[4] = (BYTE)dwData2;
306 pbyData[5] = (BYTE)(dwData2>>8);
307 pbyData[6] = (BYTE)(dwData2>>16);
308 pbyData[7] = (BYTE)(dwData2>>24);
309 for (ii = 8; ii < 24; ii++)
310 pbyData[ii] = *pbyKey++;
311
312 CONTROLnsRequestOut(pDevice,
313 MESSAGE_TYPE_SETKEY,
314 wOffset,
315 (WORD)uKeyIdx,
316 24,
317 pbyData
318 );
319
320
321}
322
323
324void MACvRegBitsOff(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
325{
326BYTE pbyData[2];
327
328 pbyData[0] = 0;
329 pbyData[1] = byBits;
330
331 CONTROLnsRequestOut(pDevice,
332 MESSAGE_TYPE_WRITE_MASK,
333 byRegOfs,
334 MESSAGE_REQUEST_MACREG,
335 2,
336 pbyData
337 );
338}
339
340
341void MACvRegBitsOn(PSDevice pDevice, BYTE byRegOfs, BYTE byBits)
342{
343BYTE pbyData[2];
344
345
346 pbyData[0] = byBits;
347 pbyData[1] = byBits;
348
349 CONTROLnsRequestOut(pDevice,
350 MESSAGE_TYPE_WRITE_MASK,
351 byRegOfs,
352 MESSAGE_REQUEST_MACREG,
353 2,
354 pbyData
355 );
356}
357
358void MACvWriteWord(PSDevice pDevice, BYTE byRegOfs, WORD wData)
359{
360BYTE pbyData[2];
361
362
363 pbyData[0] = (BYTE)(wData & 0xff);
364 pbyData[1] = (BYTE)(wData >> 8);
365
366 CONTROLnsRequestOut(pDevice,
367 MESSAGE_TYPE_WRITE,
368 byRegOfs,
369 MESSAGE_REQUEST_MACREG,
370 2,
371 pbyData
372 );
373
374}
375
376void MACvWriteBSSIDAddress(PSDevice pDevice, PBYTE pbyEtherAddr)
377{
378BYTE pbyData[6];
379
380
381 pbyData[0] = *((PBYTE)pbyEtherAddr);
382 pbyData[1] = *((PBYTE)pbyEtherAddr+1);
383 pbyData[2] = *((PBYTE)pbyEtherAddr+2);
384 pbyData[3] = *((PBYTE)pbyEtherAddr+3);
385 pbyData[4] = *((PBYTE)pbyEtherAddr+4);
386 pbyData[5] = *((PBYTE)pbyEtherAddr+5);
387
388 CONTROLnsRequestOut(pDevice,
389 MESSAGE_TYPE_WRITE,
390 MAC_REG_BSSID0,
391 MESSAGE_REQUEST_MACREG,
392 6,
393 pbyData
394 );
395}
396
397void MACvEnableProtectMD(PSDevice pDevice)
398{
399BYTE pbyData[2];
400
401
402 pbyData[0] = EnCFG_ProtectMd;
403 pbyData[1] = EnCFG_ProtectMd;
404
405 CONTROLnsRequestOut(pDevice,
406 MESSAGE_TYPE_WRITE_MASK,
407 MAC_REG_ENCFG0,
408 MESSAGE_REQUEST_MACREG,
409 2,
410 pbyData
411 );
412}
413
414void MACvDisableProtectMD(PSDevice pDevice)
415{
416BYTE pbyData[2];
417
418
419 pbyData[0] = 0;
420 pbyData[1] = EnCFG_ProtectMd;
421
422 CONTROLnsRequestOut(pDevice,
423 MESSAGE_TYPE_WRITE_MASK,
424 MAC_REG_ENCFG0,
425 MESSAGE_REQUEST_MACREG,
426 2,
427 pbyData
428 );
429}
430
431void MACvEnableBarkerPreambleMd(PSDevice pDevice)
432{
433BYTE pbyData[2];
434
435
436 pbyData[0] = EnCFG_BarkerPream;
437 pbyData[1] = EnCFG_BarkerPream;
438
439 CONTROLnsRequestOut(pDevice,
440 MESSAGE_TYPE_WRITE_MASK,
441 MAC_REG_ENCFG2,
442 MESSAGE_REQUEST_MACREG,
443 2,
444 pbyData
445 );
446}
447
448void MACvDisableBarkerPreambleMd(PSDevice pDevice)
449{
450BYTE pbyData[2];
451
452
453 pbyData[0] = 0;
454 pbyData[1] = EnCFG_BarkerPream;
455
456 CONTROLnsRequestOut(pDevice,
457 MESSAGE_TYPE_WRITE_MASK,
458 MAC_REG_ENCFG2,
459 MESSAGE_REQUEST_MACREG,
460 2,
461 pbyData
462 );
463}
464
465
466void MACvWriteBeaconInterval(PSDevice pDevice, WORD wInterval)
467{
468BYTE pbyData[2];
469
470 pbyData[0] = (BYTE) (wInterval & 0xff);
471 pbyData[1] = (BYTE) (wInterval >> 8);
472
473 CONTROLnsRequestOut(pDevice,
474 MESSAGE_TYPE_WRITE,
475 MAC_REG_BI,
476 MESSAGE_REQUEST_MACREG,
477 2,
478 pbyData
479 );
480}
481