All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] team: add ethtool get_link_ksettings
@ 2019-05-27  3:31 Hangbin Liu
  2019-05-27 17:09 ` David Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Hangbin Liu @ 2019-05-27  3:31 UTC (permalink / raw)
  To: netdev; +Cc: Jiri Pirko, davem, Hangbin Liu

Like bond, add ethtool get_link_ksettings to show the total speed.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 drivers/net/team/team.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index 2106045b3e16..5e892ee4c006 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -2058,9 +2058,34 @@ static void team_ethtool_get_drvinfo(struct net_device *dev,
 	strlcpy(drvinfo->version, UTS_RELEASE, sizeof(drvinfo->version));
 }
 
+static int team_ethtool_get_link_ksettings(struct net_device *dev,
+					   struct ethtool_link_ksettings *cmd)
+{
+	struct team *team= netdev_priv(dev);
+	unsigned long speed = 0;
+	struct team_port *port;
+
+	cmd->base.duplex = DUPLEX_UNKNOWN;
+	cmd->base.port = PORT_OTHER;
+
+	list_for_each_entry(port, &team->port_list, list) {
+		if (team_port_txable(port)) {
+			if (port->state.speed != SPEED_UNKNOWN)
+				speed += port->state.speed;
+			if (cmd->base.duplex == DUPLEX_UNKNOWN &&
+			    port->state.duplex != DUPLEX_UNKNOWN)
+				cmd->base.duplex = port->state.duplex;
+		}
+	}
+	cmd->base.speed = speed ? : SPEED_UNKNOWN;
+
+	return 0;
+}
+
 static const struct ethtool_ops team_ethtool_ops = {
 	.get_drvinfo		= team_ethtool_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
+	.get_link_ksettings	= team_ethtool_get_link_ksettings,
 };
 
 /***********************
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-06-17 20:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27  3:31 [PATCH net-next] team: add ethtool get_link_ksettings Hangbin Liu
2019-05-27 17:09 ` David Miller
2019-05-28  9:08 ` Jiri Pirko
2019-05-28 10:02   ` Hangbin Liu
2019-05-28 11:24     ` Jiri Pirko
2019-06-13  6:16       ` Hangbin Liu
2019-06-14  8:32         ` Jiri Pirko
2019-06-14 15:55           ` David Miller
2019-06-14  8:32 ` Jiri Pirko
2019-06-17  1:32 ` [PATCHv2 " Hangbin Liu
2019-06-17  9:03   ` Jiri Pirko
2019-06-17 20:23   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.