staging: brcm80211: remove include file sbhndpio.h
[firefly-linux-kernel-4.4.55.git] / drivers / staging / brcm80211 / brcmsmac / wl_mac80211.c
index 3109e3da31d154acd3645e2fee5ca849d4fb5a9f..137a382bac52b3d23ddd3c2087a9fe383d3c6dad 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/etherdevice.h>
-#include <linux/string.h>
+#include <linux/types.h>
 #include <linux/pci_ids.h>
-#include <bcmdefs.h>
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
-#include <osl.h>
-#define WLC_MAXBSSCFG          1       /* single BSS configs */
-
-#include <wlc_cfg.h>
+#include <linux/firmware.h>
 #include <net/mac80211.h>
-#include <phy_version.h>
+
+#include <proto/802.11.h>
+#include <osl.h>
+#include <bcmdefs.h>
+#include <bcmwifi.h>
 #include <bcmutils.h>
 #include <pcicfg.h>
 #include <wlioctl.h>
-#include <wlc_key.h>
-#include <sbhndpio.h>
 #include <sbhnddma.h>
-#include <wlc_channel.h>
-#include <wlc_pub.h>
-#include <wlc_scb.h>
-#include <wl_dbg.h>
-#include <wl_export.h>
-
-#include <wl_mac80211.h>
-#include <linux/firmware.h>
-#include <wl_ucode.h>
-#include <d11ucode_ext.h>
 
+#include "phy/wlc_phy_int.h"
+#include "d11.h"
+#include "wlc_types.h"
+#include "wlc_cfg.h"
+#include "phy/phy_version.h"
+#include "wlc_key.h"
+#include "wlc_channel.h"
+#include "wlc_scb.h"
+#include "wlc_pub.h"
+#include "wl_dbg.h"
+#include "wl_export.h"
+#include "wl_ucode.h"
+#include "d11ucode_ext.h"
+#include "wl_mac80211.h"
 
 static void wl_timer(unsigned long data);
-static void _wl_timer(wl_timer_t *t);
+static void _wl_timer(struct wl_timer *t);
 
 
 static int ieee_hw_init(struct ieee80211_hw *hw);
@@ -78,6 +80,12 @@ static int wl_start(struct sk_buff *skb, struct wl_info *wl);
 static int wl_start_int(struct wl_info *wl, struct ieee80211_hw *hw,
                        struct sk_buff *skb);
 static void wl_dpc(unsigned long data);
+static irqreturn_t wl_isr(int irq, void *dev_id);
+
+static int __devinit wl_pci_probe(struct pci_dev *pdev,
+                                 const struct pci_device_id *ent);
+static void wl_remove(struct pci_dev *pdev);
+static void wl_free(struct wl_info *wl);
 
 MODULE_AUTHOR("Broadcom Corporation");
 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
@@ -93,8 +101,6 @@ static struct pci_device_id wl_id_table[] = {
 };
 
 MODULE_DEVICE_TABLE(pci, wl_id_table);
-static void wl_remove(struct pci_dev *pdev);
-
 
 #ifdef BCMDBG
 static int msglevel = 0xdeadbeef;
@@ -105,6 +111,8 @@ module_param(phymsglevel, int, 0);
 
 #define HW_TO_WL(hw)    (hw->priv)
 #define WL_TO_HW(wl)     (wl->pub->ieee_hw)
+
+/* MAC80211 callback functions */
 static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
 static int wl_ops_start(struct ieee80211_hw *hw);
 static void wl_ops_stop(struct ieee80211_hw *hw);
@@ -171,10 +179,10 @@ static int wl_ops_start(struct ieee80211_hw *hw)
          WL_NONE("%s : Initial channel: %d\n", __func__, curchan->hw_value);
        */
 
-       WL_LOCK(wl);
        ieee80211_wake_queues(hw);
-       WL_UNLOCK(wl);
+       WL_LOCK(wl);
        blocked = wl_rfkill_set_hw_state(wl);
+       WL_UNLOCK(wl);
        if (!blocked)
                wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
 
