From nobody Thu Dec 18 13:01:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86440C32772 for ; Tue, 23 Aug 2022 09:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348223AbiHWJIf (ORCPT ); Tue, 23 Aug 2022 05:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347959AbiHWJHX (ORCPT ); Tue, 23 Aug 2022 05:07:23 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB0C861F7; Tue, 23 Aug 2022 01:30:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 77D0FCE1B40; Tue, 23 Aug 2022 08:29:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C977C433C1; Tue, 23 Aug 2022 08:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243363; bh=HrtdRP3M5t5rCJ+EvLj3UpIdzU7gplhRQ6l4rCEq1CY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=va2m+Eunn9FkS3VQzir4BRXcuPt8ObVGOEylbbF8Y1Bj3tSh2N/t9kRTGoXjcZXQh Nl/qdjz6Nr3hxeYgnrsRWYqmTgRcIQIl67M5pjUkLYQwxMzoUFbIO27gh71tgam1qJ 9rw0KE3IwFvotWJop3Pn5jLOhh2/G/mQTG3cF2vo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.19 253/365] net: mscc: ocelot: make struct ocelot_stat_layout array indexable Date: Tue, 23 Aug 2022 10:02:34 +0200 Message-Id: <20220823080128.778682232@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Vladimir Oltean [ Upstream commit 9190460084ddd0e9235f55eab0fdd5456b5f2fd5 ] The ocelot counters are 32-bit and require periodic reading, every 2 seconds, by ocelot_port_update_stats(), so that wraparounds are detected. Currently, the counters reported by ocelot_get_stats64() come from the 32-bit hardware counters directly, rather than from the 64-bit accumulated ocelot->stats, and this is a problem for their integrity. The strategy is to make ocelot_get_stats64() able to cherry-pick individual stats from ocelot->stats the way in which it currently reads them out from SYS_COUNT_* registers. But currently it can't, because ocelot->stats is an opaque u64 array that's used only to feed data into ethtool -S. To solve that problem, we need to make ocelot->stats indexable, and associate each element with an element of struct ocelot_stat_layout used by ethtool -S. This makes ocelot_stat_layout a fat (and possibly sparse) array, so we need to change the way in which we access it. We no longer need OCELOT_STAT_END as a sentinel, because we know the array's size (OCELOT_NUM_STATS). We just need to skip the array elements that were left unpopulated for the switch revision (ocelot, felix, seville). Signed-off-by: Vladimir Oltean Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/dsa/ocelot/felix_vsc9959.c | 468 ++++++++++++++++----- drivers/net/dsa/ocelot/seville_vsc9953.c | 468 ++++++++++++++++----- drivers/net/ethernet/mscc/ocelot.c | 40 +- drivers/net/ethernet/mscc/ocelot_vsc7514.c | 468 ++++++++++++++++----- include/soc/mscc/ocelot.h | 105 ++++- 5 files changed, 1243 insertions(+), 306 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelo= t/felix_vsc9959.c index 601fae886b26..6439b56f381f 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -550,101 +550,379 @@ static const struct reg_field vsc9959_regfields[REG= FIELD_MAX] =3D { [SYS_PAUSE_CFG_PAUSE_ENA] =3D REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 7, 4), }; =20 -static const struct ocelot_stat_layout vsc9959_stats_layout[] =3D { - { .offset =3D 0x00, .name =3D "rx_octets", }, - { .offset =3D 0x01, .name =3D "rx_unicast", }, - { .offset =3D 0x02, .name =3D "rx_multicast", }, - { .offset =3D 0x03, .name =3D "rx_broadcast", }, - { .offset =3D 0x04, .name =3D "rx_shorts", }, - { .offset =3D 0x05, .name =3D "rx_fragments", }, - { .offset =3D 0x06, .name =3D "rx_jabbers", }, - { .offset =3D 0x07, .name =3D "rx_crc_align_errs", }, - { .offset =3D 0x08, .name =3D "rx_sym_errs", }, - { .offset =3D 0x09, .name =3D "rx_frames_below_65_octets", }, - { .offset =3D 0x0A, .name =3D "rx_frames_65_to_127_octets", }, - { .offset =3D 0x0B, .name =3D "rx_frames_128_to_255_octets", }, - { .offset =3D 0x0C, .name =3D "rx_frames_256_to_511_octets", }, - { .offset =3D 0x0D, .name =3D "rx_frames_512_to_1023_octets", }, - { .offset =3D 0x0E, .name =3D "rx_frames_1024_to_1526_octets", }, - { .offset =3D 0x0F, .name =3D "rx_frames_over_1526_octets", }, - { .offset =3D 0x10, .name =3D "rx_pause", }, - { .offset =3D 0x11, .name =3D "rx_control", }, - { .offset =3D 0x12, .name =3D "rx_longs", }, - { .offset =3D 0x13, .name =3D "rx_classified_drops", }, - { .offset =3D 0x14, .name =3D "rx_red_prio_0", }, - { .offset =3D 0x15, .name =3D "rx_red_prio_1", }, - { .offset =3D 0x16, .name =3D "rx_red_prio_2", }, - { .offset =3D 0x17, .name =3D "rx_red_prio_3", }, - { .offset =3D 0x18, .name =3D "rx_red_prio_4", }, - { .offset =3D 0x19, .name =3D "rx_red_prio_5", }, - { .offset =3D 0x1A, .name =3D "rx_red_prio_6", }, - { .offset =3D 0x1B, .name =3D "rx_red_prio_7", }, - { .offset =3D 0x1C, .name =3D "rx_yellow_prio_0", }, - { .offset =3D 0x1D, .name =3D "rx_yellow_prio_1", }, - { .offset =3D 0x1E, .name =3D "rx_yellow_prio_2", }, - { .offset =3D 0x1F, .name =3D "rx_yellow_prio_3", }, - { .offset =3D 0x20, .name =3D "rx_yellow_prio_4", }, - { .offset =3D 0x21, .name =3D "rx_yellow_prio_5", }, - { .offset =3D 0x22, .name =3D "rx_yellow_prio_6", }, - { .offset =3D 0x23, .name =3D "rx_yellow_prio_7", }, - { .offset =3D 0x24, .name =3D "rx_green_prio_0", }, - { .offset =3D 0x25, .name =3D "rx_green_prio_1", }, - { .offset =3D 0x26, .name =3D "rx_green_prio_2", }, - { .offset =3D 0x27, .name =3D "rx_green_prio_3", }, - { .offset =3D 0x28, .name =3D "rx_green_prio_4", }, - { .offset =3D 0x29, .name =3D "rx_green_prio_5", }, - { .offset =3D 0x2A, .name =3D "rx_green_prio_6", }, - { .offset =3D 0x2B, .name =3D "rx_green_prio_7", }, - { .offset =3D 0x80, .name =3D "tx_octets", }, - { .offset =3D 0x81, .name =3D "tx_unicast", }, - { .offset =3D 0x82, .name =3D "tx_multicast", }, - { .offset =3D 0x83, .name =3D "tx_broadcast", }, - { .offset =3D 0x84, .name =3D "tx_collision", }, - { .offset =3D 0x85, .name =3D "tx_drops", }, - { .offset =3D 0x86, .name =3D "tx_pause", }, - { .offset =3D 0x87, .name =3D "tx_frames_below_65_octets", }, - { .offset =3D 0x88, .name =3D "tx_frames_65_to_127_octets", }, - { .offset =3D 0x89, .name =3D "tx_frames_128_255_octets", }, - { .offset =3D 0x8A, .name =3D "tx_frames_256_511_octets", }, - { .offset =3D 0x8B, .name =3D "tx_frames_512_1023_octets", }, - { .offset =3D 0x8C, .name =3D "tx_frames_1024_1526_octets", }, - { .offset =3D 0x8D, .name =3D "tx_frames_over_1526_octets", }, - { .offset =3D 0x8E, .name =3D "tx_yellow_prio_0", }, - { .offset =3D 0x8F, .name =3D "tx_yellow_prio_1", }, - { .offset =3D 0x90, .name =3D "tx_yellow_prio_2", }, - { .offset =3D 0x91, .name =3D "tx_yellow_prio_3", }, - { .offset =3D 0x92, .name =3D "tx_yellow_prio_4", }, - { .offset =3D 0x93, .name =3D "tx_yellow_prio_5", }, - { .offset =3D 0x94, .name =3D "tx_yellow_prio_6", }, - { .offset =3D 0x95, .name =3D "tx_yellow_prio_7", }, - { .offset =3D 0x96, .name =3D "tx_green_prio_0", }, - { .offset =3D 0x97, .name =3D "tx_green_prio_1", }, - { .offset =3D 0x98, .name =3D "tx_green_prio_2", }, - { .offset =3D 0x99, .name =3D "tx_green_prio_3", }, - { .offset =3D 0x9A, .name =3D "tx_green_prio_4", }, - { .offset =3D 0x9B, .name =3D "tx_green_prio_5", }, - { .offset =3D 0x9C, .name =3D "tx_green_prio_6", }, - { .offset =3D 0x9D, .name =3D "tx_green_prio_7", }, - { .offset =3D 0x9E, .name =3D "tx_aged", }, - { .offset =3D 0x100, .name =3D "drop_local", }, - { .offset =3D 0x101, .name =3D "drop_tail", }, - { .offset =3D 0x102, .name =3D "drop_yellow_prio_0", }, - { .offset =3D 0x103, .name =3D "drop_yellow_prio_1", }, - { .offset =3D 0x104, .name =3D "drop_yellow_prio_2", }, - { .offset =3D 0x105, .name =3D "drop_yellow_prio_3", }, - { .offset =3D 0x106, .name =3D "drop_yellow_prio_4", }, - { .offset =3D 0x107, .name =3D "drop_yellow_prio_5", }, - { .offset =3D 0x108, .name =3D "drop_yellow_prio_6", }, - { .offset =3D 0x109, .name =3D "drop_yellow_prio_7", }, - { .offset =3D 0x10A, .name =3D "drop_green_prio_0", }, - { .offset =3D 0x10B, .name =3D "drop_green_prio_1", }, - { .offset =3D 0x10C, .name =3D "drop_green_prio_2", }, - { .offset =3D 0x10D, .name =3D "drop_green_prio_3", }, - { .offset =3D 0x10E, .name =3D "drop_green_prio_4", }, - { .offset =3D 0x10F, .name =3D "drop_green_prio_5", }, - { .offset =3D 0x110, .name =3D "drop_green_prio_6", }, - { .offset =3D 0x111, .name =3D "drop_green_prio_7", }, - OCELOT_STAT_END +static const struct ocelot_stat_layout vsc9959_stats_layout[OCELOT_NUM_STA= TS] =3D { + [OCELOT_STAT_RX_OCTETS] =3D { + .name =3D "rx_octets", + .offset =3D 0x00, + }, + [OCELOT_STAT_RX_UNICAST] =3D { + .name =3D "rx_unicast", + .offset =3D 0x01, + }, + [OCELOT_STAT_RX_MULTICAST] =3D { + .name =3D "rx_multicast", + .offset =3D 0x02, + }, + [OCELOT_STAT_RX_BROADCAST] =3D { + .name =3D "rx_broadcast", + .offset =3D 0x03, + }, + [OCELOT_STAT_RX_SHORTS] =3D { + .name =3D "rx_shorts", + .offset =3D 0x04, + }, + [OCELOT_STAT_RX_FRAGMENTS] =3D { + .name =3D "rx_fragments", + .offset =3D 0x05, + }, + [OCELOT_STAT_RX_JABBERS] =3D { + .name =3D "rx_jabbers", + .offset =3D 0x06, + }, + [OCELOT_STAT_RX_CRC_ALIGN_ERRS] =3D { + .name =3D "rx_crc_align_errs", + .offset =3D 0x07, + }, + [OCELOT_STAT_RX_SYM_ERRS] =3D { + .name =3D "rx_sym_errs", + .offset =3D 0x08, + }, + [OCELOT_STAT_RX_64] =3D { + .name =3D "rx_frames_below_65_octets", + .offset =3D 0x09, + }, + [OCELOT_STAT_RX_65_127] =3D { + .name =3D "rx_frames_65_to_127_octets", + .offset =3D 0x0A, + }, + [OCELOT_STAT_RX_128_255] =3D { + .name =3D "rx_frames_128_to_255_octets", + .offset =3D 0x0B, + }, + [OCELOT_STAT_RX_256_511] =3D { + .name =3D "rx_frames_256_to_511_octets", + .offset =3D 0x0C, + }, + [OCELOT_STAT_RX_512_1023] =3D { + .name =3D "rx_frames_512_to_1023_octets", + .offset =3D 0x0D, + }, + [OCELOT_STAT_RX_1024_1526] =3D { + .name =3D "rx_frames_1024_to_1526_octets", + .offset =3D 0x0E, + }, + [OCELOT_STAT_RX_1527_MAX] =3D { + .name =3D "rx_frames_over_1526_octets", + .offset =3D 0x0F, + }, + [OCELOT_STAT_RX_PAUSE] =3D { + .name =3D "rx_pause", + .offset =3D 0x10, + }, + [OCELOT_STAT_RX_CONTROL] =3D { + .name =3D "rx_control", + .offset =3D 0x11, + }, + [OCELOT_STAT_RX_LONGS] =3D { + .name =3D "rx_longs", + .offset =3D 0x12, + }, + [OCELOT_STAT_RX_CLASSIFIED_DROPS] =3D { + .name =3D "rx_classified_drops", + .offset =3D 0x13, + }, + [OCELOT_STAT_RX_RED_PRIO_0] =3D { + .name =3D "rx_red_prio_0", + .offset =3D 0x14, + }, + [OCELOT_STAT_RX_RED_PRIO_1] =3D { + .name =3D "rx_red_prio_1", + .offset =3D 0x15, + }, + [OCELOT_STAT_RX_RED_PRIO_2] =3D { + .name =3D "rx_red_prio_2", + .offset =3D 0x16, + }, + [OCELOT_STAT_RX_RED_PRIO_3] =3D { + .name =3D "rx_red_prio_3", + .offset =3D 0x17, + }, + [OCELOT_STAT_RX_RED_PRIO_4] =3D { + .name =3D "rx_red_prio_4", + .offset =3D 0x18, + }, + [OCELOT_STAT_RX_RED_PRIO_5] =3D { + .name =3D "rx_red_prio_5", + .offset =3D 0x19, + }, + [OCELOT_STAT_RX_RED_PRIO_6] =3D { + .name =3D "rx_red_prio_6", + .offset =3D 0x1A, + }, + [OCELOT_STAT_RX_RED_PRIO_7] =3D { + .name =3D "rx_red_prio_7", + .offset =3D 0x1B, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_0] =3D { + .name =3D "rx_yellow_prio_0", + .offset =3D 0x1C, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_1] =3D { + .name =3D "rx_yellow_prio_1", + .offset =3D 0x1D, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_2] =3D { + .name =3D "rx_yellow_prio_2", + .offset =3D 0x1E, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_3] =3D { + .name =3D "rx_yellow_prio_3", + .offset =3D 0x1F, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_4] =3D { + .name =3D "rx_yellow_prio_4", + .offset =3D 0x20, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_5] =3D { + .name =3D "rx_yellow_prio_5", + .offset =3D 0x21, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_6] =3D { + .name =3D "rx_yellow_prio_6", + .offset =3D 0x22, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_7] =3D { + .name =3D "rx_yellow_prio_7", + .offset =3D 0x23, + }, + [OCELOT_STAT_RX_GREEN_PRIO_0] =3D { + .name =3D "rx_green_prio_0", + .offset =3D 0x24, + }, + [OCELOT_STAT_RX_GREEN_PRIO_1] =3D { + .name =3D "rx_green_prio_1", + .offset =3D 0x25, + }, + [OCELOT_STAT_RX_GREEN_PRIO_2] =3D { + .name =3D "rx_green_prio_2", + .offset =3D 0x26, + }, + [OCELOT_STAT_RX_GREEN_PRIO_3] =3D { + .name =3D "rx_green_prio_3", + .offset =3D 0x27, + }, + [OCELOT_STAT_RX_GREEN_PRIO_4] =3D { + .name =3D "rx_green_prio_4", + .offset =3D 0x28, + }, + [OCELOT_STAT_RX_GREEN_PRIO_5] =3D { + .name =3D "rx_green_prio_5", + .offset =3D 0x29, + }, + [OCELOT_STAT_RX_GREEN_PRIO_6] =3D { + .name =3D "rx_green_prio_6", + .offset =3D 0x2A, + }, + [OCELOT_STAT_RX_GREEN_PRIO_7] =3D { + .name =3D "rx_green_prio_7", + .offset =3D 0x2B, + }, + [OCELOT_STAT_TX_OCTETS] =3D { + .name =3D "tx_octets", + .offset =3D 0x80, + }, + [OCELOT_STAT_TX_UNICAST] =3D { + .name =3D "tx_unicast", + .offset =3D 0x81, + }, + [OCELOT_STAT_TX_MULTICAST] =3D { + .name =3D "tx_multicast", + .offset =3D 0x82, + }, + [OCELOT_STAT_TX_BROADCAST] =3D { + .name =3D "tx_broadcast", + .offset =3D 0x83, + }, + [OCELOT_STAT_TX_COLLISION] =3D { + .name =3D "tx_collision", + .offset =3D 0x84, + }, + [OCELOT_STAT_TX_DROPS] =3D { + .name =3D "tx_drops", + .offset =3D 0x85, + }, + [OCELOT_STAT_TX_PAUSE] =3D { + .name =3D "tx_pause", + .offset =3D 0x86, + }, + [OCELOT_STAT_TX_64] =3D { + .name =3D "tx_frames_below_65_octets", + .offset =3D 0x87, + }, + [OCELOT_STAT_TX_65_127] =3D { + .name =3D "tx_frames_65_to_127_octets", + .offset =3D 0x88, + }, + [OCELOT_STAT_TX_128_255] =3D { + .name =3D "tx_frames_128_255_octets", + .offset =3D 0x89, + }, + [OCELOT_STAT_TX_256_511] =3D { + .name =3D "tx_frames_256_511_octets", + .offset =3D 0x8A, + }, + [OCELOT_STAT_TX_512_1023] =3D { + .name =3D "tx_frames_512_1023_octets", + .offset =3D 0x8B, + }, + [OCELOT_STAT_TX_1024_1526] =3D { + .name =3D "tx_frames_1024_1526_octets", + .offset =3D 0x8C, + }, + [OCELOT_STAT_TX_1527_MAX] =3D { + .name =3D "tx_frames_over_1526_octets", + .offset =3D 0x8D, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_0] =3D { + .name =3D "tx_yellow_prio_0", + .offset =3D 0x8E, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_1] =3D { + .name =3D "tx_yellow_prio_1", + .offset =3D 0x8F, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_2] =3D { + .name =3D "tx_yellow_prio_2", + .offset =3D 0x90, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_3] =3D { + .name =3D "tx_yellow_prio_3", + .offset =3D 0x91, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_4] =3D { + .name =3D "tx_yellow_prio_4", + .offset =3D 0x92, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_5] =3D { + .name =3D "tx_yellow_prio_5", + .offset =3D 0x93, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_6] =3D { + .name =3D "tx_yellow_prio_6", + .offset =3D 0x94, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_7] =3D { + .name =3D "tx_yellow_prio_7", + .offset =3D 0x95, + }, + [OCELOT_STAT_TX_GREEN_PRIO_0] =3D { + .name =3D "tx_green_prio_0", + .offset =3D 0x96, + }, + [OCELOT_STAT_TX_GREEN_PRIO_1] =3D { + .name =3D "tx_green_prio_1", + .offset =3D 0x97, + }, + [OCELOT_STAT_TX_GREEN_PRIO_2] =3D { + .name =3D "tx_green_prio_2", + .offset =3D 0x98, + }, + [OCELOT_STAT_TX_GREEN_PRIO_3] =3D { + .name =3D "tx_green_prio_3", + .offset =3D 0x99, + }, + [OCELOT_STAT_TX_GREEN_PRIO_4] =3D { + .name =3D "tx_green_prio_4", + .offset =3D 0x9A, + }, + [OCELOT_STAT_TX_GREEN_PRIO_5] =3D { + .name =3D "tx_green_prio_5", + .offset =3D 0x9B, + }, + [OCELOT_STAT_TX_GREEN_PRIO_6] =3D { + .name =3D "tx_green_prio_6", + .offset =3D 0x9C, + }, + [OCELOT_STAT_TX_GREEN_PRIO_7] =3D { + .name =3D "tx_green_prio_7", + .offset =3D 0x9D, + }, + [OCELOT_STAT_TX_AGED] =3D { + .name =3D "tx_aged", + .offset =3D 0x9E, + }, + [OCELOT_STAT_DROP_LOCAL] =3D { + .name =3D "drop_local", + .offset =3D 0x100, + }, + [OCELOT_STAT_DROP_TAIL] =3D { + .name =3D "drop_tail", + .offset =3D 0x101, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_0] =3D { + .name =3D "drop_yellow_prio_0", + .offset =3D 0x102, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_1] =3D { + .name =3D "drop_yellow_prio_1", + .offset =3D 0x103, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_2] =3D { + .name =3D "drop_yellow_prio_2", + .offset =3D 0x104, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_3] =3D { + .name =3D "drop_yellow_prio_3", + .offset =3D 0x105, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_4] =3D { + .name =3D "drop_yellow_prio_4", + .offset =3D 0x106, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_5] =3D { + .name =3D "drop_yellow_prio_5", + .offset =3D 0x107, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_6] =3D { + .name =3D "drop_yellow_prio_6", + .offset =3D 0x108, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_7] =3D { + .name =3D "drop_yellow_prio_7", + .offset =3D 0x109, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_0] =3D { + .name =3D "drop_green_prio_0", + .offset =3D 0x10A, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_1] =3D { + .name =3D "drop_green_prio_1", + .offset =3D 0x10B, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_2] =3D { + .name =3D "drop_green_prio_2", + .offset =3D 0x10C, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_3] =3D { + .name =3D "drop_green_prio_3", + .offset =3D 0x10D, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_4] =3D { + .name =3D "drop_green_prio_4", + .offset =3D 0x10E, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_5] =3D { + .name =3D "drop_green_prio_5", + .offset =3D 0x10F, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_6] =3D { + .name =3D "drop_green_prio_6", + .offset =3D 0x110, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_7] =3D { + .name =3D "drop_green_prio_7", + .offset =3D 0x111, + }, }; =20 static const struct vcap_field vsc9959_vcap_es0_keys[] =3D { diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/oce= lot/seville_vsc9953.c index ebe9ddbbe2b7..fe5d4642d0bc 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -545,101 +545,379 @@ static const struct reg_field vsc9953_regfields[REG= FIELD_MAX] =3D { [SYS_PAUSE_CFG_PAUSE_ENA] =3D REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 11, 4), }; =20 -static const struct ocelot_stat_layout vsc9953_stats_layout[] =3D { - { .offset =3D 0x00, .name =3D "rx_octets", }, - { .offset =3D 0x01, .name =3D "rx_unicast", }, - { .offset =3D 0x02, .name =3D "rx_multicast", }, - { .offset =3D 0x03, .name =3D "rx_broadcast", }, - { .offset =3D 0x04, .name =3D "rx_shorts", }, - { .offset =3D 0x05, .name =3D "rx_fragments", }, - { .offset =3D 0x06, .name =3D "rx_jabbers", }, - { .offset =3D 0x07, .name =3D "rx_crc_align_errs", }, - { .offset =3D 0x08, .name =3D "rx_sym_errs", }, - { .offset =3D 0x09, .name =3D "rx_frames_below_65_octets", }, - { .offset =3D 0x0A, .name =3D "rx_frames_65_to_127_octets", }, - { .offset =3D 0x0B, .name =3D "rx_frames_128_to_255_octets", }, - { .offset =3D 0x0C, .name =3D "rx_frames_256_to_511_octets", }, - { .offset =3D 0x0D, .name =3D "rx_frames_512_to_1023_octets", }, - { .offset =3D 0x0E, .name =3D "rx_frames_1024_to_1526_octets", }, - { .offset =3D 0x0F, .name =3D "rx_frames_over_1526_octets", }, - { .offset =3D 0x10, .name =3D "rx_pause", }, - { .offset =3D 0x11, .name =3D "rx_control", }, - { .offset =3D 0x12, .name =3D "rx_longs", }, - { .offset =3D 0x13, .name =3D "rx_classified_drops", }, - { .offset =3D 0x14, .name =3D "rx_red_prio_0", }, - { .offset =3D 0x15, .name =3D "rx_red_prio_1", }, - { .offset =3D 0x16, .name =3D "rx_red_prio_2", }, - { .offset =3D 0x17, .name =3D "rx_red_prio_3", }, - { .offset =3D 0x18, .name =3D "rx_red_prio_4", }, - { .offset =3D 0x19, .name =3D "rx_red_prio_5", }, - { .offset =3D 0x1A, .name =3D "rx_red_prio_6", }, - { .offset =3D 0x1B, .name =3D "rx_red_prio_7", }, - { .offset =3D 0x1C, .name =3D "rx_yellow_prio_0", }, - { .offset =3D 0x1D, .name =3D "rx_yellow_prio_1", }, - { .offset =3D 0x1E, .name =3D "rx_yellow_prio_2", }, - { .offset =3D 0x1F, .name =3D "rx_yellow_prio_3", }, - { .offset =3D 0x20, .name =3D "rx_yellow_prio_4", }, - { .offset =3D 0x21, .name =3D "rx_yellow_prio_5", }, - { .offset =3D 0x22, .name =3D "rx_yellow_prio_6", }, - { .offset =3D 0x23, .name =3D "rx_yellow_prio_7", }, - { .offset =3D 0x24, .name =3D "rx_green_prio_0", }, - { .offset =3D 0x25, .name =3D "rx_green_prio_1", }, - { .offset =3D 0x26, .name =3D "rx_green_prio_2", }, - { .offset =3D 0x27, .name =3D "rx_green_prio_3", }, - { .offset =3D 0x28, .name =3D "rx_green_prio_4", }, - { .offset =3D 0x29, .name =3D "rx_green_prio_5", }, - { .offset =3D 0x2A, .name =3D "rx_green_prio_6", }, - { .offset =3D 0x2B, .name =3D "rx_green_prio_7", }, - { .offset =3D 0x40, .name =3D "tx_octets", }, - { .offset =3D 0x41, .name =3D "tx_unicast", }, - { .offset =3D 0x42, .name =3D "tx_multicast", }, - { .offset =3D 0x43, .name =3D "tx_broadcast", }, - { .offset =3D 0x44, .name =3D "tx_collision", }, - { .offset =3D 0x45, .name =3D "tx_drops", }, - { .offset =3D 0x46, .name =3D "tx_pause", }, - { .offset =3D 0x47, .name =3D "tx_frames_below_65_octets", }, - { .offset =3D 0x48, .name =3D "tx_frames_65_to_127_octets", }, - { .offset =3D 0x49, .name =3D "tx_frames_128_255_octets", }, - { .offset =3D 0x4A, .name =3D "tx_frames_256_511_octets", }, - { .offset =3D 0x4B, .name =3D "tx_frames_512_1023_octets", }, - { .offset =3D 0x4C, .name =3D "tx_frames_1024_1526_octets", }, - { .offset =3D 0x4D, .name =3D "tx_frames_over_1526_octets", }, - { .offset =3D 0x4E, .name =3D "tx_yellow_prio_0", }, - { .offset =3D 0x4F, .name =3D "tx_yellow_prio_1", }, - { .offset =3D 0x50, .name =3D "tx_yellow_prio_2", }, - { .offset =3D 0x51, .name =3D "tx_yellow_prio_3", }, - { .offset =3D 0x52, .name =3D "tx_yellow_prio_4", }, - { .offset =3D 0x53, .name =3D "tx_yellow_prio_5", }, - { .offset =3D 0x54, .name =3D "tx_yellow_prio_6", }, - { .offset =3D 0x55, .name =3D "tx_yellow_prio_7", }, - { .offset =3D 0x56, .name =3D "tx_green_prio_0", }, - { .offset =3D 0x57, .name =3D "tx_green_prio_1", }, - { .offset =3D 0x58, .name =3D "tx_green_prio_2", }, - { .offset =3D 0x59, .name =3D "tx_green_prio_3", }, - { .offset =3D 0x5A, .name =3D "tx_green_prio_4", }, - { .offset =3D 0x5B, .name =3D "tx_green_prio_5", }, - { .offset =3D 0x5C, .name =3D "tx_green_prio_6", }, - { .offset =3D 0x5D, .name =3D "tx_green_prio_7", }, - { .offset =3D 0x5E, .name =3D "tx_aged", }, - { .offset =3D 0x80, .name =3D "drop_local", }, - { .offset =3D 0x81, .name =3D "drop_tail", }, - { .offset =3D 0x82, .name =3D "drop_yellow_prio_0", }, - { .offset =3D 0x83, .name =3D "drop_yellow_prio_1", }, - { .offset =3D 0x84, .name =3D "drop_yellow_prio_2", }, - { .offset =3D 0x85, .name =3D "drop_yellow_prio_3", }, - { .offset =3D 0x86, .name =3D "drop_yellow_prio_4", }, - { .offset =3D 0x87, .name =3D "drop_yellow_prio_5", }, - { .offset =3D 0x88, .name =3D "drop_yellow_prio_6", }, - { .offset =3D 0x89, .name =3D "drop_yellow_prio_7", }, - { .offset =3D 0x8A, .name =3D "drop_green_prio_0", }, - { .offset =3D 0x8B, .name =3D "drop_green_prio_1", }, - { .offset =3D 0x8C, .name =3D "drop_green_prio_2", }, - { .offset =3D 0x8D, .name =3D "drop_green_prio_3", }, - { .offset =3D 0x8E, .name =3D "drop_green_prio_4", }, - { .offset =3D 0x8F, .name =3D "drop_green_prio_5", }, - { .offset =3D 0x90, .name =3D "drop_green_prio_6", }, - { .offset =3D 0x91, .name =3D "drop_green_prio_7", }, - OCELOT_STAT_END +static const struct ocelot_stat_layout vsc9953_stats_layout[OCELOT_NUM_STA= TS] =3D { + [OCELOT_STAT_RX_OCTETS] =3D { + .name =3D "rx_octets", + .offset =3D 0x00, + }, + [OCELOT_STAT_RX_UNICAST] =3D { + .name =3D "rx_unicast", + .offset =3D 0x01, + }, + [OCELOT_STAT_RX_MULTICAST] =3D { + .name =3D "rx_multicast", + .offset =3D 0x02, + }, + [OCELOT_STAT_RX_BROADCAST] =3D { + .name =3D "rx_broadcast", + .offset =3D 0x03, + }, + [OCELOT_STAT_RX_SHORTS] =3D { + .name =3D "rx_shorts", + .offset =3D 0x04, + }, + [OCELOT_STAT_RX_FRAGMENTS] =3D { + .name =3D "rx_fragments", + .offset =3D 0x05, + }, + [OCELOT_STAT_RX_JABBERS] =3D { + .name =3D "rx_jabbers", + .offset =3D 0x06, + }, + [OCELOT_STAT_RX_CRC_ALIGN_ERRS] =3D { + .name =3D "rx_crc_align_errs", + .offset =3D 0x07, + }, + [OCELOT_STAT_RX_SYM_ERRS] =3D { + .name =3D "rx_sym_errs", + .offset =3D 0x08, + }, + [OCELOT_STAT_RX_64] =3D { + .name =3D "rx_frames_below_65_octets", + .offset =3D 0x09, + }, + [OCELOT_STAT_RX_65_127] =3D { + .name =3D "rx_frames_65_to_127_octets", + .offset =3D 0x0A, + }, + [OCELOT_STAT_RX_128_255] =3D { + .name =3D "rx_frames_128_to_255_octets", + .offset =3D 0x0B, + }, + [OCELOT_STAT_RX_256_511] =3D { + .name =3D "rx_frames_256_to_511_octets", + .offset =3D 0x0C, + }, + [OCELOT_STAT_RX_512_1023] =3D { + .name =3D "rx_frames_512_to_1023_octets", + .offset =3D 0x0D, + }, + [OCELOT_STAT_RX_1024_1526] =3D { + .name =3D "rx_frames_1024_to_1526_octets", + .offset =3D 0x0E, + }, + [OCELOT_STAT_RX_1527_MAX] =3D { + .name =3D "rx_frames_over_1526_octets", + .offset =3D 0x0F, + }, + [OCELOT_STAT_RX_PAUSE] =3D { + .name =3D "rx_pause", + .offset =3D 0x10, + }, + [OCELOT_STAT_RX_CONTROL] =3D { + .name =3D "rx_control", + .offset =3D 0x11, + }, + [OCELOT_STAT_RX_LONGS] =3D { + .name =3D "rx_longs", + .offset =3D 0x12, + }, + [OCELOT_STAT_RX_CLASSIFIED_DROPS] =3D { + .name =3D "rx_classified_drops", + .offset =3D 0x13, + }, + [OCELOT_STAT_RX_RED_PRIO_0] =3D { + .name =3D "rx_red_prio_0", + .offset =3D 0x14, + }, + [OCELOT_STAT_RX_RED_PRIO_1] =3D { + .name =3D "rx_red_prio_1", + .offset =3D 0x15, + }, + [OCELOT_STAT_RX_RED_PRIO_2] =3D { + .name =3D "rx_red_prio_2", + .offset =3D 0x16, + }, + [OCELOT_STAT_RX_RED_PRIO_3] =3D { + .name =3D "rx_red_prio_3", + .offset =3D 0x17, + }, + [OCELOT_STAT_RX_RED_PRIO_4] =3D { + .name =3D "rx_red_prio_4", + .offset =3D 0x18, + }, + [OCELOT_STAT_RX_RED_PRIO_5] =3D { + .name =3D "rx_red_prio_5", + .offset =3D 0x19, + }, + [OCELOT_STAT_RX_RED_PRIO_6] =3D { + .name =3D "rx_red_prio_6", + .offset =3D 0x1A, + }, + [OCELOT_STAT_RX_RED_PRIO_7] =3D { + .name =3D "rx_red_prio_7", + .offset =3D 0x1B, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_0] =3D { + .name =3D "rx_yellow_prio_0", + .offset =3D 0x1C, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_1] =3D { + .name =3D "rx_yellow_prio_1", + .offset =3D 0x1D, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_2] =3D { + .name =3D "rx_yellow_prio_2", + .offset =3D 0x1E, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_3] =3D { + .name =3D "rx_yellow_prio_3", + .offset =3D 0x1F, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_4] =3D { + .name =3D "rx_yellow_prio_4", + .offset =3D 0x20, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_5] =3D { + .name =3D "rx_yellow_prio_5", + .offset =3D 0x21, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_6] =3D { + .name =3D "rx_yellow_prio_6", + .offset =3D 0x22, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_7] =3D { + .name =3D "rx_yellow_prio_7", + .offset =3D 0x23, + }, + [OCELOT_STAT_RX_GREEN_PRIO_0] =3D { + .name =3D "rx_green_prio_0", + .offset =3D 0x24, + }, + [OCELOT_STAT_RX_GREEN_PRIO_1] =3D { + .name =3D "rx_green_prio_1", + .offset =3D 0x25, + }, + [OCELOT_STAT_RX_GREEN_PRIO_2] =3D { + .name =3D "rx_green_prio_2", + .offset =3D 0x26, + }, + [OCELOT_STAT_RX_GREEN_PRIO_3] =3D { + .name =3D "rx_green_prio_3", + .offset =3D 0x27, + }, + [OCELOT_STAT_RX_GREEN_PRIO_4] =3D { + .name =3D "rx_green_prio_4", + .offset =3D 0x28, + }, + [OCELOT_STAT_RX_GREEN_PRIO_5] =3D { + .name =3D "rx_green_prio_5", + .offset =3D 0x29, + }, + [OCELOT_STAT_RX_GREEN_PRIO_6] =3D { + .name =3D "rx_green_prio_6", + .offset =3D 0x2A, + }, + [OCELOT_STAT_RX_GREEN_PRIO_7] =3D { + .name =3D "rx_green_prio_7", + .offset =3D 0x2B, + }, + [OCELOT_STAT_TX_OCTETS] =3D { + .name =3D "tx_octets", + .offset =3D 0x40, + }, + [OCELOT_STAT_TX_UNICAST] =3D { + .name =3D "tx_unicast", + .offset =3D 0x41, + }, + [OCELOT_STAT_TX_MULTICAST] =3D { + .name =3D "tx_multicast", + .offset =3D 0x42, + }, + [OCELOT_STAT_TX_BROADCAST] =3D { + .name =3D "tx_broadcast", + .offset =3D 0x43, + }, + [OCELOT_STAT_TX_COLLISION] =3D { + .name =3D "tx_collision", + .offset =3D 0x44, + }, + [OCELOT_STAT_TX_DROPS] =3D { + .name =3D "tx_drops", + .offset =3D 0x45, + }, + [OCELOT_STAT_TX_PAUSE] =3D { + .name =3D "tx_pause", + .offset =3D 0x46, + }, + [OCELOT_STAT_TX_64] =3D { + .name =3D "tx_frames_below_65_octets", + .offset =3D 0x47, + }, + [OCELOT_STAT_TX_65_127] =3D { + .name =3D "tx_frames_65_to_127_octets", + .offset =3D 0x48, + }, + [OCELOT_STAT_TX_128_255] =3D { + .name =3D "tx_frames_128_255_octets", + .offset =3D 0x49, + }, + [OCELOT_STAT_TX_256_511] =3D { + .name =3D "tx_frames_256_511_octets", + .offset =3D 0x4A, + }, + [OCELOT_STAT_TX_512_1023] =3D { + .name =3D "tx_frames_512_1023_octets", + .offset =3D 0x4B, + }, + [OCELOT_STAT_TX_1024_1526] =3D { + .name =3D "tx_frames_1024_1526_octets", + .offset =3D 0x4C, + }, + [OCELOT_STAT_TX_1527_MAX] =3D { + .name =3D "tx_frames_over_1526_octets", + .offset =3D 0x4D, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_0] =3D { + .name =3D "tx_yellow_prio_0", + .offset =3D 0x4E, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_1] =3D { + .name =3D "tx_yellow_prio_1", + .offset =3D 0x4F, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_2] =3D { + .name =3D "tx_yellow_prio_2", + .offset =3D 0x50, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_3] =3D { + .name =3D "tx_yellow_prio_3", + .offset =3D 0x51, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_4] =3D { + .name =3D "tx_yellow_prio_4", + .offset =3D 0x52, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_5] =3D { + .name =3D "tx_yellow_prio_5", + .offset =3D 0x53, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_6] =3D { + .name =3D "tx_yellow_prio_6", + .offset =3D 0x54, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_7] =3D { + .name =3D "tx_yellow_prio_7", + .offset =3D 0x55, + }, + [OCELOT_STAT_TX_GREEN_PRIO_0] =3D { + .name =3D "tx_green_prio_0", + .offset =3D 0x56, + }, + [OCELOT_STAT_TX_GREEN_PRIO_1] =3D { + .name =3D "tx_green_prio_1", + .offset =3D 0x57, + }, + [OCELOT_STAT_TX_GREEN_PRIO_2] =3D { + .name =3D "tx_green_prio_2", + .offset =3D 0x58, + }, + [OCELOT_STAT_TX_GREEN_PRIO_3] =3D { + .name =3D "tx_green_prio_3", + .offset =3D 0x59, + }, + [OCELOT_STAT_TX_GREEN_PRIO_4] =3D { + .name =3D "tx_green_prio_4", + .offset =3D 0x5A, + }, + [OCELOT_STAT_TX_GREEN_PRIO_5] =3D { + .name =3D "tx_green_prio_5", + .offset =3D 0x5B, + }, + [OCELOT_STAT_TX_GREEN_PRIO_6] =3D { + .name =3D "tx_green_prio_6", + .offset =3D 0x5C, + }, + [OCELOT_STAT_TX_GREEN_PRIO_7] =3D { + .name =3D "tx_green_prio_7", + .offset =3D 0x5D, + }, + [OCELOT_STAT_TX_AGED] =3D { + .name =3D "tx_aged", + .offset =3D 0x5E, + }, + [OCELOT_STAT_DROP_LOCAL] =3D { + .name =3D "drop_local", + .offset =3D 0x80, + }, + [OCELOT_STAT_DROP_TAIL] =3D { + .name =3D "drop_tail", + .offset =3D 0x81, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_0] =3D { + .name =3D "drop_yellow_prio_0", + .offset =3D 0x82, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_1] =3D { + .name =3D "drop_yellow_prio_1", + .offset =3D 0x83, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_2] =3D { + .name =3D "drop_yellow_prio_2", + .offset =3D 0x84, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_3] =3D { + .name =3D "drop_yellow_prio_3", + .offset =3D 0x85, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_4] =3D { + .name =3D "drop_yellow_prio_4", + .offset =3D 0x86, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_5] =3D { + .name =3D "drop_yellow_prio_5", + .offset =3D 0x87, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_6] =3D { + .name =3D "drop_yellow_prio_6", + .offset =3D 0x88, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_7] =3D { + .name =3D "drop_yellow_prio_7", + .offset =3D 0x89, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_0] =3D { + .name =3D "drop_green_prio_0", + .offset =3D 0x8A, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_1] =3D { + .name =3D "drop_green_prio_1", + .offset =3D 0x8B, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_2] =3D { + .name =3D "drop_green_prio_2", + .offset =3D 0x8C, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_3] =3D { + .name =3D "drop_green_prio_3", + .offset =3D 0x8D, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_4] =3D { + .name =3D "drop_green_prio_4", + .offset =3D 0x8E, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_5] =3D { + .name =3D "drop_green_prio_5", + .offset =3D 0x8F, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_6] =3D { + .name =3D "drop_green_prio_6", + .offset =3D 0x90, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_7] =3D { + .name =3D "drop_green_prio_7", + .offset =3D 0x91, + }, }; =20 static const struct vcap_field vsc9953_vcap_es0_keys[] =3D { diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc= /ocelot.c index c67f162f8ab5..68991b021c56 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1860,16 +1860,20 @@ void ocelot_get_strings(struct ocelot *ocelot, int = port, u32 sset, u8 *data) if (sset !=3D ETH_SS_STATS) return; =20 - for (i =3D 0; i < ocelot->num_stats; i++) + for (i =3D 0; i < OCELOT_NUM_STATS; i++) { + if (ocelot->stats_layout[i].name[0] =3D=3D '\0') + continue; + memcpy(data + i * ETH_GSTRING_LEN, ocelot->stats_layout[i].name, ETH_GSTRING_LEN); + } } EXPORT_SYMBOL(ocelot_get_strings); =20 /* Caller must hold &ocelot->stats_lock */ static int ocelot_port_update_stats(struct ocelot *ocelot, int port) { - unsigned int idx =3D port * ocelot->num_stats; + unsigned int idx =3D port * OCELOT_NUM_STATS; struct ocelot_stats_region *region; int err, j; =20 @@ -1930,9 +1934,15 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot,= int port, u64 *data) /* check and update now */ err =3D ocelot_port_update_stats(ocelot, port); =20 - /* Copy all counters */ - for (i =3D 0; i < ocelot->num_stats; i++) - *data++ =3D ocelot->stats[port * ocelot->num_stats + i]; + /* Copy all supported counters */ + for (i =3D 0; i < OCELOT_NUM_STATS; i++) { + int index =3D port * OCELOT_NUM_STATS + i; + + if (ocelot->stats_layout[i].name[0] =3D=3D '\0') + continue; + + *data++ =3D ocelot->stats[index]; + } =20 spin_unlock(&ocelot->stats_lock); =20 @@ -1943,10 +1953,16 @@ EXPORT_SYMBOL(ocelot_get_ethtool_stats); =20 int ocelot_get_sset_count(struct ocelot *ocelot, int port, int sset) { + int i, num_stats =3D 0; + if (sset !=3D ETH_SS_STATS) return -EOPNOTSUPP; =20 - return ocelot->num_stats; + for (i =3D 0; i < OCELOT_NUM_STATS; i++) + if (ocelot->stats_layout[i].name[0] !=3D '\0') + num_stats++; + + return num_stats; } EXPORT_SYMBOL(ocelot_get_sset_count); =20 @@ -1958,7 +1974,10 @@ static int ocelot_prepare_stats_regions(struct ocelo= t *ocelot) =20 INIT_LIST_HEAD(&ocelot->stats_regions); =20 - for (i =3D 0; i < ocelot->num_stats; i++) { + for (i =3D 0; i < OCELOT_NUM_STATS; i++) { + if (ocelot->stats_layout[i].name[0] =3D=3D '\0') + continue; + if (region && ocelot->stats_layout[i].offset =3D=3D last + 1) { region->count++; } else { @@ -3340,7 +3359,6 @@ static void ocelot_detect_features(struct ocelot *oce= lot) =20 int ocelot_init(struct ocelot *ocelot) { - const struct ocelot_stat_layout *stat; char queue_name[32]; int i, ret; u32 port; @@ -3353,12 +3371,8 @@ int ocelot_init(struct ocelot *ocelot) } } =20 - ocelot->num_stats =3D 0; - for_each_stat(ocelot, stat) - ocelot->num_stats++; - ocelot->stats =3D devm_kcalloc(ocelot->dev, - ocelot->num_phys_ports * ocelot->num_stats, + ocelot->num_phys_ports * OCELOT_NUM_STATS, sizeof(u64), GFP_KERNEL); if (!ocelot->stats) return -ENOMEM; diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ether= net/mscc/ocelot_vsc7514.c index 961f803aca19..9ff910560043 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -96,101 +96,379 @@ static const struct reg_field ocelot_regfields[REGFIE= LD_MAX] =3D { [SYS_PAUSE_CFG_PAUSE_ENA] =3D REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 12, 4), }; =20 -static const struct ocelot_stat_layout ocelot_stats_layout[] =3D { - { .name =3D "rx_octets", .offset =3D 0x00, }, - { .name =3D "rx_unicast", .offset =3D 0x01, }, - { .name =3D "rx_multicast", .offset =3D 0x02, }, - { .name =3D "rx_broadcast", .offset =3D 0x03, }, - { .name =3D "rx_shorts", .offset =3D 0x04, }, - { .name =3D "rx_fragments", .offset =3D 0x05, }, - { .name =3D "rx_jabbers", .offset =3D 0x06, }, - { .name =3D "rx_crc_align_errs", .offset =3D 0x07, }, - { .name =3D "rx_sym_errs", .offset =3D 0x08, }, - { .name =3D "rx_frames_below_65_octets", .offset =3D 0x09, }, - { .name =3D "rx_frames_65_to_127_octets", .offset =3D 0x0A, }, - { .name =3D "rx_frames_128_to_255_octets", .offset =3D 0x0B, }, - { .name =3D "rx_frames_256_to_511_octets", .offset =3D 0x0C, }, - { .name =3D "rx_frames_512_to_1023_octets", .offset =3D 0x0D, }, - { .name =3D "rx_frames_1024_to_1526_octets", .offset =3D 0x0E, }, - { .name =3D "rx_frames_over_1526_octets", .offset =3D 0x0F, }, - { .name =3D "rx_pause", .offset =3D 0x10, }, - { .name =3D "rx_control", .offset =3D 0x11, }, - { .name =3D "rx_longs", .offset =3D 0x12, }, - { .name =3D "rx_classified_drops", .offset =3D 0x13, }, - { .name =3D "rx_red_prio_0", .offset =3D 0x14, }, - { .name =3D "rx_red_prio_1", .offset =3D 0x15, }, - { .name =3D "rx_red_prio_2", .offset =3D 0x16, }, - { .name =3D "rx_red_prio_3", .offset =3D 0x17, }, - { .name =3D "rx_red_prio_4", .offset =3D 0x18, }, - { .name =3D "rx_red_prio_5", .offset =3D 0x19, }, - { .name =3D "rx_red_prio_6", .offset =3D 0x1A, }, - { .name =3D "rx_red_prio_7", .offset =3D 0x1B, }, - { .name =3D "rx_yellow_prio_0", .offset =3D 0x1C, }, - { .name =3D "rx_yellow_prio_1", .offset =3D 0x1D, }, - { .name =3D "rx_yellow_prio_2", .offset =3D 0x1E, }, - { .name =3D "rx_yellow_prio_3", .offset =3D 0x1F, }, - { .name =3D "rx_yellow_prio_4", .offset =3D 0x20, }, - { .name =3D "rx_yellow_prio_5", .offset =3D 0x21, }, - { .name =3D "rx_yellow_prio_6", .offset =3D 0x22, }, - { .name =3D "rx_yellow_prio_7", .offset =3D 0x23, }, - { .name =3D "rx_green_prio_0", .offset =3D 0x24, }, - { .name =3D "rx_green_prio_1", .offset =3D 0x25, }, - { .name =3D "rx_green_prio_2", .offset =3D 0x26, }, - { .name =3D "rx_green_prio_3", .offset =3D 0x27, }, - { .name =3D "rx_green_prio_4", .offset =3D 0x28, }, - { .name =3D "rx_green_prio_5", .offset =3D 0x29, }, - { .name =3D "rx_green_prio_6", .offset =3D 0x2A, }, - { .name =3D "rx_green_prio_7", .offset =3D 0x2B, }, - { .name =3D "tx_octets", .offset =3D 0x40, }, - { .name =3D "tx_unicast", .offset =3D 0x41, }, - { .name =3D "tx_multicast", .offset =3D 0x42, }, - { .name =3D "tx_broadcast", .offset =3D 0x43, }, - { .name =3D "tx_collision", .offset =3D 0x44, }, - { .name =3D "tx_drops", .offset =3D 0x45, }, - { .name =3D "tx_pause", .offset =3D 0x46, }, - { .name =3D "tx_frames_below_65_octets", .offset =3D 0x47, }, - { .name =3D "tx_frames_65_to_127_octets", .offset =3D 0x48, }, - { .name =3D "tx_frames_128_255_octets", .offset =3D 0x49, }, - { .name =3D "tx_frames_256_511_octets", .offset =3D 0x4A, }, - { .name =3D "tx_frames_512_1023_octets", .offset =3D 0x4B, }, - { .name =3D "tx_frames_1024_1526_octets", .offset =3D 0x4C, }, - { .name =3D "tx_frames_over_1526_octets", .offset =3D 0x4D, }, - { .name =3D "tx_yellow_prio_0", .offset =3D 0x4E, }, - { .name =3D "tx_yellow_prio_1", .offset =3D 0x4F, }, - { .name =3D "tx_yellow_prio_2", .offset =3D 0x50, }, - { .name =3D "tx_yellow_prio_3", .offset =3D 0x51, }, - { .name =3D "tx_yellow_prio_4", .offset =3D 0x52, }, - { .name =3D "tx_yellow_prio_5", .offset =3D 0x53, }, - { .name =3D "tx_yellow_prio_6", .offset =3D 0x54, }, - { .name =3D "tx_yellow_prio_7", .offset =3D 0x55, }, - { .name =3D "tx_green_prio_0", .offset =3D 0x56, }, - { .name =3D "tx_green_prio_1", .offset =3D 0x57, }, - { .name =3D "tx_green_prio_2", .offset =3D 0x58, }, - { .name =3D "tx_green_prio_3", .offset =3D 0x59, }, - { .name =3D "tx_green_prio_4", .offset =3D 0x5A, }, - { .name =3D "tx_green_prio_5", .offset =3D 0x5B, }, - { .name =3D "tx_green_prio_6", .offset =3D 0x5C, }, - { .name =3D "tx_green_prio_7", .offset =3D 0x5D, }, - { .name =3D "tx_aged", .offset =3D 0x5E, }, - { .name =3D "drop_local", .offset =3D 0x80, }, - { .name =3D "drop_tail", .offset =3D 0x81, }, - { .name =3D "drop_yellow_prio_0", .offset =3D 0x82, }, - { .name =3D "drop_yellow_prio_1", .offset =3D 0x83, }, - { .name =3D "drop_yellow_prio_2", .offset =3D 0x84, }, - { .name =3D "drop_yellow_prio_3", .offset =3D 0x85, }, - { .name =3D "drop_yellow_prio_4", .offset =3D 0x86, }, - { .name =3D "drop_yellow_prio_5", .offset =3D 0x87, }, - { .name =3D "drop_yellow_prio_6", .offset =3D 0x88, }, - { .name =3D "drop_yellow_prio_7", .offset =3D 0x89, }, - { .name =3D "drop_green_prio_0", .offset =3D 0x8A, }, - { .name =3D "drop_green_prio_1", .offset =3D 0x8B, }, - { .name =3D "drop_green_prio_2", .offset =3D 0x8C, }, - { .name =3D "drop_green_prio_3", .offset =3D 0x8D, }, - { .name =3D "drop_green_prio_4", .offset =3D 0x8E, }, - { .name =3D "drop_green_prio_5", .offset =3D 0x8F, }, - { .name =3D "drop_green_prio_6", .offset =3D 0x90, }, - { .name =3D "drop_green_prio_7", .offset =3D 0x91, }, - OCELOT_STAT_END +static const struct ocelot_stat_layout ocelot_stats_layout[OCELOT_NUM_STAT= S] =3D { + [OCELOT_STAT_RX_OCTETS] =3D { + .name =3D "rx_octets", + .offset =3D 0x00, + }, + [OCELOT_STAT_RX_UNICAST] =3D { + .name =3D "rx_unicast", + .offset =3D 0x01, + }, + [OCELOT_STAT_RX_MULTICAST] =3D { + .name =3D "rx_multicast", + .offset =3D 0x02, + }, + [OCELOT_STAT_RX_BROADCAST] =3D { + .name =3D "rx_broadcast", + .offset =3D 0x03, + }, + [OCELOT_STAT_RX_SHORTS] =3D { + .name =3D "rx_shorts", + .offset =3D 0x04, + }, + [OCELOT_STAT_RX_FRAGMENTS] =3D { + .name =3D "rx_fragments", + .offset =3D 0x05, + }, + [OCELOT_STAT_RX_JABBERS] =3D { + .name =3D "rx_jabbers", + .offset =3D 0x06, + }, + [OCELOT_STAT_RX_CRC_ALIGN_ERRS] =3D { + .name =3D "rx_crc_align_errs", + .offset =3D 0x07, + }, + [OCELOT_STAT_RX_SYM_ERRS] =3D { + .name =3D "rx_sym_errs", + .offset =3D 0x08, + }, + [OCELOT_STAT_RX_64] =3D { + .name =3D "rx_frames_below_65_octets", + .offset =3D 0x09, + }, + [OCELOT_STAT_RX_65_127] =3D { + .name =3D "rx_frames_65_to_127_octets", + .offset =3D 0x0A, + }, + [OCELOT_STAT_RX_128_255] =3D { + .name =3D "rx_frames_128_to_255_octets", + .offset =3D 0x0B, + }, + [OCELOT_STAT_RX_256_511] =3D { + .name =3D "rx_frames_256_to_511_octets", + .offset =3D 0x0C, + }, + [OCELOT_STAT_RX_512_1023] =3D { + .name =3D "rx_frames_512_to_1023_octets", + .offset =3D 0x0D, + }, + [OCELOT_STAT_RX_1024_1526] =3D { + .name =3D "rx_frames_1024_to_1526_octets", + .offset =3D 0x0E, + }, + [OCELOT_STAT_RX_1527_MAX] =3D { + .name =3D "rx_frames_over_1526_octets", + .offset =3D 0x0F, + }, + [OCELOT_STAT_RX_PAUSE] =3D { + .name =3D "rx_pause", + .offset =3D 0x10, + }, + [OCELOT_STAT_RX_CONTROL] =3D { + .name =3D "rx_control", + .offset =3D 0x11, + }, + [OCELOT_STAT_RX_LONGS] =3D { + .name =3D "rx_longs", + .offset =3D 0x12, + }, + [OCELOT_STAT_RX_CLASSIFIED_DROPS] =3D { + .name =3D "rx_classified_drops", + .offset =3D 0x13, + }, + [OCELOT_STAT_RX_RED_PRIO_0] =3D { + .name =3D "rx_red_prio_0", + .offset =3D 0x14, + }, + [OCELOT_STAT_RX_RED_PRIO_1] =3D { + .name =3D "rx_red_prio_1", + .offset =3D 0x15, + }, + [OCELOT_STAT_RX_RED_PRIO_2] =3D { + .name =3D "rx_red_prio_2", + .offset =3D 0x16, + }, + [OCELOT_STAT_RX_RED_PRIO_3] =3D { + .name =3D "rx_red_prio_3", + .offset =3D 0x17, + }, + [OCELOT_STAT_RX_RED_PRIO_4] =3D { + .name =3D "rx_red_prio_4", + .offset =3D 0x18, + }, + [OCELOT_STAT_RX_RED_PRIO_5] =3D { + .name =3D "rx_red_prio_5", + .offset =3D 0x19, + }, + [OCELOT_STAT_RX_RED_PRIO_6] =3D { + .name =3D "rx_red_prio_6", + .offset =3D 0x1A, + }, + [OCELOT_STAT_RX_RED_PRIO_7] =3D { + .name =3D "rx_red_prio_7", + .offset =3D 0x1B, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_0] =3D { + .name =3D "rx_yellow_prio_0", + .offset =3D 0x1C, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_1] =3D { + .name =3D "rx_yellow_prio_1", + .offset =3D 0x1D, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_2] =3D { + .name =3D "rx_yellow_prio_2", + .offset =3D 0x1E, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_3] =3D { + .name =3D "rx_yellow_prio_3", + .offset =3D 0x1F, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_4] =3D { + .name =3D "rx_yellow_prio_4", + .offset =3D 0x20, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_5] =3D { + .name =3D "rx_yellow_prio_5", + .offset =3D 0x21, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_6] =3D { + .name =3D "rx_yellow_prio_6", + .offset =3D 0x22, + }, + [OCELOT_STAT_RX_YELLOW_PRIO_7] =3D { + .name =3D "rx_yellow_prio_7", + .offset =3D 0x23, + }, + [OCELOT_STAT_RX_GREEN_PRIO_0] =3D { + .name =3D "rx_green_prio_0", + .offset =3D 0x24, + }, + [OCELOT_STAT_RX_GREEN_PRIO_1] =3D { + .name =3D "rx_green_prio_1", + .offset =3D 0x25, + }, + [OCELOT_STAT_RX_GREEN_PRIO_2] =3D { + .name =3D "rx_green_prio_2", + .offset =3D 0x26, + }, + [OCELOT_STAT_RX_GREEN_PRIO_3] =3D { + .name =3D "rx_green_prio_3", + .offset =3D 0x27, + }, + [OCELOT_STAT_RX_GREEN_PRIO_4] =3D { + .name =3D "rx_green_prio_4", + .offset =3D 0x28, + }, + [OCELOT_STAT_RX_GREEN_PRIO_5] =3D { + .name =3D "rx_green_prio_5", + .offset =3D 0x29, + }, + [OCELOT_STAT_RX_GREEN_PRIO_6] =3D { + .name =3D "rx_green_prio_6", + .offset =3D 0x2A, + }, + [OCELOT_STAT_RX_GREEN_PRIO_7] =3D { + .name =3D "rx_green_prio_7", + .offset =3D 0x2B, + }, + [OCELOT_STAT_TX_OCTETS] =3D { + .name =3D "tx_octets", + .offset =3D 0x40, + }, + [OCELOT_STAT_TX_UNICAST] =3D { + .name =3D "tx_unicast", + .offset =3D 0x41, + }, + [OCELOT_STAT_TX_MULTICAST] =3D { + .name =3D "tx_multicast", + .offset =3D 0x42, + }, + [OCELOT_STAT_TX_BROADCAST] =3D { + .name =3D "tx_broadcast", + .offset =3D 0x43, + }, + [OCELOT_STAT_TX_COLLISION] =3D { + .name =3D "tx_collision", + .offset =3D 0x44, + }, + [OCELOT_STAT_TX_DROPS] =3D { + .name =3D "tx_drops", + .offset =3D 0x45, + }, + [OCELOT_STAT_TX_PAUSE] =3D { + .name =3D "tx_pause", + .offset =3D 0x46, + }, + [OCELOT_STAT_TX_64] =3D { + .name =3D "tx_frames_below_65_octets", + .offset =3D 0x47, + }, + [OCELOT_STAT_TX_65_127] =3D { + .name =3D "tx_frames_65_to_127_octets", + .offset =3D 0x48, + }, + [OCELOT_STAT_TX_128_255] =3D { + .name =3D "tx_frames_128_255_octets", + .offset =3D 0x49, + }, + [OCELOT_STAT_TX_256_511] =3D { + .name =3D "tx_frames_256_511_octets", + .offset =3D 0x4A, + }, + [OCELOT_STAT_TX_512_1023] =3D { + .name =3D "tx_frames_512_1023_octets", + .offset =3D 0x4B, + }, + [OCELOT_STAT_TX_1024_1526] =3D { + .name =3D "tx_frames_1024_1526_octets", + .offset =3D 0x4C, + }, + [OCELOT_STAT_TX_1527_MAX] =3D { + .name =3D "tx_frames_over_1526_octets", + .offset =3D 0x4D, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_0] =3D { + .name =3D "tx_yellow_prio_0", + .offset =3D 0x4E, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_1] =3D { + .name =3D "tx_yellow_prio_1", + .offset =3D 0x4F, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_2] =3D { + .name =3D "tx_yellow_prio_2", + .offset =3D 0x50, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_3] =3D { + .name =3D "tx_yellow_prio_3", + .offset =3D 0x51, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_4] =3D { + .name =3D "tx_yellow_prio_4", + .offset =3D 0x52, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_5] =3D { + .name =3D "tx_yellow_prio_5", + .offset =3D 0x53, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_6] =3D { + .name =3D "tx_yellow_prio_6", + .offset =3D 0x54, + }, + [OCELOT_STAT_TX_YELLOW_PRIO_7] =3D { + .name =3D "tx_yellow_prio_7", + .offset =3D 0x55, + }, + [OCELOT_STAT_TX_GREEN_PRIO_0] =3D { + .name =3D "tx_green_prio_0", + .offset =3D 0x56, + }, + [OCELOT_STAT_TX_GREEN_PRIO_1] =3D { + .name =3D "tx_green_prio_1", + .offset =3D 0x57, + }, + [OCELOT_STAT_TX_GREEN_PRIO_2] =3D { + .name =3D "tx_green_prio_2", + .offset =3D 0x58, + }, + [OCELOT_STAT_TX_GREEN_PRIO_3] =3D { + .name =3D "tx_green_prio_3", + .offset =3D 0x59, + }, + [OCELOT_STAT_TX_GREEN_PRIO_4] =3D { + .name =3D "tx_green_prio_4", + .offset =3D 0x5A, + }, + [OCELOT_STAT_TX_GREEN_PRIO_5] =3D { + .name =3D "tx_green_prio_5", + .offset =3D 0x5B, + }, + [OCELOT_STAT_TX_GREEN_PRIO_6] =3D { + .name =3D "tx_green_prio_6", + .offset =3D 0x5C, + }, + [OCELOT_STAT_TX_GREEN_PRIO_7] =3D { + .name =3D "tx_green_prio_7", + .offset =3D 0x5D, + }, + [OCELOT_STAT_TX_AGED] =3D { + .name =3D "tx_aged", + .offset =3D 0x5E, + }, + [OCELOT_STAT_DROP_LOCAL] =3D { + .name =3D "drop_local", + .offset =3D 0x80, + }, + [OCELOT_STAT_DROP_TAIL] =3D { + .name =3D "drop_tail", + .offset =3D 0x81, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_0] =3D { + .name =3D "drop_yellow_prio_0", + .offset =3D 0x82, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_1] =3D { + .name =3D "drop_yellow_prio_1", + .offset =3D 0x83, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_2] =3D { + .name =3D "drop_yellow_prio_2", + .offset =3D 0x84, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_3] =3D { + .name =3D "drop_yellow_prio_3", + .offset =3D 0x85, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_4] =3D { + .name =3D "drop_yellow_prio_4", + .offset =3D 0x86, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_5] =3D { + .name =3D "drop_yellow_prio_5", + .offset =3D 0x87, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_6] =3D { + .name =3D "drop_yellow_prio_6", + .offset =3D 0x88, + }, + [OCELOT_STAT_DROP_YELLOW_PRIO_7] =3D { + .name =3D "drop_yellow_prio_7", + .offset =3D 0x89, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_0] =3D { + .name =3D "drop_green_prio_0", + .offset =3D 0x8A, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_1] =3D { + .name =3D "drop_green_prio_1", + .offset =3D 0x8B, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_2] =3D { + .name =3D "drop_green_prio_2", + .offset =3D 0x8C, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_3] =3D { + .name =3D "drop_green_prio_3", + .offset =3D 0x8D, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_4] =3D { + .name =3D "drop_green_prio_4", + .offset =3D 0x8E, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_5] =3D { + .name =3D "drop_green_prio_5", + .offset =3D 0x8F, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_6] =3D { + .name =3D "drop_green_prio_6", + .offset =3D 0x90, + }, + [OCELOT_STAT_DROP_GREEN_PRIO_7] =3D { + .name =3D "drop_green_prio_7", + .offset =3D 0x91, + }, }; =20 static void ocelot_pll5_init(struct ocelot *ocelot) diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 72b9474391da..2428bc64cb1d 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -105,11 +105,6 @@ #define REG_RESERVED_ADDR 0xffffffff #define REG_RESERVED(reg) REG(reg, REG_RESERVED_ADDR) =20 -#define for_each_stat(ocelot, stat) \ - for ((stat) =3D (ocelot)->stats_layout; \ - ((stat)->name[0] !=3D '\0'); \ - (stat)++) - enum ocelot_target { ANA =3D 1, QS, @@ -540,13 +535,108 @@ enum ocelot_ptp_pins { TOD_ACC_PIN }; =20 +enum ocelot_stat { + OCELOT_STAT_RX_OCTETS, + OCELOT_STAT_RX_UNICAST, + OCELOT_STAT_RX_MULTICAST, + OCELOT_STAT_RX_BROADCAST, + OCELOT_STAT_RX_SHORTS, + OCELOT_STAT_RX_FRAGMENTS, + OCELOT_STAT_RX_JABBERS, + OCELOT_STAT_RX_CRC_ALIGN_ERRS, + OCELOT_STAT_RX_SYM_ERRS, + OCELOT_STAT_RX_64, + OCELOT_STAT_RX_65_127, + OCELOT_STAT_RX_128_255, + OCELOT_STAT_RX_256_511, + OCELOT_STAT_RX_512_1023, + OCELOT_STAT_RX_1024_1526, + OCELOT_STAT_RX_1527_MAX, + OCELOT_STAT_RX_PAUSE, + OCELOT_STAT_RX_CONTROL, + OCELOT_STAT_RX_LONGS, + OCELOT_STAT_RX_CLASSIFIED_DROPS, + OCELOT_STAT_RX_RED_PRIO_0, + OCELOT_STAT_RX_RED_PRIO_1, + OCELOT_STAT_RX_RED_PRIO_2, + OCELOT_STAT_RX_RED_PRIO_3, + OCELOT_STAT_RX_RED_PRIO_4, + OCELOT_STAT_RX_RED_PRIO_5, + OCELOT_STAT_RX_RED_PRIO_6, + OCELOT_STAT_RX_RED_PRIO_7, + OCELOT_STAT_RX_YELLOW_PRIO_0, + OCELOT_STAT_RX_YELLOW_PRIO_1, + OCELOT_STAT_RX_YELLOW_PRIO_2, + OCELOT_STAT_RX_YELLOW_PRIO_3, + OCELOT_STAT_RX_YELLOW_PRIO_4, + OCELOT_STAT_RX_YELLOW_PRIO_5, + OCELOT_STAT_RX_YELLOW_PRIO_6, + OCELOT_STAT_RX_YELLOW_PRIO_7, + OCELOT_STAT_RX_GREEN_PRIO_0, + OCELOT_STAT_RX_GREEN_PRIO_1, + OCELOT_STAT_RX_GREEN_PRIO_2, + OCELOT_STAT_RX_GREEN_PRIO_3, + OCELOT_STAT_RX_GREEN_PRIO_4, + OCELOT_STAT_RX_GREEN_PRIO_5, + OCELOT_STAT_RX_GREEN_PRIO_6, + OCELOT_STAT_RX_GREEN_PRIO_7, + OCELOT_STAT_TX_OCTETS, + OCELOT_STAT_TX_UNICAST, + OCELOT_STAT_TX_MULTICAST, + OCELOT_STAT_TX_BROADCAST, + OCELOT_STAT_TX_COLLISION, + OCELOT_STAT_TX_DROPS, + OCELOT_STAT_TX_PAUSE, + OCELOT_STAT_TX_64, + OCELOT_STAT_TX_65_127, + OCELOT_STAT_TX_128_255, + OCELOT_STAT_TX_256_511, + OCELOT_STAT_TX_512_1023, + OCELOT_STAT_TX_1024_1526, + OCELOT_STAT_TX_1527_MAX, + OCELOT_STAT_TX_YELLOW_PRIO_0, + OCELOT_STAT_TX_YELLOW_PRIO_1, + OCELOT_STAT_TX_YELLOW_PRIO_2, + OCELOT_STAT_TX_YELLOW_PRIO_3, + OCELOT_STAT_TX_YELLOW_PRIO_4, + OCELOT_STAT_TX_YELLOW_PRIO_5, + OCELOT_STAT_TX_YELLOW_PRIO_6, + OCELOT_STAT_TX_YELLOW_PRIO_7, + OCELOT_STAT_TX_GREEN_PRIO_0, + OCELOT_STAT_TX_GREEN_PRIO_1, + OCELOT_STAT_TX_GREEN_PRIO_2, + OCELOT_STAT_TX_GREEN_PRIO_3, + OCELOT_STAT_TX_GREEN_PRIO_4, + OCELOT_STAT_TX_GREEN_PRIO_5, + OCELOT_STAT_TX_GREEN_PRIO_6, + OCELOT_STAT_TX_GREEN_PRIO_7, + OCELOT_STAT_TX_AGED, + OCELOT_STAT_DROP_LOCAL, + OCELOT_STAT_DROP_TAIL, + OCELOT_STAT_DROP_YELLOW_PRIO_0, + OCELOT_STAT_DROP_YELLOW_PRIO_1, + OCELOT_STAT_DROP_YELLOW_PRIO_2, + OCELOT_STAT_DROP_YELLOW_PRIO_3, + OCELOT_STAT_DROP_YELLOW_PRIO_4, + OCELOT_STAT_DROP_YELLOW_PRIO_5, + OCELOT_STAT_DROP_YELLOW_PRIO_6, + OCELOT_STAT_DROP_YELLOW_PRIO_7, + OCELOT_STAT_DROP_GREEN_PRIO_0, + OCELOT_STAT_DROP_GREEN_PRIO_1, + OCELOT_STAT_DROP_GREEN_PRIO_2, + OCELOT_STAT_DROP_GREEN_PRIO_3, + OCELOT_STAT_DROP_GREEN_PRIO_4, + OCELOT_STAT_DROP_GREEN_PRIO_5, + OCELOT_STAT_DROP_GREEN_PRIO_6, + OCELOT_STAT_DROP_GREEN_PRIO_7, + OCELOT_NUM_STATS, +}; + struct ocelot_stat_layout { u32 offset; char name[ETH_GSTRING_LEN]; }; =20 -#define OCELOT_STAT_END { .name =3D "" } - struct ocelot_stats_region { struct list_head node; u32 offset; @@ -709,7 +799,6 @@ struct ocelot { const u32 *const *map; const struct ocelot_stat_layout *stats_layout; struct list_head stats_regions; - unsigned int num_stats; =20 u32 pool_size[OCELOT_SB_NUM][OCELOT_SB_POOL_NUM]; int packet_buffer_size; --=20 2.35.1