From patchwork Fri Mar 29 11:23:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balaji Pothunoori X-Patchwork-Id: 10876903 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15DB215AC for ; Fri, 29 Mar 2019 11:23:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF95C28AC0 for ; Fri, 29 Mar 2019 11:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1E5B28EC1; Fri, 29 Mar 2019 11:23:28 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 86B8C28AC0 for ; Fri, 29 Mar 2019 11:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=cMD4uvpE+vqHKcG819bU3d8FWxkcR2k3oueKzaniwGc=; b=k6M 2xjbG/fwFecrkVjqsxAZ6s+2YUzPrngK4HHU7x0tJmARkkwogwC9/FmAfln4ESUEIhlixkMcVH69I 9KcuHTiv7NA3NQqkvMg2VvMBZpRkS97iZbP+VppKO5ogDY7Pg0gXwExqjK7zlILprJcvw9uxUP8DX HNZDN8fRuqh+xTpcz1rEl0l45iayeRAHVCD8ofW+vlQ7lPdXfkZtBnz5pIuFZUIaSuyNmWXWYZH2f vNFl+yDHctw9V7gq2xdjlC1Nh/0D08Omaxbu/l6We6LaZj+tt3wme+n7PIX9DkPGk1pcUSD7caqta KNi85FpdBSjz5N++v+/890MEGGN6e+w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9pba-0002la-D0; Fri, 29 Mar 2019 11:23:26 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9pbX-0002jl-6d for ath10k@lists.infradead.org; Fri, 29 Mar 2019 11:23:25 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D21246079C; Fri, 29 Mar 2019 11:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553858602; bh=zUrrSWfxaUOJfFO3vzCEhjn6IT6vFdfDMgejN5N3vsE=; h=From:To:Cc:Subject:Date:From; b=iPLlOdtPJ6bReT9jH0I43rX74lSAtdPW6EXiy2sZkt8cRlJ3QZijOQG9RwqnawDZf E+GsWu1Zf4OeuxynoR0G3eS7xidSW5p/wtvFR5oJi0ljSpeOBilXXD+rG26H9pCsLV N3G+ca/E2J38l7zKibMksn8i2o12g5h5pz4ZIbT8= Received: from checstex0244823-lin.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bpothuno@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5E5A860735; Fri, 29 Mar 2019 11:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553858602; bh=zUrrSWfxaUOJfFO3vzCEhjn6IT6vFdfDMgejN5N3vsE=; h=From:To:Cc:Subject:Date:From; b=iPLlOdtPJ6bReT9jH0I43rX74lSAtdPW6EXiy2sZkt8cRlJ3QZijOQG9RwqnawDZf E+GsWu1Zf4OeuxynoR0G3eS7xidSW5p/wtvFR5oJi0ljSpeOBilXXD+rG26H9pCsLV N3G+ca/E2J38l7zKibMksn8i2o12g5h5pz4ZIbT8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5E5A860735 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bpothuno@codeaurora.org From: Balaji Pothunoori To: johannes@sipsolutions.net, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org Subject: [PATCH v4] iw: Add support for controlling tx power for per station Date: Fri, 29 Mar 2019 16:53:15 +0530 Message-Id: <1553858595-21819-1-git-send-email-bpothuno@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190329_042323_276236_7E258F4D X-CRM114-Status: GOOD ( 10.97 ) 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: Balaji Pothunoori , Ashok Raj Nagarajan MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ashok Raj Nagarajan This patch allows userspace to set transmit power, in dBm units, to a station associated to the AP. To set a limit tx power of 20 dBm: iw wlan0 station set txpwr limit 20 To revert the user defined tx power for a station: iw wlan0 station set txpwr auto Co-developed-by: Balaji Pothunoori Signed-off-by: Ashok Raj Nagarajan Signed-off-by: Balaji Pothunoori --- v2: modified user configured units to dBm from mBm v3: no changes, rebased v4: rebased and removed check for sta_txpwr in order to configure tx power '0' station.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/station.c b/station.c index 25cbbc3..0454f87 100644 --- a/station.c +++ b/station.c @@ -661,6 +661,7 @@ 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_airtime_weight; +static const struct cmd *station_set_txpwr; static const struct cmd *select_station_cmd(int argc, char **argv) { @@ -674,6 +675,8 @@ static const struct cmd *select_station_cmd(int argc, char **argv) return station_set_mesh_power_mode; if (strcmp(argv[1], "airtime_weight") == 0) return station_set_airtime_weight; + if (strcmp(argv[1], "txpwr") == 0) + return station_set_txpwr; return NULL; } @@ -873,6 +876,72 @@ COMMAND_ALIAS(station, set, " airtime_weight ", "Set airtime weight for this station.", select_station_cmd, station_set_airtime_weight); +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]; + 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_U8(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_U16(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,