Skip to content

Commit

Permalink
[devices]: Haliburton xcvrd event support (sonic-net#2486)
Browse files Browse the repository at this point in the history
* [platform/broadcom] Add xcvr event interrupt for haliburton

* [device/celestica] Sfputil implement xcvr event monitor on haliburton

* Codes cleanup, remove gpio_ich module unload line
  • Loading branch information
pphuchar authored and MichelMoriniaux committed May 28, 2019
1 parent 81b93aa commit e8ec7d2
Show file tree
Hide file tree
Showing 4 changed files with 1,082 additions and 13 deletions.
41 changes: 31 additions & 10 deletions device/celestica/x86_64-cel_e1031-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
try:
import time
import os
import select
from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))
Expand Down Expand Up @@ -121,15 +122,35 @@ def reset(self, port_num):
raise NotImplementedError

def get_transceiver_change_event(self, timeout=0):
epoll = select.epoll()
port_dict = {}
timeout_sec = timeout/1000
modabs_interrupt_path = '/sys/devices/platform/e1031.smc/SFP/modabs_int'
ports_evt = {}
try:
with open(modabs_interrupt_path, 'r') as port_changes:
changes = int(port_changes.read(), 16)
for port_num in self._sfp_port:
change = (changes >> ( port_num - 49)) & 1
if change == 1:
ports_evt[str(port_num)] = str(self.get_presence(port_num))
except IOError:
return False, {}
return True, ports_evt
# We get notified when there is an SCI interrupt from GPIO SUS7
fd = open("/sys/devices/platform/hlx-ich.0/sci_int_gpio_sus7", "r")
fd.read()

epoll.register(fd.fileno(), select.EPOLLIN & select.EPOLLET)
events = epoll.poll(timeout=timeout_sec if timeout != 0 else -1)
if events:
found_flag = 0
# Read the QSFP ABS interrupt & status registers
with open(modabs_interrupt_path, 'r') as port_changes:
changes = int(port_changes.read(), 16)
for port_num in self._sfp_port:
change = (changes >> ( port_num - 49)) & 1
if change == 1:
port_dict[str(port_num)] = str(int(self.get_presence(port_num)))
found_flag = 1

if not found_flag:
return False, {}

return True, port_dict

finally:
fd.close()
epoll.close()

return False, {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ case "$1" in
start)
echo -n "Setting up board... "

modprobe smc

modprobe smc
modprobe hlx_gpio_ich

found=0
for devnum in 0 1; do
devname=`cat /sys/bus/i2c/devices/i2c-${devnum}/name`
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
obj-m := mc24lc64t.o emc2305.o smc.o
obj-m := mc24lc64t.o emc2305.o smc.o hlx_gpio_ich.o
Loading

0 comments on commit e8ec7d2

Please sign in to comment.