Commit 08a75a88 authored by Ilan Peer's avatar Ilan Peer Committed by Johannes Berg

cfg80211: Handle WMM rules in regulatory domain intersection

The support added for regulatory WMM rules did not handle
the case of regulatory domain intersections. Fix it.
Signed-off-by: default avatarIlan Peer <ilan.peer@intel.com>
Fixes: 230ebaa1 ("cfg80211: read wmm rules from regulatory database")
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 78be2d21
...@@ -1309,6 +1309,16 @@ reg_intersect_dfs_region(const enum nl80211_dfs_regions dfs_region1, ...@@ -1309,6 +1309,16 @@ reg_intersect_dfs_region(const enum nl80211_dfs_regions dfs_region1,
return dfs_region1; return dfs_region1;
} }
static void reg_wmm_rules_intersect(const struct ieee80211_wmm_ac *wmm_ac1,
const struct ieee80211_wmm_ac *wmm_ac2,
struct ieee80211_wmm_ac *intersect)
{
intersect->cw_min = max_t(u16, wmm_ac1->cw_min, wmm_ac2->cw_min);
intersect->cw_max = max_t(u16, wmm_ac1->cw_max, wmm_ac2->cw_max);
intersect->cot = min_t(u16, wmm_ac1->cot, wmm_ac2->cot);
intersect->aifsn = max_t(u8, wmm_ac1->aifsn, wmm_ac2->aifsn);
}
/* /*
* Helper for regdom_intersect(), this does the real * Helper for regdom_intersect(), this does the real
* mathematical intersection fun * mathematical intersection fun
...@@ -1323,6 +1333,8 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, ...@@ -1323,6 +1333,8 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1,
struct ieee80211_freq_range *freq_range; struct ieee80211_freq_range *freq_range;
const struct ieee80211_power_rule *power_rule1, *power_rule2; const struct ieee80211_power_rule *power_rule1, *power_rule2;
struct ieee80211_power_rule *power_rule; struct ieee80211_power_rule *power_rule;
const struct ieee80211_wmm_rule *wmm_rule1, *wmm_rule2;
struct ieee80211_wmm_rule *wmm_rule;
u32 freq_diff, max_bandwidth1, max_bandwidth2; u32 freq_diff, max_bandwidth1, max_bandwidth2;
freq_range1 = &rule1->freq_range; freq_range1 = &rule1->freq_range;
...@@ -1333,6 +1345,10 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, ...@@ -1333,6 +1345,10 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1,
power_rule2 = &rule2->power_rule; power_rule2 = &rule2->power_rule;
power_rule = &intersected_rule->power_rule; power_rule = &intersected_rule->power_rule;
wmm_rule1 = &rule1->wmm_rule;
wmm_rule2 = &rule2->wmm_rule;
wmm_rule = &intersected_rule->wmm_rule;
freq_range->start_freq_khz = max(freq_range1->start_freq_khz, freq_range->start_freq_khz = max(freq_range1->start_freq_khz,
freq_range2->start_freq_khz); freq_range2->start_freq_khz);
freq_range->end_freq_khz = min(freq_range1->end_freq_khz, freq_range->end_freq_khz = min(freq_range1->end_freq_khz,
...@@ -1376,6 +1392,29 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1, ...@@ -1376,6 +1392,29 @@ static int reg_rules_intersect(const struct ieee80211_regdomain *rd1,
intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms, intersected_rule->dfs_cac_ms = max(rule1->dfs_cac_ms,
rule2->dfs_cac_ms); rule2->dfs_cac_ms);
if (rule1->has_wmm && rule2->has_wmm) {
u8 ac;
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
reg_wmm_rules_intersect(&wmm_rule1->client[ac],
&wmm_rule2->client[ac],
&wmm_rule->client[ac]);
reg_wmm_rules_intersect(&wmm_rule1->ap[ac],
&wmm_rule2->ap[ac],
&wmm_rule->ap[ac]);
}
intersected_rule->has_wmm = true;
} else if (rule1->has_wmm) {
*wmm_rule = *wmm_rule1;
intersected_rule->has_wmm = true;
} else if (rule2->has_wmm) {
*wmm_rule = *wmm_rule2;
intersected_rule->has_wmm = true;
} else {
intersected_rule->has_wmm = false;
}
if (!is_valid_reg_rule(intersected_rule)) if (!is_valid_reg_rule(intersected_rule))
return -EINVAL; return -EINVAL;
......
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