From patchwork Tue Sep 13 10:43:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Forsblad X-Patchwork-Id: 12974687 X-Patchwork-Delegate: kuba@kernel.org 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 50945C6FA82 for ; Tue, 13 Sep 2022 10:43:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbiIMKnq (ORCPT ); Tue, 13 Sep 2022 06:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbiIMKni (ORCPT ); Tue, 13 Sep 2022 06:43:38 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ABBE5E306 for ; Tue, 13 Sep 2022 03:43:37 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id o2so17220837lfc.10 for ; Tue, 13 Sep 2022 03:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/OApzMapfMzOLbd6sKsMHZFgaTEweXQQvS5umrNIFN4=; b=pr7x0EfbzC9sQ9OnoF0A8FbBUJTb7A0J0Lxa4CDDER+J+pMlwDpGoO9WfPQ2eoEWNL H2n7JpXTOu/t1lqbEE0E+fQef/L5YJsPvTB0MHJF2Fo4tOl8Am/JHFvlYzlnYdtPO+aJ a/QnS2DU6nAXV9D9xCNYo1exW20FgjDwsNA9zbwCIhtE6e+4mEyZIxHdKjq3JvR2sS74 PRC9h6rKwi17Idf5BMPbuPPJL+mj4FywY2PxawG9OOJATc1ux2KljtCdHC423zHlTZ41 kV0QW+t5MqKEqCcu+YnPln47a4076Ic62krQVxGFOnB9RU85vkUEaQtDpMzfnyC7teuz Zp0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/OApzMapfMzOLbd6sKsMHZFgaTEweXQQvS5umrNIFN4=; b=EgvBNToJCalVDvapJ/CiglCSXUfYlkTb3ryg0iPSgi7nFBiEH01YamEueRxxwP0WmR IiLRF0Q2Zth22seDMmhuZbpjbrsr5ZJ2iH9CTzRSwCLqDMkIwuhzkVWgzK+4bgj+KfoI GS/d8wKZ7KvkZ++RBtCSj0un7jcmSj36s/yrc3SjwMJI/gXJSOUr3y5D81TPaDzgAcel dletaeDehQ1ps6CCcBmjEDpKAWSk1tnJovlIsI2LLvS6pFEI8kd4fLvdHQWMSbwOxvGK of9Mo2iG44+QSMxQo3/1EESoAiiMK8k4jncFwuzq9UGfUJzVtVOUEGRdnXmtQln/rXSS 1Vzw== X-Gm-Message-State: ACgBeo2jp3K7gUYST1RdCrNuHAFZ57Di/N4su71l17+9Z3OHz3GLpXL2 qdVPlItqF2Iw3cjOYt5WT4jeqwTZcEpaChAK X-Google-Smtp-Source: AA6agR4Cu3OTInePEXL871AcX1SJL4p4XbbPvFG+n4dk0JxIeo5iRnM5w9pCLe3rsD1CJIvTSDdT/Q== X-Received: by 2002:a05:6512:3f05:b0:497:9e06:255b with SMTP id y5-20020a0565123f0500b004979e06255bmr9685805lfa.175.1663065815705; Tue, 13 Sep 2022 03:43:35 -0700 (PDT) Received: from wse-c0089.westermo.com (h-98-128-229-160.NA.cust.bahnhof.se. [98.128.229.160]) by smtp.gmail.com with ESMTPSA id i2-20020a2ea362000000b0026bf27c7056sm1018946ljn.67.2022.09.13.03.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Sep 2022 03:43:35 -0700 (PDT) From: Mattias Forsblad To: netdev@vger.kernel.org Cc: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux@armlinux.org.uk, Mattias Forsblad Subject: [PATCH net-next v10 5/6] net: dsa: mv88e6xxx: rmon: Use RMU for reading RMON data Date: Tue, 13 Sep 2022 12:43:19 +0200 Message-Id: <20220913104320.471673-6-mattias.forsblad@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220913104320.471673-1-mattias.forsblad@gmail.com> References: <20220913104320.471673-1-mattias.forsblad@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Use the Remote Management Unit for efficiently accessing the RMON data. Signed-off-by: Mattias Forsblad --- drivers/net/dsa/mv88e6xxx/chip.c | 36 +++++++++++++++++++++++++------- drivers/net/dsa/mv88e6xxx/chip.h | 2 ++ drivers/net/dsa/mv88e6xxx/smi.c | 3 +++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 294bf9bbaf3f..c9cfe935715c 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1234,16 +1234,30 @@ static int mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port, u16 bank1_select, u16 histogram) { struct mv88e6xxx_hw_stat *stat; + int offset = 0; + u64 high; int i, j; for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) { stat = &mv88e6xxx_hw_stats[i]; if (stat->type & types) { - mv88e6xxx_reg_lock(chip); - data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, - bank1_select, - histogram); - mv88e6xxx_reg_unlock(chip); + if (mv88e6xxx_rmu_available(chip) && + !(stat->type & STATS_TYPE_PORT)) { + if (stat->type & STATS_TYPE_BANK1) + offset = 32; + + data[j] = chip->ports[port].rmu_raw_stats[stat->reg + offset]; + if (stat->size == 8) { + high = chip->ports[port].rmu_raw_stats[stat->reg + offset + + 1]; + data[j] += (high << 32); + } + } else { + mv88e6xxx_reg_lock(chip); + data[j] = _mv88e6xxx_get_ethtool_stat(chip, stat, port, + bank1_select, histogram); + mv88e6xxx_reg_unlock(chip); + } j++; } @@ -1312,10 +1326,9 @@ static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port, mv88e6xxx_reg_unlock(chip); } -static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, - uint64_t *data) +void mv88e6xxx_get_ethtool_stats_mdio(struct mv88e6xxx_chip *chip, int port, + uint64_t *data) { - struct mv88e6xxx_chip *chip = ds->priv; int ret; mv88e6xxx_reg_lock(chip); @@ -1327,7 +1340,14 @@ static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, return; mv88e6xxx_get_stats(chip, port, data); +} + +static void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int port, + uint64_t *data) +{ + struct mv88e6xxx_chip *chip = ds->priv; + chip->smi_ops->get_rmon(chip, port, data); } static int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h index ea1789feeacf..5459037067e6 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -809,6 +809,8 @@ int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, int bit, int val); struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip); +void mv88e6xxx_get_ethtool_stats_mdio(struct mv88e6xxx_chip *chip, int port, + uint64_t *data); static inline void mv88e6xxx_reg_lock(struct mv88e6xxx_chip *chip) { diff --git a/drivers/net/dsa/mv88e6xxx/smi.c b/drivers/net/dsa/mv88e6xxx/smi.c index a990271b7482..ae805c449b85 100644 --- a/drivers/net/dsa/mv88e6xxx/smi.c +++ b/drivers/net/dsa/mv88e6xxx/smi.c @@ -83,6 +83,7 @@ static int mv88e6xxx_smi_direct_wait(struct mv88e6xxx_chip *chip, static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_direct_ops = { .read = mv88e6xxx_smi_direct_read, .write = mv88e6xxx_smi_direct_write, + .get_rmon = mv88e6xxx_get_ethtool_stats_mdio, }; static int mv88e6xxx_smi_dual_direct_read(struct mv88e6xxx_chip *chip, @@ -100,6 +101,7 @@ static int mv88e6xxx_smi_dual_direct_write(struct mv88e6xxx_chip *chip, static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_dual_direct_ops = { .read = mv88e6xxx_smi_dual_direct_read, .write = mv88e6xxx_smi_dual_direct_write, + .get_rmon = mv88e6xxx_get_ethtool_stats_mdio, }; /* Offset 0x00: SMI Command Register @@ -166,6 +168,7 @@ static const struct mv88e6xxx_bus_ops mv88e6xxx_smi_indirect_ops = { .read = mv88e6xxx_smi_indirect_read, .write = mv88e6xxx_smi_indirect_write, .init = mv88e6xxx_smi_indirect_init, + .get_rmon = mv88e6xxx_get_ethtool_stats_mdio, }; int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,