[yang][smartswitch] Add YANG model for MID_PLANE_BRIDGE and DPU tables. (#17311)

- Why I did it
Add the YANG model according to Smart Switch IP address assignment HDL.

- How I did it
Implement new YANG model containers.

- How to verify it
Run YANG model unit tests. The changes add new unit tests to cover new functionality.
This commit is contained in:
Oleksandr Ivantsiv 2023-12-19 23:05:11 -08:00 committed by GitHub
parent 30ff77350f
commit 885f1629dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 177 additions and 2 deletions

View File

@ -2718,6 +2718,37 @@ The FIPS table introduces FIPS configuration.
} }
} }
``` ```
### MID_PLANE_BRIDGE"
The MID_PLANE_BRIDGE" table introduces the configuration for the midplane bridge interface for Smart Switch.
```json
{
"MID_PLANE_BRIDGE": {
"GLOBAL" : {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
}
}
```
### DPUS
The DPUS table introduces the information on the DPUs (Data Processing Unit) available on the platform.
```json
{
"DPUS": {
"dpu0": {
"midplane_interface": "dpu0"
},
"dpu1": {
"midplane_interface": "dpu1"
}
}
}
```
#### 5.2.3 Update value directly in db memory #### 5.2.3 Update value directly in db memory

View File

@ -197,7 +197,8 @@ setup(
'./yang-models/sonic-static-route.yang', './yang-models/sonic-static-route.yang',
'./yang-models/sonic-system-port.yang', './yang-models/sonic-system-port.yang',
'./yang-models/sonic-macsec.yang', './yang-models/sonic-macsec.yang',
'./yang-models/sonic-bgp-sentinel.yang']), './yang-models/sonic-bgp-sentinel.yang',
'./yang-models/sonic-smart-switch.yang',]),
('cvlyang-models', ['./cvlyang-models/sonic-acl.yang', ('cvlyang-models', ['./cvlyang-models/sonic-acl.yang',
'./cvlyang-models/sonic-bgp-common.yang', './cvlyang-models/sonic-bgp-common.yang',
'./cvlyang-models/sonic-bgp-global.yang', './cvlyang-models/sonic-bgp-global.yang',

View File

@ -2558,6 +2558,20 @@
"bank": "1", "bank": "1",
"link": "PortChannel2" "link": "PortChannel2"
} }
},
"MID_PLANE_BRIDGE": {
"GLOBAL" : {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
},
"DPUS": {
"dpu0": {
"midplane_interface": "dpu0"
},
"dpu1": {
"midplane_interface": "dpu1"
}
} }
}, },
"SAMPLE_CONFIG_DB_UNKNOWN": { "SAMPLE_CONFIG_DB_UNKNOWN": {

View File

@ -0,0 +1,9 @@
{
"SMART_SWITCH_MID_PLANE_BRIDGE_WITH_DPU_TEST" : {
"desc": "Valid configuration in MID_PLANE_BRIDGE and DPUS tables."
},
"SMART_SWITCH_DPU_NAME_TEST" : {
"desc": "DPU name validation.",
"eStr": "does not satisfy the constraint"
}
}

View File

@ -0,0 +1,40 @@
{
"SMART_SWITCH_MID_PLANE_BRIDGE_WITH_DPU_TEST": {
"sonic-smart-switch:sonic-smart-switch": {
"sonic-smart-switch:MID_PLANE_BRIDGE": {
"GLOBAL": {
"bridge": "bridge_midplane",
"ip_prefix": "169.254.200.254/24"
}
},
"sonic-smart-switch:DPUS": {
"DPUS_LIST": [
{
"dpu_name": "dpu0",
"midplane_interface": "dpu0"
},
{
"dpu_name": "dpu1",
"midplane_interface": "dpu1"
}
]
}
}
},
"SMART_SWITCH_DPU_NAME_TEST": {
"sonic-smart-switch:sonic-smart-switch": {
"sonic-smart-switch:DPUS": {
"DPUS_LIST": [
{
"dpu_name": "dpu0",
"midplane_interface": "dpuX"
},
{
"dpu_name": "dpu1",
"midplane_interface": "dpu0"
}
]
}
}
}
}

View File

@ -157,7 +157,7 @@ module sonic-device_metadata {
leaf subtype { leaf subtype {
type string { type string {
pattern "DualToR"; pattern "DualToR|SmartSwitch";
} }
} }

View File

@ -0,0 +1,80 @@
module sonic-smart-switch {
yang-version 1.1;
namespace "http://github.com/sonic-net/sonic-smart-switch";
prefix smart-switch;
import ietf-inet-types {
prefix inet;
}
import sonic-types {
prefix stypes;
}
import sonic-port {
prefix port;
}
description "Smart Switch yang Module for SONiC OS";
revision 2023-10-17 {
description "First Revision";
}
container sonic-smart-switch {
container MID_PLANE_BRIDGE {
description "MID_PLANE_BRIDGE part of config_db.json";
container GLOBAL {
leaf bridge {
type string {
pattern "bridge_midplane";
}
description "Name of the midplane bridge";
must "(current()/../ip_prefix)";
}
leaf ip_prefix {
type stypes:sonic-ip4-prefix;
description "IP prefix of the midplane bridge";
}
}
/* end of container GLOBAL */
}
/* end of container MID_PLANE_BRIDGE */
container DPUS {
description "DPUS part of config_db.json";
list DPUS_LIST {
key "dpu_name";
leaf dpu_name {
description "Name of the DPU";
type string {
pattern "dpu[0-9]+";
}
}
leaf midplane_interface {
description "Name of the interface that represents DPU";
type string {
pattern "dpu[0-9]+";
}
must "(current() = current()/../dpu_name)";
}
}
/* end of container DPUS_LIST */
}
/* end of container DPUS */
}
/* end of container sonic-smart-switch */
}
/* end of module sonic-smart-switch */