-
Notifications
You must be signed in to change notification settings - Fork 208
[xcvrd] Add bitmap support for SFP error event #184
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d864b18
Add bitmap support for SFP error event
Junchao-Mellanox 84f2fa3
Add unit test for sfp error bitmap
Junchao-Mellanox 20d8f27
Move common code to sfp_status_helper.py
Junchao-Mellanox 5ad1246
Remove unused comment lines
Junchao-Mellanox 5bbc490
Fix LGTM warning
fc36b01
Fix LGTM warning
Junchao-Mellanox c907826
Merge branch 'sfp-bit-map' of github.com:Junchao-Mellanox/sonic-platf…
Junchao-Mellanox 1ad32df
Remove unused import
Junchao-Mellanox 5a5aac4
Handle the error status returned by platform APIs
stephenxs 08ab761
Fix review comments
stephenxs f7b5949
Merge pull request #26 from stephenxs/sfp-bit-map-error-status
Junchao-Mellanox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| from sonic_platform_base.sfp_base import SfpBase | ||
|
|
||
| # SFP status definition, shall be aligned with the definition in get_change_event() of ChassisBase | ||
| SFP_STATUS_REMOVED = '0' | ||
| SFP_STATUS_INSERTED = '1' | ||
|
|
||
| # SFP error code dictinary, new elements can be added if new errors need to be supported. | ||
| SFP_ERRORS_BLOCKING_MASK = 0x02 | ||
| SFP_ERRORS_GENERIC_MASK = 0x0000FFFE | ||
| SFP_ERRORS_VENDOR_SPECIFIC_MASK = 0xFFFF0000 | ||
|
|
||
| def is_error_block_eeprom_reading(error_bits): | ||
| return 0 != (error_bits & SFP_ERRORS_BLOCKING_MASK) | ||
|
|
||
|
|
||
| def has_vendor_specific_error(error_bits): | ||
| return 0 != (error_bits & SFP_ERRORS_VENDOR_SPECIFIC_MASK) | ||
|
|
||
|
|
||
| def fetch_generic_error_description(error_bits): | ||
| generic_error_bits = (error_bits & SFP_ERRORS_GENERIC_MASK) | ||
| error_descriptions = [] | ||
| if generic_error_bits: | ||
| for error_bit, error_description in SfpBase.SFP_ERROR_BIT_TO_DESCRIPTION_DICT.items(): | ||
| if error_bit & generic_error_bits: | ||
| error_descriptions.append(error_description) | ||
| return error_descriptions | ||
|
|
||
|
|
||
| def detect_port_in_error_status(logical_port_name, status_tbl): | ||
| rec, fvp = status_tbl.get(logical_port_name) | ||
| if rec: | ||
| status_dict = dict(fvp) | ||
| error = status_dict.get('error') | ||
| return SfpBase.SFP_ERROR_DESCRIPTION_BLOCKING in error | ||
| return False | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.