wifi: correctly represent S1G channels
Subsystems (2)
v2 cover wifi: correctly represent S1G channels
This patchset correctly supports S1G channels within cfg80211 and mac80211. Preliminary discussion can be found in [1] and the v1 RFC can be found in [2].
The goal is to align how S1G channels are represented within the chandef and validated throughout cfg80211 with how VHT is done. The S1G PHY is based on the VHT PHY, just at 1/10th the clock rate. There is, however, the introduction of 2MHz primary channels. This allow S1G interfaces to operate with either a 1MHz or 2MHz primary channel.
Changes since v1:
1. Do not remove the IEEE80211_CHAN_1/2/4... flags, instead add our new flags to the end of the enum to ensure we don't break ABI. Same goes for the NL80211_FREQUENCY_ATTR_1/2/4... flags.
2. Don't declare local variables within the switch statement in cfg80211_chandef_valid() to prevent clang compiler warnings. Also rename control_khz to control_freq_khz to make it clearer why we have both control_freq and control_freq_khz.
3. Move some variable declarations into the chandef->s1g_primary_2mhz scope within cfg80211_s1g_usable()
4. Move brace to end of line when using for_each_s1g_subchan
5. Validate that the s1g_primary_2mhz flag is not set when we aren't an S1G interface within cfg80211_chandef_valid()
6. Since we aren't removing the flags anymore, we can remove ieee80211_s1g_channel_width() entirely in the last patch. Unfortunately removing it beforehand breaks the incremental build process since mac80211 still uses it in patch 1.
7. use u8_get_bits instead of FIELD_GET
8. If an error occurs when parsing the S1G operation element within ieee80211_determine_ap_chan(), ensure we fallback to 1MHz width and 1MHz primary instead of WARN_ON.
lachlan
[1] https://lore.kernel.org/linux-wireless/xu4ftmpdwwpokw6exaprrv6wleptq7ggleiluiu6x2dzqbqfhv@6s4m3okiohzw/
[2] https://lore.kernel.org/linux-wireless/[email protected]/T/#mdb626caa000b7a1585e82856f32b5eecde9e6557
Lachlan Hodges (3):
wifi: cfg80211: correctly implement and validate S1G chandef
wifi: mac80211: correctly initialise S1G chandef for STA
wifi: cfg80211: remove ieee80211_s1g_channel_width
include/linux/ieee80211.h | 18 +++++- include/net/cfg80211.h | 105 +++++++++++++++++++++++++++++++---- include/uapi/linux/nl80211.h | 14 +++++ net/mac80211/ieee80211_i.h | 3 +- net/mac80211/main.c | 6 +- net/mac80211/mlme.c | 53 ++++++++++++++++-- net/mac80211/scan.c | 13 +++-- net/mac80211/util.c | 39 ++++++++++--- net/wireless/chan.c | 103 +++++++++++++++++++++++----------- net/wireless/nl80211.c | 38 ++++++++----- net/wireless/reg.c | 76 ++++++++----------------- net/wireless/util.c | 27 --------- 12 files changed, 334 insertions(+), 161 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 wifi: cfg80211: correctly implement and validate S1G chandef
Currently, the S1G channelisation implementation differs from that of VHT, which is the PHY that S1G is based on. The major difference between the clock rate is 1/10th of VHT. However how their channelisation is represented within cfg80211 and mac80211 vastly differ.
To rectify this, remove the use of IEEE80211_CHAN_1/2/4.. flags that were previously used to indicate the control channel width, however it should be implied that the control channels are 1MHz in the case of S1G. Additionally, introduce the invert - being IEEE80211_CHAN_NO_4/8/16MHz - that imply the control channel may not be used for a certain bandwidth. With these new flags, we can perform regulatory and chandef validation just as we would for VHT.
To deal with the notion that S1G PHYs may contain a 2MHz primary channel, introduce a new variable, s1g_primary_2mhz, which indicates whether we are operating on a 2MHz primary channel. In this case, the chandef::chan points to the 1MHz primary channel pointed to by the primary channel location. Alongside this, introduce some new helper routines that can extract the sibling 1MHz channel. The sibling being the alternate 1MHz primary subchannel within the 2MHz primary channel that is not pointed to by chandef::chan.
Furthermore, due to unique restrictions imposed on S1G PHYs, introduce a new flag, IEEE80211_CHAN_S1G_NO_PRIMARY, which states that the 1MHz channel cannot be used as a primary channel. This is assumed to be set by vendors as it is hardware and regdom specific, When we validate a 2MHz primary channel, we need to ensure both 1MHz subchannels do not contain this flag. If one or both of the 1MHz subchannels contain this flag then the 2MHz primary is not permitted for use as a primary channel.
Properly integrate S1G channel validation such that it is implemented according with other PHY types such as VHT. Additionally, implement a new S1G-specific regulatory flag to allow cfg80211 to understand specific vendor requirements for S1G PHYs.
---
v1 -> v2:
1. Dont remove existing IEEE80211_CHAN_1/2/4... flags. Same for NL80211_FREQUENCY_ATTR_1/2/4...
2. Don't declare local variables in the switch statement to prevent clang compiler warning
3. Move some variables declarations into smaller scope in cfg80211_s1g_usable()
4. Move braces to end of line when using for_each_s1g_subchan
5. Ensure non-s1g interfaces don't set s1g_primary_2mhz flag within cfg80211_chandef_valid()
--- include/net/cfg80211.h | 95 ++++++++++++++++++++++++++++++++ include/uapi/linux/nl80211.h | 14 +++++ net/wireless/chan.c | 103 ++++++++++++++++++++++++----------- net/wireless/nl80211.c | 38 ++++++++----- net/wireless/reg.c | 76 ++++++++------------------ 5 files changed, 225 insertions(+), 101 deletions(-)
include/net/cfg80211.h +95 -0
@@ -129,6 +129,13 @@ struct wiphy;* with very low power (VLP), even if otherwise set to NO_IR. * @IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY: Allow activity on a 20 MHz channel, * even if otherwise set to NO_IR. +* @IEEE80211_CHAN_S1G_NO_PRIMARY: Prevents the channel for use as an S1G +* primary channel. Does not prevent the wider operating channel +* described by the chandef from being used. In order for a 2MHz primary +* to be used, both 1MHz subchannels shall not contain this flag. +* @IEEE80211_CHAN_NO_4MHZ: 4 MHz bandwidth is not permitted on this channel. +* @IEEE80211_CHAN_NO_8MHZ: 8 MHz bandwidth is not permitted on this channel. +* @IEEE80211_CHAN_NO_16MHZ: 16 MHz bandwidth is not permitted on this channel. */ enum ieee80211_channel_flags {IEEE80211_CHAN_DISABLED =BIT (0 ),
@@ -158,6 +165,10 @@ enum ieee80211_channel_flags {IEEE80211_CHAN_CAN_MONITOR =BIT (24 ),IEEE80211_CHAN_ALLOW_6GHZ_VLP_AP =BIT (25 ),IEEE80211_CHAN_ALLOW_20MHZ_ACTIVITY =BIT (26 ), +IEEE80211_CHAN_S1G_NO_PRIMARY =BIT (27 ), +IEEE80211_CHAN_NO_4MHZ =BIT (28 ), +IEEE80211_CHAN_NO_8MHZ =BIT (29 ), + IEEE80211_CHAN_NO_16MHZ = BIT(30), };#define IEEE80211_CHAN_NO_HT40 \
@@ -821,6 +832,9 @@ struct key_params {* @punctured: mask of the punctured 20 MHz subchannels, with * bits turned on being disabled (punctured); numbered * from lower to higher frequency (like in the spec) +* @s1g_primary_2mhz: Indicates if the control channel pointed to +* by 'chan' exists as a 1MHz primary subchannel within an +* S1G 2MHz primary channel. */ struct cfg80211_chan_def {struct ieee80211_channel *chan;
@@ -830,6 +844,7 @@ struct cfg80211_chan_def {struct ieee80211_edmg edmg;u16 freq1_offset;u16 punctured; +bool s1g_primary_2mhz; };/*
@@ -990,6 +1005,18 @@ cfg80211_chandef_is_edmg(const struct cfg80211_chan_def *chandef)return chandef->edmg.channels || chandef->edmg.bw_config; } +/** +* cfg80211_chandef_is_s1g - check if chandef represents an S1G channel +* @chandef: the channel definition +* +* Return: %true if S1G. +*/ +static inline bool +cfg80211_chandef_is_s1g (const struct cfg80211_chan_def *chandef) +{ +return chandef->chan->band ==NL80211_BAND_S1GHZ ; +} +/** * cfg80211_chandef_compatible - check if two channel definitions are compatible * @chandef1: first channel definition
@@ -10052,4 +10079,72 @@ ssize_t wiphy_locked_debugfs_write(struct wiphy *wiphy, struct file *file, void *data);#endif +/** +* cfg80211_s1g_get_start_freq_khz - get S1G chandef start frequency +* @chandef: the chandef to use +* +* Return: the chandefs starting frequency in KHz +*/ +static inline u32 +cfg80211_s1g_get_start_freq_khz (const struct cfg80211_chan_def *chandef) +{ +u32 bw_mhz =cfg80211_chandef_get_width (chandef); +u32 center_khz = +MHZ_TO_KHZ (chandef->center_freq1) + chandef->freq1_offset; +return center_khz - bw_mhz *500 +500 ; +} + +/** +* cfg80211_s1g_get_end_freq_khz - get S1G chandef end frequency +* @chandef: the chandef to use +* +* Return: the chandefs ending frequency in KHz +*/ +static inline u32 +cfg80211_s1g_get_end_freq_khz (const struct cfg80211_chan_def *chandef) +{ +u32 bw_mhz =cfg80211_chandef_get_width (chandef); +u32 center_khz = +MHZ_TO_KHZ (chandef->center_freq1) + chandef->freq1_offset; +return center_khz + bw_mhz *500 -500 ; +} + +/** +* cfg80211_s1g_get_primary_sibling - retrieve the sibling 1MHz subchannel +* for an S1G chandef using a 2MHz primary channel. +* @wiphy: wiphy the channel belongs to +* @chandef: the chandef to use +* +* When chandef::s1g_primary_2mhz is set to true, we are operating on a 2MHz +* primary channel. The 1MHz subchannel designated by the primary channel +* location exists within chandef::chan, whilst the 'sibling' is denoted as +* being the other 1MHz subchannel that make up the 2MHz primary channel. +* +* Returns: the sibling 1MHz &struct ieee80211_channel, or %NULL on failure. +*/ +static inline struct ieee80211_channel * +cfg80211_s1g_get_primary_sibling (struct wiphy *wiphy, +const struct cfg80211_chan_def *chandef) +{ +int width_mhz =cfg80211_chandef_get_width (chandef); +u32 pri_1mhz_khz, sibling_1mhz_khz, op_low_1mhz_khz, pri_index; + +if (!chandef->s1g_primary_2mhz || width_mhz <2 ) +return NULL ; + + pri_1mhz_khz =ieee80211_channel_to_khz (chandef->chan); + op_low_1mhz_khz =cfg80211_s1g_get_start_freq_khz (chandef); + +/* +* Compute the index of the primary 1 MHz subchannel within the +* operating channel, relative to the lowest 1 MHz center frequency. +* Flip the least significant bit to select the even/odd sibling, +* then translate that index back into a channel frequency. +*/ + pri_index = (pri_1mhz_khz - op_low_1mhz_khz) /1000 ; + sibling_1mhz_khz = op_low_1mhz_khz + ((pri_index ^1 ) *1000 ); + +return ieee80211_get_channel_khz (wiphy, sibling_1mhz_khz); +} +#endif /* __NET_CFG80211_H */
include/uapi/linux/nl80211.h +14 -0
@@ -2936,6 +2936,10 @@ enum nl80211_commands {* indicate that it wants strict checking on the BSS parameters to be * modified. * +* @NL80211_ATTR_S1G_PRIMARY_2MHZ: flag attribute indicating that the S1G +* primary channel is 2 MHz wide, and the control channel designates +* the 1 MHz primary subchannel within that 2 MHz primary. +* * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3498,6 +3502,7 @@ enum nl80211_attrs {NL80211_ATTR_S1G_LONG_BEACON_PERIOD ,NL80211_ATTR_S1G_SHORT_BEACON ,NL80211_ATTR_BSS_PARAM , + NL80211_ATTR_S1G_PRIMARY_2MHZ,/* add attributes here, update the policy in nl80211.c */
@@ -4396,6 +4401,12 @@ enum nl80211_wmm_rule {* very low power (VLP) AP, despite being NO_IR. * @NL80211_FREQUENCY_ATTR_ALLOW_20MHZ_ACTIVITY: This channel can be active in * 20 MHz bandwidth, despite being NO_IR. +* @NL80211_FREQUENCY_ATTR_NO_4MHZ: 4 MHz operation is not allowed on this +* channel in current regulatory domain. +* @NL80211_FREQUENCY_ATTR_NO_8MHZ: 8 MHz operation is not allowed on this +* channel in current regulatory domain. +* @NL80211_FREQUENCY_ATTR_NO_16MHZ: 16 MHz operation is not allowed on this +* channel in current regulatory domain. * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number * currently defined * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -4441,6 +4452,9 @@ enum nl80211_frequency_attr {NL80211_FREQUENCY_ATTR_CAN_MONITOR ,NL80211_FREQUENCY_ATTR_ALLOW_6GHZ_VLP_AP ,NL80211_FREQUENCY_ATTR_ALLOW_20MHZ_ACTIVITY , +NL80211_FREQUENCY_ATTR_NO_4MHZ , +NL80211_FREQUENCY_ATTR_NO_8MHZ , +NL80211_FREQUENCY_ATTR_NO_16MHZ ,/* keep last */ __NL80211_FREQUENCY_ATTR_AFTER_LAST,
net/wireless/chan.c +70 -33
156 lines not on this page · raw message
net/wireless/nl80211.c +23 -15
@@ -880,6 +880,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { [NL80211_ATTR_S1G_SHORT_BEACON ] = NLA_POLICY_NESTED(nl80211_s1g_short_beacon), [NL80211_ATTR_BSS_PARAM] = { .type = NLA_FLAG }, + [NL80211_ATTR_S1G_PRIMARY_2MHZ] = { .type = NLA_FLAG }, };/* policy for the key attributes */
@@ -1268,6 +1269,15 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy, nla_put_flag(msg, NL80211_FREQUENCY_ATTR_ALLOW_20MHZ_ACTIVITY)) goto nla_put_failure; +if ((chan->flags &IEEE80211_CHAN_NO_4MHZ ) && +nla_put_flag (msg,NL80211_FREQUENCY_ATTR_NO_4MHZ )) + goto nla_put_failure; +if ((chan->flags &IEEE80211_CHAN_NO_8MHZ ) && +nla_put_flag (msg,NL80211_FREQUENCY_ATTR_NO_8MHZ )) + goto nla_put_failure; +if ((chan->flags &IEEE80211_CHAN_NO_16MHZ ) && +nla_put_flag (msg,NL80211_FREQUENCY_ATTR_NO_16MHZ )) + goto nla_put_failure; } if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
@@ -3449,6 +3459,7 @@ static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev, chandef->center_freq1 =KHZ_TO_MHZ (control_freq); chandef->freq1_offset = control_freq %1000 ; chandef->center_freq2 =0 ; + chandef->s1g_primary_2mhz = false;if (!chandef->chan) { NL_SET_ERR_MSG_ATTR(extack, attrs[NL80211_ATTR_WIPHY_FREQ],
@@ -3492,27 +3503,21 @@ static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,return -EINVAL ; } }else if (attrs[NL80211_ATTR_CHANNEL_WIDTH ]) { - chandef->width = -nla_get_u32 (attrs[NL80211_ATTR_CHANNEL_WIDTH ]); -if (chandef->chan->band ==NL80211_BAND_S1GHZ ) { -/* User input error for channel width doesn't match channel */ -if (chandef->width !=ieee80211_s1g_channel_width (chandef->chan)) { -NL_SET_ERR_MSG_ATTR (extack, - attrs[NL80211_ATTR_CHANNEL_WIDTH ], -"bad channel width" ); -return -EINVAL ; - } - } + chandef->width =nla_get_u32 (attrs[NL80211_ATTR_CHANNEL_WIDTH ]);if (attrs[NL80211_ATTR_CENTER_FREQ1 ]) { chandef->center_freq1 =nla_get_u32 (attrs[NL80211_ATTR_CENTER_FREQ1 ]); - chandef->freq1_offset = -nla_get_u32_default (attrs[NL80211_ATTR_CENTER_FREQ1_OFFSET ], -0 ); + chandef->freq1_offset =nla_get_u32_default ( + attrs[NL80211_ATTR_CENTER_FREQ1_OFFSET ],0 ); } +if (attrs[NL80211_ATTR_CENTER_FREQ2 ]) chandef->center_freq2 =nla_get_u32 (attrs[NL80211_ATTR_CENTER_FREQ2 ]); + +if (attrs[NL80211_ATTR_S1G_PRIMARY_2MHZ ]) + chandef->s1g_primary_2mhz =nla_get_flag ( + attrs[NL80211_ATTR_S1G_PRIMARY_2MHZ ]); }if (info->attrs[NL80211_ATTR_WIPHY_EDMG_CHANNELS ]) {
@@ -10362,8 +10367,9 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) goto out_free; } -/* ignore disabled channels */ +/* Ignore disabled / no primary channels */ if (chan->flags &IEEE80211_CHAN_DISABLED || + chan->flags &IEEE80211_CHAN_S1G_NO_PRIMARY || !cfg80211_wdev_channel_allowed (wdev, chan))continue ;
@@ -10385,6 +10391,8 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) chan = &wiphy->bands[band]->channels[j];if (chan->flags &IEEE80211_CHAN_DISABLED || + chan->flags & +IEEE80211_CHAN_S1G_NO_PRIMARY || !cfg80211_wdev_channel_allowed (wdev, chan))continue ;
net/wireless/reg.c +23 -53
88 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v2 2/3 wifi: mac80211: correctly initialise S1G chandef for STA
In reply to Lachlan HodgesWhen moving to the APs channel, ensure we correctly initialise the chandef and perform the required validation. Additionally, if the AP is beaconing on a 2MHz primary, calculate the 2MHz primary center frequency by extracting the sibling 1MHz primary and averaging the frequencies to find the 2MHz primary center frequency.
---
v1 -> v2:
1. Use u8_get_bits instead of FIELD_GET
2. Fallback to default 1MHz primary chan when failing to parse the S1G Operation element
--- include/linux/ieee80211.h | 18 ++++++++++++- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/main.c | 6 +++-- net/mac80211/mlme.c | 53 +++++++++++++++++++++++++++++++++----- net/mac80211/scan.c | 13 +++++----- net/mac80211/util.c | 39 +++++++++++++++++++++++----- 6 files changed, 109 insertions(+), 23 deletions(-)
include/linux/ieee80211.h +17 -1
@@ -1182,6 +1182,18 @@ enum ieee80211_s1g_chanwidth { IEEE80211_S1G_CHANWIDTH_16MHZ = 15, }; +/** +* enum ieee80211_s1g_pri_chanwidth - S1G primary channel widths +* described in IEEE80211-2024 Table 10-39. +* +* @IEEE80211_S1G_PRI_CHANWIDTH_2MHZ: 2MHz primary channel +* @IEEE80211_S1G_PRI_CHANWIDTH_1MHZ: 1MHz primary channel +*/ +enum ieee80211_s1g_pri_chanwidth { +IEEE80211_S1G_PRI_CHANWIDTH_2MHZ =0 , +IEEE80211_S1G_PRI_CHANWIDTH_1MHZ =1 , +}; +#define WLAN_SA_QUERY_TR_ID_LEN 2#define WLAN_MEMBERSHIP_LEN 8#define WLAN_USER_POSITION_LEN 16
@@ -3170,8 +3182,12 @@ ieee80211_he_spr_size(const u8 *he_spr_ie)#define S1G_CAP9_LINK_ADAPT_PER_CONTROL_RESPONSE BIT(0) -#define S1G_OPER_CH_WIDTH_PRIMARY_1MHZ BIT(0) +#define S1G_OPER_CH_WIDTH_PRIMARY BIT(0)#define S1G_OPER_CH_WIDTH_OPER GENMASK(4, 1) +#define S1G_OPER_CH_PRIMARY_LOCATION BIT(5) + +#define S1G_2M_PRIMARY_LOCATION_LOWER 0 +#define S1G_2M_PRIMARY_LOCATION_UPPER 1/* EHT MAC capabilities as defined in P802.11be_D2.0 section 9.4.2.313.2 */ #define IEEE80211_EHT_MAC_CAP0_EPCS_PRIO_ACCESS 0x01
net/mac80211/ieee80211_i.h +2 -1
@@ -2710,7 +2710,8 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_local *local,const struct ieee80211_he_operation *he_oper, const struct ieee80211_eht_operation *eht_oper, struct cfg80211_chan_def *chandef); -bool ieee80211_chandef_s1g_oper (const struct ieee80211_s1g_oper_ie *oper, +bool ieee80211_chandef_s1g_oper (struct ieee80211_local *local, +const struct ieee80211_s1g_oper_ie *oper,struct cfg80211_chan_def *chandef);void ieee80211_chandef_downgrade (struct cfg80211_chan_def *chandef,struct ieee80211_conn_settings *conn);
net/mac80211/main.c +4 -2
@@ -1243,11 +1243,13 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)if (!dflt_chandef.chan) {/* * Assign the first enabled channel to dflt_chandef -* from the list of channels +* from the list of channels. For S1G interfaces +* ensure it can be used as a primary. */ for (i =0 ; i < sband->n_channels; i++)if (!(sband->channels[i].flags & -IEEE80211_CHAN_DISABLED )) + (IEEE80211_CHAN_DISABLED | +IEEE80211_CHAN_S1G_NO_PRIMARY )))break ;/* if none found then use the first anyway */ if (i == sband->n_channels)
net/mac80211/mlme.c +47 -6
77 lines not on this page · raw message
net/mac80211/scan.c +7 -6
@@ -996,15 +996,15 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, local->scan_chandef.freq1_offset = chan->freq_offset; local->scan_chandef.center_freq2 =0 ; -/* For scanning on the S1G band, detect the channel width according to -* the channel being scanned. -*/ +/* For S1G, only scan the 1MHz primaries. */ if (chan->band ==NL80211_BAND_S1GHZ ) { - local->scan_chandef.width =ieee80211_s1g_channel_width (chan); + local->scan_chandef.width =NL80211_CHAN_WIDTH_1 ; + local->scan_chandef.s1g_primary_2mhz = false; goto set_channel; } -/* If scanning on oper channel, use whatever channel-type +/* +* If scanning on oper channel, use whatever channel-type * is currently in use. */ if (chan == local->hw.conf.chandef.chan)
@@ -1213,7 +1213,8 @@ int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,for (band =0 ; band <NUM_NL80211_BANDS ; band++) {if (!local->hw.wiphy->bands[band] || - band ==NL80211_BAND_6GHZ ) + band ==NL80211_BAND_6GHZ || + band ==NL80211_BAND_S1GHZ )continue ; max_n = local->hw.wiphy->bands[band]->n_channels;
net/mac80211/util.c +32 -7
@@ -3199,10 +3199,11 @@ bool ieee80211_chandef_he_6ghz_oper(struct ieee80211_local *local,return true; } -bool ieee80211_chandef_s1g_oper (const struct ieee80211_s1g_oper_ie *oper, +bool ieee80211_chandef_s1g_oper (struct ieee80211_local *local, +const struct ieee80211_s1g_oper_ie *oper,struct cfg80211_chan_def *chandef) { -u32 oper_freq; +u32 oper_khz, pri_1mhz_khz, pri_2mhz_khz;if (!oper)return false;
@@ -3227,12 +3228,36 @@ bool ieee80211_chandef_s1g_oper(const struct ieee80211_s1g_oper_ie *oper,return false; } - oper_freq =ieee80211_channel_to_freq_khz (oper->oper_ch, -NL80211_BAND_S1GHZ ); - chandef->center_freq1 =KHZ_TO_MHZ (oper_freq); - chandef->freq1_offset = oper_freq %1000 ; + chandef->s1g_primary_2mhz = false; -return true; +switch (u8_get_bits (oper->ch_width,S1G_OPER_CH_WIDTH_PRIMARY )) { +case IEEE80211_S1G_PRI_CHANWIDTH_1MHZ : + pri_1mhz_khz =ieee80211_channel_to_freq_khz ( + oper->primary_ch,NL80211_BAND_S1GHZ ); +break ; +case IEEE80211_S1G_PRI_CHANWIDTH_2MHZ : + chandef->s1g_primary_2mhz = true; + pri_2mhz_khz =ieee80211_channel_to_freq_khz ( + oper->primary_ch,NL80211_BAND_S1GHZ ); + +if (u8_get_bits (oper->ch_width,S1G_OPER_CH_PRIMARY_LOCATION ) == +S1G_2M_PRIMARY_LOCATION_LOWER ) + pri_1mhz_khz = pri_2mhz_khz -500 ; +else + pri_1mhz_khz = pri_2mhz_khz +500 ; +break ; +default : +return false; + } + + oper_khz =ieee80211_channel_to_freq_khz (oper->oper_ch, +NL80211_BAND_S1GHZ ); + chandef->center_freq1 =KHZ_TO_MHZ (oper_khz); + chandef->freq1_offset = oper_khz %1000 ; + chandef->chan = +ieee80211_get_channel_khz (local->hw.wiphy, pri_1mhz_khz); + +return chandef->chan; } int ieee80211_put_srates_elem(struct sk_buff *skb,
Signature · 1 line
2.43.0
PATCH v2 3/3 wifi: cfg80211: remove ieee80211_s1g_channel_width
In reply to Lachlan HodgesWith the introduction of proper S1G channel flags, this function is no longer used. Remove it.
---
v1 -> v2:
1. Remove the function entirely at once
--- include/net/cfg80211.h | 10 ---------- net/wireless/util.c | 27 --------------------------- 2 files changed, 37 deletions(-)
include/net/cfg80211.h +0 -10
@@ -6714,16 +6714,6 @@ ieee80211_channel_to_khz(const struct ieee80211_channel *chan)return MHZ_TO_KHZ (chan->center_freq) + chan->freq_offset; } -/** -* ieee80211_s1g_channel_width - get allowed channel width from @chan -* -* Only allowed for band NL80211_BAND_S1GHZ -* @chan: channel -* Return: The allowed channel width for this center_freq -*/ -enum nl80211_chan_width -ieee80211_s1g_channel_width (const struct ieee80211_channel *chan); -/** * ieee80211_channel_to_freq_khz - convert channel number to frequency * @chan: channel number
net/wireless/util.c +0 -27
@@ -106,33 +106,6 @@ u32 ieee80211_channel_to_freq_khz(int chan, enum nl80211_band band) }EXPORT_SYMBOL (ieee80211_channel_to_freq_khz); -enum nl80211_chan_width -ieee80211_s1g_channel_width (const struct ieee80211_channel *chan) -{ -if (WARN_ON (!chan || chan->band !=NL80211_BAND_S1GHZ )) -return NL80211_CHAN_WIDTH_20_NOHT ; - -/*S1G defines a single allowed channel width per channel. -* Extract that width here. -*/ -if (chan->flags &IEEE80211_CHAN_1MHZ ) -return NL80211_CHAN_WIDTH_1 ; -else if (chan->flags &IEEE80211_CHAN_2MHZ ) -return NL80211_CHAN_WIDTH_2 ; -else if (chan->flags &IEEE80211_CHAN_4MHZ ) -return NL80211_CHAN_WIDTH_4 ; -else if (chan->flags &IEEE80211_CHAN_8MHZ ) -return NL80211_CHAN_WIDTH_8 ; -else if (chan->flags &IEEE80211_CHAN_16MHZ ) -return NL80211_CHAN_WIDTH_16 ; - -pr_err ("unknown channel width for channel at %dKHz?\n" , -ieee80211_channel_to_khz (chan)); - -return NL80211_CHAN_WIDTH_1 ; -} -EXPORT_SYMBOL (ieee80211_s1g_channel_width); -int ieee80211_freq_khz_to_channel (u32 freq) {/* TODO: just handle MHz for now */
Signature · 1 line
2.43.0
Johannes Berg
maintainerHi Lachlan,
Quoted 2 lines · Lachlan Hodges
This patchset correctly supports S1G channels within cfg80211 and mac80211. Preliminary discussion can be found in [1] and the v1 RFC can be found in [2].
I was just looking at chandef stuff for NPCA (see the other thread), and noticed that S1G isn't really (fully) represented in
- cfg80211_chandef_identical()
- _cfg80211_chandef_compatible() (not sure about this regarding primary 2mhz)
- nl80211_send_chandef()
Seems to me that some things should be added there?
johannes
Quoted 1 line · Johannes Berg
Hi Lachlan,
Hi Johannes
Quoted 8 lines · Lachlan Hodges
Quoted 2 lines
This patchset correctly supports S1G channels within cfg80211 and mac80211. Preliminary discussion can be found in [1] and the v1 RFC can be found in [2].
I was just looking at chandef stuff for NPCA (see the other thread), and noticed that S1G isn't really (fully) represented in
-
cfg80211_chandef_identical()
Yep can fix this. I actually do recall having this on my TODO as part of this patchset but must have forgotten.
Quoted 1 line
-
_cfg80211_chandef_compatible()(not sure about this regarding primary 2mhz)
This looks to require a similar S1G specific path like we did within _cfg80211_chandef_usable(). Also zooming out a bit, may need some adjustments within _ieee80211_change_chanctx(). Additionally would be good to extend the unit tests for this.
I will do some more research and testing here.
Quoted 1 line
-
nl80211_send_chandef()
Added to list. Also some wider channel switching logic may be reviewed, though probably only once a an S1G driver is available upstream (hopefully soon :-))
Will get these done soon, thanks for the reminder.
lachlan
Quoted 8 lines
Quoted 1 line
-
_cfg80211_chandef_compatible()(not sure about this regarding primary 2mhz)This looks to require a similar S1G specific path like we did within
_cfg80211_chandef_usable(). Also zooming out a bit, may need some adjustments within_ieee80211_change_chanctx(). Additionally would be good to extend the unit tests for this.I will do some more research and testing here.
So, I have been doing some reading here.
Firstly, _cfg80211_chandef_compatible() is not used during the association process as S1G doesn't require the same "upgrade" process to parse the various HT -> VHT etc. elements and ensure the HT chandef is compatible with the VHT chandef and so on. (This is obvious though otherwise S1G wouldn't work at all :D)
The next scenario is channel context sharing by interfaces. This again would be very similar to non-S1G - where as long as the primaries are shared the channel context can be used (among other things of course):
[...] if (c1->width == NL80211_CHAN_WIDTH_1) return c2; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_2); if (ret) return ret; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_4); if (ret) return ret; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_8); if (ret) return ret; [...]
The above would then be in addition to all the common checks, such that the control channel is the same etc.
The problem is, as mentioned previously, adding specific S1G Tx/Rx rate flags within link_sta_info / ieee80211_link_sta such that interfaces using a subband primary (say 4MHz on 8MHz chanctx) can clamp their Tx and Rx is not super nice (This was briefly mentioned in [1])
So essentially I have two ideas / queries:
1) For now, we could simply say unless the chandefs are exactly the same, they aren't compatible for S1G. We don't even test this internally, but we aren't the only users here. This would enable _ieee80211_change_chanctx() to function for S1G, probably through an S1G specific function that we can extend in the future.
2) In the future if / when some basic rate reporting / S1G bandwidths are implemented this could be revisted to mimic VHT. Implementing proper rates for S1G will probably require some time to figure out how to implement it cleanly.
Let me know what you think. I will also send some patches for the s1g_primary_2mhz in the chandef sometime this week.
[1] https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/
lachlan
Johannes Berg
maintainerQuoted 9 lines · Lachlan Hodges
Quoted 8 lines
Quoted 1 line
-
_cfg80211_chandef_compatible()(not sure about this regarding primary 2mhz)This looks to require a similar S1G specific path like we did within
_cfg80211_chandef_usable(). Also zooming out a bit, may need some adjustments within_ieee80211_change_chanctx(). Additionally would be good to extend the unit tests for this.I will do some more research and testing here.
Quoted 7 lines
So, I have been doing some reading here.
Firstly,
_cfg80211_chandef_compatible()is not used during the association process as S1G doesn't require the same "upgrade" process to parse the various HT -> VHT etc. elements and ensure the HT chandef is compatible with the VHT chandef and so on. (This is obvious though otherwise S1G wouldn't work at all :D)
True, it's overall much less complex :)
Quoted 21 lines
The next scenario is channel context sharing by interfaces. This again would be very similar to non-S1G - where as long as the primaries are shared the channel context can be used (among other things of course):
[...] if (c1->width == NL80211_CHAN_WIDTH_1) return c2; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_2); if (ret) return ret; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_4); if (ret) return ret; ret = check_s1g_chandef_primary_compat(c1, c2, NL80211_CHAN_WIDTH_8); if (ret) return ret; [...]
Quoted 7 lines
The above would then be in addition to all the common checks, such that the control channel is the same etc.
The problem is, as mentioned previously, adding specific S1G Tx/Rx rate flags within
link_sta_info/ieee80211_link_stasuch that interfaces using a subband primary (say 4MHz on 8MHz chanctx) can clamp their Tx and Rx is not super nice (This was briefly mentioned in [1])
Ah, right, so it could be physically compatible, but right now we don't have a way to signal TX/RX on a "sub-channel".
Quoted 7 lines
So essentially I have two ideas / queries:
1) For now, we could simply say unless the chandefs are exactly the same, they aren't compatible for S1G. We don't even test this internally, but we aren't the only users here. This would enable
_ieee80211_change_chanctx()to function for S1G, probably through an S1G specific function that we can extend in the future.
I'm fine with that, if you don't think you're going to have multi-role and chanctx sharing, who am I to complain :) Might even already be the case?
Quoted 4 lines
2) In the future if / when some basic rate reporting / S1G bandwidths are implemented this could be revisted to mimic VHT. Implementing proper rates for S1G will probably require some time to figure out how to implement it cleanly.
Sure, also again, if you don't really need it (now), no point doing all the work.
Quoted 2 lines
Let me know what you think. I will also send some patches for the
s1g_primary_2mhzin the chandef sometime this week.
Sounds good :)
Thanks for taking a look. Really I just wanted to ask about it, while I was looking at it for NPCA I noticed that at least some cases seemed to not be quite covered (e.g. as you say s1g_primary_2mhz, this was the one that mostly caught my eye anyway.)
johannes