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

[action] [PR:19358] Support yang model for buffer pool percentage (#19358) #19740

Merged
merged 1 commit into from
Sep 11, 2024
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
4 changes: 3 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ When the system is running in traditional buffer model, the size of all of the b
```

When the system is running in dynamic buffer model, the size of some of the buffer pools can be omitted and will be dynamically calculated.
In this case, A percentage can be configured on a pool, representing how many the available buffer can be allloced to the pool.

```
{
Expand All @@ -561,11 +562,12 @@ When the system is running in dynamic buffer model, the size of some of the buff
},
"egress_lossy_pool": {
"type": "egress",
"mode": "dynamic",
"mode": "dynamic"
},
"ingress_lossless_pool": {
"type": "ingress",
"mode": "dynamic",
"percentage": "80"
}
}
}
Expand Down
6 changes: 6 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 @@ -36,6 +36,11 @@
"size": "12766208",
"type": "egress",
"mode": "dynamic"
},
"ingress_percentage_pool": {
"type": "ingress",
"mode": "dynamic",
"percentage": "90"
}
},
"BUFFER_PROFILE": {
Expand Down Expand Up @@ -351,6 +356,7 @@
},
"DEVICE_METADATA": {
"localhost": {
"buffer_model": "dynamic",
"type": "ToRRouter",
"asic_id": "06:00.0",
"mac": "00:11:22:33:dd:5a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,23 @@
"BUFFER_POOL_WRONG_SIZE_VALUE": {
"desc": "BUFFER_POOL_WRONG_SIZE_VALUE pattern failure.",
"eStr": "wrong"
},
"BUFFER_POOL_CORRECT_PERCENTAGE_VALUE": {
"desc": "BUFFER_POOL_CORRECT_PERCENTAGE_VALUE no failure."
},
"BUFFER_POOL_CORRECT_LARGE_PERCENTAGE_VALUE": {
"desc": "BUFFER_POOL_CORRECT_PERCENTAGE_VALUE no failure."
},
"BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE": {
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE pattern failure.",
"eStr": "Invalid value"
},
"BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE": {
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE pattern failure.",
"eStr": "Invalid value"
},
"BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE": {
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE pattern failure.",
"eStr": "Percentage should not be configured along with size"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,90 @@
]
}
}
},
"BUFFER_POOL_CORRECT_PERCENTAGE_VALUE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost":{
"buffer_model": "dynamic"
}
}
},
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "ingress_lossless_pool",
"mode": "dynamic",
"percentage": "99",
"type": "ingress"
}
]
}
}
},
"BUFFER_POOL_CORRECT_LARGE_PERCENTAGE_VALUE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"localhost":{
"buffer_model": "dynamic"
}
}
},
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "ingress_lossless_pool",
"mode": "dynamic",
"percentage": "200",
"type": "ingress"
}
]
}
}
},
"BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE": {
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "ingress_lossless_pool",
"mode": "static",
"percentage": "-10",
"type": "ingress"
}
]
}
}
},
"BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE": {
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "ingress_lossless_pool",
"mode": "static",
"percentage": "NaN",
"type": "ingress"
}
]
}
}
},
"BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE": {
"sonic-buffer-pool:sonic-buffer-pool": {
"sonic-buffer-pool:BUFFER_POOL": {
"BUFFER_POOL_LIST": [
{
"name": "ingress_lossless_pool",
"mode": "static",
"percentage": "90",
"size": "12766208",
"type": "ingress"
}
]
}
}
}
}
18 changes: 18 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-buffer-pool.yang
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module sonic-buffer-pool {
namespace "http://github.com/sonic-net/sonic-buffer-pool";
prefix bpl;

import sonic-device_metadata {
prefix device_metadata;
}

organization
"SONiC";

Expand Down Expand Up @@ -57,6 +61,20 @@ module sonic-buffer-pool {
type uint64;
description "Buffer Pool Xoff Threshold (in Bytes)";
}

leaf percentage {
type uint8;
description "
Buffer Pool percentage.
The buffer pool size will be available_buffer * percentage / 100 if percentage is provided.
It is valid in dynamic buffer model only.";
must "(not(current()/../size))" {
error-message "Percentage should not be configured along with size";
}
must "/device_metadata:sonic-device_metadata/device_metadata:DEVICE_METADATA/device_metadata:localhost/device_metadata:buffer_model = 'dynamic'" {
error-message "Percentage must be configured in dynamic buffer model";
}
}
}
}
}
Expand Down
Loading