diff mbox series

[4/4] wcn36xx: Add SNR reporting via get_survey()

Message ID 20220107153323.1807905-5-bryan.odonoghue@linaro.org (mailing list archive)
State Superseded
Headers show
Series wcn36xx: Add spectrum survey reporting | expand

Commit Message

Bryan O'Donoghue Jan. 7, 2022, 3:33 p.m. UTC
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 <bryan.odonoghue@linaro.org>
---
 drivers/net/wireless/ath/wcn36xx/main.c | 42 +++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Comments

kernel test robot Jan. 7, 2022, 7:28 p.m. UTC | #1
Hi Bryan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on kvalo-wireless-drivers-next/master]
[also build test WARNING on kvalo-ath/ath-next next-20220107]
[cannot apply to kvalo-wireless-drivers/master v5.16-rc8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bryan-O-Donoghue/wcn36xx-Add-spectrum-survey-reporting/20220107-233226
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20220108/202201080336.Ut3ffMZu-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/81c9665c3b1b0b2167717fbd52c32b5ea0f215af
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bryan-O-Donoghue/wcn36xx-Add-spectrum-survey-reporting/20220107-233226
        git checkout 81c9665c3b1b0b2167717fbd52c32b5ea0f215af
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/wireless/ath/wcn36xx/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/wcn36xx/main.c:1360:5: warning: no previous prototype for 'wcn36xx_get_survey' [-Wmissing-prototypes]
    1360 | int wcn36xx_get_survey(struct ieee80211_hw *hw, int idx,
         |     ^~~~~~~~~~~~~~~~~~


vim +/wcn36xx_get_survey +1360 drivers/net/wireless/ath/wcn36xx/main.c

  1359	
> 1360	int wcn36xx_get_survey(struct ieee80211_hw *hw, int idx,
  1361			       struct survey_info *survey)
  1362	{
  1363		struct wcn36xx *wcn = hw->priv;
  1364		struct ieee80211_supported_band *sband;
  1365		struct wcn36xx_chan_survey *chan_survey;
  1366		unsigned long flags;
  1367	
  1368		sband = wcn->hw->wiphy->bands[NL80211_BAND_2GHZ];
  1369		if (idx >= sband->n_channels) {
  1370			idx -= sband->n_channels;
  1371			sband = wcn->hw->wiphy->bands[NL80211_BAND_5GHZ];
  1372		}
  1373	
  1374		if (!sband || idx >= sband->n_channels)
  1375			return -ENOENT;
  1376	
  1377		spin_lock_irqsave(&wcn->survey_lock, flags);
  1378	
  1379		chan_survey = &wcn->chan_survey[idx];
  1380		survey->channel = &sband->channels[idx];
  1381		survey->noise = chan_survey->rssi - chan_survey->snr;
  1382		survey->filled = 0;
  1383	
  1384		if (chan_survey->rssi > -100 && chan_survey->rssi < 0)
  1385			survey->filled |= SURVEY_INFO_NOISE_DBM;
  1386	
  1387		if (survey->channel == wcn->channel)
  1388			survey->filled |= SURVEY_INFO_IN_USE;
  1389	
  1390		spin_unlock_irqrestore(&wcn->survey_lock, flags);
  1391	
  1392		 wcn36xx_dbg(WCN36XX_DBG_MAC,
  1393			     "ch %d rssi %d snr %d noise %d filled %x freq %d\n",
  1394			     HW_VALUE_CHANNEL(survey->channel->hw_value),
  1395			     chan_survey->rssi, chan_survey->snr, survey->noise,
  1396			     survey->filled, survey->channel->center_freq);
  1397	
  1398		return 0;
  1399	}
  1400	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

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)
 };