Skip to content

Commit 4130ff4

Browse files
Adding YANG model for TC_TO_DSCP_MAP (#21395)
Fixed issue : #20575 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 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 Tested branch (Please provide the tested image version) 202411 Description for the changelog Adding YANG model for TC_TO_DSCP_MAP along with test files.
1 parent 3755c6a commit 4130ff4

File tree

6 files changed

+182
-2
lines changed

6 files changed

+182
-2
lines changed

src/sonic-yang-mgmt/sonic_yang_ext.py

+2-1
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

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def run(self):
196196
'./yang-models/sonic-tc-priority-group-map.yang',
197197
'./yang-models/sonic-tc-queue-map.yang',
198198
'./yang-models/sonic-peer-switch.yang',
199+
'./yang-models/sonic-tc-dscp-map.yang',
199200
'./yang-models/sonic-pfc-priority-queue-map.yang',
200201
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
201202
'./yang-models/sonic-logger.yang',

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

+11
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,17 @@
22782278
}
22792279
},
22802280

2281+
"TC_TO_DSCP_MAP": {
2282+
"tc_to_dscp_map1": {
2283+
"1": "1",
2284+
"2": "2"
2285+
},
2286+
"tc_to_dscp_map2": {
2287+
"3": "3",
2288+
"4": "4"
2289+
}
2290+
},
2291+
22812292
"MAP_PFC_PRIORITY_TO_QUEUE": {
22822293
"pfc_prio_to_q_map1": {
22832294
"1": "1",

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

+14
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

+87-1
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
}
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)