-
Notifications
You must be signed in to change notification settings - Fork 161
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
[xcvrd] Add to support MEDIA_LANE_SPEED_KEY in media_settings.json #528
base: master
Are you sure you want to change the base?
[xcvrd] Add to support MEDIA_LANE_SPEED_KEY in media_settings.json #528
Conversation
* Add to support MEDIA_LANE_SPEED_KEY in media_settings.json The MEDIA_LANE_SPEED_KEY consists of transceiver's media type and lane_speed information. To define MEDIA_LANE_SPEED_KEY as: "50000,CR", when the lane_speed is 50G in each lane and media type is Copper. "50000" , when the lane_speed is 50G in each lane, and its media type is Fiber. * Add "def get_media_lane_speed_key" Use the this API to to query the MEDIA_LANE_SPEED_KEY for the transceiver. * Modify "def get_media_settings_key" to add new key for MEDIA_LANE_SPEED_KEY. * Modify "def get_media_settings_value" to parse MEDIA_LANE_SPEED_KEY. * Add unit test with "media_settings_with_media_lane_speed_key_format.json" as sample "media_settings.json" file. * Fix unit test error due to adding MEDIA_LANE_SPEED_KEY. * Add unit test for "def get_media_lane_speed_key". * Add unit test for getting media settings value with MEDIA_LANE_SPEED_KEY.
|
@@ -0,0 +1,54 @@ | |||
{ | |||
"GLOBAL_MEDIA_SETTINGS": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order not to misunderstand your suggestion, I would like to re-address your suggestion as:
why not make use of regex with 'media_key' or 'lane_speed_key' ?
A. Here is my response with the sample media_settings.json and Transceiver information in B. and C. as below.
A.1
However, it is possible to construct 'media_key' with regex as in the media_settings.json as below B.1.
In Breakout mode 2x200G in physical_port=1 and 1x400G in physical_port=2, 'lane_speed_key' can't help to locate the media_dict (Pre-empassis setting).
From this Transceiver information, 'lane_speed_key' are different in :
- 'lane_speed_key'='speed:400G' for Breakout mode 1x400G physical_port=2
- 'lane_speed_key': 'speed:200GBASE-CR4' for Breakout mode 2x200G physical_port=1
However, it is possible to resolve this issue via duplicating the same media_dict for "speed:400G*" and "speed:200G*" as below media-settings.json in B.1.
But, the above resolution still does not resolve the issue for the Transceiver QSFP28-* in physical_port=5,9,13,14.
However, it is still possible to resolve this issue via adding another 'lane_speed_key' format or add another 'media_key' for physical_port=5,9,13,14, but I think that is not the purpose that the regex to simplify the media_setting.sjon format.
A.2
To refer to B.2, you will see that 'media_lane_speed_key' could help to simplify media_settings.json in our platform.
B. Sample media_settings.json
B.1 To construct the media_settings.json with 'media_key' and 'lane_speed_key'
{
"GLOBAL_MEDIA_SETTINGS": {
"1-32": {
"QSFP-DD-passive_copper_media_interface-*|QSFP28-*-CR4*":{
"speed:400G*":{
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
},
"speed:200G*":{
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
},
"QSFP-DD-passive_copper_media_interface-*|QSFP28-Unknown-*":{
"post2": {"lane0": "0x101","lane1": "0x101","lane2": "0x101","lane3": "0x101","lane4": "0x101","lane5": "0x101","lane6": "0x101","lane7": "0x101"},
"post3": {"lane0": "0x101","lane1": "0x101", "lane2": "0x101","lane3": "0x101","lane4": "0x101","lane5": "0x101","lane6": "0x101","lane7": "0x101"},
"pre2": {"lane0": "0x101","lane1": "0x101","lane2": "0x101","lane3": "0x101","lane4": "0x101","lane5": "0x101","lane6": "0x101","lane7": "0x101"},
"preemphasis": {"lane0": "0x007F01","lane1": "0x007F01","lane2": "0x007F01","lane3": "0x007F01","lane4": "0x007F01","lane5": "0x007F01","lane6": "0x007F01","lane7": "0x007F01"}
}
}
}
}
B.2 To construct the media_settings.json with 'media_lane_speed_key'
{
"GLOBAL_MEDIA_SETTINGS": {
"1-32": {
"50000,CR":{
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
},
"50000":{
"post2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"post3": {"lane0": "0x102","lane1": "0x102", "lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"pre2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"preemphasis": {"lane0": "0x007F02","lane1": "0x007F02","lane2": "0x007F02","lane3": "0x007F02","lane4": "0x007F02","lane5": "0x007F02","lane6": "0x007F02","lane7": "0x007F02"}
}
}
}
}
C. Sample Transceiver information
**For Brteakout mode is 2x200G in physical_port=1**
physical_port=1 logical_port_name=Ethernet0, port_speed=200000 lane_count=4
key={
'vendor_key': 'EDGECORE -ET7502-DAC-2.5M ',
'media_key': 'QSFP-DD-passive_copper_media_interface-2.5M',
'lane_speed_key': 'speed:200GBASE-CR4',
'media_lane_speed_key': '50000,CR'
}
media_dict={
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
physical_port=1 logical_port_name=Ethernet4, port_speed=200000 lane_count=4
key={
'vendor_key': 'EDGECORE -ET7502-DAC-2.5M ',
'media_key': 'QSFP-DD-passive_copper_media_interface-2.5M',
'lane_speed_key': 'speed:200GBASE-CR4',
'media_lane_speed_key': '50000,CR'
}
media_dict={
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
**For Breakout mode is 1x400G, physical_port=2,5,9,13,14**
physical_port=2 logical_port_name=Ethernet8, port_speed=400000 lane_count=8
key={
'vendor_key': 'EDGECORE -ET7502-DAC-2.5M ',
'media_key': 'QSFP-DD-passive_copper_media_interface-2.5M',
'lane_speed_key': 'speed:400G',
'media_lane_speed_key': '50000,CR'
}
media_dict={
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
physical_port=5 logical_port_name=Ethernet32, port_speed=400000 lane_count=8
key={
'vendor_key': 'EDGECORE -ET7502-LR4 ',
'media_key': 'QSFP-DD-sm_media_interface',
'lane_speed_key': 'speed:400GAUI-8',
'media_lane_speed_key': '50000'
}
media_dict={
"post2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"post3": {"lane0": "0x102","lane1": "0x102", "lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"pre2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"preemphasis": {"lane0": "0x007F02","lane1": "0x007F02","lane2": "0x007F02","lane3": "0x007F02","lane4": "0x007F02","lane5": "0x007F02","lane6": "0x007F02","lane7": "0x007F02"}
}
physical_port=9 logical_port_name=Ethernet64, port_speed=400000 lane_count=8
key={
'vendor_key': 'EDGECORE -ET7402-LR4 ',
'media_key': 'QSFP28-Unknown-M',
'lane_speed_key': None,
'media_lane_speed_key': '50000'
}
media_dict={
"post2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"post3": {"lane0": "0x102","lane1": "0x102", "lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"pre2": {"lane0": "0x102","lane1": "0x102","lane2": "0x102","lane3": "0x102","lane4": "0x102","lane5": "0x102","lane6": "0x102","lane7": "0x102"},
"preemphasis": {"lane0": "0x007F02","lane1": "0x007F02","lane2": "0x007F02","lane3": "0x007F02","lane4": "0x007F02","lane5": "0x007F02","lane6": "0x007F02","lane7": "0x007F02"}
}
physical_port=13 logical_port_name=Ethernet96, port_speed=400000 lane_count=8
key={
'vendor_key': 'EDGECORE -ET7402-DAC-0.5M ',
'media_key': 'QSFP28-40GBASE-CR4-1.0M',
'lane_speed_key': None,
'media_lane_speed_key': '50000,CR'
}
media_dict={
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
physical_port=14 logical_port_name=Ethernet104, port_speed=400000 lane_count=8
key={
'vendor_key': 'EDGECORE -ET7402-DAC-0.5M ',
'media_key': 'QSFP28-40GBASE-CR4-1.0M',
'lane_speed_key': None,
'media_lane_speed_key': '50000,CR'
}
media_dict={
"post2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"post3": {"lane0": "0x100","lane1": "0x100", "lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"pre2": {"lane0": "0x100","lane1": "0x100","lane2": "0x100","lane3": "0x100","lane4": "0x100","lane5": "0x100","lane6": "0x100","lane7": "0x100"},
"preemphasis": {"lane0": "0x007F00","lane1": "0x007F00","lane2": "0x007F00","lane3": "0x007F00","lane4": "0x007F00","lane5": "0x007F00","lane6": "0x007F00","lane7": "0x007F00"}
}
Add to support MEDIA_LANE_SPEED_KEY in media_settings.json The MEDIA_LANE_SPEED_KEY consists of transceiver's media type and lane_speed information. To define MEDIA_LANE_SPEED_KEY as: "50000,CR", when the lane_speed is 50G in each lane and media type is Copper. "50000" , when the lane_speed is 50G in each lane, and its media type is Fiber.
Add "def get_media_lane_speed_key" Use the this API to to query the MEDIA_LANE_SPEED_KEY for the transceiver.
Modify "def get_media_settings_key" to add new key for MEDIA_LANE_SPEED_KEY.
Modify "def get_media_settings_value" to parse MEDIA_LANE_SPEED_KEY.
Add unit test with "media_settings_with_media_lane_speed_key_format.json" as sample "media_settings.json" file.
Fix unit test error due to adding MEDIA_LANE_SPEED_KEY.
Add unit test for "def get_media_lane_speed_key".
Add unit test for getting media settings value with MEDIA_LANE_SPEED_KEY.
Description
Motivation and Context
How Has This Been Tested?
To test the feature in "sonic-buildimage" build folder.
To get into sonic-docker build environment
To install the following deb packages
/sonic$ sudo dpkg -i ./target/debs/bullseye/libnl-3-200_*.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/libnl-genl-3-200_*.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/libnl-route-3-200_*.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/libnl-nf-3-200_*.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/libyang_1.0.73_amd64.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/libswsscommon_1.0.0_amd64.deb
/sonic$ sudo dpkg -i ./target/debs/bullseye/python3-swsscommon_1.0.0_amd64.deb
/sonic$ sudo pip3 install ./target/python-wheels/bullseye/swsssdk-2.0.1-py3-none-any.whl
/sonic$ sudo pip3 install ./target/python-wheels/bullseye/sonic_py_common-1.0-py3-none-any.whl
/sonic$ sudo pip3 install ./target/python-wheels/bullseye/sonic_yang_mgmt-1.0-py3-none-any.whl
/sonic$ sudo pip3 install ./target/python-wheels/bullseye/sonic_yang_models-1.0-py3-none-any.whl
/sonic$ sudo pip3 install ./target/python-wheels/bullseye/sonic_config_engine-1.0-py3-none-any.whl
/sonic$ sudo pip3 install ./target/python-wheels/bookworm/sonic_platform_common-1.0-py3-none-any.whl
To run the pytset for test_xcvrd.py as:
Test log Information
Please refer to to test log before check-in-code and after check-in code as logs, it shows all adding testing cases are PASS.
pytest-after-checed-in-code-log.txt
pytest-before-checed-in-code-log.txt