@@ -183,11 +191,11 @@ static int wl_ops_start(struct ieee80211_hw *hw)
 
 static void wl_ops_stop(struct ieee80211_hw *hw)
 {
+#ifdef BRCMDBG
        struct wl_info *wl = hw->priv;
        ASSERT(wl);
-       WL_LOCK(wl);
+#endif /*BRCMDBG*/
        ieee80211_stop_queues(hw);
-       WL_UNLOCK(wl);
 }
 
 static int
@@ -354,7 +362,9 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
                        val = 1;
                else
                        val = 0;
+               WL_LOCK(wl);
                wlc_set(wl->wlc, WLC_SET_SHORTSLOT_OVERRIDE, val);
+               WL_UNLOCK(wl);
        }
 
        if (changed & BSS_CHANGED_HT) {
@@ -383,8 +393,10 @@ wl_ops_bss_info_changed(struct ieee80211_hw *hw,
                /* BSSID changed, for whatever reason (IBSS and managed mode) */
                WL_NONE("%s: new BSSID: aid %d  bss:%pM\n", __func__,
                        info->aid, info->bssid);
+               WL_LOCK(wl);
                wlc_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET,
                                  info->bssid);
+               WL_UNLOCK(wl);
        }
        if (changed & BSS_CHANGED_BEACON) {
                /* Beacon data changed, retrieve new beacon (beaconing modes) */
@@ -612,6 +624,7 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
        struct scb *scb = (struct scb *)sta->drv_priv;
 #endif
        struct wl_info *wl = hw->priv;
+       int status;
 
        ASSERT(scb->magic == SCB_MAGIC);
        switch (action) {
@@ -622,7 +635,10 @@ wl_ops_ampdu_action(struct ieee80211_hw *hw,
                WL_NONE("%s: action = IEEE80211_AMPDU_RX_STOP\n", __func__);
                break;
        case IEEE80211_AMPDU_TX_START:
-               if (!wlc_aggregatable(wl->wlc, tid)) {
+               WL_LOCK(wl);
+               status = wlc_aggregatable(wl->wlc, tid);
+               WL_UNLOCK(wl);
+               if (!status) {
                        /* WL_ERROR("START: tid %d is not agg' able, return FAILURE to stack\n", tid); */
                        return -1;
                }
@@ -1088,7 +1104,7 @@ static int ieee_hw_init(struct ieee80211_hw *hw)
  *
  * Perimeter lock is initialized in the course of this function.
  */
-int __devinit
+static int __devinit
 wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        int rc;
@@ -1218,6 +1234,7 @@ static void wl_remove(struct pci_dev *pdev)
 {
        struct wl_info *wl;
        struct ieee80211_hw *hw;
+       int status;
 
        hw = pci_get_drvdata(pdev);
        wl = HW_TO_WL(hw);
@@ -1226,7 +1243,10 @@ static void wl_remove(struct pci_dev *pdev)
                return;
        }
 
-       if (!wlc_chipmatch(pdev->vendor, pdev->device)) {
+       WL_LOCK(wl);
+       status = wlc_chipmatch(pdev->vendor, pdev->device);
+       WL_UNLOCK(wl);
+       if (!status) {
                WL_ERROR("wl: wl_remove: wlc_chipmatch failed\n");
                return;
        }
@@ -1322,9 +1342,9 @@ module_exit(wl_module_exit);
  * precondition: can both be called locked and unlocked
  *
  */
-void wl_free(struct wl_info *wl)
+static void wl_free(struct wl_info *wl)
 {
-       wl_timer_t *t, *next;
+       struct wl_timer *t, *next;
        struct osl_info *osh;
 
        ASSERT(wl);
@@ -1513,7 +1533,7 @@ void wl_down(struct wl_info *wl)
        WL_LOCK(wl);
 }
 
-irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
+static irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id)
 {
        struct wl_info *wl;
        bool ours, wantdpc;
@@ -1578,47 +1598,18 @@ static void BCMFASTPATH wl_dpc(unsigned long data)
        WL_UNLOCK(wl);
 }
 
-static void wl_link_up(struct wl_info *wl, char *ifname)
-{
-       WL_NONE("wl%d: link up (%s)\n", wl->pub->unit, ifname);
-}
-
-static void wl_link_down(struct wl_info *wl, char *ifname)
-{
-       WL_NONE("wl%d: link down (%s)\n", wl->pub->unit, ifname);
-}
-
-/*
- * precondition: perimeter lock has been acquired
- */
-void wl_event(struct wl_info *wl, char *ifname, wlc_event_t *e)
-{
-
-       switch (e->event.event_type) {
-       case WLC_E_LINK:
-       case WLC_E_NDIS_LINK:
-               if (e->event.flags & WLC_EVENT_MSG_LINK)
-                       wl_link_up(wl, ifname);
-               else
-                       wl_link_down(wl, ifname);
-               break;
-       case WLC_E_RADIO:
-               break;
-       }
-}
-
 /*
  * is called by the kernel from software irq context
  */
 static void wl_timer(unsigned long data)
 {
-       _wl_timer((wl_timer_t *) data);
+       _wl_timer((struct wl_timer *) data);
 }
 
 /*
 * precondition: perimeter lock is not acquired
  */
-static void _wl_timer(wl_timer_t *t)
+static void _wl_timer(struct wl_timer *t)
 {
        WL_LOCK(t->wl);
 
@@ -1645,18 +1636,18 @@ static void _wl_timer(wl_timer_t *t)
  *
  * precondition: perimeter lock has been acquired
  */
-wl_timer_t *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), void *arg,
-                         const char *name)
+struct wl_timer *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg),
+                              void *arg, const char *name)
 {
-       wl_timer_t *t;
+       struct wl_timer *t;
 
-       t = kmalloc(sizeof(wl_timer_t), GFP_ATOMIC);
+       t = kmalloc(sizeof(struct wl_timer), GFP_ATOMIC);
        if (!t) {
                WL_ERROR("wl%d: wl_init_timer: out of memory\n", wl->pub->unit);
                return 0;
        }
 
-       memset(t, 0, sizeof(wl_timer_t));
+       memset(t, 0, sizeof(struct wl_timer));
 
        init_timer(&t->timer);
        t->timer.data = (unsigned long) t;
@@ -1681,7 +1672,7 @@ wl_timer_t *wl_init_timer(struct wl_info *wl, void (*fn) (void *arg), void *arg,
  *
  * precondition: perimeter lock has been acquired
  */
-void wl_add_timer(struct wl_info *wl, wl_timer_t *t, uint ms, int periodic)
+void wl_add_timer(struct wl_info *wl, struct wl_timer *t, uint ms, int periodic)
 {
 #ifdef BCMDBG
        if (t->set) {
@@ -1705,7 +1696,7 @@ void wl_add_timer(struct wl_info *wl, wl_timer_t *t, uint ms, int periodic)
  *
  * precondition: perimeter lock has been acquired
  */
-bool wl_del_timer(struct wl_info *wl, wl_timer_t *t)
+bool wl_del_timer(struct wl_info *wl, struct wl_timer *t)
 {
        if (t->set) {
                t->set = false;
@@ -1721,9 +1712,9 @@ bool wl_del_timer(struct wl_info *wl, wl_timer_t *t)
 /*
  * precondition: perimeter lock has been acquired
  */
-void wl_free_timer(struct wl_info *wl, wl_timer_t *t)
+void wl_free_timer(struct wl_info *wl, struct wl_timer *t)
 {
-       wl_timer_t *tmp;
+       struct wl_timer *tmp;
 
        /* delete the timer in case it is active */
        wl_del_timer(wl, t);
@@ -1988,8 +1979,10 @@ bool wl_rfkill_set_hw_state(struct wl_info *wl)
 
        WL_NONE("%s: update hw state: blocked=%s\n", __func__,
                blocked ? "true" : "false");
+       WL_UNLOCK(wl);
        wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
        if (blocked)
                wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy);
+       WL_LOCK(wl);
        return blocked;
 }