From patchwork Fri Jun 11 20:05:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12316565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4E3FC48BE5 for ; Fri, 11 Jun 2021 20:51:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 802D3613D9 for ; Fri, 11 Jun 2021 20:51:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 802D3613D9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YBbecfjcyrPn9fcxhTHg8Nun3Gg6wNfzL/oMnmahddg=; b=MO5dKmx0JAkd7X U/jQaUQDtb8X4N39hys9z5FZuH/6M6MFVfcSwLhGsdlsAG/y4gEQGHvXa394cDenpWujL9oO+2BCV I2XqsjETuCTFTK5qNhrXtG9JeHOl4NC59RLChP4jTqGuYpS93bTSCQtfZBiiIxjm+CgHeSpwNdKv5 w7mlfu/ffbXaTfgh5DG1Gy20dV4qag9o0MIYMVtcmFAsdUbjdv67G/Mkna2/SsXY+nypN77EV4Nsz QGin0r4yMhZFHSwo8D66SWAYmyrCr1q8T7PymOjY7W0MixTqUtwnqgZkjCFf1DMdiIfO3dZzam9aQ P0WrGEsv0+pta5/nTodA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lro5I-0070Jw-DS; Fri, 11 Jun 2021 20:48:58 +0000 Received: from mail-ed1-f52.google.com ([209.85.208.52]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrnQj-006p0W-NR for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 20:07:03 +0000 Received: by mail-ed1-f52.google.com with SMTP id dj8so38459156edb.6 for ; Fri, 11 Jun 2021 13:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9J82lfUtfOhld0+zQlTxDsuWpTNh0bxTBpmDmOlV2PA=; b=Alta6xDeTN7DRmmYxXL3IQ/X8sdytpS/n+GrYjjCG+93ybbRgoiTbtUlTuwrejXkS3 37KscVpgba9Ajo8v4+ukFvsZdgCV3Eis4Y8B2w5+VmiMXmZSBqKI9yPFFwf6B3oaCvb0 3XD+BX8twxmcSQJsUYyiRU+SvtCuan0UyDTDNXa0B/ASWbIOsHWj7WKXT0EZSUZKwZmx SVp8EzuSGVTqS4NY+MMh6HXNZEDfePGudBMp55S89oUIJHkuW0RfXCYZ8dsBNKJKJAVh Wx6dfaNXWSt91P3JjBsFl+UbfBuuy7yvPpt5gOWoAHBzCq4zRxb/RGNMCMWOO5grSWhb +hNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9J82lfUtfOhld0+zQlTxDsuWpTNh0bxTBpmDmOlV2PA=; b=XSsDQj0i/etBn7M2DRdhgC/19N0msLPTFL30RpSYfM4vpj/7VtXTTn/AYLSrrwDvx6 s8uA/B0t4uOWywinyRT5Wsq4bDcDnr72EhbtB83nTOKyXXQuP84FvYLr+nu6aXnfUcZb yDdUILEHodAl2rBX/XY3nhSzSZNdpKc3cQ8bwHda0inIEJs8Hy9FhlLNFFW86LRCYkJd nq73/xZwkZGrnxpAG3VoYhS6nADvJQZ6ED0icQQamomh3noI0FiUTf3ZMxZPR0UWdaVy lzGwgCOdXFQr0n2IOTI1NDNf2EAhQSNntVzwakC3IQ+H5pUaT5LBoPwZRzrYY64G9EPG I49A== X-Gm-Message-State: AOAM533SHNudFOxLnTO1jwrnN++MKsZg0Q7W93k5UcKVI7wQSJRdLsMW HPnPIyOEU8/ywx7Zrh6pwTgGPDDsiQQ= X-Google-Smtp-Source: ABdhPJxNlEpITTIafXz9TBGJwWkEwcqI6EwN3AZjuzC31TaR/L75yoR1cwbJcMlwbIx7aX9G5kR7UQ== X-Received: by 2002:a50:ec08:: with SMTP id g8mr5549553edr.376.1623441959700; Fri, 11 Jun 2021 13:05:59 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id w2sm2392084ejn.118.2021.06.11.13.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:05:59 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Vladimir Oltean Subject: [PATCH v3 net-next 09/13] net: pcs: xpcs: export xpcs_do_config and xpcs_link_up Date: Fri, 11 Jun 2021 23:05:27 +0300 Message-Id: <20210611200531.2384819-10-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210611200531.2384819-1-olteanv@gmail.com> References: <20210611200531.2384819-1-olteanv@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210611_130701_843956_C26DB7E8 X-CRM114-Status: GOOD ( 18.98 ) 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 From: Vladimir Oltean The sja1105 hardware has a quirk in that some changes require a switch reset, which loses all configuration. When the reset is initiated, everything needs to be reprogrammed, including the MACs and the PCS. This is currently done in sja1105_static_config_reload() - we manually call sja1105_adjust_port_config(), sja1105_sgmii_pcs_config() and sja1105_sgmii_pcs_force_speed() which are all internal functions. There is a desire for sja1105 to use the common xpcs driver, and that means that the equivalents of those functions, xpcs_do_config() and xpcs_link_up() respectively, will no longer be local functions. Forcing phylink to retrigger a resolve somehow, say by doing dev_close() followed by dev_open() is not really an option, because the CPU port might have a PCS as well, and there is no net device which we can close and reopen for that. Additionally, the dev_close/dev_open sequence might force a renegotiation of the copper-side link for SGMII ports connected to a PHY, and this is undesirable as well, because the switch reset is much quicker than a PHY autoneg, so we would have a lot more downtime. The only solution I see is for the sja1105 driver to keep doing what it's doing, and that means we need to export the equivalents from xpcs for sja1105_sgmii_pcs_config and sja1105_sgmii_pcs_force_speed, and call them directly in sja1105_static_config_reload(). This will be done during the conversion patch. Signed-off-by: Vladimir Oltean --- v2->v3: none v1->v2: none drivers/net/pcs/pcs-xpcs.c | 10 ++++++---- include/linux/pcs/pcs-xpcs.h | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index b66e46fc88dc..63fda3fc40aa 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -757,8 +757,8 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs) return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret); } -static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, - unsigned int mode) +int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, + unsigned int mode) { const struct xpcs_compat *compat; int ret; @@ -797,6 +797,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, return 0; } +EXPORT_SYMBOL_GPL(xpcs_do_config); static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, @@ -945,8 +946,8 @@ static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode, pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); } -static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, - phy_interface_t interface, int speed, int duplex) +void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); @@ -955,6 +956,7 @@ static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, if (interface == PHY_INTERFACE_MODE_SGMII) return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); } +EXPORT_SYMBOL_GPL(xpcs_link_up); static u32 xpcs_get_id(struct dw_xpcs *xpcs) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index dae7dd8ac683..add077a81b21 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -27,6 +27,10 @@ struct dw_xpcs { }; int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); +void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex); +int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, + unsigned int mode); void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns,