* [PATCH] iw: Add support for controlling tx power for per station
@ 2019-01-17 13:29 Balaji Pothunoori
2019-01-25 12:35 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Balaji Pothunoori @ 2019-01-17 13:29 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, Ashok Raj Nagarajan, Balaji Pothunoori
From: Ashok Raj Nagarajan <arnagara@codeaurora.org>
This patch allows userspace to set transmit power,
in mBm units, to a station associated to the AP.
To set a limit tx power of 2000 mBm:
iw wlan0 station set <mac-addr> txpwr limit 2000
To revert the user defined tx power for a station:
iw wlan0 station set <mac-addr> txpwr auto
iCo-developed-by: Balaji Pothunoori <bpothuno@codeaurora.org>
Signed-off-by: Ashok Raj Nagarajan <arnagara@codeaurora.org>
Signed-off-by: Balaji Pothunoori <bpothuno@codeaurora.org>
---
station.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/station.c b/station.c
index e1477ef..3cce617 100644
--- a/station.c
+++ b/station.c
@@ -651,6 +651,7 @@ COMMAND(station, del, "<MAC address> [subtype <subtype>] [reason-code <code>]",
static const struct cmd *station_set_plink;
static const struct cmd *station_set_vlan;
static const struct cmd *station_set_mesh_power_mode;
+static const struct cmd *station_set_txpwr;
static const struct cmd *select_station_cmd(int argc, char **argv)
{
@@ -662,6 +663,8 @@ static const struct cmd *select_station_cmd(int argc, char **argv)
return station_set_vlan;
if (strcmp(argv[1], "mesh_power_mode") == 0)
return station_set_mesh_power_mode;
+ if (strcmp(argv[1], "txpwr") == 0)
+ return station_set_txpwr;
return NULL;
}
@@ -813,6 +816,74 @@ COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
"Set link-specific mesh power mode for this station",
select_station_cmd, station_set_mesh_power_mode);
+static int handle_station_set_txpwr(struct nl80211_state *state,
+ struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ enum nl80211_tx_power_setting type;
+ unsigned char mac_addr[ETH_ALEN];
+ unsigned int sta_txpwr = 0;
+ char *err = NULL;
+
+ if (argc != 3 && argc != 4)
+ return 1;
+
+ if (mac_addr_a2n(mac_addr, argv[0])) {
+ fprintf(stderr, "invalid mac address\n");
+ return 2;
+ }
+
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+ argc--;
+ argv++;
+
+ if (strcmp("txpwr", argv[0]) != 0)
+ return 1;
+ argc--;
+ argv++;
+
+ if (!strcmp(argv[0], "auto"))
+ type = NL80211_TX_POWER_AUTOMATIC;
+ else if (!strcmp(argv[0], "limit"))
+ type = NL80211_TX_POWER_LIMITED;
+ else {
+ printf("Invalid parameter: %s\n", argv[0]);
+ return 2;
+ }
+
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER_SETTING, type);
+
+ if (type != NL80211_TX_POWER_AUTOMATIC) {
+ if (argc != 2) {
+ printf("Missing TX power level argument.\n");
+ return 2;
+ }
+
+ argc--;
+ argv++;
+
+ sta_txpwr = strtoul(argv[0], &err, 0);
+
+ if (sta_txpwr)
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER, sta_txpwr);
+ }
+
+ argc--;
+ argv++;
+
+ if (argc)
+ return 1;
+
+ return 0;
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND_ALIAS(station, set, "<MAC address> txpwr <auto|limit> [<tx power mBm>]",
+ NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_txpwr,
+ "Set Tx power for this station.",
+ select_station_cmd, station_set_txpwr);
+
static int handle_station_dump(struct nl80211_state *state,
struct nl_msg *msg,
int argc, char **argv,
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] iw: Add support for controlling tx power for per station
2019-01-17 13:29 [PATCH] iw: Add support for controlling tx power for per station Balaji Pothunoori
@ 2019-01-25 12:35 ` Johannes Berg
2019-01-29 12:25 ` Balaji Pothunoori
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2019-01-25 12:35 UTC (permalink / raw)
To: Balaji Pothunoori; +Cc: linux-wireless, Ashok Raj Nagarajan
On Thu, 2019-01-17 at 18:59 +0530, Balaji Pothunoori wrote:
> From: Ashok Raj Nagarajan <arnagara@codeaurora.org>
>
> This patch allows userspace to set transmit power,
> in mBm units, to a station associated to the AP.
>
> To set a limit tx power of 2000 mBm:
> iw wlan0 station set <mac-addr> txpwr limit 2000
I would prefer if this was *dBm*, rather than mBm, and be allowed to
take float values, i.e. this would become "limit 20".
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iw: Add support for controlling tx power for per station
2019-01-25 12:35 ` Johannes Berg
@ 2019-01-29 12:25 ` Balaji Pothunoori
2019-01-29 12:26 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: Balaji Pothunoori @ 2019-01-29 12:25 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, Ashok Raj Nagarajan
On 2019-01-25 18:05, Johannes Berg wrote:
> On Thu, 2019-01-17 at 18:59 +0530, Balaji Pothunoori wrote:
>> From: Ashok Raj Nagarajan <arnagara@codeaurora.org>
>>
>> This patch allows userspace to set transmit power,
>> in mBm units, to a station associated to the AP.
>>
>> To set a limit tx power of 2000 mBm:
>> iw wlan0 station set <mac-addr> txpwr limit 2000
>
> I would prefer if this was *dBm*, rather than mBm, and be allowed to
> take float values, i.e. this would become "limit 20".
>
> johannes
Johannes,
Curiously asking, existing txpower set for vap/phy interface will in mBm
from user space.
why would you suggesting dBm for per peer txpower set?
Existing designs :
root@OpenWrt:~# iw | grep power
dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]
phy <phyname> set txpower <auto|fixed|limit> [<tx power in mBm>]
Regards,
Balaji.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] iw: Add support for controlling tx power for per station
2019-01-29 12:25 ` Balaji Pothunoori
@ 2019-01-29 12:26 ` Johannes Berg
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2019-01-29 12:26 UTC (permalink / raw)
To: Balaji Pothunoori; +Cc: linux-wireless, Ashok Raj Nagarajan
On Tue, 2019-01-29 at 17:55 +0530, Balaji Pothunoori wrote:
>
> Curiously asking, existing txpower set for vap/phy interface will in mBm
> from user space.
> why would you suggesting dBm for per peer txpower set?
Yeah :-(
I basically think it's a mistake. I don't know if we can fix it now
though.
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] iw: Add support for controlling tx power for per station
@ 2016-06-14 17:46 ` Ashok Raj Nagarajan
0 siblings, 0 replies; 6+ messages in thread
From: Ashok Raj Nagarajan @ 2016-06-14 17:46 UTC (permalink / raw)
To: johannes; +Cc: ath10k, linux-wireless, arnagara, Ashok Raj Nagarajan
This patch allows userspace to set transmit power, in mBm units, to a
station associated to the AP.
To set a limit tx power of 2000 mBm:
iw wlan0 station set <mac-addr> txpwr limit 2000
To revert the user defined tx power for a station:
iw wlan0 station set <mac-addr> txpwr auto
Signed-off-by: Ashok Raj Nagarajan <arnagara@qti.qualcomm.com>
---
station.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/station.c b/station.c
index f3e3da8..8364593 100644
--- a/station.c
+++ b/station.c
@@ -569,6 +569,7 @@ COMMAND(station, del, "<MAC address> [subtype <subtype>] [reason-code <code>]",
static const struct cmd *station_set_plink;
static const struct cmd *station_set_vlan;
static const struct cmd *station_set_mesh_power_mode;
+static const struct cmd *station_set_txpwr;
static const struct cmd *select_station_cmd(int argc, char **argv)
{
@@ -580,6 +581,8 @@ static const struct cmd *select_station_cmd(int argc, char **argv)
return station_set_vlan;
if (strcmp(argv[1], "mesh_power_mode") == 0)
return station_set_mesh_power_mode;
+ if (strcmp(argv[1], "txpwr") == 0)
+ return station_set_txpwr;
return NULL;
}
@@ -731,6 +734,72 @@ COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
"Set link-specific mesh power mode for this station",
select_station_cmd, station_set_mesh_power_mode);
+static int handle_station_set_txpwr(struct nl80211_state *state,
+ struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ enum nl80211_tx_power_setting type;
+ unsigned char mac_addr[ETH_ALEN];
+ unsigned int sta_txpwr = 0;
+ char *err = NULL;
+
+ if (argc != 3 && argc != 4)
+ return 1;
+
+ if (mac_addr_a2n(mac_addr, argv[0])) {
+ fprintf(stderr, "invalid mac address\n");
+ return 2;
+ }
+
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+ argc--;
+ argv++;
+
+ if (strcmp("txpwr", argv[0]) != 0)
+ return 1;
+ argc--;
+ argv++;
+
+ if (!strcmp(argv[0], "auto"))
+ type = NL80211_TX_POWER_AUTOMATIC;
+ else if (!strcmp(argv[0], "limit"))
+ type = NL80211_TX_POWER_LIMITED;
+ else {
+ printf("Invalid parameter: %s\n", argv[0]);
+ return 2;
+ }
+
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER_SETTING, type);
+
+ if (type != NL80211_TX_POWER_AUTOMATIC) {
+ if (argc != 2) {
+ printf("Missing TX power level argument.\n");
+ return 2;
+ }
+
+ argc--;
+ argv++;
+
+ sta_txpwr = strtoul(argv[0], &err, 0);
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER, sta_txpwr);
+ }
+
+ argc--;
+ argv++;
+
+ if (argc)
+ return 1;
+
+ return 0;
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND_ALIAS(station, set, "<MAC address> txpwr <auto|limit> [<tx power mBm>]",
+ NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_txpwr,
+ "Set Tx power for this station.",
+ select_station_cmd, station_set_txpwr);
+
static int handle_station_dump(struct nl80211_state *state,
struct nl_msg *msg,
int argc, char **argv,
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] iw: Add support for controlling tx power for per station
@ 2016-06-14 17:46 ` Ashok Raj Nagarajan
0 siblings, 0 replies; 6+ messages in thread
From: Ashok Raj Nagarajan @ 2016-06-14 17:46 UTC (permalink / raw)
To: johannes; +Cc: Ashok Raj Nagarajan, arnagara, linux-wireless, ath10k
This patch allows userspace to set transmit power, in mBm units, to a
station associated to the AP.
To set a limit tx power of 2000 mBm:
iw wlan0 station set <mac-addr> txpwr limit 2000
To revert the user defined tx power for a station:
iw wlan0 station set <mac-addr> txpwr auto
Signed-off-by: Ashok Raj Nagarajan <arnagara@qti.qualcomm.com>
---
station.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/station.c b/station.c
index f3e3da8..8364593 100644
--- a/station.c
+++ b/station.c
@@ -569,6 +569,7 @@ COMMAND(station, del, "<MAC address> [subtype <subtype>] [reason-code <code>]",
static const struct cmd *station_set_plink;
static const struct cmd *station_set_vlan;
static const struct cmd *station_set_mesh_power_mode;
+static const struct cmd *station_set_txpwr;
static const struct cmd *select_station_cmd(int argc, char **argv)
{
@@ -580,6 +581,8 @@ static const struct cmd *select_station_cmd(int argc, char **argv)
return station_set_vlan;
if (strcmp(argv[1], "mesh_power_mode") == 0)
return station_set_mesh_power_mode;
+ if (strcmp(argv[1], "txpwr") == 0)
+ return station_set_txpwr;
return NULL;
}
@@ -731,6 +734,72 @@ COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
"Set link-specific mesh power mode for this station",
select_station_cmd, station_set_mesh_power_mode);
+static int handle_station_set_txpwr(struct nl80211_state *state,
+ struct nl_msg *msg,
+ int argc, char **argv,
+ enum id_input id)
+{
+ enum nl80211_tx_power_setting type;
+ unsigned char mac_addr[ETH_ALEN];
+ unsigned int sta_txpwr = 0;
+ char *err = NULL;
+
+ if (argc != 3 && argc != 4)
+ return 1;
+
+ if (mac_addr_a2n(mac_addr, argv[0])) {
+ fprintf(stderr, "invalid mac address\n");
+ return 2;
+ }
+
+ NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr);
+ argc--;
+ argv++;
+
+ if (strcmp("txpwr", argv[0]) != 0)
+ return 1;
+ argc--;
+ argv++;
+
+ if (!strcmp(argv[0], "auto"))
+ type = NL80211_TX_POWER_AUTOMATIC;
+ else if (!strcmp(argv[0], "limit"))
+ type = NL80211_TX_POWER_LIMITED;
+ else {
+ printf("Invalid parameter: %s\n", argv[0]);
+ return 2;
+ }
+
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER_SETTING, type);
+
+ if (type != NL80211_TX_POWER_AUTOMATIC) {
+ if (argc != 2) {
+ printf("Missing TX power level argument.\n");
+ return 2;
+ }
+
+ argc--;
+ argv++;
+
+ sta_txpwr = strtoul(argv[0], &err, 0);
+ NLA_PUT_U32(msg, NL80211_ATTR_STA_TX_POWER, sta_txpwr);
+ }
+
+ argc--;
+ argv++;
+
+ if (argc)
+ return 1;
+
+ return 0;
+ nla_put_failure:
+ return -ENOBUFS;
+}
+COMMAND_ALIAS(station, set, "<MAC address> txpwr <auto|limit> [<tx power mBm>]",
+ NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_txpwr,
+ "Set Tx power for this station.",
+ select_station_cmd, station_set_txpwr);
+
static int handle_station_dump(struct nl80211_state *state,
struct nl_msg *msg,
int argc, char **argv,
--
1.9.1
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-29 12:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 13:29 [PATCH] iw: Add support for controlling tx power for per station Balaji Pothunoori
2019-01-25 12:35 ` Johannes Berg
2019-01-29 12:25 ` Balaji Pothunoori
2019-01-29 12:26 ` Johannes Berg
-- strict thread matches above, loose matches on Subject: below --
2016-06-14 17:46 Ashok Raj Nagarajan
2016-06-14 17:46 ` Ashok Raj Nagarajan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.