]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/ath/wcn36xx/main.c
Merge remote-tracking branch 'bjorn/for-srini/wcn36xx-fixes-4.4' into release/qcomlt-4.4
[karo-tx-linux.git] / drivers / net / wireless / ath / wcn36xx / main.c
index 4bdd0da0793cb4e9bb203248a3f552caf70378ed..5ca4568e69e2e63f8a4c792d32e4a21e87e6032b 100644 (file)
@@ -289,6 +289,8 @@ static int wcn36xx_start(struct ieee80211_hw *hw)
                        wcn36xx_feat_caps_info(wcn);
        }
 
+       wcn36xx_smd_update_cfg(wcn, WCN36XX_HAL_CFG_ENABLE_MC_ADDR_LIST, 1);
+
        /* DMA channel initialization */
        ret = wcn36xx_dxe_init(wcn);
        if (ret) {
@@ -347,9 +349,7 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
                wcn36xx_dbg(WCN36XX_DBG_MAC, "wcn36xx_config channel switch=%d\n",
                            ch);
                list_for_each_entry(tmp, &wcn->vif_list, list) {
-                       vif = container_of((void *)tmp,
-                                          struct ieee80211_vif,
-                                          drv_priv);
+                       vif = wcn36xx_priv_to_vif(tmp);
                        wcn36xx_smd_switch_channel(wcn, vif, ch);
                }
        }
@@ -357,15 +357,60 @@ static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
        return 0;
 }
 
