Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2631746pxy; Tue, 3 Aug 2021 10:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrdwhaw46k1kPQCeKP4h+TEJ+JILnDoxt3QiwF/ccbecspOsHvnsFNh1JVsN4z5WODk9do X-Received: by 2002:a92:4410:: with SMTP id r16mr177706ila.82.1628013568651; Tue, 03 Aug 2021 10:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628013568; cv=none; d=google.com; s=arc-20160816; b=lq1HS8lQWVIFRZfxQn0ipAfnucske+JAsdAeGxCZ4xIDdYaQ7arL4bBBR5W5GuwaAW uKaeL6QMoBFAT7YPpAdjvAb3MQrdBF83FDQJseIsfl7QvClsnvRObPGfNi7hGmbUuVPb rMFs9Bu6wam2KNlmDlXSqIUVzysfJzEVQeOwXNy2VKQz2GhPEDd1ZrtXszCEsbvTa9nr mTTLn7wNMaRxebrNymixeSzCkbQTQLpHN2FAbcYZYZh6nOjgJ+oflgHZcWvm95sJ5wwV I1UKusmKYb6vYLZxMVlguiFGl4r5hKsCOCW9KBqIQbG95qXz/pvNw5nqNDR7r8IdzSeQ xZcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Tdw0LBp8Rh5jr4aGmvRn7AE4LGCGrTl1BbqZQ65lHxA=; b=ggdEVQXqog2yooeYwgwwDVjPsQOiyFNPZiUpC8WDdNq3KqjFshkfPZg7tyUfd2QWcq GmNQhftT0WIujLDkQtTiGu96HBkG2eP5x9P9Y7Vp9zeMwfCGCtLMmxCGQ7Itk3z6cPxc zMks0wVui1JhCa8orx2z8o/a1XqQcxMj8LHECtYGmqfvMs2ZAwap/KF0TMvops4V6JC6 V727jcqTe72ZQ3g4/5Yjdp2fgZ7yWDZirqFP7OTb/owrALQEfc10SvfsoBPx9SulXrqE 9YWFgxttMleEdKharmK/v2jT2ZtUtk2a1gFT0bkiBUmEpdHmMO4WO/6f71DtDTunGl8v 9few== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si16387493ioq.16.2021.08.03.10.59.15; Tue, 03 Aug 2021 10:59:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233498AbhHCQhN (ORCPT + 99 others); Tue, 3 Aug 2021 12:37:13 -0400 Received: from mga02.intel.com ([134.134.136.20]:56666 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233449AbhHCQhM (ORCPT ); Tue, 3 Aug 2021 12:37:12 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10065"; a="200900149" X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="200900149" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 09:36:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,292,1620716400"; d="scan'208";a="636665141" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga005.jf.intel.com with ESMTP; 03 Aug 2021 09:36:48 -0700 Received: from alobakin-mobl.ger.corp.intel.com (eflejszm-mobl2.ger.corp.intel.com [10.213.26.164]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 173GahEo029968; Tue, 3 Aug 2021 17:36:44 +0100 From: Alexander Lobakin To: "David S. Miller" , Jakub Kicinski Cc: Alexander Lobakin , Jesse Brandeburg , Lukasz Czapnik , Marcin Kubiak , Michal Kubiak , Michal Swiatkowski , Jonathan Corbet , Netanel Belgazal , Arthur Kiyanovski , Guy Tzalik , Saeed Bishara , Ioana Ciornei , Claudiu Manoil , Thomas Petazzoni , Marcin Wojtas , Russell King , Edward Cree , Martin Habets , "Michael S. Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shay Agroskin , Sameeh Jubran , Alexander Duyck , Danielle Ratson , Ido Schimmel , Andrew Lunn , Vladyslav Tarasiuk , Arnd Bergmann , Andrew Morton , Jian Shen , Petr Vorel , Dan Murphy , Yangbo Lu , Michal Kubecek , Zheng Yongjun , Heiner Kallweit , YueHaibing , Johannes Berg , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Subject: [PATCH net-next 00/21] ethtool, stats: introduce and use standard XDP stats Date: Tue, 3 Aug 2021 18:36:20 +0200 Message-Id: <20210803163641.3743-1-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series follows the Jakub's work on standard statistics and unifies XDP statistics across [most of] the drivers. The only driver left unconverted is mlx5 -- it has rather complex statistics, so I believe it would be better to leave this up to its developers. The stats itself consists of 12 counters: - packets: number of frames passed to bpf_prog_run_xdp(); - errors: number of general XDP errors, if driver has one unified counter; - aborted: number of XDP_ABORTED returns; - drop: number of XDP_DROP returns; - invalid: number of returns of unallowed values (i.e. not XDP_*); - pass: number of XDP_PASS returns; - redirect: number of successfully performed XDP_REDIRECT requests; - redirect_errors: number of failed XDP_REDIRECT requests; - tx: number of successfully performed XDP_TX requests; - tx_errors: number of failed XDP_TX requests; - xmit: number of xdp_frames successfully transmitted via .ndo_xdp_xmit(); - xmit_drops: number of frames dropped from .ndo_xdp_xmit(). As most drivers stores them on a per-channel basis, Ethtool standard stats infra has been expanded to support this. A new nested attribute has been added which indicated that the fields enclosed in this block are related to one particular channel. If Ethtool utility is older than the kernel, those blocks will just be skipped with no errors. When the stats are not per-channel, Ethtool core treats them as regular and so does Ethtool utility display them. Otherwise, the example output looks like: $ ./ethtool -S enp175s0f0 --all-groups Standard stats for enp175s0f0: [ snip ] channel0-xdp-aborted: 1 channel0-xdp-drop: 2 channel0-xdp-illegal: 3 channel0-xdp-pass: 4 channel0-xdp-redirect: 5 [ snip ] ...and the JSON output looks like: [ snip ] "xdp": { "per-channel": [ "channel0": { "aborted": 1, "drop": 2, "illegal": 3, "pass": 4, "redirect": 5, [ snip ] } ] } [ snip ] Rouhly half of the commits are present to unify XDP stats logics across the drivers, and the first two are preparatory/housekeeping. This set is also available here: [0] [0] https://github.com/alobakin/linux/tree/xdp_stats Alexander Lobakin (21): ethtool, stats: use a shorthand pointer in stats_prepare_data() ethtool, stats: add compile-time checks for standard stats ethtool, stats: introduce standard XDP statistics ethernet, dpaa2: simplify per-channel Ethtool stats counting ethernet, dpaa2: convert to standard XDP stats ethernet, ena: constify src and syncp args of ena_safe_update_stat() ethernet, ena: convert to standard XDP stats ethernet, enetc: convert to standard XDP stats ethernet, mvneta: rename xdp_xmit_err to xdp_xmit_drops ethernet, mvneta: convert to standard XDP stats ethernet, mvpp2: rename xdp_xmit_err to xdp_xmit_drops ethernet, mvpp2: convert to standard XDP stats ethernet, sfc: convert to standard XDP stats veth: rename rx_drops to xdp_errors veth: rename xdp_xmit_errors to xdp_xmit_drops veth: rename drop xdp_ suffix from packets and bytes stats veth: convert to standard XDP stats virtio-net: rename xdp_tx{,__drops} SQ stats to xdp_xmit{,__drops} virtio-net: don't mix error-caused drops with XDP_DROP cases virtio-net: convert to standard XDP stats Documentation, ethtool-netlink: update standard statistics documentation Documentation/networking/ethtool-netlink.rst | 45 +++-- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 50 +++++- .../net/ethernet/freescale/dpaa2/dpaa2-eth.h | 7 +- .../ethernet/freescale/dpaa2/dpaa2-ethtool.c | 38 +++- .../ethernet/freescale/enetc/enetc_ethtool.c | 58 ++++-- drivers/net/ethernet/marvell/mvneta.c | 112 ++++++------ drivers/net/ethernet/marvell/mvpp2/mvpp2.h | 2 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 96 +++------- drivers/net/ethernet/sfc/ef100_ethtool.c | 2 + drivers/net/ethernet/sfc/ethtool.c | 2 + drivers/net/ethernet/sfc/ethtool_common.c | 35 +++- drivers/net/ethernet/sfc/ethtool_common.h | 3 + drivers/net/veth.c | 167 ++++++++++-------- drivers/net/virtio_net.c | 76 ++++++-- include/linux/ethtool.h | 36 ++++ include/uapi/linux/ethtool.h | 2 + include/uapi/linux/ethtool_netlink.h | 34 ++++ net/ethtool/netlink.h | 1 + net/ethtool/stats.c | 163 +++++++++++++++-- net/ethtool/strset.c | 5 + 20 files changed, 659 insertions(+), 275 deletions(-) -- 2.31.1