Commit f1852d64 authored by Sameeh Jubran's avatar Sameeh Jubran Committed by David S. Miller

net: ena: ethtool: convert stat_offset to 64 bit resolution

The type of all stat fields is u64, therefore when iterating over stat
fields in a stats struct, it makes sense to use an offset in 64 bit
resolution. Doing so allows us to drop some of the casting that is
currently used when referencing stats.
Signed-off-by: default avatarSameeh Jubran <sameehj@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5484658
...@@ -41,12 +41,12 @@ struct ena_stats { ...@@ -41,12 +41,12 @@ struct ena_stats {
#define ENA_STAT_ENA_COM_ENTRY(stat) { \ #define ENA_STAT_ENA_COM_ENTRY(stat) { \
.name = #stat, \ .name = #stat, \
.stat_offset = offsetof(struct ena_com_stats_admin, stat) \ .stat_offset = offsetof(struct ena_com_stats_admin, stat) / sizeof(u64) \
} }
#define ENA_STAT_ENTRY(stat, stat_type) { \ #define ENA_STAT_ENTRY(stat, stat_type) { \
.name = #stat, \ .name = #stat, \
.stat_offset = offsetof(struct ena_stats_##stat_type, stat) \ .stat_offset = offsetof(struct ena_stats_##stat_type, stat) / sizeof(u64) \
} }
#define ENA_STAT_RX_ENTRY(stat) \ #define ENA_STAT_RX_ENTRY(stat) \
...@@ -141,8 +141,7 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data) ...@@ -141,8 +141,7 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data)
for (j = 0; j < ENA_STATS_ARRAY_TX; j++) { for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
ena_stats = &ena_stats_tx_strings[j]; ena_stats = &ena_stats_tx_strings[j];
ptr = (u64 *)((uintptr_t)&ring->tx_stats + ptr = (u64 *)&ring->tx_stats + ena_stats->stat_offset;
(uintptr_t)ena_stats->stat_offset);
ena_safe_update_stat(ptr, (*data)++, &ring->syncp); ena_safe_update_stat(ptr, (*data)++, &ring->syncp);
} }
...@@ -153,8 +152,8 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data) ...@@ -153,8 +152,8 @@ static void ena_queue_stats(struct ena_adapter *adapter, u64 **data)
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) { for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
ena_stats = &ena_stats_rx_strings[j]; ena_stats = &ena_stats_rx_strings[j];
ptr = (u64 *)((uintptr_t)&ring->rx_stats + ptr = (u64 *)&ring->rx_stats +
(uintptr_t)ena_stats->stat_offset); ena_stats->stat_offset;
ena_safe_update_stat(ptr, (*data)++, &ring->syncp); ena_safe_update_stat(ptr, (*data)++, &ring->syncp);
} }
...@@ -170,8 +169,8 @@ static void ena_dev_admin_queue_stats(struct ena_adapter *adapter, u64 **data) ...@@ -170,8 +169,8 @@ static void ena_dev_admin_queue_stats(struct ena_adapter *adapter, u64 **data)
for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) { for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) {
ena_stats = &ena_stats_ena_com_strings[i]; ena_stats = &ena_stats_ena_com_strings[i];
ptr = (u64 *)((uintptr_t)&adapter->ena_dev->admin_queue.stats + ptr = (u64 *)&adapter->ena_dev->admin_queue.stats +
(uintptr_t)ena_stats->stat_offset); ena_stats->stat_offset;
*(*data)++ = *ptr; *(*data)++ = *ptr;
} }
...@@ -189,8 +188,7 @@ static void ena_get_ethtool_stats(struct net_device *netdev, ...@@ -189,8 +188,7 @@ static void ena_get_ethtool_stats(struct net_device *netdev,
for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) { for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) {
ena_stats = &ena_stats_global_strings[i]; ena_stats = &ena_stats_global_strings[i];
ptr = (u64 *)((uintptr_t)&adapter->dev_stats + ptr = (u64 *)&adapter->dev_stats + ena_stats->stat_offset;
(uintptr_t)ena_stats->stat_offset);
ena_safe_update_stat(ptr, data++, &adapter->syncp); ena_safe_update_stat(ptr, data++, &adapter->syncp);
} }
......
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