Commit 44bd741e authored by Don Skidmore's avatar Don Skidmore Committed by Jeff Kirsher

ixgbevf: Add zero_base handler to network statistics

This patch removes the need to keep a zero_base variable in the adapter
structure. Now we just use two different macros to set the non-zero and
zero base. This adds to readability and shortens some of the structure
initialization under 80 columns. The gathering of status for ethtool was
slightly modified to again better fit into 80 columns and become a bit
more readable.
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: default avatarDon Skidmore <donald.c.skidmore@intel.com>
Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 3b5dca26
...@@ -45,16 +45,27 @@ ...@@ -45,16 +45,27 @@
struct ixgbe_stats { struct ixgbe_stats {
char stat_string[ETH_GSTRING_LEN]; char stat_string[ETH_GSTRING_LEN];
struct {
int sizeof_stat; int sizeof_stat;
int stat_offset; int stat_offset;
int base_stat_offset; int base_stat_offset;
int saved_reset_offset; int saved_reset_offset;
};
}; };
#define IXGBEVF_STAT(m, b, r) sizeof(((struct ixgbevf_adapter *)0)->m), \ #define IXGBEVF_STAT(m, b, r) { \
offsetof(struct ixgbevf_adapter, m), \ .sizeof_stat = FIELD_SIZEOF(struct ixgbevf_adapter, m), \
offsetof(struct ixgbevf_adapter, b), \ .stat_offset = offsetof(struct ixgbevf_adapter, m), \
offsetof(struct ixgbevf_adapter, r) .base_stat_offset = offsetof(struct ixgbevf_adapter, b), \
.saved_reset_offset = offsetof(struct ixgbevf_adapter, r) \
}
#define IXGBEVF_ZSTAT(m) { \
.sizeof_stat = FIELD_SIZEOF(struct ixgbevf_adapter, m), \
.stat_offset = offsetof(struct ixgbevf_adapter, m), \
.base_stat_offset = -1, \
.saved_reset_offset = -1 \
}
static const struct ixgbe_stats ixgbe_gstrings_stats[] = { static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
{"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc, {"rx_packets", IXGBEVF_STAT(stats.vfgprc, stats.base_vfgprc,
...@@ -65,22 +76,19 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = { ...@@ -65,22 +76,19 @@ static const struct ixgbe_stats ixgbe_gstrings_stats[] = {
stats.saved_reset_vfgorc)}, stats.saved_reset_vfgorc)},
{"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc, {"tx_bytes", IXGBEVF_STAT(stats.vfgotc, stats.base_vfgotc,
stats.saved_reset_vfgotc)}, stats.saved_reset_vfgotc)},
{"tx_busy", IXGBEVF_STAT(tx_busy, zero_base, zero_base)}, {"tx_busy", IXGBEVF_ZSTAT(tx_busy)},
{"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc, {"multicast", IXGBEVF_STAT(stats.vfmprc, stats.base_vfmprc,
stats.saved_reset_vfmprc)}, stats.saved_reset_vfmprc)},
{"rx_csum_offload_good", IXGBEVF_STAT(hw_csum_rx_good, zero_base, {"rx_csum_offload_good", IXGBEVF_ZSTAT(hw_csum_rx_good)},
zero_base)}, {"rx_csum_offload_errors", IXGBEVF_ZSTAT(hw_csum_rx_error)},
{"rx_csum_offload_errors", IXGBEVF_STAT(hw_csum_rx_error, zero_base, {"tx_csum_offload_ctxt", IXGBEVF_ZSTAT(hw_csum_tx_good)},
zero_base)},
{"tx_csum_offload_ctxt", IXGBEVF_STAT(hw_csum_tx_good, zero_base,
zero_base)},
#ifdef BP_EXTENDED_STATS #ifdef BP_EXTENDED_STATS
{"rx_bp_poll_yield", IXGBEVF_STAT(bp_rx_yields, zero_base, zero_base)}, {"rx_bp_poll_yield", IXGBEVF_ZSTAT(bp_rx_yields)},
{"rx_bp_cleaned", IXGBEVF_STAT(bp_rx_cleaned, zero_base, zero_base)}, {"rx_bp_cleaned", IXGBEVF_ZSTAT(bp_rx_cleaned)},
{"rx_bp_misses", IXGBEVF_STAT(bp_rx_missed, zero_base, zero_base)}, {"rx_bp_misses", IXGBEVF_ZSTAT(bp_rx_missed)},
{"tx_bp_napi_yield", IXGBEVF_STAT(bp_tx_yields, zero_base, zero_base)}, {"tx_bp_napi_yield", IXGBEVF_ZSTAT(bp_tx_yields)},
{"tx_bp_cleaned", IXGBEVF_STAT(bp_tx_cleaned, zero_base, zero_base)}, {"tx_bp_cleaned", IXGBEVF_ZSTAT(bp_tx_cleaned)},
{"tx_bp_misses", IXGBEVF_STAT(bp_tx_missed, zero_base, zero_base)}, {"tx_bp_misses", IXGBEVF_ZSTAT(bp_tx_missed)},
#endif #endif
}; };
...@@ -398,6 +406,7 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev, ...@@ -398,6 +406,7 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data) struct ethtool_stats *stats, u64 *data)
{ {
struct ixgbevf_adapter *adapter = netdev_priv(netdev); struct ixgbevf_adapter *adapter = netdev_priv(netdev);
char *base = (char *) adapter;
int i; int i;
#ifdef BP_EXTENDED_STATS #ifdef BP_EXTENDED_STATS
u64 rx_yields = 0, rx_cleaned = 0, rx_missed = 0, u64 rx_yields = 0, rx_cleaned = 0, rx_missed = 0,
...@@ -426,18 +435,21 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev, ...@@ -426,18 +435,21 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
ixgbevf_update_stats(adapter); ixgbevf_update_stats(adapter);
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
char *p = (char *)adapter + char *p = base + ixgbe_gstrings_stats[i].stat_offset;
ixgbe_gstrings_stats[i].stat_offset; char *b = base + ixgbe_gstrings_stats[i].base_stat_offset;
char *b = (char *)adapter + char *r = base + ixgbe_gstrings_stats[i].saved_reset_offset;
ixgbe_gstrings_stats[i].base_stat_offset;
char *r = (char *)adapter + if (ixgbe_gstrings_stats[i].sizeof_stat == sizeof(u64)) {
ixgbe_gstrings_stats[i].saved_reset_offset; if (ixgbe_gstrings_stats[i].base_stat_offset >= 0)
data[i] = ((ixgbe_gstrings_stats[i].sizeof_stat == data[i] = *(u64 *)p - *(u64 *)b + *(u64 *)r;
sizeof(u64)) ? *(u64 *)p : *(u32 *)p) - else
((ixgbe_gstrings_stats[i].sizeof_stat == data[i] = *(u64 *)p;
sizeof(u64)) ? *(u64 *)b : *(u32 *)b) + } else {
((ixgbe_gstrings_stats[i].sizeof_stat == if (ixgbe_gstrings_stats[i].base_stat_offset >= 0)
sizeof(u64)) ? *(u64 *)r : *(u32 *)r); data[i] = *(u32 *)p - *(u32 *)b + *(u32 *)r;
else
data[i] = *(u32 *)p;
}
} }
} }
......
...@@ -361,7 +361,6 @@ struct ixgbevf_adapter { ...@@ -361,7 +361,6 @@ struct ixgbevf_adapter {
struct ixgbe_hw hw; struct ixgbe_hw hw;
u16 msg_enable; u16 msg_enable;
struct ixgbevf_hw_stats stats; struct ixgbevf_hw_stats stats;
u64 zero_base;
/* Interrupt Throttle Rate */ /* Interrupt Throttle Rate */
u32 eitr_param; u32 eitr_param;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment