RE: [PATCH 06/10] cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}
> > On Tue, 2017-09-05 at 16:49 +, Grumbach, Emmanuel wrote: > > On Tue, 2017-09-05 at 16:30 +0200, Johannes Berg wrote: > > > On Sat, 2017-08-05 at 11:44 +0300, Luca Coelho wrote: > > > > > > > + regd = get_wiphy_regdom(wiphy); > > > > + if (regd) { > > > > + const struct ieee80211_reg_rule *reg_rule = > > > > + freq_reg_info_regd(MHZ_TO_KHZ(channel- > > > > > center_freq), > > > > > > > > + regd, > > > > MHZ_TO_KHZ(20)); > > > > > > > > > > This could return an error, how can you be sure it doesn't? > > > > > > > Hm... so I guess I could check that it didn't return any error and if > > it did, then flags = 0? > > > > Something like this? (on top of this patch): > > [snip] > > yeah that's obviously the easy thing to do - I just wasn't sure that you > didn't > have a reason to believe it could never be an ERR_PTR :) > TBH, I don't really know... I don't know if *all* the channels are covered by rules. For sure, if there is no rule, I can assume that the HT40{+,-} are not set... But I don't know if that's even possible.
Re: [PATCH 06/10] cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}
On Tue, 2017-09-05 at 16:49 +, Grumbach, Emmanuel wrote: > On Tue, 2017-09-05 at 16:30 +0200, Johannes Berg wrote: > > On Sat, 2017-08-05 at 11:44 +0300, Luca Coelho wrote: > > > > > + regd = get_wiphy_regdom(wiphy); > > > + if (regd) { > > > + const struct ieee80211_reg_rule *reg_rule = > > > + freq_reg_info_regd(MHZ_TO_KHZ(channel- > > > > center_freq), > > > > > > + regd, > > > MHZ_TO_KHZ(20)); > > > > > > > This could return an error, how can you be sure it doesn't? > > > > Hm... so I guess I could check that it didn't return any error and if > it did, then flags = 0? > > Something like this? (on top of this patch): > [snip] yeah that's obviously the easy thing to do - I just wasn't sure that you didn't have a reason to believe it could never be an ERR_PTR :) johannes
Re: [PATCH 06/10] cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}
On Tue, 2017-09-05 at 16:30 +0200, Johannes Berg wrote: > On Sat, 2017-08-05 at 11:44 +0300, Luca Coelho wrote: > > > + regd = get_wiphy_regdom(wiphy); > > + if (regd) { > > + const struct ieee80211_reg_rule *reg_rule = > > + freq_reg_info_regd(MHZ_TO_KHZ(channel- > > > center_freq), > > > > + regd, MHZ_TO_KHZ(20)); > > > > This could return an error, how can you be sure it doesn't? > Hm... so I guess I could check that it didn't return any error and if it did, then flags = 0? Something like this? (on top of this patch): @@ -1506,15 +1506,15 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy, channel_after = c; } + flags = 0; regd = get_wiphy_regdom(wiphy); if (regd) { const struct ieee80211_reg_rule *reg_rule = freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), regd, MHZ_TO_KHZ(20)); - flags = reg_rule->flags; - } else { - flags = 0; + if (!IS_ERR(reg_rule)) + flags = reg_rule->flags; } /*
Re: [PATCH 06/10] cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}
On Sat, 2017-08-05 at 11:44 +0300, Luca Coelho wrote: > + regd = get_wiphy_regdom(wiphy); > + if (regd) { > + const struct ieee80211_reg_rule *reg_rule = > + freq_reg_info_regd(MHZ_TO_KHZ(channel- > >center_freq), > + regd, MHZ_TO_KHZ(20)); > This could return an error, how can you be sure it doesn't? johannes
[PATCH 06/10] cfg80211: honor NL80211_RRF_NO_HT40{MINUS,PLUS}
From: Emmanuel Grumbach Honor the NL80211_RRF_NO_HT40{MINUS,PLUS} flags in reg_process_ht_flags_channel. Not doing so leads can lead to a firmware assert in iwlwifi for example. This fixes https://bugzilla.kernel.org/show_bug.cgi?id=195299 Fixes: b0d7aa59592b ("cfg80211: allow wiphy specific regdomain management") Signed-off-by: Emmanuel Grumbach Signed-off-by: Luca Coelho --- net/wireless/reg.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 5fae296a6a58..29879440626e 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -4,6 +4,7 @@ * Copyright 2007 Johannes Berg * Copyright 2008-2011 Luis R. Rodriguez * Copyright 2013-2014 Intel Mobile Communications GmbH + * Copyright 2017 Intel Deutschland GmbH * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1483,7 +1484,9 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy, { struct ieee80211_supported_band *sband = wiphy->bands[channel->band]; struct ieee80211_channel *channel_before = NULL, *channel_after = NULL; + const struct ieee80211_regdomain *regd; unsigned int i; + u32 flags; if (!is_ht40_allowed(channel)) { channel->flags |= IEEE80211_CHAN_NO_HT40; @@ -1503,17 +1506,30 @@ static void reg_process_ht_flags_channel(struct wiphy *wiphy, channel_after = c; } + regd = get_wiphy_regdom(wiphy); + if (regd) { + const struct ieee80211_reg_rule *reg_rule = + freq_reg_info_regd(MHZ_TO_KHZ(channel->center_freq), + regd, MHZ_TO_KHZ(20)); + + flags = reg_rule->flags; + } else { + flags = 0; + } + /* * Please note that this assumes target bandwidth is 20 MHz, * if that ever changes we also need to change the below logic * to include that as well. */ - if (!is_ht40_allowed(channel_before)) + if (!is_ht40_allowed(channel_before) || + flags & NL80211_RRF_NO_HT40MINUS) channel->flags |= IEEE80211_CHAN_NO_HT40MINUS; else channel->flags &= ~IEEE80211_CHAN_NO_HT40MINUS; - if (!is_ht40_allowed(channel_after)) + if (!is_ht40_allowed(channel_after) || + flags & NL80211_RRF_NO_HT40PLUS) channel->flags |= IEEE80211_CHAN_NO_HT40PLUS; else channel->flags &= ~IEEE80211_CHAN_NO_HT40PLUS; -- 2.13.2