Commit 86a362c4 authored by Russell King's avatar Russell King Committed by David S. Miller

phylink: get rid of separate Cisco SGMII and 802.3z modes

Since the handling of SGMII and 802.3z is now the same, combine the
MLO_AN_xxx constants into a single MLO_AN_INBAND, and use the PHY
interface mode to distinguish between Cisco SGMII and 802.3z.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cf4f2675
...@@ -117,8 +117,7 @@ static const char *phylink_an_mode_str(unsigned int mode) ...@@ -117,8 +117,7 @@ static const char *phylink_an_mode_str(unsigned int mode)
static const char *modestr[] = { static const char *modestr[] = {
[MLO_AN_PHY] = "phy", [MLO_AN_PHY] = "phy",
[MLO_AN_FIXED] = "fixed", [MLO_AN_FIXED] = "fixed",
[MLO_AN_SGMII] = "SGMII", [MLO_AN_INBAND] = "inband",
[MLO_AN_8023Z] = "802.3z",
}; };
return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown"; return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown";
...@@ -244,6 +243,7 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np) ...@@ -244,6 +243,7 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, Asym_Pause); phylink_set(pl->supported, Asym_Pause);
phylink_set(pl->supported, Pause); phylink_set(pl->supported, Pause);
pl->link_config.an_enabled = true; pl->link_config.an_enabled = true;
pl->link_an_mode = MLO_AN_INBAND;
switch (pl->link_config.interface) { switch (pl->link_config.interface) {
case PHY_INTERFACE_MODE_SGMII: case PHY_INTERFACE_MODE_SGMII:
...@@ -253,17 +253,14 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np) ...@@ -253,17 +253,14 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, 100baseT_Full); phylink_set(pl->supported, 100baseT_Full);
phylink_set(pl->supported, 1000baseT_Half); phylink_set(pl->supported, 1000baseT_Half);
phylink_set(pl->supported, 1000baseT_Full); phylink_set(pl->supported, 1000baseT_Full);
pl->link_an_mode = MLO_AN_SGMII;
break; break;
case PHY_INTERFACE_MODE_1000BASEX: case PHY_INTERFACE_MODE_1000BASEX:
phylink_set(pl->supported, 1000baseX_Full); phylink_set(pl->supported, 1000baseX_Full);
pl->link_an_mode = MLO_AN_8023Z;
break; break;
case PHY_INTERFACE_MODE_2500BASEX: case PHY_INTERFACE_MODE_2500BASEX:
phylink_set(pl->supported, 2500baseX_Full); phylink_set(pl->supported, 2500baseX_Full);
pl->link_an_mode = MLO_AN_8023Z;
break; break;
case PHY_INTERFACE_MODE_10GKR: case PHY_INTERFACE_MODE_10GKR:
...@@ -280,7 +277,6 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np) ...@@ -280,7 +277,6 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np)
phylink_set(pl->supported, 10000baseLR_Full); phylink_set(pl->supported, 10000baseLR_Full);
phylink_set(pl->supported, 10000baseLRM_Full); phylink_set(pl->supported, 10000baseLRM_Full);
phylink_set(pl->supported, 10000baseER_Full); phylink_set(pl->supported, 10000baseER_Full);
pl->link_an_mode = MLO_AN_SGMII;
break; break;
default: default:
...@@ -422,8 +418,7 @@ static void phylink_resolve(struct work_struct *w) ...@@ -422,8 +418,7 @@ static void phylink_resolve(struct work_struct *w)
phylink_mac_config(pl, &link_state); phylink_mac_config(pl, &link_state);
break; break;
case MLO_AN_SGMII: case MLO_AN_INBAND:
case MLO_AN_8023Z:
phylink_get_mac_state(pl, &link_state); phylink_get_mac_state(pl, &link_state);
if (pl->phydev) { if (pl->phydev) {
bool changed = false; bool changed = false;
...@@ -654,7 +649,8 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy) ...@@ -654,7 +649,8 @@ int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
int ret; int ret;
if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED || if (WARN_ON(pl->link_an_mode == MLO_AN_FIXED ||
pl->link_an_mode == MLO_AN_8023Z)) (pl->link_an_mode == MLO_AN_INBAND &&
phy_interface_mode_is_8023z(pl->link_interface))))
return -EINVAL; return -EINVAL;
ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface); ret = phy_attach_direct(pl->netdev, phy, 0, pl->link_interface);
...@@ -677,7 +673,8 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn) ...@@ -677,7 +673,8 @@ int phylink_of_phy_connect(struct phylink *pl, struct device_node *dn)
/* Fixed links and 802.3z are handled without needing a PHY */ /* Fixed links and 802.3z are handled without needing a PHY */
if (pl->link_an_mode == MLO_AN_FIXED || if (pl->link_an_mode == MLO_AN_FIXED ||
pl->link_an_mode == MLO_AN_8023Z) (pl->link_an_mode == MLO_AN_INBAND &&
phy_interface_mode_is_8023z(pl->link_interface)))
return 0; return 0;
phy_node = of_parse_phandle(dn, "phy-handle", 0); phy_node = of_parse_phandle(dn, "phy-handle", 0);
...@@ -851,8 +848,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl, ...@@ -851,8 +848,7 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
phylink_get_ksettings(&link_state, kset); phylink_get_ksettings(&link_state, kset);
break; break;
case MLO_AN_SGMII: case MLO_AN_INBAND:
case MLO_AN_8023Z:
/* If there is a phy attached, then use the reported /* If there is a phy attached, then use the reported
* settings from the phy with no modification. * settings from the phy with no modification.
*/ */
...@@ -1029,8 +1025,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, ...@@ -1029,8 +1025,7 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl,
phylink_mac_config(pl, config); phylink_mac_config(pl, config);
break; break;
case MLO_AN_SGMII: case MLO_AN_INBAND:
case MLO_AN_8023Z:
phylink_mac_config(pl, config); phylink_mac_config(pl, config);
phylink_mac_an_restart(pl); phylink_mac_an_restart(pl);
break; break;
...@@ -1247,9 +1242,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id, ...@@ -1247,9 +1242,7 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,
case MLO_AN_PHY: case MLO_AN_PHY:
return -EOPNOTSUPP; return -EOPNOTSUPP;
case MLO_AN_SGMII: case MLO_AN_INBAND:
/* No phy, fall through to 8023z method */
case MLO_AN_8023Z:
if (phy_id == 0) { if (phy_id == 0) {
val = phylink_get_mac_state(pl, &state); val = phylink_get_mac_state(pl, &state);
if (val < 0) if (val < 0)
...@@ -1274,9 +1267,7 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id, ...@@ -1274,9 +1267,7 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id,
case MLO_AN_PHY: case MLO_AN_PHY:
return -EOPNOTSUPP; return -EOPNOTSUPP;
case MLO_AN_SGMII: case MLO_AN_INBAND:
/* No phy, fall through to 8023z method */
case MLO_AN_8023Z:
break; break;
} }
...@@ -1291,7 +1282,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd) ...@@ -1291,7 +1282,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
WARN_ON(!lockdep_rtnl_is_held()); WARN_ON(!lockdep_rtnl_is_held());
if (pl->phydev) { if (pl->phydev) {
/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */ /* PHYs only exist for MLO_AN_PHY and SGMII */
switch (cmd) { switch (cmd) {
case SIOCGMIIPHY: case SIOCGMIIPHY:
mii->phy_id = pl->phydev->mdio.addr; mii->phy_id = pl->phydev->mdio.addr;
...@@ -1360,10 +1351,8 @@ static int phylink_sfp_module_insert(void *upstream, ...@@ -1360,10 +1351,8 @@ static int phylink_sfp_module_insert(void *upstream,
switch (iface) { switch (iface) {
case PHY_INTERFACE_MODE_SGMII: case PHY_INTERFACE_MODE_SGMII:
mode = MLO_AN_SGMII;
break;
case PHY_INTERFACE_MODE_1000BASEX: case PHY_INTERFACE_MODE_1000BASEX:
mode = MLO_AN_8023Z; mode = MLO_AN_INBAND;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1390,7 +1379,7 @@ static int phylink_sfp_module_insert(void *upstream, ...@@ -1390,7 +1379,7 @@ static int phylink_sfp_module_insert(void *upstream,
phylink_an_mode_str(mode), phy_modes(config.interface), phylink_an_mode_str(mode), phy_modes(config.interface),
__ETHTOOL_LINK_MODE_MASK_NBITS, support); __ETHTOOL_LINK_MODE_MASK_NBITS, support);
if (mode == MLO_AN_8023Z && pl->phydev) if (phy_interface_mode_is_8023z(iface) && pl->phydev)
return -EINVAL; return -EINVAL;
changed = !bitmap_equal(pl->supported, support, changed = !bitmap_equal(pl->supported, support,
......
...@@ -20,13 +20,12 @@ enum { ...@@ -20,13 +20,12 @@ enum {
MLO_AN_PHY = 0, /* Conventional PHY */ MLO_AN_PHY = 0, /* Conventional PHY */
MLO_AN_FIXED, /* Fixed-link mode */ MLO_AN_FIXED, /* Fixed-link mode */
MLO_AN_SGMII, /* Cisco SGMII protocol */ MLO_AN_INBAND, /* In-band protocol */
MLO_AN_8023Z, /* 1000base-X protocol */
}; };
static inline bool phylink_autoneg_inband(unsigned int mode) static inline bool phylink_autoneg_inband(unsigned int mode)
{ {
return mode == MLO_AN_SGMII || mode == MLO_AN_8023Z; return mode == MLO_AN_INBAND;
} }
struct phylink_link_state { struct phylink_link_state {
...@@ -69,7 +68,7 @@ struct phylink_mac_ops { ...@@ -69,7 +68,7 @@ struct phylink_mac_ops {
/** /**
* mac_config: configure the MAC for the selected mode and state * mac_config: configure the MAC for the selected mode and state
* @ndev: net_device structure for the MAC * @ndev: net_device structure for the MAC
* @mode: one of MLO_AN_FIXED, MLO_AN_PHY, MLO_AN_8023Z, MLO_AN_SGMII * @mode: one of MLO_AN_FIXED, MLO_AN_PHY, MLO_AN_INBAND
* @state: state structure * @state: state structure
* *
* The action performed depends on the currently selected mode: * The action performed depends on the currently selected mode:
...@@ -77,14 +76,10 @@ struct phylink_mac_ops { ...@@ -77,14 +76,10 @@ struct phylink_mac_ops {
* %MLO_AN_FIXED, %MLO_AN_PHY: * %MLO_AN_FIXED, %MLO_AN_PHY:
* set the specified speed, duplex, pause mode, and phy interface * set the specified speed, duplex, pause mode, and phy interface
* mode in the provided @state. * mode in the provided @state.
* %MLO_AN_8023Z: * %MLO_AN_INBAND:
* place the link in 1000base-X mode, advertising the parameters * place the link in an inband negotiation mode (such as
* given in advertising in @state. * 1000base-X or Cisco SGMII mode depending on the phy interface
* %MLO_AN_SGMII: * mode), advertising the parameters given in advertising in @state.
* place the link in Cisco SGMII mode - there is no advertisment
* to make as the PHY communicates the speed and duplex to the
* MAC over the in-band control word. Configuration of the pause
* mode is as per MLO_AN_PHY since this is not included.
*/ */
void (*mac_config)(struct net_device *ndev, unsigned int mode, void (*mac_config)(struct net_device *ndev, unsigned int mode,
const struct phylink_link_state *state); const struct phylink_link_state *state);
......
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