From patchwork Sat Feb 24 15:54:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10240419 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7F4B6602A0 for ; Sat, 24 Feb 2018 15:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E78E29BC9 for ; Sat, 24 Feb 2018 15:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6320D29C2E; Sat, 24 Feb 2018 15:54:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B81529BC9 for ; Sat, 24 Feb 2018 15:54:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751508AbeBXPya (ORCPT ); Sat, 24 Feb 2018 10:54:30 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:45557 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751446AbeBXPy2 (ORCPT ); Sat, 24 Feb 2018 10:54:28 -0500 Received: by mail-wr0-f195.google.com with SMTP id p104so16935362wrc.12 for ; Sat, 24 Feb 2018 07:54:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Z0pkjLWzSKzT1NzgRbSO1N976fmbVg9co7FesEDNURM=; b=mRJgshT+c9OX9s8USf5f+PhWW5X1a8GJEim8nFUsQn6DP0WJDg0hEQ33cG/38ngabp MPiroJWknpDfbjUjiqxIPAzw9Kri4Xy0R/g87sXzR4elbsJeX0pANyW9xkk4FArQSX7C W6ZHSvfREJN4Ssvxy1dzuVlU+nSDFyilRCbzebLRkMHNrSTsmJSsme9hB5pcYppv9UQi dODYL46VgdCq5I7N1/PVsgE3ggnRi341xP2rGsygdvndSmjh0GZEYpLQ3gVrjR9Ha78H Y3aWAIwXu2cpm+2odfoyNKC7liKiMNd8qOe2ei/qVd8iTVvZ8nXZI9uxk9//MTm+S1Qs t6Vg== X-Gm-Message-State: APf1xPBf/uSkuJfBE9HySsOW1dX1zuVrxMgR058j00hHXNzdeFm1CcIy s1p0IoOlrY97CBeJyJ/+6/Sh9REao/ahLw== X-Google-Smtp-Source: AH8x224fHzZHWO1yUSRxMujRVwR879PhB4DaFKAwmwjfW6lD2Z5EcPg/MGw2azR42hKXPvPh3KlJJw== X-Received: by 10.223.151.129 with SMTP id s1mr4948177wrb.206.1519487667355; Sat, 24 Feb 2018 07:54:27 -0800 (PST) Received: from localhost.localdomain ([151.66.2.62]) by smtp.gmail.com with ESMTPSA id o204sm4307297wma.1.2018.02.24.07.54.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Feb 2018 07:54:26 -0800 (PST) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org Subject: [PATCH 2/3] mt76: add mt76_init_stream_cap routine Date: Sat, 24 Feb 2018 16:54:13 +0100 Message-Id: <20180224155414.31063-3-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.16.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add mt76_init_stream_cap utility routine to set ht/vht sta capabilities related to number of streams currently used by the device (it will be used by mac80211 set_antenna callback) Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mac80211.c | 56 +++++++++++++++++++-------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index ec94b86a37fd..a2a382a13466 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -119,6 +119,43 @@ static int mt76_led_init(struct mt76_dev *dev) return devm_led_classdev_register(dev->dev, &dev->led_cdev); } +static void mt76_init_stream_cap(struct mt76_dev *dev, + struct ieee80211_supported_band *sband, + bool vht) +{ + struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; + int i, nstream = __sw_hweight8(dev->antenna_mask); + struct ieee80211_sta_vht_cap *vht_cap; + u16 mcs_map = 0; + + if (nstream > 1) + ht_cap->cap |= IEEE80211_HT_CAP_TX_STBC; + else + ht_cap->cap &= ~IEEE80211_HT_CAP_TX_STBC; + + for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; i++) + ht_cap->mcs.rx_mask[i] = i < nstream ? 0xff : 0; + + if (!vht) + return; + + vht_cap = &sband->vht_cap; + if (nstream > 1) + vht_cap->cap |= IEEE80211_VHT_CAP_TXSTBC; + else + vht_cap->cap &= ~IEEE80211_VHT_CAP_TXSTBC; + + for (i = 0; i < 8; i++) { + if (i < nstream) + mcs_map |= (IEEE80211_VHT_MCS_SUPPORT_0_9 << (i * 2)); + else + mcs_map |= + (IEEE80211_VHT_MCS_NOT_SUPPORTED << (i * 2)); + } + vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); + vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); +} + static int mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, const struct ieee80211_channel *chan, int n_chan, @@ -128,7 +165,6 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, struct ieee80211_sta_ht_cap *ht_cap; struct ieee80211_sta_vht_cap *vht_cap; void *chanlist; - u16 mcs_map; int size; size = n_chan * sizeof(*chan); @@ -153,34 +189,20 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_TX_STBC | (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); - ht_cap->mcs.rx_mask[0] = 0xff; - ht_cap->mcs.rx_mask[1] = 0xff; ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; ht_cap->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; ht_cap->ampdu_density = IEEE80211_HT_MPDU_DENSITY_4; + mt76_init_stream_cap(dev, sband, vht); + if (!vht) return 0; vht_cap = &sband->vht_cap; vht_cap->vht_supported = true; - - mcs_map = (IEEE80211_VHT_MCS_SUPPORT_0_9 << (0 * 2)) | - (IEEE80211_VHT_MCS_SUPPORT_0_9 << (1 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (2 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (3 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (4 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (5 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (6 * 2)) | - (IEEE80211_VHT_MCS_NOT_SUPPORTED << (7 * 2)); - - vht_cap->vht_mcs.rx_mcs_map = cpu_to_le16(mcs_map); - vht_cap->vht_mcs.tx_mcs_map = cpu_to_le16(mcs_map); vht_cap->cap |= IEEE80211_VHT_CAP_RXLDPC | - IEEE80211_VHT_CAP_TXSTBC | IEEE80211_VHT_CAP_RXSTBC_1 | IEEE80211_VHT_CAP_SHORT_GI_80;