OSDN Git Service

ath10k: add support for controlling tx power to a station
authorAshok Raj Nagarajan <arnagara@codeaurora.org>
Mon, 3 Jun 2019 15:09:02 +0000 (18:09 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 25 Jun 2019 13:14:00 +0000 (16:14 +0300)
This patch will add the support to control the transmit power for traffic
to a station associated with the AP.

Underlying firmware will enforce that the maximum tx power will be based
on the regulatory requirements. If the user given transmit power is greater
than the allowed tx power in the given channel, then the firmware will use
the maximum tx power in the same channel.

Max and Min tx power values will depends on no of tx chain masks,
for QCA9984 allowed tx power range values from 6 to 23.

When 0 is sent to the firmware as tx power, it will revert to the default
tx power for the station.

Tested Hardware : QCA9984
Tested Firmware : 10.4-3.9.0.2-00046

Co-developed-by: Balaji Pothunoori <bpothuno@codeaurora.org>
Signed-off-by: Ashok Raj Nagarajan <arnagara@codeaurora.org>
Signed-off-by: Balaji Pothunoori <bpothuno@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/debug.h
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath10k/wmi.h

index a5b2039..82f7eb8 100644 (file)
@@ -71,6 +71,9 @@ struct ath10k_pktlog_hdr {
 /* FIXME: How to calculate the buffer size sanely? */
 #define ATH10K_FW_STATS_BUF_SIZE (1024 * 1024)
 
+#define ATH10K_TX_POWER_MAX_VAL 70
+#define ATH10K_TX_POWER_MIN_VAL 0
+
 extern unsigned int ath10k_debug_mask;
 
 __printf(2, 3) void ath10k_info(struct ath10k *ar, const char *fmt, ...);
index 24ac525..e43a566 100644 (file)
@@ -6410,6 +6410,41 @@ static void ath10k_mac_dec_num_stations(struct ath10k_vif *arvif,
        ar->num_stations--;
 }
 
+static int ath10k_sta_set_txpwr(struct ieee80211_hw *hw,
+                               struct ieee80211_vif *vif,
+                               struct ieee80211_sta *sta)
+{
+       struct ath10k *ar = hw->priv;
+       struct ath10k_vif *arvif = (void *)vif->drv_priv;
+       int ret = 0;
+       s16 txpwr;
+
+       if (sta->txpwr.type == NL80211_TX_POWER_AUTOMATIC) {
+               txpwr = 0;
+       } else {
+               txpwr = sta->txpwr.power;
+               if (!txpwr)
+                       return -EINVAL;
+       }
+
+       if (txpwr > ATH10K_TX_POWER_MAX_VAL || txpwr < ATH10K_TX_POWER_MIN_VAL)
+               return -EINVAL;
+
+       mutex_lock(&ar->conf_mutex);
+
+       ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr,
+                                       WMI_PEER_USE_FIXED_PWR, txpwr);
+       if (ret) {
+               ath10k_warn(ar, "failed to set tx power for station ret: %d\n",
+                           ret);
+               goto out;
+       }
+
+out:
+       mutex_unlock(&ar->conf_mutex);
+       return ret;
+}
+
 static int ath10k_sta_state(struct ieee80211_hw *hw,
                            struct ieee80211_vif *vif,
                            struct ieee80211_sta *sta,
@@ -8155,6 +8190,7 @@ static const struct ieee80211_ops ath10k_ops = {
        .set_key                        = ath10k_set_key,
        .set_default_unicast_key        = ath10k_set_default_unicast_key,
        .sta_state                      = ath10k_sta_state,
+       .sta_set_txpwr                  = ath10k_sta_set_txpwr,
        .conf_tx                        = ath10k_conf_tx,
        .remain_on_channel              = ath10k_remain_on_channel,
        .cancel_remain_on_channel       = ath10k_cancel_remain_on_channel,
@@ -8843,6 +8879,9 @@ int ath10k_mac_register(struct ath10k *ar)
                wiphy_ext_feature_set(ar->hw->wiphy,
                                      NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER);
 
+       if (test_bit(WMI_SERVICE_TX_PWR_PER_PEER, ar->wmi.svc_map))
+               wiphy_ext_feature_set(ar->hw->wiphy,
+                                     NL80211_EXT_FEATURE_STA_TX_PWR);
        /*
         * on LL hardware queues are managed entirely by the FW
         * so we only advertise to mac we can do the queues thing
index cc87a0d..838768c 100644 (file)
@@ -201,6 +201,7 @@ enum wmi_service {
        WMI_SERVICE_PER_PACKET_SW_ENCRYPT,
        WMI_SERVICE_REPORT_AIRTIME,
        WMI_SERVICE_SYNC_DELETE_CMDS,
+       WMI_SERVICE_TX_PWR_PER_PEER,
 
        /* Remember to add the new value to wmi_service_name()! */
 
@@ -368,6 +369,7 @@ enum wmi_10_4_service {
        WMI_10_4_SERVICE_RTT_RESPONDER_ROLE,
        WMI_10_4_SERVICE_EXT_PEER_TID_CONFIGS_SUPPORT,
        WMI_10_4_SERVICE_REPORT_AIRTIME,
+       WMI_10_4_SERVICE_TX_PWR_PER_PEER,
 };
 
 static inline char *wmi_service_name(enum wmi_service service_id)
@@ -493,6 +495,7 @@ static inline char *wmi_service_name(enum wmi_service service_id)
        SVCSTR(WMI_SERVICE_PER_PACKET_SW_ENCRYPT);
        SVCSTR(WMI_SERVICE_REPORT_AIRTIME);
        SVCSTR(WMI_SERVICE_SYNC_DELETE_CMDS);
+       SVCSTR(WMI_SERVICE_TX_PWR_PER_PEER);
 
        case WMI_SERVICE_MAX:
                return NULL;
@@ -820,6 +823,8 @@ static inline void wmi_10_4_svc_map(const __le32 *in, unsigned long *out,
               WMI_SERVICE_PER_PACKET_SW_ENCRYPT, len);
        SVCMAP(WMI_10_4_SERVICE_REPORT_AIRTIME,
               WMI_SERVICE_REPORT_AIRTIME, len);
+       SVCMAP(WMI_10_4_SERVICE_TX_PWR_PER_PEER,
+              WMI_SERVICE_TX_PWR_PER_PEER, len);
 }
 
 #undef SVCMAP
@@ -6262,6 +6267,7 @@ enum wmi_peer_param {
        WMI_PEER_CHAN_WIDTH = 0x4,
        WMI_PEER_NSS        = 0x5,
        WMI_PEER_USE_4ADDR  = 0x6,
+       WMI_PEER_USE_FIXED_PWR = 0x8,
        WMI_PEER_PARAM_FIXED_RATE = 0x9,
        WMI_PEER_DEBUG      = 0xa,
        WMI_PEER_PHYMODE    = 0xd,