Skip to content

Commit ada0e85

Browse files
committed
Add FEC correctable and uncorrectable port stats
Signed-off-by: Prince George <[email protected]>
1 parent ac2f553 commit ada0e85

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

scripts/portstat

+26-12
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ NStats = namedtuple("NStats", "rx_ok, rx_err, rx_drop, rx_ovr, tx_ok,\
5151
rx_uca, rx_mca, rx_bca, rx_all,\
5252
tx_64, tx_65_127, tx_128_255, tx_256_511, tx_512_1023, tx_1024_1518, tx_1519_2047, tx_2048_4095, tx_4096_9216, tx_9217_16383,\
5353
tx_uca, tx_mca, tx_bca, tx_all,\
54-
rx_jbr, rx_frag, rx_usize, rx_ovrrun")
54+
rx_jbr, rx_frag, rx_usize, rx_ovrrun, fec_corr, fec_uncorr")
5555
header_all = ['IFACE', 'STATE', 'RX_OK', 'RX_BPS', 'RX_PPS', 'RX_UTIL', 'RX_ERR', 'RX_DRP', 'RX_OVR',
56-
'TX_OK', 'TX_BPS', 'TX_PPS', 'TX_UTIL', 'TX_ERR', 'TX_DRP', 'TX_OVR']
56+
'TX_OK', 'TX_BPS', 'TX_PPS', 'TX_UTIL', 'TX_ERR', 'TX_DRP', 'TX_OVR', 'FEC_CORR', 'FEC_UNCORR']
5757
header_std = ['IFACE', 'STATE', 'RX_OK', 'RX_BPS', 'RX_UTIL', 'RX_ERR', 'RX_DRP', 'RX_OVR',
5858
'TX_OK', 'TX_BPS', 'TX_UTIL', 'TX_ERR', 'TX_DRP', 'TX_OVR']
59-
header_errors_only = ['IFACE', 'STATE', 'RX_ERR', 'RX_DRP', 'RX_OVR', 'TX_ERR', 'TX_DRP', 'TX_OVR']
59+
header_errors_only = ['IFACE', 'STATE', 'RX_ERR', 'RX_DRP', 'RX_OVR', 'TX_ERR', 'TX_DRP', 'TX_OVR', 'FEC_CORR', 'FEC_UNCORR']
6060
header_rates_only = ['IFACE', 'STATE', 'RX_OK', 'RX_BPS', 'RX_PPS', 'RX_UTIL', 'TX_OK', 'TX_BPS', 'TX_PPS', 'TX_UTIL']
6161

