Skip to content

Commit a305d46

Browse files
committed
Update DpdkDriver to use the new API introduced in the previous commit
- Reenable DPDK in CMakeLists.txt - Initialize an ARP table at driver startup using the content of /proc/net/arp - Select eth port via the symbolic name of the network interface (e.g., eno1d1) (the current implementation uses ioctl to obtain the IP and MAC addresses of a network interface) - Add a system test for DPDK driver: test/dpdk_test.cc
1 parent 9d4e95e commit a305d46

File tree

14 files changed

+435
-314
lines changed

14 files changed

+435
-314
lines changed

CMakeLists.txt

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
1313
find_package(Doxygen OPTIONAL_COMPONENTS dot mscgen dia)
1414

1515
# Network Interface library (https://www.dpdk.org/)
16-
# find_package(Dpdk REQUIRED)
16+
find_package(Dpdk REQUIRED)
1717

1818
# Source control tool; needed to download external libraries.
1919
find_package(Git REQUIRED)
@@ -135,34 +135,34 @@ target_compile_options(FakeDriver
135135
)
136136

137137
## lib DpdkDriver ##############################################################
138-
#add_library(DpdkDriver
139-
# src/Drivers/DPDK/DpdkDriver.cc
140-
# src/Drivers/DPDK/DpdkDriverImpl.cc
141-
# src/Drivers/DPDK/MacAddress.cc
142-
#)
143-
#add_library(Homa::DpdkDriver ALIAS DpdkDriver)
144-
#target_include_directories(DpdkDriver
145-
# PUBLIC
146-
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
147-
# $<INSTALL_INTERFACE:include>
148-
# PRIVATE
149-
# ${CMAKE_CURRENT_SOURCE_DIR}/src
150-
#)
151-
#target_link_libraries(DpdkDriver
152-
# PRIVATE
153-
# Dpdk::Dpdk
154-
# PUBLIC
155-
# Homa
156-
#)
157-
#target_compile_features(DpdkDriver
158-
# PUBLIC
159-
# cxx_std_11
160-
#)
161-
#target_compile_options(DpdkDriver
162-
# PRIVATE
163-
# -Wall
164-
# -Wextra
165-
#)
138+
add_library(DpdkDriver
139+
src/Drivers/DPDK/DpdkDriver.cc
140+
src/Drivers/DPDK/DpdkDriverImpl.cc
141+
src/Drivers/DPDK/MacAddress.cc
142+
)
143+
add_library(Homa::DpdkDriver ALIAS DpdkDriver)
144+
target_include_directories(DpdkDriver
145+
PUBLIC
146+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
147+
$<INSTALL_INTERFACE:include>
148+
PRIVATE
149+
${CMAKE_CURRENT_SOURCE_DIR}/src
150+
)
151+
target_link_libraries(DpdkDriver
152+
PRIVATE
153+
Dpdk::Dpdk
154+
PUBLIC
155+
Homa
156+
)
157+
target_compile_features(DpdkDriver
158+
PUBLIC
159+
cxx_std_11
160+
)
161+
target_compile_options(DpdkDriver
162+
PRIVATE
163+
-Wall
164+
-Wextra
165+
)
166166

167167
################################################################################
168168
## Tests #######################################################################
@@ -195,8 +195,7 @@ endif()
195195
## Install & Export ############################################################
196196
################################################################################
197197

