From patchwork Mon Apr 15 15:09:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karl Beldan X-Patchwork-Id: 2445451 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3D2C0DF2E5 for ; Mon, 15 Apr 2013 15:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752995Ab3DOPOL (ORCPT ); Mon, 15 Apr 2013 11:14:11 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:60009 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467Ab3DOPOK (ORCPT ); Mon, 15 Apr 2013 11:14:10 -0400 Received: by mail-we0-f170.google.com with SMTP id z2so3744370wey.15 for ; Mon, 15 Apr 2013 08:14:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=/0c8lkbi+kzweLTu3PAxIdlkh8nwGTmvrRA7zLyYpuo=; b=Lso8VpxNSDD4IozhDqBXwhGSecX/Yyw5AYZMAaVCBz2thMLxz4NZg9cYPmUROL4GV6 7nTrsQgrz03BWnw3B///5vy/DzaVJU2clOaThdsXEwoSLCTl3rE3Iv2ekY2Pr1UJFBcK VP4bHdTGrb7hy/b+j7AzmZ8sFmpGxwSo1Fr5T6Qfi6935kE2zT/x7mLTCSgk54354dA1 gtAGyacM6J2LmOJlb0NPCkWr2xUZvBiWOfuZXxiCp4HV/LdSXiHaqU+MkeBKlDF+epJD YPtxywRJkAQfwdhDtUQ8PO4NAABIofFFHhSxsWP8x16HjvlJTDPqi/aUtOgauYz7ibhE wX8A== X-Received: by 10.180.39.207 with SMTP id r15mr12927794wik.16.1366038848774; Mon, 15 Apr 2013 08:14:08 -0700 (PDT) Received: from magnum.frso.rivierawaves.com (vpn.rivierawaves.com. [91.151.119.162]) by mx.google.com with ESMTPS id j10sm6396488wie.1.2013.04.15.08.14.07 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 08:14:08 -0700 (PDT) From: Karl Beldan To: Johannes Berg Cc: linux-wireless , Karl Beldan , Karl Beldan Subject: [PATCH 1/2] mac80211: VHT off-by-one NSS Date: Mon, 15 Apr 2013 17:09:29 +0200 Message-Id: <1366038570-12457-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 From: Karl Beldan The number of VHT spatial streams (NSS) is found in: - s8 ieee80211_tx_rate.rate.idx[6:4] (tx - filled by rate control) - u8 ieee80211_rx_status.vht_nss (rx - filled by driver) Tx discriminates valid rates indexes with the sign bit and encodes NSS starting from 0 to 7 (note this matches some hw encodings e.g IWLMVM). Rx does not have the same constraints, and encodes NSS starting from 1 to 8 (note this matches what wireshark expects in the radiotap header). To handle ieee80211_tx_rate.rate.idx[6:4] ieee80211_rate_set_vht() and ieee80211_rate_get_vht_nss() assume their nss parameter and return value respectively runs from 0 to 7. ATM, there are only 2 users of these: cfg.c:sta_set_rate_info_t() and iwlwifi/mvm/tx.c:iwl_mvm_hwrate_to_tx_control(), but both assume nss runs from 1 to 8. This patch fixes this inconsistency by making ieee80211_rate_set_vht() and ieee80211_rate_get_vht_nss() handle an nss running from 1 to 8. Signed-off-by: Karl Beldan --- This might feel very verbose for such a trivial thing. include/net/mac80211.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 0dde213..2317ca9 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -601,8 +601,8 @@ static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate, u8 mcs, u8 nss) { WARN_ON(mcs & ~0xF); - WARN_ON(nss & ~0x7); - rate->idx = (nss << 4) | mcs; + WARN_ON((nss - 1) & ~0x7); + rate->idx = ((nss - 1) << 4) | mcs; } static inline u8 @@ -614,7 +614,7 @@ ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate) static inline u8 ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) { - return rate->idx >> 4; + return (rate->idx >> 4) + 1; } /**