Commit 9865b881 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by David S. Miller

net: dsa: qca8k: convert to phylink_generic_validate()

Populate the supported interfaces and MAC capabilities for the QCA8K
DSA switch and remove the old validate implementation to allow DSA to
use phylink_generic_validate() for this switch driver.

In making this change, we bring consistency to the ethtool linkmodes
that phylink's validate step produces, thereby following the expected
behaviour as the phylink documentation has explained. Specifically, the
ethtool 1000baseX_Full capability is now permitted for all interface
modes, as it is a property of the PHY driver whether 1000baseX fiber
connections can be supported.
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 82fdbb91
...@@ -2031,67 +2031,39 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2031,67 +2031,39 @@ qca8k_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
} }
} }
static void static void qca8k_phylink_get_caps(struct dsa_switch *ds, int port,
qca8k_phylink_validate(struct dsa_switch *ds, int port, struct phylink_config *config)
unsigned long *supported,
struct phylink_link_state *state)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
switch (port) { switch (port) {
case 0: /* 1st CPU port */ case 0: /* 1st CPU port */
if (state->interface != PHY_INTERFACE_MODE_NA && phy_interface_set_rgmii(config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_RGMII && __set_bit(PHY_INTERFACE_MODE_SGMII,
state->interface != PHY_INTERFACE_MODE_RGMII_ID && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_RGMII_TXID &&
state->interface != PHY_INTERFACE_MODE_RGMII_RXID &&
state->interface != PHY_INTERFACE_MODE_SGMII)
goto unsupported;
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5: case 5:
/* Internal PHY */ /* Internal PHY */
if (state->interface != PHY_INTERFACE_MODE_NA && __set_bit(PHY_INTERFACE_MODE_GMII,
state->interface != PHY_INTERFACE_MODE_GMII && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_INTERNAL) __set_bit(PHY_INTERFACE_MODE_INTERNAL,
goto unsupported; config->supported_interfaces);
break; break;
case 6: /* 2nd CPU port / external PHY */ case 6: /* 2nd CPU port / external PHY */
if (state->interface != PHY_INTERFACE_MODE_NA && phy_interface_set_rgmii(config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_RGMII && __set_bit(PHY_INTERFACE_MODE_SGMII,
state->interface != PHY_INTERFACE_MODE_RGMII_ID && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_RGMII_TXID && __set_bit(PHY_INTERFACE_MODE_1000BASEX,
state->interface != PHY_INTERFACE_MODE_RGMII_RXID && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_SGMII &&
state->interface != PHY_INTERFACE_MODE_1000BASEX)
goto unsupported;
break; break;
default:
unsupported:
linkmode_zero(supported);
return;
} }
phylink_set_port_modes(mask); config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
phylink_set(mask, Autoneg); MAC_10 | MAC_100 | MAC_1000FD;
phylink_set(mask, 1000baseT_Full);
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 100baseT_Full);
if (state->interface == PHY_INTERFACE_MODE_1000BASEX)
phylink_set(mask, 1000baseX_Full);
phylink_set(mask, Pause);
phylink_set(mask, Asym_Pause);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
} }
static int static int
...@@ -3045,7 +3017,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = { ...@@ -3045,7 +3017,7 @@ static const struct dsa_switch_ops qca8k_switch_ops = {
.port_vlan_filtering = qca8k_port_vlan_filtering, .port_vlan_filtering = qca8k_port_vlan_filtering,
.port_vlan_add = qca8k_port_vlan_add, .port_vlan_add = qca8k_port_vlan_add,
.port_vlan_del = qca8k_port_vlan_del, .port_vlan_del = qca8k_port_vlan_del,
.phylink_validate = qca8k_phylink_validate, .phylink_get_caps = qca8k_phylink_get_caps,
.phylink_mac_link_state = qca8k_phylink_mac_link_state, .phylink_mac_link_state = qca8k_phylink_mac_link_state,
.phylink_mac_config = qca8k_phylink_mac_config, .phylink_mac_config = qca8k_phylink_mac_config,
.phylink_mac_link_down = qca8k_phylink_mac_link_down, .phylink_mac_link_down = qca8k_phylink_mac_link_down,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment