diff mbox series

iw: add TID specific Tx bitrate configuration

Message ID 1597903916-8674-1-git-send-email-tamizhr@codeaurora.org (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series iw: add TID specific Tx bitrate configuration | expand

Commit Message

Tamizh chelvam Aug. 20, 2020, 6:11 a.m. UTC
Add TID specific Tx bitrate configuration by using
handle_bitrates already APIs.

Examples:
	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto
	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9

Signed-off-by: Tamizh Chelvam <tamizhr@codeaurora.org>
---
 bitrate.c   | 27 ++++++++++++++++++++-------
 interface.c | 34 +++++++++++++++++++++++++++++++++-
 iw.h        |  3 +++
 3 files changed, 56 insertions(+), 8 deletions(-)

Comments

Sergey Matyukevich Aug. 20, 2020, 7:49 a.m. UTC | #1
Hello Tamizh,

> Add TID specific Tx bitrate configuration by using
> handle_bitrates already APIs.
> 
> Examples:
> 	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto
> 	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9
> 
> Signed-off-by: Tamizh Chelvam <tamizhr@codeaurora.org>
> ---
>  bitrate.c   | 27 ++++++++++++++++++++-------
>  interface.c | 34 +++++++++++++++++++++++++++++++++-
>  iw.h        |  3 +++
>  3 files changed, 56 insertions(+), 8 deletions(-)

...

>  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|off]] [amsdu [on|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,
>  	"Setup per-node TID specific configuration for TIDs selected by bitmask.\n"
>  	"If MAC address is not specified, then supplied TID configuration\n"
> @@ -955,4 +985,6 @@ COMMAND(set, tidconf, "[peer <MAC address>] tids <mask> [override] [sretry <num>
>  	"  $ iw dev wlan0 tids 0x5 ampdu off amsdu off rtscts on\n"
>  	"  $ iw dev wlan0 tids 0x3 override ampdu on noack on rtscts on\n"
>  	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
> +	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
> +	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"

It just occured to me that I wrote incorrect help message in the patch
adding tidconf command. IIRC the correct usage should be: 

$ iw dev wlan0 set tidconf peer 1:2:3:4:5:6 tids 0x3 ampdu off tids 0x2 sretry 10 lretry 100
$ iw dev wlan0 set tidconf tids 0xff ampdu off amsdu off sretry 10 lretry 100 noack off

Could you please update new help entries and fix the existing ones ?


Regards,
Sergey
Tamizh chelvam Aug. 20, 2020, 10:02 a.m. UTC | #2
Hi Sergey,

> 
>> Add TID specific Tx bitrate configuration by using
>> handle_bitrates already APIs.
>> 
>> Examples:
>> 	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto
>> 	$ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit 
>> vht-mcs-5 4:9
>> 
>> Signed-off-by: Tamizh Chelvam <tamizhr@codeaurora.org>
>> ---
>>  bitrate.c   | 27 ++++++++++++++++++++-------
>>  interface.c | 34 +++++++++++++++++++++++++++++++++-
>>  iw.h        |  3 +++
>>  3 files changed, 56 insertions(+), 8 deletions(-)
> 
> ...
> 
>>  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|off]] [amsdu [on|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,
>>  	"Setup per-node TID specific configuration for TIDs selected by 
>> bitmask.\n"
>>  	"If MAC address is not specified, then supplied TID configuration\n"
>> @@ -955,4 +985,6 @@ COMMAND(set, tidconf, "[peer <MAC address>] tids 
>> <mask> [override] [sretry <num>
>>  	"  $ iw dev wlan0 tids 0x5 ampdu off amsdu off rtscts on\n"
>>  	"  $ iw dev wlan0 tids 0x3 override ampdu on noack on rtscts on\n"
>>  	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 
>> amsdu off rtscts on\n"
>> +	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
>> +	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit 
>> vht-mcs-5 4:9\n"
> 
> It just occured to me that I wrote incorrect help message in the patch
> adding tidconf command. IIRC the correct usage should be:
> 
> $ iw dev wlan0 set tidconf peer 1:2:3:4:5:6 tids 0x3 ampdu off tids
> 0x2 sretry 10 lretry 100
> $ iw dev wlan0 set tidconf tids 0xff ampdu off amsdu off sretry 10
> lretry 100 noack off
> 
> Could you please update new help entries and fix the existing ones ?
> 
Sure, will send as separate patch along with fixing new entries in this 
patch.


Tamizh.
Johannes Berg Aug. 27, 2020, 11:37 a.m. UTC | #3
On Thu, 2020-08-20 at 11:41 +0530, Tamizh Chelvam wrote:
> Add TID specific Tx bitrate configuration by using
> handle_bitrates already APIs.

In addition to what Sergey said, I get:

interface.c: In function ‘handle_tid_config’:
interface.c:944:11: warning: implicit conversion from ‘enum nl80211_tid_config_attr’ to ‘enum nl80211_attrs’ [-Wenum-conversion]
  944 |           NL80211_TID_CONFIG_ATTR_TX_RATE);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please address that too.

johannes
diff mbox series

Patch

diff --git a/bitrate.c b/bitrate.c
index 780017f..32a23a9 100644
--- a/bitrate.c
+++ b/bitrate.c
@@ -76,13 +76,12 @@  static int setup_vht(struct nl80211_txrate_vht *txrate_vht,
 
 #define VHT_ARGC_MAX	100
 
-static int handle_bitrates(struct nl80211_state *state,
-			   struct nl_msg *msg,
-			   int argc, char **argv,
-			   enum id_input id)
+int set_bitrates(struct nl_msg *msg,
+		 int argc, char **argv,
+		 enum nl80211_attrs attr)
 {
 	struct nlattr *nl_rates, *nl_band;
-	int i;
+	int i, ret = 0;
 	bool have_legacy_24 = false, have_legacy_5 = false;
 	uint8_t legacy_24[32], legacy_5[32];
 	int n_legacy_24 = 0, n_legacy_5 = 0;
@@ -195,10 +194,16 @@  static int handle_bitrates(struct nl80211_state *state,
 		case S_GI:
 			break;
 		default:
+			if (attr != NL80211_ATTR_TX_RATES)
+				goto next;
 			return 1;
 		}
 	}
 
+next:
+	if (attr != NL80211_ATTR_TX_RATES)
+		ret = i;
+
 	if (have_vht_mcs_24)
 		if (!setup_vht(&txrate_vht_24, vht_argc_24, vht_argv_24))
 			return -EINVAL;
@@ -213,7 +218,7 @@  static int handle_bitrates(struct nl80211_state *state,
 	if (sgi_24 && lgi_24)
 		return 1;
 
-	nl_rates = nla_nest_start(msg, NL80211_ATTR_TX_RATES);
+	nl_rates = nla_nest_start(msg, attr);
 	if (!nl_rates)
 		goto nla_put_failure;
 
@@ -253,11 +258,19 @@  static int handle_bitrates(struct nl80211_state *state,
 
 	nla_nest_end(msg, nl_rates);
 
-	return 0;
+	return ret;
  nla_put_failure:
 	return -ENOBUFS;
 }
 
+static int handle_bitrates(struct nl80211_state *state,
+			   struct nl_msg *msg,
+			   int argc, char **argv,
+			   enum id_input id)
+{
+	return set_bitrates(msg, argc, argv, NL80211_ATTR_TX_RATES);
+}
+
 #define DESCR_LEGACY "[legacy-<2.4|5> <legacy rate in Mbps>*]"
 #define DESCR DESCR_LEGACY " [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]"
 
diff --git a/interface.c b/interface.c
index df96bed..b55261f 100644
--- a/interface.c
+++ b/interface.c
@@ -757,6 +757,7 @@  static int handle_tid_config(struct nl80211_state *state,
 {
 	struct nlattr *tids_array = NULL;
 	struct nlattr *tids_entry = NULL;
+	enum nl80211_tx_rate_setting txrate_type;
 	unsigned char peer[ETH_ALEN];
 	int tids_num = 0;
 	char *end;
@@ -920,6 +921,33 @@  static int handle_tid_config(struct nl80211_state *state,
 
 				argc -= 2;
 				argv += 2;
+			} else if (strcmp(argv[0], "bitrates") == 0) {
+				if (argc < 2) {
+					fprintf(stderr, "not enough args for %s\n", argv[0]);
+					return HANDLER_RET_USAGE;
+				}
+				if (!strcmp(argv[1], "auto"))
+					txrate_type = NL80211_TX_RATE_AUTOMATIC;
+				else if (!strcmp(argv[1], "fixed"))
+					txrate_type = NL80211_TX_RATE_FIXED;
+				else if (!strcmp(argv[1], "limit"))
+					txrate_type = NL80211_TX_RATE_LIMITED;
+				else {
+					printf("Invalid parameter: %s\n", argv[0]);
+					return 2;
+				}
+				NLA_PUT_U8(msg, NL80211_TID_CONFIG_ATTR_TX_RATE_TYPE, txrate_type);
+				argc -= 2;
+				argv += 2;
+				if (txrate_type != NL80211_TX_RATE_AUTOMATIC) {
+					ret = set_bitrates(msg, argc, argv,
+							   NL80211_TID_CONFIG_ATTR_TX_RATE);
+					if (ret < 2)
+						return 1;
+
+					argc -= ret;
+					argv += ret;
+				}
 			} else {
 				fprintf(stderr, "Unknown parameter: %s\n", argv[0]);
 				return HANDLER_RET_USAGE;
@@ -945,7 +973,9 @@  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|off]] [amsdu [on|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,
 	"Setup per-node TID specific configuration for TIDs selected by bitmask.\n"
 	"If MAC address is not specified, then supplied TID configuration\n"
@@ -955,4 +985,6 @@  COMMAND(set, tidconf, "[peer <MAC address>] tids <mask> [override] [sretry <num>
 	"  $ iw dev wlan0 tids 0x5 ampdu off amsdu off rtscts on\n"
 	"  $ iw dev wlan0 tids 0x3 override ampdu on noack on rtscts on\n"
 	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on\n"
+	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
+	"  $ iw dev wlan0 peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
 	);
diff --git a/iw.h b/iw.h
index bc0b3ac..46bc9b5 100644
--- a/iw.h
+++ b/iw.h
@@ -245,4 +245,7 @@  void nan_bf(uint8_t idx, uint8_t *bf, uint16_t bf_len, const uint8_t *buf,
 
 char *hex2bin(const char *hex, char *buf);
 
+int set_bitrates(struct nl_msg *msg, int argc, char **argv,
+		 enum nl80211_attrs attr);
+
 #endif /* __IW_H */