Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-06-18 Thread Ben Greear

On 06/18/2018 01:46 PM, Johannes Berg wrote:

On Thu, 2018-05-31 at 08:52 -0700, Ben Greear wrote:


On 05/31/2018 02:06 AM, vnara...@codeaurora.org wrote:

On 2018-05-23 15:24, Johannes Berg wrote:

On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:

This patch provides support to send accumulated survey data to
user if low level drivers provides non-accumulated survey data.


I think the commit log should say what you need this for?

It's simultaneously a new flag, and a lot of code, but it's not clear
what the point is?

johannes


I will sent next version of patch with updated commit log.

Providing you the earlier discussion of this patch to give quick overview about 
this patch.
https://patchwork.kernel.org/patch/9701459/


It is simple to fix the firmware, it just has several bugs related to clearing 
the
accumulator as well as the 'real' values.  If you can find a QCA firmware 
engineer
that will accept patches I can show them how to fix this easily.  I recently
fixed this in my wave-1 firmware.  I posted patches to the ath10k driver to
support this a week or so ago, but not sure if Kalle will apply them.


That would be nicer even, but I guess we still have to worry about older
firmware? Perhaps not for survey support? Dunno.

Obviously less code is better, but I can't really say how easy it would
be to get firmware updates rolled out to people who'd need them ...


And, it is likely that even if you don't use the 'clear' option, you are going 
to
get wraps in the firmware and that will just be other harder to debug bugs.


You have to use clear if you don't accumulate completely in fw, no?


At least some firmware is broken in numerous ways, and there is no clear way to
tell which firmware is broken how as far as I can tell.  It does appear to be 
fixed in
recent 10.4 (wave-2) firmware, so maybe they will fix 10.2 as well.

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com



Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-06-18 Thread Johannes Berg
On Thu, 2018-05-31 at 08:52 -0700, Ben Greear wrote:
> 
> On 05/31/2018 02:06 AM, vnara...@codeaurora.org wrote:
> > On 2018-05-23 15:24, Johannes Berg wrote:
> > > On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:
> > > > This patch provides support to send accumulated survey data to
> > > > user if low level drivers provides non-accumulated survey data.
> > > 
> > > I think the commit log should say what you need this for?
> > > 
> > > It's simultaneously a new flag, and a lot of code, but it's not clear
> > > what the point is?
> > > 
> > > johannes
> > 
> > I will sent next version of patch with updated commit log.
> > 
> > Providing you the earlier discussion of this patch to give quick overview 
> > about this patch.
> > https://patchwork.kernel.org/patch/9701459/
> 
> It is simple to fix the firmware, it just has several bugs related to 
> clearing the
> accumulator as well as the 'real' values.  If you can find a QCA firmware 
> engineer
> that will accept patches I can show them how to fix this easily.  I recently
> fixed this in my wave-1 firmware.  I posted patches to the ath10k driver to
> support this a week or so ago, but not sure if Kalle will apply them.

That would be nicer even, but I guess we still have to worry about older
firmware? Perhaps not for survey support? Dunno.

Obviously less code is better, but I can't really say how easy it would
be to get firmware updates rolled out to people who'd need them ...

> And, it is likely that even if you don't use the 'clear' option, you are 
> going to
> get wraps in the firmware and that will just be other harder to debug bugs.

You have to use clear if you don't accumulate completely in fw, no?

johannes


Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-06-18 Thread Johannes Berg
On Thu, 2018-05-31 at 14:36 +0530, vnara...@codeaurora.org wrote:
> On 2018-05-23 15:24, Johannes Berg wrote:
> > On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:
> > > This patch provides support to send accumulated survey data to
> > > user if low level drivers provides non-accumulated survey data.
> > 
> > I think the commit log should say what you need this for?
> > 
> > It's simultaneously a new flag, and a lot of code, but it's not clear
> > what the point is?
> > 
> > johannes
> 
> I will sent next version of patch with updated commit log.
> 
> Providing you the earlier discussion of this patch to give quick 
> overview about this patch.
> https://patchwork.kernel.org/patch/9701459/

Haha. I guess it's too long ago :)

johannes


Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-05-31 Thread Ben Greear




On 05/31/2018 02:06 AM, vnara...@codeaurora.org wrote:

On 2018-05-23 15:24, Johannes Berg wrote:

On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:

This patch provides support to send accumulated survey data to
user if low level drivers provides non-accumulated survey data.


I think the commit log should say what you need this for?

It's simultaneously a new flag, and a lot of code, but it's not clear
what the point is?

johannes


I will sent next version of patch with updated commit log.

Providing you the earlier discussion of this patch to give quick overview about 
this patch.
https://patchwork.kernel.org/patch/9701459/


It is simple to fix the firmware, it just has several bugs related to clearing 
the
accumulator as well as the 'real' values.  If you can find a QCA firmware 
engineer
that will accept patches I can show them how to fix this easily.  I recently
fixed this in my wave-1 firmware.  I posted patches to the ath10k driver to
support this a week or so ago, but not sure if Kalle will apply them.

And, it is likely that even if you don't use the 'clear' option, you are going 
to
get wraps in the firmware and that will just be other harder to debug bugs.

Thanks,
Ben

--
Ben Greear 
Candela Technologies Inc  http://www.candelatech.com


Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-05-31 Thread vnaralas

On 2018-05-23 15:24, Johannes Berg wrote:

On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:

This patch provides support to send accumulated survey data to
user if low level drivers provides non-accumulated survey data.


I think the commit log should say what you need this for?

It's simultaneously a new flag, and a lot of code, but it's not clear
what the point is?

johannes


I will sent next version of patch with updated commit log.

