Skip to content

Commit 4b581f1

Browse files
authored
sonic-port.yang: add link training support (#10025)
This is part of HLD sonic-net/SONiC#925 #### Why I did it Add link-training support #### How I did it Update SONiC YANG for port link-training support #### Description for the changelog Add "link_training" to sonic-port.yang #### Link to config_db schema for YANG module changes https://github.com/sonic-net/SONiC/wiki/Configuration#port
1 parent 5eda219 commit 4b581f1

File tree

5 files changed

+79
-5
lines changed

5 files changed

+79
-5
lines changed

src/sonic-yang-models/doc/Configuration.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,8 @@ optional attributes.
11671167
"description": "fortyGigE1/1/1",
11681168
"mtu": "9100",
11691169
"alias": "fortyGigE1/1/1",
1170-
"speed": "40000"
1170+
"speed": "40000",
1171+
"link_training": "off"
11711172
},
11721173
"Ethernet1": {
11731174
"index": "1",
@@ -1176,9 +1177,10 @@ optional attributes.
11761177
"mtu": "9100",
11771178
"alias": "fortyGigE1/1/2",
11781179
"admin_status": "up",
1179-
"speed": "40000"
1180+
"speed": "40000",
1181+
"link_training": "on"
11801182
},
1181-
"Ethernet63": {
1183+
"Ethernet63": {
11821184
"index": "63",
11831185
"lanes": "87,88",
11841186
"description": "fortyGigE1/4/16",

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,8 @@
438438
"index": "0",
439439
"asic_port_name": "Eth0-ASIC1",
440440
"role": "Ext",
441-
"macsec": "test"
441+
"macsec": "test",
442+
"link_training": "off"
442443
},
443444
"Ethernet1": {
444445
"alias": "Eth1/2",
@@ -449,7 +450,8 @@
449450
"admin_status": "up",
450451
"autoneg": "on",
451452
"adv_speeds": "100000,50000",
452-
"adv_interface_types": "CR,CR4"
453+
"adv_interface_types": "CR,CR4",
454+
"link_training": "on"
453455
},
454456
"Ethernet2": {
455457
"alias": "Eth1/3",

src/sonic-yang-models/tests/yang_model_tests/tests/port.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@
6969
"desc": "PORT_INVALID_ADVTYPES_TEST_2 must condition failure.",
7070
"eStrKey" : "Must"
7171
},
72+
"PORT_VALID_LINK_TRAINING_TEST_1": {
73+
"desc": "PORT_VALID_LINK_TRAINING_TEST_1 no failure."
74+
},
75+
"PORT_VALID_LINK_TRAINING_TEST_2": {
76+
"desc": "PORT_VALID_LINK_TRAINING_TEST_2 no failure."
77+
},
78+
"PORT_INVALID_LINK_TRAINING_TEST": {
79+
"desc": "PORT_INVALID_LINK_TRAINING_TEST must condition failure.",
80+
"eStrKey" : "Pattern",
81+
"eStr": ["on|off"]
82+
},
7283
"PORT_INVALID_TPID_TEST": {
7384
"desc": "PORT_INVALID_TPID_TEST invalid tpid value failure.",
7485
"eStrKey" : "Pattern",

src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,57 @@
311311
}
312312
},
313313

314+
"PORT_VALID_LINK_TRAINING_TEST_1": {
315+
"sonic-port:sonic-port": {
316+
"sonic-port:PORT": {
317+
"PORT_LIST": [
318+
{
319+
"name": "Ethernet8",
320+
"alias": "eth8",
321+
"lanes": "65",
322+
"speed": 25000,
323+
"tpid": "0x8100",
324+
"link_training": "on"
325+
}
326+
]
327+
}
328+
}
329+
},
330+
331+
"PORT_VALID_LINK_TRAINING_TEST_2": {
332+
"sonic-port:sonic-port": {
333+
"sonic-port:PORT": {
334+
"PORT_LIST": [
335+
{
336+
"name": "Ethernet8",
337+
"alias": "eth8",
338+
"lanes": "65",
339+
"speed": 25000,
340+
"tpid": "0x8100",
341+
"link_training": "off"
342+
}
343+
]
344+
}
345+
}
346+
},
347+
348+
"PORT_INVALID_LINK_TRAINING_TEST": {
349+
"sonic-port:sonic-port": {
350+
"sonic-port:PORT": {
351+
"PORT_LIST": [
352+
{
353+
"name": "Ethernet8",
354+
"alias": "eth8",
355+
"lanes": "65",
356+
"speed": 25000,
357+
"tpid": "0x8100",
358+
"link_training": 0
359+
}
360+
]
361+
}
362+
}
363+
},
364+
314365
"PORT_INVALID_TPID_TEST": {
315366
"sonic-port:sonic-port": {
316367
"sonic-port:PORT": {

src/sonic-yang-models/yang-models/sonic-port.yang

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ module sonic-port{
6565
}
6666
}
6767

68+
leaf link_training {
69+
description "Port link training mode";
70+
71+
type string {
72+
pattern "on|off";
73+
}
74+
}
75+
6876
leaf autoneg {
6977
description "Port auto negotiation mode";
7078

0 commit comments

Comments
 (0)