suricata
util-dpdk.c
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
#include "
suricata.h
"
25
#include "
util-dpdk.h
"
26
27
void
DPDKCleanupEAL
(
void
)
28
{
29
#ifdef HAVE_DPDK
30
if
(
run_mode
==
RUNMODE_DPDK
) {
31
int
retval = rte_eal_cleanup();
32
if
(retval != 0)
33
SCLogError
(
SC_ERR_DPDK_EAL_DEINIT
,
"EAL cleanup failed: %s"
, strerror(-retval));
34
}
35
#endif
36
}
37
38
void
DPDKCloseDevice
(
LiveDevice
*ldev)
39
{
40
(void)ldev;
// avoid warnings of unused variable
41
#ifdef HAVE_DPDK
42
uint16_t port_id;
43
int
retval;
44
if
(
run_mode
==
RUNMODE_DPDK
) {
45
retval = rte_eth_dev_get_port_by_name(ldev->
dev
, &port_id);
46
if
(retval < 0) {
47
SCLogError
(
SC_ERR_DPDK_EAL_DEINIT
,
"Unable to get port id of \"%s\", error: %s"
,
48
ldev->
dev
, rte_strerror(-retval));
49
return
;
50
}
51
52
SCLogInfo
(
"Closing device %s"
, ldev->
dev
);
53
rte_eth_dev_close(port_id);
54
}
55
#endif
56
}
RUNMODE_DPDK
@ RUNMODE_DPDK
Definition:
runmodes.h:39
SC_ERR_DPDK_EAL_DEINIT
@ SC_ERR_DPDK_EAL_DEINIT
Definition:
util-error.h:375
LiveDevice_
Definition:
util-device.h:40
LiveDevice_::dev
char * dev
Definition:
util-device.h:41
SCLogInfo
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition:
util-debug.h:217
DPDKCloseDevice
void DPDKCloseDevice(LiveDevice *ldev)
Definition:
util-dpdk.c:38
util-dpdk.h
run_mode
int run_mode
Definition:
suricata.c:203
SCLogError
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition:
util-debug.h:257
suricata.h
DPDKCleanupEAL
void DPDKCleanupEAL(void)
Definition:
util-dpdk.c:27
src
util-dpdk.c
Generated on Sat May 21 2022 23:30:40 for suricata by
1.8.18