Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2018 Intel Corporation 3 : : */ 4 : : 5 : : #include <stdio.h> 6 : : #include <errno.h> 7 : : #include <stdint.h> 8 : : 9 : : #include <eal_export.h> 10 : : #include <rte_common.h> 11 : : 12 : : #include "bpf_impl.h" 13 : : 14 : : RTE_EXPORT_SYMBOL(rte_bpf_destroy) 15 : : void 16 : 48 : rte_bpf_destroy(struct rte_bpf *bpf) 17 : : { 18 [ + - ]: 48 : if (bpf != NULL) { 19 [ + - ]: 48 : if (bpf->jit.func != NULL) 20 : 48 : munmap(bpf->jit.func, bpf->jit.sz); 21 : 48 : munmap(bpf, bpf->sz); 22 : : } 23 : 48 : } 24 : : 25 : : RTE_EXPORT_SYMBOL(rte_bpf_get_jit) 26 : : int 27 : 20 : rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit) 28 : : { 29 [ + - ]: 20 : if (bpf == NULL || jit == NULL) 30 : : return -EINVAL; 31 : : 32 : 20 : jit[0] = bpf->jit; 33 : 20 : return 0; 34 : : } 35 : : 36 : : int 37 : 48 : __rte_bpf_jit(struct rte_bpf *bpf) 38 : : { 39 : : int32_t rc; 40 : : 41 : : #if defined(RTE_ARCH_X86_64) 42 : 48 : rc = __rte_bpf_jit_x86(bpf); 43 : : #elif defined(RTE_ARCH_ARM64) 44 : : rc = __rte_bpf_jit_arm64(bpf); 45 : : #else 46 : : rc = -ENOTSUP; 47 : : #endif 48 : : 49 [ - + ]: 48 : if (rc != 0) 50 : 0 : RTE_BPF_LOG_LINE(WARNING, "%s(%p) failed, error code: %d;", 51 : : __func__, bpf, rc); 52 : 48 : return rc; 53 : : } 54 : : 55 [ - + ]: 252 : RTE_LOG_REGISTER_DEFAULT(rte_bpf_logtype, INFO);