LCOV - code coverage report
Current view: top level - root/contrail/vrouter/include - vr_btable.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 16 62.5 %
Date: 2026-08-03 02:19:58 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * vr_btable.h --
       3             :  *
       4             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       5             :  */
       6             : #ifndef __VR_BTABLE_H__
       7             : #define __VR_BTABLE_H__
       8             : 
       9             : #define VB_FLAG_MEMORY_ATTACHED 0x1
      10             : 
      11             : #define VR_SINGLE_ALLOC_LIMIT   (4 * 1024 * 1024)
      12             : 
      13             : struct vr_btable_partition {
      14             :     unsigned int vb_offset;
      15             :     unsigned int vb_mem_size;
      16             : };
      17             : 
      18             : struct vr_btable {
      19             :     unsigned int    vb_entries;
      20             :     unsigned short  vb_esize;
      21             :     unsigned short  vb_partitions;
      22             :     unsigned int    vb_flags;
      23             :     unsigned int    vb_alloc_limit;
      24             :     unsigned short  vb_alloc_limit_log;
      25             :     unsigned int    vb_alloc_limit_mask;
      26             :     void            **vb_mem;
      27             :     struct vr_btable_partition *vb_table_info;
      28             : };
      29             : 
      30             : struct vr_btable_partition *vr_btable_get_partition(struct vr_btable *,
      31             :         unsigned int);
      32             : void *vr_btable_get_address(struct vr_btable *, unsigned int);
      33             : 
      34             : void vr_btable_free(struct vr_btable *);
      35             : struct vr_btable *vr_btable_alloc(unsigned int, unsigned int);
      36             : struct vr_btable *vr_btable_attach(struct iovec *, unsigned int, unsigned short);
      37             : 
      38             : static inline unsigned int
      39           0 : vr_btable_entries(struct vr_btable *table)
      40             : {
      41           0 :     return table->vb_entries;
      42             : }
      43             : 
      44             : static inline unsigned int
      45           0 : vr_btable_size(struct vr_btable *table)
      46             : {
      47           0 :     return table->vb_entries * table->vb_esize;
      48             : }
      49             : 
      50             : static inline void *
      51   150113737 : vr_btable_get(struct vr_btable *table, unsigned int entry)
      52             : {
      53             :     unsigned int t_index, t_offset, entry_cont;
      54             : 
      55   150113737 :     if (entry >= table->vb_entries)
      56           0 :         return NULL;
      57             : 
      58   150113737 :     entry_cont = entry * table->vb_esize;
      59             : 
      60   150113737 :     if (table->vb_alloc_limit_mask) {
      61   131918281 :         t_index = entry_cont >> table->vb_alloc_limit_log;
      62   131918281 :         t_offset = entry_cont & table->vb_alloc_limit_mask;
      63             :     } else {
      64    18195456 :         t_index = entry_cont / table->vb_alloc_limit;
      65    18195456 :         t_offset = entry_cont % table->vb_alloc_limit;
      66             :     }
      67             : 
      68   150113737 :     if (t_index >= table->vb_partitions)
      69           0 :         return NULL;
      70             : 
      71   150113737 :     return ((char *)table->vb_mem[t_index] + t_offset);
      72             : }
      73             : 
      74             : #endif /* __VR_BTABLE_H__ */

Generated by: LCOV version 1.14