Skip to content

Commit 923454c

Browse files
minimaxwellkuba-moo
authored andcommitted
net: phylink: use a dedicated helper to parse usgmii control word
Q-USGMII is a derivative of USGMII, that uses a specific formatting for the control word. The layout is close to the USXGMII control word, but doesn't support speeds over 1Gbps. Use a dedicated decoding logic for the USGMII control word, re-using USXGMII definitions but only considering 10/100/1000Mbps speeds Fixes: 5e61fe1 ("net: phy: Introduce QUSGMII PHY mode") Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent b9dc104 commit 923454c

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

drivers/net/phy/phylink.c

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,41 @@ void phylink_decode_usxgmii_word(struct phylink_link_state *state,
32983298
}
32993299
EXPORT_SYMBOL_GPL(phylink_decode_usxgmii_word);
33003300

3301+
/**
3302+
* phylink_decode_usgmii_word() - decode the USGMII word from a MAC PCS
3303+
* @state: a pointer to a struct phylink_link_state.
3304+
* @lpa: a 16 bit value which stores the USGMII auto-negotiation word
3305+
*
3306+
* Helper for MAC PCS supporting the USGMII protocol and the auto-negotiation
3307+
* code word. Decode the USGMII code word and populate the corresponding fields
3308+
* (speed, duplex) into the phylink_link_state structure. The structure for this
3309+
* word is the same as the USXGMII word, except it only supports speeds up to
3310+
* 1Gbps.
3311+
*/
3312+
static void phylink_decode_usgmii_word(struct phylink_link_state *state,
3313+
uint16_t lpa)
3314+
{
3315+
switch (lpa & MDIO_USXGMII_SPD_MASK) {
3316+
case MDIO_USXGMII_10:
3317+
state->speed = SPEED_10;
3318+
break;
3319+
case MDIO_USXGMII_100:
3320+
state->speed = SPEED_100;
3321+
break;
3322+
case MDIO_USXGMII_1000:
3323+
state->speed = SPEED_1000;
3324+
break;
3325+
default:
3326+
state->link = false;
3327+
return;
3328+
}
3329+
3330+
if (lpa & MDIO_USXGMII_FULL_DUPLEX)
3331+
state->duplex = DUPLEX_FULL;
3332+
else
3333+
state->duplex = DUPLEX_HALF;
3334+
}
3335+
33013336
/**
33023337
* phylink_mii_c22_pcs_decode_state() - Decode MAC PCS state from MII registers
33033338
* @state: a pointer to a &struct phylink_link_state.
@@ -3335,9 +3370,11 @@ void phylink_mii_c22_pcs_decode_state(struct phylink_link_state *state,
33353370

33363371
case PHY_INTERFACE_MODE_SGMII:
33373372
case PHY_INTERFACE_MODE_QSGMII:
3338-
case PHY_INTERFACE_MODE_QUSGMII:
33393373
phylink_decode_sgmii_word(state, lpa);
33403374
break;
3375+
case PHY_INTERFACE_MODE_QUSGMII:
3376+
phylink_decode_usgmii_word(state, lpa);
3377+
break;
33413378

33423379
default:
33433380
state->link = false;

0 commit comments

Comments
 (0)