Skip to contentSkip to conversation

net: veth: use new api ethtool_{get|set}_link_ksettings

PATCH In review Philippe Reynes 2 participants 3 messages Mar 18, 2017 – Mar 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: veth: use new api ethtool_{get|set}_link_ksettings

The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings.

---
 drivers/net/veth.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/veth.c +10 -12
index 8c39d6d..730b133 100644
@@ -45,18 +45,16 @@ struct veth_priv {
 	{ "peer_ifindex" },
 };
 
-static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int veth_get_link_ksettings(struct net_device *dev,
+				   struct ethtool_link_ksettings *cmd)
 {
-	cmd->supported		= 0;
-	cmd->advertising	= 0;
-	ethtool_cmd_speed_set(cmd, SPEED_10000);
-	cmd->duplex		= DUPLEX_FULL;
-	cmd->port		= PORT_TP;
-	cmd->phy_address	= 0;
-	cmd->transceiver	= XCVR_INTERNAL;
-	cmd->autoneg		= AUTONEG_DISABLE;
-	cmd->maxtxpkt		= 0;
-	cmd->maxrxpkt		= 0;
+	ethtool_link_ksettings_zero_link_mode(cmd, supported);
+	ethtool_link_ksettings_zero_link_mode(cmd, advertising);
+	cmd->base.speed = SPEED_10000;
+	cmd->base.duplex	= DUPLEX_FULL;
+	cmd->base.port		= PORT_TP;
+	cmd->base.phy_address	= 0;
+	cmd->base.autoneg	= AUTONEG_DISABLE;
 	return 0;
 }
 
@@ -95,12 +93,12 @@ static void veth_get_ethtool_stats(struct net_device *dev,
 }
 
 static const struct ethtool_ops veth_ethtool_ops = {
-	.get_settings		= veth_get_settings,
 	.get_drvinfo		= veth_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
 	.get_strings		= veth_get_strings,
 	.get_sset_count		= veth_get_sset_count,
 	.get_ethtool_stats	= veth_get_ethtool_stats,
+	.get_link_ksettings	= veth_get_link_ksettings,
 };
 
 static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 26 lines · Philippe Reynes

The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings.

---
 drivers/net/veth.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/veth.c +2 -7
index 8c39d6d..730b133 100644
@@ -45,18 +45,16 @@ struct veth_priv {
        { "peer_ifindex" },
 };
 
-static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+static int veth_get_link_ksettings(struct net_device *dev,
+                                  struct ethtool_link_ksettings *cmd)
 {
-       cmd->supported          = 0;
-       cmd->advertising        = 0;
-       ethtool_cmd_speed_set(cmd, SPEED_10000);
-       cmd->duplex             = DUPLEX_FULL;
-       cmd->port               = PORT_TP;
-       cmd->phy_address        = 0;

drivers/net/veth.c struct veth_priv { · line 56

Quoted 10 lines
drivers/net/veth.c +6 -4
-       cmd->transceiver        = XCVR_INTERNAL;
-       cmd->autoneg            = AUTONEG_DISABLE;
-       cmd->maxtxpkt           = 0;
-       cmd->maxrxpkt           = 0;
+       ethtool_link_ksettings_zero_link_mode(cmd, supported);
+       ethtool_link_ksettings_zero_link_mode(cmd, advertising);
+       cmd->base.speed = SPEED_10000;
+       cmd->base.duplex        = DUPLEX_FULL;
+       cmd->base.port          = PORT_TP;
+       cmd->base.phy_address   = 0;

It seem always:

        memset(&link_ksettings, 0, sizeof(link_ksettings));
        err = dev->ethtool_ops->get_link_ksettings(dev, &link_ksettings);

do we really need:

       ethtool_link_ksettings_zero_link_mode(cmd, supported);
       ethtool_link_ksettings_zero_link_mode(cmd, advertising);
       cmd->base.phy_address   = 0;

?

Quoted 21 lines
drivers/net/veth.c +2 -2
+       cmd->base.autoneg       = AUTONEG_DISABLE;
        return 0;
 }
 
@@ -95,12 +93,12 @@ static void veth_get_ethtool_stats(struct net_device *dev,
 }
 
 static const struct ethtool_ops veth_ethtool_ops = {
-       .get_settings           = veth_get_settings,
        .get_drvinfo            = veth_get_drvinfo,
        .get_link               = ethtool_op_get_link,
        .get_strings            = veth_get_strings,
        .get_sset_count         = veth_get_sset_count,
        .get_ethtool_stats      = veth_get_ethtool_stats,
+       .get_link_ksettings     = veth_get_link_ksettings,
 };
 
 static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
--

1.7.4.4

#2 lore raw

Hi Xin Long,

Quoted 39 lines · Xin Long
Quoted 27 lines · Philippe Reynes

The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings.

---
 drivers/net/veth.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
drivers/net/veth.c +2 -7
index 8c39d6d..730b133 100644
@@ -45,18 +45,16 @@ struct veth_priv {
        { "peer_ifindex" },
 };
 
-static int veth_get_settings(struct net_device *dev, struct ethtool_cmd
 *cmd)
+static int veth_get_link_ksettings(struct net_device *dev,
+                                  struct ethtool_link_ksettings *cmd)
 {
-       cmd->supported          = 0;
-       cmd->advertising        = 0;
-       ethtool_cmd_speed_set(cmd, SPEED_10000);
-       cmd->duplex             = DUPLEX_FULL;
-       cmd->port               = PORT_TP;
-       cmd->phy_address        = 0;

drivers/net/veth.c struct veth_priv { · line 57

Quoted 10 lines
drivers/net/veth.c +6 -4
-       cmd->transceiver        = XCVR_INTERNAL;
-       cmd->autoneg            = AUTONEG_DISABLE;
-       cmd->maxtxpkt           = 0;
-       cmd->maxrxpkt           = 0;
+       ethtool_link_ksettings_zero_link_mode(cmd, supported);
+       ethtool_link_ksettings_zero_link_mode(cmd, advertising);
+       cmd->base.speed = SPEED_10000;
+       cmd->base.duplex        = DUPLEX_FULL;
+       cmd->base.port          = PORT_TP;
+       cmd->base.phy_address   = 0;

It seem always:

Quoted 2 lines
        memset(&link_ksettings, 0, sizeof(link_ksettings));
        err = dev->ethtool_ops->get_link_ksettings(dev, &link_ksettings);

You're right.

Quoted 5 lines

do we really need:

       ethtool_link_ksettings_zero_link_mode(cmd, supported);
       ethtool_link_ksettings_zero_link_mode(cmd, advertising);
       cmd->base.phy_address   = 0;

?

As this code is just an api change, I prefer to keep this code. Of course, if David prefer to remove this code, I'll remove it.

But you're right, there is a lot of function "get_link_ksettings" that set to 0 some variable. It's useless as done just before calling the callback.

Regards,
Philippe