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 <rte_common.h> 10 : : 11 : : #include "bpf_impl.h" 12 : : 13 : : void 14 : 48 : rte_bpf_destroy(struct rte_bpf *bpf) 15 : : { 16 [ + - ]: 48 : if (bpf != NULL) { 17 [ + - ]: 48 : if (bpf->jit.func != NULL) 18 : 48 : munmap(bpf->jit.func, bpf->jit.sz); 19 : 48 : munmap(bpf, bpf->sz); 20 : : } 21 : 48 : } 22 : : 23 : : int 24 : 20 : rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit) 25 : : { 26 [ + - ]: 20 : if (bpf == NULL || jit == NULL) 27 : : return -EINVAL; 28 : : 29 : 20 : jit[0] = bpf->jit; 30 : 20 : return 0; 31 : : } 32 : : 33 : : int 34 : 48 : __rte_bpf_jit(struct rte_bpf *bpf) 35 : : { 36 : : int32_t rc; 37 : : 38 : : #if defined(RTE_ARCH_X86_64) 39 : 48 : rc = __rte_bpf_jit_x86(bpf); 40 : : #elif defined(RTE_ARCH_ARM64) 41 : : rc = __rte_bpf_jit_arm64(bpf); 42 : : #else 43 : : rc = -ENOTSUP; 44 : : #endif 45 : : 46 [ - + ]: 48 : if (rc != 0) 47 : 0 : RTE_BPF_LOG_LINE(WARNING, "%s(%p) failed, error code: %d;", 48 : : __func__, bpf, rc); 49 : 48 : return rc; 50 : : } 51 : : 52 [ - + ]: 252 : RTE_LOG_REGISTER_DEFAULT(rte_bpf_logtype, INFO);