All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mac80211:  Be more careful when changing channels.
@ 2011-01-28  6:09 greearb
  2011-01-28  9:28 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: greearb @ 2011-01-28  6:09 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

If we cannot set the channel type, set the channel back to the
original.

Don't update the driver hardware if nothing actually changed.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 9bf2193... 3e5a75b... M	net/mac80211/cfg.c
 net/mac80211/cfg.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9bf2193..3e5a75b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1223,10 +1223,16 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
 {
 	struct ieee80211_local *local = wiphy_priv(wiphy);
 	struct ieee80211_sub_if_data *sdata = NULL;
+	struct ieee80211_channel *old_oper;
+	enum nl80211_channel_type old_oper_type;
+	enum nl80211_channel_type old_vif_oper_type = NL80211_CHAN_NO_HT;
 
 	if (netdev)
 		sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
 
+	if (sdata)
+		old_vif_oper_type == sdata->vif.bss_conf.channel_type;
+
 	switch (ieee80211_get_channel_mode(local, NULL)) {
 	case CHAN_MODE_HOPPING:
 		return -EBUSY;
@@ -1240,13 +1246,21 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
 		break;
 	}
 
+	old_oper = local->oper_channel;
 	local->oper_channel = chan;
 
-	if (!ieee80211_set_channel_type(local, sdata, channel_type))
+	old_oper_type = local->_oper_channel_type;
+	if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
+		local->oper_channel = old_oper;
 		return -EBUSY;
+	}
+
+	if ((old_oper != local->oper_channel) ||
+	    (old_oper_type != local->_oper_channel_type))
+		ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
 
-	ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
-	if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR)
+	if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
+	    old_vif_oper_type != sdata->vif.bss_conf.channel_type)
 		ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
 
 	return 0;
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mac80211:  Be more careful when changing channels.
  2011-01-28  6:09 [PATCH] mac80211: Be more careful when changing channels greearb
@ 2011-01-28  9:28 ` Johannes Berg
  2011-01-28 17:15   ` Ben Greear
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2011-01-28  9:28 UTC (permalink / raw)
  To: greearb; +Cc: linux-wireless

On Thu, 2011-01-27 at 22:09 -0800, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> If we cannot set the channel type, set the channel back to the
> original.
> 
> Don't update the driver hardware if nothing actually changed.

Good catch.


> +	old_oper = local->oper_channel;
>  	local->oper_channel = chan;
>  
> -	if (!ieee80211_set_channel_type(local, sdata, channel_type))
> +	old_oper_type = local->_oper_channel_type;
> +	if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
> +		local->oper_channel = old_oper;
>  		return -EBUSY;
> +	}
> +
> +	if ((old_oper != local->oper_channel) ||
> +	    (old_oper_type != local->_oper_channel_type))
> +		ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
>  
> -	ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
> -	if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR)
> +	if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
> +	    old_vif_oper_type != sdata->vif.bss_conf.channel_type)
>  		ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);

But why the complicated code? Couldn't you just swap the
set_channel_type() and oper_channel = chan around? set_channel_type()
doesn't need oper_channel set.

johannes


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mac80211:  Be more careful when changing channels.
  2011-01-28  9:28 ` Johannes Berg
@ 2011-01-28 17:15   ` Ben Greear
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Greear @ 2011-01-28 17:15 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On 01/28/2011 01:28 AM, Johannes Berg wrote:
> On Thu, 2011-01-27 at 22:09 -0800, greearb@candelatech.com wrote:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> If we cannot set the channel type, set the channel back to the
>> original.
>>
>> Don't update the driver hardware if nothing actually changed.
>
> Good catch.
>
>
>> +	old_oper = local->oper_channel;
>>   	local->oper_channel = chan;
>>
>> -	if (!ieee80211_set_channel_type(local, sdata, channel_type))
>> +	old_oper_type = local->_oper_channel_type;
>> +	if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
>> +		local->oper_channel = old_oper;
>>   		return -EBUSY;
>> +	}
>> +
>> +	if ((old_oper != local->oper_channel) ||
>> +	    (old_oper_type != local->_oper_channel_type))
>> +		ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
>>
>> -	ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
>> -	if (sdata&&  sdata->vif.type != NL80211_IFTYPE_MONITOR)
>> +	if ((sdata&&  sdata->vif.type != NL80211_IFTYPE_MONITOR)&&
>> +	    old_vif_oper_type != sdata->vif.bss_conf.channel_type)
>>   		ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
>
> But why the complicated code? Couldn't you just swap the
> set_channel_type() and oper_channel = chan around? set_channel_type()
> doesn't need oper_channel set.

Yes, that would simplify the first part.  The extra checks at the bottom need to
remain as far as I can tell.

I'll send a new patch today.

Thanks,
Ben

>
> johannes
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-28 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28  6:09 [PATCH] mac80211: Be more careful when changing channels greearb
2011-01-28  9:28 ` Johannes Berg
2011-01-28 17:15   ` Ben Greear

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.