tc: m_action: rename hw stats type uAPI

Follow the kernel rename to shorten the identifiers.
Rename hw_stats_type to hw_stats.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
Jakub Kicinski 2020-03-20 13:21:45 -07:00 committed by David Ahern
parent 1ff1edb6d5
commit 1c74c20cbe
1 changed files with 19 additions and 20 deletions

View File

@ -150,31 +150,30 @@ new_cmd(char **argv)
(matches(*argv, "add") == 0); (matches(*argv, "add") == 0);
} }
static const struct hw_stats_type_item { static const struct hw_stats_item {
const char *str; const char *str;
__u8 type; __u8 type;
} hw_stats_type_items[] = { } hw_stats_items[] = {
{ "immediate", TCA_ACT_HW_STATS_TYPE_IMMEDIATE }, { "immediate", TCA_ACT_HW_STATS_IMMEDIATE },
{ "delayed", TCA_ACT_HW_STATS_TYPE_DELAYED }, { "delayed", TCA_ACT_HW_STATS_DELAYED },
{ "disabled", 0 }, /* no bit set */ { "disabled", 0 }, /* no bit set */
}; };
static void print_hw_stats(const struct rtattr *arg) static void print_hw_stats(const struct rtattr *arg)
{ {
struct nla_bitfield32 *hw_stats_type_bf = RTA_DATA(arg); struct nla_bitfield32 *hw_stats_bf = RTA_DATA(arg);
__u8 hw_stats_type; __u8 hw_stats;
int i; int i;
hw_stats_type = hw_stats_type_bf->value & hw_stats_type_bf->selector; hw_stats = hw_stats_bf->value & hw_stats_bf->selector;
print_string(PRINT_FP, NULL, "\t", NULL); print_string(PRINT_FP, NULL, "\t", NULL);
open_json_array(PRINT_ANY, "hw_stats"); open_json_array(PRINT_ANY, "hw_stats");
for (i = 0; i < ARRAY_SIZE(hw_stats_type_items); i++) { for (i = 0; i < ARRAY_SIZE(hw_stats_items); i++) {
const struct hw_stats_type_item *item; const struct hw_stats_item *item;
item = &hw_stats_type_items[i]; item = &hw_stats_items[i];
if ((!hw_stats_type && !item->type) || if ((!hw_stats && !item->type) || hw_stats & item->type)
hw_stats_type & item->type)
print_string(PRINT_ANY, NULL, " %s", item->str); print_string(PRINT_ANY, NULL, " %s", item->str);
} }
close_json_array(PRINT_JSON, NULL); close_json_array(PRINT_JSON, NULL);
@ -184,18 +183,18 @@ static int parse_hw_stats(const char *str, struct nlmsghdr *n)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(hw_stats_type_items); i++) { for (i = 0; i < ARRAY_SIZE(hw_stats_items); i++) {
const struct hw_stats_type_item *item; const struct hw_stats_item *item;
item = &hw_stats_type_items[i]; item = &hw_stats_items[i];
if (matches(str, item->str) == 0) { if (matches(str, item->str) == 0) {
struct nla_bitfield32 hw_stats_type_bf = { struct nla_bitfield32 hw_stats_bf = {
.value = item->type, .value = item->type,
.selector = item->type .selector = item->type
}; };
addattr_l(n, MAX_MSG, TCA_ACT_HW_STATS_TYPE, addattr_l(n, MAX_MSG, TCA_ACT_HW_STATS,
&hw_stats_type_bf, sizeof(hw_stats_type_bf)); &hw_stats_bf, sizeof(hw_stats_bf));
return 0; return 0;
} }
@ -399,8 +398,8 @@ static int tc_print_one_action(FILE *f, struct rtattr *arg)
TCA_ACT_FLAGS_NO_PERCPU_STATS); TCA_ACT_FLAGS_NO_PERCPU_STATS);
print_string(PRINT_FP, NULL, "%s", _SL_); print_string(PRINT_FP, NULL, "%s", _SL_);
} }
if (tb[TCA_ACT_HW_STATS_TYPE]) if (tb[TCA_ACT_HW_STATS])
print_hw_stats(tb[TCA_ACT_HW_STATS_TYPE]); print_hw_stats(tb[TCA_ACT_HW_STATS]);
return 0; return 0;
} }