Skip to content

Commit 636f7f1

Browse files
authored
Add port FEC BER show changes (sonic-net#3607)
* Add port FEC BER show changes Signed-off-by: vincent ng <[email protected]> * Add port FEC BER show changes Signed-off-by: vincent ng <[email protected]> * Add port FEC BER show changes Signed-off-by: vincent ng <[email protected]> * Add port FEC BER show changes Signed-off-by: vincent ng <[email protected]> * Add port FEC BER show changes Signed-off-by: vincent ng <[email protected]> --------- Signed-off-by: vincent ng <[email protected]>
1 parent 5e60031 commit 636f7f1

File tree

4 files changed

+42
-13
lines changed

4 files changed

+42
-13
lines changed

doc/Command-Reference.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -4894,6 +4894,7 @@ Optional argument "-p" specify a period (in seconds) with which to gather counte
48944894
show interfaces counters rates
48954895
show interfaces counters rif [-p|--period <period>] [-i <interface_name>]
48964896
show interfaces counters fec-histogram [-i <interface_name>]
4897+
show interfaces counters fec-stats
48974898
```
48984899

48994900
- Example:
@@ -5039,6 +5040,18 @@ In a FEC histogram, "bins" represent ranges of errors or specific categories of
50395040
BIN15: 0
50405041
```
50415042

5043+
The "fec-stats" subcommand is used to disply the interface fec related statistic.
5044+
5045+
- Example:
5046+
```
5047+
admin@ctd615:~$ show interfaces counters fec-stats
5048+
IFACE STATE FEC_CORR FEC_UNCORR FEC_SYMBOL_ERR FEC_PRE_BER FEC_POST_BER
5049+
----------- ------- ---------- ------------ ---------------- ------------- --------------
5050+
Ethernet0 U 0 0 0 1.48e-20 0.00e+00
5051+
Ethernet8 U 0 0 0 1.98e-19 0.00e+00
5052+
Ethernet16 U 0 0 0 1.77e-20 0.00e+00
5053+
```
5054+
50425055

50435056
**show interfaces description**
50445057

@@ -13907,4 +13920,4 @@ enabled Login You are on
1390713920
All access and/or use are subject to monitoring.
1390813921
1390913922
Help: https://sonic-net.github.io/SONiC/
13910-
```
13923+
```

tests/portstat_test.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
"""
3636

3737
intf_fec_counters = """\
38-
IFACE STATE FEC_CORR FEC_UNCORR FEC_SYMBOL_ERR
39-
--------- ------- ---------- ------------ ----------------
40-
Ethernet0 D 130,402 3 4
41-
Ethernet4 N/A 110,412 1 0
42-
Ethernet8 N/A 100,317 0 0
38+
IFACE STATE FEC_CORR FEC_UNCORR FEC_SYMBOL_ERR FEC_PRE_BER FEC_POST_BER
39+
--------- ------- ---------- ------------ ---------------- ------------- --------------
40+
Ethernet0 D 130,402 3 4 N/A N/A
41+
Ethernet4 N/A 110,412 1 0 N/A N/A
42+
Ethernet8 N/A 100,317 0 0 N/A N/A
4343
"""
4444

4545
intf_fec_counters_fec_hist = """\

utilities_common/netstat.py

+10
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ def format_prate(rate):
108108
return "{:.2f}".format(float(rate))+'/s'
109109

110110

111+
def format_fec_ber(rate):
112+
"""
113+
Show the ber rate.
114+
"""
115+
if rate == STATUS_NA:
116+
return STATUS_NA
117+
else:
118+
return "{:.2e}".format(float(rate))
119+
120+
111121
def format_util(brate, port_rate):
112122
"""
113123
Calculate the util.

utilities_common/portstat.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from utilities_common import constants
1212
import utilities_common.multi_asic as multi_asic_util
1313
from utilities_common.netstat import ns_diff, table_as_json, format_brate, format_prate, \
14-
format_util, format_number_with_comma, format_util_directly
14+
format_util, format_number_with_comma, format_util_directly, \
15+
format_fec_ber
1516

1617
"""
1718
The order and count of statistics mentioned below needs to be in sync with the values in portstat script
@@ -32,11 +33,11 @@
3233
header_std = ['IFACE', 'STATE', 'RX_OK', 'RX_BPS', 'RX_UTIL', 'RX_ERR', 'RX_DRP', 'RX_OVR',
3334
'TX_OK', 'TX_BPS', 'TX_UTIL', 'TX_ERR', 'TX_DRP', 'TX_OVR']
3435
header_errors_only = ['IFACE', 'STATE', 'RX_ERR', 'RX_DRP', 'RX_OVR', 'TX_ERR', 'TX_DRP', 'TX_OVR']
35-
header_fec_only = ['IFACE', 'STATE', 'FEC_CORR', 'FEC_UNCORR', 'FEC_SYMBOL_ERR']
36+
header_fec_only = ['IFACE', 'STATE', 'FEC_CORR', 'FEC_UNCORR', 'FEC_SYMBOL_ERR', 'FEC_PRE_BER', 'FEC_POST_BER']
3637
header_rates_only = ['IFACE', 'STATE', 'RX_OK', 'RX_BPS', 'RX_PPS', 'RX_UTIL', 'TX_OK', 'TX_BPS', 'TX_PPS', 'TX_UTIL']
3738

38-
rates_key_list = ['RX_BPS', 'RX_PPS', 'RX_UTIL', 'TX_BPS', 'TX_PPS', 'TX_UTIL']
39-
ratestat_fields = ("rx_bps", "rx_pps", "rx_util", "tx_bps", "tx_pps", "tx_util")
39+
rates_key_list = ['RX_BPS', 'RX_PPS', 'RX_UTIL', 'TX_BPS', 'TX_PPS', 'TX_UTIL', 'FEC_PRE_BER', 'FEC_POST_BER']
40+
ratestat_fields = ("rx_bps", "rx_pps", "rx_util", "tx_bps", "tx_pps", "tx_util", "fec_pre_ber", "fec_post_ber")
4041
RateStats = namedtuple("RateStats", ratestat_fields)
4142

4243
"""
@@ -194,10 +195,13 @@ def collect_stat_from_lc(self):
194195
tx_err = self.db.get(self.db.CHASSIS_STATE_DB, key, "tx_err")
195196
tx_drop = self.db.get(self.db.CHASSIS_STATE_DB, key, "tx_drop")
196197
tx_ovr = self.db.get(self.db.CHASSIS_STATE_DB, key, "tx_ovr")
198+
fec_pre_ber = self.db.get(self.db.CHASSIS_STATE_DB, key, "fec_pre_ber")
199+
fec_post_ber = self.db.get(self.db.CHASSIS_STATE_DB, key, "fec_post_ber")
197200
port_alias = key.split("|")[-1]
198201
cnstat_dict[port_alias] = NStats._make([rx_ok, rx_err, rx_drop, rx_ovr, tx_ok, tx_err, tx_drop, tx_ovr] +
199202
[STATUS_NA] * (len(NStats._fields) - 8))._asdict()
200-
ratestat_dict[port_alias] = RateStats._make([rx_bps, rx_pps, rx_util, tx_bps, tx_pps, tx_util])
203+
ratestat_dict[port_alias] = RateStats._make([rx_bps, rx_pps, rx_util, tx_bps,
204+
tx_pps, tx_util, fec_pre_ber, fec_post_ber])
201205
self.cnstat_dict.update(cnstat_dict)
202206
self.ratestat_dict.update(ratestat_dict)
203207

@@ -238,7 +242,7 @@ def get_rates(table_id):
238242
"""
239243
Get the rates from specific table.
240244
"""
241-
fields = ["0", "0", "0", "0", "0", "0"]
245+
fields = ["0", "0", "0", "0", "0", "0", "0", "0"]
242246
for pos, name in enumerate(rates_key_list):
243247
full_table_id = RATES_TABLE_PREFIX + table_id
244248
counter_data = self.db.get(self.db.COUNTERS_DB, full_table_id, name)
@@ -363,7 +367,9 @@ def cnstat_print(self, cnstat_dict, ratestat_dict, intf_list, use_json, print_al
363367
table.append((key, self.get_port_state(key),
364368
format_number_with_comma(data['fec_corr']),
365369
format_number_with_comma(data['fec_uncorr']),
366-
format_number_with_comma(data['fec_symbol_err'])))
370+
format_number_with_comma(data['fec_symbol_err']),
371+
format_fec_ber(rates.fec_pre_ber),
372+
format_fec_ber(rates.fec_post_ber)))
367373
elif rates_only:
368374
header = header_rates_only
369375
table.append((key, self.get_port_state(key),

0 commit comments

Comments
 (0)