diff options
author | Sathya Perla <sathya.perla@emulex.com> | 2011-07-25 19:10:15 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-01 00:12:00 -0700 |
commit | ab1594e92e6765fd4af316f130eea8f5c920823d (patch) | |
tree | 9631e8ef947f2db4635e56387d18730b8b4b7206 /drivers/net/benet/be_ethtool.c | |
parent | be2net: cleanup and refactor stats code (diff) | |
download | linux-dev-ab1594e92e6765fd4af316f130eea8f5c920823d.tar.xz linux-dev-ab1594e92e6765fd4af316f130eea8f5c920823d.zip |
be2net: use stats-sync to read/write 64-bit stats
64-bit stats in be2net are written/read as follows using the stats-sync
interface for safe access in 32-bit archs:
64-bit sync writer reader
stats
------------------------------------------------------------------------------
tx_stats tx_stats->sync be_xmit be_get_stats64,
ethtool
tx-compl tx_stats->sync_compl tx-compl-processing ethtool
rx-stats rx_stats->sync rx-compl-processing be_get_stats64,
ethtool,
eqd-update
This patch is based on Stephen Hemminger's earlier patch on the same issue...
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_ethtool.c')
-rw-r--r-- | drivers/net/benet/be_ethtool.c | 61 |
1 files changed, 41 insertions, 20 deletions
diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c index 0300b9ddda06..e92a8d8813a0 100644 --- a/drivers/net/benet/be_ethtool.c +++ b/drivers/net/benet/be_ethtool.c @@ -74,10 +74,12 @@ static const struct be_ethtool_stat et_stats[] = { }; #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) -/* Stats related to multi RX queues */ +/* Stats related to multi RX queues: get_stats routine assumes bytes, pkts + * are first and second members respectively. + */ static const struct be_ethtool_stat et_rx_stats[] = { - {DRVSTAT_RX_INFO(rx_bytes)}, - {DRVSTAT_RX_INFO(rx_pkts)}, + {DRVSTAT_RX_INFO(rx_bytes)},/* If moving this member see above note */ + {DRVSTAT_RX_INFO(rx_pkts)}, /* If moving this member see above note */ {DRVSTAT_RX_INFO(rx_polls)}, {DRVSTAT_RX_INFO(rx_events)}, {DRVSTAT_RX_INFO(rx_compl)}, @@ -88,8 +90,11 @@ static const struct be_ethtool_stat et_rx_stats[] = { }; #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) -/* Stats related to multi TX queues */ +/* Stats related to multi TX queues: get_stats routine assumes compl is the + * first member + */ static const struct be_ethtool_stat et_tx_stats[] = { + {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */ {DRVSTAT_TX_INFO(tx_bytes)}, {DRVSTAT_TX_INFO(tx_pkts)}, {DRVSTAT_TX_INFO(tx_reqs)}, @@ -243,32 +248,48 @@ be_get_ethtool_stats(struct net_device *netdev, struct be_rx_obj *rxo; struct be_tx_obj *txo; void *p; - int i, j, base; + unsigned int i, j, base = 0, start; for (i = 0; i < ETHTOOL_STATS_NUM; i++) { p = (u8 *)&adapter->drv_stats + et_stats[i].offset; - data[i] = (et_stats[i].size == sizeof(u64)) ? - *(u64 *)p: *(u32 *)p; + data[i] = *(u32 *)p; } + base += ETHTOOL_STATS_NUM; - base = ETHTOOL_STATS_NUM; for_all_rx_queues(adapter, rxo, j) { - for (i = 0; i < ETHTOOL_RXSTATS_NUM; i++) { - p = (u8 *)rx_stats(rxo) + et_rx_stats[i].offset; - data[base + j * ETHTOOL_RXSTATS_NUM + i] = - (et_rx_stats[i].size == sizeof(u64)) ? - *(u64 *)p: *(u32 *)p; + struct be_rx_stats *stats = rx_stats(rxo); + + do { + start = u64_stats_fetch_begin_bh(&stats->sync); + data[base] = stats->rx_bytes; + data[base + 1] = stats->rx_pkts; + } while (u64_stats_fetch_retry_bh(&stats->sync, start)); + + for (i = 2; i < ETHTOOL_RXSTATS_NUM; i++) { + p = (u8 *)stats + et_rx_stats[i].offset; + data[base + i] = *(u32 *)p; } + base += ETHTOOL_RXSTATS_NUM; } - base = ETHTOOL_STATS_NUM + adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM; for_all_tx_queues(adapter, txo, j) { - for (i = 0; i < ETHTOOL_TXSTATS_NUM; i++) { - p = (u8 *)tx_stats(txo) + et_tx_stats[i].offset; - data[base + j * ETHTOOL_TXSTATS_NUM + i] = - (et_tx_stats[i].size == sizeof(u64)) ? - *(u64 *)p: *(u32 *)p; - } + struct be_tx_stats *stats = tx_stats(txo); + + do { + start = u64_stats_fetch_begin_bh(&stats->sync_compl); + data[base] = stats->tx_compl; + } while (u64_stats_fetch_retry_bh(&stats->sync_compl, start)); + + do { + start = u64_stats_fetch_begin_bh(&stats->sync); + for (i = 1; i < ETHTOOL_TXSTATS_NUM; i++) { + p = (u8 *)stats + et_tx_stats[i].offset; + data[base + i] = + (et_tx_stats[i].size == sizeof(u64)) ? + *(u64 *)p : *(u32 *)p; + } + } while (u64_stats_fetch_retry_bh(&stats->sync, start)); + base += ETHTOOL_TXSTATS_NUM; } } |