Skip to content

Commit 4d17beb

Browse files
committed
Merge branch 'fixes-for-q-usgmii-speeds-and-autoneg'
Maxime Chevallier says: ==================== fixes for Q-USGMII speeds and autoneg This is the second version of a small changeset for QUSGMII support, fixing inconsistencies in reported max speed and control word parsing. As reported here [1], there are some inconsistencies for the Q-USGMII mode speeds and configuration. The first patch in this fixup series makes so that we correctly report the max speed of 1Gbps for this mode. The second patch uses a dedicated helper to decode the control word. This is necessary as although USGMII control words are close to USXGMII, they don't support the same speeds. [1] : https://lore.kernel.org/netdev/ZHnd+6FUO77XFJvQ@shell.armlinux.org.uk/ ==================== Link: https://lore.kernel.org/r/20230609080305.546028-1-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 75e6def + 923454c commit 4d17beb

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

drivers/net/phy/phylink.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int phylink_interface_max_speed(phy_interface_t interface)
188188
case PHY_INTERFACE_MODE_RGMII_ID:
189189
case PHY_INTERFACE_MODE_RGMII:
190190
case PHY_INTERFACE_MODE_QSGMII:
191+
case PHY_INTERFACE_MODE_QUSGMII:
191192
case PHY_INTERFACE_MODE_SGMII:
192193
case PHY_INTERFACE_MODE_GMII:
193194
return SPEED_1000;
@@ -204,7 +205,6 @@ static int phylink_interface_max_speed(phy_interface_t interface)
204205
case PHY_INTERFACE_MODE_10GBASER:
205206
case PHY_INTERFACE_MODE_10GKR:
206207
case PHY_INTERFACE_MODE_USXGMII:
207-
case PHY_INTERFACE_MODE_QUSGMII:
208208
return SPEED_10000;
209209

210210
case PHY_INTERFACE_MODE_25GBASER:
@@ -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)