Skip to content

Handle NotImplementedError exception while changing optoe write max#2985

Merged
prgeor merged 4 commits intosonic-net:masterfrom
mihirpat1:get_eeprom_path_exception_handling
Sep 19, 2023
Merged

Handle NotImplementedError exception while changing optoe write max#2985
prgeor merged 4 commits intosonic-net:masterfrom
mihirpat1:get_eeprom_path_exception_handling

Conversation

@mihirpat1
Copy link
Copy Markdown
Contributor

@mihirpat1 mihirpat1 commented Sep 18, 2023

What I did

For platforms which do not implement get_eeprom_path API, NotImplementedError will be returned when the user downloads CDB firmware through "sfputil firmware download <port> <fw_path>" CLI.
We need to handle such case and allow FW download to proceed since the corresponding platform may not support Optoe driver or may not have get_eeprom_path not implemented.

https://github.com/sonic-net/sonic-utilities/blob/572902878cf4bb3345de37791d231456b9df95cb/sfputil/main.py#L1328C4-L1328C52

get_eeprom_path API related code
https://github.com/sonic-net/sonic-platform-common/blob/master/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py#L169
https://github.com/sonic-net/sonic-platform-common/blob/master/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py#L148

How I did it

Handling NotImplementedError exception now while calling set_optoe_write_max API to allow FW download.

How to verify it

The "sfputil firmware download <fw_path>" CLI was verified successfully in the following scenarios

  1. When get_eeprom_path API is implemented
  2. When get_eeprom_path API is not implemented

Previous command output (if the output of a command-line utility has changed)

Error seen while initiating FW download when get_eeprom_path is not defined

root@dut:/firmware# sfputil firmware download Ethernet144 fw.bin
CDB: Starting firmware download
Traceback (most recent call last):
  File "/usr/local/bin/sfputil", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/sfputil/main.py", line 1508, in download
    status = download_firmware(port_name, filepath)
  File "/usr/local/lib/python3.9/dist-packages/sfputil/main.py", line 1365, in download_firmware
    sfp.set_optoe_write_max(SMBUS_BLOCK_WRITE_SIZE)
  File "/usr/local/lib/python3.9/dist-packages/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py", line 170, in set_optoe_write_max
    sys_path = self.get_eeprom_path()
  File "/usr/local/lib/python3.9/dist-packages/sonic_platform_base/sonic_xcvr/sfp_optoe_base.py", line 149, in get_eeprom_path
    raise NotImplementedError
NotImplementedError
root@dut:/firmware#

New command output (if the output of a command-line utility has changed)

root@dut:/firmware# sfputil firmware download Ethernet32 'fw.bin' 
CDB: Starting firmware download                                                                                                                     1.bin' 
Platform doesn't implement optoe write max change. Skipping value increase.
Downloading ...  [###################################-]   99%  00:00:00
Platform doesn't implement optoe write max change. Skipping value restore!
CDB: firmware download complete
Firmware download complete success
Total download Time: 0:10:54.897812
root@dut:/firmware# 

@mihirpat1 mihirpat1 changed the title Get eeprom path exception handling Handle NotImplementedError exception while changing optoe write max Sep 19, 2023
@prgeor prgeor merged commit 701994f into sonic-net:master Sep 19, 2023
@prgeor
Copy link
Copy Markdown
Contributor

prgeor commented Sep 19, 2023

@yxieca @StormLiangMS please cherry pick to 202205 and 202305

@mihirpat1
Copy link
Copy Markdown
Contributor Author

@yxieca @StormLiangMS please cherry pick to 202205 and 202305

ADO - 25173918

StormLiangMS pushed a commit that referenced this pull request Sep 21, 2023
…2985)

* Handle NotImplementedError exception while changing optoe write max

Signed-off-by: Mihir Patel <[email protected]>

* Added unit test for more coverage

* Removed unused import

---------

Signed-off-by: Mihir Patel <[email protected]>
yxieca pushed a commit that referenced this pull request Sep 26, 2023
…2985)

* Handle NotImplementedError exception while changing optoe write max

Signed-off-by: Mihir Patel <[email protected]>

* Added unit test for more coverage

* Removed unused import

---------

Signed-off-by: Mihir Patel <[email protected]>
JunhongMao pushed a commit to JunhongMao/sonic-utilities that referenced this pull request Oct 4, 2023
…onic-net#2985)

* Handle NotImplementedError exception while changing optoe write max

Signed-off-by: Mihir Patel <[email protected]>

* Added unit test for more coverage

* Removed unused import

---------

Signed-off-by: Mihir Patel <[email protected]>
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.

4 participants