From patchwork Fri Nov 30 22:53:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10707385 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 A6DFB14BD for ; Fri, 30 Nov 2018 22:53:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78E322BFD0 for ; Fri, 30 Nov 2018 22:53:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6709A2DB6D; Fri, 30 Nov 2018 22:53:34 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF9B02F237 for ; Fri, 30 Nov 2018 22:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbeLAKEW (ORCPT ); Sat, 1 Dec 2018 05:04:22 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45696 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeLAKEW (ORCPT ); Sat, 1 Dec 2018 05:04:22 -0500 Received: by mail-pf1-f193.google.com with SMTP id g62so3481878pfd.12 for ; Fri, 30 Nov 2018 14:53:30 -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:mime-version :content-transfer-encoding; bh=vI0KI725ppQ0QeLybOn4zRDFbG68JsgaLaeS7ewMwVs=; b=FC7h9H+DMLKizpZo+y0wAxjKBRzX9yld/uScHN2kAY8wmn3wW3yEbDrCuu6kZiB0hS tDhgTBzWsbzx4Rb6Lh3sKonl3Li5VQN6uzO3sDwamOBOvdy6krnrPLAQslLDgILE6gLD CKrFVMBgiM7LJpFsbMU1qmka3pJ3AURjHWE6s= 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:mime-version :content-transfer-encoding; bh=vI0KI725ppQ0QeLybOn4zRDFbG68JsgaLaeS7ewMwVs=; b=dgyShKigJ/1dBpzpvgXbORaYGlp6DXkgPo+o2L3kAQlCg9vkSjMktn9Rv2WXlWRVbv 6CEXW6B0yyROjmgYkKDR4fjfJd/Kp9yAWmD4TiB+sX5Kqj+pVUgwptX2rVUVjt/yB72L I+JePHgEaEBZxh4O6M04bC4kn97LAS6PR7BqX8W0+X/Ve/x3eJrKAhL5wGsriiwIYQrn 8q7wUj/ND8A4xwVzxFAWFKgB+cSvJp2X63qgDxwDsY6l0RJWIjiFlTsic3KISplAHVcT YFPtrivAxqsbwMOY1DMG57ZQ15XOmPxmiUbQ2tQYV2Jduv3h0s8821j0o8s/8Hjkhsiu DJ2A== X-Gm-Message-State: AA+aEWZYSzhOWYQbQ8b2AWdzIlgZB5NFHX1h7MD8xN0SCzmXEvH3zBmv EXRnwWHjpZD59G+6yfYEg813mA== X-Google-Smtp-Source: AFSGD/U2ai+4OERoKbpzYCn/NSuldX/3K+5nLpm7A2GZ7CSD1EXdlWv3Ij2GzDnSslIOvbfks0q2rg== X-Received: by 2002:a63:580a:: with SMTP id m10mr6234892pgb.332.1543618410248; Fri, 30 Nov 2018 14:53:30 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:534:b7c0:a63c:460c]) by smtp.gmail.com with ESMTPSA id 7sm25542478pfm.8.2018.11.30.14.53.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:53:29 -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: [PATCH 1/3] mwifiex: debugfs: correct histogram spacing, formatting Date: Fri, 30 Nov 2018 14:53:01 -0800 Message-Id: <20181130225303.143409-1-briannorris@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, snippets of this file look like: rx rates (in Mbps): 0=1M 1=2M2=5.5M 3=11M 4=6M 5=9M 6=12M 7=18M 8=24M 9=36M 10=48M 11=54M12-27=MCS0-15(BW20) 28-43=MCS0-15(BW40) 44-53=MCS0-9(VHT:BW20)54-63=MCS0-9(VHT:BW40)64-73=MCS0-9(VHT:BW80) ... noise_flr[--96dBm] = 22 noise_flr[--95dBm] = 149 noise_flr[--94dBm] = 9 noise_flr[--93dBm] = 2 We're missing some spaces, and we're adding a minus sign ('-') on values that are already negative signed integers. Signed-off-by: Brian Norris --- drivers/net/wireless/marvell/mwifiex/debugfs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c index cce70252fd96..65e48e16cb49 100644 --- a/drivers/net/wireless/marvell/mwifiex/debugfs.c +++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c @@ -273,14 +273,14 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf, "total samples = %d\n", atomic_read(&phist_data->num_samples)); - p += sprintf(p, "rx rates (in Mbps): 0=1M 1=2M"); + p += sprintf(p, "rx rates (in Mbps): 0=1M 1=2M "); p += sprintf(p, "2=5.5M 3=11M 4=6M 5=9M 6=12M\n"); - p += sprintf(p, "7=18M 8=24M 9=36M 10=48M 11=54M"); + p += sprintf(p, "7=18M 8=24M 9=36M 10=48M 11=54M "); p += sprintf(p, "12-27=MCS0-15(BW20) 28-43=MCS0-15(BW40)\n"); if (ISSUPP_11ACENABLED(priv->adapter->fw_cap_info)) { - p += sprintf(p, "44-53=MCS0-9(VHT:BW20)"); - p += sprintf(p, "54-63=MCS0-9(VHT:BW40)"); + p += sprintf(p, "44-53=MCS0-9(VHT:BW20) "); + p += sprintf(p, "54-63=MCS0-9(VHT:BW40) "); p += sprintf(p, "64-73=MCS0-9(VHT:BW80)\n\n"); } else { p += sprintf(p, "\n"); @@ -310,7 +310,7 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf, for (i = 0; i < MWIFIEX_MAX_NOISE_FLR; i++) { value = atomic_read(&phist_data->noise_flr[i]); if (value) - p += sprintf(p, "noise_flr[-%02ddBm] = %d\n", + p += sprintf(p, "noise_flr[%02ddBm] = %d\n", (int)(i-128), value); } for (i = 0; i < MWIFIEX_MAX_SIG_STRENGTH; i++) { From patchwork Fri Nov 30 22:53:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10707387 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 2E24917D5 for ; Fri, 30 Nov 2018 22:53:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F3FE2F237 for ; Fri, 30 Nov 2018 22:53:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12F312F310; Fri, 30 Nov 2018 22:53:35 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 986E22F237 for ; Fri, 30 Nov 2018 22:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbeLAKEY (ORCPT ); Sat, 1 Dec 2018 05:04:24 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38628 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbeLAKEY (ORCPT ); Sat, 1 Dec 2018 05:04:24 -0500 Received: by mail-pg1-f196.google.com with SMTP id g189so3109233pgc.5 for ; Fri, 30 Nov 2018 14:53:32 -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=NbjsXLVqAGcoOPHHlVEOC/gIJ309Wj8RSk9PCEb9Esw=; b=ODmpjPS83p7cqWStCxfWSzap+EXqjZhyrnlPzn92A8aL2BM0qUA+afxUmOVHKhBBT2 z1ljRSGpEvJ2KXAw+FZBrOq5WM2qRnR7uWAk0Mg6kYzQlRXnxINEf1fI+rSBBgku7S2t Q6WmL3TDcKbtlRQz7Mc1+MrWUoL4gTBXkr2rQ= 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=NbjsXLVqAGcoOPHHlVEOC/gIJ309Wj8RSk9PCEb9Esw=; b=BTzGIQUKXHrWz7UoGfDyEYXg8nKPk6xFPU930osY6FqZfokrYCgAovIOoBBJw4TvpF LjAb1JNGK055yd1b0euUgmi2I9hKwMY53RLl13NVEsAXUWosdTyjUsHkelMIHf62pY3k kdoJ5F3cc+Lzs0ecRMgfLWJLjxwqL/lWodUxsnEiMbGR2f6ErY4EU9nMH3DzaP5Bd3jf 2UCVYba2G2kmqmt6IDX8XKCSljIfVaECGi5rGjAYnJ61KBGK5StoMnxkB+q5LK7kORcB GitMure4jK0CxMimaZ6VmNL6zued5qOLzKUPDH6a0VOrf1qKeU2/oE9tx5xSFkz7huMz EPEQ== X-Gm-Message-State: AA+aEWbm9j1oSiBc/e6z+ilXd0eeU20XysioPpeWQSQwGYA4dHnGfsMp 6hHHvi9y4UWrUoziaFMF+bFnXg== X-Google-Smtp-Source: AFSGD/Vw8gY2e8WnCWieBWvjNuumvBYwZ4pMPqFwVFDw5e1OHaclur/i9OEdco8qe4yC+onRtl1eVQ== X-Received: by 2002:a62:6a88:: with SMTP id f130mr7458297pfc.201.1543618411904; Fri, 30 Nov 2018 14:53:31 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:534:b7c0:a63c:460c]) by smtp.gmail.com with ESMTPSA id 7sm25542478pfm.8.2018.11.30.14.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:53:31 -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: [PATCH 2/3] mwifiex: refactor mwifiex_parse_htinfo() for reuse Date: Fri, 30 Nov 2018 14:53:02 -0800 Message-Id: <20181130225303.143409-2-briannorris@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog In-Reply-To: <20181130225303.143409-1-briannorris@chromium.org> References: <20181130225303.143409-1-briannorris@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function converts some firmware-specific parameters into cfg80211 'rate_info' structures. It currently assumes it's dealing only with TX bitrate, but the RX bitrate looks to be the same, so refactor this function to be reusable. Signed-off-by: Brian Norris --- .../net/wireless/marvell/mwifiex/cfg80211.c | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index adc88433faa8..02b80ea232a7 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -1275,27 +1275,27 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy, } static void -mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 tx_htinfo, +mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 rateinfo, u8 htinfo, struct rate_info *rate) { struct mwifiex_adapter *adapter = priv->adapter; if (adapter->is_hw_11ac_capable) { /* bit[1-0]: 00=LG 01=HT 10=VHT */ - if (tx_htinfo & BIT(0)) { + if (htinfo & BIT(0)) { /* HT */ - rate->mcs = priv->tx_rate; + rate->mcs = rateinfo; rate->flags |= RATE_INFO_FLAGS_MCS; } - if (tx_htinfo & BIT(1)) { + if (htinfo & BIT(1)) { /* VHT */ - rate->mcs = priv->tx_rate & 0x0F; + rate->mcs = rateinfo & 0x0F; rate->flags |= RATE_INFO_FLAGS_VHT_MCS; } - if (tx_htinfo & (BIT(1) | BIT(0))) { + if (htinfo & (BIT(1) | BIT(0))) { /* HT or VHT */ - switch (tx_htinfo & (BIT(3) | BIT(2))) { + switch (htinfo & (BIT(3) | BIT(2))) { case 0: rate->bw = RATE_INFO_BW_20; break; @@ -1310,26 +1310,26 @@ mwifiex_parse_htinfo(struct mwifiex_private *priv, u8 tx_htinfo, break; } - if (tx_htinfo & BIT(4)) + if (htinfo & BIT(4)) rate->flags |= RATE_INFO_FLAGS_SHORT_GI; - if ((priv->tx_rate >> 4) == 1) + if ((rateinfo >> 4) == 1) rate->nss = 2; else rate->nss = 1; } } else { /* - * Bit 0 in tx_htinfo indicates that current Tx rate - * is 11n rate. Valid MCS index values for us are 0 to 15. + * Bit 0 in htinfo indicates that current rate is 11n. Valid + * MCS index values for us are 0 to 15. */ - if ((tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) { - rate->mcs = priv->tx_rate; + if ((htinfo & BIT(0)) && (rateinfo < 16)) { + rate->mcs = rateinfo; rate->flags |= RATE_INFO_FLAGS_MCS; rate->bw = RATE_INFO_BW_20; - if (tx_htinfo & BIT(1)) + if (htinfo & BIT(1)) rate->bw = RATE_INFO_BW_40; - if (tx_htinfo & BIT(2)) + if (htinfo & BIT(2)) rate->flags |= RATE_INFO_FLAGS_SHORT_GI; } } @@ -1375,7 +1375,8 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, sinfo->tx_packets = node->stats.tx_packets; sinfo->tx_failed = node->stats.tx_failed; - mwifiex_parse_htinfo(priv, node->stats.last_tx_htinfo, + mwifiex_parse_htinfo(priv, priv->tx_rate, + node->stats.last_tx_htinfo, &sinfo->txrate); sinfo->txrate.legacy = node->stats.last_tx_rate * 5; @@ -1401,7 +1402,8 @@ mwifiex_dump_station_info(struct mwifiex_private *priv, HostCmd_ACT_GEN_GET, DTIM_PERIOD_I, &priv->dtim_period, true); - mwifiex_parse_htinfo(priv, priv->tx_htinfo, &sinfo->txrate); + mwifiex_parse_htinfo(priv, priv->tx_rate, priv->tx_htinfo, + &sinfo->txrate); sinfo->signal_avg = priv->bcn_rssi_avg; sinfo->rx_bytes = priv->stats.rx_bytes; From patchwork Fri Nov 30 22:53:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10707389 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 6E2E614BD for ; Fri, 30 Nov 2018 22:53:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B8772F38C for ; Fri, 30 Nov 2018 22:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F5CF2F38F; Fri, 30 Nov 2018 22:53:36 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF63C2F38C for ; Fri, 30 Nov 2018 22:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbeLAKE0 (ORCPT ); Sat, 1 Dec 2018 05:04:26 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38214 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbeLAKEZ (ORCPT ); Sat, 1 Dec 2018 05:04:25 -0500 Received: by mail-pl1-f195.google.com with SMTP id e5so3486273plb.5 for ; Fri, 30 Nov 2018 14:53:34 -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=zHpumVE7CiL9v8AD3wpXOTeWk03uT8+vkWyJQvkc7po=; b=VU7Ky/AEtFMLq5kqhgHJKIeE7YO9FNv5fuMouhzTorRHxSD6WIw0k4wdchbOrwb5Yb rfFokNEhvW/Z374FhXyXTheIsktnWve6URCth22hvUD9uR3+B/A/Mtyksf4HynnIeulo l8Nc2QTkp4xb/WEqH2C300mmTreMwFZy4AIpg= 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=zHpumVE7CiL9v8AD3wpXOTeWk03uT8+vkWyJQvkc7po=; b=f6Lt41BE5OqAeyDA0c2J7GzEVKu4LWxkNryrrZFo5vEJmeBXnLsBc/xsYhzLhxvkst vWiChdNzcBMtktVt2wGMnV6ffRfc8m4qVvf33hzSo0t2dP3kkNQ8KVoHx97iBXbZVRCH OZvHKCqblWmyBoCXr/+PvqydqY2jgp1PO85SW54XfQbWIG13zp9El4wQAKeOiyAr8uIV QGdlT3gbr6aCLKfsZFEM0viXH+x0jKmmchPDd4ohiFlny1xsoJcNYUnK8cW9CTvx0fWL 1b5Grk69tsKx+ni9tGA+fu7SOeBvL0S2xeWHPJMcAeeW0+K978v9pST6v1JAYxV/X6MI iSTw== X-Gm-Message-State: AA+aEWZ7YTWojsRIA3qrBmcmGfzsn9LuFpSti+EX18roVnC2FRe+sRpd FpvVTkUN77ZbZVdCmG2dZApujg== X-Google-Smtp-Source: AFSGD/VBNOjiBKHsZKbqz1xUKy/a07/2tf4MFbjDG/Im7dOqs8dmpsnVi/UrDLXlRzDKFVRVlc7ZOg== X-Received: by 2002:a17:902:2969:: with SMTP id g96mr7343737plb.295.1543618413661; Fri, 30 Nov 2018 14:53:33 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:534:b7c0:a63c:460c]) by smtp.gmail.com with ESMTPSA id 7sm25542478pfm.8.2018.11.30.14.53.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 14:53:32 -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: [PATCH 3/3] mwifiex: add NL80211_STA_INFO_RX_BITRATE support Date: Fri, 30 Nov 2018 14:53:03 -0800 Message-Id: <20181130225303.143409-3-briannorris@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog In-Reply-To: <20181130225303.143409-1-briannorris@chromium.org> References: <20181130225303.143409-1-briannorris@chromium.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- I'd appreciate it if someone from Marvell could double check my work here. .../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); }