From 201792f3cd79e349a37e33611154d638cf842b6a 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 dd3c702e630b..2339a7859171 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -1176,7 +1176,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", @@ -1186,7 +1188,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", @@ -1194,7 +1198,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 8a2227ef0804..a042bc6a9473 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -446,7 +446,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", @@ -458,7 +460,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 0d67a73148b3..3b94cedab4d9 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 7f5c91230df8..b6ccf9ec8780 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 6921613624ff..6e03f777a859 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 */