Repository navigation
[xcvrd] Modify to support regular expression when parsing the key in media_settings.json - #471
Conversation
…media_settings.json
|
@DennisChiuEC Please add unit test |
|
OK, I will add the unit test case. |
|
@tshalvi would you please review? |
| if is_si_per_speed_supported(media_dict[key[VENDOR_KEY]]): | ||
| if key[LANE_SPEED_KEY] is not None and key[LANE_SPEED_KEY] in media_dict[key[VENDOR_KEY]]: # e.g: 'speed:400GAUI-8' | ||
| return media_dict[key[VENDOR_KEY]][key[LANE_SPEED_KEY]] | ||
| for dict_key in media_dict.keys(): |
There was a problem hiding this comment.
@DennisChiuEC can you write a function get_media_settings
| if is_si_per_speed_supported(media_dict[key[MEDIA_KEY]]): | ||
| if key[LANE_SPEED_KEY] is not None and key[LANE_SPEED_KEY] in media_dict[key[MEDIA_KEY]]: | ||
| return media_dict[key[MEDIA_KEY]][key[LANE_SPEED_KEY]] | ||
| for dict_key in media_dict.keys(): |
There was a problem hiding this comment.
@DennisChiuEC can you write a function get_media_settings
|
|
||
| def get_media_settings(key, media_dict): | ||
| for dict_key in media_dict.keys(): | ||
| if ( re.match(dict_key, key[VENDOR_KEY]) or re.match(dict_key, key[VENDOR_KEY].split('-')[0]) # e.g: 'AMPHENOL-1234' |
There was a problem hiding this comment.
| if ( re.match(dict_key, key[VENDOR_KEY]) or re.match(dict_key, key[VENDOR_KEY].split('-')[0]) # e.g: 'AMPHENOL-1234' | |
| if (re.match(dict_key, key[VENDOR_KEY]) or \ | |
| re.match(dict_key, key[VENDOR_KEY].split('-')[0]) # e.g: 'AMPHENOL-1234' |
| if key[LANE_SPEED_KEY] is not None and key[LANE_SPEED_KEY] in media_dict[dict_key]: # e.g: 'speed:400GAUI-8' | ||
| return media_dict[dict_key][key[LANE_SPEED_KEY]] | ||
| else: | ||
| return {} |
There was a problem hiding this comment.
Why are we returning {} and not None?
There was a problem hiding this comment.
It was added by the previous PR.
I just defined a function to simplify the code.
|
@prgeor could we add |
|
@bingwang-ms Can you please help to cherry-pick this to 202405? |
…media_settings.json (sonic-net#471) * [xcvrd] Modify to support regular expression when parsing the key in media_settings.json * fix unit test error * add unit test for getting media settings value with regular expression * define get_media_settings() * apply the suggestion for if condition
|
Cherry-pick PR to 202405: #537 |
…media_settings.json (#471) * [xcvrd] Modify to support regular expression when parsing the key in media_settings.json * fix unit test error * add unit test for getting media settings value with regular expression * define get_media_settings() * apply the suggestion for if condition
…media_settings.json (sonic-net#471) * [xcvrd] Modify to support regular expression when parsing the key in media_settings.json * fix unit test error * add unit test for getting media settings value with regular expression * define get_media_settings() * apply the suggestion for if condition
|
Cherry-pick PR to 202311: #544 |
…media_settings.json (#471) * [xcvrd] Modify to support regular expression when parsing the key in media_settings.json * fix unit test error * add unit test for getting media settings value with regular expression * define get_media_settings() * apply the suggestion for if condition
@longhuan-cisco Can you please help to create a separate 202311 PR for PR#533 since the dependent PR#471 is now cherry-picked to 202311. |
raised #545 for it |
…-7060CX-32S-Q32 for supporting unreliable LOS (#17652) Why I did it This PR adds a media_settings.json file to apply the parameters for arista x86_64-arista_7060_cx32s platform for QSFP+ interface of 40G speed and LR4, SR4 types. This change will go together with sonic-net/sonic-platform-daemons#471 which has the support for parsing QSFP+ 40G speed regex style keys in media_settings.json and apply the change to interface parameters in APPL DB This is indented as a part of long term fix repair item to correct RX_ERR on links facing x86_64-arista_7060_cx32s with 40G optical cables. Work item tracking 32609588 How I did it added the meda_settings.json file How to verify it tested by deploying the change and running it with xcvrd/SAI changes Signed-off-by: Vaibhav Dahiya <vdahiya@microsoft.com>
Description
Let media_settings.json can use regular expression to match 'vendor key' or 'media key'
when define a set of transceiver to use the same SI value.
Motivation and Context
Make the definition of SI value for a set of vendor or media can be more flexible
How Has This Been Tested?
root@sonic:~# cat /var/log/swss/swss.rec | grep preemphasis2024-04-17.01:53:10.594465|PORT_TABLE:Ethernet0|SET|preemphasis:0x0c8418,0x0c8418,0x0c8418,0x0c84182024-04-17.01:53:11.827324|PORT_TABLE:Ethernet4|SET|preemphasis:0x0c8418,0x0c8418,0x0c8418,0x0c8418Example of media_settings.json
"GLOBAL_MEDIA_SETTINGS": {"1-32": {"VENDOR.*-PN.*": {"preemphasis": {"lane0": "0x0c8418","lane1": "0x0c8418","lane2": "0x0c8418","lane3": "0x0c8418","lane4": "0x0c8418"}}}Additional Information (Optional)