From patchwork Fri Jul 5 10:31:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 11032955 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 0D95A138D for ; Fri, 5 Jul 2019 15:48:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDE5C2846D for ; Fri, 5 Jul 2019 15:48:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F5D2871A; Fri, 5 Jul 2019 15:48:02 +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=-4.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, 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 48A4B2846D for ; Fri, 5 Jul 2019 15:48:02 +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:References:In-Reply-To: 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: List-Owner; bh=mnzKLvN9tTdrhcoW3Kn1GZK8Nsy9qqHrwZmEiFkW/Bo=; b=eVLI9H94O1mJ77 1oa/6dtzy/T013EStwXjWMKsQ+HbAhBccWB/mR3PfT30IV7ZEzDdHOQwNNAd4kI6OcTlnIbHAZ158 fNO5nqXY1pLGpqbcrW8tH5oSBLM6BzZOedt3jsIWJtPwfu62xiMWPK6rI+8PwtGzgL3yERkseP3qi 90DeFAQrLU1tbUlct2TW1wsg+rk8cRoLBbmKMLO90tP3PbDWxEN1YZvix+0/Y3o3vYC7qgMIEdgMV /5OhrOyz90kmkd3rkDKDDM4bZnoOr0CcwVncganBbs29fXtLgqWi+Jx8CA4oQdMQgxJckc7JcoKUI aT/gUVOfigK+3Jaokuwg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hjQRL-0002RH-Sg; Fri, 05 Jul 2019 15:47:59 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjQNe-0005nI-Fo for ath11k@bombadil.infradead.org; Fri, 05 Jul 2019 15:44:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mf5Fde2gG95WpGUQ22PwBtDNx5lFGfrl9hRZUh6oVDg=; b=zPyii2o16tA6/JcpayA+uAwsXZ jDB60zIjfgLkopB57t/KsT2q7gVn2IFolSHxK3PeQbWh13lyfaXxf/9Uk4fbrPTRn3/tLo7FyJwej YTBi9+asNJSH1xFRt89Kf6WtHhW1rvyAkUenvBdbxHKRLD9l6r3HDGeiAagV0AUaw0pzEZete8ZuC /95POS/PFy/ZFp9VZUamZKg70Br2L6hqV+hmb85WHH1WbiQqcYkbnQUXZYxeteSJ4P86/lQwhTxED CkPzwMBjGKefywLV6smxq4Ro+lWFJ8W61OscNBy19+1JjvmZZFLINZLb0Ow10VPkeUhdaxlQ5k4Xr e/ek190w==; Received: from dvalin.narfation.org ([213.160.73.56]) by merlin.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hjLcl-0001Ae-GO for ath11k@lists.infradead.org; Fri, 05 Jul 2019 10:39:28 +0000 Received: from sven-desktop.home.narfation.org (p5B34C688.dip0.t-ipconnect.de [91.52.198.136]) by dvalin.narfation.org (Postfix) with ESMTPSA id 5B1F120948; Fri, 5 Jul 2019 10:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1562322684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mf5Fde2gG95WpGUQ22PwBtDNx5lFGfrl9hRZUh6oVDg=; b=Zhmcqj9Bfjk6JqeBgqb5LnrocRNMjrh/JjEkHolrZ7lQnlcegeySyy5dtMmdw9ukdTWfyV SlZdmWYUfqR0LQiQEvLdeULkFhvySHaDg0WthH5i+9sTqlPTkQ1IS6W4qSDnIjipj5V0yG WMZn4T36jwY7WBXFiTJEClE52wQSoKU= From: Sven Eckelmann To: ath11k@lists.infradead.org Subject: [PATCH 2/3] ath11k: support for mgmt rate control Date: Fri, 5 Jul 2019 12:31:07 +0200 Message-Id: <20190705103109.3731-3-sven@narfation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190705103109.3731-1-sven@narfation.org> References: <20190705103109.3731-1-sven@narfation.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1562322684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mf5Fde2gG95WpGUQ22PwBtDNx5lFGfrl9hRZUh6oVDg=; b=NXpk76j9Vu+OZNO0bp0PxUmvvXed1a9SqIgkt9BFv8/FfhJ8MonlBVl2Opu3LPAjiFI/HP uE1CmgwIJEjCdlYkm10gdalXLOjpmG5tJcPjkTy+09t+od4y+9BrTqKapAN9EuatVVkfqT xE23Y7gDDZZsUHFn+uDZVvm91pFfdwA= ARC-Seal: i=1; s=20121; d=narfation.org; t=1562322684; a=rsa-sha256; cv=none; b=p68mpeKyhW6myMwevgQg3wogzPhEOlOsxGN2tFWgJTp6Y2mbtjXGj+umPkxfvdSBTGZv6t yEvOKTI8LO/b/AX6UlAsvJc5OrOj13c7Kr8K2OCDRAV7cJuOmhAwlEVFA0Z8xPFHgSBWfB /2B7BwpwTCfADm/5UgEmDk6ObW5qeB4= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=sven smtp.mailfrom=sven@narfation.org X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sven Eckelmann Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sven Eckelmann The management frames have to be sent at a basic rate. But the ath11k firmware is always doing them on 1 Mbit/s for 2.4GHz and 6 Mbit/s for 5GHz. These might not be the basic rates which the AP advertised. Clients which don't support these rates will therefore not be able to receive them correctly. mac80211 already provides a list of basic rates for the driver. ath11k has to pick the lowest one and send it to the firmware rate control. Signed-off-by: Sven Eckelmann --- drivers/net/wireless/ath/ath11k/mac.c | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 592fe79e8489..cda5b39f1a9b 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -1614,6 +1614,62 @@ static void ath11k_bss_disassoc(struct ieee80211_hw *hw, /* TODO: cancel connection_loss_work */ } +static u32 ath11k_mac_get_rate_hw_value(int bitrate) +{ + u32 preamble; + u16 hw_value; + int rate; + size_t i; + + if (ath11k_mac_bitrate_is_cck(bitrate)) + preamble = WMI_RATE_PREAMBLE_CCK; + else + preamble = WMI_RATE_PREAMBLE_OFDM; + + for (i = 0; i < ARRAY_SIZE(ath11k_legacy_rates); i++) { + if (ath11k_legacy_rates[i].bitrate != bitrate) + continue; + + hw_value = ath11k_legacy_rates[i].hw_value; + rate = ATH11K_HW_RATE_CODE(hw_value, 0, preamble); + + return rate; + } + + return -EINVAL; +} + +static void ath11k_recalculate_mgmt_rate(struct ath11k *ar, + struct ieee80211_vif *vif, + struct cfg80211_chan_def *def) +{ + struct ath11k_vif *arvif = (void *)vif->drv_priv; + const struct ieee80211_supported_band *sband; + u8 basic_rate_idx; + int hw_rate_code; + u32 vdev_param; + u16 bitrate; + int ret; + + lockdep_assert_held(&ar->conf_mutex); + + sband = ar->hw->wiphy->bands[def->chan->band]; + basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1; + bitrate = sband->bitrates[basic_rate_idx].bitrate; + + hw_rate_code = ath11k_mac_get_rate_hw_value(bitrate); + if (hw_rate_code < 0) { + ath11k_warn(ar->ab, "bitrate not supported %d\n", bitrate); + return; + } + + vdev_param = WMI_VDEV_PARAM_MGMT_RATE; + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param, + hw_rate_code); + if (ret) + ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret); +} + static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *info, @@ -1821,6 +1877,10 @@ static void ath11k_mac_op_bss_info_changed(struct ieee80211_hw *hw, arvif->vdev_id, ret); } + if (changed & BSS_CHANGED_BASIC_RATES && + !ath11k_mac_vif_chan(arvif->vif, &def)) + ath11k_recalculate_mgmt_rate(ar, vif, &def); + mutex_unlock(&ar->conf_mutex); }