From 1cbfc9ceb8ceee79b145226253fbb78503c0f67c Mon Sep 17 00:00:00 2001 From: Prince George <45705344+prgeor@users.noreply.github.com> Date: Tue, 14 Mar 2023 09:34:16 -0700 Subject: [PATCH] [yang]: Add Yang model support for adding Channel to PORT table (#14228) Why I did it Add 'channel' to the CONFIG_DB PORT table. This will be needed to support PORT breakout to multiple channel ports so that Xcvrd can understand which datapath or channel to initialize on the CMIS compliant optics How I did it Add 'channel' to the CONFIG_DB PORT table. How to verify it Added unit test for valid and invalid channel number Channel 0 -> No breakout Channel 1 to 8 -> Breakout channel 1,2, ..8 Signed-off-by: Prince George --- src/sonic-yang-models/doc/Configuration.md | 27 +++++++++ .../tests/files/sample_config_db.json | 27 ++++++--- .../tests/yang_model_tests/tests/port.json | 9 ++- .../yang_model_tests/tests_config/port.json | 55 ++++++++++++++++++- .../yang-models/sonic-port.yang | 7 +++ 5 files changed, 114 insertions(+), 11 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 4199a36da..aeb670a28 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -1473,6 +1473,33 @@ optional attributes. } } +2x100G port breakout +{ +"PORT": { + "Ethernet0": { + "admin_status": "up", + "index": "1", + "lanes": "101,102,103,104", + "description": "etp1a", + "mtu": "9100", + "alias": "etp1a", + "speed": "100000", + "channel": 1 + }, + "Ethernet4": { + "admin_status": "up", + "index": "1", + "lanes": "105,106,107,108", + "description": "etp1b", + "mtu": "9100", + "alias": "etp1b", + "speed": "100000", + "channel": 2 + }, + } +} + + ``` ### Port Channel diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 4caf93abb..d5ff06062 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -558,7 +558,8 @@ "admin_status": "up", "autoneg": "on", "adv_speeds": "all", - "adv_interface_types": "all" + "adv_interface_types": "all", + "channel" : "0" }, "Ethernet3": { "alias": "Eth1/4", @@ -566,7 +567,8 @@ "description": "", "speed": "11100", "tpid": "0x88A8", - "admin_status": "up" + "admin_status": "up", + "channel": "1" }, "Ethernet4": { "alias": "Eth2/1", @@ -574,7 +576,8 @@ "description": "", "speed": "11100", "tpid": "0x9100", - "admin_status": "up" + "admin_status": "up", + "channel": "2" }, "Ethernet5": { "alias": "Eth2/2", @@ -582,7 +585,8 @@ "description": "", "speed": "11100", "tpid": "0x9200", - "admin_status": "up" + "admin_status": "up", + "channel": "3" }, "Ethernet6": { "alias": "Eth2/3", @@ -590,7 +594,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "4" }, "Ethernet7": { "alias": "Eth2/4", @@ -598,7 +603,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "5" }, "Ethernet8": { "alias": "Eth3/1", @@ -606,7 +612,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "6" }, "Ethernet9": { "alias": "Eth3/2", @@ -614,7 +621,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "7" }, "Ethernet10": { "alias": "Eth3/3", @@ -622,7 +630,8 @@ "description": "", "speed": "11100", "tpid": "0x8100", - "admin_status": "up" + "admin_status": "up", + "channel": "8" }, "Ethernet11": { "alias": "Eth3/4", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json index 6f7af54c4..e02df9d54 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json @@ -120,6 +120,13 @@ "PORT_INVALID_MULTIASIC_TEST": { "desc": "PORT_INVALID_MULTIASIC_TEST invalid role pattern, expect fail", "eStrKey": "Pattern" + }, + "PORT_VALID_CHANNEL_NUMBER": { + "desc": "PORT_VALID_CHANNEL_NUMBER no failure." + }, + "PORT_INVALID_CHANNEL_NUMBER": { + "desc": "Out of range channel number", + "eStrKey": "Range", + "eStr": "0..8" } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json index 684caa243..39b31dbb6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json @@ -515,7 +515,60 @@ } } }, - + + "PORT_INVALID_CHANNEL_NUMBER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "alias": "etp1a", + "lanes": "60, 61", + "speed": 100000, + "channel": 9 + } + ] + } + } + }, + + "PORT_VALID_CHANNEL_NUMBER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet0", + "alias": "etp1a", + "lanes": "60, 61", + "speed": 100000, + "channel": 1 + }, + { + "name": "Ethernet2", + "alias": "etp1b", + "lanes": "62, 63", + "speed": 100000, + "channel": 2 + }, + { + "name": "Ethernet4", + "alias": "etp1c", + "lanes": "64, 65", + "speed": 100000, + "channel": 3 + }, + { + "name": "Ethernet6", + "alias": "etp1d", + "lanes": "66, 67", + "speed": 100000, + "channel": 4 + } + ] + } + } + }, + "PORT_VALID_MULTIASIC_TEST": { "sonic-port:sonic-port": { "sonic-port:PORT": { diff --git a/src/sonic-yang-models/yang-models/sonic-port.yang b/src/sonic-yang-models/yang-models/sonic-port.yang index e2408d593..667b3b1f3 100644 --- a/src/sonic-yang-models/yang-models/sonic-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-port.yang @@ -121,6 +121,13 @@ module sonic-port{ } } + leaf channel { + description "Logical channel(s) for physical port breakout"; + type uint8 { + range 0..8; + } + } + leaf index { type uint16; }