diff options
Diffstat (limited to 'drivers/net/ethernet/sfc/ef10.c')
-rw-r--r-- | drivers/net/ethernet/sfc/ef10.c | 87 |
1 files changed, 65 insertions, 22 deletions
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 844ee7539d33..676c3c057bfb 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
@@ -754,6 +754,18 @@ static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = { | |||
754 | EF10_DMA_STAT(rx_align_error, RX_ALIGN_ERROR_PKTS), | 754 | EF10_DMA_STAT(rx_align_error, RX_ALIGN_ERROR_PKTS), |
755 | EF10_DMA_STAT(rx_length_error, RX_LENGTH_ERROR_PKTS), | 755 | EF10_DMA_STAT(rx_length_error, RX_LENGTH_ERROR_PKTS), |
756 | EF10_DMA_STAT(rx_nodesc_drops, RX_NODESC_DROPS), | 756 | EF10_DMA_STAT(rx_nodesc_drops, RX_NODESC_DROPS), |
757 | EF10_DMA_STAT(rx_pm_trunc_bb_overflow, PM_TRUNC_BB_OVERFLOW), | ||
758 | EF10_DMA_STAT(rx_pm_discard_bb_overflow, PM_DISCARD_BB_OVERFLOW), | ||
759 | EF10_DMA_STAT(rx_pm_trunc_vfifo_full, PM_TRUNC_VFIFO_FULL), | ||
760 | EF10_DMA_STAT(rx_pm_discard_vfifo_full, PM_DISCARD_VFIFO_FULL), | ||
761 | EF10_DMA_STAT(rx_pm_trunc_qbb, PM_TRUNC_QBB), | ||
762 | EF10_DMA_STAT(rx_pm_discard_qbb, PM_DISCARD_QBB), | ||
763 | EF10_DMA_STAT(rx_pm_discard_mapping, PM_DISCARD_MAPPING), | ||
764 | EF10_DMA_STAT(rx_dp_q_disabled_packets, RXDP_Q_DISABLED_PKTS), | ||
765 | EF10_DMA_STAT(rx_dp_di_dropped_packets, RXDP_DI_DROPPED_PKTS), | ||
766 | EF10_DMA_STAT(rx_dp_streaming_packets, RXDP_STREAMING_PKTS), | ||
767 | EF10_DMA_STAT(rx_dp_emerg_fetch, RXDP_EMERGENCY_FETCH_CONDITIONS), | ||
768 | EF10_DMA_STAT(rx_dp_emerg_wait, RXDP_EMERGENCY_WAIT_CONDITIONS), | ||
757 | }; | 769 | }; |
758 | 770 | ||
759 | #define HUNT_COMMON_STAT_MASK ((1ULL << EF10_STAT_tx_bytes) | \ | 771 | #define HUNT_COMMON_STAT_MASK ((1ULL << EF10_STAT_tx_bytes) | \ |
@@ -808,44 +820,72 @@ static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = { | |||
808 | #define HUNT_40G_EXTRA_STAT_MASK ((1ULL << EF10_STAT_rx_align_error) | \ | 820 | #define HUNT_40G_EXTRA_STAT_MASK ((1ULL << EF10_STAT_rx_align_error) | \ |
809 | (1ULL << EF10_STAT_rx_length_error)) | 821 | (1ULL << EF10_STAT_rx_length_error)) |
810 | 822 | ||
811 | #if BITS_PER_LONG == 64 | 823 | /* These statistics are only provided if the firmware supports the |
812 | #define STAT_MASK_BITMAP(bits) (bits) | 824 | * capability PM_AND_RXDP_COUNTERS. |
813 | #else | 825 | */ |
814 | #define STAT_MASK_BITMAP(bits) (bits) & 0xffffffff, (bits) >> 32 | 826 | #define HUNT_PM_AND_RXDP_STAT_MASK ( \ |
815 | #endif | 827 | (1ULL << EF10_STAT_rx_pm_trunc_bb_overflow) | \ |
816 | 828 | (1ULL << EF10_STAT_rx_pm_discard_bb_overflow) | \ | |
817 | static const unsigned long *efx_ef10_stat_mask(struct efx_nic *efx) | 829 | (1ULL << EF10_STAT_rx_pm_trunc_vfifo_full) | \ |
818 | { | 830 | (1ULL << EF10_STAT_rx_pm_discard_vfifo_full) | \ |
819 | static const unsigned long hunt_40g_stat_mask[] = { | 831 | (1ULL << EF10_STAT_rx_pm_trunc_qbb) | \ |
820 | STAT_MASK_BITMAP(HUNT_COMMON_STAT_MASK | | 832 | (1ULL << EF10_STAT_rx_pm_discard_qbb) | \ |
821 | HUNT_40G_EXTRA_STAT_MASK) | 833 | (1ULL << EF10_STAT_rx_pm_discard_mapping) | \ |
822 | }; | 834 | (1ULL << EF10_STAT_rx_dp_q_disabled_packets) | \ |
823 | static const unsigned long hunt_10g_only_stat_mask[] = { | 835 | (1ULL << EF10_STAT_rx_dp_di_dropped_packets) | \ |
824 | STAT_MASK_BITMAP(HUNT_COMMON_STAT_MASK | | 836 | (1ULL << EF10_STAT_rx_dp_streaming_packets) | \ |
825 | HUNT_10G_ONLY_STAT_MASK) | 837 | (1ULL << EF10_STAT_rx_dp_emerg_fetch) | \ |
826 | }; | 838 | (1ULL << EF10_STAT_rx_dp_emerg_wait)) |
839 | |||
840 | static u64 efx_ef10_raw_stat_mask(struct efx_nic *efx) | ||
841 | { | ||
842 | u64 raw_mask = HUNT_COMMON_STAT_MASK; | ||
827 | u32 port_caps = efx_mcdi_phy_get_caps(efx); | 843 | u32 port_caps = efx_mcdi_phy_get_caps(efx); |
844 | struct efx_ef10_nic_data *nic_data = efx->nic_data; | ||
828 | 845 | ||
829 | if (port_caps & (1 << MC_CMD_PHY_CAP_40000FDX_LBN)) | 846 | if (port_caps & (1 << MC_CMD_PHY_CAP_40000FDX_LBN)) |
830 | return hunt_40g_stat_mask; | 847 | raw_mask |= HUNT_40G_EXTRA_STAT_MASK; |
831 | else | 848 | else |
832 | return hunt_10g_only_stat_mask; | 849 | raw_mask |= HUNT_10G_ONLY_STAT_MASK; |
850 | |||
851 | if (nic_data->datapath_caps & | ||
852 | (1 << MC_CMD_GET_CAPABILITIES_OUT_PM_AND_RXDP_COUNTERS_LBN)) | ||
853 | raw_mask |= HUNT_PM_AND_RXDP_STAT_MASK; | ||
854 | |||
855 | return raw_mask; | ||
856 | } | ||
857 | |||
858 | static void efx_ef10_get_stat_mask(struct efx_nic *efx, unsigned long *mask) | ||
859 | { | ||
860 | u64 raw_mask = efx_ef10_raw_stat_mask(efx); | ||
861 | |||
862 | #if BITS_PER_LONG == 64 | ||
863 | mask[0] = raw_mask; | ||
864 | #else | ||
865 | mask[0] = raw_mask & 0xffffffff; | ||
866 | mask[1] = raw_mask >> 32; | ||
867 | #endif | ||
833 | } | 868 | } |
834 | 869 | ||
835 | static size_t efx_ef10_describe_stats(struct efx_nic *efx, u8 *names) | 870 | static size_t efx_ef10_describe_stats(struct efx_nic *efx, u8 *names) |
836 | { | 871 | { |
872 | DECLARE_BITMAP(mask, EF10_STAT_COUNT); | ||
873 | |||
874 | efx_ef10_get_stat_mask(efx, mask); | ||
837 | return efx_nic_describe_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, | 875 | return efx_nic_describe_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, |
838 | efx_ef10_stat_mask(efx), names); | 876 | mask, names); |
839 | } | 877 | } |
840 | 878 | ||
841 | static int efx_ef10_try_update_nic_stats(struct efx_nic *efx) | 879 | static int efx_ef10_try_update_nic_stats(struct efx_nic *efx) |
842 | { | 880 | { |
843 | struct efx_ef10_nic_data *nic_data = efx->nic_data; | 881 | struct efx_ef10_nic_data *nic_data = efx->nic_data; |
844 | const unsigned long *stats_mask = efx_ef10_stat_mask(efx); | 882 | DECLARE_BITMAP(mask, EF10_STAT_COUNT); |
845 | __le64 generation_start, generation_end; | 883 | __le64 generation_start, generation_end; |
846 | u64 *stats = nic_data->stats; | 884 | u64 *stats = nic_data->stats; |
847 | __le64 *dma_stats; | 885 | __le64 *dma_stats; |
848 | 886 | ||
887 | efx_ef10_get_stat_mask(efx, mask); | ||
888 | |||
849 | dma_stats = efx->stats_buffer.addr; | 889 | dma_stats = efx->stats_buffer.addr; |
850 | nic_data = efx->nic_data; | 890 | nic_data = efx->nic_data; |
851 | 891 | ||
@@ -853,8 +893,9 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx) | |||
853 | if (generation_end == EFX_MC_STATS_GENERATION_INVALID) | 893 | if (generation_end == EFX_MC_STATS_GENERATION_INVALID) |
854 | return 0; | 894 | return 0; |
855 | rmb(); | 895 | rmb(); |
856 | efx_nic_update_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, stats_mask, | 896 | efx_nic_update_stats(efx_ef10_stat_desc, EF10_STAT_COUNT, mask, |
857 | stats, efx->stats_buffer.addr, false); | 897 | stats, efx->stats_buffer.addr, false); |
898 | rmb(); | ||
858 | generation_start = dma_stats[MC_CMD_MAC_GENERATION_START]; | 899 | generation_start = dma_stats[MC_CMD_MAC_GENERATION_START]; |
859 | if (generation_end != generation_start) | 900 | if (generation_end != generation_start) |
860 | return -EAGAIN; | 901 | return -EAGAIN; |
@@ -873,12 +914,14 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx) | |||
873 | static size_t efx_ef10_update_stats(struct efx_nic *efx, u64 *full_stats, | 914 | static size_t efx_ef10_update_stats(struct efx_nic *efx, u64 *full_stats, |
874 | struct rtnl_link_stats64 *core_stats) | 915 | struct rtnl_link_stats64 *core_stats) |
875 | { | 916 | { |
876 | const unsigned long *mask = efx_ef10_stat_mask(efx); | 917 | DECLARE_BITMAP(mask, EF10_STAT_COUNT); |
877 | struct efx_ef10_nic_data *nic_data = efx->nic_data; | 918 | struct efx_ef10_nic_data *nic_data = efx->nic_data; |
878 | u64 *stats = nic_data->stats; | 919 | u64 *stats = nic_data->stats; |
879 | size_t stats_count = 0, index; | 920 | size_t stats_count = 0, index; |
880 | int retry; | 921 | int retry; |
881 | 922 | ||
923 | efx_ef10_get_stat_mask(efx, mask); | ||
924 | |||
882 | /* If we're unlucky enough to read statistics during the DMA, wait | 925 | /* If we're unlucky enough to read statistics during the DMA, wait |
883 | * up to 10ms for it to finish (typically takes <500us) | 926 | * up to 10ms for it to finish (typically takes <500us) |
884 | */ | 927 | */ |