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
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ def initTest(self):
'desc': 'LOAD PORT TABLE FEC PATTERN FAILURE',
'eStr': self.defaultYANGFailure['Pattern'] + ['rc']
},
'PORT_INVALID_AUTONEG_TEST': {
'desc': 'LOAD PORT TABLE AUTONEG PATTERN FAILURE.',
'eStr': self.defaultYANGFailure['Pattern'] + ['invalid'],
},
'CRM_WITH_WRONG_PERCENTAGE': {
'desc': 'CRM_WITH_WRONG_PERCENTAGE must condition failure.',
'eStr': self.defaultYANGFailure['Must']
Expand Down
28 changes: 27 additions & 1 deletion src/sonic-yang-models/tests/yang_model_tests/yangTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,11 @@
"fec": "rs",
"mtu": 9000,
"admin_status": "up",
"pfc_asym": "on"
"pfc_asym": "on",
"autoneg": "on",
"adv_speeds": ["10000","25000"],
"adv_interface_types": ["all"],
"interface_type": "CR"
}]
}
}
Expand All @@ -656,6 +660,28 @@
}
},

"PORT_INVALID_AUTONEG_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"port_name": "Ethernet8",
"alias": "eth8",
"lanes": "65",
"description": "Ethernet8",
"speed": 25000,
"fec": "rs",
"mtu": 9000,
"admin_status": "up",
"pfc_asym": "on",
"autoneg": "invalid",
"adv_speeds": "10000,25000",
"adv_interface_types": "CR,CR2",
"interface_type": "CR"
}]
}
}
},

"ACL_RULE_ARP_TYPE_ICMPV6_CODE_MISMATCH": {
"sonic-acl:sonic-acl": {
"sonic-acl:ACL_RULE": {
Expand Down
30 changes: 30 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-port.yang
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,36 @@ module sonic-port{
}
}

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

leaf-list adv_speeds {
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
}

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

leaf-list adv_interface_types {
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
}
}

leaf mtu {
type uint16 {
range 1..9216;
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 @@ -107,4 +107,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;
}
}
}