From 3a9be95e54149e3287851ad0e9dd766bac7f5992 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Thu, 1 Jun 2017 12:18:59 -0700 Subject: [PATCH] Implement tagging mode for VLAN_MEMBER_TABLE (#233) --- orchagent/portsorch.cpp | 31 +++++++++++++++++++++++++++++-- orchagent/portsorch.h | 2 +- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index dc22f29a9413..bcff868cd828 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -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()) { @@ -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++; @@ -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(); @@ -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()); diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 0dfe0aba0a37..debb9a3e7c05 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -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);