Skip to content

Commit 998a8a8

Browse files
hkallweitdavem330
authored andcommitted
net: phy: let genphy_c45_read_link manage the devices to check
Let genphy_c45_read_link manage the devices to check, this removes overhead from callers. Add C22EXT to the list of excluded devices because it doesn't implement the status register. According to the 802.3 clause 45 spec registers 29.0 - 29.4 are reserved. At the moment we have very few clause 45 PHY drivers, so we are lacking experience whether other drivers will have to exclude further devices, or may need to check PHY XS. If we should figure out that list of devices to check needs to be configurable, I think best will be to add a device list member to struct phy_driver. v2: - adjusted commit message - exclude also device C22EXT from link checking Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 71bd106 commit 998a8a8

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

drivers/net/phy/marvell10g.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,16 +428,8 @@ static int mv3310_read_10gbr_status(struct phy_device *phydev)
428428

429429
static int mv3310_read_status(struct phy_device *phydev)
430430
{
431-
u32 mmd_mask = phydev->c45_ids.devices_in_package;
432431
int val;
433432

434-
/* The vendor devads do not report link status. Avoid the PHYXS
435-
* instance as there are three, and its status depends on the MAC
436-
* being appropriately configured for the negotiated speed.
437-
*/
438-
mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2) |
439-
BIT(MDIO_MMD_PHYXS));
440-
441433
phydev->speed = SPEED_UNKNOWN;
442434
phydev->duplex = DUPLEX_UNKNOWN;
443435
linkmode_zero(phydev->lp_advertising);
@@ -453,7 +445,7 @@ static int mv3310_read_status(struct phy_device *phydev)
453445
if (val & MDIO_STAT1_LSTATUS)
454446
return mv3310_read_10gbr_status(phydev);
455447

456-
val = genphy_c45_read_link(phydev, mmd_mask);
448+
val = genphy_c45_read_link(phydev);
457449
if (val < 0)
458450
return val;
459451

drivers/net/phy/phy-c45.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,24 @@ EXPORT_SYMBOL_GPL(genphy_c45_aneg_done);
118118
/**
119119
* genphy_c45_read_link - read the overall link status from the MMDs
120120
* @phydev: target phy_device struct
121-
* @mmd_mask: MMDs to read status from
122121
*
123122
* Read the link status from the specified MMDs, and if they all indicate
124123
* that the link is up, set phydev->link to 1. If an error is encountered,
125124
* a negative errno will be returned, otherwise zero.
126125
*/
127-
int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask)
126+
int genphy_c45_read_link(struct phy_device *phydev)
128127
{
128+
u32 mmd_mask = phydev->c45_ids.devices_in_package;
129129
int val, devad;
130130
bool link = true;
131131

132+
/* The vendor devads and C22EXT do not report link status. Avoid the
133+
* PHYXS instance as its status may depend on the MAC being
134+
* appropriately configured for the negotiated speed.
135+
*/
136+
mmd_mask &= ~(MDIO_DEVS_VEND1 | MDIO_DEVS_VEND2 | MDIO_DEVS_C22EXT |
137+
MDIO_DEVS_PHYXS);
138+
132139
while (mmd_mask && link) {
133140
devad = __ffs(mmd_mask);
134141
mmd_mask &= ~BIT(devad);
@@ -266,16 +273,11 @@ EXPORT_SYMBOL_GPL(gen10g_config_aneg);
266273

267274
int gen10g_read_status(struct phy_device *phydev)
268275
{
269-
u32 mmd_mask = phydev->c45_ids.devices_in_package;
270-
271276
/* For now just lie and say it's 10G all the time */
272277
phydev->speed = SPEED_10000;
273278
phydev->duplex = DUPLEX_FULL;
274279

275-
/* Avoid reading the vendor MMDs */
276-
mmd_mask &= ~(BIT(MDIO_MMD_VEND1) | BIT(MDIO_MMD_VEND2));
277-
278-
return genphy_c45_read_link(phydev, mmd_mask);
280+
return genphy_c45_read_link(phydev);
279281
}
280282
EXPORT_SYMBOL_GPL(gen10g_read_status);
281283

include/linux/phy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
10941094
/* Clause 45 PHY */
10951095
int genphy_c45_restart_aneg(struct phy_device *phydev);
10961096
int genphy_c45_aneg_done(struct phy_device *phydev);
1097-
int genphy_c45_read_link(struct phy_device *phydev, u32 mmd_mask);
1097+
int genphy_c45_read_link(struct phy_device *phydev);
10981098
int genphy_c45_read_lpa(struct phy_device *phydev);
10991099
int genphy_c45_read_pma(struct phy_device *phydev);
11001100
int genphy_c45_pma_setup_forced(struct phy_device *phydev);

include/uapi/linux/mdio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
#define MDIO_DEVS_TC MDIO_DEVS_PRESENT(MDIO_MMD_TC)
124124
#define MDIO_DEVS_AN MDIO_DEVS_PRESENT(MDIO_MMD_AN)
125125
#define MDIO_DEVS_C22EXT MDIO_DEVS_PRESENT(MDIO_MMD_C22EXT)
126+
#define MDIO_DEVS_VEND1 MDIO_DEVS_PRESENT(MDIO_MMD_VEND1)
127+
#define MDIO_DEVS_VEND2 MDIO_DEVS_PRESENT(MDIO_MMD_VEND2)
126128

127129
/* Control register 2. */
128130
#define MDIO_PMA_CTRL2_TYPE 0x000f /* PMA/PMD type selection */

0 commit comments

Comments
 (0)