Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yang-models] Add YANG model for SYSTEM_PORT #12689

Merged
merged 6 commits into from
Feb 2, 2023

Conversation

kenneth-arista
Copy link
Contributor

@kenneth-arista kenneth-arista commented Nov 12, 2022

Add YANG model for SYSTEM_PORT.
Resolves #12458

Signed-off-by: Kenneth Cheung kennethcheung@arista.com

Why I did it

YANG model for SYSTEM_PORT in CONFIG_DB was missing.

How I did it

Added new YANG model and associated unit tests.

How to verify it

Passing unit tests

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205 (this release is targeted for deploying VoQ chassis where this YANG model is relevant.

@kenneth-arista
Copy link
Contributor Author

@rlhui for awareness

@kenneth-arista
Copy link
Contributor Author

@arlakshm

@kenneth-arista kenneth-arista force-pushed the master-system-port-yang branch 2 times, most recently from de3d1a6 to 2d93191 Compare November 18, 2022 07:20
@zhangyanzhao
Copy link
Collaborator

@arlakshm @praveen-li would you please help to review this PR? Thanks.

@zhangyanzhao
Copy link
Collaborator

@arlakshm @praveen-li would you please help to review this PR? Thanks.

@arlakshm @praveen-li kindly ping.

@praveen-li
Copy link
Collaborator

praveen-li commented Dec 15, 2022 via email

@rlhui rlhui assigned praveen-li and arlakshm and unassigned praveen-li Dec 15, 2022
@rlhui rlhui added the Chassis 🤖 Modular chassis support label Dec 15, 2022
Copy link
Collaborator

@praveen-li praveen-li 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, barring few questions\doubts. Thanks.

"SYSTEM_PORT_POSITIVE_CONFIG": {
"desc": "Configure SYSTEM_PORT positive config."
},
"SYSTEM_PORT_WRONG_SPEED_CONFIG": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

SYSTEM_PORT_WRONG_SPEED_CONFIG -> SYSTEM_PORT_WRONG_SPEED_PATTERN

Preferred if test name has condition being tested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1290,6 +1290,56 @@
"login": "local"
}
},
"SYSTEM_PORT": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

kindly point to the source of truth for config, e.g. HLD, Orchagent processing functions etc. Thx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see PortsOrch::addSystemPorts() in sonic-swss/orchagent/portsorch.cpp


yang-version 1.1;

namespace "http://github.com/Azure/sonic-system-port";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Azure --> sonic-net

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

