]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: pcs: xpcs: Fix PMA identifier handling in XPCS
authorAlexander Duyck <alexanderduyck@fb.com>
Fri, 21 Nov 2025 16:40:09 +0000 (08:40 -0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 27 Nov 2025 09:41:31 +0000 (10:41 +0100)
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>
drivers/net/pcs/pcs-xpcs.c
include/linux/pcs/pcs-xpcs.h
include/uapi/linux/mdio.h

index 9fb9d4fd2a5b07f909f1d8456d35c507bff7c6c8..a94a7cb93664ac2519a5a37adcdb2f21d17b717d 100644 (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)
index e40f554ff717a31fd63176a60886ca63d2cea570..4cf6bd611e5ac15c69157648a0c8afd7b0ff34e5 100644 (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 {
index f23cab33e5866b2959bf82fd09a370baf8283e36..8d769f100de60f0f634f7fdfc34e60332b4c17e1 100644 (file)
 #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 */