1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 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"
16 int iavf_common_logger;
19 iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
20 struct iavf_dma_mem *mem,
24 const struct rte_memzone *mz = NULL;
25 char z_name[RTE_MEMZONE_NAMESIZE];
28 return IAVF_ERR_PARAM;
30 snprintf(z_name, sizeof(z_name), "iavf_dma_%"PRIu64, rte_rand());
31 mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY,
32 RTE_MEMZONE_IOVA_CONTIG, alignment,
35 return IAVF_ERR_NO_MEMORY;
40 mem->zone = (const void *)mz;
46 iavf_free_dma_mem_d(__rte_unused struct iavf_hw *hw,
47 struct iavf_dma_mem *mem)
50 return IAVF_ERR_PARAM;
52 rte_memzone_free((const struct rte_memzone *)mem->zone);
61 iavf_allocate_virt_mem_d(__rte_unused struct iavf_hw *hw,
62 struct iavf_virt_mem *mem,
66 return IAVF_ERR_PARAM;
69 mem->va = rte_zmalloc("iavf", size, 0);
74 return IAVF_ERR_NO_MEMORY;
78 iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
79 struct iavf_virt_mem *mem)
82 return IAVF_ERR_PARAM;
90 RTE_INIT(iavf_common_init_log)
92 iavf_common_logger = rte_log_register("pmd.common.iavf");
93 if (iavf_common_logger >= 0)
94 rte_log_set_level(iavf_common_logger, RTE_LOG_NOTICE);