Skip to content

Commit

Permalink
optimize port state refresh logic
Browse files Browse the repository at this point in the history
Signed-off-by: Dante Su <dante.su@broadcom.com>
  • Loading branch information
ds952811 committed May 23, 2022
1 parent 081d491 commit 18632a3
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6005,36 +6005,17 @@ void PortsOrch::updatePortOperStatus(Port &port, sai_port_oper_status_t status)
if (port.m_type == Port::PHY)
{
updateDbPortOperStatus(port, status);
if (port.m_admin_state_up && port.m_autoneg > 0)

/* Refresh the port states and reschedule the poller tasks */
if (port.m_autoneg > 0)
{
if (status == SAI_PORT_OPER_STATUS_UP)
{
/* Refresh AN port states */
refreshPortStateAutoNeg(port);
/* Stop port state polling for AN */
updatePortStatePoll(port, PORT_STATE_POLL_AN, false);
}
else
{
/* Restart autoneg state polling upon link down event */
m_portStateTable.hdel(port.m_alias, "rmt_adv_speeds");
updatePortStatePoll(port, PORT_STATE_POLL_AN, true);
}
refreshPortStateAutoNeg(port);
updatePortStatePoll(port, PORT_STATE_POLL_AN, !(status == SAI_PORT_OPER_STATUS_UP));
}
if (port.m_admin_state_up && port.m_link_training > 0)
if (port.m_link_training > 0)
{
/* Refresh LT port states for both link up and down */
refreshPortStateLinkTraining(port);
if (status == SAI_PORT_OPER_STATUS_UP)
{
/* Stop port state polling for LT */
updatePortStatePoll(port, PORT_STATE_POLL_LT, false);
}
else
{
/* Restart port state polling upon link down event */
updatePortStatePoll(port, PORT_STATE_POLL_LT, true);
}
updatePortStatePoll(port, PORT_STATE_POLL_LT, !(status == SAI_PORT_OPER_STATUS_UP));
}
}
port.m_oper_status = status;
Expand Down Expand Up @@ -7231,17 +7212,18 @@ void PortsOrch::refreshPortStateAutoNeg(const Port &port)
return;
}

string adv_speeds;
string adv_speeds = "N/A";

if (getPortAdvSpeeds(port, true, adv_speeds))
{
m_portStateTable.hset(port.m_alias, "rmt_adv_speeds", adv_speeds);
}
else
if (port.m_admin_state_up)
{
m_portStateTable.hset(port.m_alias, "rmt_adv_speeds", "N/A");
updatePortStatePoll(port, PORT_STATE_POLL_AN, false);
if (!getPortAdvSpeeds(port, true, adv_speeds))
{
adv_speeds = "N/A";
updatePortStatePoll(port, PORT_STATE_POLL_AN, false);
}
}

m_portStateTable.hset(port.m_alias, "rmt_adv_speeds", adv_speeds);
}

/* Refresh the per-port Link-Training operational states */
Expand All @@ -7256,7 +7238,7 @@ void PortsOrch::refreshPortStateLinkTraining(const Port &port)

string status = "off";

if ((port.m_link_training > 0) && (port.m_cap_lt > 0))
if (port.m_admin_state_up && port.m_link_training > 0 && port.m_cap_lt > 0)
{
sai_port_link_training_rx_status_t rx_status;
sai_port_link_training_failure_status_t failure;
Expand Down

0 comments on commit 18632a3

Please sign in to comment.