mt76: connac: move mt76_connac_mcu_get_cipher in common code
authorLorenzo Bianconi <lorenzo@kernel.org>
Sun, 19 Dec 2021 17:40:11 +0000 (18:40 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Feb 2022 12:57:57 +0000 (13:57 +0100)
Move mt76_connac_mcu_get_cipher in mt76-connac code and remove
duplicated code from mt7921 and mt7915 driver.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c

index bd93697b7d4b72166bac9fea3824bf83aa7814f0..756daf1ce6b8f0795ccbdf22d79440c6f25ff413 100644 (file)
@@ -1428,6 +1428,33 @@ struct mt76_connac_config {
        u8 data[320];
 } __packed;
 
+static inline enum mcu_cipher_type
+mt76_connac_mcu_get_cipher(int cipher)
+{
+       switch (cipher) {
+       case WLAN_CIPHER_SUITE_WEP40:
+               return MCU_CIPHER_WEP40;
+       case WLAN_CIPHER_SUITE_WEP104:
+               return MCU_CIPHER_WEP104;
+       case WLAN_CIPHER_SUITE_TKIP:
+               return MCU_CIPHER_TKIP;
+       case WLAN_CIPHER_SUITE_AES_CMAC:
+               return MCU_CIPHER_BIP_CMAC_128;
+       case WLAN_CIPHER_SUITE_CCMP:
+               return MCU_CIPHER_AES_CCMP;
+       case WLAN_CIPHER_SUITE_CCMP_256:
+               return MCU_CIPHER_CCMP_256;
+       case WLAN_CIPHER_SUITE_GCMP:
+               return MCU_CIPHER_GCMP;
+       case WLAN_CIPHER_SUITE_GCMP_256:
+               return MCU_CIPHER_GCMP_256;
+       case WLAN_CIPHER_SUITE_SMS4:
+               return MCU_CIPHER_WAPI;
+       default:
+               return MCU_CIPHER_NONE;
+       }
+}
+
 #define to_wcid_lo(id)         FIELD_GET(GENMASK(7, 0), (u16)id)
 #define to_wcid_hi(id)         FIELD_GET(GENMASK(9, 8), (u16)id)
 
index 73e40bb9a05fb178f1fe404edcb72da335b2fbef..2af79932145a320cd8771ebeaa732abc9c1c4688 100644 (file)
@@ -85,33 +85,6 @@ struct mt7915_fw_region {
 #define HE_PHY(p, c)                   u8_get_bits(c, IEEE80211_HE_PHY_##p)
 #define HE_MAC(m, c)                   u8_get_bits(c, IEEE80211_HE_MAC_##m)
 
-static enum mcu_cipher_type
-mt7915_mcu_get_cipher(int cipher)
-{
-       switch (cipher) {
-       case WLAN_CIPHER_SUITE_WEP40:
-               return MCU_CIPHER_WEP40;
-       case WLAN_CIPHER_SUITE_WEP104:
-               return MCU_CIPHER_WEP104;
-       case WLAN_CIPHER_SUITE_TKIP:
-               return MCU_CIPHER_TKIP;
-       case WLAN_CIPHER_SUITE_AES_CMAC:
-               return MCU_CIPHER_BIP_CMAC_128;
-       case WLAN_CIPHER_SUITE_CCMP:
-               return MCU_CIPHER_AES_CCMP;
-       case WLAN_CIPHER_SUITE_CCMP_256:
-               return MCU_CIPHER_CCMP_256;
-       case WLAN_CIPHER_SUITE_GCMP:
-               return MCU_CIPHER_GCMP;
-       case WLAN_CIPHER_SUITE_GCMP_256:
-               return MCU_CIPHER_GCMP_256;
-       case WLAN_CIPHER_SUITE_SMS4:
-               return MCU_CIPHER_WAPI;
-       default:
-               return MCU_CIPHER_NONE;
-       }
-}
-
 static u8 mt7915_mcu_chan_bw(struct cfg80211_chan_def *chandef)
 {
        static const u8 width_to_bw[] = {
@@ -984,7 +957,7 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb,
                struct sec_key *sec_key;
                u8 cipher;
 
-               cipher = mt7915_mcu_get_cipher(key->cipher);
+               cipher = mt76_connac_mcu_get_cipher(key->cipher);
                if (cipher == MCU_CIPHER_NONE)
                        return -EOPNOTSUPP;
 
index ef1e1ef91611b8ebd3923c0e7d328804130eb22e..0858b026de2dc4bf47b285a9b8e1c740e1184678 100644 (file)
@@ -93,33 +93,6 @@ struct mt7921_fw_region {
 #define PATCH_SEC_ENC_SCRAMBLE_INFO_MASK       GENMASK(15, 0)
 #define PATCH_SEC_ENC_AES_KEY_MASK             GENMASK(7, 0)
 
-static enum mcu_cipher_type
-mt7921_mcu_get_cipher(int cipher)
-{
-       switch (cipher) {
-       case WLAN_CIPHER_SUITE_WEP40:
-               return MCU_CIPHER_WEP40;
-       case WLAN_CIPHER_SUITE_WEP104:
-               return MCU_CIPHER_WEP104;
-       case WLAN_CIPHER_SUITE_TKIP:
-               return MCU_CIPHER_TKIP;
-       case WLAN_CIPHER_SUITE_AES_CMAC:
-               return MCU_CIPHER_BIP_CMAC_128;
-       case WLAN_CIPHER_SUITE_CCMP:
-               return MCU_CIPHER_AES_CCMP;
-       case WLAN_CIPHER_SUITE_CCMP_256:
-               return MCU_CIPHER_CCMP_256;
-       case WLAN_CIPHER_SUITE_GCMP:
-               return MCU_CIPHER_GCMP;
-       case WLAN_CIPHER_SUITE_GCMP_256:
-               return MCU_CIPHER_GCMP_256;
-       case WLAN_CIPHER_SUITE_SMS4:
-               return MCU_CIPHER_WAPI;
-       default:
-               return MCU_CIPHER_NONE;
-       }
-}
-
 static u8 mt7921_mcu_chan_bw(struct cfg80211_chan_def *chandef)
 {
        static const u8 width_to_bw[] = {
@@ -483,7 +456,7 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb,
                struct sec_key *sec_key;
                u8 cipher;
 
-               cipher = mt7921_mcu_get_cipher(key->cipher);
+               cipher = mt76_connac_mcu_get_cipher(key->cipher);
                if (cipher == MCU_CIPHER_NONE)
                        return -EOPNOTSUPP;