cfg80211: Add support to set tx power for a station associated
PATCH 1/3 cfg80211: Add support to set tx power for a station associated
From: Ashok Raj Nagarajan <[email protected]>
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.
--- include/net/cfg80211.h | 12 ++++++++++++ include/uapi/linux/nl80211.h | 14 ++++++++++++++ net/wireless/nl80211.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+)
include/net/cfg80211.h +12 -0
@@ -958,6 +958,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), };/**
@@ -1001,6 +1002,15 @@ enum station_parameters_apply_mask {* @support_p2p_ps: information if station supports P2P PS mechanism * @he_capa: HE capabilities of station * @he_capa_len: the length of the HE capabilities +* @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. +* @type: In particular if TPC %type is NL80211_TX_POWER_LIMITED then txpwr will +* be less than or equal to specified from userspace, whereas if TPC %type +* is NL80211_TX_POWER_AUTOMATIC then it indicates default txpwr. +* NL80211_TX_POWER_FIXED is not a valid configuration option for +* per peer TPC. */ struct station_parameters {const u8 *supported_rates;
@@ -1030,6 +1040,8 @@ struct station_parameters {int support_p2p_ps;const struct ieee80211_he_cap_elem *he_capa;u8 he_capa_len; +s16 txpwr; +enum nl80211_tx_power_setting type; };/**
include/uapi/linux/nl80211.h +14 -0
@@ -2292,6 +2292,15 @@ enum nl80211_commands {* This is also used for capability advertisement in the wiphy information, * with the appropriate sub-attributes. * +* @NL80211_ATTR_STA_TX_POWER_SETTING: Transmit power setting type (u8) for +* station associated with the AP. See &enum nl80211_tx_power_setting for +* possible values. +* @NL80211_ATTR_STA_TX_POWER: Transmit power level (s16) 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
@@ -2740,6 +2749,8 @@ enum nl80211_attrs {NL80211_ATTR_TIMEOUT ,NL80211_ATTR_PEER_MEASUREMENTS , +NL80211_ATTR_STA_TX_POWER_SETTING , + NL80211_ATTR_STA_TX_POWER,/* add attributes here, update the policy in nl80211.c */
@@ -5308,6 +5319,8 @@ enum nl80211_feature_flags {* able to rekey an in-use key correctly. Userspace must not rekey PTK keys * if this flag is not set. Ignoring this can leak clear text packets and/or * freeze the connection. +* @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.
@@ -5348,6 +5361,7 @@ enum nl80211_ext_feature_index {NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT ,NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 ,NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER , +NL80211_EXT_FEATURE_STA_TX_PWR ,/* add new features before the definition below */ NUM_NL80211_EXT_FEATURES,
net/wireless/nl80211.c +35 -0
@@ -347,6 +347,8 @@ const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { .len = NL80211_MAX_SUPP_RATES }, [NL80211_ATTR_STA_PLINK_ACTION] = NLA_POLICY_MAX(NLA_U8, NUM_NL80211_PLINK_ACTIONS - 1), + [NL80211_ATTR_STA_TX_POWER_SETTING] = { .type = NLA_U8 }, + [NL80211_ATTR_STA_TX_POWER] = { .type = NLA_S16 }, [NL80211_ATTR_STA_VLAN] = { .type = NLA_U32 }, [NL80211_ATTR_MNTR_FLAGS] = { /* NLA_NESTED can't be empty */ }, [NL80211_ATTR_MESH_ID] = { .type = NLA_BINARY,
@@ -5377,6 +5379,31 @@ 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 ]; +int idx; + +if (info->attrs[NL80211_ATTR_STA_TX_POWER_SETTING ]) { +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 ; + params->type =nla_get_u32 (info->attrs[idx]); + +if (params->type ==NL80211_TX_POWER_LIMITED ) { + idx =NL80211_ATTR_STA_TX_POWER ; + params->txpwr =nla_get_u32 (info->attrs[idx]); + } + 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 ];
@@ -5461,6 +5488,10 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)nla_get_u8 (info->attrs[NL80211_ATTR_OPMODE_NOTIF ]); } + 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)
@@ -5589,6 +5620,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) params.plink_action =nla_get_u8 (info->attrs[NL80211_ATTR_STA_PLINK_ACTION ]); + err =nl80211_parse_sta_txpower_setting (info, ¶ms); +if (err) +return err; + err =nl80211_parse_sta_channel_info (info, ¶ms);if (err)return err;
Signature · 7 lines
2.7.4 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Johannes Berg
maintainerinclude/net/cfg80211.h struct station_parameters { · line 1044
Quoted 3 lines · Balaji Pothunoori
include/net/cfg80211.h +2
-0+s16 txpwr; +enum nl80211_tx_power_setting type;
you should probably call this txpwr_type, or do something like
struct {
s16 power;
enum ... type;
} txpwr;net/wireless/nl80211.c const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { · line 350
Quoted 1 line
net/wireless/nl80211.c +1
-0+ [NL80211_ATTR_STA_TX_POWER_SETTING] = { .type = NLA_U8 },
That should use NLA_POLICY_RANGE()
net/wireless/nl80211.c static int nl80211_set_station_tdls(struct genl_info *info, · line 5399
Quoted 8 lines
net/wireless/nl80211.c +6
-0+ [NL80211_ATTR_STA_TX_POWER ] = { .type =NLA_S16 }, + params->type = nla_get_u32(info->attrs[idx]); + +if (params->type ==NL80211_TX_POWER_LIMITED ) { + idx =NL80211_ATTR_STA_TX_POWER ; + params->txpwr =nla_get_u32 (info->attrs[idx]);
You cannot use nla_get_u32 with U8/S16 attributes, use the correct corresponding helper.
johannes