Skip to contentSkip to conversation

introduce background radar support for mt7915 driver

PATCH Superseded Lorenzo Bianconi 4 participants 12 messages Jan 12, 2022 – Apr 17, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lorenzo Bianconi

author maintainer
#0 lore raw

cover introduce background radar support for mt7915 driver

Introduce radar/CAC background detection support for mt7915 driver Background radar/CAC detection allows to avoid the CAC downtime switching on a different channel during CAC detection on the selected radar channel.

Lorenzo Bianconi (6):
mt76: mt7915: introduce mt7915_set_radar_background routine
mt76: mt7915: enable radar trigger on rdd2
mt76: mt7915: introduce rdd_monitor debugfs node
mt76: mt7915: report radar pattern if detected by rdd2
mt76: mt7915: enable radar background detection dt-bindings:net:wireless:mediatek,mt76: add disable-radar-offchan

 .../bindings/net/wireless/mediatek,mt76.yaml  |   9 ++
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |   1 +
 .../wireless/mediatek/mt76/mt7915/debugfs.c   |  55 +++++++++-
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  10 ++
 .../net/wireless/mediatek/mt76/mt7915/main.c  |  50 +++++++++
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 100 +++++++++++++++++-
 .../net/wireless/mediatek/mt76/mt7915/mcu.h   |  23 ++++
 .../wireless/mediatek/mt76/mt7915/mt7915.h    |   7 ++
 8 files changed, 253 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/6 mt76: mt7915: introduce mt7915_set_radar_background routine

Introduce mt7915_mcu_rdd_background_enable and mt7915_mcu_background_chain_ctrl routines to configure rx dfs dedicated chain. This is a preliminary patch to add zero-wait dfs support performing CAC detection on rdd2.

---
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |  1 +
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  3 +
 .../net/wireless/mediatek/mt76/mt7915/main.c  | 50 ++++++++++
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 93 +++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7915/mcu.h   | 23 +++++
 .../wireless/mediatek/mt76/mt7915/mt7915.h    |  7 ++
 6 files changed, 177 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -0
