LCOV - code coverage report
Current view: top level - lib/bpf - bpf_impl.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 5 5 100.0 %
Date: 2025-01-02 22:41:34 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 19 24 79.2 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef BPF_IMPL_H
       6                 :            : #define BPF_IMPL_H
       7                 :            : 
       8                 :            : #include <rte_bpf.h>
       9                 :            : #include <sys/mman.h>
      10                 :            : 
      11                 :            : #define MAX_BPF_STACK_SIZE      0x200
      12                 :            : 
      13                 :            : struct rte_bpf {
      14                 :            :         struct rte_bpf_prm prm;
      15                 :            :         struct rte_bpf_jit jit;
      16                 :            :         size_t sz;
      17                 :            :         uint32_t stack_sz;
      18                 :            : };
      19                 :            : 
      20                 :            : /*
      21                 :            :  * Use '__rte' prefix for non-static internal functions
      22                 :            :  * to avoid potential name conflict with other libraries.
      23                 :            :  */
      24                 :            : int __rte_bpf_validate(struct rte_bpf *bpf);
      25                 :            : int __rte_bpf_jit(struct rte_bpf *bpf);
      26                 :            : int __rte_bpf_jit_x86(struct rte_bpf *bpf);
      27                 :            : int __rte_bpf_jit_arm64(struct rte_bpf *bpf);
      28                 :            : 
      29                 :            : extern int rte_bpf_logtype;
      30                 :            : #define RTE_LOGTYPE_BPF rte_bpf_logtype
      31                 :            : 
      32                 :            : #define RTE_BPF_LOG_LINE(lvl, ...) \
      33                 :            :         RTE_LOG_LINE(lvl, BPF, __VA_ARGS__)
      34                 :            : 
      35                 :            : static inline size_t
      36                 :            : bpf_size(uint32_t bpf_op_sz)
      37                 :            : {
      38   [ +  +  +  +  :       1623 :         if (bpf_op_sz == BPF_B)
                   +  + ]
      39                 :            :                 return sizeof(uint8_t);
      40   [ +  +  +  +  :       1325 :         else if (bpf_op_sz == BPF_H)
                   +  + ]
      41                 :            :                 return sizeof(uint16_t);
      42   [ +  +  +  +  :        948 :         else if (bpf_op_sz == BPF_W)
                   -  + ]
      43                 :            :                 return sizeof(uint32_t);
      44   [ +  -  +  -  :         56 :         else if (bpf_op_sz == EBPF_DW)
                   -  - ]
      45                 :         56 :                 return sizeof(uint64_t);
      46                 :            :         return 0;
      47                 :            : }
      48                 :            : 
      49                 :            : #endif /* BPF_IMPL_H */

Generated by: LCOV version 1.14