All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
@ 2018-08-10 11:59 Eelco Chaudron
  2018-08-10 14:44 ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Eelco Chaudron @ 2018-08-10 11:59 UTC (permalink / raw)
  To: netdev; +Cc: davem, stephen

Add support for showing hardware specific counters to easy
troubleshooting hardware offload.

$ tc -s filter show dev enp3s0np0 parent ffff:
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 2.0.0.0
  src_ip 1.0.0.0
  ip_flags nofrag
  in_hw
        action order 1: mirred (Egress Redirect to device eth1) stolen
        index 1 ref 1 bind 1 installed 0 sec used 0 sec
        Action statistics:
        Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 requeues 0)
        Sent software 187542 bytes 4077 pkt
        Sent hardware 534697200 bytes 8911620 pkt
        backlog 0b 0p requeues 0
        cookie 89173e6a44447001becfd486bda17e29


Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
v2:
 * Removed unnecessary initialization
 * Made not displaying of missing TCA_STATS_BASIC_HW more obvious
 * Use _SL_ macro for single line output

 include/uapi/linux/gen_stats.h |    1 +
 tc/tc_util.c                   |   41 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/include/uapi/linux/gen_stats.h b/include/uapi/linux/gen_stats.h
index 24a861c..065408e 100644
--- a/include/uapi/linux/gen_stats.h
+++ b/include/uapi/linux/gen_stats.h
@@ -12,6 +12,7 @@ enum {
 	TCA_STATS_APP,
 	TCA_STATS_RATE_EST64,
 	TCA_STATS_PAD,
+	TCA_STATS_BASIC_HW,
 	__TCA_STATS_MAX,
 };
 #define TCA_STATS_MAX (__TCA_STATS_MAX - 1)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index d757852..5a1bbf2 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -800,6 +800,44 @@ void print_tm(FILE *f, const struct tcf_t *tm)
 	}
 }
 
+static void print_tcstats_basic_hw(struct rtattr **tbs, char *prefix)
+{
+	struct gnet_stats_basic bs_hw;
+
+	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]) {
+		struct gnet_stats_basic bs;
+
+		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, "%s", _SL_);
+			print_string(PRINT_FP, NULL, "%s", prefix);
+			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, "%s", _SL_);
+	print_string(PRINT_FP, NULL, "%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);
+}
+
 void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtattr **xstats)
 {
 	SPRINT_BUF(b1);
@@ -826,6 +864,9 @@ void print_tcstats2_attr(FILE *fp, struct rtattr *rta, char *prefix, struct rtat
 		print_uint(PRINT_ANY, "requeues", " requeues %u) ", q.requeues);
 	}
 
+	if (tbs[TCA_STATS_BASIC_HW])
+		print_tcstats_basic_hw(tbs, prefix);
+
 	if (tbs[TCA_STATS_RATE_EST64]) {
 		struct gnet_stats_rate_est64 re = {0};
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-08-10 11:59 [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics Eelco Chaudron
@ 2018-08-10 14:44 ` Stephen Hemminger
  2018-08-10 14:48   ` Eelco Chaudron
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-08-10 14:44 UTC (permalink / raw)
  To: Eelco Chaudron; +Cc: netdev, davem

On Fri, 10 Aug 2018 07:59:30 -0400
Eelco Chaudron <echaudro@redhat.com> wrote:

> +		if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
> +			print_string(PRINT_FP, NULL, "%s", _SL_);
> +			print_string(PRINT_FP, NULL, "%s", prefix);
> +			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, "%s", _SL_);
> +	print_string(PRINT_FP, NULL, "%s", prefix);
> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
> +		     bs_hw.bytes);

What does the output look like?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-08-10 14:44 ` Stephen Hemminger
@ 2018-08-10 14:48   ` Eelco Chaudron
  2018-10-01  7:08     ` Eelco Chaudron
  0 siblings, 1 reply; 8+ messages in thread
From: Eelco Chaudron @ 2018-08-10 14:48 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, davem



On 10 Aug 2018, at 16:44, Stephen Hemminger wrote:

> On Fri, 10 Aug 2018 07:59:30 -0400
> Eelco Chaudron <echaudro@redhat.com> wrote:
>
>> +		if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
>> +			print_string(PRINT_FP, NULL, "%s", _SL_);
>> +			print_string(PRINT_FP, NULL, "%s", prefix);
>> +			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, "%s", _SL_);
>> +	print_string(PRINT_FP, NULL, "%s", prefix);
>> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
>> +		     bs_hw.bytes);
>
> What does the output look like?

See the two +’es below:

$ tc -s filter show dev enp3s0np0 parent ffff:
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 2.0.0.0
  src_ip 1.0.0.0
  ip_flags nofrag
  in_hw
        action order 1: mirred (Egress Redirect to device eth1) stolen
        index 1 ref 1 bind 1 installed 0 sec used 0 sec
        Action statistics:
        Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 requeues 0)
+       Sent software 187542 bytes 4077 pkt
+       Sent hardware 534697200 bytes 8911620 pkt
        backlog 0b 0p requeues 0
        cookie 89173e6a44447001becfd486bda17e29

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-08-10 14:48   ` Eelco Chaudron
@ 2018-10-01  7:08     ` Eelco Chaudron
  2018-10-01  9:10       ` Stephen Hemminger
  0 siblings, 1 reply; 8+ messages in thread
From: Eelco Chaudron @ 2018-10-01  7:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, davem


On 10 Aug 2018, at 16:48, Eelco Chaudron wrote:

> On 10 Aug 2018, at 16:44, Stephen Hemminger wrote:
>
>> On Fri, 10 Aug 2018 07:59:30 -0400
>> Eelco Chaudron <echaudro@redhat.com> wrote:
>>
>>> +		if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
>>> +			print_string(PRINT_FP, NULL, "%s", _SL_);
>>> +			print_string(PRINT_FP, NULL, "%s", prefix);
>>> +			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, "%s", _SL_);
>>> +	print_string(PRINT_FP, NULL, "%s", prefix);
>>> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
>>> +		     bs_hw.bytes);
>>
>> What does the output look like?
>
> See the two +’es below:
>
> $ tc -s filter show dev enp3s0np0 parent ffff:
> filter protocol ip pref 1 flower chain 0
> filter protocol ip pref 1 flower chain 0 handle 0x1
>   eth_type ipv4
>   dst_ip 2.0.0.0
>   src_ip 1.0.0.0
>   ip_flags nofrag
>   in_hw
>         action order 1: mirred (Egress Redirect to device eth1) stolen
>         index 1 ref 1 bind 1 installed 0 sec used 0 sec
>         Action statistics:
>         Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 
> requeues 0)
> +       Sent software 187542 bytes 4077 pkt
> +       Sent hardware 534697200 bytes 8911620 pkt
>         backlog 0b 0p requeues 0
>         cookie 89173e6a44447001becfd486bda17e29

