Skip to content
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
34 changes: 33 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Table of Contents
* [Restapi](#restapi)
* [System Port](#system-port)
* [Tacplus Server](#tacplus-server)
* [TC to DSCP map](#tc-to-dscp-map)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
* [Telemetry](#telemetry)
Expand Down Expand Up @@ -2363,6 +2364,21 @@ and is listed in this table.
}
```

### TC to DSCP map

```json
{
"TC_TO_DSCP_MAP": {
"AZURE": {
"5": "10",
"6": "20"
}
}
}
```

**Note:**
* configuration is mandatory when packet trimming Asymmetric DSCP mode is used

### TC to Priority group map

Expand Down Expand Up @@ -2515,7 +2531,8 @@ and try sending it on a different queue to deliver a packet drop notification to

***TRIMMING***

```
Symmetric DSCP and static queue:
```json
{
"SWITCH_TRIMMING": {
"GLOBAL": {
Expand All @@ -2527,7 +2544,22 @@ and try sending it on a different queue to deliver a packet drop notification to
}
```

Asymmetric DSCP and dynamic queue:
```json
{
"SWITCH_TRIMMING": {
"GLOBAL": {
"size": "128",
"dscp_value": "from-tc",
"tc_value": "8",
"queue_index": "dynamic"
}
}
}
```

**Note:**
* when `dscp_value` is set to `from-tc`, the `tc_value` is used for mapping to DSCP
* when `queue_index` is set to `dynamic`, the `dscp_value` is used for mapping to queue

### Versions
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@
"SWITCH_TRIMMING": {
"GLOBAL": {
"size": "128",
"dscp_value": "48",
"dscp_value": "from-tc",
"tc_value": "6",
"queue_index": "6"
}
},
Expand Down
46 changes: 36 additions & 10 deletions src/sonic-yang-models/tests/yang_model_pytests/test_trimming.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@

class TestTrimming:
@pytest.mark.parametrize(
"index", [
pytest.param('6', id="static"),
pytest.param('dynamic', id="dynamic")
"queue", [
pytest.param('6', id="queue-static"),
pytest.param('dynamic', id="queue-dynamic")
]
)
def test_valid_data(self, yang_model, index):
@pytest.mark.parametrize(
"dscp", [
pytest.param('48', id="dscp-symmetric"),
pytest.param('from-tc', id="dscp-asymmetric")
]
)
def test_valid_data(self, yang_model, dscp, queue):
data = {
"sonic-trimming:sonic-trimming": {
"sonic-trimming:SWITCH_TRIMMING": {
"GLOBAL": {
"size": "128",
"dscp_value": "48",
"queue_index": index
"dscp_value": dscp,
"tc_value": "6",
"queue_index": queue
}
}
}
Expand Down Expand Up @@ -45,7 +52,7 @@ def test_neg_size(self, yang_model, size, error_message):
@pytest.mark.parametrize(
"dscp,error_message", [
pytest.param('-1', 'Invalid value', id="min-1"),
pytest.param('64', 'Invalid DSCP value', id="max+1")
pytest.param('64', 'Invalid value', id="max+1")
]
)
def test_neg_dscp_value(self, yang_model, dscp, error_message):
Expand All @@ -62,17 +69,36 @@ def test_neg_dscp_value(self, yang_model, dscp, error_message):
yang_model.load_data(data, error_message)

@pytest.mark.parametrize(
"index,error_message", [
"tc,error_message", [
pytest.param('-1', 'Invalid value', id="min-1"),
pytest.param('256', 'Invalid value', id="max+1")
]
)
def test_neg_tc_value(self, yang_model, tc, error_message):
data = {
"sonic-trimming:sonic-trimming": {
"sonic-trimming:SWITCH_TRIMMING": {
"GLOBAL": {
"tc_value": tc
}
}
}
}

yang_model.load_data(data, error_message)

@pytest.mark.parametrize(
"queue,error_message", [
pytest.param('-1', 'Invalid value', id="min-1"),
pytest.param('256', 'Invalid value', id="max+1")
]
)
def test_neg_queue_index(self, yang_model, index, error_message):
def test_neg_queue_index(self, yang_model, queue, error_message):
data = {
"sonic-trimming:sonic-trimming": {
"sonic-trimming:SWITCH_TRIMMING": {
"GLOBAL": {
"queue_index": index
"queue_index": queue
}
}
}
Expand Down
24 changes: 18 additions & 6 deletions src/sonic-yang-models/yang-models/sonic-trimming.yang
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,31 @@ module sonic-trimming {
}

leaf dscp_value {
description "DSCP value assigned to a packet after trimming";
type uint8 {
range "0..63" {
error-message "Invalid DSCP value";
error-app-tag dscp-invalid;
description
"DSCP value assigned to a packet after trimming.
When set to from-tc, the tc_value is used for mapping to the DSCP";
type union {
type uint8 {
range "0..63" {
error-message "Invalid DSCP value";
error-app-tag dscp-invalid;
}
}
type string {
pattern "from-tc";
}
}
}

leaf tc_value {
description "TC value assigned to a packet after trimming";
type uint8;
}

leaf queue_index {
description
"Queue index to use for transmission of a packet after trimming.
When set to dynamic, the dscp_value is used for mapping to queue";
When set to dynamic, the dscp_value is used for mapping to the queue";
type union {
type uint8;
type string {
Expand Down
Loading