198-
#install(TARGETS Homa DpdkDriver FakeDriver EXPORT HomaTargets
199-
install(TARGETS Homa FakeDriver EXPORT HomaTargets
198+
install(TARGETS Homa DpdkDriver FakeDriver EXPORT HomaTargets
200199
LIBRARY DESTINATION lib
201200
ARCHIVE DESTINATION lib
202201
RUNTIME DESTINATION bin
@@ -275,11 +274,11 @@ target_sources(unit_test
275274
target_link_libraries(unit_test FakeDriver)
276275

277276
#DPDK Tests
278-
#target_sources(unit_test
279-
# PUBLIC
280-
# ${CMAKE_CURRENT_SOURCE_DIR}/src/Drivers/DPDK/MacAddressTest.cc
281-
#)
282-
#target_link_libraries(unit_test DpdkDriver)
277+
target_sources(unit_test
278+
PUBLIC
279+
${CMAKE_CURRENT_SOURCE_DIR}/src/Drivers/DPDK/MacAddressTest.cc
280+
)
281+
target_link_libraries(unit_test DpdkDriver)
283282

284283
target_link_libraries(unit_test gmock_main)
285284
# -fno-access-control allows access to private members for testing

include/Homa/Drivers/DPDK/DpdkDriver.h

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class DpdkDriver : public Driver {
5353
* has exclusive access to DPDK. Note: This call will initialize the DPDK
5454
* EAL with default values.
5555
*
56-
* @param port
57-
* Selects which physical port to use for communication.
56+
* @param ifname
57+
* Selects which network interface to use for communication.
5858
* @param config
5959
* Optional configuration parameters (see Config).
6060
* @throw DriverInitFailure
6161
* Thrown if DpdkDriver fails to initialize for any reason.
6262
*/
63-
DpdkDriver(int port, const Config* const config = nullptr);
63+
DpdkDriver(const char* ifname, const Config* const config = nullptr);
6464

6565
/**
6666
* Construct a DpdkDriver and initialize the DPDK EAL using the provided
@@ -75,7 +75,7 @@ class DpdkDriver : public Driver {
7575
* overriding the default affinity set by rte_eal_init().
7676
*
7777
* @param port
78-
* Selects which physical port to use for communication.
78+
* Selects which network interface to use for communication.
7979
* @param argc
8080
* Parameter passed to rte_eal_init().
8181
* @param argv
@@ -85,7 +85,7 @@ class DpdkDriver : public Driver {
8585
* @throw DriverInitFailure
8686
* Thrown if DpdkDriver fails to initialize for any reason.
8787
*/
88-
DpdkDriver(int port, int argc, char* argv[],
88+
DpdkDriver(const char* ifname, int argc, char* argv[],
8989
const Config* const config = nullptr);
9090

9191
/// Used to signal to the DpdkDriver constructor that the DPDK EAL should
@@ -101,7 +101,7 @@ class DpdkDriver : public Driver {
101101
* called before calling this constructor.
102102
*
103103
* @param port
104-
* Selects which physical port to use for communication.
104+
* Selects which network interface to use for communication.
105105
* @param _
106106
* Parameter is used only to define this constructors alternate
107107
* signature.
@@ -110,29 +110,20 @@ class DpdkDriver : public Driver {
110110
* @throw DriverInitFailure
111111
* Thrown if DpdkDriver fails to initialize for any reason.
112112
*/
113-
DpdkDriver(int port, NoEalInit _, const Config* const config = nullptr);
113+
DpdkDriver(const char* ifname, NoEalInit _,
114+
const Config* const config = nullptr);
114115

115116
/**
116117
* DpdkDriver Destructor.
117118
*/
118119
virtual ~DpdkDriver();
119120

120-
/// See Driver::getAddress()
121-
virtual Address getAddress(std::string const* const addressString);
122-
virtual Address getAddress(WireFormatAddress const* const wireAddress);
123-
124-
/// See Driver::addressToString()
125-
virtual std::string addressToString(const Address address);
126-
127-
/// See Driver::addressToWireFormat()
128-
virtual void addressToWireFormat(const Address address,
129-
WireFormatAddress* wireAddress);
130-
131121
/// See Driver::allocPacket()
132122
virtual Packet* allocPacket();
133123

134124
/// See Driver::sendPacket()
135-
virtual void sendPacket(Packet* packet);
125+
virtual void sendPacket(Packet* packet, IpAddress destination,
126+
int priority);
136127

137128
/// See Driver::cork()
138129
virtual void cork();
@@ -157,7 +148,7 @@ class DpdkDriver : public Driver {
157148
virtual uint32_t getBandwidth();
158149

159150
/// See Driver::getLocalAddress()
160-
virtual Driver::Address getLocalAddress();
151+
virtual IpAddress getLocalAddress();
161152

162153
/// See Driver::getQueuedBytes();
163154
virtual uint32_t getQueuedBytes();

include/Homa/Util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ downCast(const Large& large)
5757

5858
std::string demangle(const char* name);
5959
std::string hexDump(const void* buf, uint64_t bytes);
60+
std::string ipToString(uint32_t ip);
61+
uint32_t stringToIp(const char* ip);
6062

6163
/**
6264
* This class is used to temporarily release lock in a safe fashion. Creating

src/Drivers/DPDK/DpdkDriver.cc

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,21 @@ namespace Homa {
2121
namespace Drivers {
2222
namespace DPDK {
2323

24-
DpdkDriver::DpdkDriver(int port, const Config* const config)
25-
: pImpl(new Impl(port, config))
24+
DpdkDriver::DpdkDriver(const char* ifname, const Config* const config)
25+
: pImpl(new Impl(ifname, config))
2626
{}
2727

28-
DpdkDriver::DpdkDriver(int port, int argc, char* argv[],
28+
DpdkDriver::DpdkDriver(const char* ifname, int argc, char* argv[],
2929
const Config* const config)
30-
: pImpl(new Impl(port, argc, argv, config))
30+
: pImpl(new Impl(ifname, argc, argv, config))
3131
{}
3232

33-
DpdkDriver::DpdkDriver(int port, NoEalInit _, const Config* const config)
34-
: pImpl(new Impl(port, _, config))
33+
DpdkDriver::DpdkDriver(const char* ifname, NoEalInit _, const Config* const config)
34+
: pImpl(new Impl(ifname, _, config))
3535
{}
3636

3737
DpdkDriver::~DpdkDriver() = default;
3838

39-
/// See Driver::getAddress()
40-
Driver::Address
41-
DpdkDriver::getAddress(std::string const* const addressString)
42-
{
43-
return pImpl->getAddress(addressString);
44-
}
45-
46-
/// See Driver::getAddress()
47-
Driver::Address
48-
DpdkDriver::getAddress(WireFormatAddress const* const wireAddress)
49-
{
50-
return pImpl->getAddress(wireAddress);
51-
}
52-
53-
/// See Driver::addressToString()
54-
std::string
55-
DpdkDriver::addressToString(const Address address)
56-
{
57-
return pImpl->addressToString(address);
58-
}
59-
60-
/// See Driver::addressToWireFormat()
61-
void
62-
DpdkDriver::addressToWireFormat(const Address address,
63-
WireFormatAddress* wireAddress)
64-
{
65-
pImpl->addressToWireFormat(address, wireAddress);
66-
}
67-
6839
/// See Driver::allocPacket()
6940
Driver::Packet*
7041
DpdkDriver::allocPacket()
@@ -74,9 +45,9 @@ DpdkDriver::allocPacket()
7445

7546
/// See Driver::sendPacket()
7647
void
77-
DpdkDriver::sendPacket(Packet* packet)
48+
DpdkDriver::sendPacket(Packet* packet, IpAddress destination, int priority)
7849
{
79-
return pImpl->sendPacket(packet);
50+
return pImpl->sendPacket(packet, destination, priority);
8051
}
8152

8253
/// See Driver::cork()
@@ -128,7 +99,7 @@ DpdkDriver::getBandwidth()
12899
}
129100

130101
/// See Driver::getLocalAddress()
131-
Driver::Address
102+
IpAddress
132103
DpdkDriver::getLocalAddress()
133104
{
134105
return pImpl->getLocalAddress();

0 commit comments

Comments
 (0)