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