mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-22 03:42:41 +00:00
252 lines
7.6 KiB
Diff
252 lines
7.6 KiB
Diff
From adcfb902b10eb942f39b12c7d6d0e591ef227c3f Mon Sep 17 00:00:00 2001
|
|
From: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
|
|
Date: Mon, 11 Oct 2021 11:24:23 +0530
|
|
Subject: [PATCH] iw: Add aggregation count and management rtscts control
|
|
support
|
|
|
|
Add ampdu and amsdu count option for tid configuration and introduced
|
|
corresponding nl attribute for the same. Added peer level configuration
|
|
to enable/disable rtscts for management frames
|
|
|
|
commands:
|
|
iw dev wlanX set station <MAC address> mgmt_rts_cts <on|off>
|
|
iw dev wlanX set tidconf tids 0x3 override ampdu <on [num]|off> amsdu <on [num]|off>
|
|
Signed-off-by: Sowmiya Sree Elavalagan <quic_ssreeela@quicinc.com>
|
|
---
|
|
bitrate.c | 2 +-
|
|
interface.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
|
|
nl80211.h | 8 ++++++++
|
|
station.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
4 files changed, 112 insertions(+), 10 deletions(-)
|
|
|
|
--- a/bitrate.c
|
|
+++ b/bitrate.c
|
|
@@ -405,7 +405,7 @@ next:
|
|
if (!setup_he(&txrate_he_ul_5, he_ul_argc_5, he_ul_argv_5))
|
|
return -EINVAL;
|
|
|
|
- nl_rates = nla_nest_start(msg, attr);
|
|
+ nl_rates = nla_nest_start(msg, attr | NLA_F_NESTED);
|
|
if (!nl_rates)
|
|
goto nla_put_failure;
|
|
|
|
--- a/interface.c
|
|
+++ b/interface.c
|
|
@@ -891,6 +891,32 @@ COMMAND(set, tid_aggr_conf, "tid <tid> <
|
|
"Enable/disable aggregation for the TIDs ");
|
|
|
|
|
|
+static int get_param_value(const char *argv0, const char *argv1,
|
|
+ const char *argv2, struct nl_msg *msg,
|
|
+ uint32_t attr)
|
|
+{
|
|
+ char *end;
|
|
+ int val;
|
|
+
|
|
+ if (strcmp(argv1, "on") == 0) {
|
|
+
|
|
+ if (argv2) {
|
|
+ val = strtol(argv2, &end, 10);
|
|
+ if (*end)
|
|
+ return 0;
|
|
+
|
|
+ NLA_PUT_U16(msg, attr, val);
|
|
+ return 1;
|
|
+ }
|
|
+ return 0;
|
|
+ } else if (strcmp(argv1, "off") == 0) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+nla_put_failure:
|
|
+ return -ENOBUFS;
|
|
+}
|
|
+
|
|
static int toggle_tid_param(const char *argv0, const char *argv1,
|
|
struct nl_msg *msg, uint32_t attr)
|
|
{
|
|
@@ -967,7 +993,9 @@ static int handle_tid_config(struct nl80
|
|
}
|
|
|
|
if (!tids_array) {
|
|
- tids_array = nla_nest_start(msg, NL80211_ATTR_TID_CONFIG);
|
|
+ tids_array = nla_nest_start(msg,
|
|
+ NL80211_ATTR_TID_CONFIG |
|
|
+ NLA_F_NESTED);
|
|
if (!tids_array)
|
|
return -ENOBUFS;
|
|
}
|
|
@@ -977,7 +1005,7 @@ static int handle_tid_config(struct nl80
|
|
tids_num++;
|
|
}
|
|
|
|
- tids_entry = nla_nest_start(msg, tids_num);
|
|
+ tids_entry = nla_nest_start(msg, tids_num | NLA_F_NESTED);
|
|
if (!tids_entry)
|
|
return -ENOBUFS;
|
|
|
|
@@ -1015,8 +1043,16 @@ static int handle_tid_config(struct nl80
|
|
if (ret)
|
|
return ret;
|
|
|
|
- argc -= 2;
|
|
- argv += 2;
|
|
+ ret = get_param_value(argv[0], argv[1], argv[2], msg,
|
|
+ NL80211_TID_CONFIG_ATTR_AMPDU_COUNT);
|
|
+ if (ret) {
|
|
+ argc -= 3;
|
|
+ argv += 3;
|
|
+ } else {
|
|
+ argc -= 2;
|
|
+ argv += 2;
|
|
+ }
|
|
+
|
|
} else if (strcmp(argv[0], "amsdu") == 0) {
|
|
if (argc < 2) {
|
|
fprintf(stderr, "not enough args for %s\n", argv[0]);
|
|
@@ -1028,8 +1064,15 @@ static int handle_tid_config(struct nl80
|
|
if (ret)
|
|
return ret;
|
|
|
|
- argc -= 2;
|
|
- argv += 2;
|
|
+ ret = get_param_value(argv[0], argv[1], argv[2], msg,
|
|
+ NL80211_TID_CONFIG_ATTR_AMSDU_COUNT);
|
|
+ if (ret) {
|
|
+ argc -= 3;
|
|
+ argv += 3;
|
|
+ } else {
|
|
+ argc -= 2;
|
|
+ argv += 2;
|
|
+ }
|
|
} else if (strcmp(argv[0], "noack") == 0) {
|
|
if (argc < 2) {
|
|
fprintf(stderr, "not enough args for %s\n", argv[0]);
|
|
@@ -1137,7 +1180,7 @@ nla_put_failure:
|
|
}
|
|
|
|
COMMAND(set, tidconf, "[peer <MAC address>] tids <mask> [override] [sretry <num>] [lretry <num>] "
|
|
- "[ampdu [on|off]] [amsdu [on|off]] [noack [on|off]] [rtscts [on|off]]"
|
|
+ "[ampdu [on <num>|off]] [amsdu [on <num>|off]] [noack [on|off]] [rtscts [on|off]]"
|
|
"[bitrates <type [auto|fixed|limit]> [legacy-<2.4|5> <legacy rate in Mbps>*] [ht-mcs-<2.4|5> <MCS index>*]"
|
|
" [vht-mcs-<2.4|5> <NSS:MCSx,MCSy... | NSS:MCSx-MCSy>*] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5]]",
|
|
NL80211_CMD_SET_TID_CONFIG, 0, CIB_NETDEV, handle_tid_config,
|
|
@@ -1147,8 +1190,8 @@ COMMAND(set, tidconf, "[peer <MAC addres
|
|
"Examples:\n"
|
|
" $ iw dev wlan0 set tidconf tids 0x1 ampdu off\n"
|
|
" $ iw dev wlan0 set tidconf tids 0x5 ampdu off amsdu off rtscts on\n"
|
|
- " $ iw dev wlan0 set tidconf tids 0x3 override ampdu on noack on rtscts on\n"
|
|
+ " $ iw dev wlan0 set tidconf tids 0x3 override ampdu on [1-1024] noack on rtscts on\n"
|
|
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
|
|
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
|
|
- " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
|
|
+ " $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit legacy-5 ht-mcs-5 vht-mcs-5 he-mcs-5 2:3\n"
|
|
);
|
|
--- a/nl80211.h
|
|
+++ b/nl80211.h
|
|
@@ -3047,6 +3047,8 @@ enum nl80211_attrs {
|
|
|
|
NL80211_ATTR_WIPHY_ANTENNA_GAIN,
|
|
|
|
+ NL80211_ATTR_STA_MGMT_RTS_CTS_CONFIG,
|
|
+
|
|
/* add attributes here, update the policy in nl80211.c */
|
|
|
|
__NL80211_ATTR_AFTER_LAST,
|
|
@@ -4220,6 +4222,10 @@ enum nl80211_mesh_power_mode {
|
|
NL80211_MESH_POWER_MAX = __NL80211_MESH_POWER_AFTER_LAST - 1
|
|
};
|
|
|
|
+enum nl80211_mgmt_rts_cts_conf {
|
|
+ NL80211_MGMT_RTS_CTS_ENABLE,
|
|
+ NL80211_MGMT_RTS_CTS_DISABLE,
|
|
+};
|
|
/**
|
|
* enum nl80211_meshconf_params - mesh configuration parameters
|
|
*
|
|
@@ -5122,6 +5128,8 @@ enum nl80211_tid_config_attr {
|
|
NL80211_TID_CONFIG_ATTR_AMSDU_CTRL,
|
|
NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE,
|
|
NL80211_TID_CONFIG_ATTR_TX_RATE,
|
|
+ NL80211_TID_CONFIG_ATTR_AMPDU_COUNT,
|
|
+ NL80211_TID_CONFIG_ATTR_AMSDU_COUNT,
|
|
|
|
/* keep last */
|
|
__NL80211_TID_CONFIG_ATTR_AFTER_LAST,
|
|
--- a/station.c
|
|
+++ b/station.c
|
|
@@ -715,6 +715,7 @@ static const struct cmd *station_set_vla
|
|
static const struct cmd *station_set_mesh_power_mode;
|
|
static const struct cmd *station_set_airtime_weight;
|
|
static const struct cmd *station_set_txpwr;
|
|
+static const struct cmd *station_set_mgmt_rts_cts;
|
|
|
|
static const struct cmd *select_station_cmd(int argc, char **argv)
|
|
{
|
|
@@ -730,6 +731,8 @@ static const struct cmd *select_station_
|
|
return station_set_airtime_weight;
|
|
if (strcmp(argv[1], "txpwr") == 0)
|
|
return station_set_txpwr;
|
|
+ if (strcmp(argv[1], "mgmt_rts_cts") == 0)
|
|
+ return station_set_mgmt_rts_cts;
|
|
return NULL;
|
|
}
|
|
|
|
@@ -995,6 +998,56 @@ COMMAND_ALIAS(station, set, "<MAC addres
|
|
"Set Tx power for this station.",
|
|
select_station_cmd, station_set_txpwr);
|
|
|
|
+static int handle_station_set_mgmt_rts_cts(struct nl80211_state *state,
|
|
+ struct nl_msg *msg,
|
|
+ int argc, char **argv,
|
|
+ enum id_input id)
|
|
+{
|
|
+ unsigned char rts_cts_conf;
|
|
+ unsigned char mac_addr[ETH_ALEN];
|
|
+
|
|
+ if (argc != 3)
|
|
+ return 1;
|
|
+
|
|
+ if (mac_addr_a2n(mac_addr, argv[0])) {
|
|
+ fprintf(stderr, "invalid mac address\n");
|
|
+ return 2;
|
|
+ }
|
|
+ argc--;
|
|
+ argv++;
|
|
+
|
|
+ if (strcmp("mgmt_rts_cts", argv[0]) != 0)
|
|
+ return 1;
|
|
+ argc--;
|
|
+ argv++;
|
|
+
|
|
+ if (strcmp("on", argv[0]) == 0)
|
|
+ rts_cts_conf = NL80211_MGMT_RTS_CTS_ENABLE;
|
|
+ else if (strcmp("off", argv[0]) == 0)
|
|
+ rts_cts_conf = NL80211_MGMT_RTS_CTS_DISABLE;
|
|
+ else {
|
|
+ fprintf(stderr, "unknown mgmt rts cts conf\n");
|
|
+ return 2;
|
|
+ }
|
|
+ argc--;
|
|
+ argv++;
|
|
+
|
|
+ if (argc)
|
|
+ return 1;
|
|
+
|
|
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
|
|
+ NLA_PUT_U8(msg, NL80211_ATTR_STA_MGMT_RTS_CTS_CONFIG, rts_cts_conf);
|
|
+
|
|
+ return 0;
|
|
+nla_put_failure:
|
|
+ return -ENOBUFS;
|
|
+}
|
|
+
|
|
+COMMAND_ALIAS(station, set, "<MAC address> mgmt_rts_cts <on|off>",
|
|
+ NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_mgmt_rts_cts,
|
|
+ "Enable/Disable rts/cts for management frames",
|
|
+ select_station_cmd, station_set_mgmt_rts_cts);
|
|
+
|
|
static int handle_station_dump(struct nl80211_state *state,
|
|
struct nl_msg *msg,
|
|
int argc, char **argv,
|