diff mbox series

[1/2] iw: Add support to set per-radio RTS threshold in multi-radio wiphy

Message ID 20250204085000.3809769-2-quic_rdevanat@quicinc.com (mailing list archive)
State New
Delegated to: Johannes Berg
Headers show
Series iw: Add Support to Set per-radio attributes for each Radio | expand

Commit Message

Roopni Devanathan Feb. 4, 2025, 8:49 a.m. UTC
Currently, setting RTS threshold changes the threshold for all radios
in a wiphy. But different radios in a wiphy can have different RTS
threshold requirements. Add a new iw command to handle this. This will
ensure that the legacy userspace will interact with traditional drivers
as well as multi-radio wiphy drivers.

In order to be able to set RTS threshold for a particular radio from
user space, without disturbing the other radios in a wiphy, pass the
radio id for which RTS threshold needs to be changed and its
corresponding RTS threshold value. The valid radio id values can be
checked in iw phy#XXX info, under "Supported wiphy radios". If the radio
index is not provided, the current behavior of setting passed RTS
threshold to all radios will be retained.

Command Usage:
iw phyXXX [radio_id <radio index>] rts <RTS Threshold value>

Sample output:
root@buildroot:~# iw phyXXX info
Wiphy phy0
        wiphy index: 0
        max # scan SSIDs: 16
        max scan IEs length: 339 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        RTS threshold: 536
        Retry short limit: 7
        Retry long limit: 4
	.....
	Supported wiphy radios:
                * Idx 0:
                        RTS Threshold: 536
                        Frequency Range: 5170 MHz - 5835 MHz
			.....

                * Idx 1:
                        RTS Threshold: 231
                        Frequency Range: 2312 MHz - 2732 MHz
			.....

                * Idx 2:
                        RTS Threshold: 425
                        Frequency Range: 5945 MHz - 7125 MHz
			.....

	Globally valid interface combinations:
		.....

Signed-off-by: Roopni Devanathan <quic_rdevanat@quicinc.com>
---
 info.c |  4 ++++
 phy.c  | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
diff mbox series

Patch

diff --git a/info.c b/info.c
index 986eaa6..cde3d80 100644
--- a/info.c
+++ b/info.c
@@ -905,6 +905,10 @@  next:
 				case NL80211_WIPHY_RADIO_ATTR_INDEX:
 					printf("\t\t* Idx %u:\n", nla_get_u32(radio_prop));
 					break;
+				case NL80211_WIPHY_RADIO_ATTR_RTS_THRESHOLD:
+					printf("\t\t\tRTS Threshold: %d\n",
+					       nla_get_u32(radio_prop));
+					break;
 				case NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE:
 					printf("\t\t\tFrequency Range: ");
 
diff --git a/phy.c b/phy.c
index 584b103..890966d 100644
--- a/phy.c
+++ b/phy.c
@@ -475,6 +475,47 @@  COMMAND(set, rts, "<rts threshold|off>",
 	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
 	"Set rts threshold.");
 
+static int handle_wiphy_params(struct nl80211_state *state,
+			       struct nl_msg *msg,
+			       int argc, char **argv,
+			       enum id_input id)
+{
+	unsigned int rts = -1, radio_idx = NL80211_WIPHY_RADIO_ID_MAX;
+	int argidx = 0;
+	char *end;
+
+	if (argc < 2)
+		return 1;
+
+	if (!strcmp("radio", argv[argidx])) {
+		radio_idx = strtoul(argv[argidx + 1], &end, 10);
+		if (*end != '\0')
+			return 1;
+
+		argidx = argidx + 2;
+	}
+
+	NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RADIO_INDEX, radio_idx);
+
+	if (!strcmp("rts", argv[argidx]) && (strcmp("off", argv[argidx + 1])))
+		rts = strtoul(argv[argidx + 1], &end, 10);
+	else
+		rts = -1;
+
+	if (*end != '\0')
+		return 1;
+
+	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, rts);
+
+	return 0;
+nla_put_failure:
+	return 1;
+}
+
+COMMAND(set, wiphy, "[radio <idx>] rts <rts_threshold value>",
+	NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_wiphy_params,
+	"Set per-radio wiphy parameters");
+
 static int handle_retry(struct nl80211_state *state,
 			struct nl_msg *msg,
 			int argc, char **argv, enum id_input id)