Skip to content

Commit

Permalink
net: phylink: pass neg_mode into c22 state decoder
Browse files Browse the repository at this point in the history
Pass the current neg_mode into phylink_mii_c22_pcs_get_state() and
phylink_mii_c22_pcs_decode_state(). Update all users of phylink PCS
that use these functions.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/E1tXGeY-000Et9-8g@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Russell King (Oracle) authored and Jakub Kicinski committed Jan 15, 2025
1 parent c673962 commit 7e3cb4e
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/freescale/fman/fman_dtsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ static void dtsec_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
{
struct fman_mac *dtsec = pcs_to_dtsec(pcs);

phylink_mii_c22_pcs_get_state(dtsec->tbidev, state);
phylink_mii_c22_pcs_get_state(dtsec->tbidev, neg_mode, state);
}

static int dtsec_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/microchip/lan966x/lan966x_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ int lan966x_stats_init(struct lan966x *lan966x);

void lan966x_port_config_down(struct lan966x_port *port);
void lan966x_port_config_up(struct lan966x_port *port);
void lan966x_port_status_get(struct lan966x_port *port,
void lan966x_port_status_get(struct lan966x_port *port, unsigned int neg_mode,
struct phylink_link_state *state);
int lan966x_port_pcs_set(struct lan966x_port *port,
struct lan966x_port_config *config);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/microchip/lan966x/lan966x_phylink.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void lan966x_pcs_get_state(struct phylink_pcs *pcs,
{
struct lan966x_port *port = lan966x_pcs_to_port(pcs);

lan966x_port_status_get(port, state);
lan966x_port_status_get(port, neg_mode, state);
}

static int lan966x_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/microchip/lan966x/lan966x_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void lan966x_port_config_up(struct lan966x_port *port)
lan966x_port_link_up(port);
}

void lan966x_port_status_get(struct lan966x_port *port,
void lan966x_port_status_get(struct lan966x_port *port, unsigned int neg_mode,
struct phylink_link_state *state)
{
struct lan966x *lan966x = port->lan966x;
Expand Down Expand Up @@ -314,7 +314,7 @@ void lan966x_port_status_get(struct lan966x_port *port,
bmsr |= BMSR_ANEGCOMPLETE;

lp_adv = DEV_PCS1G_ANEG_STATUS_LP_ADV_GET(val);
phylink_mii_c22_pcs_decode_state(state, bmsr, lp_adv);
phylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lp_adv);
} else {
if (!state->link)
return;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/xilinx/xilinx_axienet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2336,7 +2336,7 @@ static void axienet_pcs_get_state(struct phylink_pcs *pcs,
{
struct mdio_device *pcs_phy = pcs_to_axienet_local(pcs)->pcs_phy;

phylink_mii_c22_pcs_get_state(pcs_phy, state);
phylink_mii_c22_pcs_get_state(pcs_phy, neg_mode, state);
}

static void axienet_pcs_an_restart(struct phylink_pcs *pcs)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/pcs/pcs-lynx.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_QSGMII:
phylink_mii_c22_pcs_get_state(lynx->mdio, state);
phylink_mii_c22_pcs_get_state(lynx->mdio, neg_mode, state);
break;
case PHY_INTERFACE_MODE_2500BASEX:
lynx_pcs_get_state_2500basex(lynx->mdio, state);
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/pcs/pcs-mtk-lynxi.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ static void mtk_pcs_lynxi_get_state(struct phylink_pcs *pcs,
regmap_read(mpcs->regmap, SGMSYS_PCS_CONTROL_1, &bm);
regmap_read(mpcs->regmap, SGMSYS_PCS_ADVERTISE, &adv);

phylink_mii_c22_pcs_decode_state(state, FIELD_GET(SGMII_BMSR, bm),
phylink_mii_c22_pcs_decode_state(state, neg_mode,
FIELD_GET(SGMII_BMSR, bm),
FIELD_GET(SGMII_LPA, adv));
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/net/pcs/pcs-xpcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,6 +1030,7 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs,
}

static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
unsigned int neg_mode,
struct phylink_link_state *state)
{
int lpa, bmsr;
Expand Down Expand Up @@ -1058,7 +1059,7 @@ static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs,
}
}

phylink_mii_c22_pcs_decode_state(state, bmsr, lpa);
phylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lpa);
}

return 0;
Expand Down Expand Up @@ -1114,7 +1115,7 @@ static void xpcs_get_state(struct phylink_pcs *pcs, unsigned int neg_mode,
"xpcs_get_state_c37_sgmii", ERR_PTR(ret));
break;
case DW_AN_C37_1000BASEX:
ret = xpcs_get_state_c37_1000basex(xpcs, state);
ret = xpcs_get_state_c37_1000basex(xpcs, neg_mode, state);
if (ret)
dev_err(&xpcs->mdiodev->dev, "%s returned %pe\n",
"xpcs_get_state_c37_1000basex", ERR_PTR(ret));
Expand Down
7 changes: 5 additions & 2 deletions drivers/net/phy/phylink.c
Original file line number Diff line number Diff line change
Expand Up @@ -3860,6 +3860,7 @@ static void phylink_decode_usgmii_word(struct phylink_link_state *state,
/**
* phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers
* @state: a pointer to a &struct phylink_link_state.
* @neg_mode: link negotiation mode (PHYLINK_PCS_NEG_xxx)
* @bmsr: The value of the %MII_BMSR register
* @lpa: The value of the %MII_LPA register
*
Expand All @@ -3872,7 +3873,7 @@ static void phylink_decode_usgmii_word(struct phylink_link_state *state,
* accessing @bmsr and @lpa cannot be done with MDIO directly.
*/
void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
u16 bmsr, u16 lpa)
unsigned int neg_mode, u16 bmsr, u16 lpa)
{
state->link = !!(bmsr & BMSR_LSTATUS);
state->an_complete = !!(bmsr & BMSR_ANEGCOMPLETE);
Expand Down Expand Up @@ -3910,6 +3911,7 @@ EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_decode_state);
/**
* phylink_mii_c22_pcs_get_state() - read the MAC PCS state
* @pcs: a pointer to a &struct mdio_device.
* @neg_mode: link negotiation mode (PHYLINK_PCS_NEG_xxx)
* @state: a pointer to a &struct phylink_link_state.
*
* Helper for MAC PCS supporting the 802.3 clause 22 register set for
Expand All @@ -3922,6 +3924,7 @@ EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_decode_state);
* structure.
*/
void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
unsigned int neg_mode,
struct phylink_link_state *state)
{
int bmsr, lpa;
Expand All @@ -3933,7 +3936,7 @@ void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
return;
}

phylink_mii_c22_pcs_decode_state(state, bmsr, lpa);
phylink_mii_c22_pcs_decode_state(state, neg_mode, bmsr, lpa);
}
EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_get_state);

Expand Down
3 changes: 2 additions & 1 deletion include/linux/phylink.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,9 @@ static inline int phylink_get_link_timer_ns(phy_interface_t interface)
}

void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
u16 bmsr, u16 lpa);
unsigned int neg_mode, u16 bmsr, u16 lpa);
void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
unsigned int neg_mode,
struct phylink_link_state *state);
int phylink_mii_c22_pcs_encode_advertisement(phy_interface_t interface,
const unsigned long *advertising);
Expand Down

0 comments on commit 7e3cb4e

Please sign in to comment.