@@ -394,12 +394,23 @@ bool PortsOrch::allPortsReady()
394
394
return m_initDone && m_pendingPortSet.empty ();
395
395
}
396
396
397
- /* Upon receiving PortInitDone, all the configured ports have been created*/
397
+ /* Upon receiving PortInitDone, all the configured ports have been created in both hardware and kernel */
398
398
bool PortsOrch::isInitDone ()
399
399
{
400
400
return m_initDone;
401
401
}
402
402
403
+ // Upon m_portConfigState transiting to PORT_CONFIG_DONE state, all physical ports have been "created" in hardware.
404
+ // Because of the asynchronous nature of sairedis calls, "create" in the strict sense means that the SAI create_port()
405
+ // function is called and the create port event has been pushed to the sairedis pipeline. Because sairedis pipeline
406
+ // preserves the order of the events received, any event that depends on the physical port being created first, e.g.,
407
+ // buffer profile apply, will be popped in the FIFO fashion, processed in the right order after the physical port is
408
+ // physically created in the ASIC, and thus can be issued safely when this function call returns true.
409
+ bool PortsOrch::isConfigDone ()
410
+ {
411
+ return m_portConfigState == PORT_CONFIG_DONE;
412
+ }
413
+
403
414
bool PortsOrch::isPortAdminUp (const string &alias)
404
415
{
405
416
auto it = m_portList.find (alias);
@@ -1513,14 +1524,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
1513
1524
1514
1525
if (alias == " PortConfigDone" )
1515
1526
{
1516
- if (m_portConfigDone )
1527
+ if (m_portConfigState != PORT_CONFIG_MISSING )
1517
1528
{
1518
- // Already done , ignore this task
1529
+ // Already received , ignore this task
1519
1530
it = consumer.m_toSync .erase (it);
1520
1531
continue ;
1521
1532
}
1522
1533
1523
- m_portConfigDone = true ;
1534
+ m_portConfigState = PORT_CONFIG_RECEIVED ;
1524
1535
1525
1536
for (auto i : kfvFieldsValues (t))
1526
1537
{
@@ -1652,7 +1663,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
1652
1663
* 2. Create new ports
1653
1664
* 3. Initialize all ports
1654
1665
*/
1655
- if (m_portConfigDone && (m_lanesAliasSpeedMap.size () == m_portCount))
1666
+ if (m_portConfigState == PORT_CONFIG_RECEIVED && (m_lanesAliasSpeedMap.size () == m_portCount))
1656
1667
{
1657
1668
for (auto it = m_portListLaneMap.begin (); it != m_portListLaneMap.end ();)
1658
1669
{
@@ -1697,9 +1708,11 @@ void PortsOrch::doPortTask(Consumer &consumer)
1697
1708
1698
1709
it = m_lanesAliasSpeedMap.erase (it);
1699
1710
}
1711
+
1712
+ m_portConfigState = PORT_CONFIG_DONE;
1700
1713
}
1701
1714
1702
- if (!m_portConfigDone )
1715
+ if (m_portConfigState != PORT_CONFIG_DONE )
1703
1716
{
1704
1717
// Not yet receive PortConfigDone. Save it for future retry
1705
1718
it++;
0 commit comments