Skip to content

Improve PortsOrch::doPortTask()#566

Merged
qiluo-msft merged 4 commits intosonic-net:masterfrom
qiluo-msft:qiluo/simpleport
Aug 8, 2018
Merged

Improve PortsOrch::doPortTask()#566
qiluo-msft merged 4 commits intosonic-net:masterfrom
qiluo-msft:qiluo/simpleport

Conversation

@qiluo-msft
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft commented Aug 7, 2018

(Reduce the scope of this PR, please check the updated comment below)

I tested with virtual switch (vs) and Mellanox platform. The initial config of 'fec' is added in /usr/share/sonic/device/*/*/port_config.ini. However this manual test is not materialized as a unit test because of some difficulty.

Original implementation of PortsOrch::doPortTask() has some issues:

  1. It was using a ConsumerStateTable, which makes the message coming out of order. The complex logic was used to handle the order. After replace ConsumerStateTable by ConsumerTable, we can simplify the logic.

  2. The original ConsumerStateTable implementation will always pop all entry attributes even there is one attribute coming. This behavior is not by design and was changed after Improve ConsumerStateTable: del after consumed, and let consumer writes the final table sonic-swss-common#204 merged. The PortsOrch::doPortTask() takes advantage of this specific behavior and doesn't handle some port attributes correctly, if they come before PortConfigDone. These attributes are m_autoneg, speed, mtu, admin_status, fec_mode.

This PR solve these issues, and add vs test case.

@qiluo-msft qiluo-msft requested review from jleveque, lguohan and stcheng and removed request for jleveque and lguohan August 7, 2018 02:10
@jipanyang
Copy link
Copy Markdown
Contributor

jipanyang commented Aug 7, 2018

If my understanding is correct, with the change, no initPort() will be called until PortConfigDone is received. The code logic below will block the au, speed, fec setting from being applied before PortConfigDone. Not sure how they will be applied later.

Also gBufferOrch->isPortReady(alias) brings more dynamics here.

            if (!gBufferOrch->isPortReady(alias))
            {
                // buffer configuration hasn't been applied yet. save it for future retry
                it++;
                continue;
            }

            Port p;
            if (!getPort(alias, p))
            {
                SWSS_LOG_ERROR("Failed to get port id by alias:%s", alias.c_str());
            }

Did you test on hardware platform with some au, fec setting in the initial config?
#Resolved

@qiluo-msft qiluo-msft changed the title Simplify PortsOrch::doPortTask Improve PortsOrch::doPortTask() Aug 7, 2018
@qiluo-msft
Copy link
Copy Markdown
Contributor Author

qiluo-msft commented Aug 7, 2018

I could confirm "with the change, no initPort() will be called until PortConfigDone is received". Is there an issue here?

"gBufferOrch->isPortReady(alias)" will block these settings. The 'it' pointed entry is not erased and remains in consumer.m_toSync. Anytime unblocked, that entry will be picked up again and applied. It is a kind of postponed.

I tested with virtual switch (vs). The initial config of 'fec' is added in /usr/share/sonic/device/x86_64-dell_s6000_s1220-r0/Force10-S6000/port_config.ini. However this manual test is not materialized as a unit test because of some difficulty.


In reply to: 410928210 [](ancestors = 410928210)

@jipanyang
Copy link
Copy Markdown
Contributor

jipanyang commented Aug 7, 2018

What if there is no buffer pg and queue configuration in configDB, will "gBufferOrch->isPortReady(alias)" be true and not block it? #Resolved

@qiluo-msft
Copy link
Copy Markdown
Contributor Author

The behavior about "gBufferOrch->isPortReady(alias)" is unchanged.


In reply to: 411042467 [](ancestors = 411042467)

@jipanyang
Copy link
Copy Markdown
Contributor

The existing port config logic doesn't have hard dependency on gBufferOrch->isPortReady(alias), but more relying on PortConfigDone check. Now your whole solution relies on this gBufferOrch->isPortReady(alias) check, at least a clear explanation and understanding of the logic is needed, more comments are needed to record the complex interdependency of PortInitDone, isPortReady and port configuration.

It looks to me, one line change in existing code will have the same effect of solving the problems you mentioned :

            if (!m_portConfigDone)
            {
                // it = consumer.m_toSync.erase(it);
                it++;
                continue;
            }

@qiluo-msft qiluo-msft closed this Aug 7, 2018
Copy link
Copy Markdown
Contributor

@jipanyang jipanyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@qiluo-msft qiluo-msft merged commit 0dd1769 into sonic-net:master Aug 8, 2018
@qiluo-msft qiluo-msft deleted the qiluo/simpleport branch August 8, 2018 04:48
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
* Simplify PortsOrch::doPortTask
* Revert "Simplify PortsOrch::doPortTask", but keep unit test
* Fix handling m_autoneg, speed, mtu, admin_status, fec_mode before PortConfigDone
* Refine unit test with swsscommon.ProducerStateTable
jianyuewu pushed a commit to jianyuewu/sonic-swss that referenced this pull request Dec 24, 2025
In some circumstances calls are made to query the Redis database without checking if a given key (or key/field pair) exists, and with code to handle the case where it does not. For example many show commands query all possible relevant data, without checking if it exists. In these cases it would be useful to be able to prevent warning logs being written for every missing field, and so we add that option in this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants