Skip to content

Commit bb4e19c

Browse files
wendanilguohan
authored andcommitted
Not wait till kernel net_devices are created for all physical ports to (sonic-net#1109)
Apply buffer profiles when hardware physical ports are created Introduce a mini state machine to track the portConfigState transition on receiving event from APPL_DB PORT_TABLE Signed-off-by: Wenda Ni <[email protected]>
1 parent bab7b93 commit bb4e19c

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

orchagent/bufferorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ void BufferOrch::doTask(Consumer &consumer)
830830
{
831831
SWSS_LOG_ENTER();
832832

833-
if (!gPortsOrch->isInitDone())
833+
if (!gPortsOrch->isConfigDone())
834834
{
835835
return;
836836
}

orchagent/portsorch.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,23 @@ bool PortsOrch::allPortsReady()
394394
return m_initDone && m_pendingPortSet.empty();
395395
}
396396

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*/
398398
bool PortsOrch::isInitDone()
399399
{
400400
return m_initDone;
401401
}
402402

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+
403414
bool PortsOrch::isPortAdminUp(const string &alias)
404415
{
405416
auto it = m_portList.find(alias);
@@ -1513,14 +1524,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
15131524

15141525
if (alias == "PortConfigDone")
15151526
{
1516-
if (m_portConfigDone)
1527+
if (m_portConfigState != PORT_CONFIG_MISSING)
15171528
{
1518-
// Already done, ignore this task
1529+
// Already received, ignore this task
15191530
it = consumer.m_toSync.erase(it);
15201531
continue;
15211532
}
15221533

1523-
m_portConfigDone = true;
1534+
m_portConfigState = PORT_CONFIG_RECEIVED;
15241535

15251536
for (auto i : kfvFieldsValues(t))
15261537
{
@@ -1652,7 +1663,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
16521663
* 2. Create new ports
16531664
* 3. Initialize all ports
16541665
*/
1655-
if (m_portConfigDone && (m_lanesAliasSpeedMap.size() == m_portCount))
1666+
if (m_portConfigState == PORT_CONFIG_RECEIVED && (m_lanesAliasSpeedMap.size() == m_portCount))
16561667
{
16571668
for (auto it = m_portListLaneMap.begin(); it != m_portListLaneMap.end();)
16581669
{
@@ -1697,9 +1708,11 @@ void PortsOrch::doPortTask(Consumer &consumer)
16971708

16981709
it = m_lanesAliasSpeedMap.erase(it);
16991710
}
1711+
1712+
m_portConfigState = PORT_CONFIG_DONE;
17001713
}
17011714

1702-
if (!m_portConfigDone)
1715+
if (m_portConfigState != PORT_CONFIG_DONE)
17031716
{
17041717
// Not yet receive PortConfigDone. Save it for future retry
17051718
it++;

orchagent/portsorch.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject
5757

5858
bool allPortsReady();
5959
bool isInitDone();
60+
bool isConfigDone();
6061
bool isPortAdminUp(const string &alias);
6162

6263
map<string, Port>& getAllPorts();
@@ -116,7 +117,14 @@ class PortsOrch : public Orch, public Subject
116117
sai_object_id_t m_default1QBridge;
117118
sai_object_id_t m_defaultVlan;
118119

119-
bool m_portConfigDone = false;
120+
typedef enum
121+
{
122+
PORT_CONFIG_MISSING,
123+
PORT_CONFIG_RECEIVED,
124+
PORT_CONFIG_DONE,
125+
} port_config_state_t;
126+
127+
port_config_state_t m_portConfigState = PORT_CONFIG_MISSING;
120128
sai_uint32_t m_portCount;
121129
map<set<int>, sai_object_id_t> m_portListLaneMap;
122130
map<set<int>, tuple<string, uint32_t, int, string>> m_lanesAliasSpeedMap;

0 commit comments

Comments
 (0)