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

[YANG] Enhance the port yang model with new port fields: adv_speeds, interface_type and adv_interface_types #6948

Merged
merged 11 commits into from
May 20, 2021
Merged
38 changes: 38 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/port.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,43 @@
"desc": "PORT_INVALID_AUTONEG_TEST must condition failure.",
"eStrKey" : "Pattern",
"eStr": ["on|off"]
},
"PORT_VALID_ADVSPEEDS_TEST_1": {
"desc": "PORT_VALID_ADVSPEEDS_TEST_1 no failure."
},
"PORT_VALID_ADVSPEEDS_TEST_2": {
"desc": "PORT_VALID_ADVSPEEDS_TEST_2 no failure."
},
"PORT_INVALID_ADVSPEEDS_TEST_1": {
"desc": "PORT_INVALID_ADVSPEEDS_TEST_1 InvalidValue condition failure.",
"eStrKey" : "InvalidValue",
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
"eStr": ["adv_speeds"]
},
"PORT_INVALID_ADVSPEEDS_TEST_2": {
"desc": "PORT_INVALID_ADVSPEEDS_TEST_2 must condition failure.",
"eStrKey" : "Must"
},
"PORT_VALID_TYPE_TEST": {
"desc": "PORT_VALID_TYPE_TEST no failure."
},
"PORT_INVALID_TYPE_TEST": {
"desc": "PORT_INVALID_TYPE_TEST InvalidValue condition failure.",
"eStrKey" : "InvalidValue",
"eStr": ["interface_type"]
},
"PORT_VALID_ADVTYPES_TEST_1": {
"desc": "PORT_VALID_ADVTYPES_TEST_1 no failure."
},
"PORT_VALID_ADVTYPES_TEST_2": {
"desc": "PORT_VALID_ADVTYPES_TEST_2 no failure."
},
"PORT_INVALID_ADVTYPES_TEST_1": {
"desc": "PORT_INVALID_ADVTYPES_TEST_1 InvalidValue condition failure.",
"eStrKey" : "InvalidValue",
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
"eStr": ["adv_interface_types"]
},
"PORT_INVALID_ADVTYPES_TEST_2": {
"desc": "PORT_INVALID_ADVTYPES_TEST_2 must condition failure.",
"eStrKey" : "Must"
}
}
170 changes: 170 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,175 @@
]
}
}
},

"PORT_VALID_ADVSPEEDS_TEST_1": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_speeds": [25000,40000]
}
]
}
}
},

"PORT_VALID_ADVSPEEDS_TEST_2": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_speeds": ["all"]
}
]
}
}
},

"PORT_INVALID_ADVSPEEDS_TEST_1": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_speeds": ["invalid"]
}
]
}
}
},

"PORT_INVALID_ADVSPEEDS_TEST_2": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_speeds": ["all", "25000"]
}
]
}
}
},

"PORT_VALID_TYPE_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"interface_type": "CR4"
}
]
}
}
},

"PORT_INVALID_TYPE_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"interface_type": "Invalid"
}
]
}
}
},

"PORT_VALID_ADVTYPES_TEST_1": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_interface_types": ["CR4", "CR"]
}
]
}
}
},

"PORT_VALID_ADVTYPES_TEST_2": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_interface_types": ["all"]
}
]
}
}
},

"PORT_INVALID_ADVTYPES_TEST_1": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_interface_types": ["Invalid"]
}
]
}
}
},

"PORT_INVALID_ADVTYPES_TEST_2": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"speed": 25000,
"autoneg": "on",
"adv_interface_types": ["all", "CR4"]
}
]
}
}
}
}
48 changes: 42 additions & 6 deletions src/sonic-yang-models/yang-models/sonic-port.yang
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,48 @@ module sonic-port{
}
}

leaf autoneg {
description "Port auto negotiation mode";

type string {
pattern "on|off";
}
}
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved

leaf-list adv_speeds {
description "Port advertised speeds, valid value could be a list of interger or all";

type union {
type uint32 {
range 1..400000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there is no other constraint on adv speed?, it can take any number of values. Kindly point to the correct paragraph in HLD for this plz, I will have a look. Thx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is no other constraint for adv_speeds, I am following the field "speed" in the same yang model file. HLD: https://github.com/Junchao-Mellanox/SONiC/blob/port-auto-neg/doc/port_auto_neg/port-auto-negotiation-design.md#config-advertised-speeds

Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
}
type string {
pattern "all";
}
}
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
}

must "(count(adv_speeds[text()='all']) = 0) or (count(adv_speeds) = 1)";

leaf interface_type {
description "Port interface type";

type stypes:interface_type;
}
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved

leaf-list adv_interface_types {
description "Port advertised interface type, valid value could be a list of stypes:interface_type or all";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly point to the correct paragraph in HLD here in comment, thanks again

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot add the HLD paragraph to the comment here because HLD is not approved yet. And HLD approval requires YANG model PR approval.


type union {
type stypes:interface_type;
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
type string {
pattern "all";
}
Junchao-Mellanox marked this conversation as resolved.
Show resolved Hide resolved
}
}

must "(count(adv_interface_types[text()='all']) = 0) or (count(adv_interface_types) = 1)";

leaf mtu {
type uint16 {
range 1..9216;
Expand Down Expand Up @@ -90,12 +132,6 @@ module sonic-port{
pattern "on|off";
}
}

leaf autoneg {
type string {
pattern "on|off";
}
}
} /* end of list PORT_LIST */

} /* end of container PORT */
Expand Down
24 changes: 24 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-types.yang
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,28 @@ module sonic-types {
pattern "percentage|used|free|PERCENTAGE|USED|FREE";
}
}

typedef interface_type {
lguohan marked this conversation as resolved.
Show resolved Hide resolved
type enumeration {
enum CR;
enum CR2;
enum CR4;
enum SR;
enum SR2;
enum SR4;
enum LR;
enum LR4;
enum KR;
enum KR4;
enum CAUI;
enum GMII;
enum SFI;
enum XLAUI;
enum KR2;
enum CAUI4;
enum XAUI;
enum XFI;
enum XGMII;
}
}
}