-
-
Save janh/085e13e29b3d5ebfe980f021cc5e1a05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ru a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c | |
--- a/drivers/net/phy/phylink.c | |
+++ b/drivers/net/phy/phylink.c | |
@@ -533,12 +533,16 @@ | |
state->an_complete = 0; | |
state->link = 1; | |
- if (pl->pcs_ops) | |
+ if (pl->pcs_ops) { | |
+ pr_debug("phylink_mac_pcs_get_state: pcs_ops\n"); | |
pl->pcs_ops->pcs_get_state(pl->pcs, state); | |
- else if (pl->mac_ops->mac_pcs_get_state) | |
+ } else if (pl->mac_ops->mac_pcs_get_state) { | |
+ pr_debug("phylink_mac_pcs_get_state: mac_ops\n"); | |
pl->mac_ops->mac_pcs_get_state(pl->config, state); | |
- else | |
+ } else { | |
+ pr_debug("phylink_mac_pcs_get_state: none\n"); | |
state->link = 0; | |
+ } | |
} | |
/* The fixed state is... fixed except for the link state, | |
@@ -654,26 +658,32 @@ | |
cur_link_state = pl->old_link_state; | |
if (pl->phylink_disable_state) { | |
+ pr_debug("phylink_resolve: phylink_disable_state\n"); | |
pl->mac_link_dropped = false; | |
link_state.link = false; | |
} else if (pl->mac_link_dropped) { | |
+ pr_debug("phylink_resolve: max_link_dropped\n"); | |
link_state.link = false; | |
retrigger = true; | |
} else { | |
+ pr_debug("phylink_resolve: link auto-negotiation mode %d\n", pl->cur_link_an_mode); | |
switch (pl->cur_link_an_mode) { | |
case MLO_AN_PHY: | |
link_state = pl->phy_state; | |
phylink_apply_manual_flow(pl, &link_state); | |
mac_config = link_state.link; | |
+ pr_debug("phylink_resolve: phy link state %u\n", link_state.link); | |
break; | |
case MLO_AN_FIXED: | |
phylink_get_fixed_state(pl, &link_state); | |
mac_config = link_state.link; | |
+ pr_debug("phylink_resolve: fixed link state %u\n", link_state.link); | |
break; | |
case MLO_AN_INBAND: | |
phylink_mac_pcs_get_state(pl, &link_state); | |
+ pr_debug("phylink_resolve: inband link state %u\n", link_state.link); | |
/* The PCS may have a latching link-fail indicator. | |
* If the link was up, bring the link down and | |
@@ -692,6 +702,7 @@ | |
* both the PHY and the MAC */ | |
if (pl->phydev) | |
link_state.link &= pl->phy_state.link; | |
+ pr_debug("phylink_resolve: inband+phy link state %u\n", link_state.link); | |
/* Only update if the PHY link is up */ | |
if (pl->phydev && pl->phy_state.link) { | |
@@ -718,6 +729,7 @@ | |
if (mac_config) { | |
if (link_state.interface != pl->link_config.interface) { | |
+ pr_debug("phylink_resolve: interface changed\n"); | |
/* The interface has changed, force the link down and | |
* then reconfigure. | |
*/ | |
@@ -728,6 +740,7 @@ | |
phylink_major_config(pl, false, &link_state); | |
pl->link_config.interface = link_state.interface; | |
} else if (!pl->pcs_ops) { | |
+ pr_debug("phylink_resolve: mac config\n"); | |
/* The interface remains unchanged, only the speed, | |
* duplex or pause settings have changed. Call the | |
* old mac_config() method to configure the MAC/PCS | |
@@ -739,6 +752,7 @@ | |
} | |
if (link_state.link != cur_link_state) { | |
+ pr_debug("phylink_resolve: state changed"); | |
pl->old_link_state = link_state.link; | |
if (!link_state.link) | |
phylink_link_down(pl); | |
@@ -746,6 +760,7 @@ | |
phylink_link_up(pl, link_state); | |
} | |
if (!link_state.link && retrigger) { | |
+ pr_debug("phylink_resolve: retrigger\n"); | |
pl->mac_link_dropped = false; | |
queue_work(system_power_efficient_wq, &pl->resolve); | |
} | |
@@ -754,8 +769,12 @@ | |
static void phylink_run_resolve(struct phylink *pl) | |
{ | |
- if (!pl->phylink_disable_state) | |
+ if (!pl->phylink_disable_state) { | |
+ pr_debug("phylink_run_resolve: queueing\n"); | |
queue_work(system_power_efficient_wq, &pl->resolve); | |
+ } else { | |
+ pr_debug("phylink_run_resolve: not queueing (phylink_disable_state)\n"); | |
+ } | |
} | |
static void phylink_run_resolve_and_disable(struct phylink *pl, int bit) | |
@@ -764,8 +783,11 @@ | |
set_bit(bit, &pl->phylink_disable_state); | |
if (state == 0) { | |
+ pr_debug("phylink_run_resolve_and_disable: queueing\n"); | |
queue_work(system_power_efficient_wq, &pl->resolve); | |
flush_work(&pl->resolve); | |
+ } else { | |
+ pr_debug("phylink_run_resolve_and_disable: not queueing (state != 0)\n"); | |
} | |
} | |
@@ -2057,6 +2079,7 @@ | |
{ | |
struct phylink *pl = upstream; | |
+ pr_info("phylink_sfp_attach\n"); | |
pl->netdev->sfp_bus = bus; | |
} | |
@@ -2064,6 +2087,7 @@ | |
{ | |
struct phylink *pl = upstream; | |
+ pr_info("phylink_sfp_detach\n"); | |
pl->netdev->sfp_bus = NULL; | |
} | |
@@ -2119,8 +2143,10 @@ | |
phylink_an_mode_str(mode), phy_modes(config.interface), | |
__ETHTOOL_LINK_MODE_MASK_NBITS, support); | |
- if (phy_interface_mode_is_8023z(iface) && pl->phydev) | |
+ if (phy_interface_mode_is_8023z(iface) && pl->phydev) { | |
+ pr_info("phylink_sfp_config: phy_interface_mode_is_8023z(iface) && pl->phydev\n"); | |
return -EINVAL; | |
+ } | |
changed = !linkmode_equal(pl->supported, support) || | |
!linkmode_equal(pl->link_config.advertising, | |
@@ -2165,9 +2191,12 @@ | |
/* If this module may have a PHY connecting later, defer until later */ | |
pl->sfp_may_have_phy = sfp_may_have_phy(pl->sfp_bus, id); | |
- if (pl->sfp_may_have_phy) | |
+ if (pl->sfp_may_have_phy) { | |
+ pr_info("phylink_sfp_module_insert: pl->sfp_may_have_phy\n"); | |
return 0; | |
+ } | |
+ pr_info("phylink_sfp_module_insert: phylink_sfp_config\n"); | |
return phylink_sfp_config(pl, MLO_AN_INBAND, support, support); | |
} | |
@@ -2177,6 +2206,7 @@ | |
/* If this SFP module has a PHY, start the PHY now. */ | |
if (pl->phydev) { | |
+ pr_info("phylink_sfp_module_start: phy_start\n"); | |
phy_start(pl->phydev); | |
return 0; | |
} | |
@@ -2184,9 +2214,12 @@ | |
/* If the module may have a PHY but we didn't detect one we | |
* need to configure the MAC here. | |
*/ | |
- if (!pl->sfp_may_have_phy) | |
+ if (!pl->sfp_may_have_phy) { | |
+ pr_info("phylink_sfp_module_start: !pl->sfp_may_have_phy\n"); | |
return 0; | |
+ } | |
+ pr_info("phylink_sfp_module_start: phylink_sfp_config\n"); | |
return phylink_sfp_config(pl, MLO_AN_INBAND, | |
pl->sfp_support, pl->sfp_support); | |
} | |
@@ -2195,6 +2228,7 @@ | |
{ | |
struct phylink *pl = upstream; | |
+ pr_info("phylink_sfp_module_stop\n"); | |
/* If this SFP module has a PHY, stop it. */ | |
if (pl->phydev) | |
phy_stop(pl->phydev); | |
@@ -2206,6 +2240,7 @@ | |
ASSERT_RTNL(); | |
+ pr_info("phylink_sfp_link_down\n"); | |
phylink_run_resolve_and_disable(pl, PHYLINK_DISABLE_LINK); | |
} | |
@@ -2215,6 +2250,7 @@ | |
ASSERT_RTNL(); | |
+ pr_info("phylink_sfp_link_up\n"); | |
clear_bit(PHYLINK_DISABLE_LINK, &pl->phylink_disable_state); | |
phylink_run_resolve(pl); | |
} | |
@@ -2249,16 +2285,19 @@ | |
else | |
mode = MLO_AN_INBAND; | |
+ pr_info("phylink_sfp_connect_phy: phylink_sfp_config\n"); | |
/* Do the initial configuration */ | |
ret = phylink_sfp_config(pl, mode, phy->supported, phy->advertising); | |
if (ret < 0) | |
return ret; | |
+ pr_info("phylink_sfp_connect_phy: phylink_attach_phy\n"); | |
interface = pl->link_config.interface; | |
ret = phylink_attach_phy(pl, phy, interface); | |
if (ret < 0) | |
return ret; | |
+ pr_info("phylink_sfp_connect_phy: phylink_bringup_phy\n"); | |
ret = phylink_bringup_phy(pl, phy, interface); | |
if (ret) | |
phy_detach(phy); | |
@@ -2268,6 +2307,7 @@ | |
static void phylink_sfp_disconnect_phy(void *upstream) | |
{ | |
+ pr_info("phylink_sfp_disconnect_phy\n"); | |
phylink_disconnect_phy(upstream); | |
} | |
diff -ru a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c | |
--- a/drivers/net/phy/sfp.c | |
+++ b/drivers/net/phy/sfp.c | |
@@ -1948,8 +1948,11 @@ | |
{ | |
int err; | |
+ pr_info("sfp_sm_module\n"); | |
+ | |
/* Handle remove event globally, it resets this state machine */ | |
if (event == SFP_E_REMOVE) { | |
+ pr_info("sfp_sm_module: remove\n"); | |
if (sfp->sm_mod_state > SFP_MOD_PROBE) | |
sfp_sm_mod_remove(sfp); | |
sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0); | |
@@ -1959,6 +1962,7 @@ | |
/* Handle device detach globally */ | |
if (sfp->sm_dev_state < SFP_DEV_DOWN && | |
sfp->sm_mod_state > SFP_MOD_WAITDEV) { | |
+ pr_info("sfp_sm_module: detach\n"); | |
if (sfp->module_power_mW > 1000 && | |
sfp->sm_mod_state > SFP_MOD_HPOWER) | |
sfp_sm_mod_hpower(sfp, false); | |
@@ -1968,6 +1972,7 @@ | |
switch (sfp->sm_mod_state) { | |
default: | |
+ pr_info("sfp_sm_module: default\n"); | |
if (event == SFP_E_INSERT) { | |
sfp_sm_mod_next(sfp, SFP_MOD_PROBE, T_SERIAL); | |
sfp->sm_mod_tries_init = R_PROBE_RETRY_INIT; | |
@@ -1976,6 +1981,7 @@ | |
break; | |
case SFP_MOD_PROBE: | |
+ pr_info("sfp_sm_module: SFP_MOD_PROBE\n"); | |
/* Wait for T_PROBE_INIT to time out */ | |
if (event != SFP_E_TIMEOUT) | |
break; | |
@@ -1995,6 +2001,7 @@ | |
} | |
} | |
if (err < 0) { | |
+ pr_info("sfp_sm_module: sfp_sm_mod_probe err %d\n", err); | |
sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); | |
break; | |
} | |
@@ -2006,6 +2013,7 @@ | |
sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0); | |
fallthrough; | |
case SFP_MOD_WAITDEV: | |
+ pr_info("sfp_sm_module: SFP_MOD_WAITDEV\n"); | |
/* Ensure that the device is attached before proceeding */ | |
if (sfp->sm_dev_state < SFP_DEV_DOWN) | |
break; | |
@@ -2013,6 +2021,7 @@ | |
/* Report the module insertion to the upstream device */ | |
err = sfp_module_insert(sfp->sfp_bus, &sfp->id); | |
if (err < 0) { | |
+ pr_info("sfp_sm_module: sfp_module_insert err %d\n", err); | |
sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); | |
break; | |
} | |
@@ -2024,11 +2033,13 @@ | |
sfp_sm_mod_next(sfp, SFP_MOD_HPOWER, 0); | |
fallthrough; | |
case SFP_MOD_HPOWER: | |
+ pr_info("sfp_sm_module: SFP_MOD_HPOWER\n"); | |
/* Enable high power mode */ | |
err = sfp_sm_mod_hpower(sfp, true); | |
if (err < 0) { | |
if (err != -EAGAIN) { | |
sfp_module_remove(sfp->sfp_bus); | |
+ pr_info("sfp_sm_module: sfp_sm_mod_hpower err %d\n", err); | |
sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0); | |
} else { | |
sfp_sm_set_timer(sfp, T_PROBE_RETRY_INIT); | |
@@ -2040,16 +2051,19 @@ | |
break; | |
case SFP_MOD_WAITPWR: | |
+ pr_info("sfp_sm_module: SFP_MOD_WAITPWR\n"); | |
/* Wait for T_HPOWER_LEVEL to time out */ | |
if (event != SFP_E_TIMEOUT) | |
break; | |
insert: | |
+ pr_info("sfp_sm_module: insert\n"); | |
sfp_sm_mod_next(sfp, SFP_MOD_PRESENT, 0); | |
break; | |
case SFP_MOD_PRESENT: | |
case SFP_MOD_ERROR: | |
+ pr_info("sfp_sm_module: SFP_MOD_PRESENT/SFP_MOD_ERROR\n"); | |
break; | |
} | |
} | |
diff -ru a/net/dsa/port.c b/net/dsa/port.c | |
--- a/net/dsa/port.c | |
+++ b/net/dsa/port.c | |
@@ -517,10 +517,12 @@ | |
/* Only called for inband modes */ | |
if (!ds->ops->phylink_mac_link_state) { | |
+ pr_debug("dsa_port_phylink_mac_pcs_get_state: !ds->ops->phylink_mac_link_state\n"); | |
state->link = 0; | |
return; | |
} | |
+ pr_debug("dsa_port_phylink_mac_pcs_get_state: call phylink_mac_link_state\n"); | |
err = ds->ops->phylink_mac_link_state(ds, dp->index, state); | |
if (err < 0) { | |
dev_err(ds->dev, "p%d: phylink_mac_link_state() failed: %d\n", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment