Skip to content

Commit

Permalink
Support yang model for buffer pool percentage (sonic-net#19358)
Browse files Browse the repository at this point in the history
#### Why I did it

Support yang model for `percentage` field in `BUFFER_POOL` table.
It is used in dynamic buffer model only and represents the percentage of a buffer pool's size compared to the available memory size

#### How I did it

#### How to verify it

Unit test and manual test
  • Loading branch information
stephenxs authored and liushilongbuaa committed Aug 1, 2024
1 parent 74e6426 commit e02ac66
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 1 deletion.
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 @@ -573,6 +573,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 @@ -584,11 +585,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

0 comments on commit e02ac66

Please sign in to comment.