Skip to content

Commit ae8140a

Browse files
mdrustadJeff Kirsher
authored andcommitted
ixgbe: Avoid needless PHY access on copper phys
Avoid a needless PHY access on copper phys to save the 10ms wait time for each PHY access. A helper function is introduced to actually do the register access and process the contents. Signed-off-by: Mark Rustad <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 897b934 commit ae8140a

File tree

2 files changed

+44
-21
lines changed

2 files changed

+44
-21
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -730,39 +730,61 @@ s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
730730
}
731731

732732
/**
733-
* ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
733+
* ixgbe_get_copper_speeds_supported - Get copper link speed from phy
734734
* @hw: pointer to hardware structure
735-
* @speed: pointer to link speed
736-
* @autoneg: boolean auto-negotiation value
737735
*
738-
* Determines the link capabilities by reading the AUTOC register.
736+
* Determines the supported link capabilities by reading the PHY auto
737+
* negotiation register.
739738
*/
740-
s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
741-
ixgbe_link_speed *speed,
742-
bool *autoneg)
739+
static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
743740
{
744-
s32 status;
745741
u16 speed_ability;
746-
747-
*speed = 0;
748-
*autoneg = true;
742+
s32 status;
749743

750744
status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
751745
&speed_ability);
746+
if (status)
747+
return status;
752748

753-
if (status == 0) {
754-
if (speed_ability & MDIO_SPEED_10G)
755-
*speed |= IXGBE_LINK_SPEED_10GB_FULL;
756-
if (speed_ability & MDIO_PMA_SPEED_1000)
757-
*speed |= IXGBE_LINK_SPEED_1GB_FULL;
758-
if (speed_ability & MDIO_PMA_SPEED_100)
759-
*speed |= IXGBE_LINK_SPEED_100_FULL;
749+
if (speed_ability & MDIO_SPEED_10G)
750+
hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
751+
if (speed_ability & MDIO_PMA_SPEED_1000)
752+
hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
753+
if (speed_ability & MDIO_PMA_SPEED_100)
754+
hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
755+
756+
switch (hw->mac.type) {
757+
case ixgbe_mac_X550:
758+
hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
759+
hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
760+
break;
761+
case ixgbe_mac_X550EM_x:
762+
hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
763+
break;
764+
default:
765+
break;
760766
}
761767

762-
/* Internal PHY does not support 100 Mbps */
763-
if (hw->mac.type == ixgbe_mac_X550EM_x)
764-
*speed &= ~IXGBE_LINK_SPEED_100_FULL;
768+
return 0;
769+
}
770+
771+
/**
772+
* ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
773+
* @hw: pointer to hardware structure
774+
* @speed: pointer to link speed
775+
* @autoneg: boolean auto-negotiation value
776+
*/
777+
s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
778+
ixgbe_link_speed *speed,
779+
bool *autoneg)
780+
{
781+
s32 status = 0;
782+
783+
*autoneg = true;
784+
if (!hw->phy.speeds_supported)
785+
status = ixgbe_get_copper_speeds_supported(hw);
765786

787+
*speed = hw->phy.speeds_supported;
766788
return status;
767789
}
768790

drivers/net/ethernet/intel/ixgbe/ixgbe_type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,6 +3384,7 @@ struct ixgbe_phy_info {
33843384
u32 phy_semaphore_mask;
33853385
bool reset_disable;
33863386
ixgbe_autoneg_advertised autoneg_advertised;
3387+
ixgbe_link_speed speeds_supported;
33873388
enum ixgbe_smart_speed smart_speed;
33883389
bool smart_speed_active;
33893390
bool multispeed_fiber;

0 commit comments

Comments
 (0)