diff mbox series

[09/10] wifi: mt76: mt7996: rework background radar check for mt7990

Message ID 20250328055058.1648755-10-shayne.chen@mediatek.com (mailing list archive)
State New
Delegated to: Felix Fietkau
Headers show
Series Add MT7990 support | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format warning Target tree name not specified in the subject
wifibot/tree_selection success Guessed tree name to be wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_clang success Errors and warnings before: 3 this patch: 3
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/build_32bit success Errors and warnings before: 0 this patch: 0
wifibot/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
wifibot/checkpatch warning WARNING: line length of 84 exceeds 80 columns
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Shayne Chen March 28, 2025, 5:50 a.m. UTC
From: StanleyYP Wang <StanleyYP.Wang@mediatek.com>

The mt7990 comes in 2T2R+1R and 3T3R variants on 5 GHz band, with only
the former supporting background radar.

Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
---
 .../wireless/mediatek/mt76/mt7996/eeprom.c    | 27 +++++++++++++++++++
 .../net/wireless/mediatek/mt76/mt7996/init.c  |  2 +-
 .../wireless/mediatek/mt76/mt7996/mt7996.h    | 20 +-------------
 3 files changed, 29 insertions(+), 20 deletions(-)

Comments

Ping-Ke Shih March 31, 2025, 5:55 a.m. UTC | #1
Shayne Chen <shayne.chen@mediatek.com> wrote:

[...]

> +
> +bool mt7996_eeprom_has_background_radar(struct mt7996_dev *dev)
> +{
> +       switch (mt76_chip(&dev->mt76)) {
> +       case MT7996_DEVICE_ID:
> +               if (dev->var.type == MT7996_VAR_TYPE_233)
> +                       return false;
> +               break;
> +       case MT7992_DEVICE_ID:
> +               if (dev->var.type == MT7992_VAR_TYPE_23)
> +                       return false;
> +               break;
> +       case MT7990_DEVICE_ID: {
> +               u8 path, rx_path, nss, *eeprom = dev->mt76.eeprom.data;
> +
> +               mt7996_eeprom_parse_stream(eeprom, MT_BAND1, &path, &rx_path, &nss);
> +               /* Disable background radar capability in 3T3R */
> +               if (path == 3 || rx_path == 3)
> +                       return false;
> +               break;
> +       }

The indentation of close brace looks weird. 

Since -Wdeclaration-after-statement is dropped, I think compilers will not
warn without the braces. But note that it is still not recommended to 
put declarations in the middle.

> +       default:
> +               return false;
> +       }
> +
> +       return true;
> +}
Shayne Chen April 1, 2025, 1:47 p.m. UTC | #2
On Mon, 2025-03-31 at 05:55 +0000, Ping-Ke Shih wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Shayne Chen <shayne.chen@mediatek.com> wrote:
> 
> [...]
> 
> > +
> > +bool mt7996_eeprom_has_background_radar(struct mt7996_dev *dev)
> > +{
> > +       switch (mt76_chip(&dev->mt76)) {
> > +       case MT7996_DEVICE_ID:
> > +               if (dev->var.type == MT7996_VAR_TYPE_233)
> > +                       return false;
> > +               break;
> > +       case MT7992_DEVICE_ID:
> > +               if (dev->var.type == MT7992_VAR_TYPE_23)
> > +                       return false;
> > +               break;
> > +       case MT7990_DEVICE_ID: {
> > +               u8 path, rx_path, nss, *eeprom = dev-
> > >mt76.eeprom.data;
> > +
> > +               mt7996_eeprom_parse_stream(eeprom, MT_BAND1, &path,
> > &rx_path, &nss);
> > +               /* Disable background radar capability in 3T3R */
> > +               if (path == 3 || rx_path == 3)
> > +                       return false;
> > +               break;
> > +       }
> 
> The indentation of close brace looks weird.

Will fix it, thanks.
> 
> Since -Wdeclaration-after-statement is dropped, I think compilers
> will not
> warn without the braces. But note that it is still not recommended to
> put declarations in the middle.
> 
Since those variables are currently only used by mt7990 case, I think
they can be putting there for the moment.

> > +       default:
> > +               return false;
> > +       }
> > +
> > +       return true;
> > +}
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
index 6f3eb053ef02..ca67a2c4b6a7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/eeprom.c
@@ -376,3 +376,30 @@  s8 mt7996_eeprom_get_power_delta(struct mt7996_dev *dev, int band)
 
 	return val & MT_EE_RATE_DELTA_SIGN ? delta : -delta;
 }
+
+bool mt7996_eeprom_has_background_radar(struct mt7996_dev *dev)
+{
+	switch (mt76_chip(&dev->mt76)) {
+	case MT7996_DEVICE_ID:
+		if (dev->var.type == MT7996_VAR_TYPE_233)
+			return false;
+		break;
+	case MT7992_DEVICE_ID:
+		if (dev->var.type == MT7992_VAR_TYPE_23)
+			return false;
+		break;
+	case MT7990_DEVICE_ID: {
+		u8 path, rx_path, nss, *eeprom = dev->mt76.eeprom.data;
+
+		mt7996_eeprom_parse_stream(eeprom, MT_BAND1, &path, &rx_path, &nss);
+		/* Disable background radar capability in 3T3R */
+		if (path == 3 || rx_path == 3)
+			return false;
+		break;
+	}
+	default:
+		return false;
+	}
+
+	return true;
+}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/init.c b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
index 9192fbdbc7da..3bbf6041c96d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/init.c
@@ -475,7 +475,7 @@  mt7996_init_wiphy(struct ieee80211_hw *hw, struct mtk_wed_device *wed)
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
 	wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER);
 
-	if (mt7996_has_background_radar(dev) &&
+	if (mt7996_eeprom_has_background_radar(dev) &&
 	    (!mdev->dev->of_node ||
 	     !of_property_read_bool(mdev->dev->of_node,
 				    "mediatek,disable-radar-background")))
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 92b01ed82e7e..a45cd3ff61a0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -488,25 +488,6 @@  mt7996_band_valid(struct mt7996_dev *dev, u8 band)
 	return band <= MT_BAND2;
 }
 
-static inline bool
-mt7996_has_background_radar(struct mt7996_dev *dev)
-{
-	switch (mt76_chip(&dev->mt76)) {
-	case MT7996_DEVICE_ID:
-		if (dev->var.type == MT7996_VAR_TYPE_233)
-			return false;
-		break;
-	case MT7992_DEVICE_ID:
-		if (dev->var.type == MT7992_VAR_TYPE_23)
-			return false;
-		break;
-	default:
-		return false;
-	}
-
-	return true;
-}
-
 static inline struct mt7996_phy *
 mt7996_band_phy(struct mt7996_dev *dev, enum nl80211_band band)
 {
@@ -570,6 +551,7 @@  int mt7996_eeprom_parse_hw_cap(struct mt7996_dev *dev, struct mt7996_phy *phy);
 int mt7996_eeprom_get_target_power(struct mt7996_dev *dev,
 				   struct ieee80211_channel *chan);
 s8 mt7996_eeprom_get_power_delta(struct mt7996_dev *dev, int band);
+bool mt7996_eeprom_has_background_radar(struct mt7996_dev *dev);
 int mt7996_dma_init(struct mt7996_dev *dev);
 void mt7996_dma_reset(struct mt7996_dev *dev, bool force);
 void mt7996_dma_prefetch(struct mt7996_dev *dev);