wlan-ap-Telecominfraproject/feeds/ipq95xx/iw/patches/611-iw-add-support-to-add-del-multi-chan-support-for-mon.patch
John Crispin 460050a114 ipq50xx: add CIF WF-198 support
Signed-off-by: John Crispin <john@phrozen.org>
2024-02-28 18:56:21 +01:00

198 lines
6.0 KiB
Diff

From 98e3c7c11e335d9f63bdf7377ba2ebfa6cc251b0 Mon Sep 17 00:00:00 2001
From: Karthikeyan Kathirvel <quic_kathirve@quicinc.com>
Date: Mon, 20 Mar 2023 14:00:30 +0530
Subject: [PATCH] iw: add support to add/del multi chan support for monitor
The below command helps to add multiple channels to monitor interface
iw dev mon0 add channel 11
iw dev mon0 add channel 36
iw dev mon0 add channel 49 6G
Similarly channel can be deleted from the monitor interface
iw dev mon0 del channel 36
The same is done for set freq command and added add freq and del freq
Signed-off-by: Karthikeyan Kathirvel <quic_kathirve@quicinc.com>
---
iw.h | 1 +
nl80211.h | 16 +++++++++
phy.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 119 insertions(+), 2 deletions(-)
diff --git a/iw.h b/iw.h
index d01b85b70df8..972df0c32fc8 100644
--- a/iw.h
+++ b/iw.h
@@ -324,6 +324,7 @@ DECLARE_SECTION(reg);
DECLARE_SECTION(roc);
DECLARE_SECTION(scan);
DECLARE_SECTION(set);
+DECLARE_SECTION(add);
DECLARE_SECTION(station);
DECLARE_SECTION(survey);
DECLARE_SECTION(switch);
diff --git a/nl80211.h b/nl80211.h
index 2d9a3d65afe8..f336ff4139dc 100644
--- a/nl80211.h
+++ b/nl80211.h
@@ -2683,6 +2683,16 @@ enum nl80211_commands {
* the operating channel as per device capability, policy and regulatory
* authority in signed mBm units.
*
+ * @NL80211_ATTR_RADAR_BITMAP: (u16) RADAR bitmap where the lowest bit
+ * corresponds to the lowest 20MHZ channel. Each bit set to 1
+ * indicates that radar is detected in that sub-channel.
+ *
+ * @NL80211_ATTR_ADD_MULTI_CHAN: Add channel to the radio, this is used
+ * for monitor interface (u32).
+ *
+ * @NL80211_ATTR_DEL_MULTI_CHAN: Delete channel from the radio, this is used
+ * for monitor interface (u32).
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3237,6 +3247,12 @@ enum nl80211_attrs {
NL80211_ATTR_MULTI_HW_MACS,
+ NL80211_ATTR_RADAR_BITMAP,
+
+ NL80211_ATTR_EHT_240MHZ_CAPABILITY,
+
+ NL80211_ATTR_ADD_MULTI_CHAN,
+ NL80211_ATTR_DEL_MULTI_CHAN,
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/phy.c b/phy.c
index e935c27af2ee..23cd45318dbd 100644
--- a/phy.c
+++ b/phy.c
@@ -15,6 +15,8 @@
#include "nl80211.h"
#include "iw.h"
+SECTION(add);
+
struct channels_ctx {
int last_band;
bool width_40;
@@ -209,6 +211,59 @@ COMMAND(set, freq,
"<control freq> [5|10|20|40|80|80+80|160|320] [<center1_freq> [<center2_freq>]] [ru-puncturing-bitmap <bitmap>]",
NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq, NULL);
+static int handle_add_freq(struct nl80211_state *state, struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ struct chandef chandef;
+ int res;
+
+ res = parse_freqchan(&chandef, false, argc, argv, NULL);
+ if (res)
+ return res;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_ADD_MULTI_CHAN, true);
+
+ return put_chandef(msg, &chandef);
+ nla_put_failure:
+ return -ENOBUFS;
+}
+
+COMMAND(add, freq,
+ "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]\n"
+ "<control freq> [5|10|20|40|80|80+80|160|320] [<center1_freq> [<center2_freq>]]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_add_freq,
+ "Set frequency/channel the hardware is using, including HT\n"
+ "configuration.");
+COMMAND(add, freq,
+ "<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]\n"
+ "<control freq> [5|10|20|40|80|80+80|160|320] [<center1_freq> [<center2_freq>]]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_add_freq, NULL);
+
+static int handle_del_freq(struct nl80211_state *state, struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ struct chandef chandef;
+ int res;
+
+ res = parse_freqchan(&chandef, false, argc, argv, NULL);
+ if (res)
+ return res;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_DEL_MULTI_CHAN, true);
+
+ return put_chandef(msg, &chandef);
+ nla_put_failure:
+ return -ENOBUFS;
+}
+
+COMMAND(del, freq, "<freq>\n",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_del_freq,
+ "del frequency/channel the hardware is using\n");
+COMMAND(del, freq, "<freq>\n",
+ NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_del_freq, NULL);
+
static int handle_chan(struct nl80211_state *state, struct nl_msg *msg,
int argc, char **argv,
enum id_input id)
@@ -227,6 +282,52 @@ COMMAND(set, channel, "<channel> [6G] [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|16
COMMAND(set, channel, "<channel> [6G] [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz] [6G] [ru-puncturing-bitmap <bitmap>]",
NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_chan, NULL);
+static int handle_add_chan(struct nl80211_state *state, struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ struct chandef chandef;
+ int res;
+
+ res = parse_freqchan(&chandef, true, argc, argv, NULL);
+ if (res)
+ return res;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_ADD_MULTI_CHAN, true);
+
+ return put_chandef(msg, &chandef);
+
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND(add, channel, "<channel> [6G] [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_add_chan, NULL);
+COMMAND(add, channel, "<channel> [6G] [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz|160MHz|320MHz] [6G]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_add_chan, NULL);
+
+static int handle_del_chan(struct nl80211_state *state, struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ struct chandef chandef;
+ int res;
+
+ res = parse_freqchan(&chandef, true, argc, argv, NULL);
+ if (res)
+ return res;
+
+ NLA_PUT_U32(msg, NL80211_ATTR_DEL_MULTI_CHAN, true);
+
+ return put_chandef(msg, &chandef);
+
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND(del, channel, "<channel> [6G]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_del_chan, NULL);
+COMMAND(del, channel, "<channel> [6G]",
+ NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_del_chan, NULL);
+
struct cac_event {
int ret;
--
2.38.0