cfg80211: Add support to set tx power for a station associated
PATCH v3 1/2 cfg80211: Add support to set tx power for a station associated
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.
---
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(+)
include/net/cfg80211.h +6 -0
@@ -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; };/**
include/uapi/linux/nl80211.h +15 -0
@@ -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,
net/wireless/nl80211.c +48 -0
72 lines not on this page · raw message
Signature · 1 line
1.9.1
Johannes Berg
maintainerQuoted 12 lines
+ * @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.
*/
structstation_parameters{
const u8*supported_rates;
include/net/cfg80211.h struct station_parameters { · line 885
Quoted 5 lines
include/net/cfg80211.h +1
-0@@ -876,6 +881,7 @@ struct station_parameters { u8 opmode_notif; bool opmode_notif_used; int support_p2p_ps; +u16 txpwr; };
Wouldn't it be better to add the tx power type (limited/automatic) here as well? That way, we don't have to play games with 0 meaning automatic (which you didn't even document, but seems to be the case), when in fact 0dBm could technically be a valid TX power as well.
Quoted 12 lines
net/wireless/nl80211.c +11
-0+ 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-Quoted 1 line
attrs[idx]);
net/wireless/nl80211.c static int nl80211_set_station_tdls(struct genl_info *info, · line 4788
Quoted 6 lines
net/wireless/nl80211.c +6
-0+ }else { +return -EINVAL ; + } + }else { + params->txpwr =0 ; + }
This could be nicer using a switch on the type, perhaps?
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (info->attrs[NL80211_ATTR_STA_TX_POWER_SETTING]) { + err = nl80211_parse_sta_txpower_setting(info,
¶ms);
net/wireless/nl80211.c static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) · line 4897
Quoted 3 lines
net/wireless/nl80211.c +3
-0+if (err) +return err; + }
Why not move the check that the attribute exists into the function?
johannes