From patchwork Tue Feb 16 14:27:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 8327251 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 6754D9F399 for ; Tue, 16 Feb 2016 14:27:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A9E22027D for ; Tue, 16 Feb 2016 14:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C79D20204 for ; Tue, 16 Feb 2016 14:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932537AbcBPO1e (ORCPT ); Tue, 16 Feb 2016 09:27:34 -0500 Received: from mail-wm0-f44.google.com ([74.125.82.44]:35498 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932498AbcBPO1d (ORCPT ); Tue, 16 Feb 2016 09:27:33 -0500 Received: by mail-wm0-f44.google.com with SMTP id c200so164225457wme.0 for ; Tue, 16 Feb 2016 06:27:33 -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=G2mpa7cRDaW8Ria/RhFe+mMoeJ+6Z8uj7wEfuxG49xU=; b=cci2O7NqNtGixvWsYqjHPTwet7SLrLGgy1pMINsZVRxEBeKkExG1yB/P3j/2vMBy/d EXS5Pju8f565PsZ2AC2h+UZ9Jndw2X8SPCNUNXY2Js5lPe/ldAoO6guuQhmEzRFBDJ1c uZ4+d7YCGtuJ4lZJW2f5F0dJnzGHsxjhp8S639VJLKcMUUYmin+IIeaL4Hxwc+YvxAJh PY7vLdyBmzn42tBflXSbn2uIDKrUt8hMGZq/5iqRaVrh97PyRyO77/pdYMTvHKwTTOj4 N+dkhuz6axBpaXv34fwyonj2zQdgobIXcw0xd8275DTufpznjt4K6V9mZppi4fJ4u9Ep lZuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=G2mpa7cRDaW8Ria/RhFe+mMoeJ+6Z8uj7wEfuxG49xU=; b=gidRSn2JMCEzsd+a47EUWrMz9hOEFDWO1WPL6iZSbHtkeNNzsKB+4701yKB9h77lHv u9Ed1JNXDICOwzp3d1OSP1qkHIiskC5FvAZ5493PD0wDPi/ecpjjuEJWDlN5/XK4dvWp YF95o8qunvJNi/3yW2Oe3n6wOJiQqJTeVhesFCkrY+C93W/zWhxqhoFG7J3jJI1v44Kt q/Sd2pQetEjtUFlSKxamO+K7vB7LYp/1X5nE1dYnFj4opVWB7x5Dt34jz65AqomzoTL5 rn9IBiO4PTln3eJQk1rDVuLa5lzhBi0DqrpNEnORRZtYzOdtxw4fwpc6TWzq97zq8smr zPhw== X-Gm-Message-State: AG10YOSD4ezHTNSAPPGg5tbhGibxQCdjagCIx3/1+y1IxIUo2TVvP9kCClFOKeeklvYYRA== X-Received: by 10.194.85.193 with SMTP id j1mr22805655wjz.122.1455632852869; Tue, 16 Feb 2016 06:27:32 -0800 (PST) Received: from localhost.localdomain (net-188-152-170-117.cust.dsl.teletu.it. [188.152.170.117]) by smtp.gmail.com with ESMTPSA id h132sm20798243wmf.9.2016.02.16.06.27.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Feb 2016 06:27:31 -0800 (PST) From: Lorenzo Bianconi To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH] mac80211: parse VHT info in injected frames Date: Tue, 16 Feb 2016 15:27:30 +0100 Message-Id: <1455632850-13733-1-git-send-email-lorenzo.bianconi83@gmail.com> X-Mailer: git-send-email 2.5.0 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, 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 Add VHT radiotap parsing support to ieee80211_parse_tx_radiotap(). That capability has been tested using a d-link dir-860l rev b1 running OpenWrt trunk and mt76 driver Signed-off-by: Lorenzo Bianconi --- Documentation/networking/mac80211-injection.txt | 10 ++++++++ net/mac80211/tx.c | 31 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/Documentation/networking/mac80211-injection.txt b/Documentation/networking/mac80211-injection.txt index ec8f934..ef57cc0 100644 --- a/Documentation/networking/mac80211-injection.txt +++ b/Documentation/networking/mac80211-injection.txt @@ -45,6 +45,16 @@ radiotap headers and used to control injection: number of retries when either IEEE80211_RADIOTAP_RATE or IEEE80211_RADIOTAP_MCS was used + * IEEE80211_RADIOTAP_VHT + + VHT rate for the transmission (only for devices without own rate control). + Also some flags are parsed + + IEEE80211_TX_RC_SHORT_GI: use short guard interval + IEEE80211_TX_RC_40_MHZ_WIDTH: send in HT40 mode + IEEE80211_TX_RC_80_MHZ_WIDTH: send in HT80 mode + IEEE80211_TX_RC_160_MHZ_WIDTH: send in HT160 mode + The injection code can also skip all other currently defined radiotap fields facilitating replay of captured radiotap headers directly. diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 7bb67fa..17db889 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1692,6 +1692,8 @@ static bool ieee80211_parse_tx_radiotap(struct ieee80211_local *local, u8 rate_retries = 0; u16 rate_flags = 0; u8 mcs_known, mcs_flags; + u16 vht_known; + u8 vht_mcs = 0, vht_nss = 0; int i; info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | @@ -1772,6 +1774,32 @@ static bool ieee80211_parse_tx_radiotap(struct ieee80211_local *local, rate_flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; break; + case IEEE80211_RADIOTAP_VHT: + vht_known = get_unaligned_le16(iterator.this_arg); + rate_found = true; + + rate_flags = IEEE80211_TX_RC_VHT_MCS; + if ((vht_known & IEEE80211_RADIOTAP_VHT_KNOWN_GI) && + (iterator.this_arg[2] & + IEEE80211_RADIOTAP_VHT_FLAG_SGI)) + rate_flags |= IEEE80211_TX_RC_SHORT_GI; + if (vht_known & + IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH) { + if (iterator.this_arg[3] == 1) + rate_flags |= + IEEE80211_TX_RC_40_MHZ_WIDTH; + else if (iterator.this_arg[3] == 4) + rate_flags |= + IEEE80211_TX_RC_80_MHZ_WIDTH; + else if (iterator.this_arg[3] == 11) + rate_flags |= + IEEE80211_TX_RC_160_MHZ_WIDTH; + } + + vht_mcs = iterator.this_arg[4] >> 4; + vht_nss = iterator.this_arg[4] & 0xF; + break; + /* * Please update the file * Documentation/networking/mac80211-injection.txt @@ -1797,6 +1825,9 @@ static bool ieee80211_parse_tx_radiotap(struct ieee80211_local *local, if (rate_flags & IEEE80211_TX_RC_MCS) { info->control.rates[0].idx = rate; + } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) { + ieee80211_rate_set_vht(info->control.rates, vht_mcs, + vht_nss); } else { for (i = 0; i < sband->n_bitrates; i++) { if (rate * 5 != sband->bitrates[i].bitrate)