]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ath10k: fix the logic of limiting tdls peer counts
authorRyan Hsu <ryanhsu@qti.qualcomm.com>
Wed, 31 May 2017 11:21:28 +0000 (14:21 +0300)
committerKalle Valo <kvalo@qca.qualcomm.com>
Thu, 1 Jun 2017 12:59:33 +0000 (15:59 +0300)
The original idea is to limit the maximum TDLS peer link, but the logic
is always false, and never be able to restrict the number of TDLS peer
creation.

Fix the logic here and also move the checking earlier, so that it could
avoid to handle the failure case, e.g disable the tdls peer, delete the
peer and also vdev count cleanup.

Signed-off-by: Ryan Hsu <ryanhsu@qti.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/ath10k/mac.c

index 4674ff33d3203ac1eb00c8b268bc3b2ffc7d32bc..48418f91396c14aeab7bb52d3fe678fbc19cf252 100644 (file)
@@ -6073,6 +6073,20 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
                           ar->num_stations + 1, ar->max_num_stations,
                           ar->num_peers + 1, ar->max_num_peers);
 
+               num_tdls_stations = ath10k_mac_tdls_vif_stations_count(hw, vif);
+               num_tdls_vifs = ath10k_mac_tdls_vifs_count(hw);
+
+               if (sta->tdls) {
+                       if (num_tdls_stations >= ar->max_num_tdls_vdevs) {
+                               ath10k_warn(ar, "vdev %i exceeded maximum number of tdls vdevs %i\n",
+                                           arvif->vdev_id,
+                                           ar->max_num_tdls_vdevs);
+                               ret = -ELNRNG;
+                               goto exit;
+                       }
+                       peer_type = WMI_PEER_TYPE_TDLS;
+               }
+
                ret = ath10k_mac_inc_num_stations(arvif, sta);
                if (ret) {
                        ath10k_warn(ar, "refusing to associate station: too many connected already (%d)\n",
@@ -6080,9 +6094,6 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
                        goto exit;
                }
 
-               if (sta->tdls)
-                       peer_type = WMI_PEER_TYPE_TDLS;
-
                ret = ath10k_peer_create(ar, vif, sta, arvif->vdev_id,
                                         sta->addr, peer_type);
                if (ret) {
@@ -6113,35 +6124,17 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
                if (!sta->tdls)
                        goto exit;
 
-               num_tdls_stations = ath10k_mac_tdls_vif_stations_count(hw, vif);
-               num_tdls_vifs = ath10k_mac_tdls_vifs_count(hw);
-
-               if (num_tdls_vifs >= ar->max_num_tdls_vdevs &&
-                   num_tdls_stations == 0) {
-                       ath10k_warn(ar, "vdev %i exceeded maximum number of tdls vdevs %i\n",
-                                   arvif->vdev_id, ar->max_num_tdls_vdevs);
-                       ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
+               ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
+                                                     WMI_TDLS_ENABLE_ACTIVE);
+               if (ret) {
+                       ath10k_warn(ar, "failed to update fw tdls state on vdev %i: %i\n",
+                                   arvif->vdev_id, ret);
+                       ath10k_peer_delete(ar, arvif->vdev_id,
+                                          sta->addr);
                        ath10k_mac_dec_num_stations(arvif, sta);
-                       ret = -ENOBUFS;
                        goto exit;
                }
 
-               if (num_tdls_stations == 0) {
-                       /* This is the first tdls peer in current vif */
-                       enum wmi_tdls_state state = WMI_TDLS_ENABLE_ACTIVE;
-
-                       ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
-                                                             state);
-                       if (ret) {
-                               ath10k_warn(ar, "failed to update fw tdls state on vdev %i: %i\n",
-                                           arvif->vdev_id, ret);
-                               ath10k_peer_delete(ar, arvif->vdev_id,
-                                                  sta->addr);
-                               ath10k_mac_dec_num_stations(arvif, sta);
-                               goto exit;
-                       }
-               }
-
                ret = ath10k_mac_tdls_peer_update(ar, arvif->vdev_id, sta,
                                                  WMI_TDLS_PEER_STATE_PEERING);
                if (ret) {