From patchwork Tue May 28 09:20:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkateswara Naralasetty X-Patchwork-Id: 10964441 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1184376 for ; Tue, 28 May 2019 09:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F34A128571 for ; Tue, 28 May 2019 09:20:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E473A285A7; Tue, 28 May 2019 09:20:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8328C28571 for ; Tue, 28 May 2019 09:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=d+uQ0cSB/2GnCTdSvlCsKxD0HAT9efiX9ZbKIMbZeZ4=; b=Gqh sjvNY4OPq0qEjkXd0l4e6rADuxkZyUXCx9LdSMSQOHDa2cdbm0Ojo0vv6UkHbRcpVM91o5f+g6O2R v8TxjPAdeUFmSZqYI8sjQJlAn2bx2lHYP6bnZZUotYB/adcMieWHcTOPpGx1uQBpOYhIuod/OccJ6 rtEwKWUUkSQ2UPVFjFNwPjDN/TenZnvPw9nkM36paf4THHJCMpUQ5X30GGoioko7A/vvLcF1mVz+E GwiggX61l4Mn6dcGYFIIeIwt7Edmu+Szb5icxQJUsNRZxpUwz3BnZrY+CjDSEqxQqQL7hZhHlttFE jY5BnntWF8YfSopvMR8tLMegWqFUz2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVYHu-0005uU-JL; Tue, 28 May 2019 09:20:54 +0000 Received: from alexa-out-blr-02.qualcomm.com ([103.229.18.198] helo=alexa-out-blr.qualcomm.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hVYHr-0005u1-23 for ath11k@lists.infradead.org; Tue, 28 May 2019 09:20:53 +0000 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by alexa-out-blr.qualcomm.com with ESMTP/TLS/AES256-SHA; 28 May 2019 14:50:49 +0530 X-IronPort-AV: E=McAfee;i="5900,7806,9270"; a="9799460" Received: from vnaralas-linux.qualcomm.com ([10.201.26.231]) by ironmsg01-blr.qualcomm.com with ESMTP; 28 May 2019 14:50:48 +0530 Received: by vnaralas-linux.qualcomm.com (Postfix, from userid 443942) id E19DE2748; Tue, 28 May 2019 14:50:47 +0530 (IST) From: Venkateswara Naralasetty To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: Allow station connections up to max supported only Date: Tue, 28 May 2019 14:50:46 +0530 Message-Id: <1559035246-3833-1-git-send-email-vnaralas@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190528_022051_730182_A8E3F400 X-CRM114-Status: UNSURE ( 9.59 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Venkateswara Naralasetty MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add support to allow station connection request up to max number of stations supported by target. Signed-off-by: Venkateswara Naralasetty --- 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);