diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 0a721774e3c4..b3ff0589dc19 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -2973,6 +2973,42 @@ The ASIC_SENSORS table introduces the asic sensors polling configuration when th } ``` +### DPU PORT Configuration^M + +The **DPU_PORT** table introduces the configuration for the DPUs(Data Processing Unit) PORT information available on the platform. + +```json +{ + "DPU_PORT": { + "dpu0": { + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::10", + "pa_ipv4": "192.168.1.10", + "pa_ipv6": "2001:db8::10", + "vdpu_id": "vdpu0", + "gnmi_port": "50052" + }, + "dpu1": { + "state": "down", + "vip_ipv4": "192.168.1.2", + "vip_ipv6": "2001:db8::20", + "pa_ipv4": "192.168.1.20", + "pa_ipv6": "2001:db8::20", + "vdpu_id": "vdpu1", + "gnmi_port": "50052" + } + } +} +``` + +**state**: Administrative status of the DPU (`up` or `down`). +**vip_ipv4**: VIP IPv4 address from minigraph. +**vip_ipv6**: VIP IPv6 address from minigraph. +**pa_ipv4**: PA IPv4 address from minigraph. +**pa_ipv6**: PA IPv6 address from minigraph. +**vdpu_id**: ID of VDPUs from minigraph. +**gnmi_port**: Port gNMI runs on. # For Developers diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 36a21caecdc9..55aa8453f3d7 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -2778,6 +2778,26 @@ "midplane_interface": "dpu1" } }, + "DPU_PORT": { + "dpu0": { + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::10", + "pa_ipv4": "192.168.1.10", + "pa_ipv6": "2001:db8::10", + "vdpu_id": "vdpu0", + "gnmi_port": "50052" + }, + "dpu1": { + "state": "down", + "vip_ipv4": "192.168.1.2", + "vip_ipv6": "2001:db8::20", + "pa_ipv4": "192.168.1.20", + "pa_ipv6": "2001:db8::20", + "vdpu_id": "vdpu1", + "gnmi_port": "50052" + } + }, "XCVRD_LOG": { "Y_CABLE": { "log_verbosity": "notice" @@ -2794,7 +2814,7 @@ "client_key": "grpcclient.key", "ca_crt": "root.pem", "grpc_ssl_credential": "azureclient.ms" - } + } }, "BANNER_MESSAGE": { "global": { diff --git a/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py b/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py index f1242719c028..4258e5e80641 100644 --- a/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py +++ b/src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py @@ -108,3 +108,165 @@ def test_dpu_midplane_interface(self, yang_model, midplane_interface, error_mess } yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "port_name, error_message", [ + ("dpu0", None), + ("dp0rt0", 'Value "dp0rt0" does not satisfy the constraint "[a-zA-Z]+[0-9]+"')] + ) + def test_dpu_port_name(self, yang_model, port_name, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": port_name, + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::1", + "pa_ipv4": "192.168.1.2", + "pa_ipv6": "2001:db8::2", + "vdpu_id": "vdpu0", + "gnmi_port": 8080 + } + ] + } + } + } + + yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "vip_ipv4, error_message", [ + ("192.168.1.1", None), + ("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')] + ) + def test_dpu_port_vip_ipv4(self, yang_model, vip_ipv4, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": "dpu0", + "state": "up", + "vip_ipv4": vip_ipv4, + "vip_ipv6": "2001:db8::1", + "pa_ipv4": "192.168.1.2", + "pa_ipv6": "2001:db8::2", + "vdpu_id": "vdpu0", + "gnmi_port": 8080 + } + ] + } + } + } + + yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "vip_ipv6, error_message", [ + ("2001:db8::1", None), + ("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')] + ) + def test_dpu_port_vip_ipv6(self, yang_model, vip_ipv6, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": "dpu0", + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": vip_ipv6, + "pa_ipv4": "192.168.1.2", + "pa_ipv6": "2001:db8::2", + "vdpu_id": "vdpu0", + "gnmi_port": 8080 + } + ] + } + } + } + + yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "pa_ipv4, error_message", [ + ("192.168.1.2", None), + ("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')] + ) + def test_dpu_port_pa_ipv4(self, yang_model, pa_ipv4, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": "dpu0", + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::1", + "pa_ipv4": pa_ipv4, + "pa_ipv6": "2001:db8::2", + "vdpu_id": "vdpu0", + "gnmi_port": 8080 + } + ] + } + } + } + + yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "pa_ipv6, error_message", [ + ("2001:db8::2", None), + ("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')] + ) + def test_dpu_port_pa_ipv6(self, yang_model, pa_ipv6, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": "dpu0", + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::1", + "pa_ipv4": "192.168.1.2", + "pa_ipv6": pa_ipv6, + "vdpu_id": "vdpu0", + "gnmi_port": 8080 + } + ] + } + } + } + + yang_model.load_data(data, error_message) + + @pytest.mark.parametrize( + "gnmi_port, error_message", [ + (8080, None), + (99999, 'Invalid value "99999" in "gnmi_port" element.')] + ) + def test_dpu_port_gnmi(self, yang_model, gnmi_port, error_message): + data = { + "sonic-smart-switch:sonic-smart-switch": { + "sonic-smart-switch:DPU_PORT": { + "DPU_PORT_LIST": [ + { + "PORT_NAME": "dpu0", + "state": "up", + "vip_ipv4": "192.168.1.1", + "vip_ipv6": "2001:db8::1", + "pa_ipv4": "192.168.1.2", + "pa_ipv6": "2001:db8::2", + "vdpu_id": "vdpu0", + "gnmi_port": gnmi_port + } + ] + } + } + } + + yang_model.load_data(data, error_message) diff --git a/src/sonic-yang-models/yang-models/sonic-smart-switch.yang b/src/sonic-yang-models/yang-models/sonic-smart-switch.yang index 77880f0362c3..1b91e5b61ced 100644 --- a/src/sonic-yang-models/yang-models/sonic-smart-switch.yang +++ b/src/sonic-yang-models/yang-models/sonic-smart-switch.yang @@ -9,13 +9,19 @@ module sonic-smart-switch { prefix inet; } - import sonic-types { - prefix stypes; - } + import sonic-types { + prefix stypes; + } import sonic-port { - prefix port; - } + prefix port; + } + + organization + "SONiC"; + + contact + "SONiC"; description "Smart Switch yang Module for SONiC OS"; @@ -23,6 +29,10 @@ module sonic-smart-switch { description "First Revision"; } + revision 2025-01-11 { + description "Add new container DPU_PORT"; + } + container sonic-smart-switch { container MID_PLANE_BRIDGE { @@ -74,6 +84,58 @@ module sonic-smart-switch { /* end of container DPUS_LIST */ } /* end of container DPUS */ + + container DPU_PORT { + description "DPU_PORTs part of config_db.json"; + + list DPU_PORT_LIST { + description "Name of the DPU port"; + key "PORT_NAME"; + + leaf PORT_NAME { + description "Name of the DPU port"; + type string { + pattern "[a-zA-Z]+[0-9]+"; + } + } + + leaf state { + description "Admin state of DPU device"; + type stypes:admin_status; + } + + leaf vip_ipv4 { + description "VIP IPv4 address from minigraph"; + type inet:ipv4-address; + } + + leaf vip_ipv6 { + description "VIP IPv6 address from minigraph"; + type inet:ipv6-address; + } + + leaf pa_ipv4 { + description "PA IPv4 address from minigraph"; + type inet:ipv4-address; + } + + leaf pa_ipv6 { + description "PA IPv6 address from minigraph"; + type inet:ipv6-address; + } + + leaf vdpu_id { + description "ID of VDPUs from minigraph"; + type string; + } + + leaf gnmi_port { + description "Port gNMI runs on."; + type inet:port-number; + } + } + } + /* end of container DPU_PORT */ } /* end of container sonic-smart-switch */ }