From patchwork Sat Jan 19 15:00:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10772065 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-2.web.codeaurora.org (Postfix) with ESMTP id 025E16C2 for ; Sat, 19 Jan 2019 15:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0632DA84 for ; Sat, 19 Jan 2019 15:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF5192DAAA; Sat, 19 Jan 2019 15:00:34 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 621572DA84 for ; Sat, 19 Jan 2019 15:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbfASPAc (ORCPT ); Sat, 19 Jan 2019 10:00:32 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33433 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728237AbfASPAc (ORCPT ); Sat, 19 Jan 2019 10:00:32 -0500 Received: by mail-wr1-f68.google.com with SMTP id c14so18479067wrr.0 for ; Sat, 19 Jan 2019 07:00:31 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=UOSHYtf2C7el6mefqufgOVFniHJMg/J6YU/SD1ztmBk=; b=MYJPOSIU2OINeSIwm3t+m/bTN5cERbcYgy28ZpCuHHBcpYaFqkQgNTnD/2Gd9Hf4qS WoMwKkkfpbL0na0OvwwdZvVqrjkEd8E8a2//Yyb9EyZ78AeVbmVatiA81/cdWBoruwMF ivdPiQnAul/x154nKsZXQDIthNiNO6qfz9HgWxCwtbK3OJLUdg3GS8Des86hOewrKCMf ZXXykG/doQ1r+3GUDY+wSnCxBpKEimDAj1y5/0SjnXI4nuQUDwvx/Ox1rwj0jbElxU79 iEA+2SRHvsEcVxXaoEegOyHy15KdSs926kbvvUrQaBsHi/a1s9EOyttdQ0yCSyWrhoip Aepw== X-Gm-Message-State: AJcUukcBa4xVwGrBKXzpDkHVcDF5bIBruvkc3FlhfQSfNjIKcboFBOOv gtm/8vwletYKLPtmsBVe42UVlg== X-Google-Smtp-Source: ALg8bN4tlcSXeA24MMEtOKSDGDph5guisS/WcSDLQ3NStRTUcbtxCzBt9W6JYjZ45YGWNG1SjDFXPA== X-Received: by 2002:adf:9bda:: with SMTP id e26mr19862902wrc.295.1547910030434; Sat, 19 Jan 2019 07:00:30 -0800 (PST) Received: from localhost.localdomain ([151.21.137.205]) by smtp.gmail.com with ESMTPSA id k128sm57531625wmd.37.2019.01.19.07.00.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 19 Jan 2019 07:00:29 -0800 (PST) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com Subject: [PATCH] mt76: do not report out-of-range rx nss Date: Sat, 19 Jan 2019 16:00:26 +0100 Message-Id: <611062117f1037517e22c589e100abb767328cc7.1547909691.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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 Take into account device rx stream in mt76x02_mac_process_rate in order to not report wrong number of rx spatial stream to mac80211. The issue has been reported on mt76x0 device which is 1x1:1 however the hw sometimes reports rx nss equal to 2 Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index 68d01e136fa0..ce9bb702045f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c @@ -476,7 +476,9 @@ void mt76x02_send_tx_status(struct mt76x02_dev *dev, } static int -mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate) +mt76x02_mac_process_rate(struct mt76x02_dev *dev, + struct mt76_rx_status *status, + u16 rate) { u8 idx = FIELD_GET(MT_RXWI_RATE_INDEX, rate); @@ -508,11 +510,15 @@ mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate) status->encoding = RX_ENC_HT; status->rate_idx = idx; break; - case MT_PHY_TYPE_VHT: + case MT_PHY_TYPE_VHT: { + u8 n_rxstream = dev->mt76.chainmask & 0xf; + status->encoding = RX_ENC_VHT; status->rate_idx = FIELD_GET(MT_RATE_INDEX_VHT_IDX, idx); - status->nss = FIELD_GET(MT_RATE_INDEX_VHT_NSS, idx) + 1; + status->nss = min_t(u8, n_rxstream, + FIELD_GET(MT_RATE_INDEX_VHT_NSS, idx) + 1); break; + } default: return -EINVAL; } @@ -656,7 +662,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb, status->tid = FIELD_GET(MT_RXWI_TID, tid_sn); status->seqno = FIELD_GET(MT_RXWI_SN, tid_sn); - return mt76x02_mac_process_rate(status, rate); + return mt76x02_mac_process_rate(dev, status, rate); } void mt76x02_mac_poll_tx_status(struct mt76x02_dev *dev, bool irq)