From patchwork Mon Jun 24 13:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13709522 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 CF0D5C2D0D1 for ; Mon, 24 Jun 2024 13:29:35 +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=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=Xd++MhLEIqxqx+UFhCSF73AGGz MmEm+bP8td9ETj2zIbQLli6cq6gJnSHKwn98w2O6+KZDPlk8DF0/vILsNC70fHZPlkWfWp0lxtJbP 0J6X9RslMF7BweWxuAXlffEUBFUgvOsDYli6K55kbPXyVGhA2laooG6I2RXRvjHDcaG4O2OapOz9J U98qKoYKUbdMg7f43nal854+3d0gzlxUPNLDadBvp3XFgggoac8gAKcLtHEGdC34rmtRs7AOfGNAO zwl9iG5/onMsvbQMM5z9tsc/Q0KCOl/9pWCCNTWyGGH89SAh16JSbC/I1GeP6OMlWCQlCDkQN50Sj GCp2pflA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjl2-0000000GvOL-2GXM; Mon, 24 Jun 2024 13:29:20 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sLjkV-0000000Gv4j-0W62 for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2024 13:28:48 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ec5779b423so19931921fa.0 for ; Mon, 24 Jun 2024 06:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719235725; x=1719840525; 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=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=H75DMK4g/Flp/Rjmmof8QiMicOxG/YZ1C9fNZezHdlR0YNf2vbX62qInW91SUHU22B CNtKG1jRuBE+i1ERx3hhSdYF7bkTjytouyeFFJK0OarysQgRqREnqcTD7IFaLsSSFoxs 4usLwiT1j+52mI0oDAx05bmnvCnQKBycoFgiSSX3VulxtiHb8PhZHrd7tV9FkHb4Hvcj ZGm9wQtmRI3oc0+pZRF7OGtmzqcjQV6wCB/gMG+WbyT+6/pzx/i7ZUHqd6+z6kh11JHG Z5Qq6V37wVuoJDUAaUmfccZyGj7W+gD6raGZ6/DnZm4YOfeCsqz8BrHez7D9hFj/BAO9 v/gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719235725; x=1719840525; 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=+SJ6K00RddygxsRAx5gvfJ+FOJjztoTh+Z/C1WD5C9E=; b=vuLZynyKgMBseDuxYa3/EX3GLqOE/buP5iyAPKEyIziuSb2+X8Og3nndxn90H/j9mA 6xC9JS+i4OhfwcEiiTIYl1GHsWol5uJJQV2ugcEDrSKlDAtv0gNwCGUtZa0WtyfgX3eh LkJpANzjAnJVdoL5/puiVhOTAyHQURBj1d73l9HALICib1yYt6J5mjZ7O4tRI2uXgwIT nhbFuj7QNmSW2F6yDJwWQVUqAAIdjlmEIn1wFAC6yjdBZLzUjYpbwGI3YyFpDdF5o6eI m6u/GMosf9O3Vi9sVrIGkLgS4NOY+qU0v7RoHwEqE6VGT3pr5CgdpCQ0cZNuI1s7rqt4 oOmQ== X-Forwarded-Encrypted: i=1; AJvYcCVpfJ1fhdsiqdYb4Ov9bGqQ4NSIUSqNxd0szlXuDmFEXesOm0bXcP8Wx0gnAMN0CJJdbJHZpKg496PaYipuyJ1A2JiwCzCwggf6bJVsddTATSAd2RA= X-Gm-Message-State: AOJu0Ywewqu0cKXprZaf30r+r93mPpH0zPkOUP/wgg8oVcFsw/51IABf WqmAs271xkFSRqx9NMj+kRrV5fghns1AgmleFORdf71/kKK5DQuU X-Google-Smtp-Source: AGHT+IH0GO4PBGc5Gd3PGuDIANu9HTgigG+8VkYo1wUOWDrul73npApHt9lg7dmWYbZTxCAcThzWtg== X-Received: by 2002:a2e:6a02:0:b0:2e1:2169:a5cc with SMTP id 38308e7fff4ca-2ec5931d8c3mr36751081fa.15.1719235724924; Mon, 24 Jun 2024 06:28:44 -0700 (PDT) Received: from localhost ([213.79.110.82]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d602703sm9729211fa.4.2024.06.24.06.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 06:28:44 -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 15/17] net: stmmac: Move internal PCS ISR to stmmac_pcs.c Date: Mon, 24 Jun 2024 16:26:32 +0300 Message-ID: <20240624132802.14238-7-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_062847_310612_91751C69 X-CRM114-Status: GOOD ( 17.44 ) 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 Similarly to the PHYLINK PCS ops, the STMMAC PCS ISR can be now fully implemented in the stmmac_pcs.c file. As before this change the resultant method will be called from the DW GMAC and DW QoS Eth core interrupt handlers. Signed-off-by: Serge Semin --- Note the AN Complete and Link state changes now cause the PHYLINK PCS state update. --- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 9 +---- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 9 +---- .../net/ethernet/stmicro/stmmac/stmmac_pcs.c | 33 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_pcs.h | 31 ++--------------- 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 332018ecd624..2d77ffd16f0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -296,14 +296,7 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); - - if (intr_status & PCS_RGSMIIIS_IRQ) { - /* TODO Dummy-read to clear the IRQ status */ - readl(ioaddr + GMAC_RGSMIIIS); - phylink_pcs_change(&hw->mac_pcs, false); - x->irq_rgmii_n++; - } + dwmac_pcs_isr(hw, intr_status, x); return ret; } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 1487f5cc5249..c58dc20eddeb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -860,14 +860,7 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } - dwmac_pcs_isr(hw->priv->pcsaddr, intr_status, x); - - if (intr_status & PCS_RGSMIIIS_IRQ) { - /* TODO Dummy-read to clear the IRQ status */ - readl(ioaddr + GMAC_PHYIF_CONTROL_STATUS); - phylink_pcs_change(&hw->mac_pcs, false); - x->irq_rgmii_n++; - } + dwmac_pcs_isr(hw, intr_status, x); return ret; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c index 24b95d1fdb64..aac49f6472f0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c @@ -134,3 +134,36 @@ const struct phylink_pcs_ops dwmac_pcs_ops = { .pcs_get_state = dwmac_pcs_get_state, }; + +void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, + struct stmmac_extra_stats *x) +{ + struct stmmac_priv *priv = hw->priv; + bool an_status = false, sr_status = false; + + if (intr_status & PCS_ANE_IRQ) { + x->irq_pcs_ane_n++; + an_status = true; + } + + if (intr_status & PCS_LINK_IRQ) { + x->irq_pcs_link_n++; + an_status = true; + } + + if (intr_status & PCS_RGSMIIIS_IRQ) { + x->irq_rgmii_n++; + sr_status = true; + } + + /* Read the AN and SGMII/RGMII/SMII status regs to clear IRQ */ + if (an_status) + readl(priv->pcsaddr + PCS_AN_STATUS); + + if (sr_status) + readl(priv->pcsaddr + PCS_SRGMII_CSR); + + /* Any PCS event shall trigger the PHYLINK PCS state update */ + if (an_status || sr_status) + phylink_pcs_change(&hw->mac_pcs, false); +} diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h index 2baebb92bea7..6e364285a4ef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.h @@ -23,6 +23,7 @@ #define PCS_ANE_LPA 0x0c /* ANE link partener ability */ #define PCS_ANE_EXP 0x10 /* ANE expansion */ #define PCS_TBI_EXT 0x14 /* TBI extended status */ +#define PCS_SRGMII_CSR 0x18 /* SGMII/RGMII/SMII CSR */ /* AN Configuration defines */ #define PCS_AN_CTRL_RAN BIT(9) /* Restart Auto-Negotiation */ @@ -57,33 +58,7 @@ #define PCS_CFG_JABTO BIT(4) /* Jabber Timeout (SMII only) */ #define PCS_CFG_FALSCARDET BIT(5) /* False Carrier (SMII only) */ -/** - * dwmac_pcs_isr - TBI, RTBI, or SGMII PHY ISR - * @ioaddr: IO registers pointer - * @intr_status: GMAC core interrupt status - * @x: pointer to log these events as stats - * Description: it is the ISR for PCS events: Auto-Negotiation Completed and - * Link status. - */ -static inline void dwmac_pcs_isr(void __iomem *pcsaddr, - unsigned int intr_status, - struct stmmac_extra_stats *x) -{ - u32 val = readl(pcsaddr + PCS_AN_STATUS); - - if (intr_status & PCS_ANE_IRQ) { - x->irq_pcs_ane_n++; - if (val & PCS_AN_STATUS_ANC) - pr_info("stmmac_pcs: ANE process completed\n"); - } - - if (intr_status & PCS_LINK_IRQ) { - x->irq_pcs_link_n++; - if (val & PCS_AN_STATUS_LS) - pr_info("stmmac_pcs: Link Up\n"); - else - pr_info("stmmac_pcs: Link Down\n"); - } -} +void dwmac_pcs_isr(struct mac_device_info *hw, unsigned int intr_status, + struct stmmac_extra_stats *x); #endif /* __STMMAC_PCS_H__ */