6262
rates_key_list = [ 'RX_BPS', 'RX_PPS', 'RX_UTIL', 'TX_BPS', 'TX_PPS', 'TX_UTIL' ]
@@ -67,7 +67,7 @@ RateStats = namedtuple("RateStats", ratestat_fields)
6767
The order and count of statistics mentioned below needs to be in sync with the values in portstat script
6868
So, any fields added/deleted in here should be reflected in portstat script also
6969
"""
70-
BUCKET_NUM = 42
70+
BUCKET_NUM = 44
7171
counter_bucket_dict = {
7272
0:['SAI_PORT_STAT_IF_IN_UCAST_PKTS', 'SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS'],
7373
1:['SAI_PORT_STAT_IF_IN_ERRORS'],
@@ -110,7 +110,9 @@ counter_bucket_dict = {
110110
38:['SAI_PORT_STAT_ETHER_STATS_JABBERS'],
111111
39:['SAI_PORT_STAT_ETHER_STATS_FRAGMENTS'],
112112
40:['SAI_PORT_STAT_ETHER_STATS_UNDERSIZE_PKTS'],
113-
41:['SAI_PORT_STAT_IP_IN_RECEIVES']
113+
41:['SAI_PORT_STAT_IP_IN_RECEIVES'],
114+
42:['SAI_PORT_STAT_IF_IN_FEC_CORRECTABLE_FRAMES'],
115+
43:['SAI_PORT_STAT_IF_IN_FEC_NOT_CORRECTABLE_FRAMES']
114116
}
115117

116118
STATUS_NA = 'N/A'
@@ -285,7 +287,9 @@ class Portstat(object):
285287
format_util(rates.tx_bps, port_speed),
286288
format_number_with_comma(data.tx_err),
287289
format_number_with_comma(data.tx_drop),
288-
format_number_with_comma(data.tx_ovr)))
290+
format_number_with_comma(data.tx_ovr),
291+
format_number_with_comma(data.fec_corr),
292+
format_number_with_comma(data.fec_uncorr)))
289293
elif errors_only:
290294
header = header_errors_only
291295
table.append((key, self.get_port_state(key),
@@ -294,7 +298,9 @@ class Portstat(object):
294298
format_number_with_comma(data.rx_ovr),
295299
format_number_with_comma(data.tx_err),
296300
format_number_with_comma(data.tx_drop),
297-
format_number_with_comma(data.tx_ovr)))
301+
format_number_with_comma(data.tx_ovr),
302+
format_number_with_comma(data.fec_corr),
303+
format_number_with_comma(data.fec_uncorr)))
298304
elif rates_only:
299305
header = header_rates_only
300306
table.append((key, self.get_port_state(key),
@@ -430,7 +436,9 @@ class Portstat(object):
430436
format_util(rates.tx_bps, port_speed),
431437
ns_diff(cntr.tx_err, old_cntr.tx_err),
432438
ns_diff(cntr.tx_drop, old_cntr.tx_drop),
433-
ns_diff(cntr.tx_ovr, old_cntr.tx_ovr)))
439+
ns_diff(cntr.tx_ovr, old_cntr.tx_ovr),
440+
ns_diff(cntr.fec_corr, old_cntr.fec_corr),
441+
ns_diff(cntr.fec_uncorr, old_cntr.fec_uncorr)))
434442
else:
435443
table.append((key, self.get_port_state(key),
436444
format_number_with_comma(cntr.rx_ok),
@@ -446,7 +454,9 @@ class Portstat(object):
446454
format_util(rates.tx_bps, port_speed),
447455
format_number_with_comma(cntr.tx_err),
448456
format_number_with_comma(cntr.tx_drop),
449-
format_number_with_comma(cntr.tx_ovr)))
457+
format_number_with_comma(cntr.tx_ovr),
458+
format_number_with_comma(cntr.fec_corr),
459+
format_number_with_comma(cntr.fec_uncorr)))
450460
elif errors_only:
451461
header = header_errors_only
452462
if old_cntr is not None:
@@ -456,15 +466,19 @@ class Portstat(object):
456466
ns_diff(cntr.rx_ovr, old_cntr.rx_ovr),
457467
ns_diff(cntr.tx_err, old_cntr.tx_err),
458468
ns_diff(cntr.tx_drop, old_cntr.tx_drop),
459-
ns_diff(cntr.tx_ovr, old_cntr.tx_ovr)))
469+
ns_diff(cntr.tx_ovr, old_cntr.tx_ovr),
470+
ns_diff(cntr.fec_corr, old_cntr.fec_corr),
471+
ns_diff(cntr.fec_uncorr, old_cntr.fec_uncorr)))
460472
else:
461473
table.append((key, self.get_port_state(key),
462474
format_number_with_comma(cntr.rx_err),
463475
format_number_with_comma(cntr.rx_drop),
464476
format_number_with_comma(cntr.rx_ovr),
465477
format_number_with_comma(cntr.tx_err),
466478
format_number_with_comma(cntr.tx_drop),
467-
format_number_with_comma(cntr.tx_ovr)))
479+
format_number_with_comma(cntr.tx_ovr),
480+
format_number_with_comma(cntr.fec_corr),
481+
format_number_with_comma(cntr.fec_uncorr)))
468482
elif rates_only:
469483
header = header_rates_only
470484
if old_cntr is not None:
@@ -639,4 +653,4 @@ Examples:
639653
portstat.cnstat_diff_print(cnstat_new_dict, cnstat_dict, ratestat_new_dict, intf_list, use_json, print_all, errors_only, rates_only, detail)
640654

641655
if __name__ == "__main__":
642-
main()
656+
main()

0 commit comments

Comments
 (0)