Linux wireless drivers development
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@nbd.name>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 02/24] wifi: mt76: add support for allocating a phy without hw
Date: Thu,  2 Jan 2025 17:34:46 +0100	[thread overview]
Message-ID: <20250102163508.52945-2-nbd@nbd.name> (raw)
In-Reply-To: <20250102163508.52945-1-nbd@nbd.name>

Preparation for supporting a single hw with multiple radios

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 39 ++++++++++++++++---
 drivers/net/wireless/mediatek/mt76/mt76.h     |  2 +
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 69fcea08e3fd..5a77f94b7f82 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -411,13 +411,15 @@ mt76_check_sband(struct mt76_phy *phy, struct mt76_sband *msband,
 	}
 
 	if (found) {
-		phy->chandef.chan = &sband->channels[0];
+		cfg80211_chandef_create(&phy->chandef, &sband->channels[0],
+					NL80211_CHAN_HT20);
 		phy->chan_state = &msband->chan[0];
 		return;
 	}
 
 	sband->n_channels = 0;
-	phy->hw->wiphy->bands[band] = NULL;
+	if (phy->hw->wiphy->bands[band] == sband)
+		phy->hw->wiphy->bands[band] = NULL;
 }
 
 static int
@@ -429,6 +431,9 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
 	INIT_LIST_HEAD(&phy->tx_list);
 	spin_lock_init(&phy->tx_lock);
 
+	if ((void *)phy != hw->priv)
+		return 0;
+
 	SET_IEEE80211_DEV(hw, dev->dev);
 	SET_IEEE80211_PERM_ADDR(hw, phy->macaddr);
 
@@ -480,6 +485,28 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
 	return 0;
 }
 
+struct mt76_phy *
+mt76_alloc_radio_phy(struct mt76_dev *dev, unsigned int size,
+		     u8 band_idx)
+{
+	struct ieee80211_hw *hw = dev->phy.hw;
+	unsigned int phy_size;
+	struct mt76_phy *phy;
+
+	phy_size = ALIGN(sizeof(*phy), 8);
+	phy = devm_kzalloc(dev->dev, size + phy_size, GFP_KERNEL);
+	if (!phy)
+		return NULL;
+
+	phy->dev = dev;
+	phy->hw = hw;
+	phy->priv = (void *)phy + phy_size;
+	phy->band_idx = band_idx;
+
+	return phy;
+}
+EXPORT_SYMBOL_GPL(mt76_alloc_radio_phy);
+
 struct mt76_phy *
 mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,
 	       const struct ieee80211_ops *ops, u8 band_idx)
@@ -552,9 +579,11 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
 	mt76_check_sband(phy, &phy->sband_5g, NL80211_BAND_5GHZ);
 	mt76_check_sband(phy, &phy->sband_6g, NL80211_BAND_6GHZ);
 
-	ret = ieee80211_register_hw(phy->hw);
-	if (ret)
-		return ret;
+	if ((void *)phy == phy->hw->priv) {
+		ret = ieee80211_register_hw(phy->hw);
+		if (ret)
+			return ret;
+	}
 
 	set_bit(MT76_STATE_REGISTERED, &phy->state);
 	phy->dev->phys[phy->band_idx] = phy;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index b649039f384b..aac8ca7265c2 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1177,6 +1177,8 @@ void mt76_unregister_device(struct mt76_dev *dev);
 void mt76_free_device(struct mt76_dev *dev);
 void mt76_unregister_phy(struct mt76_phy *phy);
 
+struct mt76_phy *mt76_alloc_radio_phy(struct mt76_dev *dev, unsigned int size,
+				      u8 band_idx);
 struct mt76_phy *mt76_alloc_phy(struct mt76_dev *dev, unsigned int size,
 				const struct ieee80211_ops *ops,
 				u8 band_idx);
-- 
2.47.1


  reply	other threads:[~2025-01-02 16:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-02 16:34 [PATCH 01/24] wifi: mt76: add code for emulating hardware scanning Felix Fietkau
2025-01-02 16:34 ` Felix Fietkau [this message]
2025-01-02 16:34 ` [PATCH 03/24] wifi: mt76: rename struct mt76_vif to mt76_vif_link Felix Fietkau
2025-01-02 16:34 ` [PATCH 04/24] wifi: mt76: add vif link specific data structure Felix Fietkau
2025-01-02 16:34 ` [PATCH 05/24] wifi: mt76: mt7996: split link specific data from struct mt7996_vif Felix Fietkau
2025-01-02 16:34 ` [PATCH 06/24] wifi: mt76: initialize more wcid fields mt76_wcid_init Felix Fietkau
2025-01-02 16:34 ` [PATCH 07/24] wifi: mt76: add chanctx functions for multi-channel phy support Felix Fietkau
2025-01-02 16:34 ` [PATCH 08/24] wifi: mt76: remove dev->wcid_phy_mask Felix Fietkau
2025-01-02 16:34 ` [PATCH 09/24] wifi: mt76: add multi-radio support to a few core hw ops Felix Fietkau
2025-01-02 16:34 ` [PATCH 10/24] wifi: mt76: add multi-radio support to tx scheduling Felix Fietkau
2025-01-02 16:34 ` [PATCH 11/24] wifi: mt76: add multi-radio support to scanning code Felix Fietkau
2025-01-02 16:34 ` [PATCH 12/24] wifi: mt76: add multi-radio remain_on_channel functions Felix Fietkau
2025-01-02 16:34 ` [PATCH 13/24] wifi: mt76: mt7996: use emulated hardware scan support Felix Fietkau
2025-01-02 16:34 ` [PATCH 14/24] wifi: mt76: mt7996: pass wcid to mt7996_mcu_sta_hdr_trans_tlv Felix Fietkau
2025-01-02 16:34 ` [PATCH 15/24] wifi: mt76: mt7996: prepare mt7996_mcu_add_dev/bss_info for MLO support Felix Fietkau
2025-01-02 16:35 ` [PATCH 16/24] wifi: mt76: mt7996: prepare mt7996_mcu_add_beacon " Felix Fietkau
2025-01-02 16:35 ` [PATCH 17/24] wifi: mt76: mt7996: prepare mt7996_mcu_set_tx " Felix Fietkau
2025-01-02 16:35 ` [PATCH 18/24] wifi: mt76: mt7996: prepare mt7996_mcu_set_timing " Felix Fietkau
2025-01-02 16:35 ` [PATCH 19/24] wifi: mt76: connac: prepare mt76_connac_mcu_sta_basic_tlv " Felix Fietkau
2025-01-02 16:35 ` [PATCH 20/24] wifi: mt76: mt7996: prepare mt7996_mcu_update_bss_color " Felix Fietkau
2025-01-02 16:35 ` [PATCH 21/24] wifi: mt76: connac: rework connac helpers Felix Fietkau
2025-01-02 16:35 ` [PATCH 22/24] wifi: mt76: mt7996: move all debugfs files to the primary phy Felix Fietkau
2025-01-02 16:35 ` [PATCH 23/24] wifi: mt76: mt7996: switch to single multi-radio wiphy Felix Fietkau
2025-05-01 21:45   ` Ben Greear
2025-01-02 16:35 ` [PATCH 24/24] wifi: mt76: mt7996: fix monitor mode Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250102163508.52945-2-nbd@nbd.name \
    --to=nbd@nbd.name \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox