From patchwork Fri Jan 27 01:48:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118059 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4E19C61DA7 for ; Fri, 27 Jan 2023 01:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232495AbjA0BsU (ORCPT ); Thu, 26 Jan 2023 20:48:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbjA0BsS (ORCPT ); Thu, 26 Jan 2023 20:48:18 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14727524D; Thu, 26 Jan 2023 17:48:16 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,249,1669042800"; d="scan'208";a="147581401" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 27 Jan 2023 10:48:16 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 6865A415F67A; Fri, 27 Jan 2023 10:48:16 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v3 1/4] net: phylink: Set host_interfaces for a non-sfp PHY Date: Fri, 27 Jan 2023 10:48:09 +0900 Message-Id: <20230127014812.1656340-2-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If a new flag (ovr_host_interfaces) in the phylink_config is set, overwrite the host_interfaces in the phy_device by link_interface. Note that an ethernet PHY driver like marvell10g will check PHY_INTERFACE_MODE_SGMII in the host_interfaces whther the host controller supports a rate matching interface mode or not. So, set PHY_INTERFACE_MODE_SGMII to the host_interfaces if it is set in the supported_interfaces. Signed-off-by: Yoshihiro Shimoda --- drivers/net/phy/phylink.c | 11 +++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 319790221d7f..dee64b4a1175 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1814,6 +1814,17 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_config.interface = pl->link_interface; } + if (pl->config->ovr_host_interfaces) { + __set_bit(pl->link_interface, phy_dev->host_interfaces); + + /* An ethernet PHY driver will check PHY_INTERFACE_MODE_SGMII + * in the host_interfaces whether the host controller supports + * a rate matching interface mode or not. + */ + if (test_bit(PHY_INTERFACE_MODE_SGMII, pl->config->supported_interfaces)) + __set_bit(PHY_INTERFACE_MODE_SGMII, phy_dev->host_interfaces); + } + ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); if (ret) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..c8dd53b1e857 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -124,6 +124,8 @@ enum phylink_op_type { * if MAC link is at %MLO_AN_FIXED mode. * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM. * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND + * @ovr_host_interfaces: if true, override host_interfaces of phy_device from + * link_interface. * @get_fixed_state: callback to execute to determine the fixed link state, * if MAC link is at %MLO_AN_FIXED mode. * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx @@ -137,6 +139,7 @@ struct phylink_config { bool poll_fixed_state; bool mac_managed_pm; bool ovr_an_inband; + bool ovr_host_interfaces; void (*get_fixed_state)(struct phylink_config *config, struct phylink_link_state *state); DECLARE_PHY_INTERFACE_MASK(supported_interfaces); From patchwork Fri Jan 27 01:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118061 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C61F0C61DA7 for ; Fri, 27 Jan 2023 01:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232545AbjA0BsV (ORCPT ); Thu, 26 Jan 2023 20:48:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232076AbjA0BsT (ORCPT ); Thu, 26 Jan 2023 20:48:19 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 371EE22A0C; Thu, 26 Jan 2023 17:48:18 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,249,1669042800"; d="scan'208";a="150707073" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 27 Jan 2023 10:48:16 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 81C3D415F68D; Fri, 27 Jan 2023 10:48:16 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v3 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling Date: Fri, 27 Jan 2023 10:48:10 +0900 Message-Id: <20230127014812.1656340-3-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Simplify struct phy *serdes handling by keeping the valiable in the struct rswitch_device. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 40 ++++++++++++-------------- drivers/net/ethernet/renesas/rswitch.h | 1 + 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 14fc0af304ce..b0c1ea72772e 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1222,49 +1222,40 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev) phylink_destroy(rdev->phylink); } -static int rswitch_serdes_set_params(struct rswitch_device *rdev) +static int rswitch_serdes_phy_get(struct rswitch_device *rdev) { struct device_node *port = rswitch_get_port_node(rdev); struct phy *serdes; - int err; serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); of_node_put(port); if (IS_ERR(serdes)) return PTR_ERR(serdes); + rdev->serdes = serdes; + + return 0; +} + +static int rswitch_serdes_set_params(struct rswitch_device *rdev) +{ + int err; - err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET, + err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET, rdev->etha->phy_interface); if (err < 0) return err; - return phy_set_speed(serdes, rdev->etha->speed); + return phy_set_speed(rdev->serdes, rdev->etha->speed); } static int rswitch_serdes_init(struct rswitch_device *rdev) { - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_init(serdes); + return phy_init(rdev->serdes); } static int rswitch_serdes_deinit(struct rswitch_device *rdev) { - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_exit(serdes); + return phy_exit(rdev->serdes); } static int rswitch_ether_port_init_one(struct rswitch_device *rdev) @@ -1286,6 +1277,10 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) if (err < 0) goto err_phylink_init; + err = rswitch_serdes_phy_get(rdev); + if (err < 0) + goto err_serdes_phy_get; + err = rswitch_serdes_set_params(rdev); if (err < 0) goto err_serdes_set_params; @@ -1293,6 +1288,7 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) return 0; err_serdes_set_params: +err_serdes_phy_get: rswitch_phylink_deinit(rdev); err_phylink_init: diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h index 49efb0f31c77..c79b1bdd8072 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -953,6 +953,7 @@ struct rswitch_device { int port; struct rswitch_etha *etha; + struct phy *serdes; }; struct rswitch_mfwd_mac_table_entry { From patchwork Fri Jan 27 01:48:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118062 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D36E6C05027 for ; Fri, 27 Jan 2023 01:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232689AbjA0BsY (ORCPT ); Thu, 26 Jan 2023 20:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231800AbjA0BsT (ORCPT ); Thu, 26 Jan 2023 20:48:19 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80582233C7; Thu, 26 Jan 2023 17:48:18 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,249,1669042800"; d="scan'208";a="147581404" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 27 Jan 2023 10:48:16 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 9AA5D415F68E; Fri, 27 Jan 2023 10:48:16 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v3 3/4] net: ethernet: renesas: rswitch: Enable ovr_host_interfaces Date: Fri, 27 Jan 2023 10:48:11 +0900 Message-Id: <20230127014812.1656340-4-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable ovr_host_interfaces to set the host_interfaces of phy_dev for a non-sfp PHY. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index b0c1ea72772e..df8bc150f596 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1195,6 +1195,7 @@ static int rswitch_phylink_init(struct rswitch_device *rdev) rdev->phylink_config.dev = &rdev->ndev->dev; rdev->phylink_config.type = PHYLINK_NETDEV; + rdev->phylink_config.ovr_host_interfaces = true; __set_bit(PHY_INTERFACE_MODE_SGMII, rdev->phylink_config.supported_interfaces); __set_bit(PHY_INTERFACE_MODE_USXGMII, rdev->phylink_config.supported_interfaces); rdev->phylink_config.mac_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD; From patchwork Fri Jan 27 01:48:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118063 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E0C8C54EAA for ; Fri, 27 Jan 2023 01:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232799AbjA0Bs0 (ORCPT ); Thu, 26 Jan 2023 20:48:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjA0BsT (ORCPT ); Thu, 26 Jan 2023 20:48:19 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85FE52367D; Thu, 26 Jan 2023 17:48:18 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,249,1669042800"; d="scan'208";a="150707077" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 27 Jan 2023 10:48:16 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id BCC55415F67A; Fri, 27 Jan 2023 10:48:16 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v3 4/4] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Date: Fri, 27 Jan 2023 10:48:12 +0900 Message-Id: <20230127014812.1656340-5-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127014812.1656340-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some Ethernet PHYs (like marvell10g) will decide the host interface mode by the media-side speed. So, the rswitch driver needs to initialize one of the Ethernet SERDES (r8a779f0-eth-serdes) ports after linked the Ethernet PHY up. The r8a779f0-eth-serdes driver has .init() for initializing all ports and .power_on() for initializing each port. So, add phy_power_{on,off} calling for it. Notes that in-band mode will not work because the initialization is not completed. So, output error message if in-band mode. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index df8bc150f596..b4906e9eb50d 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1161,12 +1161,20 @@ static void rswitch_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { + struct net_device *ndev = to_net_dev(config->dev); + + if (mode == MLO_AN_INBAND) + netdev_err(ndev, "Link up/down will not work because in-band mode\n"); } static void rswitch_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + + phy_power_off(rdev->serdes); } static void rswitch_mac_link_up(struct phylink_config *config, @@ -1174,7 +1182,11 @@ static void rswitch_mac_link_up(struct phylink_config *config, phy_interface_t interface, int speed, int duplex, bool tx_pause, bool rx_pause) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + /* Current hardware cannot change speed at runtime */ + phy_power_on(rdev->serdes); } static const struct phylink_mac_ops rswitch_phylink_ops = {