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
111 #define PREAMBLE_TYPE_DEF 1
115 #define RTS_THRESH_DEF 2347
118 #define FRAG_THRESH_DEF 2346
122 #define DATA_RATE_DEF 13
142 #define OP_MODE_DEF 0
157 #define PS_MODE_DEF 0
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");
173 #define BBP_TYPE_DEF 2
183 #define X80211h_MODE_DEF 0
231 static void device_init_diversity_timer(
PSDevice pDevice);
235 static void device_free_tx_bufs(
PSDevice pDevice);
236 static void device_free_rx_bufs(
PSDevice pDevice);
237 static void device_free_int_bufs(
PSDevice pDevice);
238 static void device_free_frag_bufs(
PSDevice pDevice);
241 static int Read_config_file(
PSDevice pDevice);
243 static int Config_FileGetParameter(
unsigned char *
string,
249 static void usb_device_reset(
PSDevice pDevice);
259 device_set_options(
PSDevice 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};
297 static void device_init_diversity_timer(
PSDevice pDevice)
324 u8 abyBroadcastAddr[
ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
325 u8 abySNAP_RFC1042[
ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
326 u8 abySNAP_Bridgetunnel[
ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
334 BYTE byCalibTXIQ = 0;
335 BYTE byCalibTXDC = 0;
336 BYTE byCalibRXIQ = 0;
339 spin_lock_irq(&pDevice->
lock);
344 abySNAP_Bridgetunnel,
351 spin_unlock_irq(&pDevice->
lock);
357 spin_unlock_irq(&pDevice->
lock);
364 spin_unlock_irq(&pDevice->
lock);
371 for (ii = 0; ii < 6; ii++)
382 (
PBYTE) &(sInitCmd));
386 spin_unlock_irq(&pDevice->
lock);
395 spin_unlock_irq(&pDevice->
lock);
408 spin_unlock_irq(&pDevice->
lock);
437 for (ii=0;ii<14;ii++) {
451 for (ii = 11; ii < 14; ii++) {
552 if( (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) ) {
609 spin_unlock_irq(&pDevice->
lock);
632 spin_unlock_irq(&pDevice->
lock);
650 skb_reset_mac_header(pDevice->
skb);
677 if (!device || !device->
dev)
681 device_close(device->
dev);
690 PSDevice device = usb_get_intfdata(intf);
692 if (!device || !device->
dev)
698 device_open(device->
dev);
706 .ndo_open = device_open,
707 .ndo_stop = device_close,
708 .ndo_do_ioctl = device_ioctl,
709 .ndo_get_stats = device_get_stats,
710 .ndo_start_xmit = device_xmit,
711 .ndo_set_rx_mode = device_set_multi,
717 u8 fake_mac[
ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
718 struct usb_device *
udev = interface_to_usbdev(intf);
734 pDevice = netdev_priv(netdev);
737 pDevice->
dev = netdev;
740 device_set_options(pDevice);
743 pDevice->tx_80211 = device_dma0_tx_80211;
747 netdev->wireless_handlers =
750 usb_set_intfdata(intf, pDevice);
759 usb_device_reset(pDevice);
763 memset(&wrqu, 0,
sizeof(wrqu));
782 static void device_free_tx_bufs(
PSDevice pDevice)
787 for (ii = 0; ii < pDevice->
cbTD; ii++) {
789 pTxContext = pDevice->
apTD[ii];
791 if (pTxContext->
pUrb) {
801 static void device_free_rx_bufs(
PSDevice pDevice)
806 for (ii = 0; ii < pDevice->
cbRD; ii++) {
808 pRCB = pDevice->
apRCB[ii];
816 dev_kfree_skb(pRCB->
skb);
823 static void usb_device_reset(
PSDevice pDevice)
828 printk(
"usb_device_reset fail status=%d\n",status);
832 static void device_free_int_bufs(
PSDevice pDevice)
846 for (ii = 0; ii < pDevice->
cbTD; ii++) {
849 if (pTxContext ==
NULL) {
853 pDevice->
apTD[ii] = pTxContext;
854 pTxContext->
pDevice = (
void *) pDevice;
879 for (ii = 0; ii < pDevice->
cbRD; ii++) {
881 pDevice->
apRCB[ii] = pRCB;
882 pRCB->
pDevice = (
void *) pDevice;
895 pRCB->
skb->dev = pDevice->
dev;
927 device_free_rx_bufs(pDevice);
930 device_free_tx_bufs(pDevice);
956 device_free_frag_bufs(pDevice);
962 static void device_free_frag_bufs(
PSDevice pDevice) {
971 dev_kfree_skb(pDeF->
skb);
983 pDeF->
skb->dev = pDevice->
dev;
996 wpa_Result.
proto = 0;
1007 if (device_alloc_bufs(pDevice) ==
FALSE) {
1012 if (device_init_defrag_cb(pDevice)==
FALSE) {
1024 Read_config_file(pDevice);
1031 device_set_multi(pDevice->
dev);
1043 device_init_diversity_timer(pDevice);
1059 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1073 spin_lock_irq(&pDevice->
lock);
1082 spin_unlock_irq(&pDevice->
lock);
1096 netif_stop_queue(pDevice->
dev);
1101 memset(&wrqu, 0,
sizeof(wrqu));
1110 device_free_frag_bufs(pDevice);
1112 device_free_rx_bufs(pDevice);
1113 device_free_tx_bufs(pDevice);
1114 device_free_int_bufs(pDevice);
1126 static int device_close(
struct net_device *dev) {
1133 if (pDevice ==
NULL)
1138 memset(&wrqu, 0,
sizeof(wrqu));
1148 device_release_WPADEV(pDevice);
1154 spin_lock_irq(&pDevice->
lock);
1157 spin_unlock_irq(&pDevice->
lock);
1162 netif_stop_queue(pDevice->
dev);
1189 device_free_tx_bufs(pDevice);
1190 device_free_rx_bufs(pDevice);
1191 device_free_int_bufs(pDevice);
1192 device_free_frag_bufs(pDevice);
1209 PSDevice device = usb_get_intfdata(intf);
1221 device_release_WPADEV(device);
1224 usb_set_intfdata(intf,
NULL);
1238 PSDevice pDevice = netdev_priv(dev);
1240 spin_lock_irq(&pDevice->
lock);
1247 spin_unlock_irq(&pDevice->
lock);
1254 PSDevice pDevice = netdev_priv(dev);
1257 spin_lock_irq(&pDevice->
lock);
1259 netif_stop_queue(dev);
1273 if (netif_queue_stopped(dev))
1274 netif_wake_queue(dev);
1278 spin_unlock_irq(&pDevice->
lock);
1283 static unsigned const ethernet_polynomial = 0x04c11db7
U;
1288 while(--length >= 0) {
1289 unsigned char current_octet = *data++;
1291 for (bit = 0; bit < 8; bit++, current_octet >>= 1) {
1293 ((crc < 0) ^ (current_octet & 1) ? ethernet_polynomial : 0);
1300 static unsigned char *kstrstr(
const unsigned char *
str1,
1301 const unsigned char *str2) {
1302 int str1_len =
strlen(str1);
1303 int str2_len =
strlen(str2);
1305 while (str1_len >= str2_len) {
1307 if(
memcmp(str1,str2,str2_len)==0)
1308 return (
unsigned char *)
str1;
1314 static int Config_FileGetParameter(
unsigned char *
string,
1315 unsigned char *
dest,
1318 unsigned char buf1[100];
1319 unsigned char buf2[100];
1320 unsigned char *start_p =
NULL, *end_p =
NULL, *tmp_p =
NULL;
1329 start_p = kstrstr(source,buf1);
1330 if (start_p ==
NULL)
1334 for (ii = 1; ; ii++) {
1335 if (
memcmp(start_p - ii,
"\n", 1) == 0)
1337 if (
memcmp(start_p - ii,
"#", 1) == 0)
1342 end_p = kstrstr(start_p,
"\n");
1343 if (end_p ==
NULL) {
1344 end_p=start_p+
strlen(start_p);
1348 memcpy(buf2,start_p,end_p-start_p);
1349 buf2[end_p-start_p]=
'\0';
1352 start_p = kstrstr(buf2,
"=");
1353 if (start_p ==
NULL)
1360 while(*tmp_p != 0x00) {
1393 printk(
"Config_FileOperation file Not exist\n");
1398 if(!(filp->
f_op) || !(filp->
f_op->read) ||!(filp->
f_op->write)) {
1399 printk(
"file %s is not read or writeable?\n",config_path);
1406 printk(
"allocate mem for file fail?\n");
1411 if(filp->
f_op->read(filp, buffer, 1024, &filp->
f_pos)<0) {
1412 printk(
"read file error?\n");
1418 printk(
"Config_FileOperation:close file fail\n");
1436 static int Read_config_file(
PSDevice pDevice) {
1438 unsigned char tmpbuffer[100];
1439 unsigned char *buffer =
NULL;
1447 if (buffer ==
NULL) {
1454 memset(tmpbuffer,0,
sizeof(tmpbuffer));
1455 if(Config_FileGetParameter(
"ZONETYPE",tmpbuffer,buffer) ==
TRUE) {
1456 if(
memcmp(tmpbuffer,
"USA",3)==0) {
1459 else if(
memcmp(tmpbuffer,
"JAPAN",5)==0) {
1462 else if(
memcmp(tmpbuffer,
"EUROPE",6)==0) {
1466 printk(
"Unknown Zonetype[%s]?\n",tmpbuffer);
1473 memset(tmpbuffer,0,
sizeof(tmpbuffer));
1474 if(Config_FileGetParameter(
"AUTHENMODE",tmpbuffer,buffer)==
TRUE) {
1478 memset(tmpbuffer,0,
sizeof(tmpbuffer));
1479 if(Config_FileGetParameter(
"ENCRYPTIONMODE",tmpbuffer,buffer)==
TRUE) {
1488 static void device_set_multi(
struct net_device *dev) {
1494 BYTE pbyData[8] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
1499 spin_lock_irq(&pDevice->
lock);
1507 if (rc == 0) pDevice->
byRxMode = byTmpMode;
1528 memset(mc_filter, 0,
sizeof(mc_filter));
1531 mc_filter[bit_nr >> 5] |=
cpu_to_le32(1 << (bit_nr & 31));
1533 for (ii = 0; ii < 4; ii++) {
1548 spin_unlock_irq(&pDevice->
lock);
1556 return &pDevice->
stats;
1568 if (pMgmt ==
NULL) {
1619 if (wrq->
u.
essid.pointer) {
1717 }
else if (wrq->
u.
encoding.length != 0) {
1806 if (wrq->
u.
data.pointer) {
1835 #endif // WIRELESS_SPY
1852 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1905 #endif // #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
1979 netif_stop_queue(pDevice->
dev);
1980 spin_lock_irq(&pDevice->
lock);
1982 spin_unlock_irq(&pDevice->
lock);
1986 spin_lock_irq(&pDevice->
lock);
1998 netif_stop_queue(pDevice->
dev);
1999 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
2009 spin_unlock_irq(&pDevice->
lock);
2046 static struct usb_driver vt6656_driver = {
2048 .probe = vt6656_probe,
2049 .disconnect = vt6656_disconnect,
2050 .id_table = vt6656_table,
2052 .suspend = vt6656_suspend,
2053 .resume = vt6656_resume,