net: pcs: xpcs: Fix PMA identifier handling in XPCS

The XPCS driver was mangling the PMA identifier as the original code
appears to have been focused on just capturing the OUI. Rather than store a
mangled ID it is better to work with the actual PMA ID and instead just
mask out the values that don't apply rather than shifting them and
reordering them as you still don't get the original OUI for the NIC without
having to bitswap the values as per the definition of the layout in IEEE
802.3-2022 22.2.4.3.1.

By laying it out as it was in the hardware it is also less likely for us to
have an unintentional collision as the enum values will occupy the revision
number area while the OUI occupies the upper 22 bits.

Signed-off-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/176374320920.959489.17267159479370601070.stgit@ahduyck-xeon-server.home.arpa
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Alexander Duyck
2025-11-21 08:40:09 -08:00
committed by Paolo Abeni
parent 7622d55276
commit 39e138173a
3 changed files with 10 additions and 6 deletions

View File

@@ -1365,17 +1365,16 @@ static int xpcs_read_ids(struct dw_xpcs *xpcs)
if (ret < 0)
return ret;
id = ret;
id = ret << 16;
ret = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_DEVID2);
if (ret < 0)
return ret;
/* Note the inverted dword order and masked out Model/Revision numbers
* with respect to what is done with the PCS ID...
/* For now we only record the OUI for the PMAPMD, we may want to
* add the model number at some point in the future.
*/
ret = (ret >> 10) & 0x3F;
id |= ret << 16;
id |= ret & MDIO_DEVID2_OUI;
/* Set the PMA ID if it hasn't been pre-initialized */
if (xpcs->info.pma == DW_XPCS_PMA_ID_NATIVE)

View File

@@ -38,7 +38,7 @@ enum dw_xpcs_pma_id {
DW_XPCS_PMA_GEN4_6G_ID,
DW_XPCS_PMA_GEN5_10G_ID,
DW_XPCS_PMA_GEN5_12G_ID,
WX_TXGBE_XPCS_PMA_10G_ID = 0x0018fc80,
WX_TXGBE_XPCS_PMA_10G_ID = 0xfc806000,
};
struct dw_xpcs_info {

View File

@@ -147,6 +147,11 @@
#define MDIO_AN_STAT1_PAGE 0x0040 /* Page received */
#define MDIO_AN_STAT1_XNP 0x0080 /* Extended next page status */
/* Device Identifier 2 */
#define MDIO_DEVID2_OUI 0xfc00 /* OUI Portion of PHY ID */
#define MDIO_DEVID2_MODEL_NUM 0x03f0 /* Manufacturer's Model Number */
#define MDIO_DEVID2_REV_NUM 0x000f /* Revision Number */
/* Speed register. */
#define MDIO_SPEED_10G 0x0001 /* 10G capable */
#define MDIO_PMA_SPEED_2B 0x0002 /* 2BASE-TL capable */