staging: rtl8192e: Pass ieee80211_device to callbacks
[deliverable/linux.git] / drivers / staging / rtl8192e / r8192E_core.c
index 8715d2cee8f1a50b687e9b16fd55b592f0809926..c392f19b0bdbfb43dc3d9fceb3c4613db83ac2f2 100644 (file)
@@ -96,8 +96,8 @@ static struct pci_driver rtl8192_pci_driver = {
 #endif
 };
 
-static void rtl8192_start_beacon(struct net_device *dev);
-static void rtl8192_stop_beacon(struct net_device *dev);
+static void rtl8192_start_beacon(struct ieee80211_device *ieee80211);
+static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211);
 static void rtl819x_watchdog_wqcallback(struct work_struct *work);
 static void rtl8192_irq_rx_tasklet(unsigned long arg);
 static void rtl8192_irq_tx_tasklet(unsigned long arg);
@@ -368,8 +368,7 @@ static int proc_get_stats_ap(char *page, char **start,
                          off_t offset, int count,
                          int *eof, void *data)
 {
-       struct net_device *dev = data;
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = data;
        struct ieee80211_device *ieee = priv->ieee80211;
        struct ieee80211_network *target;
        int len = 0;
@@ -398,8 +397,7 @@ static int proc_get_registers(char *page, char **start,
                          off_t offset, int count,
                          int *eof, void *data)
 {
-       struct net_device *dev = data;
-       struct r8192_priv *priv = ieee80211_priv(dev);
+       struct r8192_priv *priv = data;
        int len = 0;
        int i,n;
        int max=0xff;
@@ -451,8 +449,7 @@ static int proc_get_stats_tx(char *page, char **start,
                          off_t offset, int count,
                          int *eof, void *data)
 {
-       struct net_device *dev = data;
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = data;
 
        int len = 0;
 
@@ -477,7 +474,7 @@ static int proc_get_stats_tx(char *page, char **start,
                priv->stats.txbeaconokint,
                priv->stats.txbeaconerr,
                priv->stats.txcmdpktokint,
-               netif_queue_stopped(dev),
+               netif_queue_stopped(priv->ieee80211->dev),
                priv->stats.txoverflow,
                priv->ieee80211->stats.tx_packets,
                priv->ieee80211->stats.tx_bytes);
@@ -492,9 +489,7 @@ static int proc_get_stats_rx(char *page, char **start,
                          off_t offset, int count,
                          int *eof, void *data)
 {
-       struct net_device *dev = data;
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
-
+       struct r8192_priv *priv = data;
        int len = 0;
 
        len += snprintf(page + len, count - len,
@@ -553,7 +548,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
                return;
        }
        e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_rx, dev);
+                                  priv->dir_dev, proc_get_stats_rx, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR,"Unable to initialize "
@@ -563,7 +558,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
 
 
        e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_tx, dev);
+                                  priv->dir_dev, proc_get_stats_tx, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
@@ -572,7 +567,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
        }
 
        e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_stats_ap, dev);
+                                  priv->dir_dev, proc_get_stats_ap, priv);
 
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
@@ -581,7 +576,7 @@ static void rtl8192_proc_init_one(struct r8192_priv *priv)
        }
 
        e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
-                                  priv->dir_dev, proc_get_registers, dev);
+                                  priv->dir_dev, proc_get_registers, priv);
        if (!e) {
                RT_TRACE(COMP_ERR, "Unable to initialize "
                      "/proc/net/rtl8192/%s/registers\n",
@@ -653,16 +648,16 @@ static void rtl8192_update_msr(struct r8192_priv *priv)
        write_nic_byte(priv, MSR, msr);
 }
 
-static void rtl8192_set_chan(struct net_device *dev,short ch)
+static void rtl8192_set_chan(struct ieee80211_device *ieee80211, short ch)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
 
        priv->chan = ch;
 
        /* need to implement rf set channel here WB */
 
        if (priv->rf_set_chan)
-               priv->rf_set_chan(dev, priv->chan);
+               priv->rf_set_chan(ieee80211, priv->chan);
 }
 
 static void rtl8192_rx_enable(struct r8192_priv *priv)
@@ -808,11 +803,11 @@ static void rtl8192_halt_adapter(struct r8192_priv *priv, bool reset)
        skb_queue_purge(&priv->skb_queue);
 }
 
-static void rtl8192_data_hard_stop(struct net_device *dev)
+static void rtl8192_data_hard_stop(struct ieee80211_device *ieee80211)
 {
 }
 
-static void rtl8192_data_hard_resume(struct net_device *dev)
+static void rtl8192_data_hard_resume(struct ieee80211_device *ieee80211)
 {
 }
 
@@ -820,9 +815,10 @@ static void rtl8192_data_hard_resume(struct net_device *dev)
  * this function TX data frames when the ieee80211 stack requires this.
  * It checks also if we need to stop the ieee tx queue, eventually do it
  */
