mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
wifi: cfg80211: refactor 6 GHz AP power type parsing
Add cfg80211_get_6ghz_power_type() to parse the 6 GHz power type from a given set of elements, which is now only inside cfg80211_6ghz_power_type_valid(). Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Link: https://msgid.link/20240523120945.84cdffd94085.I76f434ee12552e8be91273f3b2d776179eaa62f1@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
ca41bfe367
commit
459662e83d
@ -533,6 +533,10 @@ struct cfg80211_internal_bss *
|
||||
cfg80211_bss_update(struct cfg80211_registered_device *rdev,
|
||||
struct cfg80211_internal_bss *tmp,
|
||||
bool signal_valid, unsigned long ts);
|
||||
|
||||
enum ieee80211_ap_reg_power
|
||||
cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len);
|
||||
|
||||
#ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
|
||||
#define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond)
|
||||
#else
|
||||
|
@ -2163,38 +2163,53 @@ struct cfg80211_inform_single_bss_data {
|
||||
u64 cannot_use_reasons;
|
||||
};
|
||||
|
||||
static bool cfg80211_6ghz_power_type_valid(const u8 *ie, size_t ielen,
|
||||
enum ieee80211_ap_reg_power
|
||||
cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len)
|
||||
{
|
||||
const struct ieee80211_he_6ghz_oper *he_6ghz_oper;
|
||||
struct ieee80211_he_operation *he_oper;
|
||||
const struct element *tmp;
|
||||
|
||||
tmp = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION,
|
||||
elems, elems_len);
|
||||
if (!tmp || tmp->datalen < sizeof(*he_oper) + 1 ||
|
||||
tmp->datalen < ieee80211_he_oper_size(tmp->data + 1))
|
||||
return IEEE80211_REG_UNSET_AP;
|
||||
|
||||
he_oper = (void *)&tmp->data[1];
|
||||
he_6ghz_oper = ieee80211_he_6ghz_oper(he_oper);
|
||||
|
||||
if (!he_6ghz_oper)
|
||||
return IEEE80211_REG_UNSET_AP;
|
||||
|
||||
switch (u8_get_bits(he_6ghz_oper->control,
|
||||
IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) {
|
||||
case IEEE80211_6GHZ_CTRL_REG_LPI_AP:
|
||||
case IEEE80211_6GHZ_CTRL_REG_INDOOR_LPI_AP:
|
||||
return IEEE80211_REG_LPI_AP;
|
||||
case IEEE80211_6GHZ_CTRL_REG_SP_AP:
|
||||
case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP:
|
||||
return IEEE80211_REG_SP_AP;
|
||||
case IEEE80211_6GHZ_CTRL_REG_VLP_AP:
|
||||
return IEEE80211_REG_VLP_AP;
|
||||
default:
|
||||
return IEEE80211_REG_UNSET_AP;
|
||||
}
|
||||
}
|
||||
|
||||
static bool cfg80211_6ghz_power_type_valid(const u8 *elems, size_t elems_len,
|
||||
const u32 flags)
|
||||
{
|
||||
const struct element *tmp;
|
||||
struct ieee80211_he_operation *he_oper;
|
||||
|
||||
tmp = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION, ie, ielen);
|
||||
if (tmp && tmp->datalen >= sizeof(*he_oper) + 1 &&
|
||||
tmp->datalen >= ieee80211_he_oper_size(tmp->data + 1)) {
|
||||
const struct ieee80211_he_6ghz_oper *he_6ghz_oper;
|
||||
|
||||
he_oper = (void *)&tmp->data[1];
|
||||
he_6ghz_oper = ieee80211_he_6ghz_oper(he_oper);
|
||||
|
||||
if (!he_6ghz_oper)
|
||||
return false;
|
||||
|
||||
switch (u8_get_bits(he_6ghz_oper->control,
|
||||
IEEE80211_HE_6GHZ_OPER_CTRL_REG_INFO)) {
|
||||
case IEEE80211_6GHZ_CTRL_REG_LPI_AP:
|
||||
case IEEE80211_6GHZ_CTRL_REG_INDOOR_LPI_AP:
|
||||
return true;
|
||||
case IEEE80211_6GHZ_CTRL_REG_SP_AP:
|
||||
case IEEE80211_6GHZ_CTRL_REG_INDOOR_SP_AP:
|
||||
return !(flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT);
|
||||
case IEEE80211_6GHZ_CTRL_REG_VLP_AP:
|
||||
return !(flags & IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
switch (cfg80211_get_6ghz_power_type(elems, elems_len)) {
|
||||
case IEEE80211_REG_LPI_AP:
|
||||
return true;
|
||||
case IEEE80211_REG_SP_AP:
|
||||
return !(flags & IEEE80211_CHAN_NO_6GHZ_AFC_CLIENT);
|
||||
case IEEE80211_REG_VLP_AP:
|
||||
return !(flags & IEEE80211_CHAN_NO_6GHZ_VLP_CLIENT);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Returned bss is reference counted and must be cleaned up appropriately. */
|
||||
|
Loading…
Reference in New Issue
Block a user