Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6024274ybi; Wed, 29 May 2019 01:28:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxLmNjGfqc4o8mD0kMrAxr3DPabB8n+9wj/Lc4di777/S0qKVEgpQIwR+seIUNYFrVjjxg X-Received: by 2002:a65:5248:: with SMTP id q8mr12797492pgp.92.1559118494102; Wed, 29 May 2019 01:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559118494; cv=none; d=google.com; s=arc-20160816; b=gt/TDHg+pkXkCFKdaCuVF9ZhKcNgNcohFXzFFWauT6ZhBOYOsmJID7QLZA/0q7ZVYm M6ykWBNizoZRhNkMVBDrE/mY4fEnoGca+IwK3f2l15nxhdVRUU4kP8qt6CL50F3nm4jN sLL6LH66j/gP6JCQEIbN4FZKKgjz89MAKMC7BKH45gbhTcd0N4jbKBRQSymuLFwn7tWk 5lT8CtFSketCKzRrdtTbvesNlatf4oYpulUbX7oRSrnNoPpCGgQmIGmQx2uEh58Yk5Bx HEmjLgBofKKmlUnpahsvFG1ishZpg8fy6RfY/0Hqf2XqRDBP2EjQkCjf96y5+axyJs8k 8Uqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5abx3jYQvXTeYD+kAxLKCJYqzpqZmDOdZ3zOA9H2MHw=; b=ZhmyZHpIsK7a/FgVij0w86NVv0dMDwS/BYsrbwTWaOzve59FeQvu2pSidMGBbClwxh 6bgCFAqud96OiE+NuNhRGGNGvTERlu68d2Zxvz+rRT3IukB6yGk1Gdfs7pZBxAJJuX41 dvu9TuYR2Exg0W4rMl0e8Z4gpSnW4uXzz7wgl1179fx8veT8B1HtbUKBPJN5/zpmrO5u atY8EjczF8tOsNrBGPdl/JcWpTb+be9wjm39bcUhWz+7pY7hVvEkP9HfovnhQEF/RzhZ vUs71sY514NjPPTSPrxc/QduR9X1MeOlaTWPjtfLxaVIjzh0Lp8Bsf2o5R65DncKJl3p GGiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YkZ56bnC; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15si22717633pgk.260.2019.05.29.01.27.52; Wed, 29 May 2019 01:28:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YkZ56bnC; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbfE2I0I (ORCPT + 99 others); Wed, 29 May 2019 04:26:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:50464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725914AbfE2I0I (ORCPT ); Wed, 29 May 2019 04:26:08 -0400 Received: from lore-desk.lan (unknown [151.66.7.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E85BF20665; Wed, 29 May 2019 08:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559118367; bh=YnvWoDdrijA6cn0+NRNDW6xHDlEOP1OH+96LBCQYHFE=; h=From:To:Cc:Subject:Date:From; b=YkZ56bnCOAKNLM4J/B5L41Z4pe2sq9rXA5aAxGua1+/cyzvYkfqBEC/vk5zLzoWqR 1gVJ0fF8feS7kyA8/7DgQlHSSn3P7bcNkDsMGLU3VHbwBoC/LUkeKVWF79YEXAfJO1 G2nue9FD4ctL8Ob8tGKzrc2KAgkpEaCVwDoybqfA= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com, royluo@google.com Subject: [PATCH] mt76: move mt76_get_rate in mt76-module Date: Wed, 29 May 2019 10:25:55 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Move mt7603_get_rate in mac80211.c and rename it to mt76_get_rate since it is shared between mt7603 and mt7615 drivers Signed-off-by: Lorenzo Bianconi --- This patch is based on 'mt76: move mt76_insert_ccmp_hdr in mt76-module' https://patchwork.kernel.org/patch/10942973/ --- drivers/net/wireless/mediatek/mt76/mac80211.c | 24 +++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 3 ++ .../net/wireless/mediatek/mt76/mt7603/mac.c | 30 ++----------------- .../net/wireless/mediatek/mt76/mt7615/mac.c | 30 ++----------------- 4 files changed, 33 insertions(+), 54 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index f9e83971902e..ec9efb79985f 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c @@ -854,3 +854,27 @@ void mt76_insert_ccmp_hdr(struct sk_buff *skb, u8 key_id) status->flag &= ~RX_FLAG_IV_STRIPPED; } EXPORT_SYMBOL_GPL(mt76_insert_ccmp_hdr); + +int mt76_get_rate(struct mt76_dev *dev, + struct ieee80211_supported_band *sband, + int idx, bool cck) +{ + int i, offset = 0, len = sband->n_bitrates; + + if (cck) { + if (sband == &dev->sband_5g.sband) + return 0; + + idx &= ~BIT(2); /* short preamble */ + } else if (sband == &dev->sband_2g.sband) { + offset = 4; + } + + for (i = offset; i < len; i++) { + if ((sband->bitrates[i].hw_value & GENMASK(7, 0)) == idx) + return i; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mt76_get_rate); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 8edf476f9f2f..97a1296562d0 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -751,6 +751,9 @@ void mt76_csa_finish(struct mt76_dev *dev); int mt76_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set); void mt76_insert_ccmp_hdr(struct sk_buff *skb, u8 key_id); +int mt76_get_rate(struct mt76_dev *dev, + struct ieee80211_supported_band *sband, + int idx, bool cck); /* internal */ void mt76_tx_free(struct mt76_dev *dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 5c09b2dbf3fd..2648fa333f93 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c @@ -370,31 +370,6 @@ void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, mt76_rmw(dev, addr + (15 * 4), tid_mask, tid_val); } -static int -mt7603_get_rate(struct mt7603_dev *dev, struct ieee80211_supported_band *sband, - int idx, bool cck) -{ - int offset = 0; - int len = sband->n_bitrates; - int i; - - if (cck) { - if (sband == &dev->mt76.sband_5g.sband) - return 0; - - idx &= ~BIT(2); /* short preamble */ - } else if (sband == &dev->mt76.sband_2g.sband) { - offset = 4; - } - - for (i = offset; i < len; i++) { - if ((sband->bitrates[i].hw_value & GENMASK(7, 0)) == idx) - return i; - } - - return 0; -} - static struct mt76_wcid * mt7603_rx_get_wcid(struct mt7603_dev *dev, u8 idx, bool unicast) { @@ -508,7 +483,7 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb) cck = true; /* fall through */ case MT_PHY_TYPE_OFDM: - i = mt7603_get_rate(dev, sband, i, cck); + i = mt76_get_rate(&dev->mt76, sband, i, cck); break; case MT_PHY_TYPE_HT_GF: case MT_PHY_TYPE_HT: @@ -1018,7 +993,8 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta, else sband = &dev->mt76.sband_2g.sband; final_rate &= GENMASK(5, 0); - final_rate = mt7603_get_rate(dev, sband, final_rate, cck); + final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, + cck); final_rate_flags = 0; break; case MT_PHY_TYPE_HT_GF: diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index 1547bce561d3..7ca2e31f96fc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -36,31 +36,6 @@ static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev, return &sta->vif->sta.wcid; } -static int mt7615_get_rate(struct mt7615_dev *dev, - struct ieee80211_supported_band *sband, - int idx, bool cck) -{ - int offset = 0; - int len = sband->n_bitrates; - int i; - - if (cck) { - if (sband == &dev->mt76.sband_5g.sband) - return 0; - - idx &= ~BIT(2); /* short preamble */ - } else if (sband == &dev->mt76.sband_2g.sband) { - offset = 4; - } - - for (i = offset; i < len; i++) { - if ((sband->bitrates[i].hw_value & GENMASK(7, 0)) == idx) - return i; - } - - return 0; -} - int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) { struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb; @@ -154,7 +129,7 @@ int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) cck = true; /* fall through */ case MT_PHY_TYPE_OFDM: - i = mt7615_get_rate(dev, sband, i, cck); + i = mt76_get_rate(&dev->mt76, sband, i, cck); break; case MT_PHY_TYPE_HT_GF: case MT_PHY_TYPE_HT: @@ -608,7 +583,8 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta, else sband = &dev->mt76.sband_2g.sband; final_rate &= MT_TX_RATE_IDX; - final_rate = mt7615_get_rate(dev, sband, final_rate, cck); + final_rate = mt76_get_rate(&dev->mt76, sband, final_rate, + cck); final_rate_flags = 0; break; case MT_PHY_TYPE_HT_GF: -- 2.21.0