]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: get tx power per link
authorRameshkumar Sundaram <quic_ramess@quicinc.com>
Mon, 25 Nov 2024 08:32:17 +0000 (14:02 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 4 Dec 2024 15:17:40 +0000 (16:17 +0100)
ML interfaces can have multiple affiliated links to it and
hence there is a need to report tx power of specified link
rather deflink.

Add changes to report tx power of requested link from mac80211,
also pass link id as an argument in get_tx_power op so that supported
drivers can use it to report link's tx power.

Co-developed-by: Aaradhana Sahu <quic_aarasahu@quicinc.com>
Signed-off-by: Aaradhana Sahu <quic_aarasahu@quicinc.com>
Signed-off-by: Rameshkumar Sundaram <quic_ramess@quicinc.com>
Link: https://patch.msgid.link/20241125083217.216095-3-quic_ramess@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/mediatek/mt76/mt76.h
include/net/mac80211.h
net/mac80211/cfg.c
net/mac80211/driver-ops.h
net/mac80211/trace.h

index e6acbff067496a22abb6b6d4808515d3c5d6da4e..7e75a9b13ef9283378b58d6434230cc7533358d1 100644 (file)
@@ -9356,6 +9356,7 @@ static int ath11k_fw_stats_request(struct ath11k *ar,
 
 static int ath11k_mac_op_get_txpower(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif,
+                                    unsigned int link_id,
                                     int *dbm)
 {
        struct ath11k *ar = hw->priv;
index b92c89dad8deac7281e0165c9e1a566ba99ece65..2f137856a823010d8e3e5aec27045a15ddbb9c2d 100644 (file)
@@ -2767,7 +2767,7 @@ void ath9k_fill_chanctx_ops(void)
 #endif
 
 static int ath9k_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                            int *dbm)
+                            unsigned int link_id, int *dbm)
 {
        struct ath_softc *sc = hw->priv;
        struct ath_vif *avp = (void *)vif->drv_priv;
index 9d5561f441347bb75951fe1468feb18d7ef4b62c..7fbce5e757df59e46522250a29c7c13ce3f35ebe 100644 (file)
@@ -1596,7 +1596,7 @@ void mt76_wcid_cleanup(struct mt76_dev *dev, struct mt76_wcid *wcid)
 EXPORT_SYMBOL_GPL(mt76_wcid_cleanup);
 
 int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                    int *dbm)
+                    unsigned int link_id, int *dbm)
 {
        struct mt76_phy *phy = hw->priv;
        int n_chains = hweight16(phy->chainmask);
index 0b75a45ad2e821ccc998923f8470c8ff6d5f4667..ca2dba3ac65d57bdb5ed510041a6589e1902e57a 100644 (file)
@@ -1431,7 +1431,7 @@ void mt76_sta_pre_rcu_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy);
 
 int mt76_get_txpower(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                    int *dbm);
+                    unsigned int link_id, int *dbm);
 int mt76_init_sar_power(struct ieee80211_hw *hw,
                        const struct cfg80211_sar_specs *sar);
 int mt76_get_sar_power(struct mt76_phy *phy,
index a97c9f85ae9a562ef8048e4c1576395267072687..5ce4dfa3fba55fd6c33e6261c340feea9e5031ed 100644 (file)
@@ -4759,7 +4759,7 @@ struct ieee80211_ops {
        u32 (*get_expected_throughput)(struct ieee80211_hw *hw,
                                       struct ieee80211_sta *sta);
        int (*get_txpower)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                          int *dbm);
+                          unsigned int link_id, int *dbm);
 
        int (*tdls_channel_switch)(struct ieee80211_hw *hw,
                                   struct ieee80211_vif *vif,
index b2410a91355605f017c49fd5f3a73b8a829924e0..2fa594fb6c1a6f33e7dd4ed93ca0af8caea7ed1f 100644 (file)
@@ -3195,15 +3195,22 @@ 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);
+       struct ieee80211_link_data *link_data;
 
        if (local->ops->get_txpower &&
            (sdata->flags & IEEE80211_SDATA_IN_DRIVER))
-               return drv_get_txpower(local, sdata, dbm);
+               return drv_get_txpower(local, sdata, link_id, dbm);
 
-       if (local->emulate_chanctx)
+       if (local->emulate_chanctx) {
                *dbm = local->hw.conf.power_level;
-       else
-               *dbm = sdata->vif.bss_conf.txpower;
+       } else {
+               link_data = wiphy_dereference(wiphy, sdata->link[link_id]);
+
+               if (link_data)
+                       *dbm = link_data->conf->txpower;
+               else
+                       return -ENOLINK;
+       }
 
        /* INT_MIN indicates no power level was set yet */
        if (*dbm == INT_MIN)
index edd1e4d4ad9d2a896282cc5465facea7a5ff0e22..c64531e0a60e78f71dea4c84c8de82bd1b66acff 100644 (file)
@@ -1273,7 +1273,8 @@ static inline u32 drv_get_expected_throughput(struct ieee80211_local *local,
 }
 
 static inline int drv_get_txpower(struct ieee80211_local *local,
-                                 struct ieee80211_sub_if_data *sdata, int *dbm)
+                                 struct ieee80211_sub_if_data *sdata,
+                                 unsigned int link_id, int *dbm)
 {
        int ret;
 
@@ -1283,8 +1284,8 @@ static inline int drv_get_txpower(struct ieee80211_local *local,
        if (!local->ops->get_txpower)
                return -EOPNOTSUPP;
 
-       ret = local->ops->get_txpower(&local->hw, &sdata->vif, dbm);
-       trace_drv_get_txpower(local, sdata, *dbm, ret);
+       ret = local->ops->get_txpower(&local->hw, &sdata->vif, link_id, dbm);
+       trace_drv_get_txpower(local, sdata, link_id, *dbm, ret);
 
        return ret;
 }
index 7a4985fc2b16be2860592053858d3c24ecf0a256..dc35fed7e9b097648a3e05e8de5fc724d94154de 100644 (file)
@@ -2173,13 +2173,14 @@ DEFINE_EVENT(chanswitch_evt, drv_channel_switch_rx_beacon,
 TRACE_EVENT(drv_get_txpower,
        TP_PROTO(struct ieee80211_local *local,
                 struct ieee80211_sub_if_data *sdata,
-                int dbm, int ret),
+                unsigned int link_id, int dbm, int ret),
 
-       TP_ARGS(local, sdata, dbm, ret),
+       TP_ARGS(local, sdata, link_id, dbm, ret),
 
        TP_STRUCT__entry(
                LOCAL_ENTRY
                VIF_ENTRY
+               __field(unsigned int, link_id)
                __field(int, dbm)
                __field(int, ret)
        ),
@@ -2187,13 +2188,14 @@ TRACE_EVENT(drv_get_txpower,
        TP_fast_assign(
                LOCAL_ASSIGN;
                VIF_ASSIGN;
+               __entry->link_id = link_id;
                __entry->dbm = dbm;
                __entry->ret = ret;
        ),
 
        TP_printk(
-               LOCAL_PR_FMT VIF_PR_FMT " dbm:%d ret:%d",
-               LOCAL_PR_ARG, VIF_PR_ARG, __entry->dbm, __entry->ret
+               LOCAL_PR_FMT VIF_PR_FMT " link_id:%d dbm:%d ret:%d",
+               LOCAL_PR_ARG, VIF_PR_ARG, __entry->link_id, __entry->dbm, __entry->ret
        )
 );