* [PATCH] e1000e: convert to stats64
@ 2010-12-14 20:32 Flavio Leitner
2010-12-14 21:29 ` Eric Dumazet
2010-12-15 23:59 ` [PATCH] " Jeff Kirsher
0 siblings, 2 replies; 10+ messages in thread
From: Flavio Leitner @ 2010-12-14 20:32 UTC (permalink / raw)
To: netdev; +Cc: e1000-devel, Flavio Leitner
Provides accurate stats at the time user reads them.
Signed-off-by: Flavio Leitner <fleitner@redhat.com>
---
drivers/net/e1000e/e1000.h | 5 ++-
drivers/net/e1000e/ethtool.c | 27 +++++++++-------
drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
3 files changed, 59 insertions(+), 41 deletions(-)
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index fdc67fe..5a5e944 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -363,6 +363,8 @@ struct e1000_adapter {
/* structs defined in e1000_hw.h */
struct e1000_hw hw;
+ spinlock_t stats64_lock;
+ struct rtnl_link_stats64 stats64;
struct e1000_hw_stats stats;
struct e1000_phy_info phy_info;
struct e1000_phy_stats phy_stats;
@@ -492,7 +494,8 @@ extern int e1000e_setup_rx_resources(struct e1000_adapter *adapter);
extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
-extern void e1000e_update_stats(struct e1000_adapter *adapter);
+extern void e1000e_update_stats(struct e1000_adapter *adapter,
+ struct rtnl_link_stats64 *net_stats);
extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 8984d16..07e4d7c 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -49,8 +49,8 @@ struct e1000_stats {
sizeof(((struct e1000_adapter *)0)->m), \
offsetof(struct e1000_adapter, m)
#define E1000_NETDEV_STAT(m) NETDEV_STATS, \
- sizeof(((struct net_device *)0)->m), \
- offsetof(struct net_device, m)
+ sizeof(((struct rtnl_link_stats64 *)0)->m), \
+ offsetof(struct rtnl_link_stats64, m)
static const struct e1000_stats e1000_gstrings_stats[] = {
{ "rx_packets", E1000_STAT(stats.gprc) },
@@ -61,21 +61,21 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
{ "tx_broadcast", E1000_STAT(stats.bptc) },
{ "rx_multicast", E1000_STAT(stats.mprc) },
{ "tx_multicast", E1000_STAT(stats.mptc) },
- { "rx_errors", E1000_NETDEV_STAT(stats.rx_errors) },
- { "tx_errors", E1000_NETDEV_STAT(stats.tx_errors) },
- { "tx_dropped", E1000_NETDEV_STAT(stats.tx_dropped) },
+ { "rx_errors", E1000_NETDEV_STAT(rx_errors) },
+ { "tx_errors", E1000_NETDEV_STAT(tx_errors) },
+ { "tx_dropped", E1000_NETDEV_STAT(tx_dropped) },
{ "multicast", E1000_STAT(stats.mprc) },
{ "collisions", E1000_STAT(stats.colc) },
- { "rx_length_errors", E1000_NETDEV_STAT(stats.rx_length_errors) },
- { "rx_over_errors", E1000_NETDEV_STAT(stats.rx_over_errors) },
+ { "rx_length_errors", E1000_NETDEV_STAT(rx_length_errors) },
+ { "rx_over_errors", E1000_NETDEV_STAT(rx_over_errors) },
{ "rx_crc_errors", E1000_STAT(stats.crcerrs) },
- { "rx_frame_errors", E1000_NETDEV_STAT(stats.rx_frame_errors) },
+ { "rx_frame_errors", E1000_NETDEV_STAT(rx_frame_errors) },
{ "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
{ "rx_missed_errors", E1000_STAT(stats.mpc) },
{ "tx_aborted_errors", E1000_STAT(stats.ecol) },
{ "tx_carrier_errors", E1000_STAT(stats.tncrs) },
- { "tx_fifo_errors", E1000_NETDEV_STAT(stats.tx_fifo_errors) },
- { "tx_heartbeat_errors", E1000_NETDEV_STAT(stats.tx_heartbeat_errors) },
+ { "tx_fifo_errors", E1000_NETDEV_STAT(tx_fifo_errors) },
+ { "tx_heartbeat_errors", E1000_NETDEV_STAT(tx_heartbeat_errors) },
{ "tx_window_errors", E1000_STAT(stats.latecol) },
{ "tx_abort_late_coll", E1000_STAT(stats.latecol) },
{ "tx_deferred_ok", E1000_STAT(stats.dc) },
@@ -1972,14 +1972,16 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
u64 *data)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
+ struct rtnl_link_stats64 *net_stats = &adapter->stats64;
int i;
char *p = NULL;
- e1000e_update_stats(adapter);
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter, net_stats);
for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
switch (e1000_gstrings_stats[i].type) {
case NETDEV_STATS:
- p = (char *) netdev +
+ p = (char *) net_stats +
e1000_gstrings_stats[i].stat_offset;
break;
case E1000_STATS:
@@ -1991,6 +1993,7 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
+ spin_unlock(&adapter->stats64_lock);
}
static void e1000_get_strings(struct net_device *netdev, u32 stringset,
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index c4ca162..0b919ab 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -894,8 +894,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -1051,8 +1049,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
}
adapter->total_tx_bytes += total_tx_bytes;
adapter->total_tx_packets += total_tx_packets;
- netdev->stats.tx_bytes += total_tx_bytes;
- netdev->stats.tx_packets += total_tx_packets;
return count < tx_ring->count;
}
@@ -1240,8 +1236,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -1421,8 +1415,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -3367,6 +3359,11 @@ void e1000e_down(struct e1000_adapter *adapter)
del_timer_sync(&adapter->phy_info_timer);
netif_carrier_off(netdev);
+
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter, &adapter->stats64);
+ spin_unlock(&adapter->stats64_lock);
+
adapter->link_speed = 0;
adapter->link_duplex = 0;
@@ -3408,6 +3405,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
+ spin_lock_init(&adapter->stats64_lock);
+
e1000e_set_interrupt_capability(adapter);
if (e1000_alloc_queues(adapter))
@@ -3880,9 +3879,9 @@ release:
* e1000e_update_stats - Update the board statistics counters
* @adapter: board private structure
**/
-void e1000e_update_stats(struct e1000_adapter *adapter)
+void e1000e_update_stats(struct e1000_adapter *adapter,
+ struct rtnl_link_stats64 *net_stats)
{
- struct net_device *netdev = adapter->netdev;
struct e1000_hw *hw = &adapter->hw;
struct pci_dev *pdev = adapter->pdev;
@@ -3950,8 +3949,12 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
adapter->stats.tsctfc += er32(TSCTFC);
/* Fill out the OS statistics structure */
- netdev->stats.multicast = adapter->stats.mprc;
- netdev->stats.collisions = adapter->stats.colc;
+ net_stats->rx_bytes = adapter->stats.gorc;
+ net_stats->rx_packets = adapter->stats.gprc;
+ net_stats->tx_bytes = adapter->stats.gotc;
+ net_stats->tx_packets = adapter->stats.gptc;
+ net_stats->multicast = adapter->stats.mprc;
+ net_stats->collisions = adapter->stats.colc;
/* Rx Errors */
@@ -3959,22 +3962,22 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
* RLEC on some newer hardware can be incorrect so build
* our own version based on RUC and ROC
*/
- netdev->stats.rx_errors = adapter->stats.rxerrc +
+ net_stats->rx_errors = adapter->stats.rxerrc +
adapter->stats.crcerrs + adapter->stats.algnerrc +
adapter->stats.ruc + adapter->stats.roc +
adapter->stats.cexterr;
- netdev->stats.rx_length_errors = adapter->stats.ruc +
+ net_stats->rx_length_errors = adapter->stats.ruc +
adapter->stats.roc;
- netdev->stats.rx_crc_errors = adapter->stats.crcerrs;
- netdev->stats.rx_frame_errors = adapter->stats.algnerrc;
- netdev->stats.rx_missed_errors = adapter->stats.mpc;
+ net_stats->rx_crc_errors = adapter->stats.crcerrs;
+ net_stats->rx_frame_errors = adapter->stats.algnerrc;
+ net_stats->rx_missed_errors = adapter->stats.mpc;
/* Tx Errors */
- netdev->stats.tx_errors = adapter->stats.ecol +
+ net_stats->tx_errors = adapter->stats.ecol +
adapter->stats.latecol;
- netdev->stats.tx_aborted_errors = adapter->stats.ecol;
- netdev->stats.tx_window_errors = adapter->stats.latecol;
- netdev->stats.tx_carrier_errors = adapter->stats.tncrs;
+ net_stats->tx_aborted_errors = adapter->stats.ecol;
+ net_stats->tx_window_errors = adapter->stats.latecol;
+ net_stats->tx_carrier_errors = adapter->stats.tncrs;
/* Tx Dropped needs to be maintained elsewhere */
@@ -4279,7 +4282,9 @@ static void e1000_watchdog_task(struct work_struct *work)
}
link_up:
- e1000e_update_stats(adapter);
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter, &adapter->stats64);
+ spin_unlock(&adapter->stats64_lock);
mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
adapter->tpt_old = adapter->stats.tpt;
@@ -4891,16 +4896,23 @@ static void e1000_reset_task(struct work_struct *work)
}
/**
- * e1000_get_stats - Get System Network Statistics
+ * e1000_get_stats64 - Get System Network Statistics
* @netdev: network interface device structure
+ * @stats: rtnl_link_stats64 pointer
*
* Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
**/
-static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
+static struct rtnl_link_stats64 *e1000_get_stats64(struct net_device *netdev,
+ struct rtnl_link_stats64 *stats)
{
- /* only return the current stats */
- return &netdev->stats;
+ struct e1000_adapter *adapter = netdev_priv(netdev);
+
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter, &adapter->stats64);
+ memcpy(stats, &adapter->stats64, sizeof(*stats));
+ spin_unlock(&adapter->stats64_lock);
+
+ return stats;
}
/**
@@ -5624,7 +5636,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
.ndo_open = e1000_open,
.ndo_stop = e1000_close,
.ndo_start_xmit = e1000_xmit_frame,
- .ndo_get_stats = e1000_get_stats,
+ .ndo_get_stats64 = e1000_get_stats64,
.ndo_set_multicast_list = e1000_set_multi,
.ndo_set_mac_address = e1000_set_mac,
.ndo_change_mtu = e1000_change_mtu,
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] e1000e: convert to stats64
2010-12-14 20:32 [PATCH] e1000e: convert to stats64 Flavio Leitner
@ 2010-12-14 21:29 ` Eric Dumazet
2010-12-16 12:31 ` [PATCH v2] " Flavio Leitner
2010-12-15 23:59 ` [PATCH] " Jeff Kirsher
1 sibling, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2010-12-14 21:29 UTC (permalink / raw)
To: Flavio Leitner; +Cc: netdev, e1000-devel
Le mardi 14 décembre 2010 à 18:32 -0200, Flavio Leitner a écrit :
> Provides accurate stats at the time user reads them.
>
> Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> ---
> drivers/net/e1000e/e1000.h | 5 ++-
> drivers/net/e1000e/ethtool.c | 27 +++++++++-------
> drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
> 3 files changed, 59 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> index fdc67fe..5a5e944 100644
> --- a/drivers/net/e1000e/e1000.h
> +++ b/drivers/net/e1000e/e1000.h
> @@ -363,6 +363,8 @@ struct e1000_adapter {
> /* structs defined in e1000_hw.h */
> struct e1000_hw hw;
>
> + spinlock_t stats64_lock;
> + struct rtnl_link_stats64 stats64;
I am not sure why you add this stats64 in e1000_adapter ?
Why isnt it provided by callers (automatic variable, or provided to
ndo_get_stats64()). I dont see accumulators, only a full rewrite of this
structure in e1000e_update_stats() ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] e1000e: convert to stats64
2010-12-14 20:32 [PATCH] e1000e: convert to stats64 Flavio Leitner
2010-12-14 21:29 ` Eric Dumazet
@ 2010-12-15 23:59 ` Jeff Kirsher
1 sibling, 0 replies; 10+ messages in thread
From: Jeff Kirsher @ 2010-12-15 23:59 UTC (permalink / raw)
To: Flavio Leitner; +Cc: e1000-devel, netdev
On Tue, Dec 14, 2010 at 12:32, Flavio Leitner <fleitner@redhat.com> wrote:
> Provides accurate stats at the time user reads them.
>
> Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> ---
> drivers/net/e1000e/e1000.h | 5 ++-
> drivers/net/e1000e/ethtool.c | 27 +++++++++-------
> drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
> 3 files changed, 59 insertions(+), 41 deletions(-)
>
I have added this patch to my tree for review and testing. Thanks Flavio.
--
Cheers,
Jeff
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] e1000e: convert to stats64
2010-12-14 21:29 ` Eric Dumazet
@ 2010-12-16 12:31 ` Flavio Leitner
2010-12-16 12:50 ` Eric Dumazet
2010-12-17 3:14 ` Jeff Kirsher
0 siblings, 2 replies; 10+ messages in thread
From: Flavio Leitner @ 2010-12-16 12:31 UTC (permalink / raw)
To: Eric Dumazet; +Cc: e1000-devel, netdev, Jeff Kirsher
On Tue, Dec 14, 2010 at 10:29:33PM +0100, Eric Dumazet wrote:
> Le mardi 14 décembre 2010 à 18:32 -0200, Flavio Leitner a écrit :
> > Provides accurate stats at the time user reads them.
> >
> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> > ---
> > drivers/net/e1000e/e1000.h | 5 ++-
> > drivers/net/e1000e/ethtool.c | 27 +++++++++-------
> > drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
> > 3 files changed, 59 insertions(+), 41 deletions(-)
> >
> > diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> > index fdc67fe..5a5e944 100644
> > --- a/drivers/net/e1000e/e1000.h
> > +++ b/drivers/net/e1000e/e1000.h
> > @@ -363,6 +363,8 @@ struct e1000_adapter {
> > /* structs defined in e1000_hw.h */
> > struct e1000_hw hw;
> >
> > + spinlock_t stats64_lock;
> > + struct rtnl_link_stats64 stats64;
>
> I am not sure why you add this stats64 in e1000_adapter ?
>
> Why isnt it provided by callers (automatic variable, or provided to
> ndo_get_stats64()). I dont see accumulators, only a full rewrite of this
> structure in e1000e_update_stats() ?
Good point. I have modified the patch to fix that.
thanks!
>From 3487bd7dacd0c23bba315270139dab6e00e5ff02 Mon Sep 17 00:00:00 2001
From: Flavio Leitner <fleitner@redhat.com>
Date: Thu, 16 Dec 2010 10:26:03 -0200
Subject: [PATCH] e1000e: convert to stats64
Provides accurate stats at the time user reads them.
Signed-off-by: Flavio Leitner <fleitner@redhat.com>
---
drivers/net/e1000e/e1000.h | 3 ++
drivers/net/e1000e/ethtool.c | 25 ++++++++-------
drivers/net/e1000e/netdev.c | 68 +++++++++++++++++++++++++++++++++--------
3 files changed, 70 insertions(+), 26 deletions(-)
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index fdc67fe..d8fc3bc 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -363,6 +363,7 @@ struct e1000_adapter {
/* structs defined in e1000_hw.h */
struct e1000_hw hw;
+ spinlock_t stats64_lock;
struct e1000_hw_stats stats;
struct e1000_phy_info phy_info;
struct e1000_phy_stats phy_stats;
@@ -493,6 +494,8 @@ extern int e1000e_setup_tx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_rx_resources(struct e1000_adapter *adapter);
extern void e1000e_free_tx_resources(struct e1000_adapter *adapter);
extern void e1000e_update_stats(struct e1000_adapter *adapter);
+extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
+ struct rtnl_link_stats64 *stats);
extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter);
extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 8984d16..f43b412 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -49,8 +49,8 @@ struct e1000_stats {
sizeof(((struct e1000_adapter *)0)->m), \
offsetof(struct e1000_adapter, m)
#define E1000_NETDEV_STAT(m) NETDEV_STATS, \
- sizeof(((struct net_device *)0)->m), \
- offsetof(struct net_device, m)
+ sizeof(((struct rtnl_link_stats64 *)0)->m), \
+ offsetof(struct rtnl_link_stats64, m)
static const struct e1000_stats e1000_gstrings_stats[] = {
{ "rx_packets", E1000_STAT(stats.gprc) },
@@ -61,21 +61,21 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
{ "tx_broadcast", E1000_STAT(stats.bptc) },
{ "rx_multicast", E1000_STAT(stats.mprc) },
{ "tx_multicast", E1000_STAT(stats.mptc) },
- { "rx_errors", E1000_NETDEV_STAT(stats.rx_errors) },
- { "tx_errors", E1000_NETDEV_STAT(stats.tx_errors) },
- { "tx_dropped", E1000_NETDEV_STAT(stats.tx_dropped) },
+ { "rx_errors", E1000_NETDEV_STAT(rx_errors) },
+ { "tx_errors", E1000_NETDEV_STAT(tx_errors) },
+ { "tx_dropped", E1000_NETDEV_STAT(tx_dropped) },
{ "multicast", E1000_STAT(stats.mprc) },
{ "collisions", E1000_STAT(stats.colc) },
- { "rx_length_errors", E1000_NETDEV_STAT(stats.rx_length_errors) },
- { "rx_over_errors", E1000_NETDEV_STAT(stats.rx_over_errors) },
+ { "rx_length_errors", E1000_NETDEV_STAT(rx_length_errors) },
+ { "rx_over_errors", E1000_NETDEV_STAT(rx_over_errors) },
{ "rx_crc_errors", E1000_STAT(stats.crcerrs) },
- { "rx_frame_errors", E1000_NETDEV_STAT(stats.rx_frame_errors) },
+ { "rx_frame_errors", E1000_NETDEV_STAT(rx_frame_errors) },
{ "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
{ "rx_missed_errors", E1000_STAT(stats.mpc) },
{ "tx_aborted_errors", E1000_STAT(stats.ecol) },
{ "tx_carrier_errors", E1000_STAT(stats.tncrs) },
- { "tx_fifo_errors", E1000_NETDEV_STAT(stats.tx_fifo_errors) },
- { "tx_heartbeat_errors", E1000_NETDEV_STAT(stats.tx_heartbeat_errors) },
+ { "tx_fifo_errors", E1000_NETDEV_STAT(tx_fifo_errors) },
+ { "tx_heartbeat_errors", E1000_NETDEV_STAT(tx_heartbeat_errors) },
{ "tx_window_errors", E1000_STAT(stats.latecol) },
{ "tx_abort_late_coll", E1000_STAT(stats.latecol) },
{ "tx_deferred_ok", E1000_STAT(stats.dc) },
@@ -1972,14 +1972,15 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,
u64 *data)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
+ struct rtnl_link_stats64 net_stats;
int i;
char *p = NULL;
- e1000e_update_stats(adapter);
+ e1000e_get_stats64(netdev, &net_stats);
for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
switch (e1000_gstrings_stats[i].type) {
case NETDEV_STATS:
- p = (char *) netdev +
+ p = (char *) &net_stats +
e1000_gstrings_stats[i].stat_offset;
break;
case E1000_STATS:
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index c4ca162..b3c4b7d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -894,8 +894,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -1051,8 +1049,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter)
}
adapter->total_tx_bytes += total_tx_bytes;
adapter->total_tx_packets += total_tx_packets;
- netdev->stats.tx_bytes += total_tx_bytes;
- netdev->stats.tx_packets += total_tx_packets;
return count < tx_ring->count;
}
@@ -1240,8 +1236,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -1421,8 +1415,6 @@ next_desc:
adapter->total_rx_bytes += total_rx_bytes;
adapter->total_rx_packets += total_rx_packets;
- netdev->stats.rx_bytes += total_rx_bytes;
- netdev->stats.rx_packets += total_rx_packets;
return cleaned;
}
@@ -3367,6 +3359,11 @@ void e1000e_down(struct e1000_adapter *adapter)
del_timer_sync(&adapter->phy_info_timer);
netif_carrier_off(netdev);
+
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter);
+ spin_unlock(&adapter->stats64_lock);
+
adapter->link_speed = 0;
adapter->link_duplex = 0;
@@ -3408,6 +3405,8 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
+ spin_lock_init(&adapter->stats64_lock);
+
e1000e_set_interrupt_capability(adapter);
if (e1000_alloc_queues(adapter))
@@ -4279,7 +4278,9 @@ static void e1000_watchdog_task(struct work_struct *work)
}
link_up:
+ spin_lock(&adapter->stats64_lock);
e1000e_update_stats(adapter);
+ spin_unlock(&adapter->stats64_lock);
mac->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
adapter->tpt_old = adapter->stats.tpt;
@@ -4891,16 +4892,55 @@ static void e1000_reset_task(struct work_struct *work)
}
/**
- * e1000_get_stats - Get System Network Statistics
+ * e1000_get_stats64 - Get System Network Statistics
* @netdev: network interface device structure
+ * @stats: rtnl_link_stats64 pointer
*
* Returns the address of the device statistics structure.
- * The statistics are actually updated from the timer callback.
**/
-static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
+struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
+ struct rtnl_link_stats64 *stats)
{
- /* only return the current stats */
- return &netdev->stats;
+ struct e1000_adapter *adapter = netdev_priv(netdev);
+
+ memset(stats, 0, sizeof(struct rtnl_link_stats64));
+ spin_lock(&adapter->stats64_lock);
+ e1000e_update_stats(adapter);
+ /* Fill out the OS statistics structure */
+ stats->rx_bytes = adapter->stats.gorc;
+ stats->rx_packets = adapter->stats.gprc;
+ stats->tx_bytes = adapter->stats.gotc;
+ stats->tx_packets = adapter->stats.gptc;
+ stats->multicast = adapter->stats.mprc;
+ stats->collisions = adapter->stats.colc;
+
+ /* Rx Errors */
+
+ /*
+ * RLEC on some newer hardware can be incorrect so build
+ * our own version based on RUC and ROC
+ */
+ stats->rx_errors = adapter->stats.rxerrc +
+ adapter->stats.crcerrs + adapter->stats.algnerrc +
+ adapter->stats.ruc + adapter->stats.roc +
+ adapter->stats.cexterr;
+ stats->rx_length_errors = adapter->stats.ruc +
+ adapter->stats.roc;
+ stats->rx_crc_errors = adapter->stats.crcerrs;
+ stats->rx_frame_errors = adapter->stats.algnerrc;
+ stats->rx_missed_errors = adapter->stats.mpc;
+
+ /* Tx Errors */
+ stats->tx_errors = adapter->stats.ecol +
+ adapter->stats.latecol;
+ stats->tx_aborted_errors = adapter->stats.ecol;
+ stats->tx_window_errors = adapter->stats.latecol;
+ stats->tx_carrier_errors = adapter->stats.tncrs;
+
+ /* Tx Dropped needs to be maintained elsewhere */
+
+ spin_unlock(&adapter->stats64_lock);
+ return stats;
}
/**
@@ -5624,7 +5664,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
.ndo_open = e1000_open,
.ndo_stop = e1000_close,
.ndo_start_xmit = e1000_xmit_frame,
- .ndo_get_stats = e1000_get_stats,
+ .ndo_get_stats64 = e1000e_get_stats64,
.ndo_set_multicast_list = e1000_set_multi,
.ndo_set_mac_address = e1000_set_mac,
.ndo_change_mtu = e1000_change_mtu,
--
1.7.3.1
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2010-12-16 12:31 ` [PATCH v2] " Flavio Leitner
@ 2010-12-16 12:50 ` Eric Dumazet
2010-12-16 13:10 ` Flavio Leitner
2010-12-17 3:14 ` Jeff Kirsher
1 sibling, 1 reply; 10+ messages in thread
From: Eric Dumazet @ 2010-12-16 12:50 UTC (permalink / raw)
To: Flavio Leitner; +Cc: netdev, e1000-devel, Jeff Kirsher
Le jeudi 16 décembre 2010 à 10:31 -0200, Flavio Leitner a écrit :
> -static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
> +struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
> + struct rtnl_link_stats64 *stats)
> {
> - /* only return the current stats */
> - return &netdev->stats;
> + struct e1000_adapter *adapter = netdev_priv(netdev);
> +
> + memset(stats, 0, sizeof(struct rtnl_link_stats64));
You dont need this memset(), stats is cleared by caller (dev_get_stats()
in net/core/dev.c), as this was always done ;)
> + spin_lock(&adapter->stats64_lock);
> + e1000e_update_stats(adapter);
> + /* Fill out the OS statistics structure */
> + stats->rx_bytes = adapter->stats.gorc;
> + stats->rx_packets = adapter->stats.gprc;
> + stats->tx_bytes = adapter->stats.gotc;
> + stats->tx_packets = adapter->stats.gptc;
> + stats->multicast = adapter->stats.mprc;
> + stats->collisions = adapter->stats.colc;
> +
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2010-12-16 12:50 ` Eric Dumazet
@ 2010-12-16 13:10 ` Flavio Leitner
2010-12-16 13:18 ` Eric Dumazet
0 siblings, 1 reply; 10+ messages in thread
From: Flavio Leitner @ 2010-12-16 13:10 UTC (permalink / raw)
To: Eric Dumazet; +Cc: e1000-devel, netdev, Jeff Kirsher
On Thu, Dec 16, 2010 at 01:50:30PM +0100, Eric Dumazet wrote:
> Le jeudi 16 décembre 2010 à 10:31 -0200, Flavio Leitner a écrit :
>
> > -static struct net_device_stats *e1000_get_stats(struct net_device *netdev)
> > +struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev,
> > + struct rtnl_link_stats64 *stats)
> > {
> > - /* only return the current stats */
> > - return &netdev->stats;
> > + struct e1000_adapter *adapter = netdev_priv(netdev);
> > +
> > + memset(stats, 0, sizeof(struct rtnl_link_stats64));
>
> You dont need this memset(), stats is cleared by caller (dev_get_stats()
> in net/core/dev.c), as this was always done ;)
Yes, but e1000_get_ethtool_stats() also calls it and doesn't do that.
I could move the memset to the caller, but I thought it would be cleaner
to leave where it is now.
> > + spin_lock(&adapter->stats64_lock);
> > + e1000e_update_stats(adapter);
> > + /* Fill out the OS statistics structure */
> > + stats->rx_bytes = adapter->stats.gorc;
> > + stats->rx_packets = adapter->stats.gprc;
> > + stats->tx_bytes = adapter->stats.gotc;
> > + stats->tx_packets = adapter->stats.gptc;
> > + stats->multicast = adapter->stats.mprc;
> > + stats->collisions = adapter->stats.colc;
> > +
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Flavio
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2010-12-16 13:10 ` Flavio Leitner
@ 2010-12-16 13:18 ` Eric Dumazet
0 siblings, 0 replies; 10+ messages in thread
From: Eric Dumazet @ 2010-12-16 13:18 UTC (permalink / raw)
To: Flavio Leitner; +Cc: netdev, e1000-devel, Jeff Kirsher
Le jeudi 16 décembre 2010 à 11:10 -0200, Flavio Leitner a écrit :
> Yes, but e1000_get_ethtool_stats() also calls it and doesn't do that.
> I could move the memset to the caller, but I thought it would be cleaner
> to leave where it is now.
Yes, no problem !
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2010-12-16 12:31 ` [PATCH v2] " Flavio Leitner
2010-12-16 12:50 ` Eric Dumazet
@ 2010-12-17 3:14 ` Jeff Kirsher
2011-01-21 17:03 ` Flavio Leitner
1 sibling, 1 reply; 10+ messages in thread
From: Jeff Kirsher @ 2010-12-17 3:14 UTC (permalink / raw)
To: Flavio Leitner; +Cc: Eric Dumazet, netdev, e1000-devel
On Thu, Dec 16, 2010 at 04:31, Flavio Leitner <fleitner@redhat.com> wrote:
> On Tue, Dec 14, 2010 at 10:29:33PM +0100, Eric Dumazet wrote:
>> Le mardi 14 décembre 2010 à 18:32 -0200, Flavio Leitner a écrit :
>> > Provides accurate stats at the time user reads them.
>> >
>> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
>> > ---
>> > drivers/net/e1000e/e1000.h | 5 ++-
>> > drivers/net/e1000e/ethtool.c | 27 +++++++++-------
>> > drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
>> > 3 files changed, 59 insertions(+), 41 deletions(-)
>> >
>> > diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
>> > index fdc67fe..5a5e944 100644
>> > --- a/drivers/net/e1000e/e1000.h
>> > +++ b/drivers/net/e1000e/e1000.h
>> > @@ -363,6 +363,8 @@ struct e1000_adapter {
>> > /* structs defined in e1000_hw.h */
>> > struct e1000_hw hw;
>> >
>> > + spinlock_t stats64_lock;
>> > + struct rtnl_link_stats64 stats64;
>>
>> I am not sure why you add this stats64 in e1000_adapter ?
>>
>> Why isnt it provided by callers (automatic variable, or provided to
>> ndo_get_stats64()). I dont see accumulators, only a full rewrite of this
>> structure in e1000e_update_stats() ?
>
> Good point. I have modified the patch to fix that.
> thanks!
>
> From 3487bd7dacd0c23bba315270139dab6e00e5ff02 Mon Sep 17 00:00:00 2001
> From: Flavio Leitner <fleitner@redhat.com>
> Date: Thu, 16 Dec 2010 10:26:03 -0200
> Subject: [PATCH] e1000e: convert to stats64
>
> Provides accurate stats at the time user reads them.
>
> Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> ---
> drivers/net/e1000e/e1000.h | 3 ++
> drivers/net/e1000e/ethtool.c | 25 ++++++++-------
> drivers/net/e1000e/netdev.c | 68 +++++++++++++++++++++++++++++++++--------
> 3 files changed, 70 insertions(+), 26 deletions(-)
>
I have dropped you previous version of the patch and applied v2 to my
tree for review and testing.
Thanks Flavio!
--
Cheers,
Jeff
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2010-12-17 3:14 ` Jeff Kirsher
@ 2011-01-21 17:03 ` Flavio Leitner
2011-01-21 22:19 ` Jeff Kirsher
0 siblings, 1 reply; 10+ messages in thread
From: Flavio Leitner @ 2011-01-21 17:03 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: e1000-devel, netdev
On Thu, Dec 16, 2010 at 07:14:35PM -0800, Jeff Kirsher wrote:
> On Thu, Dec 16, 2010 at 04:31, Flavio Leitner <fleitner@redhat.com> wrote:
> > On Tue, Dec 14, 2010 at 10:29:33PM +0100, Eric Dumazet wrote:
> >> Le mardi 14 décembre 2010 à 18:32 -0200, Flavio Leitner a écrit :
> >> > Provides accurate stats at the time user reads them.
> >> >
> >> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> >> > ---
> >> > drivers/net/e1000e/e1000.h | 5 ++-
> >> > drivers/net/e1000e/ethtool.c | 27 +++++++++-------
> >> > drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
> >> > 3 files changed, 59 insertions(+), 41 deletions(-)
> >> >
> >> > diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> >> > index fdc67fe..5a5e944 100644
> >> > --- a/drivers/net/e1000e/e1000.h
> >> > +++ b/drivers/net/e1000e/e1000.h
> >> > @@ -363,6 +363,8 @@ struct e1000_adapter {
> >> > /* structs defined in e1000_hw.h */
> >> > struct e1000_hw hw;
> >> >
> >> > + spinlock_t stats64_lock;
> >> > + struct rtnl_link_stats64 stats64;
> >>
> >> I am not sure why you add this stats64 in e1000_adapter ?
> >>
> >> Why isnt it provided by callers (automatic variable, or provided to
> >> ndo_get_stats64()). I dont see accumulators, only a full rewrite of this
> >> structure in e1000e_update_stats() ?
> >
> > Good point. I have modified the patch to fix that.
> > thanks!
> >
> > From 3487bd7dacd0c23bba315270139dab6e00e5ff02 Mon Sep 17 00:00:00 2001
> > From: Flavio Leitner <fleitner@redhat.com>
> > Date: Thu, 16 Dec 2010 10:26:03 -0200
> > Subject: [PATCH] e1000e: convert to stats64
> >
> > Provides accurate stats at the time user reads them.
> >
> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> > ---
> > drivers/net/e1000e/e1000.h | 3 ++
> > drivers/net/e1000e/ethtool.c | 25 ++++++++-------
> > drivers/net/e1000e/netdev.c | 68 +++++++++++++++++++++++++++++++++--------
> > 3 files changed, 70 insertions(+), 26 deletions(-)
> >
>
> I have dropped you previous version of the patch and applied v2 to my
> tree for review and testing.
> Thanks Flavio!
Hi Jeff,
Do you have any feedback on this patch?
thanks,
--
Flavio
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] e1000e: convert to stats64
2011-01-21 17:03 ` Flavio Leitner
@ 2011-01-21 22:19 ` Jeff Kirsher
0 siblings, 0 replies; 10+ messages in thread
From: Jeff Kirsher @ 2011-01-21 22:19 UTC (permalink / raw)
To: Flavio Leitner; +Cc: netdev@vger.kernel.org, e1000-devel@lists.sourceforge.net
[-- Attachment #1: Type: text/plain, Size: 2589 bytes --]
On Fri, 2011-01-21 at 09:03 -0800, Flavio Leitner wrote:
> On Thu, Dec 16, 2010 at 07:14:35PM -0800, Jeff Kirsher wrote:
> > On Thu, Dec 16, 2010 at 04:31, Flavio Leitner <fleitner@redhat.com> wrote:
> > > On Tue, Dec 14, 2010 at 10:29:33PM +0100, Eric Dumazet wrote:
> > >> Le mardi 14 décembre 2010 à 18:32 -0200, Flavio Leitner a écrit :
> > >> > Provides accurate stats at the time user reads them.
> > >> >
> > >> > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> > >> > ---
> > >> > drivers/net/e1000e/e1000.h | 5 ++-
> > >> > drivers/net/e1000e/ethtool.c | 27 +++++++++-------
> > >> > drivers/net/e1000e/netdev.c | 68 ++++++++++++++++++++++++-----------------
> > >> > 3 files changed, 59 insertions(+), 41 deletions(-)
> > >> >
> > >> > diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
> > >> > index fdc67fe..5a5e944 100644
> > >> > --- a/drivers/net/e1000e/e1000.h
> > >> > +++ b/drivers/net/e1000e/e1000.h
> > >> > @@ -363,6 +363,8 @@ struct e1000_adapter {
> > >> > /* structs defined in e1000_hw.h */
> > >> > struct e1000_hw hw;
> > >> >
> > >> > + spinlock_t stats64_lock;
> > >> > + struct rtnl_link_stats64 stats64;
> > >>
> > >> I am not sure why you add this stats64 in e1000_adapter ?
> > >>
> > >> Why isnt it provided by callers (automatic variable, or provided to
> > >> ndo_get_stats64()). I dont see accumulators, only a full rewrite of this
> > >> structure in e1000e_update_stats() ?
> > >
> > > Good point. I have modified the patch to fix that.
> > > thanks!
> > >
> > > From 3487bd7dacd0c23bba315270139dab6e00e5ff02 Mon Sep 17 00:00:00 2001
> > > From: Flavio Leitner <fleitner@redhat.com>
> > > Date: Thu, 16 Dec 2010 10:26:03 -0200
> > > Subject: [PATCH] e1000e: convert to stats64
> > >
> > > Provides accurate stats at the time user reads them.
> > >
> > > Signed-off-by: Flavio Leitner <fleitner@redhat.com>
> > > ---
> > > drivers/net/e1000e/e1000.h | 3 ++
> > > drivers/net/e1000e/ethtool.c | 25 ++++++++-------
> > > drivers/net/e1000e/netdev.c | 68 +++++++++++++++++++++++++++++++++--------
> > > 3 files changed, 70 insertions(+), 26 deletions(-)
> > >
> >
> > I have dropped you previous version of the patch and applied v2 to my
> > tree for review and testing.
> > Thanks Flavio!
>
> Hi Jeff,
>
> Do you have any feedback on this patch?
> thanks,
I have the patch ready to push to Dave for net-next, along with a few
other e1000e patches. I was just waiting for net-next to open (which it
did a few days ago).
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-01-21 22:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14 20:32 [PATCH] e1000e: convert to stats64 Flavio Leitner
2010-12-14 21:29 ` Eric Dumazet
2010-12-16 12:31 ` [PATCH v2] " Flavio Leitner
2010-12-16 12:50 ` Eric Dumazet
2010-12-16 13:10 ` Flavio Leitner
2010-12-16 13:18 ` Eric Dumazet
2010-12-17 3:14 ` Jeff Kirsher
2011-01-21 17:03 ` Flavio Leitner
2011-01-21 22:19 ` Jeff Kirsher
2010-12-15 23:59 ` [PATCH] " Jeff Kirsher
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).