1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_random.h>
10 #include <rte_malloc.h>
11 #include <rte_memzone.h>
13 #include "iavf_type.h"
14 #include "iavf_prototype.h"
17 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
18 struct iavf_dma_mem *mem,
22 const struct rte_memzone *mz = NULL;
23 char z_name[RTE_MEMZONE_NAMESIZE];
26 return IAVF_ERR_PARAM;
28 snprintf(z_name, sizeof(z_name), "iavf_dma_%"PRIu64, rte_rand());
29 mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY,
30 RTE_MEMZONE_IOVA_CONTIG, alignment,
33 return IAVF_ERR_NO_MEMORY;
38 mem->zone = (const void *)mz;
44 iavf_free_dma_mem_d(__rte_unused struct iavf_hw *hw,
45 struct iavf_dma_mem *mem)
48 return IAVF_ERR_PARAM;
50 rte_memzone_free((const struct rte_memzone *)mem->zone);
59 iavf_allocate_virt_mem_d(__rte_unused struct iavf_hw *hw,
60 struct iavf_virt_mem *mem,
64 return IAVF_ERR_PARAM;
67 mem->va = rte_zmalloc("iavf", size, 0);
72 return IAVF_ERR_NO_MEMORY;
76 iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
77 struct iavf_virt_mem *mem)
80 return IAVF_ERR_PARAM;
88 RTE_LOG_REGISTER_DEFAULT(iavf_common_logger, NOTICE);