From nobody Mon Nov 25 00:19:10 2024 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 CF5C319F423; Fri, 1 Nov 2024 13:32:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730467955; cv=none; b=ReIU07nrL16vl+H6nAUqxo6Xd1YxWTjWnfggBLAZEKr69hS/+NrP8pL3jyq4c+4qJZI7x/Y755tU5KRcCfy39m3fS6U3a7L9gfTUrj09H0q0VHmKJR6JVgAFljP1m32P12gDP7K55McjQcNGivlPjOMGiokkKLNzaNaGzPkMzf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730467955; c=relaxed/simple; bh=I+3MFGIX+jhUQkHCLw6fpg1IKJZkkFJfO8qiuFVNgN4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dO0zMBiXhNCThZkS1AFUmqeeUMuQI+nRVq4ljbyrxFDftx0VBR4NBBvPGOxe9b1WZuXXCJzrUaNjArdWsEsIec8A+6U5OzOTuCHNEdoFaOUtZz/B6txJn460xCNJQPBDqS3x59qYm1+eZXQt/XM8YVm4kfJfh9RlZVRwUXB77rc= 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=SYtYfhDF; arc=none smtp.client-ip=209.85.210.177 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="SYtYfhDF" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-71e467c3996so1620733b3a.2; Fri, 01 Nov 2024 06:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730467952; x=1731072752; 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=WtzA86pp72kOdXxZZwIORo56/g13hQx8u+e/ETOI+EM=; b=SYtYfhDFIF/3jGf1ECPD3o0YJj9oYBMWcfeopiaQ8sry9lgY4arDNGOAWVQ2T/3jaG 2naxMznf3BTXywnPDzmN1P7Ki4gg7YbNt0DUqHJDNo6syWtrOocG3Jv2EC/k3bO/TDoR vptN9p2Qr1WQpVQSoXGMMsnQD+GS+i+lpwGqXULMAXomcofp4IqWiOXpwB5r8eD/vWNg oPbNFg9cSFF3PydDe+g89w58bW6P+PRST2gdjRbTYtxpkIWGW97eueLwBFek1ID7Ql6+ +jXMvpJZzGkEVIhUx27i7mXYJnvxxIORFLOGildPooMnkqVr5lJ7MRDoJQQBKRl5aVmQ vdYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730467952; x=1731072752; 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=WtzA86pp72kOdXxZZwIORo56/g13hQx8u+e/ETOI+EM=; b=NXzCI3ReSSnFu1WZyAB7H68/Gh0Z5mY8ofJp2Upu5ni26qSeWX4ABKDQexxq84X4xy 1D7i7KeYbsmUrGDtJBw4lxd4GGdtQrl5uD11XCY4TGaQbVEa628sAOVc0D2ORUolvuDm rkvcZO73okSj08ZLHB4n+Jj9Jb0byit+TkyVJQpo4n/+ESTS2oygc876+wwRRuj0d4wT S2csOfcAm/ob4SmCCHUEJZ5xeF6bX3demDDSEWdvxBls/3XkO8OUzuu1XJfj+MYUc0r6 36AQouWaZ7austs8CNJTwlIpxfFxCJS0PJMZLN//GNv94vgLLx/rhxHZNGsmxWff4yDk X3wA== X-Forwarded-Encrypted: i=1; AJvYcCUUx3ajIsJJV/coILQORncMeRD9SQ8zWj8ZHsQyDMdhA/v4luFkxepP62y9+TWwMSRm0HWNZUCZW9mvK3c=@vger.kernel.org X-Gm-Message-State: AOJu0YzR+5RllQuTk1rERowSGTjKSwnsKxj92dWj1OigT7PpE39SmGmr a4D0TQ9KSlYTrwvN8Rk6VPnw6tCpV4irj8owByue0GYyrof+Zejk75U8JA== X-Google-Smtp-Source: AGHT+IEIrf5Jc0S5SUHIgMo8LFRuqQulN1uTl6WBxSZzPDPh2/GVfOJ18wu6iTPuwNXTONnPcdvvbA== X-Received: by 2002:a05:6a21:3a82:b0:1d8:f1f4:f4ee with SMTP id adf61e73a8af0-1d9a83aba1bmr28240695637.8.1730467952395; Fri, 01 Nov 2024 06:32:32 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id 41be03b00d2f7-7ee452ac4ffsm2425552a12.25.2024.11.01.06.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2024 06:32:31 -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 v8 7/8] net: stmmac: xgmac: Complete FPE support Date: Fri, 1 Nov 2024 21:31:34 +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 | 2 + 3 files changed, 47 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 5ccdc6887b28..3a4bee029c7f 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 b5a896d315bf..b884eac7142d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h @@ -24,6 +24,8 @@ 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