netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sridhar Samudrala <sridhar.samudrala@intel.com>
To: davem@davemloft.net, jiri@resnulli.us, netdev@vger.kernel.org
Subject: [PATCH] team: add support to get speed via ethtool
Date: Thu,  5 Mar 2015 13:48:35 -0800	[thread overview]
Message-ID: <1425592115-1750-1-git-send-email-sridhar.samudrala@intel.com> (raw)

With this patch ethtool <team> OR cat /sys/class/net/<team>/speed
returns the speed of team based on member ports speed and state.

Based on get speed support in bonding driver.

Signed-off-by: Sridhar Samudrala <sridhar.samudrala@intel.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 9d3366f..e822803 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1954,6 +1954,30 @@ static int team_change_carrier(struct net_device *dev, bool new_carrier)
 	return 0;
 }
 
+static int team_ethtool_get_settings(struct net_device *dev,
+				     struct ethtool_cmd *ecmd)
+{
+	struct team *team = netdev_priv(dev);
+	struct team_port *port;
+	unsigned long speed = 0;
+
+	ecmd->duplex = DUPLEX_UNKNOWN;
+	ecmd->port = PORT_OTHER;
+
+	mutex_lock(&team->lock);
+	list_for_each_entry(port, &team->port_list, list) {
+		if (port->linkup)
+			speed += port->state.speed;
+		if (ecmd->duplex == DUPLEX_UNKNOWN &&
+		    port->state.duplex != 0)
+			ecmd->duplex = port->state.duplex;
+	}
+	ethtool_cmd_speed_set(ecmd, speed);
+	mutex_unlock(&team->lock);
+
+	return 0;
+}
+
 static const struct net_device_ops team_netdev_ops = {
 	.ndo_init		= team_init,
 	.ndo_uninit		= team_uninit,
@@ -1995,6 +2019,7 @@ static void team_ethtool_get_drvinfo(struct net_device *dev,
 static const struct ethtool_ops team_ethtool_ops = {
 	.get_drvinfo		= team_ethtool_get_drvinfo,
 	.get_link		= ethtool_op_get_link,
+	.get_settings		= team_ethtool_get_settings,
 };
 
 /***********************
-- 
1.8.4.2

             reply	other threads:[~2015-03-05 21:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05 21:48 Sridhar Samudrala [this message]
2015-03-06  5:24 ` [PATCH] team: add support to get speed via ethtool David Miller
2015-03-07  3:10   ` Andy Gospodarek
2015-03-07  6:12     ` David Miller
2015-03-07 12:30       ` Andy Gospodarek
2015-03-07  6:14     ` David Miller
2015-03-07 12:47       ` Andy Gospodarek
2015-03-06  7:16 ` Jiri Pirko
2015-03-06 19:30   ` Samudrala, Sridhar
2015-03-07  2:42     ` Andy Gospodarek
2015-03-07 13:57     ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425592115-1750-1-git-send-email-sridhar.samudrala@intel.com \
    --to=sridhar.samudrala@intel.com \
    --cc=davem@davemloft.net \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).