def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep_loopback = 3 # The inter-frame gap is to give the DUT time to print its output packets = [] data_val = 0; pkt_length = 20 data_pid = 0x3 #DATA0 for pkt_length in range(10, 20): # min 237 # increased to 277 when SETUP/OUT checking added AppendOutToken(packets, ep_loopback, inter_pkt_gap=277) packets.append(TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) data_val = data_val + pkt_length data_pid = data_pid ^ 8 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 1 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 AppendOutToken(packets, ep) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Note, quite big gap to allow checking. dataval += 10 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) dataval += 11 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=12, bad_crc=True, pid=0x3)) #DATA0 # Bad CRC - dont expect ACK #packets.append(RxHandshakePacket()) #Due to bad CRC, XUD will not ACK and expect a resend of the same packet - so dont change PID dataval += 12 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=13, pid=0x3)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) # PID toggle as normal dataval += 13 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=14, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 2 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 AppendInToken(packets, ep) packets.append( RxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(TxHandshakePacket()) dataval += 10 AppendInToken(packets, ep, inter_pkt_gap=5000) packets.append( RxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb)) #DATA1 packets.append(TxHandshakePacket()) #pretend CRC got broken on way to host and dont send ACK dataval += 11 AppendInToken(packets, ep, inter_pkt_gap=5000) packets.append( RxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 #packets.append(TxHandshakePacket()) #xCore should resend same packet again.. AppendInToken(packets, ep, inter_pkt_gap=5000) packets.append( RxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 packets.append(TxHandshakePacket()) dataval += 12 AppendInToken(packets, ep, inter_pkt_gap=5000) packets.append( RxDataPacket(rand, data_start_val=dataval, length=13, pid=0xb)) #DATA1 packets.append(TxHandshakePacket()) dataval += 13 AppendInToken(packets, ep, inter_pkt_gap=5000) packets.append( RxDataPacket(rand, data_start_val=dataval, length=14, pid=0x3)) #DATA0 packets.append(TxHandshakePacket()) # Note, quite big gap to allow checking. do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 1 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 AppendOutToken(packets, ep) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Note, quite big gap to allow checking. dataval += 10 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) #Pretend the ACK went missing. Re-send same packet. xCORE should ACK but throw pkt away AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) dataval += 11 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) dataval += 12 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=13, pid=0xb)) #DATA1 packets.append(RxHandshakePacket(timeout=9)) dataval += 13 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=14, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) # The inter-frame gap is to give the DUT time to print its output packets = [] data_val = 0 pkt_length = 20 data_pid = 0x3 #DATA0 for pkt_length in range(10, 20): #min 237 AppendOutToken(packets, 3, inter_pkt_gap=1) packets.append( TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) AppendOutToken(packets, 4, inter_pkt_gap=1) packets.append( TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) AppendOutToken(packets, 5, inter_pkt_gap=0) packets.append( TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) AppendOutToken(packets, 6, inter_pkt_gap=0) packets.append( TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) data_val = data_val + pkt_length data_pid = data_pid ^ 8 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) ep_loopback = 3 ep_loopback_kill = 2 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 data_pid = 0x3 #DATA0 for pkt_length in range(0, 20): AppendOutToken(packets, ep_loopback) packets.append( TxDataPacket(rand, data_start_val=dataval, length=pkt_length, pid=data_pid)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) # 357 was min IPG supported on bulk loopback to not nak # For move from sc_xud to lib_xud (14.1.2 tools) had to increase this to 377 # Increased again due to setup/out checking AppendInToken(packets, ep_loopback, inter_pkt_gap=417) packets.append( RxDataPacket(rand, data_start_val=dataval, length=pkt_length, pid=data_pid, timeout=9)) #DATA0 packets.append(TxHandshakePacket()) data_pid = data_pid ^ 8 pkt_length = 10 #Loopback and die.. AppendOutToken(packets, ep_loopback_kill) packets.append(TxDataPacket(rand, length=pkt_length, pid=3)) #DATA0 packets.append(RxHandshakePacket()) AppendInToken(packets, ep_loopback_kill, inter_pkt_gap=400) packets.append(RxDataPacket(rand, length=pkt_length, pid=3)) #DATA0 packets.append(TxHandshakePacket()) do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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() broadcast_mac_address = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] # The inter-frame gap is to give the DUT time to print its output packets = [] for mac_address in [dut_mac_address, broadcast_mac_address]: packets.append( MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (1, 72)])) packets.append( MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (5, 52)], inter_frame_gap=packet_processing_time(tx_phy, 72, mac))) packets.append( MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (7, 1500)], inter_frame_gap=packet_processing_time(tx_phy, 52, mac))) # Send enough basic frames to ensure the buffers in the DUT have wrapped for i in range(11): packets.append( MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i, 1500)], inter_frame_gap=packet_processing_time( tx_phy, 1500, mac))) do_error = True # The gigabit RGMII can't handle spurious errors if tx_clk.get_rate() == Clock.CLK_125MHz: do_error = False error_driver = TxError(tx_phy, do_error) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[error_driver])
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(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 1 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 # Ping EP 2, expect NAK AppendPingToken(packets, 2) packets.append(RxHandshakePacket(pid=0x5a)) # And again AppendPingToken(packets, 2) packets.append(RxHandshakePacket(pid=0x5a)) # Send packet to EP 1, xCORE should mark EP 2 as ready AppendOutToken(packets, ep) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Ping EP 2 again - expect ACK AppendPingToken(packets, 2, inter_pkt_gap=6000) packets.append(RxHandshakePacket()) # And again.. AppendPingToken(packets, 2) packets.append(RxHandshakePacket()) # Send out to EP 2.. expect ack AppendOutToken(packets, 2, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Re-Ping EP 2, expect NAK AppendPingToken(packets, 2) packets.append(RxHandshakePacket(pid=0x5a)) # And again AppendPingToken(packets, 2) packets.append(RxHandshakePacket(pid=0x5a)) do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) ep_loopback = 3 ep_loopback_kill = 2 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 data_pid = 0x3 #DATA0 for pkt_length in range(200, 204): AppendOutToken(packets, ep_loopback) packets.append( TxDataPacket(rand, data_start_val=dataval, length=pkt_length, pid=data_pid)) #DATA0 #XXwas min IPG supported on iso loopback to not nak #This was 420, had to increase when moved to lib_xud (14.1.2 tools) # increased again from 437 when SETUP/OUT checking added AppendInToken(packets, ep_loopback, inter_pkt_gap=477) packets.append( RxDataPacket(rand, data_start_val=dataval, length=pkt_length, pid=data_pid, timeout=9)) #DATA0 #No toggle for Iso pkt_length = 10 #Loopback and die.. AppendOutToken(packets, ep_loopback_kill) packets.append(TxDataPacket(rand, length=pkt_length, pid=3)) #DATA0 packets.append(RxHandshakePacket()) AppendInToken(packets, ep_loopback_kill, inter_pkt_gap=397) packets.append(RxDataPacket(rand, length=pkt_length, pid=3)) #DATA0 packets.append(TxHandshakePacket()) do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 0 # The inter-frame gap is to give the DUT time to print its output packets = [] AppendSetupToken(packets, ep) packets.append(TxDataPacket(rand, length=3, pid=3, bad_crc=True)) #packets.append(RxHandshakePacket()) AppendSetupToken(packets, ep) packets.append(TxDataPacket(rand, length=8, pid=3, bad_crc=False)) packets.append(RxHandshakePacket(timeout=11)) # Note, quite big gap to allow checking. packets.append( TokenPacket( inter_pkt_gap=2000, pid=0xe1, #OUT address=dev_address, endpoint=ep)) packets.append(TxDataPacket(rand, length=10, pid=0xb)) packets.append(RxHandshakePacket()) packets.append( TokenPacket( inter_pkt_gap=2000, pid=0x69, #OUT address=dev_address, endpoint=ep)) #Expect 0-length packets.append(RxDataPacket(rand, length=0, pid=0x4b)) # Send ACK packets.append(TxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 0 # The inter-frame gap is to give the DUT time to print its output packets = [] AppendSetupToken(packets, ep) # DATA0 data packet with bad CRC packets.append(TxDataPacket(rand, length=8, pid=3, bad_crc=True)) # Dont expect an ACK due to bad CRC #packets.append(RxHandshakePacket()) AppendSetupToken(packets, ep, inter_pkt_gap=400) packets.append(TxDataPacket(rand, length=8, pid=3, bad_crc=False)) packets.append(RxHandshakePacket(timeout=11)) # Note, quite big gap to allow checking. AppendOutToken(packets, ep, inter_pkt_gap=2000) packets.append(TxDataPacket(rand, length=10, pid=0xb)) packets.append(RxHandshakePacket()) #IN AppendInToken(packets, ep, inter_pkt_gap=500) #Expect 0-length packets.append(RxDataPacket(rand, length=0, pid=0x4b)) # Send ACK packets.append(TxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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() broadcast_mac_address = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] # The inter-frame gap is to give the DUT time to print its output packets = [] for mac_address in [dut_mac_address, broadcast_mac_address]: packets.append(MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (1, 72)] )) packets.append(MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (5, 52)], inter_frame_gap=packet_processing_time(tx_phy, 72, mac) )) packets.append(MiiPacket(rand, dst_mac_addr=mac_address, create_data_args=['step', (7, 1500)], inter_frame_gap=packet_processing_time(tx_phy, 52, mac) )) # Send enough basic frames to ensure the buffers in the DUT have wrapped for i in range(11): packets.append(MiiPacket(rand, dst_mac_addr=dut_mac_address, create_data_args=['step', (i, 1500)], inter_frame_gap=packet_processing_time(tx_phy, 1500, mac) )) do_error = True # The gigabit RGMII can't handle spurious errors if tx_clk.get_rate() == Clock.CLK_125MHz: do_error = False error_driver = TxError(tx_phy, do_error) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[error_driver])
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(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) ep = 2 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 AppendOutToken(packets, ep) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 # Note, quite big gap to allow checking. dataval += 10 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0x3)) #DATA0 dataval += 11 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 dataval += 12 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=13, pid=0x3)) #DATA0 dataval += 13 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=14, pid=0x3)) #DATA0 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) ep = 3 packets = [] data_val = 0 pkt_length = 20 data_pid = 0x3 #DATA0 for pkt_length in range(10, 20): # < 17 fails for SI # < 37 fails for DI AppendOutToken(packets, ep, inter_pkt_gap=37) packets.append( TxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) #DATA0 # 9 works for SI packets.append(RxHandshakePacket(timeout=10)) AppendInToken(packets, ep, inter_pkt_gap=0) packets.append( RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) data_val = data_val + pkt_length data_pid = data_pid ^ 8 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) start_ep = 3 # The inter-frame gap is to give the DUT time to print its output packets = [] data_val = 0; pkt_length = 20 data_pid = 0x3 #DATA0 for pkt_length in range(10, 20): #Single EP: #317 lowest for valid data (SI) #337 for initial DI version #Multi EP: #177 lowest for valid data (DI) AppendInToken(packets, start_ep, inter_pkt_gap=177) packets.append(RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) AppendInToken(packets, start_ep+1, inter_pkt_gap=177) packets.append(RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) AppendInToken(packets, start_ep+2, inter_pkt_gap=177) packets.append(RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) AppendInToken(packets, start_ep+3, inter_pkt_gap=177) packets.append(RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) data_val = data_val + pkt_length data_pid = data_pid ^ 8 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
def do_test(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) ep = 0 # The inter-frame gap is to give the DUT time to print its output packets = [] # SETUP transaction AppendSetupToken(packets, ep) packets.append(TxDataPacket(rand, length=8, pid=3)) packets.append(RxHandshakePacket(timeout=11)) # IN transaction # Note, quite big gap to allow checking. packets.append(TokenPacket( inter_pkt_gap=2000, pid=0x69, #IN endpoint=ep)) packets.append(RxDataPacket(rand, length=10, pid=0x4b)) packets.append(TxHandshakePacket()) # Send 0 length OUT transaction packets.append(TokenPacket( inter_pkt_gap=2000, pid=0xe1, #OUT endpoint=ep)) packets.append(TxDataPacket(rand, length=0, pid=0xb)) packets.append(RxHandshakePacket()) # Send ACK packets.append(TxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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(arch, clk, phy, seed): rand = random.Random() rand.seed(seed) ep = 3 # The inter-frame gap is to give the DUT time to print its output packets = [] data_val = 0 pkt_length = 20 data_pid = 0x3 #DATA0 for pkt_length in range(10, 20): #317 lowest for valid data (non-dual issue version) #337 for initial dual-issue version AppendInToken(packets, ep, inter_pkt_gap=337) packets.append( RxDataPacket(rand, data_start_val=data_val, length=pkt_length, pid=data_pid)) packets.append(TxHandshakePacket()) data_val = data_val + pkt_length data_pid = data_pid ^ 8 do_rx_test(arch, clk, phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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() # Part A error_packets = [] # Test Frame 1 - Fragments (no SFD, no valid CRC) max_fragment_len = 143 if tx_clk.get_rate == Clock.CLK_125MHz: max_fragment_len = 142 # Incrememnt is meant to be 1, but for pragmatic reasons just test a subset of options (range(2, max_fragment_len, 1)) for m in [2, max_fragment_len/3, max_fragment_len/2, max_fragment_len]: error_packets.append(MiiPacket(rand, num_preamble_nibbles=m, num_data_bytes=0, sfd_nibble=None, dst_mac_addr=[], src_mac_addr=[], ether_len_type=[], send_crc_word=False, dropped=True )) # Test Frame 2 - Runts - undersized data with a valid CRC # NOTES: # - Take 4 off the data length to leave room for the CRC # - The data contents will be the DUT MAC address when long enough to contain a dst address # Incrememnt is meant to be 1, but for pragmatic reasons just test a subset of options (range(5, 45, 1)) for n in [5, 25, 45]: error_packets.append(MiiPacket(rand, dst_mac_addr=[], src_mac_addr=[], ether_len_type=[], data_bytes=[(x & 0xff) for x in range(n - 4)], dropped=True )) # There should have been no errors logged by the MAC #controller.dumpStats() # Part B # Test Frame 5 - send a 7-octect preamble error_packets.append(MiiPacket(rand, num_preamble_nibbles=15, num_data_bytes=0, sfd_nibble=None, dst_mac_addr=[], src_mac_addr=[], ether_len_type=[], send_crc_word=False, dropped=True )) # Test Frame 6 - send a 7-octect preamble with SFD error_packets.append(MiiPacket(rand, num_preamble_nibbles=15, num_data_bytes=0, dst_mac_addr=[], src_mac_addr=[], ether_len_type=[], send_crc_word=False, dropped=True )) # Test Frame 7 - send a 7-octect preamble with SFD and dest MAC error_packets.append(MiiPacket(rand, num_preamble_nibbles=15, num_data_bytes=6, dst_mac_addr=dut_mac_address, src_mac_addr=[], ether_len_type=[], send_crc_word=False, dropped=True )) # Test Frame 8 - send a 7-octect preamble with SFD, dest and src MAC error_packets.append(MiiPacket(rand, num_preamble_nibbles=15, num_data_bytes=12, dst_mac_addr=dut_mac_address, ether_len_type=[], send_crc_word=False, dropped=True )) # There should have been no errors logged by the MAC #controller.dumpStats() # Part C # Don't support flow control - so don't run # Part D # Parts A & 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, 46)], 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), 46)], inter_frame_gap=ifg )) do_rx_test(mac, arch, rx_clk, rx_phy, tx_clk, tx_phy, packets, __file__, seed)
def do_test(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 1 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0 AppendOutToken(packets, ep) packets.append( TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Assert RxError during packet dataval += 10 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb, rxe_assert_time=5)) #DATA1 # xCORE should ignore the packet and not handshake... #packets.append(RxHandshakePacket()) # Re-send.. AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb, rxe_assert_time=0)) #DATA1 packets.append(RxHandshakePacket()) dataval += 11 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 packets.append(RxHandshakePacket(timeout=9)) dataval += 12 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=13, pid=0xb, rxe_assert_time=1)) #DATA1 #packets.append(RxHandshakePacket()) #resend AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=13, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) dataval += 13 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append( TxDataPacket(rand, data_start_val=dataval, length=14, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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)
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(arch, tx_clk, tx_phy, seed): rand = random.Random() rand.seed(seed) dev_address = get_dut_address() ep = 1 # The inter-frame gap is to give the DUT time to print its output packets = [] dataval = 0; # Reserved PID packets.append(TokenPacket( inter_pkt_gap=2000, pid=0x0, address=dev_address, endpoint=ep)) # Valid IN but not for us.. packets.append(TokenPacket( inter_pkt_gap=200, pid=0x69, address=dev_address, endpoint=ep, valid=False)) # Valid OUT but not for us.. packets.append(TokenPacket( inter_pkt_gap=200, pid=0xe1, address=dev_address, endpoint=ep, valid=False)) AppendOutToken(packets, ep) packets.append(TxDataPacket(rand, data_start_val=dataval, length=10, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) # Valid SETUP but not for us.. packets.append(TokenPacket( inter_pkt_gap=200, pid=0x2d, address=dev_address, endpoint=ep, valid=False)) # Note, quite big gap to allow checking. dataval += 10 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append(TxDataPacket(rand, data_start_val=dataval, length=11, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) # Valid PING but not for us.. packets.append(TokenPacket( inter_pkt_gap=200, pid=0xb4, address=dev_address, endpoint=ep, valid=False)) dataval += 11 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append(TxDataPacket(rand, data_start_val=dataval, length=12, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) dataval += 12 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append(TxDataPacket(rand, data_start_val=dataval, length=13, pid=0xb)) #DATA1 packets.append(RxHandshakePacket()) dataval += 13 AppendOutToken(packets, ep, inter_pkt_gap=6000) packets.append(TxDataPacket(rand, data_start_val=dataval, length=14, pid=0x3)) #DATA0 packets.append(RxHandshakePacket()) do_rx_test(arch, tx_clk, tx_phy, packets, __file__, seed, level='smoke', extra_tasks=[])
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)