-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orchagent: Host interface tag processing #328
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,11 @@ static const vector<sai_queue_stat_t> queueStatIds = | |
SAI_QUEUE_STAT_DROPPED_BYTES | ||
}; | ||
|
||
static char* hostif_vlan_tag[] = { | ||
[SAI_HOSTIF_VLAN_TAG_STRIP] = "SAI_HOSTIF_VLAN_TAG_STRIP", | ||
[SAI_HOSTIF_VLAN_TAG_KEEP] = "SAI_HOSTIF_VLAN_TAG_KEEP", | ||
[SAI_HOSTIF_VLAN_TAG_ORIGINAL] = "SAI_HOSTIF_VLAN_TAG_ORIGINAL" | ||
}; | ||
/* | ||
* Initialize PortsOrch | ||
* 0) By default, a switch has one CPU port, one 802.1Q bridge, and one default | ||
|
@@ -563,6 +568,50 @@ bool PortsOrch::getPortPvid(Port &port, sai_uint32_t &pvid) | |
return true; | ||
} | ||
|
||
bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
vector<Port> portv; | ||
|
||
/* | ||
* Before SAI_HOSTIF_VLAN_TAG_ORIGINAL is supported by libsai from all asic vendors, | ||
* the VLAN tag on hostif is explicitly controlled with SAI_HOSTIF_VLAN_TAG_STRIP & | ||
* SAI_HOSTIF_VLAN_TAG_KEEP attributes. | ||
*/ | ||
if (port.m_type == Port::PHY) | ||
{ | ||
portv.push_back(port); | ||
} | ||
else if (port.m_type == Port::LAG) | ||
{ | ||
getLagMember(port, portv); | ||
} | ||
else | ||
{ | ||
SWSS_LOG_ERROR("port type %d not supported", port.m_type); | ||
return false; | ||
} | ||
|
||
for (const auto p: portv) | ||
{ | ||
sai_attribute_t attr; | ||
attr.id = SAI_HOSTIF_ATTR_VLAN_TAG; | ||
attr.value.s32 = strip; | ||
|
||
sai_status_t status = sai_hostif_api->set_hostif_attribute(p.m_hif_id, &attr); | ||
if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s to host interface %s", | ||
hostif_vlan_tag[strip], p.m_alias.c_str()); | ||
return false; | ||
} | ||
SWSS_LOG_NOTICE("Set %s to host interface: %s", | ||
hostif_vlan_tag[strip], p.m_alias.c_str()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool PortsOrch::validatePortSpeed(sai_object_id_t port_id, sai_uint32_t speed) | ||
{ | ||
sai_attribute_t attr; | ||
|
@@ -1633,7 +1682,7 @@ bool PortsOrch::initializePort(Port &p) | |
initializeQueues(p); | ||
|
||
/* Create host interface */ | ||
addHostIntfs(p.m_port_id, p.m_alias, p.m_hif_id); | ||
addHostIntfs(p, p.m_alias, p.m_hif_id); | ||
|
||
#if 0 | ||
// TODO: Assure if_nametoindex(p.m_alias.c_str()) != 0 | ||
|
@@ -1661,7 +1710,7 @@ bool PortsOrch::initializePort(Port &p) | |
return true; | ||
} | ||
|
||
bool PortsOrch::addHostIntfs(sai_object_id_t id, string alias, sai_object_id_t &host_intfs_id) | ||
bool PortsOrch::addHostIntfs(Port &port, string alias, sai_object_id_t &host_intfs_id) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
|
@@ -1673,7 +1722,7 @@ bool PortsOrch::addHostIntfs(sai_object_id_t id, string alias, sai_object_id_t & | |
attrs.push_back(attr); | ||
|
||
attr.id = SAI_HOSTIF_ATTR_OBJ_ID; | ||
attr.value.oid = id; | ||
attr.value.oid = port.m_port_id; | ||
attrs.push_back(attr); | ||
|
||
attr.id = SAI_HOSTIF_ATTR_NAME; | ||
|
@@ -1738,6 +1787,12 @@ bool PortsOrch::addBridgePort(Port &port) | |
return false; | ||
} | ||
|
||
if (!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_KEEP)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s for hostif of port %s", | ||
hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_KEEP], port.m_alias.c_str()); | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's move this to addVlanMember(), in the untagged mode, we do not need to call KEEP. |
||
m_portList[port.m_alias] = port; | ||
SWSS_LOG_NOTICE("Add bridge port %s to default 1Q bridge", port.m_alias.c_str()); | ||
|
||
|
@@ -1765,6 +1820,13 @@ bool PortsOrch::removeBridgePort(Port &port) | |
return false; | ||
} | ||
|
||
if (!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_STRIP)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s for hostif of port %s", | ||
hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_STRIP], port.m_alias.c_str()); | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move this to removeVlanMember() |
||
|
||
/* Flush FDB entries pointing to this bridge port */ | ||
// TODO: Remove all FDB entries associated with this bridge port before | ||
// removing the bridge port itself | ||
|
@@ -2047,6 +2109,15 @@ bool PortsOrch::addLagMember(Port &lag, Port &port) | |
|
||
m_portList[lag.m_alias] = lag; | ||
|
||
if (lag.m_bridge_port_id > 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also check if the port belongs to multiple vlans or not, if yes then add keep, otherwise do not need to do anything. |
||
{ | ||
if (!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_KEEP)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s for hostif of port %s which is in LAG %s", | ||
hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_KEEP], port.m_alias.c_str(), lag.m_alias.c_str()); | ||
return false; | ||
} | ||
} | ||
sai_uint32_t pvid; | ||
if (getPortPvid(lag, pvid)) | ||
{ | ||
|
@@ -2079,6 +2150,15 @@ bool PortsOrch::removeLagMember(Port &lag, Port &port) | |
lag.m_members.erase(port.m_alias); | ||
m_portList[lag.m_alias] = lag; | ||
|
||
if (lag.m_bridge_port_id > 0) | ||
{ | ||
if (!setHostIntfsStripTag(port, SAI_HOSTIF_VLAN_TAG_STRIP)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set %s for hostif of port %s which is leaving LAG %s", | ||
hostif_vlan_tag[SAI_HOSTIF_VLAN_TAG_STRIP], port.m_alias.c_str(), lag.m_alias.c_str()); | ||
return false; | ||
} | ||
} | ||
LagMemberUpdate update = { lag, port, false }; | ||
notify(SUBJECT_TYPE_LAG_MEMBER_CHANGE, static_cast<void *>(&update)); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
align the spaces, or just use 8 spaces. same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done