Skip to content

Commit ba601b0

Browse files
authored
[smartswitch][YANG]Add yang model for DPU_PORT information (#21439)
Why I did it Add yang model for the DPU_PORT container information as below: DPU_PORT|<PORT_NAME>:  state: up|down ; admin state of DPU device  vip_ipv4: ipv4 ip ; from minigraph  vip_ipv6: ipv6 ip ; from minigraph pa_ipv4: ipv4 pa ip ; from minigraph pa_ipv6: ipv6 pa ip ; from minigraph vdpu_id: id of vdpu ; from minigraph gnmi_port: gnmi server port ; How I did it Add new DPU_PORT container to the sonic-smart-switch.yang file. How to verify it Uploaded the new image file to the Smart Switch and confirmed that the YANG model has been updated with the new sonic-smart-switch.yang file. Description for the changelog Add yang model for the DPU_PORT information below: DPU_PORT|<PORT_NAME>:  state: up|down ; admin state of DPU device  vip_ipv4: ipv4 ip ; from minigraph  vip_ipv6: ipv6 ip ; from minigraph pa_ipv4: ipv4 pa ip ; from minigraph pa_ipv6: ipv6 pa ip ; from minigraph vdpu_id: id of vdpu ; from minigraph gnmi_port: gnmi server port ; Addresses #21141
1 parent ed5e748 commit ba601b0

File tree

4 files changed

+285
-5
lines changed

4 files changed

+285
-5
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,6 +2973,42 @@ The ASIC_SENSORS table introduces the asic sensors polling configuration when th
29732973
}
29742974
```
29752975

2976+
### DPU PORT Configuration^M
2977+
2978+
The **DPU_PORT** table introduces the configuration for the DPUs(Data Processing Unit) PORT information available on the platform.
2979+
2980+
```json
2981+
{
2982+
"DPU_PORT": {
2983+
"dpu0": {
2984+
"state": "up",
2985+
"vip_ipv4": "192.168.1.1",
2986+
"vip_ipv6": "2001:db8::10",
2987+
"pa_ipv4": "192.168.1.10",
2988+
"pa_ipv6": "2001:db8::10",
2989+
"vdpu_id": "vdpu0",
2990+
"gnmi_port": "50052"
2991+
},
2992+
"dpu1": {
2993+
"state": "down",
2994+
"vip_ipv4": "192.168.1.2",
2995+
"vip_ipv6": "2001:db8::20",
2996+
"pa_ipv4": "192.168.1.20",
2997+
"pa_ipv6": "2001:db8::20",
2998+
"vdpu_id": "vdpu1",
2999+
"gnmi_port": "50052"
3000+
}
3001+
}
3002+
}
3003+
```
3004+
3005+
**state**: Administrative status of the DPU (`up` or `down`).
3006+
**vip_ipv4**: VIP IPv4 address from minigraph.
3007+
**vip_ipv6**: VIP IPv6 address from minigraph.
3008+
**pa_ipv4**: PA IPv4 address from minigraph.
3009+
**pa_ipv6**: PA IPv6 address from minigraph.
3010+
**vdpu_id**: ID of VDPUs from minigraph.
3011+
**gnmi_port**: Port gNMI runs on.
29763012

29773013
# For Developers
29783014

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,26 @@
27792779
"midplane_interface": "dpu1"
27802780
}
27812781
},
2782+
"DPU_PORT": {
2783+
"dpu0": {
2784+
"state": "up",
2785+
"vip_ipv4": "192.168.1.1",
2786+
"vip_ipv6": "2001:db8::10",
2787+
"pa_ipv4": "192.168.1.10",
2788+
"pa_ipv6": "2001:db8::10",
2789+
"vdpu_id": "vdpu0",
2790+
"gnmi_port": "50052"
2791+
},
2792+
"dpu1": {
2793+
"state": "down",
2794+
"vip_ipv4": "192.168.1.2",
2795+
"vip_ipv6": "2001:db8::20",
2796+
"pa_ipv4": "192.168.1.20",
2797+
"pa_ipv6": "2001:db8::20",
2798+
"vdpu_id": "vdpu1",
2799+
"gnmi_port": "50052"
2800+
}
2801+
},
27822802
"XCVRD_LOG": {
27832803
"Y_CABLE": {
27842804
"log_verbosity": "notice"

src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,165 @@ def test_dpu_midplane_interface(self, yang_model, midplane_interface, error_mess
108108
}
109109

110110
yang_model.load_data(data, error_message)
111+
112+
@pytest.mark.parametrize(
113+
"port_name, error_message", [
114+
("dpu0", None),
115+
("dp0rt0", 'Value "dp0rt0" does not satisfy the constraint "[a-zA-Z]+[0-9]+"')]
116+
)
117+
def test_dpu_port_name(self, yang_model, port_name, error_message):
118+
data = {
119+
"sonic-smart-switch:sonic-smart-switch": {
120+
"sonic-smart-switch:DPU_PORT": {
121+
"DPU_PORT_LIST": [
122+
{
123+
"PORT_NAME": port_name,
124+
"state": "up",
125+
"vip_ipv4": "192.168.1.1",
126+
"vip_ipv6": "2001:db8::1",
127+
"pa_ipv4": "192.168.1.2",
128+
"pa_ipv6": "2001:db8::2",
129+
"vdpu_id": "vdpu0",
130+
"gnmi_port": 8080
131+
}
132+
]
133+
}
134+
}
135+
}
136+
137+
yang_model.load_data(data, error_message)
138+
139+
@pytest.mark.parametrize(
140+
"vip_ipv4, error_message", [
141+
("192.168.1.1", None),
142+
("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')]
143+
)
144+
def test_dpu_port_vip_ipv4(self, yang_model, vip_ipv4, error_message):
145+
data = {
146+
"sonic-smart-switch:sonic-smart-switch": {
147+
"sonic-smart-switch:DPU_PORT": {
148+
"DPU_PORT_LIST": [
149+
{
150+
"PORT_NAME": "dpu0",
151+
"state": "up",
152+
"vip_ipv4": vip_ipv4,
153+
"vip_ipv6": "2001:db8::1",
154+
"pa_ipv4": "192.168.1.2",
155+
"pa_ipv6": "2001:db8::2",
156+
"vdpu_id": "vdpu0",
157+
"gnmi_port": 8080
158+
}
159+
]
160+
}
161+
}
162+
}
163+
164+
yang_model.load_data(data, error_message)
165+
166+
@pytest.mark.parametrize(
167+
"vip_ipv6, error_message", [
168+
("2001:db8::1", None),
169+
("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')]
170+
)
171+
def test_dpu_port_vip_ipv6(self, yang_model, vip_ipv6, error_message):
172+
data = {
173+
"sonic-smart-switch:sonic-smart-switch": {
174+
"sonic-smart-switch:DPU_PORT": {
175+
"DPU_PORT_LIST": [
176+
{
177+
"PORT_NAME": "dpu0",
178+
"state": "up",
179+
"vip_ipv4": "192.168.1.1",
180+
"vip_ipv6": vip_ipv6,
181+
"pa_ipv4": "192.168.1.2",
182+
"pa_ipv6": "2001:db8::2",
183+
"vdpu_id": "vdpu0",
184+
"gnmi_port": 8080
185+
}
186+
]
187+
}
188+
}
189+
}
190+
191+
yang_model.load_data(data, error_message)
192+
193+
@pytest.mark.parametrize(
194+
"pa_ipv4, error_message", [
195+
("192.168.1.2", None),
196+
("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')]
197+
)
198+
def test_dpu_port_pa_ipv4(self, yang_model, pa_ipv4, error_message):
199+
data = {
200+
"sonic-smart-switch:sonic-smart-switch": {
201+
"sonic-smart-switch:DPU_PORT": {
202+
"DPU_PORT_LIST": [
203+
{
204+
"PORT_NAME": "dpu0",
205+
"state": "up",
206+
"vip_ipv4": "192.168.1.1",
207+
"vip_ipv6": "2001:db8::1",
208+
"pa_ipv4": pa_ipv4,
209+
"pa_ipv6": "2001:db8::2",
210+
"vdpu_id": "vdpu0",
211+
"gnmi_port": 8080
212+
}
213+
]
214+
}
215+
}
216+
}
217+
218+
yang_model.load_data(data, error_message)
219+
220+
@pytest.mark.parametrize(
221+
"pa_ipv6, error_message", [
222+
("2001:db8::2", None),
223+
("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')]
224+
)
225+
def test_dpu_port_pa_ipv6(self, yang_model, pa_ipv6, error_message):
226+
data = {
227+
"sonic-smart-switch:sonic-smart-switch": {
228+
"sonic-smart-switch:DPU_PORT": {
229+
"DPU_PORT_LIST": [
230+
{
231+
"PORT_NAME": "dpu0",
232+
"state": "up",
233+
"vip_ipv4": "192.168.1.1",
234+
"vip_ipv6": "2001:db8::1",
235+
"pa_ipv4": "192.168.1.2",
236+
"pa_ipv6": pa_ipv6,
237+
"vdpu_id": "vdpu0",
238+
"gnmi_port": 8080
239+
}
240+
]
241+
}
242+
}
243+
}
244+
245+
yang_model.load_data(data, error_message)
246+
247+
@pytest.mark.parametrize(
248+
"gnmi_port, error_message", [
249+
(8080, None),
250+
(99999, 'Invalid value "99999" in "gnmi_port" element.')]
251+
)
252+
def test_dpu_port_gnmi(self, yang_model, gnmi_port, error_message):
253+
data = {
254+
"sonic-smart-switch:sonic-smart-switch": {
255+
"sonic-smart-switch:DPU_PORT": {
256+
"DPU_PORT_LIST": [
257+
{
258+
"PORT_NAME": "dpu0",
259+
"state": "up",
260+
"vip_ipv4": "192.168.1.1",
261+
"vip_ipv6": "2001:db8::1",
262+
"pa_ipv4": "192.168.1.2",
263+
"pa_ipv6": "2001:db8::2",
264+
"vdpu_id": "vdpu0",
265+
"gnmi_port": gnmi_port
266+
}
267+
]
268+
}
269+
}
270+
}
271+
272+
yang_model.load_data(data, error_message)

src/sonic-yang-models/yang-models/sonic-smart-switch.yang

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,30 @@ module sonic-smart-switch {
99
prefix inet;
1010
}
1111

12-
import sonic-types {
13-
prefix stypes;
14-
}
12+
import sonic-types {
13+
prefix stypes;
14+
}
1515

1616
import sonic-port {
17-
prefix port;
18-
}
17+
prefix port;
18+
}
19+
20+
organization
21+
"SONiC";
22+
23+
contact
24+
"SONiC";
1925

2026
description "Smart Switch yang Module for SONiC OS";
2127

2228
revision 2023-10-17 {
2329
description "First Revision";
2430
}
2531

32+
revision 2025-01-11 {
33+
description "Add new container DPU_PORT";
34+
}
35+
2636
container sonic-smart-switch {
2737

2838
container MID_PLANE_BRIDGE {
@@ -74,6 +84,58 @@ module sonic-smart-switch {
7484
/* end of container DPUS_LIST */
7585
}
7686
/* end of container DPUS */
87+
88+
container DPU_PORT {
89+
description "DPU_PORTs part of config_db.json";
90+
91+
list DPU_PORT_LIST {
92+
description "Name of the DPU port";
93+
key "PORT_NAME";
94+
95+
leaf PORT_NAME {
96+
description "Name of the DPU port";
97+
type string {
98+
pattern "[a-zA-Z]+[0-9]+";
99+
}
100+
}
101+
102+
leaf state {
103+
description "Admin state of DPU device";
104+
type stypes:admin_status;
105+
}
106+
107+
leaf vip_ipv4 {
108+
description "VIP IPv4 address from minigraph";
109+
type inet:ipv4-address;
110+
}
111+
112+
leaf vip_ipv6 {
113+
description "VIP IPv6 address from minigraph";
114+
type inet:ipv6-address;
115+
}
116+
117+
leaf pa_ipv4 {
118+
description "PA IPv4 address from minigraph";
119+
type inet:ipv4-address;
120+
}
121+
122+
leaf pa_ipv6 {
123+
description "PA IPv6 address from minigraph";
124+
type inet:ipv6-address;
125+
}
126+
127+
leaf vdpu_id {
128+
description "ID of VDPUs from minigraph";
129+
type string;
130+
}
131+
132+
leaf gnmi_port {
133+
description "Port gNMI runs on.";
134+
type inet:port-number;
135+
}
136+
}
137+
}
138+
/* end of container DPU_PORT */
77139
}
78140
/* end of container sonic-smart-switch */
79141
}

0 commit comments

Comments
 (0)