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.
21 * Purpose: driver entry for initial, open, close, tx and rx.
29 * vt6656_probe - 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 - asynchronous data tx function
33 * device_set_multi - set mac filter
34 * device_ioctl - ioctl entry
35 * device_close - shutdown mac/bbp & free dma/descriptor 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 buffered 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
75 /*--------------------- Static Definitions -------------------------*/
76 /* static int msglevel = MSG_LEVEL_DEBUG; */
77 static int msglevel =MSG_LEVEL_INFO;
80 * define module options
83 /* version information */
84 #define DRIVER_AUTHOR \
85 "VIA Networking Technologies, Inc., <lyndonchen@vntek.com.tw>"
86 MODULE_AUTHOR(DRIVER_AUTHOR);
87 MODULE_LICENSE("GPL");
88 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
90 #define DEVICE_PARAM(N,D) \
91 static int N[MAX_UINTS]=OPTION_DEFAULT;\
92 module_param_array(N, int, NULL, 0);\
93 MODULE_PARM_DESC(N, D);
95 #define RX_DESC_DEF0 64
96 DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
99 #define TX_DESC_DEF0 64
100 DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
102 #define CHANNEL_DEF 6
103 DEVICE_PARAM(Channel, "Channel number");
106 /* PreambleType[] is the preamble length used for transmit.
107 0: indicate allows long preamble type
108 1: indicate allows short preamble type
111 #define PREAMBLE_TYPE_DEF 1
113 DEVICE_PARAM(PreambleType, "Preamble Type");
115 #define RTS_THRESH_DEF 2347
116 DEVICE_PARAM(RTSThreshold, "RTS threshold");
118 #define FRAG_THRESH_DEF 2346
119 DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
122 #define DATA_RATE_DEF 13
124 0: indicate 1 Mbps 0x02
125 1: indicate 2 Mbps 0x04
126 2: indicate 5.5 Mbps 0x0B
127 3: indicate 11 Mbps 0x16
128 4: indicate 6 Mbps 0x0c
129 5: indicate 9 Mbps 0x12
130 6: indicate 12 Mbps 0x18
131 7: indicate 18 Mbps 0x24
132 8: indicate 24 Mbps 0x30
133 9: indicate 36 Mbps 0x48
134 10: indicate 48 Mbps 0x60
135 11: indicate 54 Mbps 0x6c
136 12: indicate 72 Mbps 0x90
137 13: indicate auto rate
140 DEVICE_PARAM(ConnectionRate, "Connection data rate");
142 #define OP_MODE_DEF 0
143 DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
145 /* OpMode[] is used for transmit.
146 0: indicate infrastruct mode used
147 1: indicate adhoc mode used
148 2: indicate AP mode used
153 0: indicate disable power saving mode
154 1: indicate enable power saving mode
157 #define PS_MODE_DEF 0
158 DEVICE_PARAM(PSMode, "Power saving mode");
161 #define SHORT_RETRY_DEF 8
162 DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
164 #define LONG_RETRY_DEF 4
165 DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
167 /* BasebandType[] baseband type selected
168 0: indicate 802.11a type
169 1: indicate 802.11b type
170 2: indicate 802.11g type
173 #define BBP_TYPE_DEF 2
174 DEVICE_PARAM(BasebandType, "baseband type");
179 0: indicate disable 802.11h
180 1: indicate enable 802.11h
183 #define X80211h_MODE_DEF 0
185 DEVICE_PARAM(b80211hEnable, "802.11h mode");
189 * Static vars definitions
192 static struct usb_device_id vt6656_table[] = {
193 {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
197 /* frequency list (map channels to frequencies) */
199 static const long frequency_list[] = {
200 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
201 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
202 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
203 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
204 5700, 5745, 5765, 5785, 5805, 5825
208 static const struct iw_handler_def iwctl_handler_def;
211 /*--------------------- Static Functions --------------------------*/
213 static int vt6656_probe(struct usb_interface *intf,
214 const struct usb_device_id *id);
215 static void vt6656_disconnect(struct usb_interface *intf);
217 #ifdef CONFIG_PM /* Minimal support for suspend and resume */
218 static int vt6656_suspend(struct usb_interface *intf, pm_message_t message);
219 static int vt6656_resume(struct usb_interface *intf);
220 #endif /* CONFIG_PM */
222 static struct net_device_stats *device_get_stats(struct net_device *dev);
223 static int device_open(struct net_device *dev);
224 static int device_xmit(struct sk_buff *skb, struct net_device *dev);
225 static void device_set_multi(struct net_device *dev);
226 static int device_close(struct net_device *dev);
227 static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
229 static int device_init_registers(struct vnt_private *pDevice,
230 DEVICE_INIT_TYPE InitType);
231 static bool device_init_defrag_cb(struct vnt_private *pDevice);
232 static void device_init_diversity_timer(struct vnt_private *pDevice);
233 static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
235 static int ethtool_ioctl(struct net_device *dev, void *useraddr);
236 static void device_free_tx_bufs(struct vnt_private *pDevice);
237 static void device_free_rx_bufs(struct vnt_private *pDevice);
238 static void device_free_int_bufs(struct vnt_private *pDevice);
239 static void device_free_frag_bufs(struct vnt_private *pDevice);
240 static bool device_alloc_bufs(struct vnt_private *pDevice);
242 static int Read_config_file(struct vnt_private *pDevice);
243 static unsigned char *Config_FileOperation(struct vnt_private *pDevice);
244 static int Config_FileGetParameter(unsigned char *string,
246 unsigned char *source);
249 static void usb_device_reset(struct vnt_private *pDevice);
253 /*--------------------- Export Variables --------------------------*/
255 /*--------------------- Export Functions --------------------------*/
259 device_set_options(struct vnt_private *pDevice) {
261 BYTE abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
262 BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
263 u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
265 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
266 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
267 memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
269 pDevice->cbTD = TX_DESC_DEF0;
270 pDevice->cbRD = RX_DESC_DEF0;
271 pDevice->uChannel = CHANNEL_DEF;
272 pDevice->wRTSThreshold = RTS_THRESH_DEF;
273 pDevice->wFragmentationThreshold = FRAG_THRESH_DEF;
274 pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
275 pDevice->byLongRetryLimit = LONG_RETRY_DEF;
276 pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
277 pDevice->byShortPreamble = PREAMBLE_TYPE_DEF;
278 pDevice->ePSMode = PS_MODE_DEF;
279 pDevice->b11hEnable = X80211h_MODE_DEF;
280 pDevice->eOPMode = OP_MODE_DEF;
281 pDevice->uConnectionRate = DATA_RATE_DEF;
282 if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true;
283 pDevice->byBBType = BBP_TYPE_DEF;
284 pDevice->byPacketType = pDevice->byBBType;
285 pDevice->byAutoFBCtrl = AUTO_FB_0;
286 pDevice->bUpdateBBVGA = true;
287 pDevice->byFOETuning = 0;
288 pDevice->byAutoPwrTunning = 0;
289 pDevice->wCTSDuration = 0;
290 pDevice->byPreambleType = 0;
291 pDevice->bExistSWNetAddr = false;
292 /* pDevice->bDiversityRegCtlON = true; */
293 pDevice->bDiversityRegCtlON = false;
297 static void device_init_diversity_timer(struct vnt_private *pDevice)
299 init_timer(&pDevice->TimerSQ3Tmax1);
300 pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice;
301 pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
302 pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
304 init_timer(&pDevice->TimerSQ3Tmax2);
305 pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice;
306 pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
307 pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
309 init_timer(&pDevice->TimerSQ3Tmax3);
310 pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice;
311 pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack;
312 pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
319 * initialization of MAC & BBP registers
322 static int device_init_registers(struct vnt_private *pDevice,
323 DEVICE_INIT_TYPE InitType)
325 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
326 u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
327 u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
328 u8 abySNAP_Bridgetunnel[ETH_ALEN]
329 = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
332 CMD_CARD_INIT sInitCmd;
333 int ntStatus = STATUS_SUCCESS;
334 RSP_CARD_INIT sInitRsp;
336 u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0;
338 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
339 spin_lock_irq(&pDevice->lock);
340 if (InitType == DEVICE_INIT_COLD) {
341 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
342 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
343 memcpy(pDevice->abySNAP_Bridgetunnel,
344 abySNAP_Bridgetunnel,
347 if ( !FIRMWAREbCheckVersion(pDevice) ) {
348 if (FIRMWAREbDownload(pDevice) == true) {
349 if (FIRMWAREbBrach2Sram(pDevice) == false) {
350 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbBrach2Sram fail \n");
351 spin_unlock_irq(&pDevice->lock);
356 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbDownload fail \n");
357 spin_unlock_irq(&pDevice->lock);
362 if ( !BBbVT3184Init(pDevice) ) {
363 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail \n");
364 spin_unlock_irq(&pDevice->lock);
369 sInitCmd.byInitClass = (BYTE)InitType;
370 sInitCmd.bExistSWNetAddr = (BYTE) pDevice->bExistSWNetAddr;
371 for (ii = 0; ii < 6; ii++)
372 sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii];
373 sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit;
374 sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit;
376 /* issue card_init command to device */
377 ntStatus = CONTROLnsRequestOut(pDevice,
378 MESSAGE_TYPE_CARDINIT,
381 sizeof(CMD_CARD_INIT),
382 (PBYTE) &(sInitCmd));
384 if ( ntStatus != STATUS_SUCCESS ) {
385 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail \n");
386 spin_unlock_irq(&pDevice->lock);
389 if (InitType == DEVICE_INIT_COLD) {
391 ntStatus = CONTROLnsRequestIn(pDevice,MESSAGE_TYPE_INIT_RSP,0,0,sizeof(RSP_CARD_INIT), (PBYTE) &(sInitRsp));
393 if (ntStatus != STATUS_SUCCESS) {
394 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n");
395 spin_unlock_irq(&pDevice->lock);
399 /* local ID for AES functions */
400 ntStatus = CONTROLnsRequestIn(pDevice,
403 MESSAGE_REQUEST_MACREG,
405 &pDevice->byLocalID);
407 if ( ntStatus != STATUS_SUCCESS ) {
408 spin_unlock_irq(&pDevice->lock);
412 /* do MACbSoftwareReset in MACvInitialize */
415 pDevice->bCCK = true;
416 pDevice->bProtectMode = false;
417 /* only used in 11g type, sync with ERP IE */
418 pDevice->bNonERPPresent = false;
419 pDevice->bBarkerPreambleMd = false;
420 if ( pDevice->bFixRate ) {
421 pDevice->wCurrentRate = (WORD) pDevice->uConnectionRate;
423 if ( pDevice->byBBType == BB_TYPE_11B )
424 pDevice->wCurrentRate = RATE_11M;
426 pDevice->wCurrentRate = RATE_54M;
429 CHvInitChannelTable(pDevice);
431 pDevice->byTopOFDMBasicRate = RATE_24M;
432 pDevice->byTopCCKBasicRate = RATE_1M;
433 pDevice->byRevId = 0;
434 /* target to IF pin while programming to RF chip */
435 pDevice->byCurPwr = 0xFF;
437 pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
438 pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
439 /* load power table */
440 for (ii = 0; ii < 14; ii++) {
441 pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
442 if (pDevice->abyCCKPwrTbl[ii] == 0)
443 pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
444 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
445 if (pDevice->abyOFDMPwrTbl[ii] == 0)
446 pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
450 * original zonetype is USA, but custom zonetype is Europe,
451 * then need to recover 12, 13, 14 channels with 11 channel
453 if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
454 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&&
455 (pDevice->byOriginalZonetype == ZoneType_USA)) {
456 for (ii = 11; ii < 14; ii++) {
457 pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
458 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
462 pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */
464 /* load OFDM A power table */
465 for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) {
466 pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
467 if (pDevice->abyOFDMAPwrTbl[ii] == 0)
468 pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
471 byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
472 if (byAntenna & EEP_ANTINV)
473 pDevice->bTxRxAntInv = true;
475 pDevice->bTxRxAntInv = false;
477 byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
479 if (byAntenna == 0) /* if not set default is both */
480 byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
482 if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
483 pDevice->byAntennaCount = 2;
484 pDevice->byTxAntennaMode = ANT_B;
485 pDevice->dwTxAntennaSel = 1;
486 pDevice->dwRxAntennaSel = 1;
487 if (pDevice->bTxRxAntInv == true)
488 pDevice->byRxAntennaMode = ANT_A;
490 pDevice->byRxAntennaMode = ANT_B;
492 if (pDevice->bDiversityRegCtlON)
493 pDevice->bDiversityEnable = true;
495 pDevice->bDiversityEnable = false;
497 pDevice->bDiversityEnable = false;
498 pDevice->byAntennaCount = 1;
499 pDevice->dwTxAntennaSel = 0;
500 pDevice->dwRxAntennaSel = 0;
501 if (byAntenna & EEP_ANTENNA_AUX) {
502 pDevice->byTxAntennaMode = ANT_A;
503 if (pDevice->bTxRxAntInv == true)
504 pDevice->byRxAntennaMode = ANT_B;
506 pDevice->byRxAntennaMode = ANT_A;
508 pDevice->byTxAntennaMode = ANT_B;
509 if (pDevice->bTxRxAntInv == true)
510 pDevice->byRxAntennaMode = ANT_A;
512 pDevice->byRxAntennaMode = ANT_B;
515 pDevice->ulDiversityNValue = 100*255;
516 pDevice->ulDiversityMValue = 100*16;
518 pDevice->byTMax2 = 4;
519 pDevice->ulSQ3TH = 0;
520 pDevice->byTMax3 = 64;
522 /* get Auto Fall Back type */
523 pDevice->byAutoFBCtrl = AUTO_FB_0;
526 pDevice->uScanTime = WLAN_SCAN_MINITIME;
528 /* default Auto Mode */
529 /* pDevice->NetworkType = Ndis802_11Automode; */
530 pDevice->eConfigPHYMode = PHY_TYPE_AUTO;
531 pDevice->byBBType = BB_TYPE_11G;
533 /* initialize BBP registers */
534 pDevice->ulTxPower = 25;
536 /* get channel range */
537 pDevice->byMinChannel = 1;
538 pDevice->byMaxChannel = CB_MAX_CHANNEL;
541 pDevice->byRFType = sInitRsp.byRFType;
543 if ((pDevice->byRFType & RF_EMU) != 0) {
544 /* force change RevID for VT3253 emu */
545 pDevice->byRevId = 0x80;
548 /* load vt3266 calibration parameters in EEPROM */
549 if (pDevice->byRFType == RF_VT3226D0) {
550 if((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
551 (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
552 byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
553 byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
554 byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
555 if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) {
556 /* CR255, enable TX/RX IQ and DC compensation mode */
557 ControlvWriteByte(pDevice,
558 MESSAGE_REQUEST_BBREG,
561 /* CR251, TX I/Q Imbalance Calibration */
562 ControlvWriteByte(pDevice,
563 MESSAGE_REQUEST_BBREG,
566 /* CR252, TX DC-Offset Calibration */
567 ControlvWriteByte(pDevice,
568 MESSAGE_REQUEST_BBREG,
571 /* CR253, RX I/Q Imbalance Calibration */
572 ControlvWriteByte(pDevice,
573 MESSAGE_REQUEST_BBREG,
577 /* CR255, turn off BB Calibration compensation */
578 ControlvWriteByte(pDevice,
579 MESSAGE_REQUEST_BBREG,
585 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
586 pMgmt->uCurrChannel = pDevice->uChannel;
587 pMgmt->uIBSSChannel = pDevice->uChannel;
588 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
590 /* get permanent network address */
591 memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6);
592 memcpy(pDevice->abyCurrentNetAddr,
593 pDevice->abyPermanentNetAddr,
596 /* if exist SW network address, use it */
597 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n",
598 pDevice->abyCurrentNetAddr);
602 * set BB and packet type at the same time
603 * set Short Slot Time, xIFS, and RSPINF
605 if (pDevice->byBBType == BB_TYPE_11A) {
606 CARDbAddBasicRate(pDevice, RATE_6M);
607 pDevice->bShortSlotTime = true;
609 CARDbAddBasicRate(pDevice, RATE_1M);
610 pDevice->bShortSlotTime = false;
612 BBvSetShortSlotTime(pDevice);
613 CARDvSetBSSMode(pDevice);
615 if (pDevice->bUpdateBBVGA) {
616 pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
617 pDevice->byBBVGANew = pDevice->byBBVGACurrent;
618 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
621 pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
622 pDevice->bHWRadioOff = false;
623 if ( (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0 ) {
624 ntStatus = CONTROLnsRequestIn(pDevice,
627 MESSAGE_REQUEST_MACREG,
631 if ( ntStatus != STATUS_SUCCESS ) {
632 spin_unlock_irq(&pDevice->lock);
635 if ( (byTmp & GPIO3_DATA) == 0 ) {
636 pDevice->bHWRadioOff = true;
637 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
639 MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
640 pDevice->bHWRadioOff = false;
645 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_TMLEN,0x38);
646 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
647 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL0,0x01);
649 if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) {
650 CARDbRadioPowerOff(pDevice);
652 CARDbRadioPowerOn(pDevice);
655 spin_unlock_irq(&pDevice->lock);
656 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
660 #ifdef CONFIG_PM /* Minimal support for suspend and resume */
662 static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
664 struct vnt_private *device = usb_get_intfdata(intf);
666 if (!device || !device->dev)
669 if (device->flags & DEVICE_FLAGS_OPENED)
670 device_close(device->dev);
672 usb_put_dev(interface_to_usbdev(intf));
677 static int vt6656_resume(struct usb_interface *intf)
679 struct vnt_private *device = usb_get_intfdata(intf);
681 if (!device || !device->dev)
684 usb_get_dev(interface_to_usbdev(intf));
686 if (!(device->flags & DEVICE_FLAGS_OPENED))
687 device_open(device->dev);
692 #endif /* CONFIG_PM */
694 static const struct net_device_ops device_netdev_ops = {
695 .ndo_open = device_open,
696 .ndo_stop = device_close,
697 .ndo_do_ioctl = device_ioctl,
698 .ndo_get_stats = device_get_stats,
699 .ndo_start_xmit = device_xmit,
700 .ndo_set_rx_mode = device_set_multi,
704 vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
706 u8 fake_mac[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
707 struct usb_device *udev = interface_to_usbdev(intf);
709 struct net_device *netdev = NULL;
710 struct vnt_private *pDevice;
712 printk(KERN_NOTICE "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
713 printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
715 udev = usb_get_dev(udev);
716 netdev = alloc_etherdev(sizeof(struct vnt_private));
718 printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n");
723 pDevice = netdev_priv(netdev);
724 memset(pDevice, 0, sizeof(struct vnt_private));
726 pDevice->dev = netdev;
729 device_set_options(pDevice);
730 spin_lock_init(&pDevice->lock);
732 pDevice->tx_80211 = device_dma0_tx_80211;
733 pDevice->vnt_mgmt.pAdapter = (void *) pDevice;
735 netdev->netdev_ops = &device_netdev_ops;
736 netdev->wireless_handlers =
737 (struct iw_handler_def *) &iwctl_handler_def;
739 usb_set_intfdata(intf, pDevice);
740 SET_NETDEV_DEV(netdev, &intf->dev);
741 memcpy(pDevice->dev->dev_addr, fake_mac, ETH_ALEN);
742 rc = register_netdev(netdev);
744 printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
748 usb_device_reset(pDevice);
760 static void device_free_tx_bufs(struct vnt_private *pDevice)
762 PUSB_SEND_CONTEXT pTxContext;
765 for (ii = 0; ii < pDevice->cbTD; ii++) {
767 pTxContext = pDevice->apTD[ii];
768 /* deallocate URBs */
769 if (pTxContext->pUrb) {
770 usb_kill_urb(pTxContext->pUrb);
771 usb_free_urb(pTxContext->pUrb);
779 static void device_free_rx_bufs(struct vnt_private *pDevice)
784 for (ii = 0; ii < pDevice->cbRD; ii++) {
786 pRCB = pDevice->apRCB[ii];
787 /* deallocate URBs */
789 usb_kill_urb(pRCB->pUrb);
790 usb_free_urb(pRCB->pUrb);
794 dev_kfree_skb(pRCB->skb);
796 kfree(pDevice->pRCBMem);
801 static void usb_device_reset(struct vnt_private *pDevice)
804 status = usb_reset_device(pDevice->usb);
806 printk("usb_device_reset fail status=%d\n",status);
810 static void device_free_int_bufs(struct vnt_private *pDevice)
812 kfree(pDevice->intBuf.pDataBuf);
817 static bool device_alloc_bufs(struct vnt_private *pDevice)
820 PUSB_SEND_CONTEXT pTxContext;
825 for (ii = 0; ii < pDevice->cbTD; ii++) {
827 pTxContext = kmalloc(sizeof(USB_SEND_CONTEXT), GFP_KERNEL);
828 if (pTxContext == NULL) {
829 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name);
832 pDevice->apTD[ii] = pTxContext;
833 pTxContext->pDevice = (void *) pDevice;
835 pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
836 if (pTxContext->pUrb == NULL) {
837 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n");
840 pTxContext->bBoolInUse = false;
843 /* allocate RCB mem */
844 pDevice->pRCBMem = kzalloc((sizeof(RCB) * pDevice->cbRD), GFP_KERNEL);
845 if (pDevice->pRCBMem == NULL) {
846 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name);
851 pDevice->FirstRecvFreeList = NULL;
852 pDevice->LastRecvFreeList = NULL;
853 pDevice->FirstRecvMngList = NULL;
854 pDevice->LastRecvMngList = NULL;
855 pDevice->NumRecvFreeList = 0;
856 pRCB = (PRCB) pDevice->pRCBMem;
858 for (ii = 0; ii < pDevice->cbRD; ii++) {
860 pDevice->apRCB[ii] = pRCB;
861 pRCB->pDevice = (void *) pDevice;
863 pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
865 if (pRCB->pUrb == NULL) {
866 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n");
869 pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
870 if (pRCB->skb == NULL) {
871 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n");
874 pRCB->skb->dev = pDevice->dev;
875 pRCB->bBoolInUse = false;
876 EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
877 pDevice->NumRecvFreeList++;
882 pDevice->pControlURB = usb_alloc_urb(0, GFP_ATOMIC);
883 if (pDevice->pControlURB == NULL) {
884 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc control urb\n");
888 pDevice->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
889 if (pDevice->pInterruptURB == NULL) {
890 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
891 usb_free_urb(pDevice->pControlURB);
895 pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
896 if (pDevice->intBuf.pDataBuf == NULL) {
897 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n");
898 usb_free_urb(pDevice->pControlURB);
899 usb_free_urb(pDevice->pInterruptURB);
906 device_free_rx_bufs(pDevice);
909 device_free_tx_bufs(pDevice);
917 static bool device_init_defrag_cb(struct vnt_private *pDevice)
920 PSDeFragControlBlock pDeF;
922 /* Init the fragment ctl entries */
923 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
924 pDeF = &(pDevice->sRxDFCB[i]);
925 if (!device_alloc_frag_buf(pDevice, pDeF)) {
926 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
931 pDevice->cbDFCB = CB_MAX_RX_FRAG;
932 pDevice->cbFreeDFCB = pDevice->cbDFCB;
936 device_free_frag_bufs(pDevice);
942 static void device_free_frag_bufs(struct vnt_private *pDevice)
944 PSDeFragControlBlock pDeF;
947 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
949 pDeF = &(pDevice->sRxDFCB[i]);
952 dev_kfree_skb(pDeF->skb);
958 int device_alloc_frag_buf(struct vnt_private *pDevice,
959 PSDeFragControlBlock pDeF)
962 pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
963 if (pDeF->skb == NULL)
966 pDeF->skb->dev = pDevice->dev;
972 /*-----------------------------------------------------------------*/
974 static int device_open(struct net_device *dev)
976 struct vnt_private *pDevice = netdev_priv(dev);
978 pDevice->fWPA_Authened = false;
980 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n");
983 pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
985 if (device_alloc_bufs(pDevice) == false) {
986 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n");
990 if (device_init_defrag_cb(pDevice)== false) {
991 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragment cb fail \n");
995 MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
996 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
997 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
998 MP_SET_FLAG(pDevice, fMP_POST_READS);
999 MP_SET_FLAG(pDevice, fMP_POST_WRITES);
1001 /* read config file */
1002 Read_config_file(pDevice);
1004 if (device_init_registers(pDevice, DEVICE_INIT_COLD) == false) {
1005 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n");
1009 device_set_multi(pDevice->dev);
1011 /* init for key management */
1012 KeyvInitTable(pDevice,&pDevice->sKey);
1013 memcpy(pDevice->vnt_mgmt.abyMACAddr,
1014 pDevice->abyCurrentNetAddr, ETH_ALEN);
1015 memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
1016 pDevice->bStopTx0Pkt = false;
1017 pDevice->bStopDataPkt = false;
1018 pDevice->bRoaming = false;
1019 pDevice->bIsRoaming = false;
1020 pDevice->bEnableRoaming = false;
1021 if (pDevice->bDiversityRegCtlON) {
1022 device_init_diversity_timer(pDevice);
1025 vMgrObjectInit(pDevice);
1026 tasklet_init(&pDevice->RxMngWorkItem, (void *)RXvMngWorkItem, (unsigned long)pDevice);
1027 tasklet_init(&pDevice->ReadWorkItem, (void *)RXvWorkItem, (unsigned long)pDevice);
1028 tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice);
1029 add_timer(&pDevice->vnt_mgmt.sTimerSecondCallback);
1030 pDevice->int_interval = 100; /* max 100 microframes */
1031 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1033 pDevice->bIsRxWorkItemQueued = true;
1034 pDevice->fKillEventPollingThread = false;
1035 pDevice->bEventAvailable = false;
1037 pDevice->bWPADEVUp = false;
1038 pDevice->bwextstep0 = false;
1039 pDevice->bwextstep1 = false;
1040 pDevice->bwextstep2 = false;
1041 pDevice->bwextstep3 = false;
1042 pDevice->bWPASuppWextEnabled = false;
1043 pDevice->byReAssocCount = 0;
1045 RXvWorkItem(pDevice);
1046 INTvWorkItem(pDevice);
1048 /* if WEP key already set by iwconfig but device not yet open */
1049 if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) {
1050 spin_lock_irq(&pDevice->lock);
1051 KeybSetDefaultKey( pDevice,
1053 pDevice->byKeyIndex | (1 << 31),
1054 pDevice->uKeyLength,
1059 spin_unlock_irq(&pDevice->lock);
1060 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1063 if (pDevice->vnt_mgmt.eConfigMode == WMAC_CONFIG_AP)
1064 bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
1066 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
1069 netif_stop_queue(pDevice->dev);
1070 pDevice->flags |= DEVICE_FLAGS_OPENED;
1072 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success..\n");
1076 device_free_frag_bufs(pDevice);
1078 device_free_rx_bufs(pDevice);
1079 device_free_tx_bufs(pDevice);
1080 device_free_int_bufs(pDevice);
1081 usb_kill_urb(pDevice->pControlURB);
1082 usb_kill_urb(pDevice->pInterruptURB);
1083 usb_free_urb(pDevice->pControlURB);
1084 usb_free_urb(pDevice->pInterruptURB);
1086 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open fail.. \n");
1092 static int device_close(struct net_device *dev)
1094 struct vnt_private *pDevice = netdev_priv(dev);
1095 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
1098 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n");
1099 if (pDevice == NULL)
1102 if (pDevice->bLinkPass) {
1103 bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
1108 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1109 pMgmt->bShareKeyAlgorithm = false;
1110 pDevice->bEncryptionEnable = false;
1111 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1112 spin_lock_irq(&pDevice->lock);
1113 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
1114 MACvDisableKeyEntry(pDevice,uu);
1115 spin_unlock_irq(&pDevice->lock);
1117 if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) {
1118 MACbShutdown(pDevice);
1120 netif_stop_queue(pDevice->dev);
1121 MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
1122 MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES);
1123 MP_CLEAR_FLAG(pDevice, fMP_POST_READS);
1124 pDevice->fKillEventPollingThread = true;
1125 del_timer(&pDevice->sTimerCommand);
1126 del_timer(&pMgmt->sTimerSecondCallback);
1128 del_timer(&pDevice->sTimerTxData);
1130 if (pDevice->bDiversityRegCtlON) {
1131 del_timer(&pDevice->TimerSQ3Tmax1);
1132 del_timer(&pDevice->TimerSQ3Tmax2);
1133 del_timer(&pDevice->TimerSQ3Tmax3);
1135 tasklet_kill(&pDevice->RxMngWorkItem);
1136 tasklet_kill(&pDevice->ReadWorkItem);
1137 tasklet_kill(&pDevice->EventWorkItem);
1139 pDevice->bRoaming = false;
1140 pDevice->bIsRoaming = false;
1141 pDevice->bEnableRoaming = false;
1142 pDevice->bCmdRunning = false;
1143 pDevice->bLinkPass = false;
1144 memset(pMgmt->abyCurrBSSID, 0, 6);
1145 pMgmt->eCurrState = WMAC_STATE_IDLE;
1147 device_free_tx_bufs(pDevice);
1148 device_free_rx_bufs(pDevice);
1149 device_free_int_bufs(pDevice);
1150 device_free_frag_bufs(pDevice);
1152 usb_kill_urb(pDevice->pControlURB);
1153 usb_kill_urb(pDevice->pInterruptURB);
1154 usb_free_urb(pDevice->pControlURB);
1155 usb_free_urb(pDevice->pInterruptURB);
1157 BSSvClearNodeDBTable(pDevice, 0);
1158 pDevice->flags &=(~DEVICE_FLAGS_OPENED);
1160 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
1165 static void vt6656_disconnect(struct usb_interface *intf)
1167 struct vnt_private *device = usb_get_intfdata(intf);
1173 usb_set_intfdata(intf, NULL);
1174 usb_put_dev(interface_to_usbdev(intf));
1176 device->flags |= DEVICE_FLAGS_UNPLUG;
1179 unregister_netdev(device->dev);
1180 free_netdev(device->dev);
1185 static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev)
1187 struct vnt_private *pDevice = netdev_priv(dev);
1189 spin_lock_irq(&pDevice->lock);
1191 if (unlikely(pDevice->bStopTx0Pkt))
1192 dev_kfree_skb_irq(skb);
1194 vDMA0_tx_80211(pDevice, skb);
1196 spin_unlock_irq(&pDevice->lock);
1198 return NETDEV_TX_OK;
1201 static int device_xmit(struct sk_buff *skb, struct net_device *dev)
1203 struct vnt_private *pDevice = netdev_priv(dev);
1204 struct net_device_stats *stats = &pDevice->stats;
1206 spin_lock_irq(&pDevice->lock);
1208 netif_stop_queue(dev);
1210 if (!pDevice->bLinkPass) {
1211 dev_kfree_skb_irq(skb);
1215 if (pDevice->bStopDataPkt) {
1216 dev_kfree_skb_irq(skb);
1217 stats->tx_dropped++;
1221 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb)) {
1222 if (netif_queue_stopped(dev))
1223 netif_wake_queue(dev);
1227 spin_unlock_irq(&pDevice->lock);
1229 return NETDEV_TX_OK;
1232 static unsigned const ethernet_polynomial = 0x04c11db7U;
1233 static inline u32 ether_crc(int length, unsigned char *data)
1237 while(--length >= 0) {
1238 unsigned char current_octet = *data++;
1240 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
1242 ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
1248 /* find out the start position of str2 from str1 */
1249 static unsigned char *kstrstr(const unsigned char *str1,
1250 const unsigned char *str2) {
1251 int str1_len = strlen(str1);
1252 int str2_len = strlen(str2);
1254 while (str1_len >= str2_len) {
1256 if(memcmp(str1,str2,str2_len)==0)
1257 return (unsigned char *) str1;
1263 static int Config_FileGetParameter(unsigned char *string,
1264 unsigned char *dest,
1265 unsigned char *source)
1267 unsigned char buf1[100];
1268 unsigned char buf2[100];
1269 unsigned char *start_p = NULL, *end_p = NULL, *tmp_p = NULL;
1273 strcat(buf1, string);
1275 source+=strlen(buf1);
1277 /* find target string start point */
1278 start_p = kstrstr(source,buf1);
1279 if (start_p == NULL)
1282 /* check if current config line is marked by "#" */
1283 for (ii = 1; ; ii++) {
1284 if (memcmp(start_p - ii, "\n", 1) == 0)
1286 if (memcmp(start_p - ii, "#", 1) == 0)
1290 /* find target string end point */
1291 end_p = kstrstr(start_p,"\n");
1292 if (end_p == NULL) { /* can't find "\n", but don't care */
1293 end_p = start_p + strlen(start_p); /* no include "\n" */
1297 memcpy(buf2, start_p, end_p-start_p); /* get the target line */
1298 buf2[end_p-start_p]='\0';
1301 start_p = kstrstr(buf2,"=");
1302 if (start_p == NULL)
1305 strcpy(buf1,start_p+1);
1309 while(*tmp_p != 0x00) {
1316 memcpy(dest,tmp_p,strlen(tmp_p));
1320 /* if read fails, return NULL, or return data pointer */
1321 static unsigned char *Config_FileOperation(struct vnt_private *pDevice)
1323 unsigned char *config_path = CONFIG_PATH;
1324 unsigned char *buffer = NULL;
1325 struct file *filp=NULL;
1326 mm_segment_t old_fs = get_fs();
1333 filp = filp_open(config_path, O_RDWR, 0);
1335 printk("Config_FileOperation file Not exist\n");
1340 if(!(filp->f_op) || !(filp->f_op->read) ||!(filp->f_op->write)) {
1341 printk("file %s is not read or writeable?\n",config_path);
1346 buffer = kmalloc(1024, GFP_KERNEL);
1348 printk("allocate mem for file fail?\n");
1353 if(filp->f_op->read(filp, buffer, 1024, &filp->f_pos)<0) {
1354 printk("read file error?\n");
1359 if(filp_close(filp,NULL))
1360 printk("Config_FileOperation:close file fail\n");
1372 /* return --->-1:fail; >=0:successful */
1373 static int Read_config_file(struct vnt_private *pDevice)
1376 unsigned char tmpbuffer[100];
1377 unsigned char *buffer = NULL;
1379 /* init config setting */
1380 pDevice->config_file.ZoneType = -1;
1381 pDevice->config_file.eAuthenMode = -1;
1382 pDevice->config_file.eEncryptionStatus = -1;
1384 buffer = Config_FileOperation(pDevice);
1385 if (buffer == NULL) {
1392 memset(tmpbuffer,0,sizeof(tmpbuffer));
1393 if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==true) {
1394 if(memcmp(tmpbuffer,"USA",3)==0) {
1395 pDevice->config_file.ZoneType=ZoneType_USA;
1397 else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
1398 pDevice->config_file.ZoneType=ZoneType_Japan;
1400 else if(memcmp(tmpbuffer,"EUROPE",6)==0) {
1401 pDevice->config_file.ZoneType=ZoneType_Europe;
1404 printk("Unknown Zonetype[%s]?\n",tmpbuffer);
1409 /* get other parameter */
1411 memset(tmpbuffer,0,sizeof(tmpbuffer));
1412 if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==true) {
1413 pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10);
1416 memset(tmpbuffer,0,sizeof(tmpbuffer));
1417 if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==true) {
1418 pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10);
1426 static void device_set_multi(struct net_device *dev)
1428 struct vnt_private *pDevice = netdev_priv(dev);
1429 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
1430 struct netdev_hw_addr *ha;
1433 u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1438 spin_lock_irq(&pDevice->lock);
1439 rc = CONTROLnsRequestIn(pDevice,
1442 MESSAGE_REQUEST_MACREG,
1446 if (rc == 0) pDevice->byRxMode = byTmpMode;
1448 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode);
1450 if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
1451 DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
1452 /* unconditionally log net taps */
1453 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
1455 else if ((netdev_mc_count(dev) > pDevice->multicast_limit) ||
1456 (dev->flags & IFF_ALLMULTI)) {
1457 CONTROLnsRequestOut(pDevice,
1460 MESSAGE_REQUEST_MACREG,
1464 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1467 memset(mc_filter, 0, sizeof(mc_filter));
1468 netdev_for_each_mc_addr(ha, dev) {
1469 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1470 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
1472 for (ii = 0; ii < 4; ii++) {
1473 MACvWriteMultiAddr(pDevice, ii, *((PBYTE)&mc_filter[0] + ii));
1474 MACvWriteMultiAddr(pDevice, ii+ 4, *((PBYTE)&mc_filter[1] + ii));
1476 pDevice->byRxMode &= ~(RCR_UNICAST);
1477 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1480 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
1482 * If AP mode, don't enable RCR_UNICAST since HW only compares
1483 * addr1 with local MAC
1485 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1486 pDevice->byRxMode &= ~(RCR_UNICAST);
1488 ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode);
1489 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode);
1490 spin_unlock_irq(&pDevice->lock);
1494 static struct net_device_stats *device_get_stats(struct net_device *dev)
1496 struct vnt_private *pDevice = netdev_priv(dev);
1498 return &pDevice->stats;
1501 static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1503 struct vnt_private *pDevice = netdev_priv(dev);
1504 struct iwreq *wrq = (struct iwreq *) rq;
1509 case IOCTL_CMD_HOSTAPD:
1511 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
1514 rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data);
1518 return ethtool_ioctl(dev, (void *) rq->ifr_data);
1526 static int ethtool_ioctl(struct net_device *dev, void *useraddr)
1530 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1534 case ETHTOOL_GDRVINFO: {
1535 struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
1536 strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
1537 strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
1538 if (copy_to_user(useraddr, &info, sizeof(info)))
1548 MODULE_DEVICE_TABLE(usb, vt6656_table);
1550 static struct usb_driver vt6656_driver = {
1551 .name = DEVICE_NAME,
1552 .probe = vt6656_probe,
1553 .disconnect = vt6656_disconnect,
1554 .id_table = vt6656_table,
1556 .suspend = vt6656_suspend,
1557 .resume = vt6656_resume,
1558 #endif /* CONFIG_PM */
1561 module_usb_driver(vt6656_driver);