index 1ebe02f55267..7b9d82dd3f9d 100644
@@ -977,6 +977,7 @@ enum {
 	MCU_EXT_CMD_SCS_CTRL = 0x82,
 	MCU_EXT_CMD_TWT_AGRT_UPDATE = 0x94,
 	MCU_EXT_CMD_FW_DBG_CTRL = 0x95,
+	MCU_EXT_CMD_OFFCH_SCAN_CTRL = 0x9a,
 	MCU_EXT_CMD_SET_RDD_TH = 0x9d,
 	MCU_EXT_CMD_MURU_CTRL = 0x9f,
 	MCU_EXT_CMD_SET_SPR = 0xa8,
drivers/net/wireless/mediatek/mt76/mt7915/init.c +3 -0
index 9613192b66c4..5c1643963506 100644
@@ -293,6 +293,9 @@ mt7915_regd_notifier(struct wiphy *wiphy,
 	memcpy(dev->mt76.alpha2, request->alpha2, sizeof(dev->mt76.alpha2));
 	dev->mt76.region = request->dfs_region;
 
+	if (dev->mt76.region == NL80211_DFS_UNSET)
+		mt7915_mcu_rdd_background_enable(phy, NULL);
+
 	mt7915_init_txpower(dev, &mphy->sband_2g.sband);
 	mt7915_init_txpower(dev, &mphy->sband_5g.sband);
 
drivers/net/wireless/mediatek/mt76/mt7915/main.c +50 -0

60 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +93 -0

99 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +23 -0
index aa05c6ceebb9..9417f7bc807a 100644
@@ -131,6 +131,29 @@ struct mt7915_mcu_rdd_report {
 	} hw_pulse[32];
 } __packed;
 
+struct mt7915_mcu_background_chain_ctrl {
+	u8 chan;		/* primary channel */
+	u8 central_chan;	/* central channel */
+	u8 bw;
+	u8 tx_stream;
+	u8 rx_stream;
+
+	u8 monitor_chan;	/* monitor channel */
+	u8 monitor_central_chan;/* monitor central channel */
+	u8 monitor_bw;
+	u8 monitor_tx_stream;
+	u8 monitor_rx_stream;
+
+	u8 scan_mode;		/* 0: ScanStop
+				 * 1: ScanStart
+				 * 2: ScanRunning
+				 */
+	u8 band_idx;		/* DBDC */
+	u8 monitor_scan_type;
+	u8 band;		/* 0: 2.4GHz, 1: 5GHz */
+	u8 rsv[2];
+} __packed;
+
 struct mt7915_mcu_eeprom {
 	u8 buffer_mode;
 	u8 format;
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +7 -0
index cd7ee716f147..f5c22b86e1a9 100644
@@ -269,6 +269,10 @@ struct mt7915_dev {
 	struct tasklet_struct irq_tasklet;
 	struct mt7915_phy phy;
 
+	/* monitor rx chain configured channel */
+	struct cfg80211_chan_def rdd2_chandef;
+	struct mt7915_phy *rdd2_phy;
+
 	u16 chainmask;
 	u32 hif_idx;
 
@@ -328,6 +332,7 @@ enum {
 enum {
 	MT_RX_SEL0,
 	MT_RX_SEL1,
+	MT_RX_SEL2, /* monitor chain */
 };
 
 enum mt7915_rdd_cmd {
@@ -461,6 +466,8 @@ int mt7915_mcu_get_temperature(struct mt7915_phy *phy);
 int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state);
 int mt7915_mcu_get_rx_rate(struct mt7915_phy *phy, struct ieee80211_vif *vif,
 			   struct ieee80211_sta *sta, struct rate_info *rate);
+int mt7915_mcu_rdd_background_enable(struct mt7915_phy *phy,
+				     struct cfg80211_chan_def *chandef);
 int mt7915_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3);
 int mt7915_mcu_fw_log_2_host(struct mt7915_dev *dev, u8 type, u8 ctrl);
 int mt7915_mcu_fw_dbg_ctrl(struct mt7915_dev *dev, u32 module, u8 level);
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/6 mt76: mt7915: enable radar trigger on rdd2

In reply to Lorenzo Bianconi

Enable radar trigger for rdd2 in mt7915_radar_trigger.

---
 drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +5 -1
index 464d2b42f0df..e140336a4fe1 100644
@@ -79,7 +79,11 @@ mt7915_radar_trigger(void *data, u64 val)
 {
 	struct mt7915_dev *dev = data;
 
-	return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_RADAR_EMULATE, 1, 0, 0);
+	if (val > MT_RX_SEL2)
+		return -EINVAL;
+
+	return mt76_connac_mcu_rdd_cmd(&dev->mt76, RDD_RADAR_EMULATE,
+				       val, 0, 0);
 }
 
 DEFINE_DEBUGFS_ATTRIBUTE(fops_radar_trigger, NULL,
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH 3/6 mt76: mt7915: introduce rdd_monitor debugfs node

In reply to Lorenzo Bianconi

Introduce rdd_monitor debugfs node in order to dump rdd2 configuration.

---
 .../wireless/mediatek/mt76/mt7915/debugfs.c   | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +49 -0
index e140336a4fe1..280823fc9f92 100644
@@ -308,6 +308,53 @@ static int mt7915_muru_stats_show(struct seq_file *file, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(mt7915_muru_stats);
 
+static int
+mt7915_rdd_monitor(struct seq_file *s, void *data)
+{
+	struct mt7915_dev *dev = dev_get_drvdata(s->private);
+	struct cfg80211_chan_def *chandef = &dev->rdd2_chandef;
+	const char *bw;
+	int ret = 0;
+
+	mutex_lock(&dev->mt76.mutex);
+
+	if (!cfg80211_chandef_valid(chandef)) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	if (!dev->rdd2_phy) {
+		seq_puts(s, "not running\n");
+		goto out;
+	}
+
+	switch (chandef->width) {
+	case NL80211_CHAN_WIDTH_40:
+		bw = "40";
+		break;
+	case NL80211_CHAN_WIDTH_80:
+		bw = "80";
+		break;
+	case NL80211_CHAN_WIDTH_160:
+		bw = "160";
+		break;
+	case NL80211_CHAN_WIDTH_80P80:
+		bw = "80P80";
+		break;
+	default:
+		bw = "20";
+		break;
+	}
+
+	seq_printf(s, "channel %d (%d MHz) width %s MHz center1: %d MHz\n",
+		   chandef->chan->hw_value, chandef->chan->center_freq,
+		   bw, chandef->center_freq1);
+out:
+	mutex_unlock(&dev->mt76.mutex);
+
+	return ret;
+}
+
 static int
 mt7915_fw_debug_wm_set(void *data, u64 val)
 {
@@ -856,6 +903,8 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
 				   &dev->hw_pattern);
 		debugfs_create_file("radar_trigger", 0200, dir, dev,
 				    &fops_radar_trigger);
+		debugfs_create_devm_seqfile(dev->mt76.dev, "rdd_monitor", dir,
+					    mt7915_rdd_monitor);
 	}
 
 	if (!ext_phy)
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH 4/6 mt76: mt7915: report radar pattern if detected by rdd2

In reply to Lorenzo Bianconi

Report radar pattern to mac80211 if detected by the offchannel chain.

---
 drivers/net/wireless/mediatek/mt76/mt7915/mcu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +6 -1
index dddefeebc7dd..e42900b2545f 100644
@@ -358,7 +358,12 @@ mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb)
 	if (r->band_idx && dev->mt76.phy2)
 		mphy = dev->mt76.phy2;
 
-	ieee80211_radar_detected(mphy->hw);
+	if (r->band_idx == MT_RX_SEL2)
+		cfg80211_background_radar_event(mphy->hw->wiphy,
+						&dev->rdd2_chandef,
+						GFP_ATOMIC);
+	else
+		ieee80211_radar_detected(mphy->hw);
 	dev->hw_pattern++;
 }
 
Signature · 1 line
2.34.1
author maintainer
#5 lore raw

PATCH 5/6 mt76: mt7915: enable radar background detection

In reply to Lorenzo Bianconi

Notify userland the hw supports background radar/CAC detection.

---
 drivers/net/wireless/mediatek/mt76/mt7915/init.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +7 -0
index 5c1643963506..91c7ce60f296 100644
@@ -309,6 +309,7 @@ static void
 mt7915_init_wiphy(struct ieee80211_hw *hw)
 {
 	struct mt7915_phy *phy = mt7915_hw_phy(hw);
+	struct mt76_dev *mdev = &phy->dev->mt76;
 	struct wiphy *wiphy = hw->wiphy;
 	struct mt7915_dev *dev = phy->dev;
 
@@ -337,6 +338,12 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT);
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HE);
 
