Skip to contentSkip to conversation

team: add ethtool support

PATCH Applied Flavio Leitner 4 participants 5 messages Dec 30, 2012 – Jan 3, 2013

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

PATCH v2 1/1 team: add ethtool support

This patch adds few ethtool operations to team driver.

---
v2 - removed generic statistics from ethtool

 drivers/net/team/team.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/team/team.c +17 -0
index ad86660..7665a088 100644
@@ -28,6 +28,7 @@
 #include <net/genetlink.h>
 #include <net/netlink.h>
 #include <net/sch_generic.h>
+#include <generated/utsrelease.h>
 #include <linux/if_team.h>
 
 #define DRV_NAME "team"
@@ -1731,6 +1732,21 @@ static const struct net_device_ops team_netdev_ops = {
 	.ndo_fix_features	= team_fix_features,
 };
 
+/***********************
+ * ethtool interface
+ ***********************/
+
+static void team_ethtool_get_drvinfo(struct net_device *dev,
+				     struct ethtool_drvinfo *drvinfo)
+{
+	strncpy(drvinfo->driver, DRV_NAME, 32);
+	strncpy(drvinfo->version, UTS_RELEASE, 32);
+}
+
+static const struct ethtool_ops team_ethtool_ops = {
+	.get_drvinfo		= team_ethtool_get_drvinfo,
+	.get_link		= ethtool_op_get_link,
+};
 
 /***********************
  * rt netlink interface
@@ -1780,6 +1796,7 @@ static void team_setup(struct net_device *dev)
 	ether_setup(dev);
 
 	dev->netdev_ops = &team_netdev_ops;
+	dev->ethtool_ops = &team_ethtool_ops;
 	dev->destructor	= team_destructor;
 	dev->tx_queue_len = 0;
 	dev->flags |= IFF_MULTICAST;
Signature · 1 line
1.8.0.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 54 lines · Sun, Dec 30, 2012 at 03:37:33AM CET, [email protected] wrote:

This patch adds few ethtool operations to team driver.

---
v2 - removed generic statistics from ethtool

drivers/net/team/team.c | 17 +++++++++++++++++

1 file changed, 17 insertions(+)
drivers/net/team/team.c +17 -0
index ad86660..7665a088 100644
@@ -28,6 +28,7 @@
 #include <net/genetlink.h>
 #include <net/netlink.h>
 #include <net/sch_generic.h>
+#include <generated/utsrelease.h>
 #include <linux/if_team.h>
 
 #define DRV_NAME "team"
@@ -1731,6 +1732,21 @@ static const struct net_device_ops team_netdev_ops = {
 	.ndo_fix_features	= team_fix_features,
 };
 
+/***********************
+ * ethtool interface
+ ***********************/
+
+static void team_ethtool_get_drvinfo(struct net_device *dev,
+				     struct ethtool_drvinfo *drvinfo)
+{
+	strncpy(drvinfo->driver, DRV_NAME, 32);
+	strncpy(drvinfo->version, UTS_RELEASE, 32);
+}
+
+static const struct ethtool_ops team_ethtool_ops = {
+	.get_drvinfo		= team_ethtool_get_drvinfo,
+	.get_link		= ethtool_op_get_link,
+};
 
 /***********************
 * rt netlink interface
@@ -1780,6 +1796,7 @@ static void team_setup(struct net_device *dev)
 	ether_setup(dev);
 
 	dev->netdev_ops = &team_netdev_ops;
+	dev->ethtool_ops = &team_ethtool_ops;
 	dev->destructor	= team_destructor;
 	dev->tx_queue_len = 0;
 	dev->flags |= IFF_MULTICAST;
Signature · 1 line
1.8.0.1
#3 lore raw
In reply to Flavio Leitner
Quoted 13 lines · Flavio Leitner

This patch adds few ethtool operations to team driver.

---
v2 - removed generic statistics from ethtool

 drivers/net/team/team.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/team/team.c +0 -0
index ad86660..7665a088 100644

[...]

drivers/net/team/team.c static const struct net_device_ops team_netdev_ops = { · line 1744

Quoted 6 lines
drivers/net/team/team.c +6 -0
+static void team_ethtool_get_drvinfo(struct net_device *dev,
+				     struct ethtool_drvinfo *drvinfo)
+{
+	strncpy(drvinfo->driver, DRV_NAME, 32);
+	strncpy(drvinfo->version, UTS_RELEASE, 32);
+}

[...]

These must be null-terminated, so use strlcpy() not strncpy().

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#4 lore raw
Quoted 23 lines · Ben Hutchings
Quoted 13 lines · Flavio Leitner

This patch adds few ethtool operations to team driver.

---
v2 - removed generic statistics from ethtool

 drivers/net/team/team.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/net/team/team.c +0 -0
index ad86660..7665a088 100644

[...]

Quoted 6 lines
drivers/net/team/team.c +6 -0
+static void team_ethtool_get_drvinfo(struct net_device *dev,
+				     struct ethtool_drvinfo *drvinfo)
+{
+	strncpy(drvinfo->driver, DRV_NAME, 32);
+	strncpy(drvinfo->version, UTS_RELEASE, 32);
+}

[...]

Quoted 1 line

These must be null-terminated, so use strlcpy() not strncpy().

Ok, I will post another patch fixing this and few other drivers as well.

Thank you!

Signature · 1 line
fbl