From 4e38eef817813c1bbd8a9cf972e4cf0134d24308 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Sun, 1 Dec 2019 21:58:13 -0800 Subject: dpdk: Add new DPDK stack to integrate with I/O services docs: Update DPDK docs with new parameters: Parameter names have had their hyphens changed to underscores, and the I/O CPU argument is now named after the lcores and reflects the naming used by DPDK. transport: Add new udp_dpdk_link, based atop the new APIs: This link is tightly coupled with the DPDK I/O service. The link class carries all the address information to communicate with the other host, and it can send packets directly through the DPDK NIC ports. However, for receiving packets, the I/O service must pull the packets from the DMA queue and attach them to the appropriate link object. The link object merely formats the frame_buff object underneath, which is embedded in the rte_mbuf container. For get_recv_buff, the link will pull buffers only from its internal queue (the one filled by the I/O service). transport: Add DPDK-specific I/O service: The I/O service is split into two parts, the user threads and the I/O worker threads. The user threads submit requests through various appropriate queues, and the I/O threads perform all the I/O on their behalf. This includes routing UDP packets to the correct receiver and getting the MAC address of a destination (by performing the ARP request and handling the ARP replies). The DPDK context stores I/O services. The context spawns all I/O services on init(), and I/O services can be fetched from the dpdk_ctx object by using a port ID. I/O service clients: The clients have two lockless ring buffers. One is to get a buffer from the I/O service; the other is to release a buffer back to the I/O service. Threads sleeping on buffer I/O are kept in a separate list from the service queue and are processed in the course of doing RX or TX. The list nodes are embedded in the dpdk_io_if, and the head of the list is on the dpdk_io_service. The I/O service will transfer the embedded wait_req to the list if it cannot acquire the mutex to complete the condition for waking. Co-authored-by: Martin Braun Co-authored-by: Ciro Nishiguchi Co-authored-by: Brent Stapleton --- host/tests/dpdk_port_test.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'host/tests/dpdk_port_test.cpp') diff --git a/host/tests/dpdk_port_test.cpp b/host/tests/dpdk_port_test.cpp index 7ef386c52..8f6b20c34 100644 --- a/host/tests/dpdk_port_test.cpp +++ b/host/tests/dpdk_port_test.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include #include @@ -101,6 +103,46 @@ int main(int argc, char **argv) service_thread.join(); std::cout << "PASS: Service thread terminated" << std::endl; delete queue; + + std::cout << "Starting up ARP thread..." << std::endl; + std::vector ports; + ports.push_back(port); + //auto io_srv = uhd::transport::dpdk_io_service::make(1, ports, 16); + auto io_srv = ctx->get_io_service(1); + + // Create link + std::cout << "Creating UDP link..." << std::endl; + uhd::transport::link_params_t params; + params.recv_frame_size = 8000; + params.send_frame_size = 8000; + params.num_recv_frames = 511; + params.num_send_frames = 511; + params.recv_buff_size = params.recv_frame_size*params.num_recv_frames; + params.send_buff_size = params.send_frame_size*params.num_send_frames; + auto link = uhd::transport::udp_dpdk_link::make("192.168.10.2", "49600", params); + + // Attach link + std::cout << "Attaching UDP send link..." << std::endl; + io_srv->attach_send_link(link); + struct ether_addr dest_mac; + link->get_remote_mac(dest_mac); + char mac_str[20]; + ether_format_addr(mac_str, 20, &dest_mac); + std::cout << "Remote MAC address is " << mac_str << std::endl; + std::cout << std::endl; + std::cout << "Attaching UDP recv link..." << std::endl; + io_srv->attach_recv_link(link); + std::cout << "Press any key to quit..." << std::endl; + std::cin.get(); + + // Shut down + std::cout << "Detaching UDP send link..." << std::endl; + io_srv->detach_send_link(link); + std::cout << "Detaching UDP recv link..." << std::endl; + io_srv->detach_recv_link(link); + std::cout << "Shutting down I/O service..." << std::endl; + io_srv.reset(); + std::cout << "Shutting down context..." << std::endl; ctx.reset(); return 0; } -- cgit v1.2.3