[PATCH 12/17] staging: wfx: show counters of all interfaces

From: Jerome Pouiller
Date: Mon Apr 27 2020 - 09:41:39 EST


From: JÃrÃme Pouiller <jerome.pouiller@xxxxxxxxxx>

The device keep up to date three series of stats. One for each
virtual interface and one for the whole device.

Until to now, the stats for the whole device were unavailable. Moreover,
it is interesting to retrieve counters for all interfaces even if they
are not awake.

Change the counters available in debugfs in order to retrieve stats
from all interfaces.

Signed-off-by: JÃrÃme Pouiller <jerome.pouiller@xxxxxxxxxx>
---
drivers/staging/wfx/debug.c | 25 ++++++++++++++++---------
drivers/staging/wfx/hif_tx_mib.c | 6 +++---
drivers/staging/wfx/hif_tx_mib.h | 2 +-
3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c
index 1164aba118a1..4dc4f6a0b92b 100644
--- a/drivers/staging/wfx/debug.c
+++ b/drivers/staging/wfx/debug.c
@@ -61,19 +61,26 @@ const char *get_reg_name(unsigned long id)

static int wfx_counters_show(struct seq_file *seq, void *v)
{
- int ret;
+ int ret, i;
struct wfx_dev *wdev = seq->private;
- struct hif_mib_extended_count_table counters;
+ struct hif_mib_extended_count_table counters[3];

- ret = hif_get_counters_table(wdev, &counters);
- if (ret < 0)
- return ret;
- if (ret > 0)
- return -EIO;
+ for (i = 0; i < ARRAY_SIZE(counters); i++) {
+ ret = hif_get_counters_table(wdev, i, counters + i);
+ if (ret < 0)
+ return ret;
+ if (ret > 0)
+ return -EIO;
+ }
+
+ seq_printf(seq, "%-24s %12s %12s %12s\n",
+ "", "global", "iface 0", "iface 1");

#define PUT_COUNTER(name) \
- seq_printf(seq, "%24s %d\n", #name ":",\
- le32_to_cpu(counters.count_##name))
+ seq_printf(seq, "%-24s %12d %12d %12d\n", #name, \
+ le32_to_cpu(counters[2].count_##name), \
+ le32_to_cpu(counters[0].count_##name), \
+ le32_to_cpu(counters[1].count_##name))

PUT_COUNTER(tx_packets);
PUT_COUNTER(tx_multicast_frames);
diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c
index 16f4908055af..6fdde5a4c9a1 100644
--- a/drivers/staging/wfx/hif_tx_mib.c
+++ b/drivers/staging/wfx/hif_tx_mib.c
@@ -64,16 +64,16 @@ int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif,
HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg));
}

-int hif_get_counters_table(struct wfx_dev *wdev,
+int hif_get_counters_table(struct wfx_dev *wdev, int vif_id,
struct hif_mib_extended_count_table *arg)
{
if (wfx_api_older_than(wdev, 1, 3)) {
// extended_count_table is wider than count_table
memset(arg, 0xFF, sizeof(*arg));
- return hif_read_mib(wdev, 0, HIF_MIB_ID_COUNTERS_TABLE,
+ return hif_read_mib(wdev, vif_id, HIF_MIB_ID_COUNTERS_TABLE,
arg, sizeof(struct hif_mib_count_table));
} else {
- return hif_read_mib(wdev, 0,
+ return hif_read_mib(wdev, vif_id,
HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, arg,
sizeof(struct hif_mib_extended_count_table));
}
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index bb7c104a03d8..b72770a4ba12 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -20,7 +20,7 @@ int hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
unsigned int listen_interval);
int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif,
int rssi_thold, int rssi_hyst);
-int hif_get_counters_table(struct wfx_dev *wdev,
+int hif_get_counters_table(struct wfx_dev *wdev, int vif_id,
struct hif_mib_extended_count_table *arg);
int hif_set_macaddr(struct wfx_vif *wvif, u8 *mac);
int hif_set_rx_filter(struct wfx_vif *wvif,
--
2.26.1