From patchwork Fri Jan 7 15:33:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12706780 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD84DC4332F for ; Fri, 7 Jan 2022 15:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348099AbiAGPbT (ORCPT ); Fri, 7 Jan 2022 10:31:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239641AbiAGPbR (ORCPT ); Fri, 7 Jan 2022 10:31:17 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A330FC061574 for ; Fri, 7 Jan 2022 07:31:16 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id s1so11748770wra.6 for ; Fri, 07 Jan 2022 07:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j/VlTdEJulPdJ5lhYnLqtXNudnIvNcxVXcQYjID5flM=; b=EKG5l10rxbPvg6Ykkp+ZdKXd6qTy2EEYHb5i/PdW7pwLvAbv1wrLEZjhM9XeqPdYez GeL4V0E9Qxkhx1jOKImMNJBSCKzhTzqIweZQnWs6xtwdOG+q1FVYVlx64QcotCzbe7rD WSUREX+cVyZ6BrDc9lqUMqSA7wOsBltizEjnBGi9K05rXPXVtQEX170u3FptFdJnByhd BjKT/1CZjNCIZYuez1x64EbmIrXSKHaO0inJtRXKJsE91yGBVuASOU/dGzRbTHDd871b CAD10QGQ4oxBwgK6Qh7YkEYWNsUkDv4dDG3lWB5q9WxYbJ1t82sKKLg1K5+/cw+zpu9p 8s5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j/VlTdEJulPdJ5lhYnLqtXNudnIvNcxVXcQYjID5flM=; b=ASlsTS/XhFy01KjR3o/WXyWfNaEIPSxAeOBvbtVKq6aQ00nLhD0PQqY0ed6reBk5b4 SQn7osrJAasFEZMLpqVYGzLby6jQiJLs4aGacDU+oa93qelRTlmTGcFdfyHscFri4aVI 0VTw2ZK3aO+leYMc/W9kRXxK+I0vpDdTiV6mvpUdD5P40wArlsCli1SxhCHRiKhBJCaA Aw8/PeY4qJ7mLr9mvDJJWm4Z7SOcvJH/Tg9FkBA8mTuLRyyZWR249OFcfcC90+hTAlWR TsAuhWLJ2fVuKwIGEMt7lA2ms4eDGUzmEH3jR/glI9zbNpcw+f40xUUnPIWnqSOJ2Hrh G+4g== X-Gm-Message-State: AOAM532xXgxDsy23L4VdmvUhb+K7CgCwOI1/GEt9a44fWrRP2bCwXN/z oCOCYBmnugl8zBJ8xAU7Uas5fA== X-Google-Smtp-Source: ABdhPJwKvqyms7weki5XSBOBdzeLHWXzQG9ut5otgerkQy1skxC0PVJbX6wQyeaWJ+DJDYEEcwfZww== X-Received: by 2002:a05:6000:1687:: with SMTP id y7mr55633491wrd.234.1641569475321; Fri, 07 Jan 2022 07:31:15 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id m6sm997242wrx.36.2022.01.07.07.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 07:31:14 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: loic.poulain@linaro.org, benl@squareup.com, bryan.odonoghue@linaro.org Subject: [PATCH 1/4] wcn36xx: Implement get_snr() Date: Fri, 7 Jan 2022 15:33:20 +0000 Message-Id: <20220107153323.1807905-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> References: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The wcn36xx BD phy descriptor returns both Received Signal Strength Information (RSSI) and Signal To Noise Ratio (SNR) with each delivered BD. The macro to extract this data is a simple-one liner, easily imported from downstream. This data will be useful to us when implementing mac80211-ops->get_survey(). Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/txrx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index ed4e8f201f510..a3eb476c2cbc4 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -23,6 +23,11 @@ static inline int get_rssi0(struct wcn36xx_rx_bd *bd) return 100 - ((bd->phy_stat0 >> 24) & 0xff); } +static inline int get_snr(struct wcn36xx_rx_bd *bd) +{ + return ((bd->phy_stat1 >> 24) & 0xff); +} + struct wcn36xx_rate { u16 bitrate; u16 mcs_or_legacy_index; From patchwork Fri Jan 7 15:33:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12706781 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00FF4C433F5 for ; Fri, 7 Jan 2022 15:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348094AbiAGPbU (ORCPT ); Fri, 7 Jan 2022 10:31:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348095AbiAGPbS (ORCPT ); Fri, 7 Jan 2022 10:31:18 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D2EC06173F for ; Fri, 7 Jan 2022 07:31:17 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id k18so11684051wrg.11 for ; Fri, 07 Jan 2022 07:31:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AsaR8KE4FUO+yauKKgOOa/fh5VYQZpsKbSDzqiBAFw4=; b=PDAuIXS4HJV16D/pIi6G6wE0bHzK9lD06+QDNBDZA0LsLOYvuY9BbFaJ+25zo9bgAx FfSRDN0D45bgazuCT0lTE4Xa3o4Gy50TEAlR3mHON78h3q+RE+iY2Hvm6g/FlnVlUfDJ V2qJEJT21YAzhSRsGbDhE1JUxJRANI1eX0+fzn2ZVDzOFbdEWk5mPk+CuVHr/O9HcXg/ +LWireHtzpdpFbgDrcJ4+6KnY70LS8SDBgWO/5FSzjBjQBQLotV2dt3thsH96eav8nqk E8sI/6FxNeACr6ppYVB6KgpIqKEuUZr55BXtuu0QMtrMK0fHCRk0geRD7lxCPwugYxmA tKEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AsaR8KE4FUO+yauKKgOOa/fh5VYQZpsKbSDzqiBAFw4=; b=7DA+4FvfzwlCAX5thdpn7gJeyKKix0AtrpWgi02ENpz2i//dfy251ru2Abb9AF0GW5 do2PmKZ7u3guPZLD6V9TqIa5eSEGhEFvGLX2zopL8dnGkyG9ZJPa/VdqAYwDtCS7ahYk 4EKiSltF6bM3wS0qqNbLMSvEwY4rHT8WeI6RbzO9KpzRnkzSHrLBZI1cfKK03hYPACyr NA3yRlPd5/oRql8Bn3V1PY29K0pmMsjueEf49I+enCa2RDhsj6Ss3LFVUAixRtfhSHpY 38ye2bZ9oGFZcTXoqAATz4VUMxqDLX7e5QC6CnwvFtJoDSJ/nPf/QZjHydxRmiKAvYAo b+uQ== X-Gm-Message-State: AOAM532VzpzqfDRhw2nEnZBOTphU3w62PXf0Ac+YLdhs7An6YZ147JuN 5r+lIMO+MrF+Tw1rNXn9Y9oe1Q77cI5yUw== X-Google-Smtp-Source: ABdhPJxHrZDbR6Qe65+5Gbhc6xfb5DKjYNuSc6d2+RiNov1TEQV+n32Sq9JO/LHyQGh/uWpVdBFlHw== X-Received: by 2002:adf:a45b:: with SMTP id e27mr1904950wra.661.1641569476231; Fri, 07 Jan 2022 07:31:16 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id m6sm997242wrx.36.2022.01.07.07.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 07:31:15 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: loic.poulain@linaro.org, benl@squareup.com, bryan.odonoghue@linaro.org Subject: [PATCH 2/4] wcn36xx: Track the band and channel we are tuned to Date: Fri, 7 Jan 2022 15:33:21 +0000 Message-Id: <20220107153323.1807905-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> References: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Track the band and channel we are currently tuned to by way of pointers to the standard structures that describe them both embedded within the driver. Tracking of the pair makes it much easier when implementing ieee80211_ops->get_survey to return quickly captured metrics for the currently tuned channel. Signed-off-by: Bryan O'Donoghue --- drivers/net/wireless/ath/wcn36xx/main.c | 27 ++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index ec355807f5817..d2b99f6112f6b 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -392,11 +392,38 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch) { struct ieee80211_vif *vif = NULL; struct wcn36xx_vif *tmp; + struct ieee80211_supported_band *band; + struct ieee80211_channel *channel; + int i, j; + + for (i = 0; i < ARRAY_SIZE(wcn->hw->wiphy->bands); i++) { + band = wcn->hw->wiphy->bands[i]; + if (!band) + break; + for (j = 0; j < band->n_channels; j++) { + if (HW_VALUE_CHANNEL(band->channels[j].hw_value) == ch) { + channel = &band->channels[j]; + break; + } + } + if (channel) + break; + } + + if (!channel) { + wcn36xx_err("Cannot tune to channel %d\n", ch); + return; + } + + wcn->band = band; + wcn->channel = channel; list_for_each_entry(tmp, &wcn->vif_list, list) { vif = wcn36xx_priv_to_vif(tmp); wcn36xx_smd_switch_channel(wcn, vif, ch); } + + return; } static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed) diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h index fbd0558c2c196..dd2570e468084 100644 --- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h +++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h @@ -281,6 +281,9 @@ struct wcn36xx { /* Debug file system entry */ struct wcn36xx_dfs_entry dfs; #endif /* CONFIG_WCN36XX_DEBUGFS */ + + struct ieee80211_supported_band *band; + struct ieee80211_channel *channel; }; static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn, From patchwork Fri Jan 7 15:33:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12706783 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82C4EC433EF for ; Fri, 7 Jan 2022 15:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348107AbiAGPbV (ORCPT ); Fri, 7 Jan 2022 10:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348098AbiAGPbT (ORCPT ); Fri, 7 Jan 2022 10:31:19 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE235C061574 for ; Fri, 7 Jan 2022 07:31:18 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id c66so4141175wma.5 for ; Fri, 07 Jan 2022 07:31:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xyJE6rJPZDtZD5lfHNqHl0e2z9z4XxYs8dm7T515T/w=; b=U8a41A6uoJrVefktS4oxKaslgPDYRCU8IVzl0Skh8G7sWbWGpZOUx3YNTeQrOhxPqK L3tAZoa2afCSU3kObagaJXxTLtQKb7rlpflZzzjekDNV2WmdqD+pTAYusdnVcTlQLKXW MaSAUNEd2HPEzreMKWgFF71c/d8oxlLYirC5BL09qZ25LlB9u/Usk5nT003G3hKsS5On VikCDpae8QvcNSANpSj+h+/NC9xf/krifIPK+kR4zEQYlgqU232+qiQSIC2YhNBntOc+ n3eq060gdefoTSb4br5JEbaj0JFjGyTVK7VJ9QNBXWyTqWqgrGnf0RGUCLzKkSLA4GxN v2ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xyJE6rJPZDtZD5lfHNqHl0e2z9z4XxYs8dm7T515T/w=; b=Farp13+hAXcD53fCU4GO3fN/wI4qJ8yw2Z796i67oWnAiva3ieYewuv0hpC8l5COBW xwykARdzTjF7rmr1XC83JBDWH+P5l79uGhRtnz97w/YT9bAIiGTgixt+ZfgUzkCpSHvx yNTw1Lpm2eUIXtAa9LCwHbLngnfikOWFlHXPxhwVkGal8ASvikyrzLSGGeOoLEGs5B4Q BiTu1VLVmUCpjWetx1uJn7gczRN6IdLIDppRi2FzZTztg2xzeYCOw5TOWzVXysnPaBaZ o80iJCXEBJjA50qvmWDvHGm1riLkb4+JmQyJfrWSGdyE3ICpJ+HODJz7yq7MHr49qIdZ XHwA== X-Gm-Message-State: AOAM530o39oSquJDggzUIKG7obk3ex5rG2SMLIlRJXecv2NKJpUhVxUX J5r63Vxx4WAi2/sdUHDSAId6EQ== X-Google-Smtp-Source: ABdhPJwiz6/2GfOcNWkjmZNrX8ITgM2VkouXtJ1/Xyrhf+YGp6vy0R2U8GZMGX/I4jY+SbPbE9gddw== X-Received: by 2002:a05:600c:245:: with SMTP id 5mr11516915wmj.23.1641569477208; Fri, 07 Jan 2022 07:31:17 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id m6sm997242wrx.36.2022.01.07.07.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 07:31:16 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: loic.poulain@linaro.org, benl@squareup.com, bryan.odonoghue@linaro.org Subject: [PATCH 3/4] wcn36xx: Track SNR and RSSI for each RX frame Date: Fri, 7 Jan 2022 15:33:22 +0000 Message-Id: <20220107153323.1807905-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> References: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The BDs for each RX frame contain both the RSSI and SNR for the received frame. If we track and store this information it can be useful to us in get_survey() and potentially elsewhere. Signed-off-by: Bryan O'Donoghue Reported-by: kernel test robot --- drivers/net/wireless/ath/wcn36xx/main.c | 12 ++++++++ drivers/net/wireless/ath/wcn36xx/txrx.c | 32 ++++++++++++++++++++++ drivers/net/wireless/ath/wcn36xx/wcn36xx.h | 10 +++++++ 3 files changed, 54 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index d2b99f6112f6b..d130ebb965146 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -331,6 +331,7 @@ static int wcn36xx_start(struct ieee80211_hw *hw) INIT_LIST_HEAD(&wcn->vif_list); spin_lock_init(&wcn->dxe_lock); + spin_lock_init(&wcn->survey_lock); return 0; @@ -394,6 +395,7 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch) struct wcn36xx_vif *tmp; struct ieee80211_supported_band *band; struct ieee80211_channel *channel; + unsigned long flags; int i, j; for (i = 0; i < ARRAY_SIZE(wcn->hw->wiphy->bands); i++) { @@ -415,8 +417,10 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch) return; } + spin_lock_irqsave(&wcn->survey_lock, flags); wcn->band = band; wcn->channel = channel; + spin_unlock_irqrestore(&wcn->survey_lock, flags); list_for_each_entry(tmp, &wcn->vif_list, list) { vif = wcn36xx_priv_to_vif(tmp); @@ -1562,6 +1566,7 @@ static int wcn36xx_probe(struct platform_device *pdev) void *wcnss; int ret; const u8 *addr; + int n_channels; wcn36xx_dbg(WCN36XX_DBG_MAC, "platform probe\n"); @@ -1589,6 +1594,13 @@ static int wcn36xx_probe(struct platform_device *pdev) goto out_wq; } + n_channels = wcn_band_2ghz.n_channels + wcn_band_5ghz.n_channels; + wcn->chan_survey = devm_kmalloc(wcn->dev, n_channels, GFP_KERNEL); + if (!wcn->chan_survey) { + ret -= ENOMEM; + goto out_wq; + } + ret = dma_set_mask_and_coherent(wcn->dev, DMA_BIT_MASK(32)); if (ret < 0) { wcn36xx_err("failed to set DMA mask: %d\n", ret); diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index a3eb476c2cbc4..0425781bc2fe1 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -271,6 +271,34 @@ static void __skb_queue_purge_irq(struct sk_buff_head *list) dev_kfree_skb_irq(skb); } +static void wcn36xx_update_survey(struct wcn36xx *wcn, int rssi, int snr, + int band, int freq) +{ + static struct ieee80211_channel *channel; + struct ieee80211_supported_band *sband; + int idx; + int i; + + idx = 0; + if (band == NL80211_BAND_5GHZ) + idx = wcn->hw->wiphy->bands[NL80211_BAND_2GHZ]->n_channels; + + sband = wcn->hw->wiphy->bands[band]; + channel = sband->channels; + + for (i = 0; i < sband->n_channels; i++, channel++) { + if (channel->center_freq == freq) { + idx += i; + break; + } + } + + spin_lock(&wcn->survey_lock); + wcn->chan_survey[idx].rssi = rssi; + wcn->chan_survey[idx].snr = snr; + spin_unlock(&wcn->survey_lock); +} + int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) { struct ieee80211_rx_status status; @@ -343,11 +371,15 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) status.band = NL80211_BAND_2GHZ; status.freq = ieee80211_channel_to_frequency(hwch, status.band); } + } else { status.band = WCN36XX_BAND(wcn); status.freq = WCN36XX_CENTER_FREQ(wcn); } + wcn36xx_update_survey(wcn, status.signal, get_snr(bd), + status.band, status.freq); + if (bd->rate_id < ARRAY_SIZE(wcn36xx_rate_table)) { rate = &wcn36xx_rate_table[bd->rate_id]; status.encoding = rate->encoding; diff --git a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h index dd2570e468084..81eaa74601d0f 100644 --- a/drivers/net/wireless/ath/wcn36xx/wcn36xx.h +++ b/drivers/net/wireless/ath/wcn36xx/wcn36xx.h @@ -194,7 +194,14 @@ struct wcn36xx_sta { enum wcn36xx_ampdu_state ampdu_state[16]; int non_agg_frame_ct; }; + struct wcn36xx_dxe_ch; + +struct wcn36xx_chan_survey { + s8 rssi; + u8 snr; +}; + struct wcn36xx { struct ieee80211_hw *hw; struct device *dev; @@ -284,6 +291,9 @@ struct wcn36xx { struct ieee80211_supported_band *band; struct ieee80211_channel *channel; + + spinlock_t survey_lock; /* protects chan_survey */ + struct wcn36xx_chan_survey *chan_survey; }; static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn, From patchwork Fri Jan 7 15:33:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 12706782 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6172C4321E for ; Fri, 7 Jan 2022 15:31:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348101AbiAGPbW (ORCPT ); Fri, 7 Jan 2022 10:31:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348102AbiAGPbU (ORCPT ); Fri, 7 Jan 2022 10:31:20 -0500 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83F0AC061401 for ; Fri, 7 Jan 2022 07:31:19 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id h10so1573352wrb.1 for ; Fri, 07 Jan 2022 07:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3caE7ZiFVRPsfUz1cJ9WrcYjXkULY6fiCjhjWppgLEs=; b=osq/ESNMmBdyZ3Ij8ISDCG5B99rgcMHSPcv8FqvNjy0q9TjoXobh8cYbuaar2pjDti IYpkJs8aCAaBGK42XIFDJB4O9JL6ocwSqH1Qpl+SFZnYsXmSJKj3lebODEGF0sdwN3g+ Bvu4JuSRPBSUHUIxCKn+aG04syONMaLJ9bnxPCUqGo3/vODwDQ4h8IFe90MpMG1oH2hw kYKcpGzBZwtAbBcQJIWAmFBU9fJxMg9KxtR31uz3QUg93Bu03UWRVQoKy3VIfkq0/ttV JTyRci8ignpmOT1b3qhjc52lBVn3MxYGk2LYGPfWVNU8fWMobL1R/eYzkqDsa7Em+YSe 9HuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3caE7ZiFVRPsfUz1cJ9WrcYjXkULY6fiCjhjWppgLEs=; b=mIk6JH0yiRj2xgZeYoDw/e7sZRARqH5w4fVR+FUAZcSqD+BgcEw1jLner5PIOiES0w pxtaL66xxyV7+uctD2PKxZYeRhJHp6s9aPByBQLqCDbGAw7c5Ioy8lWQAkfPgHKiC1vW nrHhSDOI4zZRgVJjC8VO+lWXdG7/SYtSJsEVGHylJqCMfb+vItgo3OjdW0I2b8UGBzRi YE528D4aEroo2JLFMROY6fDOrvIiDJpQq+PpLaa2BEGmHUyWNVTsZtVeU01NqCrmT8Yc Jb09mAs955pvQzvVHh//kjQWHeTvLNGC3Jt75EQSXiG2GKb2KC5wzr8gV/uu1d1+1IVQ 1MXw== X-Gm-Message-State: AOAM530FLv8Pg85UW0lG/W+UvZtkc+cxLYzCuYGx7YB77GnNXjx7b8Jw liWFHSWLF6QTryqifs+6V9uWLA== X-Google-Smtp-Source: ABdhPJxP/LtECTOcLF1eTcgsMe+Mm9jzmNY1cAbNE7xAawb3DcVWlasFk4TfQ/ICCR24z/+0jjD+ww== X-Received: by 2002:a05:6000:1845:: with SMTP id c5mr54191134wri.499.1641569478109; Fri, 07 Jan 2022 07:31:18 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id m6sm997242wrx.36.2022.01.07.07.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 07:31:17 -0800 (PST) From: Bryan O'Donoghue To: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, wcn36xx@lists.infradead.org, linux-arm-msm@vger.kernel.org Cc: loic.poulain@linaro.org, benl@squareup.com, bryan.odonoghue@linaro.org Subject: [PATCH 4/4] wcn36xx: Add SNR reporting via get_survey() Date: Fri, 7 Jan 2022 15:33:23 +0000 Message-Id: <20220107153323.1807905-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> References: <20220107153323.1807905-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support for get_survey() reporting. Current channel and noise-floor are reported, other parameters such as scan, busy, TX and RX time are not immediately available. Noise is a useful metric to report, so bring it out now. Signed-off-by: Bryan O'Donoghue Reported-by: kernel test robot --- drivers/net/wireless/ath/wcn36xx/main.c | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index d130ebb965146..bcef590be60dc 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -1357,6 +1357,47 @@ static void wcn36xx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, } } +int wcn36xx_get_survey(struct ieee80211_hw *hw, int idx, + struct survey_info *survey) +{ + struct wcn36xx *wcn = hw->priv; + struct ieee80211_supported_band *sband; + struct wcn36xx_chan_survey *chan_survey; + unsigned long flags; + + sband = wcn->hw->wiphy->bands[NL80211_BAND_2GHZ]; + if (idx >= sband->n_channels) { + idx -= sband->n_channels; + sband = wcn->hw->wiphy->bands[NL80211_BAND_5GHZ]; + } + + if (!sband || idx >= sband->n_channels) + return -ENOENT; + + spin_lock_irqsave(&wcn->survey_lock, flags); + + chan_survey = &wcn->chan_survey[idx]; + survey->channel = &sband->channels[idx]; + survey->noise = chan_survey->rssi - chan_survey->snr; + survey->filled = 0; + + if (chan_survey->rssi > -100 && chan_survey->rssi < 0) + survey->filled |= SURVEY_INFO_NOISE_DBM; + + if (survey->channel == wcn->channel) + survey->filled |= SURVEY_INFO_IN_USE; + + spin_unlock_irqrestore(&wcn->survey_lock, flags); + + wcn36xx_dbg(WCN36XX_DBG_MAC, + "ch %d rssi %d snr %d noise %d filled %x freq %d\n", + HW_VALUE_CHANNEL(survey->channel->hw_value), + chan_survey->rssi, chan_survey->snr, survey->noise, + survey->filled, survey->channel->center_freq); + + return 0; +} + static const struct ieee80211_ops wcn36xx_ops = { .start = wcn36xx_start, .stop = wcn36xx_stop, @@ -1385,6 +1426,7 @@ static const struct ieee80211_ops wcn36xx_ops = { .ipv6_addr_change = wcn36xx_ipv6_addr_change, #endif .flush = wcn36xx_flush, + .get_survey = wcn36xx_get_survey, CFG80211_TESTMODE_CMD(wcn36xx_tm_cmd) };