diff mbox

[v3] mac80211_hwsim: claim CSA support for AP

Message ID 1385111186-19551-1-git-send-email-karl.beldan@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Karl Beldan Nov. 22, 2013, 9:06 a.m. UTC
From: Karl Beldan <karl.beldan@rivierawaves.com>

Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
 drivers/net/wireless/mac80211_hwsim.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

Comments

Karl Beldan Nov. 22, 2013, 10:45 a.m. UTC | #1
On Fri, Nov 22, 2013 at 10:06:26AM +0100, Karl Beldan wrote:
> From: Karl Beldan <karl.beldan@rivierawaves.com>
> 
> Signed-off-by: Karl Beldan <karl.beldan@rivierawaves.com>
> Cc: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> ---
>  drivers/net/wireless/mac80211_hwsim.c | 31 ++++++++++++++++++++++++++++++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
> index a11dc7c..cc30acd 100644
> --- a/drivers/net/wireless/mac80211_hwsim.c
> +++ b/drivers/net/wireless/mac80211_hwsim.c
> @@ -168,6 +168,7 @@ struct hwsim_vif_priv {
>  	u8 bssid[ETH_ALEN];
>  	bool assoc;
>  	bool bcn_en;
> +	int csa_bcn_cnt;
>  	u16 aid;
>  };
>  
> @@ -1058,6 +1059,18 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
>  
>  	mac80211_hwsim_tx_frame(hw, skb,
>  				rcu_dereference(vif->chanctx_conf)->def.chan);
> +
> +	if (vif->csa_active) {
> +		struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
> +
> +		vp->csa_bcn_cnt++;
> +		if (ieee80211_csa_is_complete(vif)) {
> +			wiphy_debug(hw->wiphy,
> +				    "%s CSA complete after %d beacons\n",
> +				    __func__, vp->csa_bcn_cnt);
> +			ieee80211_csa_finish(vif);
> +		}
> +	}
>  }
>  

Hmm, I thought the CSA code would make ieee80211_beacon_get_tim return
NULL (or do something alike) after the last ieee80211_beacon_get_tim
returned a beacon with a null CSA count until the config is done - but
it seems it doesn't - in that case this change would be race prone.
Did I miss something ?
 
Karl
--
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
Simon Wunderlich Nov. 22, 2013, 12:08 p.m. UTC | #2
Hello Karl,

> 
> Hmm, I thought the CSA code would make ieee80211_beacon_get_tim return
> NULL (or do something alike) after the last ieee80211_beacon_get_tim
> returned a beacon with a null CSA count until the config is done - but
> it seems it doesn't - in that case this change would be race prone.
> Did I miss something ?

No, you have to do the check yourself (as you appearently did). In ath9k I'm 
checking if the CSA finished before scheduling the next beacon. Can you do the 
same for hwsim? Where do you see the race?

Simon

P.S.: Please use my new e-mail address, the old one will go out of service by 
end of the year.
--
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
diff mbox

Patch

diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index a11dc7c..cc30acd 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -168,6 +168,7 @@  struct hwsim_vif_priv {
 	u8 bssid[ETH_ALEN];
 	bool assoc;
 	bool bcn_en;
+	int csa_bcn_cnt;
 	u16 aid;
 };
 
@@ -1058,6 +1059,18 @@  static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
 
 	mac80211_hwsim_tx_frame(hw, skb,
 				rcu_dereference(vif->chanctx_conf)->def.chan);
+
+	if (vif->csa_active) {
+		struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+
+		vp->csa_bcn_cnt++;
+		if (ieee80211_csa_is_complete(vif)) {
+			wiphy_debug(hw->wiphy,
+				    "%s CSA complete after %d beacons\n",
+				    __func__, vp->csa_bcn_cnt);
+			ieee80211_csa_finish(vif);
+		}
+	}
 }
 
 static enum hrtimer_restart
@@ -1692,6 +1705,19 @@  static void mac80211_hwsim_unassign_vif_chanctx(struct ieee80211_hw *hw,
 	hwsim_check_chanctx_magic(ctx);
 }
 
+static void mac80211_hwsim_channel_switch_beacon(struct ieee80211_hw *hw,
+						 struct ieee80211_vif *vif,
+						 struct cfg80211_chan_def *chandef)
+{
+	struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
+
+	hwsim_check_magic(vif);
+	vp->csa_bcn_cnt = 0;
+	wiphy_debug(hw->wiphy, "%s (freq=%d(%d - %d)/%s)\n", __func__,
+		    chandef->chan->center_freq, chandef->center_freq1,
+		    chandef->center_freq2, hwsim_chanwidths[chandef->width]);
+}
+
 static struct ieee80211_ops mac80211_hwsim_ops =
 {
 	.tx = mac80211_hwsim_tx,
@@ -1716,6 +1742,7 @@  static struct ieee80211_ops mac80211_hwsim_ops =
 	.flush = mac80211_hwsim_flush,
 	.get_tsf = mac80211_hwsim_get_tsf,
 	.set_tsf = mac80211_hwsim_set_tsf,
+	.channel_switch_beacon = mac80211_hwsim_channel_switch_beacon,
 };
 
 
@@ -2359,7 +2386,9 @@  static int __init init_mac80211_hwsim(void)
 
 		hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS |
 				    WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
-				    WIPHY_FLAG_AP_UAPSD;
+				    WIPHY_FLAG_AP_UAPSD |
+				    WIPHY_FLAG_HAS_CHANNEL_SWITCH;
+
 		hw->wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
 
 		/* ask mac80211 to reserve space for magic */