From: Stephen Hemminger <stephen@networkplumber.org>
To: Eelco Chaudron <echaudro@redhat.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH iproute2/net-next] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
Date: Thu, 9 Aug 2018 09:07:23 -0700 [thread overview]
Message-ID: <20180809090723.3caf4b3f@xeon-e3> (raw)
In-Reply-To: <20180809151602.5951.21421.stgit@wsfd-netdev20.ntdv.lab.eng.bos.redhat.com>
On Thu, 9 Aug 2018 11:16:02 -0400
Eelco Chaudron <echaudro@redhat.com> wrote:
>
> +static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)
> +{
> + struct gnet_stats_basic bs = {0};
If not present don't print it rather than printing zero.
> + struct gnet_stats_basic bs_hw = {0};
This initialization is unnecessary since you always overwrite it.
> +
> + if (!tbs[TCA_STATS_BASIC_HW])
> + return;
> +
> + memcpy(&bs_hw, RTA_DATA(tbs[TCA_STATS_BASIC_HW]),
> + MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC_HW]), sizeof(bs_hw)));
> +
> + if (bs_hw.bytes == 0 && bs_hw.packets == 0)
> + return;
> +
> + if (tbs[TCA_STATS_BASIC]) {
> + memcpy(&bs, RTA_DATA(tbs[TCA_STATS_BASIC]),
> + MIN(RTA_PAYLOAD(tbs[TCA_STATS_BASIC]),
> + sizeof(bs)));
> + }
> +
> + if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
> + print_string(PRINT_FP, NULL, "\n%s", prefix);
Please use the magic string _SL_ to allow supporting single line output mode.
> + print_lluint(PRINT_ANY, "sw_bytes",
> + "Sent software %llu bytes",
> + bs.bytes - bs_hw.bytes);
> + print_uint(PRINT_ANY, "sw_packets", " %u pkt",
> + bs.packets - bs_hw.packets);
> + }
> +
> + print_string(PRINT_FP, NULL, "\n%s", prefix);
> + print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
> + bs_hw.bytes);
> + print_uint(PRINT_ANY, "hw_packets", " %u pkt", bs_hw.packets);
> +}
next prev parent reply other threads:[~2018-08-09 18:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 15:16 [PATCH iproute2/net-next] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics Eelco Chaudron
2018-08-09 16:07 ` Stephen Hemminger [this message]
2018-08-09 16:56 ` Eelco Chaudron
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=20180809090723.3caf4b3f@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=echaudro@redhat.com \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).