From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E01C1A08B2; Thu, 31 Oct 2024 12:38:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378316; cv=none; b=mLLK6DWQK3DGrIwUw4gfdgBK+Jivy+R0jvGsMY2peGKbWxz3fyUI6IDXsiXdNX/krG+D2gLYC8PclAbJgElWfUVuGmzB/fei8VWttTox8kCUcQABCCAkws/UYcUtRb2STs0st4BJvL0ElDTRh5w1gLrWBWoTy8vu78ZsFa3V8/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378316; c=relaxed/simple; bh=Nag3b2hWtQEl30hz5TCfrUyWvGXMuk3VpBOmpZq+w4Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ttxn+3Y2nnV9fSAZYH3qgMYibteatW+9wmC7BXs6cDFxIAOuLg+DfiBuYlqWjpLUpIUnJe9Bfn4x752+SRNC1FfSDg2mRjdS+9PXbKbOcAkMweaUbzFLeGW3f6C1+OhkQmElj4+fhdzjsz1DhJNaJISa1zPZNNDKtitl6LC1D7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OWjKJjod; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWjKJjod" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-71e61b47c6cso699421b3a.2; Thu, 31 Oct 2024 05:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378311; x=1730983111; darn=vger.kernel.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=nU2caFtjLJow7ZnUUVJfpGtQO6czkRGSdnGX15Mzw20=; b=OWjKJjodrwT80MvCKtx29UyzBVzoWkipsUGTpzXMATnllCdX6A2Ln6gIxy1XqCnXC1 ++7rpyX9UlYfgc6Q4QPzzI6/TY5PFclDxw1ps+5Ir15qEj9JDG7IEII8giUDLjFuQDmK yziG42aU7KVqrPnuOhsSi21WjDjW5emQ0C1eWE//I5Oc/wX43XMBqRRBmYJBzV/fcxM/ 7pYswtkqyqe9U0zi0MAJXfr0RwJG0UFcIQeot3SZ20v2TM5kCTey/zehI/0q7MqmSmYT ii8akeeEqr0noByAk1RQae8XbengWT/SOU18PtG37LtVwEFAKIKw3Tz85cJeAgGoRA6Q Gn7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378311; x=1730983111; 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=nU2caFtjLJow7ZnUUVJfpGtQO6czkRGSdnGX15Mzw20=; b=dvVley40ssDFl+vyq9KCbn9KLp3gF7jiOrToHzAPAd+r8dk7BAVOdAq9+qqAPdxmkl ri2eTUbvrhINRB/t0RtwXVLrod0WX6hW5QONlGKHccYrPDgwhpHnz2TidLeqDpR1WRLS 8gerzz7l4BrNnTJR9LgInQxFuXGzC2t/oJ03artEogpsWO6DbcYplPzmUvBtRoMKNUUk AyTsVgceJWP/KJgZcAehZeeLZ8iHTvY2OkySFWPEmJR0eYn8Fg8EP/F2df72RNXwEMhV +Gm6lvhZBBb9K93yGtE2i60FXAljTfaA+FlTluCccHODG8+cgUU5Z9C/xhgbaoHRhtsL w9Qw== X-Forwarded-Encrypted: i=1; AJvYcCXqAAFp1pfoCW4O8PR/BVWPgWmFiWz9Si4XsnYcuNFlY8F30Triu2CyIZBDQJmAs/IklM/1CG34k8z4XiI=@vger.kernel.org X-Gm-Message-State: AOJu0YwhGbiHf0L/dCcnKaaQD+TPpBrUWRnGwm6dYdRSTpBJLWhmJ/RJ m6ZnoEL6u44H35XdrZ46lp/wQAZQkeKHAhg5iBu8NHMb9hlKHjsfjZcQxA== X-Google-Smtp-Source: AGHT+IGLJ54CUQmQmEiBbbETgqI0Kxo26AxxynsoAhwf36yJv8b1ulVtzONW85LXH4yRlch1/XBSCg== X-Received: by 2002:a05:6a00:1910:b0:71e:5e04:be9b with SMTP id d2e1a72fcca58-72062fb21f2mr28778575b3a.12.1730378310924; Thu, 31 Oct 2024 05:38:30 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:38:30 -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 , andrew+netdev@lunn.ch, 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 v7 1/8] net: stmmac: Introduce separate files for FPE implementation Date: Thu, 31 Oct 2024 20:37:55 +0800 Message-Id: <9876134957283296792864da97eab60328f8d478.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" By moving FPE related code info separate files, FPE implementation becomes a separate module initially. No functional change intended. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Simon Horman Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 150 -------- drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 26 -- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 - .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 27 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 10 - .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 354 ++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 45 +++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 149 +------- 11 files changed, 405 insertions(+), 363 deletions(-) create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/eth= ernet/stmicro/stmmac/Makefile index c2f0e91f6bf8..7e46dca90628 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -6,7 +6,7 @@ stmmac-objs:=3D stmmac_main.o stmmac_ethtool.o stmmac_mdio.= o ring_mode.o \ mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o dwmac4_descs.o \ dwmac4_dma.o dwmac4_lib.o dwmac4_core.o dwmac5.o hwif.o \ stmmac_tc.o dwxgmac2_core.o dwxgmac2_dma.o dwxgmac2_descs.o \ - stmmac_xdp.o stmmac_est.o \ + stmmac_xdp.o stmmac_est.o stmmac_fpe.o \ $(stmmac-y) =20 stmmac-$(CONFIG_STMMAC_SELFTESTS) +=3D stmmac_selftests.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac4_core.c index e65a65666cc1..4d217926820a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -16,6 +16,7 @@ #include #include #include "stmmac.h" +#include "stmmac_fpe.h" #include "stmmac_pcs.h" #include "dwmac4.h" #include "dwmac5.h" diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/eth= ernet/stmicro/stmmac/dwmac5.c index 08add508db84..1c431b918719 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -572,153 +572,3 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int = index, writel(val, ioaddr + MAC_PPS_CONTROL); return 0; } - -void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable) -{ - u32 value; - - if (tx_enable) { - cfg->fpe_csr =3D EFPE; - value =3D readl(ioaddr + GMAC_RXQ_CTRL1); - value &=3D ~GMAC_RXQCTRL_FPRQ; - value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; - writel(value, ioaddr + GMAC_RXQ_CTRL1); - } else { - cfg->fpe_csr =3D 0; - } - writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); - - value =3D 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); - - value |=3D GMAC_INT_FPE_EN; - } - } else { - value &=3D ~GMAC_INT_FPE_EN; - } - - writel(value, ioaddr + GMAC_INT_EN); -} - -int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) -{ - u32 value; - int status; - - status =3D 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 =3D readl(ioaddr + MAC_FPE_CTRL_STS); - - if (value & TRSP) { - status |=3D FPE_EVENT_TRSP; - netdev_dbg(dev, "FPE: Respond mPacket is transmitted\n"); - } - - if (value & TVER) { - status |=3D FPE_EVENT_TVER; - netdev_dbg(dev, "FPE: Verify mPacket is transmitted\n"); - } - - if (value & RRSP) { - status |=3D FPE_EVENT_RRSP; - netdev_dbg(dev, "FPE: Respond mPacket is received\n"); - } - - if (value & RVER) { - status |=3D FPE_EVENT_RVER; - netdev_dbg(dev, "FPE: Verify mPacket is received\n"); - } - - return status; -} - -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *= cfg, - enum stmmac_mpacket_type type) -{ - u32 value =3D cfg->fpe_csr; - - if (type =3D=3D MPACKET_VERIFY) - value |=3D SVER; - else if (type =3D=3D MPACKET_RESPONSE) - value |=3D SRSP; - - writel(value, ioaddr + MAC_FPE_CTRL_STS); -} - -int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr) -{ - return FIELD_GET(DWMAC5_ADD_FRAG_SZ, readl(ioaddr + MTL_FPE_CTRL_STS)); -} - -void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) -{ - u32 value; - - value =3D readl(ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), - ioaddr + MTL_FPE_CTRL_STS); -} - -#define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mappi= ng" -#define WEIGHT_ERR_MSG "TXQ weight %u differs across other TXQs in TC: [%u= ]" - -int dwmac5_fpe_map_preemption_class(struct net_device *ndev, - struct netlink_ext_ack *extack, u32 pclass) -{ - u32 val, offset, count, queue_weight, preemptible_txqs =3D 0; - struct stmmac_priv *priv =3D netdev_priv(ndev); - u32 num_tc =3D ndev->num_tc; - - if (!pclass) - goto update_mapping; - - /* DWMAC CORE4+ can not program TC:TXQ mapping to hardware. - * - * Synopsys Databook: - * "The number of Tx DMA channels is equal to the number of Tx queues, - * and is direct one-to-one mapping." - */ - for (u32 tc =3D 0; tc < num_tc; tc++) { - count =3D ndev->tc_to_txq[tc].count; - offset =3D ndev->tc_to_txq[tc].offset; - - if (pclass & BIT(tc)) - preemptible_txqs |=3D GENMASK(offset + count - 1, offset); - - /* This is 1:1 mapping, go to next TC */ - if (count =3D=3D 1) - continue; - - if (priv->plat->tx_sched_algorithm =3D=3D MTL_TX_ALGORITHM_SP) { - NL_SET_ERR_MSG_MOD(extack, ALG_ERR_MSG); - return -EINVAL; - } - - queue_weight =3D priv->plat->tx_queues_cfg[offset].weight; - - for (u32 i =3D 1; i < count; i++) { - if (priv->plat->tx_queues_cfg[offset + i].weight !=3D - queue_weight) { - NL_SET_ERR_MSG_FMT_MOD(extack, WEIGHT_ERR_MSG, - queue_weight, tc); - return -EINVAL; - } - } - } - -update_mapping: - val =3D readl(priv->ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(val, preemptible_txqs, DWMAC5_PREEMPTION_CLASS), - priv->ioaddr + MTL_FPE_CTRL_STS); - - return 0; -} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/eth= ernet/stmicro/stmmac/dwmac5.h index 6c6eb6790e83..00b151b3b688 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h @@ -11,15 +11,6 @@ #define PRTYEN BIT(1) #define TMOUTEN BIT(0) =20 -#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 MAC_PPS_CONTROL 0x00000b70 #define PPS_MAXIDX(x) ((((x) + 1) * 8) - 1) #define PPS_MINIDX(x) ((x) * 8) @@ -39,12 +30,6 @@ #define MAC_PPSx_INTERVAL(x) (0x00000b88 + ((x) * 0x10)) #define MAC_PPSx_WIDTH(x) (0x00000b8c + ((x) * 0x10)) =20 -#define MTL_FPE_CTRL_STS 0x00000c90 -/* Preemption Classification */ -#define DWMAC5_PREEMPTION_CLASS GENMASK(15, 8) -/* Additional Fragment Size of preempted frames */ -#define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0) - #define MTL_RXP_CONTROL_STATUS 0x00000ca0 #define RXPI BIT(31) #define NPE GENMASK(23, 16) @@ -108,16 +93,5 @@ int dwmac5_rxp_config(void __iomem *ioaddr, struct stmm= ac_tc_entry *entries, int dwmac5_flex_pps_config(void __iomem *ioaddr, int index, struct stmmac_pps_cfg *cfg, bool enable, u32 sub_second_inc, u32 systime_flags); -void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable); -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, - struct stmmac_fpe_cfg *cfg, - enum stmmac_mpacket_type type); -int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); -int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr); -void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size); -int dwmac5_fpe_map_preemption_class(struct net_device *ndev, - struct netlink_ext_ack *extack, u32 pclass); =20 #endif /* __DWMAC5_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index 6a2c7d22df1e..917796293c26 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -193,8 +193,6 @@ #define XGMAC_MDIO_ADDR 0x00000200 #define XGMAC_MDIO_DATA 0x00000204 #define XGMAC_MDIO_C22P 0x00000220 -#define XGMAC_FPE_CTRL_STS 0x00000280 -#define XGMAC_EFPE BIT(0) #define XGMAC_ADDRx_HIGH(x) (0x00000300 + (x) * 0x8) #define XGMAC_ADDR_MAX 32 #define XGMAC_AE BIT(31) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/= net/ethernet/stmicro/stmmac/dwxgmac2_core.c index f519d43738b0..111ba5a524ed 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -8,6 +8,7 @@ #include #include #include "stmmac.h" +#include "stmmac_fpe.h" #include "stmmac_ptp.h" #include "dwxlgmac2.h" #include "dwxgmac2.h" @@ -1504,32 +1505,6 @@ static void dwxgmac2_set_arp_offload(struct mac_devi= ce_info *hw, bool en, writel(value, ioaddr + XGMAC_RX_CONFIG); } =20 -static void dwxgmac3_fpe_configure(void __iomem *ioaddr, - struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable) -{ - u32 value; - - if (!tx_enable) { - value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); - - value &=3D ~XGMAC_EFPE; - - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); - return; - } - - value =3D readl(ioaddr + XGMAC_RXQ_CTRL1); - value &=3D ~XGMAC_RQ; - value |=3D (num_rxq - 1) << XGMAC_RQ_SHIFT; - writel(value, ioaddr + XGMAC_RXQ_CTRL1); - - value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); - value |=3D XGMAC_EFPE; - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); -} - const struct stmmac_ops dwxgmac210_ops =3D { .core_init =3D dwxgmac2_core_init, .set_mac =3D dwxgmac2_set_mac, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/eth= ernet/stmicro/stmmac/stmmac.h index ea135203ff2e..816b979e72cc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -146,15 +146,6 @@ struct stmmac_channel { u32 index; }; =20 -/* FPE link-partner hand-shaking mPacket type */ -enum stmmac_mpacket_type { - MPACKET_VERIFY =3D 0, - MPACKET_RESPONSE =3D 1, -}; - -#define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3 -#define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128 - struct stmmac_fpe_cfg { /* Serialize access to MAC Merge state between ethtool requests * and link state updates. @@ -420,7 +411,6 @@ bool stmmac_eee_init(struct stmmac_priv *priv); int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt); int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_si= ze); int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled); -void stmmac_fpe_apply(struct stmmac_priv *priv); =20 static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 2a37592a6281..2792a4c6cbcd 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -17,9 +17,9 @@ #include =20 #include "stmmac.h" +#include "stmmac_fpe.h" #include "dwmac_dma.h" #include "dwxgmac2.h" -#include "dwmac5.h" =20 #define REG_SPACE_SIZE 0x1060 #define GMAC4_REG_SPACE_SIZE 0x116C diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c new file mode 100644 index 000000000000..59e666668ac1 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -0,0 +1,354 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Furong Xu <0x1207@gmail.com> + * stmmac FPE(802.3 Qbu) handling + */ +#include "stmmac.h" +#include "stmmac_fpe.h" +#include "dwmac4.h" +#include "dwmac5.h" +#include "dwxgmac2.h" + +#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 MTL_FPE_CTRL_STS 0x00000c90 +/* Preemption Classification */ +#define DWMAC5_PREEMPTION_CLASS GENMASK(15, 8) +/* Additional Fragment Size of preempted frames */ +#define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0) + +#define XGMAC_FPE_CTRL_STS 0x00000280 +#define XGMAC_EFPE BIT(0) + +void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) +{ + struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; + unsigned long flags; + + timer_shutdown_sync(&fpe_cfg->verify_timer); + + spin_lock_irqsave(&fpe_cfg->lock, flags); + + if (is_up && fpe_cfg->pmac_enabled) { + /* VERIFY process requires pmac enabled when NIC comes up */ + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false, true); + + /* New link =3D> maybe new partner =3D> new verification process */ + stmmac_fpe_apply(priv); + } else { + /* No link =3D> turn off EFPE */ + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false, false); + } + + spin_unlock_irqrestore(&fpe_cfg->lock, flags); +} + +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *= cfg, + enum stmmac_mpacket_type type) +{ + u32 value =3D cfg->fpe_csr; + + if (type =3D=3D MPACKET_VERIFY) + value |=3D SVER; + else if (type =3D=3D MPACKET_RESPONSE) + value |=3D SRSP; + + writel(value, ioaddr + MAC_FPE_CTRL_STS); +} + +void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) +{ + struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; + + /* This is interrupt context, just spin_lock() */ + spin_lock(&fpe_cfg->lock); + + if (!fpe_cfg->pmac_enabled || status =3D=3D FPE_EVENT_UNKNOWN) + goto unlock_out; + + /* LP has sent verify mPacket */ + if ((status & FPE_EVENT_RVER) =3D=3D FPE_EVENT_RVER) + stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, + MPACKET_RESPONSE); + + /* Local has sent verify mPacket */ + if ((status & FPE_EVENT_TVER) =3D=3D FPE_EVENT_TVER && + fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) + fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_VERIFYING; + + /* LP has sent response mPacket */ + if ((status & FPE_EVENT_RRSP) =3D=3D FPE_EVENT_RRSP && + fpe_cfg->status =3D=3D ETHTOOL_MM_VERIFY_STATUS_VERIFYING) + fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; + +unlock_out: + spin_unlock(&fpe_cfg->lock); +} + +/** + * stmmac_fpe_verify_timer - Timer for MAC Merge verification + * @t: timer_list struct containing private info + * + * Verify the MAC Merge capability in the local TX direction, by + * transmitting Verify mPackets up to 3 times. Wait until link + * partner responds with a Response mPacket, otherwise fail. + */ +static void stmmac_fpe_verify_timer(struct timer_list *t) +{ + struct stmmac_fpe_cfg *fpe_cfg =3D from_timer(fpe_cfg, t, verify_timer); + struct stmmac_priv *priv =3D container_of(fpe_cfg, struct stmmac_priv, + fpe_cfg); + unsigned long flags; + bool rearm =3D false; + + spin_lock_irqsave(&fpe_cfg->lock, flags); + + switch (fpe_cfg->status) { + case ETHTOOL_MM_VERIFY_STATUS_INITIAL: + case ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + if (fpe_cfg->verify_retries !=3D 0) { + stmmac_fpe_send_mpacket(priv, priv->ioaddr, + fpe_cfg, MPACKET_VERIFY); + rearm =3D true; + } else { + fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_FAILED; + } + + fpe_cfg->verify_retries--; + break; + + case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + true, true); + break; + + default: + break; + } + + if (rearm) { + mod_timer(&fpe_cfg->verify_timer, + jiffies + msecs_to_jiffies(fpe_cfg->verify_time)); + } + + spin_unlock_irqrestore(&fpe_cfg->lock, flags); +} + +static void stmmac_fpe_verify_timer_arm(struct stmmac_fpe_cfg *fpe_cfg) +{ + if (fpe_cfg->pmac_enabled && fpe_cfg->tx_enabled && + fpe_cfg->verify_enabled && + fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_FAILED && + fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) { + timer_setup(&fpe_cfg->verify_timer, stmmac_fpe_verify_timer, 0); + mod_timer(&fpe_cfg->verify_timer, jiffies); + } +} + +void stmmac_fpe_init(struct stmmac_priv *priv) +{ + priv->fpe_cfg.verify_retries =3D STMMAC_FPE_MM_MAX_VERIFY_RETRIES; + priv->fpe_cfg.verify_time =3D STMMAC_FPE_MM_MAX_VERIFY_TIME_MS; + priv->fpe_cfg.status =3D ETHTOOL_MM_VERIFY_STATUS_DISABLED; + timer_setup(&priv->fpe_cfg.verify_timer, stmmac_fpe_verify_timer, 0); + spin_lock_init(&priv->fpe_cfg.lock); +} + +void stmmac_fpe_apply(struct stmmac_priv *priv) +{ + struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; + + /* If verification is disabled, configure FPE right away. + * Otherwise let the timer code do it. + */ + if (!fpe_cfg->verify_enabled) { + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + fpe_cfg->tx_enabled, + fpe_cfg->pmac_enabled); + } else { + fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_INITIAL; + fpe_cfg->verify_retries =3D STMMAC_FPE_MM_MAX_VERIFY_RETRIES; + + if (netif_running(priv->dev)) + stmmac_fpe_verify_timer_arm(fpe_cfg); + } +} + +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, + u32 num_txq, u32 num_rxq, + bool tx_enable, bool pmac_enable) +{ + u32 value; + + if (tx_enable) { + cfg->fpe_csr =3D EFPE; + value =3D readl(ioaddr + GMAC_RXQ_CTRL1); + value &=3D ~GMAC_RXQCTRL_FPRQ; + value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; + writel(value, ioaddr + GMAC_RXQ_CTRL1); + } else { + cfg->fpe_csr =3D 0; + } + writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); + + value =3D 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); + + value |=3D GMAC_INT_FPE_EN; + } + } else { + value &=3D ~GMAC_INT_FPE_EN; + } + + writel(value, ioaddr + GMAC_INT_EN); +} + +int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +{ + u32 value; + int status; + + status =3D 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 =3D readl(ioaddr + MAC_FPE_CTRL_STS); + + if (value & TRSP) { + status |=3D FPE_EVENT_TRSP; + netdev_dbg(dev, "FPE: Respond mPacket is transmitted\n"); + } + + if (value & TVER) { + status |=3D FPE_EVENT_TVER; + netdev_dbg(dev, "FPE: Verify mPacket is transmitted\n"); + } + + if (value & RRSP) { + status |=3D FPE_EVENT_RRSP; + netdev_dbg(dev, "FPE: Respond mPacket is received\n"); + } + + if (value & RVER) { + status |=3D FPE_EVENT_RVER; + netdev_dbg(dev, "FPE: Verify mPacket is received\n"); + } + + return status; +} + +int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr) +{ + return FIELD_GET(DWMAC5_ADD_FRAG_SZ, readl(ioaddr + MTL_FPE_CTRL_STS)); +} + +void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) +{ + u32 value; + + value =3D readl(ioaddr + MTL_FPE_CTRL_STS); + writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), + ioaddr + MTL_FPE_CTRL_STS); +} + +#define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mappi= ng" +#define WEIGHT_ERR_MSG "TXQ weight %u differs across other TXQs in TC: [%u= ]" + +int dwmac5_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass) +{ + u32 val, offset, count, queue_weight, preemptible_txqs =3D 0; + struct stmmac_priv *priv =3D netdev_priv(ndev); + u32 num_tc =3D ndev->num_tc; + + if (!pclass) + goto update_mapping; + + /* DWMAC CORE4+ can not program TC:TXQ mapping to hardware. + * + * Synopsys Databook: + * "The number of Tx DMA channels is equal to the number of Tx queues, + * and is direct one-to-one mapping." + */ + for (u32 tc =3D 0; tc < num_tc; tc++) { + count =3D ndev->tc_to_txq[tc].count; + offset =3D ndev->tc_to_txq[tc].offset; + + if (pclass & BIT(tc)) + preemptible_txqs |=3D GENMASK(offset + count - 1, offset); + + /* This is 1:1 mapping, go to next TC */ + if (count =3D=3D 1) + continue; + + if (priv->plat->tx_sched_algorithm =3D=3D MTL_TX_ALGORITHM_SP) { + NL_SET_ERR_MSG_MOD(extack, ALG_ERR_MSG); + return -EINVAL; + } + + queue_weight =3D priv->plat->tx_queues_cfg[offset].weight; + + for (u32 i =3D 1; i < count; i++) { + if (priv->plat->tx_queues_cfg[offset + i].weight !=3D + queue_weight) { + NL_SET_ERR_MSG_FMT_MOD(extack, WEIGHT_ERR_MSG, + queue_weight, tc); + return -EINVAL; + } + } + } + +update_mapping: + val =3D readl(priv->ioaddr + MTL_FPE_CTRL_STS); + writel(u32_replace_bits(val, preemptible_txqs, DWMAC5_PREEMPTION_CLASS), + priv->ioaddr + MTL_FPE_CTRL_STS); + + return 0; +} + +void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *c= fg, + u32 num_txq, u32 num_rxq, + bool tx_enable, bool pmac_enable) +{ + u32 value; + + if (!tx_enable) { + value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); + + value &=3D ~XGMAC_EFPE; + + writel(value, ioaddr + XGMAC_FPE_CTRL_STS); + return; + } + + value =3D readl(ioaddr + XGMAC_RXQ_CTRL1); + value &=3D ~XGMAC_RQ; + value |=3D (num_rxq - 1) << XGMAC_RQ_SHIFT; + writel(value, ioaddr + XGMAC_RXQ_CTRL1); + + value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); + value |=3D XGMAC_EFPE; + writel(value, ioaddr + XGMAC_FPE_CTRL_STS); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.h new file mode 100644 index 000000000000..25725fd5182f --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024 Furong Xu <0x1207@gmail.com> + * stmmac FPE(802.3 Qbu) handling + */ +#ifndef _STMMAC_FPE_H_ +#define _STMMAC_FPE_H_ + +#include +#include + +#define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3 +#define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128 + +/* FPE link-partner hand-shaking mPacket type */ +enum stmmac_mpacket_type { + MPACKET_VERIFY =3D 0, + MPACKET_RESPONSE =3D 1, +}; + +struct stmmac_priv; +struct stmmac_fpe_cfg; + +void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up); +void stmmac_fpe_event_status(struct stmmac_priv *priv, int status); +void stmmac_fpe_init(struct stmmac_priv *priv); +void stmmac_fpe_apply(struct stmmac_priv *priv); + +void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, + u32 num_txq, u32 num_rxq, + bool tx_enable, bool pmac_enable); +void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, + struct stmmac_fpe_cfg *cfg, + enum stmmac_mpacket_type type); +int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); +int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr); +void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size); +int dwmac5_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass); + +void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *c= fg, + u32 num_txq, u32 num_rxq, + bool tx_enable, bool pmac_enable); + +#endif diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index d3895d7eecfc..ab547430a717 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -43,6 +43,7 @@ #include #include #include "stmmac_ptp.h" +#include "stmmac_fpe.h" #include "stmmac.h" #include "stmmac_xdp.h" #include @@ -966,35 +967,6 @@ static void stmmac_mac_config(struct phylink_config *c= onfig, unsigned int mode, /* Nothing to do, xpcs_config() handles everything */ } =20 -static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is= _up) -{ - struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; - unsigned long flags; - - timer_shutdown_sync(&fpe_cfg->verify_timer); - - spin_lock_irqsave(&fpe_cfg->lock, flags); - - if (is_up && fpe_cfg->pmac_enabled) { - /* VERIFY process requires pmac enabled when NIC comes up */ - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - false, true); - - /* New link =3D> maybe new partner =3D> new verification process */ - stmmac_fpe_apply(priv); - } else { - /* No link =3D> turn off EFPE */ - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - false, false); - } - - spin_unlock_irqrestore(&fpe_cfg->lock, flags); -} - static void stmmac_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { @@ -5953,35 +5925,6 @@ static int stmmac_set_features(struct net_device *ne= tdev, return 0; } =20 -static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) -{ - struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; - - /* This is interrupt context, just spin_lock() */ - spin_lock(&fpe_cfg->lock); - - if (!fpe_cfg->pmac_enabled || status =3D=3D FPE_EVENT_UNKNOWN) - goto unlock_out; - - /* LP has sent verify mPacket */ - if ((status & FPE_EVENT_RVER) =3D=3D FPE_EVENT_RVER) - stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, - MPACKET_RESPONSE); - - /* Local has sent verify mPacket */ - if ((status & FPE_EVENT_TVER) =3D=3D FPE_EVENT_TVER && - fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) - fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_VERIFYING; - - /* LP has sent response mPacket */ - if ((status & FPE_EVENT_RRSP) =3D=3D FPE_EVENT_RRSP && - fpe_cfg->status =3D=3D ETHTOOL_MM_VERIFY_STATUS_VERIFYING) - fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; - -unlock_out: - spin_unlock(&fpe_cfg->lock); -} - static void stmmac_common_interrupt(struct stmmac_priv *priv) { u32 rx_cnt =3D priv->plat->rx_queues_to_use; @@ -7337,90 +7280,6 @@ int stmmac_reinit_ringparam(struct net_device *dev, = u32 rx_size, u32 tx_size) return ret; } =20 -/** - * stmmac_fpe_verify_timer - Timer for MAC Merge verification - * @t: timer_list struct containing private info - * - * Verify the MAC Merge capability in the local TX direction, by - * transmitting Verify mPackets up to 3 times. Wait until link - * partner responds with a Response mPacket, otherwise fail. - */ -static void stmmac_fpe_verify_timer(struct timer_list *t) -{ - struct stmmac_fpe_cfg *fpe_cfg =3D from_timer(fpe_cfg, t, verify_timer); - struct stmmac_priv *priv =3D container_of(fpe_cfg, struct stmmac_priv, - fpe_cfg); - unsigned long flags; - bool rearm =3D false; - - spin_lock_irqsave(&fpe_cfg->lock, flags); - - switch (fpe_cfg->status) { - case ETHTOOL_MM_VERIFY_STATUS_INITIAL: - case ETHTOOL_MM_VERIFY_STATUS_VERIFYING: - if (fpe_cfg->verify_retries !=3D 0) { - stmmac_fpe_send_mpacket(priv, priv->ioaddr, - fpe_cfg, MPACKET_VERIFY); - rearm =3D true; - } else { - fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_FAILED; - } - - fpe_cfg->verify_retries--; - break; - - case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - true, true); - break; - - default: - break; - } - - if (rearm) { - mod_timer(&fpe_cfg->verify_timer, - jiffies + msecs_to_jiffies(fpe_cfg->verify_time)); - } - - spin_unlock_irqrestore(&fpe_cfg->lock, flags); -} - -static void stmmac_fpe_verify_timer_arm(struct stmmac_fpe_cfg *fpe_cfg) -{ - if (fpe_cfg->pmac_enabled && fpe_cfg->tx_enabled && - fpe_cfg->verify_enabled && - fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_FAILED && - fpe_cfg->status !=3D ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) { - timer_setup(&fpe_cfg->verify_timer, stmmac_fpe_verify_timer, 0); - mod_timer(&fpe_cfg->verify_timer, jiffies); - } -} - -void stmmac_fpe_apply(struct stmmac_priv *priv) -{ - struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; - - /* If verification is disabled, configure FPE right away. - * Otherwise let the timer code do it. - */ - if (!fpe_cfg->verify_enabled) { - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - fpe_cfg->tx_enabled, - fpe_cfg->pmac_enabled); - } else { - fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_INITIAL; - fpe_cfg->verify_retries =3D STMMAC_FPE_MM_MAX_VERIFY_RETRIES; - - if (netif_running(priv->dev)) - stmmac_fpe_verify_timer_arm(fpe_cfg); - } -} - static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timesta= mp) { const struct stmmac_xdp_buff *ctx =3D (void *)_ctx; @@ -7699,11 +7558,7 @@ int stmmac_dvr_probe(struct device *device, =20 mutex_init(&priv->lock); =20 - priv->fpe_cfg.verify_retries =3D STMMAC_FPE_MM_MAX_VERIFY_RETRIES; - priv->fpe_cfg.verify_time =3D STMMAC_FPE_MM_MAX_VERIFY_TIME_MS; - priv->fpe_cfg.status =3D ETHTOOL_MM_VERIFY_STATUS_DISABLED; - timer_setup(&priv->fpe_cfg.verify_timer, stmmac_fpe_verify_timer, 0); - spin_lock_init(&priv->fpe_cfg.lock); + stmmac_fpe_init(priv); =20 /* If a specific clk_csr value is passed from the platform * this means that the CSR Clock Range selection cannot be --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CF131A0AE0; Thu, 31 Oct 2024 12:38:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378321; cv=none; b=VBaStn9aiDcL5FrUuXvI6Q4sRldFcE6fC2ip4LJcZGxeNBR5n69lwYDZjpEQeQ1Evq2nO99i8r9OzMDIaO76DjUfoG1JdRP8iUTduCp7Rivv0hgyvEWeCYVSXT63mR1PrJzqpiuKSGe5YJYDayRTweWWf+xaQLqoQs13zMbiJ24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378321; c=relaxed/simple; bh=K3aeVQdXxYORP6bkak+eKLGpcS1KQcwR/8W6BFcxkMU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t5u2f6KP+o/BbL4fgqTDSWxqAz8ejqAsXB6hKqyJEAywy6d1cKKsYeeYhlYlUr/WH2WiWHwn4N5GQZRDboAMrmHzASMBVffO/922Sj+MTYOP1wdxaeup9n0DGG05iMM4YW2BBkblNJg66mDcXkrBXkxJFZeAdA0rvCzmi29OfnY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E7s79Z7p; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E7s79Z7p" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-720aa3dbda5so583871b3a.1; Thu, 31 Oct 2024 05:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378318; x=1730983118; darn=vger.kernel.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=oA7WOqPFmljVeUTS9Q7PTFWVVQjhu5akthLiR/BA8aQ=; b=E7s79Z7pkn8Vrw1qJOoT13duV+Zz9lYdFgcReSvZi7aV2xtnN7zWB7urTX48fTiQ9/ Ts6tX2mZA6acYfUiAb5gIW1Ztcpq7rYkQp9YAQwMI6RcLBdpKvXmFZGoxAugAwpmc4WA OkVePnkx/h2b9vumAcQF5QDcbCAbV7Q97n8G1r+LlRtqUIodRpP5HewZWXMjfcJ5Ut20 QTGxLjdveNlbFpwDaMdw241TjN5TRXAd4ZCOIAZMmw1lu5j2uB0ynxFJfYlZMit9EynP ca+LPwmBplcBTuIIzFVYzXEgvPizPu4lgOsNqz4kVxbyPrLNf3Pl3zT7K5L8JdNEho74 jq9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378318; x=1730983118; 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=oA7WOqPFmljVeUTS9Q7PTFWVVQjhu5akthLiR/BA8aQ=; b=PJGT2prbU+/aon3jiMldS/wY9Bwv2lhZTF3p0YSMQqUXDOJ4Ge+8Vbw1ESDHQgMsR0 J7+8YArNPiD8rDb/9b6UyGmEIjNa8XABh0nD/jpQW+NQQBMtP36h+F29KUCtSQX9Qqsj 4m0HvOybSJ6GcDr6T+/1IVxqZ7KfRiBPGNUGYgquG8DdCp9lm+kGRxu4wBz/yYy8wwS5 zvsdd8ZObCUYoWmJ90GEzoRPYb3/kghm1egYsdJjr9asxL87Gl44DxO7fpmLmRbPPphl O3CL53jK7Xd8Ggv2iebhPgadQhoXNJsuziQbYRx3+8AyRGzndk4HwzDO7wugwOLp9d1L WHjA== X-Forwarded-Encrypted: i=1; AJvYcCVJXThFoRjzwlfE3p6I3llBh4vdwA/RHJpk5eMdhBAiRjosvq1QJvpnDCIiuLnRNpYg0SHPUGSiJpYv+l4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxta/s8atxqUNnwdabTXFL2NroMjmEtgd+z+ZVZXvfRvkycnmHt u9wFWgKPX1MdyL51rNH8wqqY6ovfRcwd6YZ0JK6krDvPJEEN34qPfTHf2Q== X-Google-Smtp-Source: AGHT+IET+sY0E46lWarvlGIdaHkkMfvFyfIQdOQLMKuA71uA9XWxqWIf0kZOahQOVcXrh5fKsYL8ug== X-Received: by 2002:a05:6a00:890:b0:71e:658f:c43b with SMTP id d2e1a72fcca58-720ab39e4famr8440895b3a.2.1730378317866; Thu, 31 Oct 2024 05:38:37 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:38:37 -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 , andrew+netdev@lunn.ch, 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 v7 2/8] net: stmmac: Rework macro definitions for gmac4 and xgmac Date: Thu, 31 Oct 2024 20:37:56 +0800 Message-Id: <26b4654455eace4e6d2db951b6f2d752dda0c4c2.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c index 59e666668ac1..4d5a1704ed61 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -9,23 +9,23 @@ #include "dwmac5.h" #include "dwxgmac2.h" =20 -#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 MTL_FPE_CTRL_STS 0x00000c90 +#define GMAC5_MAC_FPE_CTRL_STS 0x00000234 +#define XGMAC_MAC_FPE_CTRL_STS 0x00000280 + +#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) =20 -#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) =20 void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { @@ -62,11 +62,11 @@ void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, stru= ct stmmac_fpe_cfg *cfg, u32 value =3D cfg->fpe_csr; =20 if (type =3D=3D MPACKET_VERIFY) - value |=3D SVER; + value |=3D STMMAC_MAC_FPE_CTRL_STS_SVER; else if (type =3D=3D MPACKET_RESPONSE) - value |=3D SRSP; + value |=3D STMMAC_MAC_FPE_CTRL_STS_SRSP; =20 - writel(value, ioaddr + MAC_FPE_CTRL_STS); + writel(value, ioaddr + GMAC5_MAC_FPE_CTRL_STS); } =20 void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) @@ -198,7 +198,7 @@ void dwmac5_fpe_configure(void __iomem *ioaddr, struct = stmmac_fpe_cfg *cfg, u32 value; =20 if (tx_enable) { - cfg->fpe_csr =3D EFPE; + cfg->fpe_csr =3D STMMAC_MAC_FPE_CTRL_STS_EFPE; value =3D readl(ioaddr + GMAC_RXQ_CTRL1); value &=3D ~GMAC_RXQCTRL_FPRQ; value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; @@ -206,14 +206,14 @@ void dwmac5_fpe_configure(void __iomem *ioaddr, struc= t stmmac_fpe_cfg *cfg, } else { cfg->fpe_csr =3D 0; } - writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); + writel(cfg->fpe_csr, ioaddr + GMAC5_MAC_FPE_CTRL_STS); =20 value =3D readl(ioaddr + GMAC_INT_EN); =20 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); =20 value |=3D GMAC_INT_FPE_EN; } @@ -234,24 +234,24 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struc= t 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 =3D readl(ioaddr + MAC_FPE_CTRL_STS); + value =3D readl(ioaddr + GMAC5_MAC_FPE_CTRL_STS); =20 - if (value & TRSP) { + if (value & STMMAC_MAC_FPE_CTRL_STS_TRSP) { status |=3D FPE_EVENT_TRSP; netdev_dbg(dev, "FPE: Respond mPacket is transmitted\n"); } =20 - if (value & TVER) { + if (value & STMMAC_MAC_FPE_CTRL_STS_TVER) { status |=3D FPE_EVENT_TVER; netdev_dbg(dev, "FPE: Verify mPacket is transmitted\n"); } =20 - if (value & RRSP) { + if (value & STMMAC_MAC_FPE_CTRL_STS_RRSP) { status |=3D FPE_EVENT_RRSP; netdev_dbg(dev, "FPE: Respond mPacket is received\n"); } =20 - if (value & RVER) { + if (value & STMMAC_MAC_FPE_CTRL_STS_RVER) { status |=3D FPE_EVENT_RVER; netdev_dbg(dev, "FPE: Verify mPacket is received\n"); } @@ -261,16 +261,17 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struc= t net_device *dev) =20 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)); } =20 void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) { u32 value; =20 - value =3D readl(ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), - ioaddr + MTL_FPE_CTRL_STS); + value =3D 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); } =20 #define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mappi= ng" @@ -321,9 +322,9 @@ int dwmac5_fpe_map_preemption_class(struct net_device *= ndev, } =20 update_mapping: - val =3D readl(priv->ioaddr + MTL_FPE_CTRL_STS); - writel(u32_replace_bits(val, preemptible_txqs, DWMAC5_PREEMPTION_CLASS), - priv->ioaddr + MTL_FPE_CTRL_STS); + val =3D 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); =20 return 0; } @@ -335,11 +336,11 @@ void dwxgmac3_fpe_configure(void __iomem *ioaddr, str= uct stmmac_fpe_cfg *cfg, u32 value; =20 if (!tx_enable) { - value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); + value =3D readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); =20 - value &=3D ~XGMAC_EFPE; + value &=3D ~STMMAC_MAC_FPE_CTRL_STS_EFPE; =20 - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); + writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); return; } =20 @@ -348,7 +349,7 @@ void dwxgmac3_fpe_configure(void __iomem *ioaddr, struc= t stmmac_fpe_cfg *cfg, value |=3D (num_rxq - 1) << XGMAC_RQ_SHIFT; writel(value, ioaddr + XGMAC_RXQ_CTRL1); =20 - value =3D readl(ioaddr + XGMAC_FPE_CTRL_STS); - value |=3D XGMAC_EFPE; - writel(value, ioaddr + XGMAC_FPE_CTRL_STS); + value =3D readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); + value |=3D STMMAC_MAC_FPE_CTRL_STS_EFPE; + writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); } --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0573F1A08B2; Thu, 31 Oct 2024 12:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378329; cv=none; b=HR1u2SZBiyzE/1+d36630QN8z6ZXjky99T5hioVpOkIc1k7saFYrn8Xaut/zuxNuDB3afmlaZvfjFiISWplGNsTqbs4qP07o8fs4XPAjwsvTgMka/uI1r9aiGyyQdnTkfJNjSJikn3+cNHPVecgYYQJu+uLvLInHeP/jk3oGXMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378329; c=relaxed/simple; bh=OB0s/jhXL+yFCwpYe41852DwefeTASptT6MO5UrYC98=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E8mkOq/zRMyPy5DZpZY2proemB0Zhd0PhaWn3YevK2+tqIGaGWRIMF+b6J0WeDAGATArVSGnMBNguiNEWMmY7eq7/fANhszb1nfd6/40XwUVabxfxLrksl87Q0fz9d/bXoivxOD09ZYhAfG2/bMW23osvDNhQAMd68N6mh2uN3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RifqFepp; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RifqFepp" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e5130832aso623231b3a.0; Thu, 31 Oct 2024 05:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378325; x=1730983125; darn=vger.kernel.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=P5sV8NO73peRV32wCfghmf/qnhPjK8SUlm0ScRZcJuo=; b=RifqFeppppQ+2ARI2rAdT+npU9Osk6VUSZHGUs49U7s+1WjWYdWMG+yvFar6FZkHYK Yxta2Y0oBXR+w5FVWBiEqg4X8LDx+v8xENB6s2H9e+6LOaGhTIVoZUfpq75YHdVYtkIg fOKHHqh/Fw4jSIErDkuA5gCBVA2Q3nQyAGbcI3jz1Lmugr+a1nUtNh8PQc8ESevp89vd 9BbcwdEwXFrFFcfdc/jKNcBDOLm+BPpSYt8D3cGUvW4AkQBcGXFh2cyYgYdxz6gv1ujF 62VFoDDOwzdFCEtT8XVqYtiP/tgkGLeWMFxEcg6VcOaCK+Bc2BsQmiRRA/Mx8oxb3vz4 STgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378325; x=1730983125; 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=P5sV8NO73peRV32wCfghmf/qnhPjK8SUlm0ScRZcJuo=; b=lxnSBwsn5t74Fr/rR2n0yhRMvF6Qc9NxUHDUqjvhjjjWLNK5q5Jyc52JtFuwmC4sot dq5rCP+ynbQXHBd437TilDB5MqvSF0IaAG/NjJx6KxTlwlQkJMfDDgHoG8oDpGlfTXBy Yi1Ag8BqJQqPVmWcR3fYqcYzPHZp2wCct/JD8uSol6DN46zlXffT3aYSp7T55b2AFh6B jOMJmSTX15b5ASAEZJywlu6+3qayQJX1zVP6/B0NN4szcYE2rHLOGSw2WeiDvxakDn0J j8Q6mtY8oFg2F6A9vuoal2OYvTbvWZ1hDtkn3j+nUgY3he1F2GPDtHsO2+JMEXac3jFY 7nsw== X-Forwarded-Encrypted: i=1; AJvYcCXivw72L9fIwJF1A7gwnkN1vQZLn+GBhtpkF1R9bC9yFX/ZuT4J0VSaeKFxgUMcEHlt8EXPY4av3TOuAaI=@vger.kernel.org X-Gm-Message-State: AOJu0YxKEUqgUuzW7pl7l4afXhHZIEsdzwFW3Ercom+e6q70gyu5TCaw Cond8MRLTyGWkq4g6kgZW4SEnV/POixzCfy5QE3fLRAzxgu/YzMe5Bu4mw== X-Google-Smtp-Source: AGHT+IG/mzByTRVsPAb1Y5N0K4H6qHHvIt7swpBx6jt17R6WtjSFpwxtF4I8Kfbb5nEiBzk8ZqimHg== X-Received: by 2002:a05:6a20:db0a:b0:1d9:28f8:f287 with SMTP id adf61e73a8af0-1d9a84b8c24mr25253430637.36.1730378324611; Thu, 31 Oct 2024 05:38:44 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:38:44 -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 , andrew+netdev@lunn.ch, 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 v7 3/8] net: stmmac: Refactor FPE functions to generic version Date: Thu, 31 Oct 2024 20:37:57 +0800 Message-Id: <1c05e448a12057b909cc6c7cc0c9645cf393d181.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" FPE implementation for DWMAC4 and DWXGMAC differs only for: 1) Offset address of MAC_FPE_CTRL_STS and MTL_FPE_CTRL_STS 2) FPRQ(Frame Preemption Residue Queue) field in MAC_RxQ_Ctrl1 3) Bit offset of Frame Preemption Interrupt Enable Refactor FPE functions to avoid code duplication and to simplify the code flow by avoiding the use of function pointers. Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 - .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 10 -- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 +- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 - drivers/net/ethernet/stmicro/stmmac/hwif.c | 7 + drivers/net/ethernet/stmicro/stmmac/hwif.h | 20 +-- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 4 +- .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 155 +++++++++--------- .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 26 +-- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +- 11 files changed, 101 insertions(+), 135 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/eth= ernet/stmicro/stmmac/dwmac4.h index 28fff6cab812..0c050324997a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -69,7 +69,6 @@ #define GMAC_RXQCTRL_TACPQE BIT(21) #define GMAC_RXQCTRL_TACPQE_SHIFT 21 #define GMAC_RXQCTRL_FPRQ GENMASK(26, 24) -#define GMAC_RXQCTRL_FPRQ_SHIFT 24 =20 /* MAC Packet Filtering */ #define GMAC_PACKET_FILTER_PR BIT(0) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/ne= t/ethernet/stmicro/stmmac/dwmac4_core.c index 4d217926820a..c25781874aa7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -1262,11 +1262,6 @@ const struct stmmac_ops dwmac410_ops =3D { .set_arp_offload =3D dwmac4_set_arp_offload, .config_l3_filter =3D dwmac4_config_l3_filter, .config_l4_filter =3D dwmac4_config_l4_filter, - .fpe_configure =3D dwmac5_fpe_configure, - .fpe_send_mpacket =3D dwmac5_fpe_send_mpacket, - .fpe_irq_status =3D dwmac5_fpe_irq_status, - .fpe_get_add_frag_size =3D dwmac5_fpe_get_add_frag_size, - .fpe_set_add_frag_size =3D dwmac5_fpe_set_add_frag_size, .fpe_map_preemption_class =3D dwmac5_fpe_map_preemption_class, .add_hw_vlan_rx_fltr =3D dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr =3D dwmac4_del_hw_vlan_rx_fltr, @@ -1317,11 +1312,6 @@ const struct stmmac_ops dwmac510_ops =3D { .set_arp_offload =3D dwmac4_set_arp_offload, .config_l3_filter =3D dwmac4_config_l3_filter, .config_l4_filter =3D dwmac4_config_l4_filter, - .fpe_configure =3D dwmac5_fpe_configure, - .fpe_send_mpacket =3D dwmac5_fpe_send_mpacket, - .fpe_irq_status =3D dwmac5_fpe_irq_status, - .fpe_get_add_frag_size =3D dwmac5_fpe_get_add_frag_size, - .fpe_set_add_frag_size =3D dwmac5_fpe_set_add_frag_size, .fpe_map_preemption_class =3D dwmac5_fpe_map_preemption_class, .add_hw_vlan_rx_fltr =3D dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr =3D dwmac4_del_hw_vlan_rx_fltr, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index 917796293c26..efd47db05dbc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -85,7 +85,6 @@ #define XGMAC_MCBCQ GENMASK(11, 8) #define XGMAC_MCBCQ_SHIFT 8 #define XGMAC_RQ GENMASK(7, 4) -#define XGMAC_RQ_SHIFT 4 #define XGMAC_UPQ GENMASK(3, 0) #define XGMAC_UPQ_SHIFT 0 #define XGMAC_RXQ_CTRL2 0x000000a8 @@ -96,6 +95,7 @@ #define XGMAC_LPIIS BIT(5) #define XGMAC_PMTIS BIT(4) #define XGMAC_INT_EN 0x000000b4 +#define XGMAC_FPEIE BIT(15) #define XGMAC_TSIE BIT(12) #define XGMAC_LPIIE BIT(5) #define XGMAC_PMTIE BIT(4) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/= net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 111ba5a524ed..de6ffda31a80 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1545,7 +1545,6 @@ const struct stmmac_ops dwxgmac210_ops =3D { .config_l3_filter =3D dwxgmac2_config_l3_filter, .config_l4_filter =3D dwxgmac2_config_l4_filter, .set_arp_offload =3D dwxgmac2_set_arp_offload, - .fpe_configure =3D dwxgmac3_fpe_configure, }; =20 static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode, @@ -1602,7 +1601,6 @@ const struct stmmac_ops dwxlgmac2_ops =3D { .config_l3_filter =3D dwxgmac2_config_l3_filter, .config_l4_filter =3D dwxgmac2_config_l4_filter, .set_arp_offload =3D dwxgmac2_set_arp_offload, - .fpe_configure =3D dwxgmac3_fpe_configure, }; =20 int dwxgmac2_setup(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ether= net/stmicro/stmmac/hwif.c index 88cce28b2f98..cfc50289aed6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -6,6 +6,7 @@ =20 #include "common.h" #include "stmmac.h" +#include "stmmac_fpe.h" #include "stmmac_ptp.h" #include "stmmac_est.h" =20 @@ -185,6 +186,7 @@ static const struct stmmac_hwif_entry { .ptp_off =3D PTP_GMAC4_OFFSET, .mmc_off =3D MMC_GMAC4_OFFSET, .est_off =3D EST_GMAC4_OFFSET, + .fpe_reg =3D &dwmac5_fpe_reg, }, .desc =3D &dwmac4_desc_ops, .dma =3D &dwmac4_dma_ops, @@ -205,6 +207,7 @@ static const struct stmmac_hwif_entry { .ptp_off =3D PTP_GMAC4_OFFSET, .mmc_off =3D MMC_GMAC4_OFFSET, .est_off =3D EST_GMAC4_OFFSET, + .fpe_reg =3D &dwmac5_fpe_reg, }, .desc =3D &dwmac4_desc_ops, .dma =3D &dwmac410_dma_ops, @@ -225,6 +228,7 @@ static const struct stmmac_hwif_entry { .ptp_off =3D PTP_GMAC4_OFFSET, .mmc_off =3D MMC_GMAC4_OFFSET, .est_off =3D EST_GMAC4_OFFSET, + .fpe_reg =3D &dwmac5_fpe_reg, }, .desc =3D &dwmac4_desc_ops, .dma =3D &dwmac410_dma_ops, @@ -246,6 +250,7 @@ static const struct stmmac_hwif_entry { .ptp_off =3D PTP_XGMAC_OFFSET, .mmc_off =3D MMC_XGMAC_OFFSET, .est_off =3D EST_XGMAC_OFFSET, + .fpe_reg =3D &dwxgmac3_fpe_reg, }, .desc =3D &dwxgmac210_desc_ops, .dma =3D &dwxgmac210_dma_ops, @@ -267,6 +272,7 @@ static const struct stmmac_hwif_entry { .ptp_off =3D PTP_XGMAC_OFFSET, .mmc_off =3D MMC_XGMAC_OFFSET, .est_off =3D EST_XGMAC_OFFSET, + .fpe_reg =3D &dwxgmac3_fpe_reg, }, .desc =3D &dwxgmac210_desc_ops, .dma =3D &dwxgmac210_dma_ops, @@ -353,6 +359,7 @@ int stmmac_hwif_init(struct stmmac_priv *priv) mac->est =3D mac->est ? : entry->est; =20 priv->hw =3D mac; + priv->fpe_cfg.reg =3D entry->regs.fpe_reg; priv->ptpaddr =3D priv->ioaddr + entry->regs.ptp_off; priv->mmcaddr =3D priv->ioaddr + entry->regs.mmc_off; if (entry->est) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ether= net/stmicro/stmmac/hwif.h index d5a9f01ecac5..64f8ed67dcc4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -420,15 +420,6 @@ struct stmmac_ops { bool en, bool udp, bool sa, bool inv, u32 match); void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr); - void (*fpe_configure)(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable); - void (*fpe_send_mpacket)(void __iomem *ioaddr, - struct stmmac_fpe_cfg *cfg, - enum stmmac_mpacket_type type); - int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); - int (*fpe_get_add_frag_size)(const void __iomem *ioaddr); - void (*fpe_set_add_frag_size)(void __iomem *ioaddr, u32 add_frag_size); int (*fpe_map_preemption_class)(struct net_device *ndev, struct netlink_ext_ack *extack, u32 pclass); @@ -530,16 +521,6 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, config_l4_filter, __args) #define stmmac_set_arp_offload(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, set_arp_offload, __args) -#define stmmac_fpe_configure(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, fpe_configure, __args) -#define stmmac_fpe_send_mpacket(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args) -#define stmmac_fpe_irq_status(__priv, __args...) \ - stmmac_do_callback(__priv, mac, fpe_irq_status, __args) -#define stmmac_fpe_get_add_frag_size(__priv, __args...) \ - stmmac_do_callback(__priv, mac, fpe_get_add_frag_size, __args) -#define stmmac_fpe_set_add_frag_size(__priv, __args...) \ - stmmac_do_void_callback(__priv, mac, fpe_set_add_frag_size, __args) #define stmmac_fpe_map_preemption_class(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, fpe_map_preemption_class, __args) =20 @@ -678,6 +659,7 @@ struct stmmac_est_ops { stmmac_do_void_callback(__priv, est, irq_status, __args) =20 struct stmmac_regs_off { + const struct stmmac_fpe_reg *fpe_reg; u32 ptp_off; u32 mmc_off; u32 est_off; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/eth= ernet/stmicro/stmmac/stmmac.h index 816b979e72cc..1d86439b8a14 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -152,6 +152,7 @@ struct stmmac_fpe_cfg { */ spinlock_t lock; =20 + const struct stmmac_fpe_reg *reg; u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */ =20 enum ethtool_mm_verify_status status; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 2792a4c6cbcd..f2783f7c46f3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -1294,7 +1294,7 @@ static int stmmac_get_mm(struct net_device *ndev, else state->tx_active =3D false; =20 - frag_size =3D stmmac_fpe_get_add_frag_size(priv, priv->ioaddr); + frag_size =3D stmmac_fpe_get_add_frag_size(priv); state->tx_min_frag_size =3D ethtool_mm_frag_size_add_to_min(frag_size); =20 spin_unlock_irqrestore(&priv->fpe_cfg.lock, flags); @@ -1329,7 +1329,7 @@ static int stmmac_set_mm(struct net_device *ndev, str= uct ethtool_mm_cfg *cfg, if (!cfg->verify_enabled) fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_DISABLED; =20 - stmmac_fpe_set_add_frag_size(priv, priv->ioaddr, frag_size); + stmmac_fpe_set_add_frag_size(priv, frag_size); stmmac_fpe_apply(priv); =20 spin_unlock_irqrestore(&fpe_cfg->lock, flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c index 4d5a1704ed61..818741579904 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -27,6 +27,21 @@ #define STMMAC_MAC_FPE_CTRL_STS_SVER BIT(1) #define STMMAC_MAC_FPE_CTRL_STS_EFPE BIT(0) =20 +/* FPE link-partner hand-shaking mPacket type */ +enum stmmac_mpacket_type { + MPACKET_VERIFY =3D 0, + MPACKET_RESPONSE =3D 1, +}; + +struct stmmac_fpe_reg { + const u32 mac_fpe_reg; /* offset of MAC_FPE_CTRL_STS */ + const u32 mtl_fpe_reg; /* offset of MTL_FPE_CTRL_STS */ + const u32 rxq_ctrl1_reg; /* offset of MAC_RxQ_Ctrl1 */ + const u32 fprq_mask; /* Frame Preemption Residue Queue */ + const u32 int_en_reg; /* offset of MAC_Interrupt_Enable */ + const u32 int_en_bit; /* Frame Preemption Interrupt Enable */ +}; + void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; @@ -38,38 +53,34 @@ void stmmac_fpe_link_state_handle(struct stmmac_priv *p= riv, bool is_up) =20 if (is_up && fpe_cfg->pmac_enabled) { /* VERIFY process requires pmac enabled when NIC comes up */ - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - false, true); + stmmac_fpe_configure(priv, false, true); =20 /* New link =3D> maybe new partner =3D> new verification process */ stmmac_fpe_apply(priv); } else { /* No link =3D> turn off EFPE */ - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - false, false); + stmmac_fpe_configure(priv, false, false); } =20 spin_unlock_irqrestore(&fpe_cfg->lock, flags); } =20 -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *= cfg, - enum stmmac_mpacket_type type) +static void stmmac_fpe_send_mpacket(struct stmmac_priv *priv, + enum stmmac_mpacket_type type) { - u32 value =3D cfg->fpe_csr; + const struct stmmac_fpe_reg *reg =3D priv->fpe_cfg.reg; + void __iomem *ioaddr =3D priv->ioaddr; + u32 value =3D priv->fpe_cfg.fpe_csr; =20 if (type =3D=3D MPACKET_VERIFY) value |=3D STMMAC_MAC_FPE_CTRL_STS_SVER; else if (type =3D=3D MPACKET_RESPONSE) value |=3D STMMAC_MAC_FPE_CTRL_STS_SRSP; =20 - writel(value, ioaddr + GMAC5_MAC_FPE_CTRL_STS); + writel(value, ioaddr + reg->mac_fpe_reg); } =20 -void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) +static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) { struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; =20 @@ -81,8 +92,7 @@ void stmmac_fpe_event_status(struct stmmac_priv *priv, in= t status) =20 /* LP has sent verify mPacket */ if ((status & FPE_EVENT_RVER) =3D=3D FPE_EVENT_RVER) - stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, - MPACKET_RESPONSE); + stmmac_fpe_send_mpacket(priv, MPACKET_RESPONSE); =20 /* Local has sent verify mPacket */ if ((status & FPE_EVENT_TVER) =3D=3D FPE_EVENT_TVER && @@ -120,8 +130,7 @@ static void stmmac_fpe_verify_timer(struct timer_list *= t) case ETHTOOL_MM_VERIFY_STATUS_INITIAL: case ETHTOOL_MM_VERIFY_STATUS_VERIFYING: if (fpe_cfg->verify_retries !=3D 0) { - stmmac_fpe_send_mpacket(priv, priv->ioaddr, - fpe_cfg, MPACKET_VERIFY); + stmmac_fpe_send_mpacket(priv, MPACKET_VERIFY); rearm =3D true; } else { fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_FAILED; @@ -131,10 +140,7 @@ static void stmmac_fpe_verify_timer(struct timer_list = *t) break; =20 case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - true, true); + stmmac_fpe_configure(priv, true, true); break; =20 default: @@ -177,10 +183,7 @@ void stmmac_fpe_apply(struct stmmac_priv *priv) * Otherwise let the timer code do it. */ if (!fpe_cfg->verify_enabled) { - stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - fpe_cfg->tx_enabled, + stmmac_fpe_configure(priv, fpe_cfg->tx_enabled, fpe_cfg->pmac_enabled); } else { fpe_cfg->status =3D ETHTOOL_MM_VERIFY_STATUS_INITIAL; @@ -191,50 +194,55 @@ void stmmac_fpe_apply(struct stmmac_priv *priv) } } =20 -void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable) +void stmmac_fpe_configure(struct stmmac_priv *priv, bool tx_enable, + bool pmac_enable) { + struct stmmac_fpe_cfg *cfg =3D &priv->fpe_cfg; + const struct stmmac_fpe_reg *reg =3D cfg->reg; + u32 num_rxq =3D priv->plat->rx_queues_to_use; + void __iomem *ioaddr =3D priv->ioaddr; u32 value; =20 if (tx_enable) { cfg->fpe_csr =3D STMMAC_MAC_FPE_CTRL_STS_EFPE; - value =3D readl(ioaddr + GMAC_RXQ_CTRL1); - value &=3D ~GMAC_RXQCTRL_FPRQ; - value |=3D (num_rxq - 1) << GMAC_RXQCTRL_FPRQ_SHIFT; - writel(value, ioaddr + GMAC_RXQ_CTRL1); + value =3D readl(ioaddr + reg->rxq_ctrl1_reg); + value &=3D ~reg->fprq_mask; + /* Keep this SHIFT, FIELD_PREP() expects a constant mask :-/ */ + value |=3D (num_rxq - 1) << __ffs(reg->fprq_mask); + writel(value, ioaddr + reg->rxq_ctrl1_reg); } else { cfg->fpe_csr =3D 0; } - writel(cfg->fpe_csr, ioaddr + GMAC5_MAC_FPE_CTRL_STS); + writel(cfg->fpe_csr, ioaddr + reg->mac_fpe_reg); =20 - value =3D readl(ioaddr + GMAC_INT_EN); + value =3D readl(ioaddr + reg->int_en_reg); =20 if (pmac_enable) { - if (!(value & GMAC_INT_FPE_EN)) { + if (!(value & reg->int_en_bit)) { /* Dummy read to clear any pending masked interrupts */ - readl(ioaddr + GMAC5_MAC_FPE_CTRL_STS); + readl(ioaddr + reg->mac_fpe_reg); =20 - value |=3D GMAC_INT_FPE_EN; + value |=3D reg->int_en_bit; } } else { - value &=3D ~GMAC_INT_FPE_EN; + value &=3D ~reg->int_en_bit; } =20 - writel(value, ioaddr + GMAC_INT_EN); + writel(value, ioaddr + reg->int_en_reg); } =20 -int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) +void stmmac_fpe_irq_status(struct stmmac_priv *priv) { + const struct stmmac_fpe_reg *reg =3D priv->fpe_cfg.reg; + void __iomem *ioaddr =3D priv->ioaddr; + struct net_device *dev =3D priv->dev; + int status =3D FPE_EVENT_UNKNOWN; u32 value; - int status; - - status =3D FPE_EVENT_UNKNOWN; =20 /* 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 =3D readl(ioaddr + GMAC5_MAC_FPE_CTRL_STS); + value =3D readl(ioaddr + reg->mac_fpe_reg); =20 if (value & STMMAC_MAC_FPE_CTRL_STS_TRSP) { status |=3D FPE_EVENT_TRSP; @@ -256,22 +264,26 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struc= t net_device *dev) netdev_dbg(dev, "FPE: Verify mPacket is received\n"); } =20 - return status; + stmmac_fpe_event_status(priv, status); } =20 -int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr) +int stmmac_fpe_get_add_frag_size(struct stmmac_priv *priv) { - return FIELD_GET(FPE_MTL_ADD_FRAG_SZ, - readl(ioaddr + GMAC5_MTL_FPE_CTRL_STS)); + const struct stmmac_fpe_reg *reg =3D priv->fpe_cfg.reg; + void __iomem *ioaddr =3D priv->ioaddr; + + return FIELD_GET(FPE_MTL_ADD_FRAG_SZ, readl(ioaddr + reg->mtl_fpe_reg)); } =20 -void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) +void stmmac_fpe_set_add_frag_size(struct stmmac_priv *priv, u32 add_frag_s= ize) { + const struct stmmac_fpe_reg *reg =3D priv->fpe_cfg.reg; + void __iomem *ioaddr =3D priv->ioaddr; u32 value; =20 - value =3D readl(ioaddr + GMAC5_MTL_FPE_CTRL_STS); + value =3D readl(ioaddr + reg->mtl_fpe_reg); writel(u32_replace_bits(value, add_frag_size, FPE_MTL_ADD_FRAG_SZ), - ioaddr + GMAC5_MTL_FPE_CTRL_STS); + ioaddr + reg->mtl_fpe_reg); } =20 #define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mappi= ng" @@ -329,27 +341,20 @@ int dwmac5_fpe_map_preemption_class(struct net_device= *ndev, return 0; } =20 -void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *c= fg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable) -{ - u32 value; - - if (!tx_enable) { - value =3D readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); - - value &=3D ~STMMAC_MAC_FPE_CTRL_STS_EFPE; - - writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); - return; - } - - value =3D readl(ioaddr + XGMAC_RXQ_CTRL1); - value &=3D ~XGMAC_RQ; - value |=3D (num_rxq - 1) << XGMAC_RQ_SHIFT; - writel(value, ioaddr + XGMAC_RXQ_CTRL1); - - value =3D readl(ioaddr + XGMAC_MAC_FPE_CTRL_STS); - value |=3D STMMAC_MAC_FPE_CTRL_STS_EFPE; - writel(value, ioaddr + XGMAC_MAC_FPE_CTRL_STS); -} +const struct stmmac_fpe_reg dwmac5_fpe_reg =3D { + .mac_fpe_reg =3D GMAC5_MAC_FPE_CTRL_STS, + .mtl_fpe_reg =3D GMAC5_MTL_FPE_CTRL_STS, + .rxq_ctrl1_reg =3D GMAC_RXQ_CTRL1, + .fprq_mask =3D GMAC_RXQCTRL_FPRQ, + .int_en_reg =3D GMAC_INT_EN, + .int_en_bit =3D GMAC_INT_FPE_EN, +}; + +const struct stmmac_fpe_reg dwxgmac3_fpe_reg =3D { + .mac_fpe_reg =3D XGMAC_MAC_FPE_CTRL_STS, + .mtl_fpe_reg =3D XGMAC_MTL_FPE_CTRL_STS, + .rxq_ctrl1_reg =3D XGMAC_RXQ_CTRL1, + .fprq_mask =3D XGMAC_RQ, + .int_en_reg =3D XGMAC_INT_EN, + .int_en_bit =3D XGMAC_FPEIE, +}; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.h index 25725fd5182f..15fcb9ef1a97 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -12,34 +12,22 @@ #define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3 #define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128 =20 -/* FPE link-partner hand-shaking mPacket type */ -enum stmmac_mpacket_type { - MPACKET_VERIFY =3D 0, - MPACKET_RESPONSE =3D 1, -}; - struct stmmac_priv; struct stmmac_fpe_cfg; =20 void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up); -void stmmac_fpe_event_status(struct stmmac_priv *priv, int status); void stmmac_fpe_init(struct stmmac_priv *priv); void stmmac_fpe_apply(struct stmmac_priv *priv); +void stmmac_fpe_configure(struct stmmac_priv *priv, bool tx_enable, + bool pmac_enable); +void stmmac_fpe_irq_status(struct stmmac_priv *priv); +int stmmac_fpe_get_add_frag_size(struct stmmac_priv *priv); +void stmmac_fpe_set_add_frag_size(struct stmmac_priv *priv, u32 add_frag_s= ize); =20 -void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable); -void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, - struct stmmac_fpe_cfg *cfg, - enum stmmac_mpacket_type type); -int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); -int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr); -void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size); int dwmac5_fpe_map_preemption_class(struct net_device *ndev, struct netlink_ext_ack *extack, u32 pclass); =20 -void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *c= fg, - u32 num_txq, u32 num_rxq, - bool tx_enable, bool pmac_enable); +extern const struct stmmac_fpe_reg dwmac5_fpe_reg; +extern const struct stmmac_fpe_reg dwxgmac3_fpe_reg; =20 #endif diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index ab547430a717..9fcf2df099ec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5943,12 +5943,8 @@ static void stmmac_common_interrupt(struct stmmac_pr= iv *priv) stmmac_est_irq_status(priv, priv, priv->dev, &priv->xstats, tx_cnt); =20 - if (priv->dma_cap.fpesel) { - int status =3D stmmac_fpe_irq_status(priv, priv->ioaddr, - priv->dev); - - stmmac_fpe_event_status(priv, status); - } + if (priv->dma_cap.fpesel) + stmmac_fpe_irq_status(priv); =20 /* To handle GMAC own interrupts */ if ((priv->plat->has_gmac) || xmac) { --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E66A1A257D; Thu, 31 Oct 2024 12:38:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378336; cv=none; b=WgsyZgMtSzGMSyXyC41U4/KJPJQd3NYvMZDBZUvGmo+ESBi9C2to4x1NcCYhPfExdD0DKjNP9OM4by0/ZbyFUl6nHObhDuj5ONqhf9BY6A1RPOt+gOAes+dSdCJimjcCv5w6LoJZs2ePN6yuw69f4lSNdg3H3xMCp7X2S8+KSOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378336; c=relaxed/simple; bh=rd78XK9KITWaeHJ37CwsKwOpCLVCYdO/RkXAMs+JQko=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=axJXR4Rat6nNEoTocDCu7R+w+utfix+OZpCO+y890+LdNg4SQ4VKq4/QD1Z2X3fuxQMuHdFS9O2hL3KEW9FKguj22BHSv4x8NqqSm7+bJ5BVIbHKd6ISqE2ZT7RDMXPmVpihFvXbZgadkJSprgM4UJEKh2BqG6fq/n6Z7iKZ3TA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cnjKv6Br; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cnjKv6Br" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-71e5a1c9071so666058b3a.0; Thu, 31 Oct 2024 05:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378333; x=1730983133; darn=vger.kernel.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=FFGEbEEjLbbQpGlnwYzVMfTZ0wqqjjrWRQOLfRsrvcs=; b=cnjKv6BrNdV2rwTBMvV6aoY/Sfq8lstzdCLJXK4In73gW8AgWFM2khBMbn0fat5NCR Zw6VIqcNI4ZPFh2oYapZmG5yuMwzIpfTH7YIQ2pPFpN1xBZXMFyg+UL2gmycXThwxsvr ZWf9eSNHCByj1cCnefqTyVqVaZHBhFVuFfV7NjS/flC2TtMNGRXJyMkO9r7YvRS3YCeF iqkTYEFOBd9tqfayqVrAQT4SyqSv+4Sf5Uv6+ku+dJvMJFKhco+4rUCi2g5I309SGewl Tj+CX+STUMlmjlWIYlsfVZgcwM08OBBxetYGFCbauOHZEkzow8IOOS8+nAIygCLmAjVg HRIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378333; x=1730983133; 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=FFGEbEEjLbbQpGlnwYzVMfTZ0wqqjjrWRQOLfRsrvcs=; b=uh0JpawV5PTICRyCsx7VlPf3WETRfadDnIZpZ5sPRlfLyMenyOfS9CfNBbSKa9HhPv LI/XlALfuHM77RrkWaovFYK8iu52c4EzKN+pM9eK8KgGFEd6Zi3xMb0vPe1nfZmRSd6n tdGZ9q2hR3DCU5sNRRsm90gsod+II85txdZpOyGkWpH9gJ9wTMCTIz9TX5gJQH4J4MEA dreT6ZIK58PygTF8Hl9eHtoue2T8r9Go9xB52HbltfseBKFyDayA1o5nTUmJ07ysIaOI zNxwyUTR4AfKi9A6eI+5L+umcWfQlBZxw0SnMP1fuy31yiETEnJelfOBabAtJV7FF6A3 1tgA== X-Forwarded-Encrypted: i=1; AJvYcCUgpaqCwatI4hO8tzzj5Jhoe5eTEvR1tncZN6x4UOv7yzm4f4nq89fYQPkobUMHkSsX8zguG4alvkQTrsQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxXoB63KbZHMYmh40FGceEt1Njy/NPDBx9Fiz11LoCIviRSWntJ 1afIAeQIkytoBvXVSRyH0DiEbo/DUNdaOgTxmSHzCcf3Mr3fFqP9wNACYQ== X-Google-Smtp-Source: AGHT+IEZxQHxPYwUn+a4vwc02ndfamOj2UcHfNlIlB+PjdVN/65q2Qw46vrTi7Bee/Ggg5dJokSHdQ== X-Received: by 2002:a05:6a20:2d29:b0:1d8:a1dc:b3b with SMTP id adf61e73a8af0-1d9eec4580fmr9881706637.20.1730378333058; Thu, 31 Oct 2024 05:38:53 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:38:51 -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 , andrew+netdev@lunn.ch, 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 v7 4/8] net: stmmac: Introduce stmmac_fpe_supported() Date: Thu, 31 Oct 2024 20:37:58 +0800 Message-Id: <917f3868cdaf8ce1d45239117c3ea1c8c45ba56c.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Call stmmac_fpe_supported() to check both HW capability and driver capability to keep FPE as an optional implementation for current and new MAC cores. Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 10 ++++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++----- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index f2783f7c46f3..1d77389ce953 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -1271,7 +1271,7 @@ static int stmmac_get_mm(struct net_device *ndev, unsigned long flags; u32 frag_size; =20 - if (!priv->dma_cap.fpesel) + if (!stmmac_fpe_supported(priv)) return -EOPNOTSUPP; =20 spin_lock_irqsave(&priv->fpe_cfg.lock, flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c index 818741579904..fe0877ef5f4f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -42,6 +42,12 @@ struct stmmac_fpe_reg { const u32 int_en_bit; /* Frame Preemption Interrupt Enable */ }; =20 +bool stmmac_fpe_supported(struct stmmac_priv *priv) +{ + return priv->dma_cap.fpesel && priv->fpe_cfg.reg && + priv->hw->mac->fpe_map_preemption_class; +} + void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { struct stmmac_fpe_cfg *fpe_cfg =3D &priv->fpe_cfg; @@ -173,6 +179,10 @@ void stmmac_fpe_init(struct stmmac_priv *priv) priv->fpe_cfg.status =3D ETHTOOL_MM_VERIFY_STATUS_DISABLED; timer_setup(&priv->fpe_cfg.verify_timer, stmmac_fpe_verify_timer, 0); spin_lock_init(&priv->fpe_cfg.lock); + + if ((!priv->fpe_cfg.reg || !priv->hw->mac->fpe_map_preemption_class) && + priv->dma_cap.fpesel) + dev_info(priv->device, "FPE on this MAC is not supported by driver.\n"); } =20 void stmmac_fpe_apply(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.h index 15fcb9ef1a97..2f8bceaf7a0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -16,6 +16,7 @@ struct stmmac_priv; struct stmmac_fpe_cfg; =20 void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up); +bool stmmac_fpe_supported(struct stmmac_priv *priv); void stmmac_fpe_init(struct stmmac_priv *priv); void stmmac_fpe_apply(struct stmmac_priv *priv); void stmmac_fpe_configure(struct stmmac_priv *priv, bool tx_enable, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index 9fcf2df099ec..883b4b814125 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -978,7 +978,7 @@ static void stmmac_mac_link_down(struct phylink_config = *config, priv->eee_enabled =3D stmmac_eee_init(priv); stmmac_set_eee_pls(priv, priv->hw, false); =20 - if (priv->dma_cap.fpesel) + if (stmmac_fpe_supported(priv)) stmmac_fpe_link_state_handle(priv, false); } =20 @@ -1092,7 +1092,7 @@ static void stmmac_mac_link_up(struct phylink_config = *config, stmmac_set_eee_pls(priv, priv->hw, true); } =20 - if (priv->dma_cap.fpesel) + if (stmmac_fpe_supported(priv)) stmmac_fpe_link_state_handle(priv, true); =20 if (priv->plat->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY) @@ -4040,7 +4040,7 @@ static int stmmac_release(struct net_device *dev) =20 stmmac_release_ptp(priv); =20 - if (priv->dma_cap.fpesel) + if (stmmac_fpe_supported(priv)) timer_shutdown_sync(&priv->fpe_cfg.verify_timer); =20 pm_runtime_put(priv->device); @@ -5943,7 +5943,7 @@ static void stmmac_common_interrupt(struct stmmac_pri= v *priv) stmmac_est_irq_status(priv, priv, priv->dev, &priv->xstats, tx_cnt); =20 - if (priv->dma_cap.fpesel) + if (stmmac_fpe_supported(priv)) stmmac_fpe_irq_status(priv); =20 /* To handle GMAC own interrupts */ @@ -7729,7 +7729,7 @@ int stmmac_suspend(struct device *dev) } rtnl_unlock(); =20 - if (priv->dma_cap.fpesel) + if (stmmac_fpe_supported(priv)) timer_shutdown_sync(&priv->fpe_cfg.verify_timer); =20 priv->speed =3D SPEED_UNKNOWN; --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F22219D89B; Thu, 31 Oct 2024 12:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378343; cv=none; b=Tf2x8YKOsPnOhI/5U//gg1IlpRboiRR4jPAJ4wiVcmvDdLTLa7+TZI5aol9/xV+I+1NvCTxhzM4pzWr4F2SfhTyi7SuHTTXDO6pTpjy+3tecSvvDZayLPKtHU+skYx+cyZewC+ArbhXLu7hXlhdPR3RYLrIxNAd8eyjiRGsi5MM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378343; c=relaxed/simple; bh=unf86eIGY5mtECgKadC7veM6vk/9GNltKKTdlYjFziM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cLvaj+0ich4R8f4HG2f88zbXv0cTWN01fUf+yK85xYcYvPRuWrc33NXWOJjXJoxmnzVmI+YCH2nH1ouJkmcduYGE+ewMPrPQQqdhsviEqkE6id+1Y61A8DSYmnhnlwi7VZK8dSFAqi6HpxhdICsffy8HJX4pthzL9weeh9eqS3Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ccrWNDSA; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ccrWNDSA" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e983487a1so671420b3a.2; Thu, 31 Oct 2024 05:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378340; x=1730983140; darn=vger.kernel.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=BWr+UUbXH8lnMLmy8eSvjMvYSmy75x4Or0Lzgqe9VF0=; b=ccrWNDSAHWakqKTmSBFYD8L4KzY12eH+lrIwtZsHee7PZ0hQ1umJl3HX5BhIdoMTUn zeP/UbJ04H3xcDpRHmtv+q3wHSrEgmgV72TZB86POvI8adVGONK1vfuenkMowF8BQ2fU 4n/qLPwpLHO6VkZZ27TdnurB+NYFsHLS6nxy9ri07DkGEZMS4waTgThYJQBAF8+NZbAS m4N/4eOAtzbCJ4W6KYqu1bfFdrybi2z1A63mmbaB6leRKlHTQe7myj61y5dlniA6k3sU oA5n7p6z4OHPfCAVXxufTIb7tdrBJT8PnzSMKTZq6euV6uWxRORwlWKxHZJwZW2i3jbT FE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378340; x=1730983140; 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=BWr+UUbXH8lnMLmy8eSvjMvYSmy75x4Or0Lzgqe9VF0=; b=kpbYJ6W7CAc6D4el+CopB9QE+85EtIKqU3kPnQKpojkSMFvWbdtTJADq0ngSpPqGNX hd4bPoNkv5Qq+IZ20j3OzCPr0DUDJYXtx2M0UHk6fzKQGRpAX+U1RgYqKH+rBDV1tGP5 5gQ6d1LlNofHQ+beIQbMuD0vUfG/hEY5TzKChJJjOUxIkgOzzQpaBMwTy/BRSdkois06 jYaGDDHWK4J73h8ayA7wgJd5oURgEOEOwOUiBULpdgM3MDd3TakI1OAjcGVr3EtgQXPP +1RhWJPRbKJs0egL2QCFgRdnoTtpbLW6O9rRbB46NPS9kI0tg3UbGkHDYB5VvYsxm97D Tptw== X-Forwarded-Encrypted: i=1; AJvYcCWLDpiUES7XnOVG5VXhmlIaOoBQVBij6PGnn/RWBeLD0vbxdvkdYRrwTfQBvpwFOm/virJXIqwdjVOU5rE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxox+9fdSxOtV+P3WieXZqfR/ovlKBKZlhTEzEBAhd/1ciUle9Q V9/8Fn/b6EO5u3+AZEverkGzKCFDkEQgGgFN3srTB0gLYmMv0AzDMnXzMw== X-Google-Smtp-Source: AGHT+IGBmQcF+qVYl01bmlNc+GnbWq0Wjs3/vOJvZ50iXD5Wd6bwcRVM5avpNRM6Y+vslybR47mm4w== X-Received: by 2002:a05:6a20:c998:b0:1d9:857a:585c with SMTP id adf61e73a8af0-1db91d89bc3mr3170917637.19.1730378340154; Thu, 31 Oct 2024 05:39:00 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:38:59 -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 , andrew+netdev@lunn.ch, 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 v7 5/8] net: stmmac: Get the TC number of net_device by netdev_get_num_tc() Date: Thu, 31 Oct 2024 20:37:59 +0800 Message-Id: <4c19d46ee5f6d4229e86eb6195295cf8916b4c09.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" netdev_get_num_tc() is the right method, we should not access net_device.num_tc directly. Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c index fe0877ef5f4f..f07972e47737 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -304,7 +304,7 @@ int dwmac5_fpe_map_preemption_class(struct net_device *= ndev, { u32 val, offset, count, queue_weight, preemptible_txqs =3D 0; struct stmmac_priv *priv =3D netdev_priv(ndev); - u32 num_tc =3D ndev->num_tc; + int num_tc =3D netdev_get_num_tc(ndev); =20 if (!pclass) goto update_mapping; --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AF1B1E495; Thu, 31 Oct 2024 12:39:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378350; cv=none; b=UkILdPZeN8WlXkjfOGis0O7+uK7nCM3u+SaLE5QTxl3NmJwp9l6jZbUASdjluQTgRcCHo1lxTMPoGVCYjA/Sb7gwVPDYXNT8UfSmHerOrg41JAUi1ZvRmmS73kbdWhLx4TO9ssn/fmE5hNNUk7aTXtkOIdXdyYon+faOOCTOV6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378350; c=relaxed/simple; bh=xPbOsAgpFplYVCCw32ulDCcKYLSLi4YhGMc48hPu7TE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yrb2gDA2k/6FdzWHq1xaC3FBR3gGTu03lmvZEits+mFjXnztXkrZDY5MriD6kOHHzQbDCrpvtpcr8lNoLkCUiPLmz4+vMAavn5wTVd1wv8sPDeuwWRhh9rfeBAyloD49kxB/YmVz8aJKtWSXUqVwFJ1UPLPiQU1+oHsTv4YTRMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DejadJwt; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DejadJwt" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-720c2db824eso291233b3a.0; Thu, 31 Oct 2024 05:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378347; x=1730983147; darn=vger.kernel.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=Gr5byz9uGWQ6qTVVNyRJz2fcSvGGfWOU5qQmAfQjTs0=; b=DejadJwtaIZrIXinKPJKLhr4omg1/iY+gZM978l/orq6niW0aJ6TI5Ri8y1mVlg7D0 7ZqSCOfjs/nLhw3L7h6W2PfD9PMOTCvJSLNpqM542Nb5EjKWqkokM/GSQS1PjNoOgHEF eJjy5IbP5Q59XfoXcFUsFwvNZqOeDFkXp4NCBz5EAh3NJqJV6zX+5OonzM8fO82xaaBn 58Iqmk5Klke8LwoY02Q8kdsOr8LOvr8bNYeizv6loXlSJ91w+LGubBsI6N9ASLcFZ1DM rxxCP8luUc3ATeOseRoVLooobehM9R3vCRPnOv1mVxuDlyTVf+utIgKERJUVw2nDqz5Q f5YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378347; x=1730983147; 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=Gr5byz9uGWQ6qTVVNyRJz2fcSvGGfWOU5qQmAfQjTs0=; b=jLFBVD1ims8GUz++4aDSnAYCalaqgkceQoCwCCCisP6F/oUkv+mG4rkaOMxVSQypnj +Ky8ibX1sIRMXdaQhw/UxuW/exK3CCm0kkJuHLoKPSQMMoIwVVEayicGlFezCZvmYRtB lZk86CSOMj89fzVUQ9g7bjO8TF7hwgRO/qzy5Pv1G3uxoi5iig+Jh0jV1A9bs5T3SVbY 6j5eX6vyRKdvcBMyZVTrsDXxYeQtiNCGxg+3kMxt2ZsmgIfSCV7z9kcmE//B7jKfHNWo k/HPqYO4z3vAodC7geJVZg5ERGKa/V3pSfcPZQ8lFi3z58OrDuv5VR7VCkxzhc7NfYhP mwpg== X-Forwarded-Encrypted: i=1; AJvYcCVVWbO6IDGl5aY68+JYIhkYPIb913iRUC61Qe0tBAhTUBNQNTYJ6Rf7l1F/3Bhc+NE4dlBoQc01Co9HEGI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4mE23UwBD6mX1DrlhvTNE2quDBgnORsM65VQuQrOEieAe9D8J 1BbblFKKVKlgAmGt2vh6A2xkC+VPNtBRCmZo+NvN45bv04lVOT/O6d08ew== X-Google-Smtp-Source: AGHT+IFrvqh3fZqXzS4zBEWib3+Sale7tzbI8D4zdSrUqBXu2tE+RWOF0X7aeH5toWPKujtUAdjN9w== X-Received: by 2002:a05:6a00:2384:b0:71e:68ae:aaed with SMTP id d2e1a72fcca58-72062f81e6dmr24955795b3a.1.1730378347148; Thu, 31 Oct 2024 05:39:07 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:39:06 -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 , andrew+netdev@lunn.ch, 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 v7 6/8] net: stmmac: xgmac: Rename XGMAC_RQ to XGMAC_FPRQ Date: Thu, 31 Oct 2024 20:38:00 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Synopsys XGMAC Databook defines MAC_RxQ_Ctrl1 register: RQ: Frame Preemption Residue Queue XGMAC_FPRQ is more readable and more consistent with GMAC4. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Simon Horman --- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/e= thernet/stmicro/stmmac/dwxgmac2.h index efd47db05dbc..a04a79003692 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -84,7 +84,7 @@ #define XGMAC_MCBCQEN BIT(15) #define XGMAC_MCBCQ GENMASK(11, 8) #define XGMAC_MCBCQ_SHIFT 8 -#define XGMAC_RQ GENMASK(7, 4) +#define XGMAC_FPRQ GENMASK(7, 4) #define XGMAC_UPQ GENMASK(3, 0) #define XGMAC_UPQ_SHIFT 0 #define XGMAC_RXQ_CTRL2 0x000000a8 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net= /ethernet/stmicro/stmmac/stmmac_fpe.c index f07972e47737..b833ccf3e455 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -364,7 +364,7 @@ const struct stmmac_fpe_reg dwxgmac3_fpe_reg =3D { .mac_fpe_reg =3D XGMAC_MAC_FPE_CTRL_STS, .mtl_fpe_reg =3D XGMAC_MTL_FPE_CTRL_STS, .rxq_ctrl1_reg =3D XGMAC_RXQ_CTRL1, - .fprq_mask =3D XGMAC_RQ, + .fprq_mask =3D XGMAC_FPRQ, .int_en_reg =3D XGMAC_INT_EN, .int_en_bit =3D XGMAC_FPEIE, }; --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F1FC19D080; Thu, 31 Oct 2024 12:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378357; cv=none; b=UUH/pLZu3ywmoPE+cw4LwHnggjaammJ24aEHa1jmbvaYfgaBNjW6F6bPSxChZkvcI3D736rTZxvG0VBOH1hYXAGsxeW9ChwIeXmNkx6PYEyJL/ukd8pnV+NHKV+Kp/CddTndGhhimO3RRzEnfZa+6Xb/NwGq+Tf1nGoBDn64wEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378357; c=relaxed/simple; bh=U21Zg27i+744I1Q1Dk1gf55xF/PKKZyEln0v0ltxpQI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qzd79QaFQYtWxvfSFuOUVtK4df56KgNx9CSkxhb0uwnHngJ9eae/Vxj2/R4Q7l1XfOlloZNFGEpD+NwaL9Dd9fcKnpl7t8OgLnl7G+XSQhKVruaqbnqC22O3f7swquMhMAX+qfFBF2NtahyKqeGkA2LG01ENqZTAJHoaqb5Ei8g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CWRuA45Z; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CWRuA45Z" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-71e3fce4a60so635140b3a.0; Thu, 31 Oct 2024 05:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378354; x=1730983154; darn=vger.kernel.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=gVhsPMRQqpy2OnJpha195VCCt6s/CZrRESIlVmFiY5k=; b=CWRuA45Z3p0yqWKzmSITeTpL7cxMJT4Qcte5oawlDpaZh/jcyDIL2ZfvY2FNgHOyeb M3vZoQU/wOjVs7y7KR0KLyLs+ztUtFsSaa6lgYkMJAEfdHObqXqG8vVRgxvurQYRypjO JPiKb+hVsHTcpDi9fVSMOFx/HlWGAwRtt7qkYCO91FsZxmQpqVHvPz18VjFJy0eGmVhz nmq35t+AeY7b+WdmFYtQ/zGEqcr9W4C6D7O7mzHi2Mh9SUOcTQHqYjqsLNRtSAKutPU9 GPakW707Srhk/xzm3u2Ed0e3S+TIb3oic00OYIIWmZd01rStZv1CSw9juLWqicRPOTHw 0YBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378354; x=1730983154; 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=gVhsPMRQqpy2OnJpha195VCCt6s/CZrRESIlVmFiY5k=; b=pracd14VQE6lPdJwr73W2rwJIVHO7aNM2IFbqn1KScXA9iuht3F3KauUGoU0vgyvSC TGeBFZ1GzytWX790m2aCCduoZCYMQg76LZ1DjIAJ5oBHYxlFj0O9CA6KqGS3+Pg+SjpJ JsgGMxs27Uam2/QSAytNVYxetNbpREtYadg3C0uwj626mJJ/9r29HWKHFssYKf7DyzHF fFeLeYRPFjF1rK7w0C89cXF5hcoVMDCw9hcSP8kBmc7IhSjaMCrVyy4xKwIvglvuj3Je xx0kqe4ToL73ZhNH9QEo/QFvzxihRJ4cgbGknY7ncn3asLx0HwaE0S99mXvIFY/xFYCj C51g== X-Forwarded-Encrypted: i=1; AJvYcCXYl7LggR52dAvq8t9vQuu6J+Qd+JvFLAzwNDsTyLyPUW7rRtM3hpIORRS/faFC2CfiDEkekac+9Y/0/vY=@vger.kernel.org X-Gm-Message-State: AOJu0YzXHU0oob0IB8l6iG6bVfY+3w5rB/PYq2NwyvsAP8061BkwPuaJ 2t0xE48zdOsdXlFabNcvrKkZawe5cphFpBt3YAEI3vVBZ77z6gdRt33n9Q== X-Google-Smtp-Source: AGHT+IH3Zm14ICyR7iSwgMxwf/UKQHEUEgmjsMUWQ2oRzm5QVHyY5n9VwcbYyUIviTW6vDUpdnWv/w== X-Received: by 2002:a05:6a21:6801:b0:1d9:3a26:4396 with SMTP id adf61e73a8af0-1d9a83d6622mr24295744637.12.1730378353991; Thu, 31 Oct 2024 05:39:13 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:39:13 -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 , andrew+netdev@lunn.ch, 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 v7 7/8] net: stmmac: xgmac: Complete FPE support Date: Thu, 31 Oct 2024 20:38:01 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D { .config_l3_filter =3D dwxgmac2_config_l3_filter, .config_l4_filter =3D dwxgmac2_config_l4_filter, .set_arp_offload =3D dwxgmac2_set_arp_offload, + .fpe_map_preemption_class =3D dwxgmac3_fpe_map_preemption_class, }; =20 static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode, @@ -1601,6 +1602,7 @@ const struct stmmac_ops dwxlgmac2_ops =3D { .config_l3_filter =3D dwxgmac2_config_l3_filter, .config_l4_filter =3D dwxgmac2_config_l4_filter, .set_arp_offload =3D dwxgmac2_set_arp_offload, + .fpe_map_preemption_class =3D dwxgmac3_fpe_map_preemption_class, }; =20 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 b833ccf3e455..884b37ad0347 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -351,6 +351,49 @@ int dwmac5_fpe_map_preemption_class(struct net_device = *ndev, return 0; } =20 +int dwxgmac3_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass) +{ + u32 val, offset, count, preemptible_txqs =3D 0; + struct stmmac_priv *priv =3D netdev_priv(ndev); + int num_tc =3D netdev_get_num_tc(ndev); + + if (!num_tc) { + /* Restore default TC:Queue mapping */ + for (u32 i =3D 0; i < priv->plat->tx_queues_to_use; i++) { + val =3D 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 =3D 0; tc < num_tc; tc++) { + count =3D ndev->tc_to_txq[tc].count; + offset =3D ndev->tc_to_txq[tc].offset; + + if (pclass & BIT(tc)) + preemptible_txqs |=3D GENMASK(offset + count - 1, offset); + + for (u32 i =3D 0; i < count; i++) { + val =3D 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 =3D 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 =3D { .mac_fpe_reg =3D GMAC5_MAC_FPE_CTRL_STS, .mtl_fpe_reg =3D 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 2f8bceaf7a0a..4d17302bc868 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -27,6 +27,9 @@ void stmmac_fpe_set_add_frag_size(struct stmmac_priv *pri= v, u32 add_frag_size); =20 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); =20 extern const struct stmmac_fpe_reg dwmac5_fpe_reg; extern const struct stmmac_fpe_reg dwxgmac3_fpe_reg; --=20 2.34.1 From nobody Sun Nov 24 23:53:18 2024 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 669EB1B3727; Thu, 31 Oct 2024 12:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378363; cv=none; b=eo34+mDOvXIqbLG2FKlcGkoRKB7VALC6MLDVHrjDxSwNdIl4MRDbKLJRiL+ch05V5JVacYwsIlrv01+c+2/D7xnVEYvZ6MtP+piYpXFB/O/PI4Qcaj1sTckiqCqgl9rRr93FUxl6DCuurJ4hJeIWhD9CANxqSJlCmiR3eItmoRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730378363; c=relaxed/simple; bh=udSu0PifOzRa5GkWP7sFryWEU4fALlPs0aaNg1SJDJs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BULUr9AwPz3aqR993pRlcqNMiFuVsZAr3riYTECP8sLRady7dCl2SJNibdcfd0vSEqPhoz4CNzRqrIdfbsYm85flPH+8niFecFbmzcU96Hm8EMQR67Bfu2efW4/JlIIna56LnHkwBG9FHxY/Oz1GWJs2I7vGH0DbKOAeqtN4hXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bPxAIQZt; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bPxAIQZt" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71e983487a1so671662b3a.2; Thu, 31 Oct 2024 05:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730378360; x=1730983160; darn=vger.kernel.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=XZgSPrHkP+5PHa4TM3CPdf/GMcXQ4aZTX0bTblaWKZw=; b=bPxAIQZtv5kZxCLcgrXU96DKUhFmPstyCLHYjVkp9TrD8+qFgEW4oHM4hHNRhYyyIx tVg2ukhTzhMMEjLch3sLYQLF4PsECQnk7bN2i8XpOc5HnEPpEbqyaclcgPMcu1ecA73U 2JxTXoZUSiwzWtS4Ak/ozDtGj0eJDyHLdx3IgeW9ex0Cn+Er0F20Qvi/TFkxxtmNQT72 10crtRRvQC6PkV44DYQMkm/DNtBEGgnKWLX3k2UjM2doVd3Ssu23NCD4vw3yUwWs8lH4 HI5FTxI9ZWjcuPzrRnOWTMNEZoFfUSrBP1fJFEIIgB7ZQaqw2aqlnGIoIXKBCZlCgPkE ff1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730378360; x=1730983160; 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=XZgSPrHkP+5PHa4TM3CPdf/GMcXQ4aZTX0bTblaWKZw=; b=daemF6RfuTuuUoTP6H8TYm3QVTAsQz9jLXld3BwXvipJVGb8TQ7iRhE4nLKim8VroE v8YgudfBBPrSkOwp64EdINLB8Ow9Y792S/NN8i3Hd9q+dI4rvtrOTsVFJY4QKBuhCuDX jZbm+U6lhrlsLRocQWYSPXetgHcx+tUx2rPOwGusPNy3VUWVywxsYSwAbgDPDXvq906M 31sHVsmXjBGJIV+RlhY0PAdG3Z6ziAJ+l8GlcYAvbh3aArRNHUrSYYm83CehW7i6UVSy Cgj3f75ND0dZfZQWu2INfXyZm82XvEXAvBl4/gDwTQtZ/JA3LeTHsMoSo6xBAO469GBJ iGqA== X-Forwarded-Encrypted: i=1; AJvYcCXd+xtZK7PozA/r1rCxgRuoSs2a35uWA2r5UMrnpe/S22nAfMU+yIei0Mnl7D2r0nL+nzcagB702qAP2sM=@vger.kernel.org X-Gm-Message-State: AOJu0YwG8N8fIiAAM83LPbM4yhJkNZgXqKFToOotify8ICIlh4ch8Onb PL3F39wK2PpSRZc6DIPcstMbZOy4l4gunhudENs45J4JVH+PKLqw9w70ow== X-Google-Smtp-Source: AGHT+IEYepYTbWzaNjZB6/WykZo7JXNjSOPeC4faI93w6dXeeMLicqGen6Mz6ACbQEadzKBbhQtzhg== X-Received: by 2002:a05:6a00:1397:b0:714:15ff:a2a4 with SMTP id d2e1a72fcca58-720b9c96d0emr4011140b3a.13.1730378360174; Thu, 31 Oct 2024 05:39:20 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-720bc20f50esm1075931b3a.94.2024.10.31.05.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2024 05:39:19 -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 , andrew+netdev@lunn.ch, 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 v7 8/8] net: stmmac: xgmac: Enable FPE for tc-mqprio/tc-taprio Date: Thu, 31 Oct 2024 20:38:02 +0800 Message-Id: <527799d9e4e28fbd51eb37754f130b037bc0f6ea.1730376866.git.0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The FPE on XGMAC is ready, it is time to update dwxgmac_tc_ops to let user configure FPE via tc-mqprio/tc-taprio. Signed-off-by: Furong Xu <0x1207@gmail.com> --- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/= ethernet/stmicro/stmmac/stmmac_tc.c index 75ad2da1a37f..6a79e6a111ed 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1290,8 +1290,8 @@ const struct stmmac_tc_ops dwxgmac_tc_ops =3D { .setup_cls_u32 =3D tc_setup_cls_u32, .setup_cbs =3D tc_setup_cbs, .setup_cls =3D tc_setup_cls, - .setup_taprio =3D tc_setup_taprio_without_fpe, + .setup_taprio =3D tc_setup_taprio, .setup_etf =3D tc_setup_etf, .query_caps =3D tc_query_caps, - .setup_mqprio =3D tc_setup_mqprio_unimplemented, + .setup_mqprio =3D tc_setup_dwmac510_mqprio, }; --=20 2.34.1