Skip to content

Commit

Permalink
Adding YANG model for TC_TO_DSCP_MAP (sonic-net#21395)
Browse files Browse the repository at this point in the history
Fixed issue : sonic-net#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.
  • Loading branch information
raaghavendrakra-arista authored and VladimirKuk committed Jan 21, 2025
1 parent dae9be5 commit ab63ada
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/sonic-yang-mgmt/sonic_yang_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'DSCP_TO_FC_MAP_LIST',
'EXP_TO_FC_MAP_LIST',
'CABLE_LENGTH_LIST',
'MPLS_TC_TO_TC_MAP_LIST'
'MPLS_TC_TO_TC_MAP_LIST',
'TC_TO_DSCP_MAP_LIST'
]

# Workaround for those fields who is defined as leaf-list in YANG model but have string value in config DB.
Expand Down
1 change: 1 addition & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def run(self):
'./yang-models/sonic-tc-priority-group-map.yang',
'./yang-models/sonic-tc-queue-map.yang',
'./yang-models/sonic-peer-switch.yang',
'./yang-models/sonic-tc-dscp-map.yang',
'./yang-models/sonic-pfc-priority-queue-map.yang',
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
'./yang-models/sonic-logger.yang',
Expand Down
11 changes: 11 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,17 @@
}
},

"TC_TO_DSCP_MAP": {
"tc_to_dscp_map1": {
"1": "1",
"2": "2"
},
"tc_to_dscp_map2": {
"3": "3",
"4": "4"
}
},

"MAP_PFC_PRIORITY_TO_QUEUE": {
"pfc_prio_to_q_map1": {
"1": "1",
Expand Down
14 changes: 14 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,19 @@
"PORT_QOS_MAP_APPLY_INVALID_PFC": {
"desc": "Configure port pfc enable with invalid pfc priority.",
"eStrKey": "Pattern"
},

"TC_TO_DSCP_MAP_CRETAE": {
"desc": "Configure a Traffic class to DSCP map."
},

"TC_TO_DSCP_MAP_CREATE_INVALID_TC": {
"desc": "Configure a Traffic class to DSCP with invalid key.",
"eStr": "Invalid Traffic Class"
},

"TC_TO_DSCP_MAP_CREATE_INVALID_DSCP": {
"desc": "Configure a Traffic class to DSCP map with invalid value.",
"eStr": "Invalid DSCP"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,92 @@
]
}
}
}
},

"TC_TO_DSCP_MAP_CRETAE": {
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
"TC_TO_DSCP_MAP_LIST": [
{
"name": "map1",
"TC_TO_DSCP_MAP": [
{
"tc": "1",
"dscp": "1"
},
{
"tc":"2",
"dscp":"2"
},
{
"tc": "8",
"dscp": "8"
}
]
},
{
"name": "map2",
"TC_TO_DSCP_MAP": [
{
"tc": "1",
"dscp": "1"
},
{
"tc":"2",
"dscp":"2"
},
{
"tc": "8",
"dscp": "8"
}
]
}
]
}
}
},

"TC_TO_DSCP_MAP_CREATE_INVALID_TC": {
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
"TC_TO_DSCP_MAP_LIST": [
{
"name": "map3",
"TC_TO_DSCP_MAP": [
{
"tc": "16",
"dscp": "1"
},
{
"tc":"2",
"dscp":"2"
}
]
}
]
}
}
},

"TC_TO_DSCP_MAP_CREATE_INVALID_DSCP": {
"sonic-tc-dscp-map:sonic-tc-dscp-map": {
"sonic-tc-dscp-map:TC_TO_DSCP_MAP": {
"TC_TO_DSCP_MAP_LIST": [
{
"name": "map3",
"TC_TO_DSCP_MAP": [
{
"tc": "1",
"dscp": "64"
},
{
"tc":"2",
"dscp":"2"
}
]
}
]
}
}
}
}
67 changes: 67 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-tc-dscp-map.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module sonic-tc-dscp-map {

yang-version 1.1;

namespace "http://github.com/sonic-net/sonic-tc-dscp-map";

prefix tdm;

import sonic-types {
prefix stypes;
}

organization
"SONiC";

contact
"SONiC";

description
"TC_TO_DSCP_MAP yang Module for SONiC OS";

revision 2025-01-10 {
description
"Initial revision.";
}

container sonic-tc-dscp-map {

container TC_TO_DSCP_MAP {

description "TC_TO_DSCP_MAP part of config_db.json";

list TC_TO_DSCP_MAP_LIST {

key "name";

leaf name {
type string {
pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})';
length 1..32 {
error-message "Invalid length for map name.";
error-app-tag map-name-invalid-length;
}
}
}

list TC_TO_DSCP_MAP { //this is list inside list for storing mapping between two fields

key "tc";

leaf tc {
type stypes:tc_type;
}

leaf dscp {
type string {
pattern "6[0-3]|[1-5][0-9]?|[0-9]?" {
error-message "Invalid DSCP";
error-app-tag dscp-invalid;
}
}
}
}
}
}
}
}

0 comments on commit ab63ada

Please sign in to comment.