From patchwork Mon Jun 24 13:26:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709519 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 40A36C2D0D1 for ; Mon, 24 Jun 2024 13:29:18 +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=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=I2AcJmtOWxMHdiZJR5LHSRSHyE wr8PGEtUa8R3Sy42rFf33XZSF2h5vst9TtOCIvz+DxxyOv2bEwAMcGzkt8Y9XH41NmojE4HNJFY9E vMz4vn5E+zUrbifqVkz6wn1/jQDTTExC6FPtSoRSV2oW0QNcA8RTk1PCjkOekVjIa5udO/R9YiOjh HPn6xNYwKjMdFPCvR4gzGZsUBh2npDdlcyVtT/D+1X+6dfQZR8+4BC2XKl+5iAakSstgIK5VdJLYW gSn2gaFiN+Y3qjvaqipJ8DmiNVQ/Hw27erVlQJ27WzGu2VzFOKTwYx/xsgEo/016AkyQGtF9wOG/E 1JNm73YQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkn-0000000GvDi-0gNM; Mon, 24 Jun 2024 13:29:05 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkO-0000000Guzu-1ChS for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:41 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52cdf4bc083so2711252e87.2 for ; Mon, 24 Jun 2024 06:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235718; x=1719840518; 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=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=fkFDTU4EzIegg8tbo8An8YBuY6haPYZTW9W5zmvUm5XVnZnRuCsEy38drtUNG/LFBq gcrEbcaK7+pqG68JGItb+z+D8+Hhiu5s7K++TYtEVKLH3yaeXyV3vQxgQUG3AwWW8/hx Ga9HTv2SWdQk5pI+GpMA3+RyObUTOSfgmtWMEH9MhDOF+5KUDCXN2X3FmOX9akXja4qA klFGTah959QkzgrBMPebKxrokIdSFG+mjDfWrdsG2F1d4f5a5D3XDkIZl5wgjYXzr068 O1QQrkLFNs+/C8yhWLIvRYAc0yX+QcFq7H2F1BT8YvSVdaMy1VivqxM/xbfls4avU1Gp QJiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235718; x=1719840518; 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=w7Ol19BJCD3Qqon4hRuLkjL5PVBIRDIZpTfM6qDSNSQ=; b=QenIUk8qAO4DKxcsfZ53yFGwZx3V+4SUn6lRTcRXiaEqDeVk8Z8wVnWGsWB/CW96dM mzQ6yaWSKQsgut6XYM67p9DIjF90HUuhPx2tbfAFkkQEoa6iEkeM/1w99GDmMSj96kJl PZEwC22gdw4OMn06dftw+SAlIroj86uHjwfY4pfjbwga3EmMuqe6ls2SNUrZN/PO8tfL cQ69HtW38WgnbiSPbPqsOjXhu3ldBr7v9wrD1q0D9tJZ33y27LjKIbK6fOM1l+pngCGQ DH0WB9fxpP/E721qZtZp8MxtD6RtFlV2M82jY8HVlyyJJ6HP66aR1AJAMsY9HKvOsPpr yxYg== X-Forwarded-Encrypted: i=1; AJvYcCUi19lXqJtnM4/7fBKldOWzC/XoscQ84VTS1voH7lsXKlN0iUgy5IQQY1AUw4dmJGEBmcUIouszXC+xZOP72lmZiDGRDzegrRwbRzM6Go8wcz3rxo0= X-Gm-Message-State: AOJu0YzTGi6GgLs0FPYiu8NOhNouJD9fkQFiCPdvygdeNMlZvqIPOnnv WtHlflH5U9evvona1A5VooMk/U4zdUixFZR4JhZtwAl/0908RCsw X-Google-Smtp-Source: AGHT+IFCP0Abnl0ON1YlKTZpmLSz+wWOfdf3+G3qM0oG3CK0Ou7QI39akcE1gEBgfNlx61R5C1552w== X-Received: by 2002:a05:6512:3d10:b0:52c:e326:f4cf with SMTP id 2adb3069b0e04-52ce326f5e4mr3905981e87.3.1719235717804; Mon, 24 Jun 2024 06:28:37 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cebd0985fsm48965e87.258.2024.06.24.06.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:37 -0700 (PDT) From: Serge Semin To: Russell King , Andrew Halaney , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Alexei Starovoitov , Jesper Dangaard Brouer , John Fastabend , Daniel Borkmann , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC net-next v2 12/17] net: stmmac: Introduce internal PCS IRQ enable/disable methods Date: Mon, 24 Jun 2024 16:26:29 +0300 Message-ID: <20240624132802.14238-4-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240624_062840_368881_E625A2E3 X-CRM114-Status: GOOD ( 14.18 ) 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 The PCS IRQ enable/disable procedures have been utilized in the framework of the PHYLINK PCS enable/disable callbacks. Since a generic STMMAC PHYLINK PCS implementation is about to be introduced let's move the procedures into the dedicated DW GMAC and DW QoS Eth HW-abstraction methods. These methods will be called from the PCS enable/disable functions defined in the stmmac_pcs.c in the DW MAC-independent manner. Signed-off-by: Serge Semin --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 34 ++++++++++++----- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 38 ++++++++++++++----- drivers/net/ethernet/stmicro/stmmac/hwif.h | 6 +++ 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 1e50cc573407..99f0bbb318ec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -365,6 +365,26 @@ static void dwmac1000_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + LPI_TIMER_CTRL); } +static void dwmac1000_pcs_enable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask &= ~GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + +static void dwmac1000_pcs_disable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_mask; + + intr_mask = readl(ioaddr + GMAC_INT_MASK); + intr_mask |= GMAC_INT_DISABLE_PCS; + writel(intr_mask, ioaddr + GMAC_INT_MASK); +} + static u16 dwmac1000_pcs_get_config_reg(struct mac_device_info *hw) { void __iomem *ioaddr = hw->pcsr; @@ -395,12 +415,8 @@ static int dwmac1000_mii_pcs_validate(struct phylink_pcs *pcs, static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_mask; - intr_mask = readl(ioaddr + GMAC_INT_MASK); - intr_mask &= ~GMAC_INT_DISABLE_PCS; - writel(intr_mask, ioaddr + GMAC_INT_MASK); + dwmac1000_pcs_enable_irq(hw); return 0; } @@ -408,12 +424,8 @@ static int dwmac1000_mii_pcs_enable(struct phylink_pcs *pcs) static void dwmac1000_mii_pcs_disable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_mask; - intr_mask = readl(ioaddr + GMAC_INT_MASK); - intr_mask |= GMAC_INT_DISABLE_PCS; - writel(intr_mask, ioaddr + GMAC_INT_MASK); + dwmac1000_pcs_disable_irq(hw); } static int dwmac1000_mii_pcs_config(struct phylink_pcs *pcs, @@ -578,6 +590,8 @@ const struct stmmac_ops dwmac1000_ops = { .set_eee_timer = dwmac1000_set_eee_timer, .set_eee_pls = dwmac1000_set_eee_pls, .debug = dwmac1000_debug, + .pcs_enable_irq = dwmac1000_pcs_enable_irq, + .pcs_disable_irq = dwmac1000_pcs_disable_irq, .pcs_get_config_reg = dwmac1000_pcs_get_config_reg, .pcs_ctrl_ane = dwmac1000_ctrl_ane, .set_mac_loopback = dwmac1000_set_mac_loopback, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index b7db076b4214..5dc8d59d3a8f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -456,6 +456,26 @@ static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw) writel(value, ioaddr + GMAC4_LPI_TIMER_CTRL); } +static void dwmac4_pcs_enable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable |= GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); +} + +static void dwmac4_pcs_disable_irq(struct mac_device_info *hw) +{ + void __iomem *ioaddr = hw->pcsr; + u32 intr_enable; + + intr_enable = readl(ioaddr + GMAC_INT_EN); + intr_enable &= ~GMAC_PCS_IRQ_DEFAULT; + writel(intr_enable, ioaddr + GMAC_INT_EN); +} + static u16 dwmac4_pcs_get_config_reg(struct mac_device_info *hw) { void __iomem *ioaddr = hw->pcsr; @@ -780,12 +800,8 @@ static int dwmac4_mii_pcs_validate(struct phylink_pcs *pcs, static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_enable; - intr_enable = readl(ioaddr + GMAC_INT_EN); - intr_enable |= GMAC_PCS_IRQ_DEFAULT; - writel(intr_enable, ioaddr + GMAC_INT_EN); + dwmac4_pcs_enable_irq(hw); return 0; } @@ -793,12 +809,8 @@ static int dwmac4_mii_pcs_enable(struct phylink_pcs *pcs) static void dwmac4_mii_pcs_disable(struct phylink_pcs *pcs) { struct mac_device_info *hw = phylink_pcs_to_mac_dev_info(pcs); - void __iomem *ioaddr = hw->pcsr; - u32 intr_enable; - intr_enable = readl(ioaddr + GMAC_INT_EN); - intr_enable &= ~GMAC_PCS_IRQ_DEFAULT; - writel(intr_enable, ioaddr + GMAC_INT_EN); + dwmac4_pcs_disable_irq(hw); } static int dwmac4_mii_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, @@ -1284,6 +1296,8 @@ const struct stmmac_ops dwmac4_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .set_mac_loopback = dwmac4_set_mac_loopback, @@ -1329,6 +1343,8 @@ const struct stmmac_ops dwmac410_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .flex_pps_config = dwmac5_flex_pps_config, @@ -1378,6 +1394,8 @@ const struct stmmac_ops dwmac510_ops = { .set_eee_pls = dwmac4_set_eee_pls, .pcs_ctrl_ane = dwmac4_ctrl_ane, .debug = dwmac4_debug, + .pcs_enable_irq = dwmac4_pcs_enable_irq, + .pcs_disable_irq = dwmac4_pcs_disable_irq, .pcs_get_config_reg = dwmac4_pcs_get_config_reg, .set_filter = dwmac4_set_filter, .safety_feat_config = dwmac5_safety_feat_config, diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 00995a0c9813..2caa946a92f9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -376,6 +376,8 @@ struct stmmac_ops { struct stmmac_extra_stats *x, u32 rx_queues, u32 tx_queues); /* PCS calls */ + void (*pcs_enable_irq)(struct mac_device_info *hw); + void (*pcs_disable_irq)(struct mac_device_info *hw); u16 (*pcs_get_config_reg)(struct mac_device_info *hw); void (*pcs_ctrl_ane)(void __iomem *pcsaddr, bool ane, bool srgmi_ral, bool loopback); @@ -493,6 +495,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, set_eee_pls, __args) #define stmmac_mac_debug(__priv, __args...) \ stmmac_do_void_callback(__priv, mac, debug, __priv, __args) +#define stmmac_pcs_enable_irq(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, pcs_enable_irq, __args) +#define stmmac_pcs_disable_irq(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, pcs_disable_irq, __args) #define stmmac_pcs_get_config_reg(__priv, __args...) \ stmmac_do_callback(__priv, mac, pcs_get_config_reg, __args) #define stmmac_pcs_ctrl_ane(__priv, __args...) \