-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[device/celestica]: Add xcvrd event support for Seastone-DX010 (#5896)
- Add sysfs interrupt to notify userspace app of external interrupt - Implement get_change_event() in chassis api.
- Loading branch information
Wirut Getbamrung
authored
Dec 14, 2020
1 parent
9580b04
commit 4257c79
Showing
7 changed files
with
1,419 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
device/celestica/x86_64-cel_seastone-r0/sonic_platform/event.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
try: | ||
import select | ||
from .helper import APIHelper | ||
from sonic_py_common.logger import Logger | ||
except ImportError as e: | ||
raise ImportError(repr(e) + " - required module not found") | ||
|
||
|
||
class SfpEvent: | ||
''' Listen to insert/remove sfp events ''' | ||
|
||
QSFP_MODPRS_IRQ = '/sys/devices/platform/dx010_cpld/qsfp_modprs_irq' | ||
GPIO_SUS6 = "/sys/devices/platform/slx-ich.0/sci_int_gpio_sus6" | ||
|
||
def __init__(self, sfp_list): | ||
self._api_helper = APIHelper() | ||
self._sfp_list = sfp_list | ||
self._logger = Logger() | ||
|
||
def get_sfp_event(self, timeout): | ||
epoll = select.epoll() | ||
port_dict = {} | ||
timeout_sec = timeout/1000 | ||
|
||
try: | ||
# We get notified when there is an SCI interrupt from GPIO SUS6 | ||
fd = open(self.GPIO_SUS6, "r") | ||
fd.read() | ||
|
||
epoll.register(fd.fileno(), select.EPOLLIN & select.EPOLLET) | ||
events = epoll.poll(timeout=timeout_sec if timeout != 0 else -1) | ||
if events: | ||
# Read the QSFP ABS interrupt & status registers | ||
port_changes = self._api_helper.read_one_line_file( | ||
self.QSFP_MODPRS_IRQ) | ||
changes = int(port_changes, 16) | ||
for sfp in self._sfp_list: | ||
change = (changes >> sfp.port_num-1) & 1 | ||
if change == 1: | ||
port_dict[str(sfp.port_num)] = str( | ||
int(sfp.get_presence())) | ||
|
||
return port_dict | ||
except Exception as e: | ||
self._logger.log_error("Failed to detect SfpEvent - " + repr(e)) | ||
return False | ||
|
||
finally: | ||
fd.close() | ||
epoll.close() | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
platform/broadcom/sonic-platform-modules-cel/dx010/modules/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
obj-m := dx010_cpld.o mc24lc64t.o emc2305.o dx010_wdt.o leds-dx010.o | ||
obj-m := dx010_cpld.o mc24lc64t.o emc2305.o dx010_wdt.o leds-dx010.o slx_gpio_ich.o |
Oops, something went wrong.