linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: nbd@nbd.name, johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com,
	ryder.lee@mediatek.com, evelyn.tsai@mediatek.com,
	john@phrozen.org
Subject: [RFC 7/7] mt76: mt7915: add cac support for offchannel chain
Date: Tue, 28 Sep 2021 17:14:38 +0200	[thread overview]
Message-ID: <1645ce5e1b844675929b74a5671a9bbd8b6d9dfb.1632841652.git.lorenzo@kernel.org> (raw)
In-Reply-To: <cover.1632841652.git.lorenzo@kernel.org>

Introduce cac management for dedicated offchannel chain.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 .../net/wireless/mediatek/mt76/mt7915/init.c  |  2 ++
 .../net/wireless/mediatek/mt76/mt7915/mac.c   | 24 ++++++++++++++++++-
 .../net/wireless/mediatek/mt76/mt7915/main.c  |  1 +
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 15 ++++++++++--
 .../wireless/mediatek/mt76/mt7915/mt7915.h    |  2 ++
 5 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index ba4d644fe846..a3630953d7c7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
@@ -907,6 +907,8 @@ int mt7915_register_device(struct mt7915_dev *dev)
 	dev->mt76.phy.priv = &dev->phy;
 	INIT_WORK(&dev->rc_work, mt7915_mac_sta_rc_work);
 	INIT_DELAYED_WORK(&dev->mphy.mac_work, mt7915_mac_work);
+	INIT_DELAYED_WORK(&dev->offchan_chain.cac_work,
+			  mt7915_offchan_cac_work);
 	INIT_LIST_HEAD(&dev->sta_rc_list);
 	INIT_LIST_HEAD(&dev->sta_poll_list);
 	INIT_LIST_HEAD(&dev->twt_list);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
index a2f94bedf9a1..5d588fe1056d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
@@ -2320,9 +2320,13 @@ void mt7915_mac_twt_teardown_flow(struct mt7915_dev *dev,
 int mt7915_dfs_set_rdd_monitor(struct mt7915_phy *phy, bool enable)
 {
 	struct mt7915_dev *dev = phy->dev;
+	struct ieee80211_channel *chan = dev->offchan_chain.chandef.chan;
+	struct delayed_work *cac_work = &dev->offchan_chain.cac_work;
 	int err, region;
 
 	if (!enable || dev->mt76.region == NL80211_DFS_UNSET) {
+		cancel_delayed_work_sync(cac_work);
+
 		err = mt7915_mcu_rdd_cmd(dev, RDD_STOP, MT_RX_SEL2, 0, 0);
 		if (err)
 			return err;
@@ -2349,5 +2353,23 @@ int mt7915_dfs_set_rdd_monitor(struct mt7915_phy *phy, bool enable)
 		break;
 	}
 
-	return mt7915_mcu_rdd_cmd(dev, RDD_START, MT_RX_SEL2, 0, region);
+	err = mt7915_mcu_rdd_cmd(dev, RDD_START, MT_RX_SEL2, 0, region);
+	if (err)
+		return err;
+
+	ieee80211_queue_delayed_work(mt76_hw(dev), cac_work,
+				     msecs_to_jiffies(chan->dfs_cac_ms));
+
+	return 0;
+}
+
+void mt7915_offchan_cac_work(struct work_struct *work)
+{
+	struct mt7915_dev *dev;
+
+	dev = (struct mt7915_dev *)container_of(work, struct mt7915_dev,
+						offchan_chain.cac_work.work);
+	cfg80211_cac_offchan_event(dev->mphy.hw->wiphy,
+				   &dev->offchan_chain.chandef,
+				   NL80211_RADAR_CAC_FINISHED, GFP_KERNEL);
 }
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/main.c b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
index 406517bfbfc2..9020aa7bf359 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/main.c
@@ -98,6 +98,7 @@ static void mt7915_stop(struct ieee80211_hw *hw)
 	struct mt7915_phy *phy = mt7915_hw_phy(hw);
 
 	cancel_delayed_work_sync(&phy->mt76->mac_work);
+	cancel_delayed_work_sync(&dev->offchan_chain.cac_work);
 
 	mutex_lock(&dev->mt76.mutex);
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index 6249be262825..d24eade6667b 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -481,10 +481,21 @@ mt7915_mcu_rx_radar_detected(struct mt7915_dev *dev, struct sk_buff *skb)
 
 	r = (struct mt7915_mcu_rdd_report *)skb->data;
 
-	if (r->band_idx && dev->mt76.phy2)
+	if (r->band_idx == MT_RX_SEL1 && dev->mt76.phy2)
 		mphy = dev->mt76.phy2;
 
-	ieee80211_radar_detected(mphy->hw);
+	if (r->band_idx == MT_RX_SEL2) {
+		cancel_delayed_work_sync(&dev->offchan_chain.cac_work);
+		cfg80211_cac_offchan_event(dev->mphy.hw->wiphy,
+					   &dev->offchan_chain.chandef,
+					   NL80211_RADAR_CAC_ABORTED,
+					   GFP_KERNEL);
+		cfg80211_radar_event(mphy->hw->wiphy,
+				     &dev->offchan_chain.chandef,
+				     GFP_KERNEL);
+	} else {
+		ieee80211_radar_detected(mphy->hw);
+	}
 	dev->hw_pattern++;
 }
 
diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index 65017a4347b9..6576eb34d211 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
@@ -194,6 +194,7 @@ struct mt7915_dev {
 	/* monitor rx chain configured channel */
 	struct {
 		struct cfg80211_chan_def chandef;
+		struct delayed_work cac_work;
 	} offchan_chain;
 
 	u16 chainmask;
@@ -463,6 +464,7 @@ void mt7915_stats_work(struct work_struct *work);
 int mt76_dfs_start_rdd(struct mt7915_dev *dev, bool force);
 int mt7915_dfs_init_radar_detector(struct mt7915_phy *phy);
 int mt7915_dfs_set_rdd_monitor(struct mt7915_phy *phy, bool enable);
+void mt7915_offchan_cac_work(struct work_struct *work);
 void mt7915_set_stream_he_caps(struct mt7915_phy *phy);
 void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy);
 void mt7915_update_channel(struct mt76_phy *mphy);
-- 
2.31.1


      parent reply	other threads:[~2021-09-28 15:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 15:14 [RFC 0/7] add offchannel monitor chain support Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 1/7] mac80211: introduce set_offchan_chain callback Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 2/7] cfg80211: introduce nl80211_set_offchan_chain callback Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 3/7] cfg80211: introduce cfg80211_cac_offchan_event routine Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 4/7] mt76: mt7915: introduce mt7915_set_offchan_chain routine Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 5/7] mt76: mt7915: enable radar trigger on rdd2 Lorenzo Bianconi
2021-09-28 15:14 ` [RFC 6/7] mt76: mt7915: introduce rdd_monitor debugfs node Lorenzo Bianconi
2021-09-28 15:14 ` Lorenzo Bianconi [this message]

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=1645ce5e1b844675929b74a5671a9bbd8b6d9dfb.1632841652.git.lorenzo@kernel.org \
    --to=lorenzo@kernel.org \
    --cc=evelyn.tsai@mediatek.com \
    --cc=johannes@sipsolutions.net \
    --cc=john@phrozen.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    /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;
as well as URLs for NNTP newsgroup(s).