Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ed45aae authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "cfg80211: add flags to define country IE processing rules"

parents c5b954d0 34f351d0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -513,6 +513,7 @@ ath_regd_init_wiphy(struct ath_regulatory *reg,
		 */
		regd = ath_world_regdomain(reg);
		wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
		wiphy->country_ie_pref = NL80211_COUNTRY_IE_FOLLOW_POWER;
	} else {
		/*
		 * This gets applied in the case of the absence of CRDA,
+26 −16
Original line number Diff line number Diff line
@@ -2257,19 +2257,25 @@ struct cfg80211_ops {
 *	has its own custom regulatory domain and cannot identify the
 *	ISO / IEC 3166 alpha2 it belongs to. When this is enabled
 *	we will disregard the first regulatory hint (when the
 * 	initiator is %REGDOM_SET_BY_CORE).
 * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will
 *	ignore regulatory domain settings until it gets its own regulatory
 *	domain via its regulatory_hint() unless the regulatory hint is
 *	from a country IE. After its gets its own regulatory domain it will
 *	only allow further regulatory domain settings to further enhance
 *	compliance. For example if channel 13 and 14 are disabled by this
 *	regulatory domain no user regulatory domain can enable these channels
 *	at a later time. This can be used for devices which do not have
 *	calibration information guaranteed for frequencies or settings
 *	outside of its regulatory domain. If used in combination with
 *	WIPHY_FLAG_CUSTOM_REGULATORY the inspected country IE power settings
 *	will be followed.
 *	initiator is %REGDOM_SET_BY_CORE). wiphys can set the custom
 *	regulatory domain using wiphy_apply_custom_regulatory()
 *	prior to wiphy registration.
 * @WIPHY_FLAG_STRICT_REGULATORY: tells us that the wiphy for this device
 *	has regulatory domain that it wishes to be considered as the
 *	superset for regulatory rules. After this device gets its regulatory
 *	domain programmed further regulatory hints shall only be considered
 *	for this device to enhance regulatory compliance, forcing the
 *	device to only possibly use subsets of the original regulatory
 *	rules. For example if channel 13 and 14 are disabled by this
 *	device's regulatory domain no user specified regulatory hint which
 *	has these channels enabled would enable them for this wiphy,
 *	the device's original regulatory domain will be trusted as the
 *	base. You can program the superset of regulatory rules for this
 *	wiphy with regulatory_hint() for cards programmed with an
 *	ISO3166-alpha2 country code. wiphys that use regulatory_hint()
 *	will have their wiphy->regd programmed once the regulatory
 *	domain is set, and all other regulatory hints will be ignored
 *	until their own regulatory domain gets programmed.
 * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure
 *	that passive scan flags and beaconing flags may not be lifted by
 *	cfg80211 due to regulatory beacon hints. For more information on beacon
@@ -2573,6 +2579,8 @@ struct wiphy_wowlan_support {
 *	802.11-2012 8.4.2.29 for the defined fields.
 * @extended_capabilities_mask: mask of the valid values
 * @extended_capabilities_len: length of the extended capabilities
 * @country_ie_pref: country IE processing preferences specified
 *	by enum nl80211_country_ie_pref
 */
struct wiphy {
	/* assign these fields before you register the wiphy */
@@ -2642,6 +2650,8 @@ struct wiphy {
	const u8 *extended_capabilities, *extended_capabilities_mask;
	u8 extended_capabilities_len;

	u8 country_ie_pref;

	/* If multiple wiphys are registered and you're handed e.g.
	 * a regular netdev with assigned ieee80211_ptr, you won't
	 * know whether it points to a wiphy your driver has registered
+28 −0
Original line number Diff line number Diff line
@@ -2242,6 +2242,34 @@ enum nl80211_reg_type {
	NL80211_REGDOM_TYPE_INTERSECTION,
};

/**
 * enum nl80211_country_ie_pref - country IE processing preferences
 *
 * enumerates the different preferences a 802.11 card can advertize
 * for parsing the country IEs. As per the current implementation
 * country IEs are only used derive the apha2, the information
 * for power settings that comes with the country IE is ignored
 * and we use the power settings from regdb.
 *
 * @NL80211_COUNTRY_IE_FOLLOW_CORE - This is the default behaviour.
 *	It allows the core to update channel flags according to the
 *	ISO3166-alpha2 in the country IE. The applied power is -
 *	MIN(power specified by custom domain, power obtained from regdb)
 * @NL80211_COUNTRY_IE_FOLLOW_POWER - for devices that have a
 *	preference that even though they may have programmed their own
 *	custom power setting prior to wiphy registration, they want
 *	to ensure their channel power settings are updated for this
 *	connection with the power settings derived from alpha2 of the
 *	country IE.
 * @NL80211_COUNTRY_IE_IGNORE_CORE - for devices that have a preference to
 *	to ignore all country IE information processed by the core.
 */
enum nl80211_country_ie_pref {
	NL80211_COUNTRY_IE_FOLLOW_CORE,
	NL80211_COUNTRY_IE_FOLLOW_POWER,
	NL80211_COUNTRY_IE_IGNORE_CORE,
};

/**
 * enum nl80211_reg_rule_attr - regulatory rule attributes
 * @__NL80211_REG_RULE_ATTR_INVALID: attribute number 0 is reserved
+6 −5
Original line number Diff line number Diff line
@@ -899,13 +899,11 @@ static void handle_channel(struct wiphy *wiphy,
	chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
	if (chan->orig_mpwr) {
		/*
		 * Devices that have their own custom regulatory domain
		 * but also use WIPHY_FLAG_STRICT_REGULATORY will follow the
		 * passed country IE power settings.
		 * Devices that use NL80211_COUNTRY_IE_FOLLOW_POWER will always
		 * follow the passed country IE power settings.
		 */
		if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
		    wiphy->flags & WIPHY_FLAG_CUSTOM_REGULATORY &&
		    wiphy->flags & WIPHY_FLAG_STRICT_REGULATORY)
		    wiphy->country_ie_pref & NL80211_COUNTRY_IE_FOLLOW_POWER)
			chan->max_power = chan->max_reg_power;
		else
			chan->max_power = min(chan->orig_mpwr,
@@ -1331,6 +1329,9 @@ get_reg_request_treatment(struct wiphy *wiphy,
	case NL80211_REGDOM_SET_BY_CORE:
		return REG_REQ_OK;
	case NL80211_REGDOM_SET_BY_COUNTRY_IE:
		if (wiphy->country_ie_pref & NL80211_COUNTRY_IE_IGNORE_CORE)
			return REG_REQ_IGNORE;

		if (reg_request_cell_base(lr)) {
			/* Trust a Cell base station over the AP's country IE */
			if (regdom_changes(pending_request->alpha2))