@@ -681,6 +681,40 @@ static void _mv88e6xxx_get_strings(struct dsa_switch *ds,
681
681
}
682
682
}
683
683
684
+ static uint64_t _mv88e6xxx_get_ethtool_stat (struct dsa_switch * ds ,
685
+ int stat ,
686
+ struct mv88e6xxx_hw_stat * stats ,
687
+ int port )
688
+ {
689
+ struct mv88e6xxx_hw_stat * s = stats + stat ;
690
+ u32 low ;
691
+ u32 high = 0 ;
692
+ int ret ;
693
+ u64 value ;
694
+
695
+ if (s -> reg >= 0x100 ) {
696
+ ret = _mv88e6xxx_reg_read (ds , REG_PORT (port ),
697
+ s -> reg - 0x100 );
698
+ if (ret < 0 )
699
+ return UINT64_MAX ;
700
+
701
+ low = ret ;
702
+ if (s -> sizeof_stat == 4 ) {
703
+ ret = _mv88e6xxx_reg_read (ds , REG_PORT (port ),
704
+ s -> reg - 0x100 + 1 );
705
+ if (ret < 0 )
706
+ return UINT64_MAX ;
707
+ high = ret ;
708
+ }
709
+ } else {
710
+ _mv88e6xxx_stats_read (ds , s -> reg , & low );
711
+ if (s -> sizeof_stat == 8 )
712
+ _mv88e6xxx_stats_read (ds , s -> reg + 1 , & high );
713
+ }
714
+ value = (((u64 )high ) << 16 ) | low ;
715
+ return value ;
716
+ }
717
+
684
718
static void _mv88e6xxx_get_ethtool_stats (struct dsa_switch * ds ,
685
719
int nr_stats ,
686
720
struct mv88e6xxx_hw_stat * stats ,
@@ -699,34 +733,9 @@ static void _mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
699
733
}
700
734
701
735
/* Read each of the counters. */
702
- for (i = 0 ; i < nr_stats ; i ++ ) {
703
- struct mv88e6xxx_hw_stat * s = stats + i ;
704
- u32 low ;
705
- u32 high = 0 ;
736
+ for (i = 0 ; i < nr_stats ; i ++ )
737
+ data [i ] = _mv88e6xxx_get_ethtool_stat (ds , i , stats , port );
706
738
707
- if (s -> reg >= 0x100 ) {
708
- ret = _mv88e6xxx_reg_read (ds , REG_PORT (port ),
709
- s -> reg - 0x100 );
710
- if (ret < 0 )
711
- goto error ;
712
- low = ret ;
713
- if (s -> sizeof_stat == 4 ) {
714
- ret = _mv88e6xxx_reg_read (ds , REG_PORT (port ),
715
- s -> reg - 0x100 + 1 );
716
- if (ret < 0 )
717
- goto error ;
718
- high = ret ;
719
- }
720
- data [i ] = (((u64 )high ) << 16 ) | low ;
721
- continue ;
722
- }
723
- _mv88e6xxx_stats_read (ds , s -> reg , & low );
724
- if (s -> sizeof_stat == 8 )
725
- _mv88e6xxx_stats_read (ds , s -> reg + 1 , & high );
726
-
727
- data [i ] = (((u64 )high ) << 32 ) | low ;
728
- }
729
- error :
730
739
mutex_unlock (& ps -> smi_mutex );
731
740
}
732
741
0 commit comments