Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3571523ybl; Mon, 12 Aug 2019 02:47:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1oN9Eno7ToHR6i0Cb2pWOUmz5e+Jzlckp6O93w3IQP8icFdHOz2oe4APLof+yfBE4Q8W1 X-Received: by 2002:a63:4a50:: with SMTP id j16mr29087417pgl.126.1565603234677; Mon, 12 Aug 2019 02:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565603234; cv=none; d=google.com; s=arc-20160816; b=uuwD4s+xYRxtl8CYevhzeOIKPPNquq1EcWc47A2CO2eMTjLTSDpG0R07YLhL/LeDvu BDbXNUrfeGXyLYfegoO87qgi1LjVXaqwyLATUAqIrbOecj/Hr/0PROaO7ZK0i1OjQoAR EMSH6kGnE9gVzuvIkyPM1EJsEF+WZbX6e+J6h1GvwaRx3ukLkhgyq1FIKmwng8dZwHtz bgIlLRUhV/JvtDN+1FQjDA7axlmxUbiiTOuRxf2DD8ajyvijEnCiZ4uKvNcGxdkZZtlS JIbw8/K0QdTsbjY1Ese0POrvTO77c/2QdFgaNmpdRniAh/8SHv5hInDcqh6Kz33gdZWE 8ZwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=NeYBrzrFweZi+QhC3Zvb1F7vPre3Bmad28y1Ou3ggUw=; b=GV4MQIonEu10qmPlstRyaIyqoIi9qFPsxy0JN4yxHV8BlsL1Kz+6y9fZI/kd4X6eZd Ev9g1iituYLG5KUEDXf9v0AOQf5zMBrVhSx4tHWt0NL0bhNU8FKxVOWxuH8YzD6yzY+z PyuElFUbar4TgR6l+rNCV1YenD1uYuxs+9aI/6R8re/B9pzMT1Js7Y8H6KfU8OvrLGOD zqSmi2pqwDfOoaIngnoM1cNf5SDSerN9EDRUtXJgVS/0XPJkHHRbQTgNaUdL03hd2PJ0 PBhJ3A5ehTLOAdZraJBcKE0BCK6XyIrV/YLM3ORQr9Pi+6Av83PgKvi8dw0ymlRxlYOu Zv1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=ef6wJ21G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o93si11385700pje.38.2019.08.12.02.46.59; Mon, 12 Aug 2019 02:47:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=ef6wJ21G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727527AbfHLJo0 (ORCPT + 99 others); Mon, 12 Aug 2019 05:44:26 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.47.102]:35298 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbfHLJoZ (ORCPT ); Mon, 12 Aug 2019 05:44:25 -0400 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 975B1C21DF; Mon, 12 Aug 2019 09:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1565603065; bh=gt1b62xswbydFg/dkNLte14Bb8f+1NcyURZaFiCiVVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=ef6wJ21G+VNbkxMRPcJSHBXKscNcCY2olzEqRpGthHrRPcwMUy5Btsw/VVRodfC3m fQWk+tKFdBnWbaYhQy6ZIAIA4rE3B+EV8vMxyvq5JBd7XBg7LOPc5JTs7uOO7st6Ow vks0CmmNFLvUiPQDoTsZ8JIEiFpo+4afUE02nhmwHUeWmxGwwLQyE4SFE1VWY74EdF aO7rHPXUKt8LJYWnFtqjab2J/OqMtTOmNnH/Y4U6rfhdhMXS/Es/v10T72QGj6RfcC LyZXoWCJtsVhaC/bkE9bKm+inMQzEcnlI0dZEFTFM3VHgaBekozUnCUmplyQ+ffoRw RmV/XcXBsZOmw== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id 44EC5A0071; Mon, 12 Aug 2019 09:44:23 +0000 (UTC) From: Jose Abreu To: netdev@vger.kernel.org Cc: Joao Pinto , Jose Abreu , Giuseppe Cavallaro , Alexandre Torgue , "David S. Miller" , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 07/12] net: stmmac: Add ethtool register dump for XGMAC cores Date: Mon, 12 Aug 2019 11:44:06 +0200 Message-Id: <3d860a78ce4e98941f7e292d251d7360755fdf2e.1565602974.git.joabreu@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the ethtool interface to dump the register map in XGMAC cores. Signed-off-by: Jose Abreu --- Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Cc: Jose Abreu Cc: "David S. Miller" Cc: Maxime Coquelin Cc: netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 ++ .../net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 11 +++++++++- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 10 ++++++++- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 24 ++++++++++++++++------ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index dbac63972faf..7fed3d2d4a95 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -244,6 +244,7 @@ #define XGMAC_RXOVFIS BIT(16) #define XGMAC_ABPSIS BIT(1) #define XGMAC_TXUNFIS BIT(0) +#define XGMAC_MAC_REGSIZE (XGMAC_MTL_QINT_STATUS(15) / 4) /* DMA Registers */ #define XGMAC_DMA_MODE 0x00003000 @@ -321,6 +322,7 @@ #define XGMAC_TBU BIT(2) #define XGMAC_TPS BIT(1) #define XGMAC_TI BIT(0) +#define XGMAC_REGSIZE ((0x0000317c + (0x80 * 15)) / 4) /* Descriptors */ #define XGMAC_TDES2_IOC BIT(31) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index f843e3640f50..a161285340c6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -239,6 +239,15 @@ static void dwxgmac2_config_cbs(struct mac_device_info *hw, writel(value, ioaddr + XGMAC_MTL_TCx_ETS_CONTROL(queue)); } +static void dwxgmac2_dump_regs(struct mac_device_info *hw, u32 *reg_space) +{ + void __iomem *ioaddr = hw->pcsr; + int i; + + for (i = 0; i < XGMAC_MAC_REGSIZE; i++) + reg_space[i] = readl(ioaddr + i * 4); +} + static int dwxgmac2_host_irq_status(struct mac_device_info *hw, struct stmmac_extra_stats *x) { @@ -1079,7 +1088,7 @@ const struct stmmac_ops dwxgmac210_ops = { .set_mtl_tx_queue_weight = dwxgmac2_set_mtl_tx_queue_weight, .map_mtl_to_dma = dwxgmac2_map_mtl_to_dma, .config_cbs = dwxgmac2_config_cbs, - .dump_regs = NULL, + .dump_regs = dwxgmac2_dump_regs, .host_irq_status = dwxgmac2_host_irq_status, .host_mtl_irq_status = dwxgmac2_host_mtl_irq_status, .flow_ctrl = dwxgmac2_flow_ctrl, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c index 0f3de4895cf7..42c13d144203 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c @@ -128,6 +128,14 @@ static void dwxgmac2_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi) writel(XGMAC_RDPS, ioaddr + XGMAC_RX_EDMA_CTRL); } +static void dwxgmac2_dma_dump_regs(void __iomem *ioaddr, u32 *reg_space) +{ + int i; + + for (i = (XGMAC_DMA_MODE / 4); i < XGMAC_REGSIZE; i++) + reg_space[i] = readl(ioaddr + i * 4); +} + static void dwxgmac2_dma_rx_mode(void __iomem *ioaddr, int mode, u32 channel, int fifosz, u8 qmode) { @@ -496,7 +504,7 @@ const struct stmmac_dma_ops dwxgmac210_dma_ops = { .init_rx_chan = dwxgmac2_dma_init_rx_chan, .init_tx_chan = dwxgmac2_dma_init_tx_chan, .axi = dwxgmac2_dma_axi, - .dump_regs = NULL, + .dump_regs = dwxgmac2_dma_dump_regs, .dma_rx_mode = dwxgmac2_dma_rx_mode, .dma_tx_mode = dwxgmac2_dma_tx_mode, .enable_dma_irq = dwxgmac2_enable_dma_irq, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index eb784fdb6d32..8828a5481f61 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -18,10 +18,12 @@ #include "stmmac.h" #include "dwmac_dma.h" +#include "dwxgmac2.h" #define REG_SPACE_SIZE 0x1060 #define MAC100_ETHTOOL_NAME "st_mac100" #define GMAC_ETHTOOL_NAME "st_gmac" +#define XGMAC_ETHTOOL_NAME "st_xgmac" #define ETHTOOL_DMA_OFFSET 55 @@ -260,6 +262,8 @@ static void stmmac_ethtool_getdrvinfo(struct net_device *dev, if (priv->plat->has_gmac || priv->plat->has_gmac4) strlcpy(info->driver, GMAC_ETHTOOL_NAME, sizeof(info->driver)); + else if (priv->plat->has_xgmac) + strlcpy(info->driver, XGMAC_ETHTOOL_NAME, sizeof(info->driver)); else strlcpy(info->driver, MAC100_ETHTOOL_NAME, sizeof(info->driver)); @@ -405,23 +409,31 @@ static int stmmac_check_if_running(struct net_device *dev) static int stmmac_ethtool_get_regs_len(struct net_device *dev) { + struct stmmac_priv *priv = netdev_priv(dev); + + if (priv->plat->has_xgmac) + return XGMAC_REGSIZE * 4; return REG_SPACE_SIZE; } static void stmmac_ethtool_gregs(struct net_device *dev, struct ethtool_regs *regs, void *space) { - u32 *reg_space = (u32 *) space; - struct stmmac_priv *priv = netdev_priv(dev); + int size = stmmac_ethtool_get_regs_len(dev); + u32 *reg_space = (u32 *) space; - memset(reg_space, 0x0, REG_SPACE_SIZE); + memset(reg_space, 0x0, size); stmmac_dump_mac_regs(priv, priv->hw, reg_space); stmmac_dump_dma_regs(priv, priv->ioaddr, reg_space); - /* Copy DMA registers to where ethtool expects them */ - memcpy(®_space[ETHTOOL_DMA_OFFSET], ®_space[DMA_BUS_MODE / 4], - NUM_DWMAC1000_DMA_REGS * 4); + + if (!priv->plat->has_xgmac) { + /* Copy DMA registers to where ethtool expects them */ + memcpy(®_space[ETHTOOL_DMA_OFFSET], + ®_space[DMA_BUS_MODE / 4], + NUM_DWMAC1000_DMA_REGS * 4); + } } static int stmmac_nway_reset(struct net_device *dev) -- 2.7.4