Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Alexander Duyck and committed by
Paolo Abeni
39e13817 7622d552

+10 -6
+4 -5
drivers/net/pcs/pcs-xpcs.c
··· 1365 1365 if (ret < 0) 1366 1366 return ret; 1367 1367 1368 - id = ret; 1368 + id = ret << 16; 1369 1369 1370 1370 ret = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_DEVID2); 1371 1371 if (ret < 0) 1372 1372 return ret; 1373 1373 1374 - /* Note the inverted dword order and masked out Model/Revision numbers 1375 - * with respect to what is done with the PCS ID... 1374 + /* For now we only record the OUI for the PMAPMD, we may want to 1375 + * add the model number at some point in the future. 1376 1376 */ 1377 - ret = (ret >> 10) & 0x3F; 1378 - id |= ret << 16; 1377 + id |= ret & MDIO_DEVID2_OUI; 1379 1378 1380 1379 /* Set the PMA ID if it hasn't been pre-initialized */ 1381 1380 if (xpcs->info.pma == DW_XPCS_PMA_ID_NATIVE)
+1 -1
include/linux/pcs/pcs-xpcs.h
··· 38 38 DW_XPCS_PMA_GEN4_6G_ID, 39 39 DW_XPCS_PMA_GEN5_10G_ID, 40 40 DW_XPCS_PMA_GEN5_12G_ID, 41 - WX_TXGBE_XPCS_PMA_10G_ID = 0x0018fc80, 41 + WX_TXGBE_XPCS_PMA_10G_ID = 0xfc806000, 42 42 }; 43 43 44 44 struct dw_xpcs_info {
+5
include/uapi/linux/mdio.h
··· 147 147 #define MDIO_AN_STAT1_PAGE 0x0040 /* Page received */ 148 148 #define MDIO_AN_STAT1_XNP 0x0080 /* Extended next page status */ 149 149 150 + /* Device Identifier 2 */ 151 + #define MDIO_DEVID2_OUI 0xfc00 /* OUI Portion of PHY ID */ 152 + #define MDIO_DEVID2_MODEL_NUM 0x03f0 /* Manufacturer's Model Number */ 153 + #define MDIO_DEVID2_REV_NUM 0x000f /* Revision Number */ 154 + 150 155 /* Speed register. */ 151 156 #define MDIO_SPEED_10G 0x0001 /* 10G capable */ 152 157 #define MDIO_PMA_SPEED_2B 0x0002 /* 2BASE-TL capable */