]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: Add support to set per-radio RTS threshold in multi-radio wiphy
authorRoopni Devanathan <quic_rdevanat@quicinc.com>
Fri, 18 Jul 2025 10:26:59 +0000 (15:56 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 3 Sep 2025 07:45:59 +0000 (09:45 +0200)
Currently, setting RTS threshold changes the threshold for all radios in a
multi-radio wiphy. But different radios in a multi-radio wiphy can have
different RTS threshold requirements. Modify the iw command to get radio
index from user to operate on per-radio attributes in a multi-radio wiphy.
Modify the command such that the legacy userspace will still interact with
traditional drivers as well as multi-radio wiphy drivers. Also, print the
RTS threshold along with other per-radio attributes for each radio under
the section - "Supported wiphy radios" in iw phy#XXX info command.

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
index for which RTS threshold needs to be changed as optional pair of
arguments, along with its corresponding RTS threshold value. The valid
radio index values can be checked in iw phy#XXX info, under "Supported
wiphy radios". If radio index is not available, i.e., in case of single
radio wiphy, passing radio index is not required. If the radio index is not
provided, then the current behavior of setting passed RTS threshold to all
radios will be retained.

Command Usage:
iw phyX set rts <rts threshold|off> [radio <radio index>]

Sample output:
root@buildroot:~# iw phyXXX info
Wiphy phy0
        wiphy index: 0
        max # scan SSIDs: 16
        max scan IEs length: 339 bytes
        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>
Link: https://patch.msgid.link/20250718102659.111058-1-quic_rdevanat@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
info.c
phy.c

diff --git a/info.c b/info.c
index 986eaa66b3b7c26c83d3042da8272c26ced1067e..18dcd368d0f821fe894feed9922f4e623f67f127 100644 (file)
--- a/info.c
+++ b/info.c
@@ -926,6 +926,10 @@ next:
                                        if (!have_combinations)
                                                printf("\t\t\tRadio level interface combinations are not supported\n");
                                        break;
+                               case NL80211_WIPHY_RADIO_ATTR_RTS_THRESHOLD:
+                                       printf("\t\t\tRTS Threshold: %d\n",
+                                              nla_get_u32(radio_prop));
+                                       break;
                                default:
                                        printf("\t\t\t* <failed to parse>\n");
                                }
diff --git a/phy.c b/phy.c
index 584b103c6a155cefed05a8721b436765ae319305..03a782220b66a70bf458e61a6b4cc1f1f1ad84b9 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -449,15 +449,14 @@ static int handle_rts(struct nl80211_state *state,
                      enum id_input id)
 {
        unsigned int rts;
+       char *end;
 
-       if (argc != 1)
+       if (argc != 1 && argc != 3)
                return 1;
 
        if (strcmp("off", argv[0]) == 0)
                rts = -1;
        else {
-               char *end;
-
                if (!*argv[0])
                        return 1;
                rts = strtoul(argv[0], &end, 10);
@@ -467,11 +466,32 @@ static int handle_rts(struct nl80211_state *state,
 
        NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD, rts);
 
+       argv++;
+       argc--;
+
+       if (argc > 1 && strcmp("radio", argv[0]) == 0) {
+               int radio_idx;
+
+               argv++;
+               argc--;
+
+               radio_idx = strtoul(argv[0], &end, 10);
+               if (*end != '\0')
+                       return 1;
+
+               NLA_PUT_U8(msg, NL80211_ATTR_WIPHY_RADIO_INDEX, radio_idx);
+               argv++;
+               argc--;
+       }
+
+       if (argc)
+               return 1;
+
        return 0;
  nla_put_failure:
        return -ENOBUFS;
 }
-COMMAND(set, rts, "<rts threshold|off>",
+COMMAND(set, rts, "<rts threshold|off> [radio <radio index>]",
        NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_rts,
        "Set rts threshold.");