aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/common/mvep/mvep_common.c
blob: 67fa65b574ad6ba4d97d29ded7fafceaf9113193 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*  SPDX-License-Identifier: BSD-3-Clause
 *  Copyright(c) 2018 Marvell International Ltd.
 */

#include <rte_common.h>

#include <env/mv_autogen_comp_flags.h>
#include <env/mv_sys_dma.h>

#include "rte_mvep_common.h"

/* Memory size (in bytes) for MUSDK dma buffers */
#define MRVL_MUSDK_DMA_MEMSIZE (40 * 1024 * 1024)

struct mvep {
	uint32_t ref_count;
};

static struct mvep mvep;

int rte_mvep_init(enum mvep_module_type module __rte_unused,
		  struct rte_kvargs *kvlist __rte_unused)
{
	int ret;

	if (!mvep.ref_count) {
		ret = mv_sys_dma_mem_init(MRVL_MUSDK_DMA_MEMSIZE);
		if (ret)
			return ret;
	}

	mvep.ref_count++;

	return 0;
}

int rte_mvep_deinit(enum mvep_module_type module __rte_unused)
{
	mvep.ref_count--;

	if (!mvep.ref_count)
		mv_sys_dma_mem_destroy();

	return 0;
}