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
49 #include <linux/file.h>
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");
98 #define TX_DESC_DEF0 64
99 DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
101 #define CHANNEL_DEF 6
102 DEVICE_PARAM(Channel, "Channel number");
104 /* PreambleType[] is the preamble length used for transmit.
105 0: indicate allows long preamble type
106 1: indicate allows short preamble type
109 #define PREAMBLE_TYPE_DEF 1
111 DEVICE_PARAM(PreambleType, "Preamble Type");
113 #define RTS_THRESH_DEF 2347
114 DEVICE_PARAM(RTSThreshold, "RTS threshold");
116 #define FRAG_THRESH_DEF 2346
117 DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
119 #define DATA_RATE_DEF 13
121 0: indicate 1 Mbps 0x02
122 1: indicate 2 Mbps 0x04
123 2: indicate 5.5 Mbps 0x0B
124 3: indicate 11 Mbps 0x16
125 4: indicate 6 Mbps 0x0c
126 5: indicate 9 Mbps 0x12
127 6: indicate 12 Mbps 0x18
128 7: indicate 18 Mbps 0x24
129 8: indicate 24 Mbps 0x30
130 9: indicate 36 Mbps 0x48
131 10: indicate 48 Mbps 0x60
132 11: indicate 54 Mbps 0x6c
133 12: indicate 72 Mbps 0x90
134 13: indicate auto rate
137 DEVICE_PARAM(ConnectionRate, "Connection data rate");
139 #define OP_MODE_DEF 0
140 DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
142 /* OpMode[] is used for transmit.
143 0: indicate infrastruct mode used
144 1: indicate adhoc mode used
145 2: indicate AP mode used
149 0: indicate disable power saving mode
150 1: indicate enable power saving mode
153 #define PS_MODE_DEF 0
154 DEVICE_PARAM(PSMode, "Power saving mode");
156 #define SHORT_RETRY_DEF 8
157 DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
159 #define LONG_RETRY_DEF 4
160 DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
162 /* BasebandType[] baseband type selected
163 0: indicate 802.11a type
164 1: indicate 802.11b type
165 2: indicate 802.11g type
168 #define BBP_TYPE_DEF 2
169 DEVICE_PARAM(BasebandType, "baseband type");
172 0: indicate disable 802.11h
173 1: indicate enable 802.11h
176 #define X80211h_MODE_DEF 0
178 DEVICE_PARAM(b80211hEnable, "802.11h mode");
181 * Static vars definitions
184 static struct usb_device_id vt6656_table[] = {
185 {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)},
189 /* frequency list (map channels to frequencies) */
191 static const long frequency_list[] = {
192 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
193 4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
194 5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
195 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
196 5700, 5745, 5765, 5785, 5805, 5825
199 static const struct iw_handler_def iwctl_handler_def;
202 static int vt6656_probe(struct usb_interface *intf,
203 const struct usb_device_id *id);
204 static void vt6656_disconnect(struct usb_interface *intf);
206 #ifdef CONFIG_PM /* Minimal support for suspend and resume */
207 static int vt6656_suspend(struct usb_interface *intf, pm_message_t message);
208 static int vt6656_resume(struct usb_interface *intf);
209 #endif /* CONFIG_PM */
211 static struct net_device_stats *device_get_stats(struct net_device *dev);
212 static int device_open(struct net_device *dev);
213 static int device_xmit(struct sk_buff *skb, struct net_device *dev);
214 static void device_set_multi(struct net_device *dev);
215 static int device_close(struct net_device *dev);
216 static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
218 static int device_init_registers(struct vnt_private *pDevice,
219 DEVICE_INIT_TYPE InitType);
220 static bool device_init_defrag_cb(struct vnt_private *pDevice);
221 static void device_init_diversity_timer(struct vnt_private *pDevice);
222 static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev);
224 static int ethtool_ioctl(struct net_device *dev, void *useraddr);
225 static void device_free_tx_bufs(struct vnt_private *pDevice);
226 static void device_free_rx_bufs(struct vnt_private *pDevice);
227 static void device_free_int_bufs(struct vnt_private *pDevice);
228 static void device_free_frag_bufs(struct vnt_private *pDevice);
229 static bool device_alloc_bufs(struct vnt_private *pDevice);
231 static int Read_config_file(struct vnt_private *pDevice);
232 static unsigned char *Config_FileOperation(struct vnt_private *pDevice);
233 static int Config_FileGetParameter(unsigned char *string,
235 unsigned char *source);
237 static void usb_device_reset(struct vnt_private *pDevice);
240 device_set_options(struct vnt_private *pDevice) {
242 u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
243 u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
244 u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
246 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
247 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
248 memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN);
250 pDevice->cbTD = TX_DESC_DEF0;
251 pDevice->cbRD = RX_DESC_DEF0;
252 pDevice->uChannel = CHANNEL_DEF;
253 pDevice->wRTSThreshold = RTS_THRESH_DEF;
254 pDevice->wFragmentationThreshold = FRAG_THRESH_DEF;
255 pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
256 pDevice->byLongRetryLimit = LONG_RETRY_DEF;
257 pDevice->wMaxTransmitMSDULifetime = DEFAULT_MSDU_LIFETIME;
258 pDevice->byShortPreamble = PREAMBLE_TYPE_DEF;
259 pDevice->ePSMode = PS_MODE_DEF;
260 pDevice->b11hEnable = X80211h_MODE_DEF;
261 pDevice->eOPMode = OP_MODE_DEF;
262 pDevice->uConnectionRate = DATA_RATE_DEF;
263 if (pDevice->uConnectionRate < RATE_AUTO) pDevice->bFixRate = true;
264 pDevice->byBBType = BBP_TYPE_DEF;
265 pDevice->byPacketType = pDevice->byBBType;
266 pDevice->byAutoFBCtrl = AUTO_FB_0;
267 pDevice->bUpdateBBVGA = true;
268 pDevice->byFOETuning = 0;
269 pDevice->byAutoPwrTunning = 0;
270 pDevice->byPreambleType = 0;
271 pDevice->bExistSWNetAddr = false;
272 /* pDevice->bDiversityRegCtlON = true; */
273 pDevice->bDiversityRegCtlON = false;
276 static void device_init_diversity_timer(struct vnt_private *pDevice)
278 init_timer(&pDevice->TimerSQ3Tmax1);
279 pDevice->TimerSQ3Tmax1.data = (unsigned long)pDevice;
280 pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack;
281 pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ);
283 init_timer(&pDevice->TimerSQ3Tmax2);
284 pDevice->TimerSQ3Tmax2.data = (unsigned long)pDevice;
285 pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack;
286 pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ);
288 init_timer(&pDevice->TimerSQ3Tmax3);
289 pDevice->TimerSQ3Tmax3.data = (unsigned long)pDevice;
290 pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerSQ3Tmax3CallBack;
291 pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ);
297 * initialization of MAC & BBP registers
300 static int device_init_registers(struct vnt_private *pDevice,
301 DEVICE_INIT_TYPE InitType)
303 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
304 u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
305 u8 abySNAP_RFC1042[ETH_ALEN] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
306 u8 abySNAP_Bridgetunnel[ETH_ALEN]
307 = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
310 CMD_CARD_INIT sInitCmd;
311 int ntStatus = STATUS_SUCCESS;
312 RSP_CARD_INIT sInitRsp;
314 u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0;
316 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType);
317 spin_lock_irq(&pDevice->lock);
318 if (InitType == DEVICE_INIT_COLD) {
319 memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN);
320 memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN);
321 memcpy(pDevice->abySNAP_Bridgetunnel,
322 abySNAP_Bridgetunnel,
325 if ( !FIRMWAREbCheckVersion(pDevice) ) {
326 if (FIRMWAREbDownload(pDevice) == true) {
327 if (FIRMWAREbBrach2Sram(pDevice) == false) {
328 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbBrach2Sram fail \n");
329 spin_unlock_irq(&pDevice->lock);
334 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" FIRMWAREbDownload fail \n");
335 spin_unlock_irq(&pDevice->lock);
340 if ( !BBbVT3184Init(pDevice) ) {
341 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail \n");
342 spin_unlock_irq(&pDevice->lock);
347 sInitCmd.byInitClass = (u8)InitType;
348 sInitCmd.bExistSWNetAddr = (u8) pDevice->bExistSWNetAddr;
349 for (ii = 0; ii < 6; ii++)
350 sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii];
351 sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit;
352 sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit;
354 /* issue card_init command to device */
355 ntStatus = CONTROLnsRequestOut(pDevice,
356 MESSAGE_TYPE_CARDINIT,
359 sizeof(CMD_CARD_INIT),
362 if ( ntStatus != STATUS_SUCCESS ) {
363 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail \n");
364 spin_unlock_irq(&pDevice->lock);
367 if (InitType == DEVICE_INIT_COLD) {
369 ntStatus = CONTROLnsRequestIn(pDevice,MESSAGE_TYPE_INIT_RSP,0,0,sizeof(RSP_CARD_INIT), (u8 *) &(sInitRsp));
371 if (ntStatus != STATUS_SUCCESS) {
372 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Cardinit request in status fail!\n");
373 spin_unlock_irq(&pDevice->lock);
377 /* local ID for AES functions */
378 ntStatus = CONTROLnsRequestIn(pDevice,
381 MESSAGE_REQUEST_MACREG,
383 &pDevice->byLocalID);
385 if ( ntStatus != STATUS_SUCCESS ) {
386 spin_unlock_irq(&pDevice->lock);
390 /* do MACbSoftwareReset in MACvInitialize */
393 pDevice->bCCK = true;
394 pDevice->bProtectMode = false;
395 /* only used in 11g type, sync with ERP IE */
396 pDevice->bNonERPPresent = false;
397 pDevice->bBarkerPreambleMd = false;
398 if ( pDevice->bFixRate ) {
399 pDevice->wCurrentRate = (u16) pDevice->uConnectionRate;
401 if ( pDevice->byBBType == BB_TYPE_11B )
402 pDevice->wCurrentRate = RATE_11M;
404 pDevice->wCurrentRate = RATE_54M;
407 CHvInitChannelTable(pDevice);
409 pDevice->byTopOFDMBasicRate = RATE_24M;
410 pDevice->byTopCCKBasicRate = RATE_1M;
411 pDevice->byRevId = 0;
412 /* target to IF pin while programming to RF chip */
413 pDevice->byCurPwr = 0xFF;
415 pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
416 pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
417 /* load power table */
418 for (ii = 0; ii < 14; ii++) {
419 pDevice->abyCCKPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
420 if (pDevice->abyCCKPwrTbl[ii] == 0)
421 pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
422 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
423 if (pDevice->abyOFDMPwrTbl[ii] == 0)
424 pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
428 * original zonetype is USA, but custom zonetype is Europe,
429 * then need to recover 12, 13, 14 channels with 11 channel
431 if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) ||
432 (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&&
433 (pDevice->byOriginalZonetype == ZoneType_USA)) {
434 for (ii = 11; ii < 14; ii++) {
435 pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
436 pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
440 pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */
442 /* load OFDM A power table */
443 for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) {
444 pDevice->abyOFDMAPwrTbl[ii] = pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
445 if (pDevice->abyOFDMAPwrTbl[ii] == 0)
446 pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
449 byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
450 if (byAntenna & EEP_ANTINV)
451 pDevice->bTxRxAntInv = true;
453 pDevice->bTxRxAntInv = false;
455 byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
457 if (byAntenna == 0) /* if not set default is both */
458 byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
460 if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
461 pDevice->byAntennaCount = 2;
462 pDevice->byTxAntennaMode = ANT_B;
463 pDevice->dwTxAntennaSel = 1;
464 pDevice->dwRxAntennaSel = 1;
465 if (pDevice->bTxRxAntInv == true)
466 pDevice->byRxAntennaMode = ANT_A;
468 pDevice->byRxAntennaMode = ANT_B;
470 if (pDevice->bDiversityRegCtlON)
471 pDevice->bDiversityEnable = true;
473 pDevice->bDiversityEnable = false;
475 pDevice->bDiversityEnable = false;
476 pDevice->byAntennaCount = 1;
477 pDevice->dwTxAntennaSel = 0;
478 pDevice->dwRxAntennaSel = 0;
479 if (byAntenna & EEP_ANTENNA_AUX) {
480 pDevice->byTxAntennaMode = ANT_A;
481 if (pDevice->bTxRxAntInv == true)
482 pDevice->byRxAntennaMode = ANT_B;
484 pDevice->byRxAntennaMode = ANT_A;
486 pDevice->byTxAntennaMode = ANT_B;
487 if (pDevice->bTxRxAntInv == true)
488 pDevice->byRxAntennaMode = ANT_A;
490 pDevice->byRxAntennaMode = ANT_B;
493 pDevice->ulDiversityNValue = 100*255;
494 pDevice->ulDiversityMValue = 100*16;
496 pDevice->byTMax2 = 4;
497 pDevice->ulSQ3TH = 0;
498 pDevice->byTMax3 = 64;
500 /* get Auto Fall Back type */
501 pDevice->byAutoFBCtrl = AUTO_FB_0;
504 pDevice->uScanTime = WLAN_SCAN_MINITIME;
506 /* default Auto Mode */
507 /* pDevice->NetworkType = Ndis802_11Automode; */
508 pDevice->eConfigPHYMode = PHY_TYPE_AUTO;
509 pDevice->byBBType = BB_TYPE_11G;
511 /* initialize BBP registers */
512 pDevice->ulTxPower = 25;
514 /* get channel range */
515 pDevice->byMinChannel = 1;
516 pDevice->byMaxChannel = CB_MAX_CHANNEL;
519 pDevice->byRFType = sInitRsp.byRFType;
521 if ((pDevice->byRFType & RF_EMU) != 0) {
522 /* force change RevID for VT3253 emu */
523 pDevice->byRevId = 0x80;
526 /* load vt3266 calibration parameters in EEPROM */
527 if (pDevice->byRFType == RF_VT3226D0) {
528 if((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
529 (pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
530 byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
531 byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
532 byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
533 if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) {
534 /* CR255, enable TX/RX IQ and DC compensation mode */
535 ControlvWriteByte(pDevice,
536 MESSAGE_REQUEST_BBREG,
539 /* CR251, TX I/Q Imbalance Calibration */
540 ControlvWriteByte(pDevice,
541 MESSAGE_REQUEST_BBREG,
544 /* CR252, TX DC-Offset Calibration */
545 ControlvWriteByte(pDevice,
546 MESSAGE_REQUEST_BBREG,
549 /* CR253, RX I/Q Imbalance Calibration */
550 ControlvWriteByte(pDevice,
551 MESSAGE_REQUEST_BBREG,
555 /* CR255, turn off BB Calibration compensation */
556 ControlvWriteByte(pDevice,
557 MESSAGE_REQUEST_BBREG,
563 pMgmt->eScanType = WMAC_SCAN_PASSIVE;
564 pMgmt->uCurrChannel = pDevice->uChannel;
565 pMgmt->uIBSSChannel = pDevice->uChannel;
566 CARDbSetMediaChannel(pDevice, pMgmt->uCurrChannel);
568 /* get permanent network address */
569 memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6);
570 memcpy(pDevice->abyCurrentNetAddr,
571 pDevice->abyPermanentNetAddr,
574 /* if exist SW network address, use it */
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n",
576 pDevice->abyCurrentNetAddr);
580 * set BB and packet type at the same time
581 * set Short Slot Time, xIFS, and RSPINF
583 if (pDevice->byBBType == BB_TYPE_11A) {
584 CARDbAddBasicRate(pDevice, RATE_6M);
585 pDevice->bShortSlotTime = true;
587 CARDbAddBasicRate(pDevice, RATE_1M);
588 pDevice->bShortSlotTime = false;
590 BBvSetShortSlotTime(pDevice);
591 CARDvSetBSSMode(pDevice);
593 if (pDevice->bUpdateBBVGA) {
594 pDevice->byBBVGACurrent = pDevice->abyBBVGA[0];
595 pDevice->byBBVGANew = pDevice->byBBVGACurrent;
596 BBvSetVGAGainOffset(pDevice, pDevice->abyBBVGA[0]);
599 pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
600 pDevice->bHWRadioOff = false;
601 if ( (pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0 ) {
602 ntStatus = CONTROLnsRequestIn(pDevice,
605 MESSAGE_REQUEST_MACREG,
609 if ( ntStatus != STATUS_SUCCESS ) {
610 spin_unlock_irq(&pDevice->lock);
613 if ( (byTmp & GPIO3_DATA) == 0 ) {
614 pDevice->bHWRadioOff = true;
615 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
617 MACvRegBitsOff(pDevice,MAC_REG_GPIOCTL1,GPIO3_INTMD);
618 pDevice->bHWRadioOff = false;
623 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_TMLEN,0x38);
624 ControlvMaskByte(pDevice,MESSAGE_REQUEST_MACREG,MAC_REG_PAPEDELAY,LEDSTS_STS,LEDSTS_SLOW);
625 MACvRegBitsOn(pDevice,MAC_REG_GPIOCTL0,0x01);
627 if ((pDevice->bHWRadioOff == true) || (pDevice->bRadioControlOff == true)) {
628 CARDbRadioPowerOff(pDevice);
630 CARDbRadioPowerOn(pDevice);
633 spin_unlock_irq(&pDevice->lock);
634 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
638 #ifdef CONFIG_PM /* Minimal support for suspend and resume */
640 static int vt6656_suspend(struct usb_interface *intf, pm_message_t message)
642 struct vnt_private *device = usb_get_intfdata(intf);
644 if (!device || !device->dev)
647 if (device->flags & DEVICE_FLAGS_OPENED)
648 device_close(device->dev);
653 static int vt6656_resume(struct usb_interface *intf)
655 struct vnt_private *device = usb_get_intfdata(intf);
657 if (!device || !device->dev)
660 if (!(device->flags & DEVICE_FLAGS_OPENED))
661 device_open(device->dev);
666 #endif /* CONFIG_PM */
668 static const struct net_device_ops device_netdev_ops = {
669 .ndo_open = device_open,
670 .ndo_stop = device_close,
671 .ndo_do_ioctl = device_ioctl,
672 .ndo_get_stats = device_get_stats,
673 .ndo_start_xmit = device_xmit,
674 .ndo_set_rx_mode = device_set_multi,
678 vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
680 u8 fake_mac[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
681 struct usb_device *udev = interface_to_usbdev(intf);
683 struct net_device *netdev = NULL;
684 struct vnt_private *pDevice;
686 printk(KERN_NOTICE "%s Ver. %s\n", DEVICE_FULL_DRV_NAM, DEVICE_VERSION);
687 printk(KERN_NOTICE "Copyright (c) 2004 VIA Networking Technologies, Inc.\n");
689 udev = usb_get_dev(udev);
690 netdev = alloc_etherdev(sizeof(struct vnt_private));
692 printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n");
697 pDevice = netdev_priv(netdev);
698 memset(pDevice, 0, sizeof(struct vnt_private));
700 pDevice->dev = netdev;
703 device_set_options(pDevice);
704 spin_lock_init(&pDevice->lock);
705 INIT_DELAYED_WORK(&pDevice->run_command_work, vRunCommand);
706 INIT_DELAYED_WORK(&pDevice->second_callback_work, BSSvSecondCallBack);
707 INIT_WORK(&pDevice->read_work_item, RXvWorkItem);
708 INIT_WORK(&pDevice->rx_mng_work_item, RXvMngWorkItem);
710 pDevice->pControlURB = usb_alloc_urb(0, GFP_ATOMIC);
711 if (!pDevice->pControlURB) {
712 DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc control urb\n");
716 pDevice->tx_80211 = device_dma0_tx_80211;
717 pDevice->vnt_mgmt.pAdapter = (void *) pDevice;
719 netdev->netdev_ops = &device_netdev_ops;
720 netdev->wireless_handlers =
721 (struct iw_handler_def *) &iwctl_handler_def;
723 usb_set_intfdata(intf, pDevice);
724 SET_NETDEV_DEV(netdev, &intf->dev);
725 memcpy(pDevice->dev->dev_addr, fake_mac, ETH_ALEN);
726 rc = register_netdev(netdev);
728 printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
732 usb_device_reset(pDevice);
744 static void device_free_tx_bufs(struct vnt_private *pDevice)
746 struct vnt_usb_send_context *pTxContext;
749 for (ii = 0; ii < pDevice->cbTD; ii++) {
751 pTxContext = pDevice->apTD[ii];
752 /* deallocate URBs */
753 if (pTxContext->pUrb) {
754 usb_kill_urb(pTxContext->pUrb);
755 usb_free_urb(pTxContext->pUrb);
762 static void device_free_rx_bufs(struct vnt_private *pDevice)
764 struct vnt_rcb *pRCB;
767 for (ii = 0; ii < pDevice->cbRD; ii++) {
769 pRCB = pDevice->apRCB[ii];
770 /* deallocate URBs */
772 usb_kill_urb(pRCB->pUrb);
773 usb_free_urb(pRCB->pUrb);
777 dev_kfree_skb(pRCB->skb);
779 kfree(pDevice->pRCBMem);
784 static void usb_device_reset(struct vnt_private *pDevice)
787 status = usb_reset_device(pDevice->usb);
789 printk("usb_device_reset fail status=%d\n",status);
793 static void device_free_int_bufs(struct vnt_private *pDevice)
795 kfree(pDevice->intBuf.pDataBuf);
799 static bool device_alloc_bufs(struct vnt_private *pDevice)
801 struct vnt_usb_send_context *pTxContext;
802 struct vnt_rcb *pRCB;
805 for (ii = 0; ii < pDevice->cbTD; ii++) {
807 pTxContext = kmalloc(sizeof(struct vnt_usb_send_context), GFP_KERNEL);
808 if (pTxContext == NULL) {
809 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name);
812 pDevice->apTD[ii] = pTxContext;
813 pTxContext->pDevice = (void *) pDevice;
815 pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
816 if (pTxContext->pUrb == NULL) {
817 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n");
820 pTxContext->bBoolInUse = false;
823 /* allocate RCB mem */
824 pDevice->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * pDevice->cbRD),
826 if (pDevice->pRCBMem == NULL) {
827 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name);
831 pDevice->FirstRecvFreeList = NULL;
832 pDevice->LastRecvFreeList = NULL;
833 pDevice->FirstRecvMngList = NULL;
834 pDevice->LastRecvMngList = NULL;
835 pDevice->NumRecvFreeList = 0;
837 pRCB = (struct vnt_rcb *)pDevice->pRCBMem;
839 for (ii = 0; ii < pDevice->cbRD; ii++) {
841 pDevice->apRCB[ii] = pRCB;
842 pRCB->pDevice = (void *) pDevice;
844 pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
846 if (pRCB->pUrb == NULL) {
847 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n");
850 pRCB->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
851 if (pRCB->skb == NULL) {
852 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n");
855 pRCB->skb->dev = pDevice->dev;
856 pRCB->bBoolInUse = false;
857 EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
858 pDevice->NumRecvFreeList++;
862 pDevice->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
863 if (pDevice->pInterruptURB == NULL) {
864 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
868 pDevice->intBuf.pDataBuf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
869 if (pDevice->intBuf.pDataBuf == NULL) {
870 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n");
871 usb_free_urb(pDevice->pInterruptURB);
878 device_free_rx_bufs(pDevice);
881 device_free_tx_bufs(pDevice);
886 static bool device_init_defrag_cb(struct vnt_private *pDevice)
889 PSDeFragControlBlock pDeF;
891 /* Init the fragment ctl entries */
892 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
893 pDeF = &(pDevice->sRxDFCB[i]);
894 if (!device_alloc_frag_buf(pDevice, pDeF)) {
895 DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc frag bufs\n",
900 pDevice->cbDFCB = CB_MAX_RX_FRAG;
901 pDevice->cbFreeDFCB = pDevice->cbDFCB;
905 device_free_frag_bufs(pDevice);
909 static void device_free_frag_bufs(struct vnt_private *pDevice)
911 PSDeFragControlBlock pDeF;
914 for (i = 0; i < CB_MAX_RX_FRAG; i++) {
916 pDeF = &(pDevice->sRxDFCB[i]);
919 dev_kfree_skb(pDeF->skb);
923 int device_alloc_frag_buf(struct vnt_private *pDevice,
924 PSDeFragControlBlock pDeF)
927 pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
928 if (pDeF->skb == NULL)
930 pDeF->skb->dev = pDevice->dev;
935 static int device_open(struct net_device *dev)
937 struct vnt_private *pDevice = netdev_priv(dev);
939 pDevice->fWPA_Authened = false;
941 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_open...\n");
943 pDevice->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS;
945 if (device_alloc_bufs(pDevice) == false) {
946 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " device_alloc_bufs fail... \n");
950 if (device_init_defrag_cb(pDevice)== false) {
951 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " Initial defragment cb fail \n");
955 MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
956 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
957 MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
958 MP_SET_FLAG(pDevice, fMP_POST_READS);
959 MP_SET_FLAG(pDevice, fMP_POST_WRITES);
961 /* read config file */
962 Read_config_file(pDevice);
964 if (device_init_registers(pDevice, DEVICE_INIT_COLD) == false) {
965 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " init register fail\n");
969 device_set_multi(pDevice->dev);
971 /* init for key management */
972 KeyvInitTable(pDevice,&pDevice->sKey);
973 memcpy(pDevice->vnt_mgmt.abyMACAddr,
974 pDevice->abyCurrentNetAddr, ETH_ALEN);
975 memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN);
976 pDevice->bStopTx0Pkt = false;
977 pDevice->bStopDataPkt = false;
978 pDevice->bRoaming = false;
979 pDevice->bIsRoaming = false;
980 pDevice->bEnableRoaming = false;
981 if (pDevice->bDiversityRegCtlON) {
982 device_init_diversity_timer(pDevice);
985 vMgrObjectInit(pDevice);
987 tasklet_init(&pDevice->EventWorkItem, (void *)INTvWorkItem, (unsigned long)pDevice);
989 schedule_delayed_work(&pDevice->second_callback_work, HZ);
991 pDevice->int_interval = 100; /* max 100 microframes */
992 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
994 pDevice->bIsRxWorkItemQueued = true;
995 pDevice->fKillEventPollingThread = false;
996 pDevice->bEventAvailable = false;
998 pDevice->bWPADEVUp = false;
999 pDevice->bwextstep0 = false;
1000 pDevice->bwextstep1 = false;
1001 pDevice->bwextstep2 = false;
1002 pDevice->bwextstep3 = false;
1003 pDevice->bWPASuppWextEnabled = false;
1004 pDevice->byReAssocCount = 0;
1006 schedule_work(&pDevice->read_work_item);
1007 INTvWorkItem(pDevice);
1009 /* if WEP key already set by iwconfig but device not yet open */
1010 if ((pDevice->bEncryptionEnable == true) && (pDevice->bTransmitKey == true)) {
1011 spin_lock_irq(&pDevice->lock);
1012 KeybSetDefaultKey( pDevice,
1014 pDevice->byKeyIndex | (1 << 31),
1015 pDevice->uKeyLength,
1020 spin_unlock_irq(&pDevice->lock);
1021 pDevice->eEncryptionStatus = Ndis802_11Encryption1Enabled;
1024 if (pDevice->vnt_mgmt.eConfigMode == WMAC_CONFIG_AP)
1025 bScheduleCommand((void *) pDevice, WLAN_CMD_RUN_AP, NULL);
1027 bScheduleCommand((void *) pDevice, WLAN_CMD_BSSID_SCAN, NULL);
1029 netif_stop_queue(pDevice->dev);
1030 pDevice->flags |= DEVICE_FLAGS_OPENED;
1032 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open success..\n");
1036 device_free_frag_bufs(pDevice);
1038 device_free_rx_bufs(pDevice);
1039 device_free_tx_bufs(pDevice);
1040 device_free_int_bufs(pDevice);
1041 usb_kill_urb(pDevice->pInterruptURB);
1042 usb_free_urb(pDevice->pInterruptURB);
1044 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_open fail.. \n");
1048 static int device_close(struct net_device *dev)
1050 struct vnt_private *pDevice = netdev_priv(dev);
1051 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
1054 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close1\n");
1055 if (pDevice == NULL)
1058 if (pDevice->bLinkPass) {
1059 bScheduleCommand((void *) pDevice, WLAN_CMD_DISASSOCIATE, NULL);
1063 memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1);
1064 pMgmt->bShareKeyAlgorithm = false;
1065 pDevice->bEncryptionEnable = false;
1066 pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled;
1067 spin_lock_irq(&pDevice->lock);
1068 for (uu = 0; uu < MAX_KEY_TABLE; uu++)
1069 MACvDisableKeyEntry(pDevice,uu);
1070 spin_unlock_irq(&pDevice->lock);
1072 if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == false) {
1073 MACbShutdown(pDevice);
1075 netif_stop_queue(pDevice->dev);
1076 MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
1077 MP_CLEAR_FLAG(pDevice, fMP_POST_WRITES);
1078 MP_CLEAR_FLAG(pDevice, fMP_POST_READS);
1079 pDevice->fKillEventPollingThread = true;
1081 cancel_delayed_work_sync(&pDevice->run_command_work);
1082 cancel_delayed_work_sync(&pDevice->second_callback_work);
1084 del_timer(&pDevice->sTimerTxData);
1086 if (pDevice->bDiversityRegCtlON) {
1087 del_timer(&pDevice->TimerSQ3Tmax1);
1088 del_timer(&pDevice->TimerSQ3Tmax2);
1089 del_timer(&pDevice->TimerSQ3Tmax3);
1092 cancel_work_sync(&pDevice->rx_mng_work_item);
1093 cancel_work_sync(&pDevice->read_work_item);
1095 tasklet_kill(&pDevice->EventWorkItem);
1097 pDevice->bRoaming = false;
1098 pDevice->bIsRoaming = false;
1099 pDevice->bEnableRoaming = false;
1100 pDevice->bCmdRunning = false;
1101 pDevice->bLinkPass = false;
1102 memset(pMgmt->abyCurrBSSID, 0, 6);
1103 pMgmt->eCurrState = WMAC_STATE_IDLE;
1105 pDevice->flags &= ~DEVICE_FLAGS_OPENED;
1107 device_free_tx_bufs(pDevice);
1108 device_free_rx_bufs(pDevice);
1109 device_free_int_bufs(pDevice);
1110 device_free_frag_bufs(pDevice);
1112 usb_kill_urb(pDevice->pInterruptURB);
1113 usb_free_urb(pDevice->pInterruptURB);
1115 BSSvClearNodeDBTable(pDevice, 0);
1117 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_close2 \n");
1122 static void vt6656_disconnect(struct usb_interface *intf)
1124 struct vnt_private *device = usb_get_intfdata(intf);
1129 usb_set_intfdata(intf, NULL);
1130 usb_put_dev(interface_to_usbdev(intf));
1132 device->flags |= DEVICE_FLAGS_UNPLUG;
1135 unregister_netdev(device->dev);
1137 usb_kill_urb(device->pControlURB);
1138 usb_free_urb(device->pControlURB);
1140 free_netdev(device->dev);
1144 static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev)
1146 struct vnt_private *pDevice = netdev_priv(dev);
1148 spin_lock_irq(&pDevice->lock);
1150 if (unlikely(pDevice->bStopTx0Pkt))
1151 dev_kfree_skb_irq(skb);
1153 vDMA0_tx_80211(pDevice, skb);
1155 spin_unlock_irq(&pDevice->lock);
1157 return NETDEV_TX_OK;
1160 static int device_xmit(struct sk_buff *skb, struct net_device *dev)
1162 struct vnt_private *pDevice = netdev_priv(dev);
1163 struct net_device_stats *stats = &pDevice->stats;
1165 spin_lock_irq(&pDevice->lock);
1167 netif_stop_queue(dev);
1169 if (!pDevice->bLinkPass) {
1170 dev_kfree_skb_irq(skb);
1174 if (pDevice->bStopDataPkt) {
1175 dev_kfree_skb_irq(skb);
1176 stats->tx_dropped++;
1180 if (nsDMA_tx_packet(pDevice, TYPE_AC0DMA, skb)) {
1181 if (netif_queue_stopped(dev))
1182 netif_wake_queue(dev);
1186 spin_unlock_irq(&pDevice->lock);
1188 return NETDEV_TX_OK;
1191 static unsigned const ethernet_polynomial = 0x04c11db7U;
1192 static inline u32 ether_crc(int length, unsigned char *data)
1196 while(--length >= 0) {
1197 unsigned char current_octet = *data++;
1199 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
1201 ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
1207 /* find out the start position of str2 from str1 */
1208 static unsigned char *kstrstr(const unsigned char *str1,
1209 const unsigned char *str2) {
1210 int str1_len = strlen(str1);
1211 int str2_len = strlen(str2);
1213 while (str1_len >= str2_len) {
1215 if(memcmp(str1,str2,str2_len)==0)
1216 return (unsigned char *) str1;
1222 static int Config_FileGetParameter(unsigned char *string,
1223 unsigned char *dest,
1224 unsigned char *source)
1226 unsigned char buf1[100];
1227 unsigned char buf2[100];
1228 unsigned char *start_p = NULL, *end_p = NULL, *tmp_p = NULL;
1232 strcat(buf1, string);
1234 source+=strlen(buf1);
1236 /* find target string start point */
1237 start_p = kstrstr(source,buf1);
1238 if (start_p == NULL)
1241 /* check if current config line is marked by "#" */
1242 for (ii = 1; ; ii++) {
1243 if (memcmp(start_p - ii, "\n", 1) == 0)
1245 if (memcmp(start_p - ii, "#", 1) == 0)
1249 /* find target string end point */
1250 end_p = kstrstr(start_p,"\n");
1251 if (end_p == NULL) { /* can't find "\n", but don't care */
1252 end_p = start_p + strlen(start_p); /* no include "\n" */
1256 memcpy(buf2, start_p, end_p-start_p); /* get the target line */
1257 buf2[end_p-start_p]='\0';
1260 start_p = kstrstr(buf2,"=");
1261 if (start_p == NULL)
1264 strcpy(buf1,start_p+1);
1268 while(*tmp_p != 0x00) {
1275 memcpy(dest,tmp_p,strlen(tmp_p));
1279 /* if read fails, return NULL, or return data pointer */
1280 static unsigned char *Config_FileOperation(struct vnt_private *pDevice)
1282 unsigned char *buffer = kmalloc(1024, GFP_KERNEL);
1286 printk("allocate mem for file fail?\n");
1290 file = filp_open(CONFIG_PATH, O_RDONLY, 0);
1293 printk("Config_FileOperation file Not exist\n");
1297 if (kernel_read(file, 0, buffer, 1024) < 0) {
1298 printk("read file error?\n");
1307 /* return --->-1:fail; >=0:successful */
1308 static int Read_config_file(struct vnt_private *pDevice)
1311 unsigned char tmpbuffer[100];
1312 unsigned char *buffer = NULL;
1314 /* init config setting */
1315 pDevice->config_file.ZoneType = -1;
1316 pDevice->config_file.eAuthenMode = -1;
1317 pDevice->config_file.eEncryptionStatus = -1;
1319 buffer = Config_FileOperation(pDevice);
1320 if (buffer == NULL) {
1327 memset(tmpbuffer,0,sizeof(tmpbuffer));
1328 if(Config_FileGetParameter("ZONETYPE",tmpbuffer,buffer) ==true) {
1329 if(memcmp(tmpbuffer,"USA",3)==0) {
1330 pDevice->config_file.ZoneType=ZoneType_USA;
1332 else if(memcmp(tmpbuffer,"JAPAN",5)==0) {
1333 pDevice->config_file.ZoneType=ZoneType_Japan;
1335 else if(memcmp(tmpbuffer,"EUROPE",6)==0) {
1336 pDevice->config_file.ZoneType=ZoneType_Europe;
1339 printk("Unknown Zonetype[%s]?\n",tmpbuffer);
1344 /* get other parameter */
1346 memset(tmpbuffer,0,sizeof(tmpbuffer));
1347 if(Config_FileGetParameter("AUTHENMODE",tmpbuffer,buffer)==true) {
1348 pDevice->config_file.eAuthenMode = (int) simple_strtol(tmpbuffer, NULL, 10);
1351 memset(tmpbuffer,0,sizeof(tmpbuffer));
1352 if(Config_FileGetParameter("ENCRYPTIONMODE",tmpbuffer,buffer)==true) {
1353 pDevice->config_file.eEncryptionStatus= (int) simple_strtol(tmpbuffer, NULL, 10);
1361 static void device_set_multi(struct net_device *dev)
1363 struct vnt_private *pDevice = netdev_priv(dev);
1364 struct vnt_manager *pMgmt = &pDevice->vnt_mgmt;
1365 struct netdev_hw_addr *ha;
1368 u8 pbyData[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1372 spin_lock_irq(&pDevice->lock);
1373 rc = CONTROLnsRequestIn(pDevice,
1376 MESSAGE_REQUEST_MACREG,
1380 if (rc == 0) pDevice->byRxMode = byTmpMode;
1382 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode in= %x\n", pDevice->byRxMode);
1384 if (dev->flags & IFF_PROMISC) { /* set promiscuous mode */
1385 DBG_PRT(MSG_LEVEL_ERR,KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
1386 /* unconditionally log net taps */
1387 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST|RCR_UNICAST);
1389 else if ((netdev_mc_count(dev) > pDevice->multicast_limit) ||
1390 (dev->flags & IFF_ALLMULTI)) {
1391 CONTROLnsRequestOut(pDevice,
1394 MESSAGE_REQUEST_MACREG,
1398 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1401 memset(mc_filter, 0, sizeof(mc_filter));
1402 netdev_for_each_mc_addr(ha, dev) {
1403 int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
1404 mc_filter[bit_nr >> 5] |= cpu_to_le32(1 << (bit_nr & 31));
1406 for (ii = 0; ii < 4; ii++) {
1407 MACvWriteMultiAddr(pDevice, ii, *((u8 *)&mc_filter[0] + ii));
1408 MACvWriteMultiAddr(pDevice, ii+ 4, *((u8 *)&mc_filter[1] + ii));
1410 pDevice->byRxMode &= ~(RCR_UNICAST);
1411 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1414 if (pMgmt->eConfigMode == WMAC_CONFIG_AP) {
1416 * If AP mode, don't enable RCR_UNICAST since HW only compares
1417 * addr1 with local MAC
1419 pDevice->byRxMode |= (RCR_MULTICAST|RCR_BROADCAST);
1420 pDevice->byRxMode &= ~(RCR_UNICAST);
1422 ControlvWriteByte(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_RCR, pDevice->byRxMode);
1423 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pDevice->byRxMode out= %x\n", pDevice->byRxMode);
1424 spin_unlock_irq(&pDevice->lock);
1428 static struct net_device_stats *device_get_stats(struct net_device *dev)
1430 struct vnt_private *pDevice = netdev_priv(dev);
1432 return &pDevice->stats;
1435 static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1437 struct vnt_private *pDevice = netdev_priv(dev);
1438 struct iwreq *wrq = (struct iwreq *) rq;
1443 case IOCTL_CMD_HOSTAPD:
1445 if (!(pDevice->flags & DEVICE_FLAGS_OPENED))
1448 rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data);
1452 return ethtool_ioctl(dev, (void *) rq->ifr_data);
1459 static int ethtool_ioctl(struct net_device *dev, void *useraddr)
1463 if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd)))
1467 case ETHTOOL_GDRVINFO: {
1468 struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
1469 strncpy(info.driver, DEVICE_NAME, sizeof(info.driver)-1);
1470 strncpy(info.version, DEVICE_VERSION, sizeof(info.version)-1);
1471 if (copy_to_user(useraddr, &info, sizeof(info)))
1481 MODULE_DEVICE_TABLE(usb, vt6656_table);
1483 static struct usb_driver vt6656_driver = {
1484 .name = DEVICE_NAME,
1485 .probe = vt6656_probe,
1486 .disconnect = vt6656_disconnect,
1487 .id_table = vt6656_table,
1489 .suspend = vt6656_suspend,
1490 .resume = vt6656_resume,
1491 #endif /* CONFIG_PM */
1494 module_usb_driver(vt6656_driver);