@@ -1751,31 +1751,21 @@ static int bnxt_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1751
1751
return 0 ;
1752
1752
}
1753
1753
1754
- u32 _bnxt_fw_to_ethtool_adv_spds (u16 fw_speeds , u8 fw_pause )
1754
+ /* TODO: support 25GB, 40GB, 50GB with different cable type */
1755
+ void _bnxt_fw_to_linkmode (unsigned long * mode , u16 fw_speeds )
1755
1756
{
1756
- u32 speed_mask = 0 ;
1757
+ linkmode_zero ( mode ) ;
1757
1758
1758
- /* TODO: support 25GB, 40GB, 50GB with different cable type */
1759
- /* set the advertised speeds */
1760
1759
if (fw_speeds & BNXT_LINK_SPEED_MSK_100MB )
1761
- speed_mask |= ADVERTISED_100baseT_Full ;
1760
+ linkmode_set_bit ( ETHTOOL_LINK_MODE_100baseT_Full_BIT , mode ) ;
1762
1761
if (fw_speeds & BNXT_LINK_SPEED_MSK_1GB )
1763
- speed_mask |= ADVERTISED_1000baseT_Full ;
1762
+ linkmode_set_bit ( ETHTOOL_LINK_MODE_1000baseT_Full_BIT , mode ) ;
1764
1763
if (fw_speeds & BNXT_LINK_SPEED_MSK_2_5GB )
1765
- speed_mask |= ADVERTISED_2500baseX_Full ;
1764
+ linkmode_set_bit ( ETHTOOL_LINK_MODE_2500baseX_Full_BIT , mode ) ;
1766
1765
if (fw_speeds & BNXT_LINK_SPEED_MSK_10GB )
1767
- speed_mask |= ADVERTISED_10000baseT_Full ;
1766
+ linkmode_set_bit ( ETHTOOL_LINK_MODE_10000baseT_Full_BIT , mode ) ;
1768
1767
if (fw_speeds & BNXT_LINK_SPEED_MSK_40GB )
1769
- speed_mask |= ADVERTISED_40000baseCR4_Full ;
1770
-
1771
- if ((fw_pause & BNXT_LINK_PAUSE_BOTH ) == BNXT_LINK_PAUSE_BOTH )
1772
- speed_mask |= ADVERTISED_Pause ;
1773
- else if (fw_pause & BNXT_LINK_PAUSE_TX )
1774
- speed_mask |= ADVERTISED_Asym_Pause ;
1775
- else if (fw_pause & BNXT_LINK_PAUSE_RX )
1776
- speed_mask |= ADVERTISED_Pause | ADVERTISED_Asym_Pause ;
1777
-
1778
- return speed_mask ;
1768
+ linkmode_set_bit (ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT , mode );
1779
1769
}
1780
1770
1781
1771
enum bnxt_media_type {
@@ -2643,23 +2633,22 @@ bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
2643
2633
return 0 ;
2644
2634
}
2645
2635
2646
- u16 bnxt_get_fw_auto_link_speeds (u32 advertising )
2636
+ u16 bnxt_get_fw_auto_link_speeds (const unsigned long * mode )
2647
2637
{
2648
2638
u16 fw_speed_mask = 0 ;
2649
2639
2650
- /* only support autoneg at speed 100, 1000, and 10000 */
2651
- if (advertising & (ADVERTISED_100baseT_Full |
2652
- ADVERTISED_100baseT_Half )) {
2640
+ if (linkmode_test_bit (ETHTOOL_LINK_MODE_100baseT_Full_BIT , mode ) ||
2641
+ linkmode_test_bit (ETHTOOL_LINK_MODE_100baseT_Half_BIT , mode ))
2653
2642
fw_speed_mask |= BNXT_LINK_SPEED_MSK_100MB ;
2654
- }
2655
- if (advertising & ( ADVERTISED_1000baseT_Full |
2656
- ADVERTISED_1000baseT_Half )) {
2643
+
2644
+ if (linkmode_test_bit ( ETHTOOL_LINK_MODE_1000baseT_Full_BIT , mode ) | |
2645
+ linkmode_test_bit ( ETHTOOL_LINK_MODE_1000baseT_Half_BIT , mode ))
2657
2646
fw_speed_mask |= BNXT_LINK_SPEED_MSK_1GB ;
2658
- }
2659
- if (advertising & ADVERTISED_10000baseT_Full )
2647
+
2648
+ if (linkmode_test_bit ( ETHTOOL_LINK_MODE_10000baseT_Full_BIT , mode ) )
2660
2649
fw_speed_mask |= BNXT_LINK_SPEED_MSK_10GB ;
2661
2650
2662
- if (advertising & ADVERTISED_40000baseCR4_Full )
2651
+ if (linkmode_test_bit ( ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT , mode ) )
2663
2652
fw_speed_mask |= BNXT_LINK_SPEED_MSK_40GB ;
2664
2653
2665
2654
return fw_speed_mask ;
@@ -3886,10 +3875,11 @@ static int bnxt_set_eeprom(struct net_device *dev,
3886
3875
3887
3876
static int bnxt_set_eee (struct net_device * dev , struct ethtool_keee * edata )
3888
3877
{
3878
+ __ETHTOOL_DECLARE_LINK_MODE_MASK (advertising );
3879
+ __ETHTOOL_DECLARE_LINK_MODE_MASK (tmp );
3889
3880
struct bnxt * bp = netdev_priv (dev );
3890
3881
struct ethtool_keee * eee = & bp -> eee ;
3891
3882
struct bnxt_link_info * link_info = & bp -> link_info ;
3892
- u32 advertising ;
3893
3883
int rc = 0 ;
3894
3884
3895
3885
if (!BNXT_PHY_CFG_ABLE (bp ))
@@ -3899,7 +3889,7 @@ static int bnxt_set_eee(struct net_device *dev, struct ethtool_keee *edata)
3899
3889
return - EOPNOTSUPP ;
3900
3890
3901
3891
mutex_lock (& bp -> link_lock );
3902
- advertising = _bnxt_fw_to_ethtool_adv_spds ( link_info -> advertising , 0 );
3892
+ _bnxt_fw_to_linkmode ( advertising , link_info -> advertising );
3903
3893
if (!edata -> eee_enabled )
3904
3894
goto eee_ok ;
3905
3895
@@ -3919,16 +3909,15 @@ static int bnxt_set_eee(struct net_device *dev, struct ethtool_keee *edata)
3919
3909
edata -> tx_lpi_timer = eee -> tx_lpi_timer ;
3920
3910
}
3921
3911
}
3922
- if (!edata -> advertised_u32 ) {
3923
- edata -> advertised_u32 = advertising & eee -> supported_u32 ;
3924
- } else if (edata -> advertised_u32 & ~advertising ) {
3925
- netdev_warn (dev , "EEE advertised %x must be a subset of autoneg advertised speeds %x\n" ,
3926
- edata -> advertised_u32 , advertising );
3912
+ if (linkmode_empty (edata -> advertised )) {
3913
+ linkmode_and (edata -> advertised , advertising , eee -> supported );
3914
+ } else if (linkmode_andnot (tmp , edata -> advertised , advertising )) {
3915
+ netdev_warn (dev , "EEE advertised must be a subset of autoneg advertised speeds\n" );
3927
3916
rc = - EINVAL ;
3928
3917
goto eee_exit ;
3929
3918
}
3930
3919
3931
- eee -> advertised_u32 = edata -> advertised_u32 ;
3920
+ linkmode_copy ( eee -> advertised , edata -> advertised ) ;
3932
3921
eee -> tx_lpi_enabled = edata -> tx_lpi_enabled ;
3933
3922
eee -> tx_lpi_timer = edata -> tx_lpi_timer ;
3934
3923
eee_ok :
@@ -3954,12 +3943,12 @@ static int bnxt_get_eee(struct net_device *dev, struct ethtool_keee *edata)
3954
3943
/* Preserve tx_lpi_timer so that the last value will be used
3955
3944
* by default when it is re-enabled.
3956
3945
*/
3957
- edata -> advertised_u32 = 0 ;
3946
+ linkmode_zero ( edata -> advertised ) ;
3958
3947
edata -> tx_lpi_enabled = 0 ;
3959
3948
}
3960
3949
3961
3950
if (!bp -> eee .eee_active )
3962
- edata -> lp_advertised_u32 = 0 ;
3951
+ linkmode_zero ( edata -> lp_advertised ) ;
3963
3952
3964
3953
return 0 ;
3965
3954
}
0 commit comments