linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2 5/6] mac80211: Add more ethtools stats: survey, rates, etc
Date: Tue, 17 Apr 2012 20:31:27 -0700	[thread overview]
Message-ID: <4F8E358F.1020501@candelatech.com> (raw)
In-Reply-To: <1334713300.3725.18.camel@jlt3.sipsolutions.net>

On 04/17/2012 06:41 PM, Johannes Berg wrote:
> On Tue, 2012-04-17 at 10:46 -0700, greearb@candelatech.com wrote:
>> +	/* Get survey stats for current channel */
>> +	survey.filled = 0;
>> +	if (drv_get_survey(local, 0,&survey) != 0) {
>> +		survey.filled = 0;
>> +		data[i++] = 0;
>> +	} else {
>> +		/* ath9k (and maybe others??) only updates internal stats
>> +		 * when you get channel index 0, so if
>> +		 * we are NOT on channel zero, get the real stats
>> +		 * now.
>> +		 */
>> +		int ch_idx = ieee80211_get_channel_idx(local->hw.wiphy,
>> +			local->oper_channel->center_freq);
>> +		if (ch_idx == 0) {
>> +			data[i++] = survey.channel->center_freq;
>> +		} else {
>> +			survey.filled = 0;
>> +			if (drv_get_survey(local, ch_idx,&survey) != 0) {
>> +				survey.filled = 0;
>> +				data[i++] = 0;
>> +			} else {
>> +				data[i++] = survey.channel->center_freq;
>> +			}
>> +		}
>> +	}
>
> This is completely incomprehensible to me. I don't think the channel
> index is what you think it is?

It is ugly, but as far as I can tell it works.  The survey method
wants an index, not channel number or frequency, from what I can tell
(I just looked at and tested ath9k).

Based on the freq returned as part of the survey results, the logic
above appears to function as I would hope.

That said, a new get-survey() method that took a channel object instead of an
index would make this code cleaner.  Or, we could store the channel
index in the channel object for fast lookup, but I was afraid storing the
index would be too risky in case channels are ever moved around for some reason
or another.

And, I could be missing something yet....

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

  reply	other threads:[~2012-04-18  3:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 17:46 [PATCH v2 0/6] Add ethtool stats support for Wireless Devices greearb
2012-04-17 17:46 ` [PATCH v2 1/6] cfg80211: Add framework to support ethtool stats greearb
2012-04-17 17:46 ` [PATCH v2 2/6] mac80211: Support getting sta_info stats via ethtool greearb
2012-04-18  1:37   ` Johannes Berg
2012-04-18  3:46     ` Ben Greear
2012-04-18  4:00       ` Johannes Berg
2012-04-18 16:27         ` Ben Greear
2012-04-18 22:39           ` Johannes Berg
2012-04-18 22:59             ` Ben Greear
2012-04-19  4:38               ` Johannes Berg
2012-04-17 17:46 ` [PATCH v2 3/6] mac80211: Framework to get wifi-driver " greearb
2012-04-17 17:46 ` [PATCH v2 4/6] wireless: Add util method to get channel index from frequency greearb
2012-04-18  1:40   ` Johannes Berg
2012-04-18  3:36     ` Ben Greear
2012-04-17 17:46 ` [PATCH v2 5/6] mac80211: Add more ethtools stats: survey, rates, etc greearb
2012-04-18  1:41   ` Johannes Berg
2012-04-18  3:31     ` Ben Greear [this message]
2012-04-18  4:05       ` Johannes Berg
2012-04-18 16:19         ` Ben Greear
2012-04-18 22:40           ` Johannes Berg
2012-04-18 22:54             ` Ben Greear
2012-04-19  4:37               ` Johannes Berg
2012-04-17 17:46 ` [PATCH v2 6/6] mac80211: Add sta_state to ethtool stats greearb
2012-04-18  1:42   ` Johannes Berg
2012-04-18  1:44 ` [PATCH v2 0/6] Add ethtool stats support for Wireless Devices Johannes Berg
2012-04-18  3:56   ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F8E358F.1020501@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).