ath10k: Fill rx duration for each peer in fw_stats for WCN3990
authorSurabhi Vishnoi <svishnoi@codeaurora.org>
Tue, 26 Feb 2019 09:53:16 +0000 (15:23 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 28 Feb 2019 08:48:19 +0000 (10:48 +0200)
Currently, rx_duration for each peer is not getting populated in
fw_stats debugfs entry for WCN3990.

WCN3990 firmware sends rx duration for each peer as part of
peer_extd_stats in WMI_UPDATE_STATS_EVENT. To enable peer_extd_stats,
firmware expects host to send fw_stats_req_mask with flag
WMI_TLV_PEER_STATS_EXTD set in WMI_REQUEST_STATS_CMD.

Send fw_stats_req_mask with flag WMI_TLV_PEER_STATS_EXTD set in
WMI_REQUEST_STATS_CMD and parse the peer_extd_stats in
WMI_UPDATE_STATS_EVENT to populate the rx_duration of each peer
in fw_stats debugfs entry.

Currently the driver handles 32-bit rx_duration, but the rx_duration
for WCN3990 can be upto 63 bit. The firmware sends rx_duration split
into two 32-bit fields, with the upper 32-bits being valid only if its
MSB is set. This change handles the 63-bit rx_duration obtained from
WCN3990 and maintain the backward compatibility.

To get the rx_duration of each connected peer :
cat /sys/kernel/debug/ieee80211/phyX/ath10k/fw_stats

Tested HW: WCN3990
Tested FW: WLAN.HL.3.1-00784-QCAHLSWMTPLZ-1

Signed-off-by: Surabhi Vishnoi <svishnoi@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/core.c
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/wmi-tlv.c
drivers/net/wireless/ath/ath10k/wmi-tlv.h
drivers/net/wireless/ath/ath10k/wmi.c
drivers/net/wireless/ath/ath10k/wmi.h

index c2d2155580eb1a074778b05bc6381f8e919b6c5b..835b8de92d55e6f94cffbc2f1449eb27acff72b3 100644 (file)
@@ -2317,8 +2317,8 @@ static int ath10k_core_init_firmware_features(struct ath10k *ar)
                else
                        ar->htt.max_num_pending_tx = TARGET_TLV_NUM_MSDU_DESC;
                ar->wow.max_num_patterns = TARGET_TLV_NUM_WOW_PATTERNS;
-               ar->fw_stats_req_mask = WMI_STAT_PDEV | WMI_STAT_VDEV |
-                       WMI_STAT_PEER;
+               ar->fw_stats_req_mask = WMI_TLV_STAT_PDEV | WMI_TLV_STAT_VDEV |
+                       WMI_TLV_STAT_PEER | WMI_TLV_STAT_PEER_EXTD;
                ar->max_spatial_stream = WMI_MAX_SPATIAL_STREAM;
                ar->wmi.mgmt_max_num_pending_tx = TARGET_TLV_MGMT_NUM_MSDU_DESC;
                break;
index 27ec5557de882baf0367654c7eb158ba1de7c9cf..e08a17b01e035dba87cc63a05d29cd59f0d732f4 100644 (file)
@@ -189,7 +189,7 @@ struct ath10k_fw_stats_peer {
        u32 peer_rssi;
        u32 peer_tx_rate;
        u32 peer_rx_rate; /* 10x only */
-       u32 rx_duration;
+       u64 rx_duration;
 };
 
 struct ath10k_fw_extd_stats_peer {
index 890887eb886ac80f904cab94fdc852ac6c430fc4..582fb11f648a583187763f61a1009d40ddff9834 100644 (file)
@@ -13,6 +13,7 @@
 #include "wmi-tlv.h"
 #include "p2p.h"
 #include "testmode.h"
+#include <linux/bitfield.h>
 
 /***************/
 /* TLV helpers */
@@ -1296,6 +1297,7 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
 {
        const void **tb;
        const struct wmi_tlv_stats_ev *ev;
+       u32 num_peer_stats_extd;
        const void *data;
        u32 num_pdev_stats;
        u32 num_vdev_stats;
@@ -1303,6 +1305,7 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
        u32 num_bcnflt_stats;
        u32 num_chan_stats;
        size_t data_len;
+       u32 stats_id;
        int ret;
        int i;
 
@@ -1327,11 +1330,13 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
        num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
        num_bcnflt_stats = __le32_to_cpu(ev->num_bcnflt_stats);
        num_chan_stats = __le32_to_cpu(ev->num_chan_stats);
+       stats_id = __le32_to_cpu(ev->stats_id);
+       num_peer_stats_extd = __le32_to_cpu(ev->num_peer_stats_extd);
 
        ath10k_dbg(ar, ATH10K_DBG_WMI,
-                  "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i\n",
+                  "wmi tlv stats update pdev %i vdev %i peer %i bcnflt %i chan %i peer_extd %i\n",
                   num_pdev_stats, num_vdev_stats, num_peer_stats,
-                  num_bcnflt_stats, num_chan_stats);
+                  num_bcnflt_stats, num_chan_stats, num_peer_stats_extd);
 
        for (i = 0; i < num_pdev_stats; i++) {
                const struct wmi_pdev_stats *src;
@@ -1396,6 +1401,28 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
 
                ath10k_wmi_pull_peer_stats(&src->old, dst);
                dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
+
+               if (stats_id & WMI_TLV_STAT_PEER_EXTD) {
+                       const struct wmi_tlv_peer_stats_extd *extd;
+                       unsigned long rx_duration_high;
+
+                       extd = data + sizeof(*src) * (num_peer_stats - i - 1)
+                              + sizeof(*extd) * i;
+
+                       dst->rx_duration = __le32_to_cpu(extd->rx_duration);
+                       rx_duration_high = __le32_to_cpu
+                                               (extd->rx_duration_high);
+
+                       if (test_bit(WMI_TLV_PEER_RX_DURATION_HIGH_VALID_BIT,
+                                    &rx_duration_high)) {
+                               rx_duration_high =
+                                       FIELD_GET(WMI_TLV_PEER_RX_DURATION_HIGH_MASK,
+                                                 rx_duration_high);
+                               dst->rx_duration |= (u64)rx_duration_high <<
+                                                   WMI_TLV_PEER_RX_DURATION_SHIFT;
+                       }
+               }
+
                list_add_tail(&dst->list, &stats->peers);
        }
 
index 52e0e73ac5f97df0d5a271ba42acb245a65cb1b8..65e6aa520b069bd34c216f1dcd64333f8269ac46 100644 (file)
@@ -1889,6 +1889,22 @@ struct wmi_tlv_req_stats_cmd {
        struct wmi_mac_addr peer_macaddr;
 } __packed;
 
+#define WMI_TLV_PEER_RX_DURATION_HIGH_VALID_BIT        31
+#define WMI_TLV_PEER_RX_DURATION_HIGH_MASK     GENMASK(30, 0)
+#define WMI_TLV_PEER_RX_DURATION_SHIFT         32
+
+struct wmi_tlv_peer_stats_extd {
+       struct wmi_mac_addr peer_macaddr;
+       __le32 rx_duration;
+       __le32 peer_tx_bytes;
+       __le32 peer_rx_bytes;
+       __le32 last_tx_rate_code;
+       __le32 last_tx_power;
+       __le32 rx_mc_bc_cnt;
+       __le32 rx_duration_high;
+       __le32 reserved[2];
+} __packed;
+
 struct wmi_tlv_vdev_stats {
        __le32 vdev_id;
        __le32 beacon_snr;
@@ -1982,6 +1998,10 @@ struct wmi_tlv_stats_ev {
        __le32 num_peer_stats;
        __le32 num_bcnflt_stats;
        __le32 num_chan_stats;
+       __le32 num_mib_stats;
+       __le32 pdev_id;
+       __le32 num_bcn_stats;
+       __le32 num_peer_stats_extd;
 } __packed;
 
 struct wmi_tlv_p2p_noa_ev {
index 52f1752e2065d631b4ef5758172275af8fe8ff66..98a90e49d666ccd54d1b087cfb31827bc0b43e6c 100644 (file)
@@ -8322,7 +8322,7 @@ ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
                        "Peer TX rate", peer->peer_tx_rate);
        len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
                        "Peer RX rate", peer->peer_rx_rate);
-       len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
+       len += scnprintf(buf + len, buf_len - len, "%30s %llu\n",
                        "Peer RX duration", peer->rx_duration);
 
        len += scnprintf(buf + len, buf_len - len, "\n");
index f6d3e76723d7bb3305c3d6b18ec0d553e2ace692..e1c40bb699328883e9c6fe05e3f9762f52484c81 100644 (file)
@@ -4534,6 +4534,13 @@ enum wmi_10_4_stats_id {
        WMI_10_4_STAT_VDEV_EXTD         = BIT(4),
 };
 
+enum wmi_tlv_stats_id {
+       WMI_TLV_STAT_PDEV       = BIT(0),
+       WMI_TLV_STAT_VDEV       = BIT(1),
+       WMI_TLV_STAT_PEER       = BIT(2),
+       WMI_TLV_STAT_PEER_EXTD  = BIT(10),
+};
+
 struct wlan_inst_rssi_args {
        __le16 cfg_retry_count;
        __le16 retry_count;