From 7bc7aaebe78ce8f782a42ff45e29087c495514fa Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Wed, 21 Feb 2024 16:13:59 -0800 Subject: [PATCH] fpga: Add netdev layer to testbenches Signed-off-by: Alex Forencich --- .../test_mqnic_core_pcie_us.py | 103 ++--- .../test_mqnic_core_pcie_us.py | 103 ++--- .../test_mqnic_core_pcie_us.py | 103 ++--- fpga/common/tb/mqnic.py | 431 ++++++++++-------- .../tb/mqnic_core_axi/test_mqnic_core_axi.py | 87 ++-- .../test_mqnic_core_pcie_ptile.py | 87 ++-- .../test_mqnic_core_pcie_s10.py | 87 ++-- .../test_mqnic_core_pcie_us.py | 87 ++-- .../test_mqnic_core_pcie_us.py | 95 ++-- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga/tb/fpga_core/test_fpga_core.py | 137 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../KR260/fpga/tb/fpga_core/test_fpga_core.py | 136 +++++- .../fpga/tb/fpga_core/test_fpga_core.py | 145 ++++-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 145 ++++-- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 136 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga/tb/fpga_core/test_fpga_core.py | 141 +++++- .../test_fpga_core.py | 141 +++++- .../fpga_pcie/tb/fpga_core/test_fpga_core.py | 141 +++++- .../tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- .../fpga_100g/tb/fpga_core/test_fpga_core.py | 123 ++++- .../fpga_25g/tb/fpga_core/test_fpga_core.py | 141 +++++- 39 files changed, 3877 insertions(+), 1332 deletions(-) diff --git a/fpga/app/custom_port_demo/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py b/fpga/app/custom_port_demo/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py index dcafb0bdd..bad8c6068 100644 --- a/fpga/app/custom_port_demo/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py +++ b/fpga/app/custom_port_demo/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py @@ -439,10 +439,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -450,14 +448,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -475,16 +473,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -498,20 +496,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -532,12 +530,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -560,10 +558,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -572,6 +570,26 @@ async def run_test_nic(dut): tb.loopback_enable = False + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + tb.log.info("Multiple large packets") count = 64 @@ -581,10 +599,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -602,10 +620,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -624,10 +642,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -636,21 +654,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -661,26 +670,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -698,10 +699,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/app/dma_bench/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py b/fpga/app/dma_bench/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py index dd286058f..66f7c10f6 100644 --- a/fpga/app/dma_bench/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py +++ b/fpga/app/dma_bench/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py @@ -437,10 +437,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -448,14 +446,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -473,16 +471,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -496,20 +494,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -530,12 +528,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -558,10 +556,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -570,6 +568,26 @@ async def run_test_nic(dut): tb.loopback_enable = False + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + tb.log.info("Multiple large packets") count = 64 @@ -579,10 +597,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -600,10 +618,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -622,10 +640,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -634,21 +652,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -659,26 +668,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -696,10 +697,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/app/template/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py b/fpga/app/template/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py index 1b1aca99c..44c942ab7 100644 --- a/fpga/app/template/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py +++ b/fpga/app/template/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py @@ -437,10 +437,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -448,14 +446,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -473,16 +471,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -496,20 +494,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -530,12 +528,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -558,10 +556,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -570,6 +568,26 @@ async def run_test_nic(dut): tb.loopback_enable = False + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + tb.log.info("Multiple large packets") count = 64 @@ -579,10 +597,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -600,10 +618,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -622,10 +640,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -634,21 +652,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -659,26 +668,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -696,10 +697,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/common/tb/mqnic.py b/fpga/common/tb/mqnic.py index 80d48a1d7..e6a771c9f 100644 --- a/fpga/common/tb/mqnic.py +++ b/fpga/common/tb/mqnic.py @@ -15,7 +15,7 @@ MQNIC_MAX_EQ = 1 MQNIC_MAX_TXQ = 32 -MQNIC_MAX_RXQ = 8 +MQNIC_MAX_RXQ = 32 MQNIC_MAX_CQ = MQNIC_MAX_TXQ*2 # Register blocks @@ -534,9 +534,6 @@ async def arm(self): await self.hw_regs.write_dword(MQNIC_EQ_CTRL_STATUS_REG, MQNIC_EQ_CMD_SET_ARM | 1) async def process_eq(self): - if not self.interface.port_up: - return - self.log.info("Process EQ") eq_cons_ptr = self.cons_ptr @@ -676,6 +673,7 @@ def __init__(self, interface): self.buf_dma = 0 self.buf = None + self.ndev = None self.cq = None self.prod_ptr = 0 @@ -688,7 +686,7 @@ def __init__(self, interface): self.hw_regs = None - async def open(self, cq, size, desc_block_size): + async def open(self, ndev, cq, size, desc_block_size): if self.hw_regs: raise Exception("Already open") @@ -714,6 +712,7 @@ async def open(self, cq, size, desc_block_size): self.prod_ptr = 0 self.cons_ptr = 0 + self.ndev = ndev self.cq = cq self.cq.src_ring = self self.cq.handler = Txq.process_tx_cq @@ -740,6 +739,7 @@ async def close(self): self.cq.src_ring = None self.cq.handler = None + self.ndev = None self.cq = None self.hw_regs = None @@ -790,12 +790,14 @@ def free_buf(self): @staticmethod async def process_tx_cq(cq): interface = cq.interface + ndev = cq.src_ring.ndev interface.log.info("Process CQ %d for TXQ %d (interface %d)", cq.cqn, cq.src_ring.index, interface.index) ring = cq.src_ring - if not interface.port_up: + if not ndev.port_up: + interface.log.info("Port not up, aborting") return # process completion queue @@ -858,6 +860,7 @@ def __init__(self, interface): self.buf_dma = 0 self.buf = None + self.ndev = None self.cq = None self.prod_ptr = 0 @@ -868,7 +871,7 @@ def __init__(self, interface): self.hw_regs = None - async def open(self, cq, size, desc_block_size): + async def open(self, ndev, cq, size, desc_block_size): if self.hw_regs: raise Exception("Already open") @@ -894,6 +897,7 @@ async def open(self, cq, size, desc_block_size): self.prod_ptr = 0 self.cons_ptr = 0 + self.ndev = ndev self.cq = cq self.cq.src_ring = self self.cq.handler = Rxq.process_rx_cq @@ -922,6 +926,7 @@ async def close(self): self.cq.src_ring = None self.cq.handler = None + self.ndev = None self.cq = None self.hw_regs = None @@ -998,12 +1003,14 @@ async def refill_buffers(self): @staticmethod async def process_rx_cq(cq): interface = cq.interface + ndev = cq.src_ring.ndev interface.log.info("Process CQ %d for RXQ %d (interface %d)", cq.cqn, cq.src_ring.index, interface.index) ring = cq.src_ring - if not interface.port_up: + if not ndev.port_up: + interface.log.info("Port not up, aborting") return # process completion queue @@ -1034,8 +1041,8 @@ async def process_rx_cq(cq): interface.log.info("Packet: %s", skb) - interface.pkt_rx_queue.append(skb) - interface.pkt_rx_sync.set() + ndev.pkt_rx_queue.append(skb) + ndev.pkt_rx_sync.set() ring.free_desc(ring_index) @@ -1098,17 +1105,23 @@ async def init(self): self.queue_count = await self.rb.read_dword(MQNIC_RB_SCHED_RR_REG_CH_COUNT) self.queue_stride = await self.rb.read_dword(MQNIC_RB_SCHED_RR_REG_CH_STRIDE) + self.queue_count = min(self.queue_count, MQNIC_MAX_TXQ) + async def enable(self): await self.set_ctrl(1) - for q in self.port.interface.txq: - await self.hw_regs.write_dword(q.index*4, 0x00000003) - async def disable(self): await self.set_ctrl(0) - for q in self.port.interface.txq: - await self.hw_regs.write_dword(q.index*4, 0x00000000) + async def enable_queue(self, queue): + await self.set_queue_ctrl(queue, 0x00000003) + + async def disable_queue(self, queue): + await self.set_queue_ctrl(queue, 0x00000000) + + async def disable_all_queues(self): + for k in range(self.queue_count): + await self.disable_queue(k) async def get_ctrl(self): return await self.rb.read_dword(MQNIC_RB_SCHED_RR_REG_CTRL) @@ -1116,6 +1129,12 @@ async def get_ctrl(self): async def set_ctrl(self, val): await self.rb.write_dword(MQNIC_RB_SCHED_RR_REG_CTRL, val) + async def get_queue_ctrl(self, queue): + return await self.hw_regs.read_dword(queue*4) + + async def set_queue_ctrl(self, queue, val): + await self.hw_regs.write_dword(queue*4, val) + class SchedulerControlTdma(BaseScheduler): def __init__(self, port, index, rb): @@ -1181,6 +1200,213 @@ async def deactivate(self): await sched.disable() +class NetDev: + def __init__(self, interface, index, port, sched_block): + self.interface = interface + self.log = interface.log + self.driver = interface.driver + self.index = index + self.port_up = False + + self.port = port + self.sched_block = sched_block + + self.txq_count = min(interface.txq_res.get_count(), 4) + self.rxq_count = min(interface.rxq_res.get_count(), 4) + + self.rx_queue_map_indir_table_size = interface.rx_queue_map_indir_table_size + self.rx_queue_map_indir_table = [k % self.rxq_count for k in range(self.rx_queue_map_indir_table_size)] + + self.txq = [] + self.rxq = [] + + self.tx_ring_size = 1024 + self.rx_ring_size = 1024 + + self.pkt_rx_queue = deque() + self.pkt_rx_sync = Event() + + async def init(self): + pass + + async def open(self): + if self.port_up: + return + + for k in range(self.rxq_count): + cq = Cq(self.interface) + await cq.open(self.interface.eq[k % len(self.interface.eq)], 1024) + await cq.arm() + rxq = Rxq(self.interface) + await rxq.open(self, cq, self.rx_ring_size, 4) + self.rxq.append(rxq) + + for k in range(self.txq_count): + cq = Cq(self.interface) + await cq.open(self.interface.eq[k % len(self.interface.eq)], 1024) + await cq.arm() + txq = Txq(self.interface) + await txq.open(self, cq, self.tx_ring_size, 4) + self.txq.append(txq) + + for k in range(self.rx_queue_map_indir_table_size): + self.rx_queue_map_indir_table[k] = k % self.rxq_count + + # configure RX indirection and RSS + await self.update_rx_queue_map_indir_table() + + # enable queues + for q in self.rxq: + await q.enable() + + for q in self.txq: + await q.enable() + + # enable transmit + await self.port.set_tx_ctrl(MQNIC_PORT_TX_CTRL_EN) + + # configure scheduler + for queue in range(self.sched_block.schedulers[0].queue_count): + found = False + for q in self.txq: + if queue == q.index: + found = True + break + if found: + await self.sched_block.schedulers[0].enable_queue(queue) + else: + await self.sched_block.schedulers[0].disable_queue(queue) + + # enable scheduler + await self.sched_block.activate() + + # enable receive + await self.port.set_rx_ctrl(MQNIC_PORT_RX_CTRL_EN) + + # wait for all writes to complete + await self.interface.hw_regs.read_dword(0) + + self.port_up = True + + async def close(self): + if not self.port_up: + return + + self.port_up = False + + await self.ports[0].set_rx_ctrl(0) + + for q in self.txq: + q.disable() + + for q in self.rxq: + q.disable() + + # wait for all writes to complete + await self.hw_regs.read_dword(0) + + for q in self.txq: + cq = q.cq + await q.free_buf() + await q.close() + await cq.close() + + for q in self.rxq: + cq = q.cq + await q.free_buf() + await q.close() + await cq.close() + + self.txq = [] + self.rxq = [] + + await self.ports[0].set_tx_ctrl(0) + + async def start_xmit(self, skb, tx_ring=None, csum_start=None, csum_offset=None): + if not self.port_up: + return + + data = bytes(skb) + + assert len(data) < self.interface.max_tx_mtu + + if tx_ring is not None: + ring_index = tx_ring + else: + ring_index = 0 + + ring = self.txq[ring_index] + + while True: + # check for space in ring + if ring.prod_ptr - ring.cons_ptr < ring.full_size: + break + + # wait for space + ring.clean_event.clear() + await ring.clean_event.wait() + + index = ring.prod_ptr & ring.size_mask + + ring.packets += 1 + ring.bytes += len(data) + + pkt = self.driver.alloc_pkt() + + assert not ring.tx_info[index] + ring.tx_info[index] = pkt + + # put data in packet buffer + pkt[10:len(data)+10] = data + + csum_cmd = 0 + + if csum_start is not None and csum_offset is not None: + csum_cmd = 0x8000 | (csum_offset << 8) | csum_start + + length = len(data) + ptr = pkt.get_absolute_address(0)+10 + offset = 0 + + # write descriptors + seg = min(length-offset, 42) if ring.desc_block_size > 1 else length-offset + struct.pack_into(" 1 else length-offset - struct.pack_into(" 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -459,26 +448,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -496,10 +477,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/common/tb/mqnic_core_pcie_ptile/test_mqnic_core_pcie_ptile.py b/fpga/common/tb/mqnic_core_pcie_ptile/test_mqnic_core_pcie_ptile.py index 170ac5e16..21e3e5a1e 100644 --- a/fpga/common/tb/mqnic_core_pcie_ptile/test_mqnic_core_pcie_ptile.py +++ b/fpga/common/tb/mqnic_core_pcie_ptile/test_mqnic_core_pcie_ptile.py @@ -415,10 +415,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -426,14 +424,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -451,16 +449,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -474,20 +472,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -508,12 +506,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -536,10 +534,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -557,10 +555,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(len(pkts)): - await tb.driver.interfaces[0].start_xmit(pkts[k], k % len(tb.driver.interfaces[0].txq)) + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -577,10 +575,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -598,10 +596,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -620,10 +618,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -632,21 +630,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -657,26 +646,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -694,10 +675,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/common/tb/mqnic_core_pcie_s10/test_mqnic_core_pcie_s10.py b/fpga/common/tb/mqnic_core_pcie_s10/test_mqnic_core_pcie_s10.py index 9da17191e..314d4a43d 100644 --- a/fpga/common/tb/mqnic_core_pcie_s10/test_mqnic_core_pcie_s10.py +++ b/fpga/common/tb/mqnic_core_pcie_s10/test_mqnic_core_pcie_s10.py @@ -363,10 +363,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -374,14 +372,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -399,16 +397,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -422,20 +420,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -456,12 +454,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -484,10 +482,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -505,10 +503,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(len(pkts)): - await tb.driver.interfaces[0].start_xmit(pkts[k], k % len(tb.driver.interfaces[0].txq)) + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -525,10 +523,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -546,10 +544,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -568,10 +566,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -580,21 +578,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -605,26 +594,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -642,10 +623,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/common/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py b/fpga/common/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py index 32279c260..9aae22855 100644 --- a/fpga/common/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py +++ b/fpga/common/tb/mqnic_core_pcie_us/test_mqnic_core_pcie_us.py @@ -437,10 +437,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -448,14 +446,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -473,16 +471,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -496,20 +494,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -530,12 +528,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -558,10 +556,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -579,10 +577,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(len(pkts)): - await tb.driver.interfaces[0].start_xmit(pkts[k], k % len(tb.driver.interfaces[0].txq)) + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -599,10 +597,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -620,10 +618,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -642,10 +640,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -654,21 +652,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -679,26 +668,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -716,10 +697,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/common/tb/mqnic_core_pcie_us_tdma/test_mqnic_core_pcie_us.py b/fpga/common/tb/mqnic_core_pcie_us_tdma/test_mqnic_core_pcie_us.py index dcba59318..eedc285d3 100644 --- a/fpga/common/tb/mqnic_core_pcie_us_tdma/test_mqnic_core_pcie_us.py +++ b/fpga/common/tb/mqnic_core_pcie_us_tdma/test_mqnic_core_pcie_us.py @@ -437,10 +437,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) for interface in tb.driver.interfaces: - await interface.open() + await interface.ndevs[0].open() - # wait for all writes to complete - await tb.driver.hw_regs.read_dword(0) tb.log.info("Init complete") tb.log.info("Send and receive single packet") @@ -448,14 +446,14 @@ async def run_test_nic(dut): for interface in tb.driver.interfaces: data = bytearray([x % 256 for x in range(1024)]) - await interface.start_xmit(data, 0) + await interface.ndevs[0].start_xmit(data, 0) pkt = await tb.port_mac[interface.index*interface.port_count].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[interface.index*interface.port_count].rx.send(pkt) - pkt = await interface.recv() + pkt = await interface.ndevs[0].recv() tb.log.info("Packet: %s", pkt) if interface.if_feature_rx_csum: @@ -473,16 +471,16 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) pkt = await tb.port_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.port_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -496,20 +494,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -530,12 +528,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -558,10 +556,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -579,10 +577,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(len(pkts)): - await tb.driver.interfaces[0].start_xmit(pkts[k], k % len(tb.driver.interfaces[0].txq)) + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -599,10 +597,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -620,10 +618,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -642,10 +640,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for k, p in enumerate(pkts): - await tb.driver.interfaces[k % len(tb.driver.interfaces)].start_xmit(p, 0) + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].recv() + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -654,21 +652,12 @@ async def run_test_nic(dut): tb.loopback_enable = False - if len(tb.driver.interfaces[0].sched_blocks) > 1: - tb.log.info("All interface 0 scheduler blocks") + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") - for block in tb.driver.interfaces[0].sched_blocks: - await block.schedulers[0].set_ctrl(1) - await block.interface.set_rx_queue_map_rss_mask(block.index, 0x00000000) - await block.interface.set_rx_queue_map_indir_table(block.index, 0, block.interface.rxq[block.index].index) - for k in range(len(block.interface.txq)): - if k % len(block.interface.sched_blocks) == block.index: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000003) - else: - await block.schedulers[0].hw_regs.write_dword(4*k, 0x00000000) - - await block.interface.ports[block.index].set_tx_ctrl(mqnic.MQNIC_PORT_TX_CTRL_EN) - await block.interface.ports[block.index].set_rx_ctrl(mqnic.MQNIC_PORT_RX_CTRL_EN) + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() count = 64 @@ -679,26 +668,18 @@ async def run_test_nic(dut): queues = set() for k, p in enumerate(pkts): - await tb.driver.interfaces[0].start_xmit(p, k % len(tb.driver.interfaces[0].sched_blocks)) + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() tb.log.info("Packet: %s", pkt) - # assert pkt.data == pkts[k] + assert pkt.data == pkts[k] if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - queues.add(pkt.queue) - - assert len(queues) == len(tb.driver.interfaces[0].sched_blocks) - tb.loopback_enable = False - for block in tb.driver.interfaces[0].sched_blocks[1:]: - await block.schedulers[0].set_ctrl(0) - await tb.driver.interfaces[0].set_rx_queue_map_rss_mask(0, 0xffffffff) - if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -716,10 +697,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] @@ -747,8 +728,8 @@ async def run_test_nic(dut): # enable queues with global enable off await tb.driver.interfaces[0].sched_blocks[0].schedulers[0].rb.write_dword(mqnic.MQNIC_RB_SCHED_RR_REG_CTRL, 0x00000001) - for k in range(len(tb.driver.interfaces[0].txq)): - await tb.driver.interfaces[0].sched_blocks[0].schedulers[0].hw_regs.write_dword(4*k, 0x00000001) + for q in tb.driver.interfaces[0].ndevs[0].txq: + await tb.driver.interfaces[0].sched_blocks[0].schedulers[0].hw_regs.write_dword(4*q.index, 0x00000001) # configure slots await tb.driver.interfaces[0].sched_blocks[0].schedulers[1].hw_regs.write_dword(8*0, 0x00000001) @@ -761,10 +742,10 @@ async def run_test_nic(dut): # send packets for k in range(count): - await tb.driver.interfaces[0].start_xmit(pkts[k], k % 4) + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % 4) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) # assert pkt.data == pkts[k] diff --git a/fpga/mqnic/250_SoC/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/250_SoC/fpga_100g/tb/fpga_core/test_fpga_core.py index 46fe02b63..fa66a2dc0 100644 --- a/fpga/mqnic/250_SoC/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/250_SoC/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -370,8 +370,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -381,26 +381,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -416,14 +416,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -436,20 +436,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -470,12 +470,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -498,14 +498,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -518,14 +539,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -538,17 +560,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/250_SoC/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/250_SoC/fpga_25g/tb/fpga_core/test_fpga_core.py index d7f849549..59d5b652c 100644 --- a/fpga/mqnic/250_SoC/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/250_SoC/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -366,8 +366,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -377,26 +377,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -412,14 +412,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -432,20 +432,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -466,12 +466,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -494,14 +494,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -514,17 +535,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -542,10 +635,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/520N_MX/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/520N_MX/fpga_25g/tb/fpga_core/test_fpga_core.py index d3f591b36..748256926 100644 --- a/fpga/mqnic/520N_MX/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/520N_MX/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -276,8 +276,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -287,26 +287,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -322,14 +322,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -342,20 +342,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -376,12 +376,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -404,14 +404,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -424,17 +445,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -452,10 +545,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/ADM_PCIE_9V3/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/ADM_PCIE_9V3/fpga_100g/tb/fpga_core/test_fpga_core.py index 2c014df80..ee31dfc57 100644 --- a/fpga/mqnic/ADM_PCIE_9V3/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/ADM_PCIE_9V3/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -372,8 +372,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -383,26 +383,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -418,14 +418,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -438,20 +438,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -472,12 +472,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -500,14 +500,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -520,14 +541,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -540,17 +562,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py index ec5d5db79..1b82b2a8a 100644 --- a/fpga/mqnic/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/ADM_PCIE_9V3/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -368,8 +368,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -379,26 +379,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -414,14 +414,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -434,20 +434,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -468,12 +468,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -496,14 +496,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -516,17 +537,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -544,10 +637,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/test_fpga_core.py index 9ff36e7e9..52608ed1e 100644 --- a/fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/Alveo/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -371,8 +371,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -382,26 +382,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -417,14 +417,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -437,20 +437,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -471,12 +471,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -499,14 +499,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -519,14 +540,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -539,17 +561,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/Alveo/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/Alveo/fpga_25g/tb/fpga_core/test_fpga_core.py index 5a3bd10b3..ed227a0df 100644 --- a/fpga/mqnic/Alveo/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/Alveo/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -358,8 +358,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -369,26 +369,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[4].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[4].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -404,14 +404,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -424,20 +424,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -458,12 +458,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -486,14 +486,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -506,17 +527,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -534,10 +627,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/DE10_Agilex/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/DE10_Agilex/fpga_100g/tb/fpga_core/test_fpga_core.py index 56546e360..fc5091748 100644 --- a/fpga/mqnic/DE10_Agilex/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/DE10_Agilex/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -346,8 +346,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -357,26 +357,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfpdd_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfpdd_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -392,14 +392,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -412,20 +412,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -446,12 +446,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -474,14 +474,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -494,14 +515,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -514,17 +536,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/DK_DEV_1SDX_P_A/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/DK_DEV_1SDX_P_A/fpga_100g/tb/fpga_core/test_fpga_core.py index ea6e237c9..703a9714f 100644 --- a/fpga/mqnic/DK_DEV_1SDX_P_A/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/DK_DEV_1SDX_P_A/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -336,8 +336,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -347,26 +347,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -382,14 +382,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -402,20 +402,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -436,12 +436,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -464,14 +464,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -484,14 +505,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -504,17 +526,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/DK_DEV_1SMX_H_A/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/DK_DEV_1SMX_H_A/fpga_25g/tb/fpga_core/test_fpga_core.py index 16e2e8022..86acc8609 100644 --- a/fpga/mqnic/DK_DEV_1SMX_H_A/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/DK_DEV_1SMX_H_A/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -278,8 +278,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -289,26 +289,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -324,14 +324,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -344,20 +344,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -378,12 +378,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -406,14 +406,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -426,17 +447,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -454,10 +547,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/DK_DEV_AGF014EA/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/DK_DEV_AGF014EA/fpga_100g/tb/fpga_core/test_fpga_core.py index 88ed526c8..50b1f630c 100644 --- a/fpga/mqnic/DK_DEV_AGF014EA/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/DK_DEV_AGF014EA/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -343,8 +343,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -354,26 +354,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfpdd_mac[2].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfpdd_mac[2].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -389,14 +389,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -409,20 +409,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -443,12 +443,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -471,14 +471,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -491,14 +512,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -511,17 +533,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/DNPCIe_40G_KU_LL_2QSFP/fpga/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/DNPCIe_40G_KU_LL_2QSFP/fpga/tb/fpga_core/test_fpga_core.py index 127af821f..666ec3ccf 100644 --- a/fpga/mqnic/DNPCIe_40G_KU_LL_2QSFP/fpga/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/DNPCIe_40G_KU_LL_2QSFP/fpga/tb/fpga_core/test_fpga_core.py @@ -338,8 +338,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -349,14 +349,14 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -372,14 +372,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -392,20 +392,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -426,12 +426,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -454,14 +454,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -474,17 +495,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -502,10 +595,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/IA_420F/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/IA_420F/fpga_100g/tb/fpga_core/test_fpga_core.py index 3168a5545..bce9886be 100644 --- a/fpga/mqnic/IA_420F/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/IA_420F/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -335,8 +335,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -346,26 +346,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfpdd_mac[2].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfpdd_mac[2].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -381,14 +381,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfpdd_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfpdd_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -401,20 +401,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -435,12 +435,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -463,14 +463,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -483,14 +504,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -503,17 +525,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/KR260/fpga/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/KR260/fpga/tb/fpga_core/test_fpga_core.py index eb5b33e05..a5e832536 100644 --- a/fpga/mqnic/KR260/fpga/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/KR260/fpga/tb/fpga_core/test_fpga_core.py @@ -123,7 +123,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_axi_dev(tb.pool, tb.hw_regs, irq=dut.irq) - await tb.driver.interfaces[0].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -133,14 +134,14 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink.recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -156,14 +157,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink.recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -176,20 +177,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -210,12 +211,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -238,14 +239,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -258,17 +280,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -286,10 +380,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py index 6a0d88e58..fb16eede1 100644 --- a/fpga/mqnic/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/NetFPGA_SUME/fpga/tb/fpga_core/test_fpga_core.py @@ -305,8 +305,8 @@ async def _run_loopback(self): if self.loopback_enable: for x in range(len(self.sfp_sink)): - if not self.sfp_sink[x].empty(): - await self.sfp_source[x].send(await self.sfp_sink[x].recv()) + if not self.sfp_sink[x].empty(): + await self.sfp_source[x].send(await self.sfp_sink[x].recv()) @cocotb.test() @@ -318,8 +318,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -329,26 +329,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[]1.recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[]1.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -364,14 +364,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -384,20 +384,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -418,12 +418,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -446,14 +446,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -466,17 +487,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -494,10 +587,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/Nexus_K3P_Q/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/Nexus_K3P_Q/fpga_25g/tb/fpga_core/test_fpga_core.py index 676ef0ca8..e20c2f411 100644 --- a/fpga/mqnic/Nexus_K3P_Q/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/Nexus_K3P_Q/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -366,8 +366,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -377,26 +377,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -412,14 +412,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -432,20 +432,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -466,12 +466,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -494,14 +494,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -514,17 +535,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -542,10 +635,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/Nexus_K3P_S/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/Nexus_K3P_S/fpga_25g/tb/fpga_core/test_fpga_core.py index 76843e730..79b9e0262 100644 --- a/fpga/mqnic/Nexus_K3P_S/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/Nexus_K3P_S/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -345,8 +345,8 @@ async def _run_loopback(self): if self.loopback_enable: for x in range(len(self.sfp_sink)): - if not self.sfp_sink[x].empty(): - await self.sfp_source[x].send(await self.sfp_sink[x].recv()) + if not self.sfp_sink[x].empty(): + await self.sfp_source[x].send(await self.sfp_sink[x].recv()) @cocotb.test() @@ -358,8 +358,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -369,26 +369,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[1].recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[1].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -404,14 +404,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -424,20 +424,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -458,12 +458,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -486,14 +486,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -506,17 +527,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -534,10 +627,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/VCU108/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/VCU108/fpga_25g/tb/fpga_core/test_fpga_core.py index 406313f1e..17f5aee35 100644 --- a/fpga/mqnic/VCU108/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/VCU108/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -336,7 +336,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -346,14 +347,14 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -369,14 +370,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -389,20 +390,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -423,12 +424,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -451,14 +452,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -471,17 +493,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -499,10 +593,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/VCU118/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/VCU118/fpga_100g/tb/fpga_core/test_fpga_core.py index 6bf3910ac..bffce1eb1 100644 --- a/fpga/mqnic/VCU118/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/VCU118/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -374,8 +374,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -385,26 +385,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -420,14 +420,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -440,20 +440,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -474,12 +474,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -502,14 +502,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -522,14 +543,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -542,17 +564,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py index 63b4f37da..3d28ae297 100644 --- a/fpga/mqnic/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/VCU118/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -370,8 +370,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -381,26 +381,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -416,14 +416,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -436,20 +436,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -470,12 +470,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -498,14 +498,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -518,17 +539,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -546,10 +639,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/XUPP3R/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/XUPP3R/fpga_100g/tb/fpga_core/test_fpga_core.py index de4493d77..c0f7173c5 100644 --- a/fpga/mqnic/XUPP3R/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/XUPP3R/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -370,8 +370,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -381,26 +381,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -416,14 +416,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -436,20 +436,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -470,12 +470,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -498,14 +498,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -518,14 +539,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -538,17 +560,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/XUPP3R/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/XUPP3R/fpga_25g/tb/fpga_core/test_fpga_core.py index 38eb63b5b..139d007d6 100644 --- a/fpga/mqnic/XUPP3R/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/XUPP3R/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -367,8 +367,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -378,26 +378,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -413,14 +413,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -433,20 +433,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -467,12 +467,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -495,14 +495,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -515,17 +536,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -543,10 +636,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/ZCU102/fpga/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/ZCU102/fpga/tb/fpga_core/test_fpga_core.py index 8b83e6b88..e1552380e 100644 --- a/fpga/mqnic/ZCU102/fpga/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/ZCU102/fpga/tb/fpga_core/test_fpga_core.py @@ -132,8 +132,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_axi_dev(tb.pool, tb.hw_regs, irq=dut.irq) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -143,26 +143,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[1].recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[1].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -178,14 +178,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -198,20 +198,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -232,12 +232,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -260,14 +260,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -280,17 +301,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -308,10 +401,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/ZCU102/fpga/tb/fpga_core_app_custom_port_demo/test_fpga_core.py b/fpga/mqnic/ZCU102/fpga/tb/fpga_core_app_custom_port_demo/test_fpga_core.py index ef25eba73..937fac8c9 100644 --- a/fpga/mqnic/ZCU102/fpga/tb/fpga_core_app_custom_port_demo/test_fpga_core.py +++ b/fpga/mqnic/ZCU102/fpga/tb/fpga_core_app_custom_port_demo/test_fpga_core.py @@ -132,8 +132,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_axi_dev(tb.pool, tb.hw_regs, irq=dut.irq) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -143,26 +143,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[1].recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[1].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -178,14 +178,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -198,20 +198,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -232,12 +232,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -260,14 +260,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -280,17 +301,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -308,10 +401,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/ZCU106/fpga_pcie/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/ZCU106/fpga_pcie/tb/fpga_core/test_fpga_core.py index 9dc504e09..03efe7f1c 100644 --- a/fpga/mqnic/ZCU106/fpga_pcie/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/ZCU106/fpga_pcie/tb/fpga_core/test_fpga_core.py @@ -355,8 +355,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -366,26 +366,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[1].recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[1].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -401,14 +401,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -421,20 +421,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -455,12 +455,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -483,14 +483,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -503,17 +524,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -531,10 +624,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/ZCU106/fpga_zynqmp/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/ZCU106/fpga_zynqmp/tb/fpga_core/test_fpga_core.py index 4ec449e73..2a5c155fc 100644 --- a/fpga/mqnic/ZCU106/fpga_zynqmp/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/ZCU106/fpga_zynqmp/tb/fpga_core/test_fpga_core.py @@ -132,8 +132,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_axi_dev(tb.pool, tb.hw_regs, irq=dut.irq) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -143,26 +143,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.sfp_sink[1].recv() # tb.log.info("Packet: %s", pkt) # await tb.sfp_source[1].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -178,14 +178,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.sfp_sink[0].recv() tb.log.info("Packet: %s", pkt) await tb.sfp_source[0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -198,20 +198,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -232,12 +232,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -260,14 +260,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -280,17 +301,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -308,10 +401,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/fb2CG/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/fb2CG/fpga_100g/tb/fpga_core/test_fpga_core.py index 03fdd0dbb..d941b413f 100644 --- a/fpga/mqnic/fb2CG/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/fb2CG/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -370,8 +370,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -381,26 +381,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -416,14 +416,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -436,20 +436,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -470,12 +470,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -498,14 +498,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -518,14 +539,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -538,17 +560,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py index 49a7b3aa6..806852436 100644 --- a/fpga/mqnic/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/fb2CG/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -366,8 +366,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -377,26 +377,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -412,14 +412,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -432,20 +432,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -466,12 +466,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -494,14 +494,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -514,17 +535,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -542,10 +635,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] diff --git a/fpga/mqnic/fb4CGg3/fpga_100g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/fb4CGg3/fpga_100g/tb/fpga_core/test_fpga_core.py index 4db749bdb..2065c91a7 100644 --- a/fpga/mqnic/fb4CGg3/fpga_100g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/fb4CGg3/fpga_100g/tb/fpga_core/test_fpga_core.py @@ -365,8 +365,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -376,26 +376,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_mac[1].tx.recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_mac[1].rx.send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -411,14 +411,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_mac[0].tx.recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_mac[0].rx.send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -431,20 +431,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -465,12 +465,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -493,14 +493,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -513,14 +534,15 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -533,17 +555,68 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + await RisingEdge(dut.clk_250mhz) await RisingEdge(dut.clk_250mhz) diff --git a/fpga/mqnic/fb4CGg3/fpga_25g/tb/fpga_core/test_fpga_core.py b/fpga/mqnic/fb4CGg3/fpga_25g/tb/fpga_core/test_fpga_core.py index 725638a2e..601a7cbce 100644 --- a/fpga/mqnic/fb4CGg3/fpga_25g/tb/fpga_core/test_fpga_core.py +++ b/fpga/mqnic/fb4CGg3/fpga_25g/tb/fpga_core/test_fpga_core.py @@ -363,8 +363,8 @@ async def run_test_nic(dut): tb.log.info("Init driver") await tb.driver.init_pcie_dev(tb.rc.find_device(tb.dev.functions[0].pcie_id)) - await tb.driver.interfaces[0].open() - # await tb.driver.interfaces[1].open() + for interface in tb.driver.interfaces: + await interface.ndevs[0].open() # wait for all writes to complete await tb.driver.hw_regs.read_dword(0) @@ -374,26 +374,26 @@ async def run_test_nic(dut): data = bytearray([x % 256 for x in range(1024)]) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - # await tb.driver.interfaces[1].start_xmit(data, 0) + # await tb.driver.interfaces[1].ndevs[0].start_xmit(data, 0) # pkt = await tb.qsfp_sink[1][0].recv() # tb.log.info("Packet: %s", pkt) # await tb.qsfp_source[1][0].send(pkt) - # pkt = await tb.driver.interfaces[1].recv() + # pkt = await tb.driver.interfaces[1].ndevs[0].recv() # tb.log.info("Packet: %s", pkt) # assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -409,14 +409,14 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) pkt = await tb.qsfp_sink[0][0].recv() tb.log.info("Packet: %s", pkt) await tb.qsfp_source[0][0].send(pkt) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff @@ -429,20 +429,20 @@ async def run_test_nic(dut): tb.loopback_enable = True for k in range(4): - await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].rxq[k].index) + await tb.driver.interfaces[0].set_rx_queue_map_indir_table(0, 0, tb.driver.interfaces[0].ndevs[0].rxq[k].index) - await tb.driver.interfaces[0].start_xmit(data, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(data, 0) - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff - assert pkt.queue == tb.driver.interfaces[0].rxq[k].index + assert pkt.queue == tb.driver.interfaces[0].ndevs[0].rxq[k].index tb.loopback_enable = False - await tb.driver.interfaces[0].update_rx_queue_map_indir_table(0) + await tb.driver.interfaces[0].ndevs[0].update_rx_queue_map_indir_table() tb.log.info("Queue mapping RSS mask test") @@ -463,12 +463,12 @@ async def run_test_nic(dut): test_pkt2 = test_pkt.copy() test_pkt2[UDP].chksum = scapy.utils.checksum(bytes(test_pkt2[UDP])) - await tb.driver.interfaces[0].start_xmit(test_pkt2.build(), 0, 34, 6) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt2.build(), 0, 34, 6) else: - await tb.driver.interfaces[0].start_xmit(test_pkt.build(), 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(test_pkt.build(), 0) for k in range(64): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) if tb.driver.interfaces[0].if_feature_rx_csum: @@ -491,14 +491,35 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Multiple TX queues") + + count = 1024 + + pkts = [bytearray([(x+k) % 256 for x in range(60)]) for k in range(count)] + + tb.loopback_enable = True + + for k in range(len(pkts)): + await tb.driver.interfaces[0].ndevs[0].start_xmit(pkts[k], k % tb.driver.interfaces[0].ndevs[0].txq_count) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False @@ -511,17 +532,89 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k] - assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + tb.log.info("Jumbo frames") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(9014)]) for k in range(count)] + + tb.loopback_enable = True + + for p in pkts: + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff tb.loopback_enable = False + if len(tb.driver.interfaces) > 1: + tb.log.info("All interfaces") + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + for k, p in enumerate(pkts): + await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[k % len(tb.driver.interfaces)].ndevs[0].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + + if len(tb.driver.interfaces[0].ndevs) > 1: + tb.log.info("All interface 0 netdevs") + + for ndev in tb.driver.interfaces[0].ndevs: + if not ndev.port_up: + await ndev.open() + + count = 64 + + pkts = [bytearray([(x+k) % 256 for x in range(1514)]) for k in range(count)] + + tb.loopback_enable = True + + queues = set() + + for k, p in enumerate(pkts): + await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].start_xmit(p, 0) + + for k in range(count): + pkt = await tb.driver.interfaces[0].ndevs[k % len(tb.driver.interfaces[0].ndevs)].recv() + + tb.log.info("Packet: %s", pkt) + assert pkt.data == pkts[k] + if tb.driver.interfaces[0].if_feature_rx_csum: + assert pkt.rx_checksum == ~scapy.utils.checksum(bytes(pkt.data[14:])) & 0xffff + + tb.loopback_enable = False + if tb.driver.interfaces[0].if_feature_lfc: tb.log.info("Test LFC pause frame RX") @@ -539,10 +632,10 @@ async def run_test_nic(dut): tb.loopback_enable = True for p in pkts: - await tb.driver.interfaces[0].start_xmit(p, 0) + await tb.driver.interfaces[0].ndevs[0].start_xmit(p, 0) for k in range(count): - pkt = await tb.driver.interfaces[0].recv() + pkt = await tb.driver.interfaces[0].ndevs[0].recv() tb.log.info("Packet: %s", pkt) assert pkt.data == pkts[k]