Re: [PATCH v2] net: intel: ixgbe: use new api ethtool_{get|set}_link_ksettings

2017-03-12 Thread David Miller
From: Philippe Reynes 
Date: Tue,  7 Mar 2017 23:32:25 +0100

> The ethtool api {get|set}_settings is deprecated.
> We move this driver to new api {get|set}_link_ksettings.
> 
> As I don't have the hardware, I'd be very pleased if
> someone may test this patch.
> 
> Signed-off-by: Philippe Reynes 
> ---
> Changelog:
> v2:
> - fix compilation (thanks andrewx bowers)

Applied.


[PATCH v2] net: intel: ixgbe: use new api ethtool_{get|set}_link_ksettings

2017-03-07 Thread Philippe Reynes
The ethtool api {get|set}_settings is deprecated.
We move this driver to new api {get|set}_link_ksettings.

As I don't have the hardware, I'd be very pleased if
someone may test this patch.

Signed-off-by: Philippe Reynes 
---
Changelog:
v2:
- fix compilation (thanks andrewx bowers)

 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c |  168 --
 1 files changed, 91 insertions(+), 77 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 90fa5bf..0da0752f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -186,60 +186,62 @@ static u32 ixgbe_get_supported_10gtypes(struct ixgbe_hw 
*hw)
}
 }
 
-static int ixgbe_get_settings(struct net_device *netdev,
- struct ethtool_cmd *ecmd)
+static int ixgbe_get_link_ksettings(struct net_device *netdev,
+   struct ethtool_link_ksettings *cmd)
 {
struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_hw *hw = &adapter->hw;
ixgbe_link_speed supported_link;
bool autoneg = false;
+   u32 supported, advertising;
+
+   ethtool_convert_link_mode_to_legacy_u32(&supported,
+   cmd->link_modes.supported);
 
hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg);
 
/* set the supported link speeds */
if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
-   ecmd->supported |= ixgbe_get_supported_10gtypes(hw);
+   supported |= ixgbe_get_supported_10gtypes(hw);
if (supported_link & IXGBE_LINK_SPEED_1GB_FULL)
-   ecmd->supported |= (ixgbe_isbackplane(hw->phy.media_type)) ?
+   supported |= (ixgbe_isbackplane(hw->phy.media_type)) ?
   SUPPORTED_1000baseKX_Full :
   SUPPORTED_1000baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_100_FULL)
-   ecmd->supported |= SUPPORTED_100baseT_Full;
+   supported |= SUPPORTED_100baseT_Full;
if (supported_link & IXGBE_LINK_SPEED_10_FULL)
-   ecmd->supported |= SUPPORTED_10baseT_Full;
+   supported |= SUPPORTED_10baseT_Full;
 
/* default advertised speed if phy.autoneg_advertised isn't set */
-   ecmd->advertising = ecmd->supported;
+   advertising = supported;
/* set the advertised speeds */
if (hw->phy.autoneg_advertised) {
-   ecmd->advertising = 0;
+   advertising = 0;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10_FULL)
-   ecmd->advertising |= ADVERTISED_10baseT_Full;
+   advertising |= ADVERTISED_10baseT_Full;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
-   ecmd->advertising |= ADVERTISED_100baseT_Full;
+   advertising |= ADVERTISED_100baseT_Full;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
-   ecmd->advertising |= ecmd->supported & ADVRTSD_MSK_10G;
+   advertising |= supported & ADVRTSD_MSK_10G;
if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) {
-   if (ecmd->supported & SUPPORTED_1000baseKX_Full)
-   ecmd->advertising |= ADVERTISED_1000baseKX_Full;
+   if (supported & SUPPORTED_1000baseKX_Full)
+   advertising |= ADVERTISED_1000baseKX_Full;
else
-   ecmd->advertising |= ADVERTISED_1000baseT_Full;
+   advertising |= ADVERTISED_1000baseT_Full;
}
} else {
if (hw->phy.multispeed_fiber && !autoneg) {
if (supported_link & IXGBE_LINK_SPEED_10GB_FULL)
-   ecmd->advertising = ADVERTISED_1baseT_Full;
+   advertising = ADVERTISED_1baseT_Full;
}
}
 
if (autoneg) {
-   ecmd->supported |= SUPPORTED_Autoneg;
-   ecmd->advertising |= ADVERTISED_Autoneg;
-   ecmd->autoneg = AUTONEG_ENABLE;
+   supported |= SUPPORTED_Autoneg;
+   advertising |= ADVERTISED_Autoneg;
+   cmd->base.autoneg = AUTONEG_ENABLE;
} else
-   ecmd->autoneg = AUTONEG_DISABLE;
-
-   ecmd->transceiver = XCVR_EXTERNAL;
+   cmd->base.autoneg = AUTONEG_DISABLE;
 
/* Determine the remaining settings based on the PHY type. */
switch (adapter->hw.phy.type) {
@@ -248,14 +250,14 @@ static int ixgbe_get_settings(struct net_device *netdev,
case ixgbe_phy_x550em_ext_t:
case ixgbe_phy_fw:
case ixgbe_phy_cu_unknown: