mac80211: merge a few pending upstream fixes
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 340-mac80211-add-support-for-driver-tx-power-reporting.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Wed, 22 Oct 2014 17:55:50 +0200
3 Subject: [PATCH] mac80211: add support for driver tx power reporting
4
5 The configured tx power is often limited by hardware capabilities,
6 channel settings, antenna configuration, etc.
7
8 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
9 ---
10
11 --- a/include/net/mac80211.h
12 +++ b/include/net/mac80211.h
13 @@ -2838,6 +2838,9 @@ enum ieee80211_roc_type {
14 * @get_expected_throughput: extract the expected throughput towards the
15 * specified station. The returned value is expressed in Kbps. It returns 0
16 * if the RC algorithm does not have proper data to provide.
17 + *
18 + * @get_txpower: get current maximum tx power (in dBm) based on configuration
19 + * and hardware limits.
20 */
21 struct ieee80211_ops {
22 void (*tx)(struct ieee80211_hw *hw,
23 @@ -3039,6 +3042,8 @@ struct ieee80211_ops {
24 int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
25 void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
26 u32 (*get_expected_throughput)(struct ieee80211_sta *sta);
27 + int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
28 + int *dbm);
29 };
30
31 /**
32 --- a/net/mac80211/cfg.c
33 +++ b/net/mac80211/cfg.c
34 @@ -2081,6 +2081,9 @@ static int ieee80211_get_tx_power(struct
35 struct ieee80211_local *local = wiphy_priv(wiphy);
36 struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
37
38 + if (local->ops->get_txpower)
39 + return local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
40 +
41 if (!local->use_chanctx)
42 *dbm = local->hw.conf.power_level;
43 else