blob: 7e40ceb7f57988cb0b3015f87c76e454e6ec2ec2 [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
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.
9 *
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.
14 *
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.
18 *
19 * File: main_usb.c
20 *
21 * Purpose: driver entry for initial, open, close, tx and rx.
22 *
23 * Author: Lyndon Chen
24 *
25 * Date: Dec 8, 2005
26 *
27 * Functions:
28 *
29 * vntwusb_found1 - module initial (insmod) driver entry
30 * device_remove1 - module remove entry
31 * device_open - allocate dma/descripter resource & initial mac/bbp function
32 * device_xmit - asynchrous data tx function
33 * device_set_multi - set mac filter
34 * device_ioctl - ioctl entry
35 * device_close - shutdown mac/bbp & free dma/descripter resource
36 * device_alloc_frag_buf - rx fragement pre-allocated function
37 * device_free_tx_bufs - free tx buffer function
38 * device_dma0_tx_80211- tx 802.11 frame via dma0
39 * device_dma0_xmit- tx PS bufferred frame via dma0
40 * device_init_registers- initial MAC & BBP & RF internal registers.
41 * device_init_rings- initial tx/rx ring buffer
42 * device_init_defrag_cb- initial & allocate de-fragement buffer.
43 * device_tx_srv- tx interrupt service function
44 *
45 * Revision History:
46 */
47#undef __NO_VERSION__
48
49#if !defined(__DEVICE_H__)
50#include "device.h"
51#endif
52#if !defined(__CARD_H__)
53#include "card.h"
54#endif
55#if !defined(__TBIT_H__)
56#include "tbit.h"
57#endif
58#if !defined(__BASEBAND_H__)
59#include "baseband.h"
60#endif
61#if !defined(__MAC_H__)
62#include "mac.h"
63#endif
64#if !defined(__TETHER_H__)
65#include "tether.h"
66#endif
67#if !defined(__WMGR_H__)
68#include "wmgr.h"
69#endif
70#if !defined(__WCTL_H__)
71#include "wctl.h"
72#endif
73#if !defined(__POWER_H__)
74#include "power.h"
75#endif
76#if !defined(__WCMD_H__)
77#include "wcmd.h"
78#endif
79#if !defined(__IOCMD_H__)
80#include "iocmd.h"
81#endif
82#if !defined(__TCRC_H__)
83#include "tcrc.h"
84#endif
85#if !defined(__RXTX_H__)
86#include "rxtx.h"
87#endif
88#if !defined(__BSSDB_H__)
89#include "bssdb.h"
90#endif
91#if !defined(__HOSTAP_H__)
92#include "hostap.h"
93#endif
94#if !defined(__WPACTL_H__)
95#include "wpactl.h"
96#endif
97#if !defined(__IOCTL_H__)
98#include "ioctl.h"
99#endif
100#if !defined(__IWCTL_H__)
101#include "iwctl.h"
102#endif
103#if !defined(__DPC_H__)
104#include "dpc.h"
105#endif
106#if !defined(__IOCMD_H__)
107#include "iocmd.h"
108#endif
109#if !defined(__DATARATE_H__)
110#include "datarate.h"
111#endif
112#if !defined(__RF_H__)
113#include "rf.h"
114#endif
115#if !defined(__FIRMWARE_H__)
116#include "firmware.h"
117#endif
118
119#if !defined(__MAC_H__)
120#include "mac.h"
121#endif
122
123#if !defined(__RNDIS_H__)
124#include "rndis.h"
125#endif
126#if !defined(__CONTROL_H__)
127#include "control.h"
128#endif
129#if !defined (_CHANNEL_H_)
130#include "channel.h"
131#endif
132#if !defined(__INT_H__)
133#include "int.h"
134#endif
135#if !defined(__IOWPA_H__)
136#include "iowpa.h"
137#endif
138
139/*--------------------- Static Definitions -------------------------*/
140//static int msglevel =MSG_LEVEL_DEBUG;
141static int msglevel =MSG_LEVEL_INFO;
142
143//
144// Define module options
145//
146
147// Version Information
148#define DRIVER_AUTHOR "VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>"
149MODULE_AUTHOR(DRIVER_AUTHOR);
150MODULE_LICENSE("GPL");
151MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
152
Forest Bond92b96792009-06-13 07:38:31 -0400153#define DEVICE_PARAM(N,D) \
154 static int N[MAX_UINTS]=OPTION_DEFAULT;\
155 module_param_array(N, int, NULL, 0);\
156 MODULE_PARM_DESC(N, D);
157
Forest Bond92b96792009-06-13 07:38:31 -0400158#define RX_DESC_MIN0 16
159#define RX_DESC_MAX0 128
160#define RX_DESC_DEF0 64
161DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
162
163
164#define TX_DESC_MIN0 16
165#define TX_DESC_MAX0 128
166#define TX_DESC_DEF0 64
167DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
168
169
170#define CHANNEL_MIN 1
171#define CHANNEL_MAX 14
172#define CHANNEL_DEF 6
173
174DEVICE_PARAM(Channel, "Channel number");
175
176
177/* PreambleType[] is the preamble length used for transmit.
178 0: indicate allows long preamble type
179 1: indicate allows short preamble type
180*/
181
182#define PREAMBLE_TYPE_DEF 1
183
184DEVICE_PARAM(PreambleType, "Preamble Type");
185
186
187#define RTS_THRESH_MIN 512
188#define RTS_THRESH_MAX 2347
189#define RTS_THRESH_DEF 2347
190
191DEVICE_PARAM(RTSThreshold, "RTS threshold");
192
193
194#define FRAG_THRESH_MIN 256
195#define FRAG_THRESH_MAX 2346
196#define FRAG_THRESH_DEF 2346
197
198DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
199
200
201#define DATA_RATE_MIN 0
202#define DATA_RATE_MAX 13
203#define DATA_RATE_DEF 13
204/* datarate[] index
205 0: indicate 1 Mbps 0x02
206 1: indicate 2 Mbps 0x04
207 2: indicate 5.5 Mbps 0x0B
208 3: indicate 11 Mbps 0x16
209 4: indicate 6 Mbps 0x0c
210 5: indicate 9 Mbps 0x12
211 6: indicate 12 Mbps 0x18
212 7: indicate 18 Mbps 0x24
213 8: indicate 24 Mbps 0x30
214 9: indicate 36 Mbps 0x48
215 10: indicate 48 Mbps 0x60
216 11: indicate 54 Mbps 0x6c
217 12: indicate 72 Mbps 0x90
218 13: indicate auto rate
219*/
220
221DEVICE_PARAM(ConnectionRate, "Connection data rate");
222
223#define OP_MODE_MAX 2
224#define OP_MODE_DEF 0
225#define OP_MODE_MIN 0
226
227DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
228
229/* OpMode[] is used for transmit.
230 0: indicate infrastruct mode used
231 1: indicate adhoc mode used
232 2: indicate AP mode used
233*/
234
235
236/* PSMode[]
237 0: indicate disable power saving mode
238 1: indicate enable power saving mode
239*/
240
241#define PS_MODE_DEF 0
242
243DEVICE_PARAM(PSMode, "Power saving mode");
244
245
246#define SHORT_RETRY_MIN 0
247#define SHORT_RETRY_MAX 31
248#define SHORT_RETRY_DEF 8
249
250
251DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
252
253#define LONG_RETRY_MIN 0
254#define LONG_RETRY_MAX 15
255#define LONG_RETRY_DEF 4
256
257
258DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
259
260
261/* BasebandType[] baseband type selected
262 0: indicate 802.11a type
263 1: indicate 802.11b type
264 2: indicate 802.11g type
265*/
266#define BBP_TYPE_MIN 0
267#define BBP_TYPE_MAX 2
268#define BBP_TYPE_DEF 2
269
270DEVICE_PARAM(BasebandType, "baseband type");
271
272
273
274/* 80211hEnable[]
275 0: indicate disable 802.11h
276 1: indicate enable 802.11h
277*/
278
279#define X80211h_MODE_DEF 0
280
281DEVICE_PARAM(b80211hEnable, "802.11h mode");
282
283
284//
285// Static vars definitions
286//
287
288
289
290static struct usb_device_id vntwusb_table[] = {
291 {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
292 {}
293};
294
295
296
Forest Bond92b96792009-06-13 07:38:31 -0400297// Frequency list (map channels to frequencies)
298/*
299static const long frequency_list[] = {
300 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
301 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
302 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
303 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
304 5700, 5745, 5765, 5785, 5805, 5825
305 };
306
307
308#ifndef IW_ENCODE_NOKEY
309#define IW_ENCODE_NOKEY 0x0800
310#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN)
311#endif
312
Forest Bond92b96792009-06-13 07:38:31 -0400313static const struct iw_handler_def iwctl_handler_def;
Forest Bond92b96792009-06-13 07:38:31 -0400314*/
315
Forest Bond92b96792009-06-13 07:38:31 -0400316
317
318/*--------------------- Static Functions --------------------------*/
Forest Bond92b96792009-06-13 07:38:31 -0400319static int vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id);
320static void vntwusb_disconnect(struct usb_interface *intf);
321#ifdef CONFIG_PM /* Minimal support for suspend and resume */
322static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message);
323static int vntwusb_resume(struct usb_interface *intf);
324#endif
Forest Bond92b96792009-06-13 07:38:31 -0400325static struct net_device_stats *device_get_stats(struct net_device *dev);
326static int device_open(struct net_device *dev);
327static int device_xmit(struct sk_buff *skb, struct net_device *dev);
328static void device_set_multi(struct net_device *dev);
329static int device_close(struct net_device *dev);
330static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
331
332static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType);
333static BOOL device_init_defrag_cb(PSDevice pDevice);
334static void device_init_diversity_timer(PSDevice pDevice);
335static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
336
337static int ethtool_ioctl(struct net_device *dev, void *useraddr);
338static void device_free_tx_bufs(PSDevice pDevice);
339static void device_free_rx_bufs(PSDevice pDevice);
340static void device_free_int_bufs(PSDevice pDevice);
341static void device_free_frag_bufs(PSDevice pDevice);
342static BOOL device_alloc_bufs(PSDevice pDevice);
343
344static int Read_config_file(PSDevice pDevice);
345static UCHAR *Config_FileOperation(PSDevice pDevice);
346static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source);
347
348//2008-0714<Add>by Mike Liu
349static BOOL device_release_WPADEV(PSDevice pDevice);
350
Forest Bond92b96792009-06-13 07:38:31 -0400351static void usb_device_reset(PSDevice pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400352
353
354
355/*--------------------- Export Variables --------------------------*/
356
357/*--------------------- Export Functions --------------------------*/
358
359
360static void
361device_set_options(PSDevice pDevice) {
362
363 BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
364 BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
365 BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
366
367
368 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
369 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
370 memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
371
372 pDevice->cbTD = TX_DESC_DEF0;
373 pDevice->cbRD = RX_DESC_DEF0;
374 pDevice->uChannel = CHANNEL_DEF;
375 pDevice->wRTSThreshold = RTS_THRESH_DEF;
376 pDevice->wFragmentationThreshold = FRAG_THRESH_DEF;
377 pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
378 pDevice->byLongRetryLimit = LONG_RETRY_DEF;
379 pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
380 pDevice->byShortPreamble = PREAMBLE_TYPE_DEF;
381 pDevice->ePSMode = PS_MODE_DEF;
382 pDevice->b11hEnable = X80211h_MODE_DEF;
383 pDevice->eOPMode = OP_MODE_DEF;
384 pDevice->uConnectionRate = DATA_RATE_DEF;
385 if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = TRUE;
386 pDevice->byBBType = BBP_TYPE_DEF;
387 pDevice->byPacketType = pDevice->byBBType;
388 pDevice->byAutoFBCtrl = AUTO_FB_0;
389 pDevice->bUpdateBBVGA = TRUE;
390 pDevice->byFOETuning = 0;
391 pDevice->byAutoPwrTunning = 0;
392 pDevice->wCTSDuration = 0;
393 pDevice->byPreambleType = 0;
394 pDevice->bExistSWNetAddr = FALSE;
395// pDevice->bDiversityRegCtlON = TRUE;
396 pDevice->bDiversityRegCtlON = FALSE;
397}
398
399
400static VOID device_init_diversity_timer(PSDevice pDevice) {
401
402 init_timer(&pDevice->TimerSQ3Tmax1);
403 pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice;
404 pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
405 pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
406
407 init_timer(&pDevice->TimerSQ3Tmax2);
408 pDevice->TimerSQ3Tmax2.data = (ULONG)pDevice;
409 pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
410 pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
411
412 init_timer(&pDevice->TimerSQ3Tmax3);
413 pDevice->TimerSQ3Tmax3.data = (ULONG)pDevice;
414 pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack;
415 pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
416
417 return;
418}
419
420
421//
422// Initialiation of MAC & BBP registers
423//
424
425static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType)
426{
427 BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
428 BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
429 BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
430 BYTE byAntenna;
431 UINT ii;
432 CMD_CARD_INIT sInitCmd;
433 NTSTATUS ntStatus = STATUS_SUCCESS;
434 RSP_CARD_INIT sInitRsp;
435 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
436 BYTE byTmp;
437 BYTE byCalibTXIQ = 0;
438 BYTE byCalibTXDC = 0;
439 BYTE byCalibRXIQ = 0;
440
441 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
442 spin_lock_irq(&pDevice->lock);
443 if (InitType == DEVICE_INIT_COLD) {
444 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN);
445 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN);
446 memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN);
447
448 if ( !FIRMWAREbCheckVersion(pDevice) ) {
449 if (FIRMWAREbDownload(pDevice) == TRUE) {
450 if (FIRMWAREbBrach2Sram(pDevice) == FALSE) {
451 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbBrach2Sram fail \n");
452 spin_unlock_irq(&pDevice->lock);
453 return FALSE;
454 }
455 } else {
456
457 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbDownload fail \n");
458 spin_unlock_irq(&pDevice->lock);
459 return FALSE;
460 }
461 }
462
463 if ( !BBbVT3184Init(pDevice) ) {
464 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail \n");
465 spin_unlock_irq(&pDevice->lock);
466 return FALSE;
467 }
468 }
469
470 sInitCmd.byInitClass = (BYTE)InitType;
471 sInitCmd.bExistSWNetAddr = (BYTE) pDevice->bExistSWNetAddr;
472 for(ii=0;ii<6;ii++)
473 sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii];
474 sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit;
475 sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit;
476
477 //issue Card_init command to device
478 ntStatus = CONTROLnsRequestOut(pDevice,
479 MESSAGE_TYPE_CARDINIT,
480 0,
481 0,
482 sizeof(CMD_CARD_INIT),
483 (PBYTE) &(sInitCmd));
484
485 if ( ntStatus != STATUS_SUCCESS ) {
486 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail \n");
487 spin_unlock_irq(&pDevice->lock);
488 return FALSE;
489 }
490 if (InitType == DEVICE_INIT_COLD) {
491
492 ntStatus = CONTROLnsRequestIn(pDevice,MESSAGE_TYPE_INIT_RSP,0,0,sizeof(RSP_CARD_INIT), (PBYTE) &(sInitRsp));
493
494 if (ntStatus != STATUS_SUCCESS) {
495 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n");
496 spin_unlock_irq(&pDevice->lock);
497 return FALSE;
498 }
499
500 //Local ID for AES functions
501 ntStatus = CONTROLnsRequestIn(pDevice,
502 MESSAGE_TYPE_READ,
503 MAC_REG_LOCALID,
504 MESSAGE_REQUEST_MACREG,
505 1,
506 &pDevice->byLocalID);
507
508 if ( ntStatus != STATUS_SUCCESS ) {
509 spin_unlock_irq(&pDevice->lock);
510 return FALSE;
511 }
512
513 // Do MACbSoftwareReset in MACvInitialize
514 // force CCK
515 pDevice->bCCK = TRUE;
516 pDevice->bProtectMode = FALSE; //Only used in 11g type, sync with ERP IE
517 pDevice->bNonERPPresent = FALSE;
518 pDevice->bBarkerPreambleMd = FALSE;
519 if ( pDevice->bFixRate ) {
520 pDevice->wCurrentRate = (WORD) pDevice->uConnectionRate;
521 } else {
522 if ( pDevice->byBBType == BB_TYPE_11B )
523 pDevice->wCurrentRate = RATE_11M;
524 else
525 pDevice->wCurrentRate = RATE_54M;
526 }
527
528 CHvInitChannelTable(pDevice);
529
530 pDevice->byTopOFDMBasicRate = RATE_24M;
531 pDevice->byTopCCKBasicRate = RATE_1M;
532 pDevice->byRevId = 0; //Target to IF pin while programming to RF chip.
533 pDevice->byCurPwr = 0xFF;
534
535 pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
536 pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
537 // Load power Table
538 for (ii=0;ii<14;ii++) {
539 pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
540 if (pDevice->abyCCKPwrTbl[ii] == 0)
541 pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
542 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
543 if (pDevice->abyOFDMPwrTbl[ii] == 0)
544 pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
545 }
546
547 //original zonetype is USA,but customize zonetype is europe,
548 // then need recover 12,13 ,14 channel with 11 channel
549 if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
550 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&&
551 (pDevice->byOriginalZonetype == ZoneType_USA)) {
552 for(ii=11;ii<14;ii++) {
553 pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
554 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
555 }
556 }
557
558 //{{ RobertYu: 20041124
559 pDevice->byOFDMPwrA = 0x34; // same as RFbMA2829SelectChannel
560 // Load OFDM A Power Table
561 for (ii=0;ii<CB_MAX_CHANNEL_5G;ii++) { //RobertYu:20041224, bug using CB_MAX_CHANNEL
562 pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
563 if (pDevice->abyOFDMAPwrTbl[ii] == 0)
564 pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
565 }
566 //}} RobertYu
567
568 byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
569 if (byAntenna & EEP_ANTINV)
570 pDevice->bTxRxAntInv = TRUE;
571 else
572 pDevice->bTxRxAntInv = FALSE;
573
574 byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
575
576 if (byAntenna == 0) // if not set default is All
577 byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
578
579 if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
580 pDevice->byAntennaCount = 2;
581 pDevice->byTxAntennaMode = ANT_B;
582 pDevice->dwTxAntennaSel = 1;
583 pDevice->dwRxAntennaSel = 1;
584 if (pDevice->bTxRxAntInv == TRUE)
585 pDevice->byRxAntennaMode = ANT_A;
586 else
587 pDevice->byRxAntennaMode = ANT_B;
588
589 if (pDevice->bDiversityRegCtlON)
590 pDevice->bDiversityEnable = TRUE;
591 else
592 pDevice->bDiversityEnable = FALSE;
593 } else {
594 pDevice->bDiversityEnable = FALSE;
595 pDevice->byAntennaCount = 1;
596 pDevice->dwTxAntennaSel = 0;
597 pDevice->dwRxAntennaSel = 0;
598 if (byAntenna & EEP_ANTENNA_AUX) {
599 pDevice->byTxAntennaMode = ANT_A;
600 if (pDevice->bTxRxAntInv == TRUE)
601 pDevice->byRxAntennaMode = ANT_B;
602 else
603 pDevice->byRxAntennaMode = ANT_A;
604 } else {
605 pDevice->byTxAntennaMode = ANT_B;
606 if (pDevice->bTxRxAntInv == TRUE)
607 pDevice->byRxAntennaMode = ANT_A;
608 else
609 pDevice->byRxAntennaMode = ANT_B;
610 }
611 }
612 pDevice->ulDiversityNValue = 100*255;
613 pDevice->ulDiversityMValue = 100*16;
614 pDevice->byTMax = 1;
615 pDevice->byTMax2 = 4;
616 pDevice->ulSQ3TH = 0;
617 pDevice->byTMax3 = 64;
618 // -----------------------------------------------------------------
619
620 //Get Auto Fall Back Type
621 pDevice->byAutoFBCtrl = AUTO_FB_0;
622
623 // Set SCAN Time
624 pDevice->uScanTime = WLAN_SCAN_MINITIME;
625
626 // default Auto Mode
627 //pDevice->NetworkType = Ndis802_11Automode;
628 pDevice->eConfigPHYMode = PHY_TYPE_AUTO;
629 pDevice->byBBType = BB_TYPE_11G;
630
631 // initialize BBP registers
632 pDevice->ulTxPower = 25;
633
634 // Get Channel range
635 pDevice->byMinChannel = 1;
636 pDevice->byMaxChannel = CB_MAX_CHANNEL;
637
638 // Get RFType
639 pDevice->byRFType = sInitRsp.byRFType;
640
641 if ((pDevice->byRFType & RF_EMU) != 0) {
642 // force change RevID for VT3253 emu
643 pDevice->byRevId = 0x80;
644 }
645
646 // Load EEPROM calibrated vt3266 parameters
647 if (pDevice->byRFType == RF_VT3226D0) {
648 if((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
649 (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
650 byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
651 byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
652 byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
653 if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) {
654 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x03); // CR255, Set BB to support TX/RX IQ and DC compensation Mode
655 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFB, byCalibTXIQ); // CR251, TX I/Q Imbalance Calibration
656 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFC, byCalibTXDC); // CR252, TX DC-Offset Calibration
657 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFD, byCalibRXIQ); // CR253, RX I/Q Imbalance Calibration
658 } else {
659 // turn off BB Calibration compensation
660 ControlvWriteByte(pDevice, MESSAGE_REQUEST_BBREG, 0xFF, 0x0); // CR255
661 }
662 }
663 }
664 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
665 pMgmt->uCurrChannel = pDevice->uChannel;
666 pMgmt->uIBSSChannel = pDevice->uChannel;
667 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
668
669 // get Permanent network address
670 MEMvCopy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6)
671 MEMvCopy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, U_ETHER_ADDR_LEN);
672
673 // if exist SW network address, use SW network address.
674
675 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %02x-%02x-%02x=%02x-%02x-%02x\n",
676 pDevice->abyCurrentNetAddr[0],
677 pDevice->abyCurrentNetAddr[1],
678 pDevice->abyCurrentNetAddr[2],
679 pDevice->abyCurrentNetAddr[3],
680 pDevice->abyCurrentNetAddr[4],
681 pDevice->abyCurrentNetAddr[5]);
682 }
683
684
685
686 // Set BB and packet type at the same time.
687 // Set Short Slot Time, xIFS, and RSPINF.
688 if (pDevice->byBBType == BB_TYPE_11A) {
689 CARDbAddBasicRate(pDevice, RATE_6M);
690 pDevice->bShortSlotTime = TRUE;
691 } else {
692 CARDbAddBasicRate(pDevice, RATE_1M);
693 pDevice->bShortSlotTime = FALSE;
694 }
695 BBvSetShortSlotTime(pDevice);
696 CARDvSetBSSMode(pDevice);
697
698 if (pDevice->bUpdateBBVGA) {
699 pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
700 pDevice->byBBVGANew = pDevice->byBBVGACurrent;
701 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
702 }
703
704 pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
705 pDevice->bHWRadioOff = FALSE;
706 if ( (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0 ) {
707 ntStatus = CONTROLnsRequestIn(pDevice,
708 MESSAGE_TYPE_READ,
709 MAC_REG_GPIOCTL1,
710 MESSAGE_REQUEST_MACREG,
711 1,
712 &byTmp);
713
714 if ( ntStatus != STATUS_SUCCESS ) {
715 spin_unlock_irq(&pDevice->lock);
716 return FALSE;
717 }
718 if ( (byTmp & GPIO3_DATA) == 0 ) {
719 pDevice->bHWRadioOff = TRUE;
720 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
721 } else {
722 MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
723 pDevice->bHWRadioOff = FALSE;
724 }
725
726 } //EEP_RADIOCTL_ENABLE
727
728 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_TMLEN,0x38);
729 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
730 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL0,0x01);
731
732 if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
733 CARDbRadioPowerOff(pDevice);
734 } else {
735 CARDbRadioPowerOn(pDevice);
736 }
737
738 spin_unlock_irq(&pDevice->lock);
739 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
740 return TRUE;
741}
742
743static BOOL device_release_WPADEV(PSDevice pDevice)
744{
745 viawget_wpa_header *wpahdr;
746 int ii=0;
747 // wait_queue_head_t Set_wait;
748 //send device close to wpa_supplicnat layer
749 if (pDevice->bWPADEVUp==TRUE) {
750 wpahdr = (viawget_wpa_header *)pDevice->skb->data;
751 wpahdr->type = VIAWGET_DEVICECLOSE_MSG;
752 wpahdr->resp_ie_len = 0;
753 wpahdr->req_ie_len = 0;
754 skb_put(pDevice->skb, sizeof(viawget_wpa_header));
755 pDevice->skb->dev = pDevice->wpadev;
Forest Bond92b96792009-06-13 07:38:31 -0400756 pDevice->skb->mac_header = pDevice->skb->data;
Forest Bond92b96792009-06-13 07:38:31 -0400757 pDevice->skb->pkt_type = PACKET_HOST;
758 pDevice->skb->protocol = htons(ETH_P_802_2);
759 memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
760 netif_rx(pDevice->skb);
761 pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
762
763 //wait release WPADEV
764 // init_waitqueue_head(&Set_wait);
765 // wait_event_timeout(Set_wait, ((pDevice->wpadev==NULL)&&(pDevice->skb == NULL)),5*HZ); //1s wait
766 while(pDevice->bWPADEVUp==TRUE) {
767 set_current_state(TASK_UNINTERRUPTIBLE);
768 schedule_timeout (HZ/20); //wait 50ms
769 ii++;
770 if(ii>20)
771 break;
772 }
773 };
774 return TRUE;
775}
776
777#ifdef CONFIG_PM /* Minimal support for suspend and resume */
778static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message)
779{
780 PSDevice pDevice = usb_get_intfdata(intf);
781 struct net_device *dev = pDevice->dev;
782
783 printk("VNTWUSB Suspend Start======>\n");
784if(dev != NULL) {
785 if(pDevice->flags & DEVICE_FLAGS_OPENED)
786 device_close(dev);
787}
788
789 usb_put_dev(interface_to_usbdev(intf));
790 return 0;
791}
792
793static int vntwusb_resume(struct usb_interface *intf)
794{
795 PSDevice pDevice = usb_get_intfdata(intf);
796 struct net_device *dev = pDevice->dev;
797
798 printk("VNTWUSB Resume Start======>\n");
799 if(dev != NULL) {
800 usb_get_dev(interface_to_usbdev(intf));
801 if(!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
802 if(device_open(dev)!=0)
803 printk("VNTWUSB Resume Start======>open fail\n");
804 }
805 }
806 return 0;
807}
808#endif
809
Forest Bonddd8db702009-06-13 07:38:54 -0400810
811static const struct net_device_ops device_netdev_ops = {
812 .ndo_open = device_open,
813 .ndo_stop = device_close,
814 .ndo_do_ioctl = device_ioctl,
815 .ndo_get_stats = device_get_stats,
816 .ndo_start_xmit = device_xmit,
817 .ndo_set_multicast_list = device_set_multi,
818};
819
820
Forest Bond92b96792009-06-13 07:38:31 -0400821static int
822vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id)
Forest Bond92b96792009-06-13 07:38:31 -0400823{
Forest Bond92b96792009-06-13 07:38:31 -0400824 BYTE fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address
Forest Bond92b96792009-06-13 07:38:31 -0400825 struct usb_device *udev = interface_to_usbdev(intf);
826 int rc = 0;
Forest Bond92b96792009-06-13 07:38:31 -0400827 struct net_device *netdev = NULL;
828 PSDevice pDevice = NULL;
829
830
831 printk(KERN_NOTICE "%s Ver. %s\n",DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
832 printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
833
Forest Bond92b96792009-06-13 07:38:31 -0400834 udev = usb_get_dev(udev);
Forest Bond92b96792009-06-13 07:38:31 -0400835
Forest Bond1e28efa2009-06-13 07:38:50 -0400836 netdev = alloc_etherdev(sizeof(DEVICE_INFO));
Forest Bond92b96792009-06-13 07:38:31 -0400837
838 if (netdev == NULL) {
839 printk(KERN_ERR DEVICE_NAME ": allocate net device failed \n");
840 kfree(pDevice);
841 goto err_nomem;
842 }
Forest Bond1e28efa2009-06-13 07:38:50 -0400843
844 pDevice = netdev_priv(netdev);
845 memset(pDevice, 0, sizeof(DEVICE_INFO));
846
Forest Bond92b96792009-06-13 07:38:31 -0400847 pDevice->dev = netdev;
848 pDevice->usb = udev;
849
Forest Bond92b96792009-06-13 07:38:31 -0400850 // Set initial settings
851 device_set_options(pDevice);
852 spin_lock_init(&pDevice->lock);
853
854 pDevice->tx_80211 = device_dma0_tx_80211;
855 pDevice->sMgmtObj.pAdapter = (PVOID)pDevice;
856
Forest Bonddd8db702009-06-13 07:38:54 -0400857 netdev->netdev_ops = &device_netdev_ops;
858
Forest Bond92b96792009-06-13 07:38:31 -0400859 netdev->wireless_handlers = (struct iw_handler_def *)&iwctl_handler_def;
Forest Bond92b96792009-06-13 07:38:31 -0400860
Forest Bond92b96792009-06-13 07:38:31 -0400861 //2008-0623-01<Remark>by MikeLiu
862 //2007-0821-01<Add>by MikeLiu
Forest Bond92b96792009-06-13 07:38:31 -0400863 usb_set_intfdata(intf, pDevice);
864 SET_NETDEV_DEV(netdev, &intf->dev);
Forest Bond92b96792009-06-13 07:38:31 -0400865 memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address
Forest Bond92b96792009-06-13 07:38:31 -0400866 rc = register_netdev(netdev);
867 if (rc != 0) {
868 printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
869 free_netdev(netdev);
870 kfree(pDevice);
871 return -ENODEV;
872 }
873 //2008-0623-02<Remark>by MikeLiu
874 //2007-0821-01<Add>by MikeLiu
875 //#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)
876 //usb_set_intfdata(intf, pDevice);
877 //SET_NETDEV_DEV(netdev, &intf->dev);
878 //#endif
879
880//2008-07-21-01<Add>by MikeLiu
881//register wpadev
miaofngdda79402009-07-15 10:33:35 -0400882#if 0
Forest Bond92b96792009-06-13 07:38:31 -0400883 if(wpa_set_wpadev(pDevice, 1)!=0) {
884 printk("Fail to Register WPADEV?\n");
885 unregister_netdev(pDevice->dev);
886 free_netdev(netdev);
887 kfree(pDevice);
888 }
miaofngdda79402009-07-15 10:33:35 -0400889#endif
Forest Bond92b96792009-06-13 07:38:31 -0400890 usb_device_reset(pDevice);
Forest Bond92b96792009-06-13 07:38:31 -0400891
892#ifdef SndEvt_ToAPI
893{
894 union iwreq_data wrqu;
895 memset(&wrqu, 0, sizeof(wrqu));
896 wrqu.data.flags = RT_INSMOD_EVENT_FLAG;
897 wrqu.data.length =IFNAMSIZ;
898 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, pDevice->dev->name);
899}
900#endif
901
902 return 0;
Forest Bond92b96792009-06-13 07:38:31 -0400903
904
905err_nomem:
Forest Bond92b96792009-06-13 07:38:31 -0400906 //2008-0922-01<Add>by MikeLiu, decrease usb counter.
907 usb_put_dev(udev);
908
909 return -ENOMEM;
Forest Bond92b96792009-06-13 07:38:31 -0400910}
911
912
913static VOID device_free_tx_bufs(PSDevice pDevice) {
914 PUSB_SEND_CONTEXT pTxContext;
915 int ii;
916
917 for (ii = 0; ii < pDevice->cbTD; ii++) {
918
919 pTxContext = pDevice->apTD[ii];
920 //de-allocate URBs
921 if (pTxContext->pUrb) {
922 vntwusb_unlink_urb(pTxContext->pUrb);
923 usb_free_urb(pTxContext->pUrb);
924 }
925 if (pTxContext)
926 kfree(pTxContext);
927 }
928 return;
929}
930
931
932static VOID device_free_rx_bufs(PSDevice pDevice) {
933 PRCB pRCB;
934 int ii;
935
936 for (ii = 0; ii < pDevice->cbRD; ii++) {
937
938 pRCB = pDevice->apRCB[ii];
939 //de-allocate URBs
940 if (pRCB->pUrb) {
941 vntwusb_unlink_urb(pRCB->pUrb);
942 usb_free_urb(pRCB->pUrb);
943 }
944 //de-allocate skb
945 if (pRCB->skb)
946 dev_kfree_skb(pRCB->skb);
947 }
948 if (pDevice->pRCBMem)
949 kfree(pDevice->pRCBMem);
950
951 return;
952}
953
954//2007-1107-02<Add>by MikeLiu
Forest Bond92b96792009-06-13 07:38:31 -0400955static void usb_device_reset(PSDevice pDevice)
956{
957 int status;
958 status = usb_reset_device(pDevice->usb);
959 if (status)
960 printk("usb_device_reset fail status=%d\n",status);
961 return ;
962}
Forest Bond92b96792009-06-13 07:38:31 -0400963
964static VOID device_free_int_bufs(PSDevice pDevice) {
965
966 if (pDevice->intBuf.pDataBuf != NULL)
967 kfree(pDevice->intBuf.pDataBuf);
968 return;
969}
970
971
972static BOOL device_alloc_bufs(PSDevice pDevice) {
973
974 PUSB_SEND_CONTEXT pTxContext;
975 PRCB pRCB;
976 int ii;
977
978
979 for (ii = 0; ii < pDevice->cbTD; ii++) {
980
981 pTxContext = kmalloc(sizeof(USB_SEND_CONTEXT), GFP_KERNEL);
982 if (pTxContext == NULL) {
983 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name);
984 goto free_tx;
985 }
986 pDevice->apTD[ii] = pTxContext;
987 pTxContext->pDevice = (PVOID) pDevice;
988 //allocate URBs
989 pTxContext->pUrb = vntwusb_alloc_urb(0);;
990 if (pTxContext->pUrb == NULL) {
991 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n");
992 goto free_tx;
993 }
994 pTxContext->bBoolInUse = FALSE;
995 }
996
997 // allocate rcb mem
998 pDevice->pRCBMem = kmalloc((sizeof(RCB) * pDevice->cbRD), GFP_KERNEL);
999 if (pDevice->pRCBMem == NULL) {
1000 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name);
1001 goto free_tx;
1002 }
1003
1004
1005 pDevice->FirstRecvFreeList = NULL;
1006 pDevice->LastRecvFreeList = NULL;
1007 pDevice->FirstRecvMngList = NULL;
1008 pDevice->LastRecvMngList = NULL;
1009 pDevice->NumRecvFreeList = 0;
1010 memset(pDevice->pRCBMem, 0, (sizeof(RCB) * pDevice->cbRD));
1011 pRCB = (PRCB) pDevice->pRCBMem;
1012
1013 for (ii = 0; ii < pDevice->cbRD; ii++) {
1014
1015 pDevice->apRCB[ii] = pRCB;
1016 pRCB->pDevice = (PVOID) pDevice;
1017 //allocate URBs
1018 pRCB->pUrb = vntwusb_alloc_urb(0);
1019
1020 if (pRCB->pUrb == NULL) {
1021 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n");
1022 goto free_rx_tx;
1023 }
1024 pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
1025 if (pRCB->skb == NULL) {
1026 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n");
1027 goto free_rx_tx;
1028 }
1029 pRCB->skb->dev = pDevice->dev;
1030 pRCB->bBoolInUse = FALSE;
1031 EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
1032 pDevice->NumRecvFreeList++;
1033 pRCB++;
1034 }
1035
1036
1037 pDevice->pControlURB = vntwusb_alloc_urb(0);
1038 if (pDevice->pControlURB == NULL) {
1039 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc control urb\n");
1040 goto free_rx_tx;
1041 }
1042
1043 pDevice->pInterruptURB = vntwusb_alloc_urb(0);
1044 if (pDevice->pInterruptURB == NULL) {
1045 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
1046 vntwusb_unlink_urb(pDevice->pControlURB);
1047 usb_free_urb(pDevice->pControlURB);
1048 goto free_rx_tx;
1049 }
1050
1051 pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
1052 if (pDevice->intBuf.pDataBuf == NULL) {
1053 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n");
1054 vntwusb_unlink_urb(pDevice->pControlURB);
1055 vntwusb_unlink_urb(pDevice->pInterruptURB);
1056 usb_free_urb(pDevice->pControlURB);
1057 usb_free_urb(pDevice->pInterruptURB);
1058 goto free_rx_tx;
1059 }
1060
1061 return TRUE;
1062
1063free_rx_tx:
1064 device_free_rx_bufs(pDevice);
1065
1066free_tx:
1067 device_free_tx_bufs(pDevice);
1068
1069 return FALSE;
1070}
1071
1072
1073
1074
1075static BOOL device_init_defrag_cb(PSDevice pDevice) {
1076 int i;
1077 PSDeFragControlBlock pDeF;
1078
1079 /* Init the fragment ctl entries */
1080 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
1081 pDeF = &(pDevice->sRxDFCB[i]);
1082 if (!device_alloc_frag_buf(pDevice, pDeF)) {
1083 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
1084 pDevice->dev->name);
1085 goto free_frag;
1086 };
1087 }
1088 pDevice->cbDFCB = CB_MAX_RX_FRAG;
1089 pDevice->cbFreeDFCB = pDevice->cbDFCB;
1090 return TRUE;
1091
1092free_frag:
1093 device_free_frag_bufs(pDevice);
1094 return FALSE;
1095}
1096
1097
1098
1099static void device_free_frag_bufs(PSDevice pDevice) {
1100 PSDeFragControlBlock pDeF;
1101 int i;
1102
1103 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
1104
1105 pDeF = &(pDevice->sRxDFCB[i]);
1106
1107 if (pDeF->skb)
1108 dev_kfree_skb(pDeF->skb);
1109 }
1110}
1111
1112
1113
1114BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) {
1115
1116 pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
1117 if (pDeF->skb == NULL)
1118 return FALSE;
1119 ASSERT(pDeF->skb);
1120 pDeF->skb->dev = pDevice->dev;
1121
1122 return TRUE;
1123}
1124
1125
1126/*-----------------------------------------------------------------*/
1127
1128static int device_open(struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001129 PSDevice pDevice=(PSDevice) netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001130
1131#ifdef WPA_SM_Transtatus
1132 extern SWPAResult wpa_Result;
1133 memset(wpa_Result.ifname,0,sizeof(wpa_Result.ifname));
1134 wpa_Result.proto = 0;
1135 wpa_Result.key_mgmt = 0;
1136 wpa_Result.eap_type = 0;
1137 wpa_Result.authenticated = FALSE;
1138 pDevice->fWPA_Authened = FALSE;
1139#endif
1140
1141 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n");
1142
1143
1144 pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
1145
1146 if (device_alloc_bufs(pDevice) == FALSE) {
1147 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n");
1148 return -ENOMEM;
1149 }
1150
1151 if (device_init_defrag_cb(pDevice)== FALSE) {
1152 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragement cb fail \n");
1153 goto free_rx_tx;
1154 }
1155
1156 MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
1157 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
1158 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
1159 MP_SET_FLAG(pDevice, fMP_POST_READS);
1160 MP_SET_FLAG(pDevice, fMP_POST_WRITES);
1161
1162 //read config file
1163 Read_config_file(pDevice);
1164
1165 if (device_init_registers(pDevice, DEVICE_INIT_COLD) == FALSE) {
1166 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n");
1167 goto free_all;
1168 }
1169
1170 device_set_multi(pDevice->dev);
1171 // Init for Key Management
1172
1173 KeyvInitTable(pDevice,&pDevice->sKey);
1174 memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
1175 memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN);
1176 pDevice->bStopTx0Pkt = FALSE;
1177 pDevice->bStopDataPkt = FALSE;
1178 pDevice->bRoaming = FALSE; //DavidWang
1179 pDevice->bIsRoaming = FALSE;//DavidWang
1180 pDevice->bEnableRoaming = FALSE;
1181 if (pDevice->bDiversityRegCtlON) {
1182 device_init_diversity_timer(pDevice);
1183 }
1184
1185 vMgrObjectInit(pDevice);
1186 tasklet_init(&pDevice->RxMngWorkItem, (void *)RXvMngWorkItem, (unsigned long)pDevice);
1187 tasklet_init(&pDevice->ReadWorkItem, (void *)RXvWorkItem, (unsigned long)pDevice);
1188 tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice);
1189 add_timer(&(pDevice->sMgmtObj.sTimerSecondCallback));
Forest Bond92b96792009-06-13 07:38:31 -04001190 pDevice->int_interval = 100; //Max 100 microframes.
Forest Bond92b96792009-06-13 07:38:31 -04001191 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1192
1193 pDevice->bIsRxWorkItemQueued = TRUE;
1194 pDevice->fKillEventPollingThread = FALSE;
1195 pDevice->bEventAvailable = FALSE;
1196
1197 pDevice->bWPADEVUp = FALSE;
1198#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1199 pDevice->bwextstep0 = FALSE;
1200 pDevice->bwextstep1 = FALSE;
1201 pDevice->bwextstep2 = FALSE;
1202 pDevice->bwextstep3 = FALSE;
1203 pDevice->bWPASuppWextEnabled = FALSE;
1204#endif
1205 pDevice->byReAssocCount = 0;
1206
1207 RXvWorkItem(pDevice);
1208 INTvWorkItem(pDevice);
1209
1210 // Patch: if WEP key already set by iwconfig but device not yet open
1211 if ((pDevice->bEncryptionEnable == TRUE) && (pDevice->bTransmitKey == TRUE)) {
1212 spin_lock_irq(&pDevice->lock);
1213 KeybSetDefaultKey( pDevice,
1214 &(pDevice->sKey),
1215 pDevice->byKeyIndex | (1 << 31),
1216 pDevice->uKeyLength,
1217 NULL,
1218 pDevice->abyKey,
1219 KEY_CTL_WEP
1220 );
1221 spin_unlock_irq(&pDevice->lock);
1222 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1223 }
1224
1225 if (pDevice->sMgmtObj.eConfigMode == WMAC_CONFIG_AP) {
1226 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
1227 }
1228 else {
1229 //mike:mark@2008-11-10
1230 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BSSID_SCAN, NULL);
1231 //bScheduleCommand((HANDLE)pDevice, WLAN_CMD_SSID, NULL);
1232 }
1233
1234
1235 netif_stop_queue(pDevice->dev);
1236 pDevice->flags |= DEVICE_FLAGS_OPENED;
1237
1238#ifdef SndEvt_ToAPI
1239{
1240 union iwreq_data wrqu;
1241 memset(&wrqu, 0, sizeof(wrqu));
1242 wrqu.data.flags = RT_UPDEV_EVENT_FLAG;
1243 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
1244}
1245#endif
1246
1247 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success.. \n");
1248 return 0;
1249
1250free_all:
1251 device_free_frag_bufs(pDevice);
1252free_rx_tx:
1253 device_free_rx_bufs(pDevice);
1254 device_free_tx_bufs(pDevice);
1255 device_free_int_bufs(pDevice);
1256 vntwusb_unlink_urb(pDevice->pControlURB);
1257 vntwusb_unlink_urb(pDevice->pInterruptURB);
1258 usb_free_urb(pDevice->pControlURB);
1259 usb_free_urb(pDevice->pInterruptURB);
1260
1261 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open fail.. \n");
1262 return -ENOMEM;
1263}
1264
1265
1266
1267static int device_close(struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001268 PSDevice pDevice=(PSDevice) netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001269 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1270
Forest Bond92b96792009-06-13 07:38:31 -04001271 int uu;
Forest Bond92b96792009-06-13 07:38:31 -04001272
1273 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1 \n");
1274 if (pDevice == NULL)
1275 return -ENODEV;
1276
1277#ifdef SndEvt_ToAPI
1278{
1279 union iwreq_data wrqu;
1280 memset(&wrqu, 0, sizeof(wrqu));
1281 wrqu.data.flags = RT_DOWNDEV_EVENT_FLAG;
1282 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
1283}
1284#endif
1285
1286//2007-1121-02<Add>by EinsnLiu
1287 if (pDevice->bLinkPass) {
1288 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
1289 mdelay(30);
1290 }
1291//End Add
1292
1293//2008-0714-01<Add>by MikeLiu
1294device_release_WPADEV(pDevice);
1295
Forest Bond92b96792009-06-13 07:38:31 -04001296 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1297 pMgmt->bShareKeyAlgorithm = FALSE;
1298 pDevice->bEncryptionEnable = FALSE;
1299 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1300 spin_lock_irq(&pDevice->lock);
1301 for(uu=0;uu<MAX_KEY_TABLE;uu++)
1302 MACvDisableKeyEntry(pDevice,uu);
1303 spin_unlock_irq(&pDevice->lock);
Forest Bond92b96792009-06-13 07:38:31 -04001304
1305 if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == FALSE) {
1306 MACbShutdown(pDevice);
1307 }
1308 netif_stop_queue(pDevice->dev);
1309 MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
1310 MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES);
1311 MP_CLEAR_FLAG(pDevice, fMP_POST_READS);
1312 pDevice->fKillEventPollingThread = TRUE;
1313 del_timer(&pDevice->sTimerCommand);
1314 del_timer(&pMgmt->sTimerSecondCallback);
1315
1316//2007-0115-02<Add>by MikeLiu
1317#ifdef TxInSleep
1318 del_timer(&pDevice->sTimerTxData);
1319#endif
1320
1321 if (pDevice->bDiversityRegCtlON) {
1322 del_timer(&pDevice->TimerSQ3Tmax1);
1323 del_timer(&pDevice->TimerSQ3Tmax2);
1324 del_timer(&pDevice->TimerSQ3Tmax3);
1325 }
1326 tasklet_kill(&pDevice->RxMngWorkItem);
1327 tasklet_kill(&pDevice->ReadWorkItem);
1328 tasklet_kill(&pDevice->EventWorkItem);
1329
1330 pDevice->bRoaming = FALSE; //DavidWang
1331 pDevice->bIsRoaming = FALSE;//DavidWang
1332 pDevice->bEnableRoaming = FALSE;
1333 pDevice->bCmdRunning = FALSE;
1334 pDevice->bLinkPass = FALSE;
1335 memset(pMgmt->abyCurrBSSID, 0, 6);
1336 pMgmt->eCurrState = WMAC_STATE_IDLE;
1337
1338 device_free_tx_bufs(pDevice);
1339 device_free_rx_bufs(pDevice);
1340 device_free_int_bufs(pDevice);
1341 device_free_frag_bufs(pDevice);
1342
1343 vntwusb_unlink_urb(pDevice->pControlURB);
1344 vntwusb_unlink_urb(pDevice->pInterruptURB);
1345 usb_free_urb(pDevice->pControlURB);
1346 usb_free_urb(pDevice->pInterruptURB);
1347
1348 BSSvClearNodeDBTable(pDevice, 0);
1349 pDevice->flags &=(~DEVICE_FLAGS_OPENED);
1350
1351 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
1352
1353 return 0;
1354}
1355
Forest Bond92b96792009-06-13 07:38:31 -04001356
1357static void vntwusb_disconnect(struct usb_interface *intf)
1358
Forest Bond92b96792009-06-13 07:38:31 -04001359{
Forest Bond92b96792009-06-13 07:38:31 -04001360
1361 PSDevice pDevice = usb_get_intfdata(intf);
Forest Bond92b96792009-06-13 07:38:31 -04001362
1363 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_disconnect1.. \n");
1364 if (pDevice == NULL)
1365 return;
1366
1367#ifdef SndEvt_ToAPI
1368{
1369 union iwreq_data wrqu;
1370 memset(&wrqu, 0, sizeof(wrqu));
1371 wrqu.data.flags = RT_RMMOD_EVENT_FLAG;
1372 wireless_send_event(pDevice->dev, IWEVCUSTOM, &wrqu, NULL);
1373}
1374#endif
1375
1376//2008-0714-01<Add>by MikeLiu
1377device_release_WPADEV(pDevice);
1378
Forest Bond92b96792009-06-13 07:38:31 -04001379 usb_set_intfdata(intf, NULL);
1380//2008-0922-01<Add>by MikeLiu, decrease usb counter.
1381 usb_put_dev(interface_to_usbdev(intf));
1382
Forest Bond92b96792009-06-13 07:38:31 -04001383 pDevice->flags |= DEVICE_FLAGS_UNPLUG;
1384 if (pDevice->dev != NULL) {
1385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "unregister_netdev..\n");
1386 unregister_netdev(pDevice->dev);
1387
1388//2008-07-21-01<Add>by MikeLiu
1389//unregister wpadev
1390 if(wpa_set_wpadev(pDevice, 0)!=0)
1391 printk("unregister wpadev fail?\n");
1392
Forest Bond92b96792009-06-13 07:38:31 -04001393 free_netdev(pDevice->dev);
Forest Bond92b96792009-06-13 07:38:31 -04001394 }
1395
1396 kfree(pDevice);
1397 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_disconnect3.. \n");
1398}
1399
1400
1401
1402
1403static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001404 PSDevice pDevice=netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001405 PBYTE pbMPDU;
1406 UINT cbMPDULen = 0;
1407
1408
1409 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211\n");
1410 spin_lock_irq(&pDevice->lock);
1411
1412 if (pDevice->bStopTx0Pkt == TRUE) {
1413 dev_kfree_skb_irq(skb);
1414 spin_unlock_irq(&pDevice->lock);
1415 return 0;
1416 };
1417
1418
1419 cbMPDULen = skb->len;
1420 pbMPDU = skb->data;
1421
1422 vDMA0_tx_80211(pDevice, skb);
1423
1424 spin_unlock_irq(&pDevice->lock);
1425
1426 return 0;
1427
1428}
1429
1430
1431static int device_xmit(struct sk_buff *skb, struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001432 PSDevice pDevice=netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001433 struct net_device_stats* pStats = &pDevice->stats;
1434
1435
1436 spin_lock_irq(&pDevice->lock);
1437
1438 netif_stop_queue(pDevice->dev);
1439
1440 if (pDevice->bLinkPass == FALSE) {
1441 dev_kfree_skb_irq(skb);
1442 spin_unlock_irq(&pDevice->lock);
1443 return 0;
1444 }
1445 if (pDevice->bStopDataPkt == TRUE) {
1446 dev_kfree_skb_irq(skb);
1447 pStats->tx_dropped++;
1448 spin_unlock_irq(&pDevice->lock);
1449 return 0;
1450 }
1451
1452 if(nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb) !=0) { //mike add:xmit fail!
1453 if (netif_queue_stopped(pDevice->dev))
1454 netif_wake_queue(pDevice->dev);
1455 }
1456
1457 spin_unlock_irq(&pDevice->lock);
1458
1459 return 0;
1460}
1461
1462
1463
1464static unsigned const ethernet_polynomial = 0x04c11db7U;
1465static inline u32 ether_crc(int length, unsigned char *data)
1466{
1467 int crc = -1;
1468
1469 while(--length >= 0) {
1470 unsigned char current_octet = *data++;
1471 int bit;
1472 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
1473 crc = (crc << 1) ^
1474 ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
1475 }
1476 }
1477 return crc;
1478}
1479
1480//find out the start position of str2 from str1
1481static UCHAR *kstrstr(const UCHAR *str1,const UCHAR *str2) {
1482 int str1_len=strlen(str1);
1483 int str2_len=strlen(str2);
1484
1485 while (str1_len >= str2_len) {
1486 str1_len--;
1487 if(memcmp(str1,str2,str2_len)==0)
1488 return (UCHAR *)str1;
1489 str1++;
1490 }
1491 return NULL;
1492}
1493
1494static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source)
1495{
1496 UCHAR buf1[100];
1497 UCHAR buf2[100];
1498 UCHAR *start_p=NULL,*end_p=NULL,*tmp_p=NULL;
1499 int ii;
1500
1501 memset(buf1,0,100);
1502 strcat(buf1, string);
1503 strcat(buf1, "=");
1504 source+=strlen(buf1);
1505
1506//find target string start point
1507 if((start_p = kstrstr(source,buf1))==NULL)
1508 return FALSE;
1509
1510//check if current config line is marked by "#" ??
1511for(ii=1;;ii++) {
1512 if(memcmp(start_p-ii,"\n",1)==0)
1513 break;
1514 if(memcmp(start_p-ii,"#",1)==0)
1515 return FALSE;
1516}
1517
1518//find target string end point
1519 if((end_p = kstrstr(start_p,"\n"))==NULL) { //cann't find "\n",but don't care
1520 end_p=start_p+strlen(start_p); //no include "\n"
1521 }
1522
1523 memset(buf2,0,100);
1524 memcpy(buf2,start_p,end_p-start_p); //get the tartget line
1525 buf2[end_p-start_p]='\0';
1526
1527 //find value
1528 if((start_p = kstrstr(buf2,"="))==NULL)
1529 return FALSE;
1530 memset(buf1,0,100);
1531 strcpy(buf1,start_p+1);
1532
1533 //except space
1534 tmp_p = buf1;
1535 while(*tmp_p != 0x00) {
1536 if(*tmp_p==' ')
1537 tmp_p++;
1538 else
1539 break;
1540 }
1541
1542 memcpy(dest,tmp_p,strlen(tmp_p));
1543 return TRUE;
1544}
1545
1546//if read fail,return NULL,or return data pointer;
1547static UCHAR *Config_FileOperation(PSDevice pDevice) {
1548 UCHAR *config_path=CONFIG_PATH;
1549 UCHAR *buffer=NULL;
1550 struct file *filp=NULL;
1551 mm_segment_t old_fs = get_fs();
Forest Bond8f9c4662009-06-13 07:38:47 -04001552 //int oldfsuid=0,oldfsgid=0;
Forest Bond92b96792009-06-13 07:38:31 -04001553 int result=0;
1554
1555 set_fs (KERNEL_DS);
Forest Bond8f9c4662009-06-13 07:38:47 -04001556 /* Can't do this anymore, so we rely on correct filesystem permissions:
1557 //Make sure a caller can read or write power as root
1558 oldfsuid=current->fsuid;
1559 oldfsgid=current->fsgid;
Forest Bond92b96792009-06-13 07:38:31 -04001560 current->fsuid = 0;
1561 current->fsgid = 0;
Forest Bond8f9c4662009-06-13 07:38:47 -04001562 */
Forest Bond92b96792009-06-13 07:38:31 -04001563
1564 //open file
1565 filp = filp_open(config_path, O_RDWR, 0);
1566 if (IS_ERR(filp)) {
1567 printk("Config_FileOperation file Not exist\n");
1568 result=-1;
1569 goto error2;
1570 }
1571
1572 if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) {
1573 printk("file %s cann't readable or writable?\n",config_path);
1574 result = -1;
1575 goto error1;
1576 }
1577
1578 buffer = (UCHAR *)kmalloc(1024, GFP_KERNEL);
1579 if(buffer==NULL) {
1580 printk("alllocate mem for file fail?\n");
1581 result = -1;
1582 goto error1;
1583 }
1584
1585 if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) {
1586 printk("read file error?\n");
1587 result = -1;
1588 }
1589
1590error1:
1591 if(filp_close(filp,NULL))
1592 printk("Config_FileOperation:close file fail\n");
1593
1594error2:
1595 set_fs (old_fs);
Forest Bond8f9c4662009-06-13 07:38:47 -04001596
1597 /*
Forest Bond92b96792009-06-13 07:38:31 -04001598 current->fsuid=oldfsuid;
1599 current->fsgid=oldfsgid;
Forest Bond8f9c4662009-06-13 07:38:47 -04001600 */
Forest Bond92b96792009-06-13 07:38:31 -04001601
1602if(result!=0) {
1603 if(buffer)
1604 kfree(buffer);
1605 buffer=NULL;
1606}
1607 return buffer;
1608}
1609
1610//return --->-1:fail; >=0:sucessful
1611static int Read_config_file(PSDevice pDevice) {
1612 int result=0;
1613 UCHAR tmpbuffer[100];
1614 UCHAR *buffer=NULL;
1615
1616 //init config setting
1617 pDevice->config_file.ZoneType = -1;
1618 pDevice->config_file.eAuthenMode = -1;
1619 pDevice->config_file.eEncryptionStatus = -1;
1620
1621 if((buffer=Config_FileOperation(pDevice)) ==NULL) {
1622 result =-1;
1623 return result;
1624 }
1625
1626//get zonetype
1627{
1628 memset(tmpbuffer,0,sizeof(tmpbuffer));
1629 if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==TRUE) {
1630 if(memcmp(tmpbuffer,"USA",3)==0) {
1631 pDevice->config_file.ZoneType=ZoneType_USA;
1632 }
1633 else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
1634 pDevice->config_file.ZoneType=ZoneType_Japan;
1635 }
1636 else if(memcmp(tmpbuffer,"EUROPE",6)==0) {
1637 pDevice->config_file.ZoneType=ZoneType_Europe;
1638 }
1639 else {
1640 printk("Unknown Zonetype[%s]?\n",tmpbuffer);
1641 }
1642 }
1643}
1644
1645#if 1
1646//get other parameter
1647 {
1648 memset(tmpbuffer,0,sizeof(tmpbuffer));
1649 if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==TRUE) {
1650 pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10);
1651 }
1652
1653 memset(tmpbuffer,0,sizeof(tmpbuffer));
1654 if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==TRUE) {
1655 pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10);
1656 }
1657 }
1658#endif
1659
1660 kfree(buffer);
1661 return result;
1662}
1663
1664static void device_set_multi(struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001665 PSDevice pDevice = (PSDevice) netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001666 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1667 u32 mc_filter[2];
1668 int ii;
1669 struct dev_mc_list *mclist;
1670 BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
1671 BYTE byTmpMode = 0;
1672 int rc;
1673
1674
1675 spin_lock_irq(&pDevice->lock);
1676 rc = CONTROLnsRequestIn(pDevice,
1677 MESSAGE_TYPE_READ,
1678 MAC_REG_RCR,
1679 MESSAGE_REQUEST_MACREG,
1680 1,
1681 &byTmpMode
1682 );
1683 if (rc == 0) pDevice->byRxMode = byTmpMode;
1684
1685 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode);
1686
1687 if (dev->flags & IFF_PROMISC) { // Set promiscuous.
1688 DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
1689 // Unconditionally log net taps.
1690 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
1691 }
1692 else if ((dev->mc_count > pDevice->multicast_limit) || (dev->flags & IFF_ALLMULTI)) {
1693 CONTROLnsRequestOut(pDevice,
1694 MESSAGE_TYPE_WRITE,
1695 MAC_REG_MAR0,
1696 MESSAGE_REQUEST_MACREG,
1697 8,
1698 pbyData
1699 );
1700 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1701 }
1702 else {
1703 memset(mc_filter, 0, sizeof(mc_filter));
1704 for (ii = 0, mclist = dev->mc_list; mclist && ii < dev->mc_count;
1705 ii++, mclist = mclist->next) {
1706 int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
1707 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
1708 }
1709 for (ii = 0; ii < 4; ii++) {
1710 MACvWriteMultiAddr(pDevice, ii, *((PBYTE)&mc_filter[0] + ii));
1711 MACvWriteMultiAddr(pDevice, ii+ 4, *((PBYTE)&mc_filter[1] + ii));
1712 }
1713 pDevice->byRxMode &= ~(RCR_UNICAST);
1714 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1715 }
1716
1717 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
1718 // If AP mode, don't enable RCR_UNICAST. Since hw only compare addr1 with local mac.
1719 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1720 pDevice->byRxMode &= ~(RCR_UNICAST);
1721 }
1722 ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode);
1723 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode);
1724 spin_unlock_irq(&pDevice->lock);
1725
1726}
1727
1728
1729static struct net_device_stats *device_get_stats(struct net_device *dev) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001730 PSDevice pDevice=(PSDevice) netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001731
1732 return &pDevice->stats;
1733}
1734
1735
1736static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
Forest Bond1e28efa2009-06-13 07:38:50 -04001737 PSDevice pDevice = (PSDevice)netdev_priv(dev);
Forest Bond92b96792009-06-13 07:38:31 -04001738 PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
1739 PSCmdRequest pReq;
1740 //BOOL bCommit = FALSE;
Forest Bond92b96792009-06-13 07:38:31 -04001741 struct iwreq *wrq = (struct iwreq *) rq;
1742 int rc =0;
Forest Bond92b96792009-06-13 07:38:31 -04001743
1744 if (pMgmt == NULL) {
1745 rc = -EFAULT;
1746 return rc;
1747 }
1748
1749 switch(cmd) {
1750
Forest Bond92b96792009-06-13 07:38:31 -04001751 case SIOCGIWNAME:
1752 rc = iwctl_giwname(dev, NULL, (char *)&(wrq->u.name), NULL);
1753 break;
1754
1755 case SIOCSIWNWID:
1756 rc = -EOPNOTSUPP;
1757 break;
1758
1759 case SIOCGIWNWID: //0x8b03 support
1760 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1761 rc = iwctl_giwnwid(dev, NULL, &(wrq->u.nwid), NULL);
1762 #else
1763 rc = -EOPNOTSUPP;
1764 #endif
1765 break;
1766
1767 // Set frequency/channel
1768 case SIOCSIWFREQ:
1769 rc = iwctl_siwfreq(dev, NULL, &(wrq->u.freq), NULL);
1770 break;
1771
1772 // Get frequency/channel
1773 case SIOCGIWFREQ:
1774 rc = iwctl_giwfreq(dev, NULL, &(wrq->u.freq), NULL);
1775 break;
1776
1777 // Set desired network name (ESSID)
1778 case SIOCSIWESSID:
1779
1780 {
1781 char essid[IW_ESSID_MAX_SIZE+1];
1782 if (wrq->u.essid.length > IW_ESSID_MAX_SIZE) {
1783 rc = -E2BIG;
1784 break;
1785 }
1786 if (copy_from_user(essid, wrq->u.essid.pointer,
1787 wrq->u.essid.length)) {
1788 rc = -EFAULT;
1789 break;
1790 }
1791 rc = iwctl_siwessid(dev, NULL,
1792 &(wrq->u.essid), essid);
1793 }
1794 break;
1795
1796
1797 // Get current network name (ESSID)
1798 case SIOCGIWESSID:
1799
1800 {
1801 char essid[IW_ESSID_MAX_SIZE+1];
1802 if (wrq->u.essid.pointer)
1803 rc = iwctl_giwessid(dev, NULL,
1804 &(wrq->u.essid), essid);
1805 if (copy_to_user(wrq->u.essid.pointer,
1806 essid,
1807 wrq->u.essid.length) )
1808 rc = -EFAULT;
1809 }
1810 break;
1811
1812 case SIOCSIWAP:
1813
1814 rc = iwctl_siwap(dev, NULL, &(wrq->u.ap_addr), NULL);
1815 break;
1816
1817
1818 // Get current Access Point (BSSID)
1819 case SIOCGIWAP:
1820 rc = iwctl_giwap(dev, NULL, &(wrq->u.ap_addr), NULL);
1821 break;
1822
1823
1824 // Set desired station name
1825 case SIOCSIWNICKN:
1826 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWNICKN \n");
1827 rc = -EOPNOTSUPP;
1828 break;
1829
1830 // Get current station name
1831 case SIOCGIWNICKN:
1832 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWNICKN \n");
1833 rc = -EOPNOTSUPP;
1834 break;
1835
1836 // Set the desired bit-rate
1837 case SIOCSIWRATE:
1838 rc = iwctl_siwrate(dev, NULL, &(wrq->u.bitrate), NULL);
1839 break;
1840
1841 // Get the current bit-rate
1842 case SIOCGIWRATE:
1843
1844 rc = iwctl_giwrate(dev, NULL, &(wrq->u.bitrate), NULL);
1845 break;
1846
1847 // Set the desired RTS threshold
1848 case SIOCSIWRTS:
1849
1850 rc = iwctl_siwrts(dev, NULL, &(wrq->u.rts), NULL);
1851 break;
1852
1853 // Get the current RTS threshold
1854 case SIOCGIWRTS:
1855
1856 rc = iwctl_giwrts(dev, NULL, &(wrq->u.rts), NULL);
1857 break;
1858
1859 // Set the desired fragmentation threshold
1860 case SIOCSIWFRAG:
1861
1862 rc = iwctl_siwfrag(dev, NULL, &(wrq->u.frag), NULL);
1863 break;
1864
1865 // Get the current fragmentation threshold
1866 case SIOCGIWFRAG:
1867
1868 rc = iwctl_giwfrag(dev, NULL, &(wrq->u.frag), NULL);
1869 break;
1870
1871 // Set mode of operation
1872 case SIOCSIWMODE:
1873 rc = iwctl_siwmode(dev, NULL, &(wrq->u.mode), NULL);
1874 break;
1875
1876 // Get mode of operation
1877 case SIOCGIWMODE:
1878 rc = iwctl_giwmode(dev, NULL, &(wrq->u.mode), NULL);
1879 break;
1880
1881 // Set WEP keys and mode
1882 case SIOCSIWENCODE:
1883 {
1884 char abyKey[WLAN_WEP232_KEYLEN];
1885
1886 if (wrq->u.encoding.pointer) {
1887
1888
1889 if (wrq->u.encoding.length > WLAN_WEP232_KEYLEN) {
1890 rc = -E2BIG;
1891 break;
1892 }
1893 memset(abyKey, 0, WLAN_WEP232_KEYLEN);
1894 if (copy_from_user(abyKey,
1895 wrq->u.encoding.pointer,
1896 wrq->u.encoding.length)) {
1897 rc = -EFAULT;
1898 break;
1899 }
1900 } else if (wrq->u.encoding.length != 0) {
1901 rc = -EINVAL;
1902 break;
1903 }
1904 rc = iwctl_siwencode(dev, NULL, &(wrq->u.encoding), abyKey);
1905 }
1906 break;
1907
1908 // Get the WEP keys and mode
1909 case SIOCGIWENCODE:
1910
1911 if (!capable(CAP_NET_ADMIN)) {
1912 rc = -EPERM;
1913 break;
1914 }
1915 {
1916 char abyKey[WLAN_WEP232_KEYLEN];
1917
1918 rc = iwctl_giwencode(dev, NULL, &(wrq->u.encoding), abyKey);
1919 if (rc != 0) break;
1920 if (wrq->u.encoding.pointer) {
1921 if (copy_to_user(wrq->u.encoding.pointer,
1922 abyKey,
1923 wrq->u.encoding.length))
1924 rc = -EFAULT;
1925 }
1926 }
1927 break;
1928
Forest Bond92b96792009-06-13 07:38:31 -04001929 // Get the current Tx-Power
1930 case SIOCGIWTXPOW:
1931 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
1932 rc = -EOPNOTSUPP;
1933 break;
1934
1935 case SIOCSIWTXPOW:
1936 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n");
1937 rc = -EOPNOTSUPP;
1938 break;
1939
Forest Bond92b96792009-06-13 07:38:31 -04001940 case SIOCSIWRETRY:
1941
1942 rc = iwctl_siwretry(dev, NULL, &(wrq->u.retry), NULL);
1943 break;
1944
1945 case SIOCGIWRETRY:
1946
1947 rc = iwctl_giwretry(dev, NULL, &(wrq->u.retry), NULL);
1948 break;
1949
Forest Bond92b96792009-06-13 07:38:31 -04001950 // Get range of parameters
1951 case SIOCGIWRANGE:
1952
1953 {
1954 struct iw_range range;
1955
1956 rc = iwctl_giwrange(dev, NULL, &(wrq->u.data), (char *) &range);
1957 if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))
1958 rc = -EFAULT;
1959 }
1960
1961 break;
1962
1963 case SIOCGIWPOWER:
1964
1965 rc = iwctl_giwpower(dev, NULL, &(wrq->u.power), NULL);
1966 break;
1967
1968
1969 case SIOCSIWPOWER:
1970
1971 rc = iwctl_siwpower(dev, NULL, &(wrq->u.power), NULL);
1972 break;
1973
1974
1975 case SIOCGIWSENS:
1976
1977 rc = iwctl_giwsens(dev, NULL, &(wrq->u.sens), NULL);
1978 break;
1979
1980 case SIOCSIWSENS:
1981 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSENS \n");
1982 rc = -EOPNOTSUPP;
1983 break;
1984
1985 case SIOCGIWAPLIST:
1986 {
1987 char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];
1988
1989 if (wrq->u.data.pointer) {
1990 rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);
1991 if (rc == 0) {
1992 if (copy_to_user(wrq->u.data.pointer,
1993 buffer,
1994 (wrq->u.data.length * (sizeof(struct sockaddr) + sizeof(struct iw_quality)))
1995 ))
1996 rc = -EFAULT;
1997 }
1998 }
1999 }
2000 break;
2001
2002
2003#ifdef WIRELESS_SPY
2004 // Set the spy list
2005 case SIOCSIWSPY:
2006
2007 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
2008 rc = -EOPNOTSUPP;
2009 break;
2010
2011 // Get the spy list
2012 case SIOCGIWSPY:
2013
2014 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n");
2015 rc = -EOPNOTSUPP;
2016 break;
2017
2018#endif // WIRELESS_SPY
2019
2020 case SIOCGIWPRIV:
2021 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPRIV \n");
2022 rc = -EOPNOTSUPP;
2023/*
2024 if(wrq->u.data.pointer) {
2025 wrq->u.data.length = sizeof(iwctl_private_args) / sizeof( iwctl_private_args[0]);
2026
2027 if(copy_to_user(wrq->u.data.pointer,
2028 (u_char *) iwctl_private_args,
2029 sizeof(iwctl_private_args)))
2030 rc = -EFAULT;
2031 }
2032*/
2033 break;
2034
2035
Forest Bond92b96792009-06-13 07:38:31 -04002036//2008-0409-07, <Add> by Einsn Liu
2037#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2038 case SIOCSIWAUTH:
2039 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWAUTH \n");
2040 rc = iwctl_siwauth(dev, NULL, &(wrq->u.param), NULL);
2041 break;
2042
2043 case SIOCGIWAUTH:
2044 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWAUTH \n");
2045 rc = iwctl_giwauth(dev, NULL, &(wrq->u.param), NULL);
2046 break;
2047
2048 case SIOCSIWGENIE:
2049 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWGENIE \n");
2050 rc = iwctl_siwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
2051 break;
2052
2053 case SIOCGIWGENIE:
2054 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWGENIE \n");
2055 rc = iwctl_giwgenie(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
2056 break;
2057
2058 case SIOCSIWENCODEEXT:
2059 {
2060 char extra[sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1];
2061 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWENCODEEXT \n");
2062 if(wrq->u.encoding.pointer){
2063 memset(extra, 0, sizeof(struct iw_encode_ext)+MAX_KEY_LEN+1);
2064 if(wrq->u.encoding.length > (sizeof(struct iw_encode_ext)+ MAX_KEY_LEN)){
2065 rc = -E2BIG;
2066 break;
2067 }
2068 if(copy_from_user(extra, wrq->u.encoding.pointer,wrq->u.encoding.length)){
2069 rc = -EFAULT;
2070 break;
2071 }
2072 }else if(wrq->u.encoding.length != 0){
2073 rc = -EINVAL;
2074 break;
2075 }
2076 rc = iwctl_siwencodeext(dev, NULL, &(wrq->u.encoding), extra);
2077 }
2078 break;
2079
2080 case SIOCGIWENCODEEXT:
2081 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODEEXT \n");
2082 rc = iwctl_giwencodeext(dev, NULL, &(wrq->u.encoding), NULL);
2083 break;
2084
2085 case SIOCSIWMLME:
2086 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWMLME \n");
2087 rc = iwctl_siwmlme(dev, NULL, &(wrq->u.data), wrq->u.data.pointer);
2088 break;
2089
2090#endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2091//End Add -- //2008-0409-07, <Add> by Einsn Liu
2092
Forest Bond92b96792009-06-13 07:38:31 -04002093 case IOCTL_CMD_TEST:
2094
2095 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
2096 rc = -EFAULT;
2097 break;
2098 } else {
2099 rc = 0;
2100 }
2101 pReq = (PSCmdRequest)rq;
2102
2103 //20080130-01,<Remark> by Mike Liu
2104 // if(pDevice->bLinkPass==TRUE)
2105 pReq->wResult = MAGIC_CODE; //Linking status:0x3142
2106 //20080130-02,<Remark> by Mike Liu
2107 // else
2108 // pReq->wResult = MAGIC_CODE+1; //disconnect status:0x3143
2109 break;
2110
2111 case IOCTL_CMD_SET:
2112 if (!(pDevice->flags & DEVICE_FLAGS_OPENED) &&
2113 (((PSCmdRequest)rq)->wCmdCode !=WLAN_CMD_SET_WPA))
2114 {
2115 rc = -EFAULT;
2116 break;
2117 } else {
2118 rc = 0;
2119 }
2120
2121 if (test_and_set_bit( 0, (void*)&(pMgmt->uCmdBusy))) {
2122 return -EBUSY;
2123 }
2124 rc = private_ioctl(pDevice, rq);
2125 clear_bit( 0, (void*)&(pMgmt->uCmdBusy));
2126 break;
2127
2128 case IOCTL_CMD_HOSTAPD:
2129
2130 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
2131 rc = -EFAULT;
2132 break;
2133 } else {
2134 rc = 0;
2135 }
2136
Forest Bond92b96792009-06-13 07:38:31 -04002137 rc = hostap_ioctl(pDevice, &wrq->u.data);
Forest Bond92b96792009-06-13 07:38:31 -04002138 break;
2139
2140 case IOCTL_CMD_WPA:
2141
2142 if (!(pDevice->flags & DEVICE_FLAGS_OPENED)) {
2143 rc = -EFAULT;
2144 break;
2145 } else {
2146 rc = 0;
2147 }
2148
Forest Bond92b96792009-06-13 07:38:31 -04002149 rc = wpa_ioctl(pDevice, &wrq->u.data);
Forest Bond92b96792009-06-13 07:38:31 -04002150 break;
2151
2152 case SIOCETHTOOL:
2153 return ethtool_ioctl(dev, (void *) rq->ifr_data);
2154 // All other calls are currently unsupported
2155
2156 default:
2157 rc = -EOPNOTSUPP;
2158 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Ioctl command not support..%x\n", cmd);
2159
2160
2161 }
2162
2163 if (pDevice->bCommit) {
2164 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
2165 netif_stop_queue(pDevice->dev);
2166 spin_lock_irq(&pDevice->lock);
2167 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RUN_AP, NULL);
2168 spin_unlock_irq(&pDevice->lock);
2169 }
2170 else {
2171 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Commit the settings\n");
2172 spin_lock_irq(&pDevice->lock);
2173//2007-1121-01<Modify>by EinsnLiu
2174 if (pDevice->bLinkPass&&
2175 memcmp(pMgmt->abyCurrSSID,pMgmt->abyDesireSSID,WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN)) {
2176 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_DISASSOCIATE, NULL);
2177 } else {
2178 pDevice->bLinkPass = FALSE;
2179 pMgmt->eCurrState = WMAC_STATE_IDLE;
2180 memset(pMgmt->abyCurrBSSID, 0, 6);
2181 }
2182 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
2183//End Modify
2184 netif_stop_queue(pDevice->dev);
2185#ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2186 pMgmt->eScanType = WMAC_SCAN_ACTIVE;
2187 if(pDevice->bWPASuppWextEnabled !=TRUE)
2188#endif
2189 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_BSSID_SCAN, pMgmt->abyDesireSSID);
2190 bScheduleCommand((HANDLE) pDevice, WLAN_CMD_SSID, NULL);
2191 spin_unlock_irq(&pDevice->lock);
2192 }
2193 pDevice->bCommit = FALSE;
2194 }
2195
2196
2197 return rc;
2198}
2199
2200
2201static int ethtool_ioctl(struct net_device *dev, void *useraddr)
2202{
2203 u32 ethcmd;
2204
2205 if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
2206 return -EFAULT;
2207
2208 switch (ethcmd) {
2209 case ETHTOOL_GDRVINFO: {
2210 struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
2211 strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
2212 strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
2213 if (copy_to_user(useraddr, &info, sizeof(info)))
2214 return -EFAULT;
2215 return 0;
2216 }
2217
2218 }
2219
2220 return -EOPNOTSUPP;
2221}
2222
2223
2224/*------------------------------------------------------------------*/
2225
2226
2227MODULE_DEVICE_TABLE(usb, vntwusb_table);
2228
2229
Forest Bond92b96792009-06-13 07:38:31 -04002230static struct usb_driver vntwusb_driver = {
Forest Bond92b96792009-06-13 07:38:31 -04002231 .name = DEVICE_NAME,
2232 .probe = vntwusb_found1,
2233 .disconnect = vntwusb_disconnect,
2234 .id_table = vntwusb_table,
2235
2236//2008-0920-01<Add>by MikeLiu
2237//for supporting S3 & S4 function
2238#ifdef CONFIG_PM
2239 .suspend = vntwusb_suspend,
2240 .resume = vntwusb_resume,
2241#endif
2242};
2243
Forest Bond92b96792009-06-13 07:38:31 -04002244static int __init vntwusb_init_module(void)
2245{
Forest Bondf4a8df92009-06-13 07:38:56 -04002246 printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION);
Forest Bond92b96792009-06-13 07:38:31 -04002247 return usb_register(&vntwusb_driver);
2248}
2249
2250static void __exit vntwusb_cleanup_module(void)
2251{
2252 usb_deregister(&vntwusb_driver);
2253}
2254
2255module_init(vntwusb_init_module);
2256module_exit(vntwusb_cleanup_module);
2257