Skip to contentSkip to conversation

cfg80211: survey report capability

RFC In review Holger Schurig 2 participants 6 messages Nov 10, 2009 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

RFC 1/1 cfg80211: survey report capability

[RFC] cfg80211: first stab at channel survey

This patch implements the NL80211_CMD_GET_SURVEY command and an get_survey() ops that a driver can implement. The goal of this command is to allow a driver to report back channel survey data (e.g. channel noise, channel occupation) back to cfg80211 and thus via nl80211 to user-space.

In future, they will either be a survey-trigger command --- or the existing scan-trigger command will be enhanced. However, the get_survey() operation is usable even in absence of this: a driver can report the channel noise in mBm with the implemented mechanism.

get_survey() is currently modelled like get_key(). I hope that's right.

struct survey_info is modelled like struct station_info. This allows different drivers to fill in different fields.

include/linux/nl80211.h +8 -0
@@ -159,6 +159,8 @@
  *	NL80211_CMD_GET_SCAN and on the "scan" multicast group)
  * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons,
  *	partial scan results may be available
+ * @NL80211_CMD_GET_SURVEY: get survey resuls, e.g. channel occupation
+ *      or noise level
  *
  * @NL80211_CMD_REG_CHANGE: indicates to userspace the regulatory domain
  * 	has been changed and provides details of the request information
@@ -341,6 +343,8 @@
 
 	NL80211_CMD_SET_WIPHY_NETNS,
 
+	NL80211_CMD_GET_SURVEY,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -584,6 +588,8 @@
  *	changed then the list changed and the dump should be repeated
  *	completely from scratch.
  *
+ * @NL80211_CHANNEL_NOISE: Noise on channel in mBm
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -714,6 +720,8 @@
 
 	NL80211_ATTR_PID,
 
+	NL80211_ATTR_NOISE,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +35 -0
@@ -232,6 +232,35 @@
 	u32 cipher;
 };
 
+/** enum survey_info_flags - survey information flags
+ *
+ * Used by the driver to indicate which info in &struct survey_info
+ * it has filled in during the get_survey().
+ */
+enum survey_info_flags {
+	SURVEY_INFO_CHANNEL = 1<<0,
+	SURVEY_INFO_NOISE = 1<<1,
+};
+
+/**
+ * struct survey_info - channel survey response
+ *
+ * Used from the get_survey() callback to report back
+ * per-channel survey information.
+ *
+ * @filled: bitflag of flags from &enum survey_info_flags
+ * @noise: channel noise in mBm
+ * @channel: the channel this survey record reports
+ *
+ * This structure can later be expanded with things like
+ * channel duty cycles etc.
+ */
+struct survey_info {
+	u32 filled;
+	struct ieee80211_channel *channel;
+	s8 noise;
+};
+
 /**
  * struct beacon_parameters - beacon parameters
  *
@@ -941,6 +970,8 @@
  * @rfkill_poll: polls the hw rfkill line, use cfg80211 reporting
  *	functions to adjust rfkill hw state
  *
+ * @get_survey: get site survey information about.
+ *
  * @testmode_cmd: run a test mode command
  */
 struct cfg80211_ops {
@@ -1060,6 +1091,10 @@
 				    const u8 *peer,
 				    const struct cfg80211_bitrate_mask *mask);
 
+	int	(*get_survey)(struct wiphy *wiphy, struct net_device *netdev,
+			void *cookie,
+			void (*callback)(void *cookie, struct survey_info*));
+
 	/* some temporary stuff to finish wext */
 	int	(*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev,
 				  bool enabled, int timeout);
net/wireless/nl80211.c +154 -0

166 lines not on this page · raw message

--
http://www.holgerschurig.de

#1 lore raw

At Tue, 10 Nov 2009 10:48:01 +0100,

Quoted 10 lines · Holger Schurig
include/linux/nl80211.h +2 -0
@@ -584,6 +588,8 @@
  *	changed then the list changed and the dump should be repeated
  *	completely from scratch.
  *
+ * @NL80211_CHANNEL_NOISE: Noise on channel in mBm
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */

include/linux/nl80211.h line 727

Quoted 8 lines
include/linux/nl80211.h +2 -0
@@ -714,6 +720,8 @@
 
 	NL80211_ATTR_PID,
 
+	NL80211_ATTR_NOISE,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,

Oops, the comment in the kdoc doesn't match the enum.

--
http://www.holgerschurig.de

maintainer
#2 lore raw
In reply to Holger Schurig
Quoted 1 line · Holger Schurig

+/** enum survey_info_flags - survey information flags

Nit: missing newline

include/net/cfg80211.h line 242

Quoted 7 lines

+ *
+ * Used by the driver to indicate which info in &struct survey_info
+ * it has filled in during the get_survey().
+ */

