LCOV - code coverage report
Current view: top level - lib/bpf - bpf.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 15 16 93.8 %
Date: 2025-01-02 22:41:34 Functions: 4 4 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 5 10 50.0 %

           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         [ -  + ]:        251 : RTE_LOG_REGISTER_DEFAULT(rte_bpf_logtype, INFO);

Generated by: LCOV version 1.14