Skip to content

Commit 9318f6c

Browse files
author
Jostar Yang
committed
Fix xcvrd busy issue
1 parent c619cb6 commit 9318f6c

File tree

6 files changed

+45
-41
lines changed

6 files changed

+45
-41
lines changed

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/chassis.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
2828
REBOOT_CAUSE_FILE = "reboot-cause.txt"
2929
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
30-
HOST_CHK_CMD = "docker > /dev/null 2>&1"
30+
HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
3131
SYSLED_FNODE = "/sys/class/leds/diag/brightness"
3232
SYSLED_MODES = {
3333
"0" : "STATUS_LED_COLOR_OFF",
@@ -43,25 +43,25 @@ class Chassis(ChassisBase):
4343
def __init__(self):
4444
ChassisBase.__init__(self)
4545
self._api_helper = APIHelper()
46-
self._api_helper = APIHelper()
4746
self.is_host = self._api_helper.is_host()
48-
47+
4948
self.config_data = {}
50-
49+
5150
self.__initialize_fan()
5251
self.__initialize_psu()
5352
self.__initialize_thermals()
5453
self.__initialize_components()
5554
self.__initialize_sfp()
5655
self.__initialize_eeprom()
57-
56+
5857
def __initialize_sfp(self):
5958
from sonic_platform.sfp import Sfp
6059
for index in range(0, PORT_END):
6160
sfp = Sfp(index)
6261
self._sfp_list.append(sfp)
62+
self._sfpevent = SfpEvent(self._sfp_list)
6363
self.sfp_module_initialized = True
64-
64+
6565
def __initialize_fan(self):
6666
from sonic_platform.fan_drawer import FanDrawer
6767
for fant_index in range(NUM_FAN_TRAY):
@@ -94,7 +94,7 @@ def __initialize_components(self):
9494
def __initialize_watchdog(self):
9595
from sonic_platform.watchdog import Watchdog
9696
self._watchdog = Watchdog()
97-
97+
9898

9999
def __is_host(self):
100100
return os.system(HOST_CHK_CMD) == 0
@@ -123,15 +123,15 @@ def get_presence(self):
123123
bool: True if Chassis is present, False if not
124124
"""
125125
return True
126-
126+
127127
def get_status(self):
128128
"""
129129
Retrieves the operational status of the device
130130
Returns:
131131
A boolean value, True if device is operating properly, False if not
132132
"""
133133
return True
134-
134+
135135
def get_base_mac(self):
136136
"""
137137
Retrieves the base MAC address for the chassis
@@ -148,7 +148,7 @@ def get_model(self):
148148
string: Model/part number of device
149149
"""
150150
return self._eeprom.get_pn()
151-
151+
152152
def get_serial(self):
153153
"""
154154
Retrieves the hardware serial number for the chassis
@@ -190,10 +190,7 @@ def get_change_event(self, timeout=0):
190190
# SFP event
191191
if not self.sfp_module_initialized:
192192
self.__initialize_sfp()
193-
194-
status, sfp_event = SfpEvent(self._sfp_list).get_sfp_event(timeout)
195-
196-
return status, sfp_event
193+
return self._sfpevent.get_sfp_event(timeout)
197194

198195
def get_sfp(self, index):
199196
"""
@@ -235,7 +232,7 @@ def is_replaceable(self):
235232
"""
236233
return False
237234

238-
235+
239236
def initizalize_system_led(self):
240237
return True
241238

@@ -253,4 +250,4 @@ def set_status_led(self, color):
253250
return False
254251
else:
255252
return self._api_helper.write_txt_file(SYSLED_FNODE, mode)
256-
253+

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/component.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
COMPONENT_LIST= [
2525
("CPLD1", "CPLD 1"),
2626
("BIOS", "Basic Input/Output System")
27-
27+
2828
]
2929

3030
class Component(ComponentBase):

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/eeprom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from io import StringIO
77
else:
88
from cStringIO import StringIO
9-
9+
1010
from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo
1111
except ImportError as e:
1212
raise ImportError(str(e) + "- required module not found")

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/event.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,47 @@
55
except ImportError as e:
66
raise ImportError(repr(e) + " - required module not found")
77

8+
POLL_INTERVAL_IN_SEC = 1
89

910
class SfpEvent:
1011
''' Listen to insert/remove sfp events '''
11-
12+
1213
def __init__(self, sfp_list):
1314
self._api_helper = APIHelper()
1415
self._sfp_list = sfp_list
1516
self._logger = Logger()
17+
self._sfp_change_event_data = {'present': 0}
1618

17-
sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
18-
def get_sfp_event(self, timeout=2000):
19-
now = time.time()
20-
port_dict = {}
21-
change_dict = {}
22-
change_dict['sfp'] = port_dict
23-
24-
if timeout < 1000:
25-
timeout = 1000
26-
timeout = timeout / float(1000) # Convert to secs
27-
28-
if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']:
29-
return True, change_dict
30-
19+
def get_presence_bitmap(self):
3120
bitmap = 0
3221
for sfp in self._sfp_list:
3322
modpres = sfp.get_presence()
3423
i=sfp.port_num-1
3524
if modpres:
3625
bitmap = bitmap | (1 << i)
26+
return bitmap
27+
28+
def get_sfp_event(self, timeout=2000):
29+
port_dict = {}
30+
change_dict = {}
31+
change_dict['sfp'] = port_dict
3732

38-
changed_ports = self.sfp_change_event_data['present'] ^ bitmap
39-
if changed_ports:
33+
if timeout < 1000:
34+
cd_ms = 1000
35+
else:
36+
cd_ms = timeout
37+
38+
while cd_ms > 0:
39+
bitmap = self.get_presence_bitmap()
40+
changed_ports = self._sfp_change_event_data['present'] ^ bitmap
41+
if changed_ports != 0:
42+
break
43+
time.sleep(POLL_INTERVAL_IN_SEC)
44+
# timeout=0 means wait for event forever
45+
if timeout != 0:
46+
cd_ms = cd_ms - POLL_INTERVAL_IN_SEC * 1000
47+
48+
if changed_ports != 0:
4049
for sfp in self._sfp_list:
4150
i=sfp.port_num-1
4251
if (changed_ports & (1 << i)):
@@ -47,9 +56,7 @@ def get_sfp_event(self, timeout=2000):
4756

4857

4958
# Update the cache dict
50-
self.sfp_change_event_data['present'] = bitmap
51-
self.sfp_change_event_data['last'] = now
52-
self.sfp_change_event_data['valid'] = 1
59+
self._sfp_change_event_data['present'] = bitmap
5360
return True, change_dict
5461
else:
5562
return True, change_dict

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/psu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import sonic_platform
1010

1111
try:
12-
from sonic_platform_base.psu_base import PsuBase
12+
from sonic_platform_base.psu_base import PsuBase
1313
from .helper import APIHelper
1414
except ImportError as e:
1515
raise ImportError(str(e) + "- required module not found")

device/accton/x86_64-accton_as4630_54pe-r0/sonic_platform/sfp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Sfp(SfpBase):
124124
# Path to sysfs
125125
PLATFORM_ROOT_PATH = "/usr/share/sonic/device"
126126
PMON_HWSKU_PATH = "/usr/share/sonic/hwsku"
127-
HOST_CHK_CMD = "docker > /dev/null 2>&1"
127+
HOST_CHK_CMD = "which systemctl > /dev/null 2>&1"
128128

129129
PLATFORM = "x86_64-accton_as4630_54pe-r0"
130130
HWSKU = "Accton-AS4630-54PE"
@@ -965,7 +965,7 @@ def tx_disable(self, tx_disable):
965965

966966
if self.port_num < 53:
967967
tx_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_tx_disable_', self.port_num)
968-
ret = self.__write_txt_file(tx_path, 1 if tx_disable else 0)
968+
ret = self._api_helper.write_txt_file(tx_path, 1 if tx_disable else 0)
969969
if ret is not None:
970970
time.sleep(0.01)
971971
return ret

0 commit comments

Comments
 (0)