27 #ifndef CONFIG_FORCE_HARD_FLOAT
40 #undef RX_DONT_PASS_UL
42 #undef DEBUG_RX_VERBOSE
48 #undef DEBUG_TX_FILLDESC
53 #undef DEBUG_REGISTERS
55 #undef DEBUG_IRQ_TASKLET
59 #define CONFIG_RTL8192_IO_MAP
61 #include <asm/uaccess.h>
73 #include <linux/slab.h>
76 #ifdef CONFIG_RTL8192_PM
103 #define TOTAL_CAM_ENTRY 32
104 #define CAM_CONTENT_COUNT 8
108 {USB_DEVICE(0x0bda, 0x8709)},
110 {USB_DEVICE(0x07aa, 0x0043)},
112 {USB_DEVICE(0x050d, 0x805E)},
114 {USB_DEVICE(0x0df6, 0x0031)},
116 {USB_DEVICE(0x1740, 0x9201)},
118 {USB_DEVICE(0x2001, 0x3301)},
120 {USB_DEVICE(0x5a57, 0x0290)},
122 {USB_DEVICE(0x043e, 0x7a01)},
131 static char* ifname =
"wlan%d";
132 static int hwwep = 1;
152 static struct usb_driver rtl8192_usb_driver = {
154 .id_table = rtl8192_usb_id_tbl,
155 .probe = rtl8192_usb_probe,
156 .disconnect = rtl8192_usb_disconnect,
157 #ifdef CONFIG_RTL8192_PM
158 .suspend = rtl8192_suspend,
159 .resume = rtl8192_resume,
174 {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24},
175 {{1,2,3,4,5,6,7,8,9,10,11},11},
176 {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21},
177 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},
178 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},
179 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},
180 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},
181 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13},
182 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},
183 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22},
184 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14}
189 int i, max_chan=-1, min_chan=-1;
191 switch (channel_plan)
216 if (ChannelPlan[channel_plan].
Len != 0){
222 if (ChannelPlan[channel_plan].
Channel[i] < min_chan || ChannelPlan[channel_plan].
Channel[i] > max_chan)
243 #define rx_hal_is_cck_rate(_pdrvinfo)\
244 (_pdrvinfo->RxRate == DESC90_RATE1M ||\
245 _pdrvinfo->RxRate == DESC90_RATE2M ||\
246 _pdrvinfo->RxRate == DESC90_RATE5_5M ||\
247 _pdrvinfo->RxRate == DESC90_RATE11M) &&\
285 struct usb_device *
udev = priv->
udev;
289 indx|0xfe00, 0, &data, 1,
HZ / 2);
293 printk(
"write_nic_byte_E TimeOut! status:%d\n", status);
302 struct usb_device *
udev = priv->
udev;
306 indx|0xfe00, 0, &data, 1,
HZ / 2);
310 printk(
"read_nic_byte_E TimeOut! status:%d\n", status);
321 struct usb_device *
udev = priv->
udev;
325 (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1,
HZ / 2);
329 printk(
"write_nic_byte TimeOut! status:%d\n", status);
342 struct usb_device *
udev = priv->
udev;
346 (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 2,
HZ / 2);
350 printk(
"write_nic_word TimeOut! status:%d\n", status);
362 struct usb_device *
udev = priv->
udev;
366 (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 4,
HZ / 2);
371 printk(
"write_nic_dword TimeOut! status:%d\n", status);
383 struct usb_device *
udev = priv->
udev;
387 (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1,
HZ / 2);
391 printk(
"read_nic_byte TimeOut! status:%d\n", status);
404 struct usb_device *
udev = priv->
udev;
408 (indx&0xff)|0xff00, (indx>>8)&0x0f,
412 printk(
"read_nic_word TimeOut! status:%d\n", status);
422 struct usb_device *
udev = priv->
udev;
426 indx|0xfe00, 0, &data, 2,
HZ / 2);
429 printk(
"read_nic_word TimeOut! status:%d\n", status);
441 struct usb_device *
udev = priv->
udev;
445 (indx&0xff)|0xff00, (indx>>8)&0x0f,
454 printk(
"read_nic_dword TimeOut! status:%d\n", status);
483 int *eof,
void *
data)
494 len +=
snprintf(page + len, count - len,
"%s ", target->
ssid);
497 len +=
snprintf(page + len, count - len,
"WPA\n");
499 len +=
snprintf(page + len, count - len,
"non_WPA\n");
506 static int proc_get_registers(
char *page,
char **start,
507 off_t offset,
int count,
508 int *eof,
void *data)
519 len +=
snprintf(page + len, count - len,
520 "\n####################page 0##################\n ");
525 len +=
snprintf(page + len, count - len,
528 for(i=0;i<16 && n<=
max;i++,n++)
529 len +=
snprintf(page + len, count - len,
534 len +=
snprintf(page + len, count - len,
535 "\n####################page 1##################\n ");
539 len +=
snprintf(page + len, count - len,
542 for(i=0;i<16 && n<=
max;i++,n++)
543 len +=
snprintf(page + len, count - len,
548 len +=
snprintf(page + len, count - len,
549 "\n####################page 3##################\n ");
553 len +=
snprintf(page + len, count - len,
556 for(i=0;i<16 && n<=
max;i++,n++)
557 len +=
snprintf(page + len, count - len,
564 len +=
snprintf(page + len, count - len,
"\n");
574 static int proc_get_stats_tx(
char *page,
char **start,
575 off_t offset,
int count,
576 int *eof,
void *data)
583 len +=
snprintf(page + len, count - len,
584 "TX VI priority ok int: %lu\n"
585 "TX VI priority error int: %lu\n"
586 "TX VO priority ok int: %lu\n"
587 "TX VO priority error int: %lu\n"
588 "TX BE priority ok int: %lu\n"
589 "TX BE priority error int: %lu\n"
590 "TX BK priority ok int: %lu\n"
591 "TX BK priority error int: %lu\n"
592 "TX MANAGE priority ok int: %lu\n"
593 "TX MANAGE priority error int: %lu\n"
594 "TX BEACON priority ok int: %lu\n"
595 "TX BEACON priority error int: %lu\n"
598 "TX queue resume: %lu\n"
599 "TX queue stopped?: %d\n"
600 "TX fifo overflow: %lu\n"
607 "TX VI dropped: %lu\n"
608 "TX VO dropped: %lu\n"
609 "TX BE dropped: %lu\n"
610 "TX BK dropped: %lu\n"
611 "TX total data packets %lu\n",
613 priv->
stats.txviokint,
615 priv->
stats.txvookint,
617 priv->
stats.txbeokint,
619 priv->
stats.txbkokint,
621 priv->
stats.txmanageokint,
622 priv->
stats.txmanageerr,
623 priv->
stats.txbeaconokint,
624 priv->
stats.txbeaconerr,
627 priv->
stats.txresumed,
628 netif_queue_stopped(dev),
629 priv->
stats.txoverflow,
636 priv->
stats.txvidrop,
637 priv->
stats.txvodrop,
638 priv->
stats.txbedrop,
639 priv->
stats.txbkdrop,
640 priv->
stats.txdatapkt
650 static int proc_get_stats_rx(
char *page,
char **start,
651 off_t offset,
int count,
652 int *eof,
void *data)
659 len +=
snprintf(page + len, count - len,
661 "RX urb status error: %lu\n"
662 "RX invalid urb error: %lu\n",
663 priv->
stats.rxoktotal,
664 priv->
stats.rxstaterr,
665 priv->
stats.rxurberr);
715 priv->
dir_dev, proc_get_stats_rx, dev);
719 "/proc/net/rtl8192/%s/stats-rx\n",
725 priv->
dir_dev, proc_get_stats_tx, dev);
729 "/proc/net/rtl8192/%s/stats-tx\n",
734 priv->
dir_dev, proc_get_stats_ap, dev);
738 "/proc/net/rtl8192/%s/stats-ap\n",
743 priv->
dir_dev, proc_get_registers, dev);
746 "/proc/net/rtl8192/%s/registers\n",
760 printk(
"ASCII BUFFER DUMP (len: %x):\n",len);
765 printk(
"\nBINARY BUFFER DUMP (len: %x):\n",len);
776 struct r8192_priv *priv = ieee80211_priv(dev);
784 struct r8192_priv *priv = ieee80211_priv(dev);
812 for(i=0;i<16 && n<=
max;i++,n++)
837 struct r8192_priv *priv = ieee80211_priv(dev);
888 static void rtl8192_rx_isr(
struct urb *
urb);
894 #ifdef USB_RX_AGGREGATION_SUPPORT
904 static int rtl8192_rx_initiate(
struct net_device*dev)
922 usb_fill_bulk_urb(entry, priv->
udev,
923 usb_rcvbulkpipe(priv->
udev, 3), skb_tail_pointer(skb),
944 usb_fill_bulk_urb(entry, priv->
udev,
945 usb_rcvbulkpipe(priv->
udev, 9), skb_tail_pointer(skb),
1018 rtl8192_rx_initiate(dev);
1033 struct r8192_priv *priv = ieee80211_priv(dev);
1043 while ((skb = __skb_dequeue(&priv->
rx_queue))) {
1098 static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
1101 if (rate >11)
return 0;
1102 return rtl_rate[
rate];
1107 static void rtl8192_rx_isr(
struct urb *
urb)
1112 struct r8192_priv *priv = ieee80211_priv(dev);
1119 priv->
stats.rxstaterr++;
1126 skb_put(skb, urb->actual_length);
1139 usb_fill_bulk_urb(urb, priv->
udev,
1140 usb_rcvbulkpipe(priv->
udev, out_pipe), skb_tail_pointer(skb),
1148 urb->transfer_buffer = skb_tail_pointer(skb);
1152 if(err && err !=
EPERM)
1153 printk(
"can not submit rxurb, err is %x,URB status is %x\n",err,urb->status);
1169 DMESG(
"rxcommandpackethandle819xusb: It is a command packet\n");
1199 unsigned long flags;
1208 memcpy((
unsigned char *)(skb->cb),&dev,
sizeof(dev));
1219 spin_unlock_irqrestore(&priv->
tx_lock,flags);
1234 unsigned long flags;
1241 memcpy((
unsigned char *)(skb->cb),&dev,
sizeof(dev));
1246 spin_unlock_irqrestore(&priv->
tx_lock,flags);
1253 spin_unlock_irqrestore(&priv->
tx_lock,flags);
1261 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
1264 u16 PaddingNum = 256 - ((skb->
len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES) % 256);
1265 return (PaddingNum&0xff);
1274 struct r8192_priv *priv = ieee80211_priv(dev);
1280 tx_desc_819x_usb_aggr_subframe *tx_agg_desc =
NULL;
1288 TotalLength = skb->
len;
1294 TotalLength += DrvAggr_PaddingAdd(dev, skb);
1296 TotalLength += (skb->
len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES);
1300 agg_skb = dev_alloc_skb(TotalLength + ieee->
tx_headroom);
1315 memcpy(agg_skb->cb, skb->cb,
sizeof(skb->cb));
1320 skb_put(agg_skb,DrvAggr_PaddingAdd(dev,skb));
1325 tx_agg_desc = (tx_desc_819x_usb_aggr_subframe *)agg_skb->
tail;
1342 tx_fwinfo->
RxMF = 0;
1343 tx_fwinfo->
RxAMD = 0;
1373 memset(tx_agg_desc, 0,
sizeof(tx_desc_819x_usb_aggr_subframe));
1379 tx_agg_desc->PktSize = skb->
len & 0xffff;
1382 tx_agg_desc->SecCAMID= 0;
1383 tx_agg_desc->RATid = tcb_desc->
RATRIndex;
1386 tx_agg_desc->NoEnc = 1;
1388 tx_agg_desc->SecType = 0x0;
1391 switch (priv->
ieee80211->pairwise_key_type)
1395 tx_agg_desc->SecType = 0x1;
1396 tx_agg_desc->NoEnc = 0;
1399 tx_agg_desc->SecType = 0x2;
1400 tx_agg_desc->NoEnc = 0;
1403 tx_agg_desc->SecType = 0x3;
1404 tx_agg_desc->NoEnc = 0;
1407 tx_agg_desc->SecType = 0x0;
1408 tx_agg_desc->NoEnc = 1;
1419 tx_agg_desc->OWN = 1;
1426 skb_put(agg_skb,TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES);
1446 u16 nMaxAggrNum = pHTInfo->UsbTxAggrNum;
1463 static void rtl8192_tx_isr(
struct urb *tx_urb)
1474 priv = ieee80211_priv(dev);
1477 if(tx_urb->status == 0) {
1482 priv->
stats.txoktotal++;
1483 priv->
ieee80211->LinkDetectInfo.NumTxOkInPeriod++;
1514 if((skb_queue_len(&priv->
ieee80211->skb_waitQ[queue_index]) != 0)&&\
1517 priv->
ieee80211->softmac_hard_start_xmit(skb, dev);
1521 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
1522 else if ((skb_queue_len(&priv->
ieee80211->skb_drv_aggQ[queue_index])!= 0)&&\
1554 if(DrvAggr_GetAggregatibleList(dev, skb, &SendList) > 1) {
1555 skb = DrvAggr_Aggregation(dev, &SendList);
1559 priv->
ieee80211->softmac_hard_start_xmit(skb, dev);
1571 struct r8192_priv *priv = ieee80211_priv(dev);
1575 msr2 = msr & ~MSR_LINK_MASK;
1589 struct r8192_priv *priv = ieee80211_priv(dev);
1591 u8 i=0, basic_rate = 0;
1592 net = & priv->
ieee80211->current_network;
1596 basic_rate = net->
rates[
i]&0x7f;
1635 #define SHORT_SLOT_TIME 9
1636 #define NON_SHORT_SLOT_TIME 20
1641 struct r8192_priv *priv = ieee80211_priv(dev);
1666 struct r8192_priv *priv = ieee80211_priv(dev);
1668 u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
1669 u16 rate_config = 0;
1670 net = & priv->
ieee80211->current_network;
1709 if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
1719 u8 bManagementFrame,
1729 if( bManagementFrame || !bShortPreamble || DataRate == 10 )
1731 FrameTime = (
u16)(144+48+(FrameLength*8/(DataRate/10)));
1735 FrameTime = (
u16)(72+24+(FrameLength*8/(DataRate/10)));
1737 if( ( FrameLength*8 % (DataRate/10) ) != 0 )
1741 Ceiling = (16 + 8*FrameLength + 6) / N_DBPS
1742 + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0);
1743 FrameTime = (
u16)(16 + 4 + 4*Ceiling + 6);
1810 struct r8192_priv *priv = ieee80211_priv(dev);
1815 unsigned int idx_pipe;
1841 #ifndef USE_ONE_PIPE
1846 #ifdef JOHN_DUMP_TXDESC
1849 for (i = 0; i < 8; i++)
1853 usb_fill_bulk_urb(tx_urb,priv->
udev, usb_sndbulkpipe(priv->
udev,idx_pipe), \
1854 skb->
data, skb->
len, rtl8192_tx_isr, skb);
1861 DMESGE(
"Error TX CMD URB, error %d",
1876 u8 QueueSelect = 0x0;
1914 RT_TRACE(
COMP_ERR,
"TransmitTCB(): Impossible Queue Selection: %d \n", QueueID);
1975 static void tx_zero_isr(
struct urb *tx_urb)
1987 struct r8192_priv *priv = ieee80211_priv(dev);
1991 struct usb_device *
udev = priv->
udev;
1994 struct urb *tx_urb =
NULL, *tx_urb_zero =
NULL;
1996 unsigned int idx_pipe;
2005 printk(
"To discard skb packet!\n");
2031 tx_fwinfo->
RxMF = 0;
2032 tx_fwinfo->
RxAMD = 0;
2061 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2074 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2093 switch (priv->
ieee80211->pairwise_key_type)
2127 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
2137 #ifndef USE_ONE_PIPE
2147 usb_fill_bulk_urb(tx_urb,udev,
2148 usb_sndbulkpipe(udev,idx_pipe), skb->
data,
2149 skb->
len, rtl8192_tx_isr, skb);
2154 bool bSend0Byte =
false;
2158 if (skb->
len > 0 && skb->
len % 512 == 0)
2163 if (skb->
len > 0 && skb->
len % 64 == 0)
2173 usb_fill_bulk_urb(tx_urb_zero,udev,
2174 usb_sndbulkpipe(udev,idx_pipe), &zero,
2175 0, tx_zero_isr, dev);
2194 struct r8192_priv *priv = ieee80211_priv(dev);
2201 #ifndef JACKSON_NEW_RX
2212 #ifdef THOMAS_BEACON
2215 void *oldaddr, *newaddr;
2219 oldaddr = priv->oldaddr;
2220 align = ((
long)oldaddr) & 3;
2222 newaddr = oldaddr + 4 -
align;
2223 priv->
rx_urb[16]->transfer_buffer_length = 16 - 4 +
align;
2226 priv->
rx_urb[16]->transfer_buffer_length = 16;
2228 priv->
rx_urb[16]->transfer_buffer = newaddr;
2235 if (!priv->pp_rxskb) {
2238 priv->pp_rxskb =
NULL;
2241 DMESGE(
"Endpoint Alloc Failure");
2245 printk(
"End of initendpoints\n");
2249 #ifdef THOMAS_BEACON
2253 struct r8192_priv *priv = ieee80211_priv(dev);
2263 kfree(priv->oldaddr);
2264 priv->oldaddr =
NULL;
2265 if (priv->pp_rxskb) {
2266 kfree(priv->pp_rxskb);
2274 struct r8192_priv *priv = ieee80211_priv(dev);
2276 #ifndef JACKSON_NEW_RX
2291 kfree(priv->oldaddr);
2292 priv->oldaddr =
NULL;
2293 if (priv->pp_rxskb) {
2294 kfree(priv->pp_rxskb);
2308 struct r8192_priv *priv = ieee80211_priv(dev);
2378 RT_TRACE(
COMP_QOS,
"qos active process with associate response received\n");
2398 static int rtl8192_qos_handle_probe_response(
struct r8192_priv *priv,
2412 if (active_network &&
2416 if ((network->
qos_data.active == 1) && (active_network == 1) &&
2418 (network->
qos_data.old_param_count !=
2420 network->
qos_data.old_param_count =
2428 &def_qos_parameters, size);
2430 if ((network->
qos_data.active == 1) && (active_network == 1)) {
2442 static int rtl8192_handle_beacon(
struct net_device * dev,
2446 struct r8192_priv *priv = ieee80211_priv(dev);
2448 rtl8192_qos_handle_probe_response(priv,1,network);
2459 static int rtl8192_qos_association_resp(
struct r8192_priv *priv,
2463 unsigned long flags;
2465 int set_qos_param = 0;
2467 if ((priv ==
NULL) || (network ==
NULL))
2481 priv->
ieee80211->current_network.qos_data.active = 1;
2485 priv->
ieee80211->current_network.qos_data.old_param_count =
\
2486 priv->ieee80211->current_network.qos_data.param_count;
2487 priv->
ieee80211->current_network.qos_data.param_count = \
2488 network->qos_data.param_count;
2492 &def_qos_parameters, size);
2493 priv->
ieee80211->current_network.qos_data.active = 0;
2494 priv->
ieee80211->current_network.qos_data.supported = 0;
2498 spin_unlock_irqrestore(&priv->
ieee80211->lock, flags);
2501 if (set_qos_param == 1)
2509 static int rtl8192_handle_assoc_response(
struct net_device *dev,
2513 struct r8192_priv *priv = ieee80211_priv(dev);
2514 rtl8192_qos_association_resp(priv, network);
2524 struct r8192_priv* priv = ieee80211_priv(dev);
2531 ratr_value |= (*(
u16*)(pMcsRate)) << 12;
2536 ratr_value &= 0x00000FF0;
2539 ratr_value &= 0x0000000F;
2542 ratr_value &= 0x00000FF7;
2547 ratr_value &= 0x0007F007;
2550 ratr_value &= 0x000FF007;
2552 ratr_value &= 0x0F81F007;
2558 ratr_value &= 0x0FFFFFFF;
2560 ratr_value |= 0x80000000;
2562 ratr_value |= 0x80000000;
2568 static u8 ccmp_ie[4] = {0x00,0x50,0xf2,0x04};
2569 static u8 ccmp_rsn_ie[4] = {0x00, 0x0f, 0xac, 0x04};
2572 struct r8192_priv* priv = ieee80211_priv(dev);
2584 if(encrypt && (wpa_ie_len == 0)) {
2588 }
else if((wpa_ie_len != 0)) {
2605 struct r8192_priv* priv = ieee80211_priv(dev);
2633 struct r8192_priv *priv = ieee80211_priv(dev);
2653 struct r8192_priv *priv = ieee80211_priv(dev);
2684 ActUpdateChannelAccessSetting( pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting );
2689 priv->
ieee80211->pHTInfo->bEnableHT = 1;
2691 priv->
ieee80211->pHTInfo->bEnableHT = 0;
2697 static void rtl8192_init_priv_variable(
struct net_device* dev)
2699 struct r8192_priv *priv = ieee80211_priv(dev);
2740 priv->
ieee80211->init_wmmparam_flag = 0;
2749 priv->
ieee80211->handle_assoc_response = rtl8192_handle_assoc_response;
2750 priv->
ieee80211->handle_beacon = rtl8192_handle_beacon;
2761 pHalData->ShortRetryLimit = 7;
2762 pHalData->LongRetryLimit = 7;
2780 pHalData->ReceiveConfig = pHalData->CSMethod |
2805 skb_queue_head_init(&priv->
rx_queue);
2810 skb_queue_head_init(&priv->
ieee80211->skb_waitQ [i]);
2813 skb_queue_head_init(&priv->
ieee80211->skb_aggQ [i]);
2816 skb_queue_head_init(&priv->
ieee80211->skb_drv_aggQ [i]);
2822 static void rtl8192_init_priv_lock(
struct r8192_priv* priv)
2827 sema_init(&priv->
wx_sem,1);
2828 sema_init(&priv->
rf_sem,1);
2836 #define DRV_NAME "wlan0"
2837 static void rtl8192_init_priv_task(
struct net_device* dev)
2839 struct r8192_priv *priv = ieee80211_priv(dev);
2858 (
unsigned long)priv);
2864 struct r8192_priv *priv = ieee80211_priv(dev);
2874 static inline u16 endian_swap(
u16* data)
2877 *data = (tmp >> 8) | (tmp << 8);
2880 static void rtl8192_read_eeprom_info(
struct net_device* dev)
2883 u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x02};
2884 u8 bLoad_From_EEPOM =
false;
2885 struct r8192_priv *priv = ieee80211_priv(dev);
2896 bLoad_From_EEPOM =
true;
2898 if (bLoad_From_EEPOM)
2919 if (bLoad_From_EEPOM)
2922 for (i=0; i<6; i+=2)
2941 if (bLoad_From_EEPOM)
2947 if (bLoad_From_EEPOM)
2955 if (bLoad_From_EEPOM)
2961 if (bLoad_From_EEPOM)
2967 if (bLoad_From_EEPOM)
2975 if (bLoad_From_EEPOM)
2982 if (bLoad_From_EEPOM)
2986 tmpValue = tmpValue & 0x00ff;
2988 tmpValue = (tmpValue & 0xff00) >> 8;
2998 if (bLoad_From_EEPOM)
3001 tmpValue = (tmpValue & 0xff00) >> 8;
3007 if (bLoad_From_EEPOM)
3012 if (bLoad_From_EEPOM)
3017 if (bLoad_From_EEPOM)
3028 for (i=0; i<14; i++)
3032 else if (i>=4 && i<=9)
3038 for (i=0; i<14; i++)
3044 else if (i>=4 && i<=9)
3053 else if (i>=4 && i<=9)
3126 struct r8192_priv *priv = ieee80211_priv(dev);
3128 printk(
"rtl8180_init:Error channel plan! Set to default.\n");
3140 struct r8192_priv *priv = ieee80211_priv(dev);
3147 u8 queuetopipe[]={3,2,1,0,4,8,7,6,5};
3155 u8 queuetopipe[]={3,2,1,0,4,4,0,4,4};
3162 rtl8192_init_priv_variable(dev);
3163 rtl8192_init_priv_lock(priv);
3164 rtl8192_init_priv_task(dev);
3166 rtl8192_read_eeprom_info(dev);
3173 DMESG(
"Endopoints initialization failed");
3194 u32 regRATR = 0, regRRSR = 0;
3195 u8 regBwOpMode = 0, regTmp = 0;
3196 struct r8192_priv *priv = ieee80211_priv(dev);
3250 ratr_value = regRATR;
3259 regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff);
3283 struct r8192_priv *priv = ieee80211_priv(dev);
3285 bool init_status =
true;
3369 u8 SECR_value = 0x0;
3382 #define DEFAULT_EDCA 0x005e4332
3387 #ifdef USB_RX_AGGREGATION_SUPPORT
3393 ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) |
3394 (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout);
3425 if(pMgntInfo->RegRfOff ==
TRUE)
3430 for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
3440 pHalData->eRFPowerState =
eRfOn;
3441 pMgntInfo->RfOffReason = 0;
3447 if(pHalData->eRFPowerState ==
eRfOff)
3451 for(eRFPath = 0; eRFPath <pHalData->NumTotalRFPath; eRFPath++)
3541 struct r8192_priv *priv = ieee80211_priv(dev);
3551 struct r8192_priv *priv = ieee80211_priv(dev);
3553 bool bStuck =
FALSE;
3570 struct r8192_priv *priv = ieee80211_priv(dev);
3574 bool bCheckFwTxCnt =
false;
3588 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
3589 if((skb_queue_len(&priv->
ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->
ieee80211->skb_aggQ[QueueID]) == 0) && (skb_queue_len(&priv->
ieee80211->skb_drv_aggQ[QueueID]) == 0))
3591 if((skb_queue_len(&priv->
ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->
ieee80211->skb_aggQ[QueueID]) == 0))
3595 bCheckFwTxCnt =
true;
3615 struct r8192_priv *priv = ieee80211_priv(dev);
3616 bool bStuck =
FALSE;
3617 static u8 rx_chk_cnt = 0;
3679 struct r8192_priv *priv = ieee80211_priv(dev);
3681 bool bRxCheck =
FALSE;
3718 struct r8192_priv *priv = ieee80211_priv(dev);
3723 rfState = priv->
ieee80211->eRFPowerState;
3761 struct r8192_priv *priv = ieee80211_priv(dev);
3762 u8* MacAddr = priv->
ieee80211->current_network.bssid;
3764 static u8 CAM_CONST_ADDR[4][6] = {
3765 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
3766 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
3767 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
3768 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
3769 static u8 CAM_CONST_BROAD[] =
3770 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3779 for(EntryId=0; EntryId<4; EntryId++)
3782 MacAddr = CAM_CONST_ADDR[EntryId];
3843 MacAddr = CAM_CONST_BROAD;
3844 for(EntryId=1 ; EntryId<4 ; EntryId++)
3867 MacAddr = CAM_CONST_BROAD;
3868 for(EntryId=1; EntryId<4 ; EntryId++)
3901 struct r8192_priv *priv = ieee80211_priv(dev);
3940 printk(
"ieee->state is IEEE80211_LINKED\n");
3949 printk(
"ieee->state is NOT LINKED\n");
3958 if(reset_status == -
EAGAIN)
4012 u32 target_command=0;
4013 u32 target_content=0;
4021 target_command= entry_i+CAM_CONTENT_COUNT*iIndex;
4022 target_command= target_command |
BIT31;
4029 if(ulStatus &
BIT31){
4056 *TotalRxDataNum = 0;
4058 SlotIndex = (priv->
ieee80211->LinkDetectInfo.SlotIndex++)%(priv->
ieee80211->LinkDetectInfo.SlotNum);
4059 priv->
ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->
ieee80211->LinkDetectInfo.NumRecvBcnInPeriod;
4060 priv->
ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->
ieee80211->LinkDetectInfo.NumRecvDataInPeriod;
4061 for( i=0; i<priv->
ieee80211->LinkDetectInfo.SlotNum; i++ ){
4062 *TotalRxBcnNum += priv->
ieee80211->LinkDetectInfo.RxBcnNum[
i];
4063 *TotalRxDataNum += priv->
ieee80211->LinkDetectInfo.RxDataNum[
i];
4075 static u8 check_reset_cnt=0;
4076 bool bBusyTraffic =
false;
4087 bBusyTraffic =
true;
4098 u32 TotalRxBcnNum = 0;
4099 u32 TotalRxDataNum = 0;
4102 if((TotalRxBcnNum+TotalRxDataNum) == 0)
4118 priv->
ieee80211->LinkDetectInfo.NumRecvBcnInPeriod=0;
4119 priv->
ieee80211->LinkDetectInfo.NumRecvDataInPeriod=0;
4123 if(check_reset_cnt++ >= 3)
4126 check_reset_cnt = 3;
4134 RT_TRACE(
COMP_RESET,
"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",
__FUNCTION__,priv->
force_reset,priv->
ResetProgress,priv->
bForcedSilentReset,priv->
bDisableNormalResetCheck,ResetType);
4153 struct r8192_priv *priv = ieee80211_priv(dev);
4155 int init_status = 0;
4173 if(!netif_queue_stopped(dev))
4174 netif_start_queue(dev);
4176 netif_wake_queue(dev);
4184 struct r8192_priv *priv = ieee80211_priv(dev);
4196 struct r8192_priv *priv = ieee80211_priv(dev);
4198 if (priv->
up == 1)
return -1;
4206 struct r8192_priv *priv = ieee80211_priv(dev);
4221 struct r8192_priv *priv = ieee80211_priv(dev);
4224 if (priv->
up == 0)
return -1;
4230 if (!netif_queue_stopped(dev))
4231 netif_stop_queue(dev);
4265 struct r8192_priv *priv = ieee80211_priv(dev);
4300 static void r8192_set_multicast(
struct net_device *dev)
4302 struct r8192_priv *priv = ieee80211_priv(dev);
4323 struct r8192_priv *priv = ieee80211_priv(dev);
4344 u8 broadcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
4380 if (ipw->
u.
crypt.key_len == 13)
4382 else if (ipw->
u.
crypt.key_len == 5)
4408 if (ipw->
u.
crypt.key_len == 13)
4410 else if (ipw->
u.
crypt.key_len == 5)
4428 #ifdef JOHN_HWSEC_DEBUG
4430 printk(
"@@ wrq->u pointer = ");
4431 for(i=0;i<wrq->
u.
data.length;i++){
4432 if(i%10==0)
printk(
"\n");
4472 RT_TRACE(
COMP_RECV,
"HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT);
4498 RT_TRACE(
COMP_RECV,
"HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate, bIsHT);
4541 signal_power = (
long)((signal_strength_index + 1) >> 1);
4544 return signal_power;
4554 bool bcheck =
false;
4556 u32 nspatial_stream, tmp_val;
4558 static u32 slide_rssi_index=0, slide_rssi_statistics=0;
4559 static u32 slide_evm_index=0, slide_evm_statistics=0;
4560 static u32 last_rssi=0, last_evm=0;
4562 static u32 slide_beacon_adc_pwdb_index=0, slide_beacon_adc_pwdb_statistics=0;
4563 static u32 last_beacon_adc_pwdb=0;
4573 pcurrent_stats->
Seq_Num = seq;
4589 last_rssi = priv->
stats.slide_signal_strength[slide_rssi_index];
4590 priv->
stats.slide_rssi_total -= last_rssi;
4596 slide_rssi_index = 0;
4599 tmp_val = priv->
stats.slide_rssi_total/slide_rssi_statistics;
4601 pcurrent_stats->
rssi = priv->
stats.signal_strength;
4620 priv->
stats.num_process_phyinfo++;
4635 if(priv->
stats.rx_rssi_percentage[rfpath] == 0)
4642 priv->
stats.rx_rssi_percentage[rfpath] =
4645 priv->
stats.rx_rssi_percentage[rfpath] = priv->
stats.rx_rssi_percentage[rfpath] + 1;
4649 priv->
stats.rx_rssi_percentage[rfpath] =
4653 RT_TRACE(
COMP_DBG,
"priv->stats.rx_rssi_percentage[rfPath] = %d \n" ,priv->
stats.rx_rssi_percentage[rfpath] );
4662 pprevious_stats->
bIsCCK?
"CCK":
"OFDM",
4671 last_beacon_adc_pwdb = priv->
stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index];
4672 priv->
stats.Slide_Beacon_Total -= last_beacon_adc_pwdb;
4677 priv->
stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = pprevious_stats->
RxPWDBAll;
4679 slide_beacon_adc_pwdb_index++;
4681 slide_beacon_adc_pwdb_index = 0;
4682 pprevious_stats->
RxPWDBAll = priv->
stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics;
4688 pprevious_stats->
bIsCCK?
"CCK":
"OFDM",
4727 last_evm = priv->
stats.slide_evm[slide_evm_index];
4728 priv->
stats.slide_evm_total -= last_evm;
4735 slide_evm_index = 0;
4738 tmp_val = priv->
stats.slide_evm_total/slide_evm_statistics;
4739 priv->
stats.signal_quality = tmp_val;
4741 priv->
stats.last_signal_strength_inpercent = tmp_val;
4747 for(nspatial_stream = 0; nspatial_stream<2 ; nspatial_stream++)
4751 if(priv->
stats.rx_evm_percentage[nspatial_stream] == 0)
4755 priv->
stats.rx_evm_percentage[nspatial_stream] =
4786 if ((antpower <= -100) || (antpower >= 20))
4790 else if (antpower >= 0)
4796 return (100+antpower);
4814 ret_val = 0 - ret_val;
4833 if(currsig >= 61 && currsig <= 100)
4835 retsig = 90 + ((currsig - 60) / 4);
4837 else if(currsig >= 41 && currsig <= 60)
4839 retsig = 78 + ((currsig - 40) / 2);
4841 else if(currsig >= 31 && currsig <= 40)
4843 retsig = 66 + (currsig - 30);
4845 else if(currsig >= 21 && currsig <= 30)
4847 retsig = 54 + (currsig - 20);
4849 else if(currsig >= 5 && currsig <= 20)
4851 retsig = 42 + (((currsig - 5) * 2) / 3);
4853 else if(currsig == 4)
4857 else if(currsig == 3)
4861 else if(currsig == 2)
4865 else if(currsig == 1)
4877 static void rtl8192_query_rxphystatus(
4882 bool bpacket_match_bssid,
4883 bool bpacket_toself,
4893 u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
4894 char rx_pwr[4], rx_pwr_all=0;
4896 char rx_snrX, rx_evmX;
4898 u32 RSSI, total_rssi=0;
4904 priv->
stats.numqry_phystatus++;
4916 prxpkt = (
u8*)pdrvinfo;
4941 priv->
stats.numqry_phystatusCCK++;
4953 rx_pwr_all = -35 - (pcck_buf->
cck_agc_rpt & 0x3e);
4956 rx_pwr_all = -23 - (pcck_buf->
cck_agc_rpt & 0x3e);
4959 rx_pwr_all = -11 - (pcck_buf->
cck_agc_rpt & 0x3e);
4973 rx_pwr_all = -35 - ((pcck_buf->
cck_agc_rpt & 0x1f)<<1) ;
4976 rx_pwr_all = -23 - ((pcck_buf->
cck_agc_rpt & 0x1f)<<1);
4979 rx_pwr_all = -11 - ((pcck_buf->
cck_agc_rpt & 0x1f)<<1) ;
4982 rx_pwr_all = 6 - ((pcck_buf->
cck_agc_rpt & 0x1f)<<1) ;
5005 if(pcck_buf->
sq_rpt > 64)
5007 else if (pcck_buf->
sq_rpt < 20)
5010 sq = ((64-sq) * 100) / 44;
5019 priv->
stats.numqry_phystatusHT++;
5040 rx_snrX = (
char)(tmp_rxsnr);
5063 rx_pwr_all = (((pofdm_buf->
pwdb_all ) >> 1 )& 0x7f) -106;
5074 max_spatial_stream = 2;
5076 max_spatial_stream = 1;
5078 for(i=0; i<max_spatial_stream; i++)
5081 rx_evmX = (
char)(tmp_rxevm);
5102 priv->
stats.received_bwtype[1+prxsc->
rxsc]++;
5104 priv->
stats.received_bwtype[0]++;
5143 bool bpacket_match_bssid, bpacket_toself;
5156 tmp_buf = (
u8*)skb->
data;
5161 praddr = hdr->
addr1;
5167 bpacket_toself = bpacket_match_bssid & (
eqMacAddr(praddr, priv->
ieee80211->dev->dev_addr));
5171 bPacketBeacon =
true;
5183 if(bpacket_match_bssid)
5185 priv->
stats.numpacket_matchbssid++;
5188 priv->
stats.numpacket_toself++;
5196 rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, bpacket_match_bssid,bpacket_toself,bPacketBeacon,bToSelfBA);
5224 u32 preamble_guardinterval;
5229 else if(stats->
bICV)
5233 preamble_guardinterval = 1;
5235 preamble_guardinterval = 0;
5242 case MGN_1M: rateIndex = 0;
break;
5243 case MGN_2M: rateIndex = 1;
break;
5244 case MGN_5_5M: rateIndex = 2;
break;
5245 case MGN_11M: rateIndex = 3;
break;
5249 case MGN_6M: rateIndex = 4;
break;
5250 case MGN_9M: rateIndex = 5;
break;
5251 case MGN_12M: rateIndex = 6;
break;
5252 case MGN_18M: rateIndex = 7;
break;
5253 case MGN_24M: rateIndex = 8;
break;
5254 case MGN_36M: rateIndex = 9;
break;
5255 case MGN_48M: rateIndex = 10;
break;
5256 case MGN_54M: rateIndex = 11;
break;
5260 case MGN_MCS0: rateIndex = 12;
break;
5261 case MGN_MCS1: rateIndex = 13;
break;
5262 case MGN_MCS2: rateIndex = 14;
break;
5263 case MGN_MCS3: rateIndex = 15;
break;
5264 case MGN_MCS4: rateIndex = 16;
break;
5265 case MGN_MCS5: rateIndex = 17;
break;
5266 case MGN_MCS6: rateIndex = 18;
break;
5267 case MGN_MCS7: rateIndex = 19;
break;
5268 case MGN_MCS8: rateIndex = 20;
break;
5269 case MGN_MCS9: rateIndex = 21;
break;
5276 default: rateIndex = 28;
break;
5278 priv->
stats.received_preamble_GI[preamble_guardinterval][rateIndex]++;
5279 priv->
stats.received_rate_histogram[0][rateIndex]++;
5280 priv->
stats.received_rate_histogram[rcvType][rateIndex]++;
5295 #ifdef USB_RX_AGGREGATION_SUPPORT
5296 if (bIsRxAggrSubframe)
5298 rx_desc_819x_usb_aggr_subframe *
desc = (rx_desc_819x_usb_aggr_subframe *)skb->
data;
5299 stats->
Length = desc->Length ;
5302 stats->
bICV = desc->ICV;
5303 stats->
bCRC = desc->CRC32;
5345 if(ret_rate == 0xff)
5354 stats->
rate = ret_rate;
5392 #ifdef USB_RX_AGGREGATION_SUPPORT
5394 if(bIsRxAggrSubframe) {
5409 #ifdef USB_RX_AGGREGATION_SUPPORT
5410 if (bIsRxAggrSubframe)
5433 bool unicast_packet =
false;
5434 #ifdef USB_RX_AGGREGATION_SUPPORT
5436 u32 TotalLength = 0;
5438 u32 PacketLength = 0;
5439 u32 PacketOccupiedLendth = 0;
5441 u32 PacketShiftBytes = 0;
5442 rx_desc_819x_usb_aggr_subframe *RxDescr =
NULL;
5443 u8 PaddingBytes = 0;
5451 #ifdef USB_RX_AGGREGATION_SUPPORT
5458 #ifdef USB_RX_AGGREGATION_SUPPORT
5459 if (TempByte &
BIT0) {
5462 TotalLength = stats.
Length - 4;
5465 TempDWord = *(
u32 *)(agg_skb->
data - 4);
5466 PacketLength = (
u16)(TempDWord & 0x3FFF);
5467 skb = dev_alloc_skb(PacketLength);
5475 rx_pkt_len = skb->
len;
5477 unicast_packet =
false;
5478 if(is_broadcast_ether_addr(ieee80211_hdr->
addr1)) {
5480 }
else if(is_multicast_ether_addr(ieee80211_hdr->
addr1)){
5484 unicast_packet =
true;
5490 priv->
stats.rxoktotal++;
5491 if(unicast_packet) {
5492 priv->
stats.rxbytesunicast += rx_pkt_len;
5495 #ifdef USB_RX_AGGREGATION_SUPPORT
5498 if (TotalLength > 0) {
5499 PacketOccupiedLendth = PacketLength + (PacketShiftBytes + 8);
5500 if ((PacketOccupiedLendth & 0xFF) != 0)
5501 PacketOccupiedLendth = (PacketOccupiedLendth & 0xFFFFFF00) + 256;
5502 PacketOccupiedLendth -= 8;
5503 TempDWord = PacketOccupiedLendth - PacketShiftBytes;
5504 if (agg_skb->
len > TempDWord)
5510 u8 tmpCRC = 0, tmpICV = 0;
5512 RxDescr = (rx_desc_819x_usb_aggr_subframe *)(agg_skb->
data);
5513 tmpCRC = RxDescr->CRC32;
5514 tmpICV = RxDescr->ICV;
5516 RxDescr->CRC32 = tmpCRC;
5517 RxDescr->ICV = tmpICV;
5525 PacketLength = stats.
Length;
5527 if(PacketLength > agg_skb->
len) {
5531 skb = dev_alloc_skb(PacketLength);
5535 rx_pkt_len = skb->
len;
5537 unicast_packet =
false;
5538 if(is_broadcast_ether_addr(ieee80211_hdr->
addr1)) {
5540 }
else if(is_multicast_ether_addr(ieee80211_hdr->
addr1)){
5544 unicast_packet =
true;
5549 priv->
stats.rxoktotal++;
5550 if(unicast_packet) {
5551 priv->
stats.rxbytesunicast += rx_pkt_len;
5557 PacketOccupiedLendth = PacketLength + PacketShiftBytes;
5558 if ((PacketOccupiedLendth & 0xFF) != 0) {
5559 PaddingBytes = 256 - (PacketOccupiedLendth & 0xFF);
5560 if (agg_skb->
len > PaddingBytes)
5566 dev_kfree_skb(agg_skb);
5570 priv->
stats.rxurberr++;
5586 struct r8192_priv *priv = ieee80211_priv(dev);
5597 #ifdef TODO // by amy about HCT
5599 CountRxErrStatistics(
Adapter, pRfd);
5602 #ifdef ENABLE_PS //by amy for adding ps function in future
5613 priv->
stats.rxframgment++;
5617 RmMonitorSignalStrength(
Adapter, pRfd);
5727 .ndo_get_stats = rtl8192_stats,
5730 .ndo_set_rx_mode = r8192_set_multicast,
5748 struct usb_device *
udev = interface_to_usbdev(intf);
5756 usb_set_intfdata(intf, dev);
5758 priv = ieee80211_priv(dev);
5765 #if WIRELESS_EXT >= 12
5766 #if WIRELESS_EXT < 17
5788 netif_stop_queue(dev);
5831 struct net_device *dev = usb_get_intfdata(intf);
5833 struct r8192_priv *priv = ieee80211_priv(dev);
5869 static int __init rtl8192_usb_module_init(
void)
5873 #ifdef CONFIG_IEEE80211_DEBUG
5906 printk(
KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n");
5911 return usb_register(&rtl8192_usb_driver);
5915 static void __exit rtl8192_usb_module_exit(
void)
5926 unsigned long flags;
5932 spin_unlock_irqrestore(&priv->
tx_lock,flags);
5940 u8 SECR_value = 0x0;
5980 u32 TargetCommand = 0;
5981 u32 TargetContent = 0;
5987 RT_TRACE(
COMP_SEC,
"====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev,EntryNo, KeyIndex, KeyType, MacAddr);
5990 usConfig |=
BIT15 | (KeyType<<2);
5992 usConfig |=
BIT15 | (KeyType<<2) | KeyIndex;
5997 TargetCommand = i+CAM_CONTENT_COUNT*EntryNo;
6001 TargetContent = (
u32)(*(MacAddr+0)) << 16|
6002 (
u32)(*(MacAddr+1)) << 24|
6010 TargetContent = (
u32)(*(MacAddr+2)) |
6011 (
u32)(*(MacAddr+3)) << 8|
6012 (
u32)(*(MacAddr+4)) << 16|
6013 (
u32)(*(MacAddr+5)) << 24;
6019 if(KeyContent !=
NULL){