Commit 2fec2ea6 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: connac: introduce is_connac_v1 utility routine

Introduce is_connac_v1 inline utility routine to check if the device is
generation v1.
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 5a521c0f
...@@ -409,24 +409,6 @@ int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev, ...@@ -409,24 +409,6 @@ int mt7615_mcu_rdd_cmd(struct mt7615_dev *dev,
int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev); int mt7615_mcu_rdd_send_pattern(struct mt7615_dev *dev);
int mt7615_mcu_fw_log_2_host(struct mt7615_dev *dev, u8 ctrl); int mt7615_mcu_fw_log_2_host(struct mt7615_dev *dev, u8 ctrl);
static inline bool is_mt7622(struct mt76_dev *dev)
{
if (!IS_ENABLED(CONFIG_MT7622_WMAC))
return false;
return mt76_chip(dev) == 0x7622;
}
static inline bool is_mt7615(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7615 || mt76_chip(dev) == 0x7611;
}
static inline bool is_mt7611(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7611;
}
static inline void mt7615_irq_enable(struct mt7615_dev *dev, u32 mask) static inline void mt7615_irq_enable(struct mt7615_dev *dev, u32 mask)
{ {
mt76_set_irq_mask(&dev->mt76, 0, 0, mask); mt76_set_irq_mask(&dev->mt76, 0, 0, mask);
......
...@@ -115,6 +115,29 @@ static inline bool is_mt7916(struct mt76_dev *dev) ...@@ -115,6 +115,29 @@ static inline bool is_mt7916(struct mt76_dev *dev)
return mt76_chip(dev) == 0x7906; return mt76_chip(dev) == 0x7906;
} }
static inline bool is_mt7622(struct mt76_dev *dev)
{
if (!IS_ENABLED(CONFIG_MT7622_WMAC))
return false;
return mt76_chip(dev) == 0x7622;
}
static inline bool is_mt7615(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7615 || mt76_chip(dev) == 0x7611;
}
static inline bool is_mt7611(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7611;
}
static inline bool is_connac_v1(struct mt76_dev *dev)
{
return is_mt7615(dev) || is_mt7663(dev) || is_mt7622(dev);
}
static inline u8 mt76_connac_chan_bw(struct cfg80211_chan_def *chandef) static inline u8 mt76_connac_chan_bw(struct cfg80211_chan_def *chandef)
{ {
static const u8 width_to_bw[] = { static const u8 width_to_bw[] = {
......
...@@ -553,8 +553,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, ...@@ -553,8 +553,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
generic->muar_idx = mvif->omac_idx; generic->muar_idx = mvif->omac_idx;
generic->qos = sta->wme; generic->qos = sta->wme;
} else { } else {
if ((is_mt7921(dev) || is_mt7915(dev)) && if (!is_connac_v1(dev) && vif->type == NL80211_IFTYPE_STATION)
vif->type == NL80211_IFTYPE_STATION)
memcpy(generic->peer_addr, vif->bss_conf.bssid, memcpy(generic->peer_addr, vif->bss_conf.bssid,
ETH_ALEN); ETH_ALEN);
else else
...@@ -571,7 +570,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev, ...@@ -571,7 +570,7 @@ void mt76_connac_mcu_wtbl_generic_tlv(struct mt76_dev *dev,
rx->rca2 = 1; rx->rca2 = 1;
rx->rv = 1; rx->rv = 1;
if (is_mt7921(dev) || is_mt7915(dev)) if (!is_connac_v1(dev))
return; return;
tlv = mt76_connac_mcu_add_nested_tlv(skb, WTBL_SPE, sizeof(*spe), tlv = mt76_connac_mcu_add_nested_tlv(skb, WTBL_SPE, sizeof(*spe),
...@@ -937,7 +936,7 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -937,7 +936,7 @@ void mt76_connac_mcu_wtbl_ht_tlv(struct mt76_dev *dev, struct sk_buff *skb,
mt76_connac_mcu_wtbl_smps_tlv(skb, sta, sta_wtbl, wtbl_tlv); mt76_connac_mcu_wtbl_smps_tlv(skb, sta, sta_wtbl, wtbl_tlv);
if (!is_mt7921(dev) && !is_mt7915(dev) && sta->ht_cap.ht_supported) { if (is_connac_v1(dev) && sta->ht_cap.ht_supported) {
/* sgi */ /* sgi */
u32 msk = MT_WTBL_W5_SHORT_GI_20 | MT_WTBL_W5_SHORT_GI_40 | u32 msk = MT_WTBL_W5_SHORT_GI_20 | MT_WTBL_W5_SHORT_GI_40 |
MT_WTBL_W5_SHORT_GI_80 | MT_WTBL_W5_SHORT_GI_160; MT_WTBL_W5_SHORT_GI_80 | MT_WTBL_W5_SHORT_GI_160;
...@@ -1039,7 +1038,7 @@ void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -1039,7 +1038,7 @@ void mt76_connac_mcu_wtbl_ba_tlv(struct mt76_dev *dev, struct sk_buff *skb,
ba->rst_ba_sb = 1; ba->rst_ba_sb = 1;
} }
if (is_mt7921(dev) || is_mt7915(dev)) { if (!is_connac_v1(dev)) {
ba->ba_winsize = enable ? cpu_to_le16(params->buf_size) : 0; ba->ba_winsize = enable ? cpu_to_le16(params->buf_size) : 0;
return; return;
} }
...@@ -1218,7 +1217,7 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif, ...@@ -1218,7 +1217,7 @@ u8 mt76_connac_get_phy_mode(struct mt76_phy *phy, struct ieee80211_vif *vif,
struct ieee80211_sta_ht_cap *ht_cap; struct ieee80211_sta_ht_cap *ht_cap;
u8 mode = 0; u8 mode = 0;
if (!is_mt7921(dev) && !is_mt7915(dev)) if (is_connac_v1(dev))
return 0x38; return 0x38;
if (sta) { if (sta) {
......
...@@ -1464,7 +1464,7 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid, ...@@ -1464,7 +1464,7 @@ mt76_connac_mcu_get_wlan_idx(struct mt76_dev *dev, struct mt76_wcid *wcid,
{ {
*wlan_idx_hi = 0; *wlan_idx_hi = 0;
if (is_mt7921(dev) || is_mt7915(dev) || is_mt7916(dev)) { if (!is_connac_v1(dev)) {
*wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0; *wlan_idx_lo = wcid ? to_wcid_lo(wcid->idx) : 0;
*wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0; *wlan_idx_hi = wcid ? to_wcid_hi(wcid->idx) : 0;
} else { } else {
......
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