From nobody Mon Nov 25 07:39:02 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 91ABD1D12E7; Wed, 30 Oct 2024 05:37:11 +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=1730266633; cv=none; b=P5zuX11ruhVexOer93AZ0JvqPDkBDpeoQ9SNxuEZovDdhUXFbIyfQMFxd8hkb9AaefURVjYEzRW4m4T0Q16mK7J5S1oCJfRa/Cdw3+0j2clphUZ9JUhBViW/sM/aYifFHfVtkp9Box3qyTIRhzPuY+HqDXW/3eRSK5Z22vincnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730266633; c=relaxed/simple; bh=LdGz6uEWf1ZFX4Lx4Wp9lQkNf0U/xMQ83F3wnTz/Qa4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cKxoAMIK5OOmCbxktEzHhN4KcvPMTMeLSSPTLlUl8RT6Mk6WOpR971SHXas61aOk4lruAoHiZJIRrxzXYF8+r5tAqRBe9Z7STo5xcBOg27bkmJ/9S/DnAj18elrl2mnNFjk8/RfJ1CvBpQsGuunOdtknPjpjg4BtO1ESVGZwtUE= 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=m+I/rt4T; 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="m+I/rt4T" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71e8235f0b6so4771264b3a.3; Tue, 29 Oct 2024 22:37:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730266630; x=1730871430; 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=4rMTL6l4+ePH78ifD4HQ4rzCV1XSwWL49wAuSNSzsWs=; b=m+I/rt4TwTjQsQciuuI6t5BP1NGO2xIsHmK1y8ckoftFs0ZVg1N1ECT6tSFUiKSTaD hLaqZsXo2SAJpw0TL7z37ywfCaG4jTlEo5uBRJDNR3TAfrbMjq9ONa6ROX5+xBK2UE5+ PuNJcUYCJEgfp1Wclp5jDWJ8XkS8Q7eXNzkof50tGE0lrW6LKMXOslg8RH3ZKgPU+qNq iNc6ElGy4Pu3a5/VcMvFf4KlVPjztliuN5QmN+a/3HLcEazYrKBhqTdClLa+mSTInR1W fC8dFzQ5kuPPJfQFfxwIJK3I21ybApnQA1g4eD8xVWhwZKQTRgBKUh2Il3nL6w1pr9NQ ZyCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730266630; x=1730871430; 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=4rMTL6l4+ePH78ifD4HQ4rzCV1XSwWL49wAuSNSzsWs=; b=V67i6Fmrcn0TkgiVfQ9lQezt8pkrgF8MAPSSmRQ389vXZiVHH+LXP1uyA+PxmKB605 WoLMCMdCJZoyiFgmOKJvWACQYyJ5wWA5SQ362n+waGGAmX8hebCCWmiSJakv3kTDhgbI vsRDzHXhwn+dT/gwJhLHA96Lu2TDbWhAUFCTOPsDzIaf7PbxD9unv+Jys6SjZEiucxDR pEmb7YI0EyXseyqXdhv8lgf0+WMTC5a7VT6AschZgWtzMWDaGxm2yKqZrUH2MjKygd73 0o923TNTsOtVRWZE1YjJOttRI9/xHSdSg0fTRKvUkLzchumyKgRJx9+PA471uAzJ+kTY 6zTA== X-Forwarded-Encrypted: i=1; AJvYcCU8NixXRwPB0Ym/sMc158e9OFkVeTn/7OBb08lD7nHXYNjRi5/7mNmqqezGg7ZjXvCSG2rtpHulmxtdWdc=@vger.kernel.org X-Gm-Message-State: AOJu0YxbY+gJR2dwLRO+AV8vCVbGf/p22Bj8mXiJc5DtJ5J9buHg5UGE /bKVLsIacMUf9KUdJ5mhfbbu51788e0hSZ02AzKB+q9KXFJ2qVl51i8TVw== X-Google-Smtp-Source: AGHT+IE7CgyZn27XxCFhKxyFp3BVb7USJ5mFVVGQGJSHnnvwU5HqtIlFwQl/alcMVDkE7vGIRyO7AA== X-Received: by 2002:a05:6a00:985:b0:71e:52ec:638d with SMTP id d2e1a72fcca58-72062fb21d1mr21241676b3a.10.1730266630361; Tue, 29 Oct 2024 22:37:10 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-7edc8661098sm8516595a12.8.2024.10.29.22.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 22:37:09 -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 v6 5/6] net: stmmac: xgmac: Complete FPE support Date: Wed, 30 Oct 2024 13:36:14 +0800 Message-Id: <7d6db0a3e995163b6f2ff69f88b650eea812ce5d.1730263957.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" 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 46a4809d5094..ab72fcd5fc79 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c @@ -343,6 +343,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); + u32 num_tc =3D ndev->num_tc; + + 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 00e616d7cbf1..9a0adb8ee23d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -35,6 +35,9 @@ void stmmac_fpe_set_add_frag_size(struct stmmac_priv *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