diff options
author | Dave Barach <dave@barachs.net> | 2016-11-28 11:41:35 -0500 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2016-12-01 22:27:31 +0000 |
commit | 7be864ad0d8e3b139a277fb4a0234480f0cc3daa (patch) | |
tree | 75e69823c8cca3b780f27b54f2753f4ba7a987a5 /vnet/vnet/interface_funcs.h | |
parent | e245d5ecef9a7b0969d160943b0a817c46e09f71 (diff) |
Add a 64-byte interface "tag" for vhost and tap interfaces
This patch should dispose of spurious objections around interface tag
requirements, currently in use as excuses not to support the vpp ML2
plugin.
Add "u8 tag[64];" to the sw_interface_details message sent by vpp to
control-plane clients. Add u8 tag[64] to the create_vhost_user_if and
tap_connect APIs.
Added debug CLI to set/show/clear the interface tag on any vnet sw
interface. Added the sw_interface_tag_add_del API to set/clear
tags on any vnet sw interface.
There can be no expectation of "tag atomicity" with respect to
physical hardware. Vpp discovers devices before establishing a
control-plane connection.
This patch upload verifies using the csit oper-161128 branch
Change-Id: If8520119e7a586c5ccf0fdda82484ac205622855
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vnet/vnet/interface_funcs.h')
-rw-r--r-- | vnet/vnet/interface_funcs.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/vnet/vnet/interface_funcs.h b/vnet/vnet/interface_funcs.h index 17c677f07b6..a488599cff0 100644 --- a/vnet/vnet/interface_funcs.h +++ b/vnet/vnet/interface_funcs.h @@ -92,6 +92,44 @@ vnet_get_device_class (vnet_main_t * vnm, u32 dev_class_index) dev_class_index); } +static inline u8 * +vnet_get_sw_interface_tag (vnet_main_t * vnm, u32 sw_if_index) +{ + uword *p; + p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); + if (p) + return ((u8 *) p[0]); + return 0; +} + +static inline void +vnet_set_sw_interface_tag (vnet_main_t * vnm, u8 * tag, u32 sw_if_index) +{ + uword *p; + p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); + if (p) + { + u8 *oldtag = (u8 *) p[0]; + hash_unset (vnm->interface_tag_by_sw_if_index, sw_if_index); + vec_free (oldtag); + } + + hash_set (vnm->interface_tag_by_sw_if_index, sw_if_index, tag); +} + +static inline void +vnet_clear_sw_interface_tag (vnet_main_t * vnm, u32 sw_if_index) +{ + uword *p; + p = hash_get (vnm->interface_tag_by_sw_if_index, sw_if_index); + if (p) + { + u8 *oldtag = (u8 *) p[0]; + hash_unset (vnm->interface_tag_by_sw_if_index, sw_if_index); + vec_free (oldtag); + } +} + /** * Call back walk type for walking SW indices on a HW interface */ |