2018-05-10 10:23:03 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2018 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include <rte_common.h>
|
|
|
|
#include <rte_eal.h>
|
|
|
|
|
|
|
|
#include "bpf_impl.h"
|
|
|
|
|
2019-06-29 11:58:52 +00:00
|
|
|
void
|
2018-05-10 10:23:03 +00:00
|
|
|
rte_bpf_destroy(struct rte_bpf *bpf)
|
|
|
|
{
|
|
|
|
if (bpf != NULL) {
|
|
|
|
if (bpf->jit.func != NULL)
|
|
|
|
munmap(bpf->jit.func, bpf->jit.sz);
|
|
|
|
munmap(bpf, bpf->sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-29 11:58:52 +00:00
|
|
|
int
|
2018-05-10 10:23:03 +00:00
|
|
|
rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
|
|
|
|
{
|
|
|
|
if (bpf == NULL || jit == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
jit[0] = bpf->jit;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
bpf_jit(struct rte_bpf *bpf)
|
|
|
|
{
|
|
|
|
int32_t rc;
|
|
|
|
|
2019-09-03 10:59:31 +00:00
|
|
|
#if defined(RTE_ARCH_X86_64)
|
2018-05-10 10:23:06 +00:00
|
|
|
rc = bpf_jit_x86(bpf);
|
2019-09-03 10:59:31 +00:00
|
|
|
#elif defined(RTE_ARCH_ARM64)
|
|
|
|
rc = bpf_jit_arm64(bpf);
|
2018-05-10 10:23:06 +00:00
|
|
|
#else
|
2018-05-10 10:23:03 +00:00
|
|
|
rc = -ENOTSUP;
|
2018-05-10 10:23:06 +00:00
|
|
|
#endif
|
|
|
|
|
2018-05-10 10:23:03 +00:00
|
|
|
if (rc != 0)
|
|
|
|
RTE_BPF_LOG(WARNING, "%s(%p) failed, error code: %d;\n",
|
|
|
|
__func__, bpf, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
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 12:51:08 +00:00
|
|
|
RTE_LOG_REGISTER_DEFAULT(rte_bpf_logtype, INFO);
|