include/net/cfg80211.h +3 -0
+enum survey_info_flags {
+	SURVEY_INFO_CHANNEL = 1<<0,
+	SURVEY_INFO_NOISE = 1<<1,

A response w/o a channel seems entirely useless, shouldn't we just require a channel?

include/net/cfg80211.h line 261

Quoted 11 lines

+ * @filled: bitflag of flags from &enum survey_info_flags
+ * @noise: channel noise in mBm
+ * @channel: the channel this survey record reports
+ *
+ * This structure can later be expanded with things like
+ * channel duty cycles etc.
+ */

include/net/cfg80211.h +4 -0
+struct survey_info {
+	u32 filled;
+	struct ieee80211_channel *channel;
+	s8 noise;

For mBm, an s8 won't be enough I think? -90 dBm == -9000 mBm?

Quoted 5 lines
net/wireless/nl80211.c +5 -0
+static void get_survey_callback(void *c, struct survey_info *params)
+{
+	struct get_survey_cookie *cookie = c;
+
+	if (params->filled & SURVEY_INFO_CHANNEL)

net/wireless/nl80211.c line 3260

Quoted 10 lines
net/wireless/nl80211.c +10 -0
+		if (nl80211_msg_put_channel(cookie->msg, params->channel))
+			goto nla_put_failure;
+
+	if (params->filled & SURVEY_INFO_NOISE)
+		NLA_PUT_U32(cookie->msg, NL80211_ATTR_NOISE,
+			params->noise);
+
+ nla_put_failure:
+	cookie->error = 1;
+}

You need to construct a nested attribute here and put the values into it so that the callback can be invoked multiple times, once for each channel. OTOH, when there are many many channels that will overrun the message size at some point and we'll pull our hair (like we're doing now with the channel list in phy info) ... so I'd prefer you move this to a dump-style model like dump_stations has.

Right now you're retrieving a single channel but can't even control which one. Maybe that's useful functionality in addition to dump when you _can_ ask for information on a specific channel, but that'd have to pass in the frequency from userspace.

Retrieving all data like you've implemented (though I guess you forgot the multiple channels case) should be a dump. Maybe that's sufficient since there won't be huge amounts of data and userspace can just pick out what it needs from the dump.

johannes

maintainer
#3 lore raw
Quoted 9 lines · Johannes Berg

Right now you're retrieving a single channel but can't even control which one. Maybe that's useful functionality in addition to dump when you _can_ ask for information on a specific channel, but that'd have to pass in the frequency from userspace.

Retrieving all data like you've implemented (though I guess you forgot the multiple channels case) should be a dump. Maybe that's sufficient since there won't be huge amounts of data and userspace can just pick out what it needs from the dump.

And maybe the get_survey() driver call can actually pass in the channel pointer ... then the drivers/mac80211 don't need to implement both get_survey() and dump_survey() since cfg80211 knows the valid channel list anyway. But that means iterating over the channel list all the time, even if the driver can only return values for a single channel.

johannes

#4 lore raw
In reply to Johannes Berg
Quoted 1 line

Nit: missing newline

Done

Quoted 6 lines

include/net/cfg80211.h line 242

Quoted 3 lines
include/net/cfg80211.h +3 -0
+enum survey_info_flags {
+	SURVEY_INFO_CHANNEL = 1<<0,
+	SURVEY_INFO_NOISE = 1<<1,

A response w/o a channel seems entirely useless, shouldn't we just require a channel?

Hey, libertas could respond just the noise and no channel. But it could then also respond with the channel, it's there anyway.

Quoted 1 line

For mBm, an s8 won't be enough I think? -90 dBm == -9000 mBm?

Oh, sure.

Quoted 6 lines

You need to construct a nested attribute here and put the values into it so that the callback can be invoked multiple times, once for each channel. OTOH, when there are many many channels that will overrun the message size at some point and we'll pull our hair (like we're doing now with the channel list in phy info) ... so I'd prefer you move this to a dump-style model like dump_stations has.

Okay.

Or maybe a little bit more nl80211_dump_scan.

Quoted 2 lines

Right now you're retrieving a single channel but can't even control which one.

Idea was to retrieve as many channels as the drivers sends using the callback.

Controlling what should be returned should be done after either enhancing scan-trigger or writing a new survey-trigger command. So survey-dump would be very similar to scan-dump: return as much data as is available (and not stale).

And this could very well be only one channel. And in absence of survey-trigger or an enhanced-scan trigger it will certainly only report info about the current channel.

Quoted 3 lines

Maybe that's useful functionality in addition to dump when you _can_ ask for information on a specific channel, but that'd have to pass in the frequency from userspace.

Would this then be useful for the scan-dump command as well?

Quoted 2 lines

Retrieving all data like you've implemented (though I guess you forgot the multiple channels case) should be a dump.

I did not forgot about the multi-channel case, I forgot about the nesting. /me's still learning nl80211 :-)

maintainer
#5 lore raw
Quoted 9 lines · Holger Schurig
Quoted 6 lines

include/net/cfg80211.h line 242

Quoted 3 lines
include/net/cfg80211.h +3 -0
+enum survey_info_flags {
+	SURVEY_INFO_CHANNEL = 1<<0,
+	SURVEY_INFO_NOISE = 1<<1,

A response w/o a channel seems entirely useless, shouldn't we just require a channel?

Hey, libertas could respond just the noise and no channel. But it could then also respond with the channel, it's there anyway.

But for the multi-channel use case, not having a channel will mean userspace has no idea what the value means ... it's useless without a channel I think.

Quoted 4 lines

Controlling what should be returned should be done after either enhancing scan-trigger or writing a new survey-trigger command. So survey-dump would be very similar to scan-dump: return as much data as is available (and not stale).

Right.

Quoted 5 lines
Quoted 3 lines

Maybe that's useful functionality in addition to dump when you _can_ ask for information on a specific channel, but that'd have to pass in the frequency from userspace.

Would this then be useful for the scan-dump command as well?

Not sure .. would you want to get scan results for just a single channel? But we can always add that later if we wanted to, I don't think it makes a whole lot of sense for either of them.

Quoted 5 lines
Quoted 2 lines

Retrieving all data like you've implemented (though I guess you forgot the multiple channels case) should be a dump.

I did not forgot about the multi-channel case, I forgot about the nesting. /me's still learning nl80211 :-)

:)

johannes