-static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
+static void rtl8192_hard_data_xmit(struct sk_buff *skb,
+                                  struct ieee80211_device *ieee80211, int rate)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        int ret;
        cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
        u8 queue_index = tcb_desc->queue_index;
@@ -836,7 +832,7 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
                return;
        }
 
-       memcpy(skb->cb, &dev, sizeof(dev));
+       memcpy(skb->cb, &ieee80211->dev, sizeof(ieee80211->dev));
 
        skb_push(skb, priv->ieee80211->tx_headroom);
        ret = rtl8192_tx(priv, skb);
@@ -856,9 +852,9 @@ static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
  * If the ring is full packet are dropped (for data frame the queue
  * is stopped before this can happen).
  */
-static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
+static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        int ret;
         cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
         u8 queue_index = tcb_desc->queue_index;
@@ -871,7 +867,7 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
                }
         }
 
-        memcpy(skb->cb, &dev, sizeof(dev));
+        memcpy(skb->cb, &ieee80211->dev, sizeof(ieee80211->dev));
        if (queue_index == TXCMD_QUEUE) {
                rtl819xE_tx_cmd(priv, skb);
                ret = 0;
@@ -881,7 +877,7 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
                tcb_desc->bTxDisableRateFallBack = 1;
                tcb_desc->bTxUseDriverAssingedRate = 1;
                tcb_desc->bTxEnableFwCalcDur = 1;
-               skb_push(skb, priv->ieee80211->tx_headroom);
+               skb_push(skb, ieee80211->tx_headroom);
                ret = rtl8192_tx(priv, skb);
                if (ret != 0) {
                        kfree_skb(skb);
@@ -923,7 +919,7 @@ static void rtl8192_tx_isr(struct r8192_priv *priv, int prio)
        }
 }
 
-static void rtl8192_stop_beacon(struct net_device *dev)
+static void rtl8192_stop_beacon(struct ieee80211_device *ieee80211)
 {
 }
 
@@ -1932,8 +1928,8 @@ static void rtl8192_init_priv_variable(struct r8192_priv *priv)
        priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
        priv->ieee80211->host_encrypt = 1;
        priv->ieee80211->host_decrypt = 1;
-       priv->ieee80211->start_send_beacons = rtl8192_start_beacon;//+by david 081107
-       priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon;//+by david 081107
+       priv->ieee80211->start_send_beacons = rtl8192_start_beacon;
+       priv->ieee80211->stop_send_beacons = rtl8192_stop_beacon;
        priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit;
        priv->ieee80211->set_chan = rtl8192_set_chan;
        priv->ieee80211->link_change = rtl8192_link_change;
@@ -2858,9 +2854,9 @@ static void rtl8192_prepare_beacon(unsigned long arg)
  * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might
  * be used to stop beacon transmission
  */
-static void rtl8192_start_beacon(struct net_device *dev)
+static void rtl8192_start_beacon(struct ieee80211_device *ieee80211)
 {
-       struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
+       struct r8192_priv *priv = ieee80211_priv(ieee80211->dev);
        struct ieee80211_network *net = &priv->ieee80211->current_network;
        u16 BcnTimeCfg = 0;
         u16 BcnCW = 6;
@@ -2976,38 +2972,31 @@ static RESET_TYPE RxCheckStuck(struct r8192_priv *priv)
        return RESET_TYPE_NORESET;
 }
 
