Skip to content

Commit

Permalink
[portsorch] Fix port queue index init bug (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangbashuang authored and Shuotian Cheng committed Nov 21, 2018
1 parent 70ac79b commit 6c70f6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 13 additions & 9 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,21 +1056,22 @@ bool PortsOrch::setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed)
return status == SAI_STATUS_SUCCESS;
}

bool PortsOrch::getQueueType(sai_object_id_t queue_id, string &type)
bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
attr.id = SAI_QUEUE_ATTR_TYPE;
sai_attribute_t attr[2];
attr[0].id = SAI_QUEUE_ATTR_TYPE;
attr[1].id = SAI_QUEUE_ATTR_INDEX;

sai_status_t status = sai_queue_api->get_queue_attribute(queue_id, 1, &attr);
sai_status_t status = sai_queue_api->get_queue_attribute(queue_id, 2, attr);
if (status != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to get queue type for queue %lu rv:%d", queue_id, status);
SWSS_LOG_ERROR("Failed to get queue type and index for queue %lu rv:%d", queue_id, status);
return false;
}

switch (attr.value.s32)
switch (attr[0].value.s32)
{
case SAI_QUEUE_TYPE_ALL:
type = "SAI_QUEUE_TYPE_ALL";
Expand All @@ -1082,10 +1083,12 @@ bool PortsOrch::getQueueType(sai_object_id_t queue_id, string &type)
type = "SAI_QUEUE_TYPE_MULTICAST";
break;
default:
SWSS_LOG_ERROR("Got unsupported queue type %d for %lu queue", attr.value.s32, queue_id);
SWSS_LOG_ERROR("Got unsupported queue type %d for %lu queue", attr[0].value.s32, queue_id);
throw runtime_error("Got unsupported queue type");
}

index = attr[1].value.u8;

return true;
}

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

queueVector.emplace_back(name.str(), id);
queuePortVector.emplace_back(id, sai_serialize_object_id(port.m_port_id));
queueIndexVector.emplace_back(id, to_string(queueIndex));

string queueType;
if (getQueueType(port.m_queue_ids[queueIndex], queueType))
uint8_t queueRealIndex = 0;
if (getQueueTypeAndIndex(port.m_queue_ids[queueIndex], queueType, queueRealIndex))
{
queueTypeVector.emplace_back(id, queueType);
queueIndexVector.emplace_back(id, to_string(queueRealIndex));
}

string key = getQueueFlexCounterTableKey(id);
Expand Down
4 changes: 2 additions & 2 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class PortsOrch : public Orch, public Subject
bool getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed);

bool setPortAdvSpeed(sai_object_id_t port_id, sai_uint32_t speed);

bool getQueueType(sai_object_id_t queue_id, string &type);
bool getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uint8_t &index);

bool m_isQueueMapGenerated = false;
void generateQueueMapPerPort(const Port& port);
Expand Down

0 comments on commit 6c70f6d

Please sign in to comment.