mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 17:17:04 -04:00
mt76: move hw mac_addr in mt76_phy
This is a preliminary patch to properly support mt7915 dbdc Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
committed by
Felix Fietkau
parent
db78a791ca
commit
98df2baeb3
@@ -88,8 +88,10 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len)
|
||||
}
|
||||
|
||||
void
|
||||
mt76_eeprom_override(struct mt76_dev *dev)
|
||||
mt76_eeprom_override(struct mt76_phy *phy)
|
||||
{
|
||||
struct mt76_dev *dev = phy->dev;
|
||||
|
||||
#ifdef CONFIG_OF
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
const u8 *mac = NULL;
|
||||
@@ -97,14 +99,14 @@ mt76_eeprom_override(struct mt76_dev *dev)
|
||||
if (np)
|
||||
mac = of_get_mac_address(np);
|
||||
if (!IS_ERR_OR_NULL(mac))
|
||||
ether_addr_copy(dev->macaddr, mac);
|
||||
ether_addr_copy(phy->macaddr, mac);
|
||||
#endif
|
||||
|
||||
if (!is_valid_ether_addr(dev->macaddr)) {
|
||||
eth_random_addr(dev->macaddr);
|
||||
if (!is_valid_ether_addr(phy->macaddr)) {
|
||||
eth_random_addr(phy->macaddr);
|
||||
dev_info(dev->dev,
|
||||
"Invalid MAC address, using random address %pM\n",
|
||||
dev->macaddr);
|
||||
phy->macaddr);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_eeprom_override);
|
||||
|
||||
@@ -273,12 +273,13 @@ mt76_check_sband(struct mt76_phy *phy, struct mt76_sband *msband,
|
||||
}
|
||||
|
||||
static void
|
||||
mt76_phy_init(struct mt76_dev *dev, struct ieee80211_hw *hw)
|
||||
mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
|
||||
{
|
||||
struct mt76_dev *dev = phy->dev;
|
||||
struct wiphy *wiphy = hw->wiphy;
|
||||
|
||||
SET_IEEE80211_DEV(hw, dev->dev);
|
||||
SET_IEEE80211_PERM_ADDR(hw, dev->macaddr);
|
||||
SET_IEEE80211_PERM_ADDR(hw, phy->macaddr);
|
||||
|
||||
wiphy->features |= NL80211_FEATURE_ACTIVE_MONITOR;
|
||||
wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH |
|
||||
@@ -354,7 +355,7 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
|
||||
{
|
||||
int ret;
|
||||
|
||||
mt76_phy_init(phy->dev, phy->hw);
|
||||
mt76_phy_init(phy, phy->hw);
|
||||
|
||||
if (phy->cap.has_2ghz) {
|
||||
ret = mt76_init_sband_2g(phy, rates, n_rates);
|
||||
@@ -450,7 +451,7 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
|
||||
int ret;
|
||||
|
||||
dev_set_drvdata(dev->dev, dev);
|
||||
mt76_phy_init(dev, hw);
|
||||
mt76_phy_init(phy, hw);
|
||||
|
||||
if (phy->cap.has_2ghz) {
|
||||
ret = mt76_init_sband_2g(phy, rates, n_rates);
|
||||
@@ -830,7 +831,7 @@ mt76_airtime_check(struct mt76_dev *dev, struct sk_buff *skb)
|
||||
return;
|
||||
|
||||
if (!wcid || !wcid->sta) {
|
||||
if (!ether_addr_equal(hdr->addr1, dev->macaddr))
|
||||
if (!ether_addr_equal(hdr->addr1, dev->phy.macaddr))
|
||||
return;
|
||||
|
||||
wcid = NULL;
|
||||
|
||||
@@ -573,6 +573,8 @@ struct mt76_phy {
|
||||
struct mt76_sband sband_2g;
|
||||
struct mt76_sband sband_5g;
|
||||
|
||||
u8 macaddr[ETH_ALEN];
|
||||
|
||||
u32 vif_mask;
|
||||
|
||||
int txpower_cur;
|
||||
@@ -628,7 +630,6 @@ struct mt76_dev {
|
||||
struct mt76_wcid global_wcid;
|
||||
struct mt76_wcid __rcu *wcid[MT76_N_WCIDS];
|
||||
|
||||
u8 macaddr[ETH_ALEN];
|
||||
u32 rev;
|
||||
|
||||
u32 aggr_stats[32];
|
||||
@@ -784,7 +785,7 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str,
|
||||
s8 *val, int len);
|
||||
|
||||
int mt76_eeprom_init(struct mt76_dev *dev, int len);
|
||||
void mt76_eeprom_override(struct mt76_dev *dev);
|
||||
void mt76_eeprom_override(struct mt76_phy *phy);
|
||||
|
||||
struct mt76_queue *
|
||||
mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,
|
||||
|
||||
@@ -172,7 +172,7 @@ int mt7603_eeprom_init(struct mt7603_dev *dev)
|
||||
|
||||
eeprom = (u8 *)dev->mt76.eeprom.data;
|
||||
dev->mphy.cap.has_2ghz = true;
|
||||
memcpy(dev->mt76.macaddr, eeprom + MT_EE_MAC_ADDR, ETH_ALEN);
|
||||
memcpy(dev->mphy.macaddr, eeprom + MT_EE_MAC_ADDR, ETH_ALEN);
|
||||
|
||||
/* Check for 1SS devices */
|
||||
dev->mphy.antenna_mask = 3;
|
||||
@@ -181,7 +181,7 @@ int mt7603_eeprom_init(struct mt7603_dev *dev)
|
||||
is_mt7688(dev))
|
||||
dev->mphy.antenna_mask = 1;
|
||||
|
||||
mt76_eeprom_override(&dev->mt76);
|
||||
mt76_eeprom_override(&dev->mphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -342,10 +342,10 @@ int mt7615_eeprom_init(struct mt7615_dev *dev, u32 addr)
|
||||
}
|
||||
|
||||
mt7615_eeprom_parse_hw_cap(dev);
|
||||
memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
memcpy(dev->mphy.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
ETH_ALEN);
|
||||
|
||||
mt76_eeprom_override(&dev->mt76);
|
||||
mt76_eeprom_override(&dev->mphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -422,8 +422,11 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
|
||||
* Make the secondary PHY MAC address local without overlapping with
|
||||
* the usual MAC address allocation scheme on multiple virtual interfaces
|
||||
*/
|
||||
mphy->hw->wiphy->perm_addr[0] |= 2;
|
||||
mphy->hw->wiphy->perm_addr[0] ^= BIT(7);
|
||||
memcpy(mphy->macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
ETH_ALEN);
|
||||
mphy->macaddr[0] |= 2;
|
||||
mphy->macaddr[0] ^= BIT(7);
|
||||
mt76_eeprom_override(mphy);
|
||||
|
||||
/* second phy can only handle 5 GHz */
|
||||
mphy->cap.has_5ghz = true;
|
||||
|
||||
@@ -342,10 +342,10 @@ int mt76x0_eeprom_init(struct mt76x02_dev *dev)
|
||||
dev_info(dev->mt76.dev, "EEPROM ver:%02hhx fae:%02hhx\n",
|
||||
version, fae);
|
||||
|
||||
memcpy(dev->mt76.macaddr, (u8 *)dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
memcpy(dev->mphy.macaddr, (u8 *)dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
ETH_ALEN);
|
||||
mt76_eeprom_override(&dev->mt76);
|
||||
mt76x02_mac_setaddr(dev, dev->mt76.macaddr);
|
||||
mt76_eeprom_override(&dev->mphy);
|
||||
mt76x02_mac_setaddr(dev, dev->mphy.macaddr);
|
||||
|
||||
mt76x0_set_chip_cap(dev);
|
||||
mt76x0_set_freq_offset(dev);
|
||||
|
||||
@@ -727,24 +727,24 @@ void mt76x02_mac_setaddr(struct mt76x02_dev *dev, const u8 *addr)
|
||||
static const u8 null_addr[ETH_ALEN] = {};
|
||||
int i;
|
||||
|
||||
ether_addr_copy(dev->mt76.macaddr, addr);
|
||||
ether_addr_copy(dev->mphy.macaddr, addr);
|
||||
|
||||
if (!is_valid_ether_addr(dev->mt76.macaddr)) {
|
||||
eth_random_addr(dev->mt76.macaddr);
|
||||
if (!is_valid_ether_addr(dev->mphy.macaddr)) {
|
||||
eth_random_addr(dev->mphy.macaddr);
|
||||
dev_info(dev->mt76.dev,
|
||||
"Invalid MAC address, using random address %pM\n",
|
||||
dev->mt76.macaddr);
|
||||
dev->mphy.macaddr);
|
||||
}
|
||||
|
||||
mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->mt76.macaddr));
|
||||
mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->mphy.macaddr));
|
||||
mt76_wr(dev, MT_MAC_ADDR_DW1,
|
||||
get_unaligned_le16(dev->mt76.macaddr + 4) |
|
||||
get_unaligned_le16(dev->mphy.macaddr + 4) |
|
||||
FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
|
||||
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW0,
|
||||
get_unaligned_le32(dev->mt76.macaddr));
|
||||
get_unaligned_le32(dev->mphy.macaddr));
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW1,
|
||||
get_unaligned_le16(dev->mt76.macaddr + 4) |
|
||||
get_unaligned_le16(dev->mphy.macaddr + 4) |
|
||||
FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 APs + 8 STAs */
|
||||
MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
|
||||
/* enable 7 additional beacon slots and control them with bypass mask */
|
||||
|
||||
@@ -305,12 +305,12 @@ mt76x02_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
|
||||
|
||||
/* Allow to change address in HW if we create first interface. */
|
||||
if (!dev->mphy.vif_mask &&
|
||||
(((vif->addr[0] ^ dev->mt76.macaddr[0]) & ~GENMASK(4, 1)) ||
|
||||
memcmp(vif->addr + 1, dev->mt76.macaddr + 1, ETH_ALEN - 1)))
|
||||
(((vif->addr[0] ^ dev->mphy.macaddr[0]) & ~GENMASK(4, 1)) ||
|
||||
memcmp(vif->addr + 1, dev->mphy.macaddr + 1, ETH_ALEN - 1)))
|
||||
mt76x02_mac_setaddr(dev, vif->addr);
|
||||
|
||||
if (vif->addr[0] & BIT(1))
|
||||
idx = 1 + (((dev->mt76.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
|
||||
idx = 1 + (((dev->mphy.macaddr[0] ^ vif->addr[0]) >> 2) & 7);
|
||||
|
||||
/*
|
||||
* Client mode typically only has one configurable BSSID register,
|
||||
@@ -678,7 +678,7 @@ void mt76x02_config_mac_addr_list(struct mt76x02_dev *dev)
|
||||
for (i = 0; i < ARRAY_SIZE(dev->macaddr_list); i++) {
|
||||
u8 *addr = dev->macaddr_list[i].addr;
|
||||
|
||||
memcpy(addr, dev->mt76.macaddr, ETH_ALEN);
|
||||
memcpy(addr, dev->mphy.macaddr, ETH_ALEN);
|
||||
|
||||
if (!i)
|
||||
continue;
|
||||
|
||||
@@ -16,7 +16,7 @@ mt76x2_eeprom_get_macaddr(struct mt76x02_dev *dev)
|
||||
{
|
||||
void *src = dev->mt76.eeprom.data + MT_EE_MAC_ADDR;
|
||||
|
||||
memcpy(dev->mt76.macaddr, src, ETH_ALEN);
|
||||
memcpy(dev->mphy.macaddr, src, ETH_ALEN);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -502,8 +502,8 @@ int mt76x2_eeprom_init(struct mt76x02_dev *dev)
|
||||
|
||||
mt76x02_eeprom_parse_hw_cap(dev);
|
||||
mt76x2_eeprom_get_macaddr(dev);
|
||||
mt76_eeprom_override(&dev->mt76);
|
||||
dev->mt76.macaddr[0] &= ~BIT(1);
|
||||
mt76_eeprom_override(&dev->mphy);
|
||||
dev->mphy.macaddr[0] &= ~BIT(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ mt76x2_fixup_xtal(struct mt76x02_dev *dev)
|
||||
|
||||
int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
|
||||
{
|
||||
const u8 *macaddr = dev->mt76.macaddr;
|
||||
const u8 *macaddr = dev->mphy.macaddr;
|
||||
u32 val;
|
||||
int i, k;
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ int mt7915_eeprom_init(struct mt7915_dev *dev)
|
||||
return ret;
|
||||
|
||||
mt7915_eeprom_parse_hw_cap(dev);
|
||||
memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
memcpy(dev->mphy.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR,
|
||||
ETH_ALEN);
|
||||
|
||||
mt76_eeprom_override(&dev->mt76);
|
||||
mt76_eeprom_override(&dev->mphy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,14 @@ static int
|
||||
mt76_testmode_tx_init(struct mt76_dev *dev)
|
||||
{
|
||||
struct mt76_testmode_data *td = &dev->test;
|
||||
struct mt76_phy *phy = &dev->phy;
|
||||
struct ieee80211_tx_info *info;
|
||||
struct ieee80211_hdr *hdr;
|
||||
struct sk_buff *skb;
|
||||
u16 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
|
||||
IEEE80211_FCTL_FROMDS;
|
||||
struct ieee80211_tx_rate *rate;
|
||||
u8 max_nss = hweight8(dev->phy.antenna_mask);
|
||||
u8 max_nss = hweight8(phy->antenna_mask);
|
||||
|
||||
if (td->tx_antenna_mask)
|
||||
max_nss = min_t(u8, max_nss, hweight8(td->tx_antenna_mask));
|
||||
@@ -78,9 +79,9 @@ mt76_testmode_tx_init(struct mt76_dev *dev)
|
||||
td->tx_skb = skb;
|
||||
hdr = __skb_put_zero(skb, td->tx_msdu_len);
|
||||
hdr->frame_control = cpu_to_le16(fc);
|
||||
memcpy(hdr->addr1, dev->macaddr, sizeof(dev->macaddr));
|
||||
memcpy(hdr->addr2, dev->macaddr, sizeof(dev->macaddr));
|
||||
memcpy(hdr->addr3, dev->macaddr, sizeof(dev->macaddr));
|
||||
memcpy(hdr->addr1, phy->macaddr, sizeof(phy->macaddr));
|
||||
memcpy(hdr->addr2, phy->macaddr, sizeof(phy->macaddr));
|
||||
memcpy(hdr->addr3, phy->macaddr, sizeof(phy->macaddr));
|
||||
|
||||
info = IEEE80211_SKB_CB(skb);
|
||||
info->flags = IEEE80211_TX_CTL_INJECTED |
|
||||
@@ -96,14 +97,14 @@ mt76_testmode_tx_init(struct mt76_dev *dev)
|
||||
|
||||
switch (td->tx_rate_mode) {
|
||||
case MT76_TM_TX_MODE_CCK:
|
||||
if (dev->phy.chandef.chan->band != NL80211_BAND_2GHZ)
|
||||
if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
|
||||
return -EINVAL;
|
||||
|
||||
if (rate->idx > 4)
|
||||
return -EINVAL;
|
||||
break;
|
||||
case MT76_TM_TX_MODE_OFDM:
|
||||
if (dev->phy.chandef.chan->band != NL80211_BAND_2GHZ)
|
||||
if (phy->chandef.chan->band != NL80211_BAND_2GHZ)
|
||||
break;
|
||||
|
||||
if (rate->idx > 8)
|
||||
@@ -114,7 +115,7 @@ mt76_testmode_tx_init(struct mt76_dev *dev)
|
||||
case MT76_TM_TX_MODE_HT:
|
||||
if (rate->idx > 8 * max_nss &&
|
||||
!(rate->idx == 32 &&
|
||||
dev->phy.chandef.width >= NL80211_CHAN_WIDTH_40))
|
||||
phy->chandef.width >= NL80211_CHAN_WIDTH_40))
|
||||
return -EINVAL;
|
||||
|
||||
rate->flags |= IEEE80211_TX_RC_MCS;
|
||||
@@ -143,7 +144,7 @@ mt76_testmode_tx_init(struct mt76_dev *dev)
|
||||
info->flags |= IEEE80211_TX_CTL_STBC;
|
||||
|
||||
if (td->tx_rate_mode >= MT76_TM_TX_MODE_HT) {
|
||||
switch (dev->phy.chandef.width) {
|
||||
switch (phy->chandef.width) {
|
||||
case NL80211_CHAN_WIDTH_40:
|
||||
rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user