Skip to content

Commit

Permalink
Cherry-pick of Master PR: #1814 in v1.10
Browse files Browse the repository at this point in the history
Cherry-pick of Master PR: #1814 in v1.10
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
  • Loading branch information
abdosi authored Jul 13, 2023
1 parent 161f9f7 commit b5faa57
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 b5faa57

Please sign in to comment.