Providing you the earlier discussion of this patch to give quick 
overview about this patch.

https://patchwork.kernel.org/patch/9701459/


Thanks,
Venkatesh.


Re: [PATCH] cfg80211: Add cumulative channel survey dump support.

2018-05-23 Thread Johannes Berg
On Tue, 2018-05-22 at 14:45 +0530, Venkateswara Naralasetty wrote:
> This patch provides support to send accumulated survey data to
> user if low level drivers provides non-accumulated survey data.

I think the commit log should say what you need this for?

It's simultaneously a new flag, and a lot of code, but it's not clear
what the point is?

johannes


[PATCH] cfg80211: Add cumulative channel survey dump support.

2018-05-22 Thread Venkateswara Naralasetty
This patch provides support to send accumulated survey data to
user if low level drivers provides non-accumulated survey data.

Signed-off-by: Venkateswara Naralasetty 
---
 include/net/cfg80211.h |  5 +
 net/wireless/core.c| 21 +
 net/wireless/nl80211.c | 34 +-
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fc40843..e0ecd7d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -580,6 +580,7 @@ ieee80211_chandef_max_power(struct cfg80211_chan_def 
*chandef)
  * @SURVEY_INFO_TIME_RX: receive time was filled in
  * @SURVEY_INFO_TIME_TX: transmit time was filled in
  * @SURVEY_INFO_TIME_SCAN: scan time was filled in
+ * @SURVEY_INFO_NON_ACC_DATA: non accumulated survey data filled in
  *
  * Used by the driver to indicate which info in  survey_info
  * it has filled in during the get_survey().
@@ -593,6 +594,7 @@ enum survey_info_flags {
SURVEY_INFO_TIME_RX = BIT(5),
SURVEY_INFO_TIME_TX = BIT(6),
SURVEY_INFO_TIME_SCAN   = BIT(7),
+   SURVEY_INFO_NON_ACC_DATA= BIT(8),
 };
 
 /**
@@ -3787,6 +3789,7 @@ struct wiphy_iftype_ext_capab {
  * bitmap of  nl80211_band values.  For instance, for
  * NL80211_BAND_2GHZ, bit 0 would be set
  * (i.e. BIT(NL80211_BAND_2GHZ)).
+ * @cumulative_survey: cumulated survey information for all channels.
  */
 struct wiphy {
/* assign these fields before you register the wiphy */
@@ -3921,6 +3924,8 @@ struct wiphy {
 
u8 nan_supported_bands;
 
+   struct survey_info *cumulative_survey;
+
char priv[0] __aligned(NETDEV_ALIGN);
 };
 
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 670aa229..4646769 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -633,6 +633,9 @@ int wiphy_register(struct wiphy *wiphy)
struct ieee80211_supported_band *sband;
bool have_band = false;
int i;
+   int n_channels = 0;
+   int idx = 0;
+
u16 ifmodes = wiphy->interface_modes;
 
 #ifdef CONFIG_PM
@@ -782,6 +785,7 @@ int wiphy_register(struct wiphy *wiphy)
}
 
have_band = true;
+   n_channels += sband->n_channels;
}
 
if (!have_band) {
@@ -866,6 +870,21 @@ int wiphy_register(struct wiphy *wiphy)
}
}
 
+   wiphy->cumulative_survey = kcalloc(n_channels,
+  sizeof(struct survey_info),
+  GFP_KERNEL);
+   if (!wiphy->cumulative_survey)
+   return -ENOMEM;
+
+   for (band = 0; band < NUM_NL80211_BANDS; band++) {
+   sband = wiphy->bands[band];
+   if (!sband)
+   continue;
+   for (i = 0; i < sband->n_channels; i++)
+   wiphy->cumulative_survey[idx++].channel =
+   >channels[i];
+   }
+
rdev->wiphy.registered = true;
rtnl_unlock();
 
@@ -955,6 +974,8 @@ void wiphy_unregister(struct wiphy *wiphy)
 #endif
cfg80211_rdev_free_wowlan(rdev);
cfg80211_rdev_free_coalesce(rdev);
+
+   kfree(wiphy->cumulative_survey);
 }
 EXPORT_SYMBOL(wiphy_unregister);
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index fe27ab4..2f22d74 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8024,11 +8024,13 @@ static int nl80211_dump_survey(struct sk_buff *skb, 
struct netlink_callback *cb)
 {
struct nlattr **attrbuf = genl_family_attrbuf(_fam);
struct survey_info survey;
+   struct survey_info *survey_data = 
struct cfg80211_registered_device *rdev;
struct wireless_dev *wdev;
int survey_idx = cb->args[2];
int res;
bool radio_stats;
+   int n_channels;
 
rtnl_lock();
res = nl80211_prepare_wdev_dump(skb, cb, , );
@@ -8048,7 +8050,12 @@ static int nl80211_dump_survey(struct sk_buff *skb, 
struct netlink_callback *cb)
goto out_err;
}
 
+   n_channels = ieee80211_get_num_supported_channels(wdev->wiphy);
+
while (1) {
+   if (n_channels <= survey_idx)
+   break;
+
res = rdev_dump_survey(rdev, wdev->netdev, survey_idx, );
if (res == -ENOENT)
break;
@@ -8062,10 +8069,35 @@ static int nl80211_dump_survey(struct sk_buff *skb, 
struct netlink_callback *cb)
continue;
}
 
+   if (survey.filled & SURVEY_INFO_NON_ACC_DATA) {
+   struct survey_info *cumulative_survey =
+   >wiphy->cumulative_survey[survey_idx];
+
+   if (cumulative_survey->channel->center_freq !=
+   survey.channel->center_freq) {
+