-static RESET_TYPE
-rtl819x_ifcheck_resetornot(struct r8192_priv *priv)
+static RESET_TYPE rtl819x_check_reset(struct r8192_priv *priv)
 {
-       RESET_TYPE      TxResetType = RESET_TYPE_NORESET;
-       RESET_TYPE      RxResetType = RESET_TYPE_NORESET;
-       RT_RF_POWER_STATE       rfState;
+       RESET_TYPE RxResetType = RESET_TYPE_NORESET;
+       RT_RF_POWER_STATE rfState;
 
        rfState = priv->eRFPowerState;
 
-       if( rfState != eRfOff &&
-               /*ADAPTER_TEST_STATUS_FLAG(Adapter, ADAPTER_STATUS_FW_DOWNLOAD_FAILURE)) &&*/
-               (priv->ieee80211->iw_mode != IW_MODE_ADHOC))
-       {
-               // If driver is in the status of firmware download failure , driver skips RF initialization and RF is
-               // in turned off state. Driver should check whether Rx stuck and do silent reset. And
-               // if driver is in firmware download failure status, driver should initialize RF in the following
-               // silent reset procedure Emily, 2008.01.21
-
-               // Driver should not check RX stuck in IBSS mode because it is required to
-               // set Check BSSID in order to send beacon, however, if check BSSID is
-               // set, STA cannot hear any packet a all. Emily, 2008.04.12
+       if (rfState != eRfOff && (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) {
+               /*
+                * If driver is in the status of firmware download failure,
+                * driver skips RF initialization and RF is in turned off state.
+                * Driver should check whether Rx stuck and do silent reset. And
+                * if driver is in firmware download failure status, driver
+                * should initialize RF in the following silent reset procedure
+                *
+                * Driver should not check RX stuck in IBSS mode because it is
+                * required to set Check BSSID in order to send beacon, however,
+                * if check BSSID is set, STA cannot hear any packet a all.
+                */
                RxResetType = RxCheckStuck(priv);
        }
 
-       RT_TRACE(COMP_RESET,"%s(): TxResetType is %d, RxResetType is %d\n",__FUNCTION__,TxResetType,RxResetType);
-       if(TxResetType==RESET_TYPE_NORMAL || RxResetType==RESET_TYPE_NORMAL)
-               return RESET_TYPE_NORMAL;
-       else if(TxResetType==RESET_TYPE_SILENT || RxResetType==RESET_TYPE_SILENT)
-               return RESET_TYPE_SILENT;
-       else
-               return RESET_TYPE_NORESET;
+       RT_TRACE(COMP_RESET, "%s():  RxResetType is %d\n", __FUNCTION__, RxResetType);
 
+       return RxResetType;
 }
 
 #ifdef ENABLE_IPS
@@ -3346,7 +3335,7 @@ static void rtl819x_watchdog_wqcallback(struct work_struct *work)
        if (priv->watchdog_check_reset_cnt++ >= 3 && !ieee->is_roaming && 
            priv->watchdog_last_time != 1)
        {
-               ResetType = rtl819x_ifcheck_resetornot(priv);
+               ResetType = rtl819x_check_reset(priv);
                priv->watchdog_check_reset_cnt = 3;
        }
        if(!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_NORMAL)
@@ -3742,8 +3731,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv * priv, u8* buffer,struct
        sc = le16_to_cpu(hdr->seq_ctl);
        frag = WLAN_GET_SEQ_FRAG(sc);
        seq = WLAN_GET_SEQ_SEQ(sc);
-       //cosa add 04292008 to record the sequence number
-       pcurrent_stats->Seq_Num = seq;
+
        //
        // Check whether we should take the previous packet into accounting
        //
@@ -4248,7 +4236,6 @@ rtl8192_record_rxdesc_forlateruse(
 {
        ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU;
        ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU;
-       //ptarget_stats->Seq_Num = psrc_stats->Seq_Num;
 }
 
 
@@ -4312,15 +4299,15 @@ static void rtl8192_tx_resume(struct r8192_priv *priv)
        struct ieee80211_device *ieee = priv->ieee80211;
        struct net_device *dev = priv->ieee80211->dev;
        struct sk_buff *skb;
-       int queue_index;
+       int i;
 
-       for(queue_index = BK_QUEUE; queue_index < TXCMD_QUEUE;queue_index++) {
-               while((!skb_queue_empty(&ieee->skb_waitQ[queue_index]))&&
-                               (priv->ieee80211->check_nic_enough_desc(dev,queue_index) > 0)) {
+       for (i = BK_QUEUE; i < TXCMD_QUEUE; i++) {
+               while ((!skb_queue_empty(&ieee->skb_waitQ[i])) &&
+                      (priv->ieee80211->check_nic_enough_desc(dev, i) > 0)) {
                        /* 1. dequeue the packet from the wait queue */
-                       skb = skb_dequeue(&ieee->skb_waitQ[queue_index]);
+                       skb = skb_dequeue(&ieee->skb_waitQ[i]);
                        /* 2. tx the packet directly */
-                       ieee->softmac_data_hard_start_xmit(skb,dev,0/* rate useless now*/);
+                       ieee->softmac_data_hard_start_xmit(skb, ieee, 0);
                }
        }
 }
@@ -4486,8 +4473,6 @@ static void rtl8192_rx(struct r8192_priv *priv)
                 if((stats.RxBufShift + stats.RxDrvInfoSize) > 0)
                     stats.bShift = 1;
 
-                stats.RxIs40MHzPacket = pDrvInfo->BW;
-
                 /* ???? */
                 TranslateRxSignalStuff819xpci(priv, skb, &stats, pdesc, pDrvInfo);
 
@@ -4509,11 +4494,6 @@ static void rtl8192_rx(struct r8192_priv *priv)
                     unicast_packet = true;
                 }
 
-                stats.packetlength = stats.Length-4;
-                stats.fraglength = stats.packetlength;
-                stats.fragoffset = 0;
-                stats.ntotalfrag = 1;
-
                 if(!ieee80211_rtl_rx(priv->ieee80211, skb, &stats)){
                     dev_kfree_skb_any(skb);
                 } else {
This page took 0.030226 seconds and 5 git commands to generate.