diff --git a/orchagent/p4orch/tests/fake_portorch.cpp b/orchagent/p4orch/tests/fake_portorch.cpp index f9098f663918..d2b7651a882c 100644 --- a/orchagent/p4orch/tests/fake_portorch.cpp +++ b/orchagent/p4orch/tests/fake_portorch.cpp @@ -606,6 +606,11 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin return true; } +bool PortsOrch::isAutoNegEnabled(sai_object_id_t id) +{ + return true; +} + task_process_status PortsOrch::setPortAutoNeg(sai_object_id_t id, int an) { return task_success; diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 7748ab4c8240..eaeba5ae82ad 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2484,6 +2484,23 @@ bool PortsOrch::getQueueTypeAndIndex(sai_object_id_t queue_id, string &type, uin return true; } +bool PortsOrch::isAutoNegEnabled(sai_object_id_t id) +{ + SWSS_LOG_ENTER(); + + sai_attribute_t attr; + attr.id = SAI_PORT_ATTR_AUTO_NEG_MODE; + + sai_status_t status = sai_port_api->get_port_attribute(id, 1, &attr); + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("Failed to get port AutoNeg status for port pid:%" PRIx64, id); + return false; + } + + return attr.value.booldata; +} + task_process_status PortsOrch::setPortAutoNeg(sai_object_id_t id, int an) { SWSS_LOG_ENTER(); @@ -4758,7 +4775,7 @@ bool PortsOrch::initializePort(Port &port) } /* initialize port admin speed */ - if (!getPortSpeed(port.m_port_id, port.m_speed)) + if (!isAutoNegEnabled(port.m_port_id) && !getPortSpeed(port.m_port_id, port.m_speed)) { SWSS_LOG_ERROR("Failed to get initial port admin speed %d", port.m_speed); return false; diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 446d6bc8de45..cec49a7bda51 100644 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -363,6 +363,7 @@ class PortsOrch : public Orch, public Subject bool m_isPortCounterMapGenerated = false; bool m_isPortBufferDropCounterMapGenerated = false; + bool isAutoNegEnabled(sai_object_id_t id); task_process_status setPortAutoNeg(sai_object_id_t id, int an); bool setPortFecMode(sai_object_id_t id, int fec); task_process_status setPortInterfaceType(sai_object_id_t id, sai_port_interface_type_t interface_type);