suricata
source-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 __SOURCE_DPDK_H__
25 #define __SOURCE_DPDK_H__
26 
27 #ifdef HAVE_DPDK
28 #include <rte_ethdev.h>
29 #endif
30 
32 
33 #define DPDK_BURST_TX_WAIT_US 1
34 
35 /* DPDK Flags */
36 // General flags
37 #define DPDK_PROMISC (1 << 0) /**< Promiscuous mode */
38 #define DPDK_MULTICAST (1 << 1) /**< Enable multicast packets */
39 // Offloads
40 #define DPDK_RX_CHECKSUM_OFFLOAD (1 << 4) /**< Enable chsum offload */
41 
42 typedef struct DPDKIfaceConfig_ {
43 #ifdef HAVE_DPDK
44  char iface[RTE_ETH_NAME_MAX_LEN];
45  uint16_t port_id;
46  uint16_t socket_id;
47  /* number of threads - zero means all available */
48  int threads;
49  /* IPS mode */
50  DpdkCopyModeEnum copy_mode;
51  const char *out_iface;
52  uint16_t out_port_id;
53  /* DPDK flags */
54  uint32_t flags;
55  ChecksumValidationMode checksum_mode;
56  /* set maximum transmission unit of the device in bytes */
57  uint16_t mtu;
58  uint16_t nb_rx_queues;
59  uint16_t nb_rx_desc;
60  uint16_t nb_tx_queues;
61  uint16_t nb_tx_desc;
62  uint32_t mempool_size;
63  uint32_t mempool_cache_size;
64  struct rte_mempool *pkt_mempool;
65  SC_ATOMIC_DECLARE(unsigned int, ref);
66  /* threads bind queue id one by one */
67  SC_ATOMIC_DECLARE(uint16_t, queue_id);
68  void (*DerefFunc)(void *);
69 
70  struct rte_flow *flow[100];
71 #endif
73 
74 /**
75  * \brief per packet DPDK vars
76  *
77  * This structure is used by the release data system and for IPS
78  */
79 typedef struct DPDKPacketVars_ {
80  struct rte_mbuf *mbuf;
81  uint16_t out_port_id;
82  uint16_t out_queue_id;
83  uint8_t copy_mode;
85 
88 
89 #endif /* __SOURCE_DPDK_H__ */
DPDK_COPY_MODE_IPS
@ DPDK_COPY_MODE_IPS
Definition: source-dpdk.h:31
DPDKPacketVars_::out_queue_id
uint16_t out_queue_id
Definition: source-dpdk.h:82
DpdkCopyModeEnum
DpdkCopyModeEnum
Definition: source-dpdk.h:31
DPDKIfaceConfig_
Definition: source-dpdk.h:42
TmModuleReceiveDPDKRegister
void TmModuleReceiveDPDKRegister(void)
Definition: source-dpdk.c:47
DPDKPacketVars_
per packet DPDK vars
Definition: source-dpdk.h:79
DPDKIfaceConfig
struct DPDKIfaceConfig_ DPDKIfaceConfig
SC_ATOMIC_DECLARE
#define SC_ATOMIC_DECLARE(type, name)
wrapper for declaring atomic variables.
Definition: util-atomic.h:281
DPDKPacketVars_::out_port_id
uint16_t out_port_id
Definition: source-dpdk.h:81
flags
uint8_t flags
Definition: decode-gre.h:0
ChecksumValidationMode
ChecksumValidationMode
Definition: decode.h:45
DPDKPacketVars_::copy_mode
uint8_t copy_mode
Definition: source-dpdk.h:83
DPDKPacketVars_::mbuf
struct rte_mbuf * mbuf
Definition: source-dpdk.h:80
TmModuleDecodeDPDKRegister
void TmModuleDecodeDPDKRegister(void)
Registration Function for DecodeDPDK.
Definition: source-dpdk.c:61
DPDKPacketVars
struct DPDKPacketVars_ DPDKPacketVars
per packet DPDK vars
DPDK_COPY_MODE_TAP
@ DPDK_COPY_MODE_TAP
Definition: source-dpdk.h:31
DPDK_COPY_MODE_NONE
@ DPDK_COPY_MODE_NONE
Definition: source-dpdk.h:31