-
Notifications
You must be signed in to change notification settings - Fork 539
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
[sonic-swss:TPID CONFIG]Added Orchagent TPID config support for Port/LAG #1747
Changes from all commits
7c2768c
3522e81
37285d1
9bc5391
88619b0
a4855a7
88eea45
ef088bc
090a2b7
67b0f87
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 |
---|---|---|
|
@@ -968,6 +968,36 @@ bool PortsOrch::setPortMtu(sai_object_id_t id, sai_uint32_t mtu) | |
return true; | ||
} | ||
|
||
|
||
bool PortsOrch::setPortTpid(sai_object_id_t id, sai_uint16_t tpid) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
sai_status_t status = SAI_STATUS_SUCCESS; | ||
sai_attribute_t attr; | ||
|
||
attr.id = SAI_PORT_ATTR_TPID; | ||
|
||
attr.value.u16 = (uint16_t)tpid; | ||
|
||
status = sai_port_api->set_port_attribute(id, &attr); | ||
if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set TPID 0x%x to port pid:%" PRIx64 ", rv:%d", | ||
attr.value.u16, id, status); | ||
task_process_status handle_status = handleSaiSetStatus(SAI_API_PORT, status); | ||
if (handle_status != task_success) | ||
{ | ||
return parseHandleSaiStatusFailure(handle_status); | ||
} | ||
} | ||
else | ||
{ | ||
SWSS_LOG_NOTICE("Set TPID 0x%x to port pid:%" PRIx64, attr.value.u16, id); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
bool PortsOrch::setPortFec(Port &port, sai_port_fec_mode_t mode) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
@@ -2451,6 +2481,8 @@ void PortsOrch::doPortTask(Consumer &consumer) | |
vector<uint32_t> adv_speeds; | ||
sai_port_interface_type_t interface_type; | ||
vector<uint32_t> adv_interface_types; | ||
string tpid_string; | ||
uint16_t tpid = 0; | ||
|
||
for (auto i : kfvFieldsValues(t)) | ||
{ | ||
|
@@ -2482,6 +2514,15 @@ void PortsOrch::doPortTask(Consumer &consumer) | |
{ | ||
mtu = (uint32_t)stoul(fvValue(i)); | ||
} | ||
/* Set port TPID */ | ||
if (fvField(i) == "tpid") | ||
{ | ||
tpid_string = fvValue(i); | ||
// Need to get rid of the leading 0x | ||
tpid_string.erase(0,2); | ||
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. Is it better to use str.find and then str.erase(0, pos)? Do we always expect a 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. The CLI enforces that the TPID values must be one of the following: "0x8100", "0x9100", "0x9200", or "0x88A8". |
||
tpid = (uint16_t)stoi(tpid_string, 0, 16); | ||
SWSS_LOG_DEBUG("Handling TPID to 0x%x, string value:%s", tpid, tpid_string.c_str()); | ||
} | ||
/* Set port speed */ | ||
else if (fvField(i) == "speed") | ||
{ | ||
|
@@ -2914,6 +2955,22 @@ void PortsOrch::doPortTask(Consumer &consumer) | |
} | ||
} | ||
|
||
if (tpid != 0 && tpid != p.m_tpid) | ||
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. How do we reset? I think the check should be just 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. In this case "tpid !=0" check serves the purpose of identifying whether it is handling non-TPID operations in which case variable tpid is initialized to "0" and there is no need to perform TPID operation. This is inline with how MTU and speed setting is being handled. Hope this explains why this check is required. |
||
{ | ||
SWSS_LOG_DEBUG("Set port %s TPID to 0x%x", alias.c_str(), tpid); | ||
if (setPortTpid(p.m_port_id, tpid)) | ||
{ | ||
p.m_tpid = tpid; | ||
m_portList[alias] = p; | ||
} | ||
else | ||
{ | ||
SWSS_LOG_ERROR("Failed to set port %s TPID to 0x%x", alias.c_str(), tpid); | ||
it++; | ||
continue; | ||
} | ||
} | ||
|
||
if (!fec_mode.empty()) | ||
{ | ||
if (fec_mode_map.find(fec_mode) != fec_mode_map.end()) | ||
|
@@ -3366,6 +3423,8 @@ void PortsOrch::doLagTask(Consumer &consumer) | |
string operation_status; | ||
uint32_t lag_id = 0; | ||
int32_t switch_id = -1; | ||
string tpid_string; | ||
uint16_t tpid = 0; | ||
|
||
for (auto i : kfvFieldsValues(t)) | ||
{ | ||
|
@@ -3395,6 +3454,14 @@ void PortsOrch::doLagTask(Consumer &consumer) | |
{ | ||
switch_id = stoi(fvValue(i)); | ||
} | ||
else if (fvField(i) == "tpid") | ||
{ | ||
tpid_string = fvValue(i); | ||
// Need to get rid of the leading 0x | ||
tpid_string.erase(0,2); | ||
tpid = (uint16_t)stoi(tpid_string, 0, 16); | ||
SWSS_LOG_DEBUG("reading TPID string:%s to uint16: 0x%x", tpid_string.c_str(), tpid); | ||
} | ||
} | ||
|
||
if (table_name == CHASSIS_APP_LAG_TABLE_NAME) | ||
|
@@ -3451,6 +3518,23 @@ void PortsOrch::doLagTask(Consumer &consumer) | |
updateChildPortsMtu(l, mtu); | ||
} | ||
|
||
if (tpid != 0) | ||
{ | ||
if (tpid != l.m_tpid) | ||
{ | ||
if(!setLagTpid(l.m_lag_id, tpid)) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set LAG %s TPID 0x%x", alias.c_str(), tpid); | ||
} | ||
else | ||
{ | ||
SWSS_LOG_DEBUG("Set LAG %s TPID to 0x%x", alias.c_str(), tpid); | ||
l.m_tpid = tpid; | ||
m_portList[alias] = l; | ||
} | ||
} | ||
} | ||
|
||
if (!learn_mode.empty() && (l.m_learn_mode != learn_mode)) | ||
{ | ||
if (l.m_bridge_port_id != SAI_NULL_OBJECT_ID) | ||
|
@@ -4656,6 +4740,35 @@ bool PortsOrch::removeLagMember(Port &lag, Port &port) | |
return true; | ||
} | ||
|
||
bool PortsOrch::setLagTpid(sai_object_id_t id, sai_uint16_t tpid) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
sai_status_t status = SAI_STATUS_SUCCESS; | ||
sai_attribute_t attr; | ||
|
||
attr.id = SAI_LAG_ATTR_TPID; | ||
|
||
attr.value.u16 = (uint16_t)tpid; | ||
|
||
status = sai_lag_api->set_lag_attribute(id, &attr); | ||
if (status != SAI_STATUS_SUCCESS) | ||
{ | ||
SWSS_LOG_ERROR("Failed to set TPID 0x%x to LAG pid:%" PRIx64 ", rv:%d", | ||
attr.value.u16, id, status); | ||
task_process_status handle_status = handleSaiSetStatus(SAI_API_LAG, status); | ||
if (handle_status != task_success) | ||
{ | ||
return parseHandleSaiStatusFailure(handle_status); | ||
} | ||
} | ||
else | ||
{ | ||
SWSS_LOG_NOTICE("Set TPID 0x%x to LAG pid:%" PRIx64 , attr.value.u16, id); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
bool PortsOrch::setCollectionOnLagMember(Port &lagMember, bool enableCollection) | ||
{ | ||
/* Port must be LAG member */ | ||
|
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.
Can we combine this with Lag to have single function and pass
is_lag
as boolean since only two lines are different and rest are the same? Just a suggestion.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.
There is a chance that we may end up having to implement the LAG handling by having Orchagent apply the LAG TPID config to all its LAG members. This is because currently only one SAI vendor supports TPID setting on Port only and not yet for LAG. For our fanout switch usage, this is already good enough. But if we ever want to apply it to LAG while SAI vendor not supporting it, it will be much easier to have the port/LAG handling having its own function to do the handling. So for now, let's keep the way it is just in case the enhancement is needed in the future.
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.
ok