Skip to content

Commit d62d3d6

Browse files
authored
[CMIS]Fix low-power to high power mode transition (sonic-net#268)
* [CMIS]Fix low-power to high power mode transition * Remove python2 tests * Improve code coverage * Parametrize the test * Improve code coverage
1 parent f918125 commit d62d3d6

File tree

4 files changed

+73
-244
lines changed

4 files changed

+73
-244
lines changed

azure-pipelines.yml

-28
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ steps:
4646

4747
- script: |
4848
set -xe
49-
sudo pip2 install swsssdk-2.0.1-py2-none-any.whl
50-
sudo pip2 install sonic_py_common-1.0-py2-none-any.whl
51-
sudo pip2 install sonic_config_engine-1.0-py2-none-any.whl
5249
sudo pip3 install swsssdk-2.0.1-py3-none-any.whl
5350
sudo pip3 install sonic_py_common-1.0-py3-none-any.whl
5451
sudo pip3 install sonic_yang_mgmt-1.0-py3-none-any.whl
@@ -66,31 +63,6 @@ steps:
6663
sudo apt-get install -y dotnet-sdk-5.0
6764
displayName: "Install .NET CORE"
6865

69-
# Python 2
70-
- script: |
71-
python2 setup.py test
72-
displayName: 'Test Python 2'
73-
74-
- task: PublishTestResults@2
75-
inputs:
76-
testResultsFiles: '$(System.DefaultWorkingDirectory)/test-results.xml'
77-
testRunTitle: Python 2
78-
failTaskOnFailedTests: true
79-
condition: succeededOrFailed()
80-
displayName: 'Publish Python 2 test results'
81-
82-
- task: PublishCodeCoverageResults@1
83-
inputs:
84-
codeCoverageTool: Cobertura
85-
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage.xml'
86-
reportDirectory: '$(System.DefaultWorkingDirectory)/htmlcov/'
87-
displayName: 'Publish Python 2 test coverage'
88-
89-
- script: |
90-
set -e
91-
python2 setup.py bdist_wheel
92-
displayName: 'Build Python 2 wheel'
93-
9466
# Python 3
9567
- script: |
9668
python3 setup.py test

sonic_platform_base/sonic_xcvr/api/public/cmis.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
class CmisApi(XcvrApi):
2424
NUM_CHANNELS = 8
25+
LowPwrRequestSW = 4
26+
LowPwrAllowRequestHW = 6
2527

2628
def __init__(self, xcvr_eeprom):
2729
super(CmisApi, self).__init__(xcvr_eeprom)
@@ -930,19 +932,20 @@ def set_lpmode(self, lpmode):
930932
lpmode_val = self.xcvr_eeprom.read(consts.MODULE_LEVEL_CONTROL)
931933
if lpmode_val is not None:
932934
if lpmode is True:
933-
lpmode_val = lpmode_val | (1 << 4)
935+
# Force module transition to LowPwr under SW control
936+
lpmode_val = lpmode_val | (1 << CmisApi.LowPwrRequestSW)
934937
self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val)
935938
time.sleep(0.1)
936939
return self.get_lpmode()
937940
else:
938-
lpmode_val = lpmode_val & ~(1 << 4)
941+
# Force transition from LowPwr to HighPower state under SW control.
942+
# This will transition LowPwrS signal to False. (see Table 6-12 CMIS v5.0)
943+
lpmode_val = lpmode_val & ~(1 << CmisApi.LowPwrRequestSW)
944+
lpmode_val = lpmode_val & ~(1 << CmisApi.LowPwrAllowRequestHW)
939945
self.xcvr_eeprom.write(consts.MODULE_LEVEL_CONTROL, lpmode_val)
940946
time.sleep(1)
941-
lpmode = self.xcvr_eeprom.read(consts.TRANS_MODULE_STATUS_FIELD)
942-
if lpmode is not None:
943-
if lpmode.get('ModuleState') == 'ModuleReady':
944-
return True
945-
return False
947+
mstate = self.get_module_state()
948+
return True if mstate == 'ModuleReady' else False
946949
return False
947950

948951
def get_loopback_capability(self):

0 commit comments

Comments
 (0)