Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 54 additions & 9 deletions tests/common/helpers/pfcwd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,60 @@ def has_neighbor_device(setup_pfc_test):
return True


def check_pfc_storm_state(dut, port, queue):
def check_pfc_storm_state(dut, port, queue, expected_state):
"""
Helper function to check if PFC storm is detected/restored on a given queue
"""
pfcwd_stats = dut.show_and_parse("show pfcwd stats")
queue_name = str(port) + ":" + str(queue)
for entry in pfcwd_stats:
if entry["queue"] == queue_name:
logger.info("PFCWD status on queue {} stats: {}".format(queue_name, entry))
return entry['storm detected/restored']
logger.info("PFCWD not triggered on queue {}".format(queue_name))
return None
pfcwd_stat = parser_show_pfcwd_stat(dut, port, queue)
if expected_state == "storm":
if ("storm" in pfcwd_stat[0]['status']) and \
int(pfcwd_stat[0]['storm_detect_count']) > int(pfcwd_stat[0]['restored_count']):
return True
else:
if ("storm" not in pfcwd_stat[0]['status']) and \
int(pfcwd_stat[0]['storm_detect_count']) == int(pfcwd_stat[0]['restored_count']):
return True
return False


def parser_show_pfcwd_stat(dut, select_port, select_queue):
"""
CLI "show pfcwd stats" output:
admin@bjw-can-7060-1:~$ show pfcwd stats
QUEUE STATUS STORM DETECTED/RESTORED TX OK/DROP RX OK/DROP TX LAST OK/DROP RX LAST OK/DROP # noqa: E501
------------- -------- ------------------------- ------------ ------------ ----------------- ----------------- # noqa: E501
Ethernet112:4 N/A 2/2 100/100 100/100 100/0 100/0 # noqa: E501
admin@bjw-can-7060-1:~$
"""
logger.info("port {} queue {}".format(select_port, select_queue))
pfcwd_stat_output = dut.show_and_parse('show pfcwd stat')

pfcwd_stat = []
for item in pfcwd_stat_output:
port, queue = item['queue'].split(':')
if port != select_port or int(queue) != int(select_queue):
continue
storm_detect_count, restored_count = item['storm detected/restored'].split('/')
tx_ok_count, tx_drop_count = item['tx ok/drop'].split('/')
rx_ok_count, rx_drop_count = item['rx ok/drop'].split('/')
tx_last_ok_count, tx_last_drop_count = item['tx last ok/drop'].split('/')
rx_last_ok_count, rx_last_drop_count = item['rx last ok/drop'].split('/')

parsed_dict = {
'port': port,
'queue': queue,
'status': item['status'],
'storm_detect_count': storm_detect_count,
'restored_count': restored_count,
'tx_ok_count': tx_ok_count,
'tx_drop_count': tx_drop_count,
'rx_ok_count': rx_ok_count,
'rx_drop_count': rx_drop_count,
'tx_last_ok_count': tx_last_ok_count,
'tx_last_drop_count': tx_last_drop_count,
'rx_last_ok_count': rx_last_ok_count,
'rx_last_drop_count': rx_last_drop_count
}
pfcwd_stat.append(parsed_dict)

return pfcwd_stat
Loading