Re: [RFC v8 net-next 15/16] net: dsa: felix: add phylink_get_caps capability
From: Colin Foster <colin.foster@in-advantage.com>
Date: 2022-09-09 18:35:44
Also in:
linux-arm-kernel
On Mon, May 09, 2022 at 05:58:07PM +0000, Vladimir Oltean wrote:
On Mon, May 09, 2022 at 05:55:37PM -0700, Colin Foster wrote:quoted
Hmm... So the main reason I needed get_caps was because phylink_generic_validate looks at mac_capabilities. I know I'll have to deal with supported_interfaces once I finally get the other four ports working, but for now the main purpose of this patch is to allow me to populate the mac_capabilities entry for phylink_generic_validate. Aside from ensuring legacy_pre_march2020 = false, I feel like the rest of the patch makes sense.But still. Just populate mac_capabilities for everybody in the common felix_phylink_get_caps(), and use the generic phylink validation only for your driver.
Resurrecting this thread, now that I'm back into the networking stuff. I removed some people from the CC chain who I think were MFD / GPIO specific. v1 of my upcoming "add dsa capabilities to the vsc7512" will build off these suggestions, but these DSA patches were dropped in the MFD set. Restoring context: my oritinal patch was:
+++ b/drivers/net/dsa/ocelot/felix.c@@ -982,15 +982,23 @@ static void felix_phylink_get_caps(struct dsa_switch *ds, int port, struct phylink_config *config) { struct ocelot *ocelot = ds->priv; + struct felix *felix; - /* This driver does not make use of the speed, duplex, pause or the - * advertisement in its mac_config, so it is safe to mark this driver - * as non-legacy. - */ - config->legacy_pre_march2020 = false; + felix = ocelot_to_felix(ocelot); + + if (felix->info->phylink_get_caps) { + felix->info->phylink_get_caps(ocelot, port, config); + } else { - __set_bit(ocelot->ports[port]->phy_mode, - config->supported_interfaces); + /* This driver does not make use of the speed, duplex, pause or + * the advertisement in its mac_config, so it is safe to mark + * this driver as non-legacy. + */ + config->legacy_pre_march2020 = false; + + __set_bit(ocelot->ports[port]->phy_mode, + config->supported_interfaces); + } }
Regarding felix_phylink_get_caps() - does it make sense that
mac_capabilities would be the same for all ports? This is where I've
currently landed, and I want to make sure it doesn't have adverse
effects on vsc9959 or seville:
static void felix_phylink_get_caps(struct dsa_switch *ds, int port,
struct phylink_config *config)
{
struct ocelot *ocelot = ds->priv;
struct felix *felix;
u32 modes;
int i;
felix = ocelot_to_felix(ocelot);
modes = felix->info->port_modes[port];
/* This driver does not make use of the speed, duplex, pause or
* the advertisement in its mac_config, so it is safe to mark
* this driver as non-legacy.
*/
config->legacy_pre_march2020 = false;
for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
if (modes & felix_phy_match_table[i])
__set_bit(i, config->supported_interfaces);
config->mac_capabilities = MAC_SYM_PAUSE | MAC_ASYM_PAUSE | MAC_10 |
MAC_100 | MAC_1000FD;
}
(this might be two patches - one for the match table and one for the
mac_capabilities)
Seemingly because net/dsa/port.c checks for phylink_validate before it
checks for mac_capabilties, it won't make a difference there, but this
seems ... wrong? Or maybe it isn't wrong until I implement the QSGMII
port that supports 2500FD (as in drivers/net/ethernet/mscc/ocelot_net.c
ocelot_port_phylink_create())