sonic-net / sonic-utilities

Command line utilities for the SONiC project
Other
152 stars 646 forks source link

portstat shows negative counter for RX_OK #129

Open pavel-shirshov opened 6 years ago

pavel-shirshov commented 6 years ago
:~$ sudo portstat
Last cached time was 2017-10-11 19:00:26.387868
      Iface    ADMIN    OPER        RX_OK       RX_BPS    RX_UTIL    RX_ERR    RX_DRP    RX_OVR       TX_OK        TX_BPS    TX_UTIL    TX_ERR       TX_DRP    TX_OVR
-----------  -------  ------  -----------  -----------  ---------  --------  --------  --------  ----------  ------------  ---------  --------  -----------  --------
Ethernet116       up      up     -584,110  9725.13 B/s      0.00%         0   586,217         0  72,208,263  4624.59 KB/s      0.09%         0  377,228,521         0
jihaix commented 5 years ago

  portstat show counter's value in two mode, namely absolute mode and relative mode .   When running command portstat -c, the value of counters will be saved in tmp file and portstat run into relative mode. In relative mode , portstat will show the diff between counters' current value and old value saved in tmp file, namely print(current - old). When running command portstat -D, portstat will clear tmp file and run into absolute mode. In this mode, portstat will show the absolute value of current counters, namely print(current).   So, portstat shows negative counter because it's in relative mode and its current value is smaller than old value saved in tmp file . There are two logical possiblities, one is the RX_OK's value is lagger than uint64 and integer overflow happends in sonic-syncd, which is very unlikely. The other is the RX_OK's value provided by SAI is less than uint64 and integer overflow happends in SAI or SDK, which is very likely. So you may check the register's bit width provided by SAI and SDK.