From patchwork Thu Sep 5 07:02:27 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: 13791823 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 5468BCD4F4D for ; Thu, 5 Sep 2024 07:10:14 +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=otlVOJXZzrcHMJzriiHIIRnACM+mCrGtCzdOQVIQKiY=; b=0A4qF8GGiy/KVYizERu7ho13YX xnTe4vHnWldHLzAcxGxmR7mjkC8eqkVAURZQVjcZHzf6ShbfRb4QhWeVHOkHAOpLe1OmkZq6UbfaW p9xM96QeYVAZx7MY8zXvIZMo8xwHshsbruwQcBou209btROS2fz1VjTHqhT16VpDV3w+epoDyET6x Wv4Mo7OYPij2X/iIdirfAVEI5w8U4g9MlqglaAQ0v1X2FbivvkM4XXUClTjCFvOE6zZFToB/C8YDP JvHncQAIuSX9HvcCnryCYeo4l9ZUTIlXME5+D85tSnjomOWunat3ZkVr6waG9Pyx/3WGk7ZPmowJ6 Ab2OVhaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm6d2-00000007Jli-06mi; Thu, 05 Sep 2024 07:10:04 +0000 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm6Wj-00000007I85-1ijl for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 07:03:35 +0000 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5dfa315ffbdso276325eaf.3 for ; Thu, 05 Sep 2024 00:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725519812; x=1726124612; 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=otlVOJXZzrcHMJzriiHIIRnACM+mCrGtCzdOQVIQKiY=; b=E8+UFms7VsC7AT6udqmpkdC6yrGolObd1XeLAUutKZjx1uSbmWFoQy+x0dLXMXenYM TCJqqVL03epw6ZDPGPA+uZsuGo+t1/A08SL+L2b9QsyMx7/s0rQFMrWM50vDmWJUjrPW yS2AkdtTcjldsFQ24A1qX6HDyx9fMnm+/CcHS+VOwUmZYPosMGN4Tgv6a16qMeGDmyv2 WC7Xih89dEmJMUkRrIvqremeh0fA27saoVBNPRa3g22KvT7Dgxvbm0clIB2O4W1apB+O xrNxvy7cG6SQ6UaC2Y8t6w3agUeSN5t318Q3HIlnmZ0O0SQ8mtgZUu4bqfWwiFNi0TJV WlLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725519812; x=1726124612; 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=otlVOJXZzrcHMJzriiHIIRnACM+mCrGtCzdOQVIQKiY=; b=hro+81cmAvt1YzTDMp1DWUq7yjuQPJfNEZCQz4J2hQv6V7WSHi31AWbPmJAt0eYeSD uX2dBd8izZnrWUOnMmVXAgwAnitxUVBnLqQRAzB/K520e07dCZBPIu+mIfuPHl0Eyp38 yt38BpwcA4HWu5lxnULlNSrG9XqNaFTyA0IzkzsuGHFjM+JiE+C5qRbYpVDbiObmycXk eGpOCQIUuIKkLZ8b7X+BjxCZWYY/DnUfnp/dgaSLfzUJDjH4JEn4WtBIt1RoQtPylRi8 zsKkHa1hogTOpPICQxo30FZ9HeoBJKt+EFZxSmd7WqdpN0OXA1B2PeFWTaH2FHZKnOyW xaww== X-Forwarded-Encrypted: i=1; AJvYcCVCkGEuGoDzvd46FL194V4lo5GrMAvHVOy72DOi38rcDAux0FOcuMJ8ranwEomKZJGvzvZB9zsoT6Bmi/RQeSn/@lists.infradead.org X-Gm-Message-State: AOJu0Yx5pEqMI76UhIxiSEmEaGhs5l/+KkuFxQgttGmTsycsZm5dc/ai 8WtVxtGt6U0dRGQXu3mLDzLv5otMG8++kCTd6ZCmMqn6qjmFz//M X-Google-Smtp-Source: AGHT+IHO4Nnb6GEpkOPdgYkTNs+lbZZUJ+YeIrG/dwz3pm5cwFCq5eRB8Be3JRWFblSobOIRGjxzQQ== X-Received: by 2002:a05:6870:a688:b0:277:f002:8073 with SMTP id 586e51a60fabf-277f0028866mr14198864fac.16.1725519812601; Thu, 05 Sep 2024 00:03:32 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71778595107sm2604897b3a.150.2024.09.05.00.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 00:03:32 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , Alexander Lobakin , Serge Semin , "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rmk+kernel@armlinux.org.uk, linux@armlinux.org.uk, xfr@outlook.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v8 6/7] net: stmmac: support fp parameter of tc-taprio Date: Thu, 5 Sep 2024 15:02:27 +0800 Message-Id: <55067bfa505933731cbd018d19213b89126321e3.1725518136.git.0x1207@gmail.com> 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-20240905_000333_793000_189FA89E X-CRM114-Status: GOOD ( 13.95 ) 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 tc-taprio can select whether traffic classes are express or preemptible. 0) tc qdisc add dev eth1 parent root handle 100 taprio \ num_tc 4 \ map 0 1 2 3 2 2 2 2 2 2 2 2 2 2 2 3 \ queues 1@0 1@1 1@2 1@3 \ base-time 1000000000 \ sched-entry S 03 10000000 \ sched-entry S 0e 10000000 \ flags 0x2 fp P E E E 1) After some traffic tests, MAC merge layer statistics are all good. Local device: [ { "ifname": "eth1", "pmac-enabled": true, "tx-enabled": true, "tx-active": true, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": true, "verify-time": 100, "max-verify-time": 128, "verify-status": "SUCCEEDED", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 0, "MACMergeFragCountRx": 0, "MACMergeFragCountTx": 17837, "MACMergeHoldCount": 18639 } } ] Remote device: [ { "ifname": "end1", "pmac-enabled": true, "tx-enabled": true, "tx-active": true, "tx-min-frag-size": 60, "rx-min-frag-size": 60, "verify-enabled": true, "verify-time": 100, "max-verify-time": 128, "verify-status": "SUCCEEDED", "statistics": { "MACMergeFrameAssErrorCount": 0, "MACMergeFrameSmdErrorCount": 0, "MACMergeFrameAssOkCount": 17189, "MACMergeFragCountRx": 17837, "MACMergeFragCountTx": 0, "MACMergeHoldCount": 0 } } ] Tested on DWMAC CORE 5.10a Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean --- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index cfdb9ab1fa2a..05ffff00a524 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -931,9 +931,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv, struct tc_taprio_qopt_offload *qopt) { u32 size, wid = priv->dma_cap.estwid, dep = priv->dma_cap.estdep; + struct netlink_ext_ack *extack = qopt->mqprio.extack; struct timespec64 time, current_time, qopt_time; ktime_t current_time_ns; - bool fpe = false; int i, ret = 0; u64 ctr; @@ -1018,16 +1018,12 @@ static int tc_taprio_configure(struct stmmac_priv *priv, switch (qopt->entries[i].command) { case TC_TAPRIO_CMD_SET_GATES: - if (fpe) - return -EINVAL; break; case TC_TAPRIO_CMD_SET_AND_HOLD: gates |= BIT(0); - fpe = true; break; case TC_TAPRIO_CMD_SET_AND_RELEASE: gates &= ~BIT(0); - fpe = true; break; default: return -EOPNOTSUPP; @@ -1058,11 +1054,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, tc_taprio_map_maxsdu_txq(priv, qopt); - if (fpe && !priv->dma_cap.fpesel) { - mutex_unlock(&priv->est_lock); - return -EOPNOTSUPP; - } - ret = stmmac_est_configure(priv, priv, priv->est, priv->plat->clk_ptp_rate); mutex_unlock(&priv->est_lock); @@ -1071,6 +1062,11 @@ static int tc_taprio_configure(struct stmmac_priv *priv, goto disable; } + ret = stmmac_fpe_map_preemption_class(priv, priv->dev, extack, + qopt->mqprio.preemptible_tcs); + if (ret) + goto disable; + netdev_info(priv->dev, "configured EST\n"); return 0; @@ -1089,11 +1085,8 @@ static int tc_taprio_configure(struct stmmac_priv *priv, mutex_unlock(&priv->est_lock); } - stmmac_fpe_configure(priv, priv->ioaddr, - &priv->fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - false, false); + stmmac_fpe_map_preemption_class(priv, priv->dev, extack, 0); + netdev_info(priv->dev, "disabled FPE\n"); return ret; @@ -1150,6 +1143,18 @@ static int tc_setup_taprio(struct stmmac_priv *priv, return err; } +static int tc_setup_taprio_without_fpe(struct stmmac_priv *priv, + struct tc_taprio_qopt_offload *qopt) +{ + if (!qopt->mqprio.preemptible_tcs) + return tc_setup_taprio(priv, qopt); + + NL_SET_ERR_MSG_MOD(qopt->mqprio.extack, + "taprio with FPE is not implemented for this MAC"); + + return -EOPNOTSUPP; +} + static int tc_setup_etf(struct stmmac_priv *priv, struct tc_etf_qopt_offload *qopt) { @@ -1266,7 +1271,7 @@ const struct stmmac_tc_ops dwmac4_tc_ops = { .setup_cls_u32 = tc_setup_cls_u32, .setup_cbs = tc_setup_cbs, .setup_cls = tc_setup_cls, - .setup_taprio = tc_setup_taprio, + .setup_taprio = tc_setup_taprio_without_fpe, .setup_etf = tc_setup_etf, .query_caps = tc_query_caps, .setup_mqprio = tc_setup_mqprio_unimplemented, @@ -1288,7 +1293,7 @@ const struct stmmac_tc_ops dwxgmac_tc_ops = { .setup_cls_u32 = tc_setup_cls_u32, .setup_cbs = tc_setup_cbs, .setup_cls = tc_setup_cls, - .setup_taprio = tc_setup_taprio, + .setup_taprio = tc_setup_taprio_without_fpe, .setup_etf = tc_setup_etf, .query_caps = tc_query_caps, .setup_mqprio = tc_setup_mqprio_unimplemented,