2020-01-10 09:37:49 +08:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2021-01-07 12:53:33 +08:00
|
|
|
* Copyright(c) 2019-2021 Intel Corporation
|
2020-01-10 09:37:49 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include <rte_common.h>
|
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_memzone.h>
|
|
|
|
|
|
|
|
#include "iavf_type.h"
|
|
|
|
#include "iavf_prototype.h"
|
|
|
|
|
|
|
|
enum iavf_status
|
|
|
|
iavf_allocate_dma_mem_d(__rte_unused struct iavf_hw *hw,
|
|
|
|
struct iavf_dma_mem *mem,
|
|
|
|
u64 size,
|
|
|
|
u32 alignment)
|
|
|
|
{
|
2021-07-06 10:57:50 +02:00
|
|
|
static uint64_t iavf_dma_memzone_id;
|
2020-01-10 09:37:49 +08:00
|
|
|
const struct rte_memzone *mz = NULL;
|
|
|
|
char z_name[RTE_MEMZONE_NAMESIZE];
|
|
|
|
|
|
|
|
if (!mem)
|
|
|
|
return IAVF_ERR_PARAM;
|
|
|
|
|
2021-07-06 10:57:50 +02:00
|
|
|
snprintf(z_name, sizeof(z_name), "iavf_dma_%" PRIu64,
|
|
|
|
__atomic_fetch_add(&iavf_dma_memzone_id, 1, __ATOMIC_RELAXED));
|
2020-01-10 09:37:49 +08:00
|
|
|
mz = rte_memzone_reserve_bounded(z_name, size, SOCKET_ID_ANY,
|
|
|
|
RTE_MEMZONE_IOVA_CONTIG, alignment,
|
|
|
|
RTE_PGSIZE_2M);
|
|
|
|
if (!mz)
|
|
|
|
return IAVF_ERR_NO_MEMORY;
|
|
|
|
|
|
|
|
mem->size = size;
|
|
|
|
mem->va = mz->addr;
|
|
|
|
mem->pa = mz->iova;
|
|
|
|
mem->zone = (const void *)mz;
|
|
|
|
|
|
|
|
return IAVF_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum iavf_status
|
|
|
|
iavf_free_dma_mem_d(__rte_unused struct iavf_hw *hw,
|
|
|
|
struct iavf_dma_mem *mem)
|
|
|
|
{
|
|
|
|
if (!mem)
|
|
|
|
return IAVF_ERR_PARAM;
|
|
|
|
|
|
|
|
rte_memzone_free((const struct rte_memzone *)mem->zone);
|
|
|
|
mem->zone = NULL;
|
|
|
|
mem->va = NULL;
|
|
|
|
mem->pa = (u64)0;
|
|
|
|
|
|
|
|
return IAVF_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum iavf_status
|
|
|
|
iavf_allocate_virt_mem_d(__rte_unused struct iavf_hw *hw,
|
|
|
|
struct iavf_virt_mem *mem,
|
|
|
|
u32 size)
|
|
|
|
{
|
|
|
|
if (!mem)
|
|
|
|
return IAVF_ERR_PARAM;
|
|
|
|
|
|
|
|
mem->size = size;
|
|
|
|
mem->va = rte_zmalloc("iavf", size, 0);
|
|
|
|
|
|
|
|
if (mem->va)
|
|
|
|
return IAVF_SUCCESS;
|
|
|
|
else
|
|
|
|
return IAVF_ERR_NO_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum iavf_status
|
|
|
|
iavf_free_virt_mem_d(__rte_unused struct iavf_hw *hw,
|
|
|
|
struct iavf_virt_mem *mem)
|
|
|
|
{
|
|
|
|
if (!mem)
|
|
|
|
return IAVF_ERR_PARAM;
|
|
|
|
|
|
|
|
rte_free(mem->va);
|
|
|
|
mem->va = NULL;
|
|
|
|
|
|
|
|
return IAVF_SUCCESS;
|
|
|
|
}
|
|
|
|
|
log: register with standardized names
Let's try to enforce the convention where most drivers use a pmd. logtype
with their class reflected in it, and libraries use a lib. logtype.
Introduce two new macros:
- RTE_LOG_REGISTER_DEFAULT can be used when a single logtype is
used in a component. It is associated to the default name provided
by the build system,
- RTE_LOG_REGISTER_SUFFIX can be used when multiple logtypes are used,
and then the passed name is appended to the default name,
RTE_LOG_REGISTER is left untouched for existing external users
and for components that do not comply with the convention.
There is a new Meson variable log_prefix to adapt the default name
for baseband (pmd.bb.), bus (no pmd.) and mempool (no pmd.) classes.
Note: achieved with below commands + reverted change on net/bonding +
edits on crypto/virtio, compress/mlx5, regex/mlx5
$ git grep -l RTE_LOG_REGISTER drivers/ |
while read file; do
pattern=${file##drivers/};
class=${pattern%%/*};
pattern=${pattern#$class/};
drv=${pattern%%/*};
case "$class" in
baseband) pattern=pmd.bb.$drv;;
bus) pattern=bus.$drv;;
mempool) pattern=mempool.$drv;;
*) pattern=pmd.$class.$drv;;
esac
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
done
$ git grep -l RTE_LOG_REGISTER lib/ |
while read file; do
pattern=${file##lib/};
pattern=lib.${pattern%%/*};
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern',/RTE_LOG_REGISTER_DEFAULT(\1,/' $file;
sed -i -e 's/RTE_LOG_REGISTER(\(.*\), '$pattern'\.\(.*\),/RTE_LOG_REGISTER_SUFFIX(\1, \2,/' $file;
done
Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2021-04-26 14:51:08 +02:00
|
|
|
RTE_LOG_REGISTER_DEFAULT(iavf_common_logger, NOTICE);
|