diff options
author | Andrew Lynch <andrew.lynch@ni.com> | 2021-11-09 09:12:08 -0600 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-12-06 13:22:03 -0800 |
commit | b17d2dfa988344debe63f1b5d7e8556fef87218f (patch) | |
tree | a629c05ddf5c880eb475a36db773aaead8977cf9 /host/lib/include | |
parent | 8ce91bc7383409602206128839a0cf2daa932319 (diff) | |
download | uhd-b17d2dfa988344debe63f1b5d7e8556fef87218f.tar.gz uhd-b17d2dfa988344debe63f1b5d7e8556fef87218f.tar.bz2 uhd-b17d2dfa988344debe63f1b5d7e8556fef87218f.zip |
dpdk: Upgrade to DPDK 19.11 API
Support DPDK versions 19.11 and 20.11
Diffstat (limited to 'host/lib/include')
-rw-r--r-- | host/lib/include/uhdlib/transport/dpdk/arp.hpp | 6 | ||||
-rw-r--r-- | host/lib/include/uhdlib/transport/dpdk/common.hpp | 32 | ||||
-rw-r--r-- | host/lib/include/uhdlib/transport/dpdk/udp.hpp | 56 | ||||
-rw-r--r-- | host/lib/include/uhdlib/transport/dpdk_io_service.hpp | 8 | ||||
-rw-r--r-- | host/lib/include/uhdlib/transport/udp_dpdk_link.hpp | 10 |
5 files changed, 56 insertions, 56 deletions
diff --git a/host/lib/include/uhdlib/transport/dpdk/arp.hpp b/host/lib/include/uhdlib/transport/dpdk/arp.hpp index 684c3c370..2272299df 100644 --- a/host/lib/include/uhdlib/transport/dpdk/arp.hpp +++ b/host/lib/include/uhdlib/transport/dpdk/arp.hpp @@ -13,14 +13,14 @@ namespace uhd { namespace transport { namespace dpdk { struct arp_request { - struct ether_addr tha; + struct rte_ether_addr tha; port_id_t port; - ipv4_addr tpa; + rte_ipv4_addr tpa; }; struct arp_entry { - struct ether_addr mac_addr; + struct rte_ether_addr mac_addr; std::vector<wait_req*> reqs; }; diff --git a/host/lib/include/uhdlib/transport/dpdk/common.hpp b/host/lib/include/uhdlib/transport/dpdk/common.hpp index c153c7107..c1302335a 100644 --- a/host/lib/include/uhdlib/transport/dpdk/common.hpp +++ b/host/lib/include/uhdlib/transport/dpdk/common.hpp @@ -37,7 +37,7 @@ struct arp_entry; using queue_id_t = uint16_t; using port_id_t = uint16_t; -using ipv4_addr = uint32_t; +using rte_ipv4_addr = uint32_t; class dpdk_adapter_info : public adapter_info { @@ -143,7 +143,7 @@ public: * \param num_desc The number of descriptors per DMA queue * \param rx_pktbuf_pool A pointer to the port's RX packet buffer pool * \param tx_pktbuf_pool A pointer to the port's TX packet buffer pool - * \param ipv4_address The IPv4 network address (w/ netmask) + * \param rte_ipv4_address The IPv4 network address (w/ netmask) * \return A unique_ptr to a dpdk_port object */ static dpdk_port::uptr make(port_id_t port, @@ -152,7 +152,7 @@ public: uint16_t num_desc, struct rte_mempool* rx_pktbuf_pool, struct rte_mempool* tx_pktbuf_pool, - std::string ipv4_address); + std::string rte_ipv4_address); dpdk_port(port_id_t port, size_t mtu, @@ -160,7 +160,7 @@ public: uint16_t num_desc, struct rte_mempool* rx_pktbuf_pool, struct rte_mempool* tx_pktbuf_pool, - std::string ipv4_address); + std::string rte_ipv4_address); ~dpdk_port(); @@ -180,7 +180,7 @@ public: /*! Getter for this port's MAC address * \return this port's MAC address */ - inline ether_addr get_mac_addr() const + inline rte_ether_addr get_mac_addr() const { return _mac_addr; } @@ -196,7 +196,7 @@ public: /*! Getter for this port's IPv4 address * \return this port's IPv4 address (in network order) */ - inline ipv4_addr get_ipv4() const + inline rte_ipv4_addr get_ipv4() const { return _ipv4; } @@ -204,7 +204,7 @@ public: /*! Getter for this port's subnet mask * \return this port's subnet mask (in network order) */ - inline ipv4_addr get_netmask() const + inline rte_ipv4_addr get_netmask() const { return _netmask; } @@ -238,12 +238,12 @@ public: } /*! Determine if the destination address is a broadcast address for this port - * \param dst_ipv4_addr The destination IPv4 address (in network order) + * \param dst_rte_ipv4_addr The destination IPv4 address (in network order) * \return whether the destination address matches this port's broadcast address */ - inline bool dst_is_broadcast(const ipv4_addr dst_ipv4_addr) const + inline bool dst_is_broadcast(const rte_ipv4_addr dst_rte_ipv4_addr) const { - uint32_t network = _netmask | ((~_netmask) & dst_ipv4_addr); + uint32_t network = _netmask | ((~_netmask) & dst_rte_ipv4_addr); return (network == 0xffffffff); } @@ -261,16 +261,16 @@ private: /*! * Construct and transmit an ARP reply (for the given ARP request) */ - int _arp_reply(queue_id_t queue_id, struct arp_hdr* arp_req); + int _arp_reply(queue_id_t queue_id, struct rte_arp_hdr* arp_req); port_id_t _port; size_t _mtu; size_t _num_queues; struct rte_mempool* _rx_pktbuf_pool; struct rte_mempool* _tx_pktbuf_pool; - struct ether_addr _mac_addr; - ipv4_addr _ipv4; - ipv4_addr _netmask; + struct rte_ether_addr _mac_addr; + rte_ipv4_addr _ipv4; + rte_ipv4_addr _netmask; // Structures protected by mutex std::mutex _mutex; @@ -279,7 +279,7 @@ private: // Structures protected by spin lock rte_spinlock_t _spinlock = RTE_SPINLOCK_INITIALIZER; - std::unordered_map<ipv4_addr, struct arp_entry*> _arp_table; + std::unordered_map<rte_ipv4_addr, struct arp_entry*> _arp_table; }; @@ -317,7 +317,7 @@ public: * \param mac_addr MAC address * \return pointer to port if match found, else nullptr */ - dpdk_port* get_port(struct ether_addr mac_addr) const; + dpdk_port* get_port(struct rte_ether_addr mac_addr) const; /*! * Get port structure from provided port ID diff --git a/host/lib/include/uhdlib/transport/dpdk/udp.hpp b/host/lib/include/uhdlib/transport/dpdk/udp.hpp index d74183bf5..712b73d81 100644 --- a/host/lib/include/uhdlib/transport/dpdk/udp.hpp +++ b/host/lib/include/uhdlib/transport/dpdk/udp.hpp @@ -15,7 +15,7 @@ namespace uhd { namespace transport { namespace dpdk { constexpr size_t HDR_SIZE_UDP_IPV4 = - (sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + sizeof(struct udp_hdr)); + (sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + sizeof(struct rte_udp_hdr)); /*! * An enumerated type representing the type of flow for an IPv4 client @@ -32,76 +32,76 @@ enum flow_type { struct ipv4_5tuple { enum flow_type flow_type; - ipv4_addr src_ip; - ipv4_addr dst_ip; + rte_ipv4_addr src_ip; + rte_ipv4_addr dst_ip; uint16_t src_port; uint16_t dst_port; }; -inline void fill_ipv4_hdr(struct rte_mbuf* mbuf, +inline void fill_rte_ipv4_hdr(struct rte_mbuf* mbuf, const dpdk_port* port, - uint32_t dst_ipv4_addr, + uint32_t dst_rte_ipv4_addr, uint8_t proto_id, uint32_t payload_len) { - struct ether_hdr* eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr*); - struct ipv4_hdr* ip_hdr = (struct ipv4_hdr*)ð_hdr[1]; + struct rte_ether_hdr* eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr*); + struct rte_ipv4_hdr* ip_hdr = (struct rte_ipv4_hdr*)ð_hdr[1]; ip_hdr->version_ihl = 0x40 | 5; ip_hdr->type_of_service = 0; ip_hdr->total_length = rte_cpu_to_be_16(20 + payload_len); ip_hdr->packet_id = 0; - ip_hdr->fragment_offset = rte_cpu_to_be_16(IPV4_HDR_DF_FLAG); + ip_hdr->fragment_offset = rte_cpu_to_be_16(RTE_IPV4_HDR_DF_FLAG); ip_hdr->time_to_live = 64; ip_hdr->next_proto_id = proto_id; ip_hdr->hdr_checksum = 0; // Require HW offload ip_hdr->src_addr = port->get_ipv4(); - ip_hdr->dst_addr = dst_ipv4_addr; + ip_hdr->dst_addr = dst_rte_ipv4_addr; mbuf->ol_flags = PKT_TX_IP_CKSUM | PKT_TX_IPV4; - mbuf->l2_len = sizeof(struct ether_hdr); - mbuf->l3_len = sizeof(struct ipv4_hdr); - mbuf->pkt_len = sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + payload_len; - mbuf->data_len = sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr) + payload_len; + mbuf->l2_len = sizeof(struct rte_ether_hdr); + mbuf->l3_len = sizeof(struct rte_ipv4_hdr); + mbuf->pkt_len = sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + payload_len; + mbuf->data_len = sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr) + payload_len; } /* All values except payload length must be in network order */ -inline void fill_udp_hdr(struct rte_mbuf* mbuf, +inline void fill_rte_udp_hdr(struct rte_mbuf* mbuf, const dpdk_port* port, - uint32_t dst_ipv4_addr, + uint32_t dst_rte_ipv4_addr, uint16_t src_port, uint16_t dst_port, uint32_t payload_len) { - struct ether_hdr* eth_hdr; - struct ipv4_hdr* ip_hdr; - struct udp_hdr* tx_hdr; + struct rte_ether_hdr* eth_hdr; + struct rte_ipv4_hdr* ip_hdr; + struct rte_udp_hdr* tx_hdr; - fill_ipv4_hdr( - mbuf, port, dst_ipv4_addr, IPPROTO_UDP, sizeof(struct udp_hdr) + payload_len); + fill_rte_ipv4_hdr( + mbuf, port, dst_rte_ipv4_addr, IPPROTO_UDP, sizeof(struct rte_udp_hdr) + payload_len); - eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr*); - ip_hdr = (struct ipv4_hdr*)ð_hdr[1]; - tx_hdr = (struct udp_hdr*)&ip_hdr[1]; + eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr*); + ip_hdr = (struct rte_ipv4_hdr*)ð_hdr[1]; + tx_hdr = (struct rte_udp_hdr*)&ip_hdr[1]; tx_hdr->src_port = src_port; tx_hdr->dst_port = dst_port; tx_hdr->dgram_len = rte_cpu_to_be_16(8 + payload_len); tx_hdr->dgram_cksum = 0; - mbuf->l4_len = sizeof(struct udp_hdr); + mbuf->l4_len = sizeof(struct rte_udp_hdr); } //! Return an IPv4 address (numeric, in network order) into a string inline std::string ipv4_num_to_str(const uint32_t ip_addr) { char addr_str[INET_ADDRSTRLEN]; - struct in_addr ipv4_addr; - ipv4_addr.s_addr = ip_addr; - inet_ntop(AF_INET, &ipv4_addr, addr_str, sizeof(addr_str)); + struct in_addr rte_ipv4_addr; + rte_ipv4_addr.s_addr = ip_addr; + inet_ntop(AF_INET, &rte_ipv4_addr, addr_str, sizeof(addr_str)); return std::string(addr_str); } -inline std::string eth_addr_to_string(const struct ether_addr mac_addr) +inline std::string eth_addr_to_string(const struct rte_ether_addr mac_addr) { auto mac_stream = boost::format("%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"); mac_stream % (uint32_t)mac_addr.addr_bytes[0] % (uint32_t)mac_addr.addr_bytes[1] diff --git a/host/lib/include/uhdlib/transport/dpdk_io_service.hpp b/host/lib/include/uhdlib/transport/dpdk_io_service.hpp index 223bed249..a10cd92ab 100644 --- a/host/lib/include/uhdlib/transport/dpdk_io_service.hpp +++ b/host/lib/include/uhdlib/transport/dpdk_io_service.hpp @@ -160,7 +160,7 @@ private: * \param ip the IPv4 address for which the caller is seeking a MAC address */ int _send_arp_request( - dpdk::dpdk_port* port, dpdk::queue_id_t queue, dpdk::ipv4_addr ip); + dpdk::dpdk_port* port, dpdk::queue_id_t queue, dpdk::rte_ipv4_addr ip); /*! * Helper function for I/O thread to process an ARP request/reply @@ -170,7 +170,7 @@ private: * \param arp_frame a pointer to the ARP frame */ int _process_arp( - dpdk::dpdk_port* port, dpdk::queue_id_t queue_id, struct arp_hdr* arp_frame); + dpdk::dpdk_port* port, dpdk::queue_id_t queue_id, struct rte_arp_hdr* arp_frame); /*! * Helper function for I/O thread to process an IPv4 packet @@ -179,7 +179,7 @@ private: * \param mbuf a pointer to the packet buffer container * \param pkt a pointer to the IPv4 header of the packet */ - int _process_ipv4(dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct ipv4_hdr* pkt); + int _process_ipv4(dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct rte_ipv4_hdr* pkt); /*! * Helper function for I/O thread to process an IPv4 packet @@ -191,7 +191,7 @@ private: * IPv4 address */ int _process_udp( - dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct udp_hdr* pkt, bool bcast); + dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct rte_udp_hdr* pkt, bool bcast); /*! * Helper function to get a unique client ID diff --git a/host/lib/include/uhdlib/transport/udp_dpdk_link.hpp b/host/lib/include/uhdlib/transport/udp_dpdk_link.hpp index 305d35319..3fce165f0 100644 --- a/host/lib/include/uhdlib/transport/udp_dpdk_link.hpp +++ b/host/lib/include/uhdlib/transport/udp_dpdk_link.hpp @@ -120,9 +120,9 @@ public: * * \param mac the remote host's MAC address */ - inline void set_remote_mac(struct ether_addr& mac) + inline void set_remote_mac(struct rte_ether_addr& mac) { - ether_addr_copy(&mac, &_remote_mac); + rte_ether_addr_copy(&mac, &_remote_mac); } /*! @@ -130,9 +130,9 @@ public: * * \param mac Where to write the MAC address */ - inline void get_remote_mac(struct ether_addr& dst) + inline void get_remote_mac(struct rte_ether_addr& dst) { - ether_addr_copy(&_remote_mac, &dst); + rte_ether_addr_copy(&_remote_mac, &dst); } /*! @@ -244,7 +244,7 @@ private: //! Remote IPv4 address, in network order uint32_t _remote_ipv4; //! Remote host's MAC address - struct ether_addr _remote_mac; + struct rte_ether_addr _remote_mac; //! Number of recv frames is not validated size_t _num_recv_frames; //! Maximum bytes of UDP payload data in recv frame |