mt76: unify mac_shared_key_setup
authorStanislaw Gruszka <sgruszka@redhat.com>
Wed, 29 Aug 2018 11:16:38 +0000 (13:16 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 4 Sep 2018 08:02:55 +0000 (11:02 +0300)
Merge mt76x{0,2} mac_shared_key_setup into common code.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt76/mt76x0/mac.c
drivers/net/wireless/mediatek/mt76/mt76x0/mac.h
drivers/net/wireless/mediatek/mt76/mt76x0/main.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_mac.h
drivers/net/wireless/mediatek/mt76/mt76x2_common.c
drivers/net/wireless/mediatek/mt76/mt76x2_init.c
drivers/net/wireless/mediatek/mt76/mt76x2_mac.h
drivers/net/wireless/mediatek/mt76/mt76x2_mac_common.c

index 4b5d482..6d0a6fb 100644 (file)
@@ -606,27 +606,3 @@ int mt76x0_mac_wcid_set_key(struct mt76x0_dev *dev, u8 idx,
 
        return 0;
 }
-
-int mt76x0_mac_shared_key_setup(struct mt76x0_dev *dev, u8 vif_idx, u8 key_idx,
-                             struct ieee80211_key_conf *key)
-{
-       enum mt76x02_cipher_type cipher;
-       u8 key_data[32];
-       u32 val;
-
-       cipher = mt76x02_mac_get_key_info(key, key_data);
-       if (cipher == MT_CIPHER_NONE && key)
-               return -EINVAL;
-
-       trace_mt76x0_set_shared_key(&dev->mt76, vif_idx, key_idx);
-
-       mt76_wr_copy(dev, MT_SKEY(vif_idx, key_idx),
-                       key_data, sizeof(key_data));
-
-       val = mt76_rr(dev, MT_SKEY_MODE(vif_idx));
-       val &= ~(MT_SKEY_MODE_MASK << MT_SKEY_MODE_SHIFT(vif_idx, key_idx));
-       val |= cipher << MT_SKEY_MODE_SHIFT(vif_idx, key_idx);
-       mt76_wr(dev, MT_SKEY_MODE(vif_idx), val);
-
-       return 0;
-}
index bea067b..d44ef1e 100644 (file)
@@ -143,8 +143,6 @@ int mt76x0_mac_wcid_set_key(struct mt76x0_dev *dev, u8 idx,
 void mt76x0_mac_wcid_set_rate(struct mt76x0_dev *dev, struct mt76_wcid *wcid,
                            const struct ieee80211_tx_rate *rate);
 
-int mt76x0_mac_shared_key_setup(struct mt76x0_dev *dev, u8 vif_idx, u8 key_idx,
-                             struct ieee80211_key_conf *key);
 u16 mt76x0_mac_tx_rate_val(struct mt76x0_dev *dev,
                         const struct ieee80211_tx_rate *rate, u8 *nss_val);
 struct mt76_tx_status
index 8fc270b..fb31c10 100644 (file)
@@ -264,7 +264,7 @@ mt76x0_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                                return ret;
                }
 
-               return mt76x0_mac_shared_key_setup(dev, mvif->idx, idx, key);
+               return mt76x02_mac_shared_key_setup(&dev->mt76, mvif->idx, idx, key);
        }
 
        return mt76x0_mac_wcid_set_key(dev, msta->wcid.idx, key);
index 7137fd2..6d45adc 100644 (file)
@@ -44,3 +44,26 @@ mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
        }
 }
 EXPORT_SYMBOL_GPL(mt76x02_mac_get_key_info);
+
+int mt76x02_mac_shared_key_setup(struct mt76_dev *dev, u8 vif_idx, u8 key_idx,
+                               struct ieee80211_key_conf *key)
+{
+       enum mt76x02_cipher_type cipher;
+       u8 key_data[32];
+       u32 val;
+
+       cipher = mt76x02_mac_get_key_info(key, key_data);
+       if (cipher == MT_CIPHER_NONE && key)
+               return -EOPNOTSUPP;
+
+       val = __mt76_rr(dev, MT_SKEY_MODE(vif_idx));
+       val &= ~(MT_SKEY_MODE_MASK << MT_SKEY_MODE_SHIFT(vif_idx, key_idx));
+       val |= cipher << MT_SKEY_MODE_SHIFT(vif_idx, key_idx);
+       __mt76_wr(dev, MT_SKEY_MODE(vif_idx), val);
+
+       __mt76_wr_copy(dev, MT_SKEY(vif_idx, key_idx), key_data,
+                      sizeof(key_data));
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mt76x02_mac_shared_key_setup);
index e06a1ff..6f8b8a1 100644 (file)
@@ -42,4 +42,6 @@ static inline bool mt76x02_wait_for_mac(struct mt76_dev *dev)
 enum mt76x02_cipher_type
 mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data);
 
