From patchwork Fri Feb 17 11:02:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 58492 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp822914wrn; Fri, 17 Feb 2023 03:04:07 -0800 (PST) X-Google-Smtp-Source: AK7set9L+8AgnwFomn4TRxwa6RD/2NYNFQa6SaSfMhxwvL8AJR3M/WYUjAnVB/g71el+KgMCUnUT X-Received: by 2002:a17:907:c685:b0:87c:ee05:a5de with SMTP id ue5-20020a170907c68500b0087cee05a5demr4865224ejc.1.1676631846969; Fri, 17 Feb 2023 03:04:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631846; cv=none; d=google.com; s=arc-20160816; b=wzXJfPFp3KwaN0XGuEjdO2I/pfat66aHBmEZ9b2F2T8ijCgGqcVClXRNvr4aLqDvvD ILeT6YcT+YCUVrkKNbbi0qoQzFFSDtUVo6a2p4FyyU73pcOAt3Ps7aJKhIsq4YZ0iZW1 IuCVNMUW9k4WCoc7T0hFUImp3WzeO4cj7BKdBRCfsXuFNbGA2m4ZSPINdJxirzfjx5wc gvPOCD6Xd2xpyzpj/L2OsR0u6OBvH3sQRlGjiiSBJ/jhmq9MPy9Bw9oAWcmvNzsAklSf FhQPKh0XW+RtRQlCvnGRueVw9k4wq96E6lM1t0RrV+fe8tunsiPzIVNpMNk0Xx2TRBnE MaQw== 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=F1u7WiJQxlpUvOPmf/SXgrVAiWirK7gztYXVzEX32Zg=; b=gXKxdku2V7pbqecYvGeaj5t1Fxi4e8J+FH9Mf6J7M0GW+nIoIOnW0X2B+Hs2GMiHWG NhPCiFbZQTAhu/rqHk9FS1n6YqlM1CQPlumYVisyJm46/iHCei8YVw+9csc734z/UVhv HrHoiwGS70obblZqYNLHPst2Bus1FpmJyvnwlEAhLGlCsKEMLf3gE6kP20xFPYDa95fq TPpVWypFm65Y+SpL+zDWLE1C1+JJVrZD+wOKdVT2/q1fuAuPW6NuhHLVLiKAAjJVJDbD t0BnGM0GyIWEL+kY/E+ZGU7KquN4GTRHJVnqqL+0PeY22B72Ib0o0m4gEG1uIstlEzo1 gE7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=nTisAfsA; 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 uo40-20020a170907cc2800b008b1318fe98bsi4476726ejc.206.2023.02.17.03.03.43; Fri, 17 Feb 2023 03:04:06 -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=nTisAfsA; 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 S229724AbjBQLC0 (ORCPT + 99 others); Fri, 17 Feb 2023 06:02:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjBQLCC (ORCPT ); Fri, 17 Feb 2023 06:02:02 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7516063BCD; Fri, 17 Feb 2023 03:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676631720; x=1708167720; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ds+xcdqyuM0AGf3EleSMTk8z7ILujR2TSv0lkawhf5Q=; b=nTisAfsAfnY5JDN9PKV5dWpBPs099NqS/+o0mrQZyac8jDuH2X279Dew uhOokDJGkYlSVxr9CI4DPSXKozBackFXlgnQOwAm3ts6fqVMScQyqi18P 05Hf+DFOxNxsjK/t2mf+bNh0XntlxgKQb+uobEJ/5j+p6KRFFejvvzYbW dLyRXBOsoV/PST5VH+dmwzIfVLT4BrILs8SvZNYBP/cti9LIeUWL+Lgyk 1t9B5lTNi5Zho6XrOqWZRx4cQRDVeolv/Ako62qwq47KxNSLPTSAAS3f7 tSx1WOixoe499R8/ieoQgPDcz4Wy7Ror+WEN+Ik5XNlRxiJ0ZeFSKMnzN A==; X-IronPort-AV: E=Sophos;i="5.97,304,1669100400"; d="scan'208";a="137756684" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Feb 2023 04:01:59 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.16; Fri, 17 Feb 2023 04:01:59 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 17 Feb 2023 04:01:55 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , , Thangaraj Samynathan Subject: [PATCH v2 net-next 1/5] net: dsa: microchip: add rmon grouping for ethtool statistics Date: Fri, 17 Feb 2023 16:32:07 +0530 Message-ID: <20230217110211.433505-2-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217110211.433505-1-rakesh.sankaranarayanan@microchip.com> References: <20230217110211.433505-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?1758075915928697725?= X-GMAIL-MSGID: =?utf-8?q?1758075915928697725?= 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. Co-developed-by: Thangaraj Samynathan Signed-off-by: Rakesh Sankaranarayanan Signed-off-by: must always be that of the developer submitting the patch. --- 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 | 180 ++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 18 +++ 5 files changed, 217 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 48360cc9fc68..2b698ac39a1f 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 729b36eeb2c4..61f4e23d8849 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -27,6 +27,7 @@ #include #include "ksz_common.h" +#include "ksz_ethtool.h" #include "ksz_ptp.h" #include "ksz8.h" #include "ksz9477.h" @@ -204,6 +205,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .freeze_mib = ksz8_freeze_mib, .port_init_cnt = ksz8_port_init_cnt, .fdb_dump = ksz8_fdb_dump, + .get_rmon_stats = ksz8_get_rmon_stats, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, .vlan_filtering = ksz8_port_vlan_filtering, @@ -241,6 +243,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, @@ -277,6 +280,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, @@ -1730,6 +1734,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) { @@ -3186,6 +3200,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, .get_ts_info = ksz_get_ts_info, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index d2d5761d58e9..a4e53431218c 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -361,6 +361,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..0f3f18545858 --- /dev/null +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -0,0 +1,180 @@ +// 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_CTL, + 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, + 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_CTL, + 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, + 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 Fri Feb 17 11:02:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 58493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp823485wrn; Fri, 17 Feb 2023 03:05:23 -0800 (PST) X-Google-Smtp-Source: AK7set8glprA63j7R8y6YyGbYFPN4umnA1EahaANAxxUhgWX7ZFa+XThYzJjtKw2vJer0vsh6aDg X-Received: by 2002:a05:6a00:1489:b0:594:26a7:cbd2 with SMTP id v9-20020a056a00148900b0059426a7cbd2mr5656709pfu.8.1676631923026; Fri, 17 Feb 2023 03:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631923; cv=none; d=google.com; s=arc-20160816; b=LxQ9rYu7Yq2a+zrsoFfkgLo8fS0Td6Ey48qc6NwlilD/sDPKHh2C5sbKNWlf+nRbgN jkzVlXf0g/hgn0X6IdctS3ny73d+NKSdRSaGTKToclx9tI/ZP3Nikk37VfdSxUypxQzc DcNz63KyZsOf/9bZJxeDsOqGoWCbJ0kl4OliQioMg8UreaejZTygK1pzE/iKfWz3yyNt 31EGpHylkE9iQqtrCsGRDZGSnMeCiDCn4pwbpiSYjetrqR6Ol9ejL7l9gVD4vGfYdldj useRT0ti2F/Xm/mEl51D3T+l6KHjhDN5cgtP1aUWF6oGYSuc0h7nZzItfKC9lJZuqJkk xagA== 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=Fi9wfSVCDJkSnpWsAoMk6Sk5QPlYaz5dNY/qMnEHETg=; b=ZXIbmy5RTHw+B1upya9ux0lIYi0qmg7AS60yMNUhCItlyO7a38VxevVEKxs/fd1zNp pn3DGUFqAocfW4wm+vuy1CqItC29/gN5q1exsOM4uxOsbzLf35dDDtwtMhYlowe/fTa7 szHFsIckRNVLmuwkvUOzlgusWLcICQXJ7CARoSS/AVWCFDvTfqiN8mKPi5RhzjkCIgY/ CCqRlBLS4vqp3LXgGijC6Dv8sWD/ONV50T0O1gP5M3Z1KPj5B2/fLQ1N2mTL4gfL4jl2 kbHGW02zZd5Vy7TVfzDGxQx9JcG8RWPR8ghMhXZJP/nmITbeA/2nM/qfT6oQ8ws/NwuA moJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="xgWeM/zR"; 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 a19-20020a62d413000000b005939fff6d47si4368048pfh.326.2023.02.17.03.05.09; Fri, 17 Feb 2023 03:05:22 -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="xgWeM/zR"; 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 S229806AbjBQLCa (ORCPT + 99 others); Fri, 17 Feb 2023 06:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbjBQLCO (ORCPT ); Fri, 17 Feb 2023 06:02:14 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3B1A644E3; Fri, 17 Feb 2023 03:02:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676631726; x=1708167726; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qQ8jpLCWB3xADM+WiiX2unPMfeq17rScD8SdIVMh6Nk=; b=xgWeM/zR6Qs6Ff3tD5BukDZ5MPDlDW2Tc8AH3YIHtkdaY1WFZWAP9S4W HD31uuQCCMx52b5ZqNrDpv2zNWneXvFgWRlxZbmKMVy9Rj7LnHGalG4JB RvrebxSnKPTApgCb/uDR4k2IU3EoZkP1RNvUBTLpnmZsPGZT0EohXqLnb tUoFz0rx+a9BBdc0urCdQy8N7n7pG0Z06IAHY50mJt9qxwy1VwklGrNXr fw4JkZf0WbI/MYOrUevLh3EL11GNzYZtGiyzyd6UBkQMvgx+bx2zWK188 z0pFBWuf4SeBeRN9JJWa2euIMTxLfxwh4yr9xqwddBoLISGNuUEkhQP7S Q==; X-IronPort-AV: E=Sophos;i="5.97,304,1669100400"; d="scan'208";a="201101352" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Feb 2023 04:02:06 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.16; Fri, 17 Feb 2023 04:02:05 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 17 Feb 2023 04:02:02 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [PATCH v2 net-next 2/5] net: dsa: microchip: add eth ctrl grouping for ethtool statistics Date: Fri, 17 Feb 2023 16:32:08 +0530 Message-ID: <20230217110211.433505-3-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217110211.433505-1-rakesh.sankaranarayanan@microchip.com> References: <20230217110211.433505-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?1758075995415488565?= X-GMAIL-MSGID: =?utf-8?q?1758075995415488565?= 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 61f4e23d8849..91fc7eed79f0 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -206,6 +206,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .port_init_cnt = ksz8_port_init_cnt, .fdb_dump = ksz8_fdb_dump, .get_rmon_stats = ksz8_get_rmon_stats, + .get_eth_ctrl_stats = ksz8_get_eth_ctrl_stats, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, .vlan_filtering = ksz8_port_vlan_filtering, @@ -244,6 +245,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, @@ -281,6 +283,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, @@ -1744,6 +1747,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) { @@ -3201,6 +3213,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, .get_ts_info = ksz_get_ts_info, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index a4e53431218c..7b0219947c7a 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -364,6 +364,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 0f3f18545858..122c4371810a 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -139,6 +139,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) @@ -178,3 +199,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 Fri Feb 17 11:02:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 58494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp823637wrn; Fri, 17 Feb 2023 03:05:49 -0800 (PST) X-Google-Smtp-Source: AK7set8fY0k0jU5qk38mfuhzyVUsLRGBIDrgI/gL8hKiJKWgOqMDTlvggOFznAVrxYRJyYVXJlg0 X-Received: by 2002:aa7:d3c5:0:b0:4ac:b2dc:8d55 with SMTP id o5-20020aa7d3c5000000b004acb2dc8d55mr8336346edr.14.1676631949358; Fri, 17 Feb 2023 03:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631949; cv=none; d=google.com; s=arc-20160816; b=mH3wjfdvuIQTQtlfdVygvYeSLY0jtfFRmzpmQHswtDby0RIbKMQj5Zlwv84TLCCmgc 7cFMh93j9TydNQBy5v/eXhO1Rv0guQRSG1a4ru/YXIAKnqziKFQ0CJDvdv1CErASorhg FDZAIjY4pLJGMlT/NMQ/X53xNR43D7yhLnw/0u8gUxlT4RABB59uc0+vrzQDqB0KuXze D4ShnGsVidbWb8YY6zHQRSLBSEe3lj3VSdvSlObjl6+Dkfn1gUawT+IKcj1AC8SkgkgJ 824trGqHBhofUgO3LnSBvI7YNOqGKOr1uus+nCqYjKiHSEL1jGXNN5UnnUQRv7AgO6IK wk2g== 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=ZqHm3MM8RzyVlAsRRKic5fT5mcN40yJiLrRLxr02U48=; b=MCca9RBBD9uYawGCPcbKt0N33MvAY2ReAqPnpyguzr3s4pUmbbryL0M0O/PJ5jS+n4 Olll5Y52SopZMULOF8+ZyfOi7+qBJ0/onPUQvhh4j6IloduKzuS798QMtg8P62GK9UYj mKrASJHPeO2Z5wa9iXrixng6Bkl2cByQ+VBWOFU9DfGMkfLot6naTPDNWf4PNR2ExtUN EfEdW3qVAH5RonilNAWMqeqg44ljPC2EG2C0I3cUGyORo9rvuFmNw2HACkT9D7roOf2Q c7vSEk2WfqfdlDAg6+a0O59qDJQ3YpendXAw/dut/aLSsyPYhIUaZeWvYjl32X3r3n/B 4H4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=02i8fHAM; 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 l23-20020aa7c3d7000000b004acc19b2698si5032955edr.162.2023.02.17.03.05.17; Fri, 17 Feb 2023 03:05:49 -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=02i8fHAM; 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 S229584AbjBQLCe (ORCPT + 99 others); Fri, 17 Feb 2023 06:02:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229921AbjBQLCR (ORCPT ); Fri, 17 Feb 2023 06:02:17 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6353028D; Fri, 17 Feb 2023 03:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676631731; x=1708167731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TvhosYpnCmaq54jP9gfBjQ65AsWAKLJ0NHHkCvJYYsE=; b=02i8fHAMnIOCfyGqS8UJ0QkFaAGsB+0AEbhmpkN6vb7DXXmaEdVo/ApL Utv9kWRqzuP2fD5ZtX9ibSBTk9VZpthUJjDODR0Lda62vXFZIxekevgvY gurmeNau07If7VUybKvE74EHQxwNEwRwWvYotmY7cWlAuJeg8yYmOKfDo 20LcTa9r2PyOmQ4/oLOvS9svyqakWVkw2AhFI1YA2157nZrNs+X03keom J3l5bkNdlPNimbdcnBawm1ZgyfaRnl8fnXeDk0lwAatTqrC1gHIgJiDfW ex092jZ6353EQEdpOSpQDTgDGXrYY6znvVJcoO0qGi5PQDgusRVUjVDfj Q==; X-IronPort-AV: E=Sophos;i="5.97,304,1669100400"; d="scan'208";a="212497761" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Feb 2023 04:02:10 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 17 Feb 2023 04:02:10 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 17 Feb 2023 04:02:07 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [PATCH v2 net-next 3/5] net: dsa: microchip: add eth mac grouping for ethtool statistics Date: Fri, 17 Feb 2023 16:32:09 +0530 Message-ID: <20230217110211.433505-4-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217110211.433505-1-rakesh.sankaranarayanan@microchip.com> References: <20230217110211.433505-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?1758076023284085257?= X-GMAIL-MSGID: =?utf-8?q?1758076023284085257?= 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 | 90 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_ethtool.h | 4 ++ 4 files changed, 109 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 91fc7eed79f0..e4a51f13afa4 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -207,6 +207,7 @@ static const struct ksz_dev_ops ksz8_dev_ops = { .fdb_dump = ksz8_fdb_dump, .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, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, .vlan_filtering = ksz8_port_vlan_filtering, @@ -246,6 +247,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, @@ -284,6 +286,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, @@ -1756,6 +1759,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) { @@ -3214,6 +3226,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, .get_ts_info = ksz_get_ts_info, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 7b0219947c7a..738e81923c31 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -366,6 +366,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 122c4371810a..42954bbfb9b4 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -160,6 +160,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] - + ctr[KSZ8_TX_DISCARDS]; + 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] + + ctr[KSZ8_RX_DISCARDS]; + mac_stats->FrameCheckSequenceErrors = ctr[KSZ8_RX_CRC_ERR]; + mac_stats->AlignmentErrors = ctr[KSZ8_RX_ALIGN_ERR]; + 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]; + + 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) @@ -220,3 +264,49 @@ 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] - + ctr[KSZ9477_TX_DISCARDS]; + 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] + + ctr[KSZ9477_RX_DISCARDS]; + mac_stats->FrameCheckSequenceErrors = ctr[KSZ9477_RX_CRC_ERR]; + mac_stats->AlignmentErrors = ctr[KSZ9477_RX_ALIGN_ERR]; + mac_stats->OctetsTransmittedOK = ctr[KSZ9477_TX_TOTAL] - + (18 * mac_stats->FramesTransmittedOK); + 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]; + + 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 Fri Feb 17 11:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 58495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp823680wrn; Fri, 17 Feb 2023 03:05:54 -0800 (PST) X-Google-Smtp-Source: AK7set/Q/Y3PN38CgVF6kWZZIrN8B3h+TnJRfPd6gBJ0CJkVH8msKBtB3EzMjwqqfYH7snLnuZjd X-Received: by 2002:a17:903:1d2:b0:19a:a6ec:6726 with SMTP id e18-20020a17090301d200b0019aa6ec6726mr371749plh.10.1676631954386; Fri, 17 Feb 2023 03:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631954; cv=none; d=google.com; s=arc-20160816; b=rhm4dtFHgHT0b6dDXLfOKRx9KlO/BcZwL88cRW+E76vWcizI8rCTqKpdDbxaHHnQhL BOQzqjlnbF4lEP0gZVpnxL05SuQqXe/G4uXXg8RmvnpLTkmkcpIA8+fP+q3L91169OHz gegM9Ea/1y3g2+sYIcCTEGQV1h2nEik7kHoYGuokN8oNqFAMe0oLZpZn4nEi0XojnDyp M/7bH8eGCDdCzOfHjs5xqwAdG5O6tdO+YlzqaHrvnQuDecNnL7V/iB7li/o5k1fH40Lj AzV6hMQ2Ln4CpowbgZKUATJFOjPyVt1GcnwwB2VG9TK5GWfo5gqvKVbm529R2En8skPe qonw== 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=GOm6q5Vs4IvHzqRLRCpapDpRO7HRIhvAWQfJRVSaPsQ=; b=vVbuI6zVMizfLCiiAwQ/h1eeGMCciMItyCj+iyu8hZk5aYvgpYxPYDjeQSXorHaU7M y9j2NPLSOT/Y/JjBd/iJAepFAuI0ZuUqZp0eR2gwDNGJYSovN98wKhZEVPaJW9rN76rK iYACU5Lo9jmwr07irSC9tvxf1t00K6pLq5ZfDC7KYlL4OOYY97nYZ80m+Inas+COqmv+ a4XmkOd6HVp7kQuod8Z3N+P9R2jMgyNxXSDG6NkSh1iP7M734qivDKXUVu4O5n+RLut7 sQpIqVsGh/hKsbVZePFHXmGznxygIE6MYHjAdnAPRXbjXwcJ04zUTpsq8PzO9PkHpFKV eePw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=r2CeWCvX; 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 ld11-20020a170902facb00b0019b0c357c8fsi2623835plb.340.2023.02.17.03.05.41; Fri, 17 Feb 2023 03:05:54 -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=r2CeWCvX; 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 S229907AbjBQLCg (ORCPT + 99 others); Fri, 17 Feb 2023 06:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbjBQLCW (ORCPT ); Fri, 17 Feb 2023 06:02:22 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 072A83028D; Fri, 17 Feb 2023 03:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676631740; x=1708167740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xuAQHwlijF+Yj0VX+hzdHh3BDSnnpTYis5wdwFZYBCU=; b=r2CeWCvXHU0dxcrwPxxhXf7bABxpbm/Y1ur/5GqiCLVCkoPo8R0EBueP qY66D4fdOl8gGXftvI4pkrzjUvdBV9FOgePpD3t31aN5DMi2kuq9AVOE7 ti0lGWA75ZwGI4Nl0I5PVoYAS9147j5/M/QEe2oEQWseSaZJ7Dn+/dJBC 5ZZfZGxg3wQgv1gSTtONZG8rLpFF1/0xR0Ye2rKniRFRI4Q9Z1hOLKc50 T9HVJUFMpJiUrJVJXYd4oR4yqVvOTX6Wm/uQv+YPp5BpfOK18TyWXn3pe +w8IjXJC/BpbvdTMeQjvwqeh7YsUINlAkOgakGJjvlYju9Ypk7t+9P1Qt g==; X-IronPort-AV: E=Sophos;i="5.97,304,1669100400"; d="scan'208";a="201101386" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Feb 2023 04:02:20 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.16; Fri, 17 Feb 2023 04:02:15 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 17 Feb 2023 04:02:12 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [PATCH v2 net-next 4/5] net: dsa: microchip: add eth phy grouping for ethtool statistics Date: Fri, 17 Feb 2023 16:32:10 +0530 Message-ID: <20230217110211.433505-5-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217110211.433505-1-rakesh.sankaranarayanan@microchip.com> References: <20230217110211.433505-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?1758076027736354328?= X-GMAIL-MSGID: =?utf-8?q?1758076027736354328?= 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 e4a51f13afa4..01adcbeffaaa 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -208,6 +208,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, .mdb_add = ksz8_mdb_add, .mdb_del = ksz8_mdb_del, .vlan_filtering = ksz8_port_vlan_filtering, @@ -248,6 +249,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, @@ -287,6 +289,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, @@ -1768,6 +1771,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) { @@ -3227,6 +3239,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, .get_ts_info = ksz_get_ts_info, diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 738e81923c31..8a71e035b699 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -368,6 +368,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 42954bbfb9b4..c0b95d78e41e 100644 --- a/drivers/net/dsa/microchip/ksz_ethtool.c +++ b/drivers/net/dsa/microchip/ksz_ethtool.c @@ -204,6 +204,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) @@ -310,3 +328,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 Fri Feb 17 11:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Sankaranarayanan X-Patchwork-Id: 58496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp823805wrn; Fri, 17 Feb 2023 03:06:11 -0800 (PST) X-Google-Smtp-Source: AK7set9bzFHgzKU199d7vmQUyyWWw++4ro/cAjdFywDcpXk5psGgXCkNCV2r98r/roCJwGPl8Kcf X-Received: by 2002:a05:6402:1b1c:b0:4ac:b32d:3dab with SMTP id by28-20020a0564021b1c00b004acb32d3dabmr1035434edb.29.1676631971135; Fri, 17 Feb 2023 03:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676631971; cv=none; d=google.com; s=arc-20160816; b=mv2Z8GVeFfUBZXyhpykvDOOTEfwokJh4TQ+ydaSGEhojIC/+naNelc4lM0pxWi1k/z sZtpQUL2Z2kZO6BXYGjQ54JYNrZudNCyG3vEeWzipIn8oBoUMgkzh2ufs0L6rSoAbNOn nFLOBogRo4TycxAxePL8sG/b7uepQY2sHjIkXAFP9K3jbVuS+j7pUNR3n8/DrtQhWSLC zHEzcLx5fkzqh2GpGup8hr7X4GZ0bZVBdIjsYJa5/MfnVLYXVa3nAakAg8WassLAPFVq DjIkyxUTfd497MFbjxkkaq2TBBu7pxhv6neY1q5ViDN6ZsVj3dpxEGLF577rOiGowBYF 7FOA== 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=4wgC1MXXuMVoHlL2Ob6ArifVyJX2qrzYEuZ44S5SKTQ=; b=vNtcwHCFbPFp9TseJ9BNMHmT0gufihvpUwWFfi+NwtQwgyBntJGI2jGQnCFQHp8qh0 2RE/CbQtZDL3lqJ5g0jusVxYDegHM3jBXKvuVvlnF9sWq3xdxXPzQK00pwRyNmsS51Zw tdeFUb1tjmsTimPlq3H7dvkGVxX7zFTZT9sRnNGwXFBKPrAo/DHSO2CgkoJX6Kj8mxVB RXCwN4UZD9pmQk5m2GFcNm5m32CcA16YP+8zbq95GnoYcsOEh1nLMQ4mQKsMvJlD7uYE BwXLE4SOi9LQi117vp7V8Hu2x3mMRlz/M+DCY27UwEvHgo2NUIsCp2ozpv/lGBVriwLd KGCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=eQNrVXFD; 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 c19-20020aa7c753000000b004acda484377si4692127eds.485.2023.02.17.03.05.44; Fri, 17 Feb 2023 03:06:11 -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=eQNrVXFD; 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 S229930AbjBQLCi (ORCPT + 99 others); Fri, 17 Feb 2023 06:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbjBQLCY (ORCPT ); Fri, 17 Feb 2023 06:02:24 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A095E62439; Fri, 17 Feb 2023 03:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1676631742; x=1708167742; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F2mURk/fbobB4rI6EopNkBH1Wbw2zILKSpSvtFfxyOs=; b=eQNrVXFDEmZzuAZDqlRVBTjeGoRydN9SESgFhTA4pQ9PUpAOAeuxXc1B kZUtuaahjaGYvQATNYZOvO7gFqwNFJsmBSyh0KDGdxO1CvFkOwxXAeNOv ylZPs1AbZOHGv04ZnH8us0rVMhGVboPYvsTNBRGpxLdeeEvObaI+9c0mV 5NTtv6R0QOp4Z1lLdcoe6ZkpweKpYAg76RxK4gD1JxiCFqzJIMkt63Mim Kh4z27MoxPhO+QxIARXFwFiyOgNXBckNZzpW+G4YaSrbUx67QTMik84oz INmU2O+o0CUjlmbZHERgjBokzEXqEXmLtg0jC0Xq/LbWoVXOZSCotp6mH Q==; X-IronPort-AV: E=Sophos;i="5.97,304,1669100400"; d="scan'208";a="201101424" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Feb 2023 04:02:21 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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.16; Fri, 17 Feb 2023 04:02:20 -0700 Received: from che-lt-i67786lx.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 17 Feb 2023 04:02:17 -0700 From: Rakesh Sankaranarayanan To: , CC: , , , , , , , , Subject: [PATCH v2 net-next 5/5] net: dsa: microchip: remove num_alus_variable Date: Fri, 17 Feb 2023 16:32:11 +0530 Message-ID: <20230217110211.433505-6-rakesh.sankaranarayanan@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217110211.433505-1-rakesh.sankaranarayanan@microchip.com> References: <20230217110211.433505-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?1758076045644458104?= X-GMAIL-MSGID: =?utf-8?q?1758076045644458104?= 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 01adcbeffaaa..152f68eda355 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1095,7 +1095,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 */ @@ -1124,7 +1123,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 */ @@ -1163,7 +1161,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 */ @@ -1188,7 +1185,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 */ @@ -1213,7 +1209,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, @@ -1234,7 +1229,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 */ @@ -1268,7 +1262,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 */ @@ -1301,7 +1294,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 */ @@ -1332,7 +1324,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 */ @@ -1358,7 +1349,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 */ @@ -1385,7 +1375,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 */ @@ -1417,7 +1406,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 */ @@ -1443,7 +1431,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 */ @@ -1469,7 +1456,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 */ @@ -1499,7 +1485,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 */ @@ -1529,7 +1514,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 8a71e035b699..40c4f5f2d9d5 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -44,7 +44,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;