Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding YANG model for TC_TO_DSCP_MAP #21395

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add this MAP to here for sonic yang support:

Type_1_list_maps_model = [
'DSCP_TO_TC_MAP_LIST',
'DOT1P_TO_TC_MAP_LIST',
'TC_TO_PRIORITY_GROUP_MAP_LIST',
'TC_TO_QUEUE_MAP_LIST',
'MAP_PFC_PRIORITY_TO_QUEUE_LIST',
'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST',
'DSCP_TO_FC_MAP_LIST',
'EXP_TO_FC_MAP_LIST',
'CABLE_LENGTH_LIST',
'MPLS_TC_TO_TC_MAP_LIST',
'TC_TO_DSCP_MAP_LIST'
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @raaghavendrakra-arista , please add new table here for sonic yang support. Others look good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wen587, I didn't get you, I see that I have already added the new MAP to the table you are pointing (line 22)
correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss that.

]

# 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 @@ -196,6 +196,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;
}
}
}
}
}
}
}
}
Loading