From patchwork Fri Nov 1 13:31:34 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: 13859412 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6E70E6B278 for ; Fri, 1 Nov 2024 13:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=WtzA86pp72kOdXxZZwIORo56/g13hQx8u+e/ETOI+EM=; b=bpbLNtvl1WHwJdFVIGQX8psNxQ KFNmjuWWTZku0d7jBlcZ1O0bbxQJCeVH7HnZGERRwXV1OIx1Ia2r1cdEPVG74G+qSdp34KwuVpIeo V6IrRGRTNxChEAYwASG7n6IEA77qDkWeZKy84nSrhTG7+efcmghqjiiZjyjyRLGjhjS0AUTUuxcWk Fe4lWaEWTjP1WG7uBcU3ucd1egRU74eNgnxLMc9iWAXBdGLZwJIj65aSAKIeM2kJZa1wN0jXDxCH1 b67rgOjfGimhKysjqPolOzx3hlGcnL7bAMuYAh2jBTq436z8P0qIPtHrqKTw7+7i65DmtpND9AECI WwBUcABg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6rzD-00000007DW2-0e5l; Fri, 01 Nov 2024 13:46:47 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6rlR-00000007BTp-0tlZ for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2024 13:32:35 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-720b2d8bb8dso1542426b3a.1 for ; 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=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WtzA86pp72kOdXxZZwIORo56/g13hQx8u+e/ETOI+EM=; b=ChLhr6szE3Wzss3q+n3hQVinlfwYQ8amnWfdpCfKfklm3rXsgqrhFb2nkKZTcM/IfX /VGSAQyu+K6MHgF91dRP2dQlf5qd+tyrnPoSMDjgfdp9uq4SBnVfl1TeGvJhn7/SkI24 9V8JhOT3h810UNtWWmAhGEv0XXSkNUbPrX/zL64mkMkxK6z8PWquKhyDV+Hl7v581ZK4 fQ+uahNikznRCcVe+3objB0ddz4YzIAz+j2QLqu81HGGJX2u2nADx+4dBgoGoS4I5mIm liGPVZ1naU7s7CfCJhEZA/5vpdagSfHyyEpZuOXAF4JIl4ut7kw7ssH/72JoGwgoV9VT 1NMQ== 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=VZHPhEscsaOqD9mK9yONAFxD8InMrInrNJlARJwMNAdiAMv4+vDuBTQZsN9mO18L2r hy8GH/xn5zlq0LrLROaaikwFpaEsaxOtbHdBdLslrpz0D9TNv3E9GpMTuIc9Oe169Qh5 z/ZMoGTJ6F0WOqt2RLvGSNlzvwu85cKGSUYuqU43dWqvdlfWlybpO98ZwIXWvCIa+xoW KPPwdnpk2oUdk7g6/+D6pPBr2XHH34/GgjXK6aMKnKpeRHahaydKao9Mla/EheSw/fg9 khj6c8UCQyx9DPTiTSq0GfsaejLCQsea1wrb82gEe2kogBNu5N2+IqtJTgo8606O5ZCf pbtw== X-Forwarded-Encrypted: i=1; AJvYcCVW3z7KUgJJe9zO8F8D8Rxpghh36ugWPh2dwB6X8luyctc4JqpeKxVHN7tEs3P67riLI31fSQ0JJHpUgtthqiDj@lists.infradead.org X-Gm-Message-State: AOJu0Yx44NZokg4QIbXHaCkNk6BMCAjIvpHoe61wTKILCUTVV3ehjULz K2isjUe1MHizZtbG3hgpk68z3K4cmjSOGW+T9TVZOCBrapmgpF46 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: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241101_063233_353782_09EBF797 X-CRM114-Status: GOOD ( 16.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement the necessary fpe_map_preemption_class callback for xgmac. Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 + .../net/ethernet/stmicro/stmmac/stmmac_fpe.c | 43 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_fpe.h | 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 = { .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 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; } +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 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 *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;