From patchwork Sat Nov 23 16:38:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karl Beldan X-Patchwork-Id: 3225321 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F27C19F26C for ; Sat, 23 Nov 2013 16:39:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09D3F2026F for ; Sat, 23 Nov 2013 16:39:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A47020304 for ; Sat, 23 Nov 2013 16:39:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755991Ab3KWQjF (ORCPT ); Sat, 23 Nov 2013 11:39:05 -0500 Received: from mail-we0-f169.google.com ([74.125.82.169]:54985 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754346Ab3KWQjD (ORCPT ); Sat, 23 Nov 2013 11:39:03 -0500 Received: by mail-we0-f169.google.com with SMTP id t60so2358123wes.0 for ; Sat, 23 Nov 2013 08:39:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CYg864iwtomsfpx0+hgjle88vbL2cz5nMtpYC9suMUs=; b=m75CizLyQA062NU5qi6xh7rmKpGdHU+F2ZyUKfHVkJNww2X0fZcsvInNVwkHj36jpr mTEei57WQZlLkagZyfvRB3tzps9mhWYjiOVUEIgdSLczbZN3/QLOhTb5SKGz7KR3dqar 1qUqbP/BSRQvy/EIUu8awrhWYvB1wfQ3a90JZvxQpv26y18X52dO2g8nhM/ob55c4Q3g f9Hzc61AhUbzMl4ZeU4/s85tpperLL6x3Fs/hFqapIfpwa9yVKbtjMHZP8apmcoU0KZW jK1jvjVrkB3xqez+xWKzdsBVVSSIZsC7RNeuDg4o7SWAzvqM9hXxO/2KeULEgQAryiH0 0jIw== X-Received: by 10.180.20.102 with SMTP id m6mr7279289wie.22.1385224741627; Sat, 23 Nov 2013 08:39:01 -0800 (PST) Received: from magnum.frso.rivierawaves.com (ppp-seco11pa2-46-193-143.43.wb.wifirst.net. [46.193.143.43]) by mx.google.com with ESMTPSA id pi6sm27843223wic.3.2013.11.23.08.38.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 23 Nov 2013 08:39:01 -0800 (PST) From: Karl Beldan To: Johannes Berg Cc: linux-wireless , Karl Beldan , Simon Wunderlich Subject: [PATCH v4] mac80211_hwsim: claim CSA support for AP Date: Sat, 23 Nov 2013 17:38:18 +0100 Message-Id: <1385224698-12294-1-git-send-email-karl.beldan@gmail.com> X-Mailer: git-send-email 1.8.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Karl Beldan This assigns the channel_switch_beacon op. For hwsim, it comes down to calling ieee80211_csa_finish once ieee80211_csa_is_complete is true. Since channel_switch_beacon is not called if CSA count starts @ 0 or 1, the check for ieee80211_csa_is_complete can be done after getting the beacon (and this way it might trigger helpful warnings). This adds a per vif bool csa_finished that is set after a call to ieee80211_csa_finish() and used to skip beaconing while csa_active is set in case a beacon is scheduled prior to csa_finalize_work completion. This bool and the number of beacons transmitted during the CSA up to the call to ieee80211_csa_finish() are reset in channel_switch_beacon op. Signed-off-by: Karl Beldan Cc: Simon Wunderlich --- drivers/net/wireless/mac80211_hwsim.c | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index a11dc7c..0fb6bb4 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -169,6 +169,8 @@ struct hwsim_vif_priv { bool assoc; bool bcn_en; u16 aid; + int csa_bcn_cnt; + bool csa_finished; }; #define HWSIM_VIF_MAGIC 0x69537748 @@ -1024,6 +1026,7 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, struct ieee80211_vif *vif) { + struct hwsim_vif_priv *vp = (void *)vif->drv_priv; struct mac80211_hwsim_data *data = arg; struct ieee80211_hw *hw = data->hw; struct ieee80211_tx_info *info; @@ -1038,6 +1041,12 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, vif->type != NL80211_IFTYPE_ADHOC) return; + if (vif->csa_active && vp->csa_finished) { + wiphy_debug(hw->wiphy, "%s skip (CSA is active & finished)\n", + __func__); + return; + } + skb = ieee80211_beacon_get(hw, vif); if (skb == NULL) return; @@ -1058,6 +1067,17 @@ 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) { + 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); + vp->csa_finished = 1; + } + } } static enum hrtimer_restart @@ -1692,6 +1712,20 @@ 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_finished = 0; + 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 +1750,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 +2394,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 */