+	if (!mdev->dev->of_node ||
+	    !of_property_read_bool(mdev->dev->of_node,
+				   "mediatek,disable-radar-background"))
+		wiphy_ext_feature_set(wiphy,
+				      NL80211_EXT_FEATURE_RADAR_BACKGROUND);
+
 	ieee80211_hw_set(hw, HAS_RATE_CONTROL);
 	ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
 	ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 5/6] mt76: mt7915: enable radar background detection

Quoted 1 line · Lorenzo Bianconi

Notify userland the hw supports background radar/CAC detection.

So, what about someone like me using mtk7915 4x4 radio from asia-rf? It has no extra RF chains afaik, and it is certainly broken when trying to use DFS channels on my system.

Maybe you need a positive check instead of negative check before enabling this feature?

Thanks,
Ben

Quoted 33 lines
---
  drivers/net/wireless/mediatek/mt76/mt7915/init.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +7 -0
index 5c1643963506..91c7ce60f296 100644
@@ -309,6 +309,7 @@ static void
  mt7915_init_wiphy(struct ieee80211_hw *hw)
  {
  	struct mt7915_phy *phy = mt7915_hw_phy(hw);
+	struct mt76_dev *mdev = &phy->dev->mt76;
  	struct wiphy *wiphy = hw->wiphy;
  	struct mt7915_dev *dev = phy->dev;
 
@@ -337,6 +338,12 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)
  	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT);
  	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HE);
 
+	if (!mdev->dev->of_node ||
+	    !of_property_read_bool(mdev->dev->of_node,
+				   "mediatek,disable-radar-background"))
+		wiphy_ext_feature_set(wiphy,
+				      NL80211_EXT_FEATURE_RADAR_BACKGROUND);
+
  	ieee80211_hw_set(hw, HAS_RATE_CONTROL);
  	ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
  	ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
author maintainer
#7 lore raw

Re: [PATCH 5/6] mt76: mt7915: enable radar background detection

Quoted 6 lines · Lorenzo Bianconi
Quoted 1 line

Notify userland the hw supports background radar/CAC detection.

So, what about someone like me using mtk7915 4x4 radio from asia-rf? It has no extra RF chains afaik, and it is certainly broken when trying to use DFS channels on my system.

according to my understanding asia-rf card can be considered an outlier from this point of view (mt7915 regular card should support a dedicated radar chain). AFAIU there is no way to autodetect this feature (@Ryder correct?), so we could add a module parameter (similar to dts one) to disable this feature. What do you think?

Regards,
Lorenzo

Quoted 44 lines

Maybe you need a positive check instead of negative check before enabling this feature?

Thanks,
Ben

Quoted 31 lines
---
  drivers/net/wireless/mediatek/mt76/mt7915/init.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7915/init.c +7 -0