Hi Stephen, anything else required for this patch to be accepted?

FYI the kernel side of this patch has been excepted on net-next.

Cheers,

Eelco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-10-01  7:08     ` Eelco Chaudron
@ 2018-10-01  9:10       ` Stephen Hemminger
  2018-10-01 10:29         ` Eelco Chaudron
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Hemminger @ 2018-10-01  9:10 UTC (permalink / raw)
  To: Eelco Chaudron; +Cc: netdev, davem

On Mon, 01 Oct 2018 09:08:32 +0200
"Eelco Chaudron" <echaudro@redhat.com> wrote:

> On 10 Aug 2018, at 16:48, Eelco Chaudron wrote:
> 
> > On 10 Aug 2018, at 16:44, Stephen Hemminger wrote:
> >  
> >> On Fri, 10 Aug 2018 07:59:30 -0400
> >> Eelco Chaudron <echaudro@redhat.com> wrote:
> >>  
> >>> +		if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
> >>> +			print_string(PRINT_FP, NULL, "%s", _SL_);
> >>> +			print_string(PRINT_FP, NULL, "%s", prefix);
> >>> +			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, "%s", _SL_);
> >>> +	print_string(PRINT_FP, NULL, "%s", prefix);
> >>> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
> >>> +		     bs_hw.bytes);  
> >>
> >> What does the output look like?  
> >
> > See the two +’es below:
> >
> > $ tc -s filter show dev enp3s0np0 parent ffff:
> > filter protocol ip pref 1 flower chain 0
> > filter protocol ip pref 1 flower chain 0 handle 0x1
> >   eth_type ipv4
> >   dst_ip 2.0.0.0
> >   src_ip 1.0.0.0
> >   ip_flags nofrag
> >   in_hw
> >         action order 1: mirred (Egress Redirect to device eth1) stolen
> >         index 1 ref 1 bind 1 installed 0 sec used 0 sec
> >         Action statistics:
> >         Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0 
> > requeues 0)
> > +       Sent software 187542 bytes 4077 pkt
> > +       Sent hardware 534697200 bytes 8911620 pkt
> >         backlog 0b 0p requeues 0
> >         cookie 89173e6a44447001becfd486bda17e29  
> 
> Hi Stephen, anything else required for this patch to be accepted?
> 
> FYI the kernel side of this patch has been excepted on net-next.
> 
> Cheers,
> 
> Eelco

David Ahern handles net-next see patchwork
  https://patchwork.ozlabs.org/patch/956225/

I think he was just waiting for the kernel part to merge.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-10-01  9:10       ` Stephen Hemminger
@ 2018-10-01 10:29         ` Eelco Chaudron
  2018-10-01 15:12           ` David Ahern
  0 siblings, 1 reply; 8+ messages in thread
From: Eelco Chaudron @ 2018-10-01 10:29 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, davem



On 1 Oct 2018, at 11:10, Stephen Hemminger wrote:

