From patchwork Tue Aug 20 09:38:29 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: 13769759 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 7E8C0C531DF for ; Tue, 20 Aug 2024 09:40:26 +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=WgQ8xoW2Sz0iprZBFSPkGxeLiY/+7DmIllsVyhzR+sk=; b=lEh3XRc8N8wcpCE9y9XoNzou90 bon6w2dqIV7TzrCZdfm5iUXBlfJSopHTkOGXFCGEKHPhStteAYwW9dNL2nJ+YW2WslmGCLSvAQWRx RcHGbeoXXwzYg1J+VXwTHSL6HaZF6WL6teaYHwkmOJcn9vUVHpQvaRgvBhEK986bkDCPE/TreVIBP FJIbaccR+SeiUQ93PmKO7mP102iPC85xgv4KJuRk31HTDVW05j4QeQ+BVZ/cYSjspO7rX0ykIbygV AYbzIOTwUlNkcrlu1OoyNWSz6p43z1cwkLkK204tv0679iRXLrJFuTk0wRqg7AAUgeuVkU+hEZt65 FsRkW6Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLLc-00000004cYA-0WWf; Tue, 20 Aug 2024 09:40:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLKQ-00000004cCo-2F3p for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Aug 2024 09:39:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WgQ8xoW2Sz0iprZBFSPkGxeLiY/+7DmIllsVyhzR+sk=; b=F8k6fbzRWNvFC60N8TQqNA5iBw 1+wlipOw7yHo6Lk5LqM9E7e84HlDsJ4qNBgKOsl0BD5qyZtXHHAt+7wkBjiIReDG55E3yXwwC1Owk UB40pNSYelSjMhWzopDQK1DaE+mWUz36a5+ob5s7wNZYBNKKEfucjVKdOp3Dc/UXhYYMjLKvT58AV z0qWjwjAqaMUOEHoc0nBTPttAkkJnLKBg1bn/4WgdreLbse0MLFIi4hrNL2ljiZlW6UNv/FgGrXjn R+2GrCQ6Zz/H8VOHyX2ltMmA3qqOaPh36sLdI1a0cHWZ+qqa1qwWZMe5ruWD9Pgg7IGjnAFyf+qu+ SQVxHlWw==; Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgLKN-00000009IUK-20Gn for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 09:39:01 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2d3c071d276so3648499a91.1 for ; Tue, 20 Aug 2024 02:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724146736; x=1724751536; 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=WgQ8xoW2Sz0iprZBFSPkGxeLiY/+7DmIllsVyhzR+sk=; b=UawOuUKzOwzSQ0IhWrlI4atC8bkC/ucY71bDxyxdnT0wBab8wDG/+mWllWNWMk6DSi C7sl+EQOXf90uJXuZUQiu2+avL1ugDYQyVzaNoOa/q3WdcGZuQAy/mFOdDDQqjOe7buV WETHs4w9Zzf8lKvt4TzXHdfBeJHlhjdfEqv6YvJsHJdZby36B0ZQY8IJmkDtqDOkIGuO jh4OY9V82mixawJDKahAep4Ti6IiX0l43Wnf30dRQ/h3V0Nnlz9ubKoUDTJEmG2U89TH N81qpN0j4b86AoH3xFWz1rlMuhfNQM0BdVxzAN1T7di6M6cG7KkA7woIEMoJjr88x5er JmGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724146736; x=1724751536; 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=WgQ8xoW2Sz0iprZBFSPkGxeLiY/+7DmIllsVyhzR+sk=; b=HVaJoumpVRALjw1b16kYgKyoLzzgjhIdJelDvKtuezDODQGNrlxfvvW3CNZDtSmHLr x2P80ftnOdJOkOVFGUVu6hGOhf5H5iRsxf/CSSQFP1e7V46HeWDi0ANU57NczpZJ06XI eQmIlX+lGPftZ37HidaO5arxA7C4T0wB4eU5aS9z6jkBWHpUGGhAaoZU1rCkfmCjrBuB 2iPi2FcnsUb8vPTu1v2LAbbrA2AdOIeAqo6+FZOVHp6e/k3UAa5lHjpDgZIiI2vq+Bmm SOi8yNM78xoIqYyiSe6ZpDiALw+1boj6jv9J9b8C/a5LSLHbqKNqECVPKAzTZK6ImsJi FfRw== X-Forwarded-Encrypted: i=1; AJvYcCU4DOkb5vUbthWWD6RJgJ9hu9V0taISWW7s5QR9hSpYtK0BYZ+OVrV04oMtmqZjM6aul7lN76UjE4WlImHWfvH9mIU6igDD0DYmbnuvxDT+LQmrQaI= X-Gm-Message-State: AOJu0YzibzTtxzh9uMAs/uPMgRx333yl/fKEOmUuu2esMPjgLnKsyr/e NLFZSyNfFIqDNlkJUo8WpdqTNp19+ndAantMGz5WNqfVtXkY1Pts X-Google-Smtp-Source: AGHT+IF0cHJ5LSpG8fcKNGdlqkHBNjcLoIXdZg7wjMcEjMwLquCqOwmqA1bmJPrBOQSLM3R3lR2QtA== X-Received: by 2002:a17:90a:c584:b0:2c8:a8f:c97 with SMTP id 98e67ed59e1d1-2d3e03e9b13mr12251597a91.37.1724146735939; Tue, 20 Aug 2024 02:38:55 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2d45246061dsm3230608a91.8.2024.08.20.02.38.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 02:38:55 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: Serge Semin , Andrew Lunn , Vladimir Oltean , "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, xfr@outlook.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v4 1/7] net: stmmac: move stmmac_fpe_cfg to stmmac_priv data Date: Tue, 20 Aug 2024 17:38:29 +0800 Message-Id: <2fc5d2d43b583f3e66b843783f067f5420a0c8da.1724145786.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-20240820_103859_693704_4A8750AE X-CRM114-Status: GOOD ( 19.73 ) 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 --- 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..d3da82982012 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -26,6 +26,8 @@ }) struct stmmac_extra_stats; +struct stmmac_fpe_cfg; +enum stmmac_mpacket_type; struct stmmac_priv; struct stmmac_safety_stats; struct dma_desc; 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;