netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-phy@lists.infradead.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Kishon Vijay Abraham I <kishon@kernel.org>,
	Vinod Koul <vkoul@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	UNGLinuxDriver@microchip.com,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Lee Jones <lee@kernel.org>
Subject: Re: [RFC v1 net-next 7/7] net: dsa: ocelot_ext: add support for external phys
Date: Thu, 16 Feb 2023 11:17:48 +0000	[thread overview]
Message-ID: <Y+4Q3PDlj+lVQAPx@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230216075321.2898003-8-colin.foster@in-advantage.com>

Hi Colin,

On Wed, Feb 15, 2023 at 11:53:21PM -0800, Colin Foster wrote:
> +static const struct phylink_mac_ops ocelot_ext_phylink_ops = {
> +	.validate		= phylink_generic_validate,

There is no need to set this anymore.

> +	.mac_config		= ocelot_ext_phylink_mac_config,
> +	.mac_link_down		= ocelot_ext_phylink_mac_link_down,
> +	.mac_link_up		= ocelot_ext_phylink_mac_link_up,
> +};
> +
> +static void ocelot_ext_pcs_get_state(struct phylink_pcs *pcs,
> +				     struct phylink_link_state *state)
> +{
> +	struct ocelot_ext_port_priv *port_priv =
> +		phylink_pcs_to_ocelot_port(pcs);
> +
> +	/* TODO: Determine state from hardware? */
> +}
> +
> +static int ocelot_ext_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
> +				 phy_interface_t interface,
> +				 const unsigned long *advertising,
> +				 bool permit_pause_to_mac)
> +{
> +	struct ocelot_ext_port_priv *port_priv =
> +		phylink_pcs_to_ocelot_port(pcs);
> +
> +	switch (interface) {
> +	case PHY_INTERFACE_MODE_QSGMII:
> +		ocelot_ext_phylink_mac_config(&port_priv->phylink_config, mode,
> +					      NULL);

Why are you calling a "mac" operation from a "pcs" operation? If this
PCS is attached to the same phylink instance as the MAC, you'll get
the .mac_config method called along with the .pcs_config, so calling
one from the other really isn't necessary.

> +		break;
> +	default:
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
> +static void ocelot_ext_pcs_an_restart(struct phylink_pcs *pcs)
> +{
> +	/* TODO: Restart autonegotiaion process */
> +}
> +
> +static void ocelot_ext_pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
> +				   phy_interface_t interface, int speed,
> +				   int duplex)
> +{
> +	struct ocelot_ext_port_priv *port_priv =
> +		phylink_pcs_to_ocelot_port(pcs);
> +
> +	ocelot_ext_phylink_mac_link_up(&port_priv->phylink_config, NULL, mode,
> +				       interface, speed, duplex, false, false);

Same here... and I fail to see why any of these need to be implemented
or what the purpose of providing this pcs code is.

> +}
> +
> +static const struct phylink_pcs_ops ocelot_ext_pcs_ops = {
> +	.pcs_get_state = ocelot_ext_pcs_get_state,
> +	.pcs_config = ocelot_ext_pcs_config,
> +	.pcs_an_restart = ocelot_ext_pcs_an_restart,
> +	.pcs_link_up = ocelot_ext_pcs_link_up,
>  };
>  
> +static int ocelot_ext_parse_port_node(struct ocelot *ocelot,
> +				      struct device_node *ports_node,
> +				      phy_interface_t phy_mode, int port)
> +{
> +	struct ocelot_ext_port_priv *ocelot_ext_port_priv;
> +	struct felix *felix = ocelot_to_felix(ocelot);
> +	struct ocelot_ext_priv *ocelot_ext_priv;
> +
> +	ocelot_ext_priv = felix_to_ocelot_ext_priv(felix);
> +
> +	ocelot_ext_port_priv = devm_kzalloc(ocelot->dev,
> +					    sizeof(*ocelot_ext_port_priv),
> +					    GFP_KERNEL);
> +	if (!ocelot_ext_port_priv)
> +		return -ENOMEM;
> +
> +	ocelot_ext_port_priv->ocelot = ocelot;
> +	ocelot_ext_port_priv->chip_port = port;
> +	ocelot_ext_port_priv->pcs.ops = &ocelot_ext_pcs_ops;
> +
> +	if (!felix->pcs)
> +		felix->pcs = devm_kcalloc(ocelot->dev, felix->info->num_ports,
> +					  sizeof(struct phylink_pcs *),
> +					  GFP_KERNEL);
> +
> +	if (!felix->pcs)
> +		return -ENOMEM;
> +
> +	felix->pcs[port] = &ocelot_ext_port_priv->pcs;
> +
> +	ocelot_ext_priv->port_priv[port] = ocelot_ext_port_priv;
> +
> +	ocelot_ext_port_priv->node = of_node_get(ports_node);
> +
> +	return 0;
> +}
> +
> +static int ocelot_ext_phylink_create(struct ocelot *ocelot, int port)
> +{
> +	struct ocelot_ext_port_priv *ocelot_ext_port_priv;
> +	struct felix *felix = ocelot_to_felix(ocelot);
> +	struct ocelot_ext_priv *ocelot_ext_priv;
> +	struct device *dev = ocelot->dev;
> +	struct ocelot_port *ocelot_port;
> +	struct device_node *portnp;
> +	phy_interface_t phy_mode;
> +	struct phylink *phylink;
> +	int err;
> +
> +	ocelot_ext_priv = felix_to_ocelot_ext_priv(felix);
> +	ocelot_port = ocelot->ports[port];
> +	ocelot_ext_port_priv = ocelot_ext_priv->port_priv[port];
> +
> +	if (!ocelot_ext_port_priv)
> +		return 0;
> +
> +	portnp = ocelot_ext_port_priv->node;
> +	phy_mode = ocelot_port->phy_mode;
> +
> +	/* Break out early if we're internal...? */
> +	if (phy_mode == PHY_INTERFACE_MODE_INTERNAL)
> +		return 0;
> +
> +	if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
> +		ocelot_port_rmwl(ocelot_port, 0,
> +				 DEV_CLOCK_CFG_MAC_TX_RST |
> +				 DEV_CLOCK_CFG_MAC_RX_RST,
> +				 DEV_CLOCK_CFG);
> +
> +	if (phy_mode != PHY_INTERFACE_MODE_INTERNAL) {
> +		struct phy *serdes = of_phy_get(portnp, NULL);
> +
> +		if (IS_ERR(serdes)) {
> +			err = PTR_ERR(serdes);
> +			dev_err_probe(dev, err,
> +				      "missing SerDes phys for port %d\n",
> +				      port);
> +			return err;
> +		}
> +
> +		err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET, phy_mode);
> +		of_phy_put(serdes);
> +		if (err) {
> +			dev_err(dev,
> +				"Could not set SerDes mode on port %d: %pe\n",
> +				port, ERR_PTR(err));
> +			return err;
> +		}
> +	}
> +
> +	ocelot_ext_port_priv->phylink_config.dev = dev;
> +	ocelot_ext_port_priv->phylink_config.type = PHYLINK_DEV;
> +	ocelot_ext_port_priv->phylink_config.mac_capabilities = MAC_ASYM_PAUSE |
> +		MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000FD | MAC_2500FD;
> +
> +	__set_bit(ocelot_port->phy_mode,
> +		  ocelot_ext_port_priv->phylink_config.supported_interfaces);
> +
> +	phylink = phylink_create(&ocelot_ext_port_priv->phylink_config,
> +				 of_fwnode_handle(portnp),
> +				 phy_mode, &ocelot_ext_phylink_ops);

I'm confused. DSA already sets up a phylink instance per port, so why
do you need another one?

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-02-16 11:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16  7:53 [RFC v1 net-next 0/7] add support for ocelot external ports Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 1/7] phy: phy-ocelot-serdes: add ability to be used in a non-syscon configuration Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 2/7] mfd: ocelot: add ocelot-serdes capability Colin Foster
2023-03-03 10:48   ` Lee Jones
2023-03-03 15:12     ` Colin Foster
2023-03-03 21:57       ` Lee Jones
2023-02-16  7:53 ` [RFC v1 net-next 3/7] net: mscc: ocelot: expose ocelot_pll5_init routine Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 4/7] net: mscc: ocelot: expose generic phylink_mac_config routine Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 5/7] net: dsa: felix: attempt to initialize internal hsio plls Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 6/7] net: dsa: felix: allow external parsing of port nodes Colin Foster
2023-02-16  7:53 ` [RFC v1 net-next 7/7] net: dsa: ocelot_ext: add support for external phys Colin Foster
2023-02-16 11:17   ` Russell King (Oracle) [this message]
2023-02-17  1:31     ` Colin Foster
2023-02-16 12:14 ` [RFC v1 net-next 0/7] add support for ocelot external ports Russell King (Oracle)
2023-02-17  0:42   ` Colin Foster
2023-02-17  1:11     ` Vladimir Oltean
2023-02-17  7:02       ` Colin Foster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+4Q3PDlj+lVQAPx@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kishon@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vkoul@kernel.org \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).