diff options
| author | Dmitry Bogdanov <dmitry.bogdanov@aquantia.com> | 2019-04-29 06:05:07 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-05-01 09:30:15 -0400 |
| commit | ce4cdbe44cffeb0d6a24bb397834ebfab75c6b2b (patch) | |
| tree | b93ecc5b7c9e95edd0d2c8258edd7aea789cee09 | |
| parent | f55d477bb513c9267a46d7a795fb09f73084f76f (diff) | |
net: aquantia: fixups on 64bit dma counters
DMA counters are 64 bit and we can fetch that to reduce
counter overflow, espesially on byte counters.
Tested-by: Nikita Danilov <ndanilov@aquantia.com>
Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
Signed-off-by: Dmitry Bogdanov <dmitry.bogdanov@aquantia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6 files changed, 36 insertions, 64 deletions
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c b/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c index d526c4f19d34..22a1c784dc9c 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c | |||
| @@ -53,6 +53,18 @@ void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value) | |||
| 53 | writel(value, hw->mmio + reg); | 53 | writel(value, hw->mmio + reg); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | /* Most of 64-bit registers are in LSW, MSW form. | ||
| 57 | Counters are normally implemented by HW as latched pairs: | ||
| 58 | reading LSW first locks MSW, to overcome LSW overflow | ||
| 59 | */ | ||
| 60 | u64 aq_hw_read_reg64(struct aq_hw_s *hw, u32 reg) | ||
| 61 | { | ||
| 62 | u64 value = aq_hw_read_reg(hw, reg); | ||
| 63 | |||
| 64 | value |= (u64)aq_hw_read_reg(hw, reg + 4) << 32; | ||
| 65 | return value; | ||
| 66 | } | ||
| 67 | |||
| 56 | int aq_hw_err_from_flags(struct aq_hw_s *hw) | 68 | int aq_hw_err_from_flags(struct aq_hw_s *hw) |
| 57 | { | 69 | { |
| 58 | int err = 0; | 70 | int err = 0; |
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h b/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h index bc711238ca0c..bf73428ed689 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h | |||
| @@ -35,6 +35,7 @@ void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, | |||
| 35 | u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift); | 35 | u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift); |
| 36 | u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg); | 36 | u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg); |
| 37 | void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value); | 37 | void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value); |
| 38 | u64 aq_hw_read_reg64(struct aq_hw_s *hw, u32 reg); | ||
| 38 | int aq_hw_err_from_flags(struct aq_hw_s *hw); | 39 | int aq_hw_err_from_flags(struct aq_hw_s *hw); |
| 39 | 40 | ||
| 40 | #endif /* AQ_HW_UTILS_H */ | 41 | #endif /* AQ_HW_UTILS_H */ |
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c index 9442deff98a8..eaab25cd08b3 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c | |||
| @@ -49,11 +49,6 @@ u32 hw_atl_glb_soft_res_get(struct aq_hw_s *aq_hw) | |||
| 49 | HW_ATL_GLB_SOFT_RES_SHIFT); | 49 | HW_ATL_GLB_SOFT_RES_SHIFT); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | u32 hw_atl_reg_rx_dma_stat_counter7get(struct aq_hw_s *aq_hw) | ||
| 53 | { | ||
| 54 | return aq_hw_read_reg(aq_hw, HW_ATL_RX_DMA_STAT_COUNTER7_ADR); | ||
| 55 | } | ||
| 56 | |||
| 57 | u32 hw_atl_reg_glb_mif_id_get(struct aq_hw_s *aq_hw) | 52 | u32 hw_atl_reg_glb_mif_id_get(struct aq_hw_s *aq_hw) |
| 58 | { | 53 | { |
| 59 | return aq_hw_read_reg(aq_hw, HW_ATL_GLB_MIF_ID_ADR); | 54 | return aq_hw_read_reg(aq_hw, HW_ATL_GLB_MIF_ID_ADR); |
| @@ -65,44 +60,24 @@ u32 hw_atl_rpb_rx_dma_drop_pkt_cnt_get(struct aq_hw_s *aq_hw) | |||
| 65 | return aq_hw_read_reg(aq_hw, HW_ATL_RPB_RX_DMA_DROP_PKT_CNT_ADR); | 60 | return aq_hw_read_reg(aq_hw, HW_ATL_RPB_RX_DMA_DROP_PKT_CNT_ADR); |
| 66 | } | 61 | } |
| 67 | 62 | ||
| 68 | u32 hw_atl_stats_rx_dma_good_octet_counterlsw_get(struct aq_hw_s *aq_hw) | 63 | u64 hw_atl_stats_rx_dma_good_octet_counter_get(struct aq_hw_s *aq_hw) |
| 69 | { | ||
| 70 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_OCTET_COUNTERLSW); | ||
| 71 | } | ||
| 72 | |||
| 73 | u32 hw_atl_stats_rx_dma_good_pkt_counterlsw_get(struct aq_hw_s *aq_hw) | ||
| 74 | { | ||
| 75 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_PKT_COUNTERLSW); | ||
| 76 | } | ||
| 77 | |||
| 78 | u32 hw_atl_stats_tx_dma_good_octet_counterlsw_get(struct aq_hw_s *aq_hw) | ||
| 79 | { | ||
| 80 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_OCTET_COUNTERLSW); | ||
| 81 | } | ||
| 82 | |||
| 83 | u32 hw_atl_stats_tx_dma_good_pkt_counterlsw_get(struct aq_hw_s *aq_hw) | ||
| 84 | { | ||
| 85 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_PKT_COUNTERLSW); | ||
| 86 | } | ||
| 87 | |||
| 88 | u32 hw_atl_stats_rx_dma_good_octet_countermsw_get(struct aq_hw_s *aq_hw) | ||
| 89 | { | 64 | { |
| 90 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_OCTET_COUNTERMSW); | 65 | return aq_hw_read_reg64(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_OCTET_COUNTERLSW); |
| 91 | } | 66 | } |
| 92 | 67 | ||
| 93 | u32 hw_atl_stats_rx_dma_good_pkt_countermsw_get(struct aq_hw_s *aq_hw) | 68 | u64 hw_atl_stats_rx_dma_good_pkt_counter_get(struct aq_hw_s *aq_hw) |
| 94 | { | 69 | { |
| 95 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_PKT_COUNTERMSW); | 70 | return aq_hw_read_reg64(aq_hw, HW_ATL_STATS_RX_DMA_GOOD_PKT_COUNTERLSW); |
| 96 | } | 71 | } |
| 97 | 72 | ||
| 98 | u32 hw_atl_stats_tx_dma_good_octet_countermsw_get(struct aq_hw_s *aq_hw) | 73 | u64 hw_atl_stats_tx_dma_good_octet_counter_get(struct aq_hw_s *aq_hw) |
| 99 | { | 74 | { |
| 100 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_OCTET_COUNTERMSW); | 75 | return aq_hw_read_reg64(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_OCTET_COUNTERLSW); |
| 101 | } | 76 | } |
| 102 | 77 | ||
| 103 | u32 hw_atl_stats_tx_dma_good_pkt_countermsw_get(struct aq_hw_s *aq_hw) | 78 | u64 hw_atl_stats_tx_dma_good_pkt_counter_get(struct aq_hw_s *aq_hw) |
| 104 | { | 79 | { |
| 105 | return aq_hw_read_reg(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_PKT_COUNTERMSW); | 80 | return aq_hw_read_reg64(aq_hw, HW_ATL_STATS_TX_DMA_GOOD_PKT_COUNTERLSW); |
| 106 | } | 81 | } |
| 107 | 82 | ||
| 108 | /* interrupt */ | 83 | /* interrupt */ |
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h index 4cfa4bd80ad3..2eb44e1cff70 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h | |||
| @@ -40,29 +40,17 @@ u32 hw_atl_glb_soft_res_get(struct aq_hw_s *aq_hw); | |||
| 40 | 40 | ||
| 41 | u32 hw_atl_rpb_rx_dma_drop_pkt_cnt_get(struct aq_hw_s *aq_hw); | 41 | u32 hw_atl_rpb_rx_dma_drop_pkt_cnt_get(struct aq_hw_s *aq_hw); |
| 42 | 42 | ||
| 43 | /* get rx dma good octet counter lsw */ | 43 | /* get rx dma good octet counter */ |
| 44 | u32 hw_atl_stats_rx_dma_good_octet_counterlsw_get(struct aq_hw_s *aq_hw); | 44 | u64 hw_atl_stats_rx_dma_good_octet_counter_get(struct aq_hw_s *aq_hw); |
| 45 | 45 | ||
| 46 | /* get rx dma good packet counter lsw */ | 46 | /* get rx dma good packet counter */ |
| 47 | u32 hw_atl_stats_rx_dma_good_pkt_counterlsw_get(struct aq_hw_s *aq_hw); | 47 | u64 hw_atl_stats_rx_dma_good_pkt_counter_get(struct aq_hw_s *aq_hw); |
| 48 | 48 | ||
| 49 | /* get tx dma good octet counter lsw */ | 49 | /* get tx dma good octet counter */ |
| 50 | u32 hw_atl_stats_tx_dma_good_octet_counterlsw_get(struct aq_hw_s *aq_hw); | 50 | u64 hw_atl_stats_tx_dma_good_octet_counter_get(struct aq_hw_s *aq_hw); |
| 51 | 51 | ||
| 52 | /* get tx dma good packet counter lsw */ | 52 | /* get tx dma good packet counter */ |
| 53 | u32 hw_atl_stats_tx_dma_good_pkt_counterlsw_get(struct aq_hw_s *aq_hw); | 53 | u64 hw_atl_stats_tx_dma_good_pkt_counter_get(struct aq_hw_s *aq_hw); |
| 54 | |||
| 55 | /* get rx dma good octet counter msw */ | ||
| 56 | u32 hw_atl_stats_rx_dma_good_octet_countermsw_get(struct aq_hw_s *aq_hw); | ||
| 57 | |||
| 58 | /* get rx dma good packet counter msw */ | ||
| 59 | u32 hw_atl_stats_rx_dma_good_pkt_countermsw_get(struct aq_hw_s *aq_hw); | ||
| 60 | |||
| 61 | /* get tx dma good octet counter msw */ | ||
| 62 | u32 hw_atl_stats_tx_dma_good_octet_countermsw_get(struct aq_hw_s *aq_hw); | ||
| 63 | |||
| 64 | /* get tx dma good packet counter msw */ | ||
| 65 | u32 hw_atl_stats_tx_dma_good_pkt_countermsw_get(struct aq_hw_s *aq_hw); | ||
| 66 | 54 | ||
| 67 | /* get msm rx errors counter register */ | 55 | /* get msm rx errors counter register */ |
| 68 | u32 hw_atl_reg_mac_msm_rx_errs_cnt_get(struct aq_hw_s *aq_hw); | 56 | u32 hw_atl_reg_mac_msm_rx_errs_cnt_get(struct aq_hw_s *aq_hw); |
| @@ -82,9 +70,6 @@ u32 hw_atl_reg_mac_msm_rx_bcst_octets_counter1get(struct aq_hw_s *aq_hw); | |||
| 82 | /* get msm rx unicast octets counter register 0 */ | 70 | /* get msm rx unicast octets counter register 0 */ |
| 83 | u32 hw_atl_reg_mac_msm_rx_ucst_octets_counter0get(struct aq_hw_s *aq_hw); | 71 | u32 hw_atl_reg_mac_msm_rx_ucst_octets_counter0get(struct aq_hw_s *aq_hw); |
| 84 | 72 | ||
| 85 | /* get rx dma statistics counter 7 */ | ||
| 86 | u32 hw_atl_reg_rx_dma_stat_counter7get(struct aq_hw_s *aq_hw); | ||
| 87 | |||
| 88 | /* get msm tx errors counter register */ | 73 | /* get msm tx errors counter register */ |
| 89 | u32 hw_atl_reg_mac_msm_tx_errs_cnt_get(struct aq_hw_s *aq_hw); | 74 | u32 hw_atl_reg_mac_msm_tx_errs_cnt_get(struct aq_hw_s *aq_hw); |
| 90 | 75 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h index 430bbd45b2f0..b64140924a02 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h | |||
| @@ -58,9 +58,6 @@ | |||
| 58 | /* preprocessor definitions for msm rx unicast octets counter register 0 */ | 58 | /* preprocessor definitions for msm rx unicast octets counter register 0 */ |
| 59 | #define HW_ATL_MAC_MSM_RX_UCST_OCTETS_COUNTER0_ADR 0x000001b8u | 59 | #define HW_ATL_MAC_MSM_RX_UCST_OCTETS_COUNTER0_ADR 0x000001b8u |
| 60 | 60 | ||
| 61 | /* preprocessor definitions for rx dma statistics counter 7 */ | ||
| 62 | #define HW_ATL_RX_DMA_STAT_COUNTER7_ADR 0x00006818u | ||
| 63 | |||
| 64 | /* preprocessor definitions for msm tx unicast frames counter register */ | 61 | /* preprocessor definitions for msm tx unicast frames counter register */ |
| 65 | #define HW_ATL_MAC_MSM_TX_UCST_FRM_CNT_ADR 0x00000108u | 62 | #define HW_ATL_MAC_MSM_TX_UCST_FRM_CNT_ADR 0x00000108u |
| 66 | 63 | ||
diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c index b521457434fc..1208f7ecdd76 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | |||
| @@ -545,7 +545,7 @@ void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, | |||
| 545 | pmbox->stats.ubtc = pmbox->stats.uptc * mtu; | 545 | pmbox->stats.ubtc = pmbox->stats.uptc * mtu; |
| 546 | pmbox->stats.dpc = atomic_read(&self->dpc); | 546 | pmbox->stats.dpc = atomic_read(&self->dpc); |
| 547 | } else { | 547 | } else { |
| 548 | pmbox->stats.dpc = hw_atl_reg_rx_dma_stat_counter7get(self); | 548 | pmbox->stats.dpc = hw_atl_rpb_rx_dma_drop_pkt_cnt_get(self); |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | err_exit:; | 551 | err_exit:; |
| @@ -763,6 +763,7 @@ static int hw_atl_fw1x_deinit(struct aq_hw_s *self) | |||
| 763 | int hw_atl_utils_update_stats(struct aq_hw_s *self) | 763 | int hw_atl_utils_update_stats(struct aq_hw_s *self) |
| 764 | { | 764 | { |
| 765 | struct hw_atl_utils_mbox mbox; | 765 | struct hw_atl_utils_mbox mbox; |
| 766 | struct aq_stats_s *cs = &self->curr_stats; | ||
| 766 | 767 | ||
| 767 | hw_atl_utils_mpi_read_stats(self, &mbox); | 768 | hw_atl_utils_mpi_read_stats(self, &mbox); |
| 768 | 769 | ||
| @@ -789,10 +790,11 @@ int hw_atl_utils_update_stats(struct aq_hw_s *self) | |||
| 789 | AQ_SDELTA(dpc); | 790 | AQ_SDELTA(dpc); |
| 790 | } | 791 | } |
| 791 | #undef AQ_SDELTA | 792 | #undef AQ_SDELTA |
| 792 | self->curr_stats.dma_pkt_rc = hw_atl_stats_rx_dma_good_pkt_counterlsw_get(self); | 793 | |
| 793 | self->curr_stats.dma_pkt_tc = hw_atl_stats_tx_dma_good_pkt_counterlsw_get(self); | 794 | cs->dma_pkt_rc = hw_atl_stats_rx_dma_good_pkt_counter_get(self); |
| 794 | self->curr_stats.dma_oct_rc = hw_atl_stats_rx_dma_good_octet_counterlsw_get(self); | 795 | cs->dma_pkt_tc = hw_atl_stats_tx_dma_good_pkt_counter_get(self); |
| 795 | self->curr_stats.dma_oct_tc = hw_atl_stats_tx_dma_good_octet_counterlsw_get(self); | 796 | cs->dma_oct_rc = hw_atl_stats_rx_dma_good_octet_counter_get(self); |
| 797 | cs->dma_oct_tc = hw_atl_stats_tx_dma_good_octet_counter_get(self); | ||
| 796 | 798 | ||
| 797 | memcpy(&self->last_stats, &mbox.stats, sizeof(mbox.stats)); | 799 | memcpy(&self->last_stats, &mbox.stats, sizeof(mbox.stats)); |
| 798 | 800 | ||
