I'm manually pasting this out of my consolidated patch..it's against
2.6.15.
You should be able to ignore the send-to-self and crc related logic
w/out incident.
If this won't work, I can send you a link to my full patch, but it has a
lot
more than just this netdev stats hack in it....
Thanks, this ought to do it.
Here is how you use it in user-space:
struct my_net_device_stats_32 {
uint32 rx_packets; /* total packets received */
uint32 tx_packets; /* total packets transmitted */
uint32 rx_bytes; /* total bytes received */
uint32 tx_bytes; /* total bytes transmitted */
uint32 rx_errors; /* bad packets received */
uint32 tx_errors; /* packet transmit problems */
uint32 rx_dropped; /* no space in linux buffers */
uint32 tx_dropped; /* no space available in linux */
uint32 multicast; /* multicast packets received */
uint32 collisions;
/* detailed rx_errors: */
uint32 rx_length_errors;
uint32 rx_over_errors; /* receiver ring buff overflow */
uint32 rx_crc_errors; /* recved pkt with crc error */
uint32 rx_frame_errors; /* recv'd frame alignment error */
uint32 rx_fifo_errors; /* recv'r fifo overrun */
uint32 rx_missed_errors; /* receiver missed packet */
/* detailed tx_errors */
uint32 tx_aborted_errors;
uint32 tx_carrier_errors;
uint32 tx_fifo_errors;
uint32 tx_heartbeat_errors;
uint32 tx_window_errors;
/* for cslip etc */
uint32 rx_compressed;
uint32 tx_compressed;
};
Hmmm, most (if not all) of those you get using netlink, like so for example:
ip -s -s link show dev eth0
But I see the incentive to add those to ethtool as well.
+ * set_rx_all: Set or clear IFF_ACCEPT_ALL_FRAMES, see if.h
+ * get_rx_all: Return 1 if set, 0 if not.
+ * set_save_fcs: Set or clear IFF_SAVE_FCS, see if.h
+ * get_save_fcs: Return 1 if set, 0 if not.
Something we would like to have in the standard kernel?
+/* Handle some generic ethtool commands here */
+static int ethtool_get_netdev_stats(struct net_device *dev, void
*useraddr) {
+
+ struct ethtool_ndstats* nds = (struct ethtool_ndstats*)(useraddr);
+
+ struct net_device_stats *stats = dev->get_stats(dev);
+ if (stats) {
+ if (copy_to_user(nds->data, stats, sizeof(*stats))) {
+ return -EFAULT;
+ }
+ }
+ else {
+ return -EOPNOTSUPP;
+ }
+ return 0;
+}
Simple enough.
int dev_ethtool(struct ifreq *ifr)
@@ -793,18 +881,28 @@ int dev_ethtool(struct ifreq *ifr)
if (!dev || !netif_device_present(dev))
return -ENODEV;
- if (!dev->ethtool_ops)
- goto ioctl;
-
if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
return -EFAULT;
- if(dev->ethtool_ops->begin)
+ if(dev->ethtool_ops && dev->ethtool_ops->begin)
if ((rc = dev->ethtool_ops->begin(dev)) < 0)
return rc;
old_features = dev->features;
-
+
+ /* Handle some generic operations that do not require specific
+ * ethtool handlers.
+ */
+ switch (ethcmd) {
+ case ETHTOOL_GNDSTATS:
+ return ethtool_get_netdev_stats(dev, useraddr);
+ default:
+ break;
+ }
+
+ if (!dev->ethtool_ops)
+ goto ioctl;
+
switch (ethcmd) {
case ETHTOOL_GSET:
Thanks for this patch, I wonder if this should be integrated into
ethtool per default?
Best regards,
Roberto Nibali, ratz
--
echo
'[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html