aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/main.c
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2011-10-05 05:55:45 -0400
committerLuciano Coelho <coelho@ti.com>2011-10-07 01:32:37 -0400
commit536129c8ad35de87ff2f864f205a54ac32bfebcc (patch)
tree0d9b40906e00bf2a11a692262d1094161d770e63 /drivers/net/wireless/wl12xx/main.c
parentcdf09495588fda7e9c15c25bc20cb828e07be314 (diff)
wl12xx: move bss_type into wlvif
move bss_type into the per-interface data, rather than being global. Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/main.c')
-rw-r--r--drivers/net/wireless/wl12xx/main.c109
1 files changed, 60 insertions, 49 deletions
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index d19c3fe34860..5b13af0f8e8e 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -377,6 +377,7 @@ static char *fwlog_param;
377static bool bug_on_recovery; 377static bool bug_on_recovery;
378 378
379static void __wl1271_op_remove_interface(struct wl1271 *wl, 379static void __wl1271_op_remove_interface(struct wl1271 *wl,
380 struct ieee80211_vif *vif,
380 bool reset_tx_queues); 381 bool reset_tx_queues);
381static void wl1271_free_ap_keys(struct wl1271 *wl); 382static void wl1271_free_ap_keys(struct wl1271 *wl);
382 383
@@ -844,6 +845,8 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl,
844static void wl12xx_fw_status(struct wl1271 *wl, 845static void wl12xx_fw_status(struct wl1271 *wl,
845 struct wl12xx_fw_status *status) 846 struct wl12xx_fw_status *status)
846{ 847{
848 struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */
849 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
847 struct timespec ts; 850 struct timespec ts;
848 u32 old_tx_blk_count = wl->tx_blocks_available; 851 u32 old_tx_blk_count = wl->tx_blocks_available;
849 int avail, freed_blocks; 852 int avail, freed_blocks;
@@ -898,7 +901,7 @@ static void wl12xx_fw_status(struct wl1271 *wl,
898 clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); 901 clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags);
899 902
900 /* for AP update num of allocated TX blocks per link and ps status */ 903 /* for AP update num of allocated TX blocks per link and ps status */
901 if (wl->bss_type == BSS_TYPE_AP_BSS) 904 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
902 wl12xx_irq_update_links_status(wl, status); 905 wl12xx_irq_update_links_status(wl, status);
903 906
904 /* update the host-chipset time offset */ 907 /* update the host-chipset time offset */
@@ -1004,7 +1007,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie)
1004 * In order to avoid starvation of the TX path, 1007 * In order to avoid starvation of the TX path,
1005 * call the work function directly. 1008 * call the work function directly.
1006 */ 1009 */
1007 wl1271_tx_work_locked(wl); 1010 wl1271_tx_work_locked(wl, wl->vif);
1008 } else { 1011 } else {
1009 spin_unlock_irqrestore(&wl->wl_lock, flags); 1012 spin_unlock_irqrestore(&wl->wl_lock, flags);
1010 } 1013 }
@@ -1251,7 +1254,7 @@ static void wl1271_recovery_work(struct work_struct *work)
1251 } 1254 }
1252 1255
1253 /* reboot the chipset */ 1256 /* reboot the chipset */
1254 __wl1271_op_remove_interface(wl, false); 1257 __wl1271_op_remove_interface(wl, wl->vif, false);
1255 1258
1256 clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); 1259 clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags);
1257 1260
@@ -1389,8 +1392,6 @@ int wl1271_plt_start(struct wl1271 *wl)
1389 goto out; 1392 goto out;
1390 } 1393 }
1391 1394
1392 wl->bss_type = BSS_TYPE_STA_BSS;
1393
1394 while (retries) { 1395 while (retries) {
1395 retries--; 1396 retries--;
1396 ret = wl1271_chip_wakeup(wl); 1397 ret = wl1271_chip_wakeup(wl);
@@ -1482,6 +1483,8 @@ int wl1271_plt_stop(struct wl1271 *wl)
1482static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 1483static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1483{ 1484{
1484 struct wl1271 *wl = hw->priv; 1485 struct wl1271 *wl = hw->priv;
1486 struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb);
1487 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(control->control.vif);
1485 unsigned long flags; 1488 unsigned long flags;
1486 int q, mapping; 1489 int q, mapping;
1487 u8 hlid = 0; 1490 u8 hlid = 0;
@@ -1489,13 +1492,13 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
1489 mapping = skb_get_queue_mapping(skb); 1492 mapping = skb_get_queue_mapping(skb);
1490 q = wl1271_tx_get_queue(mapping); 1493 q = wl1271_tx_get_queue(mapping);
1491 1494
1492 if (wl->bss_type == BSS_TYPE_AP_BSS) 1495 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
1493 hlid = wl12xx_tx_get_hlid_ap(wl, skb); 1496 hlid = wl12xx_tx_get_hlid_ap(wl, skb);
1494 1497
1495 spin_lock_irqsave(&wl->wl_lock, flags); 1498 spin_lock_irqsave(&wl->wl_lock, flags);
1496 1499
1497 /* queue the packet */ 1500 /* queue the packet */
1498 if (wl->bss_type == BSS_TYPE_AP_BSS) { 1501 if (wlvif->bss_type == BSS_TYPE_AP_BSS) {
1499 if (!wl1271_is_active_sta(wl, hlid)) { 1502 if (!wl1271_is_active_sta(wl, hlid)) {
1500 wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", 1503 wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d",
1501 hlid, q); 1504 hlid, q);
@@ -1552,7 +1555,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl)
1552 1555
1553 /* The FW is low on RX memory blocks, so send the dummy packet asap */ 1556 /* The FW is low on RX memory blocks, so send the dummy packet asap */
1554 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) 1557 if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags))
1555 wl1271_tx_work_locked(wl); 1558 wl1271_tx_work_locked(wl, wl->vif);
1556 1559
1557 /* 1560 /*
1558 * If the FW TX is busy, TX work will be scheduled by the threaded 1561 * If the FW TX is busy, TX work will be scheduled by the threaded
@@ -1686,9 +1689,9 @@ out_unlock:
1686static int wl1271_configure_suspend(struct wl1271 *wl, 1689static int wl1271_configure_suspend(struct wl1271 *wl,
1687 struct wl12xx_vif *wlvif) 1690 struct wl12xx_vif *wlvif)
1688{ 1691{
1689 if (wl->bss_type == BSS_TYPE_STA_BSS) 1692 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
1690 return wl1271_configure_suspend_sta(wl, wlvif); 1693 return wl1271_configure_suspend_sta(wl, wlvif);
1691 if (wl->bss_type == BSS_TYPE_AP_BSS) 1694 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
1692 return wl1271_configure_suspend_ap(wl); 1695 return wl1271_configure_suspend_ap(wl);
1693 return 0; 1696 return 0;
1694} 1697}
@@ -1697,8 +1700,8 @@ static void wl1271_configure_resume(struct wl1271 *wl,
1697 struct wl12xx_vif *wlvif) 1700 struct wl12xx_vif *wlvif)
1698{ 1701{
1699 int ret; 1702 int ret;
1700 bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; 1703 bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS;
1701 bool is_ap = wl->bss_type == BSS_TYPE_AP_BSS; 1704 bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS;
1702 1705
1703 if (!is_sta && !is_ap) 1706 if (!is_sta && !is_ap)
1704 return; 1707 return;
@@ -1820,9 +1823,9 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
1820 wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); 1823 wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
1821} 1824}
1822 1825
1823static u8 wl12xx_get_role_type(struct wl1271 *wl) 1826static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1824{ 1827{
1825 switch (wl->bss_type) { 1828 switch (wlvif->bss_type) {
1826 case BSS_TYPE_AP_BSS: 1829 case BSS_TYPE_AP_BSS:
1827 if (wl->p2p) 1830 if (wl->p2p)
1828 return WL1271_ROLE_P2P_GO; 1831 return WL1271_ROLE_P2P_GO;
@@ -1839,13 +1842,14 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl)
1839 return WL1271_ROLE_IBSS; 1842 return WL1271_ROLE_IBSS;
1840 1843
1841 default: 1844 default:
1842 wl1271_error("invalid bss_type: %d", wl->bss_type); 1845 wl1271_error("invalid bss_type: %d", wlvif->bss_type);
1843 } 1846 }
1844 return WL12XX_INVALID_ROLE_TYPE; 1847 return WL12XX_INVALID_ROLE_TYPE;
1845} 1848}
1846 1849
1847static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) 1850static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif)
1848{ 1851{
1852 wlvif->bss_type = MAX_BSS_TYPE;
1849 wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; 1853 wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
1850 wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; 1854 wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC;
1851 wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; 1855 wlvif->rate_set = CONF_TX_RATE_MASK_BASIC;
@@ -1856,6 +1860,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1856{ 1860{
1857 struct wl1271 *wl = hw->priv; 1861 struct wl1271 *wl = hw->priv;
1858 struct wiphy *wiphy = hw->wiphy; 1862 struct wiphy *wiphy = hw->wiphy;
1863 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
1859 int retries = WL1271_BOOT_RETRIES; 1864 int retries = WL1271_BOOT_RETRIES;
1860 int ret = 0; 1865 int ret = 0;
1861 u8 role_type; 1866 u8 role_type;
@@ -1871,7 +1876,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1871 ret = -EBUSY; 1876 ret = -EBUSY;
1872 goto out; 1877 goto out;
1873 } 1878 }
1874 wl12xx_init_vif_data(wl12xx_vif_to_data(vif)); 1879 wl12xx_init_vif_data(wlvif);
1875 1880
1876 /* 1881 /*
1877 * in some very corner case HW recovery scenarios its possible to 1882 * in some very corner case HW recovery scenarios its possible to
@@ -1888,25 +1893,25 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1888 wl->p2p = 1; 1893 wl->p2p = 1;
1889 /* fall-through */ 1894 /* fall-through */
1890 case NL80211_IFTYPE_STATION: 1895 case NL80211_IFTYPE_STATION:
1891 wl->bss_type = BSS_TYPE_STA_BSS; 1896 wlvif->bss_type = BSS_TYPE_STA_BSS;
1892 wl->set_bss_type = BSS_TYPE_STA_BSS; 1897 wl->set_bss_type = BSS_TYPE_STA_BSS;
1893 break; 1898 break;
1894 case NL80211_IFTYPE_ADHOC: 1899 case NL80211_IFTYPE_ADHOC:
1895 wl->bss_type = BSS_TYPE_IBSS; 1900 wlvif->bss_type = BSS_TYPE_IBSS;
1896 wl->set_bss_type = BSS_TYPE_STA_BSS; 1901 wl->set_bss_type = BSS_TYPE_STA_BSS;
1897 break; 1902 break;
1898 case NL80211_IFTYPE_P2P_GO: 1903 case NL80211_IFTYPE_P2P_GO:
1899 wl->p2p = 1; 1904 wl->p2p = 1;
1900 /* fall-through */ 1905 /* fall-through */
1901 case NL80211_IFTYPE_AP: 1906 case NL80211_IFTYPE_AP:
1902 wl->bss_type = BSS_TYPE_AP_BSS; 1907 wlvif->bss_type = BSS_TYPE_AP_BSS;
1903 break; 1908 break;
1904 default: 1909 default:
1905 ret = -EOPNOTSUPP; 1910 ret = -EOPNOTSUPP;
1906 goto out; 1911 goto out;
1907 } 1912 }
1908 1913
1909 role_type = wl12xx_get_role_type(wl); 1914 role_type = wl12xx_get_role_type(wl, wlvif);
1910 if (role_type == WL12XX_INVALID_ROLE_TYPE) { 1915 if (role_type == WL12XX_INVALID_ROLE_TYPE) {
1911 ret = -EINVAL; 1916 ret = -EINVAL;
1912 goto out; 1917 goto out;
@@ -1938,8 +1943,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1938 if (ret < 0) 1943 if (ret < 0)
1939 goto irq_disable; 1944 goto irq_disable;
1940 1945
1941 if (wl->bss_type == BSS_TYPE_STA_BSS || 1946 if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
1942 wl->bss_type == BSS_TYPE_IBSS) { 1947 wlvif->bss_type == BSS_TYPE_IBSS) {
1943 /* 1948 /*
1944 * The device role is a special role used for 1949 * The device role is a special role used for
1945 * rx and tx frames prior to association (as 1950 * rx and tx frames prior to association (as
@@ -2020,8 +2025,10 @@ out:
2020} 2025}
2021 2026
2022static void __wl1271_op_remove_interface(struct wl1271 *wl, 2027static void __wl1271_op_remove_interface(struct wl1271 *wl,
2028 struct ieee80211_vif *vif,
2023 bool reset_tx_queues) 2029 bool reset_tx_queues)
2024{ 2030{
2031 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2025 int ret, i; 2032 int ret, i;
2026 2033
2027 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); 2034 wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
@@ -2037,7 +2044,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
2037 mutex_unlock(&wl_list_mutex); 2044 mutex_unlock(&wl_list_mutex);
2038 2045
2039 /* enable dyn ps just in case (if left on due to fw crash etc) */ 2046 /* enable dyn ps just in case (if left on due to fw crash etc) */
2040 if (wl->bss_type == BSS_TYPE_STA_BSS) 2047 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
2041 ieee80211_enable_dyn_ps(wl->vif); 2048 ieee80211_enable_dyn_ps(wl->vif);
2042 2049
2043 if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { 2050 if (wl->scan.state != WL1271_SCAN_STATE_IDLE) {
@@ -2054,7 +2061,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
2054 if (ret < 0) 2061 if (ret < 0)
2055 goto deinit; 2062 goto deinit;
2056 2063
2057 if (wl->bss_type == BSS_TYPE_STA_BSS) { 2064 if (wlvif->bss_type == BSS_TYPE_STA_BSS) {
2058 ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id); 2065 ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id);
2059 if (ret < 0) 2066 if (ret < 0)
2060 goto deinit; 2067 goto deinit;
@@ -2100,7 +2107,6 @@ deinit:
2100 2107
2101 memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); 2108 memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1);
2102 wl->ssid_len = 0; 2109 wl->ssid_len = 0;
2103 wl->bss_type = MAX_BSS_TYPE;
2104 wl->set_bss_type = MAX_BSS_TYPE; 2110 wl->set_bss_type = MAX_BSS_TYPE;
2105 wl->p2p = 0; 2111 wl->p2p = 0;
2106 wl->band = IEEE80211_BAND_2GHZ; 2112 wl->band = IEEE80211_BAND_2GHZ;
@@ -2169,7 +2175,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
2169 */ 2175 */
2170 if (wl->vif) { 2176 if (wl->vif) {
2171 WARN_ON(wl->vif != vif); 2177 WARN_ON(wl->vif != vif);
2172 __wl1271_op_remove_interface(wl, true); 2178 __wl1271_op_remove_interface(wl, vif, true);
2173 } 2179 }
2174 2180
2175 mutex_unlock(&wl->mutex); 2181 mutex_unlock(&wl->mutex);
@@ -2180,7 +2186,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2180 bool set_assoc) 2186 bool set_assoc)
2181{ 2187{
2182 int ret; 2188 int ret;
2183 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); 2189 bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS);
2184 2190
2185 /* 2191 /*
2186 * One of the side effects of the JOIN command is that is clears 2192 * One of the side effects of the JOIN command is that is clears
@@ -2364,7 +2370,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2364 goto out; 2370 goto out;
2365 } 2371 }
2366 2372
2367 is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 2373 is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
2368 2374
2369 ret = wl1271_ps_elp_wakeup(wl); 2375 ret = wl1271_ps_elp_wakeup(wl);
2370 if (ret < 0) 2376 if (ret < 0)
@@ -2375,7 +2381,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2375 ((wl->band != conf->channel->band) || 2381 ((wl->band != conf->channel->band) ||
2376 (wl->channel != channel))) { 2382 (wl->channel != channel))) {
2377 /* send all pending packets */ 2383 /* send all pending packets */
2378 wl1271_tx_work_locked(wl); 2384 wl1271_tx_work_locked(wl, vif);
2379 wl->band = conf->channel->band; 2385 wl->band = conf->channel->band;
2380 wl->channel = channel; 2386 wl->channel = channel;
2381 2387
@@ -2536,6 +2542,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
2536{ 2542{
2537 struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; 2543 struct wl1271_filter_params *fp = (void *)(unsigned long)multicast;
2538 struct wl1271 *wl = hw->priv; 2544 struct wl1271 *wl = hw->priv;
2545 struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */
2546 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2547
2539 int ret; 2548 int ret;
2540 2549
2541 wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter changed %x" 2550 wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter changed %x"
@@ -2553,7 +2562,7 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
2553 if (ret < 0) 2562 if (ret < 0)
2554 goto out; 2563 goto out;
2555 2564
2556 if (wl->bss_type != BSS_TYPE_AP_BSS) { 2565 if (wlvif->bss_type != BSS_TYPE_AP_BSS) {
2557 if (*total & FIF_ALLMULTI) 2566 if (*total & FIF_ALLMULTI)
2558 ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0); 2567 ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0);
2559 else if (fp) 2568 else if (fp)
@@ -2673,12 +2682,13 @@ out:
2673 return ret; 2682 return ret;
2674} 2683}
2675 2684
2676static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, 2685static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2686 u16 action, u8 id, u8 key_type,
2677 u8 key_size, const u8 *key, u32 tx_seq_32, 2687 u8 key_size, const u8 *key, u32 tx_seq_32,
2678 u16 tx_seq_16, struct ieee80211_sta *sta) 2688 u16 tx_seq_16, struct ieee80211_sta *sta)
2679{ 2689{
2680 int ret; 2690 int ret;
2681 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 2691 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
2682 2692
2683 if (is_ap) { 2693 if (is_ap) {
2684 struct wl1271_station *wl_sta; 2694 struct wl1271_station *wl_sta;
@@ -2774,6 +2784,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2774 struct ieee80211_key_conf *key_conf) 2784 struct ieee80211_key_conf *key_conf)
2775{ 2785{
2776 struct wl1271 *wl = hw->priv; 2786 struct wl1271 *wl = hw->priv;
2787 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2777 int ret; 2788 int ret;
2778 u32 tx_seq_32 = 0; 2789 u32 tx_seq_32 = 0;
2779 u16 tx_seq_16 = 0; 2790 u16 tx_seq_16 = 0;
@@ -2833,7 +2844,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2833 2844
2834 switch (cmd) { 2845 switch (cmd) {
2835 case SET_KEY: 2846 case SET_KEY:
2836 ret = wl1271_set_key(wl, KEY_ADD_OR_REPLACE, 2847 ret = wl1271_set_key(wl, wlvif, KEY_ADD_OR_REPLACE,
2837 key_conf->keyidx, key_type, 2848 key_conf->keyidx, key_type,
2838 key_conf->keylen, key_conf->key, 2849 key_conf->keylen, key_conf->key,
2839 tx_seq_32, tx_seq_16, sta); 2850 tx_seq_32, tx_seq_16, sta);
@@ -2844,7 +2855,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2844 break; 2855 break;
2845 2856
2846 case DISABLE_KEY: 2857 case DISABLE_KEY:
2847 ret = wl1271_set_key(wl, KEY_REMOVE, 2858 ret = wl1271_set_key(wl, wlvif, KEY_REMOVE,
2848 key_conf->keyidx, key_type, 2859 key_conf->keyidx, key_type,
2849 key_conf->keylen, key_conf->key, 2860 key_conf->keylen, key_conf->key,
2850 0, 0, sta); 2861 0, 0, sta);
@@ -2966,6 +2977,7 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw,
2966 struct ieee80211_sched_scan_ies *ies) 2977 struct ieee80211_sched_scan_ies *ies)
2967{ 2978{
2968 struct wl1271 *wl = hw->priv; 2979 struct wl1271 *wl = hw->priv;
2980 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2969 int ret; 2981 int ret;
2970 2982
2971 wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_start"); 2983 wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_start");
@@ -2976,11 +2988,11 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw,
2976 if (ret < 0) 2988 if (ret < 0)
2977 goto out; 2989 goto out;
2978 2990
2979 ret = wl1271_scan_sched_scan_config(wl, req, ies); 2991 ret = wl1271_scan_sched_scan_config(wl, wlvif, req, ies);
2980 if (ret < 0) 2992 if (ret < 0)
2981 goto out_sleep; 2993 goto out_sleep;
2982 2994
2983 ret = wl1271_scan_sched_scan_start(wl); 2995 ret = wl1271_scan_sched_scan_start(wl, wlvif);
2984 if (ret < 0) 2996 if (ret < 0)
2985 goto out_sleep; 2997 goto out_sleep;
2986 2998
@@ -3225,7 +3237,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl,
3225 u32 changed) 3237 u32 changed)
3226{ 3238{
3227 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); 3239 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3228 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 3240 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
3229 int ret = 0; 3241 int ret = 0;
3230 3242
3231 if ((changed & BSS_CHANGED_BEACON_INT)) { 3243 if ((changed & BSS_CHANGED_BEACON_INT)) {
@@ -3387,7 +3399,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
3387{ 3399{
3388 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); 3400 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3389 bool do_join = false, set_assoc = false; 3401 bool do_join = false, set_assoc = false;
3390 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); 3402 bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS);
3391 bool ibss_joined = false; 3403 bool ibss_joined = false;
3392 u32 sta_rate_set = 0; 3404 u32 sta_rate_set = 0;
3393 int ret; 3405 int ret;
@@ -3623,7 +3635,7 @@ sta_not_found:
3623 3635
3624 if (changed & BSS_CHANGED_ARP_FILTER) { 3636 if (changed & BSS_CHANGED_ARP_FILTER) {
3625 __be32 addr = bss_conf->arp_addr_list[0]; 3637 __be32 addr = bss_conf->arp_addr_list[0];
3626 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); 3638 WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS);
3627 3639
3628 if (bss_conf->arp_addr_cnt == 1 && 3640 if (bss_conf->arp_addr_cnt == 1 &&
3629 bss_conf->arp_filter_enabled) { 3641 bss_conf->arp_filter_enabled) {
@@ -3742,7 +3754,8 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
3742 u32 changed) 3754 u32 changed)
3743{ 3755{
3744 struct wl1271 *wl = hw->priv; 3756 struct wl1271 *wl = hw->priv;
3745 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 3757 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3758 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
3746 int ret; 3759 int ret;
3747 3760
3748 wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed 0x%x", 3761 wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed 0x%x",
@@ -3933,6 +3946,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw,
3933 struct ieee80211_sta *sta) 3946 struct ieee80211_sta *sta)
3934{ 3947{
3935 struct wl1271 *wl = hw->priv; 3948 struct wl1271 *wl = hw->priv;
3949 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3936 int ret = 0; 3950 int ret = 0;
3937 u8 hlid; 3951 u8 hlid;
3938 3952
@@ -3941,7 +3955,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw,
3941 if (unlikely(wl->state == WL1271_STATE_OFF)) 3955 if (unlikely(wl->state == WL1271_STATE_OFF))
3942 goto out; 3956 goto out;
3943 3957
3944 if (wl->bss_type != BSS_TYPE_AP_BSS) 3958 if (wlvif->bss_type != BSS_TYPE_AP_BSS)
3945 goto out; 3959 goto out;
3946 3960
3947 wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); 3961 wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid);
@@ -3983,6 +3997,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw,
3983 struct ieee80211_sta *sta) 3997 struct ieee80211_sta *sta)
3984{ 3998{
3985 struct wl1271 *wl = hw->priv; 3999 struct wl1271 *wl = hw->priv;
4000 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3986 struct wl1271_station *wl_sta; 4001 struct wl1271_station *wl_sta;
3987 int ret = 0, id; 4002 int ret = 0, id;
3988 4003
@@ -3991,7 +4006,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw,
3991 if (unlikely(wl->state == WL1271_STATE_OFF)) 4006 if (unlikely(wl->state == WL1271_STATE_OFF))
3992 goto out; 4007 goto out;
3993 4008
3994 if (wl->bss_type != BSS_TYPE_AP_BSS) 4009 if (wlvif->bss_type != BSS_TYPE_AP_BSS)
3995 goto out; 4010 goto out;
3996 4011
3997 wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); 4012 wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid);
@@ -4026,6 +4041,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw,
4026 u8 buf_size) 4041 u8 buf_size)
4027{ 4042{
4028 struct wl1271 *wl = hw->priv; 4043 struct wl1271 *wl = hw->priv;
4044 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4029 int ret; 4045 int ret;
4030 u8 hlid, *ba_bitmap; 4046 u8 hlid, *ba_bitmap;
4031 4047
@@ -4043,10 +4059,10 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw,
4043 goto out; 4059 goto out;
4044 } 4060 }
4045 4061
4046 if (wl->bss_type == BSS_TYPE_STA_BSS) { 4062 if (wlvif->bss_type == BSS_TYPE_STA_BSS) {
4047 hlid = wl->sta_hlid; 4063 hlid = wl->sta_hlid;
4048 ba_bitmap = &wl->ba_rx_bitmap; 4064 ba_bitmap = &wl->ba_rx_bitmap;
4049 } else if (wl->bss_type == BSS_TYPE_AP_BSS) { 4065 } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) {
4050 struct wl1271_station *wl_sta; 4066 struct wl1271_station *wl_sta;
4051 4067
4052 wl_sta = (struct wl1271_station *)sta->drv_priv; 4068 wl_sta = (struct wl1271_station *)sta->drv_priv;
@@ -4197,10 +4213,6 @@ static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw)
4197 4213
4198 /* packets are considered pending if in the TX queue or the FW */ 4214 /* packets are considered pending if in the TX queue or the FW */
4199 ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0); 4215 ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0);
4200
4201 /* the above is appropriate for STA mode for PS purposes */
4202 WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS);
4203
4204out: 4216out:
4205 mutex_unlock(&wl->mutex); 4217 mutex_unlock(&wl->mutex);
4206 4218
@@ -4846,7 +4858,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
4846 wl->flags = 0; 4858 wl->flags = 0;
4847 wl->sg_enabled = true; 4859 wl->sg_enabled = true;
4848 wl->hw_pg_ver = -1; 4860 wl->hw_pg_ver = -1;
4849 wl->bss_type = MAX_BSS_TYPE;
4850 wl->set_bss_type = MAX_BSS_TYPE; 4861 wl->set_bss_type = MAX_BSS_TYPE;
4851 wl->last_tx_hlid = 0; 4862 wl->last_tx_hlid = 0;
4852 wl->ap_ps_map = 0; 4863 wl->ap_ps_map = 0;