aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/cmake/Modules/FindDPDK.cmake2
-rw-r--r--host/lib/CMakeLists.txt2
-rw-r--r--host/lib/include/uhdlib/transport/dpdk/arp.hpp6
-rw-r--r--host/lib/include/uhdlib/transport/dpdk/common.hpp32
-rw-r--r--host/lib/include/uhdlib/transport/dpdk/udp.hpp56
-rw-r--r--host/lib/include/uhdlib/transport/dpdk_io_service.hpp8
-rw-r--r--host/lib/include/uhdlib/transport/udp_dpdk_link.hpp10
-rw-r--r--host/lib/transport/dpdk_simple.cpp6
-rw-r--r--host/lib/transport/udp_dpdk_link.cpp20
-rw-r--r--host/lib/transport/uhd-dpdk/dpdk_common.cpp50
-rw-r--r--host/lib/transport/uhd-dpdk/dpdk_io_service.cpp62
-rw-r--r--host/tests/dpdk_port_test.cpp4
12 files changed, 129 insertions, 129 deletions
diff --git a/host/cmake/Modules/FindDPDK.cmake b/host/cmake/Modules/FindDPDK.cmake
index 90240e61d..4f1426dfd 100644
--- a/host/cmake/Modules/FindDPDK.cmake
+++ b/host/cmake/Modules/FindDPDK.cmake
@@ -39,7 +39,7 @@ else()
endif()
find_package(PkgConfig)
-PKG_CHECK_MODULES(PC_DPDK QUIET libdpdk>=18.11)
+PKG_CHECK_MODULES(PC_DPDK QUIET libdpdk>=19.11)
find_path (DPDK_VERSION_INCLUDE_DIR rte_version.h
HINTS ${PC_DPDK_INCLUDE_DIRS}
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index 78cce3e97..309a5bf72 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -60,7 +60,7 @@ endmacro(INCLUDE_SUBDIRECTORY)
message(STATUS "")
# Dependencies
find_package(LIBUSB)
-find_package(DPDK 18.11 EXACT)
+find_package(DPDK 19.11...20.11)
LIBUHD_REGISTER_COMPONENT("USB" ENABLE_USB ON "ENABLE_LIBUHD;LIBUSB_FOUND" OFF OFF)
# Devices
LIBUHD_REGISTER_COMPONENT("B100" ENABLE_B100 ON "ENABLE_LIBUHD;ENABLE_USB" OFF OFF)
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*)&eth_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*)&eth_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*)&eth_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*)&eth_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
diff --git a/host/lib/transport/dpdk_simple.cpp b/host/lib/transport/dpdk_simple.cpp
index 835885cba..0e52d425d 100644
--- a/host/lib/transport/dpdk_simple.cpp
+++ b/host/lib/transport/dpdk_simple.cpp
@@ -129,9 +129,9 @@ public:
// Extract the sender's address. This is only possible because we know
// the memory layout of the buff
- struct udp_hdr* udp_hdr_end = (struct udp_hdr*)buff->data();
- struct ipv4_hdr* ip_hdr_end = (struct ipv4_hdr*)(&udp_hdr_end[-1]);
- struct ipv4_hdr* ip_hdr = (struct ipv4_hdr*)(&ip_hdr_end[-1]);
+ struct rte_udp_hdr* rte_udp_hdr_end = (struct rte_udp_hdr*)buff->data();
+ struct rte_ipv4_hdr* ip_hdr_end = (struct rte_ipv4_hdr*)(&rte_udp_hdr_end[-1]);
+ struct rte_ipv4_hdr* ip_hdr = (struct rte_ipv4_hdr*)(&ip_hdr_end[-1]);
_last_recv_addr = ip_hdr->src_addr;
// Extract the buffer data
diff --git a/host/lib/transport/udp_dpdk_link.cpp b/host/lib/transport/udp_dpdk_link.cpp
index dc56de43c..b2fe55e24 100644
--- a/host/lib/transport/udp_dpdk_link.cpp
+++ b/host/lib/transport/udp_dpdk_link.cpp
@@ -101,13 +101,13 @@ udp_dpdk_link::sptr udp_dpdk_link::make(const dpdk::port_id_t port_id,
void udp_dpdk_link::enqueue_recv_mbuf(struct rte_mbuf* mbuf)
{
// Get packet size
- struct udp_hdr* hdr = rte_pktmbuf_mtod_offset(
- mbuf, struct udp_hdr*, sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr));
- size_t packet_size = rte_be_to_cpu_16(hdr->dgram_len) - sizeof(struct udp_hdr);
+ struct rte_udp_hdr* hdr = rte_pktmbuf_mtod_offset(
+ mbuf, struct rte_udp_hdr*, sizeof(struct rte_ether_hdr) + sizeof(struct rte_ipv4_hdr));
+ size_t packet_size = rte_be_to_cpu_16(hdr->dgram_len) - sizeof(struct rte_udp_hdr);
// Prepare the dpdk_frame_buff
auto buff = new (rte_mbuf_to_priv(mbuf)) dpdk_frame_buff(mbuf);
buff->header_jump(
- 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));
buff->set_packet_size(packet_size);
// Add the dpdk_frame_buff to the list
if (_recv_buff_head) {
@@ -155,7 +155,7 @@ frame_buff::uptr udp_dpdk_link::get_send_buff(int32_t /*timeout_ms*/)
if (mbuf) {
auto buff = new (rte_mbuf_to_priv(mbuf)) dpdk_frame_buff(mbuf);
buff->header_jump(
- 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));
return frame_buff::uptr(buff);
}
return frame_buff::uptr();
@@ -169,12 +169,12 @@ void udp_dpdk_link::release_send_buff(frame_buff::uptr buff)
if (buff_ptr->packet_size()) {
// Fill in L2 header
auto local_mac = _port->get_mac_addr();
- struct ether_hdr* l2_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr*);
- ether_addr_copy(&_remote_mac, &l2_hdr->d_addr);
- ether_addr_copy(&local_mac, &l2_hdr->s_addr);
- l2_hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+ struct rte_ether_hdr* l2_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr*);
+ rte_ether_addr_copy(&_remote_mac, &l2_hdr->d_addr);
+ rte_ether_addr_copy(&local_mac, &l2_hdr->s_addr);
+ l2_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
// Fill in L3 and L4 headers
- dpdk::fill_udp_hdr(mbuf,
+ dpdk::fill_rte_udp_hdr(mbuf,
_port,
_remote_ipv4,
_local_port,
diff --git a/host/lib/transport/uhd-dpdk/dpdk_common.cpp b/host/lib/transport/uhd-dpdk/dpdk_common.cpp
index 78b29513a..7ad124408 100644
--- a/host/lib/transport/uhd-dpdk/dpdk_common.cpp
+++ b/host/lib/transport/uhd-dpdk/dpdk_common.cpp
@@ -42,14 +42,14 @@ inline char* eal_add_opt(
return ptr;
}
-inline void separate_ipv4_addr(
- const std::string ipv4, uint32_t& ipv4_addr, uint32_t& netmask)
+inline void separate_rte_ipv4_addr(
+ const std::string ipv4, uint32_t& rte_ipv4_addr, uint32_t& netmask)
{
std::vector<std::string> result;
boost::algorithm::split(
result, ipv4, [](const char& in) { return in == '/'; }, boost::token_compress_on);
UHD_ASSERT_THROW(result.size() == 2);
- ipv4_addr = (uint32_t)inet_addr(result[0].c_str());
+ rte_ipv4_addr = (uint32_t)inet_addr(result[0].c_str());
int netbits = std::atoi(result[1].c_str());
netmask = htonl(0xffffffff << (32 - netbits));
}
@@ -61,10 +61,10 @@ dpdk_port::uptr dpdk_port::make(port_id_t port,
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)
{
return std::make_unique<dpdk_port>(
- port, mtu, num_queues, num_desc, rx_pktbuf_pool, tx_pktbuf_pool, ipv4_address);
+ port, mtu, num_queues, num_desc, rx_pktbuf_pool, tx_pktbuf_pool, rte_ipv4_address);
}
dpdk_port::dpdk_port(port_id_t port,
@@ -73,7 +73,7 @@ dpdk_port::dpdk_port(port_id_t port,
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)
: _port(port)
, _mtu(mtu)
, _num_queues(num_queues)
@@ -94,7 +94,7 @@ dpdk_port::dpdk_port(port_id_t port,
_mtu = actual_mtu;
}
- separate_ipv4_addr(ipv4_address, _ipv4, _netmask);
+ separate_rte_ipv4_addr(rte_ipv4_address, _ipv4, _netmask);
/* Set hardware offloads */
struct rte_eth_dev_info dev_info;
@@ -251,11 +251,11 @@ uint16_t dpdk_port::alloc_udp_port(uint16_t udp_port)
return rte_cpu_to_be_16(port_selected);
}
-int dpdk_port::_arp_reply(queue_id_t queue_id, struct arp_hdr* arp_req)
+int dpdk_port::_arp_reply(queue_id_t queue_id, struct rte_arp_hdr* arp_req)
{
struct rte_mbuf* mbuf;
- struct ether_hdr* hdr;
- struct arp_hdr* arp_frame;
+ struct rte_ether_hdr* hdr;
+ struct rte_arp_hdr* arp_frame;
mbuf = rte_pktmbuf_alloc(_tx_pktbuf_pool);
if (unlikely(mbuf == NULL)) {
@@ -263,21 +263,21 @@ int dpdk_port::_arp_reply(queue_id_t queue_id, struct arp_hdr* arp_req)
return -ENOMEM;
}
- hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr*);
- arp_frame = (struct arp_hdr*)&hdr[1];
+ hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr*);
+ arp_frame = (struct rte_arp_hdr*)&hdr[1];
- ether_addr_copy(&arp_req->arp_data.arp_sha, &hdr->d_addr);
- ether_addr_copy(&_mac_addr, &hdr->s_addr);
- hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_ARP);
+ rte_ether_addr_copy(&arp_req->arp_data.arp_sha, &hdr->d_addr);
+ rte_ether_addr_copy(&_mac_addr, &hdr->s_addr);
+ hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
- arp_frame->arp_hrd = rte_cpu_to_be_16(ARP_HRD_ETHER);
- arp_frame->arp_pro = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
- arp_frame->arp_hln = 6;
- arp_frame->arp_pln = 4;
- arp_frame->arp_op = rte_cpu_to_be_16(ARP_OP_REPLY);
- ether_addr_copy(&_mac_addr, &arp_frame->arp_data.arp_sha);
+ arp_frame->arp_hardware = rte_cpu_to_be_16(RTE_ARP_HRD_ETHER);
+ arp_frame->arp_protocol = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+ arp_frame->arp_hlen = 6;
+ arp_frame->arp_plen = 4;
+ arp_frame->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY);
+ rte_ether_addr_copy(&_mac_addr, &arp_frame->arp_data.arp_sha);
arp_frame->arp_data.arp_sip = _ipv4;
- ether_addr_copy(&hdr->d_addr, &arp_frame->arp_data.arp_tha);
+ rte_ether_addr_copy(&hdr->d_addr, &arp_frame->arp_data.arp_tha);
arp_frame->arp_data.arp_tip = arp_req->arp_data.arp_sip;
mbuf->pkt_len = 42;
@@ -418,7 +418,7 @@ void dpdk_ctx::init(const device_addr_t& user_args)
device_addrs_t nics(num_dpdk_ports);
RTE_ETH_FOREACH_DEV(i)
{
- struct ether_addr mac_addr;
+ struct rte_ether_addr mac_addr;
rte_eth_macaddr_get(i, &mac_addr);
nics[i]["dpdk_mac"] = eth_addr_to_string(mac_addr);
}
@@ -543,11 +543,11 @@ dpdk_port* dpdk_ctx::get_port(port_id_t port) const
return _ports.at(port).get();
}
-dpdk_port* dpdk_ctx::get_port(struct ether_addr mac_addr) const
+dpdk_port* dpdk_ctx::get_port(struct rte_ether_addr mac_addr) const
{
assert(is_init_done());
for (const auto& port : _ports) {
- struct ether_addr port_mac_addr;
+ struct rte_ether_addr port_mac_addr;
rte_eth_macaddr_get(port.first, &port_mac_addr);
for (int j = 0; j < 6; j++) {
if (mac_addr.addr_bytes[j] != port_mac_addr.addr_bytes[j]) {
diff --git a/host/lib/transport/uhd-dpdk/dpdk_io_service.cpp b/host/lib/transport/uhd-dpdk/dpdk_io_service.cpp
index 1fcedca51..4c8fa3f35 100644
--- a/host/lib/transport/uhd-dpdk/dpdk_io_service.cpp
+++ b/host/lib/transport/uhd-dpdk/dpdk_io_service.cpp
@@ -572,7 +572,7 @@ int dpdk_io_service::_service_arp_request(dpdk::wait_req* req)
{
int status = 0;
auto arp_req_data = (struct dpdk::arp_request*)req->data;
- dpdk::ipv4_addr dst_addr = arp_req_data->tpa;
+ dpdk::rte_ipv4_addr dst_addr = arp_req_data->tpa;
auto ctx_sptr = _ctx.lock();
UHD_ASSERT_THROW(ctx_sptr);
dpdk::dpdk_port* port = ctx_sptr->get_port(arp_req_data->port);
@@ -595,7 +595,7 @@ int dpdk_io_service::_service_arp_request(dpdk::wait_req* req)
_send_arp_request(port, 0, arp_req_data->tpa);
} else {
entry = port->_arp_table.at(dst_addr);
- if (is_zero_ether_addr(&entry->mac_addr)) {
+ if (rte_is_zero_ether_addr(&entry->mac_addr)) {
UHD_LOG_TRACE("DPDK::IO_SERVICE",
"ARP: Address in table, but not populated yet. Resending ARP request.");
port->_arp_table.at(dst_addr)->reqs.push_back(req);
@@ -603,7 +603,7 @@ int dpdk_io_service::_service_arp_request(dpdk::wait_req* req)
_send_arp_request(port, 0, arp_req_data->tpa);
} else {
UHD_LOG_TRACE("DPDK::IO_SERVICE", "ARP: Address in table.");
- ether_addr_copy(&entry->mac_addr, &arp_req_data->tha);
+ rte_ether_addr_copy(&entry->mac_addr, &arp_req_data->tha);
status = 0;
}
}
@@ -613,11 +613,11 @@ arp_end:
}
int dpdk_io_service::_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)
{
struct rte_mbuf* mbuf;
- struct ether_hdr* hdr;
- struct arp_hdr* arp_frame;
+ struct rte_ether_hdr* hdr;
+ struct rte_arp_hdr* arp_frame;
mbuf = rte_pktmbuf_alloc(port->get_tx_pktbuf_pool());
if (unlikely(mbuf == NULL)) {
@@ -626,21 +626,21 @@ int dpdk_io_service::_send_arp_request(
return -ENOMEM;
}
- hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr*);
- arp_frame = (struct arp_hdr*)&hdr[1];
+ hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr*);
+ arp_frame = (struct rte_arp_hdr*)&hdr[1];
- memset(hdr->d_addr.addr_bytes, 0xFF, ETHER_ADDR_LEN);
+ memset(hdr->d_addr.addr_bytes, 0xFF, RTE_ETHER_ADDR_LEN);
hdr->s_addr = port->get_mac_addr();
- hdr->ether_type = rte_cpu_to_be_16(ETHER_TYPE_ARP);
+ hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
- arp_frame->arp_hrd = rte_cpu_to_be_16(ARP_HRD_ETHER);
- arp_frame->arp_pro = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
- arp_frame->arp_hln = 6;
- arp_frame->arp_pln = 4;
- arp_frame->arp_op = rte_cpu_to_be_16(ARP_OP_REQUEST);
+ arp_frame->arp_hardware = rte_cpu_to_be_16(RTE_ARP_HRD_ETHER);
+ arp_frame->arp_protocol = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
+ arp_frame->arp_hlen = 6;
+ arp_frame->arp_plen = 4;
+ arp_frame->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REQUEST);
arp_frame->arp_data.arp_sha = port->get_mac_addr();
arp_frame->arp_data.arp_sip = port->get_ipv4();
- memset(arp_frame->arp_data.arp_tha.addr_bytes, 0x00, ETHER_ADDR_LEN);
+ memset(arp_frame->arp_data.arp_tha.addr_bytes, 0x00, RTE_ETHER_ADDR_LEN);
arp_frame->arp_data.arp_tip = ip;
mbuf->pkt_len = 42;
@@ -657,7 +657,7 @@ int dpdk_io_service::_send_arp_request(
/* Do a burst of RX on port */
int dpdk_io_service::_rx_burst(dpdk::dpdk_port* port, dpdk::queue_id_t queue)
{
- struct ether_hdr* hdr;
+ struct rte_ether_hdr* hdr;
char* l2_data;
struct rte_mbuf* bufs[RX_BURST_SIZE];
const uint16_t num_rx =
@@ -668,20 +668,20 @@ int dpdk_io_service::_rx_burst(dpdk::dpdk_port* port, dpdk::queue_id_t queue)
for (int buf = 0; buf < num_rx; buf++) {
uint64_t ol_flags = bufs[buf]->ol_flags;
- hdr = rte_pktmbuf_mtod(bufs[buf], struct ether_hdr*);
+ hdr = rte_pktmbuf_mtod(bufs[buf], struct rte_ether_hdr*);
l2_data = (char*)&hdr[1];
switch (rte_be_to_cpu_16(hdr->ether_type)) {
- case ETHER_TYPE_ARP:
- _process_arp(port, queue, (struct arp_hdr*)l2_data);
+ case RTE_ETHER_TYPE_ARP:
+ _process_arp(port, queue, (struct rte_arp_hdr*)l2_data);
rte_pktmbuf_free(bufs[buf]);
break;
- case ETHER_TYPE_IPv4:
+ case RTE_ETHER_TYPE_IPV4:
if ((ol_flags & PKT_RX_IP_CKSUM_MASK) == PKT_RX_IP_CKSUM_BAD) {
UHD_LOG_WARNING("DPDK::IO_SERVICE", "RX packet has bad IP cksum");
} else if ((ol_flags & PKT_RX_IP_CKSUM_MASK) == PKT_RX_IP_CKSUM_NONE) {
UHD_LOG_WARNING("DPDK::IO_SERVICE", "RX packet missing IP cksum");
} else {
- _process_ipv4(port, bufs[buf], (struct ipv4_hdr*)l2_data);
+ _process_ipv4(port, bufs[buf], (struct rte_ipv4_hdr*)l2_data);
}
break;
default:
@@ -693,10 +693,10 @@ int dpdk_io_service::_rx_burst(dpdk::dpdk_port* port, dpdk::queue_id_t queue)
}
int dpdk_io_service::_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)
{
uint32_t dest_ip = arp_frame->arp_data.arp_sip;
- struct ether_addr dest_addr = arp_frame->arp_data.arp_sha;
+ struct rte_ether_addr dest_addr = arp_frame->arp_data.arp_sha;
UHD_LOG_TRACE("DPDK::IO_SERVICE",
"Processing ARP packet: " << dpdk::ipv4_num_to_str(dest_ip) << " -> "
<< dpdk::eth_addr_to_string(dest_addr));
@@ -709,14 +709,14 @@ int dpdk_io_service::_process_arp(
return -ENOMEM;
}
entry = new (entry) dpdk::arp_entry();
- ether_addr_copy(&dest_addr, &entry->mac_addr);
+ rte_ether_addr_copy(&dest_addr, &entry->mac_addr);
port->_arp_table[dest_ip] = entry;
} else {
entry = port->_arp_table.at(dest_ip);
- ether_addr_copy(&dest_addr, &entry->mac_addr);
+ rte_ether_addr_copy(&dest_addr, &entry->mac_addr);
for (auto req : entry->reqs) {
auto arp_data = (struct dpdk::arp_request*)req->data;
- ether_addr_copy(&dest_addr, &arp_data->tha);
+ rte_ether_addr_copy(&dest_addr, &arp_data->tha);
while (_servq.complete(req) == -ENOBUFS)
;
}
@@ -725,7 +725,7 @@ int dpdk_io_service::_process_arp(
rte_spinlock_unlock(&port->_spinlock);
/* Respond if this was an ARP request */
- if (arp_frame->arp_op == rte_cpu_to_be_16(ARP_OP_REQUEST)
+ if (arp_frame->arp_opcode == rte_cpu_to_be_16(RTE_ARP_OP_REQUEST)
&& arp_frame->arp_data.arp_tip == port->get_ipv4()) {
UHD_LOG_TRACE("DPDK::IO_SERVICE", "Sending ARP reply.");
port->_arp_reply(queue_id, arp_frame);
@@ -735,7 +735,7 @@ int dpdk_io_service::_process_arp(
}
int dpdk_io_service::_process_ipv4(
- dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct ipv4_hdr* pkt)
+ dpdk::dpdk_port* port, struct rte_mbuf* mbuf, struct rte_ipv4_hdr* pkt)
{
bool bcast = port->dst_is_broadcast(pkt->dst_addr);
if (pkt->dst_addr != port->get_ipv4() && !bcast) {
@@ -743,7 +743,7 @@ int dpdk_io_service::_process_ipv4(
return -ENODEV;
}
if (pkt->next_proto_id == IPPROTO_UDP) {
- return _process_udp(port, mbuf, (struct udp_hdr*)&pkt[1], bcast);
+ return _process_udp(port, mbuf, (struct rte_udp_hdr*)&pkt[1], bcast);
}
rte_pktmbuf_free(mbuf);
return -EINVAL;
@@ -751,7 +751,7 @@ int dpdk_io_service::_process_ipv4(
int dpdk_io_service::_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*/)
{
// Get the link
struct dpdk::ipv4_5tuple ht_key = {.flow_type = dpdk::flow_type::FLOW_TYPE_UDP,
diff --git a/host/tests/dpdk_port_test.cpp b/host/tests/dpdk_port_test.cpp
index 323d02e48..4932b167d 100644
--- a/host/tests/dpdk_port_test.cpp
+++ b/host/tests/dpdk_port_test.cpp
@@ -120,10 +120,10 @@ int main(int argc, char** argv)
// Attach link
std::cout << "Attaching UDP send link..." << std::endl;
io_srv->attach_send_link(link);
- struct ether_addr dest_mac;
+ struct rte_ether_addr dest_mac;
link->get_remote_mac(dest_mac);
char mac_str[20];
- ether_format_addr(mac_str, 20, &dest_mac);
+ rte_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;