From patchwork Thu Jul 10 12:27:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rostislav Lisovy X-Patchwork-Id: 4523381 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F7D9BEEAA for ; Thu, 10 Jul 2014 12:28:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4707A201D5 for ; Thu, 10 Jul 2014 12:28:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5ABA82016C for ; Thu, 10 Jul 2014 12:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752163AbaGJM16 (ORCPT ); Thu, 10 Jul 2014 08:27:58 -0400 Received: from mail-we0-f175.google.com ([74.125.82.175]:45846 "EHLO mail-we0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbaGJM15 (ORCPT ); Thu, 10 Jul 2014 08:27:57 -0400 Received: by mail-we0-f175.google.com with SMTP id k48so8778193wev.34 for ; Thu, 10 Jul 2014 05:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wKUwH8yquCbk9CUeJ24Pbv9MTr0otGb8VQbuM+fXRHk=; b=K4OgJGkzKL8lMJI+3DKzJkR5eucUD2+Oz5ZypwIb0mU6uTCiJ+FLZDAjEyE5ny8Ejd D6ViOTMNsHEOWLpJ9XRrqR6o0laVOoXP+uJ8aC+2qzuE4ymL0TiNvQTlBnRwybqeFaIa eKSC+Y9uO3myLokiLvjjn+YfUu2FA/BFIMHWYR7GkjeEiXAjZykKQrIlj3QOzBtB0Rkv JH6og04yZHeGCnBRTXnPZAuCviT8v4QHEMPcp3p6nSyuuZvYg6GSyX+DFM+0xuRSEtb8 v8DK9YPX/vr3JwB1XVaNnNwUksMjQVfD6sVvWkZc6qMFY/6ow2YTRCjp6pCaNqNtN+wi IGQA== X-Received: by 10.180.20.14 with SMTP id j14mr13834559wie.48.1404995276288; Thu, 10 Jul 2014 05:27:56 -0700 (PDT) Received: from c2c-vostro1.felk.cvut.cz ([147.32.86.112]) by mx.google.com with ESMTPSA id w10sm29922016wie.22.2014.07.10.05.27.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 05:27:55 -0700 (PDT) From: Rostislav Lisovy X-Google-Original-From: Rostislav Lisovy To: Johannes Berg , "John W. Linville" , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michal Sojka , s.sander@nordsys.de, jan-niklas.meier@volkswagen.de, Rostislav Lisovy Subject: [PATCH] mac80211: Parse IEEE80211_RADIOTAP_RATE on TX Date: Thu, 10 Jul 2014 14:27:41 +0200 Message-Id: <1404995261-6626-1-git-send-email-rostislav.lisovy@fel.cvut.cz> X-Mailer: git-send-email 2.0.0.rc4 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.4 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 support for parsing radiotap field IEEE80211_RADIOTAP_RATE for transmitted frames. Use the provided datarate value in info->control.rates[] array so it will be used for transmission. Signed-off-by: Rostislav Lisovy --- This feature is essential for Transmit Datarate Control (TDC) in future implementation of IEEE 802.11-2012 "Wireless Access for the Vehicular Environment" support. include/net/mac80211.h | 2 ++ net/mac80211/rate.c | 4 ++++ net/mac80211/tx.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 9ce5cb1..7ba8faa 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -549,11 +549,13 @@ enum mac80211_tx_info_flags { * * @IEEE80211_TX_CTRL_PORT_CTRL_PROTO: this frame is a port control * protocol frame (e.g. EAP) + * @IEEE80211_TX_CTRL_USERRATE: Fixed datarate set by the user * * These flags are used in tx_info->control.flags. */ enum mac80211_tx_control_flags { IEEE80211_TX_CTRL_PORT_CTRL_PROTO = BIT(0), + IEEE80211_TX_CTRL_USERRATE = BIT(1), }; /* diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 8fdadfd..1111dee 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -673,6 +673,10 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata, priv_sta = sta->rate_ctrl_priv; } + if ((info->flags & IEEE80211_TX_CTL_INJECTED) && + (info->control.flags & IEEE80211_TX_CTRL_USERRATE)) + return; + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { info->control.rates[i].idx = -1; info->control.rates[i].flags = 0; diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 865bdaf..2099c70 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1541,7 +1541,11 @@ static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, NULL); + struct ieee80211_sub_if_data *sdata; + struct ieee80211_supported_band *sband; + int rate; u16 txflags; + int i, j; info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | IEEE80211_TX_CTL_DONTFRAG; @@ -1592,6 +1596,45 @@ static bool ieee80211_parse_tx_radiotap(struct sk_buff *skb) info->flags |= IEEE80211_TX_CTL_NO_ACK; break; + case IEEE80211_RADIOTAP_RATE: + if (!(*iterator.this_arg)) + break; + + rate = 0; + sdata = vif_to_sdata(info->control.vif); + sband = sdata->wdev.wiphy->bands[info->band]; + for (i = 0; i < sband->n_bitrates; i++) { + /* Radiotap datarate: Units of 500 Kbps + * ieee80211_rate.bitrate: Units of 100 Kbps + */ + if ((sband->bitrates[i].bitrate * 2) == + ((*iterator.this_arg) * 10)) { + rate = i; + break; + } + } + + if (!rate) + break; + + info->flags |= IEEE80211_TX_CTRL_USERRATE; + + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { + if (info->control.rates[i].idx < 0) + break; + + /* Rate masking supports only legacy + * rates for now + */ + if (info->control.rates[i].flags & + IEEE80211_TX_RC_MCS) + continue; + + for (j = 0; j < sband->n_bitrates; j++) + info->control.rates[i].idx = rate; + } + break; + /* * Please update the file * Documentation/networking/mac80211-injection.txt