From patchwork Tue Jul 9 08:21:24 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: 13727426 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 B3A6DC3DA41 for ; Tue, 9 Jul 2024 08:24:21 +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=eP0LjrMRjIFsgCTgIBPUz0T81YiHTsFBk9I0t0JMtzc=; b=ZqCK07+qWnFGtgAQkxi1M2exWY ko4ydQVBdzF856h6O0nDoVsn2SHNbWw2ogp4atW85ABS3BX5S/iGRFsDa9AehAipq6XCtR1Vebbbl yKKz+ucXYyVz8fXTeK7tvjuGWOxgcKgK2dyWac7SGDhdAPtF0dogy34WyKhEDGqbNTEuoP6ESKRv2 e9M1QuxJ1LfKlx3htovW1+X9mnkzD09eTPo1bZQpCiRssacCYVbmfQ8/OLdnur3SQeAnUTThbUS7n ItyswylBpBy9qvGl1HxcYdSfc3L8X6lleRfknWK8xNdwaTlGRnRQPPJb27xlw4+EPw7MsX79NQ4BY Gv5jjXVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR68y-00000006OL9-2pN3; Tue, 09 Jul 2024 08:24:12 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR68M-00000006O2g-3MCH for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 08:23:36 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2c980b55741so2862827a91.2 for ; Tue, 09 Jul 2024 01:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720513413; x=1721118213; 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=eP0LjrMRjIFsgCTgIBPUz0T81YiHTsFBk9I0t0JMtzc=; b=CAT0d/ZQ/w0t10AIs2mP+uFwNTCnyfFcvgqj5QFlcMonF8gWJn7aV5C4nwZ9k6nOWX l1o7clEA+Rkl5RBapaA3umqAC/TjpnsUpK3rFy0HD4h74UHTKoWVkC3qOpHfPnsVgRBW 478jWZ6Md11s2XHj3q/cESxIlaAX5CssbUWYcULINQ4xW+oz8gPezYJPdUoJNfVM423p XZep2gHRwvyzFhp5IKvIPDvu5yhmkeD9RzpG9BMOk0ZDhzv8Yir9Xy+EET0pZeLyfUlg YCZjXmWbIAuzWi+yV7BAkg8KSVoFtJTpfNavOL+jbI6QJh/urOhTWOjmTn5bcleFMr5y Nq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720513413; x=1721118213; 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=eP0LjrMRjIFsgCTgIBPUz0T81YiHTsFBk9I0t0JMtzc=; b=QvsNbUwaaqFugRzdENhyBOPUCh4lqc40e7xgz/dZKQuxRD+YIqkc+R3eFWE+WV8+ml eGCGauTRD26IRljbt5MxmBfiW/75Cl+wZfNKyy8jonSROiRZuZkmm4pj/mlYr9xj8Jr3 0oO7plKcqgW851a9TgLqD0/D2b1VnLSTOn1IE3tdXEPuCf+2iYrT2C5OcQWGB9AGEFiN C2KFqxeQFTU87prI5+lnS8Tx3H5f7mFfRBpsz3rdNr3aYcNz7HP1fsleyDWHdfpfXPsx V0RiYn7zV4pSJiVvjeqnvunjkAqokiBkDBgEGwVZK9mndcriQvHgvQUmYkEUtqceVO6+ LKaQ== X-Forwarded-Encrypted: i=1; AJvYcCVFii++mzBORfTH3L4vGBmLHiAFxeNjmlC+8gH8ekKHZPOM4NjxJ+t0Ud6lqIHqQl/TQe5Lq6vUBmsZJQ0W255isBnEzf7OJe+uot9SFFDd4AHCz4s= X-Gm-Message-State: AOJu0Ywju/vF+PrJy+lrpuFB/NZ7FHirM0APAuRDZMMUtAY893e2wcd4 WlrHPpPjN5JnBdpK2bdj/nICuTTH4DI65p5YmYfz98CPUK3jARDu X-Google-Smtp-Source: AGHT+IEsA/J8BKGkc+qhPKYByQIdxwFS8gpklEmLtJM7nUypk4CDvh/2Q/FxDq9p43lqdv9itrHpzw== X-Received: by 2002:a17:90a:db58:b0:2c9:8d5d:d175 with SMTP id 98e67ed59e1d1-2ca35d59cedmr1492273a91.48.1720513413478; Tue, 09 Jul 2024 01:23:33 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c99a92a430sm9588929a91.4.2024.07.09.01.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 01:23:33 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Andrew Lunn , "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v1 6/7] net: stmmac: xgmac: complete FPE support Date: Tue, 9 Jul 2024 16:21:24 +0800 Message-Id: <36336e43ee530596d77b15b80e3afac7bfd3319a.1720512888.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-20240709_012334_877655_4E13820A X-CRM114-Status: GOOD ( 16.57 ) 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 FPE implementation for DWMAC4 and DWXGMAC differs only for: 1) Offset address of MAC_FPE_CTRL_STS 2) FPRQ(Frame Preemption Residue Queue) field in MAC_RxQ_Ctrl1 Introduce dwxgmac_fpe_ops to complete the FPE implementation for DWXGMAC. Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/hwif.c | 2 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 37 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 1 + 4 files changed, 41 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 655012ffbc0a..f13ed91b498f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -259,6 +259,7 @@ static const struct stmmac_hwif_entry { .tc = &dwmac510_tc_ops, .mmc = &dwxgmac_mmc_ops, .est = &dwmac510_est_ops, + .fpe = &dwxgmac_fpe_ops, .setup = dwxgmac2_setup, .quirks = NULL, }, { @@ -280,6 +281,7 @@ static const struct stmmac_hwif_entry { .tc = &dwmac510_tc_ops, .mmc = &dwxgmac_mmc_ops, .est = &dwmac510_est_ops, + .fpe = &dwxgmac_fpe_ops, .setup = dwxlgmac2_setup, .quirks = stmmac_dwxlgmac_quirks, }, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 7b19614c611d..81ce8ede2641 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -686,6 +686,7 @@ extern const struct stmmac_mmc_ops dwmac_mmc_ops; extern const struct stmmac_mmc_ops dwxgmac_mmc_ops; extern const struct stmmac_est_ops dwmac510_est_ops; extern const struct stmmac_fpe_ops dwmac4_fpe_ops; +extern const struct stmmac_fpe_ops dwxgmac_fpe_ops; #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c index 97e404fac56a..c6894d5263c9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -7,6 +7,7 @@ #include "stmmac.h" #include "stmmac_fpe.h" #include "dwmac4.h" +#include "dwxgmac2.h" static int __fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) { @@ -92,3 +93,39 @@ const struct stmmac_fpe_ops dwmac4_fpe_ops = { .irq_status = dwmac4_fpe_irq_status, .send_mpacket = dwmac4_fpe_send_mpacket, }; + +static void dwxgmac_fpe_configure(void __iomem *ioaddr, + struct stmmac_fpe_cfg *cfg, + u32 num_txq, u32 num_rxq, bool enable) +{ + u32 value; + + if (enable) { + cfg->fpe_csr = FPE_CTRL_STS_EFPE; + value = readl(ioaddr + XGMAC_RXQ_CTRL1); + value &= ~XGMAC_FPRQ; + value |= (num_rxq - 1) << XGMAC_FPRQ_SHIFT; + writel(value, ioaddr + XGMAC_RXQ_CTRL1); + } else { + cfg->fpe_csr = 0; + } + + writel(cfg->fpe_csr, ioaddr + FPE_CTRL_STS_XGMAC_OFFSET); +} + +static int dwxgmac_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + return __fpe_irq_status(ioaddr + FPE_CTRL_STS_XGMAC_OFFSET, dev); +} + +static void dwxgmac_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, + enum stmmac_mpacket_type type) +{ + __fpe_send_mpacket(ioaddr + FPE_CTRL_STS_XGMAC_OFFSET, cfg, type); +} + +const struct stmmac_fpe_ops dwxgmac_fpe_ops = { + .configure = dwxgmac_fpe_configure, + .irq_status = dwxgmac_fpe_irq_status, + .send_mpacket = dwxgmac_fpe_send_mpacket, +}; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h index efdb5536e856..b74cf8f2c2f2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -5,6 +5,7 @@ */ #define FPE_CTRL_STS_GMAC4_OFFSET 0x00000234 +#define FPE_CTRL_STS_XGMAC_OFFSET 0x00000280 #define FPE_CTRL_STS_TRSP BIT(19) #define FPE_CTRL_STS_TVER BIT(18)