New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / common / mvep / mvep_common.c
1 /*  SPDX-License-Identifier: BSD-3-Clause
2  *  Copyright(c) 2018 Marvell International Ltd.
3  */
4
5 #include <rte_common.h>
6
7 #include <env/mv_autogen_comp_flags.h>
8 #include <env/mv_sys_dma.h>
9
10 #include "rte_mvep_common.h"
11
12 /* Memory size (in bytes) for MUSDK dma buffers */
13 #define MRVL_MUSDK_DMA_MEMSIZE (40 * 1024 * 1024)
14
15 struct mvep {
16         uint32_t ref_count;
17 };
18
19 static struct mvep mvep;
20
21 int rte_mvep_init(enum mvep_module_type module __rte_unused,
22                   struct rte_kvargs *kvlist __rte_unused)
23 {
24         int ret;
25
26         if (!mvep.ref_count) {
27                 ret = mv_sys_dma_mem_init(MRVL_MUSDK_DMA_MEMSIZE);
28                 if (ret)
29                         return ret;
30         }
31
32         mvep.ref_count++;
33
34         return 0;
35 }
36
37 int rte_mvep_deinit(enum mvep_module_type module __rte_unused)
38 {
39         mvep.ref_count--;
40
41         if (!mvep.ref_count)
42                 mv_sys_dma_mem_destroy();
43
44         return 0;
45 }