Skip to content
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

[Nvidia] Remove the dependency on python_sdk_api for sfp api #16545

Merged
merged 2 commits into from
Sep 23, 2023

Conversation

vivekrnv
Copy link
Contributor

Why I did it

Sfp api can now be called from the host which doesn't have the python_sdk_api installed. Also, sfp api has been migrated to use sysfs instead of sdk handle.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Remove all the redundant sdk methods and hardcode constants.

How to verify it

Before this change:

root@sonic:/home/admin# sudo sfputil show error-status --fetch-from-hardware
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 955, in error_status
    output_table = fetch_error_status_from_platform_api(port)
  File "/usr/local/lib/python3.9/dist-packages/sfputil/main.py", line 896, in fetch_error_status_from_platform_api
    error_description = platform_chassis.get_sfp(physical_port).get_error_description()
  File "/usr/local/lib/python3.9/dist-packages/sonic_platform/sfp.py", line 440, in get_error_description
    if oper_status == SX_PORT_MODULE_STATUS_INITIALIZING:
NameError: name 'SX_PORT_MODULE_STATUS_INITIALIZING' is not defined

After this change:

root@sonic:/home/admin# sudo sfputil show error-status --fetch-from-hardware
Port         Error Status
-----------  --------------
Ethernet0    OK
Ethernet8    OK
Ethernet16   OK
Ethernet24   OK
Ethernet28   OK
Ethernet32   OK
Ethernet36   OK
Ethernet40   OK
Ethernet42   OK
Ethernet44   OK
Ethernet46   OK
Ethernet64   OK
Ethernet66   OK
Ethernet68   OK
Ethernet70   OK
Ethernet72   OK
Ethernet80   OK
Ethernet88   OK
Ethernet96   OK
Ethernet104  OK
Ethernet112  OK
Ethernet120  OK
Ethernet128  OK
Ethernet136  OK
Ethernet144  OK
Ethernet152  OK
Ethernet160  OK
Ethernet168  OK
Ethernet176  OK
Ethernet184  OK
Ethernet192  OK
Ethernet200  OK
Ethernet208  OK
Ethernet216  OK
Ethernet224  OK
Ethernet232  OK
Ethernet240  OK
Ethernet248  OK

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@lguohan lguohan merged commit 456a90e into sonic-net:master Sep 23, 2023
11 checks passed
@lguohan
Copy link
Collaborator

lguohan commented Sep 23, 2023

@Junchao-Mellanox , since this is requested for backport, please provide test results on 202305 branch.

@vivekrnv
Copy link
Contributor Author

sudo sfputil show error-status --fetch-from-hardware

Manually Verified on 202305 image generated with these changes:

admin@r-lionfish-16:~$ show ver

SONiC Software Version: SONiC.202305_RC.5-5290287ef_Internal
SONiC OS Version: 11
Distribution: Debian 11.7
Kernel: 5.10.0-18-2-amd64
Build commit: 5290287ef
Build date: Sat Sep 23 03:29:16 UTC 2023
Built by: sw-r2d2-bot@r-build-sonic-ci02-241

Platform: x86_64-mlnx_msn3420-r0
HwSKU: ACS-MSN3420
ASIC: mellanox
ASIC Count: 1
Serial Number: MT2019X13878
Model Number: MSN3420-CB2FO
Hardware Revision: A1
Uptime: 02:29:37 up  9:02,  1 user,  load average: 0.82, 0.62, 0.53
Date: Tue 26 Sep 2023 02:29:37

Docker images:
REPOSITORY                                         TAG                              IMAGE ID       SIZE
docker-orchagent                                   202305_RC.5-5290287ef_Internal   434cb504ab0f   328MB
docker-orchagent                                   latest                           434cb504ab0f   328MB
docker-fpm-frr                                     202305_RC.5-5290287ef_Internal   fd8ae82b7f98   348MB
docker-fpm-frr                                     latest                           fd8ae82b7f98   348MB
docker-nat                                         202305_RC.5-5290287ef_Internal   7836cbc8c63d   320MB
docker-nat                                         latest                           7836cbc8c63d   320MB
docker-teamd                                       202305_RC.5-5290287ef_Internal   8108067e406f   317MB
docker-teamd                                       latest                           8108067e406f   317MB
docker-sflow                                       202305_RC.5-5290287ef_Internal   76cef6b21e26   318MB
docker-sflow                                       latest                           76cef6b21e26   318MB
docker-macsec                                      latest                           f5490e417d12   319MB
docker-syncd-mlnx                                  202305_RC.5-5290287ef_Internal   39ac3bcbf1a5   833MB
docker-syncd-mlnx                                  latest                           39ac3bcbf1a5   833MB
docker-platform-monitor                            202305_RC.5-5290287ef_Internal   e4cbb1cb5010   825MB
docker-platform-monitor                            latest                           e4cbb1cb5010   825MB
docker-dhcp-relay                                  latest                           bebdcf27c327   306MB
docker-eventd                                      202305_RC.5-5290287ef_Internal   1419f733bf41   299MB
docker-eventd                                      latest                           1419f733bf41   299MB
docker-snmp                                        202305_RC.5-5290287ef_Internal   6d1caf04cbcd   338MB
docker-snmp                                        latest                           6d1caf04cbcd   338MB
docker-sonic-telemetry                             202305_RC.5-5290287ef_Internal   a63ac8a26e0f   385MB
docker-sonic-telemetry                             latest                           a63ac8a26e0f   385MB
docker-lldp                                        202305_RC.5-5290287ef_Internal   675f412c20c4   341MB
docker-lldp                                        latest                           675f412c20c4   341MB
docker-database                                    202305_RC.5-5290287ef_Internal   6972f8460559   299MB
docker-database                                    latest                           6972f8460559   299MB
docker-mux                                         202305_RC.5-5290287ef_Internal   09562030c7ad   348MB
docker-mux                                         latest                           09562030c7ad   348MB
docker-router-advertiser                           202305_RC.5-5290287ef_Internal   8e606192ccad   299MB
docker-router-advertiser                           latest                           8e606192ccad   299MB
docker-sonic-mgmt-framework                        202305_RC.5-5290287ef_Internal   f788c31e9236   415MB
docker-sonic-mgmt-framework                        latest                           f788c31e9236   415MB
urm.nvidia.com/sw-nbu-sws-sonic-docker/sonic-wjh   1.0.0-202305-3                   c6076fe61c5d   433MB
urm.nvidia.com/sw-nbu-sws-sonic-docker/doai        1.1.0-202305-3                   b417d3d39afd   277MB