index 5c1643963506..91c7ce60f296 100644
@@ -309,6 +309,7 @@ static void
  mt7915_init_wiphy(struct ieee80211_hw *hw)
  {
  	struct mt7915_phy *phy = mt7915_hw_phy(hw);
+	struct mt76_dev *mdev = &phy->dev->mt76;
  	struct wiphy *wiphy = hw->wiphy;
  	struct mt7915_dev *dev = phy->dev;
@@ -337,6 +338,12 @@ mt7915_init_wiphy(struct ieee80211_hw *hw)
  	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_VHT);
  	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_BEACON_RATE_HE);
+	if (!mdev->dev->of_node ||
+	    !of_property_read_bool(mdev->dev->of_node,
+				   "mediatek,disable-radar-background"))
+		wiphy_ext_feature_set(wiphy,
+				      NL80211_EXT_FEATURE_RADAR_BACKGROUND);
+
  	ieee80211_hw_set(hw, HAS_RATE_CONTROL);
  	ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
  	ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
 
Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
author maintainer
#8 lore raw

PATCH 6/6 dt-bindings:net:wireless:mediatek,mt76: add disable-radar-offchan

In reply to Lorenzo Bianconi

Add the capability to disable/enable radar/CAC detection running on a dedicated offchannel chain available on some hw. Offchannel radar/CAC detection allows to avoid CAC downtime switching on a different channel during CAC detection on the selected radar channel.

---
 .../devicetree/bindings/net/wireless/mediatek,mt76.yaml  | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +9 -0
index 1489d3c1cd6e..4a564bb59552 100644
@@ -69,6 +69,15 @@ properties:
       calibration data is generic and specific calibration data should be
       pulled from the OTP ROM
 
+  mediatek,disable-radar-background:
+    type: boolean
+    description:
+      Disable/enable radar/CAC detection running on a dedicated offchannel
+      chain available on some hw.
+      Background radar/CAC detection allows to avoid the CAC downtime
+      switching on a different channel during CAC detection on the selected
+      radar channel.
+
   led:
     type: object
     $ref: /schemas/leds/common.yaml#
Signature · 1 line
2.34.1
#9 lore raw
In reply to Lorenzo Bianconi
Quoted 4 lines

Introduce radar/CAC background detection support for mt7915 driver Background radar/CAC detection allows to avoid the CAC downtime switching on a different channel during CAC detection on the selected radar channel.

@Rob: I forgot to add devicetree ML in cc. Do I need to repost?

Regards,
Lorenzo

Quoted 22 lines

Lorenzo Bianconi (6):
mt76: mt7915: introduce mt7915_set_radar_background routine
mt76: mt7915: enable radar trigger on rdd2
mt76: mt7915: introduce rdd_monitor debugfs node
mt76: mt7915: report radar pattern if detected by rdd2
mt76: mt7915: enable radar background detection dt-bindings:net:wireless:mediatek,mt76: add disable-radar-offchan

 .../bindings/net/wireless/mediatek,mt76.yaml  |   9 ++
 .../wireless/mediatek/mt76/mt76_connac_mcu.h  |   1 +
 .../wireless/mediatek/mt76/mt7915/debugfs.c   |  55 +++++++++-
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  10 ++
 .../net/wireless/mediatek/mt76/mt7915/main.c  |  50 +++++++++
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 100 +++++++++++++++++-
 .../net/wireless/mediatek/mt76/mt7915/mcu.h   |  23 ++++
 .../wireless/mediatek/mt76/mt7915/mt7915.h    |   7 ++
 8 files changed, 253 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
maintainer
#10 lore raw
Quoted 7 lines · Lorenzo Bianconi
Quoted 5 lines

Introduce radar/CAC background detection support for mt7915 driver Background radar/CAC detection allows to avoid the CAC downtime switching on a different channel during CAC detection on the selected radar channel.

@Rob: I forgot to add devicetree ML in cc. Do I need to repost?

Yes, that's the only way patchwork picks up patches and checks run.

Rob

#11 lore raw
Quoted 8 lines
Quoted 6 lines · Lorenzo Bianconi
Quoted 5 lines

Introduce radar/CAC background detection support for mt7915 driver Background radar/CAC detection allows to avoid the CAC downtime switching on a different channel during CAC detection on the selected radar channel.

Quoted 6 lines
Quoted 1 line

@Rob: I forgot to add devicetree ML in cc. Do I need to repost?

Yes, that's the only way patchwork picks up patches and checks run.

Rob

ack, posted v2.

Regards,
Lorenzo