From: Jiri Pirko <jiri@resnulli.us>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org, stephen@networkplumber.org, mlxsw@mellanox.com
Subject: Re: [patch iproute2/net-next v2] tc: m_action: introduce support for hw stats type
Date: Wed, 11 Mar 2020 08:47:08 +0100 [thread overview]
Message-ID: <20200311074708.GA2209@nanopsycho> (raw)
In-Reply-To: <1a44786f-bffd-213f-fe13-ca43845c5420@gmail.com>
Wed, Mar 11, 2020 at 12:44:42AM CET, dsahern@gmail.com wrote:
>On 3/9/20 9:54 AM, Jiri Pirko wrote:
>> @@ -24,6 +25,27 @@ enum {
>> * actions stats.
>> */
>>
>> +/* tca HW stats type
>> + * When user does not pass the attribute, he does not care.
>> + * It is the same as if he would pass the attribute with
>> + * all supported bits set.
>> + * In case no bits are set, user is not interested in getting any HW statistics.
>> + */
>> +#define TCA_ACT_HW_STATS_TYPE_IMMEDIATE (1 << 0) /* Means that in dump, user
>> + * gets the current HW stats
>> + * state from the device
>> + * queried at the dump time.
>> + */
>> +#define TCA_ACT_HW_STATS_TYPE_DELAYED (1 << 1) /* Means that in dump, user gets
>
>really long names for attributes.
>
>
>> +static void print_hw_stats(const struct rtattr *arg)
>> +{
>> + struct nla_bitfield32 *hw_stats_type_bf = RTA_DATA(arg);
>> + __u8 hw_stats_type;
>> + int i;
>> +
>> + hw_stats_type = hw_stats_type_bf->value & hw_stats_type_bf->selector;
>> + print_string(PRINT_FP, NULL, "\t", NULL);
>> + open_json_array(PRINT_ANY, "hw_stats");
>> +
>> + for (i = 0; i < ARRAY_SIZE(hw_stats_type_items); i++) {
>> + const struct hw_stats_type_item *item;
>> +
>> + item = &hw_stats_type_items[i];
>> + if ((!hw_stats_type && !item->type) ||
>> + hw_stats_type & item->type)
>> + print_string(PRINT_ANY, NULL, " %s", item->str);
>
>the stats type can be both delayed and immediate?
Yes, if offloaded to 2 drivers, each supporting different stats.
>
>> + }
>> + close_json_array(PRINT_JSON, NULL);
>> +}
>> +
>> +static int parse_hw_stats(const char *str, struct nlmsghdr *n)
>> +{
>> + int i;
>> +
>> + for (i = 0; i < ARRAY_SIZE(hw_stats_type_items); i++) {
>> + const struct hw_stats_type_item *item;
>> +
>> + item = &hw_stats_type_items[i];
>> + if (matches(str, item->str) == 0) {
>> + struct nla_bitfield32 hw_stats_type_bf =
>> + { item->type,
>> + item->type };
>> + addattr_l(n, MAX_MSG, TCA_ACT_HW_STATS_TYPE,
>> + &hw_stats_type_bf, sizeof(hw_stats_type_bf));
>
>that is not human friendly. how about something like:
>
> struct nla_bitfield32 hw_stats_type_bf = {
> .value = item->type,
> .selector = item->type
> };
Okay.
>
>with a line between the declaration and code.
>
>and "disabled" corresponds to 0 which does not align with a
>TCA_ACT_HW_STATS_TYPE_ so why send it
It is a bitfield. So 0 means no bit is set, therefore disabled.
prev parent reply other threads:[~2020-03-11 7:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 15:54 [patch iproute2/net-next v2] tc: m_action: introduce support for hw stats type Jiri Pirko
2020-03-10 23:44 ` David Ahern
2020-03-11 7:47 ` Jiri Pirko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200311074708.GA2209@nanopsycho \
--to=jiri@resnulli.us \
--cc=dsahern@gmail.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.