From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger 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 Message-ID: <20180809090723.3caf4b3f@xeon-e3> References: <20180809151602.5951.21421.stgit@wsfd-netdev20.ntdv.lab.eng.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, davem@davemloft.net To: Eelco Chaudron Return-path: Received: from mail-pg1-f195.google.com ([209.85.215.195]:39330 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731227AbeHISc7 (ORCPT ); Thu, 9 Aug 2018 14:32:59 -0400 Received: by mail-pg1-f195.google.com with SMTP id a11-v6so2960478pgw.6 for ; Thu, 09 Aug 2018 09:07:25 -0700 (PDT) In-Reply-To: <20180809151602.5951.21421.stgit@wsfd-netdev20.ntdv.lab.eng.bos.redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: 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. > + 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); > +}