Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH rtw-next v2 0/3] wifi: rtw89: allow AP mode on 6 GHz
@ 2026-12-03 11:11 Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 1/3] wifi: rtw89: advertise HE 6 GHz antenna pattern consistency Josef Schlehofer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-12-03 11:11 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless

rtw89 currently refuses to start an AP on 6 GHz. This series adds
support for it. I tested it with a Cudy BE6500 (RTL8922AU) as the
6 GHz AP on a Turris Omnia running OpenWrt.

Patch 1 advertises the HE 6 GHz antenna pattern consistency bits that
hostapd requires by default. Patch 2 gives P2P interfaces the HE and
EHT capabilities of station and AP. Patch 3 reads the AP's 6 GHz power
type from the beacon's HE Operation element, since mac80211 does not
set a power type for AP interfaces. It accepts LPI and VLP at AP start,
and other power types make the start fail.

Changes in v2:
- Patch 2 is new, suggested by Zong-Zhe.
- Patch 3 reuses reg_6ghz_power, the ap_reg_power field is gone.
- Patch 3 handles the AP inside rtw89_reg_6ghz_recalc(), and
  mac80211.c only calls that function.
- Patch 3 no longer refuses a P2P GO on 6 GHz.

v1: https://lore.kernel.org/linux-wireless/20261129120744.88178-1-pepe.schlehofer@gmail.com/

