Skip to content

Commit 6c70f6d

Browse files
yangbashuangShuotian Cheng
authored and
Shuotian Cheng
committed
[portsorch] Fix port queue index init bug (sonic-net#505)
1 parent 70ac79b commit 6c70f6d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

orchagent/portsorch.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -1056,21 +1056,22 @@ bool PortsOrch::setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed)
10561056
return status == SAI_STATUS_SUCCESS;
10571057
}
10581058

1059-
bool PortsOrch::getQueueType(sai_object_id_t queue_id, string &type)
1059+
bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index)
10601060
{
10611061
SWSS_LOG_ENTER();
10621062

1063-
sai_attribute_t attr;
1064-
attr.id = SAI_QUEUE_ATTR_TYPE;
1063+
sai_attribute_t attr[2];
1064+
attr[0].id = SAI_QUEUE_ATTR_TYPE;
1065+
attr[1].id = SAI_QUEUE_ATTR_INDEX;
10651066

1066-
sai_status_t status = sai_queue_api->get_queue_attribute(queue_id, 1, &attr);
1067+
sai_status_t status = sai_queue_api->get_queue_attribute(queue_id, 2, attr);
10671068
if (status != SAI_STATUS_SUCCESS)
10681069
{
1069-
SWSS_LOG_ERROR("Failed to get queue type for queue %lu rv:%d", queue_id, status);
1070+
SWSS_LOG_ERROR("Failed to get queue type and index for queue %lu rv:%d", queue_id, status);
10701071
return false;
10711072
}
10721073

1073-
switch (attr.value.s32)
1074+
switch (attr[0].value.s32)
10741075
{
10751076
case SAI_QUEUE_TYPE_ALL:
10761077
type = "SAI_QUEUE_TYPE_ALL";
@@ -1082,10 +1083,12 @@ bool PortsOrch::getQueueType(sai_object_id_t queue_id, string &type)
10821083
type = "SAI_QUEUE_TYPE_MULTICAST";
10831084
break;
10841085
default:
1085-
SWSS_LOG_ERROR("Got unsupported queue type %d for %lu queue", attr.value.s32, queue_id);
1086+
SWSS_LOG_ERROR("Got unsupported queue type %d for %lu queue", attr[0].value.s32, queue_id);
10861087
throw runtime_error("Got unsupported queue type");
10871088
}
10881089

1090+
index = attr[1].value.u8;
1091+
10891092
return true;
10901093
}
10911094

@@ -2867,12 +2870,13 @@ void PortsOrch::generateQueueMapPerPort(const Port& port)
28672870

28682871
queueVector.emplace_back(name.str(), id);
28692872
queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id));
2870-
queueIndexVector.emplace_back(id, to_string(queueIndex));
28712873

28722874
string queueType;
2873-
if (getQueueType(port.m_queue_ids[queueIndex], queueType))
2875+
uint8_t queueRealIndex = 0;
2876+
if (getQueueTypeAndIndex(port.m_queue_ids[queueIndex], queueType, queueRealIndex))
28742877
{
28752878
queueTypeVector.emplace_back(id, queueType);
2879+
queueIndexVector.emplace_back(id, to_string(queueRealIndex));
28762880
}
28772881

28782882
string key = getQueueFlexCounterTableKey(id);

orchagent/portsorch.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ class PortsOrch : public Orch, public Subject
160160
bool getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed);
161161

162162
bool setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed);
163-
164-
bool getQueueType(sai_object_id_t queue_id, string &type);
163+
164+
bool getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index);
165165

166166
bool m_isQueueMapGenerated = false;
167167
void generateQueueMapPerPort(const Port& port);

0 commit comments

Comments
 (0)