From a49860cc7f4a0b9d9b733b297dbca5227feb8e20 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Mon, 28 Aug 2023 20:05:11 +0800 Subject: [PATCH] Add yang model for scheduler in PORT_QOS_MAP (#16244) Signed-off-by: Stephen Sun --- .../tests/files/sample_config_db.json | 26 +++++++--- .../tests/yang_model_tests/tests/qosmaps.json | 5 ++ .../tests_config/qosmaps.json | 50 ++++++++++++++++++- .../yang-models/sonic-port-qos-map.yang | 11 ++++ 4 files changed, 83 insertions(+), 9 deletions(-) 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 5ae899f0c2..8e45c0332f 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1898,6 +1898,15 @@ "pbs": "2048", "pir": "2560000", "type": "STRICT" + }, + "port_scheduler": { + "cbs": "256", + "cir": "1250000", + "meter_type": "bytes", + "pbs": "1024", + "pir": "25000000", + "type": "DWRR", + "weight": "10" } }, @@ -2062,14 +2071,15 @@ }, "PORT_QOS_MAP": { "Ethernet0": { - "dot1p_to_tc_map" : "Dot1p_to_tc_map1", - "dscp_to_tc_map": "Dscp_to_tc_map1", - "tc_to_queue_map": "tc_to_q_map1", - "tc_to_pg_map": "tc_to_pg_map1", - "pfc_to_queue_map": "pfc_prio_to_q_map1", - "pfc_to_pg_map" : "pfc_prio_to_pg_map1", - "pfc_enable" : "3,4", - "pfcwd_sw_enable" : "3,4" + "dot1p_to_tc_map" : "Dot1p_to_tc_map1", + "dscp_to_tc_map": "Dscp_to_tc_map1", + "tc_to_queue_map": "tc_to_q_map1", + "tc_to_pg_map": "tc_to_pg_map1", + "pfc_to_queue_map": "pfc_prio_to_q_map1", + "pfc_to_pg_map" : "pfc_prio_to_pg_map1", + "pfc_enable" : "3,4", + "pfcwd_sw_enable" : "3,4", + "scheduler" : "port_scheduler" }, "Ethernet4": { "dot1p_to_tc_map" : "Dot1p_to_tc_map2", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json index db068f714f..c89e8e89ce 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json @@ -96,6 +96,11 @@ "eStrKey": "LeafRef" }, + "PORT_QOS_MAP_APPLY_NON_EXISTS_SCHEDULER": { + "desc": "Configure non exists scheduler on port.", + "eStrKey": "LeafRef" + }, + "PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": { "desc": "Configure port qos map entry on non exists port.", "eStr": "Invalid value" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json index 3082bb10e9..355187b497 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json @@ -657,6 +657,24 @@ ] } }, + + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"port_scheduler", + "cbs": "256", + "cir": "1250000", + "meter_type": "bytes", + "pbs": "1024", + "pir": "25000000", + "type": "DWRR", + "weight": "10" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { "sonic-port-qos-map:PORT_QOS_MAP": { "PORT_QOS_MAP_LIST": [ @@ -670,7 +688,8 @@ "dscp_to_tc_map": "map1", "dot1p_to_tc_map": "map1", "pfc_enable": "2,3,4,6", - "pfcwd_sw_enable" : "2,3,4,6" + "pfcwd_sw_enable" : "2,3,4,6", + "scheduler" : "port_scheduler" } ] } @@ -751,6 +770,35 @@ } }, + "PORT_QOS_MAP_APPLY_NON_EXISTS_SCHEDULER": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet0", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { + "sonic-port-qos-map:PORT_QOS_MAP": { + "PORT_QOS_MAP_LIST": [ + { + "ifname": "Ethernet0", + "scheduler": "scheduler1" + } + ] + } + } + }, + "PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": { "sonic-port:sonic-port": { "sonic-port:PORT": { diff --git a/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang index 346b08bd1b..b8a448c652 100644 --- a/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang +++ b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang @@ -34,6 +34,10 @@ module sonic-port-qos-map { prefix dot1ptm; } + import sonic-scheduler { + prefix sch; + } + organization "SONiC"; @@ -117,6 +121,13 @@ module sonic-port-qos-map { path "/dot1ptm:sonic-dot1p-tc-map/dot1ptm:DOT1P_TO_TC_MAP/dot1ptm:DOT1P_TO_TC_MAP_LIST/dot1ptm:name"; } } + + leaf scheduler { + type leafref { + path "/sch:sonic-scheduler/sch:SCHEDULER/sch:SCHEDULER_LIST/sch:name"; //Reference to SCHEDULER table + } + description "Scheduler for port."; + } } } }