diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-10-25 18:32:53 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2014-11-04 04:15:09 -0500 |
commit | 5b3dc42b1b0db0264bbbe4ae44c15ab97bfd1e93 (patch) | |
tree | 3a53814de5743eb3fdf491609a050a417632c9f4 | |
parent | 0563921abf01a7a38b5f670c3de05dc0b0b8617d (diff) |
mac80211: add support for driver tx power reporting
The configured tx power is often limited by hardware capabilities,
channel settings, antenna configuration, etc.
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
[fix tracing compilation]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | include/net/mac80211.h | 5 | ||||
-rw-r--r-- | net/mac80211/cfg.c | 3 | ||||
-rw-r--r-- | net/mac80211/driver-ops.h | 14 | ||||
-rw-r--r-- | net/mac80211/trace.h | 27 |
4 files changed, 49 insertions, 0 deletions
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index 1614b2fc3bf6..03edbf6f6230 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -2857,6 +2857,9 @@ enum ieee80211_roc_type { | |||
2857 | * @get_expected_throughput: extract the expected throughput towards the | 2857 | * @get_expected_throughput: extract the expected throughput towards the |
2858 | * specified station. The returned value is expressed in Kbps. It returns 0 | 2858 | * specified station. The returned value is expressed in Kbps. It returns 0 |
2859 | * if the RC algorithm does not have proper data to provide. | 2859 | * if the RC algorithm does not have proper data to provide. |
2860 | * | ||
2861 | * @get_txpower: get current maximum tx power (in dBm) based on configuration | ||
2862 | * and hardware limits. | ||
2860 | */ | 2863 | */ |
2861 | struct ieee80211_ops { | 2864 | struct ieee80211_ops { |
2862 | void (*tx)(struct ieee80211_hw *hw, | 2865 | void (*tx)(struct ieee80211_hw *hw, |
@@ -3065,6 +3068,8 @@ struct ieee80211_ops { | |||
3065 | int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | 3068 | int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); |
3066 | void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | 3069 | void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); |
3067 | u32 (*get_expected_throughput)(struct ieee80211_sta *sta); | 3070 | u32 (*get_expected_throughput)(struct ieee80211_sta *sta); |
3071 | int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
3072 | int *dbm); | ||
3068 | }; | 3073 | }; |
3069 | 3074 | ||
3070 | /** | 3075 | /** |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index fbcc209687c8..b9659b8b70f8 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -2133,6 +2133,9 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy, | |||
2133 | struct ieee80211_local *local = wiphy_priv(wiphy); | 2133 | struct ieee80211_local *local = wiphy_priv(wiphy); |
2134 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | 2134 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
2135 | 2135 | ||
2136 | if (local->ops->get_txpower) | ||
2137 | return drv_get_txpower(local, sdata, dbm); | ||
2138 | |||
2136 | if (!local->use_chanctx) | 2139 | if (!local->use_chanctx) |
2137 | *dbm = local->hw.conf.power_level; | 2140 | *dbm = local->hw.conf.power_level; |
2138 | else | 2141 | else |
diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index 3df28e0fa045..d1e128e5db41 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h | |||
@@ -1279,4 +1279,18 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local, | |||
1279 | return ret; | 1279 | return ret; |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | static inline int drv_get_txpower(struct ieee80211_local *local, | ||
1283 | struct ieee80211_sub_if_data *sdata, int *dbm) | ||
1284 | { | ||
1285 | int ret; | ||
1286 | |||
1287 | if (!local->ops->get_txpower) | ||
1288 | return -EOPNOTSUPP; | ||
1289 | |||
1290 | ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm); | ||
1291 | trace_drv_get_txpower(local, sdata, *dbm, ret); | ||
1292 | |||
1293 | return ret; | ||
1294 | } | ||
1295 | |||
1282 | #endif /* __MAC80211_DRIVER_OPS */ | 1296 | #endif /* __MAC80211_DRIVER_OPS */ |
diff --git a/net/mac80211/trace.h b/net/mac80211/trace.h index 976606aebac9..aeeace5ba47b 100644 --- a/net/mac80211/trace.h +++ b/net/mac80211/trace.h | |||
@@ -2150,6 +2150,33 @@ DEFINE_EVENT(local_sdata_evt, drv_post_channel_switch, | |||
2150 | TP_ARGS(local, sdata) | 2150 | TP_ARGS(local, sdata) |
2151 | ); | 2151 | ); |
2152 | 2152 | ||
2153 | TRACE_EVENT(drv_get_txpower, | ||
2154 | TP_PROTO(struct ieee80211_local *local, | ||
2155 | struct ieee80211_sub_if_data *sdata, | ||
2156 | int dbm, int ret), | ||
2157 | |||
2158 | TP_ARGS(local, sdata, dbm, ret), | ||
2159 | |||
2160 | TP_STRUCT__entry( | ||
2161 | LOCAL_ENTRY | ||
2162 | VIF_ENTRY | ||
2163 | __field(int, dbm) | ||
2164 | __field(int, ret) | ||
2165 | ), | ||
2166 | |||
2167 | TP_fast_assign( | ||
2168 | LOCAL_ASSIGN; | ||
2169 | VIF_ASSIGN; | ||
2170 | __entry->dbm = dbm; | ||
2171 | __entry->ret = ret; | ||
2172 | ), | ||
2173 | |||
2174 | TP_printk( | ||
2175 | LOCAL_PR_FMT VIF_PR_FMT " dbm:%d ret:%d", | ||
2176 | LOCAL_PR_ARG, VIF_PR_ARG, __entry->dbm, __entry->ret | ||
2177 | ) | ||
2178 | ); | ||
2179 | |||
2153 | 2180 | ||
2154 | #ifdef CONFIG_MAC80211_MESSAGE_TRACING | 2181 | #ifdef CONFIG_MAC80211_MESSAGE_TRACING |
2155 | #undef TRACE_SYSTEM | 2182 | #undef TRACE_SYSTEM |