admin@r-lionfish-16:~$ sudo sfputil show error-status --fetch-from-hardware
Port         Error Status
-----------  --------------
Ethernet0    OK
Ethernet4    OK
Ethernet8    OK
Ethernet12   OK
Ethernet16   OK
Ethernet20   OK
Ethernet24   OK
Ethernet28   OK
Ethernet32   OK
Ethernet36   OK
Ethernet40   OK
Ethernet44   OK
Ethernet48   OK
Ethernet52   OK
Ethernet56   OK
Ethernet60   OK
Ethernet64   OK
Ethernet68   OK
Ethernet72   OK
Ethernet76   OK
Ethernet80   OK
Ethernet84   OK
Ethernet88   OK
Ethernet92   OK
Ethernet96   OK
Ethernet100  OK
Ethernet104  OK
Ethernet108  OK
Ethernet112  OK
Ethernet116  OK
Ethernet120  OK
Ethernet124  OK
Ethernet128  OK
Ethernet132  OK
Ethernet136  OK
Ethernet140  OK
Ethernet144  OK
Ethernet148  OK
Ethernet152  OK
Ethernet156  OK
Ethernet160  OK
Ethernet164  OK
Ethernet168  OK
Ethernet172  OK
Ethernet176  OK
Ethernet180  OK
Ethernet184  OK
Ethernet188  OK
Ethernet192  OK
Ethernet196  OK
Ethernet198  OK
Ethernet200  OK
Ethernet202  OK
Ethernet204  OK
Ethernet205  OK
Ethernet206  OK
Ethernet207  OK
Ethernet208  OK
Ethernet209  OK
Ethernet210  OK
Ethernet211  OK
Ethernet212  OK
Ethernet216  OK
Ethernet220  OK
Ethernet224  OK
Ethernet228  OK
Ethernet232  OK
Ethernet236  OK

@prgeor
Copy link
Contributor

prgeor commented Sep 27, 2023

@StormLiangMS Please cherry pick to 202305

@mihirpat1
Copy link
Contributor

@StormLiangMS Please cherry pick to 202305

ADO - 25267245

mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Sep 27, 2023
…et#16545)

Sfp api can now be called from the host which doesn't have the python_sdk_api installed. Also, sfp api has been migrated to use sysfs instead of sdk handle.

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202305: #16718

mssonicbld pushed a commit that referenced this pull request Sep 27, 2023
Sfp api can now be called from the host which doesn't have the python_sdk_api installed. Also, sfp api has been migrated to use sysfs instead of sdk handle.

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
keboliu added a commit to keboliu/sonic-buildimage that referenced this pull request Nov 2, 2023
liat-grozovik pushed a commit that referenced this pull request Nov 27, 2023
- Why I did it
The current low power mode setting implementation requests the user to set the port to admin down first before toggling LP mode, this is not backward compatible, now revert it to the old way so that the user can toggle the LP mode regardless of the port admin status.

- How I did it
Revert the recent changes related to LPM in PR #14130 and #16545

- How to verify it
Run all sfputil and SFP platform API related tests on all the Mellanox platforms.

Signed-off-by: Kebo Liu <kebol@nvidia.com>
mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Nov 30, 2023
- Why I did it
The current low power mode setting implementation requests the user to set the port to admin down first before toggling LP mode, this is not backward compatible, now revert it to the old way so that the user can toggle the LP mode regardless of the port admin status.

- How I did it
Revert the recent changes related to LPM in PR sonic-net#14130 and sonic-net#16545

- How to verify it
Run all sfputil and SFP platform API related tests on all the Mellanox platforms.

Signed-off-by: Kebo Liu <kebol@nvidia.com>
yxieca pushed a commit that referenced this pull request Dec 4, 2023
- Why I did it
The current low power mode setting implementation requests the user to set the port to admin down first before toggling LP mode, this is not backward compatible, now revert it to the old way so that the user can toggle the LP mode regardless of the port admin status.

- How I did it
Revert the recent changes related to LPM in PR #14130 and #16545

- How to verify it
Run all sfputil and SFP platform API related tests on all the Mellanox platforms.

Signed-off-by: Kebo Liu <kebol@nvidia.com>
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.

7 participants