Skip to content

[xcvrd] Modify to support regular expression when parsing the key in media_settings.json - #471

Merged
prgeor merged 5 commits into
sonic-net:masterfrom
DennisChiuEC:re_match_media_type
Jul 5, 2024
Merged

prgeor merged 5 commits into
sonic-net:masterfrom
DennisChiuEC:re_match_media_type

Conversation

@DennisChiuEC

Copy link
Copy Markdown
Contributor

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 preemphasis
2024-04-17.01:53:10.594465|PORT_TABLE:Ethernet0|SET|preemphasis:0x0c8418,0x0c8418,0x0c8418,0x0c8418
2024-04-17.01:53:11.827324|PORT_TABLE:Ethernet4|SET|preemphasis:0x0c8418,0x0c8418,0x0c8418,0x0c8418

Example 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)

@DennisChiuEC
DennisChiuEC marked this pull request as draft April 18, 2024 03:06
@DennisChiuEC
DennisChiuEC marked this pull request as ready for review April 18, 2024 03:29
@prgeor

prgeor commented Apr 21, 2024

Copy link
Copy Markdown
Collaborator

@DennisChiuEC Please add unit test

@prgeor prgeor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@moshemos @tshalvi Please review

@prgeor
prgeor requested a review from keboliu April 21, 2024 20:36
@DennisChiuEC

Copy link
Copy Markdown
Contributor Author

OK, I will add the unit test case.

@keboliu
keboliu requested review from noaOrMlnx and removed request for noaOrMlnx April 23, 2024 03:14
@keboliu

keboliu commented Apr 30, 2024

Copy link
Copy Markdown
Collaborator

@tshalvi would you please review?

@keboliu
keboliu removed their request for review May 7, 2024 01:31
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():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@DennisChiuEC can you write a function get_media_settings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@DennisChiuEC can you write a function get_media_settings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


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'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
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'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

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 {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we returning {} and not None?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was added by the previous PR.
I just defined a function to simplify the code.

@prgeor prgeor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@tshalvi can you please review?

@longhuan-cisco

Copy link
Copy Markdown
Contributor

@prgeor could we add Request for 202405 Branch to cherry-pick this PR?

@mihirpat1

Copy link
Copy Markdown
Contributor

@bingwang-ms Can you please help to cherry-pick this to 202405?

mssonicbld pushed a commit to mssonicbld/sonic-platform-daemons that referenced this pull request Sep 4, 2024
…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
@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202405: #537

mssonicbld pushed a commit that referenced this pull request Sep 4, 2024
…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

Copy link
Copy Markdown
Contributor

@prgeor

Could we also cherry-pick this PR to 202311?

PR #533 (which was requested for 202311 cherry-pick) depends on the regular expression support introduced by this PR.

@mihirpat1

Copy link
Copy Markdown
Contributor

@prgeor

Could we also cherry-pick this PR to 202311?

PR #533 (which was requested for 202311 cherry-pick) depends on the regular expression support introduced by this PR.

@yxieca Can you please help to cherry pick this PR to 202311?
MSFT ADO - 28898451

mssonicbld pushed a commit to mssonicbld/sonic-platform-daemons that referenced this pull request Oct 2, 2024
…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
@mssonicbld

Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202311: #544

mssonicbld pushed a commit that referenced this pull request Oct 2, 2024
…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
@mihirpat1

Copy link
Copy Markdown
Contributor

@prgeor

Could we also cherry-pick this PR to 202311?

PR #533 (which was requested for 202311 cherry-pick) depends on the regular expression support introduced by this PR.

@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.

@longhuan-cisco

Copy link
Copy Markdown
Contributor

@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

yxieca pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Apr 28, 2025
…-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>
lotus-nexthop pushed a commit to lotus-nexthop/sonic-platform-daemons that referenced this pull request Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants