Michael McTernan

[PATCH] Ethtool support for FEC MIB control registers

Discussion created by Michael McTernan on May 11, 2012

The Fast Ethernet Controller, as used the at least the i.MX28 and i.MX53 has a bunch of registers which give packet counts and various statistics.  This can be very useful in tracking problems such as mismatched speed/duplex settings or board level problems.

Attached is a patch tested on i.MX28 and i.MX53 with kernels 2.6.38 and 3.0.0 respectively (where fec.c appears as the same).  This allows the counters to be dumped by Ethtool e.g.

ethtool -S eth0
NIC statistics:
     rmon_t_drop            : 0
     rmon_t_packets         : 22398
     rmon_t_bc_packets      : 39
     rmon_t_mc_packets      : 0
     rmon_t_crc_or_align_err: 0
     rmon_t_undersize       : 0
     rmon_t_oversize        : 0
     rmon_t_frag            : 0
     rmon_t_jab             : 0
     rmon_t_collision       : 0
     rmon_t_p64byte         : 39
     rmon_t_p65to127        : 12306
     rmon_t_p128to255       : 561
     rmon_t_p256to511       : 638
     rmon_t_p512to1023      : 1698
     rmon_t_p1024to2047     : 7156
     rmon_t_p_gte2028       : 0
     rmon_t_octets          : 12883771
     ieee_t_drop            : 0
     ieee_t_frame_ok        : 22398
     ieee_t_1col            : 0
     ieee_t_mcol            : 0
     ieee_t_def             : 0
     ieee_t_lcol            : 0
     ieee_t_excol           : 0
     ieee_t_macerr          : 0
     ieee_t_cserr           : 0
     ieee_t_sqe             : 0
     ieee_t_fdxfc           : 0
     ieee_t_octets_ok       : 12883771
     rmon_r_packets         : 21760
     rmon_r_bc_packets      : 0
     rmon_r_mc_packets      : 2
     rmon_r_crc_or_align_err: 0
     rmon_r_undersize       : 0
     rmon_r_oversize        : 0
     rmon_r_frag            : 0
     rmon_r_jab             : 0
     rmon_r_resvd_0         : 0
     rmon_r_p64             : 1
     rmon_r_p65to127        : 18969
     rmon_r_p128to255       : 0
     rmon_t_p256to511       : 2790
     rmon_r_p512to1023      : 0
     rmon_r_p1024to2047     : 0
     rmon_r_p_gte2048       : 0
     rmon_r_octets          : 2542934
     ieee_r_drop            : 0
     ieee_r_frame_ok        : 21758
     ieee_r_crc             : 0
     ieee_r_align           : 0
     ieee_r_macerr          : 0
     ieee_r_fdxfc           : 0
     ieee_r_octets_ok       : 2542770

 

It's probably applicable to other parts as well, although I don't have any way to test.  Also in the patch is a change to swap_buffer() which looked to compile to faster code when I checked the assembly.  It makes minuscule difference to anything though.

Original Attachment has been moved to: 176-fecethtoolstats.patch

Outcomes