sonic-buildimage/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfpreset.py
Kebo Liu 72ec212fa7
[Mellanox] Refactor SFP related platform API and plugins with new SDK API (#5326)
Refactor SFP reset, low power get/set API, and plugins with new SDK SX APIs. Previously they were calling SDK SXD APIs which have glibc dependency because of shared memory usage.

Remove implementation "set_power_override", "tx_disable_channel", "tx_disable" which using SXD APIs, once related SDK SX API available, will add them back based on new SDK SX APIs.
2020-09-11 13:23:23 -07:00

29 lines
726 B
Python

#!/usr/bin/env python
"""
This utility reset the given SFP module.
"""
import sys
import errno
from python_sdk_api.sx_api import *
# Check if SFP port number is provided
if len(sys.argv) < 2:
print("SFP module number or LPM is missed.")
print("Usage: sfpreset.py <SFP module>")
sys.exit(errno.EINVAL)
# Init SDK API
rc, handle = sx_api_open(None)
if rc != SX_STATUS_SUCCESS:
print("Failed to open api handle.\nPlease check that SDK is running.")
sys.exit(errno.EACCES)
# Get SFP module number
sfp_module = int(sys.argv[1]) - 1
rc = sx_mgmt_phy_mod_reset(handle, sfp_module)
assert rc == SX_STATUS_SUCCESS, "sx_mgmt_phy_mod_reset failed, rc = %d" % rc
sx_api_close(handle)