add "channels" PHY command listing frequencies with more details
PATCH 1/1 add "channels" PHY command listing frequencies with more details
Channels (frequencies) are getting more details that users may want to know about. E.g. it's important to know which frequencies allow using 40/80/160 MHz channels to setup AP properly.
We list channels in "info" command output but it's already quite big and it was agreed to introduce new command rather than expand the old one.
This patch adds "channels" command printing what was already available in the "info" plus details about supported channel widths. It also removes DFS info from the "info" output.
--- info.c | 30 -------------- phy.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 30 deletions(-)
info.c +0 -30
@@ -47,20 +47,6 @@ static char *cipher_name(__u32 c) } } -static char *dfs_state_name (enum nl80211_dfs_state state) -{ -switch (state) { -case NL80211_DFS_USABLE : -return "usable" ; -case NL80211_DFS_AVAILABLE : -return "available" ; -case NL80211_DFS_UNAVAILABLE : -return "unavailable" ; -default : -return "unknown" ; - } -} -static int ext_feature_isset (const unsigned char *ext_features,int ext_features_len,enum nl80211_ext_feature_index ftidx) {
@@ -198,22 +184,6 @@ next:if (open)printf (")" );printf ("\n" ); - -if (!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED ] && tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]) { -enum nl80211_dfs_state state =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]); -unsigned long time; - -printf ("\t\t\t DFS state: %s" ,dfs_state_name (state)); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]) { - time =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]); -printf (" (for %lu sec)" , time/1000 ); - } -printf ("\n" ); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ]) -printf ("\t\t\t DFS CAC time: %u ms\n" , -nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ])); - } - } }
phy.c +143 -0
149 lines not on this page · raw message
Signature · 1 line
1.8.4.5
Quoted 10 lines · Rafał Miłecki
Channels (frequencies) are getting more details that users may want to
know about. E.g. it's important to know which frequencies allow using 40/80/160 MHz channels to setup AP properly.We list channels in "info" command output but it's already quite big and
it was agreed to introduce new command rather than expand the old one.
Quoted 4 lines
This patch adds "channels" command printing what was already available
in the "info" plus details about supported channel widths. It also removes DFS info from the "info" output.
Very nice.
Unfortunately, I get compiler warnings about width_* being possibly used uninitialized. Can you address that please?
Quoted 2 lines
+TOPLEVEL(channels, NULL,
NL80211_CMD_GET_WIPHY, 0,CIB_PHY,handle_channels, "Show available channels.");
Maybe that should be allowed for a CIB_DEV too?
johannes
Quoted 16 lines · Johannes Berg
Quoted 10 lines · Rafał Miłecki
Channels (frequencies) are getting more details that users may want to
know about. E.g. it's important to know which frequencies allow using 40/80/160 MHz channels to setup AP properly.We list channels in "info" command output but it's already quite big and
it was agreed to introduce new command rather than expand the old one.Quoted 4 lines
This patch adds "channels" command printing what was already available
in the "info" plus details about supported channel widths. It also removes DFS info from the "info" output.
Quoted 4 lines
Very nice.
Unfortunately, I get compiler warnings about width_* being possibly used uninitialized. Can you address that please?
It's nice your compiled got this mistake, my didn't. There were actually meant to be static. I'll fix that.
Quoted 4 lines
Quoted 2 lines
+TOPLEVEL(channels, NULL,
NL80211_CMD_GET_WIPHY, 0,CIB_PHY,handle_channels, "Show available channels.");Maybe that should be allowed for a
CIB_DEVtoo?
Since this is PHY specific, I was thinking it should be CIB_PHY. I didn't see reason to allow querying devices. Similarly we don't support "iw dev wlan0 reg get".
Anyway, I can change that if you think it's better for some reason. Any hint how to make command usable with both: phy and dev?
Signature · 1 line
Rafał
Quoted 4 lines · Rafał Miłecki
Quoted 2 lines
Unfortunately, I get compiler warnings about width_* being possibly used uninitialized. Can you address that please?
It's nice your compiled got this mistake, my didn't. There were actually meant to be static. I'll fix that.
I actually think the compiler is wrong, and there's no reason for them to be static, is there?
The first iteration of the loop should always initialize since -1 is used for initialization?
In any case, I'd prefer to avoid static, if necessary pass some kind of context structure in to the function?
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
+TOPLEVEL(channels, NULL,
NL80211_CMD_GET_WIPHY, 0,CIB_PHY,handle_channels, "Show available channels.");Maybe that should be allowed for a
CIB_DEVtoo?Since this is PHY specific, I was thinking it should be
CIB_PHY. I didn't see reason to allow querying devices. Similarly we don't support "iw dev wlan0 reg get".Anyway, I can change that if you think it's better for some reason.
I was just thinking that supporting it with wlan0 would in certain cases make it easier for the user (not having to look up the phy number)
Quoted 1 line
Any hint how to make command usable with both: phy and dev?
Just add:
TOPLEVEL(channels, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NETDEV, ...);
johannes
Quoted 7 lines · Johannes Berg
Quoted 4 lines · Rafał Miłecki
Quoted 2 lines
Unfortunately, I get compiler warnings about width_* being possibly used uninitialized. Can you address that please?
It's nice your compiled got this mistake, my didn't. There were actually meant to be static. I'll fix that.
Quoted 8 lines
I actually think the compiler is wrong, and there's no reason for them to be static, is there?
The first iteration of the loop should always initialize since -1 is used for initialization?
In any case, I'd prefer to avoid static, if necessary pass some kind of context structure in to the function?
I don't know if we can assume getting all three attributes:NL80211_BAND_ATTR_HT_CAPANL80211_BAND_ATTR_VHT_CAPANL80211_BAND_ATTR_FREQS
at the same single handler call. I guess not. That's why I believe we need all width_* to be static, so they keep value across separated handler calls.
Quoted 13 lines
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
+TOPLEVEL(channels, NULL,
NL80211_CMD_GET_WIPHY, 0,CIB_PHY,handle_channels, "Show available channels.");Maybe that should be allowed for a
CIB_DEVtoo?Since this is PHY specific, I was thinking it should be
CIB_PHY. I didn't see reason to allow querying devices. Similarly we don't support "iw dev wlan0 reg get".Anyway, I can change that if you think it's better for some reason.
I was just thinking that supporting it with wlan0 would in certain cases make it easier for the user (not having to look up the phy number)
Quoted 5 lines
Quoted 1 line
Any hint how to make command usable with both: phy and dev?
Just add:
TOPLEVEL(channels, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NETDEV, ...);
But this will disallow using "iw phy phy0 channels". I'd prefer to have this one working in the first place and having "iw dev wlan0 channels" as an alternative. Is there a way to achieve that easily?
Signature · 1 line
Rafał
Quoted 17 lines · Rafał Miłecki
Quoted 7 lines · Johannes Berg
Quoted 4 lines · Rafał Miłecki
Quoted 2 lines
Unfortunately, I get compiler warnings about width_* being possibly used uninitialized. Can you address that please?
It's nice your compiled got this mistake, my didn't. There were actually meant to be static. I'll fix that.
Quoted 8 lines
I actually think the compiler is wrong, and there's no reason for them to be static, is there?
The first iteration of the loop should always initialize since -1 is used for initialization?
In any case, I'd prefer to avoid static, if necessary pass some kind of context structure in to the function?
Quoted 7 lines
I don't know if we can assume getting all three attributes:
NL80211_BAND_ATTR_HT_CAPANL80211_BAND_ATTR_VHT_CAPANL80211_BAND_ATTR_FREQS
at the same single handler call. I guess not. That's why I believe we need all width_* to be static, so they keep value across separated handler calls.
Yes, this is definitely the case. I did some debugging from user space and printed one line per a single handler call:
[i:0] WIPHY_BANDS:0
[i:1] WIPHY_BANDS:0
[i:2] WIPHY_BANDS:0
[i:3] WIPHY_BANDS:1 ATTR_HT_CAPA:1 ATTR_VHT_CAPA:0 ATTR_FREQS:0 [i:4] WIPHY_BANDS:1 ATTR_HT_CAPA:1 ATTR_VHT_CAPA:1 ATTR_FREQS:0 [i:5] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:6] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:7] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:8] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:9] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:10] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:11] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:12] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 [i:13] WIPHY_BANDS:1 ATTR_HT_CAPA:0 ATTR_VHT_CAPA:0 ATTR_FREQS:1 (...)
As you can see we have ATTR_HT_CAPA and ATTR_VHT_CAPA set only in few early calls. It means we need to extract info from them and store it in static variables.
PATCH v2 1/1 add "channels" PHY command listing frequencies with more details
In reply to Rafał MiłeckiChannels (frequencies) are getting more details that users may want to know about. E.g. it's important to know which frequencies allow using 40/80/160 MHz channels to setup AP properly.
We list channels in "info" command output but it's already quite big and it was agreed to introduce new command rather than expand the old one.
This patch adds "channels" command printing what was already available in the "info" plus details about supported channel widths. It also removes DFS info from the "info" output.
---
V2: Make width_40, width_80 & width_160 variables static. This is needed
to keep their values across separated handler calls.
--- info.c | 30 -------------- phy.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+), 30 deletions(-)
info.c +0 -30
@@ -47,20 +47,6 @@ static char *cipher_name(__u32 c) } } -static char *dfs_state_name (enum nl80211_dfs_state state) -{ -switch (state) { -case NL80211_DFS_USABLE : -return "usable" ; -case NL80211_DFS_AVAILABLE : -return "available" ; -case NL80211_DFS_UNAVAILABLE : -return "unavailable" ; -default : -return "unknown" ; - } -} -static int ext_feature_isset (const unsigned char *ext_features,int ext_features_len,enum nl80211_ext_feature_index ftidx) {
@@ -198,22 +184,6 @@ next:if (open)printf (")" );printf ("\n" ); - -if (!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED ] && tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]) { -enum nl80211_dfs_state state =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]); -unsigned long time; - -printf ("\t\t\t DFS state: %s" ,dfs_state_name (state)); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]) { - time =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]); -printf (" (for %lu sec)" , time/1000 ); - } -printf ("\n" ); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ]) -printf ("\t\t\t DFS CAC time: %u ms\n" , -nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ])); - } - } }
phy.c +143 -0
149 lines not on this page · raw message
Signature · 1 line
1.8.4.5
phy.c line 34
Quoted 5 lines · Rafał Miłecki
phy.c +4
-0+static int print_channels_handler (struct nl_msg *msg,void *arg) +{ +struct genlmsghdr *gnlh =nlmsg_data (nlmsg_hdr (msg)); +
extra blank line
phy.c line 42
Quoted 8 lines
phy.c +8
-0+struct nlattr *tb_msg[NL80211_ATTR_MAX +1 ]; +struct nlattr *tb_band[NL80211_BAND_ATTR_MAX +1 ]; +struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX +1 ]; +struct nlattr *nl_band; +struct nlattr *nl_freq; +int rem_band, rem_freq; +static int last_band =-1 ; +static bool width_40, width_80, width_160;
You shouldn't make them static - make a little struct containing them, and pass it as "arg"
phy.c line 150
Quoted 4 lines
+static int handle_channels(struct
nl80211_state*state, structnl_msg*msg,phy.c +2
-0+ int argc, char **argv, enum id_input id) +{
struct ... xyz = {};
phy.c line 154
Quoted 4 lines
phy.c +4
-0+nla_put_flag (msg,NL80211_ATTR_SPLIT_WIPHY_DUMP ); +nlmsg_hdr (msg)->nlmsg_flags |=NLM_F_DUMP ; + +register_handler (print_channels_handler,NULL );
register_handler(..., &xyz);
johannes
PATCH v3 1/1 add "channels" PHY command listing frequencies with more details
In reply to Rafał MiłeckiChannels (frequencies) are getting more details that users may want to know about. E.g. it's important to know which frequencies allow using 40/80/160 MHz channels to setup AP properly.
We list channels in "info" command output but it's already quite big and it was agreed to introduce new command rather than expand the old one.
This patch adds "channels" command printing what was already available in the "info" plus details about supported channel widths. It also removes DFS info from the "info" output.
---
V2: Make width_40, width_80 & width_160 variables static. This is needed
to keep their values across separated handler calls.
V3: Introduce struct channels_ctx to avoid multiple static variables in
a print_channels_handler.
--- info.c | 30 ------------- phy.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 30 deletions(-)
info.c +0 -30
@@ -47,20 +47,6 @@ static char *cipher_name(__u32 c) } } -static char *dfs_state_name (enum nl80211_dfs_state state) -{ -switch (state) { -case NL80211_DFS_USABLE : -return "usable" ; -case NL80211_DFS_AVAILABLE : -return "available" ; -case NL80211_DFS_UNAVAILABLE : -return "unavailable" ; -default : -return "unknown" ; - } -} -static int ext_feature_isset (const unsigned char *ext_features,int ext_features_len,enum nl80211_ext_feature_index ftidx) {
@@ -198,22 +184,6 @@ next:if (open)printf (")" );printf ("\n" ); - -if (!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED ] && tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]) { -enum nl80211_dfs_state state =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE ]); -unsigned long time; - -printf ("\t\t\t DFS state: %s" ,dfs_state_name (state)); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]) { - time =nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_TIME ]); -printf (" (for %lu sec)" , time/1000 ); - } -printf ("\n" ); -if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ]) -printf ("\t\t\t DFS CAC time: %u ms\n" , -nla_get_u32 (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME ])); - } - } }
phy.c +152 -0
158 lines not on this page · raw message
Signature · 1 line
1.8.4.5