Commit 98df2bae authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: move hw mac_addr in mt76_phy



This is a preliminary patch to properly support mt7915 dbdc

Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent db78a791
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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);
+6 −5
Original line number Diff line number Diff line
@@ -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;
+3 −2
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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;
}
+2 −2
Original line number Diff line number Diff line
@@ -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;
}
Loading