[yang-models] Add YANG model for SYSTEM_PORT (#12689)

Add YANG model for SYSTEM_PORT.
Resolves https://github.com/sonic-net/sonic-buildimage/issues/12458

#### Why I did it
YANG model for SYSTEM_PORT in CONFIG_DB was missing. 

#### How I did it
Added new YANG model and associated unit tests.

#### How to verify it
Passing unit tests
This commit is contained in:
kenneth-arista 2023-02-02 10:19:30 -08:00 committed by GitHub
parent ee1c32a802
commit 9d19ac92a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 331 additions and 16 deletions

View File

@ -619,7 +619,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/1</Name>
<Name>Ethernet0</Name>
<Hostname>linecard-1</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -630,7 +630,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/2</Name>
<Name>Ethernet4</Name>
<Hostname>linecard-1</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -641,7 +641,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/3</Name>
<Name>Ethernet8</Name>
<Hostname>linecard-1</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -652,7 +652,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/4</Name>
<Name>Ethernet12</Name>
<Hostname>linecard-1</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -675,7 +675,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/5</Name>
<Name>Ethernet0</Name>
<Hostname>linecard-2</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -686,7 +686,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/6</Name>
<Name>Ethernet4</Name>
<Hostname>linecard-2</Hostname>
<AsicName>Asic0</AsicName>
<Speed>40000</Speed>
@ -709,7 +709,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/7</Name>
<Name>Ethernet8</Name>
<Hostname>linecard-2</Hostname>
<AsicName>Asic1</AsicName>
<Speed>40000</Speed>
@ -720,7 +720,7 @@
<NumVoq>8</NumVoq>
</SystemPort>
<SystemPort>
<Name>Ethernet1/8</Name>
<Name>Ethernet12</Name>
<Hostname>linecard-2</Hostname>
<AsicName>Asic1</AsicName>
<Speed>40000</Speed>

View File

@ -889,16 +889,16 @@ class TestCfgGen(TestCase):
json.loads(self.run_script(argument)),
{
"linecard-1|Asic0|Cpu0": { "core_port_index": "0", "num_voq": "8", "switch_id": "0", "speed": "1000", "core_index": "0", "system_port_id": "1" },
"linecard-1|Asic0|Ethernet1/1": { "core_port_index": "1", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "0", "system_port_id": "2" },
"linecard-1|Asic0|Ethernet1/2": { "core_port_index": "2", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "0", "system_port_id": "3" },
"linecard-1|Asic0|Ethernet1/3": { "core_port_index": "3", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "1", "system_port_id": "4" },
"linecard-1|Asic0|Ethernet1/4": { "core_port_index": "4", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "1", "system_port_id": "5" },
"linecard-1|Asic0|Ethernet0": { "core_port_index": "1", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "0", "system_port_id": "2" },
"linecard-1|Asic0|Ethernet4": { "core_port_index": "2", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "0", "system_port_id": "3" },
"linecard-1|Asic0|Ethernet8": { "core_port_index": "3", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "1", "system_port_id": "4" },
"linecard-1|Asic0|Ethernet12": { "core_port_index": "4", "num_voq": "8", "switch_id": "0", "speed": "40000", "core_index": "1", "system_port_id": "5" },
"linecard-2|Asic0|Cpu0": { "core_port_index": "0", "num_voq": "8", "switch_id": "2", "speed": "1000", "core_index": "0", "system_port_id": "256" },
"linecard-2|Asic0|Ethernet1/5": { "core_port_index": "1", "num_voq": "8", "switch_id": "2", "speed": "40000", "core_index": "0", "system_port_id": "257" },
"linecard-2|Asic0|Ethernet1/6": { "core_port_index": "2", "num_voq": "8", "switch_id": "2", "speed": "40000", "core_index": "1", "system_port_id": "258" },
"linecard-2|Asic0|Ethernet0": { "core_port_index": "1", "num_voq": "8", "switch_id": "2", "speed": "40000", "core_index": "0", "system_port_id": "257" },
"linecard-2|Asic0|Ethernet4": { "core_port_index": "2", "num_voq": "8", "switch_id": "2", "speed": "40000", "core_index": "1", "system_port_id": "258" },
"linecard-2|Asic1|Cpu0": { "core_port_index": "0", "num_voq": "8", "switch_id": "4", "speed": "1000", "core_index": "0", "system_port_id": "259" },
"linecard-2|Asic1|Ethernet1/7": { "core_port_index": "1", "num_voq": "8", "switch_id": "4", "speed": "40000", "core_index": "0", "system_port_id": "260" },
"linecard-2|Asic1|Ethernet1/8": { "core_port_index": "2", "num_voq": "8", "switch_id": "4", "speed": "40000", "core_index": "1", "system_port_id": "261" }
"linecard-2|Asic1|Ethernet8": { "core_port_index": "1", "num_voq": "8", "switch_id": "4", "speed": "40000", "core_index": "0", "system_port_id": "260" },
"linecard-2|Asic1|Ethernet12": { "core_port_index": "2", "num_voq": "8", "switch_id": "4", "speed": "40000", "core_index": "1", "system_port_id": "261" }
}
)

