Skip to content

Commit d00278a

Browse files
authored
Adding YANG model for TC_TO_DSCP_MAP (#21463)
issue : #20575 <!-- Please make sure you've read and understood our contributing guidelines: https://github.com/Azure/SONiC/blob/gh-pages/CONTRIBUTING.md ** Make sure all your commits include a signature generated with `git commit -s` ** If this is a bug fix, make sure your description includes "fixes #xxxx", or "closes #xxxx" or "resolves #xxxx" Please provide the following information: --> #### Why I did it "config-reload" in dualtor topologies were failing due to absence of TC_TO_DSCP Yang model. The above failure was seen after the the PR sonic-net/sonic-utilities#3102 ##### Work item tracking - Microsoft ADO **(number only)**: #### How I did it #### How to verify it Step-1: In DUT add the yang file to "/usr/local/yang-models/sonic-tc-dscp-map.yang" to this path. Step-2: config reload -y <!-- If PR needs to be backported, then the PR must be tested against the base branch and the earliest backport release branch and provide tested image version on these two branches. For example, if the PR is requested for master, 202211 and 202012, then the requester needs to provide test results on master and 202012. --> #### Which release branch to backport (provide reason below if selected) <!-- - Note we only backport fixes to a release branch, *not* features! - Please also provide a reason for the backporting below. - e.g. - [x] 202006 --> - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 - [ ] 202111 - [ ] 202205 - [ ] 202211 - [ ] 202305 #### Tested branch (Please provide the tested image version) <!-- - Please provide tested image version - e.g. - [x] 20201231.100 --> - [x] 202411 #### Description for the changelog Adding YANG model for TC_TO_DSCP_MAP along with test files. <!-- Write a short (one line) summary that describes the changes in this pull request for inclusion in the changelog: --> <!-- Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU. --> #### Link to config_db schema for YANG module changes <!-- Provide a link to config_db schema for the table for which YANG model is defined Link should point to correct section on https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md --> #### A picture of a cute animal (not mandatory but encouraged)
1 parent fed968a commit d00278a

File tree

6 files changed

+182
-2
lines changed

6 files changed

+182
-2
lines changed

src/sonic-yang-mgmt/sonic_yang_ext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
'DSCP_TO_FC_MAP_LIST',
1919
'EXP_TO_FC_MAP_LIST',
2020
'CABLE_LENGTH_LIST',
21-
'MPLS_TC_TO_TC_MAP_LIST'
21+
'MPLS_TC_TO_TC_MAP_LIST',
22+
'TC_TO_DSCP_MAP_LIST'
2223
]
2324

2425
# Workaround for those fields who is defined as leaf-list in YANG model but have string value in config DB.

src/sonic-yang-models/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def run(self):
195195
'./yang-models/sonic-tc-priority-group-map.yang',
196196
'./yang-models/sonic-tc-queue-map.yang',
197197
'./yang-models/sonic-peer-switch.yang',
198+
'./yang-models/sonic-tc-dscp-map.yang',
198199
'./yang-models/sonic-pfc-priority-queue-map.yang',
199200
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
200201
'./yang-models/sonic-logger.yang',

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,6 +2268,17 @@
22682268
}
22692269
},
22702270

2271+
"TC_TO_DSCP_MAP": {
2272+
"tc_to_dscp_map1": {
2273+
"1": "1",
2274+
"2": "2"
2275+
},
2276+
"tc_to_dscp_map2": {
2277+
"3": "3",
2278+
"4": "4"
2279+
}
2280+
},
2281+
22712282
"MAP_PFC_PRIORITY_TO_QUEUE": {
22722283
"pfc_prio_to_q_map1": {
22732284
"1": "1",

src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,19 @@
109109
"PORT_QOS_MAP_APPLY_INVALID_PFC": {
110110
"desc": "Configure port pfc enable with invalid pfc priority.",
111111
"eStrKey": "Pattern"
112+
},
113+
114+
"TC_TO_DSCP_MAP_CRETAE": {
115+
"desc": "Configure a Traffic class to DSCP map."
116+
},
117+
118+
"TC_TO_DSCP_MAP_CREATE_INVALID_TC": {
119+
"desc": "Configure a Traffic class to DSCP with invalid key.",
120+
"eStr": "Invalid Traffic Class"
121+
},
122+
123+
"TC_TO_DSCP_MAP_CREATE_INVALID_DSCP": {
124+
"desc": "Configure a Traffic class to DSCP map with invalid value.",
125+
"eStr": "Invalid DSCP"
112126
}
113127
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,92 @@
855855
]
856856
}
857857
}
858-
}
858+
},
859859

