Skip to content

Commit 2debc5f

Browse files
author
Pavel Siska
committed
ipfixprobe - introduce input DPDK plugin
1 parent f59f7ea commit 2debc5f

18 files changed

+123
-200
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ include(cmake/installation.cmake)
1212

1313
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
1414

15+
option(ENABLE_INPUT_DPDK "Enable build of input DPDK plugin" ON)
16+
1517
set(CMAKE_C_STANDARD 11)
1618
set(CMAKE_C_STANDARD_REQUIRED ON)
1719
set(CMAKE_C_EXTENSIONS ON)

cmake/dependencies.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ find_package(PkgConfig REQUIRED)
44
find_package(Threads REQUIRED)
55
find_package(Atomic REQUIRED)
66
find_package(Unwind REQUIRED)
7+
8+
if (ENABLE_INPUT_DPDK)
9+
pkg_check_modules(DPDK REQUIRED libdpdk)
10+
endif()

src/plugins/input/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_subdirectory(parser)
22
add_subdirectory(pcap)
33
add_subdirectory(raw)
4+
add_subdirectory(dpdk)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
project(ipfixprobe-input-dpdk VERSION 1.0.0 DESCRIPTION "ipfixprobe-input-dpdk plugin")
2+
3+
add_library(ipfixprobe-input-dpdk MODULE
4+
src/dpdk.cpp
5+
src/dpdkDevice.cpp
6+
src/dpdkDevice.hpp
7+
src/dpdk.hpp
8+
src/dpdkMbuf.cpp
9+
src/dpdkMbuf.hpp
10+
src/dpdkPortTelemetry.cpp
11+
src/dpdkPortTelemetry.hpp
12+
src/dpdkTelemetry.cpp
13+
src/dpdkTelemetry.hpp
14+
src/dpdk-ring.cpp
15+
src/dpdk-ring.hpp
16+
)
17+
18+
set_target_properties(ipfixprobe-input-dpdk PROPERTIES
19+
CXX_VISIBILITY_PRESET hidden
20+
VISIBILITY_INLINES_HIDDEN YES
21+
)
22+
23+
target_include_directories(ipfixprobe-input-dpdk PRIVATE
24+
${DPDK_INCLUDE_DIRS}
25+
${CMAKE_SOURCE_DIR}/include/
26+
${CMAKE_SOURCE_DIR}/src/plugins/input/parser
27+
)
28+
29+
target_compile_options(ipfixprobe-input-dpdk PRIVATE ${DPDK_CFLAGS_OTHER})
30+
31+
target_link_libraries(ipfixprobe-input-dpdk PRIVATE
32+
ipfixprobe-parser
33+
${DPDK_LIBRARIES}
34+
)
35+
36+
install(TARGETS ipfixprobe-input-dpdk
37+
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixprobe/input/"
38+
)

src/plugins/input/dpdk/README.md

Whitespace-only changes.
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,42 @@
11
/**
2-
* \file dpdk-ring.cpp
3-
* \brief DPDK ring input interface for ipfixprobe (secondary DPDK app).
4-
* \author Jaroslav Pesek <[email protected]>
5-
* \date 2023
6-
*/
7-
/*
8-
* Copyright (C) 2023 CESNET
9-
*
10-
* LICENSE TERMS
2+
* @file
3+
* @brief DPDK ring input interface for ipfixprobe (secondary DPDK app).
4+
* @author Pavel Siska <[email protected]>
5+
* @author Jaroslav Pesek <[email protected]>
6+
* @date 2025
117
*
12-
* Redistribution and use in source and binary forms, with or without
13-
* modification, are permitted provided that the following conditions
14-
* are met:
15-
* 1. Redistributions of source code must retain the above copyright
16-
* notice, this list of conditions and the following disclaimer.
17-
* 2. Redistributions in binary form must reproduce the above copyright
18-
* notice, this list of conditions and the following disclaimer in
19-
* the documentation and/or other materials provided with the
20-
* distribution.
21-
* 3. Neither the name of the Company nor the names of its contributors
22-
* may be used to endorse or promote products derived from this
23-
* software without specific prior written permission.
8+
* Copyright (c) 2025 CESNET
249
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2511
*/
26-
#include "dpdk-ring.h"
2712

13+
#include "dpdk-ring.hpp"
2814
#include "parser.hpp"
2915

3016
#include <cstring>
3117
#include <mutex>
3218

19+
#include <ipfixprobe/pluginFactory/pluginManifest.hpp>
20+
#include <ipfixprobe/pluginFactory/pluginRegistrar.hpp>
3321
#include <rte_eal.h>
3422
#include <rte_errno.h>
3523
#include <rte_ethdev.h>
3624
#include <rte_version.h>
3725
#include <unistd.h>
3826

3927
namespace ipxp {
40-
__attribute__((constructor)) static void register_this_plugin()
41-
{
42-
static PluginRecord rec = PluginRecord("dpdk-ring", []() { return new DpdkRingReader(); });
43-
register_plugin(&rec);
44-
}
28+
29+
static const PluginManifest dpdkRingPluginManifest = {
30+
.name = "dpdk-ring",
31+
.description = "Input plugin for reading packets using DPDK ring.",
32+
.pluginVersion = "1.0.0",
33+
.apiVersion = "1.0.0",
34+
.usage =
35+
[]() {
36+
DpdkRingOptParser parser;
37+
parser.usage(std::cout);
38+
},
39+
};
4540

4641
DpdkRingCore* DpdkRingCore::m_instance = nullptr;
4742

@@ -108,10 +103,11 @@ void DpdkRingCore::configureEal(const std::string& ealParams)
108103
}
109104
}
110105

111-
DpdkRingReader::DpdkRingReader()
106+
DpdkRingReader::DpdkRingReader(const std::string& params)
112107
: m_dpdkRingCore(DpdkRingCore::getInstance())
113108
{
114109
pkts_read_ = 0;
110+
init(params.c_str());
115111
}
116112

117113
DpdkRingReader::~DpdkRingReader()
@@ -270,4 +266,7 @@ void DpdkRingReader::prefetchPackets()
270266
}
271267
}
272268

269+
static const PluginRegistrar<DpdkRingReader, InputPluginFactory>
270+
dpdkRingRegistrar(dpdkRingPluginManifest);
271+
273272
} // namespace ipxp
Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,27 @@
11
/**
2-
* \file dpdk-ring.h
3-
* \brief DPDK ring input interface for ipfixprobe (secondary DPDK app).
4-
* \author Jaroslav Pesek <[email protected]>
5-
* \date 2023
6-
*/
7-
/*
8-
* Copyright (C) 2023 CESNET
9-
*
10-
* LICENSE TERMS
2+
* @file
3+
* @brief DPDK ring input interface for ipfixprobe (secondary DPDK app).
4+
* @author Pavel Siska <[email protected]>
5+
* @author Jaroslav Pesek <[email protected]>
6+
* @date 2025
117
*
12-
* Redistribution and use in source and binary forms, with or without
13-
* modification, are permitted provided that the following conditions
14-
* are met:
15-
* 1. Redistributions of source code must retain the above copyright
16-
* notice, this list of conditions and the following disclaimer.
17-
* 2. Redistributions in binary form must reproduce the above copyright
18-
* notice, this list of conditions and the following disclaimer in
19-
* the documentation and/or other materials provided with the
20-
* distribution.
21-
* 3. Neither the name of the Company nor the names of its contributors
22-
* may be used to endorse or promote products derived from this
23-
* software without specific prior written permission.
8+
* Copyright (c) 2025 CESNET
249
*
10+
* SPDX-License-Identifier: BSD-3-Clause
2511
*/
26-
#ifdef WITH_DPDK
2712

28-
#ifndef IPXP_DPDK_RING_READER_H
29-
#define IPXP_DPDK_RING_READER_H
13+
#pragma once
3014

3115
#include <memory>
3216
#include <sstream>
3317

34-
#include <ipfixprobe/input.hpp>
18+
#include <ipfixprobe/inputPlugin.hpp>
3519
#include <ipfixprobe/utils.hpp>
3620
#include <rte_mbuf.h>
3721
#include <rte_ring.h>
3822

3923
namespace ipxp {
24+
4025
class DpdkRingOptParser : public OptionsParser {
4126
private:
4227
static constexpr size_t DEFAULT_MBUF_BURST_SIZE = 64;
@@ -48,8 +33,8 @@ class DpdkRingOptParser : public OptionsParser {
4833
public:
4934
DpdkRingOptParser()
5035
: OptionsParser(
51-
"dpdk-ring",
52-
"DPDK ring input interface for ipfixprobe (secondary DPDK app).")
36+
"dpdk-ring",
37+
"DPDK ring input interface for ipfixprobe (secondary DPDK app).")
5338
, pkt_buffer_size_(DEFAULT_MBUF_BURST_SIZE)
5439
{
5540
register_option(
@@ -131,7 +116,7 @@ class DpdkRingReader : public InputPlugin {
131116
std::string get_name() const override { return "dpdk-ring"; }
132117

133118
~DpdkRingReader();
134-
DpdkRingReader();
119+
DpdkRingReader(const std::string& params);
135120

136121
void configure_telemetry_dirs(
137122
std::shared_ptr<telemetry::Directory> plugin_dir,
@@ -175,7 +160,5 @@ class DpdkRingReader : public InputPlugin {
175160
bool m_nfbMetadataEnabled = false;
176161
NfbMetadataDynfieldInfo m_nfbMetadataDynfieldInfo = {};
177162
};
178-
} // namespace ipxp
179163

180-
#endif // IPXP_DPDK_RING_READER_H
181-
#endif
164+
} // namespace ipxp

0 commit comments

Comments
 (0)