blob: 630a68ce919d03f4cc21fe712b675ca578b96f7e [file] [log] [blame]
From ce9be27dcc763b3a9b399dfe8f62ee1c0fed9734 Mon Sep 17 00:00:00 2001
From: Shayne Chen <shayne.chen@mediatek.com>
Date: Fri, 4 Feb 2022 21:35:14 +0800
Subject: [PATCH 1111/1112] mt76: tool: add more commands
---
.../net/wireless/mediatek/mt76/tools/fields.c | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/tools/fields.c b/tools/fields.c
index e3f6908..036406c 100644
--- a/tools/fields.c
+++ b/tools/fields.c
@@ -10,6 +10,7 @@ static const char * const testmode_state[] = {
[MT76_TM_STATE_IDLE] = "idle",
[MT76_TM_STATE_TX_FRAMES] = "tx_frames",
[MT76_TM_STATE_RX_FRAMES] = "rx_frames",
+ [MT76_TM_STATE_TX_CONT] = "tx_cont",
};
static const char * const testmode_tx_mode[] = {
@@ -201,6 +202,63 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
printf("%srx_per=%.02f%%\n", prefix, 100 * failed / total);
}
+static bool parse_mac(const struct tm_field *field, int idx,
+ struct nl_msg *msg, const char *val)
+{
+#define ETH_ALEN 6
+ bool ret = true;
+ char *str, *cur, *ap;
+ void *a;
+
+ ap = str = strdup(val);
+
+ a = nla_nest_start(msg, idx);
+
+ idx = 0;
+ while ((cur = strsep(&ap, ",")) != NULL) {
+ unsigned char addr[ETH_ALEN];
+ char *val, *tmp = cur;
+ int i = 0;
+
+ while ((val = strsep(&tmp, ":")) != NULL) {
+ if (i >= ETH_ALEN)
+ break;
+
+ addr[i++] = strtoul(val, NULL, 16);
+ }
+
+ nla_put(msg, idx, ETH_ALEN, addr);
+
+ idx++;
+ }
+
+ nla_nest_end(msg, a);
+
+ free(str);
+
+ return ret;
+}
+
+static void print_mac(const struct tm_field *field, struct nlattr *attr)
+{
+#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
+#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
+ unsigned char addr[3][6];
+ struct nlattr *cur;
+ int idx = 0;
+ int rem;
+
+ nla_for_each_nested(cur, attr, rem) {
+ if (nla_len(cur) != 6)
+ continue;
+ memcpy(addr[idx++], nla_data(cur), 6);
+ }
+
+ printf("" MACSTR "," MACSTR "," MACSTR "",
+ MAC2STR(addr[0]), MAC2STR(addr[1]), MAC2STR(addr[2]));
+
+ return;
+}
#define FIELD_GENERIC(_field, _name, ...) \
[FIELD_NAME(_field)] = { \
@@ -250,6 +308,13 @@ static void print_extra_stats(const struct tm_field *field, struct nlattr **tb)
##__VA_ARGS__ \
)
+#define FIELD_MAC(_field, _name) \
+ [FIELD_NAME(_field)] = { \
+ .name = _name, \
+ .parse = parse_mac, \
+ .print = print_mac \
+ }
+
#define FIELD_NAME(_field) MT76_TM_RX_ATTR_##_field
static const struct tm_field rx_fields[NUM_MT76_TM_RX_ATTRS] = {
FIELD_RO(s32, FREQ_OFFSET, "freq_offset"),
@@ -300,10 +365,16 @@ static const struct tm_field testdata_fields[NUM_MT76_TM_ATTRS] = {
FIELD(u8, TX_RATE_LDPC, "tx_rate_ldpc"),
FIELD(u8, TX_RATE_STBC, "tx_rate_stbc"),
FIELD(u8, TX_LTF, "tx_ltf"),
+ FIELD(u8, TX_DUTY_CYCLE, "tx_duty_cycle"),
+ FIELD(u32, TX_IPG, "tx_ipg"),
+ FIELD(u32, TX_TIME, "tx_time"),
FIELD(u8, TX_POWER_CONTROL, "tx_power_control"),
FIELD_ARRAY(u8, TX_POWER, "tx_power"),
FIELD(u8, TX_ANTENNA, "tx_antenna"),
+ FIELD(u8, TX_SPE_IDX, "tx_spe_idx"),
FIELD(u32, FREQ_OFFSET, "freq_offset"),
+ FIELD(u8, AID, "aid"),
+ FIELD_MAC(MAC_ADDRS, "mac_addrs"),
FIELD_NESTED_RO(STATS, stats, "",
.print_extra = print_extra_stats),
};
@@ -322,9 +393,14 @@ static struct nla_policy testdata_policy[NUM_MT76_TM_ATTRS] = {
[MT76_TM_ATTR_TX_RATE_LDPC] = { .type = NLA_U8 },
[MT76_TM_ATTR_TX_RATE_STBC] = { .type = NLA_U8 },
[MT76_TM_ATTR_TX_LTF] = { .type = NLA_U8 },
+ [MT76_TM_ATTR_TX_DUTY_CYCLE] = { .type = NLA_U8 },
+ [MT76_TM_ATTR_TX_IPG] = { .type = NLA_U32 },
+ [MT76_TM_ATTR_TX_TIME] = { .type = NLA_U32 },
[MT76_TM_ATTR_TX_POWER_CONTROL] = { .type = NLA_U8 },
[MT76_TM_ATTR_TX_ANTENNA] = { .type = NLA_U8 },
+ [MT76_TM_ATTR_TX_SPE_IDX] = { .type = NLA_U8 },
[MT76_TM_ATTR_FREQ_OFFSET] = { .type = NLA_U32 },
+ [MT76_TM_ATTR_AID] = { .type = NLA_U8 },
[MT76_TM_ATTR_STATS] = { .type = NLA_NESTED },
};
--
2.25.1