Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757401AbeAIBqO (ORCPT + 1 other); Mon, 8 Jan 2018 20:46:14 -0500 Received: from mx4.wp.pl ([212.77.101.11]:7255 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750864AbeAIBqL (ORCPT ); Mon, 8 Jan 2018 20:46:11 -0500 Date: Mon, 8 Jan 2018 17:46:02 -0800 From: Jakub Kicinski To: David Miller Cc: lipeng321@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, salil.mehta@huawei.com Subject: Re: [PATCH net-next 12/20] net: hns3: Add packet statistics of netdev Message-ID: <20180108174602.34bee66b@cakuba.netronome.com> In-Reply-To: <20180108.203913.1283013651432416478.davem@davemloft.net> References: <1515147504-86802-1-git-send-email-lipeng321@huawei.com> <1515147504-86802-13-git-send-email-lipeng321@huawei.com> <20180108120431.1e4b45e1@cakuba.netronome.com> <20180108.203913.1283013651432416478.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-WP-MailID: 779440bc618050bb27ce482da5b01511 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 000000A [EROU] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, 08 Jan 2018 20:39:13 -0500 (EST), David Miller wrote: > From: Jakub Kicinski > Date: Mon, 8 Jan 2018 12:04:31 -0800 > > > Ugh, I so didn't review this in time :( I think there is a consensus > > that we should avoid duplicating standard stats in ethtool. Especially > > those old ones. Like "collisions", I assume this is a modern NIC, are > > collisions still a thing? > > There is no standard way to get per-queue values, and ethtool stats are > how pretty much every driver provides it. Right, agreed. I'm only objecting to this patch (12/20), where we can see the telltale code like this: + const struct rtnl_link_stats64 *net_stats; + struct rtnl_link_stats64 temp; + + net_stats = dev_get_stats(netdev, &temp); + for (i = 0; i < HNS3_NETDEV_STATS_COUNT; i++) { + stat = (u8 *)net_stats + hns3_netdev_stats[i].stats_offset; + *data++ = *(u64 *)stat; + } Where: +#define HNS3_NETDEV_STAT(_string, _member) { \ + .stats_string = _string, \ + .stats_offset = offsetof(struct rtnl_link_stats64, _member) \ +} + +static const struct hns3_stats hns3_netdev_stats[] = { + /* Rx per-queue statistics */ + HNS3_NETDEV_STAT("rx_packets", rx_packets), + HNS3_NETDEV_STAT("tx_packets", tx_packets), etc. IOW dumping struct rtnl_link_stats64 to ethtool -S member by member. Let me put the netlink per-queue stats on my soft TODO list :)