From patchwork Fri Oct 18 06:39:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 13841254 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47464D3C54C for ; Fri, 18 Oct 2024 06:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mJBrMWadSURgW3lrGPFAUIV2ihBDIP0p4IQDH1u3f8Y=; b=HbAsP6slBqgG/RYsMjtw37E00H JbjxwsHA8kLjXC6AE6DcurfIHgYeRxSY1bi8WT/7ieTllFEhvcEitOK9F9JzwOlYcs9pvZ2k7vjc+ XipDBeollUUrpR5JdJuq+VRCN04dgsB1jyPr+HN6plPMlIt4HwuvcevhfsW7ZSR6RKqSXv6cdhUSe CLFjQxInUW70/RU5L8abt1duNe8Px6fVPsSXRRvZQuLLTl2cccVBNYrpnSxlLIpUStN3hEVQcRirf o/3+mz1n4Pea4ncadRRQ72chczG2x81Fteds6dCGl3aDBEQhWP2BrLjLcHjvsZbml50SN72XfZXOG cKUeoGng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1gkR-0000000HCuE-2MSb; Fri, 18 Oct 2024 06:46:07 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1geY-0000000HAmm-1si7 for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 06:40:04 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-20c805a0753so15005245ad.0 for ; Thu, 17 Oct 2024 23:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729233601; x=1729838401; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mJBrMWadSURgW3lrGPFAUIV2ihBDIP0p4IQDH1u3f8Y=; b=j+kbV33Cu4kwwChyx4Jzb17wyWz2hWY3cQUHWapDseYYGFFQIL/YSeUIKUaTTiuYSI aPY6Dbtp/9XzYcOtoLS/UpK4sqYhnDoNTgQ/hWgtWN+kpmGGb/1FQydir/IiolyWM+U/ jZI9a5H/UzqKFhfoU2t001Oyem1N4cnqjQ+ggSYDwk7FNPxZEyZk6R+UleCqNQQ4KjRh 0oqS59qqAPW/LTlFzwFlsWDB1RjnYg4Qzbk0zOLCgVL582DafP2+pcLs4s1h+KN5+CBn 8wCeuVLd0lK4vy11FJMcGxvnYu/N5QwhGPiQiVm4i5LgcOn5vvTHmj0qSlCG7t/od1Qa 1LHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729233601; x=1729838401; 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:message-id:reply-to; bh=mJBrMWadSURgW3lrGPFAUIV2ihBDIP0p4IQDH1u3f8Y=; b=nY1zTAKkjm/jAYY0ZvmytCRhG4LmCLPcP8YvieD5crIPuSDpGE0tUec5w8nDs7105k 402JxyjYTC6pbaOJ/5vwd+YrEY1+K5DVYlTG3Mss6gVJn7uasH6YhqCeqPyk67/Nm9Kk UDRmJRHAe8cXbh0oDMI7YIJWEp51x2Qztn+qCWQIw005JJ2ONfDWio2wl+IBImNZ6Mo4 9ShQhYctYbeDqyrInLCKZaKQZr4xUolxJUuwVBiRJA0Ztel9tU9Nct/RYkZEbk9SdrwP sxVQqk582f6I3grJbTUlV01160sfua5iOZ4ljK1yDUH2n6iG5/em1lF1lB/WQcJEc45k vZBA== X-Forwarded-Encrypted: i=1; AJvYcCWWLzozwqMoryhSMqLDBTLt+Dv08Ty5uqmEhVJgUKP50SPRFIcBG7xXR+GnDE9BMtjiahDZ4+HFv615dcN2GQFd@lists.infradead.org X-Gm-Message-State: AOJu0YyQpRsK280PCmzKigcXCtljVqiur7gQMSS1J8uln/BDmP43Xyp6 Mx7tZzmL7QQ9nsyvwF5sl3WeHLsi+Zu3sCoLRX6zAiVzWb5ffL0xv57f5Q== X-Google-Smtp-Source: AGHT+IGsS874WnrFtUOTPyI4Qn/agw3rFHyEhGOMETNbdgrhODcOysO8jwRtZw8mC/mIDifBqviXww== X-Received: by 2002:a17:902:dac7:b0:20c:5bf8:bd6e with SMTP id d9443c01a7336-20e5a8fb30amr19403765ad.48.1729233601438; Thu, 17 Oct 2024 23:40:01 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-20e5a74766fsm6285455ad.73.2024.10.17.23.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 23:40:00 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Vladimir Oltean , Andrew Lunn , Simon Horman , Serge Semin , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , xfr@outlook.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v2 3/8] net: stmmac: Rework macro definitions for gmac4 and xgmac Date: Fri, 18 Oct 2024 14:39:09 +0800 Message-Id: <67d6b04934773de6732c4dd331c3441d90bc6dbe.1729233020.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_234002_595976_E0C7DDC0 X-CRM114-Status: GOOD ( 17.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rename and add macro definitions to better reuse them in common code. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Simon Horman --- .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 49 ++++++++++--------- .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 26 +++++----- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c index c01eb7243d56..0aa30e302dd8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -168,7 +168,7 @@ static void dwmac5_fpe_configure(void __iomem *ioaddr, u32 value; if (tx_enable) { - cfg->fpe_csr = EFPE; + cfg->fpe_csr = STMMAC_MAC_FPE_CTRL_STS_EFPE; value = readl(ioaddr + GMAC_RXQ_CTRL1); value &= ~GMAC_RXQCTRL_FPRQ; value |= (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; @@ -176,14 +176,14 @@ static void dwmac5_fpe_configure(void __iomem *ioaddr, } else { cfg->fpe_csr = 0; } - writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); + writel(cfg->fpe_csr, ioaddr + GMAC5_MAC_FPE_CTRL_STS); value = readl(ioaddr + GMAC_INT_EN); if (pmac_enable) { if (!(value & GMAC_INT_FPE_EN)) { /* Dummy read to clear any pending masked interrupts */ - readl(ioaddr + MAC_FPE_CTRL_STS); + readl(ioaddr + GMAC5_MAC_FPE_CTRL_STS); value |= GMAC_INT_FPE_EN; } @@ -204,24 +204,24 @@ static int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) /* Reads from the MAC_FPE_CTRL_STS register should only be performed * here, since the status flags of MAC_FPE_CTRL_STS are "clear on read" */ - value = readl(ioaddr + MAC_FPE_CTRL_STS); + value = readl(ioaddr + GMAC5_MAC_FPE_CTRL_STS); - if (value & TRSP) { + if (value & STMMAC_MAC_FPE_CTRL_STS_TRSP) { status |= FPE_EVENT_TRSP; netdev_dbg(dev, "FPE: Respond mPacket is transmitted\n"); } - if (value & TVER) { + if (value & STMMAC_MAC_FPE_CTRL_STS_TVER) { status |= FPE_EVENT_TVER; netdev_dbg(dev, "FPE: Verify mPacket is transmitted\n"); } - if (value & RRSP) { + if (value & STMMAC_MAC_FPE_CTRL_STS_RRSP) { status |= FPE_EVENT_RRSP; netdev_dbg(dev, "FPE: Respond mPacket is received\n"); } - if (value & RVER) { + if (value & STMMAC_MAC_FPE_CTRL_STS_RVER) { status |= FPE_EVENT_RVER; netdev_dbg(dev, "FPE: Verify mPacket is received\n"); } @@ -236,16 +236,17 @@ static void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, u32 value = cfg->fpe_csr; if (type == MPACKET_VERIFY) - value |= SVER; + value |= STMMAC_MAC_FPE_CTRL_STS_SVER; else if (type == MPACKET_RESPONSE) - value |= SRSP; + value |= STMMAC_MAC_FPE_CTRL_STS_SRSP; - writel(value, ioaddr + MAC_FPE_CTRL_STS); + writel(value, ioaddr + GMAC5_MAC_FPE_CTRL_STS); } static int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr) { - return FIELD_GET(DWMAC5_ADD_FRAG_SZ, readl(ioaddr + MTL_FPE_CTRL_STS)); + return FIELD_GET(FPE_MTL_ADD_FRAG_SZ, + readl(ioaddr + GMAC5_MTL_FPE_CTRL_STS)); } static void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, @@ -253,9 +254,9 @@ static void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, { u32 value; - value = readl(ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), - ioaddr + MTL_FPE_CTRL_STS); + value = readl(ioaddr + GMAC5_MTL_FPE_CTRL_STS); + writel(u32_replace_bits(value, add_frag_size, FPE_MTL_ADD_FRAG_SZ), + ioaddr + GMAC5_MTL_FPE_CTRL_STS); } #define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mapping" @@ -307,9 +308,9 @@ static int dwmac5_fpe_map_preemption_class(struct net_device *ndev, } update_mapping: - val = readl(priv->ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(val, preemptible_txqs, DWMAC5_PREEMPTION_CLASS), - priv->ioaddr + MTL_FPE_CTRL_STS); + val = readl(priv->ioaddr + GMAC5_MTL_FPE_CTRL_STS); + writel(u32_replace_bits(val, preemptible_txqs, FPE_MTL_PREEMPTION_CLASS), + priv->ioaddr + GMAC5_MTL_FPE_CTRL_STS); return 0; } @@ -322,11 +323,11 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, u32 value; if (!tx_enable) { - value = readl(ioaddr + XGMAC_FPE_CTRL_STS); + value = readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); - value &= ~XGMAC_EFPE; + value &= ~STMMAC_MAC_FPE_CTRL_STS_EFPE; - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); + writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); return; } @@ -335,9 +336,9 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, value |= (num_rxq - 1) << XGMAC_RQ_SHIFT; writel(value, ioaddr + XGMAC_RXQ_CTRL1); - value = readl(ioaddr + XGMAC_FPE_CTRL_STS); - value |= XGMAC_EFPE; - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); + value = readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); + value |= STMMAC_MAC_FPE_CTRL_STS_EFPE; + writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); } const struct stmmac_fpe_ops dwmac5_fpe_ops = { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h index a113b5c57de9..c0305f11575b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -8,23 +8,23 @@ #define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3 #define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128 -#define MAC_FPE_CTRL_STS 0x00000234 -#define TRSP BIT(19) -#define TVER BIT(18) -#define RRSP BIT(17) -#define RVER BIT(16) -#define SRSP BIT(2) -#define SVER BIT(1) -#define EFPE BIT(0) +#define GMAC5_MAC_FPE_CTRL_STS 0x00000234 +#define XGMAC_MAC_FPE_CTRL_STS 0x00000280 -#define MTL_FPE_CTRL_STS 0x00000c90 +#define GMAC5_MTL_FPE_CTRL_STS 0x00000c90 +#define XGMAC_MTL_FPE_CTRL_STS 0x00001090 /* Preemption Classification */ -#define DWMAC5_PREEMPTION_CLASS GENMASK(15, 8) +#define FPE_MTL_PREEMPTION_CLASS GENMASK(15, 8) /* Additional Fragment Size of preempted frames */ -#define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0) +#define FPE_MTL_ADD_FRAG_SZ GENMASK(1, 0) -#define XGMAC_FPE_CTRL_STS 0x00000280 -#define XGMAC_EFPE BIT(0) +#define STMMAC_MAC_FPE_CTRL_STS_TRSP BIT(19) +#define STMMAC_MAC_FPE_CTRL_STS_TVER BIT(18) +#define STMMAC_MAC_FPE_CTRL_STS_RRSP BIT(17) +#define STMMAC_MAC_FPE_CTRL_STS_RVER BIT(16) +#define STMMAC_MAC_FPE_CTRL_STS_SRSP BIT(2) +#define STMMAC_MAC_FPE_CTRL_STS_SVER BIT(1) +#define STMMAC_MAC_FPE_CTRL_STS_EFPE BIT(0) /* FPE link-partner hand-shaking mPacket type */ enum stmmac_mpacket_type {