leaf asic_name {
type string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: any constraints needed ? e.g. asic[0-9].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

leaf ifname {
type string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it need to be a leafref to PORT\Interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can use a leafref. I had it as follows previously but ran into a build problem. Let's try again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I encountered the same build failure; e.g.
ERROR:YANG-TEST: Exception >Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:name" of value "Ethernet0" points to a non-existing leaf. in not empty< in /sonic/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py:208

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ganglyu for the tip.

}

leaf core_index {
type uint8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Allowed 0-255 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

8-bits give us flexibility to support more cores in future ASICs. Admittedly, 255 cores is not likely. If you prefer, I can constrain to maximum 8 cores as so:

type uint8 {
range 0..7;
}

}

leaf core_port_index {
type uint16;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Allowed 0-2^16-1 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, similar to core_index we would like flexibility to support logical indices that can exceed 8 bits.

}

leaf num_voq {
type uint8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Allowed 0-255 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am happy to constrain this. The number of VOQs per port is typically 8 but can be more. I'll constrain this to between 1..8 for now.

@zhangyanzhao
Copy link
Collaborator

@praveen-li @kenneth-arista do we still have open questions for this PR? Or just need to fix build failure? Thanks.

@kenneth-arista
Copy link
Contributor Author

I don't have any open questions.

/azpw run Azure.sonic-buildimage

@kenneth-arista
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

description "Number of VoQs associated with a port.";
}

leaf speed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add description? And what's the unit? kbps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A VOQ is a Virtual Output Queue. Typically one VOQ is allocated per traffic class per port. The unit is the number of queues per port. For example, 8 corresponds to 8 VOQs per port. This number is not related to the speed or a port.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then why do we have speed for VOQ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a YANG model for a system port and not for a VOQ. A system port has many attributes, some of which are core_index (which core the port is associated with in a multicore ASIC), number of VOQs associated with the port, and the speed of the port.

Are you asking about this description Number of VoQs associated with a port? Or are you asking about the description for leaf speed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm asking about leaf speed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Max speed is 800000 bps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. I meant to say the units are in kbps. Max speed for future compatibility is 800Gbps.

Copy link
Contributor

Choose a reason for hiding this comment

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

If unit is kbps, max speed is 800Mbps. Plese include unit in description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I'm not thinking straight. The listed range is 1..800000. So, units are million bits per second since 800,000 mbps == 800,000,000,000 bps.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, please add description with unit.

@ganglyu
Copy link
Contributor

ganglyu commented Jan 6, 2023

@kenneth-arista would you please update doc/Configuration.md?

@ganglyu
Copy link
Contributor

ganglyu commented Jan 9, 2023

@kenneth-arista
sonic-config-engine unit test failed, related unit test will generate config db schema and run yang validation.
We need to fix related unit test, please let me know if you need any help.

@kenneth-arista
Copy link
Contributor Author

Hi @ganglyu, I see a number of failures in sonic-config-engine/tests/test_cfggen.py according to one of the pipeline outputs. Can you provide some pointers as to how to address these failures?

For example,

======================================================================
FAIL: test_minigraph_voq_metadata (tests.test_cfggen.TestCfgGen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 880, in test_minigraph_voq_metadata
    output = json.loads(self.run_script(argument))
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 55, in run_script
    self.assertTrue(self.yang.validate(argument))
AssertionError: False is not true

@ganglyu
Copy link
Contributor

ganglyu commented Jan 12, 2023

Hi @ganglyu, I see a number of failures in sonic-config-engine/tests/test_cfggen.py according to one of the pipeline outputs. Can you provide some pointers as to how to address these failures?

For example,

======================================================================
FAIL: test_minigraph_voq_metadata (tests.test_cfggen.TestCfgGen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 880, in test_minigraph_voq_metadata
    output = json.loads(self.run_script(argument))
  File "/sonic/src/sonic-config-engine/tests/test_cfggen.py", line 55, in run_script
    self.assertTrue(self.yang.validate(argument))
AssertionError: False is not true

We have fixed a related issue, would you please merge the latest code?

Add YANG model for SYSTEM_PORT.

Signed-off-by: Kenneth Cheung <kennethcheung@arista.com>
Revert leafref for ifname because of build failure.
- ifname should be a leafref
- adding missing port info in json test_config
- add missing description for speed attribute
@ganglyu
Copy link
Contributor

ganglyu commented Jan 13, 2023

@kenneth-arista
Take below error for example, test_minigraph_voq_system_ports failed to run yang validation, it seems that leafref for
"Ethernet1/8" does not exist, maybe we can add or replace Ethernet1/8 in sample-voq-graph.xml to fix this issue.

yang data generated from /sonic/src/sonic-config-engine/tests/sample-voq-graph.xml is not valid: Data Loading Failed
Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:name" of value "Ethernet1/8" points to a non-existing leaf.

Running sonic-cfggen -j /sonic/src/sonic-config-engine/tests/macsec_profile.json -m /sonic/src/sonic-config-engine/tests/sample-voq-graph.xml -p /sonic/src/sonic-config-engine/tests/voq-sample-port-config.ini --var-json SYSTEM_PORT

Validating yang schema

sonic_yang(3):Data Loading Failed:Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:name" of value "Ethernet1/8" points to a non-existing leaf.
yang data generated from /sonic/src/sonic-config-engine/tests/sample-voq-graph.xml is not valid: Data Loading Failed
Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:name" of value "Ethernet1/8" points to a non-existing leaf.

System ports also includes Cpu0 ports, which are not defined in
port_config.ini and thus the YANG was modified accordingly.
@kenneth-arista
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zhangyanzhao
Copy link
Collaborator

@praveen-li are you ok to approve this PR? Thanks.

@praveen-li
Copy link
Collaborator

praveen-li commented Jan 19, 2023 via email

@ganglyu ganglyu mentioned this pull request Jan 20, 2023
7 tasks
Copy link
Collaborator

@praveen-li praveen-li left a comment

Choose a reason for hiding this comment

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

Thx for contribution. Looks good to me now.

@qiluo-msft qiluo-msft merged commit 9d19ac9 into sonic-net:master Feb 2, 2023
@kenneth-arista kenneth-arista deleted the master-system-port-yang branch February 3, 2023 18:09
@kenneth-arista
Copy link
Contributor Author

Can we get this PR back ported to 202205 if needed? @arlakshm

@arlakshm arlakshm added the Chassis for 202205 branch PRs needed for 202205 branch in msft repo label Apr 11, 2024
@gechiang gechiang added the Included in Chassis for 202205 Branch Indicate PR is already in MSFT repo 202205 branch label Apr 20, 2024
mlok-nokia pushed a commit to mlok-nokia/sonic-buildimage that referenced this pull request Jun 5, 2024
Add YANG model for SYSTEM_PORT.
Resolves sonic-net#12458

YANG model for SYSTEM_PORT in CONFIG_DB was missing.

Added new YANG model and associated unit tests.

Passing unit tests
mlok-nokia pushed a commit to mlok-nokia/sonic-buildimage that referenced this pull request Jun 5, 2024
[yang-models] Add YANG model for SYSTEM_PORT (sonic-net#12689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chassis for 202205 branch PRs needed for 202205 branch in msft repo Chassis 🤖 Modular chassis support Included in Chassis for 202205 Branch Indicate PR is already in MSFT repo 202205 branch
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Need Yang for SYSTEM_PORT table
9 participants