Skip to content

Commit

Permalink
Changed SAI attrs to NVGRE
Browse files Browse the repository at this point in the history
Signed-off-by: Vadym Hlushko <[email protected]>
  • Loading branch information
vadymhlushko-mlnx committed Oct 29, 2021
1 parent 7330fec commit 6b26af5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions orchagent/nvgreorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ static const std::vector<map_type_t> nvgreMapTypes = {
};

static const std::map<map_type_t, sai_tunnel_map_type_t> nvgreEncapTunnelMap = {
{ MAP_T_VLAN, SAI_TUNNEL_MAP_TYPE_VLAN_ID_TO_VNI },
{ MAP_T_BRIDGE, SAI_TUNNEL_MAP_TYPE_BRIDGE_IF_TO_VNI }
{ MAP_T_VLAN, SAI_TUNNEL_MAP_TYPE_VLAN_ID_TO_VSID },
{ MAP_T_BRIDGE, SAI_TUNNEL_MAP_TYPE_BRIDGE_IF_TO_VSID }
};

static inline sai_tunnel_map_type_t get_encap_nvgre_mapper(map_type_t map)
Expand All @@ -28,8 +28,8 @@ static inline sai_tunnel_map_type_t get_encap_nvgre_mapper(map_type_t map)
}

static const std::map<map_type_t, sai_tunnel_map_type_t> nvgreDecapTunnelMap = {
{ MAP_T_VLAN, SAI_TUNNEL_MAP_TYPE_VNI_TO_VLAN_ID },
{ MAP_T_BRIDGE, SAI_TUNNEL_MAP_TYPE_VNI_TO_BRIDGE_IF }
{ MAP_T_VLAN, SAI_TUNNEL_MAP_TYPE_VSID_TO_VLAN_ID },
{ MAP_T_BRIDGE, SAI_TUNNEL_MAP_TYPE_VSID_TO_BRIDGE_IF }
};

static inline sai_tunnel_map_type_t get_decap_nvgre_mapper(map_type_t map)
Expand All @@ -40,10 +40,10 @@ static inline sai_tunnel_map_type_t get_decap_nvgre_mapper(map_type_t map)
static const map<map_type_t, std::pair<sai_tunnel_map_entry_attr_t, sai_tunnel_map_entry_attr_t>> nvgreEncapTunnelMapKeyVal =
{
{ MAP_T_VLAN,
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VLAN_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_VALUE }
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VLAN_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VSID_ID_VALUE }
},
{ MAP_T_BRIDGE,
{ SAI_TUNNEL_MAP_ENTRY_ATTR_BRIDGE_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_VALUE }
{ SAI_TUNNEL_MAP_ENTRY_ATTR_BRIDGE_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VSID_ID_VALUE }
}
};

Expand All @@ -60,10 +60,10 @@ static inline sai_tunnel_map_entry_attr_t get_encap_nvgre_map_val(map_type_t map
static const map<map_type_t, std::pair<sai_tunnel_map_entry_attr_t, sai_tunnel_map_entry_attr_t>> nvgreDecapTunnelMapKeyVal =
{
{ MAP_T_VLAN,
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VLAN_ID_VALUE }
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VSID_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_VLAN_ID_VALUE }
},
{ MAP_T_BRIDGE,
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_BRIDGE_ID_VALUE }
{ SAI_TUNNEL_MAP_ENTRY_ATTR_VSID_ID_KEY, SAI_TUNNEL_MAP_ENTRY_ATTR_BRIDGE_ID_VALUE }
}
};

Expand Down Expand Up @@ -138,7 +138,7 @@ sai_object_id_t NvgreTunnel::sai_create_tunnel(struct tunnel_sai_ids_t &ids, con
std::vector<sai_attribute_t> tunnel_attrs;

attr.id = SAI_TUNNEL_ATTR_TYPE;
attr.value.s32 = SAI_TUNNEL_TYPE_VXLAN;
attr.value.s32 = SAI_TUNNEL_TYPE_NVGRE;
tunnel_attrs.push_back(attr);

attr.id = SAI_TUNNEL_ATTR_UNDERLAY_INTERFACE;
Expand Down
15 changes: 7 additions & 8 deletions tests/test_nvgre_tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,14 @@ def check_nvgre_tunnel(self, dvs, tunnel_name, src_ip):
assert how_many_entries_exist(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP_ENTRY) == len(self.tunnel_map_entry_ids), "The TUNNEL_MAP_ENTRY is created too early"
assert how_many_entries_exist(asic_db, SAI_OBJECT_TYPE_TUNNEL) == (len(self.tunnel_ids) + 1), "The TUNNEL wasn't created"

check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[0], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VLAN_ID_TO_VNI' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[1], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_BRIDGE_IF_TO_VNI' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[2], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_VLAN_ID' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[3], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_BRIDGE_IF' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[0], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VLAN_ID_TO_VSID' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[1], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_BRIDGE_IF_TO_VSID' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[2], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VSID_TO_VLAN_ID' })
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP, tunnel_map_ids[3], { 'SAI_TUNNEL_MAP_ATTR_TYPE': 'SAI_TUNNEL_MAP_TYPE_VSID_TO_BRIDGE_IF' })

# TODO: change types to NVGRE
check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL, tunnel_id,
{
'SAI_TUNNEL_ATTR_TYPE': 'SAI_TUNNEL_TYPE_VXLAN',
'SAI_TUNNEL_ATTR_TYPE': 'SAI_TUNNEL_TYPE_NVGRE',
'SAI_TUNNEL_ATTR_UNDERLAY_INTERFACE': loopback_id,
'SAI_TUNNEL_ATTR_DECAP_MAPPERS': f'2:{tunnel_map_ids[2]},{tunnel_map_ids[3]}',
'SAI_TUNNEL_ATTR_ENCAP_MAPPERS': f'2:{tunnel_map_ids[0]},{tunnel_map_ids[1]}',
Expand Down Expand Up @@ -215,9 +214,9 @@ def check_nvgre_tunnel_map_entry(self, dvs, tunnel_name, vlan_id, vsid):

check_object(asic_db, SAI_OBJECT_TYPE_TUNNEL_MAP_ENTRY, tunnel_map_entry_id[0],
{
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP_TYPE': 'SAI_TUNNEL_MAP_TYPE_VNI_TO_VLAN_ID',
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP_TYPE': 'SAI_TUNNEL_MAP_TYPE_VSID_TO_VLAN_ID',
'SAI_TUNNEL_MAP_ENTRY_ATTR_TUNNEL_MAP': tunnel_map_ids[2],
'SAI_TUNNEL_MAP_ENTRY_ATTR_VNI_ID_KEY': vsid,
'SAI_TUNNEL_MAP_ENTRY_ATTR_VSID_ID_KEY': vsid,
'SAI_TUNNEL_MAP_ENTRY_ATTR_VLAN_ID_VALUE': vlan_id,
}
)
Expand Down

0 comments on commit 6b26af5

Please sign in to comment.