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 SURICATA_SOURCE_DPDK_H
25 #define SURICATA_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 #define DPDK_IRQ_MODE (1 << 2) /**< Interrupt mode */
42 // Offloads
43 #define DPDK_RX_CHECKSUM_OFFLOAD (1 << 4) /**< Enable chsum offload */
44 
46 
47 typedef struct DPDKWorkerSync_ {
48  uint16_t worker_cnt;
49  SC_ATOMIC_DECLARE(uint16_t, worker_checked_in);
51 
52 typedef struct DPDKIfaceConfig_ {
53 #ifdef HAVE_DPDK
54  char iface[RTE_ETH_NAME_MAX_LEN];
55  uint16_t port_id;
56  int32_t socket_id;
57  /* number of threads - zero means all available */
58  int threads;
59  /* IPS mode */
60  DpdkCopyModeEnum copy_mode;
61  const char *out_iface;
62  uint16_t out_port_id;
63  /* DPDK flags */
64  uint32_t flags;
65  ChecksumValidationMode checksum_mode;
66  uint64_t rss_hf;
67  /* set maximum transmission unit of the device in bytes */
68  uint16_t mtu;
69  uint16_t nb_rx_queues;
70  uint16_t nb_rx_desc;
71  uint16_t nb_tx_queues;
72  uint16_t nb_tx_desc;
73  uint32_t mempool_size;
74  uint32_t mempool_cache_size;
75  struct rte_mempool *pkt_mempool;
76  SC_ATOMIC_DECLARE(unsigned int, ref);
77  /* threads bind queue id one by one */
78  SC_ATOMIC_DECLARE(uint16_t, queue_id);
79  SC_ATOMIC_DECLARE(uint16_t, inconsistent_numa_cnt);
80  DPDKWorkerSync *workers_sync;
81  void (*DerefFunc)(void *);
82 
83  struct rte_flow *flow[100];
84 #endif
86 
87 /**
88  * \brief per packet DPDK vars
89  *
90  * This structure is used by the release data system and for IPS
91  */
92 typedef struct DPDKPacketVars_ {
93  struct rte_mbuf *mbuf;
94  uint16_t out_port_id;
95  uint16_t out_queue_id;
96  uint8_t copy_mode;
98 
100 void TmModuleDecodeDPDKRegister(void);
101 
102 #endif /* SURICATA_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:95
DpdkCopyModeEnum
DpdkCopyModeEnum
Definition: source-dpdk.h:33
DPDKIfaceConfig_
Definition: source-dpdk.h:52
DPDKWorkerSync_
Definition: source-dpdk.h:47
TmModuleReceiveDPDKRegister
void TmModuleReceiveDPDKRegister(void)
Definition: source-dpdk.c:50
DPDKPacketVars_
per packet DPDK vars
Definition: source-dpdk.h:92
DPDKWorkerSync_::worker_cnt
uint16_t worker_cnt
Definition: source-dpdk.h:48
DPDKIfaceConfig
struct DPDKIfaceConfig_ DPDKIfaceConfig
SC_ATOMIC_DECLARE
#define SC_ATOMIC_DECLARE(type, name)
wrapper for declaring atomic variables.
Definition: util-atomic.h:280
DPDKPacketVars_::out_port_id
uint16_t out_port_id
Definition: source-dpdk.h:94
DPDKWorkerSync
struct DPDKWorkerSync_ DPDKWorkerSync
flags
uint8_t flags
Definition: decode-gre.h:0
ChecksumValidationMode
ChecksumValidationMode
Definition: decode.h:45
suricata-common.h
DPDKPacketVars_::copy_mode
uint8_t copy_mode
Definition: source-dpdk.h:96
DPDKWorkerSync_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint16_t, worker_checked_in)
DPDKPacketVars_::mbuf
struct rte_mbuf * mbuf
Definition: source-dpdk.h:93
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