From patchwork Wed Nov 30 13:28:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 27797 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp927594wrr; Wed, 30 Nov 2022 05:35:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf6oSBsmuqOx5AtUTDPp9tPqNNA6sXXCEnqDqfbHkNobysuIvPyqrYRRFrsI2eexTDBdiDIv X-Received: by 2002:a17:902:ef8e:b0:189:6793:644e with SMTP id iz14-20020a170902ef8e00b001896793644emr26994997plb.55.1669815350158; Wed, 30 Nov 2022 05:35:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815350; cv=none; d=google.com; s=arc-20160816; b=cZRKtwyIiS4oMaQgfsO3E7HeAzbZekU8la1vznZHocVyUpYwFoibjIpdmsrBNqxq21 ObXJg0XtfKJCAmlMQTXvEyDEDrjuJOaNVuWMttwAK7s8TjCeUWQn1nmEFZticeDFPIhm QiP6E6em0NXewYD9Ub4+0sApr+HNczZupKCknG5INg3Mn0hj+gbF8o7FSErlApROuBbq 2iYC145kVmSln0xMtiWhve2p9JZ35IwMaEouh7kfmyWT47S0zKwMDSsYk8n0uHhfYkTZ tr1QHmHqDUV3GbJ3VOIZ3zLCbmRg8/rNdnlCWLTvje2S8Sn2pplUnriJ1kbLmujHBY4s 0kGQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D/vSeSdwlsuAyGy7/zaKmfNmlu08tkKoT9SamBW+fqs=; b=KmgCJDWtFVmgyjoL7HAF2ssm5PQE/A2QBcrAazyD//L6NZwPo7YT2QPvL9HZWvuheR h+3Vy/D9O34upi+p05urEf+Pft9TgPdFskh5MjZVFyluLfTdUsvyOH85gbCZHxntUDuq MuHPX4qViILO0qpQA29w7TIzCscgfWlppoq6wJ/BKEoAGOYR7/3K1WjuEV810QzEyEo4 9IvJ77YAvkGBdwCmCRezF+rQqxcLQ7O7RHMGJRhVzWmo4nNvDQx/HsOgXS4UNv96mr4K KHYiOEn1ot5aWQetK+hMgPSHqU7PoN159qNnoCA6qH8CudJwj4WbYai9OLPJTSItBgY8 YGnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Kl+iITf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056a00199500b00574694c97c7si1692061pfl.300.2022.11.30.05.35.36; Wed, 30 Nov 2022 05:35:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Kl+iITf3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbiK3N3x (ORCPT + 99 others); Wed, 30 Nov 2022 08:29:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234022AbiK3N3s (ORCPT ); Wed, 30 Nov 2022 08:29:48 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0BB366C9A; Wed, 30 Nov 2022 05:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669814987; x=1701350987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D8xEpmhqSV+pyWd3PBzu+0gtBcOl/hTNlpWkQLkNN3c=; b=Kl+iITf3EJ9UkZCqezdIVV8e29ph3bojYC7qn4Uit4x6gBh9U2Ahk7hg 9hQhIiECgo802dGOk1Ssx9UB4xcBVjCOFJhE3+gFcnnYOAv/3mwaepuxf UG8vZMunv+yMXrnsytWZCU64N7Im9iWDPh7XJhklxxM5p/9S1jHflNED3 pwduSJbGKUGXdmVU5Jb0eY6Ius+ShxfVlHQaEQuehNI9B+r+pMGNxjzs6 1j0oHQQi426tGfHdy45BgMfNC6GgJ36Pjt65qQLJ2mjnl4SDM+GGZVxJK I2Wt2oH51CyTovjxHOpo4Oesoug5odOQt1DWu1OjLYvWoCAUmo437nzMM Q==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="202016568" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 06:29:47 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 06:29:46 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 06:29:43 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [RFC Patch net-next 1/5] net: dsa: microchip: add rmon grouping for ethtool statistics Date: Wed, 30 Nov 2022 18:58:58 +0530 Message-ID: <20221130132902.2984580-2-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> References: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750928300691417869?= X-GMAIL-MSGID: =?utf-8?q?1750928300691417869?= Add support for ethtool standard device statistics grouping. Support rmon statistics grouping using rmon groups parameter in ethtool command. rmon provides packet size based range grouping. Common mib parameters are used across all KSZ series swtches for packet size statistics, except for KSZ8830. KSZ series have mib counters for packets with size: - less than 64 Bytes, - 65 to 127 Bytes, - 128 to 255 Bytes, - 256 to 511 Bytes, - 512 to 1023 Bytes, - 1024 to 1522 Bytes, - 1523 to 2000 Bytes and - More than 2001 Bytes KSZ8830 have mib counters upto 1024-1522 range only. Since no other change, common range used across all KSZ series, but used upto only upto 1024-1522 for KSZ8830. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz_common.c | 15 ++ drivers/net/dsa/microchip/ksz_common.h | 3 + drivers/net/dsa/microchip/ksz_ethtool.c | 178 ++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 18 +++ 5 files changed, 215 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz_ethtool.c create mode 100644 drivers/net/dsa/microchip/ksz_ethtool.h diff --git a/drivers/net/dsa/microchip/Makefile b/drivers/net/dsa/microchip/Makefile index 28873559efc2..413a706a47fb 100644 --- a/drivers/net/dsa/microchip/Makefile +++ b/drivers/net/dsa/microchip/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_switch.o ksz_switch-objs := ksz_common.o +ksz_switch-objs += ksz_ethtool.o ksz_switch-objs += ksz9477.o ksz_switch-objs += ksz8795.o ksz_switch-objs += lan937x_main.o diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 8c8db315317d..7a9d7ef818a7 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -24,6 +24,7 @@ #include #include "ksz_common.h" +#include "ksz_ethtool.h" #include "ksz8.h" #include "ksz9477.h" #include "lan937x.h" @@ -157,6 +158,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .r_mib_pkt = ksz8_r_mib_pkt, .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, + .get_rmon_stats = ksz8_get_rmon_stats, .fdb_dump = ksz8_fdb_dump, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, @@ -194,6 +196,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, + .get_rmon_stats = ksz9477_get_rmon_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -230,6 +233,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .r_mib_stat64 = ksz_r_mib_stats64, .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, + .get_rmon_stats = ksz9477_get_rmon_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -1609,6 +1613,16 @@ static void ksz_get_pause_stats(struct dsa_switch *ds, int port, spin_unlock(&mib->stats64_lock); } +static void ksz_get_rmon_stats(struct dsa_switch *ds, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct ksz_device *dev = ds->priv; + + if (dev->dev_ops->get_rmon_stats) + dev->dev_ops->get_rmon_stats(dev, port, rmon_stats, ranges); +} + static void ksz_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *buf) { @@ -2859,6 +2873,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .port_mirror_del = ksz_port_mirror_del, .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, + .get_rmon_stats = ksz_get_rmon_stats, .port_change_mtu = ksz_change_mtu, .port_max_mtu = ksz_max_mtu, }; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index c6726cbd5465..ad6d196d2927 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -339,6 +339,9 @@ struct ksz_dev_ops { int (*reset)(struct ksz_device *dev); int (*init)(struct ksz_device *dev); void (*exit)(struct ksz_device *dev); + void (*get_rmon_stats)(struct ksz_device *dev, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); diff --git a/drivers/net/dsa/microchip/ksz_ethtool.c b/drivers/net/dsa/microchip/ksz_ethtool.c new file mode 100644 index 000000000000..7e1f1b4d1e98 --- /dev/null +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Microchip KSZ series ethtool statistics + * + * Copyright (C) 2022 Microchip Technology Inc. + */ + +#include "ksz_common.h" +#include "ksz_ethtool.h" + +enum ksz8_mib_entry { + ksz8_rx, + ksz8_rx_hi, + ksz8_rx_undersize, + ksz8_rx_fragments, + ksz8_rx_oversize, + ksz8_rx_jabbers, + ksz8_rx_symbol_err, + ksz8_rx_crc_err, + ksz8_rx_align_err, + ksz8_rx_mac_ctrl, + ksz8_rx_pause, + ksz8_rx_bcast, + ksz8_rx_mcast, + ksz8_rx_ucast, + ksz8_rx_64_or_less, + ksz8_rx_65_127, + ksz8_rx_128_255, + ksz8_rx_256_511, + ksz8_rx_512_1023, + ksz8_rx_1024_1522, + ksz8_tx, + ksz8_tx_hi, + ksz8_tx_late_col, + ksz8_tx_pause, + ksz8_tx_bcast, + ksz8_tx_mcast, + ksz8_tx_ucast, + ksz8_tx_deferred, + ksz8_tx_total_col, + ksz8_tx_exc_col, + ksz8_tx_single_col, + ksz8_tx_mult_col, + ksz8_rx_discards = 0x100, + ksz8_tx_discards, +}; + +enum ksz9477_mib_entry { + ksz9477_rx_hi, + ksz9477_rx_undersize, + ksz9477_rx_fragments, + ksz9477_rx_oversize, + ksz9477_rx_jabbers, + ksz9477_rx_symbol_err, + ksz9477_rx_crc_err, + ksz9477_rx_align_err, + ksz9477_rx_mac_ctrl, + ksz9477_rx_pause, + ksz9477_rx_bcast, + ksz9477_rx_mcast, + ksz9477_rx_ucast, + ksz9477_rx_64_or_less, + ksz9477_rx_65_127, + ksz9477_rx_128_255, + ksz9477_rx_256_511, + ksz9477_rx_512_1023, + ksz9477_rx_1024_1522, + ksz9477_rx_1523_2000, + ksz9477_rx_2001, + ksz9477_tx_hi, + ksz9477_tx_late_col, + ksz9477_tx_pause, + ksz9477_tx_bcast, + ksz9477_tx_mcast, + ksz9477_tx_ucast, + ksz9477_tx_deferred, + ksz9477_tx_total_col, + ksz9477_tx_exc_col, + ksz9477_tx_single_col, + ksz9477_tx_mult_col, + ksz9477_rx_total = 0x80, + ksz9477_tx_total, + ksz9477_rx_discards, + ksz9477_tx_discards, +}; + +static const struct ethtool_rmon_hist_range ksz_rmon_ranges[] = { + { 0, 64 }, + { 65, 127 }, + { 128, 255 }, + { 256, 511 }, + { 512, 1023 }, + { 1024, 1522 }, + { 1523, 2000 }, + { 2001, 9000 }, + {} +}; + +#define KSZ8_HIST_LEN 6 +#define KSZ9477_HIST_LEN 8 + +void ksz8_get_rmon_stats(struct ksz_device *dev, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct ksz_port_mib *mib; + u64 *cnt; + u8 i; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz8_rx_undersize]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_undersize, NULL, cnt); + rmon_stats->undersize_pkts = *cnt; + + cnt = &mib->counters[ksz8_rx_oversize]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_oversize, NULL, cnt); + rmon_stats->oversize_pkts = *cnt; + + cnt = &mib->counters[ksz8_rx_fragments]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_fragments, NULL, cnt); + rmon_stats->fragments = *cnt; + + cnt = &mib->counters[ksz8_rx_jabbers]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_jabbers, NULL, cnt); + rmon_stats->jabbers = *cnt; + + for (i = 0; i < KSZ8_HIST_LEN; i++) { + cnt = &mib->counters[ksz8_rx_64_or_less + i]; + dev->dev_ops->r_mib_pkt(dev, port, (ksz8_rx_64_or_less + i), NULL, cnt); + rmon_stats->hist[i] = *cnt; + } + + mutex_unlock(&mib->cnt_mutex); + + *ranges = ksz_rmon_ranges; +} + +void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges) +{ + struct ksz_port_mib *mib; + u64 *cnt; + u8 i; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz9477_rx_undersize]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_undersize, NULL, cnt); + rmon_stats->undersize_pkts = *cnt; + + cnt = &mib->counters[ksz9477_rx_oversize]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_oversize, NULL, cnt); + rmon_stats->oversize_pkts = *cnt; + + cnt = &mib->counters[ksz9477_rx_fragments]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_fragments, NULL, cnt); + rmon_stats->fragments = *cnt; + + cnt = &mib->counters[ksz9477_rx_jabbers]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_jabbers, NULL, cnt); + rmon_stats->jabbers = *cnt; + + for (i = 0; i < KSZ9477_HIST_LEN; i++) { + cnt = &mib->counters[ksz9477_rx_64_or_less + i]; + dev->dev_ops->r_mib_pkt(dev, port, (ksz9477_rx_64_or_less + i), NULL, cnt); + rmon_stats->hist[i] = *cnt; + } + + mutex_unlock(&mib->cnt_mutex); + + *ranges = ksz_rmon_ranges; +} diff --git a/drivers/net/dsa/microchip/ksz_ethtool.h b/drivers/net/dsa/microchip/ksz_ethtool.h new file mode 100644 index 000000000000..6927e2f143f8 --- /dev/null +++ b/drivers/net/dsa/microchip/ksz_ethtool.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Microchip KSZ series ethtool statistics + * + * Copyright (C) 2022 Microchip Technology Inc. + */ + +#ifndef __KSZ_ETHTOOL_H +#define __KSZ_ETHTOOL_H + +void ksz8_get_rmon_stats(struct ksz_device *dev, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); + +void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, + struct ethtool_rmon_stats *rmon_stats, + const struct ethtool_rmon_hist_range **ranges); +#endif From patchwork Wed Nov 30 13:28:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 27795 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp926908wrr; Wed, 30 Nov 2022 05:34:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GsTlfLnW1gWDjj87j1KG4m/+wRAgA207/NmaCXo+OxvpQdgfMm6Bpu3Kpjm/NHi60KYwl X-Received: by 2002:a17:906:c283:b0:7ae:2277:9fec with SMTP id r3-20020a170906c28300b007ae22779fecmr50558294ejz.623.1669815265275; Wed, 30 Nov 2022 05:34:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815265; cv=none; d=google.com; s=arc-20160816; b=oIPsQC4kEUxv4jm9b4qEap//rThM6WXZQoMTi5AfND9CNWsAmwk3UF4Lu00ZkCWwVr p6hjrt/O3U8faa0kMRVHvyf/2aaQDHn+V3ojwnHFSuDatiVqWP1W+Nch4EqHXWBcNegm wLsLOWAFL6Li3XL6rkQLkPf/qJmqcZxJD0spPPbBsagEo9Lxf3Td5kD8+V5qYsA1tYZJ +iob0Cmf/f0WPonHGPwdq2ZAm6E/iEe/CSMIGU8n4YPrSikHR930vcDn7BLmv81DVJMx k8zYb6HhL1hcpSlupRMz1CgJbkvHrh7YgUrHuXdp6XboztpChzjtAfmJR4PhoB8sKQta K9FQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4MQjGJpHiOGz3vuFPAFywLpjyaE8U82C/yZ1h9QwUkM=; b=JLbR9lzluLFvWlqlX6ursQi/LToypa7CUPcPZJLDUNDvYRlVebvWczpDChoarz0AN8 XoqL+pcdBbtlfOF4g1YvYQtGOJh9Y9g0kBfWXmMp6t+FGaSwM3euQd4w4wvkADHhUKRf /A1VPSX/tmTy0kdIaitHzzUTCSzHfp6g2U/t/44uIeuvUsp3oSOgX6/QUzTEGT/rxSiw +Ux8MUhVLrS+KN3n0Q/xmMFL26fyyMITm7qR9czmInAse/NHQ5fI1Dr4p5BP97OBW6g5 YV2LreLGKjtjS4gyw7D/615ORYjmZFj+lrL4t2yHzABp3HppBS83YdhpgLRToGB+0Mej 0R/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=MXEDj3Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rh16-20020a17090720f000b0078b88453306si999924ejb.285.2022.11.30.05.34.01; Wed, 30 Nov 2022 05:34:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=MXEDj3Tc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234452AbiK3N35 (ORCPT + 99 others); Wed, 30 Nov 2022 08:29:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235506AbiK3N3x (ORCPT ); Wed, 30 Nov 2022 08:29:53 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF59B6D4B0; Wed, 30 Nov 2022 05:29:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669814992; x=1701350992; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bG2YB0NkrzG6BJsd5W3PcjQo2F7CAw9j+x82YqMWPLQ=; b=MXEDj3TcxOYF7e5IRPSyZv/WpuZKTI9SxzUkLfwGgHnn1tW2J6NMj1lp efbvuIdLwABE6NxcvDq8W28XKkEt84ZtbXDumgTc0x5frEoEwfYCogehj 3zZsKCS59PkyiKfHWVcvWiKIpAjLNmJ01CxU5mDxW8T3dePB/+0R/vPqS 09UdZQ2ei5w5y2ZxevbHAM3IqH+L9syMoTKiFM3b2gR+khnqY0wpj2Crs vl3yjlhN8ZovLQW0c90MQV9e455Ymdg/PIp943RyYFmp56/dAYPcmA6Xz yY4uj6qB1QDdnCfPbPts9EbLAmLznd5oTzVbrqP/QjKc35woiqxcoXdKc Q==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191142261" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 06:29:52 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 06:29:52 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 06:29:48 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [RFC Patch net-next 2/5] net: dsa: microchip: add eth ctrl grouping for ethtool statistics Date: Wed, 30 Nov 2022 18:58:59 +0530 Message-ID: <20221130132902.2984580-3-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> References: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750928211366372951?= X-GMAIL-MSGID: =?utf-8?q?1750928211366372951?= Add support for ethtool standard device statistics grouping. Support ethernet mac ctrl statistics grouping using eth-ctrl groups parameter in ethtool command. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 13 ++++++++ drivers/net/dsa/microchip/ksz_common.h | 2 ++ drivers/net/dsa/microchip/ksz_ethtool.c | 42 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 4 +++ 4 files changed, 61 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 7a9d7ef818a7..9b13a38d553d 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -159,6 +159,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, .get_rmon_stats = ksz8_get_rmon_stats, + .get_eth_ctrl_stats = ksz8_get_eth_ctrl_stats, .fdb_dump = ksz8_fdb_dump, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, @@ -197,6 +198,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, .get_rmon_stats = ksz9477_get_rmon_stats, + .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -234,6 +236,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .freeze_mib = ksz9477_freeze_mib, .port_init_cnt = ksz9477_port_init_cnt, .get_rmon_stats = ksz9477_get_rmon_stats, + .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -1623,6 +1626,15 @@ static void ksz_get_rmon_stats(struct dsa_switch *ds, int port, dev->dev_ops->get_rmon_stats(dev, port, rmon_stats, ranges); } +static void ksz_get_eth_ctrl_stats(struct dsa_switch *ds, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct ksz_device *dev = ds->priv; + + if (dev->dev_ops->get_eth_ctrl_stats) + dev->dev_ops->get_eth_ctrl_stats(dev, port, ctrl_stats); +} + static void ksz_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *buf) { @@ -2874,6 +2886,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .get_stats64 = ksz_get_stats64, .get_pause_stats = ksz_get_pause_stats, .get_rmon_stats = ksz_get_rmon_stats, + .get_eth_ctrl_stats = ksz_get_eth_ctrl_stats, .port_change_mtu = ksz_change_mtu, .port_max_mtu = ksz_max_mtu, }; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index ad6d196d2927..07627ff1a749 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -342,6 +342,8 @@ struct ksz_dev_ops { void (*get_rmon_stats)(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); + void (*get_eth_ctrl_stats)(struct ksz_device *dev, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats); }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); diff --git a/drivers/net/dsa/microchip/ksz_ethtool.c b/drivers/net/dsa/microchip/ksz_ethtool.c index 7e1f1b4d1e98..4c9ca21e1806 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -138,6 +138,27 @@ void ksz8_get_rmon_stats(struct ksz_device *dev, int port, *ranges = ksz_rmon_ranges; } +void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct ksz_port_mib *mib; + u64 *cnt; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz8_tx_pause]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_tx_pause, NULL, cnt); + ctrl_stats->MACControlFramesTransmitted = *cnt; + + cnt = &mib->counters[ksz8_rx_pause]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_pause, NULL, cnt); + ctrl_stats->MACControlFramesReceived = *cnt; + + mutex_unlock(&mib->cnt_mutex); +} + void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges) @@ -176,3 +197,24 @@ void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, *ranges = ksz_rmon_ranges; } + +void ksz9477_get_eth_ctrl_stats(struct ksz_device *dev, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats) +{ + struct ksz_port_mib *mib; + u64 *cnt; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz9477_tx_pause]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_tx_pause, NULL, cnt); + ctrl_stats->MACControlFramesTransmitted = *cnt; + + cnt = &mib->counters[ksz9477_rx_pause]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_pause, NULL, cnt); + ctrl_stats->MACControlFramesReceived = *cnt; + + mutex_unlock(&mib->cnt_mutex); +} diff --git a/drivers/net/dsa/microchip/ksz_ethtool.h b/drivers/net/dsa/microchip/ksz_ethtool.h index 6927e2f143f8..18dc155d60b9 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.h +++ b/drivers/net/dsa/microchip/ksz_ethtool.h @@ -11,8 +11,12 @@ void ksz8_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); +void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats); void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); +void ksz9477_get_eth_ctrl_stats(struct ksz_device *dev, int port, + struct ethtool_eth_ctrl_stats *ctrl_stats); #endif From patchwork Wed Nov 30 13:29:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 27798 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp927910wrr; Wed, 30 Nov 2022 05:36:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UhjTlpf1xYhyx81jL1Nx3RNd29UBxhaDJfWYEflVKCndvQu81ZdqaLRxPFsNOlTHJhIMK X-Received: by 2002:a17:902:6505:b0:186:ba52:1dc7 with SMTP id b5-20020a170902650500b00186ba521dc7mr53374022plk.41.1669815377463; Wed, 30 Nov 2022 05:36:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815377; cv=none; d=google.com; s=arc-20160816; b=ikLWAGSAj4CLA7T5iWtH9HL5T77fJx6t++rsWJ5+/j6NiF43tXZL+XUnIXQdp+f+FO HKcO76ct06NCDdZvVlHOkIcnk8S7HC3Y7sLB6jA8s8GFxpW+kkoswci7/A25muOtN+dO 8EjsOi7JegHgay/3iS+NSUgPFi48IwMAcv47yLtpCYcbU/VVqIXTj/p6OmGM7yolbls6 Pmd5JV68pnxPBTbQSOUKff38PZM5VWjfd0/ae7kAl743fsuFB8q6eWuF72URVzAJAcYm XwP1nn/nA17/8814WFtmh9gY/3xjYG2DX8jKSgVTc8Z9MWWSJSPmAlvoC8DsdDIlkQRm fOPQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=65SyNewB8xEod10FBAEk2Pid5hV7ZXj+re9oMOQdOB8=; b=us0R6PkTXGQBIR58e4IVhEp60yeFQlWa0YiR9+bmI+weGA5BIRk7i0bEJQaHIj4N7u fpiWuSKzTWaUzlV/Qk/CPrv5kzVzUmOkxcfsmDOKpN0QYPpB6OH3aU1SWit/G9GZRZXX 4obpVRKzytMQhlraC6x70q1QCxOVqI0r+NJ+3saOX7lUYacnrci6bAT0IYT2DuiuwXWJ Ec7URZ2a5JvGF3JPAXxUZZzKnElczBYeX0S958X0W3Cfayp0DzEzQYSIZeoAMqWD6HBv VWP0Cw6UjOG3cRjJKKFXB1+RnteNffXvCTaEyV/HWsXrqIOxgMpY+UIZN9nIkg6eD8O9 Show== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=utuKCcr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a170902f68d00b00186a5b86ea3si1416255plg.50.2022.11.30.05.36.01; Wed, 30 Nov 2022 05:36:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=utuKCcr2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235809AbiK3NaU (ORCPT + 99 others); Wed, 30 Nov 2022 08:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbiK3NaN (ORCPT ); Wed, 30 Nov 2022 08:30:13 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C199071F0C; Wed, 30 Nov 2022 05:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669814997; x=1701350997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GcfHlGYSRmzVmdhXul6GAVE2u5JqJYb0z41bOinu+S4=; b=utuKCcr22OeKA+MkmSVMJ6MwCQWm0S4SvlMi4qKTLJuWctiCAM09+Ajm Q5fP8YPYlmsbqvOyGNMa4xzE2EEMQiTgsJDtZn+xOey88iAORSZB6m1Ce XXtON87IalCA3ytdtsdk6fGu5qmnammFjENqlTtnPgOQlal3XZKgO3VAi DxymADpI3laFHbYFZpSAh9DibTIJPmUjVphrdnfSrzpMn9NyCW71NiMSi jZxWJbh2M/TyVvscrihEXZf6nncDyrb6KLBIvh6cVdeFRMgqy6FnqEd0S kwid4WCQ82RuTrLCWeNiJ3IpIC8/cHHpA/77GS5kR51zS3ACOaFJRLy0n g==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191142269" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 06:29:57 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 06:29:57 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 06:29:53 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [RFC Patch net-next 3/5] net: dsa: microchip: add eth mac grouping for ethtool statistics Date: Wed, 30 Nov 2022 18:59:00 +0530 Message-ID: <20221130132902.2984580-4-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> References: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750928328963660076?= X-GMAIL-MSGID: =?utf-8?q?1750928328963660076?= Add support for ethtool standard device statistics grouping. Support ethernet mac statistics grouping using eth-mac groups parameter in ethtool command. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 13 ++++ drivers/net/dsa/microchip/ksz_common.h | 2 + drivers/net/dsa/microchip/ksz_ethtool.c | 88 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 4 ++ 4 files changed, 107 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 9b13a38d553d..ceb3c4f120bd 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -160,6 +160,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .port_init_cnt = ksz8_port_init_cnt, .get_rmon_stats = ksz8_get_rmon_stats, .get_eth_ctrl_stats = ksz8_get_eth_ctrl_stats, + .get_eth_mac_stats = ksz8_get_eth_mac_stats, .fdb_dump = ksz8_fdb_dump, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, @@ -199,6 +200,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .port_init_cnt = ksz9477_port_init_cnt, .get_rmon_stats = ksz9477_get_rmon_stats, .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, + .get_eth_mac_stats = ksz9477_get_eth_mac_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -237,6 +239,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .port_init_cnt = ksz9477_port_init_cnt, .get_rmon_stats = ksz9477_get_rmon_stats, .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, + .get_eth_mac_stats = ksz9477_get_eth_mac_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -1635,6 +1638,15 @@ static void ksz_get_eth_ctrl_stats(struct dsa_switch *ds, int port, dev->dev_ops->get_eth_ctrl_stats(dev, port, ctrl_stats); } +static void ksz_get_eth_mac_stats(struct dsa_switch *ds, int port, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct ksz_device *dev = ds->priv; + + if (dev->dev_ops->get_eth_mac_stats) + dev->dev_ops->get_eth_mac_stats(dev, port, mac_stats); +} + static void ksz_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *buf) { @@ -2887,6 +2899,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .get_pause_stats = ksz_get_pause_stats, .get_rmon_stats = ksz_get_rmon_stats, .get_eth_ctrl_stats = ksz_get_eth_ctrl_stats, + .get_eth_mac_stats = ksz_get_eth_mac_stats, .port_change_mtu = ksz_change_mtu, .port_max_mtu = ksz_max_mtu, }; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 07627ff1a749..5b77f98483a9 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -344,6 +344,8 @@ struct ksz_dev_ops { const struct ethtool_rmon_hist_range **ranges); void (*get_eth_ctrl_stats)(struct ksz_device *dev, int port, struct ethtool_eth_ctrl_stats *ctrl_stats); + void (*get_eth_mac_stats)(struct ksz_device *dev, int port, + struct ethtool_eth_mac_stats *mac_stats); }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); diff --git a/drivers/net/dsa/microchip/ksz_ethtool.c b/drivers/net/dsa/microchip/ksz_ethtool.c index 4c9ca21e1806..96529fea8e84 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -159,6 +159,50 @@ void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port, mutex_unlock(&mib->cnt_mutex); } +void ksz8_get_eth_mac_stats(struct ksz_device *dev, int port, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct ksz_port_mib *mib; + u64 *ctr; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + ctr = mib->counters; + + while (mib->cnt_ptr < dev->info->mib_cnt) { + dev->dev_ops->r_mib_pkt(dev, port, mib->cnt_ptr, + NULL, &mib->counters[mib->cnt_ptr]); + ++mib->cnt_ptr; + } + + mac_stats->FramesTransmittedOK = ctr[ksz8_tx_mcast] + + ctr[ksz8_tx_bcast] + + ctr[ksz8_tx_ucast] + + ctr[ksz8_tx_pause]; + mac_stats->SingleCollisionFrames = ctr[ksz8_tx_single_col]; + mac_stats->MultipleCollisionFrames = ctr[ksz8_tx_mult_col]; + mac_stats->FramesReceivedOK = ctr[ksz8_rx_mcast] + + ctr[ksz8_rx_bcast] + + ctr[ksz8_rx_ucast] + + ctr[ksz8_rx_pause]; + mac_stats->FrameCheckSequenceErrors = ctr[ksz8_rx_crc_err]; + mac_stats->AlignmentErrors = ctr[ksz8_rx_align_err]; + mac_stats->OctetsTransmittedOK = ctr[ksz8_tx_total_col]; + mac_stats->FramesWithDeferredXmissions = ctr[ksz8_tx_deferred]; + mac_stats->LateCollisions = ctr[ksz8_tx_late_col]; + mac_stats->FramesAbortedDueToXSColls = ctr[ksz8_tx_exc_col]; + mac_stats->MulticastFramesXmittedOK = ctr[ksz8_tx_mcast]; + mac_stats->BroadcastFramesXmittedOK = ctr[ksz8_tx_bcast]; + mac_stats->MulticastFramesReceivedOK = ctr[ksz8_rx_mcast]; + mac_stats->BroadcastFramesReceivedOK = ctr[ksz8_rx_bcast]; + mac_stats->InRangeLengthErrors = ctr[ksz8_rx_oversize]; + + mib->cnt_ptr = 0; + + mutex_unlock(&mib->cnt_mutex); +} + void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges) @@ -218,3 +262,47 @@ void ksz9477_get_eth_ctrl_stats(struct ksz_device *dev, int port, mutex_unlock(&mib->cnt_mutex); } + +void ksz9477_get_eth_mac_stats(struct ksz_device *dev, int port, + struct ethtool_eth_mac_stats *mac_stats) +{ + struct ksz_port_mib *mib; + u64 *ctr; + + mib = &dev->ports[port].mib; + ctr = mib->counters; + + mutex_lock(&mib->cnt_mutex); + + while (mib->cnt_ptr < dev->info->mib_cnt) { + dev->dev_ops->r_mib_pkt(dev, port, mib->cnt_ptr, + NULL, &mib->counters[mib->cnt_ptr]); + ++mib->cnt_ptr; + } + + mac_stats->FramesTransmittedOK = ctr[ksz9477_tx_mcast] + + ctr[ksz9477_tx_bcast] + + ctr[ksz9477_tx_ucast] + + ctr[ksz9477_tx_pause]; + mac_stats->SingleCollisionFrames = ctr[ksz9477_tx_single_col]; + mac_stats->MultipleCollisionFrames = ctr[ksz9477_tx_mult_col]; + mac_stats->FramesReceivedOK = ctr[ksz9477_rx_mcast] + + ctr[ksz9477_rx_bcast] + + ctr[ksz9477_rx_ucast] + + ctr[ksz9477_rx_pause]; + mac_stats->FrameCheckSequenceErrors = ctr[ksz9477_rx_crc_err]; + mac_stats->AlignmentErrors = ctr[ksz9477_rx_align_err]; + mac_stats->OctetsTransmittedOK = ctr[ksz9477_tx_total_col]; + mac_stats->FramesWithDeferredXmissions = ctr[ksz9477_tx_deferred]; + mac_stats->LateCollisions = ctr[ksz9477_tx_late_col]; + mac_stats->FramesAbortedDueToXSColls = ctr[ksz9477_tx_exc_col]; + mac_stats->MulticastFramesXmittedOK = ctr[ksz9477_tx_mcast]; + mac_stats->BroadcastFramesXmittedOK = ctr[ksz9477_tx_bcast]; + mac_stats->MulticastFramesReceivedOK = ctr[ksz9477_rx_mcast]; + mac_stats->BroadcastFramesReceivedOK = ctr[ksz9477_rx_bcast]; + mac_stats->InRangeLengthErrors = ctr[ksz9477_rx_oversize]; + + mib->cnt_ptr = 0; + + mutex_unlock(&mib->cnt_mutex); +} diff --git a/drivers/net/dsa/microchip/ksz_ethtool.h b/drivers/net/dsa/microchip/ksz_ethtool.h index 18dc155d60b9..2dcfe8922b4e 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.h +++ b/drivers/net/dsa/microchip/ksz_ethtool.h @@ -13,10 +13,14 @@ void ksz8_get_rmon_stats(struct ksz_device *dev, int port, const struct ethtool_rmon_hist_range **ranges); void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port, struct ethtool_eth_ctrl_stats *ctrl_stats); +void ksz8_get_eth_mac_stats(struct ksz_device *dev, int port, + struct ethtool_eth_mac_stats *mac_stats); void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges); void ksz9477_get_eth_ctrl_stats(struct ksz_device *dev, int port, struct ethtool_eth_ctrl_stats *ctrl_stats); +void ksz9477_get_eth_mac_stats(struct ksz_device *dev, int port, + struct ethtool_eth_mac_stats *mac_stats); #endif From patchwork Wed Nov 30 13:29:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 27796 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp927085wrr; Wed, 30 Nov 2022 05:34:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6L7QMpNfOg0Q0ldNN5qrNv3Dum0APfYAABYQWWWp2NCe1WECu1StBnszHW9vE/eLaIWI8t X-Received: by 2002:a17:90b:3d0a:b0:218:a599:d0ac with SMTP id pt10-20020a17090b3d0a00b00218a599d0acmr50897801pjb.88.1669815286991; Wed, 30 Nov 2022 05:34:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815286; cv=none; d=google.com; s=arc-20160816; b=d72bkcrRaSmZXNPYTd2DYnIibBrgPr/qE5IX9Vve+K4IGvwyq7URFRSY7+AKfvKhVl mAu1quqbTsljyumfmSKTMiVIZFjwtDBJeke+8TYlc7EgpxO5dDhTby1h0Ri8MDD1FQiK Gzx4V+hfhhxvUFMRrXr89hILXtKkg23jT1+0Pyl5jO8h1l/vfZS3IUubE23X4PkZjWvG XGuLvpcfs+KEyIEJFs2ZsusjRiKm6bXMBv69DUqDrWKQoNbgTILmzrf1upPUg8C7yITE nbKEID7IE+yhE/dlYyB9gA9Io842eiZY/63Cm0qshJbhF4qyZPe+tOK14gSlkSE+KPrv zkKQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2ox4QdDXBkLXuKBlClCotuMGkCb9QR16yMSxDW1/uLI=; b=kZ4yjIAEDHqNWty7gRXr/VQ3KVtWR5bJeTjY/Yx7sgWf0dkFiePwNw1ci03aH38deC FpvgOLDs+eGQxGHWzpG1Kl2dWFzlhwhuyIgaQ0m0+YrFSo5XB9c9x7kdtrGb0AbPFTkr 9HQwCVWIOlAB2rsmtRTlf6rrKeV2W7e8T6xXbxLDruuoP8Ku+jP387GPWU5boaMBq8Yy 0A3EfagvzKlkjWYgTZXNmrH1rcD+X5P7E22T+BiyOBuy7wMuRvEuPfH4fvlTLI4xrilK I9ON855nUZQkA58QOO+UkpKnpYcxs0m6sRcGloozudDLP8DYVbIo7CdK/+mKhb0ZYB6z fllQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=uKQSHkCy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a170902c11100b00178386d88c6si1208708pli.186.2022.11.30.05.34.32; Wed, 30 Nov 2022 05:34:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=uKQSHkCy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233030AbiK3Nai (ORCPT + 99 others); Wed, 30 Nov 2022 08:30:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235871AbiK3NaV (ORCPT ); Wed, 30 Nov 2022 08:30:21 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4B77CAB5; Wed, 30 Nov 2022 05:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669815002; x=1701351002; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zI8qmvOdp+9rHbSq/mQh0++aRx/yJ0H3E/ueXM5IhBA=; b=uKQSHkCyKH7sx+Myid4Kkv734MeQJWze6QcAN++Di2t9QomzASNeZCt4 x6Uf9VdXxsVkT+UoKUeO466ZEkKLXZUS1DCNcDRHGsM08B5E+BaYlzPZT 3nLR9nTeW5KIxDUTjpm3b9xV3FhuywiXGfvdVu65IJse2Wqgl+S61LonL hNg+wYis8w4KlQ4n82/O9kv5P6IEScvUvlGmrOXl0ctks7PZqo3n+HBAw x1ZV8XIXC5UgnNG7vFnXqY0ZDi0lSgMN2ZCevw3PgVD1wK9NS5ByUs1U2 HoOHaXHxy2TLcJGTY9cNd1wa4nUrD2gCe6aiofxASbII9iEjI9vscLLqP g==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191136742" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 06:30:02 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 06:30:02 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 06:29:58 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [RFC Patch net-next 4/5] net: dsa: microchip: add eth phy grouping for ethtool statistics Date: Wed, 30 Nov 2022 18:59:01 +0530 Message-ID: <20221130132902.2984580-5-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> References: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750928234679475917?= X-GMAIL-MSGID: =?utf-8?q?1750928234679475917?= Add support for ethtool standard device statistics grouping. Support ethernet phy statistics grouping using eth-phy groups parameter in ethtool command. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 13 +++++++++ drivers/net/dsa/microchip/ksz_common.h | 2 ++ drivers/net/dsa/microchip/ksz_ethtool.c | 36 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 5 ++++ 4 files changed, 56 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index ceb3c4f120bd..0f3925d0c668 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -161,6 +161,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .get_rmon_stats = ksz8_get_rmon_stats, .get_eth_ctrl_stats = ksz8_get_eth_ctrl_stats, .get_eth_mac_stats = ksz8_get_eth_mac_stats, + .get_eth_phy_stats = ksz8_get_eth_phy_stats, .fdb_dump = ksz8_fdb_dump, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, @@ -201,6 +202,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .get_rmon_stats = ksz9477_get_rmon_stats, .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, .get_eth_mac_stats = ksz9477_get_eth_mac_stats, + .get_eth_phy_stats = ksz9477_get_eth_phy_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -240,6 +242,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .get_rmon_stats = ksz9477_get_rmon_stats, .get_eth_ctrl_stats = ksz9477_get_eth_ctrl_stats, .get_eth_mac_stats = ksz9477_get_eth_mac_stats, + .get_eth_phy_stats = ksz9477_get_eth_phy_stats, .vlan_filtering = ksz9477_port_vlan_filtering, .vlan_add = ksz9477_port_vlan_add, .vlan_del = ksz9477_port_vlan_del, @@ -1647,6 +1650,15 @@ static void ksz_get_eth_mac_stats(struct dsa_switch *ds, int port, dev->dev_ops->get_eth_mac_stats(dev, port, mac_stats); } +static void ksz_get_eth_phy_stats(struct dsa_switch *ds, int port, + struct ethtool_eth_phy_stats *phy_stats) +{ + struct ksz_device *dev = ds->priv; + + if (dev->dev_ops->get_eth_phy_stats) + dev->dev_ops->get_eth_phy_stats(dev, port, phy_stats); +} + static void ksz_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *buf) { @@ -2900,6 +2912,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .get_rmon_stats = ksz_get_rmon_stats, .get_eth_ctrl_stats = ksz_get_eth_ctrl_stats, .get_eth_mac_stats = ksz_get_eth_mac_stats, + .get_eth_phy_stats = ksz_get_eth_phy_stats, .port_change_mtu = ksz_change_mtu, .port_max_mtu = ksz_max_mtu, }; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 5b77f98483a9..c253d761b62b 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -346,6 +346,8 @@ struct ksz_dev_ops { struct ethtool_eth_ctrl_stats *ctrl_stats); void (*get_eth_mac_stats)(struct ksz_device *dev, int port, struct ethtool_eth_mac_stats *mac_stats); + void (*get_eth_phy_stats)(struct ksz_device *dev, int port, + struct ethtool_eth_phy_stats *phy_stats); }; struct ksz_device *ksz_switch_alloc(struct device *base, void *priv); diff --git a/drivers/net/dsa/microchip/ksz_ethtool.c b/drivers/net/dsa/microchip/ksz_ethtool.c index 96529fea8e84..5061c503437a 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -203,6 +203,24 @@ void ksz8_get_eth_mac_stats(struct ksz_device *dev, int port, mutex_unlock(&mib->cnt_mutex); } +void ksz8_get_eth_phy_stats(struct ksz_device *dev, int port, + struct ethtool_eth_phy_stats *phy_stats) +{ + struct ksz_port_mib *mib; + u64 *cnt; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz8_rx_symbol_err]; + dev->dev_ops->r_mib_pkt(dev, port, ksz8_rx_symbol_err, NULL, cnt); + + phy_stats->SymbolErrorDuringCarrier = *cnt; + + mutex_unlock(&mib->cnt_mutex); +} + void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, const struct ethtool_rmon_hist_range **ranges) @@ -306,3 +324,21 @@ void ksz9477_get_eth_mac_stats(struct ksz_device *dev, int port, mutex_unlock(&mib->cnt_mutex); } + +void ksz9477_get_eth_phy_stats(struct ksz_device *dev, int port, + struct ethtool_eth_phy_stats *phy_stats) +{ + struct ksz_port_mib *mib; + u64 *cnt; + + mib = &dev->ports[port].mib; + + mutex_lock(&mib->cnt_mutex); + + cnt = &mib->counters[ksz9477_rx_symbol_err]; + dev->dev_ops->r_mib_pkt(dev, port, ksz9477_rx_symbol_err, NULL, cnt); + + phy_stats->SymbolErrorDuringCarrier = *cnt; + + mutex_unlock(&mib->cnt_mutex); +} diff --git a/drivers/net/dsa/microchip/ksz_ethtool.h b/drivers/net/dsa/microchip/ksz_ethtool.h index 2dcfe8922b4e..042a0b38a899 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.h +++ b/drivers/net/dsa/microchip/ksz_ethtool.h @@ -15,6 +15,8 @@ void ksz8_get_eth_ctrl_stats(struct ksz_device *dev, int port, struct ethtool_eth_ctrl_stats *ctrl_stats); void ksz8_get_eth_mac_stats(struct ksz_device *dev, int port, struct ethtool_eth_mac_stats *mac_stats); +void ksz8_get_eth_phy_stats(struct ksz_device *dev, int port, + struct ethtool_eth_phy_stats *phy_stats); void ksz9477_get_rmon_stats(struct ksz_device *dev, int port, struct ethtool_rmon_stats *rmon_stats, @@ -23,4 +25,7 @@ void ksz9477_get_eth_ctrl_stats(struct ksz_device *dev, int port, struct ethtool_eth_ctrl_stats *ctrl_stats); void ksz9477_get_eth_mac_stats(struct ksz_device *dev, int port, struct ethtool_eth_mac_stats *mac_stats); +void ksz9477_get_eth_phy_stats(struct ksz_device *dev, int port, + struct ethtool_eth_phy_stats *phy_stats); + #endif From patchwork Wed Nov 30 13:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 27799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp927938wrr; Wed, 30 Nov 2022 05:36:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5wQ1MzpHRpH8nOxKamcy46iJViA+B4PnlS2POAUd6VT19dsEXl2pq+fel1v71iVOHq7JhY X-Received: by 2002:a63:f442:0:b0:477:ea30:7d6a with SMTP id p2-20020a63f442000000b00477ea307d6amr22225136pgk.212.1669815390468; Wed, 30 Nov 2022 05:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815390; cv=none; d=google.com; s=arc-20160816; b=bMq+GJknVbR773h3E1JubvVQfVHQe7Ws3o1FL+YIf9MtRob/SZvW4YgO8y6TZjJ2gs wYy7oIDfBSUihTL9LyuYq4IPqHNRCtgy9y9a6U694ErXXTyBq+uBIf61GLAeaSSG5fCX ugDHqlAftw+YO86fO3HJLZ+L11BZba+d+NP3tatUaTG2LitCjkw0Pd2NzanWbolhlscF q0vMyLecTkk9+kIkPyexg/BdDfcCwLhdcKzXfweaKYrDW4E639CaQ00uJSO5s95caSpS jPjuY1qMg1SHwq1MW7Me1XPVdtSC40poqiZQynC6ChZ0/IbYpVPdo4alSDh3SsKr3ml5 plXw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9pE4tzK13rKrHhp5tAyz9ryLlBNh/67zI8Ttvu440Ps=; b=pDKYV+gxlgHBNyCS2V4YMX0R+VhK0A0L9Gf3awq93a9rcqmd5bMd70UfCc6ZIkwwnr aeOCjumgdED3RmAtIrpTJdXhxvS30anJ49obX2wP2zjOl3kKtH6GEwjMLhwusBZBKeeA koPLszVNttWcJibXSybkTs/z8XTgRjwxlzuSEL9yinYj338l0AAGLNn0TYgAISF5z60d RjISxlcoRBK9Ef+jjQHO/qVbkyXMF3QZ2pur64T+pclKGNCvTJd8MyKxRFQuoV6Qpnau kXBdHicMxdpUlui8T4lKKrjvG7Zi1ag2DFgeLoU+cNv/LBRwQbHZiIkegJOBA9BLo+sI brng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Fbky42qX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a170903234b00b00179cf094dccsi1305595plh.526.2022.11.30.05.36.16; Wed, 30 Nov 2022 05:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=Fbky42qX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235915AbiK3Na4 (ORCPT + 99 others); Wed, 30 Nov 2022 08:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235920AbiK3Nab (ORCPT ); Wed, 30 Nov 2022 08:30:31 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0A186A0D; Wed, 30 Nov 2022 05:30:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669815008; x=1701351008; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WFdq3U0yW/+3gkKwBv5k1rgVGnA4EX8hYiO9CLomOCk=; b=Fbky42qX7iaFrBvFlIOdNyKyAktDgi/gvE4Q6i+UggLSPHa7C+w0ublT 9mRJSAEt4LBr+YQ73FHoX/TMJGg7WQai5FIJB9JsHGTOopKPhESVyi8lZ bQ2sXOeSNFPetDEP57LoPeNf8XvFL05Lj9XJP1soIuWvekRidD/z3iAUR tRB2kGmdM/cnB7vL4xyNi2emEbJcmSZo7sQ3Zc8ECQNqO5KwkKz3BdWME fG3UiKrzIDh5plDyv/Y73wJq8FWFFJyAsQ6zAZReaAd2smgLfGEQS4nUn R0Nh6+43fZCnxfRwOwFO1JhFrk8UaKw4TBxJHbtBE/WO8dARvH/W0kPND g==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="125804059" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 06:30:07 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 06:30:06 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 06:30:03 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [RFC Patch net-next 5/5] net: dsa: microchip: remove num_alus variable Date: Wed, 30 Nov 2022 18:59:02 +0530 Message-ID: <20221130132902.2984580-6-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> References: <20221130132902.2984580-1-rakesh.sankaranarayanan@microchip.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750928342755804552?= X-GMAIL-MSGID: =?utf-8?q?1750928342755804552?= Remove num_alus variable from ksz_chip_data structure since it is unused now. Signed-off-by: Rakesh Sankaranarayanan --- drivers/net/dsa/microchip/ksz_common.c | 16 ---------------- drivers/net/dsa/microchip/ksz_common.h | 1 - 2 files changed, 17 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 0f3925d0c668..3e616f1e71b9 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1048,7 +1048,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ8563_CHIP_ID, .dev_name = "KSZ8563", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x07, /* can be configured as cpu port */ .port_cnt = 3, /* total port count */ @@ -1075,7 +1074,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ8795_CHIP_ID, .dev_name = "KSZ8795", .num_vlans = 4096, - .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total cpu and user ports */ @@ -1113,7 +1111,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ8794_CHIP_ID, .dev_name = "KSZ8794", .num_vlans = 4096, - .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total cpu and user ports */ @@ -1137,7 +1134,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ8765_CHIP_ID, .dev_name = "KSZ8765", .num_vlans = 4096, - .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total cpu and user ports */ @@ -1161,7 +1157,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ8830_CHIP_ID, .dev_name = "KSZ8863/KSZ8873", .num_vlans = 16, - .num_alus = 0, .num_statics = 8, .cpu_ports = 0x4, /* can be configured as cpu port */ .port_cnt = 3, @@ -1181,7 +1176,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9477_CHIP_ID, .dev_name = "KSZ9477", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ @@ -1213,7 +1207,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9896_CHIP_ID, .dev_name = "KSZ9896", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x3F, /* can be configured as cpu port */ .port_cnt = 6, /* total physical port count */ @@ -1245,7 +1238,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9897_CHIP_ID, .dev_name = "KSZ9897", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ @@ -1275,7 +1267,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9893_CHIP_ID, .dev_name = "KSZ9893", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x07, /* can be configured as cpu port */ .port_cnt = 3, /* total port count */ @@ -1300,7 +1291,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9563_CHIP_ID, .dev_name = "KSZ9563", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x07, /* can be configured as cpu port */ .port_cnt = 3, /* total port count */ @@ -1325,7 +1315,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = KSZ9567_CHIP_ID, .dev_name = "KSZ9567", .num_vlans = 4096, - .num_alus = 4096, .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ @@ -1355,7 +1344,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = LAN9370_CHIP_ID, .dev_name = "LAN9370", .num_vlans = 4096, - .num_alus = 1024, .num_statics = 256, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ @@ -1379,7 +1367,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = LAN9371_CHIP_ID, .dev_name = "LAN9371", .num_vlans = 4096, - .num_alus = 1024, .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 6, /* total physical port count */ @@ -1403,7 +1390,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = LAN9372_CHIP_ID, .dev_name = "LAN9372", .num_vlans = 4096, - .num_alus = 1024, .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ @@ -1431,7 +1417,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = LAN9373_CHIP_ID, .dev_name = "LAN9373", .num_vlans = 4096, - .num_alus = 1024, .num_statics = 256, .cpu_ports = 0x38, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ @@ -1459,7 +1444,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .chip_id = LAN9374_CHIP_ID, .dev_name = "LAN9374", .num_vlans = 4096, - .num_alus = 1024, .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index c253d761b62b..359148fb9097 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -41,7 +41,6 @@ struct ksz_chip_data { u32 chip_id; const char *dev_name; int num_vlans; - int num_alus; int num_statics; int cpu_ports; int port_cnt;