f-stack/dpdk/lib/bpf/bpf.c

57 lines
945 B
C
Raw Normal View History

2019-06-25 11:12:58 +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"
2020-06-18 16:55:50 +00:00
void
2019-06-25 11:12:58 +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);
}
}
2020-06-18 16:55:50 +00:00
int
2019-06-25 11:12:58 +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;
2020-06-18 16:55:50 +00:00
#if defined(RTE_ARCH_X86_64)
2019-06-25 11:12:58 +00:00
rc = bpf_jit_x86(bpf);
2020-06-18 16:55:50 +00:00
#elif defined(RTE_ARCH_ARM64)
rc = bpf_jit_arm64(bpf);
2019-06-25 11:12:58 +00:00
#else
rc = -ENOTSUP;
#endif
if (rc != 0)
RTE_BPF_LOG(WARNING, "%s(%p) failed, error code: %d;\n",
__func__, bpf, rc);
return rc;
}
2022-09-06 04:00:10 +00:00
RTE_LOG_REGISTER_DEFAULT(rte_bpf_logtype, INFO);