From patchwork Fri Sep 6 04:55:56 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: 13793224 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 81A88C54FC6 for ; Fri, 6 Sep 2024 04:58:52 +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=ys+dAZUSX7qkSyHoVS9H9w5gJ/q9VoC1vU6YNN+XK4o=; b=kT27EFp6kYKlv+EM2QHVt7GEWx LkJ737dqH5z0TvyX1D3yZIavGs0bi8H/Hga4lRSxMqBzyRETwlGTYiQDRrBZqH6ogB9lI6Wf7vep/ hJCwZrHbJ9CFcac7MWHOgxCkXkr5zHBHiXq1/pJm2onnyj0wXYFN1hJIjXg9+rF+ZGNSee9RvZYYU sc4qSiyGK9mRJJNUN46Jm7dbF8OTIaa/ytu3n+At66p25cQ5G2y3N6gENaFN21Bn4NJ0ofhHDF60X qUXw5Gng8GXPuN+/9r09o+W2OvMJHz/KlqQaJhfOV7ZImDOMz0TpKPcLqIr37AEdFxcXGkHVsmGSO kKQhZOTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR3T-0000000AfSw-3VPm; Fri, 06 Sep 2024 04:58:43 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR1a-0000000AewT-1n66 for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:56:47 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-7184a7c8a45so592881b3a.0 for ; Thu, 05 Sep 2024 21:56:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598605; x=1726203405; 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=ys+dAZUSX7qkSyHoVS9H9w5gJ/q9VoC1vU6YNN+XK4o=; b=Oqsl0i8zEe8CgBZsGHiCBJL8xd+BivCE9iGFgY02hiPl0ZwbrESRyka0k1guHLWDmp 0BPsMITEzC7azpiiNNRdI+meKW/6PP8lLG3PHSB2cILQ0KKINRvUz6KHOhqiVOKAz0l9 ZZfZevbPVjiYiIUSwzaRMJom+S2cJnmCysQkr+bsOWM0KLpF3CE2ms/5XnuMsSn/6PsI q2AynLBBqv+8CjhEchUkdGhvO/F1HxNon9QNGdd5oQ3mapedCUUcSooFV9b2n8TiIK6o DvduSAauiRfHcXQWCyV/aSx4AWrkqk8q4YOzvm/+1WOd/+bVvaelRuDtTIJCLltKMdqr zi5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598605; x=1726203405; 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=ys+dAZUSX7qkSyHoVS9H9w5gJ/q9VoC1vU6YNN+XK4o=; b=e2xgQujRgOe3WQZHLbqDWFIA9V0ZBmf0ybnLXsjRs1SE3GIJ4GS/vkJ4MEGuVImeSa aklLd6XlDTWlnuEbMKAxnMjgqbFfMDPnC9RcP0WcPuzY8/29t3s3LSuUg2nYmUGACwxt dgF2GTSDkTBnp3Rg45SqGhrrzvOCNGc0nP3A9196GDeh0+J7Tg88nfxDD2o3oB64Y5Om Ui5wQLgMOii9DDhlY4PFiIv/YEPCtE4mm3b60rUPYVgK64npzE/HewYaz7mQcCfDxbRw k/dlIJ6Y+HzLv05IVuHIyMeXP2cEUDSBlOs97awazLT8nAblpZPvOWVdoDmhfZDRW3Pj peOA== X-Forwarded-Encrypted: i=1; AJvYcCU1LDxiywIoLfX87MFuD1uzOLkxk3OLD64x88DC82AekEb2P3j9DJo7I/nIxPxpeRsl4fTGVM0PwJ1tXxzc8k+X@lists.infradead.org X-Gm-Message-State: AOJu0Yxkblw+u3nqkXiBKHhwcv6qzfnEUTT+Xu2CGGpDwKBOT8UvJL0T GMcnr/6Wvft4UrVrGd5Qu3e/wrvzFPWCbZEBOBDaCjLQwBZuU6dR X-Google-Smtp-Source: AGHT+IF421vhoj/5JOvHxHpFZjoQvBF9wMGpiyJAU5UIEPXU0d5cceWIGXHcUDJyR8G7Cs4ExelgiA== X-Received: by 2002:a05:6a00:4b4c:b0:70e:a524:6490 with SMTP id d2e1a72fcca58-718d5dedc1cmr1560184b3a.1.1725598605293; Thu, 05 Sep 2024 21:56:45 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.56.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:56:44 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 1/7] net: stmmac: move stmmac_fpe_cfg to stmmac_priv data Date: Fri, 6 Sep 2024 12:55:56 +0800 Message-Id: <22161115297dbf54fd8ae1f0c4fb4ae7c448825f.1725597121.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_215646_476483_EB59CDD7 X-CRM114-Status: GOOD ( 18.92 ) 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 By moving the fpe_cfg field to the stmmac_priv data, stmmac_fpe_cfg becomes platform-data eventually, instead of a run-time config. Suggested-by: Serge Semin Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean Reviewed-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 ++ drivers/net/ethernet/stmicro/stmmac/stmmac.h | 30 ++++++++++++++++++- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ++++++------- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 16 ++-------- include/linux/stmmac.h | 28 ----------------- 5 files changed, 44 insertions(+), 52 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 7e90f34b8c88..68574798c03f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -28,6 +28,8 @@ struct stmmac_extra_stats; struct stmmac_priv; struct stmmac_safety_stats; +struct stmmac_fpe_cfg; +enum stmmac_mpacket_type; struct dma_desc; struct dma_extended_desc; struct dma_edesc; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b23b920eedb1..458d6b16ce21 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -146,6 +146,33 @@ struct stmmac_channel { u32 index; }; +/* FPE link state */ +enum stmmac_fpe_state { + FPE_STATE_OFF = 0, + FPE_STATE_CAPABLE = 1, + FPE_STATE_ENTERING_ON = 2, + FPE_STATE_ON = 3, +}; + +/* FPE link-partner hand-shaking mPacket type */ +enum stmmac_mpacket_type { + MPACKET_VERIFY = 0, + MPACKET_RESPONSE = 1, +}; + +enum stmmac_fpe_task_state_t { + __FPE_REMOVING, + __FPE_TASK_SCHED, +}; + +struct stmmac_fpe_cfg { + bool enable; /* FPE enable */ + bool hs_enable; /* FPE handshake enable */ + enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */ + enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */ + u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */ +}; + struct stmmac_tc_entry { bool in_use; bool in_hw; @@ -339,11 +366,12 @@ struct stmmac_priv { struct workqueue_struct *wq; struct work_struct service_task; - /* Workqueue for handling FPE hand-shaking */ + /* Frame Preemption feature (FPE) */ unsigned long fpe_task_state; struct workqueue_struct *fpe_wq; struct work_struct fpe_task; char wq_name[IFNAMSIZ + 4]; + struct stmmac_fpe_cfg fpe_cfg; /* TC Handling */ unsigned int tc_entries_max; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d9fca8d1227c..529fe31f8b04 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -968,7 +968,7 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { - struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; bool *hs_enable = &fpe_cfg->hs_enable; @@ -3536,7 +3536,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) if (priv->dma_cap.fpesel) { stmmac_fpe_start_wq(priv); - if (priv->plat->fpe_cfg->enable) + if (priv->fpe_cfg.enable) stmmac_fpe_handshake(priv, true); } @@ -5982,7 +5982,7 @@ static int stmmac_set_features(struct net_device *netdev, static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) { - struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; bool *hs_enable = &fpe_cfg->hs_enable; @@ -7381,7 +7381,7 @@ static void stmmac_fpe_lp_task(struct work_struct *work) { struct stmmac_priv *priv = container_of(work, struct stmmac_priv, fpe_task); - struct stmmac_fpe_cfg *fpe_cfg = priv->plat->fpe_cfg; + struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; bool *hs_enable = &fpe_cfg->hs_enable; @@ -7427,17 +7427,17 @@ static void stmmac_fpe_lp_task(struct work_struct *work) void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable) { - if (priv->plat->fpe_cfg->hs_enable != enable) { + if (priv->fpe_cfg.hs_enable != enable) { if (enable) { stmmac_fpe_send_mpacket(priv, priv->ioaddr, - priv->plat->fpe_cfg, + &priv->fpe_cfg, MPACKET_VERIFY); } else { - priv->plat->fpe_cfg->lo_fpe_state = FPE_STATE_OFF; - priv->plat->fpe_cfg->lp_fpe_state = FPE_STATE_OFF; + priv->fpe_cfg.lo_fpe_state = FPE_STATE_OFF; + priv->fpe_cfg.lp_fpe_state = FPE_STATE_OFF; } - priv->plat->fpe_cfg->hs_enable = enable; + priv->fpe_cfg.hs_enable = enable; } } @@ -7898,7 +7898,7 @@ int stmmac_suspend(struct device *dev) if (priv->dma_cap.fpesel) { /* Disable FPE */ stmmac_fpe_configure(priv, priv->ioaddr, - priv->plat->fpe_cfg, + &priv->fpe_cfg, priv->plat->tx_queues_to_use, priv->plat->rx_queues_to_use, false); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 996f2bcd07a2..9cc41ed01882 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -282,16 +282,6 @@ static int tc_init(struct stmmac_priv *priv) if (ret) return -ENOMEM; - if (!priv->plat->fpe_cfg) { - priv->plat->fpe_cfg = devm_kzalloc(priv->device, - sizeof(*priv->plat->fpe_cfg), - GFP_KERNEL); - if (!priv->plat->fpe_cfg) - return -ENOMEM; - } else { - memset(priv->plat->fpe_cfg, 0, sizeof(*priv->plat->fpe_cfg)); - } - /* Fail silently as we can still use remaining features, e.g. CBS */ if (!dma_cap->frpsel) return 0; @@ -1076,7 +1066,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv, /* Actual FPE register configuration will be done after FPE handshake * is success. */ - priv->plat->fpe_cfg->enable = fpe; + priv->fpe_cfg.enable = fpe; ret = stmmac_est_configure(priv, priv, priv->est, priv->plat->clk_ptp_rate); @@ -1109,9 +1099,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv, mutex_unlock(&priv->est_lock); } - priv->plat->fpe_cfg->enable = false; + priv->fpe_cfg.enable = false; stmmac_fpe_configure(priv, priv->ioaddr, - priv->plat->fpe_cfg, + &priv->fpe_cfg, priv->plat->tx_queues_to_use, priv->plat->rx_queues_to_use, false); diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 338991c08f00..d79ff252cfdc 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -138,33 +138,6 @@ struct stmmac_txq_cfg { int tbs_en; }; -/* FPE link state */ -enum stmmac_fpe_state { - FPE_STATE_OFF = 0, - FPE_STATE_CAPABLE = 1, - FPE_STATE_ENTERING_ON = 2, - FPE_STATE_ON = 3, -}; - -/* FPE link-partner hand-shaking mPacket type */ -enum stmmac_mpacket_type { - MPACKET_VERIFY = 0, - MPACKET_RESPONSE = 1, -}; - -enum stmmac_fpe_task_state_t { - __FPE_REMOVING, - __FPE_TASK_SCHED, -}; - -struct stmmac_fpe_cfg { - bool enable; /* FPE enable */ - bool hs_enable; /* FPE handshake enable */ - enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */ - enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */ - u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */ -}; - struct stmmac_safety_feature_cfg { u32 tsoee; u32 mrxpee; @@ -232,7 +205,6 @@ struct plat_stmmacenet_data { struct fwnode_handle *port_node; struct device_node *mdio_node; struct stmmac_dma_cfg *dma_cfg; - struct stmmac_fpe_cfg *fpe_cfg; struct stmmac_safety_feature_cfg *safety_feat_cfg; int clk_csr; int has_gmac; From patchwork Fri Sep 6 04:55:57 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: 13793225 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 F2F2ECE7AB2 for ; Fri, 6 Sep 2024 04:59:54 +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=awdxA94+EDwJxMaDIv2LrPwLHdX9C7ivLS6VUmJAIug=; b=Xmcp0hZIceUXvu9w59WAsej5gx ge9u5Fx1wUpmkatseJRwZHncSr5lNRJvg5zMo6Vjp+IJB1T2h3HbknQmnSvCn7sqI8sRguHJCGFt0 PPLxomfE+2d4Y17MW3DXVOucBvJaF2hGzXSuGOrcu4POJUBc5EkGoFhc87VeaiMKJl7DylB40WfR/ M/cF91fj9xTxE2/GZigX+B/TcMjoScmwfNBj9NorDXT8tSPJvrqIkFPeBgmRwX0he7fl1Z9KlBdE6 SK9v0HUCeVZGlm8vx+2hDw4OSboASP3Jn6yNydsq0ITa/Hxomu/ObWZpCwuWkyCd3IU7o1uM0rbr8 Oli+819Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR4P-0000000Affl-0Acw; Fri, 06 Sep 2024 04:59:41 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR1f-0000000AeyL-46t7 for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:56:53 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-71798a15ce5so727196b3a.0 for ; Thu, 05 Sep 2024 21:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598611; x=1726203411; 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=awdxA94+EDwJxMaDIv2LrPwLHdX9C7ivLS6VUmJAIug=; b=Uw/Bl2zHQ4aSyLZwCg5poe1ZwOitgxzXUNOnMXAFZB1tIM2TImIHiNkeAb6nvg3URa YdTiAR7wAyTz3zKqfPZhAwur/VxOBLB4I+hBI2uXZpdyvFjKozz6IcfNqrcqoedVo87R kAI5KalVAcm3ps7XzBaf5Q5+T41gMPR8+VJ9WmveWr1hRCTTFWmisH3H0eBqJ7P9NUxT uRzi1tCZETtrMHD1/joKtKCtFlFUvW5I0mUZSrjL68c1CHbgCWGwZDCU/kDwRm37ed5B /NwlVZLTCUVxnPM0V4gmiC8ZoCwGfR7ryNKbqeoZZknt0ryGPsdnZ/+lMic907cvMoN+ lduA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598611; x=1726203411; 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=awdxA94+EDwJxMaDIv2LrPwLHdX9C7ivLS6VUmJAIug=; b=PQ/AucDS8/WAYms6j1STodXmqOpOlC70f4VkYVrNbf/vZ0ckPxQgIozlU9E7Rcl7bu Qe1qfryfio0SDiLdRVJ6JuLSGS4ICLsiJAeDN/gsHzrOSTcpYXEMoDCm7zcNspUBFD4Q WAoQPnEmnrEEqmRhKZt9erxnXE2Ee+3UJXNHQoJchmq8d7CbBug7o/f+aw/3vf8wA956 /9NI7dKauHCYHdTUGn4GkLWREekqN6zJMwn6WQ/9X3n+MuD6FhwDCOFTiHJLx6bH7221 HNVWC2wt4RHxJOTyIRpzw5aw54Dz4Tk9ugZ/9ic6GAPoYqT8iBg6PonN8gWIYoLlYOOW CvFA== X-Forwarded-Encrypted: i=1; AJvYcCVPxFPfvJ4EY5WK6VkMWk3evscZRz056Z12RrHROyFdimhZUnp6KPwwQUHLIhFNx/4FbBORESViBDfv7fg6fDXv@lists.infradead.org X-Gm-Message-State: AOJu0YwE8M+kubnrlNloLq430dqYxdBNNNWsJHJIeorIZYzv1fv/d28w 06uIpkMDj0cajWWWMEhqFpx+z8AVJ7lbLaHnwIb0C2RyX+6qZ33l X-Google-Smtp-Source: AGHT+IHhLryr0A8pwiJ/WABHRdfza5mcvYUq9KAqWs1D4gDvA0WovWkUgZpTbm906++5urOriKthfg== X-Received: by 2002:a05:6a20:43a9:b0:1bd:1d5f:35be with SMTP id adf61e73a8af0-1cf1bfbb548mr2884149637.11.1725598610767; Thu, 05 Sep 2024 21:56:50 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.56.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:56:50 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 2/7] net: stmmac: drop stmmac_fpe_handshake Date: Fri, 6 Sep 2024 12:55:57 +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-20240905_215652_030604_AAF9794F X-CRM114-Status: GOOD ( 13.10 ) 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 ethtool --set-mm can trigger FPE verification process by calling stmmac_fpe_send_mpacket, stmmac_fpe_handshake should be gone. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 - .../net/ethernet/stmicro/stmmac/stmmac_main.c | 23 +------------------ .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 8 ------- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 458d6b16ce21..3ad182ef8e97 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -425,7 +425,6 @@ bool stmmac_eee_init(struct stmmac_priv *priv); int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt); int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size); int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled); -void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable); static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 529fe31f8b04..3072ad33b105 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3533,13 +3533,9 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) stmmac_set_hw_vlan_mode(priv, priv->hw); - if (priv->dma_cap.fpesel) { + if (priv->dma_cap.fpesel) stmmac_fpe_start_wq(priv); - if (priv->fpe_cfg.enable) - stmmac_fpe_handshake(priv, true); - } - return 0; } @@ -7425,22 +7421,6 @@ static void stmmac_fpe_lp_task(struct work_struct *work) clear_bit(__FPE_TASK_SCHED, &priv->fpe_task_state); } -void stmmac_fpe_handshake(struct stmmac_priv *priv, bool enable) -{ - if (priv->fpe_cfg.hs_enable != enable) { - if (enable) { - stmmac_fpe_send_mpacket(priv, priv->ioaddr, - &priv->fpe_cfg, - MPACKET_VERIFY); - } else { - priv->fpe_cfg.lo_fpe_state = FPE_STATE_OFF; - priv->fpe_cfg.lp_fpe_state = FPE_STATE_OFF; - } - - priv->fpe_cfg.hs_enable = enable; - } -} - static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp) { const struct stmmac_xdp_buff *ctx = (void *)_ctx; @@ -7902,7 +7882,6 @@ int stmmac_suspend(struct device *dev) priv->plat->tx_queues_to_use, priv->plat->rx_queues_to_use, false); - stmmac_fpe_handshake(priv, false); stmmac_fpe_stop_wq(priv); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 9cc41ed01882..b0cc45331ff7 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1078,11 +1078,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, netdev_info(priv->dev, "configured EST\n"); - if (fpe) { - stmmac_fpe_handshake(priv, true); - netdev_info(priv->dev, "start FPE handshake\n"); - } - return 0; disable: @@ -1107,9 +1102,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, false); netdev_info(priv->dev, "disabled FPE\n"); - stmmac_fpe_handshake(priv, false); - netdev_info(priv->dev, "stop FPE handshake\n"); - return ret; } From patchwork Fri Sep 6 04:55:58 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: 13793226 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 7BE16CE7AB2 for ; Fri, 6 Sep 2024 05:00:53 +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=rq9z6vN84jHE1o/8v11+e/nMxFrrgaq4EEV4/Gazqec=; b=V/7QfBJT0V6Iufz9fFAi+5WQtD Xa/OI1aXses70ARtHbKK81aziEM/MAsZu3AQhSPSo12h/2GDbFzb9bdLqmns/olR594mzcLvJT77g /miJhIcT3Yu3jpqBHr5t39e5cf5OPnngrcQKUDM4TJy/ALk1ggu3wtuIbomSKCMAaV/Q5q54UN50f mGUwDy1jusJ8UBUL1ARt9sxJuAZ+l86shoV2Ja5HhgfRkHhjPk/FqwpOdVDfteNs5IuJAGiQ9kGGN KCwvrEYMIVvcbejRbNLxElygKQg0MMISDFZObjlfntl6G+W5rylJ+DoluSMMIOpCVrEPuUWGA5Zyh apogoXMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR5M-0000000AfwN-2T9D; Fri, 06 Sep 2024 05:00:40 +0000 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR1m-0000000Af0D-03di for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:57:00 +0000 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5dfb53d4b13so992187eaf.2 for ; Thu, 05 Sep 2024 21:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598617; x=1726203417; 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=rq9z6vN84jHE1o/8v11+e/nMxFrrgaq4EEV4/Gazqec=; b=WXv0ImstyvgHr4qyntZE5Qzwv/lH9KsrwYZERUVORPh37kKcQQa1S0bqLlPrlNG9xN sRTLrIVj3CoIA+IIcCDFD6y3kfqORjjWylVDe5TucYWfbO+xwM7yUFp3Wn3hkxQb2u9+ FifxlibmPpZveEaqA5XvC3QmdBpgHVotSHnWWHKub/T6AKX2g0Ij2wHU3Yxz5E88QrTB GBu6aJWlKxlKMygtdUrSNku1BajRSIJvRHh0C/u/O2VSZua/ai06k8C/NGCk7hbgngwG MOT83M582u0uYrHMbznGSgNw8pjpWrKBJi3Kc2VIlTqnD9Bszw2tqk76GUNmW2H7M6jK wzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598617; x=1726203417; 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=rq9z6vN84jHE1o/8v11+e/nMxFrrgaq4EEV4/Gazqec=; b=i4IhHKxtwA7ZNlHz3PpZHzxDsA1bBO29kIq4tib9qBDJjd2jHvEz8joDXiqFn9358s x+DCX0NY2J4SY4bROOeSqHdn/nztbxgKKIhsfACkOCrGURflafVaeCjpnwQH26h+WE6S rdBbO+Q3YPeMJFumNixftru3UhQP6ORVDgUZCu1b/d4Qs7LX+ep00siwh47oCj9SRtAN 7SAo8ma+tG+IBec5KZoWWyuvqr2GxEyI5tmWTsohrASqtssUJ52ssMe3qVqYHX34xJHq i3rN5GVT2j/9lTzXMQv3lKbYWDjIL3IwV1Qq4wKepKuhX1qOj4W6YCmULmMM4h7n5opQ iYdg== X-Forwarded-Encrypted: i=1; AJvYcCXZubCRquyPIdoXTy6WVDbh2f6uXR1UGjP5Rte6gQ49JLl4DhUTnkFqR5uIMu1hWuhLGTML6qDJV+mZpLu00DNI@lists.infradead.org X-Gm-Message-State: AOJu0Ywwycpl7HYPFzz9k6v3ha+ocqXELx1ksFK8oMMwsMpDZ9bflPOT MelJomjKWg3AkPrLez2MREMfNBjVNgrx0SaOy3R0/ijLzfXLhSfZ X-Google-Smtp-Source: AGHT+IEdTJM5UZSgUXQ5nZvRUN19SYH9yz/gxo3ReIyjqF2jIfbwFm/69r3520cpje5zYCHTnASJTg== X-Received: by 2002:a05:6218:260d:b0:1b5:f923:33d2 with SMTP id e5c5f4694b2df-1b8385bc29fmr150650155d.1.1725598616731; Thu, 05 Sep 2024 21:56:56 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:56:56 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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>, Vladimir Oltean Subject: [PATCH net-next v9 3/7] net: stmmac: refactor FPE verification process Date: Fri, 6 Sep 2024 12:55:58 +0800 Message-Id: <13f5833e52a47895864db726f090f323ec691c62.1725597121.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_215658_091428_BC00FEC1 X-CRM114-Status: GOOD ( 24.64 ) 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 Drop driver defined stmmac_fpe_state, and switch to common ethtool_mm_verify_status for local TX verification status. Local side and remote side verification processes are completely independent. There is no reason at all to keep a local state and a remote state. Add a spinlock to avoid races among ISR, timer, link update and register configuration. This patch is based on Vladimir Oltean's proposal. Vladimir Oltean says: ==================== In the INITIAL state, the timer sends MPACKET_VERIFY. Eventually the stmmac_fpe_event_status() IRQ fires and advances the state to VERIFYING, then rearms the timer after verify_time ms. If a subsequent IRQ comes in and modifies the state to SUCCEEDED after getting MPACKET_RESPONSE, the timer sees this. It must enable the EFPE bit now. Otherwise, it decrements the verify_limit counter and tries again. Eventually it moves the status to FAILED, from which the IRQ cannot move it anywhere else, except for another stmmac_fpe_apply() call. ==================== Co-developed-by: Vladimir Oltean Signed-off-by: Vladimir Oltean Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 - drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 19 +- drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 2 +- .../ethernet/stmicro/stmmac/dwxgmac2_core.c | 9 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 36 ++- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 252 +++++++++--------- .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 8 +- 8 files changed, 163 insertions(+), 169 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 31c387cc5f26..7947b1212a2d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -58,10 +58,6 @@ static void dwmac4_core_init(struct mac_device_info *hw, if (hw->pcs) value |= GMAC_PCS_IRQ_DEFAULT; - /* Enable FPE interrupt */ - if ((GMAC_HW_FEAT_FPESEL & readl(ioaddr + GMAC_HW_FEATURE3)) >> 26) - value |= GMAC_INT_FPE_EN; - writel(value, ioaddr + GMAC_INT_EN); if (GMAC_INT_DEFAULT_ENABLE & GMAC_INT_TSIE) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index e02cebc3f1b7..850cfc4df6eb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -575,11 +575,11 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index, void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, u32 num_txq, u32 num_rxq, - bool enable) + bool tx_enable, bool pmac_enable) { u32 value; - if (enable) { + if (tx_enable) { cfg->fpe_csr = EFPE; value = readl(ioaddr + GMAC_RXQ_CTRL1); value &= ~GMAC_RXQCTRL_FPRQ; @@ -589,6 +589,21 @@ void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, cfg->fpe_csr = 0; } writel(cfg->fpe_csr, ioaddr + MAC_FPE_CTRL_STS); + + value = readl(ioaddr + GMAC_INT_EN); + + if (pmac_enable) { + if (!(value & GMAC_INT_FPE_EN)) { + /* Dummy read to clear any pending masked interrupts */ + readl(ioaddr + MAC_FPE_CTRL_STS); + + value |= GMAC_INT_FPE_EN; + } + } else { + value &= ~GMAC_INT_FPE_EN; + } + + writel(value, ioaddr + GMAC_INT_EN); } int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h index bf33a51d229e..c3031c1357d0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h @@ -104,7 +104,7 @@ int dwmac5_flex_pps_config(void __iomem *ioaddr, int index, u32 sub_second_inc, u32 systime_flags); void dwmac5_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, u32 num_txq, u32 num_rxq, - bool enable); + bool tx_enable, bool pmac_enable); void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, enum stmmac_mpacket_type type); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index cbf2dd976ab1..f519d43738b0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1504,13 +1504,14 @@ static void dwxgmac2_set_arp_offload(struct mac_device_info *hw, bool en, writel(value, ioaddr + XGMAC_RX_CONFIG); } -static void dwxgmac3_fpe_configure(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, - u32 num_txq, - u32 num_rxq, bool enable) +static void dwxgmac3_fpe_configure(void __iomem *ioaddr, + struct stmmac_fpe_cfg *cfg, + u32 num_txq, u32 num_rxq, + bool tx_enable, bool pmac_enable) { u32 value; - if (!enable) { + if (!tx_enable) { value = readl(ioaddr + XGMAC_FPE_CTRL_STS); value &= ~XGMAC_EFPE; diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 68574798c03f..4942fc398ea6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -421,7 +421,7 @@ struct stmmac_ops { void (*set_arp_offload)(struct mac_device_info *hw, bool en, u32 addr); void (*fpe_configure)(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, u32 num_txq, u32 num_rxq, - bool enable); + bool tx_enable, bool pmac_enable); void (*fpe_send_mpacket)(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, enum stmmac_mpacket_type type); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 3ad182ef8e97..ea135203ff2e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -146,31 +146,30 @@ struct stmmac_channel { u32 index; }; -/* FPE link state */ -enum stmmac_fpe_state { - FPE_STATE_OFF = 0, - FPE_STATE_CAPABLE = 1, - FPE_STATE_ENTERING_ON = 2, - FPE_STATE_ON = 3, -}; - /* FPE link-partner hand-shaking mPacket type */ enum stmmac_mpacket_type { MPACKET_VERIFY = 0, MPACKET_RESPONSE = 1, }; -enum stmmac_fpe_task_state_t { - __FPE_REMOVING, - __FPE_TASK_SCHED, -}; +#define STMMAC_FPE_MM_MAX_VERIFY_RETRIES 3 +#define STMMAC_FPE_MM_MAX_VERIFY_TIME_MS 128 struct stmmac_fpe_cfg { - bool enable; /* FPE enable */ - bool hs_enable; /* FPE handshake enable */ - enum stmmac_fpe_state lp_fpe_state; /* Link Partner FPE state */ - enum stmmac_fpe_state lo_fpe_state; /* Local station FPE state */ + /* Serialize access to MAC Merge state between ethtool requests + * and link state updates. + */ + spinlock_t lock; + u32 fpe_csr; /* MAC_FPE_CTRL_STS reg cache */ + + enum ethtool_mm_verify_status status; + struct timer_list verify_timer; + bool verify_enabled; + int verify_retries; + bool pmac_enabled; + u32 verify_time; + bool tx_enabled; }; struct stmmac_tc_entry { @@ -367,10 +366,6 @@ struct stmmac_priv { struct work_struct service_task; /* Frame Preemption feature (FPE) */ - unsigned long fpe_task_state; - struct workqueue_struct *fpe_wq; - struct work_struct fpe_task; - char wq_name[IFNAMSIZ + 4]; struct stmmac_fpe_cfg fpe_cfg; /* TC Handling */ @@ -425,6 +420,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv); int stmmac_reinit_queues(struct net_device *dev, u32 rx_cnt, u32 tx_cnt); int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size); int stmmac_bus_clks_config(struct stmmac_priv *priv, bool enabled); +void stmmac_fpe_apply(struct stmmac_priv *priv); static inline bool stmmac_xdp_is_enabled(struct stmmac_priv *priv) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3072ad33b105..4192681a8ac5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -969,17 +969,30 @@ static void stmmac_mac_config(struct phylink_config *config, unsigned int mode, static void stmmac_fpe_link_state_handle(struct stmmac_priv *priv, bool is_up) { struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; - enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; - enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; - bool *hs_enable = &fpe_cfg->hs_enable; + unsigned long flags; - if (is_up && *hs_enable) { - stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, - MPACKET_VERIFY); + timer_shutdown_sync(&fpe_cfg->verify_timer); + + spin_lock_irqsave(&fpe_cfg->lock, flags); + + if (is_up && fpe_cfg->pmac_enabled) { + /* VERIFY process requires pmac enabled when NIC comes up */ + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false, true); + + /* New link => maybe new partner => new verification process */ + stmmac_fpe_apply(priv); } else { - *lo_state = FPE_STATE_OFF; - *lp_state = FPE_STATE_OFF; + /* No link => turn off EFPE */ + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + false, false); } + + spin_unlock_irqrestore(&fpe_cfg->lock, flags); } static void stmmac_mac_link_down(struct phylink_config *config, @@ -3358,27 +3371,6 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv) } } -static int stmmac_fpe_start_wq(struct stmmac_priv *priv) -{ - char *name; - - clear_bit(__FPE_TASK_SCHED, &priv->fpe_task_state); - clear_bit(__FPE_REMOVING, &priv->fpe_task_state); - - name = priv->wq_name; - sprintf(name, "%s-fpe", priv->dev->name); - - priv->fpe_wq = create_singlethread_workqueue(name); - if (!priv->fpe_wq) { - netdev_err(priv->dev, "%s: Failed to create workqueue\n", name); - - return -ENOMEM; - } - netdev_info(priv->dev, "FPE workqueue start"); - - return 0; -} - /** * stmmac_hw_setup - setup mac in a usable state. * @dev : pointer to the device structure. @@ -3533,9 +3525,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register) stmmac_set_hw_vlan_mode(priv, priv->hw); - if (priv->dma_cap.fpesel) - stmmac_fpe_start_wq(priv); - return 0; } @@ -4032,18 +4021,6 @@ static int stmmac_open(struct net_device *dev) return ret; } -static void stmmac_fpe_stop_wq(struct stmmac_priv *priv) -{ - set_bit(__FPE_REMOVING, &priv->fpe_task_state); - - if (priv->fpe_wq) { - destroy_workqueue(priv->fpe_wq); - priv->fpe_wq = NULL; - } - - netdev_info(priv->dev, "FPE workqueue stop"); -} - /** * stmmac_release - close entry point of the driver * @dev : device pointer. @@ -4091,10 +4068,10 @@ static int stmmac_release(struct net_device *dev) stmmac_release_ptp(priv); - pm_runtime_put(priv->device); - if (priv->dma_cap.fpesel) - stmmac_fpe_stop_wq(priv); + timer_shutdown_sync(&priv->fpe_cfg.verify_timer); + + pm_runtime_put(priv->device); return 0; } @@ -5979,44 +5956,29 @@ static int stmmac_set_features(struct net_device *netdev, static void stmmac_fpe_event_status(struct stmmac_priv *priv, int status) { struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; - enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; - enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; - bool *hs_enable = &fpe_cfg->hs_enable; - if (status == FPE_EVENT_UNKNOWN || !*hs_enable) - return; + /* This is interrupt context, just spin_lock() */ + spin_lock(&fpe_cfg->lock); - /* If LP has sent verify mPacket, LP is FPE capable */ - if ((status & FPE_EVENT_RVER) == FPE_EVENT_RVER) { - if (*lp_state < FPE_STATE_CAPABLE) - *lp_state = FPE_STATE_CAPABLE; + if (!fpe_cfg->pmac_enabled || status == FPE_EVENT_UNKNOWN) + goto unlock_out; - /* If user has requested FPE enable, quickly response */ - if (*hs_enable) - stmmac_fpe_send_mpacket(priv, priv->ioaddr, - fpe_cfg, - MPACKET_RESPONSE); - } + /* LP has sent verify mPacket */ + if ((status & FPE_EVENT_RVER) == FPE_EVENT_RVER) + stmmac_fpe_send_mpacket(priv, priv->ioaddr, fpe_cfg, + MPACKET_RESPONSE); - /* If Local has sent verify mPacket, Local is FPE capable */ - if ((status & FPE_EVENT_TVER) == FPE_EVENT_TVER) { - if (*lo_state < FPE_STATE_CAPABLE) - *lo_state = FPE_STATE_CAPABLE; - } + /* Local has sent verify mPacket */ + if ((status & FPE_EVENT_TVER) == FPE_EVENT_TVER && + fpe_cfg->status != ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) + fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_VERIFYING; - /* If LP has sent response mPacket, LP is entering FPE ON */ + /* LP has sent response mPacket */ if ((status & FPE_EVENT_RRSP) == FPE_EVENT_RRSP) - *lp_state = FPE_STATE_ENTERING_ON; + fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED; - /* If Local has sent response mPacket, Local is entering FPE ON */ - if ((status & FPE_EVENT_TRSP) == FPE_EVENT_TRSP) - *lo_state = FPE_STATE_ENTERING_ON; - - if (!test_bit(__FPE_REMOVING, &priv->fpe_task_state) && - !test_and_set_bit(__FPE_TASK_SCHED, &priv->fpe_task_state) && - priv->fpe_wq) { - queue_work(priv->fpe_wq, &priv->fpe_task); - } +unlock_out: + spin_unlock(&fpe_cfg->lock); } static void stmmac_common_interrupt(struct stmmac_priv *priv) @@ -7372,53 +7334,88 @@ int stmmac_reinit_ringparam(struct net_device *dev, u32 rx_size, u32 tx_size) return ret; } -#define SEND_VERIFY_MPAKCET_FMT "Send Verify mPacket lo_state=%d lp_state=%d\n" -static void stmmac_fpe_lp_task(struct work_struct *work) +/** + * stmmac_fpe_verify_timer - Timer for MAC Merge verification + * @t: timer_list struct containing private info + * + * Verify the MAC Merge capability in the local TX direction, by + * transmitting Verify mPackets up to 3 times. Wait until link + * partner responds with a Response mPacket, otherwise fail. + */ +static void stmmac_fpe_verify_timer(struct timer_list *t) { - struct stmmac_priv *priv = container_of(work, struct stmmac_priv, - fpe_task); - struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; - enum stmmac_fpe_state *lo_state = &fpe_cfg->lo_fpe_state; - enum stmmac_fpe_state *lp_state = &fpe_cfg->lp_fpe_state; - bool *hs_enable = &fpe_cfg->hs_enable; - bool *enable = &fpe_cfg->enable; - int retries = 20; - - while (retries-- > 0) { - /* Bail out immediately if FPE handshake is OFF */ - if (*lo_state == FPE_STATE_OFF || !*hs_enable) - break; - - if (*lo_state == FPE_STATE_ENTERING_ON && - *lp_state == FPE_STATE_ENTERING_ON) { - stmmac_fpe_configure(priv, priv->ioaddr, - fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, - *enable); - - netdev_info(priv->dev, "configured FPE\n"); + struct stmmac_fpe_cfg *fpe_cfg = from_timer(fpe_cfg, t, verify_timer); + struct stmmac_priv *priv = container_of(fpe_cfg, struct stmmac_priv, + fpe_cfg); + unsigned long flags; + bool rearm = false; - *lo_state = FPE_STATE_ON; - *lp_state = FPE_STATE_ON; - netdev_info(priv->dev, "!!! BOTH FPE stations ON\n"); - break; - } + spin_lock_irqsave(&fpe_cfg->lock, flags); - if ((*lo_state == FPE_STATE_CAPABLE || - *lo_state == FPE_STATE_ENTERING_ON) && - *lp_state != FPE_STATE_ON) { - netdev_info(priv->dev, SEND_VERIFY_MPAKCET_FMT, - *lo_state, *lp_state); + switch (fpe_cfg->status) { + case ETHTOOL_MM_VERIFY_STATUS_INITIAL: + case ETHTOOL_MM_VERIFY_STATUS_VERIFYING: + if (fpe_cfg->verify_retries != 0) { stmmac_fpe_send_mpacket(priv, priv->ioaddr, - fpe_cfg, - MPACKET_VERIFY); + fpe_cfg, MPACKET_VERIFY); + rearm = true; + } else { + fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_FAILED; } - /* Sleep then retry */ - msleep(500); + + fpe_cfg->verify_retries--; + break; + + case ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED: + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + true, true); + break; + + default: + break; } - clear_bit(__FPE_TASK_SCHED, &priv->fpe_task_state); + if (rearm) { + mod_timer(&fpe_cfg->verify_timer, + jiffies + msecs_to_jiffies(fpe_cfg->verify_time)); + } + + spin_unlock_irqrestore(&fpe_cfg->lock, flags); +} + +static void stmmac_fpe_verify_timer_arm(struct stmmac_fpe_cfg *fpe_cfg) +{ + if (fpe_cfg->pmac_enabled && fpe_cfg->tx_enabled && + fpe_cfg->verify_enabled && + fpe_cfg->status != ETHTOOL_MM_VERIFY_STATUS_FAILED && + fpe_cfg->status != ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED) { + timer_setup(&fpe_cfg->verify_timer, stmmac_fpe_verify_timer, 0); + mod_timer(&fpe_cfg->verify_timer, jiffies); + } +} + +void stmmac_fpe_apply(struct stmmac_priv *priv) +{ + struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; + + /* If verification is disabled, configure FPE right away. + * Otherwise let the timer code do it. + */ + if (!fpe_cfg->verify_enabled) { + stmmac_fpe_configure(priv, priv->ioaddr, fpe_cfg, + priv->plat->tx_queues_to_use, + priv->plat->rx_queues_to_use, + fpe_cfg->tx_enabled, + fpe_cfg->pmac_enabled); + } else { + fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_INITIAL; + fpe_cfg->verify_retries = STMMAC_FPE_MM_MAX_VERIFY_RETRIES; + + if (netif_running(priv->dev)) + stmmac_fpe_verify_timer_arm(fpe_cfg); + } } static int stmmac_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp) @@ -7535,9 +7532,6 @@ int stmmac_dvr_probe(struct device *device, INIT_WORK(&priv->service_task, stmmac_service_task); - /* Initialize Link Partner FPE workqueue */ - INIT_WORK(&priv->fpe_task, stmmac_fpe_lp_task); - /* Override with kernel parameters if supplied XXX CRS XXX * this needs to have multiple instances */ @@ -7702,6 +7696,11 @@ int stmmac_dvr_probe(struct device *device, mutex_init(&priv->lock); + priv->fpe_cfg.verify_retries = STMMAC_FPE_MM_MAX_VERIFY_RETRIES; + priv->fpe_cfg.verify_time = STMMAC_FPE_MM_MAX_VERIFY_TIME_MS; + priv->fpe_cfg.status = ETHTOOL_MM_VERIFY_STATUS_DISABLED; + spin_lock_init(&priv->fpe_cfg.lock); + /* If a specific clk_csr value is passed from the platform * this means that the CSR Clock Range selection cannot be * changed at run-time and it is fixed. Viceversa the driver'll try to @@ -7875,15 +7874,8 @@ int stmmac_suspend(struct device *dev) } rtnl_unlock(); - if (priv->dma_cap.fpesel) { - /* Disable FPE */ - stmmac_fpe_configure(priv, priv->ioaddr, - &priv->fpe_cfg, - priv->plat->tx_queues_to_use, - priv->plat->rx_queues_to_use, false); - - stmmac_fpe_stop_wq(priv); - } + if (priv->dma_cap.fpesel) + timer_shutdown_sync(&priv->fpe_cfg.verify_timer); priv->speed = SPEED_UNKNOWN; return 0; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index b0cc45331ff7..a58282d6458c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1063,11 +1063,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, return -EOPNOTSUPP; } - /* Actual FPE register configuration will be done after FPE handshake - * is success. - */ - priv->fpe_cfg.enable = fpe; - ret = stmmac_est_configure(priv, priv, priv->est, priv->plat->clk_ptp_rate); mutex_unlock(&priv->est_lock); @@ -1094,12 +1089,11 @@ static int tc_taprio_configure(struct stmmac_priv *priv, mutex_unlock(&priv->est_lock); } - priv->fpe_cfg.enable = false; stmmac_fpe_configure(priv, priv->ioaddr, &priv->fpe_cfg, priv->plat->tx_queues_to_use, priv->plat->rx_queues_to_use, - false); + false, false); netdev_info(priv->dev, "disabled FPE\n"); return ret; From patchwork Fri Sep 6 04:55:59 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: 13793227 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 B0579C54FC6 for ; Fri, 6 Sep 2024 05:01:51 +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=yVrqVlledOe24UT3HTkVIrvC7QnAMFX2xjElHBP1Nwo=; b=2RhZzyWDUwjbiQ4l6Bd7j0kZtq OBUxT8f+LJM7dQsza/replI0M6SYJg9YztRy12Er7UIQiGWQgZTKA7zmhqgr2Gl5yZmvok8IyT82v Jm0MS+w6LvUGvmIx/cQA3CCFA13OrNFcTKLWNBRT3bzqTtgFqVeyCsBwIlifuhz3hR4pq7YpQo2oP VV+pp0c4w9DxcWeJaPI2Siw11xPMaIQdNmpkob+trZDZW/A/pPWc2k2mn0JrbF6dHsI3XgUiHcPTz VEraMGp93GLs+6xYOZ9zYlkuFwARpa52MHLtCSOcQdR0VF+7us+ocojNuYayfzQjXF3bKXT42wPRd TGDpphsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR6K-0000000AgA7-0m8W; Fri, 06 Sep 2024 05:01:40 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR1r-0000000Af1p-1zJ7 for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:57:04 +0000 Received: by mail-ot1-x32e.google.com with SMTP id 46e09a7af769-70f794cd0e3so1000430a34.2 for ; Thu, 05 Sep 2024 21:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598622; x=1726203422; 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=yVrqVlledOe24UT3HTkVIrvC7QnAMFX2xjElHBP1Nwo=; b=lniyl88GIoUJH0t2i1snonWwgkupuAU/+vaR9hIurnyIAUiFScavABYPo3gDMYdj7H u9BRXJe4wz9Q4+oX+bGhVKUZqqwrCoyfjg1fLi98D1GKVbZznARzs96UjhLEvTEtXTrm UGOItXlZl/a5aYYzQIE+2FAWpGMjQqORP9RRgIr13WS0SycHOVivAm2YRYAWK8/jeHRA Ln1qIO1m24OKKJHoraXL4bPIj6oT1DNHdFSubTUxc+wV0400XOu7vC7YBTxn/sSol5WR PuoXa7ChKzMkw7hsITmuHUm7HdK3Zolx/8zEIMr3iVx8tEDiG0eQijbV3zESuhcvPohV noog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598622; x=1726203422; 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=yVrqVlledOe24UT3HTkVIrvC7QnAMFX2xjElHBP1Nwo=; b=KL+kt72CYuZPCCDXzioxsKqC0PsnBQ6/U3bxvDBAbB+cWwsqzp2rHIpvYlANVCijqS QvbuG5DZgYgCspcFlq42dh0AgHeuu4a1rHQvenAVNtPU6nN1LrsftpbCmagDvuolFnrj rxbf3kB7fBUXecCPuZ9FoR/WmPGsxdnLfezG/ET4oZseM4Wp5uNdmpTqwyKLCQlbIk7n WeriSuH4UsoVnhUFTUD8xN92bQQhJLzaweBkcSXBBBBpCwa8+LncxcXEUryK5hKadvjQ J4n54ybLfMlCdF7SqkUxxK934P9HiWNNC5Ctd7SN3fKrm25129jIzJf1hNf5KoHVP1oE ACAw== X-Forwarded-Encrypted: i=1; AJvYcCUGVFd6nUVOSwWKEhFmhj8OWimX8iMeD4kKWPvoCGFKxnLwa0uil547ywU4TGiULKq5eNRCnkQ7YQDn+4ZnVNQF@lists.infradead.org X-Gm-Message-State: AOJu0YyA6yIHvEgR2kca/MyOSO8AhCS7qv/KSj3Jv6qjDqqkfPD0XSGR ZpFzIr0wpkVxvz744Okn/BNKsd34gQrU70wt0YrsTo8vp7uHiudI X-Google-Smtp-Source: AGHT+IEQQjEx8tkAfwbAeTn/6AJAVQgEFSE2ZKudGjLhzwsAULZD1vnYUnvC75zy66CTJbbtJbvyiw== X-Received: by 2002:a05:6358:99a0:b0:1aa:a01a:23da with SMTP id e5c5f4694b2df-1b8386f20c1mr160258655d.27.1725598622322; Thu, 05 Sep 2024 21:57:02 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:57:01 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 4/7] net: stmmac: configure FPE via ethtool-mm Date: Fri, 6 Sep 2024 12:55:59 +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-20240905_215703_539185_10381AD1 X-CRM114-Status: GOOD ( 18.61 ) 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 ethtool --show-mm and --set-mm callbacks. NIC up/down, link up/down, suspend/resume, kselftest-ethtool_mm, all tested okay. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean --- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 4 + drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 14 +++ drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 6 ++ drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 ++ .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 96 +++++++++++++++++++ 5 files changed, 126 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 7947b1212a2d..679efcc631f1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -1264,6 +1264,8 @@ const struct stmmac_ops dwmac410_ops = { .fpe_configure = dwmac5_fpe_configure, .fpe_send_mpacket = dwmac5_fpe_send_mpacket, .fpe_irq_status = dwmac5_fpe_irq_status, + .fpe_get_add_frag_size = dwmac5_fpe_get_add_frag_size, + .fpe_set_add_frag_size = dwmac5_fpe_set_add_frag_size, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, @@ -1316,6 +1318,8 @@ const struct stmmac_ops dwmac510_ops = { .fpe_configure = dwmac5_fpe_configure, .fpe_send_mpacket = dwmac5_fpe_send_mpacket, .fpe_irq_status = dwmac5_fpe_irq_status, + .fpe_get_add_frag_size = dwmac5_fpe_get_add_frag_size, + .fpe_set_add_frag_size = dwmac5_fpe_set_add_frag_size, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index 850cfc4df6eb..db7bbc50cfae 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -653,3 +653,17 @@ void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, writel(value, ioaddr + MAC_FPE_CTRL_STS); } + +int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr) +{ + return FIELD_GET(DWMAC5_ADD_FRAG_SZ, readl(ioaddr + MTL_FPE_CTRL_STS)); +} + +void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) +{ + u32 value; + + value = readl(ioaddr + MTL_FPE_CTRL_STS); + writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), + ioaddr + MTL_FPE_CTRL_STS); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h index c3031c1357d0..58704c15f320 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h @@ -39,6 +39,10 @@ #define MAC_PPSx_INTERVAL(x) (0x00000b88 + ((x) * 0x10)) #define MAC_PPSx_WIDTH(x) (0x00000b8c + ((x) * 0x10)) +#define MTL_FPE_CTRL_STS 0x00000c90 +/* Additional Fragment Size of preempted frames */ +#define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0) + #define MTL_RXP_CONTROL_STATUS 0x00000ca0 #define RXPI BIT(31) #define NPE GENMASK(23, 16) @@ -109,5 +113,7 @@ void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, struct stmmac_fpe_cfg *cfg, enum stmmac_mpacket_type type); int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); +int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr); +void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size); #endif /* __DWMAC5_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 4942fc398ea6..f080e271f7af 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -426,6 +426,8 @@ struct stmmac_ops { struct stmmac_fpe_cfg *cfg, enum stmmac_mpacket_type type); int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); + int (*fpe_get_add_frag_size)(const void __iomem *ioaddr); + void (*fpe_set_add_frag_size)(void __iomem *ioaddr, u32 add_frag_size); }; #define stmmac_core_init(__priv, __args...) \ @@ -530,6 +532,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args) #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) +#define stmmac_fpe_get_add_frag_size(__priv, __args...) \ + stmmac_do_callback(__priv, mac, fpe_get_add_frag_size, __args) +#define stmmac_fpe_set_add_frag_size(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, fpe_set_add_frag_size, __args) /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 220c582904f4..266e7d335929 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -19,6 +19,7 @@ #include "stmmac.h" #include "dwmac_dma.h" #include "dwxgmac2.h" +#include "dwmac5.h" #define REG_SPACE_SIZE 0x1060 #define GMAC4_REG_SPACE_SIZE 0x116C @@ -1263,6 +1264,98 @@ static int stmmac_set_tunable(struct net_device *dev, return ret; } +static int stmmac_get_mm(struct net_device *ndev, + struct ethtool_mm_state *state) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + unsigned long flags; + u32 frag_size; + + if (!priv->dma_cap.fpesel) + return -EOPNOTSUPP; + + spin_lock_irqsave(&priv->fpe_cfg.lock, flags); + + state->max_verify_time = STMMAC_FPE_MM_MAX_VERIFY_TIME_MS; + state->verify_enabled = priv->fpe_cfg.verify_enabled; + state->pmac_enabled = priv->fpe_cfg.pmac_enabled; + state->verify_time = priv->fpe_cfg.verify_time; + state->tx_enabled = priv->fpe_cfg.tx_enabled; + state->verify_status = priv->fpe_cfg.status; + state->rx_min_frag_size = ETH_ZLEN; + + /* FPE active if common tx_enabled and + * (verification success or disabled(forced)) + */ + if (state->tx_enabled && + (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED || + state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED)) + state->tx_active = true; + else + state->tx_active = false; + + frag_size = stmmac_fpe_get_add_frag_size(priv, priv->ioaddr); + state->tx_min_frag_size = ethtool_mm_frag_size_add_to_min(frag_size); + + spin_unlock_irqrestore(&priv->fpe_cfg.lock, flags); + + return 0; +} + +static int stmmac_set_mm(struct net_device *ndev, struct ethtool_mm_cfg *cfg, + struct netlink_ext_ack *extack) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + struct stmmac_fpe_cfg *fpe_cfg = &priv->fpe_cfg; + unsigned long flags; + u32 frag_size; + int err; + + err = ethtool_mm_frag_size_min_to_add(cfg->tx_min_frag_size, + &frag_size, extack); + if (err) + return err; + + /* Wait for the verification that's currently in progress to finish */ + timer_shutdown_sync(&fpe_cfg->verify_timer); + + spin_lock_irqsave(&fpe_cfg->lock, flags); + + fpe_cfg->verify_enabled = cfg->verify_enabled; + fpe_cfg->pmac_enabled = cfg->pmac_enabled; + fpe_cfg->verify_time = cfg->verify_time; + fpe_cfg->tx_enabled = cfg->tx_enabled; + + if (!cfg->verify_enabled) + fpe_cfg->status = ETHTOOL_MM_VERIFY_STATUS_DISABLED; + + stmmac_fpe_set_add_frag_size(priv, priv->ioaddr, frag_size); + stmmac_fpe_apply(priv); + + spin_unlock_irqrestore(&fpe_cfg->lock, flags); + + return 0; +} + +static void stmmac_get_mm_stats(struct net_device *ndev, + struct ethtool_mm_stats *s) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + struct stmmac_counters *mmc = &priv->mmc; + + if (!priv->dma_cap.rmon) + return; + + stmmac_mmc_read(priv, priv->mmcaddr, mmc); + + s->MACMergeFrameAssErrorCount = mmc->mmc_rx_packet_assembly_err_cntr; + s->MACMergeFrameAssOkCount = mmc->mmc_rx_packet_assembly_ok_cntr; + s->MACMergeFrameSmdErrorCount = mmc->mmc_rx_packet_smd_err_cntr; + s->MACMergeFragCountRx = mmc->mmc_rx_fpe_fragment_cntr; + s->MACMergeFragCountTx = mmc->mmc_tx_fpe_fragment_cntr; + s->MACMergeHoldCount = mmc->mmc_tx_hold_req_cntr; +} + static const struct ethtool_ops stmmac_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_MAX_FRAMES, @@ -1301,6 +1394,9 @@ static const struct ethtool_ops stmmac_ethtool_ops = { .set_tunable = stmmac_set_tunable, .get_link_ksettings = stmmac_ethtool_get_link_ksettings, .set_link_ksettings = stmmac_ethtool_set_link_ksettings, + .get_mm = stmmac_get_mm, + .set_mm = stmmac_set_mm, + .get_mm_stats = stmmac_get_mm_stats, }; void stmmac_set_ethtool_ops(struct net_device *netdev) From patchwork Fri Sep 6 04:56:00 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: 13793228 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 20986CD5BDD for ; Fri, 6 Sep 2024 05:02:49 +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=gj/t8zv5zEM8ykbWAIj163LrvaUZcMNe4Z//jXG9eTs=; b=OgKh3jr0+RWhCgwPotBodYtvXV lS8ugL4YXzWvWi/j1l+8uomXZg2C7GgNEkZIXYaCmbu+I2zfoRHtn8Yg1VfIpu0rw1BMOIamxGiYV +dHss8ZVpjvMzkD8MDv4W3TZcy2ZcsrQgE8J515eTwdHDrJxf1zVcTk6DErkQIeANZVJ2f2aTY9rc TRVCyli6oONl1+borQ1sJnCMEvyUvGdAxL3qpK6FngAYVzKddrsOYNCdGb6G2vCM700heY3FuiwD7 gkqfslVMJveTbbT2+rvgT0TGsfa3YA8cF/2JQdvgjK69FjmxHqUykV3rBQWQQd8tTrBrjAkEuF4LL 9IFBNjQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR7F-0000000AgHv-0xoQ; Fri, 06 Sep 2024 05:02:37 +0000 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR1x-0000000Af3n-1t4b for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:57:10 +0000 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-70f6118f1b5so1143400a34.0 for ; Thu, 05 Sep 2024 21:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598628; x=1726203428; 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=gj/t8zv5zEM8ykbWAIj163LrvaUZcMNe4Z//jXG9eTs=; b=bsOBOZJUZW/BfDlJT7PLwVA9hQkS6Hom05M5KQJbetEoFgGAO0/4WrtBGznONusk3B pT4PXY6YsRVBZjfm/kx8oe0gXtzyRTfpe2R0Yr+1AJqH+m8RYWnYH9L2kLTrczMjbDyX NzypwmOwKJ/97mjvVsxCrW1QCuASDc15YDU9yoG8sU5Fh8lQ8B84urlB+K5BPgxar4+f /YTz76lYb0tbJKsip7B+uhb8syMx+MikAhSMFQkHHq9fzmGdedrSd50ycS0pPJyBk4Na NiISy0lWbGQHlfQvuW9B9V/RkzysyT/+WQY1vQX9/IJUW4ZfxuQEZBwyv6SEIUzc3sNn sexg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598628; x=1726203428; 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=gj/t8zv5zEM8ykbWAIj163LrvaUZcMNe4Z//jXG9eTs=; b=sB1cO4zZdvNEVNRFt52OSZsOGDRcTthVymqIjhJ0Rk/z9C47+vBUFJ6vPVnL0Ejl7R EG2yqJbp2LjodrI2y4wxMLzfdLRhgg946hYrcyeMxehrIYznADEc/6CmZkzC50eeHpzQ 0d/dGy6j08rNfCtD1iHazVE1yjk/+6sfJSjG9VEFehArUworXHzURPRUcwp8M/BA37OS QyY+fHO2dWoTyGmDhmSgf4/uUSPsDD6dqs5YrlLztYojfxvB6H5RhQCKYOWhb66wxl4B NNOT283XVFaJ2Ck1U6Q2C8D1zYjnkZ0YxagBmFtl0CJf+aiW43AB9qeQh0EsbSKY4AFo jxvg== X-Forwarded-Encrypted: i=1; AJvYcCUpAKH03X28wbegN0PH9DJFrt+W/sIn6EOg3fcfOq4cOiksYnOEUvA4iMIddIFcGm6VmhKAdigo2GjUbkh//H53@lists.infradead.org X-Gm-Message-State: AOJu0YyPXEUapoo4oUYQZD4iNtv6o+LS5K4NZMwdXw5ELhwR0dshJ52i M4WtZ0lKcwO4yjZ26CO/UXeC3rnkiwfFGQ9pyb8XqKUSiztYJN5h4Bk0cg== X-Google-Smtp-Source: AGHT+IGRYWT4g2pFYcTkuFsC+3xMEa32qeR1J75LNNbWHjFC+2w7kE4JUJE252ff/ck7oyVkmZoKrg== X-Received: by 2002:a05:6218:260d:b0:1aa:c73d:5a8a with SMTP id e5c5f4694b2df-1b83866d4b0mr156332455d.16.1725598627965; Thu, 05 Sep 2024 21:57:07 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:57:07 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 5/7] net: stmmac: support fp parameter of tc-mqprio Date: Fri, 6 Sep 2024 12:56:00 +0800 Message-Id: <90c7c47f89bfb1b611c20e5e4a1c477969e1dc84.1725597121.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_215709_521069_16F262A7 X-CRM114-Status: GOOD ( 23.23 ) 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-mqprio can select whether traffic classes are express or preemptible. After some traffic tests, MAC merge layer statistics are all good. Local device: ethtool --include-statistics --json --show-mm eth1 [ { "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": 35105, "MACMergeHoldCount": 0 } } ] Remote device: ethtool --include-statistics --json --show-mm end1 [ { "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": 35105, "MACMergeFragCountRx": 35105, "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/dwmac4_core.c | 2 + drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 55 +++++++++++ drivers/net/ethernet/stmicro/stmmac/dwmac5.h | 4 + drivers/net/ethernet/stmicro/stmmac/hwif.c | 6 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 12 +++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 + .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 94 +++++++++++++++++++ 7 files changed, 172 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 679efcc631f1..a1858f083eef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -1266,6 +1266,7 @@ const struct stmmac_ops dwmac410_ops = { .fpe_irq_status = dwmac5_fpe_irq_status, .fpe_get_add_frag_size = dwmac5_fpe_get_add_frag_size, .fpe_set_add_frag_size = dwmac5_fpe_set_add_frag_size, + .fpe_map_preemption_class = dwmac5_fpe_map_preemption_class, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, @@ -1320,6 +1321,7 @@ const struct stmmac_ops dwmac510_ops = { .fpe_irq_status = dwmac5_fpe_irq_status, .fpe_get_add_frag_size = dwmac5_fpe_get_add_frag_size, .fpe_set_add_frag_size = dwmac5_fpe_set_add_frag_size, + .fpe_map_preemption_class = dwmac5_fpe_map_preemption_class, .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index db7bbc50cfae..ab96fc055f48 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -667,3 +667,58 @@ void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size) writel(u32_replace_bits(value, add_frag_size, DWMAC5_ADD_FRAG_SZ), ioaddr + MTL_FPE_CTRL_STS); } + +#define ALG_ERR_MSG "TX algorithm SP is not suitable for one-to-many mapping" +#define WEIGHT_ERR_MSG "TXQ weight %u differs across other TXQs in TC: [%u]" + +int dwmac5_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass) +{ + u32 val, offset, count, queue_weight, preemptible_txqs = 0; + struct stmmac_priv *priv = netdev_priv(ndev); + u32 num_tc = ndev->num_tc; + + if (!pclass) + goto update_mapping; + + /* DWMAC CORE4+ can not program TC:TXQ mapping to hardware. + * + * Synopsys Databook: + * "The number of Tx DMA channels is equal to the number of Tx queues, + * and is direct one-to-one mapping." + */ + 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); + + /* This is 1:1 mapping, go to next TC */ + if (count == 1) + continue; + + if (priv->plat->tx_sched_algorithm == MTL_TX_ALGORITHM_SP) { + NL_SET_ERR_MSG_MOD(extack, ALG_ERR_MSG); + return -EINVAL; + } + + queue_weight = priv->plat->tx_queues_cfg[offset].weight; + + for (u32 i = 1; i < count; i++) { + if (priv->plat->tx_queues_cfg[offset + i].weight != + queue_weight) { + NL_SET_ERR_MSG_FMT_MOD(extack, WEIGHT_ERR_MSG, + queue_weight, tc); + return -EINVAL; + } + } + } + +update_mapping: + val = readl(priv->ioaddr + MTL_FPE_CTRL_STS); + writel(u32_replace_bits(val, preemptible_txqs, DWMAC5_PREEMPTION_CLASS), + priv->ioaddr + MTL_FPE_CTRL_STS); + + return 0; +} diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h index 58704c15f320..6c6eb6790e83 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.h @@ -40,6 +40,8 @@ #define MAC_PPSx_WIDTH(x) (0x00000b8c + ((x) * 0x10)) #define MTL_FPE_CTRL_STS 0x00000c90 +/* Preemption Classification */ +#define DWMAC5_PREEMPTION_CLASS GENMASK(15, 8) /* Additional Fragment Size of preempted frames */ #define DWMAC5_ADD_FRAG_SZ GENMASK(1, 0) @@ -115,5 +117,7 @@ void dwmac5_fpe_send_mpacket(void __iomem *ioaddr, int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev); int dwmac5_fpe_get_add_frag_size(const void __iomem *ioaddr); void dwmac5_fpe_set_add_frag_size(void __iomem *ioaddr, u32 add_frag_size); +int dwmac5_fpe_map_preemption_class(struct net_device *ndev, + struct netlink_ext_ack *extack, u32 pclass); #endif /* __DWMAC5_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c b/drivers/net/ethernet/stmicro/stmmac/hwif.c index 29367105df54..88cce28b2f98 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.c +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c @@ -171,7 +171,7 @@ static const struct stmmac_hwif_entry { .mac = &dwmac4_ops, .hwtimestamp = &stmmac_ptp, .mode = NULL, - .tc = &dwmac510_tc_ops, + .tc = &dwmac4_tc_ops, .mmc = &dwmac_mmc_ops, .est = &dwmac510_est_ops, .setup = dwmac4_setup, @@ -252,7 +252,7 @@ static const struct stmmac_hwif_entry { .mac = &dwxgmac210_ops, .hwtimestamp = &stmmac_ptp, .mode = NULL, - .tc = &dwmac510_tc_ops, + .tc = &dwxgmac_tc_ops, .mmc = &dwxgmac_mmc_ops, .est = &dwmac510_est_ops, .setup = dwxgmac2_setup, @@ -273,7 +273,7 @@ static const struct stmmac_hwif_entry { .mac = &dwxlgmac2_ops, .hwtimestamp = &stmmac_ptp, .mode = NULL, - .tc = &dwmac510_tc_ops, + .tc = &dwxgmac_tc_ops, .mmc = &dwxgmac_mmc_ops, .est = &dwmac510_est_ops, .setup = dwxlgmac2_setup, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index f080e271f7af..d5a9f01ecac5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -7,6 +7,7 @@ #include #include +#include #define stmmac_do_void_callback(__priv, __module, __cname, __arg0, __args...) \ ({ \ @@ -428,6 +429,9 @@ struct stmmac_ops { int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); int (*fpe_get_add_frag_size)(const void __iomem *ioaddr); void (*fpe_set_add_frag_size)(void __iomem *ioaddr, u32 add_frag_size); + int (*fpe_map_preemption_class)(struct net_device *ndev, + struct netlink_ext_ack *extack, + u32 pclass); }; #define stmmac_core_init(__priv, __args...) \ @@ -536,6 +540,8 @@ struct stmmac_ops { stmmac_do_callback(__priv, mac, fpe_get_add_frag_size, __args) #define stmmac_fpe_set_add_frag_size(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, fpe_set_add_frag_size, __args) +#define stmmac_fpe_map_preemption_class(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, fpe_map_preemption_class, __args) /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { @@ -623,6 +629,8 @@ struct stmmac_tc_ops { struct tc_etf_qopt_offload *qopt); int (*query_caps)(struct stmmac_priv *priv, struct tc_query_caps_base *base); + int (*setup_mqprio)(struct stmmac_priv *priv, + struct tc_mqprio_qopt_offload *qopt); }; #define stmmac_tc_init(__priv, __args...) \ @@ -639,6 +647,8 @@ struct stmmac_tc_ops { stmmac_do_callback(__priv, tc, setup_etf, __args) #define stmmac_tc_query_caps(__priv, __args...) \ stmmac_do_callback(__priv, tc, query_caps, __args) +#define stmmac_tc_setup_mqprio(__priv, __args...) \ + stmmac_do_callback(__priv, tc, setup_mqprio, __args) struct stmmac_counters; @@ -682,7 +692,9 @@ extern const struct stmmac_dma_ops dwmac4_dma_ops; extern const struct stmmac_ops dwmac410_ops; extern const struct stmmac_dma_ops dwmac410_dma_ops; extern const struct stmmac_ops dwmac510_ops; +extern const struct stmmac_tc_ops dwmac4_tc_ops; extern const struct stmmac_tc_ops dwmac510_tc_ops; +extern const struct stmmac_tc_ops dwxgmac_tc_ops; extern const struct stmmac_ops dwxgmac210_ops; extern const struct stmmac_ops dwxlgmac2_ops; extern const struct stmmac_dma_ops dwxgmac210_dma_ops; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4192681a8ac5..cc25fd46b33b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6215,6 +6215,8 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type, switch (type) { case TC_QUERY_CAPS: return stmmac_tc_query_caps(priv, priv, type_data); + case TC_SETUP_QDISC_MQPRIO: + return stmmac_tc_setup_mqprio(priv, priv, type_data); case TC_SETUP_BLOCK: return flow_block_cb_setup_simple(type_data, &stmmac_block_cb_list, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index a58282d6458c..cfdb9ab1fa2a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1174,6 +1174,13 @@ static int tc_query_caps(struct stmmac_priv *priv, struct tc_query_caps_base *base) { switch (base->type) { + case TC_SETUP_QDISC_MQPRIO: { + struct tc_mqprio_caps *caps = base->caps; + + caps->validate_queue_counts = true; + + return 0; + } case TC_SETUP_QDISC_TAPRIO: { struct tc_taprio_caps *caps = base->caps; @@ -1190,6 +1197,81 @@ static int tc_query_caps(struct stmmac_priv *priv, } } +static void stmmac_reset_tc_mqprio(struct net_device *ndev, + struct netlink_ext_ack *extack) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + netdev_reset_tc(ndev); + netif_set_real_num_tx_queues(ndev, priv->plat->tx_queues_to_use); + stmmac_fpe_map_preemption_class(priv, ndev, extack, 0); +} + +static int tc_setup_dwmac510_mqprio(struct stmmac_priv *priv, + struct tc_mqprio_qopt_offload *mqprio) +{ + struct netlink_ext_ack *extack = mqprio->extack; + struct tc_mqprio_qopt *qopt = &mqprio->qopt; + u32 offset, count, num_stack_tx_queues = 0; + struct net_device *ndev = priv->dev; + u32 num_tc = qopt->num_tc; + int err; + + if (!num_tc) { + stmmac_reset_tc_mqprio(ndev, extack); + return 0; + } + + err = netdev_set_num_tc(ndev, num_tc); + if (err) + return err; + + for (u32 tc = 0; tc < num_tc; tc++) { + offset = qopt->offset[tc]; + count = qopt->count[tc]; + num_stack_tx_queues += count; + + err = netdev_set_tc_queue(ndev, tc, count, offset); + if (err) + goto err_reset_tc; + } + + err = netif_set_real_num_tx_queues(ndev, num_stack_tx_queues); + if (err) + goto err_reset_tc; + + err = stmmac_fpe_map_preemption_class(priv, ndev, extack, + mqprio->preemptible_tcs); + if (err) + goto err_reset_tc; + + return 0; + +err_reset_tc: + stmmac_reset_tc_mqprio(ndev, extack); + + return err; +} + +static int tc_setup_mqprio_unimplemented(struct stmmac_priv *priv, + struct tc_mqprio_qopt_offload *mqprio) +{ + NL_SET_ERR_MSG_MOD(mqprio->extack, + "mqprio HW offload is not implemented for this MAC"); + return -EOPNOTSUPP; +} + +const struct stmmac_tc_ops dwmac4_tc_ops = { + .init = tc_init, + .setup_cls_u32 = tc_setup_cls_u32, + .setup_cbs = tc_setup_cbs, + .setup_cls = tc_setup_cls, + .setup_taprio = tc_setup_taprio, + .setup_etf = tc_setup_etf, + .query_caps = tc_query_caps, + .setup_mqprio = tc_setup_mqprio_unimplemented, +}; + const struct stmmac_tc_ops dwmac510_tc_ops = { .init = tc_init, .setup_cls_u32 = tc_setup_cls_u32, @@ -1198,4 +1280,16 @@ const struct stmmac_tc_ops dwmac510_tc_ops = { .setup_taprio = tc_setup_taprio, .setup_etf = tc_setup_etf, .query_caps = tc_query_caps, + .setup_mqprio = tc_setup_dwmac510_mqprio, +}; + +const struct stmmac_tc_ops dwxgmac_tc_ops = { + .init = tc_init, + .setup_cls_u32 = tc_setup_cls_u32, + .setup_cbs = tc_setup_cbs, + .setup_cls = tc_setup_cls, + .setup_taprio = tc_setup_taprio, + .setup_etf = tc_setup_etf, + .query_caps = tc_query_caps, + .setup_mqprio = tc_setup_mqprio_unimplemented, }; From patchwork Fri Sep 6 04:56: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: 13793229 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 2D1AAC54FC6 for ; Fri, 6 Sep 2024 05:03:47 +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=pUTbWYSzdPbEowJ7j1vGQGnAzD494Zg9qCau1Jp3NnY=; b=asiUBv2kAfDeGh8lVepd86nXKF KarsJJnhgrgKPmJXlwblZRWWidamOHZdKzfHSFWpwgup6Unsrtjju6hEafH4+qNft9l7lUgnmja8M 6hq48kTcLv5CT3/pJa0VCwv25MW3mhg/OHGTPwFWk9eznw9tz2eZY5x71A1OLBIX6Jc++T237ZkgX CNT76FSlL9z2mgNKVj5BWoqVkaxtgy0J99lbi4Ag/NGbh5mBH2nrPMnKGf0uwpHv2UAdx0HMpEXTj QDqfGI15xO7rHs9n47BeyrkhhnIyC8cJeMfOSqF+9ufcuWHTr8j2dslFHwcLKZixdQtDaI+3aHGl6 fj6dUprw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR8B-0000000AgTH-2KX0; Fri, 06 Sep 2024 05:03:35 +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 1smR22-0000000Af5C-38mE for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:57:16 +0000 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-5e172cc6d66so944879eaf.2 for ; Thu, 05 Sep 2024 21:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598633; x=1726203433; 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=pUTbWYSzdPbEowJ7j1vGQGnAzD494Zg9qCau1Jp3NnY=; b=G2mABL5B+IJ4aXanTL0ztzYks1ERHX7O/xyEo8JJaWcfhlaSGbnz5UHJZIkWHcbZ+u 3YXBZLmZNUsh2ilvdPJUPCq3hWYuODZzK+v+WoNRdWnX7menobvckZZLAjDTa3WGvfTd ji0nbEPh2bpunkwlyYzYTeu3PhaIYHAIUQ2sZvZxA9CIK84Rr4ipmWHANi9i744AHZt7 j1X0dxbkFcME3vOJPNSKwWyzDa7TCvad9QAIvm1L/l47uKyFnjzbtqRZFm8l/BQ0BihC QJrN7cn7kSZyme8NU7Ar3nKp5EWqT75jIvv/IAmR4ifoiODZqyN85zVAtvtoFsEsCG0Z RZ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598633; x=1726203433; 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=pUTbWYSzdPbEowJ7j1vGQGnAzD494Zg9qCau1Jp3NnY=; b=QoDDop9kgUqEhQN6fYULM2XiNJ06wcK7YAhr5ISp50Ze5RzhakNn5JO81kLuAm26zV EncfC1wNfdWn8mDd9p/MSYrT4gRDi/rSy1ydkxfRus0GqcYzBqrb5v/GeZMWgQxQ5Uib XSJY5i13aBBvGqoPYZyyTw30dmcmc6tFsmVOQrLRhGS752qf/WI8uCsn59fsBycA8H4s hxQNvNuNQDs3UJjRPPV689Xva8zjjT1Ww0ER5SG3tE6SePhA00QaHKNaBF31fdONWR8Q z4C7AEIyCVKUeTGL5ePoEo6Fdsij9yIx7oLJ7Q5Bc2OAFCRb5ZTDBNUQl4xBzW9tIgq9 4m6A== X-Forwarded-Encrypted: i=1; AJvYcCWPPpzNDxGpJ6COHzIow10PGPX5q0uXMl6TbAZFEwTETZlik72r6y+BKiniSzAXs0hMZh6R5KgK+P0Uz6fgQ9G4@lists.infradead.org X-Gm-Message-State: AOJu0YxK76lmf+scOE0QK0pMnoXxI4m8GqedgzyDBMoVuSexwVBk/cLc fF867SM2cSLNIEYauT3Qza7ci6oAeDIAQqQQPlkft2XEdkOsNuI9N5jbqQ== X-Google-Smtp-Source: AGHT+IEmwYoF6D91vqG3EN8hhpjG7cVhE7/POmkWJ+xVqKe899Zu0KnuMeWe7OE+KzPXhV7cKxv0Nw== X-Received: by 2002:a05:6358:5425:b0:1b5:f81c:8768 with SMTP id e5c5f4694b2df-1b8385ceffbmr195848055d.9.1725598633429; Thu, 05 Sep 2024 21:57:13 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:57:12 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 6/7] net: stmmac: support fp parameter of tc-taprio Date: Fri, 6 Sep 2024 12:56:01 +0800 Message-Id: <8e72e92a48e1aca2a38794037d7eb3382711e305.1725597121.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_215714_878710_1EF68A72 X-CRM114-Status: GOOD ( 13.87 ) 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, From patchwork Fri Sep 6 04:56:02 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: 13793230 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 A46ADCD5BDD for ; Fri, 6 Sep 2024 05:04:42 +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=nRhWJrEYy3VMtGEOiJyga7bTazzfIqhRdV1t7XTzZag=; b=dpx7aP3CGRy2C2xIwzhlInEV4o 5f2eZ8B47h8KnLJKmRYMoYBU8qZM5MuJbxahWvHpNHiXCveWMeVvPHq1/xOe2AL+HI/lLi1LhuxKC y6/5wmbtN4lgQ5abYfirvGiLiBfkD4/TA18PnwGVzUGArEU+O5+31qn3PKaaLDeSM9QVfpHhFipy2 vMwJz2Bc9hbkGtkUWovzjFnZIxyO6YPZ6MNWd/QRvLhGr6hfA3oyxKlSRWIanVPsufuSPmHjiz3ys K/LwPb2AoPGwJvqL/ubZzrjFVwMaNlX0phb7G+MfKPR+jPHB1XbQUEGMT1hEei5K+EkB6Kb243fLP Jh7ZcyJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR97-0000000AgaX-3Ble; Fri, 06 Sep 2024 05:04:33 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smR28-0000000Af75-0ZWX for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 04:57:21 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5dfad5a9c21so1020868eaf.0 for ; Thu, 05 Sep 2024 21:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725598639; x=1726203439; 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=nRhWJrEYy3VMtGEOiJyga7bTazzfIqhRdV1t7XTzZag=; b=OiMY7ViGbz1CJdW3TwYx+lVarDbOrBkI3CxrzFD4FB2qTp027nRmFgQ4rlToGioUTR dJTtCOACz9DRLVUREQw/VBQm9l5oG0qfjKB1BZDEPelzoW6zjrr7i7qHSEbBsjTplICA 9uqz2ok0W5qHnb3WMbbM3iCqT1ttTpNa6rAmogzV3opWuhX77M3I3BvxzQVnE2J1A21P B4yyqFm70KYL4TON06FmlDOY6vVF6JDEyQnE5KXdlkon2HMZKl88tq/dzN6CGwsgFvYo TGbiQEBDWCoOhF14DeHjy8sd5qimef061IU7+UUb3d7PGtLFXYxabmODgBgjwsCpJLCv vN/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725598639; x=1726203439; 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=nRhWJrEYy3VMtGEOiJyga7bTazzfIqhRdV1t7XTzZag=; b=kSnbo6d+LdNNZkfSYsvQZKmg4UFg9lBTiFy5zKUtwOPf0hfUfdASP09OEzAZfMnWhC KRHE458I9Jd2cKdw3u65ZjsvuLe3fx/eUZY9Kr9DePOJoRiqHUxBswNpEwwj6D93trt3 6/B9cnonbY3Mx/ceYHO83t50b81107XnJzUoeoTnivgxG9iqt1evMd9mY+BRoaj9Vam7 SI893d8yySlY1DCFWNoD0Fdq/kP3jtuR6iuDCc2kW3eTEh1jtpRM7dOluV+CngsqprGD tdKsUEcCOlBC7evL8AFIb/IPb7C3P2v/0J/k9mrsp8Un07MbA3a0jYnPyHbsRtpNo1jB EFqA== X-Forwarded-Encrypted: i=1; AJvYcCXAtBaTcFeaEGWQuCFWusomTgOq/ccPB94DEkFyxUfSkjd6avxF+ILFp0MhZM74fTwx7xwdrnPxTvtMSDZaRyTc@lists.infradead.org X-Gm-Message-State: AOJu0YzwFwFKwugzdd+xCEwGiWY0FXoGGF5jzJc4IQx+NcBz2Iu0Sv1W QwoY06feWoM9aLFNLXH9uo2qcZSW6ELOU/quQvZavjXwYoHc0J7V X-Google-Smtp-Source: AGHT+IFCUKUTtjgKr3GIy0Uy986g8UvKVqkWYYM5qB832p7WPOQoTiQsAlcR/uJnyiSROeb2fH9mEA== X-Received: by 2002:a05:6358:5498:b0:1b5:eda9:963f with SMTP id e5c5f4694b2df-1b603ccaed3mr2990635155d.29.1725598638878; Thu, 05 Sep 2024 21:57:18 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-71791e54585sm1704002b3a.182.2024.09.05.21.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 21:57:18 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Vladimir Oltean , 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 v9 7/7] net: stmmac: silence FPE kernel logs Date: Fri, 6 Sep 2024 12:56:02 +0800 Message-Id: <5d4fabe80145cb6779bf8ccc3f0624c61e9666be.1725597121.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_215720_197964_9B118DBA X-CRM114-Status: GOOD ( 12.29 ) 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 ethtool --show-mm can get real-time state of FPE. fpe_irq_status logs should keep quiet. tc-taprio can always query driver state, delete unbalanced logs. Signed-off-by: Furong Xu <0x1207@gmail.com> Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 8 ++++---- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index ab96fc055f48..08add508db84 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -620,22 +620,22 @@ int dwmac5_fpe_irq_status(void __iomem *ioaddr, struct net_device *dev) if (value & TRSP) { status |= FPE_EVENT_TRSP; - netdev_info(dev, "FPE: Respond mPacket is transmitted\n"); + netdev_dbg(dev, "FPE: Respond mPacket is transmitted\n"); } if (value & TVER) { status |= FPE_EVENT_TVER; - netdev_info(dev, "FPE: Verify mPacket is transmitted\n"); + netdev_dbg(dev, "FPE: Verify mPacket is transmitted\n"); } if (value & RRSP) { status |= FPE_EVENT_RRSP; - netdev_info(dev, "FPE: Respond mPacket is received\n"); + netdev_dbg(dev, "FPE: Respond mPacket is received\n"); } if (value & RVER) { status |= FPE_EVENT_RVER; - netdev_info(dev, "FPE: Verify mPacket is received\n"); + netdev_dbg(dev, "FPE: Verify mPacket is received\n"); } return status; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 05ffff00a524..832998bc020b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -1067,8 +1067,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, if (ret) goto disable; - netdev_info(priv->dev, "configured EST\n"); - return 0; disable: @@ -1087,8 +1085,6 @@ static int tc_taprio_configure(struct stmmac_priv *priv, stmmac_fpe_map_preemption_class(priv, priv->dev, extack, 0); - netdev_info(priv->dev, "disabled FPE\n"); - return ret; }