diff options
Diffstat (limited to 'drivers/staging/rtl8192u/r8192U_core.c')
-rw-r--r-- | drivers/staging/rtl8192u/r8192U_core.c | 1067 |
1 files changed, 274 insertions, 793 deletions
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 76403864644c..929ac29197cc 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -56,29 +56,6 @@ double __extendsfdf2(float a) } #endif -#undef LOOP_TEST -#undef DUMP_RX -#undef DUMP_TX -#undef DEBUG_TX_DESC2 -#undef RX_DONT_PASS_UL -#undef DEBUG_EPROM -#undef DEBUG_RX_VERBOSE -#undef DUMMY_RX -#undef DEBUG_ZERO_RX -#undef DEBUG_RX_SKB -#undef DEBUG_TX_FRAG -#undef DEBUG_RX_FRAG -#undef DEBUG_TX_FILLDESC -#undef DEBUG_TX -#undef DEBUG_IRQ -#undef DEBUG_RX -#undef DEBUG_RXALLOC -#undef DEBUG_REGISTERS -#undef DEBUG_RING -#undef DEBUG_IRQ_TASKLET -#undef DEBUG_TX_ALLOC -#undef DEBUG_TX_DESC - #define CONFIG_RTL8192_IO_MAP #include <asm/uaccess.h> @@ -160,12 +137,12 @@ static struct usb_driver rtl8192_usb_driver = { }; -typedef struct _CHANNEL_LIST { +struct CHANNEL_LIST { u8 Channel[32]; u8 Len; -} CHANNEL_LIST, *PCHANNEL_LIST; +}; -static CHANNEL_LIST ChannelPlan[] = { +static struct CHANNEL_LIST ChannelPlan[] = { {{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}, //FCC {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, //IC {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, //ETSI @@ -665,15 +642,6 @@ static void tx_timeout(struct net_device *dev) schedule_work(&priv->reset_wq); } - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for (i = 0; i < 63; i++) - RT_TRACE(COMP_EPROM, "EEPROM addr %x : %x", i, eprom_read(dev, i)); -} - void rtl8192_update_msr(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -711,13 +679,11 @@ void rtl8192_set_chan(struct net_device *dev, short ch) /* this hack should avoid frame TX during channel setting*/ -#ifndef LOOP_TEST //need to implement rf set channel here WB if (priv->rf_set_chan) priv->rf_set_chan(dev, priv->chan); mdelay(10); -#endif } static void rtl8192_rx_isr(struct urb *urb); @@ -725,14 +691,8 @@ static void rtl8192_rx_isr(struct urb *urb); static u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats) { -#ifdef USB_RX_AGGREGATION_SUPPORT - if (pstats->bisrxaggrsubframe) - return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize - + pstats->RxBufShift + 8); - else -#endif - return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize - + pstats->RxBufShift); + return (sizeof(rx_desc_819x_usb) + pstats->RxDrvInfoSize + + pstats->RxBufShift); } static int rtl8192_rx_initiate(struct net_device *dev) @@ -1046,194 +1006,6 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) void rtl8192_try_wake_queue(struct net_device *dev, int pri); -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE -u16 DrvAggr_PaddingAdd(struct net_device *dev, struct sk_buff *skb) -{ - u16 PaddingNum = 256 - ((skb->len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES) % 256); - return PaddingNum & 0xff; -} - -u8 MRateToHwRate8190Pci(u8 rate); -u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc); -u8 MapHwQueueToFirmwareQueue(u8 QueueID); -struct sk_buff *DrvAggr_Aggregation(struct net_device *dev, struct ieee80211_drv_agg_txb *pSendList) -{ - struct ieee80211_device *ieee = netdev_priv(dev); - struct r8192_priv *priv = ieee80211_priv(dev); - cb_desc *tcb_desc = NULL; - u8 i; - u32 TotalLength; - struct sk_buff *skb; - struct sk_buff *agg_skb; - tx_desc_819x_usb_aggr_subframe *tx_agg_desc = NULL; - tx_fwinfo_819x_usb *tx_fwinfo = NULL; - - // - // Local variable initialization. - // - /* first skb initialization */ - skb = pSendList->tx_agg_frames[0]; - TotalLength = skb->len; - - /* Get the total aggregation length including the padding space and - * sub frame header. - */ - for (i = 1; i < pSendList->nr_drv_agg_frames; i++) { - TotalLength += DrvAggr_PaddingAdd(dev, skb); - skb = pSendList->tx_agg_frames[i]; - TotalLength += (skb->len + TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES); - } - - /* allocate skb to contain the aggregated packets */ - agg_skb = dev_alloc_skb(TotalLength + ieee->tx_headroom); - memset(agg_skb->data, 0, agg_skb->len); - skb_reserve(agg_skb, ieee->tx_headroom); - - /* reserve info for first subframe Tx descriptor to be set in the tx function */ - skb = pSendList->tx_agg_frames[0]; - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tcb_desc->drv_agg_enable = 1; - tcb_desc->pkt_size = skb->len; - tcb_desc->DrvAggrNum = pSendList->nr_drv_agg_frames; - netdev_dbg(dev, "DrvAggNum = %d\n", tcb_desc->DrvAggrNum); - memcpy(agg_skb->cb, skb->cb, sizeof(skb->cb)); - memcpy(skb_put(agg_skb, skb->len), skb->data, skb->len); - - for (i = 1; i < pSendList->nr_drv_agg_frames; i++) { - /* push the next sub frame to be 256 byte aline */ - skb_put(agg_skb, DrvAggr_PaddingAdd(dev, skb)); - - /* Subframe drv Tx descriptor and firmware info setting */ - skb = pSendList->tx_agg_frames[i]; - tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - tx_agg_desc = (tx_desc_819x_usb_aggr_subframe *)skb_tail_pointer(agg_skb); - tx_fwinfo = (tx_fwinfo_819x_usb *)(skb_tail_pointer(agg_skb) + sizeof(tx_desc_819x_usb_aggr_subframe)); - - memset(tx_fwinfo, 0, sizeof(tx_fwinfo_819x_usb)); - /* DWORD 0 */ - tx_fwinfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; - tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate); - tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; - tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc); - if (tcb_desc->bAMPDUEnable) { /* AMPDU enabled */ - tx_fwinfo->AllowAggregation = 1; - /* DWORD 1 */ - tx_fwinfo->RxMF = tcb_desc->ampdu_factor; - tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity - } else { - tx_fwinfo->AllowAggregation = 0; - /* DWORD 1 */ - tx_fwinfo->RxMF = 0; - tx_fwinfo->RxAMD = 0; - } - - /* Protection mode related */ - tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; - tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; - tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; - tx_fwinfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; - tx_fwinfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); - tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->RTSSC) : 0; - tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT == 1) ? ((tcb_desc->bRTSBW) ? 1 : 0) : 0; - tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : - (tcb_desc->bRTSUseShortGI ? 1 : 0); - - /* Set Bandwidth and sub-channel settings. */ - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { - if (tcb_desc->bPacketBW) { - tx_fwinfo->TxBandwidth = 1; - tx_fwinfo->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode - } else { - tx_fwinfo->TxBandwidth = 0; - tx_fwinfo->TxSubCarrier = priv->nCur40MhzPrimeSC; - } - } else { - tx_fwinfo->TxBandwidth = 0; - tx_fwinfo->TxSubCarrier = 0; - } - - /* Fill Tx descriptor */ - memset(tx_agg_desc, 0, sizeof(tx_desc_819x_usb_aggr_subframe)); - /* DWORD 0 */ - tx_agg_desc->Offset = sizeof(tx_fwinfo_819x_usb) + 8; - /* already raw data, need not to subtract header length */ - tx_agg_desc->PktSize = skb->len & 0xffff; - - /*DWORD 1*/ - tx_agg_desc->SecCAMID = 0; - tx_agg_desc->RATid = tcb_desc->RATRIndex; - tx_agg_desc->NoEnc = 1; - tx_agg_desc->SecType = 0x0; - - if (tcb_desc->bHwSec) { - switch (priv->ieee80211->pairwise_key_type) { - case KEY_TYPE_WEP40: - case KEY_TYPE_WEP104: - tx_agg_desc->SecType = 0x1; - tx_agg_desc->NoEnc = 0; - break; - case KEY_TYPE_TKIP: - tx_agg_desc->SecType = 0x2; - tx_agg_desc->NoEnc = 0; - break; - case KEY_TYPE_CCMP: - tx_agg_desc->SecType = 0x3; - tx_agg_desc->NoEnc = 0; - break; - case KEY_TYPE_NA: - tx_agg_desc->SecType = 0x0; - tx_agg_desc->NoEnc = 1; - break; - } - } - - tx_agg_desc->QueueSelect = MapHwQueueToFirmwareQueue(tcb_desc->queue_index); - tx_agg_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb); - - tx_agg_desc->DISFB = tcb_desc->bTxDisableRateFallBack; - tx_agg_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate; - - tx_agg_desc->OWN = 1; - - //DWORD 2 - /* According windows driver, it seems that there no need to fill this field */ - - /* to fill next packet */ - skb_put(agg_skb, TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES); - memcpy(skb_put(agg_skb, skb->len), skb->data, skb->len); - } - - for (i = 0; i < pSendList->nr_drv_agg_frames; i++) - dev_kfree_skb_any(pSendList->tx_agg_frames[i]); - - return agg_skb; -} - -/* NOTE: - This function return a list of PTCB which is proper to be aggregate with the input TCB. - If no proper TCB is found to do aggregation, SendList will only contain the input TCB. -*/ -u8 DrvAggr_GetAggregatibleList(struct net_device *dev, struct sk_buff *skb, - struct ieee80211_drv_agg_txb *pSendList) -{ - struct ieee80211_device *ieee = netdev_priv(dev); - PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - u16 nMaxAggrNum = pHTInfo->UsbTxAggrNum; - cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); - u8 QueueID = tcb_desc->queue_index; - - do { - pSendList->tx_agg_frames[pSendList->nr_drv_agg_frames++] = skb; - if (pSendList->nr_drv_agg_frames >= nMaxAggrNum) - break; - - } while ((skb = skb_dequeue(&ieee->skb_drv_aggQ[QueueID]))); - - RT_TRACE(COMP_AMSDU, "DrvAggr_GetAggregatibleList, nAggrTcbNum = %d \n", pSendList->nr_drv_agg_frames); - return pSendList->nr_drv_agg_frames; -} -#endif - static void rtl8192_tx_isr(struct urb *tx_urb) { struct sk_buff *skb = (struct sk_buff *)tx_urb->context; @@ -1285,37 +1057,6 @@ static void rtl8192_tx_isr(struct urb *tx_urb) return; //modified by david to avoid further processing AMSDU } -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - else if ((skb_queue_len(&priv->ieee80211->skb_drv_aggQ[queue_index]) != 0) && - (!(priv->ieee80211->queue_stop))) { - // Tx Driver Aggregation process - /* The driver will aggregation the packets according to the following stats - * 1. check whether there's tx irq available, for it's a completion return - * function, it should contain enough tx irq; - * 2. check packet type; - * 3. initialize sendlist, check whether the to-be send packet no greater than 1 - * 4. aggregates the packets, and fill firmware info and tx desc into it, etc. - * 5. check whether the packet could be sent, otherwise just insert into wait head - * */ - skb = skb_dequeue(&priv->ieee80211->skb_drv_aggQ[queue_index]); - if (!check_nic_enough_desc(dev, queue_index)) { - skb_queue_head(&(priv->ieee80211->skb_drv_aggQ[queue_index]), skb); - return; - } - - /*TODO*/ - { - struct ieee80211_drv_agg_txb SendList; - - memset(&SendList, 0, sizeof(struct ieee80211_drv_agg_txb)); - if (DrvAggr_GetAggregatibleList(dev, skb, &SendList) > 1) { - skb = DrvAggr_Aggregation(dev, &SendList); - - } - } - priv->ieee80211->softmac_hard_start_xmit(skb, dev); - } -#endif } } @@ -1330,83 +1071,83 @@ static void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) for (i = 0; i < net->rates_len; i++) { basic_rate = net->rates[i]&0x7f; switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; } } for (i = 0; i < net->rates_ex_len; i++) { basic_rate = net->rates_ex[i]&0x7f; switch (basic_rate) { - case MGN_1M: - *rate_config |= RRSR_1M; - break; - case MGN_2M: - *rate_config |= RRSR_2M; - break; - case MGN_5_5M: - *rate_config |= RRSR_5_5M; - break; - case MGN_11M: - *rate_config |= RRSR_11M; - break; - case MGN_6M: - *rate_config |= RRSR_6M; - break; - case MGN_9M: - *rate_config |= RRSR_9M; - break; - case MGN_12M: - *rate_config |= RRSR_12M; - break; - case MGN_18M: - *rate_config |= RRSR_18M; - break; - case MGN_24M: - *rate_config |= RRSR_24M; - break; - case MGN_36M: - *rate_config |= RRSR_36M; - break; - case MGN_48M: - *rate_config |= RRSR_48M; - break; - case MGN_54M: - *rate_config |= RRSR_54M; - break; + case MGN_1M: + *rate_config |= RRSR_1M; + break; + case MGN_2M: + *rate_config |= RRSR_2M; + break; + case MGN_5_5M: + *rate_config |= RRSR_5_5M; + break; + case MGN_11M: + *rate_config |= RRSR_11M; + break; + case MGN_6M: + *rate_config |= RRSR_6M; + break; + case MGN_9M: + *rate_config |= RRSR_9M; + break; + case MGN_12M: + *rate_config |= RRSR_12M; + break; + case MGN_18M: + *rate_config |= RRSR_18M; + break; + case MGN_24M: + *rate_config |= RRSR_24M; + break; + case MGN_36M: + *rate_config |= RRSR_36M; + break; + case MGN_48M: + *rate_config |= RRSR_48M; + break; + case MGN_54M: + *rate_config |= RRSR_54M; + break; } } } @@ -1486,28 +1227,6 @@ inline u8 rtl8192_IsWirelessBMode(u16 rate) u16 N_DBPSOfRate(u16 DataRate); -u16 ComputeTxTime(u16 FrameLength, u16 DataRate, u8 bManagementFrame, - u8 bShortPreamble) -{ - u16 FrameTime; - u16 N_DBPS; - u16 Ceiling; - - if (rtl8192_IsWirelessBMode(DataRate)) { - if (bManagementFrame || !bShortPreamble || DataRate == 10) /* long preamble */ - FrameTime = (u16)(144+48+(FrameLength*8/(DataRate/10))); - else // Short preamble - FrameTime = (u16)(72+24+(FrameLength*8/(DataRate/10))); - if ((FrameLength*8 % (DataRate/10)) != 0) /* Get the Ceilling */ - FrameTime++; - } else { //802.11g DSSS-OFDM PLCP length field calculation. - N_DBPS = N_DBPSOfRate(DataRate); - Ceiling = (16 + 8*FrameLength + 6) / N_DBPS - + (((16 + 8*FrameLength + 6) % N_DBPS) ? 1 : 0); - FrameTime = (u16)(16 + 4 + 4*Ceiling + 6); - } - return FrameTime; -} u16 N_DBPSOfRate(u16 DataRate) { @@ -1553,15 +1272,6 @@ u16 N_DBPSOfRate(u16 DataRate) return N_DBPS; } -unsigned int txqueue2outpipe(struct r8192_priv *priv, unsigned int tx_queue) -{ - if (tx_queue >= 9) { - RT_TRACE(COMP_ERR, "%s():Unknown queue ID!!!\n", __func__); - return 0x04; - } - return priv->txqueue_to_outpipemap[tx_queue]; -} - short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -1591,12 +1301,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) //---------------------------------------------------------------------------- // Fill up USB_OUT_CONTEXT. //---------------------------------------------------------------------------- - // Get index to out pipe from specified QueueID. -#ifndef USE_ONE_PIPE - idx_pipe = txqueue2outpipe(priv, queue_index); -#else idx_pipe = 0x04; -#endif usb_fill_bulk_urb(tx_urb, priv->udev, usb_sndbulkpipe(priv->udev, idx_pipe), skb->data, skb->len, rtl8192_tx_isr, skb); @@ -1666,98 +1371,98 @@ static u8 MRateToHwRate8190Pci(u8 rate) u8 ret = DESC90_RATE1M; switch (rate) { - case MGN_1M: - ret = DESC90_RATE1M; - break; - case MGN_2M: - ret = DESC90_RATE2M; - break; - case MGN_5_5M: - ret = DESC90_RATE5_5M; - break; - case MGN_11M: - ret = DESC90_RATE11M; - break; - case MGN_6M: - ret = DESC90_RATE6M; - break; - case MGN_9M: - ret = DESC90_RATE9M; - break; - case MGN_12M: - ret = DESC90_RATE12M; - break; - case MGN_18M: - ret = DESC90_RATE18M; - break; - case MGN_24M: - ret = DESC90_RATE24M; - break; - case MGN_36M: - ret = DESC90_RATE36M; - break; - case MGN_48M: - ret = DESC90_RATE48M; - break; - case MGN_54M: - ret = DESC90_RATE54M; - break; + case MGN_1M: + ret = DESC90_RATE1M; + break; + case MGN_2M: + ret = DESC90_RATE2M; + break; + case MGN_5_5M: + ret = DESC90_RATE5_5M; + break; + case MGN_11M: + ret = DESC90_RATE11M; + break; + case MGN_6M: + ret = DESC90_RATE6M; + break; + case MGN_9M: + ret = DESC90_RATE9M; + break; + case MGN_12M: + ret = DESC90_RATE12M; + break; + case MGN_18M: + ret = DESC90_RATE18M; + break; + case MGN_24M: + ret = DESC90_RATE24M; + break; + case MGN_36M: + ret = DESC90_RATE36M; + break; + case MGN_48M: + ret = DESC90_RATE48M; + break; + case MGN_54M: + ret = DESC90_RATE54M; + break; - // HT rate since here - case MGN_MCS0: - ret = DESC90_RATEMCS0; - break; - case MGN_MCS1: - ret = DESC90_RATEMCS1; - break; - case MGN_MCS2: - ret = DESC90_RATEMCS2; - break; - case MGN_MCS3: - ret = DESC90_RATEMCS3; - break; - case MGN_MCS4: - ret = DESC90_RATEMCS4; - break; - case MGN_MCS5: - ret = DESC90_RATEMCS5; - break; - case MGN_MCS6: - ret = DESC90_RATEMCS6; - break; - case MGN_MCS7: - ret = DESC90_RATEMCS7; - break; - case MGN_MCS8: - ret = DESC90_RATEMCS8; - break; - case MGN_MCS9: - ret = DESC90_RATEMCS9; - break; - case MGN_MCS10: - ret = DESC90_RATEMCS10; - break; - case MGN_MCS11: - ret = DESC90_RATEMCS11; - break; - case MGN_MCS12: - ret = DESC90_RATEMCS12; - break; - case MGN_MCS13: - ret = DESC90_RATEMCS13; - break; - case MGN_MCS14: - ret = DESC90_RATEMCS14; - break; - case MGN_MCS15: - ret = DESC90_RATEMCS15; - break; - case (0x80|0x20): - ret = DESC90_RATEMCS32; - break; + /* HT rate since here */ + case MGN_MCS0: + ret = DESC90_RATEMCS0; + break; + case MGN_MCS1: + ret = DESC90_RATEMCS1; + break; + case MGN_MCS2: + ret = DESC90_RATEMCS2; + break; + case MGN_MCS3: + ret = DESC90_RATEMCS3; + break; + case MGN_MCS4: + ret = DESC90_RATEMCS4; + break; + case MGN_MCS5: + ret = DESC90_RATEMCS5; + break; + case MGN_MCS6: + ret = DESC90_RATEMCS6; + break; + case MGN_MCS7: + ret = DESC90_RATEMCS7; + break; + case MGN_MCS8: + ret = DESC90_RATEMCS8; + break; + case MGN_MCS9: + ret = DESC90_RATEMCS9; + break; + case MGN_MCS10: + ret = DESC90_RATEMCS10; + break; + case MGN_MCS11: + ret = DESC90_RATEMCS11; + break; + case MGN_MCS12: + ret = DESC90_RATEMCS12; + break; + case MGN_MCS13: + ret = DESC90_RATEMCS13; + break; + case MGN_MCS14: + ret = DESC90_RATEMCS14; + break; + case MGN_MCS15: + ret = DESC90_RATEMCS15; + break; + case (0x80|0x20): + ret = DESC90_RATEMCS32; + break; - default: - break; + default: + break; } return ret; } @@ -1857,25 +1562,13 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) tx_fwinfo->TxSubCarrier = 0; } -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - if (tcb_desc->drv_agg_enable) - tx_fwinfo->Tx_INFO_RSVD = (tcb_desc->DrvAggrNum & 0x1f) << 1; -#endif /* Fill Tx descriptor */ memset(tx_desc, 0, sizeof(tx_desc_819x_usb)); /* DWORD 0 */ tx_desc->LINIP = 0; tx_desc->CmdInit = 1; tx_desc->Offset = sizeof(tx_fwinfo_819x_usb) + 8; - -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - if (tcb_desc->drv_agg_enable) - tx_desc->PktSize = tcb_desc->pkt_size; - else -#endif - { - tx_desc->PktSize = (skb->len - TX_PACKET_SHIFT_BYTES) & 0xffff; - } + tx_desc->PktSize = (skb->len - TX_PACKET_SHIFT_BYTES) & 0xffff; /*DWORD 1*/ tx_desc->SecCAMID = 0; @@ -1916,21 +1609,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) tx_desc->LastSeg = 1; tx_desc->OWN = 1; -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - if (tcb_desc->drv_agg_enable) { - tx_desc->TxBufferSize = tcb_desc->pkt_size + sizeof(tx_fwinfo_819x_usb); - } else -#endif - { - //DWORD 2 - tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN); - } - /* Get index to out pipe from specified QueueID */ -#ifndef USE_ONE_PIPE - idx_pipe = txqueue2outpipe(priv, tcb_desc->queue_index); -#else + /* DWORD 2 */ + tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN); idx_pipe = 0x5; -#endif /* To submit bulk urb */ usb_fill_bulk_urb(tx_urb, udev, @@ -2230,19 +1911,18 @@ static int rtl8192_handle_beacon(struct net_device *dev, static int rtl8192_qos_association_resp(struct r8192_priv *priv, struct ieee80211_network *network) { - int ret = 0; unsigned long flags; u32 size = sizeof(struct ieee80211_qos_parameters); int set_qos_param = 0; if ((priv == NULL) || (network == NULL)) - return ret; + return 0; if (priv->ieee80211->state != IEEE80211_LINKED) - return ret; + return 0; if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) - return ret; + return 0; spin_lock_irqsave(&priv->ieee80211->lock, flags); if (network->flags & NETWORK_HAS_QOS_PARAMETERS) { @@ -2271,7 +1951,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, queue_work(priv->priv_wq, &priv->qos_activate); - return ret; + return 0; } @@ -2869,9 +2549,6 @@ static short rtl8192_init(struct net_device *dev) return -ENOMEM; } -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif return 0; } @@ -3066,22 +2743,6 @@ static bool rtl8192_adapter_start(struct net_device *dev) for (i = 0; i < QOS_QUEUE_NUM; i++) write_nic_dword(dev, WDCAPARA_ADD[i], DEFAULT_EDCA); } -#ifdef USB_RX_AGGREGATION_SUPPORT - //3 For usb rx firmware aggregation control - if (priv->ResetProgress == RESET_TYPE_NORESET) { - u32 ulValue; - PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo; - ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) | - (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout); - /* - * If usb rx firmware aggregation is enabled, - * when anyone of three threshold conditions above is reached, - * firmware will send aggregated packet to driver. - */ - write_nic_dword(dev, 0x1a8, ulValue); - priv->bCurrentRxAggrEnable = true; - } -#endif rtl8192_phy_configmac(dev); @@ -3235,12 +2896,8 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev) for (QueueID = 0; QueueID <= BEACON_QUEUE; QueueID++) { if (QueueID == TXCMD_QUEUE) continue; -#ifdef USB_TX_DRIVER_AGGREGATION_ENABLE - 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)) -#else if ((skb_queue_len(&priv->ieee80211->skb_waitQ[QueueID]) == 0) && (skb_queue_len(&priv->ieee80211->skb_aggQ[QueueID]) == 0)) -#endif - continue; + continue; bCheckFwTxCnt = true; } @@ -3532,34 +3189,6 @@ RESET_START: } } -void CAM_read_entry(struct net_device *dev, u32 iIndex) -{ - u32 target_command = 0; - u32 target_content = 0; - u8 entry_i = 0; - u32 ulStatus; - s32 i = 100; - for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { - // polling bit, and No Write enable, and address - target_command = entry_i+CAM_CONTENT_COUNT*iIndex; - target_command = target_command | BIT31; - - //Check polling bit is clear - while ((i--) >= 0) { - read_nic_dword(dev, RWCAM, &ulStatus); - if (ulStatus & BIT31) - continue; - else - break; - } - write_nic_dword(dev, RWCAM, target_command); - RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A0: %x \n", target_command); - read_nic_dword(dev, RCAMO, &target_content); - RT_TRACE(COMP_SEC, "CAM_read_entry(): WRITE A8: %x \n", target_content); - } - printk("\n"); -} - static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, u32 *TotalRxDataNum) { @@ -4656,102 +4285,96 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, preamble_guardinterval = 0;// long switch (stats->rate) { - // - // CCK rate - // - case MGN_1M: - rateIndex = 0; - break; - case MGN_2M: - rateIndex = 1; - break; - case MGN_5_5M: - rateIndex = 2; - break; - case MGN_11M: - rateIndex = 3; - break; - // - // Legacy OFDM rate - // - case MGN_6M: - rateIndex = 4; - break; - case MGN_9M: - rateIndex = 5; - break; - case MGN_12M: - rateIndex = 6; - break; - case MGN_18M: - rateIndex = 7; - break; - case MGN_24M: - rateIndex = 8; - break; - case MGN_36M: - rateIndex = 9; - break; - case MGN_48M: - rateIndex = 10; - break; - case MGN_54M: - rateIndex = 11; - break; - // - // 11n High throughput rate - // - case MGN_MCS0: - rateIndex = 12; - break; - case MGN_MCS1: - rateIndex = 13; - break; - case MGN_MCS2: - rateIndex = 14; - break; - case MGN_MCS3: - rateIndex = 15; - break; - case MGN_MCS4: - rateIndex = 16; - break; - case MGN_MCS5: - rateIndex = 17; - break; - case MGN_MCS6: - rateIndex = 18; - break; - case MGN_MCS7: - rateIndex = 19; - break; - case MGN_MCS8: - rateIndex = 20; - break; - case MGN_MCS9: - rateIndex = 21; - break; - case MGN_MCS10: - rateIndex = 22; - break; - case MGN_MCS11: - rateIndex = 23; - break; - case MGN_MCS12: - rateIndex = 24; - break; - case MGN_MCS13: - rateIndex = 25; - break; - case MGN_MCS14: - rateIndex = 26; - break; - case MGN_MCS15: - rateIndex = 27; - break; - default: - rateIndex = 28; - break; + /* CCK rate */ + case MGN_1M: + rateIndex = 0; + break; + case MGN_2M: + rateIndex = 1; + break; + case MGN_5_5M: + rateIndex = 2; + break; + case MGN_11M: + rateIndex = 3; + break; + /* Legacy OFDM rate */ + case MGN_6M: + rateIndex = 4; + break; + case MGN_9M: + rateIndex = 5; + break; + case MGN_12M: + rateIndex = 6; + break; + case MGN_18M: + rateIndex = 7; + break; + case MGN_24M: + rateIndex = 8; + break; + case MGN_36M: + rateIndex = 9; + break; + case MGN_48M: + rateIndex = 10; + break; + case MGN_54M: + rateIndex = 11; + break; + /* 11n High throughput rate */ + case MGN_MCS0: + rateIndex = 12; + break; + case MGN_MCS1: + rateIndex = 13; + break; + case MGN_MCS2: + rateIndex = 14; + break; + case MGN_MCS3: + rateIndex = 15; + break; + case MGN_MCS4: + rateIndex = 16; + break; + case MGN_MCS5: + rateIndex = 17; + break; + case MGN_MCS6: + rateIndex = 18; + break; + case MGN_MCS7: + rateIndex = 19; + break; + case MGN_MCS8: + rateIndex = 20; + break; + case MGN_MCS9: + rateIndex = 21; + break; + case MGN_MCS10: + rateIndex = 22; + break; + case MGN_MCS11: + rateIndex = 23; + break; + case MGN_MCS12: + rateIndex = 24; + break; + case MGN_MCS13: + rateIndex = 25; + break; + case MGN_MCS14: + rateIndex = 26; + break; + case MGN_MCS15: + rateIndex = 27; + break; + default: + rateIndex = 28; + break; } priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; priv->stats.received_rate_histogram[0][rateIndex]++; //total @@ -4771,30 +4394,16 @@ static void query_rxdesc_status(struct sk_buff *skb, // //Get Rx Descriptor Information // -#ifdef USB_RX_AGGREGATION_SUPPORT - if (bIsRxAggrSubframe) { - rx_desc_819x_usb_aggr_subframe *desc = (rx_desc_819x_usb_aggr_subframe *)skb->data; - stats->Length = desc->Length; - stats->RxDrvInfoSize = desc->RxDrvInfoSize; - stats->RxBufShift = 0; //RxBufShift = 2 in RxDesc, but usb didn't shift bytes in fact. - stats->bICV = desc->ICV; - stats->bCRC = desc->CRC32; - stats->bHwError = stats->bCRC|stats->bICV; - stats->Decrypted = !desc->SWDec;//RTL8190 set this bit to indicate that Hw does not decrypt packet - } else -#endif - { - rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; + rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; - stats->Length = desc->Length; - stats->RxDrvInfoSize = desc->RxDrvInfoSize; - stats->RxBufShift = 0; - stats->bICV = desc->ICV; - stats->bCRC = desc->CRC32; - stats->bHwError = stats->bCRC|stats->bICV; - //RTL8190 set this bit to indicate that Hw does not decrypt packet - stats->Decrypted = !desc->SWDec; - } + stats->Length = desc->Length; + stats->RxDrvInfoSize = desc->RxDrvInfoSize; + stats->RxBufShift = 0; + stats->bICV = desc->ICV; + stats->bCRC = desc->CRC32; + stats->bHwError = stats->bCRC|stats->bICV; + /* RTL8190 set this bit to indicate that Hw does not decrypt packet */ + stats->Decrypted = !desc->SWDec; if ((priv->ieee80211->pHTInfo->bCurrentHTSupport == true) && (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP)) stats->bHwError = false; @@ -4859,11 +4468,6 @@ static void query_rxdesc_status(struct sk_buff *skb, skb_pull(skb, stats->RxBufShift + stats->RxDrvInfoSize); } -#ifdef USB_RX_AGGREGATION_SUPPORT - /* for the rx aggregated sub frame, the redundant space truly contained in the packet */ - if (bIsRxAggrSubframe) - skb_pull(skb, 8); -#endif /* for debug 2008.5.29 */ //added by vivi, for MP, 20080108 @@ -4873,18 +4477,6 @@ static void query_rxdesc_status(struct sk_buff *skb, } -u32 GetRxPacketShiftBytes819xUsb(struct ieee80211_rx_stats *Status, bool bIsRxAggrSubframe) -{ -#ifdef USB_RX_AGGREGATION_SUPPORT - if (bIsRxAggrSubframe) - return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize - + Status->RxBufShift + 8); - else -#endif - return (sizeof(rx_desc_819x_usb) + Status->RxDrvInfoSize - + Status->RxBufShift); -} - static void rtl8192_rx_nomal(struct sk_buff *skb) { rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; @@ -4899,42 +4491,13 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) u32 rx_pkt_len = 0; struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; bool unicast_packet = false; -#ifdef USB_RX_AGGREGATION_SUPPORT - struct sk_buff *agg_skb = NULL; - u32 TotalLength = 0; - u32 TempDWord = 0; - u32 PacketLength = 0; - u32 PacketOccupiedLendth = 0; - u8 TempByte = 0; - u32 PacketShiftBytes = 0; - rx_desc_819x_usb_aggr_subframe *RxDescr = NULL; - u8 PaddingBytes = 0; - //add just for testing - u8 testing; - -#endif /* 20 is for ps-poll */ if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { -#ifdef USB_RX_AGGREGATION_SUPPORT - TempByte = *(skb->data + sizeof(rx_desc_819x_usb)); -#endif /* first packet should not contain Rx aggregation header */ query_rxdesc_status(skb, &stats, false); /* TODO */ /* hardware related info */ -#ifdef USB_RX_AGGREGATION_SUPPORT - if (TempByte & BIT0) { - agg_skb = skb; - TotalLength = stats.Length - 4; /*sCrcLng*/ - /* though the head pointer has passed this position */ - TempDWord = *(u32 *)(agg_skb->data - 4); - PacketLength = (u16)(TempDWord & 0x3FFF); /*sCrcLng*/ - skb = dev_alloc_skb(PacketLength); - memcpy(skb_put(skb, PacketLength), agg_skb->data, PacketLength); - PacketShiftBytes = GetRxPacketShiftBytes819xUsb(&stats, false); - } -#endif /* Process the MPDU received */ skb_trim(skb, skb->len - 4/*sCrcLng*/); @@ -4957,76 +4520,6 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) if (unicast_packet) priv->stats.rxbytesunicast += rx_pkt_len; } -#ifdef USB_RX_AGGREGATION_SUPPORT - testing = 1; - if (TotalLength > 0) { - PacketOccupiedLendth = PacketLength + (PacketShiftBytes + 8); - if ((PacketOccupiedLendth & 0xFF) != 0) - PacketOccupiedLendth = (PacketOccupiedLendth & 0xFFFFFF00) + 256; - PacketOccupiedLendth -= 8; - TempDWord = PacketOccupiedLendth - PacketShiftBytes; /*- PacketLength */ - if (agg_skb->len > TempDWord) - skb_pull(agg_skb, TempDWord); - else - agg_skb->len = 0; - - while (agg_skb->len >= GetRxPacketShiftBytes819xUsb(&stats, true)) { - u8 tmpCRC = 0, tmpICV = 0; - RxDescr = (rx_desc_819x_usb_aggr_subframe *)(agg_skb->data); - tmpCRC = RxDescr->CRC32; - tmpICV = RxDescr->ICV; - memcpy(agg_skb->data, &agg_skb->data[44], 2); - RxDescr->CRC32 = tmpCRC; - RxDescr->ICV = tmpICV; - - memset(&stats, 0, sizeof(struct ieee80211_rx_stats)); - stats.signal = 0; - stats.noise = -98; - stats.rate = 0; - stats.freq = IEEE80211_24GHZ_BAND; - query_rxdesc_status(agg_skb, &stats, true); - PacketLength = stats.Length; - - if (PacketLength > agg_skb->len) - break; - /* Process the MPDU received */ - skb = dev_alloc_skb(PacketLength); - memcpy(skb_put(skb, PacketLength), agg_skb->data, PacketLength); - skb_trim(skb, skb->len - 4/*sCrcLng*/); - - rx_pkt_len = skb->len; - ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; - unicast_packet = false; - if (is_broadcast_ether_addr(ieee80211_hdr->addr1)) { - //TODO - } else if (is_multicast_ether_addr(ieee80211_hdr->addr1)) { - //TODO - } else { - /* unicast packet */ - unicast_packet = true; - } - if (!ieee80211_rx(priv->ieee80211, skb, &stats)) { - dev_kfree_skb_any(skb); - } else { - priv->stats.rxoktotal++; - if (unicast_packet) - priv->stats.rxbytesunicast += rx_pkt_len; - } - /* should trim the packet which has been copied to target skb */ - skb_pull(agg_skb, PacketLength); - PacketShiftBytes = GetRxPacketShiftBytes819xUsb(&stats, true); - PacketOccupiedLendth = PacketLength + PacketShiftBytes; - if ((PacketOccupiedLendth & 0xFF) != 0) { - PaddingBytes = 256 - (PacketOccupiedLendth & 0xFF); - if (agg_skb->len > PaddingBytes) - skb_pull(agg_skb, PaddingBytes); - else - agg_skb->len = 0; - } - } - dev_kfree_skb(agg_skb); - } -#endif } else { priv->stats.rxurberr++; netdev_dbg(dev, "actual_length: %d\n", skb->len); @@ -5276,18 +4769,6 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) RT_TRACE(COMP_DOWN, "wlan driver removed\n"); } -/* fun with the built-in ieee80211 stack... */ -extern int ieee80211_debug_init(void); -extern void ieee80211_debug_exit(void); -extern int ieee80211_crypto_init(void); -extern void ieee80211_crypto_deinit(void); -extern int ieee80211_crypto_tkip_init(void); -extern void ieee80211_crypto_tkip_exit(void); -extern int ieee80211_crypto_ccmp_init(void); -extern void ieee80211_crypto_ccmp_exit(void); -extern int ieee80211_crypto_wep_init(void); -extern void ieee80211_crypto_wep_exit(void); - static int __init rtl8192_usb_module_init(void) { int ret; |