Commit a0c30621 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller

bnxt_en: Switch over to use the 64-bit software accumulated counters.

Now we can report all the full 64-bit CPU endian software accumulated
counters instead of the hw counters, some of which may be less than
64-bit wide.  Define the necessary macros to access the software
counters.
Reviewed-by: default avatarVasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fea6b333
...@@ -9799,34 +9799,33 @@ static void bnxt_get_ring_stats(struct bnxt *bp, ...@@ -9799,34 +9799,33 @@ static void bnxt_get_ring_stats(struct bnxt *bp,
{ {
int i; int i;
for (i = 0; i < bp->cp_nr_rings; i++) { for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_napi *bnapi = bp->bnapi[i]; struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
struct ctx_hw_stats *hw_stats = cpr->stats.hw_stats; u64 *sw = cpr->stats.sw_stats;
stats->rx_packets += le64_to_cpu(hw_stats->rx_ucast_pkts); stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_ucast_pkts);
stats->rx_packets += le64_to_cpu(hw_stats->rx_mcast_pkts); stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts);
stats->rx_packets += le64_to_cpu(hw_stats->rx_bcast_pkts); stats->rx_packets += BNXT_GET_RING_STATS64(sw, rx_bcast_pkts);
stats->tx_packets += le64_to_cpu(hw_stats->tx_ucast_pkts); stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_ucast_pkts);
stats->tx_packets += le64_to_cpu(hw_stats->tx_mcast_pkts); stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_mcast_pkts);
stats->tx_packets += le64_to_cpu(hw_stats->tx_bcast_pkts); stats->tx_packets += BNXT_GET_RING_STATS64(sw, tx_bcast_pkts);
stats->rx_bytes += le64_to_cpu(hw_stats->rx_ucast_bytes); stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_ucast_bytes);
stats->rx_bytes += le64_to_cpu(hw_stats->rx_mcast_bytes); stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_mcast_bytes);
stats->rx_bytes += le64_to_cpu(hw_stats->rx_bcast_bytes); stats->rx_bytes += BNXT_GET_RING_STATS64(sw, rx_bcast_bytes);
stats->tx_bytes += le64_to_cpu(hw_stats->tx_ucast_bytes); stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_ucast_bytes);
stats->tx_bytes += le64_to_cpu(hw_stats->tx_mcast_bytes); stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_mcast_bytes);
stats->tx_bytes += le64_to_cpu(hw_stats->tx_bcast_bytes); stats->tx_bytes += BNXT_GET_RING_STATS64(sw, tx_bcast_bytes);
stats->rx_missed_errors += stats->rx_missed_errors +=
le64_to_cpu(hw_stats->rx_discard_pkts); BNXT_GET_RING_STATS64(sw, rx_discard_pkts);
stats->multicast += le64_to_cpu(hw_stats->rx_mcast_pkts); stats->multicast += BNXT_GET_RING_STATS64(sw, rx_mcast_pkts);
stats->tx_dropped += le64_to_cpu(hw_stats->tx_error_pkts); stats->tx_dropped += BNXT_GET_RING_STATS64(sw, tx_error_pkts);
} }
} }
...@@ -9864,20 +9863,26 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) ...@@ -9864,20 +9863,26 @@ bnxt_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
bnxt_add_prev_stats(bp, stats); bnxt_add_prev_stats(bp, stats);
if (bp->flags & BNXT_FLAG_PORT_STATS) { if (bp->flags & BNXT_FLAG_PORT_STATS) {
struct rx_port_stats *rx = bp->port_stats.hw_stats; u64 *rx = bp->port_stats.sw_stats;
struct tx_port_stats *tx = bp->port_stats.hw_stats + u64 *tx = bp->port_stats.sw_stats +
BNXT_TX_PORT_STATS_BYTE_OFFSET; BNXT_TX_PORT_STATS_BYTE_OFFSET / 8;
stats->rx_crc_errors = le64_to_cpu(rx->rx_fcs_err_frames); stats->rx_crc_errors =
stats->rx_frame_errors = le64_to_cpu(rx->rx_align_err_frames); BNXT_GET_RX_PORT_STATS64(rx, rx_fcs_err_frames);
stats->rx_length_errors = le64_to_cpu(rx->rx_undrsz_frames) + stats->rx_frame_errors =
le64_to_cpu(rx->rx_ovrsz_frames) + BNXT_GET_RX_PORT_STATS64(rx, rx_align_err_frames);
le64_to_cpu(rx->rx_runt_frames); stats->rx_length_errors =
stats->rx_errors = le64_to_cpu(rx->rx_false_carrier_frames) + BNXT_GET_RX_PORT_STATS64(rx, rx_undrsz_frames) +
le64_to_cpu(rx->rx_jbr_frames); BNXT_GET_RX_PORT_STATS64(rx, rx_ovrsz_frames) +
stats->collisions = le64_to_cpu(tx->tx_total_collisions); BNXT_GET_RX_PORT_STATS64(rx, rx_runt_frames);
stats->tx_fifo_errors = le64_to_cpu(tx->tx_fifo_underruns); stats->rx_errors =
stats->tx_errors = le64_to_cpu(tx->tx_err); BNXT_GET_RX_PORT_STATS64(rx, rx_false_carrier_frames) +
BNXT_GET_RX_PORT_STATS64(rx, rx_jbr_frames);
stats->collisions =
BNXT_GET_TX_PORT_STATS64(tx, tx_total_collisions);
stats->tx_fifo_errors =
BNXT_GET_TX_PORT_STATS64(tx, tx_fifo_underruns);
stats->tx_errors = BNXT_GET_TX_PORT_STATS64(tx, tx_err);
} }
clear_bit(BNXT_STATE_READ_STATS, &bp->state); clear_bit(BNXT_STATE_READ_STATS, &bp->state);
} }
......
...@@ -1928,6 +1928,15 @@ struct bnxt { ...@@ -1928,6 +1928,15 @@ struct bnxt {
struct device *hwmon_dev; struct device *hwmon_dev;
}; };
#define BNXT_GET_RING_STATS64(sw, counter) \
(*((sw) + offsetof(struct ctx_hw_stats, counter) / 8))
#define BNXT_GET_RX_PORT_STATS64(sw, counter) \
(*((sw) + offsetof(struct rx_port_stats, counter) / 8))
#define BNXT_GET_TX_PORT_STATS64(sw, counter) \
(*((sw) + offsetof(struct tx_port_stats, counter) / 8))
#define BNXT_PORT_STATS_SIZE \ #define BNXT_PORT_STATS_SIZE \
(sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024) (sizeof(struct rx_port_stats) + sizeof(struct tx_port_stats) + 1024)
......
...@@ -559,20 +559,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -559,20 +559,19 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
for (i = 0; i < bp->cp_nr_rings; i++) { for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_napi *bnapi = bp->bnapi[i]; struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
struct ctx_hw_stats *hw = cpr->stats.hw_stats; u64 *sw_stats = cpr->stats.sw_stats;
__le64 *hw_stats = cpr->stats.hw_stats;
u64 *sw; u64 *sw;
int k; int k;
if (is_rx_ring(bp, i)) { if (is_rx_ring(bp, i)) {
for (k = 0; k < NUM_RING_RX_HW_STATS; j++, k++) for (k = 0; k < NUM_RING_RX_HW_STATS; j++, k++)
buf[j] = le64_to_cpu(hw_stats[k]); buf[j] = sw_stats[k];
} }
if (is_tx_ring(bp, i)) { if (is_tx_ring(bp, i)) {
k = NUM_RING_RX_HW_STATS; k = NUM_RING_RX_HW_STATS;
for (; k < NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS; for (; k < NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS;
j++, k++) j++, k++)
buf[j] = le64_to_cpu(hw_stats[k]); buf[j] = sw_stats[k];
} }
if (!tpa_stats || !is_rx_ring(bp, i)) if (!tpa_stats || !is_rx_ring(bp, i))
goto skip_tpa_ring_stats; goto skip_tpa_ring_stats;
...@@ -580,7 +579,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -580,7 +579,7 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
k = NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS; k = NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS;
for (; k < NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS + for (; k < NUM_RING_RX_HW_STATS + NUM_RING_TX_HW_STATS +
tpa_stats; j++, k++) tpa_stats; j++, k++)
buf[j] = le64_to_cpu(hw_stats[k]); buf[j] = sw_stats[k];
skip_tpa_ring_stats: skip_tpa_ring_stats:
sw = (u64 *)&cpr->sw_stats.rx; sw = (u64 *)&cpr->sw_stats.rx;
...@@ -594,9 +593,9 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -594,9 +593,9 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
buf[j] = sw[k]; buf[j] = sw[k];
bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter += bnxt_sw_func_stats[RX_TOTAL_DISCARDS].counter +=
le64_to_cpu(hw->rx_discard_pkts); BNXT_GET_RING_STATS64(sw_stats, rx_discard_pkts);
bnxt_sw_func_stats[TX_TOTAL_DISCARDS].counter += bnxt_sw_func_stats[TX_TOTAL_DISCARDS].counter +=
le64_to_cpu(hw->tx_discard_pkts); BNXT_GET_RING_STATS64(sw_stats, tx_discard_pkts);
} }
for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++) for (i = 0; i < BNXT_NUM_SW_FUNC_STATS; i++, j++)
...@@ -604,49 +603,47 @@ static void bnxt_get_ethtool_stats(struct net_device *dev, ...@@ -604,49 +603,47 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
skip_ring_stats: skip_ring_stats:
if (bp->flags & BNXT_FLAG_PORT_STATS) { if (bp->flags & BNXT_FLAG_PORT_STATS) {
__le64 *port_stats = bp->port_stats.hw_stats; u64 *port_stats = bp->port_stats.sw_stats;
for (i = 0; i < BNXT_NUM_PORT_STATS; i++, j++) { for (i = 0; i < BNXT_NUM_PORT_STATS; i++, j++)
buf[j] = le64_to_cpu(*(port_stats + buf[j] = *(port_stats + bnxt_port_stats_arr[i].offset);
bnxt_port_stats_arr[i].offset));
}
} }
if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) { if (bp->flags & BNXT_FLAG_PORT_STATS_EXT) {
__le64 *rx_port_stats_ext = bp->rx_port_stats_ext.hw_stats; u64 *rx_port_stats_ext = bp->rx_port_stats_ext.sw_stats;
__le64 *tx_port_stats_ext = bp->tx_port_stats_ext.hw_stats; u64 *tx_port_stats_ext = bp->tx_port_stats_ext.sw_stats;
for (i = 0; i < bp->fw_rx_stats_ext_size; i++, j++) { for (i = 0; i < bp->fw_rx_stats_ext_size; i++, j++) {
buf[j] = le64_to_cpu(*(rx_port_stats_ext + buf[j] = *(rx_port_stats_ext +
bnxt_port_stats_ext_arr[i].offset)); bnxt_port_stats_ext_arr[i].offset);
} }
for (i = 0; i < bp->fw_tx_stats_ext_size; i++, j++) { for (i = 0; i < bp->fw_tx_stats_ext_size; i++, j++) {
buf[j] = le64_to_cpu(*(tx_port_stats_ext + buf[j] = *(tx_port_stats_ext +
bnxt_tx_port_stats_ext_arr[i].offset)); bnxt_tx_port_stats_ext_arr[i].offset);
} }
if (bp->pri2cos_valid) { if (bp->pri2cos_valid) {
for (i = 0; i < 8; i++, j++) { for (i = 0; i < 8; i++, j++) {
long n = bnxt_rx_bytes_pri_arr[i].base_off + long n = bnxt_rx_bytes_pri_arr[i].base_off +
bp->pri2cos_idx[i]; bp->pri2cos_idx[i];
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n)); buf[j] = *(rx_port_stats_ext + n);
} }
for (i = 0; i < 8; i++, j++) { for (i = 0; i < 8; i++, j++) {
long n = bnxt_rx_pkts_pri_arr[i].base_off + long n = bnxt_rx_pkts_pri_arr[i].base_off +
bp->pri2cos_idx[i]; bp->pri2cos_idx[i];
buf[j] = le64_to_cpu(*(rx_port_stats_ext + n)); buf[j] = *(rx_port_stats_ext + n);
} }
for (i = 0; i < 8; i++, j++) { for (i = 0; i < 8; i++, j++) {
long n = bnxt_tx_bytes_pri_arr[i].base_off + long n = bnxt_tx_bytes_pri_arr[i].base_off +
bp->pri2cos_idx[i]; bp->pri2cos_idx[i];
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n)); buf[j] = *(tx_port_stats_ext + n);
} }
for (i = 0; i < 8; i++, j++) { for (i = 0; i < 8; i++, j++) {
long n = bnxt_tx_pkts_pri_arr[i].base_off + long n = bnxt_tx_pkts_pri_arr[i].base_off +
bp->pri2cos_idx[i]; bp->pri2cos_idx[i];
buf[j] = le64_to_cpu(*(tx_port_stats_ext + n)); buf[j] = *(tx_port_stats_ext + n);
} }
} }
} }
......
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