Commit 33f7a32d authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-phylink_generic_validate'

Russell King says:

====================
Trivial DSA conversions to phylink_generic_validate()

This series converts five DSA drivers to use phylink_generic_validate().
No feedback or testing reports were received from the CFT posting.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 83a18b8e 1f8d99de
...@@ -709,49 +709,25 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port) ...@@ -709,49 +709,25 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port)
PHY_BRCM_IDDQ_SUSPEND; PHY_BRCM_IDDQ_SUSPEND;
} }
static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port, static void bcm_sf2_sw_get_caps(struct dsa_switch *ds, int port,
unsigned long *supported, struct phylink_config *config)
struct phylink_link_state *state)
{ {
unsigned long *interfaces = config->supported_interfaces;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
if (!phy_interface_mode_is_rgmii(state->interface) &&
state->interface != PHY_INTERFACE_MODE_MII &&
state->interface != PHY_INTERFACE_MODE_REVMII &&
state->interface != PHY_INTERFACE_MODE_GMII &&
state->interface != PHY_INTERFACE_MODE_INTERNAL &&
state->interface != PHY_INTERFACE_MODE_MOCA) {
linkmode_zero(supported);
if (port != core_readl(priv, CORE_IMP0_PRT_ID))
dev_err(ds->dev,
"Unsupported interface: %d for port %d\n",
state->interface, port);
return;
}
/* Allow all the expected bits */
phylink_set(mask, Autoneg);
phylink_set_port_modes(mask);
phylink_set(mask, Pause);
phylink_set(mask, Asym_Pause);
/* With the exclusion of MII and Reverse MII, we support Gigabit, if (priv->int_phy_mask & BIT(port)) {
* including Half duplex __set_bit(PHY_INTERFACE_MODE_INTERNAL, interfaces);
*/ } else if (priv->moca_port == port) {
if (state->interface != PHY_INTERFACE_MODE_MII && __set_bit(PHY_INTERFACE_MODE_MOCA, interfaces);
state->interface != PHY_INTERFACE_MODE_REVMII) { } else {
phylink_set(mask, 1000baseT_Full); __set_bit(PHY_INTERFACE_MODE_MII, interfaces);
phylink_set(mask, 1000baseT_Half); __set_bit(PHY_INTERFACE_MODE_REVMII, interfaces);
__set_bit(PHY_INTERFACE_MODE_GMII, interfaces);
phy_interface_set_rgmii(interfaces);
} }
phylink_set(mask, 10baseT_Half); config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
phylink_set(mask, 10baseT_Full); MAC_10 | MAC_100 | MAC_1000;
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 100baseT_Full);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
} }
static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port, static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
...@@ -1218,7 +1194,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = { ...@@ -1218,7 +1194,7 @@ static const struct dsa_switch_ops bcm_sf2_ops = {
.get_sset_count = bcm_sf2_sw_get_sset_count, .get_sset_count = bcm_sf2_sw_get_sset_count,
.get_ethtool_phy_stats = b53_get_ethtool_phy_stats, .get_ethtool_phy_stats = b53_get_ethtool_phy_stats,
.get_phy_flags = bcm_sf2_sw_get_phy_flags, .get_phy_flags = bcm_sf2_sw_get_phy_flags,
.phylink_validate = bcm_sf2_sw_validate, .phylink_get_caps = bcm_sf2_sw_get_caps,
.phylink_mac_config = bcm_sf2_sw_mac_config, .phylink_mac_config = bcm_sf2_sw_mac_config,
.phylink_mac_link_down = bcm_sf2_sw_mac_link_down, .phylink_mac_link_down = bcm_sf2_sw_mac_link_down,
.phylink_mac_link_up = bcm_sf2_sw_mac_link_up, .phylink_mac_link_up = bcm_sf2_sw_mac_link_up,
......
...@@ -1461,27 +1461,22 @@ static int ksz8_setup(struct dsa_switch *ds) ...@@ -1461,27 +1461,22 @@ static int ksz8_setup(struct dsa_switch *ds)
return 0; return 0;
} }
static void ksz8_validate(struct dsa_switch *ds, int port, static void ksz8_get_caps(struct dsa_switch *ds, int port,
unsigned long *supported, struct phylink_config *config)
struct phylink_link_state *state)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
struct ksz_device *dev = ds->priv; struct ksz_device *dev = ds->priv;
if (port == dev->cpu_port) { if (port == dev->cpu_port) {
if (state->interface != PHY_INTERFACE_MODE_RMII && __set_bit(PHY_INTERFACE_MODE_RMII,
state->interface != PHY_INTERFACE_MODE_MII && config->supported_interfaces);
state->interface != PHY_INTERFACE_MODE_NA) __set_bit(PHY_INTERFACE_MODE_MII,
goto unsupported; config->supported_interfaces);
} else { } else {
if (state->interface != PHY_INTERFACE_MODE_INTERNAL && __set_bit(PHY_INTERFACE_MODE_INTERNAL,
state->interface != PHY_INTERFACE_MODE_NA) config->supported_interfaces);
goto unsupported;
} }
/* Allow all the expected bits */ config->mac_capabilities = MAC_10 | MAC_100;
phylink_set_port_modes(mask);
phylink_set(mask, Autoneg);
/* Silicon Errata Sheet (DS80000830A): /* Silicon Errata Sheet (DS80000830A):
* "Port 1 does not respond to received flow control PAUSE frames" * "Port 1 does not respond to received flow control PAUSE frames"
...@@ -1489,27 +1484,11 @@ static void ksz8_validate(struct dsa_switch *ds, int port, ...@@ -1489,27 +1484,11 @@ static void ksz8_validate(struct dsa_switch *ds, int port,
* switches. * switches.
*/ */
if (!ksz_is_ksz88x3(dev) || port) if (!ksz_is_ksz88x3(dev) || port)
phylink_set(mask, Pause); config->mac_capabilities |= MAC_SYM_PAUSE;
/* Asym pause is not supported on KSZ8863 and KSZ8873 */ /* Asym pause is not supported on KSZ8863 and KSZ8873 */
if (!ksz_is_ksz88x3(dev)) if (!ksz_is_ksz88x3(dev))
phylink_set(mask, Asym_Pause); config->mac_capabilities |= MAC_ASYM_PAUSE;
/* 10M and 100M are only supported */
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 100baseT_Full);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
return;
unsupported:
linkmode_zero(supported);
dev_err(ds->dev, "Unsupported interface: %s, port: %d\n",
phy_modes(state->interface), port);
} }
static const struct dsa_switch_ops ksz8_switch_ops = { static const struct dsa_switch_ops ksz8_switch_ops = {
...@@ -1518,7 +1497,7 @@ static const struct dsa_switch_ops ksz8_switch_ops = { ...@@ -1518,7 +1497,7 @@ static const struct dsa_switch_ops ksz8_switch_ops = {
.setup = ksz8_setup, .setup = ksz8_setup,
.phy_read = ksz_phy_read16, .phy_read = ksz_phy_read16,
.phy_write = ksz_phy_write16, .phy_write = ksz_phy_write16,
.phylink_validate = ksz8_validate, .phylink_get_caps = ksz8_get_caps,
.phylink_mac_link_down = ksz_mac_link_down, .phylink_mac_link_down = ksz_mac_link_down,
.port_enable = ksz_enable_port, .port_enable = ksz_enable_port,
.get_strings = ksz8_get_strings, .get_strings = ksz8_get_strings,
......
...@@ -499,52 +499,27 @@ static enum dsa_tag_protocol ar9331_sw_get_tag_protocol(struct dsa_switch *ds, ...@@ -499,52 +499,27 @@ static enum dsa_tag_protocol ar9331_sw_get_tag_protocol(struct dsa_switch *ds,
return DSA_TAG_PROTO_AR9331; return DSA_TAG_PROTO_AR9331;
} }
static void ar9331_sw_phylink_validate(struct dsa_switch *ds, int port, static void ar9331_sw_phylink_get_caps(struct dsa_switch *ds, int port,
unsigned long *supported, struct phylink_config *config)
struct phylink_link_state *state)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
MAC_10 | MAC_100;
switch (port) { switch (port) {
case 0: case 0:
if (state->interface != PHY_INTERFACE_MODE_GMII) __set_bit(PHY_INTERFACE_MODE_GMII,
goto unsupported; config->supported_interfaces);
config->mac_capabilities |= MAC_1000;
phylink_set(mask, 1000baseT_Full);
phylink_set(mask, 1000baseT_Half);
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5: case 5:
if (state->interface != PHY_INTERFACE_MODE_INTERNAL) __set_bit(PHY_INTERFACE_MODE_INTERNAL,
goto unsupported; config->supported_interfaces);
break; break;
default:
linkmode_zero(supported);
dev_err(ds->dev, "Unsupported port: %i\n", port);
return;
} }
phylink_set_port_modes(mask);
phylink_set(mask, Pause);
phylink_set(mask, Asym_Pause);
phylink_set(mask, 10baseT_Half);
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Half);
phylink_set(mask, 100baseT_Full);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
return;
unsupported:
linkmode_zero(supported);
dev_err(ds->dev, "Unsupported interface: %d, port: %d\n",
state->interface, port);
} }
static void ar9331_sw_phylink_mac_config(struct dsa_switch *ds, int port, static void ar9331_sw_phylink_mac_config(struct dsa_switch *ds, int port,
...@@ -697,7 +672,7 @@ static const struct dsa_switch_ops ar9331_sw_ops = { ...@@ -697,7 +672,7 @@ static const struct dsa_switch_ops ar9331_sw_ops = {
.get_tag_protocol = ar9331_sw_get_tag_protocol, .get_tag_protocol = ar9331_sw_get_tag_protocol,
.setup = ar9331_sw_setup, .setup = ar9331_sw_setup,
.port_disable = ar9331_sw_port_disable, .port_disable = ar9331_sw_port_disable,
.phylink_validate = ar9331_sw_phylink_validate, .phylink_get_caps = ar9331_sw_phylink_get_caps,
.phylink_mac_config = ar9331_sw_phylink_mac_config, .phylink_mac_config = ar9331_sw_phylink_mac_config,
.phylink_mac_link_down = ar9331_sw_phylink_mac_link_down, .phylink_mac_link_down = ar9331_sw_phylink_mac_link_down,
.phylink_mac_link_up = ar9331_sw_phylink_mac_link_up, .phylink_mac_link_up = ar9331_sw_phylink_mac_link_up,
......
...@@ -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,
......
...@@ -442,34 +442,27 @@ static void xrs700x_teardown(struct dsa_switch *ds) ...@@ -442,34 +442,27 @@ static void xrs700x_teardown(struct dsa_switch *ds)
cancel_delayed_work_sync(&priv->mib_work); cancel_delayed_work_sync(&priv->mib_work);
} }
static void xrs700x_phylink_validate(struct dsa_switch *ds, int port, static void xrs700x_phylink_get_caps(struct dsa_switch *ds, int port,
unsigned long *supported, struct phylink_config *config)
struct phylink_link_state *state)
{ {
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
switch (port) { switch (port) {
case 0: case 0:
__set_bit(PHY_INTERFACE_MODE_RMII,
config->supported_interfaces);
config->mac_capabilities = MAC_10FD | MAC_100FD;
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
phylink_set(mask, 1000baseT_Full); phy_interface_set_rgmii(config->supported_interfaces);
config->mac_capabilities = MAC_10FD | MAC_100FD | MAC_1000FD;
break; break;
default: default:
linkmode_zero(supported);
dev_err(ds->dev, "Unsupported port: %i\n", port); dev_err(ds->dev, "Unsupported port: %i\n", port);
return; break;
} }
phylink_set_port_modes(mask);
/* The switch only supports full duplex. */
phylink_set(mask, 10baseT_Full);
phylink_set(mask, 100baseT_Full);
linkmode_and(supported, supported, mask);
linkmode_and(state->advertising, state->advertising, mask);
} }
static void xrs700x_mac_link_up(struct dsa_switch *ds, int port, static void xrs700x_mac_link_up(struct dsa_switch *ds, int port,
...@@ -703,7 +696,7 @@ static const struct dsa_switch_ops xrs700x_ops = { ...@@ -703,7 +696,7 @@ static const struct dsa_switch_ops xrs700x_ops = {
.setup = xrs700x_setup, .setup = xrs700x_setup,
.teardown = xrs700x_teardown, .teardown = xrs700x_teardown,
.port_stp_state_set = xrs700x_port_stp_state_set, .port_stp_state_set = xrs700x_port_stp_state_set,
.phylink_validate = xrs700x_phylink_validate, .phylink_get_caps = xrs700x_phylink_get_caps,
.phylink_mac_link_up = xrs700x_mac_link_up, .phylink_mac_link_up = xrs700x_mac_link_up,
.get_strings = xrs700x_get_strings, .get_strings = xrs700x_get_strings,
.get_sset_count = xrs700x_get_sset_count, .get_sset_count = xrs700x_get_sset_count,
......
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