All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath11k: Allow station connections up to max supported only
@ 2019-05-28  9:20 Venkateswara Naralasetty
  2019-05-29 15:18 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Venkateswara Naralasetty @ 2019-05-28  9:20 UTC (permalink / raw)
  To: ath11k; +Cc: Venkateswara Naralasetty

This patch add support to allow station connection request up to max
number of stations supported by target.

Signed-off-by: Venkateswara Naralasetty <vnaralas@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/core.h |  1 +
 drivers/net/wireless/ath/ath11k/mac.c  | 43 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h
index 148c9a4..b10d81f 100644
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -448,6 +448,7 @@ struct ath11k {
 	u32 txpower_scale;
 	u32 power_scale;
 	u32 chan_tx_pwr;
+	u32 num_stations;
 	u32 max_num_stations;
 	bool monitor_present;
 	struct mutex conf_mutex;
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index cb0de8e..7de1832 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -744,6 +744,7 @@ void ath11k_mac_peer_cleanup_all(struct ath11k *ar)
 	spin_unlock_bh(&ab->data_lock);
 
 	ar->num_peers = 0;
+	ar->num_stations = 0;
 }
 
 static void ath11k_peer_cleanup(struct ath11k *ar, u32 vdev_id)
@@ -2530,6 +2531,37 @@ static void ath11k_sta_rc_update_wk(struct work_struct *wk)
 	mutex_unlock(&ar->conf_mutex);
 }
 
+static int ath11k_mac_inc_num_stations(struct ath11k_vif *arvif,
+				       struct ieee80211_sta *sta)
+{
+	struct ath11k *ar = arvif->ar;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls)
+		return 0;
+
+	if (ar->num_stations >= ar->max_num_stations)
+		return -ENOBUFS;
+
+	ar->num_stations++;
+
+	return 0;
+}
+
+static void ath11k_mac_dec_num_stations(struct ath11k_vif *arvif,
+					struct ieee80211_sta *sta)
+{
+	struct ath11k *ar = arvif->ar;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	if (arvif->vdev_type == WMI_VDEV_TYPE_STA && !sta->tdls)
+		return;
+
+	ar->num_stations--;
+}
+
 static int ath11k_sta_state(struct ieee80211_hw *hw,
 			    struct ieee80211_vif *vif,
 			    struct ieee80211_sta *sta,
@@ -2555,6 +2587,13 @@ static int ath11k_sta_state(struct ieee80211_hw *hw,
 		arsta->arvif = arvif;
 		INIT_WORK(&arsta->update_wk, ath11k_sta_rc_update_wk);
 
+		ret = ath11k_mac_inc_num_stations(arvif, sta);
+		if (ret) {
+			ath11k_warn(ar->ab, "refusing to associate station: too many connected already (%d)\n",
+				    ar->max_num_stations);
+			goto exit;
+		}
+
 		if (ath11k_debug_is_extd_rx_stats_enabled(ar)) {
 			arsta->rx_stats = kzalloc(sizeof(*arsta->rx_stats),
 						  GFP_KERNEL);
@@ -2571,6 +2610,7 @@ static int ath11k_sta_state(struct ieee80211_hw *hw,
 		if (ret) {
 			ath11k_warn(ar->ab, "Failed to add peer: %pM for VDEV: %d\n",
 				    sta->addr, arvif->vdev_id);
+			ath11k_mac_dec_num_stations(arvif, sta);
 			goto exit;
 		}
 
@@ -2600,6 +2640,7 @@ static int ath11k_sta_state(struct ieee80211_hw *hw,
 			ath11k_warn(ar->ab, "failed to setup dp for peer %pM on vdev %i (%d)\n",
 				    sta->addr, arvif->vdev_id, ret);
 			ath11k_peer_delete(ar, arvif->vdev_id, sta->addr);
+			ath11k_mac_dec_num_stations(arvif, sta);
 		}
 	} else if ((old_state == IEEE80211_STA_NONE &&
 		    new_state == IEEE80211_STA_NOTEXIST)) {
@@ -2614,6 +2655,8 @@ static int ath11k_sta_state(struct ieee80211_hw *hw,
 				    "Removed peer: %pM for VDEV: %d\n",
 				    sta->addr, arvif->vdev_id);
 
+		ath11k_mac_dec_num_stations(arvif, sta);
+
 		if (ath11k_debug_is_extd_tx_stats_enabled(ar))
 			kfree(arsta->tx_stats);
 
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ath11k: Allow station connections up to max supported only
  2019-05-28  9:20 [PATCH] ath11k: Allow station connections up to max supported only Venkateswara Naralasetty
@ 2019-05-29 15:18 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-05-29 15:18 UTC (permalink / raw)
  To: Venkateswara Naralasetty; +Cc: ath11k

Venkateswara Naralasetty <vnaralas@codeaurora.org> wrote:

> This patch add support to allow station connection request up to max
> number of stations supported by target.
> 
> Signed-off-by: Venkateswara Naralasetty <vnaralas@codeaurora.org>

Patch applied to ath.git, thanks.

b81048217c6f ath11k: Allow station connections up to max supported only

-- 
https://patchwork.kernel.org/patch/10964441/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-29 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-28  9:20 [PATCH] ath11k: Allow station connections up to max supported only Venkateswara Naralasetty
2019-05-29 15:18 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.