Commit c368362c authored by Ryder Lee's avatar Ryder Lee Committed by Felix Fietkau

mt76: fix iv and CCMP header insertion

The iv from RXD is only for TKIP_RSC/CCMP_PN/GCMP_PN, and it needs a
check for CCMP header insertion. Move mt76_cipher_type to mt76.h to
reduce duplicated code.
Signed-off-by: default avatarXing Song <xing.song@mediatek.com>
Signed-off-by: default avatarRyder Lee <ryder.lee@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 723885a6
...@@ -87,6 +87,22 @@ enum mt76_rxq_id { ...@@ -87,6 +87,22 @@ enum mt76_rxq_id {
__MT_RXQ_MAX __MT_RXQ_MAX
}; };
enum mt76_cipher_type {
MT_CIPHER_NONE,
MT_CIPHER_WEP40,
MT_CIPHER_TKIP,
MT_CIPHER_TKIP_NO_MIC,
MT_CIPHER_AES_CCMP,
MT_CIPHER_WEP104,
MT_CIPHER_BIP_CMAC_128,
MT_CIPHER_WEP128,
MT_CIPHER_WAPI,
MT_CIPHER_CCMP_CCX,
MT_CIPHER_CCMP_256,
MT_CIPHER_GCMP,
MT_CIPHER_GCMP_256,
};
struct mt76_queue_buf { struct mt76_queue_buf {
dma_addr_t addr; dma_addr_t addr;
u16 len; u16 len;
......
...@@ -550,14 +550,27 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb) ...@@ -550,14 +550,27 @@ mt7603_mac_fill_rx(struct mt7603_dev *dev, struct sk_buff *skb)
u8 *data = (u8 *)rxd; u8 *data = (u8 *)rxd;
if (status->flag & RX_FLAG_DECRYPTED) { if (status->flag & RX_FLAG_DECRYPTED) {
status->iv[0] = data[5]; switch (FIELD_GET(MT_RXD2_NORMAL_SEC_MODE, rxd2)) {
status->iv[1] = data[4]; case MT_CIPHER_AES_CCMP:
status->iv[2] = data[3]; case MT_CIPHER_CCMP_CCX:
status->iv[3] = data[2]; case MT_CIPHER_CCMP_256:
status->iv[4] = data[1]; insert_ccmp_hdr =
status->iv[5] = data[0]; FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
fallthrough;
insert_ccmp_hdr = FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2); case MT_CIPHER_TKIP:
case MT_CIPHER_TKIP_NO_MIC:
case MT_CIPHER_GCMP:
case MT_CIPHER_GCMP_256:
status->iv[0] = data[5];
status->iv[1] = data[4];
status->iv[2] = data[3];
status->iv[3] = data[2];
status->iv[4] = data[1];
status->iv[5] = data[0];
break;
default:
break;
}
} }
rxd += 4; rxd += 4;
...@@ -831,7 +844,7 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta, ...@@ -831,7 +844,7 @@ void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta,
sta->wcid.tx_info |= MT_WCID_TX_INFO_SET; sta->wcid.tx_info |= MT_WCID_TX_INFO_SET;
} }
static enum mt7603_cipher_type static enum mt76_cipher_type
mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data) mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
{ {
memset(key_data, 0, 32); memset(key_data, 0, 32);
...@@ -863,7 +876,7 @@ mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data) ...@@ -863,7 +876,7 @@ mt7603_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid, int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
enum mt7603_cipher_type cipher; enum mt76_cipher_type cipher;
u32 addr = mt7603_wtbl3_addr(wcid); u32 addr = mt7603_wtbl3_addr(wcid);
u8 key_data[32]; u8 key_data[32];
int key_len = sizeof(key_data); int key_len = sizeof(key_data);
......
...@@ -765,16 +765,4 @@ enum { ...@@ -765,16 +765,4 @@ enum {
#define MT_WTBL1_OR (MT_WTBL1_BASE + 0x2300) #define MT_WTBL1_OR (MT_WTBL1_BASE + 0x2300)
#define MT_WTBL1_OR_PSM_WRITE BIT(31) #define MT_WTBL1_OR_PSM_WRITE BIT(31)
enum mt7603_cipher_type {
MT_CIPHER_NONE,
MT_CIPHER_WEP40,
MT_CIPHER_TKIP,
MT_CIPHER_TKIP_NO_MIC,
MT_CIPHER_AES_CCMP,
MT_CIPHER_WEP104,
MT_CIPHER_BIP_CMAC_128,
MT_CIPHER_WEP128,
MT_CIPHER_WAPI,
};
#endif #endif
...@@ -57,6 +57,33 @@ static const struct mt7615_dfs_radar_spec jp_radar_specs = { ...@@ -57,6 +57,33 @@ static const struct mt7615_dfs_radar_spec jp_radar_specs = {
}, },
}; };
static enum mt76_cipher_type
mt7615_mac_get_cipher(int cipher)
{
switch (cipher) {
case WLAN_CIPHER_SUITE_WEP40:
return MT_CIPHER_WEP40;
case WLAN_CIPHER_SUITE_WEP104:
return MT_CIPHER_WEP104;
case WLAN_CIPHER_SUITE_TKIP:
return MT_CIPHER_TKIP;
case WLAN_CIPHER_SUITE_AES_CMAC:
return MT_CIPHER_BIP_CMAC_128;
case WLAN_CIPHER_SUITE_CCMP:
return MT_CIPHER_AES_CCMP;
case WLAN_CIPHER_SUITE_CCMP_256:
return MT_CIPHER_CCMP_256;
case WLAN_CIPHER_SUITE_GCMP:
return MT_CIPHER_GCMP;
case WLAN_CIPHER_SUITE_GCMP_256:
return MT_CIPHER_GCMP_256;
case WLAN_CIPHER_SUITE_SMS4:
return MT_CIPHER_WAPI;
default:
return MT_CIPHER_NONE;
}
}
static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev, static struct mt76_wcid *mt7615_rx_get_wcid(struct mt7615_dev *dev,
u8 idx, bool unicast) u8 idx, bool unicast)
{ {
...@@ -313,14 +340,27 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb) ...@@ -313,14 +340,27 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
u8 *data = (u8 *)rxd; u8 *data = (u8 *)rxd;
if (status->flag & RX_FLAG_DECRYPTED) { if (status->flag & RX_FLAG_DECRYPTED) {
status->iv[0] = data[5]; switch (FIELD_GET(MT_RXD2_NORMAL_SEC_MODE, rxd2)) {
status->iv[1] = data[4]; case MT_CIPHER_AES_CCMP:
status->iv[2] = data[3]; case MT_CIPHER_CCMP_CCX:
status->iv[3] = data[2]; case MT_CIPHER_CCMP_256:
status->iv[4] = data[1]; insert_ccmp_hdr =
status->iv[5] = data[0]; FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
fallthrough;
insert_ccmp_hdr = FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2); case MT_CIPHER_TKIP:
case MT_CIPHER_TKIP_NO_MIC:
case MT_CIPHER_GCMP:
case MT_CIPHER_GCMP_256:
status->iv[0] = data[5];
status->iv[1] = data[4];
status->iv[2] = data[3];
status->iv[3] = data[2];
status->iv[4] = data[1];
status->iv[5] = data[0];
break;
default:
break;
}
} }
rxd += 4; rxd += 4;
if ((u8 *)rxd - skb->data >= skb->len) if ((u8 *)rxd - skb->data >= skb->len)
...@@ -1078,7 +1118,7 @@ EXPORT_SYMBOL_GPL(mt7615_mac_set_rates); ...@@ -1078,7 +1118,7 @@ EXPORT_SYMBOL_GPL(mt7615_mac_set_rates);
static int static int
mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid, mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
struct ieee80211_key_conf *key, struct ieee80211_key_conf *key,
enum mt7615_cipher_type cipher, u16 cipher_mask, enum mt76_cipher_type cipher, u16 cipher_mask,
enum set_key_cmd cmd) enum set_key_cmd cmd)
{ {
u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx) + 30 * 4; u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx) + 30 * 4;
...@@ -1118,7 +1158,7 @@ mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid, ...@@ -1118,7 +1158,7 @@ mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, struct mt76_wcid *wcid,
static int static int
mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid, mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid,
enum mt7615_cipher_type cipher, u16 cipher_mask, enum mt76_cipher_type cipher, u16 cipher_mask,
int keyidx, enum set_key_cmd cmd) int keyidx, enum set_key_cmd cmd)
{ {
u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx), w0, w1; u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx), w0, w1;
...@@ -1157,7 +1197,7 @@ mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid, ...@@ -1157,7 +1197,7 @@ mt7615_mac_wtbl_update_pk(struct mt7615_dev *dev, struct mt76_wcid *wcid,
static void static void
mt7615_mac_wtbl_update_cipher(struct mt7615_dev *dev, struct mt76_wcid *wcid, mt7615_mac_wtbl_update_cipher(struct mt7615_dev *dev, struct mt76_wcid *wcid,
enum mt7615_cipher_type cipher, u16 cipher_mask, enum mt76_cipher_type cipher, u16 cipher_mask,
enum set_key_cmd cmd) enum set_key_cmd cmd)
{ {
u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx); u32 addr = mt7615_mac_wtbl_addr(dev, wcid->idx);
...@@ -1183,7 +1223,7 @@ int __mt7615_mac_wtbl_set_key(struct mt7615_dev *dev, ...@@ -1183,7 +1223,7 @@ int __mt7615_mac_wtbl_set_key(struct mt7615_dev *dev,
struct ieee80211_key_conf *key, struct ieee80211_key_conf *key,
enum set_key_cmd cmd) enum set_key_cmd cmd)
{ {
enum mt7615_cipher_type cipher; enum mt76_cipher_type cipher;
u16 cipher_mask = wcid->cipher; u16 cipher_mask = wcid->cipher;
int err; int err;
......
...@@ -383,48 +383,6 @@ struct mt7615_dfs_radar_spec { ...@@ -383,48 +383,6 @@ struct mt7615_dfs_radar_spec {
struct mt7615_dfs_pattern radar_pattern[16]; struct mt7615_dfs_pattern radar_pattern[16];
}; };
enum mt7615_cipher_type {
MT_CIPHER_NONE,
MT_CIPHER_WEP40,
MT_CIPHER_TKIP,
MT_CIPHER_TKIP_NO_MIC,
MT_CIPHER_AES_CCMP,
MT_CIPHER_WEP104,
MT_CIPHER_BIP_CMAC_128,
MT_CIPHER_WEP128,
MT_CIPHER_WAPI,
MT_CIPHER_CCMP_256 = 10,
MT_CIPHER_GCMP,
MT_CIPHER_GCMP_256,
};
static inline enum mt7615_cipher_type
mt7615_mac_get_cipher(int cipher)
{
switch (cipher) {
case WLAN_CIPHER_SUITE_WEP40:
return MT_CIPHER_WEP40;
case WLAN_CIPHER_SUITE_WEP104:
return MT_CIPHER_WEP104;
case WLAN_CIPHER_SUITE_TKIP:
return MT_CIPHER_TKIP;
case WLAN_CIPHER_SUITE_AES_CMAC:
return MT_CIPHER_BIP_CMAC_128;
case WLAN_CIPHER_SUITE_CCMP:
return MT_CIPHER_AES_CCMP;
case WLAN_CIPHER_SUITE_CCMP_256:
return MT_CIPHER_CCMP_256;
case WLAN_CIPHER_SUITE_GCMP:
return MT_CIPHER_GCMP;
case WLAN_CIPHER_SUITE_GCMP_256:
return MT_CIPHER_GCMP_256;
case WLAN_CIPHER_SUITE_SMS4:
return MT_CIPHER_WAPI;
default:
return MT_CIPHER_NONE;
}
}
static inline struct mt7615_txp_common * static inline struct mt7615_txp_common *
mt7615_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t) mt7615_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t)
{ {
......
...@@ -34,24 +34,24 @@ mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data) ...@@ -34,24 +34,24 @@ mt76x02_mac_get_key_info(struct ieee80211_key_conf *key, u8 *key_data)
{ {
memset(key_data, 0, 32); memset(key_data, 0, 32);
if (!key) if (!key)
return MT_CIPHER_NONE; return MT76X02_CIPHER_NONE;
if (key->keylen > 32) if (key->keylen > 32)
return MT_CIPHER_NONE; return MT76X02_CIPHER_NONE;
memcpy(key_data, key->key, key->keylen); memcpy(key_data, key->key, key->keylen);
switch (key->cipher) { switch (key->cipher) {
case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP40:
return MT_CIPHER_WEP40; return MT76X02_CIPHER_WEP40;
case WLAN_CIPHER_SUITE_WEP104: case WLAN_CIPHER_SUITE_WEP104:
return MT_CIPHER_WEP104; return MT76X02_CIPHER_WEP104;
case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_TKIP:
return MT_CIPHER_TKIP; return MT76X02_CIPHER_TKIP;
case WLAN_CIPHER_SUITE_CCMP: case WLAN_CIPHER_SUITE_CCMP:
return MT_CIPHER_AES_CCMP; return MT76X02_CIPHER_AES_CCMP;
default: default:
return MT_CIPHER_NONE; return MT76X02_CIPHER_NONE;
} }
} }
...@@ -63,7 +63,7 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx, ...@@ -63,7 +63,7 @@ int mt76x02_mac_shared_key_setup(struct mt76x02_dev *dev, u8 vif_idx,
u32 val; u32 val;
cipher = mt76x02_mac_get_key_info(key, key_data); cipher = mt76x02_mac_get_key_info(key, key_data);
if (cipher == MT_CIPHER_NONE && key) if (cipher == MT76X02_CIPHER_NONE && key)
return -EOPNOTSUPP; return -EOPNOTSUPP;
val = mt76_rr(dev, MT_SKEY_MODE(vif_idx)); val = mt76_rr(dev, MT_SKEY_MODE(vif_idx));
...@@ -91,10 +91,10 @@ void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx, ...@@ -91,10 +91,10 @@ void mt76x02_mac_wcid_sync_pn(struct mt76x02_dev *dev, u8 idx,
eiv = mt76_rr(dev, MT_WCID_IV(idx) + 4); eiv = mt76_rr(dev, MT_WCID_IV(idx) + 4);
pn = (u64)eiv << 16; pn = (u64)eiv << 16;
if (cipher == MT_CIPHER_TKIP) { if (cipher == MT76X02_CIPHER_TKIP) {
pn |= (iv >> 16) & 0xff; pn |= (iv >> 16) & 0xff;
pn |= (iv & 0xff) << 8; pn |= (iv & 0xff) << 8;
} else if (cipher >= MT_CIPHER_AES_CCMP) { } else if (cipher >= MT76X02_CIPHER_AES_CCMP) {
pn |= iv & 0xffff; pn |= iv & 0xffff;
} else { } else {
return; return;
...@@ -112,7 +112,7 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, ...@@ -112,7 +112,7 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx,
u64 pn; u64 pn;
cipher = mt76x02_mac_get_key_info(key, key_data); cipher = mt76x02_mac_get_key_info(key, key_data);
if (cipher == MT_CIPHER_NONE && key) if (cipher == MT76X02_CIPHER_NONE && key)
return -EOPNOTSUPP; return -EOPNOTSUPP;
mt76_wr_copy(dev, MT_WCID_KEY(idx), key_data, sizeof(key_data)); mt76_wr_copy(dev, MT_WCID_KEY(idx), key_data, sizeof(key_data));
...@@ -126,16 +126,16 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx, ...@@ -126,16 +126,16 @@ int mt76x02_mac_wcid_set_key(struct mt76x02_dev *dev, u8 idx,
pn = atomic64_read(&key->tx_pn); pn = atomic64_read(&key->tx_pn);
iv_data[3] = key->keyidx << 6; iv_data[3] = key->keyidx << 6;
if (cipher >= MT_CIPHER_TKIP) { if (cipher >= MT76X02_CIPHER_TKIP) {
iv_data[3] |= 0x20; iv_data[3] |= 0x20;
put_unaligned_le32(pn >> 16, &iv_data[4]); put_unaligned_le32(pn >> 16, &iv_data[4]);
} }
if (cipher == MT_CIPHER_TKIP) { if (cipher == MT76X02_CIPHER_TKIP) {
iv_data[0] = (pn >> 8) & 0xff; iv_data[0] = (pn >> 8) & 0xff;
iv_data[1] = (iv_data[0] | 0x20) & 0x7f; iv_data[1] = (iv_data[0] | 0x20) & 0x7f;
iv_data[2] = pn & 0xff; iv_data[2] = pn & 0xff;
} else if (cipher >= MT_CIPHER_AES_CCMP) { } else if (cipher >= MT76X02_CIPHER_AES_CCMP) {
put_unaligned_le16((pn & 0xffff), &iv_data[0]); put_unaligned_le16((pn & 0xffff), &iv_data[0]);
} }
} }
......
...@@ -692,15 +692,15 @@ struct mt76_wcid_key { ...@@ -692,15 +692,15 @@ struct mt76_wcid_key {
} __packed __aligned(4); } __packed __aligned(4);
enum mt76x02_cipher_type { enum mt76x02_cipher_type {
MT_CIPHER_NONE, MT76X02_CIPHER_NONE,
MT_CIPHER_WEP40, MT76X02_CIPHER_WEP40,
MT_CIPHER_WEP104, MT76X02_CIPHER_WEP104,
MT_CIPHER_TKIP, MT76X02_CIPHER_TKIP,
MT_CIPHER_AES_CCMP, MT76X02_CIPHER_AES_CCMP,
MT_CIPHER_CKIP40, MT76X02_CIPHER_CKIP40,
MT_CIPHER_CKIP104, MT76X02_CIPHER_CKIP104,
MT_CIPHER_CKIP128, MT76X02_CIPHER_CKIP128,
MT_CIPHER_WAPI, MT76X02_CIPHER_WAPI,
}; };
#endif #endif
...@@ -413,14 +413,27 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb) ...@@ -413,14 +413,27 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb)
u8 *data = (u8 *)rxd; u8 *data = (u8 *)rxd;
if (status->flag & RX_FLAG_DECRYPTED) { if (status->flag & RX_FLAG_DECRYPTED) {
status->iv[0] = data[5]; switch (FIELD_GET(MT_RXD1_NORMAL_SEC_MODE, rxd1)) {
status->iv[1] = data[4]; case MT_CIPHER_AES_CCMP:
status->iv[2] = data[3]; case MT_CIPHER_CCMP_CCX:
status->iv[3] = data[2]; case MT_CIPHER_CCMP_256:
status->iv[4] = data[1]; insert_ccmp_hdr =
status->iv[5] = data[0]; FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
fallthrough;
insert_ccmp_hdr = FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2); case MT_CIPHER_TKIP:
case MT_CIPHER_TKIP_NO_MIC:
case MT_CIPHER_GCMP:
case MT_CIPHER_GCMP_256:
status->iv[0] = data[5];
status->iv[1] = data[4];
status->iv[2] = data[3];
status->iv[3] = data[2];
status->iv[4] = data[1];
status->iv[5] = data[0];
break;
default:
break;
}
} }
rxd += 4; rxd += 4;
if ((u8 *)rxd - skb->data >= skb->len) if ((u8 *)rxd - skb->data >= skb->len)
......
...@@ -88,28 +88,28 @@ struct mt7915_fw_region { ...@@ -88,28 +88,28 @@ struct mt7915_fw_region {
#define HE_PHY(p, c) u8_get_bits(c, IEEE80211_HE_PHY_##p) #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) #define HE_MAC(m, c) u8_get_bits(c, IEEE80211_HE_MAC_##m)
static enum mt7915_cipher_type static enum mcu_cipher_type
mt7915_mcu_get_cipher(int cipher) mt7915_mcu_get_cipher(int cipher)
{ {
switch (cipher) { switch (cipher) {
case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP40:
return MT_CIPHER_WEP40; return MCU_CIPHER_WEP40;
case WLAN_CIPHER_SUITE_WEP104: case WLAN_CIPHER_SUITE_WEP104:
return MT_CIPHER_WEP104; return MCU_CIPHER_WEP104;
case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_TKIP:
return MT_CIPHER_TKIP; return MCU_CIPHER_TKIP;
case WLAN_CIPHER_SUITE_AES_CMAC: case WLAN_CIPHER_SUITE_AES_CMAC:
return MT_CIPHER_BIP_CMAC_128; return MCU_CIPHER_BIP_CMAC_128;
case WLAN_CIPHER_SUITE_CCMP: case WLAN_CIPHER_SUITE_CCMP:
return MT_CIPHER_AES_CCMP; return MCU_CIPHER_AES_CCMP;
case WLAN_CIPHER_SUITE_CCMP_256: case WLAN_CIPHER_SUITE_CCMP_256:
return MT_CIPHER_CCMP_256; return MCU_CIPHER_CCMP_256;
case WLAN_CIPHER_SUITE_GCMP: case WLAN_CIPHER_SUITE_GCMP:
return MT_CIPHER_GCMP; return MCU_CIPHER_GCMP;
case WLAN_CIPHER_SUITE_GCMP_256: case WLAN_CIPHER_SUITE_GCMP_256:
return MT_CIPHER_GCMP_256; return MCU_CIPHER_GCMP_256;
case WLAN_CIPHER_SUITE_SMS4: case WLAN_CIPHER_SUITE_SMS4:
return MT_CIPHER_WAPI; return MCU_CIPHER_WAPI;
default: default:
return MT_CIPHER_NONE; return MT_CIPHER_NONE;
} }
...@@ -1207,14 +1207,14 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb, ...@@ -1207,14 +1207,14 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb,
sec_key = &sec->key[0]; sec_key = &sec->key[0];
sec_key->cipher_len = sizeof(*sec_key); sec_key->cipher_len = sizeof(*sec_key);
if (cipher == MT_CIPHER_BIP_CMAC_128) { if (cipher == MCU_CIPHER_BIP_CMAC_128) {
sec_key->cipher_id = MT_CIPHER_AES_CCMP; sec_key->cipher_id = MCU_CIPHER_AES_CCMP;
sec_key->key_id = bip->keyidx; sec_key->key_id = bip->keyidx;
sec_key->key_len = 16; sec_key->key_len = 16;
memcpy(sec_key->key, bip->key, 16); memcpy(sec_key->key, bip->key, 16);
sec_key = &sec->key[1]; sec_key = &sec->key[1];
sec_key->cipher_id = MT_CIPHER_BIP_CMAC_128; sec_key->cipher_id = MCU_CIPHER_BIP_CMAC_128;
sec_key->cipher_len = sizeof(*sec_key); sec_key->cipher_len = sizeof(*sec_key);
sec_key->key_len = 16; sec_key->key_len = 16;
memcpy(sec_key->key, key->key, 16); memcpy(sec_key->key, key->key, 16);
...@@ -1226,14 +1226,14 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb, ...@@ -1226,14 +1226,14 @@ mt7915_mcu_sta_key_tlv(struct mt7915_sta *msta, struct sk_buff *skb,
sec_key->key_len = key->keylen; sec_key->key_len = key->keylen;
memcpy(sec_key->key, key->key, key->keylen); memcpy(sec_key->key, key->key, key->keylen);
if (cipher == MT_CIPHER_TKIP) { if (cipher == MCU_CIPHER_TKIP) {
/* Rx/Tx MIC keys are swapped */ /* Rx/Tx MIC keys are swapped */
memcpy(sec_key->key + 16, key->key + 24, 8); memcpy(sec_key->key + 16, key->key + 24, 8);
memcpy(sec_key->key + 24, key->key + 16, 8); memcpy(sec_key->key + 24, key->key + 16, 8);
} }
/* store key_conf for BIP batch update */ /* store key_conf for BIP batch update */
if (cipher == MT_CIPHER_AES_CCMP) { if (cipher == MCU_CIPHER_AES_CCMP) {
memcpy(bip->key, key->key, key->keylen); memcpy(bip->key, key->key, key->keylen);
bip->keyidx = key->keyidx; bip->keyidx = key->keyidx;
} }
......
...@@ -1072,18 +1072,17 @@ enum { ...@@ -1072,18 +1072,17 @@ enum {
STA_REC_MAX_NUM STA_REC_MAX_NUM
}; };
enum mt7915_cipher_type { enum mcu_cipher_type {
MT_CIPHER_NONE, MCU_CIPHER_WEP40 = 1,
MT_CIPHER_WEP40, MCU_CIPHER_WEP104,
MT_CIPHER_WEP104, MCU_CIPHER_WEP128,
MT_CIPHER_WEP128, MCU_CIPHER_TKIP,
MT_CIPHER_TKIP, MCU_CIPHER_AES_CCMP,
MT_CIPHER_AES_CCMP, MCU_CIPHER_CCMP_256,
MT_CIPHER_CCMP_256, MCU_CIPHER_GCMP,
MT_CIPHER_GCMP, MCU_CIPHER_GCMP_256,
MT_CIPHER_GCMP_256, MCU_CIPHER_WAPI,
MT_CIPHER_WAPI, MCU_CIPHER_BIP_CMAC_128,
MT_CIPHER_BIP_CMAC_128,
}; };
enum { enum {
......
...@@ -403,14 +403,27 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) ...@@ -403,14 +403,27 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
u8 *data = (u8 *)rxd; u8 *data = (u8 *)rxd;
if (status->flag & RX_FLAG_DECRYPTED) { if (status->flag & RX_FLAG_DECRYPTED) {
status->iv[0] = data[5]; switch (FIELD_GET(MT_RXD1_NORMAL_SEC_MODE, rxd1)) {
status->iv[1] = data[4]; case MT_CIPHER_AES_CCMP:
status->iv[2] = data[3]; case MT_CIPHER_CCMP_CCX:
status->iv[3] = data[2]; case MT_CIPHER_CCMP_256:
status->iv[4] = data[1]; insert_ccmp_hdr =
status->iv[5] = data[0]; FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2);
fallthrough;
insert_ccmp_hdr = FIELD_GET(MT_RXD2_NORMAL_FRAG, rxd2); case MT_CIPHER_TKIP:
case MT_CIPHER_TKIP_NO_MIC:
case MT_CIPHER_GCMP:
case MT_CIPHER_GCMP_256:
status->iv[0] = data[5];
status->iv[1] = data[4];
status->iv[2] = data[3];
status->iv[3] = data[2];
status->iv[4] = data[1];
status->iv[5] = data[0];
break;
default:
break;
}
} }
rxd += 4; rxd += 4;
if ((u8 *)rxd - skb->data >= skb->len) if ((u8 *)rxd - skb->data >= skb->len)
......
...@@ -88,28 +88,28 @@ struct mt7921_fw_region { ...@@ -88,28 +88,28 @@ struct mt7921_fw_region {
#define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id) #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
#define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id) #define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
static enum mt7921_cipher_type static enum mcu_cipher_type
mt7921_mcu_get_cipher(int cipher) mt7921_mcu_get_cipher(int cipher)
{ {
switch (cipher) { switch (cipher) {
case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP40:
return MT_CIPHER_WEP40; return MCU_CIPHER_WEP40;
case WLAN_CIPHER_SUITE_WEP104: case WLAN_CIPHER_SUITE_WEP104:
return MT_CIPHER_WEP104; return MCU_CIPHER_WEP104;
case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_TKIP:
return MT_CIPHER_TKIP; return MCU_CIPHER_TKIP;
case WLAN_CIPHER_SUITE_AES_CMAC: case WLAN_CIPHER_SUITE_AES_CMAC:
return MT_CIPHER_BIP_CMAC_128; return MCU_CIPHER_BIP_CMAC_128;
case WLAN_CIPHER_SUITE_CCMP: case WLAN_CIPHER_SUITE_CCMP:
return MT_CIPHER_AES_CCMP; return MCU_CIPHER_AES_CCMP;
case WLAN_CIPHER_SUITE_CCMP_256: case WLAN_CIPHER_SUITE_CCMP_256:
return MT_CIPHER_CCMP_256; return MCU_CIPHER_CCMP_256;
case WLAN_CIPHER_SUITE_GCMP: case WLAN_CIPHER_SUITE_GCMP:
return MT_CIPHER_GCMP; return MCU_CIPHER_GCMP;
case WLAN_CIPHER_SUITE_GCMP_256: case WLAN_CIPHER_SUITE_GCMP_256:
return MT_CIPHER_GCMP_256; return MCU_CIPHER_GCMP_256;
case WLAN_CIPHER_SUITE_SMS4: case WLAN_CIPHER_SUITE_SMS4:
return MT_CIPHER_WAPI; return MCU_CIPHER_WAPI;
default: default:
return MT_CIPHER_NONE; return MT_CIPHER_NONE;
} }
...@@ -625,14 +625,14 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb, ...@@ -625,14 +625,14 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb,
sec_key = &sec->key[0]; sec_key = &sec->key[0];
sec_key->cipher_len = sizeof(*sec_key); sec_key->cipher_len = sizeof(*sec_key);
if (cipher == MT_CIPHER_BIP_CMAC_128) { if (cipher == MCU_CIPHER_BIP_CMAC_128) {
sec_key->cipher_id = MT_CIPHER_AES_CCMP; sec_key->cipher_id = MCU_CIPHER_AES_CCMP;
sec_key->key_id = bip->keyidx; sec_key->key_id = bip->keyidx;
sec_key->key_len = 16; sec_key->key_len = 16;
memcpy(sec_key->key, bip->key, 16); memcpy(sec_key->key, bip->key, 16);
sec_key = &sec->key[1]; sec_key = &sec->key[1];
sec_key->cipher_id = MT_CIPHER_BIP_CMAC_128; sec_key->cipher_id = MCU_CIPHER_BIP_CMAC_128;
sec_key->cipher_len = sizeof(*sec_key); sec_key->cipher_len = sizeof(*sec_key);
sec_key->key_len = 16; sec_key->key_len = 16;
memcpy(sec_key->key, key->key, 16); memcpy(sec_key->key, key->key, 16);
...@@ -644,14 +644,14 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb, ...@@ -644,14 +644,14 @@ mt7921_mcu_sta_key_tlv(struct mt7921_sta *msta, struct sk_buff *skb,
sec_key->key_len = key->keylen; sec_key->key_len = key->keylen;
memcpy(sec_key->key, key->key, key->keylen); memcpy(sec_key->key, key->key, key->keylen);
if (cipher == MT_CIPHER_TKIP) { if (cipher == MCU_CIPHER_TKIP) {
/* Rx/Tx MIC keys are swapped */ /* Rx/Tx MIC keys are swapped */
memcpy(sec_key->key + 16, key->key + 24, 8); memcpy(sec_key->key + 16, key->key + 24, 8);
memcpy(sec_key->key + 24, key->key + 16, 8); memcpy(sec_key->key + 24, key->key + 16, 8);
} }
/* store key_conf for BIP batch update */ /* store key_conf for BIP batch update */
if (cipher == MT_CIPHER_AES_CCMP) { if (cipher == MCU_CIPHER_AES_CCMP) {
memcpy(bip->key, key->key, key->keylen); memcpy(bip->key, key->key, key->keylen);
bip->keyidx = key->keyidx; bip->keyidx = key->keyidx;
} }
......
...@@ -198,18 +198,17 @@ struct sta_rec_sec { ...@@ -198,18 +198,17 @@ struct sta_rec_sec {
struct sec_key key[2]; struct sec_key key[2];
} __packed; } __packed;
enum mt7921_cipher_type { enum mcu_cipher_type {
MT_CIPHER_NONE, MCU_CIPHER_WEP40 = 1,
MT_CIPHER_WEP40, MCU_CIPHER_WEP104,
MT_CIPHER_WEP104, MCU_CIPHER_WEP128,
MT_CIPHER_WEP128, MCU_CIPHER_TKIP,
MT_CIPHER_TKIP, MCU_CIPHER_AES_CCMP,
MT_CIPHER_AES_CCMP, MCU_CIPHER_CCMP_256,
MT_CIPHER_CCMP_256, MCU_CIPHER_GCMP,
MT_CIPHER_GCMP, MCU_CIPHER_GCMP_256,
MT_CIPHER_GCMP_256, MCU_CIPHER_WAPI,
MT_CIPHER_WAPI, MCU_CIPHER_BIP_CMAC_128,
MT_CIPHER_BIP_CMAC_128,
}; };
enum { enum {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment