LCOV - code coverage report
Current view: top level - vnet/interface - caps.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 7 21 33.3 %
Date: 2023-10-26 01:39:38 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: Apache-2.0
       2             :  * Copyright(c) 2021 Cisco Systems, Inc.
       3             :  */
       4             : 
       5             : #include <vlib/vlib.h>
       6             : #include <vnet/vnet.h>
       7             : #include <vnet/interface.h>
       8             : 
       9         575 : VLIB_REGISTER_LOG_CLASS (if_caps_log, static) = {
      10             :   .class_name = "interface",
      11             :   .subclass_name = "caps",
      12             : };
      13             : 
      14             : #define log_debug(fmt, ...)                                                   \
      15             :   vlib_log_debug (if_caps_log.class, fmt, __VA_ARGS__)
      16             : 
      17             : format_function_t format_vnet_hw_if_caps;
      18             : 
      19             : void
      20         655 : vnet_hw_if_change_caps (vnet_main_t *vnm, u32 hw_if_index,
      21             :                         vnet_hw_if_caps_change_t *caps)
      22             : {
      23         655 :   vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
      24         655 :   vnet_hw_if_caps_t old = hi->caps;
      25             : 
      26         655 :   hi->caps = (hi->caps & ~caps->mask) | caps->val;
      27             : 
      28         655 :   log_debug ("change: interface %U, set: %U, cleared: %U",
      29             :              format_vnet_hw_if_index_name, vnm, hw_if_index,
      30             :              format_vnet_hw_if_caps, (old ^ hi->caps) & caps->val,
      31             :              format_vnet_hw_if_caps, (old ^ hi->caps) & ~caps->val);
      32         655 : }
      33             : 
      34             : u8 *
      35           0 : format_vnet_hw_if_caps (u8 *s, va_list *va)
      36             : {
      37           0 :   vnet_hw_if_caps_t caps = va_arg (*va, vnet_hw_if_caps_t);
      38             : 
      39           0 :   const char *strings[sizeof (vnet_hw_if_caps_t) * 8] = {
      40             : #define _(bit, sfx, str) [bit] = (str),
      41             :     foreach_vnet_hw_if_caps
      42             : #undef _
      43             :   };
      44             : 
      45           0 :   if (caps == 0)
      46           0 :     return format (s, "none");
      47             : 
      48           0 :   while (caps)
      49             :     {
      50           0 :       int bit = get_lowest_set_bit_index (caps);
      51             : 
      52           0 :       if (strings[bit])
      53           0 :         s = format (s, "%s", strings[bit]);
      54             :       else
      55           0 :         s = format (s, "unknown-%u", bit);
      56             : 
      57           0 :       caps = clear_lowest_set_bit (caps);
      58           0 :       if (caps)
      59           0 :         vec_add1 (s, ' ');
      60             :     }
      61             : 
      62           0 :   return s;
      63             : }

Generated by: LCOV version 1.14