-#define WCN36XX_SUPPORTED_FILTERS (0)
+#define WCN36XX_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
+                                  FIF_ALLMULTI)
 
 static void wcn36xx_configure_filter(struct ieee80211_hw *hw,
                                     unsigned int changed,
                                     unsigned int *total, u64 multicast)
 {
+       struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
+       struct wcn36xx *wcn = hw->priv;
+       struct wcn36xx_vif *tmp;
+       struct ieee80211_vif *vif = NULL;
+
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac configure filter\n");
 
        *total &= WCN36XX_SUPPORTED_FILTERS;
+
+       fp = (void *)(unsigned long)multicast;
+       list_for_each_entry(tmp, &wcn->vif_list, list) {
+               vif = wcn36xx_priv_to_vif(tmp);
+
+               /* FW handles MC filtering only when connected as STA */
+               if (*total & (FIF_ALLMULTI | FIF_PROMISC_IN_BSS))
+                       wcn36xx_smd_set_mc_list(wcn, vif, NULL);
+               else if (NL80211_IFTYPE_STATION == vif->type && tmp->sta_assoc)
+                       wcn36xx_smd_set_mc_list(wcn, vif, fp);
+       }
+       kfree(fp);
+}
+
+static u64 wcn36xx_prepare_multicast(struct ieee80211_hw *hw,
+                                    struct netdev_hw_addr_list *mc_list)
+{
+       struct wcn36xx_hal_rcv_flt_mc_addr_list_type *fp;
+       struct netdev_hw_addr *ha;
+
+       wcn36xx_dbg(WCN36XX_DBG_MAC, "mac prepare multicast list\n");
+       fp = kzalloc(sizeof(*fp), GFP_ATOMIC);
+       if (!fp) {
+               wcn36xx_err("Out of memory setting filters.\n");
+               return 0;
+       }
+
+       fp->mc_addr_count = 0;
+       /* update multicast filtering parameters */
+       if (netdev_hw_addr_list_count(mc_list) <=
+           WCN36XX_HAL_MAX_NUM_MULTICAST_ADDRESS) {
+               netdev_hw_addr_list_for_each(ha, mc_list) {
+                       memcpy(fp->mc_addr[fp->mc_addr_count],
+                                       ha->addr, ETH_ALEN);
+                       fp->mc_addr_count++;
+               }
+       }
+
+       return (u64)(unsigned long)fp;
 }
 
 static void wcn36xx_tx(struct ieee80211_hw *hw,
@@ -376,7 +421,7 @@ static void wcn36xx_tx(struct ieee80211_hw *hw,
        struct wcn36xx_sta *sta_priv = NULL;
 
        if (control->sta)
-               sta_priv = (struct wcn36xx_sta *)control->sta->drv_priv;
+               sta_priv = wcn36xx_sta_to_priv(control->sta);
 
        if (wcn36xx_start_tx(wcn, sta_priv, skb))
                ieee80211_free_txskb(wcn->hw, skb);
@@ -388,8 +433,8 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                           struct ieee80211_key_conf *key_conf)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
-       struct wcn36xx_sta *sta_priv = vif_priv->sta;
+       struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
+       struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
        int ret = 0;
        u8 key[WLAN_MAX_KEY_LEN];
 
@@ -474,6 +519,7 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                break;
        case DISABLE_KEY:
                if (!(IEEE80211_KEY_FLAG_PAIRWISE & key_conf->flags)) {
+                       vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
                        wcn36xx_smd_remove_bsskey(wcn,
                                vif_priv->encrypt_type,
                                key_conf->keyidx);
@@ -521,7 +567,7 @@ static void wcn36xx_update_allowed_rates(struct ieee80211_sta *sta,
 {
        int i, size;
        u16 *rates_table;
-       struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+       struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
        u32 rates = sta->supp_rates[band];
 
        memset(&sta_priv->supported_rates, 0,
@@ -591,7 +637,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
        struct sk_buff *skb = NULL;
        u16 tim_off, tim_len;
        enum wcn36xx_hal_link_state link_state;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+       struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss info changed vif %p changed 0x%08x\n",
                    vif, changed);
@@ -621,7 +667,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
 
                if (!is_zero_ether_addr(bss_conf->bssid)) {
                        vif_priv->is_joining = true;
-                       vif_priv->bss_index = 0xff;
+                       vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
                        wcn36xx_smd_join(wcn, bss_conf->bssid,
                                         vif->addr, WCN36XX_HW_CHANNEL(wcn));
                        wcn36xx_smd_config_bss(wcn, vif, NULL,
@@ -629,6 +675,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
                } else {
                        vif_priv->is_joining = false;
                        wcn36xx_smd_delete_bss(wcn, vif);
+                       vif_priv->encrypt_type = WCN36XX_HAL_ED_NONE;
                }
        }
 
@@ -656,6 +703,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
                                     vif->addr,
                                     bss_conf->aid);
 
+                       vif_priv->sta_assoc = true;
                        rcu_read_lock();
                        sta = ieee80211_find_sta(vif, bss_conf->bssid);
                        if (!sta) {
@@ -664,7 +712,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
                                rcu_read_unlock();
                                goto out;
                        }
-                       sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+                       sta_priv = wcn36xx_sta_to_priv(sta);
 
                        wcn36xx_update_allowed_rates(sta, WCN36XX_BAND(wcn));
 
@@ -687,6 +735,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
                                    bss_conf->bssid,
                                    vif->addr,
                                    bss_conf->aid);
+                       vif_priv->sta_assoc = false;
                        wcn36xx_smd_set_link_st(wcn,
                                                bss_conf->bssid,
                                                vif->addr,
@@ -714,7 +763,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
 
                if (bss_conf->enable_beacon) {
                        vif_priv->dtim_period = bss_conf->dtim_period;
-                       vif_priv->bss_index = 0xff;
+                       vif_priv->bss_index = WCN36XX_HAL_BSS_INVALID_IDX;
                        wcn36xx_smd_config_bss(wcn, vif, NULL,
                                               vif->addr, false);
                        skb = ieee80211_beacon_get_tim(hw, vif, &tim_off,
@@ -758,7 +807,7 @@ static void wcn36xx_remove_interface(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+       struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac remove interface vif %p\n", vif);
 
        list_del(&vif_priv->list);
@@ -769,7 +818,7 @@ static int wcn36xx_add_interface(struct ieee80211_hw *hw,
                                 struct ieee80211_vif *vif)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
+       struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
 
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac add interface vif %p type %d\n",
                    vif, vif->type);
@@ -793,13 +842,12 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
                           struct ieee80211_sta *sta)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
-       struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+       struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
+       struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM\n",
                    vif, sta->addr);
 
        spin_lock_init(&sta_priv->ampdu_lock);
-       vif_priv->sta = sta_priv;
        sta_priv->vif = vif_priv;
        /*
         * For STA mode HW will be configured on BSS_CHANGED_ASSOC because
@@ -818,14 +866,12 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
                              struct ieee80211_sta *sta)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_vif *vif_priv = (struct wcn36xx_vif *)vif->drv_priv;
-       struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+       struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
 
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d\n",
                    vif, sta->addr, sta_priv->sta_index);
 
        wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
-       vif_priv->sta = NULL;
        sta_priv->vif = NULL;
        return 0;
 }
@@ -863,13 +909,11 @@ static int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
                    u8 buf_size, bool amsdu)
 {
        struct wcn36xx *wcn = hw->priv;
-       struct wcn36xx_sta *sta_priv = NULL;
+       struct wcn36xx_sta *sta_priv = wcn36xx_sta_to_priv(sta);
 
        wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d\n",
                    action, tid);
 
-       sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
-
        switch (action) {
        case IEEE80211_AMPDU_RX_START:
                sta_priv->tid = tid;
@@ -922,6 +966,7 @@ static const struct ieee80211_ops wcn36xx_ops = {
        .resume                 = wcn36xx_resume,
 #endif
        .config                 = wcn36xx_config,
+       .prepare_multicast      = wcn36xx_prepare_multicast,
        .configure_filter       = wcn36xx_configure_filter,
        .tx                     = wcn36xx_tx,
        .set_key                = wcn36xx_set_key,
@@ -969,6 +1014,9 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn)
 
        wcn->hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD;
 
+       /* TODO: Figure out why this is necessary */
+       wcn->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
+
 #ifdef CONFIG_PM
        wcn->hw->wiphy->wowlan = &wowlan_support;
 #endif