@@ -444,6 +444,18 @@ static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = {
444444 EF10_DMA_STAT (rx_align_error , RX_ALIGN_ERROR_PKTS ),
445445 EF10_DMA_STAT (rx_length_error , RX_LENGTH_ERROR_PKTS ),
446446 EF10_DMA_STAT (rx_nodesc_drops , RX_NODESC_DROPS ),
447+ EF10_DMA_STAT (rx_pm_trunc_bb_overflow , PM_TRUNC_BB_OVERFLOW ),
448+ EF10_DMA_STAT (rx_pm_discard_bb_overflow , PM_DISCARD_BB_OVERFLOW ),
449+ EF10_DMA_STAT (rx_pm_trunc_vfifo_full , PM_TRUNC_VFIFO_FULL ),
450+ EF10_DMA_STAT (rx_pm_discard_vfifo_full , PM_DISCARD_VFIFO_FULL ),
451+ EF10_DMA_STAT (rx_pm_trunc_qbb , PM_TRUNC_QBB ),
452+ EF10_DMA_STAT (rx_pm_discard_qbb , PM_DISCARD_QBB ),
453+ EF10_DMA_STAT (rx_pm_discard_mapping , PM_DISCARD_MAPPING ),
454+ EF10_DMA_STAT (rx_dp_q_disabled_packets , RXDP_Q_DISABLED_PKTS ),
455+ EF10_DMA_STAT (rx_dp_di_dropped_packets , RXDP_DI_DROPPED_PKTS ),
456+ EF10_DMA_STAT (rx_dp_streaming_packets , RXDP_STREAMING_PKTS ),
457+ EF10_DMA_STAT (rx_dp_emerg_fetch , RXDP_EMERGENCY_FETCH_CONDITIONS ),
458+ EF10_DMA_STAT (rx_dp_emerg_wait , RXDP_EMERGENCY_WAIT_CONDITIONS ),
447459};
448460
449461#define HUNT_COMMON_STAT_MASK ((1ULL << EF10_STAT_tx_bytes) | \
@@ -498,53 +510,82 @@ static const struct efx_hw_stat_desc efx_ef10_stat_desc[EF10_STAT_COUNT] = {
498510#define HUNT_40G_EXTRA_STAT_MASK ((1ULL << EF10_STAT_rx_align_error) | \
499511 (1ULL << EF10_STAT_rx_length_error))
500512
501- #if BITS_PER_LONG == 64
502- #define STAT_MASK_BITMAP (bits ) (bits)
503- #else
504- #define STAT_MASK_BITMAP (bits ) (bits) & 0xffffffff, (bits) >> 32
505- #endif
506-
507- static const unsigned long * efx_ef10_stat_mask (struct efx_nic * efx )
508- {
509- static const unsigned long hunt_40g_stat_mask [] = {
510- STAT_MASK_BITMAP (HUNT_COMMON_STAT_MASK |
511- HUNT_40G_EXTRA_STAT_MASK )
512- };
513- static const unsigned long hunt_10g_only_stat_mask [] = {
514- STAT_MASK_BITMAP (HUNT_COMMON_STAT_MASK |
515- HUNT_10G_ONLY_STAT_MASK )
516- };
513+ /* These statistics are only provided if the firmware supports the
514+ * capability PM_AND_RXDP_COUNTERS.
515+ */
516+ #define HUNT_PM_AND_RXDP_STAT_MASK ( \
517+ (1ULL << EF10_STAT_rx_pm_trunc_bb_overflow) | \
518+ (1ULL << EF10_STAT_rx_pm_discard_bb_overflow) | \
519+ (1ULL << EF10_STAT_rx_pm_trunc_vfifo_full) | \
520+ (1ULL << EF10_STAT_rx_pm_discard_vfifo_full) | \
521+ (1ULL << EF10_STAT_rx_pm_trunc_qbb) | \
522+ (1ULL << EF10_STAT_rx_pm_discard_qbb) | \
523+ (1ULL << EF10_STAT_rx_pm_discard_mapping) | \
524+ (1ULL << EF10_STAT_rx_dp_q_disabled_packets) | \
525+ (1ULL << EF10_STAT_rx_dp_di_dropped_packets) | \
526+ (1ULL << EF10_STAT_rx_dp_streaming_packets) | \
527+ (1ULL << EF10_STAT_rx_dp_emerg_fetch) | \
528+ (1ULL << EF10_STAT_rx_dp_emerg_wait))
529+
530+ static u64 efx_ef10_raw_stat_mask (struct efx_nic * efx )
531+ {
532+ u64 raw_mask = HUNT_COMMON_STAT_MASK ;
517533 u32 port_caps = efx_mcdi_phy_get_caps (efx );
534+ struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
518535
519536 if (port_caps & (1 << MC_CMD_PHY_CAP_40000FDX_LBN ))
520- return hunt_40g_stat_mask ;
537+ raw_mask |= HUNT_40G_EXTRA_STAT_MASK ;
521538 else
522- return hunt_10g_only_stat_mask ;
539+ raw_mask |= HUNT_10G_ONLY_STAT_MASK ;
540+
541+ if (nic_data -> datapath_caps &
542+ (1 << MC_CMD_GET_CAPABILITIES_OUT_PM_AND_RXDP_COUNTERS_LBN ))
543+ raw_mask |= HUNT_PM_AND_RXDP_STAT_MASK ;
544+
545+ return raw_mask ;
546+ }
547+
548+ static void efx_ef10_get_stat_mask (struct efx_nic * efx , unsigned long * mask )
549+ {
550+ u64 raw_mask = efx_ef10_raw_stat_mask (efx );
551+
552+ #if BITS_PER_LONG == 64
553+ mask [0 ] = raw_mask ;
554+ #else
555+ mask [0 ] = raw_mask & 0xffffffff ;
556+ mask [1 ] = raw_mask >> 32 ;
557+ #endif
523558}
524559
525560static size_t efx_ef10_describe_stats (struct efx_nic * efx , u8 * names )
526561{
562+ DECLARE_BITMAP (mask , EF10_STAT_COUNT );
563+
564+ efx_ef10_get_stat_mask (efx , mask );
527565 return efx_nic_describe_stats (efx_ef10_stat_desc , EF10_STAT_COUNT ,
528- efx_ef10_stat_mask ( efx ) , names );
566+ mask , names );
529567}
530568
531569static int efx_ef10_try_update_nic_stats (struct efx_nic * efx )
532570{
533571 struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
534- const unsigned long * stats_mask = efx_ef10_stat_mask ( efx );
572+ DECLARE_BITMAP ( mask , EF10_STAT_COUNT );
535573 __le64 generation_start , generation_end ;
536574 u64 * stats = nic_data -> stats ;
537575 __le64 * dma_stats ;
538576
577+ efx_ef10_get_stat_mask (efx , mask );
578+
539579 dma_stats = efx -> stats_buffer .addr ;
540580 nic_data = efx -> nic_data ;
541581
542582 generation_end = dma_stats [MC_CMD_MAC_GENERATION_END ];
543583 if (generation_end == EFX_MC_STATS_GENERATION_INVALID )
544584 return 0 ;
545585 rmb ();
546- efx_nic_update_stats (efx_ef10_stat_desc , EF10_STAT_COUNT , stats_mask ,
586+ efx_nic_update_stats (efx_ef10_stat_desc , EF10_STAT_COUNT , mask ,
547587 stats , efx -> stats_buffer .addr , false);
588+ rmb ();
548589 generation_start = dma_stats [MC_CMD_MAC_GENERATION_START ];
549590 if (generation_end != generation_start )
550591 return - EAGAIN ;
@@ -563,12 +604,14 @@ static int efx_ef10_try_update_nic_stats(struct efx_nic *efx)
563604static size_t efx_ef10_update_stats (struct efx_nic * efx , u64 * full_stats ,
564605 struct rtnl_link_stats64 * core_stats )
565606{
566- const unsigned long * mask = efx_ef10_stat_mask ( efx );
607+ DECLARE_BITMAP ( mask , EF10_STAT_COUNT );
567608 struct efx_ef10_nic_data * nic_data = efx -> nic_data ;
568609 u64 * stats = nic_data -> stats ;
569610 size_t stats_count = 0 , index ;
570611 int retry ;
571612
613+ efx_ef10_get_stat_mask (efx , mask );
614+
572615 /* If we're unlucky enough to read statistics during the DMA, wait
573616 * up to 10ms for it to finish (typically takes <500us)
574617 */
0 commit comments