From patchwork Thu Oct 31 12:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 13857861 X-Patchwork-Delegate: kuba@kernel.org 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Implement the necessary fpe_map_preemption_class callback for xgmac. Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 + .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 43 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 3 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index de6ffda31a80..9a60a6e8f633 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1545,6 +1545,7 @@ const struct stmmac_ops dwxgmac210_ops = { .config_l3_filter = dwxgmac2_config_l3_filter, .config_l4_filter = dwxgmac2_config_l4_filter, .set_arp_offload = dwxgmac2_set_arp_offload, + .fpe_map_preemption_class = dwxgmac3_fpe_map_preemption_class, }; static void dwxlgmac2_rx_queue_enable(struct mac_device_info *hw, u8 mode, @@ -1601,6 +1602,7 @@ const struct stmmac_ops dwxlgmac2_ops = { .config_l3_filter = dwxgmac2_config_l3_filter, .config_l4_filter = dwxgmac2_config_l4_filter, .set_arp_offload = dwxgmac2_set_arp_offload, + .fpe_map_preemption_class = dwxgmac3_fpe_map_preemption_class, }; int dwxgmac2_setup(struct stmmac_priv *priv) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c index 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; } +int dwxgmac3_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass) +{ + u32 val, offset, count, preemptible_txqs = 0; + struct stmmac_priv *priv = netdev_priv(ndev); + int num_tc = netdev_get_num_tc(ndev); + + if (!num_tc) { + /* Restore default TC:Queue mapping */ + for (u32 i = 0; i < priv->plat->tx_queues_to_use; i++) { + val = readl(priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(i)); + writel(u32_replace_bits(val, i, XGMAC_Q2TCMAP), + priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(i)); + } + } + + /* Synopsys Databook: + * "All Queues within a traffic class are selected in a round robin + * fashion (when packets are available) when the traffic class is + * selected by the scheduler for packet transmission. This is true for + * any of the scheduling algorithms." + */ + for (u32 tc = 0; tc < num_tc; tc++) { + count = ndev->tc_to_txq[tc].count; + offset = ndev->tc_to_txq[tc].offset; + + if (pclass & BIT(tc)) + preemptible_txqs |= GENMASK(offset + count - 1, offset); + + for (u32 i = 0; i < count; i++) { + val = readl(priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(offset + i)); + writel(u32_replace_bits(val, tc, XGMAC_Q2TCMAP), + priv->ioaddr + XGMAC_MTL_TXQ_OPMODE(offset + i)); + } + } + + val = readl(priv->ioaddr + XGMAC_MTL_FPE_CTRL_STS); + writel(u32_replace_bits(val, preemptible_txqs, FPE_MTL_PREEMPTION_CLASS), + priv->ioaddr + XGMAC_MTL_FPE_CTRL_STS); + + return 0; +} + const struct stmmac_fpe_reg dwmac5_fpe_reg = { .mac_fpe_reg = GMAC5_MAC_FPE_CTRL_STS, .mtl_fpe_reg = GMAC5_MTL_FPE_CTRL_STS, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.h index 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 *priv, u32 add_frag_size); int dwmac5_fpe_map_preemption_class(struct net_device *ndev, struct netlink_ext_ack *extack, u32 pclass); +int dwxgmac3_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, + u32 pclass); extern const struct stmmac_fpe_reg dwmac5_fpe_reg; extern const struct stmmac_fpe_reg dwxgmac3_fpe_reg;