> On Mon, 01 Oct 2018 09:08:32 +0200
> "Eelco Chaudron" <echaudro@redhat.com> wrote:
>
>> On 10 Aug 2018, at 16:48, Eelco Chaudron wrote:
>>
>>> On 10 Aug 2018, at 16:44, Stephen Hemminger wrote:
>>>
>>>> On Fri, 10 Aug 2018 07:59:30 -0400
>>>> Eelco Chaudron <echaudro@redhat.com> wrote:
>>>>
>>>>> +		if (bs.bytes >= bs_hw.bytes && bs.packets >= bs_hw.packets) {
>>>>> +			print_string(PRINT_FP, NULL, "%s", _SL_);
>>>>> +			print_string(PRINT_FP, NULL, "%s", prefix);
>>>>> +			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, "%s", _SL_);
>>>>> +	print_string(PRINT_FP, NULL, "%s", prefix);
>>>>> +	print_lluint(PRINT_ANY, "hw_bytes", "Sent hardware %llu bytes",
>>>>> +		     bs_hw.bytes);
>>>>
>>>> What does the output look like?
>>>
>>> See the two +’es below:
>>>
>>> $ tc -s filter show dev enp3s0np0 parent ffff:
>>> filter protocol ip pref 1 flower chain 0
>>> filter protocol ip pref 1 flower chain 0 handle 0x1
>>>   eth_type ipv4
>>>   dst_ip 2.0.0.0
>>>   src_ip 1.0.0.0
>>>   ip_flags nofrag
>>>   in_hw
>>>         action order 1: mirred (Egress Redirect to device eth1) stolen
>>>         index 1 ref 1 bind 1 installed 0 sec used 0 sec
>>>         Action statistics:
>>>         Sent 534884742 bytes 8915697 pkt (dropped 0, overlimits 0
>>> requeues 0)
>>> +       Sent software 187542 bytes 4077 pkt
>>> +       Sent hardware 534697200 bytes 8911620 pkt
>>>         backlog 0b 0p requeues 0
>>>         cookie 89173e6a44447001becfd486bda17e29
>>
>> Hi Stephen, anything else required for this patch to be accepted?
>>
>> FYI the kernel side of this patch has been excepted on net-next.
>>
>> Cheers,
>>
>> Eelco
>
> David Ahern handles net-next see patchwork
>   https://patchwork.ozlabs.org/patch/956225/
>
> I think he was just waiting for the kernel part to merge.

Thanks for making me aware of the patchwork for iproute.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-10-01 10:29         ` Eelco Chaudron
@ 2018-10-01 15:12           ` David Ahern
  2018-10-02  7:28             ` Eelco Chaudron
  0 siblings, 1 reply; 8+ messages in thread
From: David Ahern @ 2018-10-01 15:12 UTC (permalink / raw)
  To: Eelco Chaudron, Stephen Hemminger; +Cc: netdev, davem

On 10/1/18 4:29 AM, Eelco Chaudron wrote:
>>> Hi Stephen, anything else required for this patch to be accepted?
>>>
>>> FYI the kernel side of this patch has been excepted on net-next.
>>>
>>> Cheers,
>>>
>>> Eelco
>>
>> David Ahern handles net-next see patchwork
>>   https://patchwork.ozlabs.org/patch/956225/
>>
>> I think he was just waiting for the kernel part to merge.
> 
> Thanks for making me aware of the patchwork for iproute.
> 

Now that the kernel side is in, please re-send the iproute2 patches.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics
  2018-10-01 15:12           ` David Ahern
@ 2018-10-02  7:28             ` Eelco Chaudron
  0 siblings, 0 replies; 8+ messages in thread
From: Eelco Chaudron @ 2018-10-02  7:28 UTC (permalink / raw)
  To: David Ahern; +Cc: Stephen Hemminger, netdev, davem



On 1 Oct 2018, at 17:12, David Ahern wrote:

> On 10/1/18 4:29 AM, Eelco Chaudron wrote:
>>>> Hi Stephen, anything else required for this patch to be accepted?
>>>>
>>>> FYI the kernel side of this patch has been excepted on net-next.
>>>>
>>>> Cheers,
>>>>
>>>> Eelco
>>>
>>> David Ahern handles net-next see patchwork
>>>   https://patchwork.ozlabs.org/patch/956225/
>>>
>>> I think he was just waiting for the kernel part to merge.
>>
>> Thanks for making me aware of the patchwork for iproute.
>>
>
> Now that the kernel side is in, please re-send the iproute2 patches.

Rebased the patch on the latest iproute2-next and sent a v3.

//Eelco

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-02 14:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10 11:59 [PATCH iproute2/net-next v2] tc_util: Add support for showing TCA_STATS_BASIC_HW statistics Eelco Chaudron
2018-08-10 14:44 ` Stephen Hemminger
2018-08-10 14:48   ` Eelco Chaudron
2018-10-01  7:08     ` Eelco Chaudron
2018-10-01  9:10       ` Stephen Hemminger
2018-10-01 10:29         ` Eelco Chaudron
2018-10-01 15:12           ` David Ahern
2018-10-02  7:28             ` Eelco Chaudron

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.