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