1 /* SPDX-License-Identifier: Apache-2.0
2 * Copyright(c) 2021 Cisco Systems, Inc.
7 #include <vnet/interface.h>
9 VLIB_REGISTER_LOG_CLASS (if_caps_log, static) = {
10 .class_name = "interface",
11 .subclass_name = "caps",
14 #define log_debug(fmt, ...) \
15 vlib_log_debug (if_caps_log.class, fmt, __VA_ARGS__)
17 format_function_t format_vnet_hw_if_caps;
20 vnet_hw_if_change_caps (vnet_main_t *vnm, u32 hw_if_index,
21 vnet_hw_if_caps_change_t *caps)
23 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
24 vnet_hw_if_caps_t old = hi->caps;
26 hi->caps = (hi->caps & ~caps->mask) | caps->val;
28 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);
35 format_vnet_hw_if_caps (u8 *s, va_list *va)
37 vnet_hw_if_caps_t caps = va_arg (*va, vnet_hw_if_caps_t);
39 const char *strings[sizeof (vnet_hw_if_caps_t) * 8] = {
40 #define _(bit, sfx, str) [bit] = (str),
41 foreach_vnet_hw_if_caps
46 return format (s, "none");
50 int bit = get_lowest_set_bit_index (caps);
53 s = format (s, "%s", strings[bit]);
55 s = format (s, "unknown-%u", bit);
57 caps = clear_lowest_set_bit (caps);