Skip to content

Commit b834489

Browse files
robhancockseddavem330
authored andcommitted
net: phy: Add is_on_sfp_module flag and phy_on_sfp helper
Add a flag and helper function to indicate that a PHY device is part of an SFP module, which is set on attach. This can be used by PHY drivers to handle SFP-specific quirks or behavior. Signed-off-by: Robert Hancock <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3afd021 commit b834489

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
13771377

13781378
if (phydev->sfp_bus_attached)
13791379
dev->sfp_bus = phydev->sfp_bus;
1380+
else if (dev->sfp_bus)
1381+
phydev->is_on_sfp_module = true;
13801382
}
13811383

13821384
/* Some Ethernet drivers try to connect to a PHY device before

include/linux/phy.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ struct macsec_ops;
492492
* @sysfs_links: Internal boolean tracking sysfs symbolic links setup/removal.
493493
* @loopback_enabled: Set true if this PHY has been loopbacked successfully.
494494
* @downshifted_rate: Set true if link speed has been downshifted.
495+
* @is_on_sfp_module: Set true if PHY is located on an SFP module.
495496
* @state: State of the PHY for management purposes
496497
* @dev_flags: Device-specific flags used by the PHY driver.
497498
* @irq: IRQ number of the PHY's interrupt (-1 if none)
@@ -565,6 +566,7 @@ struct phy_device {
565566
unsigned sysfs_links:1;
566567
unsigned loopback_enabled:1;
567568
unsigned downshifted_rate:1;
569+
unsigned is_on_sfp_module:1;
568570

569571
unsigned autoneg:1;
570572
/* The most recently read link state */
@@ -1296,6 +1298,15 @@ static inline bool phy_is_internal(struct phy_device *phydev)
12961298
return phydev->is_internal;
12971299
}
12981300

1301+
/**
1302+
* phy_on_sfp - Convenience function for testing if a PHY is on an SFP module
1303+
* @phydev: the phy_device struct
1304+
*/
1305+
static inline bool phy_on_sfp(struct phy_device *phydev)
1306+
{
1307+
return phydev->is_on_sfp_module;
1308+
}
1309+
12991310
/**
13001311
* phy_interface_mode_is_rgmii - Convenience function for testing if a
13011312
* PHY interface mode is RGMII (all variants)

0 commit comments

Comments
 (0)