From patchwork Fri Oct 18 06:39:13 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: 13841282 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 31600D3C54C for ; Fri, 18 Oct 2024 06:52: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=oAXwTR66yAILUnUD8iXKY4J9SzL8DhxXJKiHt0S8h0U=; b=Rct00qfbDBe1v+JCuntH0OailE YtC+uCDVrrw68y35uql/+EGCq42mmze7HaTwiJRbqsX18q6LaKQ/GdQbQ7WeSTkArTVvsnI0ceK0L C6S72WPNTtK7jYF9d8a2cFOP2wqp5xk/0PgzKC2I5RQgNAkeuIYzT+vUHUr0y+J652OvDCwEbzP82 J78ZmbbI+R8GGp7N0xNMRWWLm7km/icoOF2NRucuotuxTzZ8VrBFeZosb9B+BAutKe7R4VXIpR+nQ v0cmQWIpA9A+h4SUzcRSlpvcUnkycHo0+JG316B3cTbJMyLBJc/B8ufTLKs1upt2sjz6PkT9jXbSz TLYk865g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1gqG-0000000HEM2-0rbz; Fri, 18 Oct 2024 06:52:08 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1gev-0000000HAuh-0G2v for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 06:40:26 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-20cf6eea3c0so14395245ad.0 for ; Thu, 17 Oct 2024 23:40:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729233624; x=1729838424; 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=oAXwTR66yAILUnUD8iXKY4J9SzL8DhxXJKiHt0S8h0U=; b=lg48q1dDvWbDysmLq41o1sno7/siZ+oWF9owtOiaG/j1OUve2FuVqadMbi7j5lszYv QmPO6niutfXpRxaDeCxpnt2vT2LZlhBLciMrfq8RDT3CitmXTh2CCEMG9TjaY2AgJ4O9 fHr87Op3wZnp9/Ym9HLXlCk6gCR6zTLmCLIq+0g4jee3BPJejlbtisD4iuLJn58D9Qel 2nV7snhmUPQ0ZNPVHw5zzX7M22rpjn7K+QlHOCo+vNexFjDw+2uOJs68ZRM3GJXOogwC omM28BmRzZdJlIYBlMDE/hhKlI/CQQ9YNIxfLIMP69kW2YLiOCY+2zNcMVRYs8XcUQKL nhAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729233624; x=1729838424; 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=oAXwTR66yAILUnUD8iXKY4J9SzL8DhxXJKiHt0S8h0U=; b=sgb+DrvmRQAyogWYQ7nfjZw7wxFTazsYHtY+lyWYYJ2yPSk/qDA+66bVXWvQFoJ2Dq VoHCCA09E6XN8l2+6P5z9mzpNJT7ehwIpPVY6ImKET2itZM4CRwX7PX4cP5eMApwj0iB 4mbEnDZbnVYbsj7rbAdGllmxGX/joJC1jCAZSBVAVMeCyMeP0bqAccKVw8Idm8rUjg16 SZ4iz9Swo6s/ac1fOwa0OsUr2Cm4CgKOQZg0O5PhAWMB8ai6D+C7hoX22nXoRwAIOqZK 7o2xBVBX8guXvPXRDveghmDk2Vng0ijaEoS2X2NQAI5OIl1xhhmqNyxz2uLMDd1/+fzj hnJw== X-Forwarded-Encrypted: i=1; AJvYcCWL7XeO0LZAShf14/MLevE6neiQKqeAz+FjQNqfJCGF7pBbWM1rz1PomeAzszLUA2crv5myYY9vNRrtMcboEXlJ@lists.infradead.org X-Gm-Message-State: AOJu0YxVrOUWKShWzqu5FY7kzAac+qdb2xDoudYWbtJHp/Y0lg/e6tiT 44h0X7ENGeGKeeGxjTOaOu2IwqBmfOzmHEaXFsO7RYzMN1X+Pz6M X-Google-Smtp-Source: AGHT+IHFQ90ihWqPYEL7Ct51SslG3VL9y32CIIVvGJDd5cHSgLsXcnYM+ZbtTXhZ468ZOJA50p73OQ== X-Received: by 2002:a17:903:32cf:b0:20c:5e86:9b5e with SMTP id d9443c01a7336-20e5a719f37mr18587745ad.3.1729233624372; Thu, 17 Oct 2024 23:40:24 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-20e5a74766fsm6285455ad.73.2024.10.17.23.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 23:40:23 -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 7/8] net: stmmac: xgmac: Complete FPE support Date: Fri, 18 Oct 2024 14:39:13 +0800 Message-Id: <1776606b2eda8430077551ca117b035f987b5b70.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_234025_139610_9414DD17 X-CRM114-Status: GOOD ( 16.28 ) 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 Implement the necessary stmmac_fpe_ops function callbacks for xgmac. Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c index dfe911b3f486..c90ed7c1279d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -373,6 +373,78 @@ static void dwxgmac3_fpe_configure(void __iomem *ioaddr, &dwxgmac3_fpe_info); } +static int dwxgmac3_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + return common_fpe_irq_status(ioaddr + XGMAC_MAC_FPE_CTRL_STS, dev); +} + +static void dwxgmac3_fpe_send_mpacket(void __iomem *ioaddr, + struct stmmac_fpe_cfg *cfg, + enum stmmac_mpacket_type type) +{ + common_fpe_send_mpacket(ioaddr + XGMAC_MAC_FPE_CTRL_STS, cfg, type); +} + +static int dwxgmac3_fpe_get_add_frag_size(const void __iomem *ioaddr) +{ + return FIELD_GET(FPE_MTL_ADD_FRAG_SZ, + readl(ioaddr + XGMAC_MTL_FPE_CTRL_STS)); +} + +static void dwxgmac3_fpe_set_add_frag_size(void __iomem *ioaddr, + u32 add_frag_size) +{ + u32 value; + + value = readl(ioaddr + XGMAC_MTL_FPE_CTRL_STS); + writel(u32_replace_bits(value, add_frag_size, FPE_MTL_ADD_FRAG_SZ), + ioaddr + XGMAC_MTL_FPE_CTRL_STS); +} + +static int dwxgmac3_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, + u32 pclass) +{ + u32 val, offset, count, preemptible_txqs = 0; + struct stmmac_priv *priv = netdev_priv(ndev); + u32 num_tc = ndev->num_tc; + + if (!num_tc) { + /* Restore default TC:Queue mapping */ + for (u32 i = 0; i < priv->plat->tx_queues_to_use; i++) { + val = readl(priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(i)); + writel(u32_replace_bits(val, i, XGMAC_Q2TCMAP), + priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(i)); + } + } + + /* Synopsys Databook: + * "All Queues within a traffic class are selected in a round robin + * fashion (when packets are available) when the traffic class is + * selected by the scheduler for packet transmission. This is true for + * any of the scheduling algorithms." + */ + for (u32 tc = 0; tc < num_tc; tc++) { + count = ndev->tc_to_txq[tc].count; + offset = ndev->tc_to_txq[tc].offset; + + if (pclass & BIT(tc)) + preemptible_txqs |= GENMASK(offset + count - 1, offset); + + for (u32 i = 0; i < count; i++) { + val = readl(priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(offset + i)); + writel(u32_replace_bits(val, tc, XGMAC_Q2TCMAP), + priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(offset + i)); + } + } + + val = readl(priv->ioaddr + XGMAC_MTL_FPE_CTRL_STS); + writel(u32_replace_bits(val, preemptible_txqs, FPE_MTL_PREEMPTION_CLASS), + priv->ioaddr + XGMAC_MTL_FPE_CTRL_STS); + + return 0; +} + const struct stmmac_fpe_ops dwmac5_fpe_ops = { .fpe_configure = dwmac5_fpe_configure, .fpe_send_mpacket = dwmac5_fpe_send_mpacket, @@ -384,4 +456,9 @@ const struct stmmac_fpe_ops dwmac5_fpe_ops = { const struct stmmac_fpe_ops dwxgmac_fpe_ops = { .fpe_configure = dwxgmac3_fpe_configure, + .fpe_send_mpacket = dwxgmac3_fpe_send_mpacket, + .fpe_irq_status = dwxgmac3_fpe_irq_status, + .fpe_get_add_frag_size = dwxgmac3_fpe_get_add_frag_size, + .fpe_set_add_frag_size = dwxgmac3_fpe_set_add_frag_size, + .fpe_map_preemption_class = dwxgmac3_fpe_map_preemption_class, };