Skip to contentSkip to conversation

mac80211: add support for driver tx power reporting

PATCH Superseded Felix Fietkau 2 participants 3 messages Oct 22, 2014 – Oct 25, 2014 mac80211

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: add support for driver tx power reporting

The configured tx power is often limited by hardware capabilities, channel settings, antenna configuration, etc.

---
 include/net/mac80211.h | 5 +++++
 net/mac80211/cfg.c     | 3 +++
 2 files changed, 8 insertions(+)
include/net/mac80211.h +5 -0
index 0ad1f47..41b0e60 100644
@@ -2838,6 +2838,9 @@ enum ieee80211_roc_type {
  * @get_expected_throughput: extract the expected throughput towards the
  *	specified station. The returned value is expressed in Kbps. It returns 0
  *	if the RC algorithm does not have proper data to provide.
+ *
+ * @get_txpower: get current maximum tx power (in dBm) based on configuration
+ *	and hardware limits.
  */
 struct ieee80211_ops {
 	void (*tx)(struct ieee80211_hw *hw,
@@ -3039,6 +3042,8 @@ struct ieee80211_ops {
 	int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	u32 (*get_expected_throughput)(struct ieee80211_sta *sta);
+	int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			   int *dbm);
 };
 
 /**
net/mac80211/cfg.c +3 -0
index fb6a150..7cb31a8 100644
@@ -2081,6 +2081,9 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy,
 	struct ieee80211_local *local = wiphy_priv(wiphy);
 	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
 
+	if (local->ops->get_txpower)
+		return local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
+
 	if (!local->use_chanctx)
 		*dbm = local->hw.conf.power_level;
 	else
Signature · 1 line
2.0.4
maintainer
#1 lore raw
Quoted 37 lines · Felix Fietkau

The configured tx power is often limited by hardware capabilities, channel settings, antenna configuration, etc.

---
 include/net/mac80211.h | 5 +++++
 net/mac80211/cfg.c     | 3 +++
 2 files changed, 8 insertions(+)
include/net/mac80211.h +5 -0
index 0ad1f47..41b0e60 100644
@@ -2838,6 +2838,9 @@ enum ieee80211_roc_type {
  * @get_expected_throughput: extract the expected throughput towards the
  *	specified station. The returned value is expressed in Kbps. It returns 0
  *	if the RC algorithm does not have proper data to provide.
+ *
+ * @get_txpower: get current maximum tx power (in dBm) based on configuration
+ *	and hardware limits.
  */
 struct ieee80211_ops {
 	void (*tx)(struct ieee80211_hw *hw,
@@ -3039,6 +3042,8 @@ struct ieee80211_ops {
 	int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	u32 (*get_expected_throughput)(struct ieee80211_sta *sta);
+	int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			   int *dbm);
 };
 
 /**
net/mac80211/cfg.c +0 -0
index fb6a150..7cb31a8 100644

net/mac80211/cfg.c static int ieee80211_get_tx_power(struct wiphy *wiphy, · line 2085

Quoted 5 lines
net/mac80211/cfg.c +2 -0
@@ -2081,6 +2081,9 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy,
 	struct ieee80211_local *local = wiphy_priv(wiphy);
 	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
 
+	if (local->ops->get_txpower)
+		return local->ops->get_txpower(&local->hw, &sdata->vif, dbm);

Might be good to have tracing?

And when this is supported, maybe there should be a cop-out for the driver to say "please use your value"? OTOH it can access the data that mac80211 currently reports so that's probably not needed?

johannes

#2 lore raw
Quoted 41 lines · Johannes Berg
Quoted 40 lines · Felix Fietkau

The configured tx power is often limited by hardware capabilities, channel settings, antenna configuration, etc.

---
 include/net/mac80211.h | 5 +++++
 net/mac80211/cfg.c     | 3 +++
 2 files changed, 8 insertions(+)
include/net/mac80211.h +5 -0
index 0ad1f47..41b0e60 100644
@@ -2838,6 +2838,9 @@ enum ieee80211_roc_type {
  * @get_expected_throughput: extract the expected throughput towards the
  *	specified station. The returned value is expressed in Kbps. It returns 0
  *	if the RC algorithm does not have proper data to provide.
+ *
+ * @get_txpower: get current maximum tx power (in dBm) based on configuration
+ *	and hardware limits.
  */
 struct ieee80211_ops {
 	void (*tx)(struct ieee80211_hw *hw,
@@ -3039,6 +3042,8 @@ struct ieee80211_ops {
 	int (*join_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	void (*leave_ibss)(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
 	u32 (*get_expected_throughput)(struct ieee80211_sta *sta);
+	int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+			   int *dbm);
 };
 
 /**
net/mac80211/cfg.c +0 -0
index fb6a150..7cb31a8 100644
@@ -2081,6 +2081,9 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy,
 	struct ieee80211_local *local = wiphy_priv(wiphy);
 	struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
 
Quoted 4 lines

net/mac80211/cfg.c static int ieee80211_get_tx_power(struct wiphy *wiphy, · line 2085

Quoted 2 lines
net/mac80211/cfg.c +2 -0
+	if (local->ops->get_txpower)
+		return local->ops->get_txpower(&local->hw, &sdata->vif, dbm);

Might be good to have tracing?

Sending v2.

Quoted 3 lines

And when this is supported, maybe there should be a cop-out for the driver to say "please use your value"? OTOH it can access the data that mac80211 currently reports so that's probably not needed?

I don't see the point in having that, since the driver can just take it from the hw/bss conf directly.

- Felix