def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) if tx_clk.get_rate() == Clock.CLK_125MHz: # This test is not relevant for gigabit return dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - Valid packet with an extra nibble (should be accepted) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, extra_nibble=True, create_data_args=['step', (22, choose_small_frame_size(rand))] )) # Part B - Invalid packet with an extra nibble (should be reported as alignmentError) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, extra_nibble=True, corrupt_crc=True, create_data_args=['step', (23, choose_small_frame_size(rand))], dropped=True )) # Part C - Parts A and B with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - maximum jabber size packet # Use a valid ether type as the type/len field can't encode the length ether_type_ip = [0x08, 0x00] # Jabber lengths as defined for 10Mb/s & 100Mb/s jabber_length = 9367 if tx_clk.get_rate() == Clock.CLK_125MHz: # Length for 1000Mb/s jabber_length = 18742 error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=ether_type_ip, num_preamble_nibbles=7, create_data_args=['step', (17, jabber_length)], dropped=True )) # Part B - Part A with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - length errors (len/type field value greater than actual data length) for (num_data_bytes, len_type, step) in [(46, 47, 20), (46, 1505, 21), (1504, 1505, 22)]: error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (step, num_data_bytes)], dropped=True )) # Also do this for VLAN tagged frames error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=[0x81, 0x00, 0x00, 0x00], ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (step, num_data_bytes)], dropped=True )) # Part B - Part A with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] ifg = tx_clk.get_min_ifg() # Part A - Ensure that two packets separated by minimum IFG are received ok packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (rand.randint(1, 254), choose_small_frame_size(rand)) ])) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (rand.randint(1, 254), choose_small_frame_size(rand)) ], inter_frame_gap=ifg)) # Part B - Determine the minimum IFG that can be supported bit_time = ifg / 96 # Allow lots of time for the DUT to recover between test bursts recovery_time = 4 * packet_processing_time(tx_phy, 46, mac) # Test shrinking the IFG by different amounts. Use the shrink as the step for debug purposes for gap_shrink in [5, 10]: new_ifg = ifg - gap_shrink * bit_time packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (gap_shrink, choose_small_frame_size(rand)) ], inter_frame_gap=recovery_time)) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (gap_shrink, choose_small_frame_size(rand)) ], inter_frame_gap=new_ifg)) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - Invalid SFD nibble: use preamble nibble (0x5) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, sfd_nibble=0x5, create_data_args=['step', (19, choose_small_frame_size(rand))], dropped=True )) # Part B - Invalid SFD: replace last byte of preamble with 0x9 instead of 0x5 error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, preamble_nibbles=[0x5 for x in range(14)] + [0x9], create_data_args=['step', (20, choose_small_frame_size(rand))], dropped=True )) # Part C - Parts A and B with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() excess_pad_packets = [] # Part A - excessive pad processing_time = 0 # These packets should not be dropped (though the standard is ambiguous). The length, however # should be reported as the length specified in the len/type field. for (num_data_bytes, len_type, step) in [(47, 46, 20), (1504, 46, 21), (1504, 1503, 22)]: excess_pad_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (step, num_data_bytes)], inter_frame_gap=processing_time )) # Update packet processing time so that next packet leaves enough time before starting processing_time = packet_processing_time(tx_phy, num_data_bytes, mac) # Part B - Part A with valid frames before/after the errror frame packets = [] for packet in excess_pad_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(excess_pad_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) + packet_processing_time(tx_phy, 1518, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A - Test the sending of all valid size untagged frames processing_time = packet_processing_time(tx_phy, 46, mac) for num_data_bytes in [46, choose_small_frame_size(rand), 1500]: packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (rand.randint(1, 254), num_data_bytes) ], inter_frame_gap=processing_time)) processing_time = packet_processing_time(tx_phy, num_data_bytes, mac) # Part B - Test the sending of sub 46 bytes of data in the length field but valid minimum packet sizes # The packet sizes longer than this are covered by Part A for len_type in [1, 2, 3, 4, 15, 45]: packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (rand.randint(1, 254), 46)], inter_frame_gap=packet_processing_time(tx_phy, 46, mac))) # Part C - Test the sending of all valid size tagged frames processing_time = packet_processing_time(tx_phy, 46, mac) for num_data_bytes in [42, choose_small_frame_size(rand), 1500]: packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=[0x81, 0x00, 0x00, 0x00], create_data_args=[ 'step', (rand.randint(1, 254), num_data_bytes) ], inter_frame_gap=processing_time)) processing_time = packet_processing_time(tx_phy, num_data_bytes, mac) # Part D # Not supporting 802.3-2012, so no envelope frames # Part E # Not doing half duplex 1000Mb/s, so don't test this do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A - Send different length preambles and ensure the packets are still received # Check a selection of preamble lengths from 1 byte to 64 bytes (including SFD) test_lengths = [3, 4, 5, 61, 127] if tx_clk.get_rate() == Clock.CLK_125MHz: # The RGMII requires a longer preamble test_lengths = [5, 7, 9, 61, 127] for num_preamble_nibbles in test_lengths: packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, num_preamble_nibbles=num_preamble_nibbles, create_data_args=[ 'step', (rand.randint(1, 254), choose_small_frame_size(rand)) ], inter_frame_gap=packet_processing_time(tx_phy, 46, mac))) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A - Test the sending of all valid size untagged frames processing_time = packet_processing_time(tx_phy, 46, mac) for num_data_bytes in [46, choose_small_frame_size(rand), 1500]: packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (rand.randint(1, 254), num_data_bytes)], inter_frame_gap=processing_time )) processing_time = packet_processing_time(tx_phy, num_data_bytes, mac) # Part B - Test the sending of sub 46 bytes of data in the length field but valid minimum packet sizes # The packet sizes longer than this are covered by Part A for len_type in [1, 2, 3, 4, 15, 45]: packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (rand.randint(1, 254), 46)], inter_frame_gap=packet_processing_time(tx_phy, 46, mac) )) # Part C - Test the sending of all valid size tagged frames processing_time = packet_processing_time(tx_phy, 46, mac) for num_data_bytes in [42, choose_small_frame_size(rand), 1500]: packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=[0x81, 0x00, 0x00, 0x00], create_data_args=['step', (rand.randint(1, 254), num_data_bytes)], inter_frame_gap=processing_time )) processing_time = packet_processing_time(tx_phy, num_data_bytes, mac) # Part D # Not supporting 802.3-2012, so no envelope frames # Part E # Not doing half duplex 1000Mb/s, so don't test this do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] ifg = tx_clk.get_min_ifg() # Part A - Ensure that two packets separated by minimum IFG are received ok packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))] )) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))], inter_frame_gap=ifg )) # Part B - Determine the minimum IFG that can be supported bit_time = ifg/96 # Allow lots of time for the DUT to recover between test bursts recovery_time = 4*packet_processing_time(tx_phy, 46, mac) # Test shrinking the IFG by different amounts. Use the shrink as the step for debug purposes for gap_shrink in [5, 10]: new_ifg = ifg - gap_shrink * bit_time packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (gap_shrink, choose_small_frame_size(rand))], inter_frame_gap=recovery_time )) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (gap_shrink, choose_small_frame_size(rand))], inter_frame_gap=new_ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A packets.append( MiiPacket( rand, create_data_args=['step', (3, choose_small_frame_size(rand))], corrupt_crc=True, dropped=True)) # Part B packets.append( MiiPacket( rand, create_data_args=['step', (4, choose_small_frame_size(rand))])) packets.append( MiiPacket( rand, inter_frame_gap=tx_clk.get_min_ifg(), create_data_args=['step', (5, choose_small_frame_size(rand))], corrupt_crc=True, dropped=True)) packets.append( MiiPacket( rand, inter_frame_gap=tx_clk.get_min_ifg(), create_data_args=['step', (6, choose_small_frame_size(rand))])) # Set all the destination MAC addresses to get through the filtering for packet in packets: packet.dst_mac_addr = dut_mac_address do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A packets.append(MiiPacket(rand, create_data_args=['step', (3, choose_small_frame_size(rand))], corrupt_crc=True, dropped=True )) # Part B packets.append(MiiPacket(rand, create_data_args=['step', (4, choose_small_frame_size(rand))] )) packets.append(MiiPacket(rand, inter_frame_gap=tx_clk.get_min_ifg(), create_data_args=['step', (5, choose_small_frame_size(rand))], corrupt_crc=True, dropped=True )) packets.append(MiiPacket(rand, inter_frame_gap=tx_clk.get_min_ifg(), create_data_args=['step', (6, choose_small_frame_size(rand))] )) # Set all the destination MAC addresses to get through the filtering for packet in packets: packet.dst_mac_addr = dut_mac_address do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] # Part A - Send different length preambles and ensure the packets are still received # Check a selection of preamble lengths from 1 byte to 64 bytes (including SFD) test_lengths = [3, 4, 5, 61, 127] if tx_clk.get_rate() == Clock.CLK_125MHz: # The RGMII requires a longer preamble test_lengths = [5, 7, 9, 61, 127] for num_preamble_nibbles in test_lengths: packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, num_preamble_nibbles=num_preamble_nibbles, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))], inter_frame_gap=packet_processing_time(tx_phy, 46, mac) )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - maximum jabber size packet # Use a valid ether type as the type/len field can't encode the length ether_type_ip = [0x08, 0x00] # Jabber lengths as defined for 10Mb/s & 100Mb/s jabber_length = 9367 if tx_clk.get_rate() == Clock.CLK_125MHz: # Length for 1000Mb/s jabber_length = 18742 error_packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=ether_type_ip, num_preamble_nibbles=7, create_data_args=['step', (17, jabber_length)], dropped=True)) # Part B - Part A with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i, packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (i % 10, choose_small_frame_size(rand)) ], inter_frame_gap=2 * packet_processing_time(tx_phy, 46, mac))) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (2 * ((i + 1) % 10), choose_small_frame_size(rand)) ], inter_frame_gap=ifg)) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] error_packets = [] # Part A - untagged frame # Valid maximum size untagged frame (1500 data + 18 header & CRC bytes) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (1, 1500)])) # Oversized untagged frame - one byte too big for the 1522 bytes allowed per frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2, 1505)], inter_frame_gap=packet_processing_time( tx_phy, 1500, mac), dropped=True) packets.append(packet) error_packets.append(packet) # Oversized untagged frame - too big for the 1522 bytes allowed per frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (3, 1600)], inter_frame_gap=packet_processing_time( tx_phy, 1500, mac), dropped=True) packets.append(packet) error_packets.append(packet) # Part B - VLAN/Prio tagged frame vlan_prio_tag = [0x81, 0x00, 0x00, 0x00] # Valid maximum size tagged frame (1500 data + 22 header & CRC bytes) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (10, 1500)])) # Oversized tagged frame - just one byte too big packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (11, 1501)], inter_frame_gap=packet_processing_time( tx_phy, 1500, mac), dropped=True) packets.append(packet) error_packets.append(packet) # Oversized tagged frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (12, 1549)], inter_frame_gap=packet_processing_time( tx_phy, 1500, mac), dropped=True) packets.append(packet) error_packets.append(packet) # Part C # TODO - oversized envelope frame # Part D # Don't support flow control - so don't run # Part E # Parts A - C with valid frames before/after the errror frame ifg = tx_clk.get_min_ifg() for i, packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (i % 10, choose_small_frame_size(rand)) ], inter_frame_gap=2 * packet_processing_time(tx_phy, 46, mac))) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (2 * ((i + 1) % 10), choose_small_frame_size(rand)) ], inter_frame_gap=ifg)) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() packets = [] error_packets = [] # Part A - untagged frame # Valid maximum size untagged frame (1500 data + 18 header & CRC bytes) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (1, 1500)] )) # Oversized untagged frame - one byte too big for the 1522 bytes allowed per frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2, 1505)], inter_frame_gap=packet_processing_time(tx_phy, 1500, mac), dropped=True ) packets.append(packet) error_packets.append(packet) # Oversized untagged frame - too big for the 1522 bytes allowed per frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (3, 1600)], inter_frame_gap=packet_processing_time(tx_phy, 1500, mac), dropped=True ) packets.append(packet) error_packets.append(packet) # Part B - VLAN/Prio tagged frame vlan_prio_tag = [0x81, 0x00, 0x00, 0x00] # Valid maximum size tagged frame (1500 data + 22 header & CRC bytes) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (10, 1500)] )) # Oversized tagged frame - just one byte too big packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (11, 1501)], inter_frame_gap=packet_processing_time(tx_phy, 1500, mac), dropped=True ) packets.append(packet) error_packets.append(packet) # Oversized tagged frame packet = MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=vlan_prio_tag, create_data_args=['step', (12, 1549)], inter_frame_gap=packet_processing_time(tx_phy, 1500, mac), dropped=True ) packets.append(packet) error_packets.append(packet) # Part C # TODO - oversized envelope frame # Part D # Don't support flow control - so don't run # Part E # Parts A - C with valid frames before/after the errror frame ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=2*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - length errors (len/type field value greater than actual data length) for (num_data_bytes, len_type, step) in [(46, 47, 20), (46, 1505, 21), (1504, 1505, 22)]: error_packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (step, num_data_bytes)], dropped=True)) # Also do this for VLAN tagged frames error_packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, vlan_prio_tag=[0x81, 0x00, 0x00, 0x00], ether_len_type=[(len_type >> 8) & 0xff, len_type & 0xff], create_data_args=['step', (step, num_data_bytes)], dropped=True)) # Part B - Part A with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i, packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (i % 10, choose_small_frame_size(rand)) ], inter_frame_gap=2 * packet_processing_time(tx_phy, 46, mac))) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=[ 'step', (2 * ((i + 1) % 10), choose_small_frame_size(rand)) ], inter_frame_gap=ifg)) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Test that packets where the RXER line goes high are dropped even # if the rest of the packet is valid # Error on the first nibble of the preamble num_data_bytes = choose_small_frame_size(rand) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, num_data_bytes=num_data_bytes, error_nibbles=[0], dropped=True )) # Error somewhere in the middle of the packet num_data_bytes = choose_small_frame_size(rand) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, num_data_bytes=num_data_bytes, dropped=True )) packet = error_packets[-1] error_nibble = rand.randint(packet.num_preamble_nibbles + 1, len(packet.get_nibbles())) packet.error_nibbles = [error_nibble] # Due to BUG 16233 the RGMII code won't always detect an error in the last two bytes num_data_bytes = choose_small_frame_size(rand) error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, num_data_bytes=num_data_bytes, dropped=True )) packet = error_packets[-1] packet.error_nibbles = [len(packet.get_nibbles()) - 5] # Now run all packets with valid frames before/after the errror frame to ensure the # errors don't interfere with valid frames packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=3*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dut_mac_address = get_dut_mac_address() error_packets = [] # Part A - Invalid preamble nibbles, but the frame should still be received preamble_nibbles = [0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5] if tx_clk.get_rate() == Clock.CLK_125MHz: preamble_nibbles = [0x5, 0x5, 0x5, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5] error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, preamble_nibbles=preamble_nibbles, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))] )) # Part B - Invalid preamble nibbles, but the packet should still be received preamble_nibbles = [0x5, 0x5, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x5] if tx_clk.get_rate() == Clock.CLK_125MHz: preamble_nibbles = [0x5, 0x5, 0x5, 0x5, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0xf, 0x5] error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, preamble_nibbles=preamble_nibbles, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))], inter_frame_gap=packet_processing_time(tx_phy, 46, mac) )) # Part C - Invalid preamble nibbles, but the packet should still be received preamble_nibbles = [0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x5, 0x8, 0x5, 0xf, 0x5] error_packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, preamble_nibbles=preamble_nibbles, create_data_args=['step', (rand.randint(1, 254), choose_small_frame_size(rand))], inter_frame_gap=packet_processing_time(tx_phy, 46, mac) )) # Part D - Parts A, B and C with valid frames before/after the errror frame packets = [] for packet in error_packets: packets.append(packet) ifg = tx_clk.get_min_ifg() for i,packet in enumerate(error_packets): # First valid frame (allowing time to process previous two valid frames) packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i%10, choose_small_frame_size(rand))], inter_frame_gap=3*packet_processing_time(tx_phy, 46, mac) )) # Take a copy to ensure that the original is not modified packet_copy = copy.deepcopy(packet) # Error frame after minimum IFG packet_copy.set_ifg(ifg) packets.append(packet_copy) # Second valid frame with minimum IFG packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (2 * ((i+1)%10), choose_small_frame_size(rand))], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)