Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee123 committed Dec 22, 2017
2 parents 909a7e9 + ee73cde commit 87eed23
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 9 deletions.
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SONIC_BUILD_INSTRUCTION := make \
USERNAME=$(USERNAME) \
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS)

.PHONY: sonic-slave-build sonic-slave-bash init
.PHONY: sonic-slave-build sonic-slave-bash init reset

.DEFAULT_GOAL := all

Expand Down Expand Up @@ -98,5 +98,18 @@ sonic-slave-bash :
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash

init :
git submodule update --init --recursive
git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'
@git submodule update --init --recursive
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'

reset :
@echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: "
@read ans && \
if [ $$ans == y ]; then \
git clean -xfdf; \
git reset --hard; \
git submodule foreach --recursive git clean -xfdf; \
git submodule foreach --recursive git reset --hard; \
git submodule update --init --recursive;\
else \
echo "Reset aborted"; \
fi
76 changes: 70 additions & 6 deletions device/accton/x86_64-accton_as5712_54x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class SfpUtil(SfpUtilBase):
PORT_START = 0
PORT_END = 71
PORTS_IN_BLOCK = 72
QSFP_PORT_START = 72
QSFP_PORT_START = 48
QSFP_PORT_END = 72

BASE_VAL_PATH = "/sys/class/i2c-adapter/i2c-{0}/{1}-0050/"

_port_to_is_present = {}
_port_to_lp_mode = {}

_port_to_eeprom_mapping = {}
_port_to_i2c_mapping = {
Expand Down Expand Up @@ -107,6 +108,14 @@ def port_start(self):
def port_end(self):
return self.PORT_END

@property
def qsfp_port_start(self):
return self.QSFP_PORT_START

@property
def qsfp_port_end(self):
return self.QSFP_PORT_END

@property
def qsfp_ports(self):
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
Expand Down Expand Up @@ -148,11 +157,66 @@ def get_presence(self, port_num):

return False

def get_low_power_mode(self, port_num):
raise NotImplementedError
def get_low_power_mode(self, port_num):
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
return False

lp_mode_path = self.BASE_VAL_PATH + "sfp_lp_mode"
self.__port_to_lp_mode = lp_mode_path.format(self._port_to_i2c_mapping[port_num][0], self._port_to_i2c_mapping[port_num][1])

try:
val_file = open(self.__port_to_lp_mode)
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

content = val_file.readline().rstrip()
val_file.close()

# content is a string, either "0" or "1"
if content == "1":
return True

def set_low_power_mode(self, port_num, lpmode):
raise NotImplementedError
return False

def set_low_power_mode(self, port_num, lpmode):
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
return False

lp_mode_path = self.BASE_VAL_PATH + "sfp_lp_mode"
self.__port_to_lp_mode = lp_mode_path.format(self._port_to_i2c_mapping[port_num][0], self._port_to_i2c_mapping[port_num][1])

try:
reg_file = open(self.__port_to_lp_mode, 'r+')
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

if lpmode is True:
reg_value = '1'
else:
reg_value = '0'

reg_file.write(reg_value)
reg_file.close()

return True

def reset(self, port_num):
raise NotImplementedError
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
return False

mod_rst_path = self.BASE_VAL_PATH + "sfp_mod_rst"
self.__port_to_mod_rst = mod_rst_path.format(self._port_to_i2c_mapping[port_num][0], self._port_to_i2c_mapping[port_num][1])
try:
reg_file = open(self.__port_to_mod_rst, 'r+')
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False

reg_value = '1'

reg_file.write(reg_value)
reg_file.close()

return True
1 change: 1 addition & 0 deletions files/image_config/sudoers/sudoers
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Cmnd_Alias READ_ONLY_CMDS = /usr/bin/decode-syseeprom, \
/usr/bin/docker images *, \
/usr/bin/docker exec -it snmp cat /etc/snmp/snmpd.conf, \
/usr/bin/docker exec -it bgp cat /etc/quagga/bgpd.conf, \
/usr/bin/docker ps, \
/usr/bin/generate_dump, \
/usr/bin/lldpctl, \
/usr/bin/lldpshow, \
Expand Down

0 comments on commit 87eed23

Please sign in to comment.