Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp68420imu; Thu, 6 Dec 2018 16:14:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/XGivJLL0BkvRQrhQ1tylrmJQ36o/6Y0GTM5WSeVD9VRpuhqX6rj2DWOCwxB17IcnHdUyXN X-Received: by 2002:a62:8e19:: with SMTP id k25mr28519pfe.185.1544141699768; Thu, 06 Dec 2018 16:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544141699; cv=none; d=google.com; s=arc-20160816; b=lHysP708uaduAVQxO/0DmOy5qfjteCBF2dzkEGxYXqrxDTtu+w0WCxG1fyymn1NCOg 6qZbO4hGDVxWrzPbaw0XXkt9aSxpO6REqd5blghZl9SyUlYvGVFTFQUXzKseuroXCXsv 6w70YPlNQAAVUwRdWvFnIqPrr7OnILKXwC7hpM36i9eeoebwcTjJXQdwgN1VKGLbUyOJ cswxcuxTRTllotgky4qrJQoJwb0jwsRXqaY25VmJFvp9F1oEVUbqGW8cUHUeAbf+6QUH 0zB3hQ4aaFKwO2DatHoaBFX2z6jpAOtaU8G6Xz/JIcKPYUAD1HoVwTdSecHn0lrBwc3X T+zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t0y6HX6J+lHDD23/0YpeJqj2ohhaa87LchmrhAZziw4=; b=fauTNkyLPMYw3WsHGECidU5c6i/uxkG1Y9DAROrEu8d3lN0ABbvElsXrymHiNJO7ME mWX539W616EJwHv3QAq/JsXgjzGGWk2bBTrRUnsUWaV8hDzb82EuhMJgrNRhxCeFZA9g IfBGNDe80Q3FbrBYh0Nn/Vp1POt6zHN7B1dIZhQc1akWy0HN9NpqNgrOCe83RQlEoOrf ORH88qXX7yD9r77MfXylERoeIpFiJ4ePmiLl8hC5bFctJQkARHsmwJ6tzAk6pC8/rQls ImG/lUJBQPH38hTiuEja9zE6GvdHTROKqFWipVGAKCzJ2hnKX+3UMYjMSGnvQ9wMoYPf BRbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PZ9MFiqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x64si1516149pfx.87.2018.12.06.16.14.43; Thu, 06 Dec 2018 16:14:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PZ9MFiqz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726011AbeLGANk (ORCPT + 99 others); Thu, 6 Dec 2018 19:13:40 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40060 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbeLGANk (ORCPT ); Thu, 6 Dec 2018 19:13:40 -0500 Received: by mail-pg1-f193.google.com with SMTP id z10so874000pgp.7 for ; Thu, 06 Dec 2018 16:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t0y6HX6J+lHDD23/0YpeJqj2ohhaa87LchmrhAZziw4=; b=PZ9MFiqz8iRa8RqqQx0fWSwRKbwKMTke0UKoX2RUtOf7grTuejFs2s0yF2GnYyvRmA T9nqEeHW+kNw5mbPhMWzC5Waov3Jg88MvBU/SNTBZJPuN9r0cNPZa+qtD0f0IB78WAcL fIcVN2nOhFUhASueVXCH1Vo4WvhK5zVEL7cBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t0y6HX6J+lHDD23/0YpeJqj2ohhaa87LchmrhAZziw4=; b=CEr9AgYIdgNVt46GvgzJ3+JtgehMRbUTA0K0RCinqV11eG+4DtsUe+nvZfWPs+y3IN OxukGC/pVY5JM/eneRhzGu2IqYA+wgD7/Uz4TwWjeCJCO0mmwkEmRopaDnQKvfMsDdO8 uRvB6kIUSMBpo+X4CwvuDbYZoWApQuGhqONfzJfuzLSLlF1XFFYoxRte0naeIlLdvtnc AzVrNBRT3QQH+VHZNtDvB3t+EMqgmeFnut9cLf/avCMxxbjlPekEVLuKwcu90Q2HP4bL 1PqAsOZUyi2TdiKL5iy97Yd4LzbnpW2Fa09MS04M2pxgMvuSD71luWEN2RtYIB8N6fmY C6pw== X-Gm-Message-State: AA+aEWbTb4v2peinfmn4qGcBq5+BdpPJ0zg9KlstMi+1pTN2eHYuvjKs Wl818cIolL2B/XckgAxNQq4bhQ== X-Received: by 2002:a63:6645:: with SMTP id a66mr45723pgc.390.1544141619817; Thu, 06 Dec 2018 16:13:39 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:534:b7c0:a63c:460c]) by smtp.gmail.com with ESMTPSA id o66sm1654437pgo.75.2018.12.06.16.13.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Dec 2018 16:13:30 -0800 (PST) From: Brian Norris To: Kalle Valo Cc: , Amitkumar Karwar , Nishant Sarmukadam , Ganapathi Bhat , Xinming Hu , linux-wireless@vger.kernel.org, Brian Norris Subject: [RFC PATCH v2 2/2] mwifiex: add NL80211_STA_INFO_RX_BITRATE support Date: Thu, 6 Dec 2018 16:12:49 -0800 Message-Id: <20181207001249.165477-2-briannorris@chromium.org> X-Mailer: git-send-email 2.20.0.rc2.403.gdbc3b29805-goog In-Reply-To: <20181207001249.165477-1-briannorris@chromium.org> References: <20181207001249.165477-1-briannorris@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Comparing the existing TX_BITRATE parsing code (in mwifiex_parse_htinfo()) with the RX bitrate histograms in debugfs.c, it appears that the rxpd_rate and rxpd_htinfo fields have the same format. At least, they give reasonable results when I parse them this way. So this patch adds support for RX_BITRATE to our station info dump. Along the way, I add legacy bitrate parsing into the same function, using the debugfs code (mwifiex_histogram_read() and mwifiex_adjust_data_rate()) as reference. Additionally, to satisfy the requirements of NL80211_STA_INFO_RX_BITRATE, I skip logging the bitrate of multicast packets. This shouldn't add a lot of overhead to the RX path, as there are already several similar 802.3 header checks in this same codepath. We can also bias the branch behavior to favor unicast, as that's the common performance-sensitive case. I'd consider this support somewhat experimental, as I have zero documentation from Marvell. But the existing driver code gives me good reason to think this is correct. I've tested this on a few different 802.11{a,b,g,n,ac} networks, and the reported bitrates look good to me. Signed-off-by: Brian Norris --- RFC: I'd appreciate it if someone from Marvell could double check my work here. v2: * no change - just split unrelated (debugfs) patch to its own series --- .../net/wireless/marvell/mwifiex/cfg80211.c | 26 +++++++++++++++++++ drivers/net/wireless/marvell/mwifiex/sta_rx.c | 13 ++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 02b80ea232a7..1467af22e394 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -1333,6 +1333,28 @@ mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 rateinfo, u8 htinfo, rate->flags |= RATE_INFO_FLAGS_SHORT_GI; } } + + /* Decode legacy rates for non-HT. */ + if (!(htinfo & (BIT(0) | BIT(1)))) { + /* Bitrates in multiples of 100kb/s. */ + static const int legacy_rates[] = { + [0] = 10, + [1] = 20, + [2] = 55, + [3] = 110, + [4] = 60, /* MWIFIEX_RATE_INDEX_OFDM0 */ + [5] = 60, + [6] = 90, + [7] = 120, + [8] = 180, + [9] = 240, + [10] = 360, + [11] = 480, + [12] = 540, + }; + if (rateinfo < ARRAY_SIZE(legacy_rates)) + rate->legacy = legacy_rates[rateinfo]; + } } /* @@ -1414,6 +1436,10 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ sinfo->txrate.legacy = rate * 5; + sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE); + mwifiex_parse_htinfo(priv, priv->rxpd_rate, priv->rxpd_htinfo, + &sinfo->rxrate); + if (priv->bss_mode == NL80211_IFTYPE_STATION) { sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BSS_PARAM); sinfo->bss_param.flags = 0; diff --git a/drivers/net/wireless/marvell/mwifiex/sta_rx.c b/drivers/net/wireless/marvell/mwifiex/sta_rx.c index 00fcbda09349..fb28a5c7f441 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_rx.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_rx.c @@ -152,14 +152,17 @@ int mwifiex_process_rx_packet(struct mwifiex_private *priv, mwifiex_process_tdls_action_frame(priv, offset, rx_pkt_len); } - priv->rxpd_rate = local_rx_pd->rx_rate; - - priv->rxpd_htinfo = local_rx_pd->ht_info; + /* Only stash RX bitrate for unicast packets. */ + if (likely(!is_multicast_ether_addr(rx_pkt_hdr->eth803_hdr.h_dest))) { + priv->rxpd_rate = local_rx_pd->rx_rate; + priv->rxpd_htinfo = local_rx_pd->ht_info; + } if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA || GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) { - adj_rx_rate = mwifiex_adjust_data_rate(priv, priv->rxpd_rate, - priv->rxpd_htinfo); + adj_rx_rate = mwifiex_adjust_data_rate(priv, + local_rx_pd->rx_rate, + local_rx_pd->ht_info); mwifiex_hist_data_add(priv, adj_rx_rate, local_rx_pd->snr, local_rx_pd->nf); } -- 2.20.0.rc2.403.gdbc3b29805-goog