suricata
util-dpdk.h
Go to the documentation of this file.
1 /* Copyright (C) 2021 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Lukas Sismis <lukas.sismis@gmail.com>
22  */
23 
24 #ifndef UTIL_DPDK_H
25 #define UTIL_DPDK_H
26 
27 #ifdef HAVE_DPDK
28 
29 #include <rte_eal.h>
30 #include <rte_ethdev.h>
31 #ifdef HAVE_DPDK_BOND
32 #include <rte_eth_bond.h>
33 #endif
34 #include <rte_launch.h>
35 #include <rte_lcore.h>
36 #include <rte_log.h>
37 #include <rte_mempool.h>
38 #include <rte_mbuf.h>
39 #include <rte_flow.h>
40 #include <rte_version.h>
41 
42 #if RTE_VERSION < RTE_VERSION_NUM(22, 0, 0, 0)
43 #define RTE_ETH_MQ_RX_RSS ETH_MQ_RX_RSS
44 #endif
45 
46 #if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
47 #define RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE DEV_TX_OFFLOAD_MBUF_FAST_FREE
48 
49 #define RTE_ETH_RX_OFFLOAD_CHECKSUM DEV_RX_OFFLOAD_CHECKSUM
50 
51 #define RTE_ETH_RX_OFFLOAD_VLAN_STRIP DEV_RX_OFFLOAD_VLAN_STRIP
52 #define RTE_ETH_RX_OFFLOAD_IPV4_CKSUM DEV_RX_OFFLOAD_IPV4_CKSUM
53 #define RTE_ETH_RX_OFFLOAD_UDP_CKSUM DEV_RX_OFFLOAD_UDP_CKSUM
54 #define RTE_ETH_RX_OFFLOAD_TCP_CKSUM DEV_RX_OFFLOAD_TCP_CKSUM
55 #define RTE_ETH_RX_OFFLOAD_TCP_LRO DEV_RX_OFFLOAD_TCP_LRO
56 #define RTE_ETH_RX_OFFLOAD_QINQ_STRIP DEV_RX_OFFLOAD_QINQ_STRIP
57 #define RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM
58 #define RTE_ETH_RX_OFFLOAD_MACSEC_STRIP DEV_RX_OFFLOAD_MACSEC_STRIP
59 #define RTE_ETH_RX_OFFLOAD_HEADER_SPLIT DEV_RX_OFFLOAD_HEADER_SPLIT
60 #define RTE_ETH_RX_OFFLOAD_VLAN_FILTER DEV_RX_OFFLOAD_VLAN_FILTER
61 #define RTE_ETH_RX_OFFLOAD_VLAN_EXTEND DEV_RX_OFFLOAD_VLAN_EXTEND
62 #define RTE_ETH_RX_OFFLOAD_SCATTER DEV_RX_OFFLOAD_SCATTER
63 #define RTE_ETH_RX_OFFLOAD_TIMESTAMP DEV_RX_OFFLOAD_TIMESTAMP
64 #define RTE_ETH_RX_OFFLOAD_SECURITY DEV_RX_OFFLOAD_SECURITY
65 #define RTE_ETH_RX_OFFLOAD_KEEP_CRC DEV_RX_OFFLOAD_KEEP_CRC
66 #define RTE_ETH_RX_OFFLOAD_SCTP_CKSUM DEV_RX_OFFLOAD_SCTP_CKSUM
67 #define RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM DEV_RX_OFFLOAD_OUTER_UDP_CKSUM
68 #define RTE_ETH_RX_OFFLOAD_RSS_HASH DEV_RX_OFFLOAD_RSS_HASH
69 
70 #define RTE_ETH_MQ_TX_NONE ETH_MQ_TX_NONE
71 
72 #define RTE_ETH_MQ_RX_NONE ETH_MQ_RX_NONE
73 
74 #define RTE_ETH_RSS_IP ETH_RSS_IP
75 #define RTE_ETH_RSS_UDP ETH_RSS_UDP
76 #define RTE_ETH_RSS_TCP ETH_RSS_TCP
77 #define RTE_ETH_RSS_SCTP ETH_RSS_SCTP
78 #define RTE_ETH_RSS_TUNNEL ETH_RSS_TUNNEL
79 
80 #define RTE_ETH_RSS_L3_SRC_ONLY ETH_RSS_L3_SRC_ONLY
81 #define RTE_ETH_RSS_L3_DST_ONLY ETH_RSS_L3_DST_ONLY
82 #define RTE_ETH_RSS_L4_SRC_ONLY ETH_RSS_L4_SRC_ONLY
83 #define RTE_ETH_RSS_L4_DST_ONLY ETH_RSS_L4_DST_ONLY
84 
85 #define RTE_ETH_RSS_IPV4 ETH_RSS_IPV4
86 #define RTE_ETH_RSS_FRAG_IPV4 ETH_RSS_FRAG_IPV4
87 #define RTE_ETH_RSS_NONFRAG_IPV4_TCP ETH_RSS_NONFRAG_IPV4_TCP
88 #define RTE_ETH_RSS_NONFRAG_IPV4_UDP ETH_RSS_NONFRAG_IPV4_UDP
89 #define RTE_ETH_RSS_NONFRAG_IPV4_SCTP ETH_RSS_NONFRAG_IPV4_SCTP
90 #define RTE_ETH_RSS_NONFRAG_IPV4_OTHER ETH_RSS_NONFRAG_IPV4_OTHER
91 #define RTE_ETH_RSS_IPV6 ETH_RSS_IPV6
92 #define RTE_ETH_RSS_FRAG_IPV6 ETH_RSS_FRAG_IPV6
93 #define RTE_ETH_RSS_NONFRAG_IPV6_TCP ETH_RSS_NONFRAG_IPV6_TCP
94 #define RTE_ETH_RSS_NONFRAG_IPV6_UDP ETH_RSS_NONFRAG_IPV6_UDP
95 #define RTE_ETH_RSS_NONFRAG_IPV6_SCTP ETH_RSS_NONFRAG_IPV6_SCTP
96 #define RTE_ETH_RSS_NONFRAG_IPV6_OTHER ETH_RSS_NONFRAG_IPV6_OTHER
97 #define RTE_ETH_RSS_L2_PAYLOAD ETH_RSS_L2_PAYLOAD
98 #define RTE_ETH_RSS_IPV6_EX ETH_RSS_IPV6_EX
99 #define RTE_ETH_RSS_IPV6_TCP_EX ETH_RSS_IPV6_TCP_EX
100 #define RTE_ETH_RSS_IPV6_UDP_EX ETH_RSS_IPV6_UDP_EX
101 #define RTE_ETH_RSS_PORT ETH_RSS_PORT
102 #define RTE_ETH_RSS_VXLAN ETH_RSS_VXLAN
103 #define RTE_ETH_RSS_NVGRE ETH_RSS_NVGRE
104 #define RTE_ETH_RSS_GTPU ETH_RSS_GTPU
105 
106 #define RTE_MBUF_F_RX_IP_CKSUM_MASK PKT_RX_IP_CKSUM_MASK
107 #define RTE_MBUF_F_RX_IP_CKSUM_NONE PKT_RX_IP_CKSUM_NONE
108 #define RTE_MBUF_F_RX_IP_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD
109 #define RTE_MBUF_F_RX_IP_CKSUM_BAD PKT_RX_IP_CKSUM_BAD
110 
111 #define RTE_MBUF_F_RX_L4_CKSUM_MASK PKT_RX_L4_CKSUM_MASK
112 #define RTE_MBUF_F_RX_L4_CKSUM_GOOD PKT_RX_L4_CKSUM_GOOD
113 #define RTE_MBUF_F_RX_L4_CKSUM_BAD PKT_RX_L4_CKSUM_BAD
114 #endif
115 
116 #endif /* HAVE_DPDK */
117 
118 #include "util-device.h"
119 
120 void DPDKCleanupEAL(void);
121 
122 void DPDKCloseDevice(LiveDevice *ldev);
123 void DPDKFreeDevice(LiveDevice *ldev);
124 
125 #ifdef HAVE_DPDK
126 const char *DPDKGetPortNameByPortID(uint16_t pid);
127 #endif /* HAVE_DPDK */
128 
129 #endif /* UTIL_DPDK_H */
DPDKCloseDevice
void DPDKCloseDevice(LiveDevice *ldev)
Definition: util-dpdk.c:39
LiveDevice_
Definition: util-device.h:50
util-device.h
DPDKCleanupEAL
void DPDKCleanupEAL(void)
Definition: util-dpdk.c:28
DPDKFreeDevice
void DPDKFreeDevice(LiveDevice *ldev)
Definition: util-dpdk.c:57