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 #include "util-dpdk.h"
29 
30 #ifdef HAVE_DPDK
31 #include <rte_ethdev.h>
32 #endif
33 
35 
36 #define DPDK_BURST_TX_WAIT_US 1
37 
38 /* DPDK Flags */
39 // General flags
40 #define DPDK_PROMISC (1 << 0) /**< Promiscuous mode */
41 #define DPDK_MULTICAST (1 << 1) /**< Enable multicast packets */
42 #define DPDK_IRQ_MODE (1 << 2) /**< Interrupt mode */
43 // Offloads
44 #define DPDK_RX_CHECKSUM_OFFLOAD (1 << 4) /**< Enable chsum offload */
45 
47 
48 typedef struct DPDKWorkerSync_ {
49  uint16_t worker_cnt;
50  SC_ATOMIC_DECLARE(uint16_t, worker_checked_in);
52 
53 typedef struct DPDKIfaceConfig_ {
54 #ifdef HAVE_DPDK
55  char iface[RTE_ETH_NAME_MAX_LEN];
56  uint16_t port_id;
57  int32_t socket_id;
58  uint16_t 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  bool vlan_strip_enabled;
70  uint16_t nb_rx_queues;
71  uint16_t nb_rx_desc;
72  uint16_t nb_tx_queues;
73  uint16_t nb_tx_desc;
74  uint32_t mempool_size;
75  uint32_t mempool_cache_size;
76  DPDKDeviceResources *pkt_mempools;
77  uint16_t linkup_timeout; // in seconds how long to wait for link to come up
78  SC_ATOMIC_DECLARE(uint16_t, ref);
79  /* threads bind queue id one by one */
80  SC_ATOMIC_DECLARE(uint16_t, queue_id);
81  SC_ATOMIC_DECLARE(uint16_t, inconsistent_numa_cnt);
82  DPDKWorkerSync *workers_sync;
83  void (*DerefFunc)(void *);
84 
85  struct rte_flow *flow[100];
86 #endif
88 
89 /**
90  * \brief per packet DPDK vars
91  *
92  * This structure is used by the release data system and for IPS
93  */
94 typedef struct DPDKPacketVars_ {
95  struct rte_mbuf *mbuf;
96  uint16_t out_port_id;
97  uint16_t out_queue_id;
100 
101 void TmModuleReceiveDPDKRegister(void);
102 void TmModuleDecodeDPDKRegister(void);
103 
104 #endif /* SURICATA_SOURCE_DPDK_H */
DPDKSetTimevalOfMachineStart
void DPDKSetTimevalOfMachineStart(void)
DPDK_COPY_MODE_IPS
@ DPDK_COPY_MODE_IPS
Definition: source-dpdk.h:34
DPDKPacketVars_::out_queue_id
uint16_t out_queue_id
Definition: source-dpdk.h:97
DpdkCopyModeEnum
DpdkCopyModeEnum
Definition: source-dpdk.h:34
DPDKIfaceConfig_
Definition: source-dpdk.h:53
DPDKWorkerSync_
Definition: source-dpdk.h:48
TmModuleReceiveDPDKRegister
void TmModuleReceiveDPDKRegister(void)
Definition: source-dpdk.c:51
DPDKPacketVars_
per packet DPDK vars
Definition: source-dpdk.h:94
DPDKWorkerSync_::worker_cnt
uint16_t worker_cnt
Definition: source-dpdk.h:49
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:96
DPDKWorkerSync
struct DPDKWorkerSync_ DPDKWorkerSync
util-dpdk.h
flags
uint8_t flags
Definition: decode-gre.h:0
ChecksumValidationMode
ChecksumValidationMode
Definition: decode.h:42
suricata-common.h
DPDKWorkerSync_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint16_t, worker_checked_in)
DPDKPacketVars_::copy_mode
DpdkCopyModeEnum copy_mode
Definition: source-dpdk.h:98
DPDKPacketVars_::mbuf
struct rte_mbuf * mbuf
Definition: source-dpdk.h:95
TmModuleDecodeDPDKRegister
void TmModuleDecodeDPDKRegister(void)
Registration Function for DecodeDPDK.
Definition: source-dpdk.c:65
DPDKPacketVars
struct DPDKPacketVars_ DPDKPacketVars
per packet DPDK vars
DPDK_COPY_MODE_TAP
@ DPDK_COPY_MODE_TAP
Definition: source-dpdk.h:34
DPDK_COPY_MODE_NONE
@ DPDK_COPY_MODE_NONE
Definition: source-dpdk.h:34