Skip to contentSkip to conversation

RESEND: [PATCH] Interface Stat Clearing Framework, skge support, ethtool support]

PATCH Phil Dibowitz 1 participant 1 message May 18, 2006

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

Resending this - saw no response.

Hey folks,

A few months back I posted an in-progress patch for adding a clear_stats framework similar to the get_stats framework and implimenting support for it in the skge driver (the one NIC I have access to), as well as adding the ethtool support for it.

While a few people said they didn't see the need for it, other people did see the need for it, and I know it's a common request on many sysadmin mailing lists I'm on.

Since no one seemed to have any technical issue with the patch, I've cleaned up the patch, tested it, and fixed a few minor issues.

Unless someone has an objection, I'd think this would be useful to a lot of people.

There are two patches attached:

interface_stats_clear.patch - the kernel patch against 2.6.17-rc3-git2 ethtool3-clearstats.patch - the ethtool patch to add the -z flag to
support it.

If the kernel patch gets accepted I'll send a more complete ethtool patch with documentation updates, etc.

Thanks.

Signature · 7 lines
Phil Dibowitz                             [email protected]
Freeware and Technical Pages              Insanity Palace of Metallica
http://www.phildev.net/                   http://www.ipom.com/

"Be who you are and say what you feel, because those who mind don't
matter and those who matter don't mind."
 - Dr. Suess

This patch adds support for clearing interface statistics using the ethtool interface adding a new 0x23 command. It adds a clear_stats function pointer to the net_device struct, and then impliments local functions in the driver much the say get_stats works. The ethtool funtion pointer points to the same functions. The driver-local functions are currently only implimented in the skge driver.

---

include/linux/netdevice.h renamed from include/linux/netdevice.h~interface_stats_clear +1 -0
diff -puN include/linux/netdevice.h~interface_stats_clear include/linux/netdevice.h
@@ -319,6 +319,7 @@ struct net_device
 
 
 	struct net_device_stats* (*get_stats)(struct net_device *dev);
+	void (*clear_stats)(struct net_device *dev);
 	struct iw_statistics*	(*get_wireless_stats)(struct net_device *dev);
 
 	/* List of functions to handle Wireless Extensions (instead of ioctl).
drivers/net/skge.c renamed from drivers/net/skge.c~interface_stats_clear +43 -1

86 lines not on this page · raw message

include/linux/ethtool.h renamed from include/linux/ethtool.h~interface_stats_clear +2 -0
diff -puN include/linux/ethtool.h~interface_stats_clear include/linux/ethtool.h
@@ -365,6 +365,7 @@ struct ethtool_ops {
 	int	(*phys_id)(struct net_device *, u32);
 	int	(*get_stats_count)(struct net_device *);
 	void	(*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *);
+	void    (*clear_ethtool_stats)(struct net_device *);
 	int	(*get_perm_addr)(struct net_device *, struct ethtool_perm_addr *, u8 *);
 	int	(*begin)(struct net_device *);
 	void	(*complete)(struct net_device *);
@@ -408,6 +409,7 @@ struct ethtool_ops {
 #define ETHTOOL_GPERMADDR	0x00000020 /* Get permanent hardware address */
 #define ETHTOOL_GUFO		0x00000021 /* Get UFO enable (ethtool_value) */
 #define ETHTOOL_SUFO		0x00000022 /* Set UFO enable (ethtool_value) */
+#define ETHTOOL_CSTATS		0x00000023 /* Clear NIC-specific statistics */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET
net/core/ethtool.c renamed from net/core/ethtool.c~interface_stats_clear +14 -0
diff -puN net/core/ethtool.c~interface_stats_clear net/core/ethtool.c
@@ -741,6 +741,17 @@ static int ethtool_get_stats(struct net_
 	return ret;
 }
 
+static int ethtool_clear_stats(struct net_device *dev, void __user *useraddr)
+{
+	struct ethtool_ops *ops = dev->ethtool_ops;
+	if (!ops->clear_ethtool_stats)
+		return -EOPNOTSUPP;
+
+	ops->clear_ethtool_stats(dev);
+
+	return 0;
+}
+
 static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
 {
 	struct ethtool_perm_addr epaddr;
@@ -906,6 +917,9 @@ int dev_ethtool(struct ifreq *ifr)
 	case ETHTOOL_SUFO:
 		rc = ethtool_set_ufo(dev, useraddr);
 		break;
+	case ETHTOOL_CSTATS:
+		rc = ethtool_clear_stats(dev, useraddr);
+		break;
 	default:
 		rc =  -EOPNOTSUPP;
 	}

_

ethtool.c renamed from ethtool.c.b4phil +80 -0

116 lines not on this page · raw message

ethtool-copy.h renamed from ethtool-copy.h.b4phil +1 -0
@@ -283,6 +283,7 @@
 #define ETHTOOL_GSTATS		0x0000001d /* get NIC-specific statistics */
 #define ETHTOOL_GTSO		0x0000001e /* Get TSO enable (ethtool_value) */
 #define ETHTOOL_STSO		0x0000001f /* Set TSO enable (ethtool_value) */
+#define ETHTOOL_CSTATS		0x00000023 /* get NIC-specific statistics */
 
 /* compatibility with older code */
 #define SPARC_ETH_GSET		ETHTOOL_GSET