Skip to content

Commit

Permalink
Changes #6 modifying vlan flood type set
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Jun 15, 2021
1 parent 5db32ee commit c5766fe
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 81 deletions.
1 change: 0 additions & 1 deletion orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct VlanInfo
sai_vlan_id_t vlan_id = 0;
sai_object_id_t host_intf_id = SAI_NULL_OBJECT_ID;
sai_vlan_flood_control_type_t uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
sai_vlan_flood_control_type_t umc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
sai_vlan_flood_control_type_t bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
sai_object_id_t l2mc_group_id = SAI_NULL_OBJECT_ID;
endpoint_ip_l2mc_group_member_map_t l2mc_members;
Expand Down
132 changes: 53 additions & 79 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,23 +418,6 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames,
}
}

supported_flood_control_types.assign(max_flood_control_types, 0);
values.count = max_flood_control_types;
values.list = supported_flood_control_types.data();

if (sai_query_attribute_enum_values_capability(gSwitchId, SAI_OBJECT_TYPE_VLAN,
SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE,
&values) != SAI_STATUS_SUCCESS)
{
SWSS_LOG_NOTICE("This device does not support unknown multicast flood control types");
}
else
{
for (uint32_t idx = 0; idx < values.count; idx++)
{
umc_sup_flood_control_type.insert(static_cast<sai_vlan_flood_control_type_t>(values.list[idx]));
}
}

supported_flood_control_types.assign(max_flood_control_types, 0);
values.count = max_flood_control_types;
Expand Down Expand Up @@ -3991,45 +3974,12 @@ bool PortsOrch::addVlan(string vlan_alias)
sai_object_id_t vlan_oid;

sai_vlan_id_t vlan_id = (uint16_t)stoi(vlan_alias.substr(4));
sai_vlan_flood_control_type_t uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
sai_vlan_flood_control_type_t umc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
sai_vlan_flood_control_type_t bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
vector<sai_attribute_t> attrs;
sai_attribute_t attr;

attr.id = SAI_VLAN_ATTR_VLAN_ID;
attr.value.u16 = vlan_id;
attrs.push_back(attr);

if(uuc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
!= uuc_sup_flood_control_type.end())
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
attrs.push_back(attr);
uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
}

if(umc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
!= umc_sup_flood_control_type.end())
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
attrs.push_back(attr);
umc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
}

if(bc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
!= umc_sup_flood_control_type.end())
{
attr.id = SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
attrs.push_back(attr);
bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
}

sai_status_t status = sai_vlan_api->create_vlan(&vlan_oid, gSwitchId,
static_cast<uint32_t>(attrs.size()), attrs.data());
sai_status_t status = sai_vlan_api->create_vlan(&vlan_oid, gSwitchId, 1, &attr);

if (status != SAI_STATUS_SUCCESS)
{
Expand All @@ -4046,9 +3996,8 @@ bool PortsOrch::addVlan(string vlan_alias)
Port vlan(vlan_alias, Port::VLAN);
vlan.m_vlan_info.vlan_oid = vlan_oid;
vlan.m_vlan_info.vlan_id = vlan_id;
vlan.m_vlan_info.uuc_flood_type = uuc_flood_type;
vlan.m_vlan_info.umc_flood_type = umc_flood_type;
vlan.m_vlan_info.bc_flood_type = bc_flood_type;
vlan.m_vlan_info.uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
vlan.m_vlan_info.bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
vlan.m_members = set<string>();
m_portList[vlan_alias] = vlan;
m_port_ref_count[vlan_alias] = 0;
Expand Down Expand Up @@ -4136,6 +4085,36 @@ bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string end_point_ip)
sai_status_t status;
sai_attribute_t attr;

if (vlan.m_vlan_info.uuc_flood_type != SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set l2mc flood type combined "
" to vlan %hu for unknown unicast flooding", vlan.m_vlan_info.vlan_id);
return false;
}
vlan.m_vlan_info.uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
}

if (vlan.m_vlan_info.bc_flood_type != SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set l2mc flood type combined "
" to vlan %hu for broadcast flooding", vlan.m_vlan_info.vlan_id);
return false;
}
vlan.m_vlan_info.bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED;
}

if (vlan.m_vlan_info.l2mc_group_id == SAI_NULL_OBJECT_ID)
{
status = sai_l2mc_group_api->create_l2mc_group(&l2mc_group_id, gSwitchId, 0, NULL);
Expand All @@ -4159,20 +4138,6 @@ bool PortsOrch::addVlanFloodGroups(Port &vlan, Port &port, string end_point_ip)
return false;
}
}
if (vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE;
attr.value.oid = l2mc_group_id;

status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set l2mc group %" PRIx64
" to vlan %hu for unknown multicast flooding",
l2mc_group_id, vlan.m_vlan_info.vlan_id);
return false;
}
}
if (vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_BROADCAST_FLOOD_GROUP;
Expand Down Expand Up @@ -4273,9 +4238,10 @@ bool PortsOrch::addVlanMember(Port &vlan, Port &port, string &tagging_mode, stri
sai_object_id_t vlan_member_id;
if (!end_point_ip.empty())
{
if (!((vlan.m_vlan_info.uuc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED) ||
(vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)))
if ((uuc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== uuc_sup_flood_control_type.end()) ||
(bc_sup_flood_control_type.find(SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
== bc_sup_flood_control_type.end()))
{
SWSS_LOG_ERROR("Flood group with end point ip is not supported");
return false;
Expand Down Expand Up @@ -4357,20 +4323,17 @@ bool PortsOrch::removeVlanEndPointIp(Port &vlan, Port &port, string end_point_ip
vlan.m_vlan_info.vlan_id);
return false;
}
}
if (vlan.m_vlan_info.umc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
attr.id = SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE;
attr.value.oid = SAI_NULL_OBJECT_ID;

attr.id = SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set null l2mc group "
" to vlan %hu for unknown multicast flooding",
SWSS_LOG_ERROR("Failed to set flood control type all"
" to vlan %hu for unknown unicast flooding",
vlan.m_vlan_info.vlan_id);
return false;
}
vlan.m_vlan_info.uuc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
}
if (vlan.m_vlan_info.bc_flood_type == SAI_VLAN_FLOOD_CONTROL_TYPE_COMBINED)
{
Expand All @@ -4385,6 +4348,17 @@ bool PortsOrch::removeVlanEndPointIp(Port &vlan, Port &port, string end_point_ip
vlan.m_vlan_info.vlan_id);
return false;
}
attr.id = SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE;
attr.value.s32 = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
status = sai_vlan_api->set_vlan_attribute(vlan.m_vlan_info.vlan_oid, &attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to set flood control type all"
" to vlan %hu for broadcast flooding",
vlan.m_vlan_info.vlan_id);
return false;
}
vlan.m_vlan_info.bc_flood_type = SAI_VLAN_FLOOD_CONTROL_TYPE_ALL;
}
status = sai_l2mc_group_api->remove_l2mc_group(vlan.m_vlan_info.l2mc_group_id);
if (status != SAI_STATUS_SUCCESS)
Expand Down
1 change: 0 additions & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ class PortsOrch : public Orch, public Subject
unordered_set<string> m_pendingPortSet;
uint32_t max_flood_control_types = 4;
set<sai_vlan_flood_control_type_t> uuc_sup_flood_control_type;
set<sai_vlan_flood_control_type_t> umc_sup_flood_control_type;
set<sai_vlan_flood_control_type_t> bc_sup_flood_control_type;

NotificationConsumer* m_portStatusNotificationConsumer;
Expand Down

0 comments on commit c5766fe

Please sign in to comment.