Skip to content

Commit

Permalink
net: dsa: populate supported_interfaces member
Browse files Browse the repository at this point in the history
Add a new DSA switch operation, phylink_get_interfaces, which should
fill in which PHY_INTERFACE_MODE_* are supported by given port.

Use this before phylink_create() to fill phylinks supported_interfaces
member, allowing phylink to determine which PHY_INTERFACE_MODEs are
supported.

Signed-off-by: Marek Behún <kabel@kernel.org>
[tweaked patch and description to add more complete support -- rmk]
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Marek Behún authored and David S. Miller committed Nov 1, 2021
1 parent ebed1cf commit c07c6e8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/net/dsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ struct dsa_switch_ops {
/*
* PHYLINK integration
*/
void (*phylink_get_interfaces)(struct dsa_switch *ds, int port,
unsigned long *supported_interfaces);
void (*phylink_validate)(struct dsa_switch *ds, int port,
unsigned long *supported,
struct phylink_link_state *state);
Expand Down
4 changes: 4 additions & 0 deletions net/dsa/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,10 @@ static int dsa_port_phylink_register(struct dsa_port *dp)
dp->pl_config.type = PHYLINK_DEV;
dp->pl_config.pcs_poll = ds->pcs_poll;

if (ds->ops->phylink_get_interfaces)
ds->ops->phylink_get_interfaces(ds, dp->index,
dp->pl_config.supported_interfaces);

dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn),
mode, &dsa_port_phylink_mac_ops);
if (IS_ERR(dp->pl)) {
Expand Down
4 changes: 4 additions & 0 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,10 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
dp->pl_config.poll_fixed_state = true;
}

if (ds->ops->phylink_get_interfaces)
ds->ops->phylink_get_interfaces(ds, dp->index,
dp->pl_config.supported_interfaces);

dp->pl = phylink_create(&dp->pl_config, of_fwnode_handle(port_dn), mode,
&dsa_port_phylink_mac_ops);
if (IS_ERR(dp->pl)) {
Expand Down

0 comments on commit c07c6e8

Please sign in to comment.