Skip to content

Commit

Permalink
Implement tagging mode for VLAN_MEMBER_TABLE (sonic-net#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-shirshov authored Jun 1, 2017
1 parent 682d7cb commit 3a9be95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,23 @@ void PortsOrch::doVlanMemberTask(Consumer &consumer)

if (op == SET_COMMAND)
{
string tagging_mode = "untagged";

for (auto i : kfvFieldsValues(t))
{
if (fvField(i) == "tagging_mode")
tagging_mode = fvValue(i);
}

if (tagging_mode != "untagged" &&
tagging_mode != "tagged" &&
tagging_mode != "priority_tagged")
{
SWSS_LOG_ERROR("Wrong tagging_mode '%s' for key: %s", tagging_mode.c_str(), kfvKey(t).c_str());
it = consumer.m_toSync.erase(it);
continue;
}

/* Duplicate entry */
if (vlan.m_members.find(port_alias) != vlan.m_members.end())
{
Expand All @@ -565,7 +582,7 @@ void PortsOrch::doVlanMemberTask(Consumer &consumer)
/* Assert the port doesn't belong to any VLAN */
assert(!port.m_vlan_id && !port.m_vlan_member_id);

if (addVlanMember(vlan, port))
if (addVlanMember(vlan, port, tagging_mode))
it = consumer.m_toSync.erase(it);
else
it++;
Expand Down Expand Up @@ -952,7 +969,7 @@ bool PortsOrch::removeVlan(Port vlan)
return true;
}

bool PortsOrch::addVlanMember(Port vlan, Port port)
bool PortsOrch::addVlanMember(Port vlan, Port port, string& tagging_mode)
{
SWSS_LOG_ENTER();

Expand All @@ -967,6 +984,16 @@ bool PortsOrch::addVlanMember(Port vlan, Port port)
attr.value.oid = port.m_port_id;
attrs.push_back(attr);

attr.id = SAI_VLAN_MEMBER_ATTR_TAGGING_MODE;
if (tagging_mode == "untagged")
attr.value.s32 = SAI_VLAN_PORT_UNTAGGED;
else if (tagging_mode == "tagged")
attr.value.s32 = SAI_VLAN_PORT_TAGGED;
else if (tagging_mode == "priority_tagged")
attr.value.s32 = SAI_VLAN_PORT_PRIORITY_TAGGED;
else assert(false);
attrs.push_back(attr);

sai_object_id_t vlan_member_id;
sai_status_t status = sai_vlan_api->create_vlan_member(&vlan_member_id, attrs.size(), attrs.data());

Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PortsOrch : public Orch, public Subject

bool addVlan(string vlan);
bool removeVlan(Port vlan);
bool addVlanMember(Port vlan, Port port);
bool addVlanMember(Port vlan, Port port, string& tagging_mode);
bool removeVlanMember(Port vlan, Port port);

bool addLag(string lag);
Expand Down

0 comments on commit 3a9be95

Please sign in to comment.