Add support for setting the S1G monitor channel. For example, to set an operating of 44, 1MHz primary of 43 with a 2MHz primary we'd use: iw dev mon0 set freq_khz 923500 8 924000 2mhz-primary phy#1 Interface mon0 ifindex 5 wdev 0x100000002 addr 0c:bf:74:00:30:fd type monitor channel 43 (923.500 MHz), width: 8 MHz, center1: 924 MHz, pri_2mhz: 1 txpower 30.00 dBm Signed-off-by: Lachlan Hodges --- iw.h | 5 +++-- util.c | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/iw.h b/iw.h index 2155b8d20468..52a17c633b75 100644 --- a/iw.h +++ b/iw.h @@ -114,6 +114,7 @@ struct chandef { unsigned int center_freq1_offset; unsigned int center_freq2; unsigned int punctured; + bool s1g_primary_2mhz; }; #define ARRAY_SIZE(ar) (sizeof(ar)/sizeof(ar[0])) @@ -223,8 +224,8 @@ int parse_keys(struct nl_msg *msg, char **argv[], int *argc); #define PARSE_FREQ_ARGS(pfx, sfx) \ pfx _PARSE_FREQ_ARGS_OPT1 sfx "\n" \ pfx _PARSE_FREQ_ARGS_OPT2 sfx -#define _PARSE_FREQ_KHZ_ARGS_OPT1 " [1MHz|2MHz|4MHz|8MHz|16MHz]" -#define _PARSE_FREQ_KHZ_ARGS_OPT2 " [1|2|4|8|16] [ []]" +#define _PARSE_FREQ_KHZ_ARGS_OPT1 " [1MHz|2MHz|4MHz|8MHz|16MHz] [2mhz-primary]" +#define _PARSE_FREQ_KHZ_ARGS_OPT2 " [1|2|4|8|16] [] [2mhz-primary]" #define PARSE_FREQ_KHZ_ARGS(pfx, sfx) \ pfx _PARSE_FREQ_KHZ_ARGS_OPT1 sfx "\n" \ pfx _PARSE_FREQ_KHZ_ARGS_OPT2 sfx diff --git a/util.c b/util.c index 64bec12487e9..eccdbf3122a9 100644 --- a/util.c +++ b/util.c @@ -507,6 +507,11 @@ enum nl80211_chan_width str_to_bw(const char *str) { .name = "80+80", .val = NL80211_CHAN_WIDTH_80P80, }, { .name = "160", .val = NL80211_CHAN_WIDTH_160, }, { .name = "320", .val = NL80211_CHAN_WIDTH_320, }, + { .name = "1", .val = NL80211_CHAN_WIDTH_1, }, + { .name = "2", .val = NL80211_CHAN_WIDTH_2, }, + { .name = "4", .val = NL80211_CHAN_WIDTH_4, }, + { .name = "8", .val = NL80211_CHAN_WIDTH_8, }, + { .name = "16", .val = NL80211_CHAN_WIDTH_16, }, }; unsigned int i; @@ -552,7 +557,11 @@ static int parse_freqs(struct chandef *chandef, int argc, char **argv, case NL80211_CHAN_WIDTH_4: case NL80211_CHAN_WIDTH_8: case NL80211_CHAN_WIDTH_16: - /* can't happen yet */ + if (!freq_in_khz) { + chandef->width = NL80211_CHAN_WIDTH_20_NOHT; + return 0; + } + need_cf1 = chandef->width != NL80211_CHAN_WIDTH_1; break; } @@ -752,7 +761,7 @@ int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv, /* Set channel width's default value */ if (chandef->control_freq < 1000) - chandef->width = NL80211_CHAN_WIDTH_16; + chandef->width = NL80211_CHAN_WIDTH_1; else chandef->width = NL80211_CHAN_WIDTH_20_NOHT; @@ -785,6 +794,12 @@ int parse_freqchan(struct chandef *chandef, bool chan, int argc, char **argv, _parsed++; } + if (freq_in_khz && argc > _parsed && + strcmp(argv[_parsed], "2mhz-primary") == 0) { + chandef->s1g_primary_2mhz = true; + _parsed++; + } + /* * Either this must consume all args, or users must pass a * valid pointer as 'parsed' and use it to know how many of @@ -850,6 +865,9 @@ int put_chandef(struct nl_msg *msg, struct chandef *chandef) if (chandef->punctured) NLA_PUT_U32(msg, NL80211_ATTR_PUNCT_BITMAP, chandef->punctured); + if (chandef->s1g_primary_2mhz) + NLA_PUT_FLAG(msg, NL80211_ATTR_S1G_PRIMARY_2MHZ); + return 0; nla_put_failure: -- 2.43.0