From patchwork Wed Feb 8 12:01:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Raj Nagarajan X-Patchwork-Id: 9562419 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5F87660434 for ; Wed, 8 Feb 2017 12:07:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D9752849E for ; Wed, 8 Feb 2017 12:07:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4004A284D2; Wed, 8 Feb 2017 12:07:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C55062849E for ; Wed, 8 Feb 2017 12:07:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cbR1f-000593-Ph; Wed, 08 Feb 2017 12:07:07 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cbR1c-00055M-Az for ath10k@lists.infradead.org; Wed, 08 Feb 2017 12:07:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=qti.qualcomm.com; i=@qti.qualcomm.com; q=dns/txt; s=qcdkim; t=1486555624; x=1518091624; h=from:to:cc:subject:date:message-id:mime-version; bh=3k97QToKDLj8K8kk9IvMwoHbiO2ThTjHJqoEuqwfUYo=; b=xaQAa0Ikq3dN0tSGu/KLxf/Q2z5BiH1mccqDZbglSK4imy2MAhrXS5Ql 4bWQWk7tw1t6gLrmF2M/Zy8Fx/O9ksAXkK01LzGwrknlTZSgIdweNGjEv xCg4hwxGZ/D8+53kvdW3p7rUD+ZxGEdQwHa5B1HnxHofTvd3AMC6HvgDx s=; X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="261165508" Received: from unknown (HELO Ironmsg03-L.qualcomm.com) ([10.53.140.110]) by wolverine01.qualcomm.com with ESMTP; 08 Feb 2017 04:06:35 -0800 X-IronPort-AV: E=McAfee;i="5800,7501,8432"; a="1309627056" Received: from nasanexm02a.na.qualcomm.com ([10.85.0.41]) by Ironmsg03-L.qualcomm.com with ESMTP/TLS/RC4-SHA; 08 Feb 2017 04:06:35 -0800 Received: from aphydexm01f.ap.qualcomm.com (10.252.127.15) by nasanexm02a.na.qualcomm.com (10.85.0.41) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 8 Feb 2017 04:06:33 -0800 Received: from qcmail1.qualcomm.com (10.80.80.8) by aphydexm01f.ap.qualcomm.com (10.252.127.15) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 8 Feb 2017 17:36:25 +0530 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Wed, 08 Feb 2017 17:31:19 +0530 From: Ashok Raj Nagarajan To: Subject: [PATCH v3] iw: Add support for controlling tx power for per station Date: Wed, 8 Feb 2017 17:31:17 +0530 Message-ID: <1486555277-25258-1-git-send-email-arnagara@qti.qualcomm.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanexm01a.na.qualcomm.com (10.85.0.81) To aphydexm01f.ap.qualcomm.com (10.252.127.15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170208_040704_511403_BAC136E8 X-CRM114-Status: GOOD ( 10.10 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ashok Raj Nagarajan , arnagara@codeaurora.org, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 txpwr limit 2000 To revert the user defined tx power for a station: iw wlan0 station set txpwr auto Signed-off-by: Ashok Raj Nagarajan --- v3: - rebased 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, " [subtype ] [reason-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, " 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, " txpwr []", + 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,