From: Venkateswara Naralasetty <vnaralas@codeaurora.org>
To: ath11k@lists.infradead.org
Cc: Venkateswara Naralasetty <vnaralas@codeaurora.org>
Subject: [PATCH] ath11k: Allow station connections up to max supported only
Date: Tue, 28 May 2019 14:50:46 +0530 [thread overview]
Message-ID: <1559035246-3833-1-git-send-email-vnaralas@codeaurora.org> (raw)
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
next reply other threads:[~2019-05-28 9:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 9:20 Venkateswara Naralasetty [this message]
2019-05-29 15:18 ` [PATCH] ath11k: Allow station connections up to max supported only Kalle Valo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1559035246-3833-1-git-send-email-vnaralas@codeaurora.org \
--to=vnaralas@codeaurora.org \
--cc=ath11k@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox