|
1 | 1 | // GCOVR_EXCL_START
|
2 | 2 |
|
3 |
| -# define LOG_MODULE PcapLogModuleKniDevice |
4 |
| - |
5 |
| -# include "KniDevice.h" |
6 |
| -# include "Logger.h" |
7 |
| -# include "SystemUtils.h" |
8 |
| - |
9 |
| -# include <unistd.h> |
10 |
| -# include <time.h> |
11 |
| -# include <thread> |
12 |
| -# include <sys/ioctl.h> |
13 |
| -# include <net/if.h> |
14 |
| -# include <net/if_arp.h> |
15 |
| - |
16 |
| -# include <rte_version.h> |
17 |
| -# include <rte_mempool.h> |
18 |
| -# include <rte_mbuf.h> |
19 |
| -# include <rte_lcore.h> |
20 |
| -# include <rte_kni.h> |
21 |
| -# include <rte_memory.h> |
22 |
| -# include <rte_branch_prediction.h> |
23 |
| - |
24 |
| -# include <cerrno> |
25 |
| -# include <cstdio> |
26 |
| -# include <cstring> |
27 |
| -# include <algorithm> |
28 |
| - |
29 |
| -# ifndef KNI_MEMPOOL_NAME_PREFIX |
30 |
| -# define KNI_MEMPOOL_NAME_PREFIX "kniMempool" |
31 |
| -# endif |
32 |
| -# ifndef MEMPOOL_CACHE_SIZE |
33 |
| -# define MEMPOOL_CACHE_SIZE 256 |
34 |
| -# endif |
35 |
| -# ifndef MAX_BURST_SIZE |
36 |
| -# define MAX_BURST_SIZE 64 |
37 |
| -# endif |
38 |
| - |
39 |
| -# define CPP_VLA(TYPE, SIZE) (TYPE*)__builtin_alloca(sizeof(TYPE) * SIZE) |
| 3 | +#define LOG_MODULE PcapLogModuleKniDevice |
| 4 | + |
| 5 | +#include "KniDevice.h" |
| 6 | +#include "Logger.h" |
| 7 | +#include "SystemUtils.h" |
| 8 | + |
| 9 | +#include <unistd.h> |
| 10 | +#include <time.h> |
| 11 | +#include <thread> |
| 12 | +#include <sys/ioctl.h> |
| 13 | +#include <net/if.h> |
| 14 | +#include <net/if_arp.h> |
| 15 | + |
| 16 | +#include <rte_version.h> |
| 17 | +#include <rte_mempool.h> |
| 18 | +#include <rte_mbuf.h> |
| 19 | +#include <rte_lcore.h> |
| 20 | +#include <rte_kni.h> |
| 21 | +#include <rte_memory.h> |
| 22 | +#include <rte_branch_prediction.h> |
| 23 | + |
| 24 | +#include <cerrno> |
| 25 | +#include <cstdio> |
| 26 | +#include <cstring> |
| 27 | +#include <algorithm> |
| 28 | + |
| 29 | +#ifndef KNI_MEMPOOL_NAME_PREFIX |
| 30 | +# define KNI_MEMPOOL_NAME_PREFIX "kniMempool" |
| 31 | +#endif |
| 32 | +#ifndef MEMPOOL_CACHE_SIZE |
| 33 | +# define MEMPOOL_CACHE_SIZE 256 |
| 34 | +#endif |
| 35 | +#ifndef MAX_BURST_SIZE |
| 36 | +# define MAX_BURST_SIZE 64 |
| 37 | +#endif |
| 38 | + |
| 39 | +#define CPP_VLA(TYPE, SIZE) (TYPE*)__builtin_alloca(sizeof(TYPE) * SIZE) |
40 | 40 |
|
41 | 41 | namespace pcpp
|
42 | 42 | {
|
@@ -117,17 +117,17 @@ namespace pcpp
|
117 | 117 | {
|
118 | 118 | return oldState = KniDevice::LINK_ERROR;
|
119 | 119 | }
|
120 |
| -# if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) |
| 120 | +#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0) |
121 | 121 | oldState = (KniDevice::KniLinkState)rte_kni_update_link(kni, state);
|
122 | 122 | if (oldState == KniDevice::LINK_ERROR)
|
123 | 123 | { //? NOTE(echo-Mike): Not LOG_ERROR because will generate a lot of junk messages on some DPDK versions
|
124 | 124 | PCPP_LOG_DEBUG("DPDK KNI Failed to update links state for device '" << deviceName << "'");
|
125 | 125 | }
|
126 |
| -# else |
| 126 | +#else |
127 | 127 | // To avoid compiler warnings
|
128 | 128 | (void)kni;
|
129 | 129 | (void)deviceName;
|
130 |
| -# endif |
| 130 | +#endif |
131 | 131 | return oldState;
|
132 | 132 | }
|
133 | 133 |
|
@@ -173,30 +173,30 @@ namespace pcpp
|
173 | 173 | kniConf.core_id = conf.kthreadCoreId;
|
174 | 174 | kniConf.mbuf_size = RTE_MBUF_DEFAULT_BUF_SIZE;
|
175 | 175 | kniConf.force_bind = conf.bindKthread ? 1 : 0;
|
176 |
| -# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0) |
| 176 | +#if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0) |
177 | 177 | if (conf.mac != MacAddress::Zero)
|
178 | 178 | conf.mac.copyTo((uint8_t*)kniConf.mac_addr);
|
179 | 179 | kniConf.mtu = conf.mtu;
|
180 |
| -# endif |
| 180 | +#endif |
181 | 181 |
|
182 | 182 | kniOps.port_id = conf.portId;
|
183 |
| -# if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0) |
| 183 | +#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 0) |
184 | 184 | if (conf.callbacks != nullptr)
|
185 | 185 | {
|
186 | 186 | kniOps.change_mtu = conf.callbacks->change_mtu;
|
187 | 187 | kniOps.config_network_if = conf.callbacks->config_network_if;
|
188 |
| -# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0) |
| 188 | +# if RTE_VERSION >= RTE_VERSION_NUM(18, 2, 0, 0) |
189 | 189 | kniOps.config_mac_address = conf.callbacks->config_mac_address;
|
190 | 190 | kniOps.config_promiscusity = conf.callbacks->config_promiscusity;
|
191 |
| -# endif |
| 191 | +# endif |
192 | 192 | }
|
193 |
| -# else |
| 193 | +#else |
194 | 194 | if (conf.oldCallbacks != nullptr)
|
195 | 195 | {
|
196 | 196 | kniOps.change_mtu = conf.oldCallbacks->change_mtu;
|
197 | 197 | kniOps.config_network_if = conf.oldCallbacks->config_network_if;
|
198 | 198 | }
|
199 |
| -# endif |
| 199 | +#endif |
200 | 200 |
|
201 | 201 | m_Device = rte_kni_alloc(m_MBufMempool, &kniConf, &kniOps);
|
202 | 202 | if (m_Device == nullptr)
|
|
0 commit comments