Testing: RTL8922AU with firmware 0.35.80.3, using OpenWrt main's rtw89
driver (backports from 7.2, plus commit a8cddb62c573 ("wifi: rtw89:
check return values in rtw89_ops_start_ap()"), commit 154d3668b645
("wifi: rtw89: set RA init rate level when the station RSSI is known")
and my two 6 GHz fixes from rtw-next). The series also builds on
rtw-next (arm64, W=1).

With patch 2, a phone that joins a P2P GO started by wpa_supplicant
gets HE on 5 GHz and on 6 GHz. Without it the GO sent to the phone at
HT rates on 5 GHz and at 54 Mbit/s on 6 GHz. The P2P client side was
not tested.

With the reworked patch 3 I reran these AP tests: start with LPI and
VLP, a refused standard power beacon, power type changes and a channel
switch on a running 6 GHz AP, and the failed-start unwind and the
blocked-VLP fallback with a temporary patch. That run still had the
P2P check. After dropping it I reran the starts and the power type
changes. The reset when an AP leaves 6 GHz is still compile-tested
only.

The two questions from the v1 cover letter are still open: the
fallback when policy blocks VLP, and whether the Rx bit could stay set
with Tx path diversity.

Josef Schlehofer (3):
  wifi: rtw89: advertise HE 6 GHz antenna pattern consistency
  wifi: rtw89: share HE and EHT capabilities with P2P interfaces
  wifi: rtw89: allow AP mode on 6 GHz

 drivers/net/wireless/realtek/rtw89/core.c     |  12 ++-
 drivers/net/wireless/realtek/rtw89/mac80211.c |  32 +++---
 drivers/net/wireless/realtek/rtw89/regd.c     | 101 +++++++++++++++++-
 3 files changed, 127 insertions(+), 18 deletions(-)

-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH rtw-next v2 1/3] wifi: rtw89: advertise HE 6 GHz antenna pattern consistency
  2026-12-03 11:11 [PATCH rtw-next v2 0/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
@ 2026-12-03 11:11 ` Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 2/3] wifi: rtw89: share HE and EHT capabilities with P2P interfaces Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 3/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-12-03 11:11 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless

hostapd by default requires the Rx and Tx antenna pattern consistency
bits in the HE 6 GHz capabilities and refuses to start an AP on 6 GHz
without them. rtw89 does not set them.

The bits tell a peer that the antenna pattern does not change during the
association. Set them for station and AP, as mt7915 and mt7996 do on
6 GHz, but not when antenna diversity or Tx path diversity can switch
antennas at runtime.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
v2: no change

 drivers/net/wireless/realtek/rtw89/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index b4d72403e0b..2ea4dec5e9e 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -6345,6 +6345,9 @@ static void rtw89_init_he_cap(struct rtw89_dev *rtwdev,
 					IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP) |
 		       le16_encode_bits(chip->max_vht_mpdu_cap,
 					IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN);
+		if (!hal->ant_diversity && !hal->tx_path_diversity)
+			capa |= cpu_to_le16(IEEE80211_HE_6GHZ_CAP_RX_ANTPAT_CONS |
+					    IEEE80211_HE_6GHZ_CAP_TX_ANTPAT_CONS);
 		iftype_data->he_6ghz_capa.capa = capa;
 	}
 }
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rtw-next v2 2/3] wifi: rtw89: share HE and EHT capabilities with P2P interfaces
  2026-12-03 11:11 [PATCH rtw-next v2 0/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 1/3] wifi: rtw89: advertise HE 6 GHz antenna pattern consistency Josef Schlehofer
@ 2026-12-03 11:11 ` Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 3/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-12-03 11:11 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless

rtw89 registers its HE and EHT capabilities for station and AP
interfaces only, so mac80211 finds none for a P2P client or a P2P GO.
A station that joins a P2P GO is then handled as a station without HE.
A GO on 5 GHz sent to an HE phone at HT rates.

Let a P2P client use the station capabilities and a P2P GO the AP
capabilities.

Suggested-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
v2: new patch

 drivers/net/wireless/realtek/rtw89/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 2ea4dec5e9e..edd350b8a21 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -6461,9 +6461,16 @@ static int rtw89_init_he_eht_cap(struct rtw89_dev *rtwdev,
 		return -ENOMEM;
 
 	for (iftype = 0; iftype < NUM_NL80211_IFTYPES; iftype++) {
+		u16 types_mask;
+
 		switch (iftype) {
 		case NL80211_IFTYPE_STATION:
+			types_mask = BIT(NL80211_IFTYPE_STATION) |
+				     BIT(NL80211_IFTYPE_P2P_CLIENT);
+			break;
 		case NL80211_IFTYPE_AP:
+			types_mask = BIT(NL80211_IFTYPE_AP) |
+				     BIT(NL80211_IFTYPE_P2P_GO);
 			break;
 		default:
 			continue;
@@ -6474,7 +6481,7 @@ static int rtw89_init_he_eht_cap(struct rtw89_dev *rtwdev,
 			break;
 		}
 
-		iftype_data[idx].types_mask = BIT(iftype);
+		iftype_data[idx].types_mask = types_mask;
 
 		rtw89_init_he_cap(rtwdev, band, iftype, &iftype_data[idx]);
 		rtw89_init_eht_cap(rtwdev, band, iftype, &iftype_data[idx]);
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH rtw-next v2 3/3] wifi: rtw89: allow AP mode on 6 GHz
  2026-12-03 11:11 [PATCH rtw-next v2 0/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 1/3] wifi: rtw89: advertise HE 6 GHz antenna pattern consistency Josef Schlehofer
  2026-12-03 11:11 ` [PATCH rtw-next v2 2/3] wifi: rtw89: share HE and EHT capabilities with P2P interfaces Josef Schlehofer
@ 2026-12-03 11:11 ` Josef Schlehofer
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Schlehofer @ 2026-12-03 11:11 UTC (permalink / raw)
  To: Ping-Ke Shih; +Cc: Zong-Zhe Yang, linux-wireless

Since commit f6baa1d3d570 ("wifi: rtw89: process regulatory for 6 GHz
power type") rtw89 refuses to start an AP on 6 GHz. The 6 GHz power
type follows the AP that a station connects to, and nothing selects one
for an AP of its own.

mac80211 sets no power type for an AP. Read it from the HE operation
element of the beacon instead, as cfg80211 does for its regulatory
checks. Allow LPI and VLP when the AP starts, and refuse other power
types. Recalculate the 6 GHz power type when the AP starts, stops,
changes its beacon or leaves 6 GHz, and undo it when starting the AP
fails. If a later beacon has a power type that cannot be used, fall
back to the default power type.

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
---
v2:
- reuse reg_6ghz_power, drop ap_reg_power
- read the AP power type in rtw89_reg_6ghz_power_recalc() and handle
  the AP in a sub-function of rtw89_reg_6ghz_recalc(), so mac80211.c
  only calls rtw89_reg_6ghz_recalc()
- return an error from the beacon parser when there is no usable power
  type. reg_6ghz_power cannot mark that case, because
  RTW89_REG_6GHZ_POWER_DFLT equals VLP
- drop the P2P GO check, patch 2 gives a GO its HE capabilities

 drivers/net/wireless/realtek/rtw89/mac80211.c |  32 +++---
 drivers/net/wireless/realtek/rtw89/regd.c     | 101 +++++++++++++++++-
 2 files changed, 116 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/mac80211.c b/drivers/net/wireless/realtek/rtw89/mac80211.c
index 98f4b5c98f6..58746776522 100644
--- a/drivers/net/wireless/realtek/rtw89/mac80211.c
+++ b/drivers/net/wireless/realtek/rtw89/mac80211.c
@@ -799,8 +799,10 @@ static void rtw89_ops_link_info_changed(struct ieee80211_hw *hw,
 		WRITE_ONCE(rtwvif_link->sync_bcn_tsf, 0);
 	}
 
-	if (changed & BSS_CHANGED_BEACON)
+	if (changed & BSS_CHANGED_BEACON) {
+		rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, true);
 		rtw89_chip_h2c_update_beacon(rtwdev, rtwvif_link);
+	}
 
 	if (changed & BSS_CHANGED_ERP_SLOT)
 		rtw89_conf_tx(rtwdev, rtwvif_link);
@@ -828,7 +830,6 @@ static int rtw89_ops_start_ap(struct ieee80211_hw *hw,
 	struct rtw89_dev *rtwdev = hw->priv;
 	struct rtw89_vif *rtwvif = vif_to_rtwvif(vif);
 	struct rtw89_vif_link *rtwvif_link;
-	const struct rtw89_chan *chan;
 	int ret = 0;
 
 	lockdep_assert_wiphy(hw->wiphy);
@@ -841,43 +842,44 @@ static int rtw89_ops_start_ap(struct ieee80211_hw *hw,
 		return -ENOLINK;
 	}
 
-	chan = rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx);
-	if (chan->band_type == RTW89_BAND_6G)
-		return -EOPNOTSUPP;
-
 	if (rtwdev->scanning)
 		rtw89_hw_scan_abort(rtwdev, rtwdev->scan_info.scanning_vif);
 
+	/* must do rtw89_reg_6ghz_recalc() before rfk channel */
+	ret = rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, true);
+	if (ret)
+		return ret;
+
 	ether_addr_copy(rtwvif_link->bssid, link_conf->bssid);
 	rtw89_cam_bssid_changed(rtwdev, rtwvif_link);
 	ret = rtw89_mac_port_update(rtwdev, rtwvif_link);
 	if (ret) {
 		rtw89_warn(rtwdev, "failed to update mac port\n");
-		return ret;
+		goto err;
 	}
 
 	ret = rtw89_chip_h2c_assoc_cmac_tbl(rtwdev, rtwvif_link, NULL);
 	if (ret) {
 		rtw89_warn(rtwdev, "failed to send h2c cmac table\n");
-		return ret;
+		goto err;
 	}
 
 	ret = rtw89_fw_h2c_role_maintain(rtwdev, rtwvif_link, NULL, RTW89_ROLE_TYPE_CHANGE);
 	if (ret) {
 		rtw89_warn(rtwdev, "failed to send h2c role info\n");
-		return ret;
+		goto err;
 	}
 
 	ret = rtw89_fw_h2c_join_info(rtwdev, rtwvif_link, NULL, true);
 	if (ret) {
 		rtw89_warn(rtwdev, "failed to send h2c join info\n");
-		return ret;
+		goto err;
 	}
 
 	ret = rtw89_fw_h2c_cam(rtwdev, rtwvif_link, NULL, NULL, RTW89_ROLE_TYPE_CHANGE);
 	if (ret) {
 		rtw89_warn(rtwdev, "failed to send h2c cam\n");
-		return ret;
+		goto err;
 	}
 
 	rtw89_chip_rfk_channel(rtwdev, rtwvif_link);
@@ -885,12 +887,16 @@ static int rtw89_ops_start_ap(struct ieee80211_hw *hw,
 	if (RTW89_CHK_FW_FEATURE(NOTIFY_AP_INFO, &rtwdev->fw)) {
 		ret = rtw89_fw_h2c_ap_info_refcount(rtwdev, true);
 		if (ret)
-			return ret;
+			goto err;
 	}
 
 	rtw89_queue_chanctx_work(rtwdev);
 
 	return 0;
+
+err:
+	rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, false);
+	return ret;
 }
 
 static
@@ -917,6 +923,8 @@ void rtw89_ops_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 	rtw89_mac_stop_ap(rtwdev, rtwvif_link);
 	rtw89_chip_h2c_assoc_cmac_tbl(rtwdev, rtwvif_link, NULL);
 	rtw89_fw_h2c_join_info(rtwdev, rtwvif_link, NULL, true);
+
+	rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, false);
 }
 
 static int rtw89_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c
