From patchwork Tue Jul 9 08:21:22 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: 13727424 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 5B09BC3DA41 for ; Tue, 9 Jul 2024 08:23:58 +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=29S9tCNcE/YwkqoQYa1nGmQDJhmHQQbSPi7L9uy3DQY=; b=eAtlI1cMiiYmNm5EmPeNRaGvzu euC+3syrKkzj36B2BYAs2qIT+ZhFjU/ZlJ7x4Ysq8dxlhvj6kNBEHTMIq3n0xa80e5X+gcTx53P7b HKqdn4X4wzYsCRuLoFbzzH7JV1YDKXOycQwqTYi6SQs5doyEockj+8eW3YhVAXZp5rOS93D96ERvA RHsNVwO5TlQSRjRJ4vw3gMDYcL2rmC2ur0YLaQVVNKMNDEFLGuJcjayXJP2O7XsC5vpC/SGLMtx33 RagJrx4mUgtRFgZLR6otMD5zhKSH1jZxucIIFDPT7fxYULCSxrk0MtGqSSGDYtCrsTR6+rnZJCZ2O BjN8020Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR68W-00000006O7j-0aZL; Tue, 09 Jul 2024 08:23:44 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sR683-00000006Ntq-0LuY for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2024 08:23:16 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-70df2135426so2453564a12.2 for ; Tue, 09 Jul 2024 01:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720513394; x=1721118194; 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=29S9tCNcE/YwkqoQYa1nGmQDJhmHQQbSPi7L9uy3DQY=; b=bV9msQhchK0mUsmR3z57jI6mk0HhGyuVv2NN9y9ssox9D/QdpiA90o9ZkdJAe8OCD7 h50aR8g7GyCJ8CSrs4bVCzx/yexcU6pz+2SpGycAh82X6FJ0Oq4F4LHNuU7gj8qzfb/4 27t+r64mjopUOuFPTDSiwsrl6QfaSWt0vmN+9A/4eb6z0wg/bfWSjAkdjH8EUruZ3SPS TY43UgR1NYJAmjjl6j/6h4K/OFkqN8mdZc1Jspw6gC/MiOSdEutBzow3mj4h60UagRvo co9jbF17TQMI72HDkzKYqxzm6eevYeSlBZlu4jo5eUIfRQin2Qb+5DyHlGyxgJmvlsN/ 5hkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720513394; x=1721118194; 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=29S9tCNcE/YwkqoQYa1nGmQDJhmHQQbSPi7L9uy3DQY=; b=IxgjguLbND50Qmu5hlb0DmUkkJ9urHU51ZaWla2LcG2BGXesYyiGclYKjV9i/fedDP 8RGaXYghWm0c9boWY7Fsdd/VeSiu2roH+OKZN8WL9FSkY96RubSIUj7K1FS2drxzJsOH htb392F3v6jRdJJCLav7+A0TWDGgaWZO6eah9Z5DC+ymvGpMdMNOl6/2Vtb05z/lPKz9 vM1sxKT2PnzmohDKrFsxcqOUwY84GixNF/B28S7ruDYlGCXEpkutLKxRk7UY4r2/N5fN dJrnAGC0W3TL6ZqkMaLWj9RpwxxqqeMlDOijOwiI3TOJ29DhV10h3mrbgtjpb6sJ70VL Z6LQ== X-Forwarded-Encrypted: i=1; AJvYcCU0Pa32nACScfqXmDBfOhSuApRmuPdStk2XIOpkrXmChLSIyDgPy2YZtkx3asouoxxADbPcXY4sAky32d/5jSRnUQp+BQZO/PAlbWNSgECBkPpSkZY= X-Gm-Message-State: AOJu0Yze5G0/2h8gt17+xFiF5JVWZ1ROFJiyKzYxmWjXPCleV4RrAnKa gOeWYwqGRIU4QpNMj2PGs0pMQx9i8aPRy4dgNF0rGsZpgznvB19+ X-Google-Smtp-Source: AGHT+IFP7v9XA+038juiIKo9wMYKaZosf3yLoyyuExumRzoZB0Txu2gnsXX83zEVAqRtpk376wQ+bg== X-Received: by 2002:a05:6a20:db0c:b0:1c2:93a7:2541 with SMTP id adf61e73a8af0-1c29822d122mr1658758637.24.1720513393543; Tue, 09 Jul 2024 01:23:13 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 01:23:13 -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 4/7] net: stmmac: gmac4: complete FPE support Date: Tue, 9 Jul 2024 16:21:22 +0800 Message-Id: <7cc2f0bd9216a4d34b6a937c22a14acc7e6cc5b2.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_012315_146567_FCB0C13A X-CRM114-Status: GOOD ( 18.43 ) 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 Introduce dwmac4_fpe_ops to complete the FPE implementation for DWMAC4 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 | 85 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 2 + 4 files changed, 90 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index fc9f58f44180..655012ffbc0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -216,6 +216,7 @@ static const struct stmmac_hwif_entry { .tc = &dwmac510_tc_ops, .mmc = &dwmac_mmc_ops, .est = &dwmac510_est_ops, + .fpe = &dwmac4_fpe_ops, .setup = dwmac4_setup, .quirks = NULL, }, { @@ -236,6 +237,7 @@ static const struct stmmac_hwif_entry { .tc = &dwmac510_tc_ops, .mmc = &dwmac_mmc_ops, .est = &dwmac510_est_ops, + .fpe = &dwmac4_fpe_ops, .setup = dwmac4_setup, .quirks = NULL, }, { diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index bd360f3ea784..7b19614c611d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -685,6 +685,7 @@ extern const struct stmmac_desc_ops dwxgmac210_desc_ops; 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; #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 f6701ba93805..97e404fac56a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -6,4 +6,89 @@ #include "stmmac.h" #include "stmmac_fpe.h" +#include "dwmac4.h" +static int __fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + u32 value; + int status; + + status = FPE_EVENT_UNKNOWN; + + /* 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); + + if (value & FPE_CTRL_STS_TRSP) { + status |= FPE_EVENT_TRSP; + netdev_info(dev, "FPE: Respond mPacket is transmitted\n"); + } + + if (value & FPE_CTRL_STS_TVER) { + status |= FPE_EVENT_TVER; + netdev_info(dev, "FPE: Verify mPacket is transmitted\n"); + } + + if (value & FPE_CTRL_STS_RRSP) { + status |= FPE_EVENT_RRSP; + netdev_info(dev, "FPE: Respond mPacket is received\n"); + } + + if (value & FPE_CTRL_STS_RVER) { + status |= FPE_EVENT_RVER; + netdev_info(dev, "FPE: Verify mPacket is received\n"); + } + + return status; +} + +static void __fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, + enum stmmac_mpacket_type type) +{ + u32 value = cfg->fpe_csr; + + if (type == MPACKET_VERIFY) + value |= FPE_CTRL_STS_SVER; + else if (type == MPACKET_RESPONSE) + value |= FPE_CTRL_STS_SRSP; + + writel(value, ioaddr); +} + +static void dwmac4_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 + GMAC_RXQ_CTRL1); + value &= ~GMAC_RXQCTRL_FPRQ; + value |= (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; + writel(value, ioaddr + GMAC_RXQ_CTRL1); + } else { + cfg->fpe_csr = 0; + } + + writel(cfg->fpe_csr, ioaddr + FPE_CTRL_STS_GMAC4_OFFSET); +} + +static int dwmac4_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + return __fpe_irq_status(ioaddr + FPE_CTRL_STS_GMAC4_OFFSET, dev); +} + +static void dwmac4_fpe_send_mpacket(void __iomem *ioaddr, + struct stmmac_fpe_cfg *cfg, + enum stmmac_mpacket_type type) +{ + __fpe_send_mpacket(ioaddr + FPE_CTRL_STS_GMAC4_OFFSET, cfg, type); +} + +const struct stmmac_fpe_ops dwmac4_fpe_ops = { + .configure = dwmac4_fpe_configure, + .irq_status = dwmac4_fpe_irq_status, + .send_mpacket = dwmac4_fpe_send_mpacket, +}; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h index 84e3ceb9bdda..efdb5536e856 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -4,6 +4,8 @@ * stmmac FPE(802.3 Qbu) handling */ +#define FPE_CTRL_STS_GMAC4_OFFSET 0x00000234 + #define FPE_CTRL_STS_TRSP BIT(19) #define FPE_CTRL_STS_TVER BIT(18) #define FPE_CTRL_STS_RRSP BIT(17)