From patchwork Wed Feb 8 11:56:24 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: 9562399 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 AA6BD6047A for ; Wed, 8 Feb 2017 12:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B62427F10 for ; Wed, 8 Feb 2017 12:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90344284D1; Wed, 8 Feb 2017 12:02:22 +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 02D6A27F10 for ; Wed, 8 Feb 2017 12:02:22 +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 1cbQww-0002OE-Ry; Wed, 08 Feb 2017 12:02:14 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cbQwu-0002Nm-2g for ath10k@bombadil.infradead.org; Wed, 08 Feb 2017 12:02:12 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cbQws-0001pA-Jc for ath10k@lists.infradead.org; Wed, 08 Feb 2017 12:02:11 +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=1486555330; x=1518091330; h=from:to:cc:subject:date:message-id:mime-version; bh=6avauEydgTImQ9IpMbxLXraEUBBAjgQYkdt4LnR9Gbk=; b=zHlyfcp9bmTu1kXLQJNj0KI//lUBkVMwbed1n8rbcKkToxuoxfeYMX4J PBM84WwQfLedzp6l5oEVlsWJWCRYkbCvaNjlLcO7H/n1d9DJ1Af+LK+gD ECW3VCSYnuw85L/LguEDyBqzZS4D/hC26WkUJ1RouZSknMrbVTrfLl5Y5 Q=; X-IronPort-AV: E=Sophos;i="5.33,346,1477983600"; d="scan'208";a="261163918" Received: from unknown (HELO Ironmsg03-R.qualcomm.com) ([10.53.140.107]) by wolverine01.qualcomm.com with ESMTP; 08 Feb 2017 04:01:45 -0800 X-IronPort-AV: E=McAfee;i="5800,7501,8432"; a="1305451590" Received: from nasanexm02g.na.qualcomm.com ([10.85.0.88]) by Ironmsg03-R.qualcomm.com with ESMTP/TLS/RC4-SHA; 08 Feb 2017 04:01:44 -0800 Received: from aphydexm01f.ap.qualcomm.com (10.252.127.15) by nasanexm02g.na.qualcomm.com (10.85.0.88) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Wed, 8 Feb 2017 04:01:43 -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:31:35 +0530 Received: by qcmail1.qualcomm.com (sSMTP sendmail emulation); Wed, 08 Feb 2017 17:26:29 +0530 From: Ashok Raj Nagarajan To: Subject: [PATCH v3 1/2] cfg80211: Add support to set tx power for a station associated Date: Wed, 8 Feb 2017 17:26:24 +0530 Message-ID: <1486554984-25097-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: NASANEXM01C.na.qualcomm.com (10.85.0.83) 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_070210_871575_C8049F28 X-CRM114-Status: GOOD ( 19.28 ) 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: johannes@sipsolutions.net, arnagara@codeaurora.org, Ashok Raj Nagarajan , 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 adds support to set transmit power setting type and transmit power level attributes to NL80211_CMD_SET_STATION in order to facilitate adjusting the transmit power level of a station associated to the AP. The added attributes allow selection of automatic and limited transmit power level, with the level defined in mBm format. Signed-off-by: Ashok Raj Nagarajan --- v2: - refactor the shared code - "keep what you had" using STATION_PARAM_APPLY_* BIT - feature flag to let the user know if this feature is supported or not (Johannes) v3: - fix the limitation of changing the txpwr after association (Ben Greear) include/net/cfg80211.h | 6 ++++++ include/uapi/linux/nl80211.h | 15 ++++++++++++++ net/wireless/nl80211.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 814be4b..661e0ea 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -808,6 +808,7 @@ enum station_parameters_apply_mask { STATION_PARAM_APPLY_UAPSD = BIT(0), STATION_PARAM_APPLY_CAPABILITY = BIT(1), STATION_PARAM_APPLY_PLINK_STATE = BIT(2), + STATION_PARAM_APPLY_STA_TXPOWER = BIT(3), }; /** @@ -849,6 +850,10 @@ enum station_parameters_apply_mask { * @opmode_notif: operating mode field from Operating Mode Notification * @opmode_notif_used: information if operating mode field is used * @support_p2p_ps: information if station supports P2P PS mechanism + * @txpwr: tx power (in mBm) to be used for sending data traffic. If tx power + * is not provided, the default per-interface tx power setting will be + * overriding. Driver should be picking up the lowest tx power, either tx + * power per-interface or per-station. */ struct station_parameters { const u8 *supported_rates; @@ -876,6 +881,7 @@ struct station_parameters { u8 opmode_notif; bool opmode_notif_used; int support_p2p_ps; + u16 txpwr; }; /** diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 6b76e3b..de2f72c 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1980,6 +1980,15 @@ enum nl80211_commands { * @NL80211_ATTR_BSSID: The BSSID of the AP. Note that %NL80211_ATTR_MAC is also * used in various commands/events for specifying the BSSID. * + * @NL80211_ATTR_STA_TX_POWER_SETTING: Transmit power setting type (u32) for + * station associated with the AP. See &enum nl80211_tx_power_setting for + * possible values. + * @NL80211_ATTR_STA_TX_POWER: Transmit power level (u32) in mBm units. This + * allows to set Tx power for a station. If this attribute is not included, + * the default per-interface tx power setting will be overriding. Driver + * should be picking up the lowest tx power, either tx power per-interface + * or per-station. + * * @NUM_NL80211_ATTR: total number of nl80211_attrs available * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use @@ -2386,6 +2395,9 @@ enum nl80211_attrs { NL80211_ATTR_BSSID, + NL80211_ATTR_STA_TX_POWER_SETTING, + NL80211_ATTR_STA_TX_POWER, + /* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST, @@ -4697,6 +4709,8 @@ enum nl80211_feature_flags { * configuration (AP/mesh) with VHT rates. * @NL80211_EXT_FEATURE_FILS_STA: This driver supports Fast Initial Link Setup * with user space SME (NL80211_CMD_AUTHENTICATE) in station mode. + * @NL80211_EXT_FEATURE_STA_TX_PWR: This driver supports controlling tx power + * to a station. * * @NUM_NL80211_EXT_FEATURES: number of extended features. * @MAX_NL80211_EXT_FEATURES: highest extended feature index. @@ -4712,6 +4726,7 @@ enum nl80211_ext_feature_index { NL80211_EXT_FEATURE_BEACON_RATE_HT, NL80211_EXT_FEATURE_BEACON_RATE_VHT, NL80211_EXT_FEATURE_FILS_STA, + NL80211_EXT_FEATURE_STA_TX_PWR, /* add new features before the definition below */ NUM_NL80211_EXT_FEATURES, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ef5eff93..701c08a 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -246,6 +246,8 @@ enum nl80211_multicast_groups { [NL80211_ATTR_STA_SUPPORTED_RATES] = { .type = NLA_BINARY, .len = NL80211_MAX_SUPP_RATES }, [NL80211_ATTR_STA_PLINK_ACTION] = { .type = NLA_U8 }, + [NL80211_ATTR_STA_TX_POWER_SETTING] = { .type = NLA_U32 }, + [NL80211_ATTR_STA_TX_POWER] = { .type = NLA_U32 }, [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ }, [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY, @@ -4755,6 +4757,40 @@ static int nl80211_set_station_tdls(struct genl_info *info, return nl80211_parse_sta_wme(info, params); } +static int nl80211_parse_sta_txpower_setting(struct genl_info *info, + struct station_parameters *params) +{ + struct cfg80211_registered_device *rdev = info->user_ptr[0]; + enum nl80211_tx_power_setting type; + int idx; + + if (!rdev->ops->set_tx_power || + !wiphy_ext_feature_isset(&rdev->wiphy, + NL80211_EXT_FEATURE_STA_TX_PWR)) + return -EOPNOTSUPP; + + idx = NL80211_ATTR_STA_TX_POWER_SETTING; + type = nla_get_u32(info->attrs[idx]); + + if (!info->attrs[NL80211_ATTR_STA_TX_POWER] && + (type != NL80211_TX_POWER_AUTOMATIC)) + return -EINVAL; + + if (type != NL80211_TX_POWER_AUTOMATIC) { + if (type == NL80211_TX_POWER_LIMITED) { + idx = NL80211_ATTR_STA_TX_POWER; + params->txpwr = nla_get_u32(info->attrs[idx]); + } else { + return -EINVAL; + } + } else { + params->txpwr = 0; + } + params->sta_modify_mask |= STATION_PARAM_APPLY_STA_TXPOWER; + + return 0; +} + static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *rdev = info->user_ptr[0]; @@ -4854,6 +4890,12 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) params.local_pm = pm; } + if (info->attrs[NL80211_ATTR_STA_TX_POWER_SETTING]) { + err = nl80211_parse_sta_txpower_setting(info, ¶ms); + if (err) + return err; + } + /* Include parameters for TDLS peer (will check later) */ err = nl80211_set_station_tdls(info, ¶ms); if (err) @@ -4981,6 +5023,12 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } + if (info->attrs[NL80211_ATTR_STA_TX_POWER_SETTING]) { + err = nl80211_parse_sta_txpower_setting(info, ¶ms); + if (err) + return err; + } + err = nl80211_parse_sta_channel_info(info, ¶ms); if (err) return err;