index 82cf78cfc64..107a7872e68 100644
--- a/drivers/net/wireless/realtek/rtw89/regd.c
+++ b/drivers/net/wireless/realtek/rtw89/regd.c
@@ -1381,16 +1381,73 @@ static bool __rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev)
 	return true;
 }
 
+/* mac80211 sets no 6 GHz power type for an AP, read it from the beacon */
+static int rtw89_reg_6ghz_ap_power_type(struct rtw89_dev *rtwdev,
+					struct rtw89_vif_link *rtwvif_link,
+					enum ieee80211_ap_reg_power *power_type)
+{
+	const size_t ies_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable);
+	struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
+	const struct ieee80211_he_6ghz_oper *he_6ghz_oper;
+	const struct ieee80211_he_operation *he_oper;
+	enum ieee80211_ap_reg_power type;
+	const struct rtw89_chan *chan;
+	const struct element *elem;
+	struct sk_buff *skb;
+	int ret = -EOPNOTSUPP;
+
+	*power_type = IEEE80211_REG_UNSET_AP;
+
+	chan = rtw89_chan_get(rtwdev, rtwvif_link->chanctx_idx);
+	if (chan->band_type != RTW89_BAND_6G)
+		return 0;
+
+	skb = ieee80211_beacon_get_template(rtwdev->hw, vif, NULL,
+					    rtwvif_link->link_id);
+	if (!skb)
+		return ret;
+
+	if (skb->len < ies_offset)
+		goto out;
+
+	elem = cfg80211_find_ext_elem(WLAN_EID_EXT_HE_OPERATION,
+				      skb->data + ies_offset,
+				      skb->len - ies_offset);
+	if (!elem || elem->datalen < sizeof(*he_oper) + 1 ||
+	    elem->datalen < ieee80211_he_oper_size(elem->data + 1))
+		goto out;
+
+	he_oper = (const void *)&elem->data[1];
+	he_6ghz_oper = ieee80211_he_6ghz_oper(he_oper);
+	if (!he_6ghz_oper)
+		goto out;
+
+	type = cfg80211_6ghz_power_type(he_6ghz_oper->control, 0);
+
+	/* only LPI and VLP are supported for an AP */
+	if (type == IEEE80211_REG_LPI_AP || type == IEEE80211_REG_VLP_AP) {
+		*power_type = type;
+		ret = 0;
+	}
+
+out:
+	dev_kfree_skb_any(skb);
+	return ret;
+}
+
 static int rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
 				       struct rtw89_vif_link *rtwvif_link, bool active,
 				       unsigned int *changed)
 {
 	struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
+	struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
 	const struct rtw89_regd *regd = regulatory->regd;
 	bool blocked[NUM_OF_RTW89_REG_6GHZ_POWER] = {};
 	u8 index = rtw89_regd_get_index(rtwdev, regd);
+	enum ieee80211_ap_reg_power power_type;
 	struct ieee80211_bss_conf *bss_conf;
 	bool dflt = false;
+	int ret = 0;
 
 	if (index == RTW89_REGD_MAX_COUNTRY_NUM ||
 	    test_bit(index, regulatory->block_6ghz_vlp))
@@ -1401,7 +1458,13 @@ static int rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
 	bss_conf = rtw89_vif_rcu_dereference_link(rtwvif_link, true);
 
 	if (active) {
-		switch (bss_conf->power_type) {
+		if (vif->type == NL80211_IFTYPE_AP)
+			ret = rtw89_reg_6ghz_ap_power_type(rtwdev, rtwvif_link,
+							   &power_type);
+		else
+			power_type = bss_conf->power_type;
+
+		switch (power_type) {
 		case IEEE80211_REG_VLP_AP:
 			rtwvif_link->reg_6ghz_power = RTW89_REG_6GHZ_POWER_VLP;
 			break;
@@ -1423,6 +1486,9 @@ static int rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
 
 	rcu_read_unlock();
 
+	if (ret)
+		return ret;
+
 	if (!dflt && blocked[rtwvif_link->reg_6ghz_power]) {
 		rtw89_debug(rtwdev, RTW89_DBG_REGD,
 			    "%c%c 6 GHz power type-%u is blocked by policy\n",
@@ -1435,14 +1501,12 @@ static int rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev,
 	return 0;
 }
 
-int rtw89_reg_6ghz_recalc(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
-			  bool active)
+static int __rtw89_reg_6ghz_recalc(struct rtw89_dev *rtwdev,
+				   struct rtw89_vif_link *rtwvif_link, bool active)
 {
 	unsigned int changed = 0;
 	int ret;
 
-	lockdep_assert_wiphy(rtwdev->hw->wiphy);
-
 	/* The result of reg_6ghz_tpe may depend on reg_6ghz_power type,
 	 * so must do reg_6ghz_tpe_recalc() after reg_6ghz_power_recalc().
 	 */
@@ -1460,3 +1524,30 @@ int rtw89_reg_6ghz_recalc(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvi
 
 	return 0;
 }
+
+static int rtw89_reg_6ghz_recalc_ap(struct rtw89_dev *rtwdev,
+				    struct rtw89_vif_link *rtwvif_link, bool active)
+{
+	int ret;
+
+	ret = __rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, active);
+
+	/* a later beacon cannot be refused, fall back to the default power type */
+	if (ret && active)
+		__rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, false);
+
+	return ret;
+}
+
+int rtw89_reg_6ghz_recalc(struct rtw89_dev *rtwdev, struct rtw89_vif_link *rtwvif_link,
+			  bool active)
+{
+	struct ieee80211_vif *vif = rtwvif_link_to_vif(rtwvif_link);
+
+	lockdep_assert_wiphy(rtwdev->hw->wiphy);
+
+	if (vif->type == NL80211_IFTYPE_AP)
+		return rtw89_reg_6ghz_recalc_ap(rtwdev, rtwvif_link, active);
+
+	return __rtw89_reg_6ghz_recalc(rtwdev, rtwvif_link, active);
+}
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-03 11:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 11:11 [PATCH rtw-next v2 0/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer
2026-12-03 11:11 ` [PATCH rtw-next v2 1/3] wifi: rtw89: advertise HE 6 GHz antenna pattern consistency Josef Schlehofer
2026-12-03 11:11 ` [PATCH rtw-next v2 2/3] wifi: rtw89: share HE and EHT capabilities with P2P interfaces Josef Schlehofer
2026-12-03 11:11 ` [PATCH rtw-next v2 3/3] wifi: rtw89: allow AP mode on 6 GHz Josef Schlehofer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox