From e2195ac505bd423d3d2f973bbe94da1c78296aa6 Mon Sep 17 00:00:00 2001 From: Alex Williams Date: Fri, 31 Aug 2018 11:35:07 -0700 Subject: transport: Add blocking recv calls to uhd-dpdk This adds an internal wait queue API to uhd-dpdk. Socket configuration requests had their blocking calls re-implemented on top of this API, and it is also used to service requests to wait on RX packets (w/ timeout). The wait API involves a multi-producer, single-consumer queue per I/O thread (waiter_ring), with a condition variable used for sleeping. The data structure is shared between user thread and I/O thread, and because timeouts make resource release time non-deterministic, we use reference counting on the shared resource. One reference is generated by the user thread and passed to the I/O thread to consume. A user thread that still needs the data after waking must get() another reference, to postpone the destruction of the resource until it is done. Timeouts are based on CLOCK_MONOTONIC. For recv, a timeout of 0 indicates blocking indefinitely, and a negative timeout indicates no timeout is desired. Also drop timeout for closing sockets in uhd-dpdk. The timeout would allow a user thread to pre-empt the I/O thread's cleanup process. The user thread would free data structures the I/O thread still needed to function. Since this timeout is superfluous anyway, let's just get rid of it. Also add some more input checking and error reporting. --- host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h') diff --git a/host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h b/host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h index 651ae144e..39fcb8597 100644 --- a/host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h +++ b/host/lib/transport/uhd-dpdk/uhd_dpdk_udp.h @@ -13,7 +13,8 @@ struct uhd_dpdk_udp_priv { uint16_t src_port; uint16_t dst_port; uint32_t dst_ipv4_addr; - uint32_t dropped_pkts; + size_t dropped_pkts; + size_t xferd_pkts; /* TODO: Cache destination address ptr to avoid ARP table lookup cost? */ //struct uhd_dpdk_arp_entry *arp_entry; }; @@ -27,4 +28,12 @@ void uhd_dpdk_udp_close(struct uhd_dpdk_config_req *req); int uhd_dpdk_udp_prep(struct uhd_dpdk_socket *sock, struct rte_mbuf *mbuf); + +/* + * Get key for RX table corresponding to this socket + * + * This is primarily used to get access to the waiter entry + */ +int _uhd_dpdk_udp_rx_key(struct uhd_dpdk_socket *sock, + struct uhd_dpdk_ipv4_5tuple *key); #endif /* _UHD_DPDK_UDP_H_ */ -- cgit v1.2.3