From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eelco Chaudron" Subject: Re: [PATCH iproute2/net-next] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics Date: Thu, 09 Aug 2018 18:56:32 +0200 Message-ID: References: <20180809151602.5951.21421.stgit@wsfd-netdev20.ntdv.lab.eng.bos.redhat.com> <20180809090723.3caf4b3f@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, davem@davemloft.net To: "Stephen Hemminger" Return-path: Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45692 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730839AbeHITWT (ORCPT ); Thu, 9 Aug 2018 15:22:19 -0400 In-Reply-To: <20180809090723.3caf4b3f@xeon-e3> Sender: netdev-owner@vger.kernel.org List-ID: Thanks for the quick reply, see inline responses. On 9 Aug 2018, at 18:07, Stephen Hemminger wrote: > On Thu, 9 Aug 2018 11:16:02 -0400 > Eelco Chaudron 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. > This is used to print separate SW counters below, which is not displayed if 0, i.e. not present. However I will move it under the “if (tbs[TCA_STATS_BASIC])” statement, so it’s more explicit. >> + struct gnet_stats_basic bs_hw = {0}; > > This initialization is unnecessary since you always overwrite it. > Thanks will remove it in the v2 >> + >> + 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. > Will do in the V2. >> + 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); >> +}