From: Amith A <amith.a@oss.qualcomm.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, amith.a@oss.qualcomm.com,
Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Subject: [PATCH wireless-next v5 2/2] wifi: mac80211_hwsim: add incumbent signal interference detection support
Date: Mon, 16 Feb 2026 08:50:27 +0530 [thread overview]
Message-ID: <20260216032027.2310956-3-amith.a@oss.qualcomm.com> (raw)
In-Reply-To: <20260216032027.2310956-1-amith.a@oss.qualcomm.com>
From: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Add a debugfs ‘simulate_incumbent_signal_interference’ with custom
file_operations and a .write that accepts “<freq_mhz> <bitmap>”. The
handler selects the 6 GHz chanctx whose primary 20 MHz center matches
<freq_mhz> and reports the event via cfg80211_incumbent_signal_notify().
The bitmap marks affected 20 MHz segments within the current chandef
(lowest bit = lowest segment)
Signed-off-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com>
Signed-off-by: Amith A <amith.a@oss.qualcomm.com>
---
drivers/net/wireless/virtual/mac80211_hwsim.c | 80 +++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 4d9f5f87e814..2a61997e8312 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -36,6 +36,9 @@
#include <linux/virtio.h>
#include <linux/virtio_ids.h>
#include <linux/virtio_config.h>
+#include <linux/uaccess.h>
+#include <linux/kstrtox.h>
+#include <linux/string.h>
#include "mac80211_hwsim.h"
#define WARN_QUEUE 100
@@ -1164,6 +1167,80 @@ static int hwsim_write_simulate_radar(void *dat, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(hwsim_simulate_radar, NULL,
hwsim_write_simulate_radar, "%llu\n");
+struct hwsim_chanctx_iter_arg {
+ struct ieee80211_chanctx_conf **out;
+ u32 freq_mhz;
+};
+
+static void hwsim_6ghz_chanctx_iter(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *conf,
+ void *data)
+{
+ struct hwsim_chanctx_iter_arg *arg = data;
+
+ if (conf->def.chan &&
+ conf->def.chan->band == NL80211_BAND_6GHZ &&
+ conf->def.chan->center_freq == arg->freq_mhz)
+ *arg->out = conf;
+}
+
+static ssize_t hwsim_simulate_incumbent_signal_write(struct file *file,
+ const char __user *ubuf,
+ size_t len, loff_t *ppos)
+{
+ struct mac80211_hwsim_data *data = file->private_data;
+ struct ieee80211_chanctx_conf *chanctx_conf = NULL;
+ struct hwsim_chanctx_iter_arg arg;
+ u32 freq_mhz, bitmap;
+ char *sptr, *token;
+ char buf[64];
+
+ if (!len || len >= sizeof(buf))
+ return -EINVAL;
+
+ if (copy_from_user(buf, ubuf, len))
+ return -EFAULT;
+ buf[len] = '\0';
+
+ strim(buf);
+ sptr = buf;
+ token = strsep(&sptr, " \t");
+ if (!token)
+ return -EINVAL;
+ if (kstrtou32(token, 0, &freq_mhz))
+ return -EINVAL;
+
+ token = strsep(&sptr, " \t");
+ if (!token)
+ return -EINVAL;
+ if (kstrtou32(token, 0, &bitmap))
+ return -EINVAL;
+
+ if (!freq_mhz)
+ return -EINVAL;
+
+ arg.out = &chanctx_conf;
+ arg.freq_mhz = freq_mhz;
+ ieee80211_iter_chan_contexts_atomic(data->hw,
+ hwsim_6ghz_chanctx_iter,
+ &arg);
+
+ if (!chanctx_conf)
+ return -EINVAL;
+
+ cfg80211_incumbent_signal_notify(data->hw->wiphy,
+ &chanctx_conf->def,
+ bitmap,
+ GFP_KERNEL);
+
+ return len;
+}
+
+static const struct file_operations hwsim_simulate_incumbent_signal_fops = {
+ .open = simple_open,
+ .write = hwsim_simulate_incumbent_signal_write,
+};
+
static int hwsim_fops_group_read(void *dat, u64 *val)
{
struct mac80211_hwsim_data *data = dat;
@@ -5832,6 +5909,9 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
debugfs_create_file("dfs_simulate_radar", 0222,
data->debugfs,
data, &hwsim_simulate_radar);
+ debugfs_create_file("simulate_incumbent_signal_interference", 0200,
+ data->debugfs,
+ data, &hwsim_simulate_incumbent_signal_fops);
if (param->pmsr_capa) {
data->pmsr_capa = *param->pmsr_capa;
--
2.34.1
next prev parent reply other threads:[~2026-02-16 3:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 3:20 [PATCH wireless-next v5 0/2] wifi: cfg80211/mac80211: add support to handle incumbent signal detected event Amith A
2026-02-16 3:20 ` [PATCH wireless-next v5 1/2] wifi: cfg80211: add support to handle incumbent signal detected event from mac80211/driver Amith A
2026-02-16 3:20 ` Amith A [this message]
2026-03-02 8:22 ` [PATCH wireless-next v5 2/2] wifi: mac80211_hwsim: add incumbent signal interference detection support Johannes Berg
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=20260216032027.2310956-3-amith.a@oss.qualcomm.com \
--to=amith.a@oss.qualcomm.com \
--cc=aditya.kumar.singh@oss.qualcomm.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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