Commit 984d8854 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7603: add debugfs knob to enable/disable edcca

Introduce a knob in mt7603 debugfs in order to enable/disable
energy detection based on CCA thresholds
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 8aac454d
...@@ -40,6 +40,35 @@ mt7603_radio_read(struct seq_file *s, void *data) ...@@ -40,6 +40,35 @@ mt7603_radio_read(struct seq_file *s, void *data)
return 0; return 0;
} }
static int
mt7603_edcca_set(void *data, u64 val)
{
struct mt7603_dev *dev = data;
mutex_lock(&dev->mt76.mutex);
dev->ed_monitor_enabled = !!val;
dev->ed_monitor = dev->ed_monitor_enabled &&
dev->region == NL80211_DFS_ETSI;
mt7603_init_edcca(dev);
mutex_unlock(&dev->mt76.mutex);
return 0;
}
static int
mt7603_edcca_get(void *data, u64 *val)
{
struct mt7603_dev *dev = data;
*val = dev->ed_monitor_enabled;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(fops_edcca, mt7603_edcca_get,
mt7603_edcca_set, "%lld\n");
void mt7603_init_debugfs(struct mt7603_dev *dev) void mt7603_init_debugfs(struct mt7603_dev *dev)
{ {
struct dentry *dir; struct dentry *dir;
...@@ -48,6 +77,7 @@ void mt7603_init_debugfs(struct mt7603_dev *dev) ...@@ -48,6 +77,7 @@ void mt7603_init_debugfs(struct mt7603_dev *dev)
if (!dir) if (!dir)
return; return;
debugfs_create_file("edcca", 0600, dir, dev, &fops_edcca);
debugfs_create_u32("reset_test", 0600, dir, &dev->reset_test); debugfs_create_u32("reset_test", 0600, dir, &dev->reset_test);
debugfs_create_devm_seqfile(dev->mt76.dev, "reset", dir, debugfs_create_devm_seqfile(dev->mt76.dev, "reset", dir,
mt7603_reset_read); mt7603_reset_read);
......
...@@ -437,7 +437,9 @@ mt7603_regd_notifier(struct wiphy *wiphy, ...@@ -437,7 +437,9 @@ mt7603_regd_notifier(struct wiphy *wiphy,
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
struct mt7603_dev *dev = hw->priv; struct mt7603_dev *dev = hw->priv;
dev->ed_monitor = request->dfs_region == NL80211_DFS_ETSI; dev->region = request->dfs_region;
dev->ed_monitor = dev->ed_monitor_enabled &&
dev->region == NL80211_DFS_ETSI;
} }
static int static int
......
...@@ -103,8 +103,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) ...@@ -103,8 +103,7 @@ mt7603_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
mutex_unlock(&dev->mt76.mutex); mutex_unlock(&dev->mt76.mutex);
} }
static void void mt7603_init_edcca(struct mt7603_dev *dev)
mt7603_init_edcca(struct mt7603_dev *dev)
{ {
/* Set lower signal level to -65dBm */ /* Set lower signal level to -65dBm */
mt76_rmw_field(dev, MT_RXTD(8), MT_RXTD_8_LOWER_SIGNAL, 0x23); mt76_rmw_field(dev, MT_RXTD(8), MT_RXTD_8_LOWER_SIGNAL, 0x23);
......
...@@ -117,8 +117,11 @@ struct mt7603_dev { ...@@ -117,8 +117,11 @@ struct mt7603_dev {
u8 mac_work_count; u8 mac_work_count;
u8 mcu_running; u8 mcu_running;
u8 ed_monitor;
enum nl80211_dfs_regions region;
u8 ed_monitor_enabled;
u8 ed_monitor;
s8 ed_trigger; s8 ed_trigger;
u8 ed_strict_mode; u8 ed_strict_mode;
u8 ed_strong_signal; u8 ed_strong_signal;
...@@ -241,4 +244,5 @@ void mt7603_update_channel(struct mt76_dev *mdev); ...@@ -241,4 +244,5 @@ void mt7603_update_channel(struct mt76_dev *mdev);
void mt7603_edcca_set_strict(struct mt7603_dev *dev, bool val); void mt7603_edcca_set_strict(struct mt7603_dev *dev, bool val);
void mt7603_cca_stats_reset(struct mt7603_dev *dev); void mt7603_cca_stats_reset(struct mt7603_dev *dev);
void mt7603_init_edcca(struct mt7603_dev *dev);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment