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
24 changes: 12 additions & 12 deletions tests/common/helpers/pfc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ def main():
(options, args) = parser.parse_args()

if options.interface is None:
print "Need to specify the interface to send PFC/global pause frame packets."
print("Need to specify the interface to send PFC/global pause frame packets.")
parser.print_help()
sys.exit(1)

if options.time > 65535 or options.time < 0:
print "Quanta is not valid. Need to be in range 0-65535."
print("Quanta is not valid. Need to be in range 0-65535.")
parser.print_help()
sys.exit(1)

if options.global_pf:
# Send global pause frames
# -p option should not be set
if options.priority != -1:
print "'-p' option is not valid when sending global pause frames ('--global' / '-g')"
print("'-p' option is not valid when sending global pause frames ('--global' / '-g')")
parser.print_help()
sys.exit(1)
elif options.priority > 255 or options.priority < 0:
print "Enable class bitmap is not valid. Need to be in range 0-255."
print("Enable class bitmap is not valid. Need to be in range 0-255.")
parser.print_help()
sys.exit(1)

Expand All @@ -72,7 +72,7 @@ def main():
for i in range(0, len(interfaces)):
sockets.append(socket(AF_PACKET, SOCK_RAW))
except:
print "Unable to create socket. Check your permissions"
print("Unable to create socket. Check your permissions")
sys.exit(1)

# Configure logging
Expand Down Expand Up @@ -122,13 +122,13 @@ def main():
pause time | 0x0000 |
-------------------------
"""
src_addr = "\x00\x01\x02\x03\x04\x05"
dst_addr = "\x01\x80\xc2\x00\x00\x01"
src_addr = b"\x00\x01\x02\x03\x04\x05"
dst_addr = b"\x01\x80\xc2\x00\x00\x01"
if options.global_pf:
opcode = "\x00\x01"
opcode = b"\x00\x01"
else:
opcode = "\x01\x01"
ethertype = "\x88\x08"
opcode = b"\x01\x01"
ethertype = b"\x88\x08"

packet = dst_addr + src_addr + ethertype + opcode
if options.global_pf:
Expand All @@ -142,10 +142,10 @@ def main():
if (class_enable & (1<<p)):
packet = packet + binascii.unhexlify(format(options.time, '04x'))
else:
packet = packet + "\x00\x00"
packet = packet + b"\x00\x00"

pre_str = 'GLOBAL_PF' if options.global_pf else 'PFC'
print "Generating %s Packet(s)" % options.num
print("Generating %s Packet(s)" % options.num)
my_logger.debug(pre_str + '_STORM_START')
iteration = options.num
while iteration > 0:
Expand Down
4 changes: 2 additions & 2 deletions tests/common/templates/pfc_storm_sonic.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cd {{pfc_gen_dir}}
{% if (pfc_asym is defined) and (pfc_asym == True) %}
nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}" > /dev/null 2>&1 &
nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} sudo python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}" > /dev/null 2>&1 &
{% else %}
nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}" > /dev/null 2>&1 &
nohup sh -c "{% if pfc_storm_defer_time is defined %}sleep {{pfc_storm_defer_time}} &&{% endif %} sudo python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}" > /dev/null 2>&1 &
{% endif %}
4 changes: 2 additions & 2 deletions tests/common/templates/pfc_storm_stop_sonic.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cd {{pfc_gen_dir}}
{% if (pfc_asym is defined) and (pfc_asym == True) %}
nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} pkill -f 'python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}'" > /dev/null 2>&1 &
nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} sudo pkill -f 'python {{pfc_gen_file}} -p {{pfc_queue_index}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}}'" > /dev/null 2>&1 &
{% else %}
nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} pkill -f 'python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}'" > /dev/null 2>&1 &
nohup sh -c "{% if pfc_storm_stop_defer_time is defined %}sleep {{pfc_storm_stop_defer_time}} &&{% endif %} sudo pkill -f 'python {{pfc_gen_file}} -p {{(1).__lshift__(pfc_queue_index)}} -t 65535 -n {{pfc_frames_number}} -i {{pfc_fanout_interface}} -r {{ansible_eth0_ipv4_addr}}'" > /dev/null 2>&1 &
{% endif %}