From patchwork Wed Oct 23 07:05:25 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: 13846606 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 50F23D2E01B for ; Wed, 23 Oct 2024 07:27:33 +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=92JLfIaRpUjF8Sxfadd8XbPPyUtSnUgfSS6vRr6nt1E=; b=4A8JWhNpBdr2EByPZ+UGPJLyg0 4TYB1EY6ZBgidvwnKGCG1n+HrMi19ZiCrAAT8qN8WbvOumCYX8mQMKUuTNzuLlHrCysLAn2lBN7BS GYLzaY7oabM1n7TFJeJrWSvX22bjeObWW4lV0KKOVt0Hvy7BXLWlE7Vul8hg4FBKWN+a4Fmura+OR gh8PGeMdFugFrQQjNnI9cFhtt7t4ZaTXXWkREHY73hIHGDSz2yH7EMOAdt3T8k43UYt3Ix0thhziC h3Ll8vwhNn/TyMY5vn24XzJgvxYyCW9K7dTTGEgYUgDQvqVibSPaJ0h3JHag4LyNCghTlM8Tggd1j kPeHm2HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3Vm4-0000000DNa4-4ACP; Wed, 23 Oct 2024 07:27:20 +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 1t3VS7-0000000DK0P-1PWU for linux-arm-kernel@lists.infradead.org; Wed, 23 Oct 2024 07:06:45 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-20cf6eea3c0so53019985ad.0 for ; Wed, 23 Oct 2024 00:06:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729667202; x=1730272002; 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=92JLfIaRpUjF8Sxfadd8XbPPyUtSnUgfSS6vRr6nt1E=; b=Ryj+rZsbpZRunN4F8b9Di7h5Wv/ZjVVM3267ti+KboqDxyX/5MTCzs9vE/tGCLWqeh mK9C+tYpw+M0LpZf9QhAV5Xl5UeovPFYmnbchxopL2Jf8PJ+RQaZgD0c6Cy0KDbZXOHe 4f8ijTT9Kv7t+FNOLELPqT9zdhvIck0YSwJugIqd5OcIAHJPu+K/7r1YS65BN0jkPyOS 6S9J0+zZzzU0HTsMXV7RxdUnW7HW39YxngCzob/I56BU18VmtXQPNtpY6YGdFCbmgE9/ WbDjGemycSg6Mz6MUEKc3/v/G6Ra8joVZ/KAMf/fpur2dxKbe1QVsXwoOGkWJQlXGM7t oN+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729667202; x=1730272002; 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=92JLfIaRpUjF8Sxfadd8XbPPyUtSnUgfSS6vRr6nt1E=; b=toPZ37BJJngvQZET/PCuVTE3KlT0cvBwRQXceZMmD7JXLBMKRqbnCGTt1TEVrgBEMj SRFblgs3LZR6Mgc3/K7NH90uOqCCVDUWapiKmeUhi2Uru2laxBPvVfDhS3NTNEZYiawl Z4hEuOzxaf0aPdYIJcqgoAqXVJ90WJs4fOrnqBmU3gPxLuLOOFALi3qTUbbguLpiHp4B EHdgAAlh+fmIk9XXITsfR1Fr8TH/4guxznc5J4QJ2Big69R678aRyj7yXom4MjLT9DNs RZKd3L3R3hpXxd9e+H7A0EfKhF9Kl4fpa7+0RFjfCjU8nb6BI97+zLlnrztJsuG6iKz8 4vGA== X-Forwarded-Encrypted: i=1; AJvYcCVHYi+AY16S6EOKzkkRaUmlw9vSe+HQiv+WZC4XJc1hnEXST+OvDm++XLpLRSMMIK0xoSXLj3WgHwSpqULtDnxz@lists.infradead.org X-Gm-Message-State: AOJu0YxZ4Or2qAYopQcsLFMCG3nwQ4EZj0jKOa7FKnpRYEQWXFiAMken UeNrs03p7jKNR0R+HiBLfxroJ2jaXfvbu9cMmsKTA+eskeG7KHG9 X-Google-Smtp-Source: AGHT+IFg1+0gg++PfvZ8hUJJpo9mELaDNf04I2kCVWV0tn6VzhK1umPvfXNOy3n6ytKA79kkAxgxwA== X-Received: by 2002:a17:903:1c4:b0:20c:7a0b:74a5 with SMTP id d9443c01a7336-20fa9ea1583mr20904445ad.39.1729667202049; Wed, 23 Oct 2024 00:06:42 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-20e7f0c167bsm51981745ad.140.2024.10.23.00.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 00:06:41 -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 , 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 v3 5/6] net: stmmac: xgmac: Complete FPE support Date: Wed, 23 Oct 2024 15:05:25 +0800 Message-Id: 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-20241023_000643_476272_C262550C X-CRM114-Status: GOOD ( 16.08 ) 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 fpe_map_preemption_class callback for xgmac. Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 + .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 43 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 3 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index de6ffda31a80..9a60a6e8f633 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1545,6 +1545,7 @@ const struct stmmac_ops dwxgmac210_ops = { .config_l3_filter = dwxgmac2_config_l3_filter, .config_l4_filter = dwxgmac2_config_l4_filter, .set_arp_offload = dwxgmac2_set_arp_offload, + .fpe_map_preemption_class = dwxgmac3_fpe_map_preemption_class, }; static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode, @@ -1601,6 +1602,7 @@ const struct stmmac_ops dwxlgmac2_ops = { .config_l3_filter = dwxgmac2_config_l3_filter, .config_l4_filter = dwxgmac2_config_l4_filter, .set_arp_offload = dwxgmac2_set_arp_offload, + .fpe_map_preemption_class = dwxgmac3_fpe_map_preemption_class, }; int dwxgmac2_setup(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c index f7d48bf2faed..b604d2aafce0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -360,6 +360,49 @@ int dwmac5_fpe_map_preemption_class(struct net_device *ndev, return 0; } +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_reg dwmac5_fpe_reg = { .mac_fpe_reg = GMAC5_MAC_FPE_CTRL_STS, .mtl_fpe_reg = GMAC5_MTL_FPE_CTRL_STS, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h index 9c7ddf34de24..fe463bb7a535 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -35,6 +35,9 @@ void stmmac_fpe_set_add_frag_size(struct stmmac_priv *priv, u32 add_frag_size); int dwmac5_fpe_map_preemption_class(struct net_device *ndev, struct netlink_ext_ack *extack, u32 pclass); +int dwxgmac3_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, + u32 pclass); extern const struct stmmac_fpe_reg dwmac5_fpe_reg; extern const struct stmmac_fpe_reg dwxgmac3_fpe_reg;