View File

@ -50,6 +50,7 @@ Table of Contents
* [Syslog Rate Limit](#syslog-rate-limit)
* [Sflow](#sflow)
* [Restapi](#restapi)
* [System Port](#system-port)
* [Tacplus Server](#tacplus-server)
* [TC to Priority group map](#tc-to-priority-group-map)
* [TC to Queue map](#tc-to-queue-map)
@ -1528,6 +1529,49 @@ Container side configuration:
}
```
### System Port
Every port on the system requires a global representation, known as a System Port,
and is listed in this table.
```
{
"SYSTEM_PORT": {
"host227-4|asic0|Ethernet0": {
"core_index": "1",
"core_port_index": "1",
"num_voq": "8",
"speed": "100000",
"switch_id": "0",
"system_port_id": "1"
},
"host227-4|asic0|Ethernet4": {
"core_index": "1",
"core_port_index": "2",
"num_voq": "8",
"speed": "100000",
"switch_id": "0",
"system_port_id": "2"
},
"host227-5|asic0|Ethernet0": {
"core_index": "1",
"core_port_index": "1",
"num_voq": "8",
"speed": "100000",
"switch_id": "4",
"system_port_id": "80"
},
"host227-5|asic0|Ethernet4": {
"core_index": "1",
"core_port_index": "2",
"num_voq": "8",
"speed": "100000",
"switch_id": "4",
"system_port_id": "81"
}
}
}
```
### Tacplus Server
```

View File

@ -175,6 +175,7 @@ setup(
'./yang-models/sonic-logger.yang',
'./yang-models/sonic-port-qos-map.yang',
'./yang-models/sonic-static-route.yang',
'./yang-models/sonic-system-port.yang',
'./yang-models/sonic-macsec.yang']),
('cvlyang-models', ['./cvlyang-models/sonic-acl.yang',
'./cvlyang-models/sonic-bgp-common.yang',
@ -241,6 +242,7 @@ setup(
'./cvlyang-models/sonic-logger.yang',
'./cvlyang-models/sonic-port-qos-map.yang',
'./cvlyang-models/sonic-static-route.yang',
'./cvlyang-models/sonic-system-port.yang',
'./cvlyang-models/sonic-macsec.yang']),
],
zip_safe=False,

View File

@ -1350,6 +1350,80 @@
"login": "local"
}
},
"SYSTEM_PORT": {
"host227-4|asic0|Cpu0": {
"core_index": "0",
"core_port_index": "0",
"num_voq": "8",
"speed": "10000",
"switch_id": "0",
"system_port_id": "1"
},
"host227-4|asic0|Ethernet0": {
"core_index": "1",
"core_port_index": "1",
"num_voq": "8",
"speed": "100000",
"switch_id": "0",
"system_port_id": "2"
},
"host227-4|asic0|Ethernet4": {
"core_index": "1",
"core_port_index": "2",
"num_voq": "8",
"speed": "100000",
"switch_id": "0",
"system_port_id": "3"
},
"host227-4|asic1|Cpu0": {
"core_index": "0",
"core_port_index": "0",
"num_voq": "8",
"speed": "10000",
"switch_id": "0",
"system_port_id": "41"
},
"host227-4|asic1|Ethernet8": {
"core_index": "0",
"core_port_index": "1",
"num_voq": "8",
"speed": "100000",
"switch_id": "2",
"system_port_id": "42"
},
"host227-4|asic1|Ethernet12": {
"core_index": "0",
"core_port_index": "2",
"num_voq": "8",
"speed": "100000",
"switch_id": "2",
"system_port_id": "43"
},
"host227-5|asic0|Cpu0": {
"core_index": "0",
"core_port_index": "0",
"num_voq": "8",
"speed": "10000",
"switch_id": "0",
"system_port_id": "81"
},
"host227-5|asic0|Ethernet0": {
"core_index": "1",
"core_port_index": "1",
"num_voq": "8",
"speed": "100000",
"switch_id": "4",
"system_port_id": "82"
},
"host227-5|asic0|Ethernet4": {
"core_index": "1",
"core_port_index": "2",
"num_voq": "8",
"speed": "100000",
"switch_id": "4",
"system_port_id": "83"
}
},
"TACPLUS": {
"global": {
"auth_type": "pap",

View File

@ -0,0 +1,9 @@
{
"SYSTEM_PORT_POSITIVE_CONFIG": {
"desc": "Configure SYSTEM_PORT positive config."
},
"SYSTEM_PORT_WRONG_SPEED_PATTERN": {
"desc": "Configure SYSTEM_PORT wrong speed.",
"eStr": ["pattern", "does not satisfy"]
}
}

View File

@ -0,0 +1,91 @@
{
"SYSTEM_PORT_POSITIVE_CONFIG": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 100000
},
{
"admin_status": "up",
"alias": "eth4",
"description": "Ethernet4",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet4",
"speed": 100000
}
]
}
},
"sonic-system-port:sonic-system-port": {
"sonic-system-port:SYSTEM_PORT": {
"SYSTEM_PORT_LIST": [
{
"hostname": "host123",
"asic_name": "asic0",
"ifname": "Ethernet0",
"core_index": "0",
"core_port_index": "10",
"num_voq": "8",
"speed": "100000",
"switch_id": "0",
"system_port_id": "100"
},
{
"hostname": "host123",
"asic_name": "asic1",
"ifname": "Ethernet4",
"core_index": "1",
"core_port_index": "20",
"num_voq": "8",
"speed": "100000",
"switch_id": "1",
"system_port_id": "200"
}
]
}
}
},
"SYSTEM_PORT_WRONG_SPEED_PATTERN": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth0",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 100000
}
]
}
},
"sonic-system-port:sonic-system-port": {
"sonic-system-port:SYSTEM_PORT": {
"SYSTEM_PORT_LIST": [
{
"hostname": "host456",
"asic_name": "asic0",
"ifname": "Ethernet0",
"core_index": "1",
"core_port_index": "20",
"num_voq": "8",
"speed": "900000",
"switch_id": "1",
"system_port_id": "200"
}
]
}
}
}
}

