From patchwork Wed Sep 9 07:46:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 7144801 X-Patchwork-Delegate: johannes@sipsolutions.net 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 898079F314 for ; Wed, 9 Sep 2015 07:48:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A56F20964 for ; Wed, 9 Sep 2015 07:48:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 934A220838 for ; Wed, 9 Sep 2015 07:48:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753019AbbIIHs0 (ORCPT ); Wed, 9 Sep 2015 03:48:26 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35990 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752787AbbIIHsY (ORCPT ); Wed, 9 Sep 2015 03:48:24 -0400 Received: by wicgb1 with SMTP id gb1so105233050wic.1 for ; Wed, 09 Sep 2015 00:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TOhCoEwnDjMDMreTxZA58ceWz8SMSxVuuHl8IIXcpAc=; b=y8MJ3RAJfq1Y2caVt4AeqXZEMadki2WUSAGH3iYw65VcquMja5U56pgWZSp+Za+EIX BKMXWMZWJ0VUQ2Xnik+8AsaQMfSRY84W3f1orhG0wPLdWu9w1k0cSBAeu7p5AYOEGZgt Ye0MeT8NdttpD7H1r34isvU8jeUE9czTepEbryUx1xC/SRnQvN/OaUhQz/GfQeSWBKP3 pxvj73H9CynyE8PeuyRXJuT8hja/SAwbDEPq8rOyQhuOR7UQN+ZLx8hmI11Kr4kg0rlH j4DVDVUeP0Fn3CRIP4aewmmRq7XoxEK/Lkwyo7gISHZfk05OjvLTCe1oSa+B5SAr0/xH bOJA== X-Received: by 10.194.201.130 with SMTP id ka2mr26873299wjc.79.1441784903036; Wed, 09 Sep 2015 00:48:23 -0700 (PDT) Received: from hschaa-desktop.site (HSI-KBW-217-008-059-040.hsi.kabelbw.de. [217.8.59.40]) by smtp.gmail.com with ESMTPSA id ul1sm8780774wjc.30.2015.09.09.00.48.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 00:48:22 -0700 (PDT) From: Helmut Schaa To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net, nbd@openwrt.org, Helmut Schaa Subject: [PATCHv2] mac80211: Copy tx'ed beacons to monitor mode Date: Wed, 9 Sep 2015 09:46:32 +0200 Message-Id: <1441784792-8847-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1441193011-2040-2-git-send-email-helmut.schaa@googlemail.com> References: <1441193011-2040-2-git-send-email-helmut.schaa@googlemail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 When debugging wireless powersave issues on the AP side it's quite helpful to see our own beacons that are transmitted by the hardware/driver. However, this is not that easy since beacons don't pass through the regular TX queues. Preferably drivers would call ieee80211_tx_status also for tx'ed beacons but that's not always possible. Hence, just send a copy of each beacon generated by ieee80211_beacon_get_tim to monitor devices when they are getting fetched by the driver. Also add a HW flag IEEE80211_HW_BEACON_TX_STATUS that can be used by drivers to indicate that they report TX status for beacons. Signed-off-by: Helmut Schaa --- Changes since RFC: * don't send beacons to cooked monitors * avoid assignment within if condition * Introduce IEEE80211_HW_BEACON_TX_STATUS Changes since v1: * Invert logic to get shorter lines (<80 chars) include/net/mac80211.h | 4 ++++ net/mac80211/debugfs.c | 1 + net/mac80211/tx.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index e3314e5..b136ac5 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1892,6 +1892,9 @@ struct ieee80211_txq { * @IEEE80211_HW_TDLS_WIDER_BW: The device/driver supports wider bandwidth * than then BSS bandwidth for a TDLS link on the base channel. * + * @IEEE80211_HW_BEACON_TX_STATUS: The device/driver provides TX status + * for sent beacons. + * * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags { @@ -1925,6 +1928,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_SUPPORTS_CLONED_SKBS, IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS, IEEE80211_HW_TDLS_WIDER_BW, + IEEE80211_HW_BEACON_TX_STATUS, /* keep last, obviously */ NUM_IEEE80211_HW_FLAGS diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index ced6bf3..d55f5ba 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -123,6 +123,7 @@ static const char *hw_flag_names[NUM_IEEE80211_HW_FLAGS + 1] = { FLAG(SUPPORTS_CLONED_SKBS), FLAG(SINGLE_SCAN_ON_ALL_BANDS), FLAG(TDLS_WIDER_BW), + FLAG(BEACON_TX_STATUS), /* keep last for the build bug below */ (void *)0x1 diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 84e0e8c..e482f3e 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3512,6 +3512,9 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, { struct ieee80211_mutable_offsets offs = {}; struct sk_buff *bcn = __ieee80211_beacon_get(hw, vif, &offs, false); + struct sk_buff *copy; + struct ieee80211_supported_band *sband; + int shift; if (tim_offset) *tim_offset = offs.tim_offset; @@ -3519,6 +3522,19 @@ struct sk_buff *ieee80211_beacon_get_tim(struct ieee80211_hw *hw, if (tim_length) *tim_length = offs.tim_length; + if (ieee80211_hw_check(hw, BEACON_TX_STATUS) || + !hw_to_local(hw)->monitors) + return bcn; + + /* send a copy to monitor interfaces */ + copy = skb_copy(bcn, GFP_ATOMIC); + if (!copy) + return bcn; + + shift = ieee80211_vif_get_shift(vif); + sband = hw->wiphy->bands[ieee80211_get_sdata_band(vif_to_sdata(vif))]; + ieee80211_tx_monitor(hw_to_local(hw), copy, sband, 1, shift, false); + return bcn; } EXPORT_SYMBOL(ieee80211_beacon_get_tim);