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
48typedef struct DPDKWorkerSync_ {
49 uint16_t worker_cnt;
50 SC_ATOMIC_DECLARE(uint16_t, worker_checked_in);
52
53typedef 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 */
100
103
104#endif /* SURICATA_SOURCE_DPDK_H */
uint8_t flags
Definition decode-gre.h:0
ChecksumValidationMode
Definition decode.h:42
void TmModuleDecodeDPDKRegister(void)
Registration Function for DecodeDPDK.
Definition source-dpdk.c:65
void TmModuleReceiveDPDKRegister(void)
Definition source-dpdk.c:51
struct DPDKPacketVars_ DPDKPacketVars
per packet DPDK vars
void DPDKSetTimevalOfMachineStart(void)
struct DPDKWorkerSync_ DPDKWorkerSync
struct DPDKIfaceConfig_ DPDKIfaceConfig
DpdkCopyModeEnum
Definition source-dpdk.h:34
@ DPDK_COPY_MODE_IPS
Definition source-dpdk.h:34
@ DPDK_COPY_MODE_NONE
Definition source-dpdk.h:34
@ DPDK_COPY_MODE_TAP
Definition source-dpdk.h:34
per packet DPDK vars
Definition source-dpdk.h:94
uint16_t out_port_id
Definition source-dpdk.h:96
struct rte_mbuf * mbuf
Definition source-dpdk.h:95
DpdkCopyModeEnum copy_mode
Definition source-dpdk.h:98
uint16_t out_queue_id
Definition source-dpdk.h:97
SC_ATOMIC_DECLARE(uint16_t, worker_checked_in)
uint16_t worker_cnt
Definition source-dpdk.h:49
#define SC_ATOMIC_DECLARE(type, name)
wrapper for declaring atomic variables.