+int mt76x02_mac_shared_key_setup(struct mt76_dev *dev, u8 vif_idx, u8 key_idx,
+                               struct ieee80211_key_conf *key);
 #endif
index fe0b394..56cceea 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "mt76x2.h"
+#include "mt76x02_mac.h"
 
 void mt76x2_txq_init(struct mt76x2_dev *dev, struct ieee80211_txq *txq)
 {
@@ -223,7 +224,7 @@ int mt76x2_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
                                return ret;
                }
 
-               return mt76x2_mac_shared_key_setup(dev, mvif->idx, idx, key);
+               return mt76x02_mac_shared_key_setup(&dev->mt76, mvif->idx, idx, key);
        }
 
        return mt76x2_mac_wcid_set_key(dev, msta->wcid.idx, key);
index 07ef0a3..1c5c355 100644 (file)
@@ -167,7 +167,7 @@ static int mt76x2_mac_reset(struct mt76x2_dev *dev, bool hard)
 
        for (i = 0; i < 16; i++)
                for (k = 0; k < 4; k++)
-                       mt76x2_mac_shared_key_setup(dev, i, k, NULL);
+                       mt76x02_mac_shared_key_setup(&dev->mt76, i, k, NULL);
 
        for (i = 0; i < 8; i++) {
                mt76x2_mac_set_bssid(dev, i, null_addr);
index 0f07fc1..4be2e0e 100644 (file)
@@ -175,9 +175,6 @@ void mt76x2_mac_wcid_set_rate(struct mt76x2_dev *dev, struct mt76_wcid *wcid,
                              const struct ieee80211_tx_rate *rate);
 void mt76x2_mac_wcid_set_drop(struct mt76x2_dev *dev, u8 idx, bool drop);
 
-int mt76x2_mac_shared_key_setup(struct mt76x2_dev *dev, u8 vif_idx, u8 key_idx,
-                               struct ieee80211_key_conf *key);
-
 int mt76x2_mac_set_beacon(struct mt76x2_dev *dev, u8 vif_idx,
                          struct sk_buff *skb);
 void mt76x2_mac_set_beacon_enable(struct mt76x2_dev *dev, u8 vif_idx, bool val);
index 92621fc..7359ef6 100644 (file)
@@ -229,29 +229,6 @@ out:
 }
 EXPORT_SYMBOL_GPL(mt76x2_send_tx_status);
 
-int mt76x2_mac_shared_key_setup(struct mt76x2_dev *dev, u8 vif_idx, u8 key_idx,
-                               struct ieee80211_key_conf *key)
-{
-       enum mt76x02_cipher_type cipher;
-       u8 key_data[32];
-       u32 val;
-
-       cipher = mt76x02_mac_get_key_info(key, key_data);
-       if (cipher == MT_CIPHER_NONE && key)
-               return -EOPNOTSUPP;
-
-       val = mt76_rr(dev, MT_SKEY_MODE(vif_idx));
-       val &= ~(MT_SKEY_MODE_MASK << MT_SKEY_MODE_SHIFT(vif_idx, key_idx));
-       val |= cipher << MT_SKEY_MODE_SHIFT(vif_idx, key_idx);
-       mt76_wr(dev, MT_SKEY_MODE(vif_idx), val);
-
-       mt76_wr_copy(dev, MT_SKEY(vif_idx, key_idx), key_data,
-                    sizeof(key_data));
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(mt76x2_mac_shared_key_setup);
-
 int mt76x2_mac_wcid_set_key(struct mt76x2_dev *dev, u8 idx,
                            struct ieee80211_key_conf *key)
 {