Commit 2ead8ae1 authored by Jacob Keller's avatar Jacob Keller Committed by Jeff Kirsher

fm10k: reduce duplicate fm10k_stat macro code

Share some of the code for setting up fm10k_stat macros by implementing
an FM10K_STAT_FIELDS macro which we can use when setting up the type
specific macros.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Tested-by: default avatarKrishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 3c6a67dd
...@@ -11,12 +11,17 @@ struct fm10k_stats { ...@@ -11,12 +11,17 @@ struct fm10k_stats {
int stat_offset; int stat_offset;
}; };
#define FM10K_NETDEV_STAT(_net_stat) { \ #define FM10K_STAT_FIELDS(_type, _name, _stat) { \
.stat_string = #_net_stat, \ .stat_string = _name, \
.sizeof_stat = FIELD_SIZEOF(struct net_device_stats, _net_stat), \ .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
.stat_offset = offsetof(struct net_device_stats, _net_stat) \ .stat_offset = offsetof(_type, _stat) \
} }
/* netdevice statistics */
#define FM10K_NETDEV_STAT(_net_stat) \
FM10K_STAT_FIELDS(struct net_device_stats, __stringify(_net_stat), \
_net_stat)
static const struct fm10k_stats fm10k_gstrings_net_stats[] = { static const struct fm10k_stats fm10k_gstrings_net_stats[] = {
FM10K_NETDEV_STAT(tx_packets), FM10K_NETDEV_STAT(tx_packets),
FM10K_NETDEV_STAT(tx_bytes), FM10K_NETDEV_STAT(tx_bytes),
...@@ -34,11 +39,9 @@ static const struct fm10k_stats fm10k_gstrings_net_stats[] = { ...@@ -34,11 +39,9 @@ static const struct fm10k_stats fm10k_gstrings_net_stats[] = {
#define FM10K_NETDEV_STATS_LEN ARRAY_SIZE(fm10k_gstrings_net_stats) #define FM10K_NETDEV_STATS_LEN ARRAY_SIZE(fm10k_gstrings_net_stats)
#define FM10K_STAT(_name, _stat) { \ /* General interface statistics */
.stat_string = _name, \ #define FM10K_STAT(_name, _stat) \
.sizeof_stat = FIELD_SIZEOF(struct fm10k_intfc, _stat), \ FM10K_STAT_FIELDS(struct fm10k_intfc, _name, _stat)
.stat_offset = offsetof(struct fm10k_intfc, _stat) \
}
static const struct fm10k_stats fm10k_gstrings_global_stats[] = { static const struct fm10k_stats fm10k_gstrings_global_stats[] = {
FM10K_STAT("tx_restart_queue", restart_queue), FM10K_STAT("tx_restart_queue", restart_queue),
...@@ -75,11 +78,9 @@ static const struct fm10k_stats fm10k_gstrings_pf_stats[] = { ...@@ -75,11 +78,9 @@ static const struct fm10k_stats fm10k_gstrings_pf_stats[] = {
FM10K_STAT("nodesc_drop", stats.nodesc_drop.count), FM10K_STAT("nodesc_drop", stats.nodesc_drop.count),
}; };
#define FM10K_MBX_STAT(_name, _stat) { \ /* mailbox statistics */
.stat_string = _name, \ #define FM10K_MBX_STAT(_name, _stat) \
.sizeof_stat = FIELD_SIZEOF(struct fm10k_mbx_info, _stat), \ FM10K_STAT_FIELDS(struct fm10k_mbx_info, _name, _stat)
.stat_offset = offsetof(struct fm10k_mbx_info, _stat) \
}
static const struct fm10k_stats fm10k_gstrings_mbx_stats[] = { static const struct fm10k_stats fm10k_gstrings_mbx_stats[] = {
FM10K_MBX_STAT("mbx_tx_busy", tx_busy), FM10K_MBX_STAT("mbx_tx_busy", tx_busy),
......
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