From d4f88cc0967ea1de66396ac07b20cf6e33a3fa1a Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Wed, 5 Jan 2022 01:52:38 +0100 Subject: interface: refactor interface capabilities code Make it shorter to type, easier to debug, make adding callbacks in future simpler. Type: improvement Change-Id: I6cdd6375e36da23bd452a7c7273ff42789e94433 Signed-off-by: Damjan Marion --- src/vnet/interface_funcs.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/vnet/interface_funcs.h') diff --git a/src/vnet/interface_funcs.h b/src/vnet/interface_funcs.h index eef5596644c..7dfa617e2fe 100644 --- a/src/vnet/interface_funcs.h +++ b/src/vnet/interface_funcs.h @@ -557,6 +557,31 @@ pcap_add_buffer (pcap_main_t *pm, struct vlib_main_t *vm, u32 buffer_index, clib_spinlock_unlock_if_init (&pm->lock); } } + +typedef struct +{ + vnet_hw_if_caps_t val; + vnet_hw_if_caps_t mask; +} vnet_hw_if_caps_change_t; + +void vnet_hw_if_change_caps (vnet_main_t *vnm, u32 hw_if_index, + vnet_hw_if_caps_change_t *caps); + +static_always_inline void +vnet_hw_if_set_caps (vnet_main_t *vnm, u32 hw_if_index, vnet_hw_if_caps_t caps) +{ + vnet_hw_if_caps_change_t cc = { .val = caps, .mask = caps }; + vnet_hw_if_change_caps (vnm, hw_if_index, &cc); +} + +static_always_inline void +vnet_hw_if_unset_caps (vnet_main_t *vnm, u32 hw_if_index, + vnet_hw_if_caps_t caps) +{ + vnet_hw_if_caps_change_t cc = { .val = 0, .mask = caps }; + vnet_hw_if_change_caps (vnm, hw_if_index, &cc); +} + #endif /* included_vnet_interface_funcs_h */ /* -- cgit 1.2.3-korg