Skip to content

Commit

Permalink
fix the issue where port sai oid not correct when speed change is don…
Browse files Browse the repository at this point in the history
…e from 400G to 100G

Fixes: sonic-net/sonic-buildimage#14706
  • Loading branch information
abdosi authored Jul 3, 2023
1 parent ba8ccba commit 72d2c1e
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions test/saithrift/src/switch_sai_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,13 +1685,29 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf {
port_lane_list_attribute.value.u32list.count = 8;
port_api->get_port_attribute(port_list_object_attribute.value.objlist.list[i], 1, &port_lane_list_attribute);

std::set<int> port_lanes;
uint32_t laneCnt = port_lane_list_attribute.value.u32list.count;
for (int j=0 ; j<laneCnt; j++){
port_lanes.insert(port_lane_list_attribute.value.u32list.list[j]);
uint32_t laneMatchCount = 0;

for (gPortMapIt = gPortMap.begin(); gPortMapIt != gPortMap.end(); gPortMapIt++)
{
laneMatchCount = 0;
for (int j=0; j<laneCnt; j++)
{
if (gPortMapIt->first.count(port_lane_list_attribute.value.u32list.list[j]))
{
laneMatchCount++;
}
else
{
break;
}
}
if (laneMatchCount == laneCnt)
{
break;
}
}

gPortMapIt = gPortMap.find(port_lanes);
if (gPortMapIt != gPortMap.end()){
std::string front_port_alias = gPortMapIt->second.c_str();
std::string front_port_number;
Expand Down Expand Up @@ -1774,13 +1790,20 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf {
port_lane_list_attribute.value.u32list.count = 8;
port_api->get_port_attribute(port_list_object_attribute.value.objlist.list[i], 1, &port_lane_list_attribute);

std::set<int> port_lanes;
uint32_t laneCnt = port_lane_list_attribute.value.u32list.count;
for (int j=0 ; j<laneCnt; j++){
port_lanes.insert(port_lane_list_attribute.value.u32list.list[j]);
uint32_t laneMatchCount = 0;
for (int j=0 ; j<laneCnt; j++)
{
if (lane_set.count(port_lane_list_attribute.value.u32list.list[j]))
{
laneMatchCount++;
}
else
{
break;
}
}

if (port_lanes == lane_set){
if (laneCnt == laneMatchCount){
port_id = (sai_thrift_object_id_t) port_list_object_attribute.value.objlist.list[i];
free(port_list_object_attribute.value.objlist.list);
free(port_lane_list_attribute.value.u32list.list);
Expand Down

0 comments on commit 72d2c1e

Please sign in to comment.