From 91f3502539c4827e529268a4222515c0460acf51 Mon Sep 17 00:00:00 2001 From: Prince George <45705344+prgeor@users.noreply.github.com> Date: Sun, 12 Jun 2022 09:14:35 -0700 Subject: [PATCH] Yang model for xcvr tx power and frequency configuration (#11053) * Yang model for xcvr tx power and frequency configuration * Add unit test cases * Addressed review comments --- src/sonic-yang-models/doc/Configuration.md | 12 +++- .../tests/files/sample_config_db.json | 8 ++- .../tests/yang_model_tests/tests/port.json | 16 +++++ .../yang_model_tests/tests_config/port.json | 68 +++++++++++++++++++ .../yang-models/sonic-port.yang | 12 ++++ 5 files changed, 111 insertions(+), 5 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 3a3cdcc883..991ed091c8 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -1196,7 +1196,9 @@ optional attributes. "mtu": "9100", "alias": "fortyGigE1/1/1", "speed": "40000", - "link_training": "off" + "link_training": "off", + "laser_freq": "191300", + "tx_power": "-27.3" }, "Ethernet1": { "index": "1", @@ -1206,7 +1208,9 @@ optional attributes. "alias": "fortyGigE1/1/2", "admin_status": "up", "speed": "40000", - "link_training": "on" + "link_training": "on", + "laser_freq": "191300", + "tx_power": "-27.3" }, "Ethernet63": { "index": "63", @@ -1214,7 +1218,9 @@ optional attributes. "description": "fortyGigE1/4/16", "mtu": "9100", "alias": "fortyGigE1/4/16", - "speed": "40000" + "speed": "40000", + "laser_freq": "191300", + "tx_power": "-27.3" } } } 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 0be6f6cb16..db613c23bc 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -447,7 +447,9 @@ "asic_port_name": "Eth0-ASIC1", "role": "Ext", "macsec": "test", - "link_training": "off" + "link_training": "off", + "laser_freq": "191600", + "tx_power": "-26.6" }, "Ethernet1": { "alias": "Eth1/2", @@ -459,7 +461,9 @@ "autoneg": "on", "adv_speeds": "100000,50000", "adv_interface_types": "CR,CR4", - "link_training": "on" + "link_training": "on", + "laser_freq": "191300", + "tx_power": "-27.3" }, "Ethernet2": { "alias": "Eth1/3", 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 0d67a73148..3b94cedab4 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 @@ -69,6 +69,22 @@ "desc": "PORT_INVALID_ADVTYPES_TEST_2 must condition failure.", "eStrKey" : "Must" }, + "PORT_VALID_XCVR_FREQ_TEST": { + "desc": "PORT_VALID_XCVR_FREQ_TEST no failure" + }, + "PORT_VALID_XCVR_TX_POWER_TEST": { + "desc": "PORT_VALID_XCVR_TX_POWER_TEST no failure" + }, + "PORT_INVALID_XCVR_FREQ_TEST": { + "desc": "PORT_INVALID_XCVR_FREQ_TEST non-integer value, expect failure", + "eStrKey": "InvalidValue", + "eStr": ["laser_freq"] + }, + "PORT_INVALID_XCVR_TX_POWER_TEST": { + "desc": "PORT_INVALID_XCVR_TX_POWER_TEST non-float value, expect failure", + "eStrKey": "InvalidValue", + "eStr": ["tx_power"] + }, "PORT_VALID_LINK_TRAINING_TEST_1": { "desc": "PORT_VALID_LINK_TRAINING_TEST_1 no failure." }, 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 7f5c91230d..b6ccf9ec87 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 @@ -311,6 +311,74 @@ } }, + "PORT_VALID_XCVR_FREQ_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 25000, + "tpid": "0x8100", + "laser_freq": 193100 + } + ] + } + } + }, + + "PORT_VALID_XCVR_TX_POWER_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 25000, + "tpid": "0x8100", + "tx_power": "27.3" + } + ] + } + } + }, + + "PORT_INVALID_XCVR_FREQ_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 25000, + "tpid": "0x8100", + "laser_freq": "27.3" + } + ] + } + } + }, + + "PORT_INVALID_XCVR_TX_POWER_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 25000, + "tpid": "0x8100", + "tx_power": "27/4" + } + ] + } + } + }, + "PORT_VALID_LINK_TRAINING_TEST_1": { "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 6921613624..6e03f777a8 100644 --- a/src/sonic-yang-models/yang-models/sonic-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-port.yang @@ -171,6 +171,18 @@ module sonic-port{ } } + leaf tx_power { + description "Target output power(dBm) for the 400G ZR transceiver"; + type decimal64 { + fraction-digits 1; + } + } + + leaf laser_freq { + description "Target laser frequency(GHz) for the 400G ZR transceiver"; + type int32; + } + } /* end of list PORT_LIST */ } /* end of container PORT */