Skip to content

Commit e02ac66

Browse files
stephenxsliushilongbuaa
authored andcommitted
Support yang model for buffer pool percentage (sonic-net#19358)
#### 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
1 parent 74e6426 commit e02ac66

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

src/sonic-yang-models/doc/Configuration.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ When the system is running in traditional buffer model, the size of all of the b
573573
```
574574

575575
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.
576+
In this case, A percentage can be configured on a pool, representing how many the available buffer can be allloced to the pool.
576577

577578
```
578579
{
@@ -584,11 +585,12 @@ When the system is running in dynamic buffer model, the size of some of the buff
584585
},
585586
"egress_lossy_pool": {
586587
"type": "egress",
587-
"mode": "dynamic",
588+
"mode": "dynamic"
588589
},
589590
"ingress_lossless_pool": {
590591
"type": "ingress",
591592
"mode": "dynamic",
593+
"percentage": "80"
592594
}
593595
}
594596
}

src/sonic-yang-models/tests/files/sample_config_db.json

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
"size": "12766208",
3737
"type": "egress",
3838
"mode": "dynamic"
39+
},
40+
"ingress_percentage_pool": {
41+
"type": "ingress",
42+
"mode": "dynamic",
43+
"percentage": "90"
3944
}
4045
},
4146
"BUFFER_PROFILE": {
@@ -351,6 +356,7 @@
351356
},
352357
"DEVICE_METADATA": {
353358
"localhost": {
359+
"buffer_model": "dynamic",
354360
"type": "ToRRouter",
355361
"asic_id": "06:00.0",
356362
"mac": "00:11:22:33:dd:5a",

src/sonic-yang-models/tests/yang_model_tests/tests/buffer_pool.json

+18
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,23 @@
3939
"BUFFER_POOL_WRONG_SIZE_VALUE": {
4040
"desc": "BUFFER_POOL_WRONG_SIZE_VALUE pattern failure.",
4141
"eStr": "wrong"
42+
},
43+
"BUFFER_POOL_CORRECT_PERCENTAGE_VALUE": {
44+
"desc": "BUFFER_POOL_CORRECT_PERCENTAGE_VALUE no failure."
45+
},
46+
"BUFFER_POOL_CORRECT_LARGE_PERCENTAGE_VALUE": {
47+
"desc": "BUFFER_POOL_CORRECT_PERCENTAGE_VALUE no failure."
48+
},
49+
"BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE": {
50+
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE pattern failure.",
51+
"eStr": "Invalid value"
52+
},
53+
"BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE": {
54+
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE pattern failure.",
55+
"eStr": "Invalid value"
56+
},
57+
"BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE": {
58+
"desc": "BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE pattern failure.",
59+
"eStr": "Percentage should not be configured along with size"
4260
}
4361
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/buffer_pool.json

+85
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,90 @@
167167
]
168168
}
169169
}
170+
},
171+
"BUFFER_POOL_CORRECT_PERCENTAGE_VALUE": {
172+
"sonic-device_metadata:sonic-device_metadata": {
173+
"sonic-device_metadata:DEVICE_METADATA": {
174+
"localhost":{
175+
"buffer_model": "dynamic"
176+
}
177+
}
178+
},
179+
"sonic-buffer-pool:sonic-buffer-pool": {
180+
"sonic-buffer-pool:BUFFER_POOL": {
181+
"BUFFER_POOL_LIST": [
182+
{
183+
"name": "ingress_lossless_pool",
184+
"mode": "dynamic",
185+
"percentage": "99",
186+
"type": "ingress"
187+
}
188+
]
189+
}
190+
}
191+
},
192+
"BUFFER_POOL_CORRECT_LARGE_PERCENTAGE_VALUE": {
193+
"sonic-device_metadata:sonic-device_metadata": {
194+
"sonic-device_metadata:DEVICE_METADATA": {
195+
"localhost":{
196+
"buffer_model": "dynamic"
197+
}
198+
}
199+
},
200+
"sonic-buffer-pool:sonic-buffer-pool": {
201+
"sonic-buffer-pool:BUFFER_POOL": {
202+
"BUFFER_POOL_LIST": [
203+
{
204+
"name": "ingress_lossless_pool",
205+
"mode": "dynamic",
206+
"percentage": "200",
207+
"type": "ingress"
208+
}
209+
]
210+
}
211+
}
212+
},
213+
"BUFFER_POOL_WRONG_PERCENTAGE_NEGATIVE_VALUE": {
214+
"sonic-buffer-pool:sonic-buffer-pool": {
215+
"sonic-buffer-pool:BUFFER_POOL": {
216+
"BUFFER_POOL_LIST": [
217+
{
218+
"name": "ingress_lossless_pool",
219+
"mode": "static",
220+
"percentage": "-10",
221+
"type": "ingress"
222+
}
223+
]
224+
}
225+
}
226+
},
227+
"BUFFER_POOL_WRONG_PERCENTAGE_NOT_A_NUMBER_VALUE": {
228+
"sonic-buffer-pool:sonic-buffer-pool": {
229+
"sonic-buffer-pool:BUFFER_POOL": {
230+
"BUFFER_POOL_LIST": [
231+
{
232+
"name": "ingress_lossless_pool",
233+
"mode": "static",
234+
"percentage": "NaN",
235+
"type": "ingress"
236+
}
237+
]
238+
}
239+
}
240+
},
241+
"BUFFER_POOL_WRONG_PERCENTAGE_VALUE_WITH_SIZE": {
242+
"sonic-buffer-pool:sonic-buffer-pool": {
243+
"sonic-buffer-pool:BUFFER_POOL": {
244+
"BUFFER_POOL_LIST": [
245+
{
246+
"name": "ingress_lossless_pool",
247+
"mode": "static",
248+
"percentage": "90",
249+
"size": "12766208",
250+
"type": "ingress"
251+
}
252+
]
253+
}
254+
}
170255
}
171256
}

src/sonic-yang-models/yang-models/sonic-buffer-pool.yang

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ module sonic-buffer-pool {
22
namespace "http://github.com/sonic-net/sonic-buffer-pool";
33
prefix bpl;
44

5+
import sonic-device_metadata {
6+
prefix device_metadata;
7+
}
8+
59
organization
610
"SONiC";
711

@@ -57,6 +61,20 @@ module sonic-buffer-pool {
5761
type uint64;
5862
description "Buffer Pool Xoff Threshold (in Bytes)";
5963
}
64+
65+
leaf percentage {
66+
type uint8;
67+
description "
68+
Buffer Pool percentage.
69+
The buffer pool size will be available_buffer * percentage / 100 if percentage is provided.
70+
It is valid in dynamic buffer model only.";
71+
must "(not(current()/../size))" {
72+
error-message "Percentage should not be configured along with size";
73+
}
74+
must "/device_metadata:sonic-device_metadata/device_metadata:DEVICE_METADATA/device_metadata:localhost/device_metadata:buffer_model = 'dynamic'" {
75+
error-message "Percentage must be configured in dynamic buffer model";
76+
}
77+
}
6078
}
6179
}
6280
}

0 commit comments

Comments
 (0)