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

[smartswitch][YANG]Add yang model for DPU_PORT information #21439

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 21 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,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"
Expand All @@ -2783,7 +2803,7 @@
"client_key": "grpcclient.key",
"ca_crt": "root.pem",
"grpc_ssl_credential": "azureclient.ms"
}
}
},
"BANNER_MESSAGE": {
"global": {
Expand Down
162 changes: 162 additions & 0 deletions src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", [
("port0", None),
vvolam marked this conversation as resolved.
Show resolved Hide resolved
("Po0rt0", 'Value "Po0rt0" 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": "port0",
"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": "port0",
"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": "port0",
"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": "port0",
"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": "port0",
"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)
72 changes: 67 additions & 5 deletions src/sonic-yang-models/yang-models/sonic-smart-switch.yang
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,30 @@ 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";

revision 2023-10-17 {
description "First Revision";
}

revision 2025-01-11 {
description "Add new container DPU_PORT";
}

container sonic-smart-switch {

container MID_PLANE_BRIDGE {
Expand Down Expand Up @@ -74,6 +84,58 @@ module sonic-smart-switch {
/* end of container DPUS_LIST */
}
/* end of container DPUS */

container DPU_PORT {
vvolam marked this conversation as resolved.
Show resolved Hide resolved
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 */
}
Expand Down
Loading