View File

@ -0,0 +1,95 @@
module sonic-system-port {
yang-version 1.1;
namespace "http://github.com/sonic-net/sonic-system-port";
prefix system-port;
import sonic-port {
prefix port;
}
import sonic-types {
prefix stypes;
}
description "SYSTEM_PORT YANG Module for SONiC OS";
revision 2022-11-10 {
description "First Revision";
}
container sonic-system-port {
container SYSTEM_PORT {
description "SYSTEM_PORT table of config_db.json";
list SYSTEM_PORT_LIST {
key "hostname asic_name ifname";
leaf hostname {
type stypes:hostname;
}
leaf asic_name {
type string {
pattern "[Aa]sic[0-4]";
}
}
leaf ifname {
type union {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:name;
}
type string {
pattern "Cpu0";
}
}
}
leaf core_index {
type uint8 {
range 0..7;
}
description "Hardware core index a port is affiliated with.";
}
leaf core_port_index {
type uint16;
description "Local port index index to an ASIC core.";
}
leaf num_voq {
type uint8 {
range 1..8;
}
description "Number of VoQs associated with a port.";
}
leaf speed {
type uint32 {
range 1..800000;
}
description "Port speed in Mbps.";
}
leaf switch_id {
type uint16;
description "On a VoQ switch, the global ASIC identifier.";
}
leaf system_port_id {
type uint32;
description "On a VoQ switch, the global port identifier.";
}
}
/* end of list SYSTEM_PORT_LIST */
}
/* end of container SYSTEM_PORT */
}
/* end of container sonic-system-port */
}
/* end of module sonic-system-port */