Commit 5be83de5 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

cfg80211: convert bools into flags

We've accumulated a number of options for wiphys
which make more sense as flags as we keep adding
more. Convert the existing ones.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9bd568a5
...@@ -450,7 +450,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg, ...@@ -450,7 +450,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,
const struct ieee80211_regdomain *regd; const struct ieee80211_regdomain *regd;
wiphy->reg_notifier = reg_notifier; wiphy->reg_notifier = reg_notifier;
wiphy->strict_regulatory = true; wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
if (ath_is_world_regd(reg)) { if (ath_is_world_regd(reg)) {
/* /*
...@@ -458,8 +458,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg, ...@@ -458,8 +458,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,
* saved on the wiphy orig_* parameters * saved on the wiphy orig_* parameters
*/ */
regd = ath_world_regdomain(reg); regd = ath_world_regdomain(reg);
wiphy->custom_regulatory = true; wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy->strict_regulatory = false;
} else { } else {
/* /*
* This gets applied in the case of the absense of CRDA, * This gets applied in the case of the absense of CRDA,
......
...@@ -2400,16 +2400,14 @@ static int iwl_setup_mac(struct iwl_priv *priv) ...@@ -2400,16 +2400,14 @@ static int iwl_setup_mac(struct iwl_priv *priv)
BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC); BIT(NL80211_IFTYPE_ADHOC);
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY |
WIPHY_FLAG_DISABLE_BEACON_HINTS;
/* Firmware does not support this */
hw->wiphy->disable_beacon_hints = true;
/* /*
* For now, disable PS by default because it affects * For now, disable PS by default because it affects
* RX performance significantly. * RX performance significantly.
*/ */
hw->wiphy->ps_default = false; hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
/* we create the 802.11 header and a zero-length SSID element */ /* we create the 802.11 header and a zero-length SSID element */
......
...@@ -3904,10 +3904,8 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) ...@@ -3904,10 +3904,8 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_STATION) |
BIT(NL80211_IFTYPE_ADHOC); BIT(NL80211_IFTYPE_ADHOC);
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY |
WIPHY_FLAG_DISABLE_BEACON_HINTS;
/* Firmware does not support this */
hw->wiphy->disable_beacon_hints = true;
hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
/* we create the 802.11 header and a zero-length SSID element */ /* we create the 802.11 header and a zero-length SSID element */
......
...@@ -1146,46 +1146,46 @@ static int __init init_mac80211_hwsim(void) ...@@ -1146,46 +1146,46 @@ static int __init init_mac80211_hwsim(void)
break; break;
case HWSIM_REGTEST_WORLD_ROAM: case HWSIM_REGTEST_WORLD_ROAM:
if (i == 0) { if (i == 0) {
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_01); &hwsim_world_regdom_custom_01);
} }
break; break;
case HWSIM_REGTEST_CUSTOM_WORLD: case HWSIM_REGTEST_CUSTOM_WORLD:
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_01); &hwsim_world_regdom_custom_01);
break; break;
case HWSIM_REGTEST_CUSTOM_WORLD_2: case HWSIM_REGTEST_CUSTOM_WORLD_2:
if (i == 0) { if (i == 0) {
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_01); &hwsim_world_regdom_custom_01);
} else if (i == 1) { } else if (i == 1) {
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_02); &hwsim_world_regdom_custom_02);
} }
break; break;
case HWSIM_REGTEST_STRICT_ALL: case HWSIM_REGTEST_STRICT_ALL:
hw->wiphy->strict_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
break; break;
case HWSIM_REGTEST_STRICT_FOLLOW: case HWSIM_REGTEST_STRICT_FOLLOW:
case HWSIM_REGTEST_STRICT_AND_DRIVER_REG: case HWSIM_REGTEST_STRICT_AND_DRIVER_REG:
if (i == 0) if (i == 0)
hw->wiphy->strict_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
break; break;
case HWSIM_REGTEST_ALL: case HWSIM_REGTEST_ALL:
if (i == 0) { if (i == 0) {
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_01); &hwsim_world_regdom_custom_01);
} else if (i == 1) { } else if (i == 1) {
hw->wiphy->custom_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
wiphy_apply_custom_regulatory(hw->wiphy, wiphy_apply_custom_regulatory(hw->wiphy,
&hwsim_world_regdom_custom_02); &hwsim_world_regdom_custom_02);
} else if (i == 4) } else if (i == 4)
hw->wiphy->strict_regulatory = true; hw->wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
break; break;
default: default:
break; break;
......
...@@ -579,7 +579,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len) ...@@ -579,7 +579,7 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
* For now, disable PS by default because it affects * For now, disable PS by default because it affects
* link stability significantly. * link stability significantly.
*/ */
dev->wiphy->ps_default = false; dev->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
mutex_init(&priv->conf_mutex); mutex_init(&priv->conf_mutex);
mutex_init(&priv->eeprom_mutex); mutex_init(&priv->eeprom_mutex);
......
...@@ -1108,27 +1108,45 @@ struct cfg80211_ops { ...@@ -1108,27 +1108,45 @@ struct cfg80211_ops {
*/ */
/** /**
* struct wiphy - wireless hardware description * enum wiphy_flags - wiphy capability flags
* @idx: the wiphy index assigned to this item *
* @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name> * @WIPHY_FLAG_CUSTOM_REGULATORY: tells us the driver for this device
* @custom_regulatory: tells us the driver for this device
* has its own custom regulatory domain and cannot identify the * has its own custom regulatory domain and cannot identify the
* ISO / IEC 3166 alpha2 it belongs to. When this is enabled * ISO / IEC 3166 alpha2 it belongs to. When this is enabled
* we will disregard the first regulatory hint (when the * we will disregard the first regulatory hint (when the
* initiator is %REGDOM_SET_BY_CORE). * initiator is %REGDOM_SET_BY_CORE).
* @strict_regulatory: tells us the driver for this device will ignore * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will
* regulatory domain settings until it gets its own regulatory domain * ignore regulatory domain settings until it gets its own regulatory
* via its regulatory_hint(). After its gets its own regulatory domain * domain via its regulatory_hint(). After its gets its own regulatory
* it will only allow further regulatory domain settings to further * domain it will only allow further regulatory domain settings to
* enhance compliance. For example if channel 13 and 14 are disabled * further enhance compliance. For example if channel 13 and 14 are
* by this regulatory domain no user regulatory domain can enable these * disabled by this regulatory domain no user regulatory domain can
* channels at a later time. This can be used for devices which do not * enable these channels at a later time. This can be used for devices
* have calibration information gauranteed for frequencies or settings * which do not have calibration information gauranteed for frequencies
* outside of its regulatory domain. * or settings outside of its regulatory domain.
* @disable_beacon_hints: enable this if your driver needs to ensure that * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure
* passive scan flags and beaconing flags may not be lifted by cfg80211 * that passive scan flags and beaconing flags may not be lifted by
* due to regulatory beacon hints. For more information on beacon * cfg80211 due to regulatory beacon hints. For more information on beacon
* hints read the documenation for regulatory_hint_found_beacon() * hints read the documenation for regulatory_hint_found_beacon()
* @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this
* wiphy at all
* @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled
* by default -- this flag will be set depending on the kernel's default
* on wiphy_new(), but can be changed by the driver if it has a good
* reason to override the default
*/
enum wiphy_flags {
WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0),
WIPHY_FLAG_STRICT_REGULATORY = BIT(1),
WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2),
WIPHY_FLAG_NETNS_OK = BIT(3),
WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4),
};
/**
* struct wiphy - wireless hardware description
* @idx: the wiphy index assigned to this item
* @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
* @reg_notifier: the driver's regulatory notification callback * @reg_notifier: the driver's regulatory notification callback
* @regd: the driver's regulatory domain, if one was requested via * @regd: the driver's regulatory domain, if one was requested via
* the regulatory_hint() API. This can be used by the driver * the regulatory_hint() API. This can be used by the driver
...@@ -1143,11 +1161,6 @@ struct cfg80211_ops { ...@@ -1143,11 +1161,6 @@ struct cfg80211_ops {
* -1 = fragmentation disabled, only odd values >= 256 used * -1 = fragmentation disabled, only odd values >= 256 used
* @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
* @net: the network namespace this wiphy currently lives in * @net: the network namespace this wiphy currently lives in
* @netnsok: if set to false, do not allow changing the netns of this
* wiphy at all
* @ps_default: default for powersave, will be set depending on the
* kernel's default on wiphy_new(), but can be changed by the
* driver if it has a good reason to override the default
*/ */
struct wiphy { struct wiphy {
/* assign these fields before you register the wiphy */ /* assign these fields before you register the wiphy */
...@@ -1158,12 +1171,7 @@ struct wiphy { ...@@ -1158,12 +1171,7 @@ struct wiphy {
/* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
u16 interface_modes; u16 interface_modes;
bool custom_regulatory; u32 flags;
bool strict_regulatory;
bool disable_beacon_hints;
bool netnsok;
bool ps_default;
enum cfg80211_signal_type signal_type; enum cfg80211_signal_type signal_type;
......
...@@ -328,7 +328,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, ...@@ -328,7 +328,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
if (!wiphy) if (!wiphy)
return NULL; return NULL;
wiphy->netnsok = true; wiphy->flags |= WIPHY_FLAG_NETNS_OK;
wiphy->privid = mac80211_wiphy_privid; wiphy->privid = mac80211_wiphy_privid;
/* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ /* Yes, putting cfg80211_bss into ieee80211_bss is a hack */
......
...@@ -74,12 +74,6 @@ config CFG80211_REG_DEBUG ...@@ -74,12 +74,6 @@ config CFG80211_REG_DEBUG
If unsure, say N. If unsure, say N.
config CFG80211_DEFAULT_PS_VALUE
int
default 1 if CFG80211_DEFAULT_PS
default 0
depends on CFG80211
config CFG80211_DEFAULT_PS config CFG80211_DEFAULT_PS
bool "enable powersave by default" bool "enable powersave by default"
depends on CFG80211 depends on CFG80211
......
...@@ -230,7 +230,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev, ...@@ -230,7 +230,7 @@ int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev; struct wireless_dev *wdev;
int err = 0; int err = 0;
if (!rdev->wiphy.netnsok) if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
return -EOPNOTSUPP; return -EOPNOTSUPP;
list_for_each_entry(wdev, &rdev->netdev_list, list) { list_for_each_entry(wdev, &rdev->netdev_list, list) {
...@@ -367,7 +367,9 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv) ...@@ -367,7 +367,9 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
rdev->wiphy.dev.class = &ieee80211_class; rdev->wiphy.dev.class = &ieee80211_class;
rdev->wiphy.dev.platform_data = rdev; rdev->wiphy.dev.platform_data = rdev;
rdev->wiphy.ps_default = CONFIG_CFG80211_DEFAULT_PS_VALUE; #ifdef CONFIG_CFG80211_DEFAULT_PS
rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
#endif
wiphy_net_set(&rdev->wiphy, &init_net); wiphy_net_set(&rdev->wiphy, &init_net);
...@@ -482,7 +484,7 @@ int wiphy_register(struct wiphy *wiphy) ...@@ -482,7 +484,7 @@ int wiphy_register(struct wiphy *wiphy)
if (IS_ERR(rdev->wiphy.debugfsdir)) if (IS_ERR(rdev->wiphy.debugfsdir))
rdev->wiphy.debugfsdir = NULL; rdev->wiphy.debugfsdir = NULL;
if (wiphy->custom_regulatory) { if (wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY) {
struct regulatory_request request; struct regulatory_request request;
request.wiphy_idx = get_wiphy_idx(wiphy); request.wiphy_idx = get_wiphy_idx(wiphy);
...@@ -680,7 +682,10 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, ...@@ -680,7 +682,10 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
wdev->wext.default_key = -1; wdev->wext.default_key = -1;
wdev->wext.default_mgmt_key = -1; wdev->wext.default_mgmt_key = -1;
wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
wdev->wext.ps = wdev->wiphy->ps_default; if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
wdev->wext.ps = true;
else
wdev->wext.ps = false;
wdev->wext.ps_timeout = 100; wdev->wext.ps_timeout = 100;
if (rdev->ops->set_power_mgmt) if (rdev->ops->set_power_mgmt)
if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, if (rdev->ops->set_power_mgmt(wdev->wiphy, dev,
......
...@@ -561,7 +561,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, ...@@ -561,7 +561,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
CMD(deauth, DEAUTHENTICATE); CMD(deauth, DEAUTHENTICATE);
CMD(disassoc, DISASSOCIATE); CMD(disassoc, DISASSOCIATE);
CMD(join_ibss, JOIN_IBSS); CMD(join_ibss, JOIN_IBSS);
if (dev->wiphy.netnsok) { if (dev->wiphy.flags & WIPHY_FLAG_NETNS_OK) {
i++; i++;
NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS); NLA_PUT_U32(msg, i, NL80211_CMD_SET_WIPHY_NETNS);
} }
......
...@@ -1008,7 +1008,7 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, ...@@ -1008,7 +1008,7 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band,
if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER && if (last_request->initiator == NL80211_REGDOM_SET_BY_DRIVER &&
request_wiphy && request_wiphy == wiphy && request_wiphy && request_wiphy == wiphy &&
request_wiphy->strict_regulatory) { request_wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY) {
/* /*
* This gaurantees the driver's requested regulatory domain * This gaurantees the driver's requested regulatory domain
* will always be used as a base for further regulatory * will always be used as a base for further regulatory
...@@ -1051,13 +1051,13 @@ static bool ignore_reg_update(struct wiphy *wiphy, ...@@ -1051,13 +1051,13 @@ static bool ignore_reg_update(struct wiphy *wiphy,
if (!last_request) if (!last_request)
return true; return true;
if (initiator == NL80211_REGDOM_SET_BY_CORE && if (initiator == NL80211_REGDOM_SET_BY_CORE &&
wiphy->custom_regulatory) wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY)
return true; return true;
/* /*
* wiphy->regd will be set once the device has its own * wiphy->regd will be set once the device has its own
* desired regulatory domain set * desired regulatory domain set
*/ */
if (wiphy->strict_regulatory && !wiphy->regd && if (wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY && !wiphy->regd &&
!is_world_regdom(last_request->alpha2)) !is_world_regdom(last_request->alpha2))
return true; return true;
return false; return false;
...@@ -1093,7 +1093,7 @@ static void handle_reg_beacon(struct wiphy *wiphy, ...@@ -1093,7 +1093,7 @@ static void handle_reg_beacon(struct wiphy *wiphy,
chan->beacon_found = true; chan->beacon_found = true;
if (wiphy->disable_beacon_hints) if (wiphy->flags & WIPHY_FLAG_DISABLE_BEACON_HINTS)
return; return;
chan_before.center_freq = chan->center_freq; chan_before.center_freq = chan->center_freq;
...@@ -1164,7 +1164,7 @@ static bool reg_is_world_roaming(struct wiphy *wiphy) ...@@ -1164,7 +1164,7 @@ static bool reg_is_world_roaming(struct wiphy *wiphy)
return true; return true;
if (last_request && if (last_request &&
last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE && last_request->initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE &&
wiphy->custom_regulatory) wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY)
return true; return true;
return false; return false;
} }
...@@ -1591,7 +1591,8 @@ static void reg_process_hint(struct regulatory_request *reg_request) ...@@ -1591,7 +1591,8 @@ static void reg_process_hint(struct regulatory_request *reg_request)
r = __regulatory_hint(wiphy, reg_request); r = __regulatory_hint(wiphy, reg_request);
/* This is required so that the orig_* parameters are saved */ /* This is required so that the orig_* parameters are saved */
if (r == -EALREADY && wiphy && wiphy->strict_regulatory) if (r == -EALREADY && wiphy &&
wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY)
wiphy_update_regulatory(wiphy, reg_request->initiator); wiphy_update_regulatory(wiphy, reg_request->initiator);
out: out:
mutex_unlock(&reg_mutex); mutex_unlock(&reg_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment