mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Merge pull request #2 from opencomputeproject/master
merge from OCP/ONL to my local forked branch
This commit is contained in:
12
Makefile
12
Makefile
@@ -15,7 +15,7 @@ include $(ONL)/make/config.mk
|
||||
all: amd64 ppc
|
||||
$(MAKE) -C REPO build-clean
|
||||
|
||||
onl-amd64 onl-x86 x86 x86_64 amd64:
|
||||
onl-amd64 onl-x86 x86 x86_64 amd64: packages_base_all
|
||||
$(MAKE) -C packages/base/amd64/kernels
|
||||
$(MAKE) -C packages/base/amd64/initrds
|
||||
$(MAKE) -C packages/base/amd64/onlp
|
||||
@@ -25,7 +25,7 @@ onl-amd64 onl-x86 x86 x86_64 amd64:
|
||||
$(MAKE) -C builds/amd64/swi
|
||||
$(MAKE) -C builds/amd64/installer/legacy
|
||||
|
||||
onl-ppc ppc:
|
||||
onl-ppc ppc: packages_base_all
|
||||
$(MAKE) -C packages/base/powerpc/kernels
|
||||
$(MAKE) -C packages/base/powerpc/initrds
|
||||
$(MAKE) -C packages/base/powerpc/onlp
|
||||
@@ -36,6 +36,9 @@ onl-ppc ppc:
|
||||
$(MAKE) -C builds/powerpc/swi
|
||||
$(MAKE) -C builds/powerpc/installer/legacy
|
||||
|
||||
packages_base_all:
|
||||
$(MAKE) -C packages/base/all
|
||||
|
||||
rpc rebuild:
|
||||
$(ONLPM) --rebuild-pkg-cache
|
||||
|
||||
@@ -58,3 +61,8 @@ docker: docker_check
|
||||
# create an interative docker shell, for debugging builds
|
||||
docker-debug: docker_check
|
||||
@docker/tools/onlbuilder -$(VERSION) --isolate --hostname onlbuilder$(VERSION) --pull
|
||||
|
||||
|
||||
versions:
|
||||
$(ONL)/tools/make-versions.py --import-file=$(ONL)/tools/onlvi --class-name=OnlVersionImplementation --output-dir $(ONL)/make --force
|
||||
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
*INSTALLER
|
||||
kernel-*
|
||||
initrd-*
|
||||
lib/
|
||||
usr/
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- parted
|
||||
- smartmontools
|
||||
- grub2
|
||||
- onl-upgrade
|
||||
|
||||
|
||||
|
||||
|
||||
67
builds/any/rootfs/jessie/common/overlay/etc/inittab
Normal file
67
builds/any/rootfs/jessie/common/overlay/etc/inittab
Normal file
@@ -0,0 +1,67 @@
|
||||
# The default runlevel.
|
||||
id:2:initdefault:
|
||||
|
||||
# Boot-time system configuration/initialization script.
|
||||
# This is run first except when booting in emergency (-b) mode.
|
||||
si0::sysinit:/etc/boot.d/boot
|
||||
si1::sysinit:/etc/init.d/rcS
|
||||
|
||||
# What to do in single-user mode.
|
||||
~~:S:wait:/sbin/sulogin
|
||||
|
||||
# /etc/init.d executes the S and K scripts upon change
|
||||
# of runlevel.
|
||||
#
|
||||
# Runlevel 0 is halt.
|
||||
# Runlevel 1 is single-user.
|
||||
# Runlevels 2-5 are multi-user.
|
||||
# Runlevel 6 is reboot.
|
||||
|
||||
l0:0:wait:/etc/init.d/rc 0
|
||||
l1:1:wait:/etc/init.d/rc 1
|
||||
l2:2:wait:/etc/init.d/rc 2
|
||||
l3:3:wait:/etc/init.d/rc 3
|
||||
l4:4:wait:/etc/init.d/rc 4
|
||||
l5:5:wait:/etc/init.d/rc 5
|
||||
l6:6:wait:/etc/init.d/rc 6
|
||||
# Normally not reached, but fallthrough in case of emergency.
|
||||
z6:6:respawn:/sbin/sulogin
|
||||
|
||||
# What to do when CTRL-ALT-DEL is pressed.
|
||||
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
|
||||
|
||||
# Action on special keypress (ALT-UpArrow).
|
||||
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."
|
||||
|
||||
# What to do when the power fails/returns.
|
||||
pf::powerwait:/etc/init.d/powerfail start
|
||||
pn::powerfailnow:/etc/init.d/powerfail now
|
||||
po::powerokwait:/etc/init.d/powerfail stop
|
||||
|
||||
# /sbin/getty invocations for the runlevels.
|
||||
#
|
||||
# The "id" field MUST be the same as the last
|
||||
# characters of the device (after "tty").
|
||||
#
|
||||
# Format:
|
||||
# <id>:<runlevels>:<action>:<process>
|
||||
#
|
||||
# Note that on most Debian systems tty7 is used by the X Window System,
|
||||
# so if you want to add more getty's go ahead but skip tty7 if you run X.
|
||||
#
|
||||
1:2345:respawn:/sbin/getty 38400 tty1
|
||||
2:23:respawn:/sbin/getty 38400 tty2
|
||||
3:23:respawn:/sbin/getty 38400 tty3
|
||||
4:23:respawn:/sbin/getty 38400 tty4
|
||||
5:23:respawn:/sbin/getty 38400 tty5
|
||||
6:23:respawn:/sbin/getty 38400 tty6
|
||||
|
||||
# Example how to put a getty on a serial line (for a terminal)
|
||||
#
|
||||
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
|
||||
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
|
||||
|
||||
# Example how to put a getty on a modem line.
|
||||
#
|
||||
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#
|
||||
############################################################
|
||||
- u-boot-tools
|
||||
- onl-loader-fit
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ Configure:
|
||||
- ${ONL}/builds/any/rootfs/${ONL_DEBIAN_SUITE}/common/overlay
|
||||
|
||||
update-rc.d:
|
||||
- 'initdev defaults'
|
||||
- 'onl-platform-baseconf defaults'
|
||||
- 'faultd defaults'
|
||||
- 'onlpd defaults'
|
||||
- 'snmpd remove'
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
- parted
|
||||
- smartmontools
|
||||
- grub2
|
||||
- onl-upgrade
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
67
builds/any/rootfs/wheezy/common/overlay/etc/inittab
Normal file
67
builds/any/rootfs/wheezy/common/overlay/etc/inittab
Normal file
@@ -0,0 +1,67 @@
|
||||
# The default runlevel.
|
||||
id:2:initdefault:
|
||||
|
||||
# Boot-time system configuration/initialization script.
|
||||
# This is run first except when booting in emergency (-b) mode.
|
||||
si0::sysinit:/etc/boot.d/boot
|
||||
si1::sysinit:/etc/init.d/rcS
|
||||
|
||||
# What to do in single-user mode.
|
||||
~~:S:wait:/sbin/sulogin
|
||||
|
||||
# /etc/init.d executes the S and K scripts upon change
|
||||
# of runlevel.
|
||||
#
|
||||
# Runlevel 0 is halt.
|
||||
# Runlevel 1 is single-user.
|
||||
# Runlevels 2-5 are multi-user.
|
||||
# Runlevel 6 is reboot.
|
||||
|
||||
l0:0:wait:/etc/init.d/rc 0
|
||||
l1:1:wait:/etc/init.d/rc 1
|
||||
l2:2:wait:/etc/init.d/rc 2
|
||||
l3:3:wait:/etc/init.d/rc 3
|
||||
l4:4:wait:/etc/init.d/rc 4
|
||||
l5:5:wait:/etc/init.d/rc 5
|
||||
l6:6:wait:/etc/init.d/rc 6
|
||||
# Normally not reached, but fallthrough in case of emergency.
|
||||
z6:6:respawn:/sbin/sulogin
|
||||
|
||||
# What to do when CTRL-ALT-DEL is pressed.
|
||||
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
|
||||
|
||||
# Action on special keypress (ALT-UpArrow).
|
||||
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."
|
||||
|
||||
# What to do when the power fails/returns.
|
||||
pf::powerwait:/etc/init.d/powerfail start
|
||||
pn::powerfailnow:/etc/init.d/powerfail now
|
||||
po::powerokwait:/etc/init.d/powerfail stop
|
||||
|
||||
# /sbin/getty invocations for the runlevels.
|
||||
#
|
||||
# The "id" field MUST be the same as the last
|
||||
# characters of the device (after "tty").
|
||||
#
|
||||
# Format:
|
||||
# <id>:<runlevels>:<action>:<process>
|
||||
#
|
||||
# Note that on most Debian systems tty7 is used by the X Window System,
|
||||
# so if you want to add more getty's go ahead but skip tty7 if you run X.
|
||||
#
|
||||
1:2345:respawn:/sbin/getty 38400 tty1
|
||||
2:23:respawn:/sbin/getty 38400 tty2
|
||||
3:23:respawn:/sbin/getty 38400 tty3
|
||||
4:23:respawn:/sbin/getty 38400 tty4
|
||||
5:23:respawn:/sbin/getty 38400 tty5
|
||||
6:23:respawn:/sbin/getty 38400 tty6
|
||||
|
||||
# Example how to put a getty on a serial line (for a terminal)
|
||||
#
|
||||
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
|
||||
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
|
||||
|
||||
# Example how to put a getty on a modem line.
|
||||
#
|
||||
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
############################################################
|
||||
- u-boot-tools
|
||||
|
||||
- onl-loader-fit
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ Configure:
|
||||
- ${ONL}/builds/any/rootfs/${ONL_DEBIAN_SUITE}/common/overlay
|
||||
|
||||
update-rc.d:
|
||||
- 'initdev defaults'
|
||||
- 'onl-platform-baseconf defaults'
|
||||
- 'faultd defaults'
|
||||
- 'onlpd defaults'
|
||||
- 'snmpd remove'
|
||||
|
||||
@@ -11,7 +11,7 @@ Quanta
|
||||
<tr class="info">
|
||||
<th> Device <th> Ports <th> CPU <th> Forwarding <th> ONL Certified <th> In Lab <th> ORC <th> OF-DPA <th> OpenNSL <th> SAI </tr>
|
||||
</thead>
|
||||
<tr> <td> QuantaMesh T1048-LB9 <td> 48x1G + 4x10G <td> FreeScale P2020 <td> Broadcom BCM56534 (Firebolt3) <td> Yes <td> Yes <td> Yes <td> Yes <td> No <td> No </tr>
|
||||
<tr> <td> QuantaMesh T1048-LB9 <td> 48x1G + 4x10G <td> FreeScale P2020 <td> Broadcom BCM56534 (Firebolt3) <td> Yes <td> Yes <td> Yes <td> No <td> No <td> No </tr>
|
||||
<tr> <td> QuantaMesh T3048-LY2 <td> 48x10G + 4x40G <td> FreeScale P2020 <td> Broadcom BCM56846 (Trident+) <td> Yes <td> Yes <td> Yes <td> Yes <td> No <td> No </tr>
|
||||
<tr> <td> QuantaMesh T3048-LY8 <td> 48x10G + 6x40G <td> Intel Rangely C2758 x86 <td> Broadcom BCM56854 (Trident2) <td> Yes* <td> No <td> No <td> No <td> No <td> No </tr>
|
||||
<tr> <td> QuantaMesh T5032-LY6 <td> 32x40G <td> Intel Rangely C2758 x86 <td> Broadcom BCM56850 (Trident2) <td> Yes* <td> No <td> No <td> No <td> No <td> No </tr>
|
||||
|
||||
1
packages/base/all/boot.d/Makefile
Normal file
1
packages/base/all/boot.d/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
16
packages/base/all/boot.d/PKG.yml
Normal file
16
packages/base/all/boot.d/PKG.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
common:
|
||||
arch: all
|
||||
version: 1.0.0
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
|
||||
packages:
|
||||
- name: onl-bootd
|
||||
version: 1.0.0
|
||||
summary: Open Network Linux Boot Stage
|
||||
|
||||
files:
|
||||
- src : /etc/boot.d
|
||||
|
||||
changelog: Change changes changes.,
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: initdev
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: S
|
||||
# Default-Stop:
|
||||
# Short-Description: Set up block and net devices
|
||||
### END INIT INFO
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
log_action_begin_msg "Setting up block and net devices"
|
||||
23
packages/base/all/boot.d/src/boot
Executable file
23
packages/base/all/boot.d/src/boot
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
############################################################
|
||||
#
|
||||
# Initial boot setup. Required before running
|
||||
# any concurrent service initialization in rcS
|
||||
#
|
||||
# This is designed to support early setup, platform,
|
||||
# and upgrade operations.
|
||||
#
|
||||
############################################################
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
export PATH
|
||||
|
||||
for script in `ls /etc/boot.d/[0-9]* | sort`; do
|
||||
$script
|
||||
done
|
||||
|
||||
#
|
||||
# Wait for console to flush prior to starting rc.S
|
||||
#
|
||||
sleep 1
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
packages:
|
||||
- name: onl-vendor-config-onl
|
||||
depends: python-yaml
|
||||
depends: [ python-yaml, onl-bootd ]
|
||||
version: 1.0.0
|
||||
arch: all
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
@@ -9,7 +9,7 @@ packages:
|
||||
|
||||
files:
|
||||
src/python/onl : $PY_INSTALL/onl
|
||||
src/init.d : /etc/init.d
|
||||
src/boot.d : /etc/boot.d
|
||||
src/bin : /usr/bin
|
||||
|
||||
changelog: Changes
|
||||
|
||||
55
packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie
Executable file
55
packages/base/all/vendor-config-onl/src/boot.d/61.upgrade-onie
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/python -u
|
||||
from onl.upgrade import ubase
|
||||
|
||||
class ONIE_Upgrade(ubase.BaseOnieUpgrade):
|
||||
name="onie"
|
||||
Name="ONIE"
|
||||
title="ONIE Upgrade Check"
|
||||
atype="An ONIE"
|
||||
|
||||
current_version_key="Current ONIE Version"
|
||||
next_version_key="Next ONIE Version"
|
||||
|
||||
def init_versions(self):
|
||||
|
||||
# Get the current platform ONIE version
|
||||
self.current_version = self.platform.onie_version()
|
||||
self.next_version = None
|
||||
self.updater = None
|
||||
|
||||
(udir, um, data) = self.platform.upgrade_manifest("onie")
|
||||
self.udir = udir
|
||||
self.data = data
|
||||
|
||||
if data:
|
||||
self.next_version = data.get('onie-version', None)
|
||||
|
||||
if data:
|
||||
self.updater = data.get('onie-updater', None)
|
||||
|
||||
if self.updater is None:
|
||||
self.finish("No ONIE updater available for the current platform.")
|
||||
|
||||
def summarize(self):
|
||||
self.logger.info("Current ONIE Version: %s" % self.current_version)
|
||||
self.logger.info(" Next ONIE Version: %s" % self.next_version)
|
||||
self.logger.info(" Force-Update: %s" % self.data['force-update'])
|
||||
self.logger.info(" Updater: %s" % self.updater)
|
||||
self.logger.info("")
|
||||
|
||||
def upgrade_notes(self):
|
||||
return """
|
||||
* The system will reboot into ONIE to complete the update, and then reboot to return to Switch Light
|
||||
"""
|
||||
|
||||
def do_upgrade(self, forced=False):
|
||||
self.install_onie_updater(self.udir, self.updater)
|
||||
self.initiate_onie_update()
|
||||
|
||||
def do_no_upgrade(self):
|
||||
self.clean_onie_updater()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ONIE_Upgrade().main()
|
||||
|
||||
153
packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader
Executable file
153
packages/base/all/vendor-config-onl/src/boot.d/62.upgrade-loader
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/python
|
||||
############################################################
|
||||
#
|
||||
# ONL Loader Upgrade
|
||||
#
|
||||
############################################################
|
||||
import os
|
||||
import fnmatch
|
||||
from onl.upgrade import ubase
|
||||
|
||||
class Loader_Upgrade(ubase.BaseUpgrade):
|
||||
name="loader"
|
||||
Name="Loader"
|
||||
title="Loader Upgrade Check"
|
||||
atype="A Loader"
|
||||
|
||||
current_version_key="Current Loader Version"
|
||||
next_version_key="Next Loader Version"
|
||||
|
||||
def init_versions(self):
|
||||
#
|
||||
# Current Loader version file.
|
||||
# If this file doesn't exist then in-place upgrade is not supported.
|
||||
#
|
||||
ETC_LOADER_VERSIONS_JSON = "/etc/onl/loader/versions.json"
|
||||
|
||||
# Upgrade Loader Version file.
|
||||
NEXT_LOADER_VERSIONS_JSON = "/etc/onl/upgrade/%s/manifest.json" % self.arch
|
||||
|
||||
self.current_version = self.load_json(ETC_LOADER_VERSIONS_JSON,
|
||||
"RELEASE_ID",
|
||||
None)
|
||||
|
||||
self.next_version = self.load_json(NEXT_LOADER_VERSIONS_JSON,
|
||||
"version", {}).get('RELEASE_ID', None)
|
||||
|
||||
def summarize(self):
|
||||
self.logger.info("Current Loader Version: %s" % self.current_version)
|
||||
self.logger.info(" Next Loader Version: %s" % self.next_version)
|
||||
self.logger.info("")
|
||||
|
||||
|
||||
def upgrade_notes(self):
|
||||
return """
|
||||
* A single reboot will be required to complete this upgrade.
|
||||
"""
|
||||
|
||||
class Loader_Upgrade_ppc(Loader_Upgrade):
|
||||
|
||||
def do_upgrade(self, forced=False):
|
||||
|
||||
PPC_FIT_UPGRADE_IMAGE_PLATFORM="/etc/onl/upgrade/ppc/%s.itb" % self.platform.platform()
|
||||
PPC_FIT_UPGRADE_IMAGE_ALL="/etc/onl/upgrade/ppc/onl-loader-fit.itb"
|
||||
PPC_FIT_LOADER_IMAGE_NAME="%s.itb" % self.platform.platform()
|
||||
|
||||
#
|
||||
# The upgrade/ppc directory must have a FIT image called $PPC_FIT_UPGRADE_IMAGE (see constants above)
|
||||
# This is obviously a little janky.
|
||||
#
|
||||
fit_image = None
|
||||
|
||||
if os.path.exists(PPC_FIT_UPGRADE_IMAGE_PLATFORM):
|
||||
fit_image = PPC_FIT_UPGRADE_IMAGE_PLATFORM
|
||||
elif os.path.exists(PPC_FIT_UPGRADE_IMAGE_ALL):
|
||||
fit_image = PPC_FIT_UPGRADE_IMAGE_ALL
|
||||
else:
|
||||
self.abort("The PPC Upgrade FIT image is missing. Upgrade cannot continue.")
|
||||
|
||||
#
|
||||
# The platform configuration file will describe which partition
|
||||
# and which format should be used to store the FIT image.
|
||||
#
|
||||
partition = None
|
||||
raw = False
|
||||
pc = self.platform.platform_config
|
||||
|
||||
if pc:
|
||||
if 'loader' in pc and pc['loader']:
|
||||
if 'partition' in pc['loader']:
|
||||
partition = pc['loader']['partition']
|
||||
else:
|
||||
self.abort("No partition listed in the loader section of the platform configuration.")
|
||||
raw = pc['loader'].get('raw', False)
|
||||
else:
|
||||
self.abort("No loader section listed in the platform configuration.")
|
||||
else:
|
||||
self.abort("No platform configuration.")
|
||||
|
||||
if raw:
|
||||
#
|
||||
# The loader file is written raw to the given partition.
|
||||
#
|
||||
print "Writing %s to %s..." % (fit_image, partition)
|
||||
if os.system("dd of=%s if=%s" % (partition, fit_image)) != 0:
|
||||
self.abort("Failure writing loader data to partition %s." % (partition))
|
||||
|
||||
else:
|
||||
#
|
||||
# Mount the loader partition and rewrite the loader image.
|
||||
#
|
||||
mdir="/mnt/upgrade/loader"
|
||||
self.mount(mdir, partition=partition)
|
||||
self.copyfile(fit_image, os.path.join(mdir, PPC_FIT_LOADER_IMAGE_NAME))
|
||||
self.umount(mdir)
|
||||
|
||||
self.reboot()
|
||||
|
||||
|
||||
|
||||
class Loader_Upgrade_x86_64(Loader_Upgrade):
|
||||
|
||||
X86_64_UPGRADE_DIR="/etc/onl/upgrade/x86_64/"
|
||||
X86_64_UPGRADE_PATTERNS = [ "kernel-*", "initrd-*" ]
|
||||
|
||||
def do_upgrade(self, forced=False):
|
||||
#
|
||||
# Mount the ONL-BOOT partition
|
||||
#
|
||||
mdir="/mnt/onl-boot"
|
||||
self.mount(mdir, label="ONL-BOOT")
|
||||
|
||||
for f in os.listdir(self.X86_64_UPGRADE_DIR):
|
||||
for pattern in self.X86_64_UPGRADE_PATTERNS:
|
||||
if fnmatch.fnmatch(f, pattern):
|
||||
self.copyfile(os.path.join(self.X86_64_UPGRADE_DIR, f), os.path.join(mdir, f))
|
||||
|
||||
src = "/lib/platform-config/current/onl/boot/grub.cfg"
|
||||
dst = os.path.join(mdir, "grub/grub.cfg")
|
||||
if os.path.exists(src):
|
||||
self.copyfile(src, dst)
|
||||
|
||||
self.umount(mdir)
|
||||
self.reboot()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import platform
|
||||
|
||||
arch = platform.machine()
|
||||
klass = None
|
||||
|
||||
if arch =='ppc':
|
||||
klass = Loader_Upgrade_ppc
|
||||
elif arch == 'x86_64':
|
||||
klass = Loader_Upgrade_x86_64
|
||||
else:
|
||||
raise Exception("The current architecture (%s) is not supported for upgrade." % arch)
|
||||
|
||||
klass().main()
|
||||
|
||||
@@ -105,6 +105,16 @@ class OnlPlatformBase(object):
|
||||
self.add_info_json("platform_info", "%s/platform-info.json" % self.basedir_onl(),
|
||||
required=False)
|
||||
|
||||
# Load the platform config yaml file
|
||||
y = os.path.join(self.basedir_onl(), "%s.yml" % self.platform())
|
||||
if os.path.exists(y):
|
||||
self.platform_config = yaml.load(open(y))
|
||||
if self.platform() in self.platform_config:
|
||||
self.platform_config = self.platform_config[self.platform()]
|
||||
else:
|
||||
self.platform_config = {}
|
||||
|
||||
|
||||
def add_info_dict(self, name, d, klass=None):
|
||||
setattr(self, name, OnlInfoObject(d, klass))
|
||||
|
||||
@@ -191,6 +201,20 @@ class OnlPlatformBase(object):
|
||||
self.sys_oid_vendor() +
|
||||
self.sys_oid_platform());
|
||||
|
||||
def onie_version(self):
|
||||
return self.onie_info.ONIE_VERSION
|
||||
|
||||
def upgrade_manifest(self, type_, override_dir=None):
|
||||
if override_dir:
|
||||
m = os.path.join(override_dir, "manifest.json")
|
||||
else:
|
||||
m = os.path.join(self.basedir_onl(), "upgrade", type_, "manifest.json")
|
||||
|
||||
if os.path.exists(m):
|
||||
return (os.path.dirname(m), m, json.load(file(m)))
|
||||
else:
|
||||
return (None, None, None)
|
||||
|
||||
|
||||
def new_device(self, driver, addr, bus, devdir):
|
||||
if not os.path.exists(os.path.join(bus, devdir)):
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=none>
|
||||
#
|
||||
# Copyright 2013, 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
#
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
@@ -0,0 +1,426 @@
|
||||
############################################################
|
||||
#
|
||||
# Upgrade Base Classes
|
||||
#
|
||||
############################################################
|
||||
import logging
|
||||
import logging.handlers
|
||||
import platform as pp
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import json
|
||||
import string
|
||||
import argparse
|
||||
from time import sleep
|
||||
from onl.platform.current import OnlPlatform
|
||||
|
||||
class BaseUpgrade(object):
|
||||
|
||||
# Customized by deriving class
|
||||
name = None
|
||||
Name = None
|
||||
atype = None
|
||||
current_version_key = None
|
||||
next_version_key = None
|
||||
def __init__(self):
|
||||
|
||||
if not (self.name and self.Name and self.atype and self.title and
|
||||
self.current_version_key and self.next_version_key):
|
||||
raise Exception("Name descriptors must be provided by deriving class.")
|
||||
|
||||
self.init_logger()
|
||||
self.init_argparser()
|
||||
self.load_config()
|
||||
self.arch = pp.machine()
|
||||
self.platform = OnlPlatform()
|
||||
|
||||
#
|
||||
# TODO.
|
||||
#
|
||||
# DEFAULT_CONFIG = {
|
||||
# "auto-upgrade" : "advisory",
|
||||
# }
|
||||
#
|
||||
# CONFIG_FILES = [
|
||||
# "/etc/boot.d/upgrade/.upgrade-config.json",
|
||||
# "/mnt/flash/override-upgrade-config.json"
|
||||
# ]
|
||||
#
|
||||
# def load_config(self):
|
||||
# self.config = self.DEFAULT_CONFIG
|
||||
# for f in self.CONFIG_FILES:
|
||||
# if os.path.exists(f):
|
||||
# self.config.update(json.load(file(f)))
|
||||
#
|
||||
# self.logger.debug("Loaded Configuration:\n%s\n" % (json.dumps(self.config, indent=2)))
|
||||
#
|
||||
# if self.name in self.config:
|
||||
# self.config = self.config['name']
|
||||
#
|
||||
# self.logger.debug("Final Configuration:\n%s\n" % (json.dumps(self.config, indent=2)))
|
||||
#
|
||||
def load_config(self):
|
||||
pass
|
||||
|
||||
|
||||
def init_logger(self):
|
||||
fmt = '%(asctime)s.%(msecs)d %(levelname)s %(name)s: %(message)s'
|
||||
datefmt="%Y-%m-%d %H:%M:%S"
|
||||
formatter = logging.Formatter(fmt, datefmt)
|
||||
|
||||
logging.basicConfig(format=fmt, datefmt=datefmt)
|
||||
|
||||
self.logger = logging.getLogger(string.rjust("%s-upgrade" % self.name, 16))
|
||||
self.logger.setLevel(logging.INFO)
|
||||
if os.getenv("DEBUG"):
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
|
||||
def init_argparser(self):
|
||||
self.ap = argparse.ArgumentParser("%s-upgrade" % self.name)
|
||||
self.ap.add_argument("--enable", action='store_true', help="Enable updates.")
|
||||
self.ap.add_argument("--force", action='store_true', help="Force update.")
|
||||
self.ap.add_argument("--no-reboot", action='store_true', help="Don't reboot.")
|
||||
self.ap.add_argument("--check", action='store_true', help="Check only.")
|
||||
self.ap.add_argument("--auto-upgrade", help="Override auto-upgrade mode.", default='advisory')
|
||||
self.ap.add_argument("--summarize", action='store_true', help="Summarize only, no upgrades.")
|
||||
|
||||
def banner(self):
|
||||
self.logger.info("************************************************************")
|
||||
self.logger.info("* %s" % self.title)
|
||||
self.logger.info("************************************************************")
|
||||
self.logger.info("")
|
||||
|
||||
def finish(self, message=None, rc=0):
|
||||
if message:
|
||||
self.logger.info("")
|
||||
if rc == 0:
|
||||
self.logger.info(message)
|
||||
else:
|
||||
self.logger.error(message)
|
||||
self.logger.info("")
|
||||
self.logger.info("************************************************************")
|
||||
self.update_upgrade_status(self.current_version_key, self.current_version)
|
||||
self.update_upgrade_status(self.next_version_key, self.next_version)
|
||||
# Flush stdout
|
||||
sleep(.1)
|
||||
sys.exit(rc)
|
||||
|
||||
def abort(self, message=None, rc=1):
|
||||
if message:
|
||||
message = "Error: %s" % message
|
||||
self.finish(message, rc)
|
||||
|
||||
def fw_getenv(self, var):
|
||||
FW_PRINTENV="/usr/bin/fw_printenv"
|
||||
if os.path.exists(FW_PRINTENV):
|
||||
try:
|
||||
if var:
|
||||
return subprocess.check_output("%s -n %s" % FW_PRINTENV, stderr=subprocess.STDOUT);
|
||||
else:
|
||||
variables = {}
|
||||
for v in subprocess.check_output("/usr/bin/fw_printenv", shell=True).split('\n'):
|
||||
(name, eq, value) = v.partition('=')
|
||||
variables[name] = value
|
||||
return variables
|
||||
except Exception, e:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
def fw_setenv(self, var, value):
|
||||
FW_SETENV="/usr/bin/fw_setenv"
|
||||
if os.system("%s %s %s" % (FW_SETENV, var, value)) != 0:
|
||||
self.abort("Error setting environment variable %s=%s. Upgrade cannot continue." % (var, value))
|
||||
|
||||
def copyfile(self, src, dst):
|
||||
self.logger.info("Installing %s -> %s..." % (src, dst))
|
||||
if not os.path.exists(src):
|
||||
self.abort("Source file '%s' does not exist." % src)
|
||||
|
||||
try:
|
||||
shutil.copyfile(src, dst)
|
||||
except Exception, e:
|
||||
self.abort("Exception while copying: %s" % e)
|
||||
|
||||
def reboot(self):
|
||||
if self.ops.no_reboot:
|
||||
self.finish("[ No Reboot ]")
|
||||
elif self.ops.check:
|
||||
self.finish("[ Check Abort ]")
|
||||
else:
|
||||
self.logger.info("The system will reboot to complete the update.")
|
||||
sleep(1)
|
||||
os.system("sync")
|
||||
sleep(1)
|
||||
while True:
|
||||
os.system("reboot -f")
|
||||
sleep(30)
|
||||
self.abort("The system did not reboot as expected.")
|
||||
|
||||
|
||||
def load_json(self, fname, key=None, default=None):
|
||||
if os.path.exists(fname):
|
||||
with open(fname) as f:
|
||||
data = json.load(f)
|
||||
if key:
|
||||
return data.get(key, default)
|
||||
else:
|
||||
return data
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
UPGRADE_STATUS_JSON = "/lib/platform-config/current/upgrade.json"
|
||||
|
||||
def update_upgrade_status(self, key, value):
|
||||
data = {}
|
||||
if os.path.exists(self.UPGRADE_STATUS_JSON):
|
||||
with open(self.UPGRADE_STATUS_JSON) as f:
|
||||
data = json.load(f)
|
||||
data[key] = value
|
||||
with open(self.UPGRADE_STATUS_JSON, "w") as f:
|
||||
json.dump(data, f)
|
||||
|
||||
|
||||
#
|
||||
# Initialize self.current_version, self.next_Version
|
||||
# and anything required for summarize()
|
||||
#
|
||||
def init_versions(self):
|
||||
raise Exception("init_versions() must be provided by the deriving class.")
|
||||
|
||||
|
||||
#
|
||||
# Perform actual upgrade. Provided by derived class.
|
||||
#
|
||||
def do_upgrade(self, forced=False):
|
||||
raise Exception("do_upgrade() must be provided by the deriving class.")
|
||||
|
||||
#
|
||||
# Perform any clean up necessary if the system is current (no upgrade required.)
|
||||
#
|
||||
def do_no_upgrade(self):
|
||||
pass
|
||||
|
||||
|
||||
def init_upgrade(self):
|
||||
self.current_version = None
|
||||
self.next_version = None
|
||||
self.init_versions()
|
||||
self.update_upgrade_status(self.current_version_key, self.current_version)
|
||||
self.update_upgrade_status(self.next_version_key, self.next_version)
|
||||
|
||||
def summarize(self):
|
||||
pass
|
||||
|
||||
|
||||
def __upgrade_prompt(self, instructions, default="yes"):
|
||||
valid = {"yes": True, "y": True, "ye": True,
|
||||
"no": False, "n": False}
|
||||
if default is None:
|
||||
prompt = " [y/n] "
|
||||
elif default == "yes":
|
||||
prompt = " [Y/n] "
|
||||
elif default == "no":
|
||||
prompt = " [y/N] "
|
||||
else:
|
||||
raise ValueError("invalid default answer: '%s'" % default)
|
||||
|
||||
notes = self.upgrade_notes()
|
||||
if notes:
|
||||
instructions = instructions + "\n" + notes + "\n"
|
||||
|
||||
instructions = "\n\n" + instructions + "\n\nStart the upgrade? "
|
||||
|
||||
while True:
|
||||
sys.stdout.write(instructions + prompt)
|
||||
choice = raw_input().lower()
|
||||
if default is not None and choice == '':
|
||||
return valid[default]
|
||||
elif choice in valid:
|
||||
return valid[choice]
|
||||
else:
|
||||
sys.stdout.write("Please respond with 'yes' or 'no' "
|
||||
"(or 'y' or 'n').\n")
|
||||
|
||||
def upgrade_prompt(self, instructions, default='yes'):
|
||||
try:
|
||||
return self.__upgrade_prompt(instructions, default)
|
||||
except Exception, e:
|
||||
self.logger.error("")
|
||||
self.logger.error("Exception: %s" % e)
|
||||
self.abort("No upgrade will be performed.")
|
||||
return False
|
||||
except KeyboardInterrupt:
|
||||
return False
|
||||
|
||||
def upgrade_notes(self):
|
||||
raise Exception("Must be provided by derived class.")
|
||||
|
||||
def __upgrade_advisory(self):
|
||||
if not self.ops.enable:
|
||||
self.finish("%s updates are not enabled." % self.Name)
|
||||
self.__do_upgrade()
|
||||
self.finish()
|
||||
|
||||
def __upgrade_force(self):
|
||||
self.logger.info("This system is configured for automatic %s updates." % self.Name)
|
||||
self.__do_upgrade()
|
||||
self.finish()
|
||||
|
||||
def __do_upgrade(self):
|
||||
if self.ops.check:
|
||||
self.finish("[ Check abort. ]")
|
||||
self.do_upgrade()
|
||||
|
||||
|
||||
def __upgrade_optional(self):
|
||||
instructions = """%s upgrade should be performed before continuing for optimal
|
||||
performance on this system.
|
||||
|
||||
While it is recommended that you perform this upgrade it is optional and you
|
||||
may continue booting for testing purposes at this time.
|
||||
|
||||
Please note that you will be asked again each time at boot to perform
|
||||
this upgrade. Automatic booting will not be possible until the upgrade
|
||||
is performed.""" % self.atype
|
||||
|
||||
if self.upgrade_prompt(instructions) == True:
|
||||
self.__do_upgrade()
|
||||
self.finish()
|
||||
else:
|
||||
self.finish("Upgrade cancelled.")
|
||||
|
||||
def __upgrade_required(self):
|
||||
instructions = """%s upgrade must be performed before the software can run on this system.
|
||||
If you choose not to perform this upgrade booting cannot continue.""" % self.atype
|
||||
|
||||
if self.upgrade_prompt(instructions) == True:
|
||||
self.__do_upgrade()
|
||||
self.finish()
|
||||
else:
|
||||
self.logger.info("The system cannot continue without performing %s update. The system will now reboot if you would like to take alternative actions." % self.atype)
|
||||
self.reboot()
|
||||
|
||||
|
||||
def __upgrade(self):
|
||||
self.logger.info("%s upgrade is required." % self.atype)
|
||||
|
||||
auto_upgrade = self.ops.auto_upgrade
|
||||
|
||||
#
|
||||
# auto-upgrade modes are:
|
||||
# advisory : Advisory only. This is the default.
|
||||
# force : Perform the upgrade automatically.
|
||||
# optional : Ask the user whether an upgrade should be performed.
|
||||
# required : Ask the user whether an upgrade should be performed.
|
||||
# Reboot if the answer is 'no'.
|
||||
#
|
||||
if auto_upgrade == 'advisory':
|
||||
self.__upgrade_advisory()
|
||||
elif auto_upgrade == 'force':
|
||||
self.__upgrade_force();
|
||||
elif auto_upgrade == 'optional':
|
||||
self.__upgrade_optional()
|
||||
elif auto_upgrade == 'required':
|
||||
self.__upgrade_required()
|
||||
else:
|
||||
self.abort("auto-upgrade mode '%s' is not supported." % auto_upgrade)
|
||||
|
||||
|
||||
def upgrade_check(self):
|
||||
|
||||
if self.current_version == self.next_version:
|
||||
# Versions match. Only continue if forced.
|
||||
if self.ops.force:
|
||||
self.logger.info("%s version %s is current." % (self.Name,
|
||||
self.current_version))
|
||||
self.logger.info("[ Upgrade Forced. ]")
|
||||
else:
|
||||
self.logger.info("%s version %s is current." % (self.Name,
|
||||
self.current_version))
|
||||
self.do_no_upgrade()
|
||||
self.finish()
|
||||
|
||||
if self.next_version:
|
||||
self.__upgrade()
|
||||
|
||||
|
||||
def mount(self, location, partition=None, label=None):
|
||||
if not os.path.isdir(location):
|
||||
os.makedirs(location)
|
||||
|
||||
if partition:
|
||||
cmd = "mount %s %s " % (partition,location)
|
||||
name = partition
|
||||
|
||||
if label:
|
||||
cmd = "mount LABEL=%s %s" % (label, location)
|
||||
name = label
|
||||
|
||||
if os.system(cmd) != 0:
|
||||
self.abort("Could not mount %s @ %s. Upgrade cannot continue." % (name, location))
|
||||
|
||||
def umount(self, location):
|
||||
if os.system("umount %s" % location) != 0:
|
||||
self.abort("Could not unmount %s. Upgrade cannot continue." % location)
|
||||
|
||||
|
||||
def main(self):
|
||||
self.ops = self.ap.parse_args()
|
||||
self.banner()
|
||||
self.init_upgrade()
|
||||
self.summarize()
|
||||
if not self.ops.summarize:
|
||||
self.upgrade_check()
|
||||
|
||||
|
||||
|
||||
|
||||
class BaseOnieUpgrade(BaseUpgrade):
|
||||
|
||||
ONIE_UPDATER_PATH = "/mnt/flash2/onie-updater"
|
||||
|
||||
def install_onie_updater(self, src_dir, updater):
|
||||
if type(updater) is list:
|
||||
# Copy all files in the list to /mnt/flash2
|
||||
for f in updater:
|
||||
src = os.path.join(src_dir, f)
|
||||
dst = os.path.join("/mnt/flash2", f)
|
||||
self.copyfile(src, dst)
|
||||
else:
|
||||
# Copy single updater to /mnt/flash2/onie-updater
|
||||
src = os.path.join(src_dir, updater)
|
||||
self.copyfile(src, self.ONIE_UPDATER_PATH)
|
||||
|
||||
|
||||
def initiate_onie_update(self):
|
||||
self.logger.info("Initiating %s Update." % self.Name)
|
||||
if self.arch == 'ppc':
|
||||
# Initiate update
|
||||
self.fw_setenv('onie_boot_reason', 'update')
|
||||
self.reboot()
|
||||
|
||||
elif self.arch == 'x86_64':
|
||||
OB = "/mnt/onie-boot"
|
||||
self.mount(OB, label="ONIE-BOOT")
|
||||
if os.system("/mnt/onie-boot/onie/tools/bin/onie-boot-mode -o update") != 0:
|
||||
self.abort("Could not set ONIE Boot Mode to Update. Upgrade cannot continue.")
|
||||
self.umount(OB)
|
||||
|
||||
SL = "/mnt/sl-boot"
|
||||
self.mount(SL, label="SL-BOOT")
|
||||
with open("/mnt/sl-boot/grub/grub.cfg", "a") as f:
|
||||
f.write("set default=ONIE\n")
|
||||
self.umount(SL)
|
||||
self.reboot()
|
||||
|
||||
else:
|
||||
self.abort("Architecture %s unhandled." % self.arch)
|
||||
|
||||
def clean_onie_updater(self):
|
||||
if os.path.exists(self.ONIE_UPDATER_PATH):
|
||||
self.logger.info("Removing previous onie-updater.")
|
||||
os.remove(self.ONIE_UPDATER_PATH)
|
||||
1
packages/base/amd64/upgrade/Makefile
Normal file
1
packages/base/amd64/upgrade/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
26
packages/base/amd64/upgrade/PKG.yml
Normal file
26
packages/base/amd64/upgrade/PKG.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
prerequisites:
|
||||
packages:
|
||||
- onl-kernel-3.9.6-x86-64-all:amd64
|
||||
- onl-kernel-3.2-deb7-x86-64-all:amd64
|
||||
- onl-kernel-3.18-x86-64-all:amd64
|
||||
- onl-loader-initrd:amd64
|
||||
|
||||
common:
|
||||
arch: amd64
|
||||
version: 1.0.0
|
||||
copyright: Copyright 2013, 2014, 2015 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
|
||||
packages:
|
||||
- name: onl-upgrade
|
||||
version: 1.0.0
|
||||
summary: Open Network Linux Upgrade package for AMD64 platforms.
|
||||
|
||||
files:
|
||||
builds/files : /etc/onl/upgrade/x86_64
|
||||
|
||||
changelog: Change changes changes.,
|
||||
|
||||
|
||||
|
||||
|
||||
1
packages/base/amd64/upgrade/builds/.gitignore
vendored
Normal file
1
packages/base/amd64/upgrade/builds/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
files
|
||||
18
packages/base/amd64/upgrade/builds/Makefile
Normal file
18
packages/base/amd64/upgrade/builds/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
# All amd64 kernels
|
||||
KERNELS := $(shell $(ONLPM) --find-file onl-kernel-3.9.6-x86-64-all:amd64 kernel-3.9.6-x86-64-all) \
|
||||
$(shell $(ONLPM) --find-file onl-kernel-3.2-deb7-x86-64-all:amd64 kernel-3.2-deb7-x86_64-all) \
|
||||
$(shell $(ONLPM) --find-file onl-kernel-3.18-x86-64-all:amd64 kernel-3.18-x86_64-all) \
|
||||
|
||||
# Loader initrd
|
||||
INITRD := $(shell $(ONLPM) --find-file onl-loader-initrd:amd64 onl-loader-initrd-amd64.cpio.gz)
|
||||
MANIFEST := $(shell $(ONLPM) --find-file onl-loader-initrd:amd64 manifest.json)
|
||||
|
||||
all:
|
||||
mkdir -p files
|
||||
cp $(KERNELS) files
|
||||
cp $(INITRD) files/initrd-amd64
|
||||
cp $(MANIFEST) files
|
||||
|
||||
|
||||
@@ -42,14 +42,6 @@ index ea97f4a..818dd01 100644
|
||||
obj-$(CONFIG_SENSORS_AD7314) += ad7314.o
|
||||
obj-$(CONFIG_SENSORS_AD7414) += ad7414.o
|
||||
obj-$(CONFIG_SENSORS_AD7418) += ad7418.o
|
||||
@@ -141,7 +143,6 @@ obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o
|
||||
obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o
|
||||
obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o
|
||||
obj-$(CONFIG_SENSORS_QUANTA_LY_HWMON) += quanta-ly-hwmon.o
|
||||
-obj-$(CONFIG_SENSORS_YM2651Y) += ym2651y.o
|
||||
|
||||
obj-$(CONFIG_PMBUS) += pmbus/
|
||||
|
||||
diff --git a/drivers/hwmon/accton_as5812_54x_fan.c b/drivers/hwmon/accton_as5812_54x_fan.c
|
||||
new file mode 100644
|
||||
index 0000000..3e25db1
|
||||
|
||||
@@ -74,13 +74,16 @@ cdefs: &cdefs
|
||||
default: 1
|
||||
- ONLP_CONFIG_API_LOCK_GLOBAL_SHARED:
|
||||
doc: "If 0, the API lock is a simple semaphore. If 1, the API lock is a global shared mutex."
|
||||
default: 0
|
||||
default: 1
|
||||
- ONLP_CONFIG_API_LOCK_TIMEOUT:
|
||||
doc: "The maximum amount of time (in usecs) to wait while attempting to acquire the API lock. Failure to acquire is fatal. A value of zero disables this feature. "
|
||||
default: 60000000
|
||||
- ONLP_CONFIG_INFO_STR_MAX:
|
||||
doc: "The maximum size of static information string buffers."
|
||||
default: 64
|
||||
- ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS:
|
||||
doc: "Include thermal threshold reporting."
|
||||
default: 1
|
||||
|
||||
# Error codes
|
||||
onlp_status: &onlp_status
|
||||
|
||||
@@ -211,7 +211,7 @@
|
||||
|
||||
|
||||
#ifndef ONLP_CONFIG_API_LOCK_GLOBAL_SHARED
|
||||
#define ONLP_CONFIG_API_LOCK_GLOBAL_SHARED 0
|
||||
#define ONLP_CONFIG_API_LOCK_GLOBAL_SHARED 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -234,6 +234,16 @@
|
||||
#define ONLP_CONFIG_INFO_STR_MAX 64
|
||||
#endif
|
||||
|
||||
/**
|
||||
* ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS
|
||||
*
|
||||
* Include thermal threshold reporting. */
|
||||
|
||||
|
||||
#ifndef ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS
|
||||
#define ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,6 +71,34 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst);
|
||||
*/
|
||||
int onlp_sfpi_eeprom_read(int port, uint8_t data[256]);
|
||||
|
||||
/**
|
||||
* @brief Read a byte from an address on the given SFP port's bus.
|
||||
* @param port The port number.
|
||||
* @param devaddr The device address.
|
||||
* @param addr The address.
|
||||
*/
|
||||
int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief Write a byte to an address on the given SFP port's bus.
|
||||
*/
|
||||
int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Read a byte from an address on the given SFP port's bus.
|
||||
* @param port The port number.
|
||||
* @param devaddr The device address.
|
||||
* @param addr The address.
|
||||
* @returns The word if successful, error otherwise.
|
||||
*/
|
||||
int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief Write a byte to an address on the given SFP port's bus.
|
||||
*/
|
||||
int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read the SFP DOM EEPROM.
|
||||
* @param port The port number.
|
||||
|
||||
@@ -154,4 +154,9 @@ int onlp_sysi_platform_info_get(onlp_platform_info_t* info);
|
||||
*/
|
||||
void onlp_sysi_platform_info_free(onlp_platform_info_t* info);
|
||||
|
||||
/**
|
||||
* @brief Builtin platform debug tool.
|
||||
*/
|
||||
int onlp_sysi_debug(aim_pvs_t* pvs, int argc, char** argv);
|
||||
|
||||
#endif /* __ONLP_SYSI_H__ */
|
||||
|
||||
@@ -143,6 +143,36 @@ int onlp_sfp_denit(void);
|
||||
*/
|
||||
int onlp_sfp_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read a byte from an address on the given SFP port's bus.
|
||||
* @param port The port number.
|
||||
* @param devaddr The device address.
|
||||
* @param addr The address.
|
||||
*/
|
||||
int onlp_sfp_dev_readb(int port, uint8_t devaddr, uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief Write a byte to an address on the given SFP port's bus.
|
||||
*/
|
||||
int onlp_sfp_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Read a byte from an address on the given SFP port's bus.
|
||||
* @param port The port number.
|
||||
* @param devaddr The device address.
|
||||
* @param addr The address.
|
||||
*/
|
||||
int onlp_sfp_dev_readw(int port, uint8_t devaddr, uint8_t addr);
|
||||
|
||||
/**
|
||||
* @brief Write a byte to an address on the given SFP port's bus.
|
||||
*/
|
||||
int onlp_sfp_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Dump the status of all SFPs
|
||||
* @param pvs The output pvs.
|
||||
|
||||
@@ -117,4 +117,6 @@ int onlp_sys_platform_manage_join(void);
|
||||
|
||||
void onlp_sys_platform_manage_now(void);
|
||||
|
||||
int onlp_sys_debug(aim_pvs_t* pvs, int argc, char** argv);
|
||||
|
||||
#endif /* __ONLP_SYS_H_ */
|
||||
|
||||
@@ -244,14 +244,29 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
|
||||
int rv;
|
||||
iof_t iof;
|
||||
onlp_fan_info_t fi;
|
||||
int yaml;
|
||||
|
||||
onlp_oid_show_iof_init_default(&iof, pvs, flags);
|
||||
|
||||
rv = onlp_fan_info_get(oid, &fi);
|
||||
|
||||
iof_push(&iof, "Fan %d", ONLP_OID_ID_GET(oid));
|
||||
yaml = flags & ONLP_OID_SHOW_F_YAML;
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, "- ");
|
||||
iof_iprintf(&iof, "Name: Fan %d", ONLP_OID_ID_GET(oid));
|
||||
}
|
||||
else {
|
||||
iof_push(&iof, "Fan %d", ONLP_OID_ID_GET(oid));
|
||||
}
|
||||
|
||||
if(rv < 0) {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
if(yaml) {
|
||||
iof_iprintf(&iof, "State: Error");
|
||||
iof_iprintf(&iof, "Error: %{onlp_status}", rv);
|
||||
} else {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
onlp_oid_show_description(&iof, &fi.hdr);
|
||||
@@ -259,10 +274,10 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
|
||||
/* Present */
|
||||
iof_iprintf(&iof, "State: Present");
|
||||
if(fi.status & ONLP_FAN_STATUS_FAILED) {
|
||||
iof_iprintf(&iof, "Status: FAILED");
|
||||
iof_iprintf(&iof, "Status: Failed");
|
||||
}
|
||||
else {
|
||||
iof_iprintf(&iof, "Status: Running.");
|
||||
iof_iprintf(&iof, "Status: Running");
|
||||
if(fi.model[0]) {
|
||||
iof_iprintf(&iof, "Model: %s", fi.model);
|
||||
}
|
||||
@@ -270,16 +285,16 @@ onlp_fan_show(onlp_oid_t oid, aim_pvs_t* pvs, uint32_t flags)
|
||||
iof_iprintf(&iof, "SN: %s", fi.serial);
|
||||
}
|
||||
if(fi.caps & ONLP_FAN_CAPS_GET_RPM) {
|
||||
iof_iprintf(&iof, "RPM: %d.", fi.rpm);
|
||||
iof_iprintf(&iof, "RPM: %d", fi.rpm);
|
||||
}
|
||||
if(fi.caps & ONLP_FAN_CAPS_GET_PERCENTAGE) {
|
||||
iof_iprintf(&iof, "Speed: %d%%.", fi.percentage);
|
||||
iof_iprintf(&iof, "Speed: %d%%", fi.percentage);
|
||||
}
|
||||
if(fi.status & ONLP_FAN_STATUS_B2F) {
|
||||
iof_iprintf(&iof, "Airflow: Back-to-Front.");
|
||||
iof_iprintf(&iof, "Airflow: Back-to-Front");
|
||||
}
|
||||
if(fi.status & ONLP_FAN_STATUS_F2B) {
|
||||
iof_iprintf(&iof, "Airflow: Front-to-Back.");
|
||||
iof_iprintf(&iof, "Airflow: Front-to-Back");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,18 +158,36 @@ onlp_led_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
int rv;
|
||||
iof_t iof;
|
||||
onlp_led_info_t info;
|
||||
int yaml;
|
||||
|
||||
VALIDATENR(id);
|
||||
onlp_oid_show_iof_init_default(&iof, pvs, flags);
|
||||
iof_push(&iof, "LED %d", ONLP_OID_ID_GET(id));
|
||||
|
||||
yaml = flags & ONLP_OID_SHOW_F_YAML;
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, " -");
|
||||
iof_iprintf(&iof, "Name: LED %d", ONLP_OID_ID_GET(id));
|
||||
}
|
||||
else {
|
||||
iof_push(&iof, "LED %d", ONLP_OID_ID_GET(id));
|
||||
}
|
||||
|
||||
rv = onlp_led_info_get(id, &info);
|
||||
if(rv < 0) {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
if(yaml) {
|
||||
iof_iprintf(&iof, "State: Error");
|
||||
iof_iprintf(&iof, "Error: %{onlp_status}", rv);
|
||||
}
|
||||
else {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
onlp_oid_show_description(&iof, &info.hdr);
|
||||
if(info.status & 1) {
|
||||
/* Present */
|
||||
iof_iprintf(&iof, "State: Present");
|
||||
iof_iprintf(&iof, "Mode: %{onlp_led_mode}", info.mode);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -124,6 +124,11 @@ onlp_config_settings_t onlp_config_settings[] =
|
||||
{ __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INFO_STR_MAX), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INFO_STR_MAX) },
|
||||
#else
|
||||
{ ONLP_CONFIG_INFO_STR_MAX(__onlp_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
#ifdef ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS
|
||||
{ __onlp_config_STRINGIFY_NAME(ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS), __onlp_config_STRINGIFY_VALUE(ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS) },
|
||||
#else
|
||||
{ ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS(__onlp_config_STRINGIFY_NAME), "__undefined__" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -174,7 +174,15 @@ onlpdump_main(int argc, char* argv[])
|
||||
const char* O = NULL;
|
||||
const char* t = NULL;
|
||||
|
||||
while( (c = getopt(argc, argv, "srehdojmM:ipxlSt:O:")) != -1) {
|
||||
/**
|
||||
* debug trap
|
||||
*/
|
||||
if(argc > 1 && !strcmp(argv[1], "debug")) {
|
||||
onlp_init();
|
||||
return onlp_sys_debug(&aim_pvs_stdout, argc-2, argv+2);
|
||||
}
|
||||
|
||||
while( (c = getopt(argc, argv, "srehdojmyM:ipxlSt:O:")) != -1) {
|
||||
switch(c)
|
||||
{
|
||||
case 's': show=1; break;
|
||||
@@ -193,21 +201,18 @@ onlpdump_main(int argc, char* argv[])
|
||||
case 'O': O = optarg; break;
|
||||
case 'S': S=1; break;
|
||||
case 'l': l=1; break;
|
||||
case 'y': show=1; showflags |= ONLP_OID_SHOW_F_YAML; break;
|
||||
default: help=1; rv = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
if(M) {
|
||||
platform_manager_daemon__(pidfile);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(help) {
|
||||
printf("Usage: %s [OPTIONS]\n", argv[0]);
|
||||
printf(" -d Use dump(). This is the default.\n");
|
||||
printf(" -s Use show() instead of dump().\n");
|
||||
printf(" -r Recursive show(). Implies -s\n");
|
||||
printf(" -e Extended show(). Implies -s\n");
|
||||
printf(" -y Yaml show(). Implies -s\n");
|
||||
printf(" -o Dump ONIE data only.\n");
|
||||
printf(" -x Dump Platform Info only.\n");
|
||||
printf(" -j Dump ONIE data in JSON format.\n");
|
||||
@@ -223,7 +228,7 @@ onlpdump_main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
|
||||
if(t){
|
||||
if(t) {
|
||||
int rv;
|
||||
onlp_onie_info_t onie;
|
||||
rv = onlp_onie_decode_file(&onie, t);
|
||||
@@ -240,6 +245,11 @@ onlpdump_main(int argc, char* argv[])
|
||||
|
||||
onlp_init();
|
||||
|
||||
if(M) {
|
||||
platform_manager_daemon__(pidfile);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if(l) {
|
||||
extern int onlp_api_lock_test(void);
|
||||
int i;
|
||||
|
||||
@@ -49,12 +49,7 @@ onlp_oid_show_iof_init_default(iof_t* iof, aim_pvs_t* pvs, uint32_t flags)
|
||||
iof->level=1;
|
||||
iof->indent_terminator="";
|
||||
iof->pop_string = NULL;
|
||||
if(flags & ONLP_OID_SHOW_F_YAML) {
|
||||
iof->push_string = ":";
|
||||
}
|
||||
else {
|
||||
iof->push_string = "";
|
||||
}
|
||||
iof->push_string = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +284,7 @@ onlp_sys_platform_manage_join(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
platform_psus_notify__(void)
|
||||
{
|
||||
|
||||
@@ -129,13 +129,28 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
int rv;
|
||||
iof_t iof;
|
||||
onlp_psu_info_t pi;
|
||||
int yaml;
|
||||
|
||||
onlp_oid_show_iof_init_default(&iof, pvs, flags);
|
||||
rv = onlp_psu_info_get(id, &pi);
|
||||
|
||||
iof_push(&iof, "PSU %d", ONLP_OID_ID_GET(id));
|
||||
yaml = flags & ONLP_OID_SHOW_F_YAML;
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, "- ");
|
||||
iof_iprintf(&iof, "Name: PSU %d", ONLP_OID_ID_GET(id));
|
||||
} else {
|
||||
iof_push(&iof, "PSU %d", ONLP_OID_ID_GET(id));
|
||||
}
|
||||
|
||||
if(rv < 0) {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
if(yaml) {
|
||||
iof_iprintf(&iof, "State: Error");
|
||||
iof_iprintf(&iof, "Error: %{onlp_status}", rv);
|
||||
}
|
||||
else {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
onlp_oid_show_description(&iof, &pi.hdr);
|
||||
@@ -146,10 +161,10 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
iof_iprintf(&iof, "Status: Unplugged");
|
||||
}
|
||||
else if(pi.status & ONLP_PSU_STATUS_FAILED) {
|
||||
iof_iprintf(&iof, "Status: Unplugged or Failed.");
|
||||
iof_iprintf(&iof, "Status: Unplugged or Failed");
|
||||
}
|
||||
else {
|
||||
iof_iprintf(&iof, "Status: Running.");
|
||||
iof_iprintf(&iof, "Status: Running");
|
||||
iof_iprintf(&iof, "Model: %s", pi.model[0] ? pi.model : "Unknown");
|
||||
if(pi.serial[0]) iof_iprintf(&iof, "SN: %s", pi.serial);
|
||||
if(pi.caps & ONLP_PSU_CAPS_AC) {
|
||||
@@ -162,7 +177,7 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
iof_iprintf(&iof, "Type: DC 48V");
|
||||
}
|
||||
else {
|
||||
iof_iprintf(&iof, "Type: Unknown.");
|
||||
iof_iprintf(&iof, "Type: Unknown");
|
||||
}
|
||||
if(pi.caps & ONLP_PSU_CAPS_VIN) {
|
||||
iof_iprintf(&iof, "Vin: %d.%d",
|
||||
@@ -197,12 +212,26 @@ onlp_psu_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
* Fans and Thermal Sensors.
|
||||
*/
|
||||
onlp_oid_t* oidp;
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, "Fans: ");
|
||||
}
|
||||
ONLP_OID_TABLE_ITER_TYPE(pi.hdr.coids, oidp, FAN) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
if(yaml) {
|
||||
iof_pop(&iof);
|
||||
}
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, "Thermals: ");
|
||||
}
|
||||
ONLP_OID_TABLE_ITER_TYPE(pi.hdr.coids, oidp, THERMAL) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
if(yaml) {
|
||||
iof_pop(&iof);
|
||||
}
|
||||
|
||||
if(flags & ONLP_OID_SHOW_F_EXTENDED) {
|
||||
/* Include all other types as well. */
|
||||
|
||||
@@ -399,3 +399,34 @@ onlp_sfp_vioctl_locked__(int port, va_list vargs)
|
||||
ONLP_LOCKED_API2(onlp_sfp_vioctl, int, port, va_list, vargs);
|
||||
|
||||
|
||||
int
|
||||
onlp_sfp_dev_readb_locked__(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
return onlp_sfpi_dev_readb(port, devaddr, addr);
|
||||
}
|
||||
ONLP_LOCKED_API3(onlp_sfp_dev_readb, int, port, uint8_t, devaddr, uint8_t, addr);
|
||||
|
||||
int
|
||||
onlp_sfp_dev_writeb_locked__(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
return onlp_sfpi_dev_writeb(port, devaddr, addr, value);
|
||||
}
|
||||
ONLP_LOCKED_API4(onlp_sfp_dev_writeb, int, port, uint8_t, devaddr, uint8_t, addr, uint8_t, value);
|
||||
|
||||
int
|
||||
onlp_sfp_dev_readw_locked__(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
return onlp_sfpi_dev_readw(port, devaddr, addr);
|
||||
}
|
||||
ONLP_LOCKED_API3(onlp_sfp_dev_readw, int, port, uint8_t, devaddr, uint8_t, addr);
|
||||
|
||||
int
|
||||
onlp_sfp_dev_writew_locked__(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
return onlp_sfpi_dev_writew(port, devaddr, addr, value);
|
||||
}
|
||||
ONLP_LOCKED_API4(onlp_sfp_dev_writew, int, port, uint8_t, devaddr, uint8_t, addr, uint16_t, value);
|
||||
|
||||
@@ -181,7 +181,7 @@ onlp_sys_dump(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
return;
|
||||
}
|
||||
|
||||
iof_push(&iof, "System Information");
|
||||
iof_push(&iof, "System Information:");
|
||||
rv = onlp_sys_info_get(&si);
|
||||
if(rv < 0) {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
@@ -227,7 +227,7 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
if(yaml ||
|
||||
flags & ONLP_OID_SHOW_F_EXTENDED ||
|
||||
(flags & ONLP_OID_SHOW_F_RECURSE) == 0) {
|
||||
iof_push(&iof, "System Information");
|
||||
iof_push(&iof, "System Information:");
|
||||
onlp_onie_show(&si.onie_info, &iof.inherit);
|
||||
iof_pop(&iof);
|
||||
}
|
||||
@@ -237,21 +237,21 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
onlp_oid_t* oidp;
|
||||
|
||||
/** Show all Chassis Fans */
|
||||
YPUSH("Fans");
|
||||
YPUSH("Fans:");
|
||||
ONLP_OID_TABLE_ITER_TYPE(si.hdr.coids, oidp, FAN) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
YPOP();
|
||||
|
||||
/** Show all System Thermals */
|
||||
YPUSH("Thermals");
|
||||
YPUSH("Thermals:");
|
||||
ONLP_OID_TABLE_ITER_TYPE(si.hdr.coids, oidp, THERMAL) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
YPOP();
|
||||
|
||||
/** Show all PSUs */
|
||||
YPUSH("PSUs");
|
||||
YPUSH("PSUs:");
|
||||
ONLP_OID_TABLE_ITER_TYPE(si.hdr.coids, oidp, PSU) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ onlp_sys_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
|
||||
if(flags & ONLP_OID_SHOW_F_EXTENDED) {
|
||||
/** Show all LEDs */
|
||||
YPUSH("LEDs");
|
||||
YPUSH("LEDs:");
|
||||
ONLP_OID_TABLE_ITER_TYPE(si.hdr.coids, oidp, LED) {
|
||||
onlp_oid_show(*oidp, &iof.inherit, flags);
|
||||
}
|
||||
@@ -287,3 +287,9 @@ onlp_sys_vioctl_locked__(int code, va_list vargs)
|
||||
}
|
||||
ONLP_LOCKED_API2(onlp_sys_vioctl, int, code, va_list, vargs);
|
||||
|
||||
static int
|
||||
onlp_sys_debug_locked__(aim_pvs_t* pvs, int argc, char* argv[])
|
||||
{
|
||||
return onlp_sysi_debug(pvs, argc, argv);
|
||||
}
|
||||
ONLP_LOCKED_API3(onlp_sys_debug, aim_pvs_t*, pvs, int, argc, char**, argv);
|
||||
|
||||
@@ -164,44 +164,64 @@ onlp_thermal_show(onlp_oid_t id, aim_pvs_t* pvs, uint32_t flags)
|
||||
iof_t iof;
|
||||
onlp_thermal_info_t ti;
|
||||
VALIDATENR(id);
|
||||
int yaml;
|
||||
|
||||
onlp_oid_show_iof_init_default(&iof, pvs, flags);
|
||||
|
||||
|
||||
rv = onlp_thermal_info_get(id, &ti);
|
||||
iof_push(&iof, "Thermal %d", ONLP_OID_ID_GET(id));
|
||||
|
||||
yaml = flags & ONLP_OID_SHOW_F_YAML;
|
||||
|
||||
if(yaml) {
|
||||
iof_push(&iof, "- ");
|
||||
iof_iprintf(&iof, "Name: Thermal %d", ONLP_OID_ID_GET(id));
|
||||
}
|
||||
else {
|
||||
iof_push(&iof, "Thermal %d", ONLP_OID_ID_GET(id));
|
||||
}
|
||||
|
||||
if(rv < 0) {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
if(yaml) {
|
||||
iof_iprintf(&iof, "State: Error");
|
||||
iof_iprintf(&iof, "Error: %{onlp_status}", rv);
|
||||
}
|
||||
else {
|
||||
onlp_oid_info_get_error(&iof, rv);
|
||||
}
|
||||
}
|
||||
else {
|
||||
onlp_oid_show_description(&iof, &ti.hdr);
|
||||
if(ti.status & 0x1) {
|
||||
/* Present */
|
||||
if(ti.status & ONLP_THERMAL_STATUS_FAILED) {
|
||||
iof_iprintf(&iof, "Status: Sensor FAILED");
|
||||
iof_iprintf(&iof, "Status: Failed");
|
||||
}
|
||||
else {
|
||||
iof_iprintf(&iof, "Status: Sensor Functional");
|
||||
iof_iprintf(&iof, "Status: Functional");
|
||||
if(ti.caps & ONLP_THERMAL_CAPS_GET_TEMPERATURE) {
|
||||
iof_iprintf(&iof, "Temperature: %d.%d C.",
|
||||
iof_iprintf(&iof, "Temperature: %d.%d C",
|
||||
ONLP_MILLI_NORMAL_INTEGER_TENTHS(ti.mcelsius));
|
||||
}
|
||||
#if ONLP_CONFIG_INCLUDE_THERMAL_THRESHOLDS == 1
|
||||
|
||||
if(ti.caps & ONLP_THERMAL_CAPS_GET_ANY_THRESHOLD) {
|
||||
iof_push(&iof, "Thresholds");
|
||||
iof_push(&iof, "Thresholds:");
|
||||
if(ti.caps & ONLP_THERMAL_CAPS_GET_WARNING_THRESHOLD) {
|
||||
iof_iprintf(&iof, "Warning : %d.%d C.",
|
||||
iof_iprintf(&iof, "Warning : %d.%d C",
|
||||
ONLP_MILLI_NORMAL_INTEGER_TENTHS(ti.thresholds.warning));
|
||||
}
|
||||
if(ti.caps & ONLP_THERMAL_CAPS_GET_ERROR_THRESHOLD) {
|
||||
iof_iprintf(&iof, "Error : %d.%d C.",
|
||||
iof_iprintf(&iof, "Error : %d.%d C",
|
||||
ONLP_MILLI_NORMAL_INTEGER_TENTHS(ti.thresholds.error));
|
||||
}
|
||||
if(ti.caps & ONLP_THERMAL_CAPS_GET_SHUTDOWN_THRESHOLD) {
|
||||
iof_iprintf(&iof, "Shutdown: %d.%d C.",
|
||||
iof_iprintf(&iof, "Shutdown: %d.%d C",
|
||||
ONLP_MILLI_NORMAL_INTEGER_TENTHS(ti.thresholds.shutdown));
|
||||
}
|
||||
iof_pop(&iof);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -40,3 +40,7 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_ioctl(int port, va_list vargs));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value));
|
||||
|
||||
@@ -48,6 +48,13 @@ onlp_sysi_platform_get(void)
|
||||
return ONLP_SYSI_PLATFORM_NAME_DEFAULT;
|
||||
}
|
||||
|
||||
int __ONLP_DEFAULTI
|
||||
onlp_sysi_debug(aim_pvs_t* pvs, int argc, char* argv[])
|
||||
{
|
||||
aim_printf(pvs, "This platform does not support debug features.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_platform_set(const char* p));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_init(void));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_onie_data_phys_addr_get(void** physaddr));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# Inclusive Makefile for the onlp_platform_defaults module.
|
||||
#
|
||||
# Autogenerated 2016-01-07 22:54:28.940349
|
||||
# Autogenerated 2016-03-23 18:28:25.688419
|
||||
#
|
||||
###############################################################################
|
||||
onlp_platform_defaults_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -45,6 +45,23 @@
|
||||
*/
|
||||
#define ONLP_I2C_F_PEC 0x4
|
||||
|
||||
|
||||
/**
|
||||
* Do not deselect mux channels after device operations.
|
||||
* The default is to deselect all intermediate muxes if possible.
|
||||
*/
|
||||
#define ONLP_I2C_F_NO_MUX_DESELECT 0x8
|
||||
|
||||
/**
|
||||
* Do not select mux channels prior to device operations.
|
||||
* The default is to select all intermediate muxes.
|
||||
*
|
||||
* This option is useful if you want to manually select
|
||||
* the mux channels for multiple operations.
|
||||
*/
|
||||
#define ONLP_I2C_F_NO_MUX_SELECT 0x10
|
||||
|
||||
|
||||
/**
|
||||
* @brief Open and prepare for reading or writing.
|
||||
* @param bus The i2c bus number.
|
||||
@@ -150,6 +167,178 @@ int onlp_i2c_writew(int bus, uint8_t addr, uint8_t offset, uint16_t word,
|
||||
uint32_t flags);
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* I2C Mux/Device Management.
|
||||
*
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/**
|
||||
* An i2c mux device driver.
|
||||
*/
|
||||
typedef struct onlp_i2c_mux_driver_s {
|
||||
/** Driver Name */
|
||||
const char* name;
|
||||
|
||||
/** Control register address for this mux. */
|
||||
uint8_t control;
|
||||
|
||||
/** Channel select values. */
|
||||
struct {
|
||||
int channel;
|
||||
uint8_t value;
|
||||
} channels[16];
|
||||
|
||||
} onlp_i2c_mux_driver_t;
|
||||
|
||||
|
||||
/**
|
||||
* An i2c mux device.
|
||||
*
|
||||
*/
|
||||
typedef struct onlp_i2c_mux_device_s {
|
||||
/* Instance description. */
|
||||
const char* name;
|
||||
|
||||
/** i2c bus number */
|
||||
int bus;
|
||||
|
||||
/** i2c address for this instance */
|
||||
uint8_t devaddr;
|
||||
|
||||
/** Mux device driver */
|
||||
onlp_i2c_mux_driver_t* driver;
|
||||
|
||||
} onlp_i2c_mux_device_t;
|
||||
|
||||
|
||||
/**
|
||||
* Description of a channel.
|
||||
*/
|
||||
typedef struct onlp_i2c_mux_channel_s {
|
||||
onlp_i2c_mux_device_t* mux;
|
||||
int channel;
|
||||
} onlp_i2c_mux_channel_t;
|
||||
|
||||
|
||||
/**
|
||||
* A set of i2c mux channels to program.
|
||||
*/
|
||||
typedef struct onlp_i2c_mux_channels_s {
|
||||
onlp_i2c_mux_channel_t channels[8];
|
||||
} onlp_i2c_mux_channels_t;
|
||||
|
||||
|
||||
/**
|
||||
* An i2c device.
|
||||
*
|
||||
* The device can be accessed only after selecting it's channel tree.
|
||||
*/
|
||||
typedef struct onlp_i2c_dev_s {
|
||||
const char* name;
|
||||
|
||||
/**
|
||||
* The sequence of mux channels can be specified
|
||||
* inline or via pointer.
|
||||
*/
|
||||
onlp_i2c_mux_channels_t ichannels;
|
||||
onlp_i2c_mux_channels_t* pchannels;
|
||||
|
||||
/**
|
||||
* Bus and address for this device after channel tree selection.
|
||||
*/
|
||||
int bus;
|
||||
uint8_t addr;
|
||||
|
||||
} onlp_i2c_dev_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Select a mux channel.
|
||||
* @param muxdev The mux device instance.
|
||||
* @param channel The channel number to select.
|
||||
*/
|
||||
int onlp_i2c_mux_select(onlp_i2c_mux_device_t* muxdev, int channel);
|
||||
|
||||
/**
|
||||
* @brief Deselect a mux channel.
|
||||
* @param muxdev The mux device instance.
|
||||
*/
|
||||
int onlp_i2c_mux_deselect(onlp_i2c_mux_device_t* muxdev);
|
||||
|
||||
/**
|
||||
* @brief Select a mux channel.
|
||||
*/
|
||||
int onlp_i2c_mux_channel_select(onlp_i2c_mux_channel_t* mc);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Select a mux channel.
|
||||
*/
|
||||
int onlp_i2c_mux_channel_deselect(onlp_i2c_mux_channel_t* mc);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Select a mux channel tree.
|
||||
*/
|
||||
int onlp_i2c_mux_channels_select(onlp_i2c_mux_channels_t* channels);
|
||||
|
||||
/**
|
||||
* @brief Deselect a mux channel tree.
|
||||
*/
|
||||
int onlp_i2c_mux_channels_deselect(onlp_i2c_mux_channels_t* channels);
|
||||
|
||||
/**
|
||||
* @brief Select a device's mux channel tree.
|
||||
*/
|
||||
int onlp_i2c_dev_mux_channels_select(onlp_i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* @brief Deselect a device's mux channel tree.
|
||||
*/
|
||||
int onlp_i2c_dev_mux_channels_deselect(onlp_i2c_dev_t* dev);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read from an device.
|
||||
*/
|
||||
int onlp_i2c_dev_read(onlp_i2c_dev_t* dev, uint8_t offset, int size,
|
||||
uint8_t* rdata, uint32_t flags);
|
||||
|
||||
/**
|
||||
* @brief Write to a device.
|
||||
*/
|
||||
int onlp_i2c_dev_write(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, int size,
|
||||
uint8_t* data, uint32_t flags);
|
||||
|
||||
int onlp_i2c_dev_readb(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint32_t flags);
|
||||
|
||||
int onlp_i2c_dev_writeb(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint8_t byte, uint32_t flags);
|
||||
|
||||
int onlp_i2c_dev_readw(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint32_t flags);
|
||||
|
||||
int onlp_i2c_dev_writew(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint16_t word, uint32_t flags);
|
||||
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* Reusable MUX device drivers.
|
||||
*
|
||||
*****************************************************************************/
|
||||
extern onlp_i2c_mux_driver_t onlp_i2c_mux_driver_pca9547a;
|
||||
extern onlp_i2c_mux_driver_t onlp_i2c_mux_driver_pca9548;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* ONLPLIB_CONFIG_INCLUDE_I2C */
|
||||
|
||||
#endif /* __ONLP_I2C_H__ */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
} while(0)
|
||||
|
||||
#define ONLP_ACTIVE_LOW_MASKS_BIT(_enable, _bit, _andmask, _ormask) \
|
||||
ONLP_ACTIVE_LOAS_MASKS(_enable, (1 << (_bit)), _andmask, _ormask)
|
||||
ONLP_ACTIVE_LOW_MASKS(_enable, (1 << (_bit)), _andmask, _ormask)
|
||||
|
||||
/**
|
||||
* Set and & or masks for active high bits.
|
||||
|
||||
@@ -255,4 +255,315 @@ onlp_i2c_writew(int bus, uint8_t addr, uint8_t offset, uint16_t word,
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
onlp_i2c_mux_select(onlp_i2c_mux_device_t* dev, int channel)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < AIM_ARRAYSIZE(dev->driver->channels); i++) {
|
||||
if(dev->driver->channels[i].channel == channel) {
|
||||
AIM_LOG_VERBOSE("i2c_mux_select: Selecting channel %2d on device '%s' [ bus=%d addr=0x%x offset=0x%x value=0x%x ]...",
|
||||
channel, dev->name, dev->bus, dev->devaddr,
|
||||
dev->driver->control, dev->driver->channels[i].value);
|
||||
|
||||
int rv = onlp_i2c_writeb(dev->bus,
|
||||
dev->devaddr,
|
||||
dev->driver->control,
|
||||
dev->driver->channels[i].value,
|
||||
0);
|
||||
|
||||
if(rv < 0) {
|
||||
AIM_LOG_ERROR("i2c_mux_select: Selecting channel %2d on device '%s' [ bus=%d addr=0x%x offset=0x%x value=0x%x ] failed: %d",
|
||||
channel, dev->name, dev->bus, dev->devaddr,
|
||||
dev->driver->control, dev->driver->channels[i].value, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_mux_deselect(onlp_i2c_mux_device_t* dev)
|
||||
{
|
||||
return onlp_i2c_mux_select(dev, -1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_mux_channel_select(onlp_i2c_mux_channel_t* mc)
|
||||
{
|
||||
return onlp_i2c_mux_select(mc->mux, mc->channel);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_mux_channel_deselect(onlp_i2c_mux_channel_t* mc)
|
||||
{
|
||||
return onlp_i2c_mux_deselect(mc->mux);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_mux_channels_select(onlp_i2c_mux_channels_t* mcs)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < AIM_ARRAYSIZE(mcs->channels); i++) {
|
||||
if(mcs->channels[i].mux) {
|
||||
int rv = onlp_i2c_mux_channel_select(mcs->channels + i);
|
||||
if(rv < 0) {
|
||||
/** Error already reported */
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_mux_channels_deselect(onlp_i2c_mux_channels_t* mcs)
|
||||
{
|
||||
int i;
|
||||
for(i = AIM_ARRAYSIZE(mcs->channels) - 1; i >= 0; i--) {
|
||||
if(mcs->channels[i].mux) {
|
||||
int rv = onlp_i2c_mux_channel_deselect(mcs->channels + i);
|
||||
if(rv < 0) {
|
||||
/** Error already reported. */
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_mux_channels_select(onlp_i2c_dev_t* dev)
|
||||
{
|
||||
if(dev->pchannels) {
|
||||
return onlp_i2c_mux_channels_select(dev->pchannels);
|
||||
}
|
||||
else {
|
||||
return onlp_i2c_mux_channels_select(&dev->ichannels);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_mux_channels_deselect(onlp_i2c_dev_t* dev)
|
||||
{
|
||||
if(dev->pchannels) {
|
||||
return onlp_i2c_mux_channels_deselect(dev->pchannels);
|
||||
}
|
||||
else {
|
||||
return onlp_i2c_mux_channels_deselect(&dev->ichannels);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
dev_mux_channels_select__(onlp_i2c_dev_t* dev, uint32_t flags)
|
||||
{
|
||||
if(flags & ONLP_I2C_F_NO_MUX_SELECT) {
|
||||
return 0;
|
||||
}
|
||||
return onlp_i2c_dev_mux_channels_select(dev);
|
||||
}
|
||||
|
||||
static int
|
||||
dev_mux_channels_deselect__(onlp_i2c_dev_t* dev, uint32_t flags)
|
||||
{
|
||||
if(flags & ONLP_I2C_F_NO_MUX_DESELECT) {
|
||||
return 0;
|
||||
}
|
||||
return onlp_i2c_dev_mux_channels_deselect(dev);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_read(onlp_i2c_dev_t* dev, uint8_t offset, int size,
|
||||
uint8_t* rdata, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_read(dev->bus, dev->addr, offset, size, rdata, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: read() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_write(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, int size, uint8_t* data, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_write(dev->bus, dev->addr, offset, size, data, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: write() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_readb(onlp_i2c_dev_t* dev, uint8_t offset, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_readb(dev->bus, dev->addr, offset, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: readb() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_writeb(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint8_t byte, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_writeb(dev->bus, dev->addr, offset, byte, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: writeb() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_readw(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_readw(dev->bus, dev->addr, offset, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: readw() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_i2c_dev_writew(onlp_i2c_dev_t* dev,
|
||||
uint8_t offset, uint16_t word, uint32_t flags)
|
||||
{
|
||||
int error, rv;
|
||||
|
||||
if( (error = dev_mux_channels_select__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if( (rv = onlp_i2c_writew(dev->bus, dev->addr, offset, word, flags)) < 0) {
|
||||
AIM_LOG_ERROR("Device %s: writew() failed: %d",
|
||||
dev->name, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if( (error = dev_mux_channels_deselect__(dev, flags)) < 0) {
|
||||
return error;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* PCA9547A
|
||||
*/
|
||||
onlp_i2c_mux_driver_t onlp_i2c_mux_driver_pca9547a =
|
||||
{
|
||||
.name = "PCA9547A",
|
||||
.control = 0,
|
||||
.channels =
|
||||
{
|
||||
{ -1, 0 },
|
||||
{ 0, 0x8 },
|
||||
{ 1, 0x9 },
|
||||
{ 2, 0xA },
|
||||
{ 3, 0xB },
|
||||
{ 4, 0xC },
|
||||
{ 5, 0xD },
|
||||
{ 6, 0xE },
|
||||
{ 7, 0xF },
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* PCA9548
|
||||
*/
|
||||
onlp_i2c_mux_driver_t onlp_i2c_mux_driver_pca9548 =
|
||||
{
|
||||
.name = "PCA9548A",
|
||||
.control = 0,
|
||||
.channels =
|
||||
{
|
||||
{ -1, 0x00 },
|
||||
{ 0, 0x01 },
|
||||
{ 1, 0x02 },
|
||||
{ 2, 0x04 },
|
||||
{ 3, 0x08 },
|
||||
{ 4, 0x10 },
|
||||
{ 5, 0x20 },
|
||||
{ 6, 0x40 },
|
||||
{ 7, 0x80 },
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
#endif /* ONLPLIB_CONFIG_INCLUDE_I2C */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# Inclusive Makefile for the onlplib module.
|
||||
#
|
||||
# Autogenerated 2016-01-07 22:54:29.056595
|
||||
# Autogenerated 2016-03-23 18:28:25.806397
|
||||
#
|
||||
###############################################################################
|
||||
onlplib_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -48,6 +48,8 @@ sff_module_types: &sff_module_types
|
||||
desc: "100GBASE-SR4"
|
||||
- 100G_BASE_LR4:
|
||||
desc: "100GBASE-LR4"
|
||||
- 100G_CWDM4:
|
||||
desc: "100G-CWDM4"
|
||||
- 40G_BASE_CR4:
|
||||
desc: "40GBASE-CR4"
|
||||
- 40G_BASE_SR4:
|
||||
|
||||
@@ -777,13 +777,18 @@ _sff8472_media_zr(const uint8_t *idprom)
|
||||
if (SFF8472_MEDIA_XGE_LRM(idprom)) return 0;
|
||||
if (SFF8472_MEDIA_XGE_ER(idprom)) return 0;
|
||||
|
||||
/* advertise media and tech as per FC */
|
||||
if (_sff8472_tech_fc_ll(idprom) == 0) return 0;
|
||||
if (_sff8472_fc_media_sm(idprom) == 0) return 0;
|
||||
|
||||
/* JSM-01ZWBA1 from JDSU does not have FC field(idprom[7~9] programmed,
|
||||
* so check other fields first */
|
||||
/* at least 10GbE */
|
||||
if (!_sff8472_bitrate_xge(idprom)) return 0;
|
||||
|
||||
/* JSM-01ZWBA1 from JDSU is 80km */
|
||||
if (idprom[14] == 80)
|
||||
return 1;
|
||||
|
||||
/* advertise media and tech as per FC */
|
||||
if (_sff8472_tech_fc_ll(idprom) == 0) return 0;
|
||||
if (_sff8472_fc_media_sm(idprom) == 0) return 0;
|
||||
/* at least 40km of single-mode */
|
||||
if ((idprom[14] > 40) && (idprom[15] == 0xff))
|
||||
return 1;
|
||||
|
||||
@@ -129,10 +129,9 @@
|
||||
#define SFF8636_CC192_100GE_AOC 0x01
|
||||
#define SFF8636_CC192_100GE_SR4 0x02
|
||||
#define SFF8636_CC192_100GE_LR4 0x03
|
||||
#define SFF8636_CC192_100GE_CWDM4_FEC 0x06
|
||||
#define SFF8636_CC192_100GE_CWDM4 0x06
|
||||
#define SFF8636_CC192_100GE_PSM4 0x07
|
||||
#define SFF8636_CC192_100GE_ACC 0x08
|
||||
#define SFF8636_CC192_100GE_CWDM4_NOFEC 0x09
|
||||
#define SFF8636_CC192_100GE_CR4 0x0B
|
||||
|
||||
#define SFF8636_MEDIA_100GE_AOC(idprom) \
|
||||
@@ -141,6 +140,8 @@
|
||||
(idprom[192] == SFF8636_CC192_100GE_SR4)
|
||||
#define SFF8636_MEDIA_100GE_LR4(idprom) \
|
||||
(idprom[192] == SFF8636_CC192_100GE_LR4)
|
||||
#define SFF8636_MEDIA_100GE_CWDM4(idprom) \
|
||||
(idprom[192] == SFF8636_CC192_100GE_CWDM4)
|
||||
#define SFF8636_MEDIA_100GE_CR4(idprom) \
|
||||
(idprom[192] == SFF8636_CC192_100GE_CR4)
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ typedef enum sff_module_type_e {
|
||||
SFF_MODULE_TYPE_100G_BASE_CR4,
|
||||
SFF_MODULE_TYPE_100G_BASE_SR4,
|
||||
SFF_MODULE_TYPE_100G_BASE_LR4,
|
||||
SFF_MODULE_TYPE_100G_CWDM4,
|
||||
SFF_MODULE_TYPE_40G_BASE_CR4,
|
||||
SFF_MODULE_TYPE_40G_BASE_SR4,
|
||||
SFF_MODULE_TYPE_40G_BASE_LR4,
|
||||
@@ -132,6 +133,7 @@ typedef enum sff_module_type_e {
|
||||
"100G_BASE_CR4", \
|
||||
"100G_BASE_SR4", \
|
||||
"100G_BASE_LR4", \
|
||||
"100G_CWDM4", \
|
||||
"40G_BASE_CR4", \
|
||||
"40G_BASE_SR4", \
|
||||
"40G_BASE_LR4", \
|
||||
|
||||
@@ -68,6 +68,11 @@ sff_module_type_get(const uint8_t* idprom)
|
||||
&& SFF8636_MEDIA_EXTENDED(idprom)
|
||||
&& SFF8636_MEDIA_100GE_CR4(idprom))
|
||||
return SFF_MODULE_TYPE_100G_BASE_CR4;
|
||||
|
||||
if (SFF8636_MODULE_QSFP28(idprom)
|
||||
&& SFF8636_MEDIA_EXTENDED(idprom)
|
||||
&& SFF8636_MEDIA_100GE_CWDM4(idprom))
|
||||
return SFF_MODULE_TYPE_100G_CWDM4;
|
||||
|
||||
if (SFF8436_MODULE_QSFP_PLUS_V2(idprom)
|
||||
&& SFF8436_MEDIA_40GE_CR4(idprom))
|
||||
@@ -214,6 +219,7 @@ sff_media_type_get(const uint8_t* idprom)
|
||||
case SFF_MODULE_TYPE_100G_AOC:
|
||||
case SFF_MODULE_TYPE_100G_BASE_SR4:
|
||||
case SFF_MODULE_TYPE_100G_BASE_LR4:
|
||||
case SFF_MODULE_TYPE_100G_CWDM4:
|
||||
case SFF_MODULE_TYPE_40G_BASE_SR4:
|
||||
case SFF_MODULE_TYPE_40G_BASE_LR4:
|
||||
case SFF_MODULE_TYPE_40G_BASE_ACTIVE:
|
||||
@@ -257,6 +263,7 @@ sff_module_caps_get(const uint8_t* idprom, uint32_t *caps)
|
||||
case SFF_MODULE_TYPE_100G_BASE_SR4:
|
||||
case SFF_MODULE_TYPE_100G_BASE_LR4:
|
||||
case SFF_MODULE_TYPE_100G_BASE_CR4:
|
||||
case SFF_MODULE_TYPE_100G_CWDM4:
|
||||
*caps |= SFF_MODULE_CAPS_F_100G;
|
||||
return 0;
|
||||
|
||||
@@ -373,6 +380,49 @@ sff_info_init(sff_info_t* rv, uint8_t* eeprom)
|
||||
}
|
||||
rv->sfp_type_name = sff_sfp_type_desc(rv->sfp_type);
|
||||
|
||||
const uint8_t *vendor, *model, *serial;
|
||||
|
||||
switch(rv->sfp_type)
|
||||
{
|
||||
case SFF_SFP_TYPE_QSFP_PLUS:
|
||||
case SFF_SFP_TYPE_QSFP28:
|
||||
vendor=rv->eeprom+148;
|
||||
model=rv->eeprom+168;
|
||||
serial=rv->eeprom+196;
|
||||
break;
|
||||
|
||||
case SFF_SFP_TYPE_SFP:
|
||||
default:
|
||||
vendor=rv->eeprom+20;
|
||||
model=rv->eeprom+40;
|
||||
serial=rv->eeprom+68;
|
||||
break;
|
||||
}
|
||||
|
||||
/* handle NULL fields, they should actually be space-padded */
|
||||
const char *empty = " ";
|
||||
if (*vendor) {
|
||||
aim_strlcpy(rv->vendor, (char*)vendor, sizeof(rv->vendor));
|
||||
make_printable__(rv->vendor);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->vendor, empty, 17);
|
||||
}
|
||||
if (*model) {
|
||||
aim_strlcpy(rv->model, (char*)model, sizeof(rv->model));
|
||||
make_printable__(rv->model);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->model, empty, 17);
|
||||
}
|
||||
if (*serial) {
|
||||
aim_strlcpy(rv->serial, (char*)serial, sizeof(rv->serial));
|
||||
make_printable__(rv->serial);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->serial, empty, 17);
|
||||
}
|
||||
|
||||
rv->module_type = sff_module_type_get(rv->eeprom);
|
||||
if(rv->module_type == SFF_MODULE_TYPE_INVALID) {
|
||||
AIM_LOG_ERROR("sff_info_init() failed: invalid module type");
|
||||
@@ -429,49 +479,6 @@ sff_info_init(sff_info_t* rv, uint8_t* eeprom)
|
||||
rv->length = -1;
|
||||
}
|
||||
|
||||
const uint8_t *vendor, *model, *serial;
|
||||
|
||||
switch(rv->sfp_type)
|
||||
{
|
||||
case SFF_SFP_TYPE_QSFP_PLUS:
|
||||
case SFF_SFP_TYPE_QSFP28:
|
||||
vendor=rv->eeprom+148;
|
||||
model=rv->eeprom+168;
|
||||
serial=rv->eeprom+196;
|
||||
break;
|
||||
|
||||
case SFF_SFP_TYPE_SFP:
|
||||
default:
|
||||
vendor=rv->eeprom+20;
|
||||
model=rv->eeprom+40;
|
||||
serial=rv->eeprom+68;
|
||||
break;
|
||||
}
|
||||
|
||||
/* handle NULL fields, they should actually be space-padded */
|
||||
const char *empty = " ";
|
||||
if (*vendor) {
|
||||
aim_strlcpy(rv->vendor, (char*)vendor, sizeof(rv->vendor));
|
||||
make_printable__(rv->vendor);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->vendor, empty, 17);
|
||||
}
|
||||
if (*model) {
|
||||
aim_strlcpy(rv->model, (char*)model, sizeof(rv->model));
|
||||
make_printable__(rv->model);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->model, empty, 17);
|
||||
}
|
||||
if (*serial) {
|
||||
aim_strlcpy(rv->serial, (char*)serial, sizeof(rv->serial));
|
||||
make_printable__(rv->serial);
|
||||
}
|
||||
else {
|
||||
aim_strlcpy(rv->serial, empty, 17);
|
||||
}
|
||||
|
||||
if(rv->length == -1) {
|
||||
rv->length_desc[0] = 0;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ aim_map_si_t sff_module_type_map[] =
|
||||
{ "100G_BASE_CR4", SFF_MODULE_TYPE_100G_BASE_CR4 },
|
||||
{ "100G_BASE_SR4", SFF_MODULE_TYPE_100G_BASE_SR4 },
|
||||
{ "100G_BASE_LR4", SFF_MODULE_TYPE_100G_BASE_LR4 },
|
||||
{ "100G_CWDM4", SFF_MODULE_TYPE_100G_CWDM4 },
|
||||
{ "40G_BASE_CR4", SFF_MODULE_TYPE_40G_BASE_CR4 },
|
||||
{ "40G_BASE_SR4", SFF_MODULE_TYPE_40G_BASE_SR4 },
|
||||
{ "40G_BASE_LR4", SFF_MODULE_TYPE_40G_BASE_LR4 },
|
||||
@@ -163,6 +164,7 @@ aim_map_si_t sff_module_type_desc_map[] =
|
||||
{ "100GBASE-CR4", SFF_MODULE_TYPE_100G_BASE_CR4 },
|
||||
{ "100GBASE-SR4", SFF_MODULE_TYPE_100G_BASE_SR4 },
|
||||
{ "100GBASE-LR4", SFF_MODULE_TYPE_100G_BASE_LR4 },
|
||||
{ "100G-CWDM4", SFF_MODULE_TYPE_100G_CWDM4 },
|
||||
{ "40GBASE-CR4", SFF_MODULE_TYPE_40G_BASE_CR4 },
|
||||
{ "40GBASE-SR4", SFF_MODULE_TYPE_40G_BASE_SR4 },
|
||||
{ "40GBASE-LR4", SFF_MODULE_TYPE_40G_BASE_LR4 },
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#
|
||||
# Inclusive Makefile for the sff module.
|
||||
#
|
||||
# Autogenerated 2016-01-07 22:54:29.117990
|
||||
# Autogenerated 2016-03-23 18:28:25.869697
|
||||
#
|
||||
###############################################################################
|
||||
sff_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
@@ -14,7 +14,8 @@ packages:
|
||||
summary: Open Network Linux FIT Loader Image
|
||||
|
||||
files:
|
||||
builds/onl-loader-fit.itb : $$PKG_INSTALL/
|
||||
builds/onl-loader-fit.itb : /etc/onl/upgrade/ppc/
|
||||
builds/manifest.json : /etc/onl/upgrade/ppc/
|
||||
|
||||
changelog: Change changes changes.,
|
||||
|
||||
|
||||
@@ -2,3 +2,4 @@ kernel-*
|
||||
*.itb
|
||||
*.its
|
||||
loader-initrd-powerpc
|
||||
manifest.json
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
include $(ONL)/make/config.powerpc.mk
|
||||
|
||||
.PHONY: onl-loader-fit.itb onl-loader-fit.its
|
||||
|
||||
onl-loader-fit.itb:
|
||||
$(ONL)/tools/flat-image-tree.py --initrd onl-loader-initrd:powerpc,onl-loader-initrd-powerpc.cpio.gz --add-platform initrd --itb $@
|
||||
$(ONLPM) --copy-file onl-loader-initrd:powerpc manifest.json .
|
||||
|
||||
onl-loader-fit.its:
|
||||
$(ONL)/tools/flat-image-tree.py --initrd onl-loader-initrd:powerpc,onl-loader-initrd-powerpc.cpio.gz --add-platform initrd --its $@
|
||||
|
||||
Submodule packages/platforms-closed updated: ca6abea540...51991fb381
@@ -3,3 +3,5 @@ powerpc-accton-as4600-54t-r0:
|
||||
kernel: onl-kernel-3.9.6-powerpc-e500v:powerpc, kernel-3.9.6-powerpc-e500v.bin.gz
|
||||
dtb: onl-kernel-3.9.6-powerpc-e500v:powerpc, powerpc-as4600-54t.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
|
||||
@@ -2,3 +2,6 @@ powerpc-accton-as5610-52x-r0:
|
||||
flat_image_tree:
|
||||
kernel: onl-kernel-3.9.6-powerpc-e500v:powerpc, kernel-3.9.6-powerpc-e500v.bin.gz
|
||||
dtb: onl-kernel-3.9.6-powerpc-e500v:powerpc, powerpc-as5610-52x.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
@@ -3,4 +3,7 @@ powerpc-accton-as5710-54x-r0:
|
||||
kernel: onl-kernel-3.8.13-powerpc-e500mc:powerpc, kernel-3.8.13-powerpc-e500mc.bin.gz
|
||||
dtb: onl-kernel-3.8.13-powerpc-e500mc:powerpc, powerpc-accton-as5710-54x-r0.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
raw: True
|
||||
|
||||
|
||||
@@ -3,4 +3,7 @@ powerpc-accton-as5710-54x-r0b:
|
||||
kernel: onl-kernel-3.8.13-powerpc-e500mc:powerpc, kernel-3.8.13-powerpc-e500mc.bin.gz
|
||||
dtb: onl-kernel-3.8.13-powerpc-e500mc:powerpc, powerpc-accton-as5710-54x-r0b.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
raw: True
|
||||
|
||||
|
||||
@@ -3,4 +3,6 @@ powerpc-accton-as6700-32x-r0:
|
||||
kernel: onl-kernel-3.8.13-powerpc-e500mc:powerpc, kernel-3.8.13-powerpc-e500mc.bin.gz
|
||||
dtb: onl-kernel-3.8.13-powerpc-e500mc:powerpc, powerpc-accton-as6700-32x-r0.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
|
||||
|
||||
@@ -3,4 +3,6 @@ powerpc-accton-as6700-32x-r1:
|
||||
kernel: onl-kernel-3.8.13-powerpc-e500mc:powerpc, kernel-3.8.13-powerpc-e500mc.bin.gz
|
||||
dtb: onl-kernel-3.8.13-powerpc-e500mc:powerpc, powerpc-accton-as6700-32x-r1.dtb
|
||||
|
||||
loader:
|
||||
partition: /dev/sda1
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#define MAX_FAN_SPEED 18000
|
||||
#define MAX_PSU_FAN_SPEED 25500
|
||||
|
||||
#define PROJECT_NAME
|
||||
#define PROJECT_NAME
|
||||
#define LEN_FILE_NAME 80
|
||||
|
||||
#define FAN_RESERVED 0
|
||||
@@ -57,7 +57,7 @@ typedef struct fan_path_S
|
||||
|
||||
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \
|
||||
{ #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \
|
||||
#prj"fan"#id"_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" }
|
||||
#prj"fan_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" }
|
||||
|
||||
#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id)
|
||||
|
||||
@@ -74,8 +74,8 @@ static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_5_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_6_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_PSU(10-0058),
|
||||
MAKE_FAN_PATH_ON_PSU(11-005b)
|
||||
MAKE_FAN_PATH_ON_PSU(11-005b),
|
||||
MAKE_FAN_PATH_ON_PSU(10-0058)
|
||||
};
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
|
||||
@@ -144,7 +144,7 @@ _onlp_fani_info_get_fan_direction(void)
|
||||
for (i = PSU1_ID; i <= PSU2_ID; i++) {
|
||||
psu_type_t psu_type;
|
||||
psu_type = get_psu_type(i, NULL, 0);
|
||||
|
||||
|
||||
if (psu_type == PSU_TYPE_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
@@ -156,47 +156,47 @@ _onlp_fani_info_get_fan_direction(void)
|
||||
return ONLP_FAN_STATUS_B2F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int fd, len, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[65] = {0};
|
||||
|
||||
|
||||
/* get fan fault status (turn on when any one fails)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (atoi(r_data) > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
}
|
||||
|
||||
/* get fan direction (both : the same)
|
||||
/* get fan direction (both : the same)
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan speed (take the min from two speeds)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (info->rpm > atoi(r_data)) {
|
||||
info->rpm = atoi(r_data);
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
|
||||
/* check present */
|
||||
/* check present */
|
||||
if (info->rpm > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
@@ -209,21 +209,21 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
|
||||
char r_data[10] = {0};
|
||||
char fullpath[80] = {0};
|
||||
|
||||
/* get fan direction
|
||||
/* get fan direction
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan fault status
|
||||
/* get fan fault status
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0;
|
||||
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
|
||||
@@ -255,7 +255,7 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
@@ -263,13 +263,13 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
case FAN_5_ON_MAIN_BOARD:
|
||||
case FAN_6_ON_MAIN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
break;
|
||||
default:
|
||||
rc = ONLP_STATUS_E_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -303,20 +303,20 @@ onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
char fullpath[70] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* reject p=0 (p=0, stop fan) */
|
||||
if (p == 0){
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/* get fullpath */
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
|
||||
@@ -165,6 +165,11 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* Diag LED Off
|
||||
*/
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int deviceNodeWriteInt(char *filename, int value, int data_len)
|
||||
char buf[8] = {0};
|
||||
sprintf(buf, "%d", value);
|
||||
|
||||
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
|
||||
return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len);
|
||||
}
|
||||
|
||||
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "x86_64_accton_as7712_32x_log.h"
|
||||
|
||||
#define CHASSIS_FAN_COUNT 6
|
||||
#define CHASSIS_THERMAL_COUNT 3
|
||||
#define CHASSIS_THERMAL_COUNT 5
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
@@ -193,6 +193,11 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
case PSU_TYPE_AC_B2F:
|
||||
ret = psu_ym2651y_info_get(info);
|
||||
break;
|
||||
case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
info->status &= ~ONLP_PSU_STATUS_FAILED;
|
||||
ret = ONLP_STATUS_OK;
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <onlplib/i2c.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
@@ -164,12 +164,6 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
@@ -191,6 +185,34 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
|
||||
@@ -38,11 +38,20 @@
|
||||
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define NUM_OF_THERMAL_ON_MAIN_BROAD 3
|
||||
#define NUM_OF_FAN_ON_MAIN_BROAD 6
|
||||
#define NUM_OF_THERMAL_ON_MAIN_BROAD CHASSIS_THERMAL_COUNT
|
||||
#define NUM_OF_FAN_ON_MAIN_BROAD CHASSIS_FAN_COUNT
|
||||
#define NUM_OF_PSU_ON_MAIN_BROAD 2
|
||||
#define NUM_OF_LED_ON_MAIN_BROAD 5
|
||||
|
||||
#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/"
|
||||
#define NUM_OF_CPLD 3
|
||||
static char arr_cplddev_name[NUM_OF_CPLD][10] =
|
||||
{
|
||||
"4-0060",
|
||||
"5-0062",
|
||||
"6-0064"
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
@@ -65,6 +74,27 @@ onlp_sysi_onie_data_get(uint8_t** data, int* size)
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD]={0};
|
||||
for (i=0; i < NUM_OF_CPLD; i++) {
|
||||
v[i] = 0;
|
||||
if(onlp_file_read_int(v+i, "%s%s/version", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_sysi_oids_get(onlp_oid_t* table, int max)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
***********************************************************/
|
||||
#include <unistd.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <onlplib/file.h>
|
||||
#include <onlp/platformi/thermali.h>
|
||||
#include <fcntl.h>
|
||||
#include "platform_lib.h"
|
||||
@@ -52,6 +53,7 @@
|
||||
enum onlp_thermal_id
|
||||
{
|
||||
THERMAL_RESERVED = 0,
|
||||
THERMAL_CPU_CORE,
|
||||
THERMAL_1_ON_MAIN_BROAD,
|
||||
THERMAL_2_ON_MAIN_BROAD,
|
||||
THERMAL_3_ON_MAIN_BROAD,
|
||||
@@ -59,28 +61,47 @@ enum onlp_thermal_id
|
||||
THERMAL_1_ON_PSU2,
|
||||
};
|
||||
|
||||
static char last_path[][30] = /* must map with onlp_thermal_id */
|
||||
static char* last_path[] = /* must map with onlp_thermal_id */
|
||||
{
|
||||
"reserved",
|
||||
NULL, /* CPU_CORE files */
|
||||
"3-0048/temp1_input",
|
||||
"3-0049/temp1_input",
|
||||
"3-004a/temp1_input",
|
||||
"3-004b/temp1_input",
|
||||
"11-005b/psu_temp1_input",
|
||||
"10-0058/psu_temp1_input",
|
||||
};
|
||||
|
||||
static char* cpu_coretemp_files[] =
|
||||
{
|
||||
"/sys/devices/platform/coretemp.0/temp2_input",
|
||||
"/sys/devices/platform/coretemp.0/temp3_input",
|
||||
"/sys/devices/platform/coretemp.0/temp4_input",
|
||||
"/sys/devices/platform/coretemp.0/temp5_input",
|
||||
NULL,
|
||||
};
|
||||
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "Chassis Thermal Sensor 1", 0},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "tmp75-MAC_up-1-48", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "Chassis Thermal Sensor 2", 0},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "tmp75-MAC_down-2-49", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "Chassis Thermal Sensor 3", 0},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "tmp75-MAC_left-3-4A", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "tmp75-CPU-4-4B", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
@@ -122,14 +143,18 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
|
||||
|
||||
/* get fullpath */
|
||||
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[local_id];
|
||||
|
||||
if(local_id == THERMAL_CPU_CORE) {
|
||||
int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* get fullpath */
|
||||
sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]);
|
||||
|
||||
OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len);
|
||||
info->mcelsius = atoi(r_data) / temp_base;
|
||||
DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius);
|
||||
|
||||
@@ -26,6 +26,7 @@ class OnlPlatform_x86_64_accton_as7712_32x_r0(OnlPlatformAccton):
|
||||
('lm75', 0x48, 3),
|
||||
('lm75', 0x49, 3),
|
||||
('lm75', 0x4a, 3),
|
||||
('lm75', 0x4b, 3),
|
||||
|
||||
('accton_i2c_cpld', 0x60, 4),
|
||||
('accton_i2c_cpld', 0x62, 5),
|
||||
|
||||
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/.gitignore
vendored
Normal file
3
packages/platforms/accton/x86-64/x86-64-accton-as7716-32x/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
*x86*64*accton*as7716*32x*.mk
|
||||
onlpdump.mk
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
@@ -0,0 +1 @@
|
||||
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as7716-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
@@ -0,0 +1,2 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
@@ -0,0 +1,45 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
MODULE := libonlp-x86-64-accton-as7716-32x
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF x86_64_accton_as7716_32x onlplib
|
||||
DEPENDMODULE_HEADERS := sff
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
SHAREDLIB := libonlp-x86-64-accton-as7716-32x.so
|
||||
$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
|
||||
include $(BUILDER)/so.mk
|
||||
.DEFAULT_GOAL := $(SHAREDLIB)
|
||||
|
||||
GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2014 v=onl>
|
||||
#
|
||||
# Copyright 2014 BigSwitch Networks, Inc.
|
||||
#
|
||||
# Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
# either express or implied. See the License for the specific
|
||||
# language governing permissions and limitations under the
|
||||
# License.
|
||||
#
|
||||
# </bsn.cl>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
|
||||
.DEFAULT_GOAL := onlpdump
|
||||
|
||||
MODULE := onlpdump
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM IOF onlp x86_64_accton_as7716_32x onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
|
||||
BINARY := onlpdump
|
||||
$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS)
|
||||
include $(BUILDER)/bin.mk
|
||||
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1
|
||||
GLOBAL_LINK_LIBS += -lpthread -lm
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
include $(ONL)/make/config.mk
|
||||
MODULE := x86_64_accton_as7716_32x
|
||||
AUTOMODULE := x86_64_accton_as7716_32x
|
||||
include $(BUILDER)/definemodule.mk
|
||||
@@ -0,0 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_32x README
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_32x Autogeneration
|
||||
#
|
||||
###############################################################################
|
||||
x86_64_accton_as7716_32x_AUTO_DEFS := module/auto/x86_64_accton_as7716_32x.yml
|
||||
x86_64_accton_as7716_32x_AUTO_DIRS := module/inc/x86_64_accton_as7716_32x module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
###############################################################################
|
||||
#
|
||||
# x86_64_accton_as7716_32x Autogeneration Definitions.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB
|
||||
- x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
- x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION:
|
||||
doc: "Assume chassis fan direction is the same as the PSU fan direction."
|
||||
default: 0
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
x86_64_accton_as7716_32x_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: x86_64_accton_as7716_32x_config
|
||||
|
||||
portingmacro:
|
||||
x86_64_accton_as7716_32x:
|
||||
macros:
|
||||
- malloc
|
||||
- free
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- vsnprintf
|
||||
- snprintf
|
||||
- strlen
|
||||
@@ -0,0 +1,14 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
*
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include <x86_64_accton_as7716_32x/x86_64_accton_as7716_32x_config.h>
|
||||
|
||||
/* <--auto.start.xmacro(ALL).define> */
|
||||
/* <auto.end.xmacro(ALL).define> */
|
||||
|
||||
/* <--auto.start.xenum(ALL).define> */
|
||||
/* <auto.end.xenum(ALL).define> */
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_32x Configuration Header
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_32x-config
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_accton_as7716_32x_CONFIG_H__
|
||||
#define __x86_64_accton_as7716_32x_CONFIG_H__
|
||||
|
||||
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
|
||||
#include <global_custom_config.h>
|
||||
#endif
|
||||
#ifdef x86_64_accton_as7716_32x_INCLUDE_CUSTOM_CONFIG
|
||||
#include <x86_64_accton_as7716_32x_custom_config.h>
|
||||
#endif
|
||||
|
||||
/* <auto.start.cdefs(x86_64_accton_as7716_32x_CONFIG_HEADER).header> */
|
||||
#include <AIM/aim.h>
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING
|
||||
*
|
||||
* Include or exclude logging. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING
|
||||
#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_LOGGING 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
*
|
||||
* Default enabled log options. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT
|
||||
#define x86_64_accton_as7716_32x_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT
|
||||
#define x86_64_accton_as7716_32x_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
*
|
||||
* Default enabled custom log bits. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT
|
||||
#define x86_64_accton_as7716_32x_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB
|
||||
*
|
||||
* Default all porting macros to use the C standard libraries. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB
|
||||
#define x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
*
|
||||
* Include standard library headers for stdlib porting macros. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
|
||||
#define x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI
|
||||
*
|
||||
* Include generic uCli support. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI
|
||||
#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_UCLI 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
*
|
||||
* Assume chassis fan direction is the same as the PSU fan direction. */
|
||||
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
|
||||
#define x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* All compile time options can be queried or displayed
|
||||
*/
|
||||
|
||||
/** Configuration settings structure. */
|
||||
typedef struct x86_64_accton_as7716_32x_config_settings_s {
|
||||
/** name */
|
||||
const char* name;
|
||||
/** value */
|
||||
const char* value;
|
||||
} x86_64_accton_as7716_32x_config_settings_t;
|
||||
|
||||
/** Configuration settings table. */
|
||||
/** x86_64_accton_as7716_32x_config_settings table. */
|
||||
extern x86_64_accton_as7716_32x_config_settings_t x86_64_accton_as7716_32x_config_settings[];
|
||||
|
||||
/**
|
||||
* @brief Lookup a configuration setting.
|
||||
* @param setting The name of the configuration option to lookup.
|
||||
*/
|
||||
const char* x86_64_accton_as7716_32x_config_lookup(const char* setting);
|
||||
|
||||
/**
|
||||
* @brief Show the compile-time configuration.
|
||||
* @param pvs The output stream.
|
||||
*/
|
||||
int x86_64_accton_as7716_32x_config_show(struct aim_pvs_s* pvs);
|
||||
|
||||
/* <auto.end.cdefs(x86_64_accton_as7716_32x_CONFIG_HEADER).header> */
|
||||
|
||||
#include "x86_64_accton_as7716_32x_porting.h"
|
||||
|
||||
#endif /* __x86_64_accton_as7716_32x_CONFIG_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,26 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* x86_64_accton_as7716_32x Doxygen Header
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_accton_as7716_32x_DOX_H__
|
||||
#define __x86_64_accton_as7716_32x_DOX_H__
|
||||
|
||||
/**
|
||||
* @defgroup x86_64_accton_as7716_32x x86_64_accton_as7716_32x - x86_64_accton_as7716_32x Description
|
||||
*
|
||||
|
||||
The documentation overview for this module should go here.
|
||||
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup x86_64_accton_as7716_32x-x86_64_accton_as7716_32x Public Interface
|
||||
* @defgroup x86_64_accton_as7716_32x-config Compile Time Configuration
|
||||
* @defgroup x86_64_accton_as7716_32x-porting Porting Macros
|
||||
*
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
#endif /* __x86_64_accton_as7716_32x_DOX_H__ */
|
||||
@@ -0,0 +1,107 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @file
|
||||
* @brief x86_64_accton_as7716_32x Porting Macros.
|
||||
*
|
||||
* @addtogroup x86_64_accton_as7716_32x-porting
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef __x86_64_accton_as7716_32x_PORTING_H__
|
||||
#define __x86_64_accton_as7716_32x_PORTING_H__
|
||||
|
||||
|
||||
/* <auto.start.portingmacro(ALL).define> */
|
||||
#if x86_64_accton_as7716_32x_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <memory.h>
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_MALLOC
|
||||
#if defined(GLOBAL_MALLOC)
|
||||
#define x86_64_accton_as7716_32x_MALLOC GLOBAL_MALLOC
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_MALLOC malloc
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_MALLOC is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_FREE
|
||||
#if defined(GLOBAL_FREE)
|
||||
#define x86_64_accton_as7716_32x_FREE GLOBAL_FREE
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_FREE free
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_FREE is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_MEMSET
|
||||
#if defined(GLOBAL_MEMSET)
|
||||
#define x86_64_accton_as7716_32x_MEMSET GLOBAL_MEMSET
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_MEMSET memset
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_MEMSET is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_MEMCPY
|
||||
#if defined(GLOBAL_MEMCPY)
|
||||
#define x86_64_accton_as7716_32x_MEMCPY GLOBAL_MEMCPY
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_MEMCPY memcpy
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_MEMCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_STRNCPY
|
||||
#if defined(GLOBAL_STRNCPY)
|
||||
#define x86_64_accton_as7716_32x_STRNCPY GLOBAL_STRNCPY
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_STRNCPY strncpy
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_STRNCPY is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_VSNPRINTF
|
||||
#if defined(GLOBAL_VSNPRINTF)
|
||||
#define x86_64_accton_as7716_32x_VSNPRINTF GLOBAL_VSNPRINTF
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_VSNPRINTF vsnprintf
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_VSNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_SNPRINTF
|
||||
#if defined(GLOBAL_SNPRINTF)
|
||||
#define x86_64_accton_as7716_32x_SNPRINTF GLOBAL_SNPRINTF
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_SNPRINTF snprintf
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_SNPRINTF is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef x86_64_accton_as7716_32x_STRLEN
|
||||
#if defined(GLOBAL_STRLEN)
|
||||
#define x86_64_accton_as7716_32x_STRLEN GLOBAL_STRLEN
|
||||
#elif x86_64_accton_as7716_32x_CONFIG_PORTING_STDLIB == 1
|
||||
#define x86_64_accton_as7716_32x_STRLEN strlen
|
||||
#else
|
||||
#error The macro x86_64_accton_as7716_32x_STRLEN is required but cannot be defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* <auto.end.portingmacro(ALL).define> */
|
||||
|
||||
|
||||
#endif /* __x86_64_accton_as7716_32x_PORTING_H__ */
|
||||
/* @} */
|
||||
@@ -0,0 +1,10 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
x86_64_accton_as7716_32x_INCLUDES := -I $(THIS_DIR)inc
|
||||
x86_64_accton_as7716_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
x86_64_accton_as7716_32x_DEPENDMODULE_ENTRIES := init:x86_64_accton_as7716_32x ucli:x86_64_accton_as7716_32x
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Local source generation targets.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
ucli:
|
||||
@../../../../tools/uclihandlers.py x86_64_accton_as7716_32x_ucli.c
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "x86_64_accton_as7716_32x_int.h"
|
||||
|
||||
#if x86_64_accton_as7716_32x_CONFIG_INCLUDE_DEBUG == 1
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
static char help__[] =
|
||||
"Usage: debug [options]\n"
|
||||
" -c CPLD Versions\n"
|
||||
" -h Help\n"
|
||||
;
|
||||
|
||||
int
|
||||
x86_64_accton_as7716_32x_debug_main(int argc, char* argv[])
|
||||
{
|
||||
int c = 0;
|
||||
int help = 0;
|
||||
int rv = 0;
|
||||
|
||||
while( (c = getopt(argc, argv, "ch")) != -1) {
|
||||
switch(c)
|
||||
{
|
||||
case 'c': c = 1; break;
|
||||
case 'h': help = 1; rv = 0; break;
|
||||
default: help = 1; rv = 1; break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(help || argc == 1) {
|
||||
printf("%s", help__);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if(c) {
|
||||
printf("Not implemented.\n");
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,393 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
* Fan Platform Implementation Defaults.
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/fani.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <fcntl.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PREFIX_PATH_ON_MAIN_BOARD "/sys/bus/i2c/devices/9-0066/"
|
||||
#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/"
|
||||
|
||||
#define MAX_FAN_SPEED 18000
|
||||
#define MAX_PSU_FAN_SPEED 25500
|
||||
|
||||
#define PROJECT_NAME
|
||||
#define LEN_FILE_NAME 80
|
||||
|
||||
#define FAN_RESERVED 0
|
||||
#define FAN_1_ON_MAIN_BOARD 1
|
||||
#define FAN_2_ON_MAIN_BOARD 2
|
||||
#define FAN_3_ON_MAIN_BOARD 3
|
||||
#define FAN_4_ON_MAIN_BOARD 4
|
||||
#define FAN_5_ON_MAIN_BOARD 5
|
||||
#define FAN_6_ON_MAIN_BOARD 6
|
||||
#define FAN_1_ON_PSU1 7
|
||||
#define FAN_1_ON_PSU2 8
|
||||
|
||||
typedef struct fan_path_S
|
||||
{
|
||||
char present[LEN_FILE_NAME];
|
||||
char status[LEN_FILE_NAME];
|
||||
char speed[LEN_FILE_NAME];
|
||||
char ctrl_speed[LEN_FILE_NAME];
|
||||
char r_speed[LEN_FILE_NAME];
|
||||
}fan_path_T;
|
||||
|
||||
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) \
|
||||
{ #prj"fan"#id"_present", #prj"fan"#id"_fault", #prj"fan"#id"_front_speed_rpm", \
|
||||
#prj"fan"#id"_duty_cycle_percentage", #prj"fan"#id"_rear_speed_rpm" }
|
||||
|
||||
#define MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id) _MAKE_FAN_PATH_ON_MAIN_BOARD(prj,id)
|
||||
|
||||
#define MAKE_FAN_PATH_ON_PSU(folder) \
|
||||
{#folder"/psu_fan1_fault", #folder"/psu_fan1_speed_rpm", \
|
||||
#folder"/psu_fan1_duty_cycle_percentage", "" }
|
||||
|
||||
static fan_path_T fan_path[] = /* must map with onlp_fan_id */
|
||||
{
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_RESERVED),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_1_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_2_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_3_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_4_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_5_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_6_ON_MAIN_BOARD),
|
||||
MAKE_FAN_PATH_ON_PSU(18-005b),
|
||||
MAKE_FAN_PATH_ON_PSU(17-0058)
|
||||
};
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
}
|
||||
|
||||
#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \
|
||||
{ \
|
||||
{ ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \
|
||||
0x0, \
|
||||
(ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \
|
||||
0, \
|
||||
0, \
|
||||
ONLP_FAN_MODE_INVALID, \
|
||||
}
|
||||
|
||||
/* Static fan information */
|
||||
onlp_fan_info_t linfo[] = {
|
||||
{ }, /* Not used */
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5),
|
||||
MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6),
|
||||
MAKE_FAN_INFO_NODE_ON_PSU(1,1),
|
||||
MAKE_FAN_INFO_NODE_ON_PSU(2,1),
|
||||
};
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define OPEN_READ_FILE(fd,fullpath,data,nbytes,len) \
|
||||
DEBUG_PRINT("[Debug][%s][%d][openfile: %s]\n", __FUNCTION__, __LINE__, fullpath); \
|
||||
if ((fd = open(fullpath, O_RDONLY)) == -1) \
|
||||
return ONLP_STATUS_E_INTERNAL; \
|
||||
if ((len = read(fd, r_data, nbytes)) <= 0){ \
|
||||
close(fd); \
|
||||
return ONLP_STATUS_E_INTERNAL;} \
|
||||
DEBUG_PRINT("[Debug][%s][%d][read data: %s]\n", __FUNCTION__, __LINE__, r_data); \
|
||||
if (close(fd) == -1) \
|
||||
return ONLP_STATUS_E_INTERNAL
|
||||
|
||||
/* There is no CPLD register for reading fan direction on this platform,
|
||||
* to read fan direction, we need to read from PSU-fan,
|
||||
* the direction of PSU-fan and chassis-fan are the same.
|
||||
*/
|
||||
static uint32_t
|
||||
_onlp_fani_info_get_fan_direction(void)
|
||||
{
|
||||
/* Try to read direction from PSU1.
|
||||
* If PSU1 is not valid, read from PSU2
|
||||
*/
|
||||
int i = 0;
|
||||
|
||||
for (i = PSU1_ID; i <= PSU2_ID; i++) {
|
||||
psu_type_t psu_type;
|
||||
psu_type = get_psu_type(i, NULL, 0);
|
||||
|
||||
if (psu_type == PSU_TYPE_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (PSU_TYPE_AC_F2B == psu_type) {
|
||||
return ONLP_FAN_STATUS_F2B;
|
||||
}
|
||||
else {
|
||||
return ONLP_FAN_STATUS_B2F;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int fd, len, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[65] = {0};
|
||||
|
||||
/* check if fan is present
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].present);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (atoi(r_data) == 0) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
/* get fan fault status (turn on when any one fails)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (atoi(r_data) > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* get fan direction (both : the same)
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan speed (take the min from two speeds)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (info->rpm > atoi(r_data)) {
|
||||
info->rpm = atoi(r_data);
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int fd, len, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[80] = {0};
|
||||
|
||||
/* get fan direction
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan fault status
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0;
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rc = 0;
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
*info = linfo[local_id];
|
||||
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
case FAN_3_ON_MAIN_BOARD:
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
case FAN_5_ON_MAIN_BOARD:
|
||||
case FAN_6_ON_MAIN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
break;
|
||||
default:
|
||||
rc = ONLP_STATUS_E_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the speed of the given fan in RPM.
|
||||
*
|
||||
* This function will only be called if the fan supprots the RPM_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_rpm_set(onlp_oid_t id, int rpm)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
int fd, len, nbytes=10, local_id;
|
||||
char data[10] = {0};
|
||||
char fullpath[70] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* reject p=0 (p=0, stop fan) */
|
||||
if (p == 0){
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
/* get fullpath */
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
case FAN_3_ON_MAIN_BOARD:
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
case FAN_5_ON_MAIN_BOARD:
|
||||
case FAN_6_ON_MAIN_BOARD:
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].ctrl_speed);
|
||||
break;
|
||||
default:
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
sprintf(data, "%d", p);
|
||||
DEBUG_PRINT("[Debug][%s][%d][openfile: %s][data=%s]\n", __FUNCTION__, __LINE__, fullpath, data);
|
||||
|
||||
/* Create output file descriptor */
|
||||
fd = open(fullpath, O_WRONLY, 0644);
|
||||
if (fd == -1){
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
len = write (fd, data, (ssize_t) nbytes);
|
||||
if (len != nbytes) {
|
||||
close(fd);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as per
|
||||
* the predefined ONLP fan speed modes: off, slow, normal, fast, max.
|
||||
*
|
||||
* Interpretation of these modes is up to the platform.
|
||||
*
|
||||
*/
|
||||
int
|
||||
onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan direction of the given OID.
|
||||
*
|
||||
* This function is only relevant if the fan OID supports both direction
|
||||
* capabilities.
|
||||
*
|
||||
* This function is optional unless the functionality is available.
|
||||
*/
|
||||
int
|
||||
onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic fan ioctl. Optional.
|
||||
*/
|
||||
int
|
||||
onlp_fani_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/ledi.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <onlplib/mmap.h>
|
||||
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define prefix_path "/sys/class/leds/accton_as7716_32x_led::"
|
||||
#define filename "brightness"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
enum onlp_led_id
|
||||
{
|
||||
LED_RESERVED = 0,
|
||||
LED_DIAG,
|
||||
LED_LOC,
|
||||
LED_FAN,
|
||||
LED_PSU1,
|
||||
LED_PSU2
|
||||
};
|
||||
|
||||
enum led_light_mode {
|
||||
LED_MODE_OFF = 0,
|
||||
LED_MODE_GREEN,
|
||||
LED_MODE_AMBER,
|
||||
LED_MODE_RED,
|
||||
LED_MODE_BLUE,
|
||||
LED_MODE_GREEN_BLINK,
|
||||
LED_MODE_AMBER_BLINK,
|
||||
LED_MODE_RED_BLINK,
|
||||
LED_MODE_BLUE_BLINK,
|
||||
LED_MODE_AUTO,
|
||||
LED_MODE_UNKNOWN
|
||||
};
|
||||
|
||||
typedef struct led_light_mode_map {
|
||||
enum onlp_led_id id;
|
||||
enum led_light_mode driver_led_mode;
|
||||
enum onlp_led_mode_e onlp_led_mode;
|
||||
} led_light_mode_map_t;
|
||||
|
||||
led_light_mode_map_t led_map[] = {
|
||||
{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
|
||||
{LED_DIAG, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE},
|
||||
{LED_DIAG, LED_MODE_RED, ONLP_LED_MODE_RED},
|
||||
{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF},
|
||||
{LED_LOC, LED_MODE_BLUE, ONLP_LED_MODE_BLUE},
|
||||
{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO},
|
||||
{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}
|
||||
};
|
||||
|
||||
static char last_path[][10] = /* must map with onlp_led_id */
|
||||
{
|
||||
"reserved",
|
||||
"diag",
|
||||
"loc",
|
||||
"fan",
|
||||
"psu1",
|
||||
"psu2"
|
||||
};
|
||||
|
||||
/*
|
||||
* Get the information for the given LED OID.
|
||||
*/
|
||||
static onlp_led_info_t linfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 1 (DIAG LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED | ONLP_LED_CAPS_ORANGE,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 2 (LOC LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 3 (FAN LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 4 (PSU1 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
ONLP_LED_CAPS_AUTO,
|
||||
},
|
||||
};
|
||||
|
||||
static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for (i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode)
|
||||
{
|
||||
return led_map[i].onlp_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
|
||||
{
|
||||
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
|
||||
|
||||
for(i = 0; i < nsize; i++)
|
||||
{
|
||||
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
|
||||
{
|
||||
return led_map[i].driver_led_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int local_id;
|
||||
char data[2] = {0};
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* get fullpath */
|
||||
sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[ONLP_OID_ID_GET(id)];
|
||||
|
||||
/* Set LED mode */
|
||||
if (deviceNodeReadString(fullpath, data, sizeof(data), 0) != 0) {
|
||||
DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
info->mode = driver_to_onlp_led_mode(local_id, atoi(data));
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
VALIDATE(id);
|
||||
|
||||
if (!on_or_off) {
|
||||
return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function puts the LED into the given mode. It is a more functional
|
||||
* interface for multimode LEDs.
|
||||
*
|
||||
* Only modes reported in the LED's capabilities will be attempted.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int local_id;
|
||||
char fullpath[50] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
sprintf(fullpath, "%s%s/%s", prefix_path, last_path[local_id], filename);
|
||||
|
||||
if (deviceNodeWriteInt(fullpath, onlp_to_driver_led_mode(local_id, mode), 0) != 0)
|
||||
{
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
###############################################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
LIBRARY := x86_64_accton_as7716_32x
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/lib.mk
|
||||
@@ -0,0 +1,157 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <AIM/aim.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
int deviceNodeWrite(char *filename, char *buffer, int buf_size, int data_len)
|
||||
{
|
||||
int fd;
|
||||
int len;
|
||||
|
||||
if ((buffer == NULL) || (buf_size < 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_WRONLY, S_IWUSR)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((len = write(fd, buffer, buf_size)) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((close(fd) == -1)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((len > buf_size) || (data_len != 0 && len != data_len)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deviceNodeWriteInt(char *filename, int value, int data_len)
|
||||
{
|
||||
char buf[8] = {0};
|
||||
sprintf(buf, "%d", value);
|
||||
|
||||
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
|
||||
}
|
||||
|
||||
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)
|
||||
{
|
||||
int fd;
|
||||
int len;
|
||||
|
||||
if ((buffer == NULL) || (buf_size < 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((len = read(fd, buffer, buf_size)) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((close(fd) == -1)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((len > buf_size) || (data_len != 0 && len != data_len)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_len)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (data_len >= buf_size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = deviceNodeReadBinary(filename, buffer, buf_size-1, data_len);
|
||||
|
||||
if (ret == 0) {
|
||||
buffer[buf_size-1] = '\0';
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define I2C_PSU_MODEL_NAME_LEN 9
|
||||
#define I2C_PSU_FAN_DIR_LEN 3
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len)
|
||||
{
|
||||
char *node = NULL;
|
||||
char model_name[I2C_PSU_MODEL_NAME_LEN + 1] = {0};
|
||||
char fan_dir[I2C_PSU_FAN_DIR_LEN + 1] = {0};
|
||||
|
||||
/* Check AC model name */
|
||||
node = (id == PSU1_ID) ? PSU1_AC_HWMON_NODE(psu_model_name) : PSU2_AC_HWMON_NODE(psu_model_name);
|
||||
|
||||
if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) != 0) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (strncmp(model_name, "YM-2651Y", strlen("YM-2651Y")) != 0) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (modelname) {
|
||||
strncpy(modelname, model_name, modelname_len-1);
|
||||
}
|
||||
|
||||
node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir);
|
||||
|
||||
if (deviceNodeReadString(node, fan_dir, sizeof(fan_dir), 0) != 0) {
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) {
|
||||
return PSU_TYPE_AC_F2B;
|
||||
}
|
||||
|
||||
if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) {
|
||||
return PSU_TYPE_AC_B2F;
|
||||
}
|
||||
|
||||
return PSU_TYPE_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#ifndef __PLATFORM_LIB_H__
|
||||
#define __PLATFORM_LIB_H__
|
||||
|
||||
#include "x86_64_accton_as7716_32x_log.h"
|
||||
|
||||
#define CHASSIS_FAN_COUNT 6
|
||||
#define CHASSIS_THERMAL_COUNT 3
|
||||
|
||||
#define PSU1_ID 1
|
||||
#define PSU2_ID 2
|
||||
|
||||
#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/18-005b/"
|
||||
#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0058/"
|
||||
|
||||
#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node
|
||||
#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node
|
||||
|
||||
#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/18-0053/"
|
||||
#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/17-0050/"
|
||||
|
||||
#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node
|
||||
#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node
|
||||
|
||||
#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom"
|
||||
|
||||
int deviceNodeWriteInt(char *filename, int value, int data_len);
|
||||
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len);
|
||||
int deviceNodeReadString(char *filename, char *buffer, int buf_size, int data_len);
|
||||
|
||||
typedef enum psu_type {
|
||||
PSU_TYPE_UNKNOWN,
|
||||
PSU_TYPE_AC_F2B,
|
||||
PSU_TYPE_AC_B2F
|
||||
} psu_type_t;
|
||||
|
||||
psu_type_t get_psu_type(int id, char* modelname, int modelname_len);
|
||||
|
||||
#define DEBUG_MODE 0
|
||||
|
||||
#if (DEBUG_MODE == 1)
|
||||
#define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT(format, ...)
|
||||
#endif
|
||||
|
||||
#endif /* __PLATFORM_LIB_H__ */
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
* Copyright 2014 Big Switch Networks, Inc.
|
||||
* Copyright 2014 Accton Technology Corporation.
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*
|
||||
* </bsn.cl>
|
||||
************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
***********************************************************/
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlplib/mmap.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define PSU_STATUS_PRESENT 1
|
||||
#define PSU_STATUS_POWER_GOOD 1
|
||||
|
||||
#define PSU_NODE_MAX_INT_LEN 8
|
||||
#define PSU_NODE_MAX_PATH_LEN 64
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static int
|
||||
psu_status_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
if (PSU1_ID == id) {
|
||||
sprintf(node_path, "%s%s", PSU1_AC_HWMON_PREFIX, node);
|
||||
}
|
||||
else if (PSU2_ID == id) {
|
||||
sprintf(node_path, "%s%s", PSU2_AC_HWMON_PREFIX, node);
|
||||
}
|
||||
|
||||
ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0);
|
||||
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_ym2651y_pmbus_info_get(int id, char *node, int *value)
|
||||
{
|
||||
int ret = 0;
|
||||
char buf[PSU_NODE_MAX_INT_LEN + 1] = {0};
|
||||
char node_path[PSU_NODE_MAX_PATH_LEN] = {0};
|
||||
|
||||
*value = 0;
|
||||
|
||||
if (PSU1_ID == id) {
|
||||
sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node);
|
||||
}
|
||||
else {
|
||||
sprintf(node_path, "%s%s", PSU2_AC_PMBUS_PREFIX, node);
|
||||
}
|
||||
|
||||
ret = deviceNodeReadString(node_path, buf, sizeof(buf), 0);
|
||||
|
||||
if (ret == 0) {
|
||||
*value = atoi(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
psu_ym2651y_info_get(onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int index = ONLP_OID_ID_GET(info->hdr.id);
|
||||
|
||||
/* Set capability
|
||||
*/
|
||||
info->caps = ONLP_PSU_CAPS_AC;
|
||||
|
||||
if (info->status & ONLP_PSU_STATUS_FAILED) {
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/* Set the associated oid_table */
|
||||
info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT);
|
||||
info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT);
|
||||
|
||||
/* Read voltage, current and power */
|
||||
if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) {
|
||||
info->mvout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_VOUT;
|
||||
}
|
||||
|
||||
if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) {
|
||||
info->miout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_IOUT;
|
||||
}
|
||||
|
||||
if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) {
|
||||
info->mpout = val;
|
||||
info->caps |= ONLP_PSU_CAPS_POUT;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get all information about the given PSU oid.
|
||||
*/
|
||||
static onlp_psu_info_t pinfo[] =
|
||||
{
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 },
|
||||
},
|
||||
{
|
||||
{ ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 },
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int val = 0;
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int index = ONLP_OID_ID_GET(id);
|
||||
psu_type_t psu_type;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
memset(info, 0, sizeof(onlp_psu_info_t));
|
||||
*info = pinfo[index]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
/* Get the present state */
|
||||
if (psu_status_info_get(index, "psu_present", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_present)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_PRESENT) {
|
||||
info->status &= ~ONLP_PSU_STATUS_PRESENT;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
info->status |= ONLP_PSU_STATUS_PRESENT;
|
||||
|
||||
|
||||
/* Get power good status */
|
||||
if (psu_status_info_get(index, "psu_power_good", &val) != 0) {
|
||||
printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index);
|
||||
}
|
||||
|
||||
if (val != PSU_STATUS_POWER_GOOD) {
|
||||
info->status |= ONLP_PSU_STATUS_FAILED;
|
||||
}
|
||||
|
||||
|
||||
/* Get PSU type
|
||||
*/
|
||||
psu_type = get_psu_type(index, info->model, sizeof(info->model));
|
||||
|
||||
switch (psu_type) {
|
||||
case PSU_TYPE_AC_F2B:
|
||||
case PSU_TYPE_AC_B2F:
|
||||
ret = psu_ym2651y_info_get(info);
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user