SONiC QoS MAPs and PORT_QOS_MAP Yang (#7375)

Why I did it
Created SONiC Yang model for the following QOS MAPs and PORT QOS MAP:
DSCP_TO_TC_MAP
DOT1P_TO_TC_MAP
TC_TO_QUEUE_MAP
TC_TO_PRIORITY_GROUP_MAP
MAP_PFC_PRIORITY_TO_QUEUE
PORT_QOS_MAP

How I did it
Defined Yang models for QOS MAPs based on Guideline doc:
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md
and
https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md

How to verify it
sonic_yang_models package build
The infra code was modified to handle the nested list definition in YANG and translate it to a flat list in DB.
This commit is contained in:
ohu1 2021-10-19 12:50:07 -07:00 committed by GitHub
parent e6733e96fe
commit 459d3d1f55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 1640 additions and 4 deletions

View File

@ -4,11 +4,17 @@
from __future__ import print_function
import yang as ly
import syslog
from json import dump, dumps, loads
from xmltodict import parse
from glob import glob
qos_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']
"""
This is the Exception thrown out of all public function of this class.
"""
@ -406,6 +412,108 @@ class SonicYangExtMixin:
return vValue
"""
Xlate a Qos Maps list
This function will xlate from a dict in config DB to a Yang JSON list
using yang model. Output will be go in self.xlateJson
Note: Exceptions from this function are collected in exceptionList and
are displayed only when an entry is not xlated properly from ConfigDB
to sonic_yang.json.
QOS MAPS Yang has inner list, which is diffrent from config DB.
Each field value in config db should be converted to inner list with
key and value.
Example:
Config DB:
"DSCP_TO_TC_MAP": {
"Dscp_to_tc_map1": {
"1": "1",
"2": "2"
}
}
YANG Model:
module: sonic-dscp-tc-map
+--rw sonic-dscp-tc-map
+--rw DSCP_TO_TC_MAP
+--rw DSCP_TO_TC_MAP_LIST* [name]
+--rw name string
+--rw DSCP_TO_TC_MAP* [dscp]
+--rw dscp string
+--rw tc? string
YANG JSON:
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "64",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
"""
def _xlateQosMapList(self, model, yang, config, table, exceptionList):
#create a dict to map each key under primary key with a dict yang model.
#This is done to improve performance of mapping from values of TABLEs in
#config DB to leaf in YANG LIST.
inner_clist = model.get('list')
if inner_clist:
inner_listKey = inner_clist['key']['@value']
inner_leafDict = self._createLeafDict(inner_clist, table)
for lkey in inner_leafDict:
if inner_listKey != lkey:
inner_listVal = lkey
# get keys from YANG model list itself
listKeys = model['key']['@value']
self.sysLog(msg="xlateList keyList:{}".format(listKeys))
primaryKeys = list(config.keys())
for pkey in primaryKeys:
try:
vKey = None
self.sysLog(syslog.LOG_DEBUG, "xlateList Extract pkey:{}".\
format(pkey))
# Find and extracts key from each dict in config
keyDict = self._extractKey(pkey, listKeys)
if inner_clist:
inner_yang_list = list()
for vKey in config[pkey]:
inner_keyDict = dict()
self.sysLog(syslog.LOG_DEBUG, "xlateList Key {} vkey {} Val {} vval {}".\
format(inner_listKey, str(vKey), inner_listVal, str(config[pkey][vKey])))
inner_keyDict[inner_listKey] = str(vKey)
inner_keyDict[inner_listVal] = str(config[pkey][vKey])
inner_yang_list.append(inner_keyDict)
keyDict[inner_clist['@name']] = inner_yang_list
yang.append(keyDict)
# delete pkey from config, done to match one key with one list
del config[pkey]
except Exception as e:
# log debug, because this exception may occur with multilists
self.sysLog(msg="xlateList Exception:{}".format(str(e)), \
debug=syslog.LOG_DEBUG, doPrint=True)
exceptionList.append(str(e))
# with multilist, we continue matching other keys.
continue
return
"""
Xlate a list
This function will xlate from a dict in config DB to a Yang JSON list
@ -417,15 +525,21 @@ class SonicYangExtMixin:
"""
def _xlateList(self, model, yang, config, table, exceptionList):
#Qos Map lists needs special handling because of inner yang list and
#config db format.
if model['@name'] in qos_maps_model:
self.sysLog(msg="_xlateQosMapList: {}".format(model['@name']))
self._xlateQosMapList(model, yang,config, table, exceptionList)
return
#create a dict to map each key under primary key with a dict yang model.
#This is done to improve performance of mapping from values of TABLEs in
#config DB to leaf in YANG LIST.
leafDict = self._createLeafDict(model, table)
leafDict = self._createLeafDict(model, table)
# get keys from YANG model list itself
listKeys = model['key']['@value']
self.sysLog(msg="xlateList keyList:{}".format(listKeys))
primaryKeys = list(config.keys())
for pkey in primaryKeys:
try:
@ -459,7 +573,6 @@ class SonicYangExtMixin:
"""
def _xlateListInContainer(self, model, yang, configC, table, exceptionList):
clist = model
#print(clist['@name'])
yang[clist['@name']] = list()
self.sysLog(msg="xlateProcessListOfContainer: {}".format(clist['@name']))
self._xlateList(clist, yang[clist['@name']], configC, table, exceptionList)
@ -629,11 +742,94 @@ class SonicYangExtMixin:
return vValue
"""
Rev xlate from <TABLE>_LIST to table in config DB
QOS MAP Yang has inner list, each inner list key:val should
be mapped to field:value in Config DB.
Example:
YANG:
module: sonic-dscp-tc-map
+--rw sonic-dscp-tc-map
+--rw DSCP_TO_TC_MAP
+--rw DSCP_TO_TC_MAP_LIST* [name]
+--rw name string
+--rw DSCP_TO_TC_MAP* [dscp]
+--rw dscp string
+--rw tc? string
YANG JSON:
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "64",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
Config DB:
"DSCP_TO_TC_MAP": {
"Dscp_to_tc_map1": {
"1": "1",
"2": "2"
}
}
"""
def _revQosMapXlateList(self, model, yang, config, table):
# get keys from YANG model list itself
listKeys = model['key']['@value']
# create a dict to map each key under primary key with a dict yang model.
# This is done to improve performance of mapping from values of TABLEs in
# config DB to leaf in YANG LIST.
# Gather inner list key and value from model
inner_clist = model.get('list')
if inner_clist:
inner_listKey = inner_clist['key']['@value']
inner_leafDict = self._createLeafDict(inner_clist, table)
for lkey in inner_leafDict:
if inner_listKey != lkey:
inner_listVal = lkey
# list with name <NAME>_LIST should be removed,
if "_LIST" in model['@name']:
for entry in yang:
# create key of config DB table
pkey, pkeydict = self._createKey(entry, listKeys)
self.sysLog(syslog.LOG_DEBUG, "revXlateList pkey:{}".format(pkey))
config[pkey]= dict()
# fill rest of the entries
inner_list = entry[inner_clist['@name']]
for index in range(len(inner_list)):
self.sysLog(syslog.LOG_DEBUG, "revXlateList fkey:{} fval {}".\
format(str(inner_list[index][inner_listKey]),\
str(inner_list[index][inner_listVal])))
config[pkey][str(inner_list[index][inner_listKey])] = str(inner_list[index][inner_listVal])
return
"""
Rev xlate from <TABLE>_LIST to table in config DB
"""
def _revXlateList(self, model, yang, config, table):
# special processing for QOS Map table.
if model['@name'] in qos_maps_model:
self._revQosMapXlateList(model, yang, config, table)
return
# get keys from YANG model list itself
listKeys = model['key']['@value']
# create a dict to map each key under primary key with a dict yang model.

View File

@ -79,6 +79,13 @@ setup(
'./yang-models/sonic-scheduler.yang',
'./yang-models/sonic-wred-profile.yang',
'./yang-models/sonic-queue.yang',
'./yang-models/sonic-dscp-tc-map.yang',
'./yang-models/sonic-dot1p-tc-map.yang',
'./yang-models/sonic-tc-priority-group-map.yang',
'./yang-models/sonic-tc-queue-map.yang',
'./yang-models/sonic-pfc-priority-queue-map.yang',
'./yang-models/sonic-pfc-priority-priority-group-map.yang',
'./yang-models/sonic-port-qos-map.yang',
'./yang-models/sonic_yang_tree']),
],
zip_safe=False,

View File

@ -1188,6 +1188,93 @@
"scheduler": "TEST@1",
"wred_profile": "Wred1"
}
},
"DSCP_TO_TC_MAP": {
"Dscp_to_tc_map1": {
"1": "1",
"2": "2"
},
"Dscp_to_tc_map2": {
"3": "3",
"4": "4"
}
},
"DOT1P_TO_TC_MAP": {
"Dot1p_to_tc_map1": {
"1": "1",
"2": "2"
},
"Dot1p_to_tc_map2": {
"3": "3",
"4": "4"
}
},
"TC_TO_PRIORITY_GROUP_MAP": {
"tc_to_pg_map1": {
"1": "1",
"2": "2"
},
"tc_to_pg_map2": {
"3": "3",
"4": "4"
}
},
"TC_TO_QUEUE_MAP": {
"tc_to_q_map1": {
"1": "1",
"2": "2"
},
"tc_to_q_map2": {
"3": "3",
"4": "4"
}
},
"MAP_PFC_PRIORITY_TO_QUEUE": {
"pfc_prio_to_q_map1": {
"1": "1",
"2": "2"
},
"pfc_prio_to_q_map2": {
"3": "3",
"4": "4"
}
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
"pfc_prio_to_pg_map1": {
"1": "1",
"2": "2"
},
"pfc_prio_to_pg_map2": {
"3": "3",
"4": "4"
}
},
"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"
},
"Ethernet4": {
"dot1p_to_tc_map" : "Dot1p_to_tc_map2",
"dscp_to_tc_map": "Dscp_to_tc_map2",
"tc_to_queue_map": "tc_to_q_map2",
"tc_to_pg_map": "tc_to_pg_map2",
"pfc_to_queue_map": "pfc_prio_to_q_map2",
"pfc_to_pg_map" : "pfc_prio_to_pg_map2",
"pfc_enable" : "3,4"
}
}
},

View File

@ -0,0 +1,104 @@
{
"DSCP_TO_TC_MAP_CRETAE": {
"desc": "Configure a DSCP to Traffic class map."
},
"DSCP_TO_TC_MAP_CREATE_INVALID_DSCP": {
"desc": "Configure a DSCP to Traffic class map with invalid key.",
"eStr": "Invalid DSCP"
},
"DSCP_TO_TC_MAP_CREATE_INVALID_TC": {
"desc": "Configure a DSCP to Traffic class map with invalid value.",
"eStr": "Invalid Traffic Class"
},
"DOT1P_TO_TC_MAP_CRETAE": {
"desc": "Configure a DOT1P to Traffic class map."
},
"DOT1P_TO_TC_MAP_CREATE_INVALID_DOT1P": {
"desc": "Configure a DOT1P to Traffic class map with invalid key.",
"eStr": "Invalid DOT1P"
},
"DOT1P_TO_TC_MAP_CREATE_INVALID_TC": {
"desc": "Configure a DOT1P to Traffic class map with invalid value.",
"eStr": "Invalid Traffic Class"
},
"TC_TO_QUEUE_MAP_CRETAE": {
"desc": "Configure a Traffic Class to Queue map."
},
"TC_TO_QUEUE_MAP_CREATE_INVALID_TC": {
"desc": "Configure a Traffic class to Queue map with invalid key.",
"eStr": "Invalid Traffic Class"
},
"TC_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"desc": "Configure a Traffic class to Queue map with invalid value.",
"eStr": "Invalid queue index"
},
"TC_TO_PRIORITY_GROUP_MAP_CRETAE": {
"desc": "Configure a Traffic Class to Priority Group map."
},
"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_TC": {
"desc": "Configure a Traffic class to Priority Group map with invalid key.",
"eStr": "Invalid Traffic Class"
},
"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"desc": "Configure a Traffic class to Priority Group map with invalid value.",
"eStr": "Invalid Priority Group"
},
"PFC_PRIORITY_TO_QUEUE_MAP_CRETAE": {
"desc": "Configure a PFC priority to Queue map."
},
"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_PFC_PRIORITY": {
"desc": "Configure a PFC priority to Queue map with invalid key.",
"eStr": "Invalid pfc priority"
},
"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"desc": "Configure a PFC priority to Queue map with invalid value.",
"eStr": "Invalid queue index"
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CRETAE": {
"desc": "Configure a PFC priority to Priority Group map."
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PFC_PRIORITY": {
"desc": "Configure a PFC priority to Priority Group map with invalid key.",
"eStr": "Invalid pfc priority"
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"desc": "Configure a PFC priority to Priority Group map with invalid value.",
"eStr": "Invalid Priority Group"
},
"PORT_QOS_MAP_APPLY_MAPS": {
"desc": "Configure qos maps on port."
},
"PORT_QOS_MAP_APPLY_NON_EXISTS_MAPS": {
"desc": "Configure non exists qos maps on port.",
"eStrKey": "LeafRef"
},
"PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": {
"desc": "Configure port qos map entry on non exists port.",
"eStrKey": "LeafRef"
},
"PORT_QOS_MAP_APPLY_INVALID_PFC": {
"desc": "Configure port pfc enable with invalid pfc priority.",
"eStrKey": "Pattern"
}
}

View File

@ -0,0 +1,724 @@
{
"DSCP_TO_TC_MAP_CRETAE": {
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map1",
"DSCP_TO_TC_MAP": [
{
"dscp": "1",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
},
{
"name": "map2",
"DSCP_TO_TC_MAP": [
{
"dscp": "1",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
},
"DSCP_TO_TC_MAP_CREATE_INVALID_DSCP": {
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "64",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
},
"DSCP_TO_TC_MAP_CREATE_INVALID_TC": {
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map3",
"DSCP_TO_TC_MAP": [
{
"dscp": "1",
"tc": "8"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
}
},
"DOT1P_TO_TC_MAP_CRETAE": {
"sonic-dot1p-tc-map:sonic-dot1p-tc-map": {
"sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": {
"DOT1P_TO_TC_MAP_LIST": [
{
"name": "map1",
"DOT1P_TO_TC_MAP": [
{
"dot1p": "1",
"tc": "1"
},
{
"dot1p":"2",
"tc":"2"
}
]
},
{
"name": "map2",
"DOT1P_TO_TC_MAP": [
{
"dot1p": "1",
"tc": "1"
},
{
"dot1p":"2",
"tc":"2"
}
]
}
]
}
}
},
"DOT1P_TO_TC_MAP_CREATE_INVALID_DOT1P": {
"sonic-dot1p-tc-map:sonic-dot1p-tc-map": {
"sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": {
"DOT1P_TO_TC_MAP_LIST": [
{
"name": "map3",
"DOT1P_TO_TC_MAP": [
{
"dot1p": "64",
"tc": "1"
},
{
"dot1p":"2",
"tc":"2"
}
]
}
]
}
}
},
"DOT1P_TO_TC_MAP_CREATE_INVALID_TC": {
"sonic-dot1p-tc-map:sonic-dot1p-tc-map": {
"sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": {
"DOT1P_TO_TC_MAP_LIST": [
{
"name": "map3",
"DOT1P_TO_TC_MAP": [
{
"dot1p": "1",
"tc": "8"
},
{
"dot1p":"2",
"tc":"2"
}
]
}
]
}
}
},
"TC_TO_QUEUE_MAP_CRETAE": {
"sonic-tc-queue-map:sonic-tc-queue-map": {
"sonic-tc-queue-map:TC_TO_QUEUE_MAP": {
"TC_TO_QUEUE_MAP_LIST": [
{
"name": "map1",
"TC_TO_QUEUE_MAP": [
{
"tc": "1",
"qindex": "1"
},
{
"tc":"2",
"qindex":"2"
}
]
},
{
"name": "map2",
"TC_TO_QUEUE_MAP": [
{
"tc": "1",
"qindex": "1"
},
{
"tc":"2",
"qindex":"2"
}
]
}
]
}
}
},
"TC_TO_QUEUE_MAP_CREATE_INVALID_TC": {
"sonic-tc-queue-map:sonic-tc-queue-map": {
"sonic-tc-queue-map:TC_TO_QUEUE_MAP": {
"TC_TO_QUEUE_MAP_LIST": [
{
"name": "map3",
"TC_TO_QUEUE_MAP": [
{
"tc": "64",
"qindex": "1"
},
{
"tc":"2",
"qindex":"2"
}
]
}
]
}
}
},
"TC_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"sonic-tc-queue-map:sonic-tc-queue-map": {
"sonic-tc-queue-map:TC_TO_QUEUE_MAP": {
"TC_TO_QUEUE_MAP_LIST": [
{
"name": "map3",
"TC_TO_QUEUE_MAP": [
{
"tc": "1",
"qindex": "8"
},
{
"tc":"2",
"qindex":"2"
}
]
}
]
}
}
},
"TC_TO_PRIORITY_GROUP_MAP_CRETAE": {
"sonic-tc-priority-group-map:sonic-tc-priority-group-map": {
"sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": {
"TC_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map1",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "1",
"pg": "1"
},
{
"tc":"2",
"pg":"2"
}
]
},
{
"name": "map2",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "1",
"pg": "1"
},
{
"tc":"2",
"pg":"2"
}
]
}
]
}
}
},
"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_TC": {
"sonic-tc-priority-group-map:sonic-tc-priority-group-map": {
"sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": {
"TC_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map3",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "64",
"pg": "1"
},
{
"tc":"2",
"pg":"2"
}
]
}
]
}
}
},
"TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"sonic-tc-priority-group-map:sonic-tc-priority-group-map": {
"sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": {
"TC_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map3",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "1",
"pg": "8"
},
{
"tc":"2",
"pg":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_QUEUE_MAP_CRETAE": {
"sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": {
"sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": {
"MAP_PFC_PRIORITY_TO_QUEUE_LIST": [
{
"name": "map1",
"MAP_PFC_PRIORITY_TO_QUEUE": [
{
"pfc_priority": "1",
"qindex": "1"
},
{
"pfc_priority":"2",
"qindex":"2"
}
]
},
{
"name": "map2",
"MAP_PFC_PRIORITY_TO_QUEUE": [
{
"pfc_priority": "1",
"qindex": "1"
},
{
"pfc_priority":"2",
"qindex":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_PFC_PRIORITY": {
"sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": {
"sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": {
"MAP_PFC_PRIORITY_TO_QUEUE_LIST": [
{
"name": "map3",
"MAP_PFC_PRIORITY_TO_QUEUE": [
{
"pfc_priority": "64",
"qindex": "1"
},
{
"pfc_priority":"2",
"qindex":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": {
"sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": {
"sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": {
"MAP_PFC_PRIORITY_TO_QUEUE_LIST": [
{
"name": "map3",
"MAP_PFC_PRIORITY_TO_QUEUE": [
{
"pfc_priority": "1",
"qindex": "8"
},
{
"pfc_priority":"2",
"qindex":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CRETAE": {
"sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": {
"sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map1",
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [
{
"pfc_priority": "1",
"pg": "1"
},
{
"pfc_priority":"2",
"pg":"2"
}
]
},
{
"name": "map2",
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [
{
"pfc_priority": "1",
"pg": "1"
},
{
"pfc_priority":"2",
"pg":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PFC_PRIORITY": {
"sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": {
"sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map3",
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [
{
"pfc_priority": "64",
"pg": "1"
},
{
"pfc_priority":"2",
"pg":"2"
}
]
}
]
}
}
},
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": {
"sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": {
"sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map3",
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [
{
"pfc_priority": "1",
"pg": "8"
},
{
"pfc_priority":"2",
"pg":"2"
}
]
}
]
}
}
},
"PORT_QOS_MAP_APPLY_MAPS": {
"sonic-dscp-tc-map:sonic-dscp-tc-map": {
"sonic-dscp-tc-map:DSCP_TO_TC_MAP": {
"DSCP_TO_TC_MAP_LIST": [
{
"name": "map1",
"DSCP_TO_TC_MAP": [
{
"dscp": "1",
"tc": "1"
},
{
"dscp":"2",
"tc":"2"
}
]
}
]
}
},
"sonic-dot1p-tc-map:sonic-dot1p-tc-map": {
"sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": {
"DOT1P_TO_TC_MAP_LIST": [
{
"name": "map1",
"DOT1P_TO_TC_MAP": [
{
"dot1p": "1",
"tc": "1"
},
{
"dot1p":"2",
"tc":"2"
}
]
}
]
}
},
"sonic-tc-queue-map:sonic-tc-queue-map": {
"sonic-tc-queue-map:TC_TO_QUEUE_MAP": {
"TC_TO_QUEUE_MAP_LIST": [
{
"name": "map1",
"TC_TO_QUEUE_MAP": [
{
"tc": "1",
"qindex": "1"
},
{
"tc":"2",
"qindex":"2"
}
]
}
]
}
},
"sonic-tc-priority-group-map:sonic-tc-priority-group-map": {
"sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": {
"TC_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map1",
"TC_TO_PRIORITY_GROUP_MAP": [
{
"tc": "1",
"pg": "1"
},
{
"tc":"2",
"pg":"2"
}
]
}
]
}
},
"sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": {
"sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": {
"MAP_PFC_PRIORITY_TO_QUEUE_LIST": [
{
"name": "map1",
"MAP_PFC_PRIORITY_TO_QUEUE": [
{
"pfc_priority": "1",
"qindex": "1"
},
{
"pfc_priority":"2",
"qindex":"2"
}
]
}
]
}
},
"sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": {
"sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": {
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [
{
"name": "map1",
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [
{
"pfc_priority": "1",
"pg": "1"
},
{
"pfc_priority":"2",
"pg":"2"
}
]
}
]
}
},
"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",
"dscp_to_tc_map": "map1",
"tc_to_pg_map": "map1",
"tc_to_queue_map": "map1",
"pfc_to_queue_map": "map1",
"pfc_to_pg_map": "map1",
"dscp_to_tc_map": "map1",
"dot1p_to_tc_map": "map1",
"pfc_enable": "3,4"
}
]
}
}
},
"PORT_QOS_MAP_APPLY_NON_EXISTS_MAPS": {
"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",
"dscp_to_tc_map": "map2",
"tc_to_pg_map": "map2",
"tc_to_queue_map": "map2",
"pfc_to_queue_map": "map2",
"pfc_to_pg_map": "map2",
"dscp_to_tc_map": "map2",
"dot1p_to_tc_map": "map2",
"pfc_enable": "3,4"
}
]
}
}
},
"PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet4",
"lanes": "65",
"mtu": "9000",
"name": "Ethernet4",
"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"
}
]
}
}
},
"PORT_QOS_MAP_APPLY_INVALID_PFC": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet4",
"lanes": "65",
"mtu": "9000",
"name": "Ethernet4",
"tpid": "0x8100",
"speed": "25000"
}
]
}
},
"sonic-port-qos-map:sonic-port-qos-map": {
"sonic-port-qos-map:PORT_QOS_MAP": {
"PORT_QOS_MAP_LIST": [
{
"ifname": "Ethernet4",
"pfc_enable": "8"
}
]
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-dot1p-tc-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-dot1p-tc-map";
prefix dot1ptm;
organization
"SONiC";
contact
"SONiC";
description
"DOT1P_TO_TC_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-dot1p-tc-map {
container DOT1P_TO_TC_MAP {
description "DOT1P_TO_TC_MAP part of config_db.json";
list DOT1P_TO_TC_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 DOT1P_TO_TC_MAP { //this is list inside list for storing mapping between two fields
key "dot1p";
leaf dot1p {
type string {
pattern "[0-7]?" {
error-message "Invalid DOT1P";
error-app-tag dot1p-invalid;
}
}
}
leaf tc {
type string {
pattern "[0-7]?"{
error-message "Invalid Traffic Class";
error-app-tag tc-invalid;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-dscp-tc-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-dscp-tc-map";
prefix dtm;
organization
"SONiC";
contact
"SONiC";
description
"DSCP_TO_TC_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-dscp-tc-map {
container DSCP_TO_TC_MAP {
description "DSCP_TO_TC_MAP part of config_db.json";
list DSCP_TO_TC_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 DSCP_TO_TC_MAP { //this is list inside list for storing mapping between two fields
key "dscp";
leaf dscp {
type string {
pattern "6[0-3]|[1-5][0-9]?|[0-9]?" {
error-message "Invalid DSCP";
error-app-tag dscp-invalid;
}
}
}
leaf tc {
type string {
pattern "[0-7]?" {
error-message "Invalid Traffic Class";
error-app-tag tc-invalid;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-pfc-priority-priority-group-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-pfc-priority-priority-group-map";
prefix pppgm;
organization
"SONiC";
contact
"SONiC";
description
"PFC_PRIORITY_TO_PRIORITY_GROUP_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-pfc-priority-priority-group-map {
container PFC_PRIORITY_TO_PRIORITY_GROUP_MAP {
description "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP part of config_db.json";
list PFC_PRIORITY_TO_PRIORITY_GROUP_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 PFC_PRIORITY_TO_PRIORITY_GROUP_MAP { //this is list inside list for storing mapping between two fields
key "pfc_priority";
leaf pfc_priority {
type string {
pattern "[0-7]?" {
error-message "Invalid pfc priority";
error-app-tag pfc-priority-invalid;
}
}
}
leaf pg {
type string {
pattern "[0-7]?" {
error-message "Invalid Priority Group";
error-app-tag pg-invalid;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-pfc-priority-queue-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-pfc-priority-queue-map";
prefix ppqm;
organization
"SONiC";
contact
"SONiC";
description
"PFC_PRIORITY_TO_QUEUE_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-pfc-priority-queue-map {
container MAP_PFC_PRIORITY_TO_QUEUE {
description "MAP_PFC_PRIORITY_TO_QUEUE part of config_db.json";
list MAP_PFC_PRIORITY_TO_QUEUE_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 MAP_PFC_PRIORITY_TO_QUEUE { //this is list inside list for storing mapping between two fields
key "pfc_priority";
leaf pfc_priority {
type string {
pattern "[0-7]?" {
error-message "Invalid pfc priority";
error-app-tag pfc-priority-invalid;
}
}
}
leaf qindex {
type string {
pattern "[0-7]?" {
error-message "Invalid queue index";
error-app-tag queue-index-invalid;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,110 @@
module sonic-port-qos-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-port-qos-map";
prefix pqm;
import sonic-port {
prefix prt;
}
import sonic-tc-priority-group-map {
prefix tpgm;
}
import sonic-tc-queue-map {
prefix tqm;
}
import sonic-pfc-priority-queue-map {
prefix ppqm;
}
import sonic-pfc-priority-priority-group-map {
prefix pppgm;
}
import sonic-dscp-tc-map {
prefix dtm;
}
import sonic-dot1p-tc-map {
prefix dot1ptm;
}
organization
"SONiC";
contact
"SONiC";
description
"SONIC PORT_QOS_MAP";
revision 2019-05-15 {
description
"Initial revision.";
}
container sonic-port-qos-map {
container PORT_QOS_MAP {
list PORT_QOS_MAP_LIST {
key "ifname";
leaf ifname {
type leafref {
path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name";
}
description
"Reference of port on which QOS MAPS to be configured.";
}
leaf tc_to_pg_map {
type leafref {
path "/tpgm:sonic-tc-priority-group-map/tpgm:TC_TO_PRIORITY_GROUP_MAP/tpgm:TC_TO_PRIORITY_GROUP_MAP_LIST/tpgm:name";
}
}
leaf tc_to_queue_map {
type leafref {
path "/tqm:sonic-tc-queue-map/tqm:TC_TO_QUEUE_MAP/tqm:TC_TO_QUEUE_MAP_LIST/tqm:name";
}
}
leaf pfc_enable {
type string {
pattern "[0-7](,[0-7])?";
}
}
leaf pfc_to_queue_map {
type leafref {
path "/ppqm:sonic-pfc-priority-queue-map/ppqm:MAP_PFC_PRIORITY_TO_QUEUE/ppqm:MAP_PFC_PRIORITY_TO_QUEUE_LIST/ppqm:name";
}
}
leaf pfc_to_pg_map {
type leafref {
path "/pppgm:sonic-pfc-priority-priority-group-map/pppgm:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP/pppgm:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST/pppgm:name";
}
}
leaf dscp_to_tc_map {
type leafref {
path "/dtm:sonic-dscp-tc-map/dtm:DSCP_TO_TC_MAP/dtm:DSCP_TO_TC_MAP_LIST/dtm:name";
}
}
leaf dot1p_to_tc_map {
type leafref {
path "/dot1ptm:sonic-dot1p-tc-map/dot1ptm:DOT1P_TO_TC_MAP/dot1ptm:DOT1P_TO_TC_MAP_LIST/dot1ptm:name";
}
}
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-tc-priority-group-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-tc-priority-group-map";
prefix tpgm;
organization
"SONiC";
contact
"SONiC";
description
"TC_TO_PRIORITY_GROUP_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-tc-priority-group-map {
container TC_TO_PRIORITY_GROUP_MAP {
description "TC_TO_PRIORITY_GROUP_MAP part of config_db.json";
list TC_TO_PRIORITY_GROUP_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_PRIORITY_GROUP_MAP { //this is list inside list for storing mapping between two fields
key "tc";
leaf tc {
type string {
pattern "[0-7]?" {
error-message "Invalid Traffic Class";
error-app-tag tc-invalid;
}
}
}
leaf pg {
type string {
pattern "[0-7]?" {
error-message "Invalid Priority Group";
error-app-tag pg-invalid;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,68 @@
module sonic-tc-queue-map {
yang-version 1.1;
namespace "http://github.com/Azure/sonic-tc-queue-map";
prefix tqm;
organization
"SONiC";
contact
"SONiC";
description
"TC_TO_QUEUE_MAP yang Module for SONiC OS";
revision 2021-04-15 {
description
"Initial revision.";
}
container sonic-tc-queue-map {
container TC_TO_QUEUE_MAP {
description "TC_TO_QUEUE_MAP part of config_db.json";
list TC_TO_QUEUE_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_QUEUE_MAP { //this is list inside list for storing mapping between two fields
key "tc";
leaf tc {
type string {
pattern "[0-7]?" {
error-message "Invalid Traffic Class";
error-app-tag tc-invalid;
}
}
}
leaf qindex {
type string {
pattern "[0-7]?" {
error-message "Invalid queue index";
error-app-tag queue-index-invalid;
}
}
}
}
}
}
}
}