From patchwork Mon Sep 12 11:28:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Forsblad X-Patchwork-Id: 12973582 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 C4C9BECAAD5 for ; Mon, 12 Sep 2022 11:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230181AbiILL3V (ORCPT ); Mon, 12 Sep 2022 07:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbiILL3G (ORCPT ); Mon, 12 Sep 2022 07:29:06 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B74286F7 for ; Mon, 12 Sep 2022 04:29:05 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id by6so10133460ljb.11 for ; Mon, 12 Sep 2022 04:29:05 -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=uVVHzGuDvuLFvg25YHbW9emnxVuHkmkPzEpBPzrTL98=; b=ADCQSgAvvIG/tXPjEQ+sz5DaHKnT8yi1yQ66t+fmKzkvZPHryMy0lNOUsOTHrAvaCZ R0S0lhlput4fjqzQrSUZfp2nwQdEP3TiKO7G5XRtiiIHUf2v6vTPGBP1eUfcHikKcolw GhMmNXS7XK+CxxPTA4eO0gWD1JnZZW/2o5HCaZJoCEn4rEM0jz3OpBJG2aTa+p+ZBhwN BK9M7uoQ4hKs6g8ueB1x7e/RZLxQpjs2muPILOYDTX+WIocEK27uUGPEQWU49eF3/pLF GJlrWAaca6PQxw6V1gEhOEHk5182DOaURlnV+2ARwAsbptpqKCzw3xigA3hrClRH3Jx1 eYVA== 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=uVVHzGuDvuLFvg25YHbW9emnxVuHkmkPzEpBPzrTL98=; b=XjRJuHSgmWZ3hHFEan/ZmX3f5Md5Ie2fEe1dIXGbL5TTIg4xJBR4seuTepBFdjpRfT J93lPTsEP+BWBRYwnDkl+8CI17V8FYgPXlSL6k111hJSfksskzpzb6SvbUQ11yqDrHEY RN8dIbwSCvh2xsg6cWfcBxyGSemuvageTGWWL6IMWEs01OAC7VA4UXwrqdFLGeAvCn4i E1noXRmH4iOVeh0jVfxyVYl/iS+koR1S86riiXrk+Eitb9Uc1O3ILT87uK6mOscZFXqy G2XO8w538GqTWwQTD2+MTB4GKIhm5ekk7YXX/sFVjl+OmQCPmmPn1DLsz8A5F4lm/Gsa dtrA== X-Gm-Message-State: ACgBeo2nPu5v+CNZD0i1CixSz+JZ05Ygv+IGi5DNIHU2N5/QJcvDLpt5 0ZvYaaBI2ujJjGWBo3XTfEYV7bVF+TniasdP X-Google-Smtp-Source: AA6agR6dYvz+vqbuGIZEK0UEpfWJF7YcVzmj/jlVSqbW70ynWxOmztiuBx6X7AMMzUwKFPQ8czRPtA== X-Received: by 2002:a2e:b16d:0:b0:26a:d1da:db8 with SMTP id a13-20020a2eb16d000000b0026ad1da0db8mr7096463ljm.217.1662982144019; Mon, 12 Sep 2022 04:29:04 -0700 (PDT) Received: from wse-c0089.raspi.local (h-98-128-229-160.NA.cust.bahnhof.se. [98.128.229.160]) by smtp.gmail.com with ESMTPSA id i14-20020a2e808e000000b0026acf2ae007sm1043269ljg.89.2022.09.12.04.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 04:29:03 -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 , Mattias Forsblad Subject: [PATCH net-next v9 5/6] net: dsa: mv88e6xxx: rmon: Use RMU for reading RMON data Date: Mon, 12 Sep 2022 13:28:54 +0200 Message-Id: <20220912112855.339804-6-mattias.forsblad@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912112855.339804-1-mattias.forsblad@gmail.com> References: <20220912112855.339804-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 | 3 +++ drivers/net/dsa/mv88e6xxx/smi.c | 3 +++ 3 files changed, 34 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 fbbee8b997cd..5459037067e6 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.h +++ b/drivers/net/dsa/mv88e6xxx/chip.h @@ -432,6 +432,7 @@ struct mv88e6xxx_bus_ops { int (*read)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); int (*write)(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); int (*init)(struct mv88e6xxx_chip *chip); + void (*get_rmon)(struct mv88e6xxx_chip *chip, int port, uint64_t *data); }; struct mv88e6xxx_mdio_bus { @@ -808,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,