860+
"TC_TO_DSCP_MAP_CRETAE": {
861+
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
862+
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
863+
"TC_TO_DSCP_MAP_LIST": [
864+
{
865+
"name": "map1",
866+
"TC_TO_DSCP_MAP": [
867+
{
868+
"tc": "1",
869+
"dscp": "1"
870+
},
871+
{
872+
"tc":"2",
873+
"dscp":"2"
874+
},
875+
{
876+
"tc": "8",
877+
"dscp": "8"
878+
}
879+
]
880+
},
881+
{
882+
"name": "map2",
883+
"TC_TO_DSCP_MAP": [
884+
{
885+
"tc": "1",
886+
"dscp": "1"
887+
},
888+
{
889+
"tc":"2",
890+
"dscp":"2"
891+
},
892+
{
893+
"tc": "8",
894+
"dscp": "8"
895+
}
896+
]
897+
}
898+
]
899+
}
900+
}
901+
},
902+
903+
"TC_TO_DSCP_MAP_CREATE_INVALID_TC": {
904+
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
905+
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
906+
"TC_TO_DSCP_MAP_LIST": [
907+
{
908+
"name": "map3",
909+
"TC_TO_DSCP_MAP": [
910+
{
911+
"tc": "16",
912+
"dscp": "1"
913+
},
914+
{
915+
"tc":"2",
916+
"dscp":"2"
917+
}
918+
]
919+
}
920+
]
921+
}
922+
}
923+
},
924+
925+
"TC_TO_DSCP_MAP_CREATE_INVALID_DSCP": {
926+
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
927+
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
928+
"TC_TO_DSCP_MAP_LIST": [
929+
{
930+
"name": "map3",
931+
"TC_TO_DSCP_MAP": [
932+
{
933+
"tc": "1",
934+
"dscp": "64"
935+
},
936+
{
937+
"tc":"2",
938+
"dscp":"2"
939+
}
940+
]
941+
}
942+
]
943+
}
944+
}
945+
}
860946
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module sonic-tc-dscp-map {
2+
3+
yang-version 1.1;
4+
5+
namespace "http://github.com/sonic-net/sonic-tc-dscp-map";
6+
7+
prefix tdm;
8+
9+
import sonic-types {
10+
prefix stypes;
11+
}
12+
13+
organization
14+
"SONiC";
15+
16+
contact
17+
"SONiC";
18+
19+
description
20+
"TC_TO_DSCP_MAP yang Module for SONiC OS";
21+
22+
revision 2025-01-10 {
23+
description
24+
"Initial revision.";
25+
}
26+
27+
container sonic-tc-dscp-map {
28+
29+
container TC_TO_DSCP_MAP {
30+
31+
description "TC_TO_DSCP_MAP part of config_db.json";
32+
33+
list TC_TO_DSCP_MAP_LIST {
34+
35+
key "name";
36+
37+
leaf name {
38+
type string {
39+
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})';
40+
length 1..32 {
41+
error-message "Invalid length for map name.";
42+
error-app-tag map-name-invalid-length;
43+
}
44+
}
45+
}
46+
47+
list TC_TO_DSCP_MAP { //this is list inside list for storing mapping between two fields
48+
49+
key "tc";
50+
51+
leaf tc {
52+
type stypes:tc_type;
53+
}
54+
55+
leaf dscp {
56+
type string {
57+
pattern "6[0-3]|[1-5][0-9]?|[0-9]?" {
58+
error-message "Invalid DSCP";
59+
error-app-tag dscp-invalid;
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)