From patchwork Tue May 30 20:58:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ryanhsu@qti.qualcomm.com X-Patchwork-Id: 9755235 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.web.codeaurora.org (Postfix) with ESMTP id B5544601D2 for ; Tue, 30 May 2017 20:59:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A87B626E74 for ; Tue, 30 May 2017 20:59:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B3C9283F5; Tue, 30 May 2017 20:59:07 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3258026E74 for ; Tue, 30 May 2017 20:59:06 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=tYWUKIxKOvRFxr9Wg/dddzoJIH2mOtQuK+mOnxNnFD0=; b=t8GslOV/Q8hkhg 1IFaSHQp6+DV9+b/x5K1T839YFt2UPKtzswK1dK/PqyHCoNZbHqfaH2WnGUyzQixbzdI+EEl5gN+P EaQ/l+Iv5ewpWKWhbppEdHkYNfVlBkwFML9MtbRSrwmH17n1k88vaSdijTJRwZIigal2EWm4t4VaF +2mB6JAIEvEdgalsOKo9t2rsscPGTx5omjguRMtH+QlmmX02qImEy61zqG2bQp9CvjJRzcvW3g9D2 XMnAkqcKDBs7VI9UyY0xO0/ZRFdfAGAHgvSYOEQ7xGnFZMNssqHCMGveY2RLVCkuUztb+982ObsfI U5ToSrd/KwJg4+oJITBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dFoEG-0007z6-VU; Tue, 30 May 2017 20:59:00 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dFoEC-0007xe-Do for ath10k@lists.infradead.org; Tue, 30 May 2017 20:58:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1496177936; x=1527713936; h=from:cc:to:subject:date:message-id:mime-version; bh=/jX8C4GYtM4dy1Clh6z34TRgkA5424IkyxYclPhLEZE=; b=YwBLRgXba3f+cotwhWBLU5LanN9lJdIsYnRLBRYmuCDXa2HrZEgvyaVv QggFUEZO9w4x14niAhJgUouonzssIJgs9mqTFppsHuNw3sflFGuR6gvTo PIbdwnABeppxDswH8/c+OtHH2BGQdpZTIFSOyY6XceEsm9MxYlbeZvWRP s=; X-IronPort-AV: E=Sophos;i="5.38,420,1491289200"; d="scan'208";a="289875442" Received: from ironmsg04-lv.qualcomm.com ([10.47.202.184]) by wolverine01.qualcomm.com with ESMTP; 30 May 2017 13:58:34 -0700 From: X-IronPort-AV: E=McAfee;i="5800,7501,8545"; a="30472563" X-MGA-submission: =?us-ascii?q?MDEhr+DJK4nlfmA7bzA/i9OwjKIHfQjxv32ghS?= =?us-ascii?q?ENYWhHpOHFlGuSgf79q/V+EUAUpuUmbSS2v8KS5KSyGSBrkPBppdsXh5?= =?us-ascii?q?061CxWhMUsVnuml5gbVDo7Agv8LLnIFRt7ZHCzo2AomV3zOytjDb093z?= =?us-ascii?q?i3?= Received: from nalasexr01g.na.qualcomm.com ([10.49.56.53]) by ironmsg04-lv.qualcomm.com with ESMTP/TLS/RC4-SHA; 30 May 2017 13:58:33 -0700 Received: from ryanhsu-linux2.qualcomm.com (10.80.80.8) by NALASEXR01G.na.qualcomm.com (10.49.56.53) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 30 May 2017 13:58:33 -0700 To: , Subject: [PATCH] ath10k: fix the logic of limiting tdls peer counts Date: Tue, 30 May 2017 13:58:29 -0700 Message-ID: <1496177909-5579-1-git-send-email-ryanhsu@qca.qualcomm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: NASANEXM01F.na.qualcomm.com (10.85.0.32) To NALASEXR01G.na.qualcomm.com (10.49.56.53) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170530_135856_582845_17CEB9F4 X-CRM114-Status: GOOD ( 11.55 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ryanhsu@qti.qualcomm.com, kaliu@qti.qualcomm.com, yintang@qti.qualcomm.com Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ryan Hsu 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 --- drivers/net/wireless/ath/ath10k/mac.c | 49 +++++++++++++++-------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 4674ff3..48418f9 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -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) {