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