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  /* number of threads - zero means all available */
59  int threads;
60  /* IPS mode */
61  DpdkCopyModeEnum copy_mode;
62  const char *out_iface;
63  uint16_t out_port_id;
64  /* DPDK flags */
65  uint32_t flags;
66  ChecksumValidationMode checksum_mode;
67  uint64_t rss_hf;
68  /* set maximum transmission unit of the device in bytes */
69  uint16_t mtu;
70  bool vlan_strip_enabled;
71  uint16_t nb_rx_queues;
72  uint16_t nb_rx_desc;
73  uint16_t nb_tx_queues;
74  uint16_t nb_tx_desc;
75  uint32_t mempool_size;
76  uint32_t mempool_cache_size;
77  DPDKDeviceResources *pkt_mempools;
78  uint16_t linkup_timeout; // in seconds how long to wait for link to come up
79  SC_ATOMIC_DECLARE(unsigned int, ref);
80  /* threads bind queue id one by one */
81  SC_ATOMIC_DECLARE(uint16_t, queue_id);
82  SC_ATOMIC_DECLARE(uint16_t, inconsistent_numa_cnt);
83  DPDKWorkerSync *workers_sync;
84  void (*DerefFunc)(void *);
85 
86  struct rte_flow *flow[100];
87 #endif
89 
90 /**
91  * \brief per packet DPDK vars
92  *
93  * This structure is used by the release data system and for IPS
94  */
95 typedef struct DPDKPacketVars_ {
96  struct rte_mbuf *mbuf;
97  uint16_t out_port_id;
98  uint16_t out_queue_id;
99  uint8_t copy_mode;
101 
102 void TmModuleReceiveDPDKRegister(void);
103 void TmModuleDecodeDPDKRegister(void);
104 
105 #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:98
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:50
DPDKPacketVars_
per packet DPDK vars
Definition: source-dpdk.h:95
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:97
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
DPDKPacketVars_::copy_mode
uint8_t copy_mode
Definition: source-dpdk.h:99
DPDKWorkerSync_::SC_ATOMIC_DECLARE
SC_ATOMIC_DECLARE(uint16_t, worker_checked_in)
DPDKPacketVars_::mbuf
struct rte_mbuf * mbuf
Definition: source-dpdk.h:96
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:34
DPDK_COPY_MODE_NONE
@ DPDK_COPY_MODE_NONE
Definition: source-dpdk.h:34