mt76: move mt76_get_rate in mt76-module
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 29 May 2019 08:25:55 +0000 (10:25 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 27 Jun 2019 10:58:13 +0000 (12:58 +0200)
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 <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7603/mac.c
drivers/net/wireless/mediatek/mt76/mt7615/mac.c

index f9e8397..ec9efb7 100644 (file)
@@ -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);
index eef0e5a..00ae1d6 100644 (file)
@@ -760,6 +760,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);
index 5c09b2d..2648fa3 100644 (file)
@@ -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 @@ out:
                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:
index 1547bce..7ca2e31 100644 (file)
@@ -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 @@ out:
                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: