Add platform minipack.

CPU: Broadwell D1527.
    MAC: BCM tomhwak3.
    Port: 128x100Gbe
Signed-off-by: roylee123 <roy_lee@accton.com>
This commit is contained in:
roylee123
2018-12-10 14:50:41 +08:00
parent e885ccba45
commit 62d9290667
41 changed files with 2333 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
*x86*64*accton*minipack*.mk
onlpdump.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk

View File

@@ -0,0 +1 @@
!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-minipack

View File

@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk

View File

@@ -0,0 +1 @@
!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-minipack ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu

View File

@@ -0,0 +1,2 @@
FILTER=src
include $(ONL)/make/subdirs.mk

View File

@@ -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-minipack
include $(BUILDER)/standardinit.mk
DEPENDMODULES := AIM IOF x86_64_accton_minipack onlplib
DEPENDMODULE_HEADERS := sff
include $(BUILDER)/dependmodules.mk
SHAREDLIB := libonlp-x86-64-accton-minipack.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

View File

@@ -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_minipack 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

View File

@@ -0,0 +1 @@
name: x86_64_accton_minipack

View File

@@ -0,0 +1,9 @@
###############################################################################
#
#
#
###############################################################################
include ../../init.mk
MODULE := x86_64_accton_minipack
AUTOMODULE := x86_64_accton_minipack
include $(BUILDER)/definemodule.mk

View File

@@ -0,0 +1,6 @@
###############################################################################
#
# x86_64_accton_minipack README
#
###############################################################################

View File

@@ -0,0 +1,9 @@
###############################################################################
#
# x86_64_accton_minipack Autogeneration
#
###############################################################################
x86_64_accton_minipack_AUTO_DEFS := module/auto/x86_64_accton_minipack.yml
x86_64_accton_minipack_AUTO_DIRS := module/inc/x86_64_accton_minipack module/src
include $(BUILDER)/auto.mk

View File

@@ -0,0 +1,50 @@
###############################################################################
#
# X86_64_ACCTON_MINIPACK Autogeneration Definitions.
#
###############################################################################
cdefs: &cdefs
- X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING:
doc: "Include or exclude logging."
default: 1
- X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT:
doc: "Default enabled log options."
default: AIM_LOG_OPTIONS_DEFAULT
- X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT:
doc: "Default enabled log bits."
default: AIM_LOG_BITS_DEFAULT
- X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
doc: "Default enabled custom log bits."
default: 0
- X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB:
doc: "Default all porting macros to use the C standard libraries."
default: 1
- X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
doc: "Include standard library headers for stdlib porting macros."
default: X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB
- X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI:
doc: "Include generic uCli support."
default: 0
- X86_64_ACCTON_MINIPACK_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_MINIPACK_CONFIG_HEADER:
defs: *cdefs
basename: x86_64_accton_minipack_config
portingmacro:
X86_64_ACCTON_MINIPACK:
macros:
- malloc
- free
- memset
- memcpy
- strncpy
- vsnprintf
- snprintf
- strlen

View File

@@ -0,0 +1,14 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
/* <--auto.start.xmacro(ALL).define> */
/* <auto.end.xmacro(ALL).define> */
/* <--auto.start.xenum(ALL).define> */
/* <auto.end.xenum(ALL).define> */

View File

@@ -0,0 +1,137 @@
/**************************************************************************//**
*
* @file
* @brief x86_64_accton_minipack Configuration Header
*
* @addtogroup x86_64_accton_minipack-config
* @{
*
*****************************************************************************/
#ifndef __X86_64_ACCTON_MINIPACK_CONFIG_H__
#define __X86_64_ACCTON_MINIPACK_CONFIG_H__
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
#include <global_custom_config.h>
#endif
#ifdef X86_64_ACCTON_MINIPACK_INCLUDE_CUSTOM_CONFIG
#include <x86_64_accton_minipack_custom_config.h>
#endif
/* <auto.start.cdefs(X86_64_ACCTON_MINIPACK_CONFIG_HEADER).header> */
#include <AIM/aim.h>
/**
* X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING
*
* Include or exclude logging. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING
#define X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING 1
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT
*
* Default enabled log options. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT
#define X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT
*
* Default enabled log bits. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT
#define X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT
*
* Default enabled custom log bits. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT
#define X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB
*
* Default all porting macros to use the C standard libraries. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB
#define X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB 1
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
*
* Include standard library headers for stdlib porting macros. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
#define X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI
*
* Include generic uCli support. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI
#define X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI 0
#endif
/**
* X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
*
* Assume chassis fan direction is the same as the PSU fan direction. */
#ifndef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
#define X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0
#endif
/**
* All compile time options can be queried or displayed
*/
/** Configuration settings structure. */
typedef struct x86_64_accton_minipack_config_settings_s {
/** name */
const char* name;
/** value */
const char* value;
} x86_64_accton_minipack_config_settings_t;
/** Configuration settings table. */
/** x86_64_accton_minipack_config_settings table. */
extern x86_64_accton_minipack_config_settings_t x86_64_accton_minipack_config_settings[];
/**
* @brief Lookup a configuration setting.
* @param setting The name of the configuration option to lookup.
*/
const char* x86_64_accton_minipack_config_lookup(const char* setting);
/**
* @brief Show the compile-time configuration.
* @param pvs The output stream.
*/
int x86_64_accton_minipack_config_show(struct aim_pvs_s* pvs);
/* <auto.end.cdefs(X86_64_ACCTON_MINIPACK_CONFIG_HEADER).header> */
#include "x86_64_accton_minipack_porting.h"
#endif /* __X86_64_ACCTON_MINIPACK_CONFIG_H__ */
/* @} */

View File

@@ -0,0 +1,26 @@
/**************************************************************************//**
*
* x86_64_accton_minipack Doxygen Header
*
*****************************************************************************/
#ifndef __X86_64_ACCTON_MINIPACK_DOX_H__
#define __X86_64_ACCTON_MINIPACK_DOX_H__
/**
* @defgroup x86_64_accton_minipack x86_64_accton_minipack - x86_64_accton_minipack Description
*
The documentation overview for this module should go here.
*
* @{
*
* @defgroup x86_64_accton_minipack-x86_64_accton_minipack Public Interface
* @defgroup x86_64_accton_minipack-config Compile Time Configuration
* @defgroup x86_64_accton_minipack-porting Porting Macros
*
* @}
*
*/
#endif /* __X86_64_ACCTON_MINIPACK_DOX_H__ */

View File

@@ -0,0 +1,107 @@
/**************************************************************************//**
*
* @file
* @brief x86_64_accton_minipack Porting Macros.
*
* @addtogroup x86_64_accton_minipack-porting
* @{
*
*****************************************************************************/
#ifndef __X86_64_ACCTON_MINIPACK_PORTING_H__
#define __X86_64_ACCTON_MINIPACK_PORTING_H__
/* <auto.start.portingmacro(ALL).define> */
#if X86_64_ACCTON_MINIPACK_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_minipack_MALLOC
#if defined(GLOBAL_MALLOC)
#define x86_64_accton_minipack_MALLOC GLOBAL_MALLOC
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_MALLOC malloc
#else
#error The macro x86_64_accton_minipack_MALLOC is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_FREE
#if defined(GLOBAL_FREE)
#define x86_64_accton_minipack_FREE GLOBAL_FREE
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_FREE free
#else
#error The macro x86_64_accton_minipack_FREE is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_MEMSET
#if defined(GLOBAL_MEMSET)
#define x86_64_accton_minipack_MEMSET GLOBAL_MEMSET
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_MEMSET memset
#else
#error The macro x86_64_accton_minipack_MEMSET is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_MEMCPY
#if defined(GLOBAL_MEMCPY)
#define x86_64_accton_minipack_MEMCPY GLOBAL_MEMCPY
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_MEMCPY memcpy
#else
#error The macro x86_64_accton_minipack_MEMCPY is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_STRNCPY
#if defined(GLOBAL_STRNCPY)
#define x86_64_accton_minipack_STRNCPY GLOBAL_STRNCPY
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_STRNCPY strncpy
#else
#error The macro x86_64_accton_minipack_STRNCPY is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_VSNPRINTF
#if defined(GLOBAL_VSNPRINTF)
#define x86_64_accton_minipack_VSNPRINTF GLOBAL_VSNPRINTF
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_VSNPRINTF vsnprintf
#else
#error The macro x86_64_accton_minipack_VSNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_SNPRINTF
#if defined(GLOBAL_SNPRINTF)
#define x86_64_accton_minipack_SNPRINTF GLOBAL_SNPRINTF
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_SNPRINTF snprintf
#else
#error The macro x86_64_accton_minipack_SNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef x86_64_accton_minipack_STRLEN
#if defined(GLOBAL_STRLEN)
#define x86_64_accton_minipack_STRLEN GLOBAL_STRLEN
#elif X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB == 1
#define x86_64_accton_minipack_STRLEN strlen
#else
#error The macro x86_64_accton_minipack_STRLEN is required but cannot be defined.
#endif
#endif
/* <auto.end.portingmacro(ALL).define> */
#endif /* __X86_64_ACCTON_MINIPACK_PORTING_H__ */
/* @} */

View File

@@ -0,0 +1,10 @@
###############################################################################
#
#
#
###############################################################################
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
x86_64_accton_minipack_INCLUDES := -I $(THIS_DIR)inc
x86_64_accton_minipack_INTERNAL_INCLUDES := -I $(THIS_DIR)src
x86_64_accton_minipack_DEPENDMODULE_ENTRIES := init:x86_64_accton_minipack ucli:x86_64_accton_minipack

View File

@@ -0,0 +1,9 @@
###############################################################################
#
# Local source generation targets.
#
###############################################################################
ucli:
@../../../../tools/uclihandlers.py x86_64_accton_minipack_ucli.c

View File

@@ -0,0 +1,222 @@
/************************************************************
* <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 <onlplib/file.h>
#include <onlp/platformi/fani.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_FAN(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
#define MAX_FAN_SPEED 15400
#define BIT(i) (1 << (i))
enum fan_id {
FAN_1_ON_FAN_BOARD = 1,
FAN_2_ON_FAN_BOARD,
FAN_3_ON_FAN_BOARD,
FAN_4_ON_FAN_BOARD,
FAN_5_ON_FAN_BOARD,
};
#define FAN_BOARD_PATH "/sys/bus/i2c/devices/8-0033/"
#define CHASSIS_FAN_INFO(fid) \
{ \
{ ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 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 finfo[] = {
{ }, /* Not used */
CHASSIS_FAN_INFO(1),
CHASSIS_FAN_INFO(2),
CHASSIS_FAN_INFO(3),
CHASSIS_FAN_INFO(4),
CHASSIS_FAN_INFO(5)
};
/*
* 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 value = 0, fid;
char path[64] = {0};
VALIDATE(id);
fid = ONLP_OID_ID_GET(id);
*info = finfo[fid];
/* get fan present status
*/
sprintf(path, "%s""fantray_present", FAN_BOARD_PATH);
if (bmc_file_read_int(&value, path, 16) < 0) {
AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path);
return ONLP_STATUS_E_INTERNAL;
}
if (value & BIT(fid-1)) {
return ONLP_STATUS_OK;
}
info->status |= ONLP_FAN_STATUS_PRESENT;
/* get front fan rpm
*/
sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2 - 1);
if (bmc_file_read_int(&value, path, 10) < 0) {
AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path);
return ONLP_STATUS_E_INTERNAL;
}
info->rpm = value;
/* get rear fan rpm
*/
sprintf(path, "%s""fan%d_input", FAN_BOARD_PATH, fid*2);
if (bmc_file_read_int(&value, path, 10) < 0) {
AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path);
return ONLP_STATUS_E_INTERNAL;
}
/* take the min value from front/rear fan speed
*/
if (info->rpm > value) {
info->rpm = value;
}
/* set fan status based on rpm
*/
if (!info->rpm) {
info->status |= ONLP_FAN_STATUS_FAILED;
return ONLP_STATUS_OK;
}
/* get speed percentage from rpm
*/
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
/* set fan direction
*/
info->status |= ONLP_FAN_STATUS_F2B;
return ONLP_STATUS_OK;
}
/*
* 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)
{
char cmd[32] = {0};
sprintf(cmd, "set_fan_speed.sh %d", p);
if (bmc_send_command(cmd) < 0) {
AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd);
return ONLP_STATUS_E_INTERNAL;
}
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;
}

View File

@@ -0,0 +1,220 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014 Big Switch Networks, Inc.
* Copyright 2013 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 <onlplib/i2c.h>
#include <onlplib/file.h>
#include <onlp/platformi/ledi.h>
#include "platform_lib.h"
#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_SYS1,
LED_SYS2
};
typedef struct led_address_s {
enum onlp_led_id id;
uint8_t bus;
uint8_t devaddr;
uint8_t offset;
} led_address_t;
typedef struct led_mode_info_s {
onlp_led_mode_t mode;
uint8_t regval;
} led_mode_info_t;
static led_address_t led_addr[] =
{
{ }, /* Not used */
{LED_SYS1, 1, 0x32, 0x3e},
{LED_SYS2, 1, 0x32, 0x3f},
};
static led_mode_info_t led_mode_info[] =
{
{ONLP_LED_MODE_OFF, 0x0},
{ONLP_LED_MODE_OFF, 0x8},
{ONLP_LED_MODE_BLUE, 0x1},
{ONLP_LED_MODE_BLUE_BLINKING, 0x9},
{ONLP_LED_MODE_GREEN, 0x2},
{ONLP_LED_MODE_GREEN_BLINKING, 0xa},
{ONLP_LED_MODE_RED, 0x4},
{ONLP_LED_MODE_RED_BLINKING, 0xc},
};
/*
* Get the information for the given LED OID.
*/
static onlp_led_info_t linfo[] =
{
{ }, /* Not used */
{
{ ONLP_LED_ID_CREATE(LED_SYS1), "Chassis LED 1 (SYS LED 1)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING |
ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_SYS2), "Chassis LED 1 (SYS LED 2)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_RED | ONLP_LED_CAPS_RED_BLINKING |
ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING,
},
};
/*
* This function will be called prior to any other onlp_ledi_* functions.
*/
int
onlp_ledi_init(void)
{
return ONLP_STATUS_OK;
}
static int
reg_value_to_onlp_led_mode(enum onlp_led_id id, int value)
{
int i;
for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) {
if (value != led_mode_info[i].regval) {
continue;
}
return led_mode_info[i].mode;
}
return ONLP_LED_MODE_AUTO;
}
static int
onlp_led_mode_to_reg_value(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
{
int i;
for (i = 0; i < AIM_ARRAYSIZE(led_mode_info); i++) {
if (onlp_led_mode != led_mode_info[i].mode) {
continue;
}
return led_mode_info[i].regval;
}
return 0;
}
int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
int lid, value;
VALIDATE(id);
lid = ONLP_OID_ID_GET(id);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[ONLP_OID_ID_GET(id)];
value = onlp_i2c_readb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, ONLP_I2C_F_FORCE);
if (value < 0) {
return ONLP_STATUS_E_INTERNAL;
}
info->mode = reg_value_to_onlp_led_mode(lid, value);
/* 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 lid, value;
VALIDATE(id);
lid = ONLP_OID_ID_GET(id);
value = onlp_led_mode_to_reg_value(lid, mode);
if (onlp_i2c_writeb(led_addr[lid].bus, led_addr[lid].devaddr, led_addr[lid].offset, value, ONLP_I2C_F_FORCE) < 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;
}

View File

@@ -0,0 +1,9 @@
###############################################################################
#
#
#
###############################################################################
LIBRARY := x86_64_accton_minipack
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(BUILDER)/lib.mk

View File

@@ -0,0 +1,337 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2017 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 <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <onlplib/file.h>
#include <onlp/onlp.h>
#include "platform_lib.h"
#define TTY_DEVICE "/dev/ttyACM0"
#define TTY_PROMPT "@bmc:"
#define TTY_I2C_TIMEOUT 55000
#define TTY_BMC_LOGIN_TIMEOUT 1000000
#define TTY_RETRY 3
#define MAXIMUM_TTY_BUFFER_LENGTH 1024
#define MAXIMUM_TTY_STRING_LENGTH (MAXIMUM_TTY_BUFFER_LENGTH - 1)
static int tty_fd = -1;
static char tty_buf[MAXIMUM_TTY_BUFFER_LENGTH] = {0};
static int tty_open(void)
{
int i = 20;
struct termios attr;
if (tty_fd > -1) {
return 0;
}
do {
if ((tty_fd = open(TTY_DEVICE, O_RDWR | O_NOCTTY | O_NDELAY)) > -1) {
tcgetattr(tty_fd, &attr);
attr.c_cflag = B57600 | CS8 | CLOCAL | CREAD;
attr.c_iflag = IGNPAR;
attr.c_oflag = 0;
attr.c_lflag = 0;
attr.c_cc[VMIN] = (unsigned char)
((MAXIMUM_TTY_STRING_LENGTH > 0xFF) ? 0xFF : MAXIMUM_TTY_STRING_LENGTH);
attr.c_cc[VTIME] = 0;
cfsetospeed(&attr, B57600);
cfsetispeed(&attr, B57600);
tcsetattr(tty_fd, TCSANOW, &attr);
return 0;
}
i--;
usleep(100000);
} while (i > 0);
return -1;
}
static int tty_close(void)
{
close(tty_fd);
tty_fd = -1;
return 0;
}
static int tty_exec_buf(unsigned long udelay, const char *str)
{
if (tty_fd < 0)
return -1;
write(tty_fd, tty_buf, strlen(tty_buf)+1);
usleep(udelay);
memset(tty_buf, 0, MAXIMUM_TTY_BUFFER_LENGTH);
read(tty_fd, tty_buf, MAXIMUM_TTY_BUFFER_LENGTH);
return (strstr(tty_buf, str) != NULL) ? 0 : -1;
}
static int tty_login(void)
{
int i = 10;
for (i = 1; i <= TTY_RETRY; i++) {
snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "\r\r");
if (!tty_exec_buf(0, TTY_PROMPT)) {
return 0;
}
if (strstr(tty_buf, "bmc login:") != NULL)
{
snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "root\r");
if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, "Password:")) {
snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "0penBmc\r");
if (!tty_exec_buf(TTY_BMC_LOGIN_TIMEOUT, TTY_PROMPT)) {
return 0;
}
}
}
usleep(50000);
}
return -1;
}
int bmc_tty_init(void)
{
int i;
if (tty_fd >= 0){
return 0;
}
for (i = 1; i <= TTY_RETRY; i++) {
if (tty_open() != 0) {
AIM_LOG_ERROR("ERROR: Cannot open TTY device\n");
continue;
}
if (tty_login() != 0) {
AIM_LOG_ERROR("ERROR: Cannot login TTY device\n");
tty_close();
continue;
}
return 0;
}
AIM_LOG_ERROR("Unable to init bmc tty\r\n");
return -1;
}
int bmc_tty_deinit(void)
{
if( tty_fd != -1 ){
tty_close();
}
else{
AIM_LOG_ERROR("ERROR: TTY not open\n");
}
return 0;
}
int bmc_send_command(char *cmd)
{
int i, ret = 0;
for (i = 1; i <= TTY_RETRY; i++) {
snprintf(tty_buf, MAXIMUM_TTY_BUFFER_LENGTH, "%s", cmd);
ret = tty_exec_buf(TTY_I2C_TIMEOUT, TTY_PROMPT);
if (ret != 0) {
// AIM_LOG_ERROR("ERROR: bmc_send_command(%s) timed out\n", cmd);
continue;
}
return 0;
}
AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd);
return -1;
}
int chk_numeric_char(char *data, int base)
{
int len, i, orig = 0;
if( *data == '\0' ){
return 0;
}
len = (int) strlen(data);
if( base == 10 ){
for( i=0; i<len; i++ ){
if( i && ( *(data+i) == 0xd ) ){
break;
}
if( i && ( *(data+i) == 0xa ) ){
break;
}
if( *(data+i) < '0' ){
return 0;
}
if( *(data+i) > '9' ){
return 0;
}
}
return 1;
}
else if( base == 16 ){
if( !memcmp(data, "0x", 2) ){
if( len <= 2 ){
return 0;
}
orig = 2;
}
else if( !memcmp(data, "0X", 2) ){
if( len <= 2 ){
return 0;
}
orig = 2;
}
for( i=orig; i<len; i++ ){
if( (i > orig) && ( *(data+i) == 0xd ) ){
break;
}
if( (i > orig) && ( *(data+i) == 0xa ) ){
break;
}
if( !( ( (*(data+i) >= '0') && (*(data+i) <= '9') ) ||
( (*(data+i) >= 'A') && (*(data+i) <= 'F') ) ||
( (*(data+i) >= 'a') && (*(data+i) <= 'f') )
)
){
return 0;
}
}
return 1;
}
return 0;
}
int
bmc_command_read_int(int* value, char *cmd, int base)
{
int len;
int i;
char *prev_str = NULL;
char *current_str= NULL;
if (bmc_send_command(cmd) < 0) {
return ONLP_STATUS_E_INTERNAL;
}
len = (int)strlen(cmd);
prev_str = strstr(tty_buf, cmd);
if (prev_str == NULL) {
return -1;
}
for (i = 1; i <= TTY_RETRY; i++) {
current_str = strstr(prev_str + len, cmd);
if(current_str == NULL) {
if( !chk_numeric_char(prev_str + len, base) ){
return -1;
}
*value = strtoul(prev_str + len, NULL, base);
break;
}else {
prev_str = current_str;
continue;
}
}
return 0;
}
int
bmc_file_read_int(int* value, char *file, int base)
{
char cmd[64] = {0};
snprintf(cmd, sizeof(cmd), "cat %s\r\n", file);
return bmc_command_read_int(value, cmd, base);
}
int
bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr)
{
int ret = 0, value;
char cmd[64] = {0};
snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x\r\n", bus, devaddr, addr);
ret = bmc_command_read_int(&value, cmd, 16);
return (ret < 0) ? ret : value;
}
int
bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value)
{
char cmd[64] = {0};
snprintf(cmd, sizeof(cmd), "i2cset -f -y %d 0x%x 0x%02x 0x%x\r\n", bus, devaddr, addr, value);
return bmc_send_command(cmd);
}
int
bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr)
{
int ret = 0, value;
char cmd[64] = {0};
snprintf(cmd, sizeof(cmd), "i2cget -f -y %d 0x%x 0x%02x w\r\n", bus, devaddr, addr);
ret = bmc_command_read_int(&value, cmd, 16);
return (ret < 0) ? ret : value;
}
int
bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size)
{
int data_len, i = 0;
char cmd[64] = {0};
char *str = NULL;
snprintf(cmd, sizeof(cmd), "i2craw -w 0x%x -r 0 %d 0x%02x\r\n", addr, bus, devaddr);
if (bmc_send_command(cmd) < 0) {
AIM_LOG_ERROR("Unable to send command to bmc(%s)\r\n", cmd);
return ONLP_STATUS_E_INTERNAL;
}
str = strstr(tty_buf, "Received:\r\n ");
if (str == NULL) {
return -1;
}
/* first byte is data length */
str += strlen("Received:\r\n ");;
data_len = strtoul(str, NULL, 16);
if (data_size < data_len) {
data_len = data_size;
}
for (i = 0; (i < data_len) && (str != NULL); i++) {
str = strstr(str, " ") + 1; /* Jump to next token */
data[i] = strtoul(str, NULL, 16);
}
data[i] = 0;
return 0;
}

View File

@@ -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_minipack_log.h"
#define DEBUG_MODE 0
#if (DEBUG_MODE == 1)
#define DEBUG_PRINT(fmt, args...) \
printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args)
#else
#define DEBUG_PRINT(fmt, args...)
#endif
#define CHASSIS_FAN_COUNT 5
#define CHASSIS_THERMAL_COUNT 8
#define CHASSIS_LED_COUNT 2
#define CHASSIS_PSU_COUNT 2
#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-40/40-0050/eeprom"
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,
THERMAL_4_ON_MAIN_BROAD,
THERMAL_5_ON_MAIN_BROAD,
THERMAL_6_ON_MAIN_BROAD,
THERMAL_7_ON_MAIN_BROAD,
};
int bmc_send_command(char *cmd);
int bmc_file_read_int(int* value, char *file, int base);
int bmc_i2c_readb(uint8_t bus, uint8_t devaddr, uint8_t addr);
int bmc_i2c_writeb(uint8_t bus, uint8_t devaddr, uint8_t addr, uint8_t value);
int bmc_i2c_readw(uint8_t bus, uint8_t devaddr, uint8_t addr);
int bmc_i2c_readraw(uint8_t bus, uint8_t devaddr, uint8_t addr, char* data, int data_size);
int bmc_tty_init(void);
int bmc_tty_deinit(void);
#endif /* __PLATFORM_LIB_H__ */

View File

@@ -0,0 +1,181 @@
/************************************************************
* <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 <onlplib/i2c.h>
#include <unistd.h>
#include <onlplib/file.h>
#include <onlp/platformi/psui.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_PSU(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
#define PSU1_ID 1
#define PSU2_ID 2
/*
* 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_init(void)
{
return ONLP_STATUS_OK;
}
static int
twos_complement_to_int(uint16_t data, uint8_t valid_bit, int mask)
{
uint16_t valid_data = data & mask;
bool is_negative = valid_data >> (valid_bit - 1);
return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
}
static int
pmbus_parse_literal_format(uint16_t value)
{
int exponent, mantissa, multiplier = 1000;
exponent = twos_complement_to_int(value >> 11, 5, 0x1f);
mantissa = twos_complement_to_int(value & 0x7ff, 11, 0x7ff);
return (exponent >= 0) ? (mantissa << exponent) * multiplier :
(mantissa * multiplier) / (1 << -exponent);
}
int
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
int pid, value, addr;
uint8_t mask = 0;
VALIDATE(id);
pid = ONLP_OID_ID_GET(id);
*info = pinfo[pid]; /* Set the onlp_oid_hdr_t */
/* Get the present status
*/
mask = 1 << ((pid-1) * 4);
value = onlp_i2c_readb(1, 0x32, 0x10, ONLP_I2C_F_FORCE);
if (value < 0) {
return ONLP_STATUS_E_INTERNAL;
}
if (value & mask) {
info->status &= ~ONLP_PSU_STATUS_PRESENT;
return ONLP_STATUS_OK;
}
info->status |= ONLP_PSU_STATUS_PRESENT;
info->caps = ONLP_PSU_CAPS_AC;
/* Get power good status
*/
mask = 1 << ((pid-1) * 4 + 1);
if (!(value & mask)) {
info->status |= ONLP_PSU_STATUS_FAILED;
return ONLP_STATUS_OK;
}
/* Get input output power status
*/
value = (pid == PSU1_ID) ? 0x2 : 0x1; /* mux channel for psu */
if (bmc_i2c_writeb(7, 0x70, 0, value) < 0) {
return ONLP_STATUS_E_INTERNAL;
}
usleep(1200);
/* Read vin */
addr = (pid == PSU1_ID) ? 0x59 : 0x5a;
value = bmc_i2c_readw(7, addr, 0x88);
if (value >= 0) {
info->mvin = pmbus_parse_literal_format(value);
info->caps |= ONLP_PSU_CAPS_VIN;
}
/* Read iin */
value = bmc_i2c_readw(7, addr, 0x89);
if (value >= 0) {
info->miin = pmbus_parse_literal_format(value);
info->caps |= ONLP_PSU_CAPS_IIN;
}
/* Get pin */
if ((info->caps & ONLP_PSU_CAPS_VIN) && (info->caps & ONLP_PSU_CAPS_IIN)) {
info->mpin = info->mvin * info->miin / 1000;
info->caps |= ONLP_PSU_CAPS_PIN;
}
/* Read iout */
value = bmc_i2c_readw(7, addr, 0x8c);
if (value >= 0) {
info->miout = pmbus_parse_literal_format(value);
info->caps |= ONLP_PSU_CAPS_IOUT;
}
/* Read pout */
value = bmc_i2c_readw(7, addr, 0x96);
if (value >= 0) {
info->mpout = pmbus_parse_literal_format(value);
info->caps |= ONLP_PSU_CAPS_POUT;
}
/* Get vout */
if ((info->caps & ONLP_PSU_CAPS_IOUT) && (info->caps & ONLP_PSU_CAPS_POUT) && info->miout != 0) {
info->mvout = info->mpout / info->miout * 1000;
info->caps |= ONLP_PSU_CAPS_VOUT;
}
/* Get model name */
bmc_i2c_readraw(7, addr, 0x9a, info->model, sizeof(info->model));
/* Get serial number */
return bmc_i2c_readraw(7, addr, 0x9e, info->serial, sizeof(info->serial));
}
int
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,229 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014 Big Switch Networks, Inc.
* Copyright 2016 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 <onlplib/i2c.h>
#include <onlp/platformi/sfpi.h>
#include <onlplib/file.h>
#include "platform_lib.h"
#include "x86_64_accton_minipack_log.h"
#define BIT(i) (1 << (i))
#define NUM_OF_SFP_PORT 32
#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom"
static const int sfp_bus_index[] = {
3, 2, 5, 4, 7, 6, 9, 8,
11, 10, 13, 12, 15, 14, 17, 16,
19, 18, 21, 20, 23, 22, 25, 24,
27, 26, 29, 28, 31, 30, 33, 32
};
/************************************************************
*
* SFPI Entry Points
*
***********************************************************/
int
onlp_sfpi_init(void)
{
/* Called at initialization time */
return ONLP_STATUS_OK;
}
int
onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
{
/*
* Ports {0, 32}
*/
int p;
AIM_BITMAP_CLR_ALL(bmap);
for(p = 0; p < NUM_OF_SFP_PORT; p++) {
AIM_BITMAP_SET(bmap, p);
}
return ONLP_STATUS_OK;
}
static uint8_t
onlp_sfpi_reg_val_to_port_sequence(uint8_t value, int revert)
{
int i;
uint8_t ret = 0;
for (i = 0; i < 8; i++) {
if (i % 2) {
ret |= (value & BIT(i)) >> 1;
}
else {
ret |= (value & BIT(i)) << 1;
}
}
return revert ? ~ret : ret;
}
int
onlp_sfpi_is_present(int port)
{
/*
* Return 1 if present.
* Return 0 if not present.
* Return < 0 if error.
*/
int present;
int bus = (port < 16) ? 36 : 37;
int addr = (port < 16) ? 0x22 : 0x23; /* pca9535 slave address */
int offset;
if (port < 8 || (port >= 16 && port <= 23)) {
offset = 0;
}
else {
offset = 1;
}
present = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE);
if (present < 0) {
return ONLP_STATUS_E_INTERNAL;
}
present = onlp_sfpi_reg_val_to_port_sequence(present, 0);
return !(present & BIT(port % 8));
}
int
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{
int i;
uint8_t bytes[4] = {0};
for (i = 0; i < AIM_ARRAYSIZE(bytes); i++) {
int bus = (i < 2) ? 36 : 37;
int addr = (i < 2) ? 0x22 : 0x23; /* pca9535 slave address */
int offset = (i % 2);
bytes[i] = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE);
if (bytes[i] < 0) {
return ONLP_STATUS_E_INTERNAL;
}
bytes[i] = onlp_sfpi_reg_val_to_port_sequence(bytes[i], 1);
}
/* Convert to 32 bit integer in port order */
i = 0;
uint32_t presence_all = 0 ;
for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) {
presence_all <<= 8;
presence_all |= bytes[i];
}
/* Populate bitmap */
for(i = 0; presence_all; i++) {
AIM_BITMAP_MOD(dst, i, (presence_all & 1));
presence_all >>= 1;
}
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])
{
int size = 0;
if(port <0 || port >= NUM_OF_SFP_PORT)
return ONLP_STATUS_E_INTERNAL;
memset(data, 0, 256);
if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, sfp_bus_index[port]) != ONLP_STATUS_OK) {
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
if (size != 256) {
AIM_LOG_ERROR("Unable to read eeprom from port(%d), size(%d) is different!\r\n", port, size);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_dom_read(int port, uint8_t data[256])
{
FILE* fp;
char file[64] = {0};
sprintf(file, PORT_EEPROM_FORMAT, sfp_bus_index[port]);
fp = fopen(file, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port);
return ONLP_STATUS_E_INTERNAL;
}
if (fseek(fp, 256, SEEK_CUR) != 0) {
fclose(fp);
AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port);
return ONLP_STATUS_E_INTERNAL;
}
int ret = fread(data, 1, 256, fp);
fclose(fp);
if (ret != 256) {
AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d, %d)", port, ret);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int
onlp_sfpi_denit(void)
{
return ONLP_STATUS_OK;
}

View File

@@ -0,0 +1,115 @@
/************************************************************
* <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 <unistd.h>
#include <fcntl.h>
#include <onlplib/file.h>
#include <onlp/platformi/sysi.h>
#include <onlp/platformi/ledi.h>
#include <onlp/platformi/thermali.h>
#include <onlp/platformi/fani.h>
#include <onlp/platformi/psui.h>
#include "platform_lib.h"
#include "x86_64_accton_minipack_int.h"
#include "x86_64_accton_minipack_log.h"
const char*
onlp_sysi_platform_get(void)
{
return "x86-64-accton-minipack-r0";
}
int
onlp_sysi_onie_data_get(uint8_t** data, int* size)
{
uint8_t* rdata = aim_zmalloc(256);
if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) {
if(*size == 256) {
*data = rdata;
return ONLP_STATUS_OK;
}
}
aim_free(rdata);
*size = 0;
return ONLP_STATUS_E_INTERNAL;
}
int
onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
int i;
onlp_oid_t* e = table;
memset(table, 0, max*sizeof(onlp_oid_t));
/* 8 Thermal sensors on the chassis */
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
/* 2 LEDs on the chassis */
for (i = 1; i <= CHASSIS_LED_COUNT; i++) {
*e++ = ONLP_LED_ID_CREATE(i);
}
/* 2 PSUs on the chassis */
for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
*e++ = ONLP_PSU_ID_CREATE(i);
}
/* 5 Fans on the chassis */
for (i = 1; i <= CHASSIS_FAN_COUNT; i++) {
*e++ = ONLP_FAN_ID_CREATE(i);
}
bmc_tty_init();
return 0;
}
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
return ONLP_STATUS_OK;
}
void
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
{
}
int
onlp_sysi_platform_manage_fans(void)
{
return ONLP_STATUS_OK;
}
int
onlp_sysi_platform_manage_leds(void)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,134 @@
/************************************************************
* <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>
************************************************************
*
* Thermal Sensor Platform Implementation.
*
***********************************************************/
#include <onlplib/file.h>
#include <onlp/platformi/thermali.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_THERMAL(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
#define THERMAL_PATH_FORMAT "/sys/bus/i2c/drivers/lm75/%s/temp1_input"
#define THERMAL_CPU_CORE_PATH_FORMAT "/sys/bus/i2c/drivers/com_e_driver/%s/temp2_input"
static char* directory[] = /* must map with onlp_thermal_id */
{
NULL,
"4-0033", /* CPU_CORE files */
"3-0048",
"3-0049",
"3-004a",
"3-004b",
"3-004c",
"8-0048",
"8-0049",
};
/* Static values */
static onlp_thermal_info_t linfo[] = {
{ }, /* Not used */
{ { 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-1", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "TMP75-2", 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-3", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "TMP75-4", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "TMP75-5", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "TMP75-6", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_7_ON_MAIN_BROAD), "TMP75-7", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
};
/*
* This will be called to intiialize the thermali subsystem.
*/
int
onlp_thermali_init(void)
{
return ONLP_STATUS_OK;
}
/*
* Retrieve the information structure for the given thermal OID.
*
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
* Otherwise, return ONLP_STATUS_OK with the OID's information.
*
* Note -- it is expected that you fill out the information
* structure even if the sensor described by the OID is not present.
*/
int
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
int tid;
char path[64] = {0};
VALIDATE(id);
tid = ONLP_OID_ID_GET(id);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[tid];
/* get path */
if (THERMAL_CPU_CORE == tid) {
sprintf(path, THERMAL_CPU_CORE_PATH_FORMAT, directory[tid]);
}else {
sprintf(path, THERMAL_PATH_FORMAT, directory[tid]);
}
if (bmc_file_read_int(&info->mcelsius, path, 10) < 0) {
AIM_LOG_ERROR("Unable to read status from file (%s)\r\n", path);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}

View File

@@ -0,0 +1,80 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
/* <auto.start.cdefs(x86_64_accton_minipack_CONFIG_HEADER).source> */
#define __x86_64_accton_minipack_config_STRINGIFY_NAME(_x) #_x
#define __x86_64_accton_minipack_config_STRINGIFY_VALUE(_x) __x86_64_accton_minipack_config_STRINGIFY_NAME(_x)
x86_64_accton_minipack_config_settings_t x86_64_accton_minipack_config_settings[] =
{
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_LOGGING(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_PORTING_STDLIB(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_UCLI(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
{ __x86_64_accton_minipack_config_STRINGIFY_NAME(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_minipack_config_STRINGIFY_VALUE(X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) },
#else
{ X86_64_ACCTON_MINIPACK_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_minipack_config_STRINGIFY_NAME), "__undefined__" },
#endif
{ NULL, NULL }
};
#undef __x86_64_accton_minipack_config_STRINGIFY_VALUE
#undef __x86_64_accton_minipack_config_STRINGIFY_NAME
const char*
x86_64_accton_minipack_config_lookup(const char* setting)
{
int i;
for(i = 0; x86_64_accton_minipack_config_settings[i].name; i++) {
if(strcmp(x86_64_accton_minipack_config_settings[i].name, setting)) {
return x86_64_accton_minipack_config_settings[i].value;
}
}
return NULL;
}
int
x86_64_accton_minipack_config_show(struct aim_pvs_s* pvs)
{
int i;
for(i = 0; x86_64_accton_minipack_config_settings[i].name; i++) {
aim_printf(pvs, "%s = %s\n", x86_64_accton_minipack_config_settings[i].name, x86_64_accton_minipack_config_settings[i].value);
}
return i;
}
/* <auto.end.cdefs(X86_64_ACCTON_MINIPACK_CONFIG_HEADER).source> */

View File

@@ -0,0 +1,10 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
/* <--auto.start.enum(ALL).source> */
/* <auto.end.enum(ALL).source> */

View File

@@ -0,0 +1,12 @@
/**************************************************************************//**
*
* x86_64_accton_minipack Internal Header
*
*****************************************************************************/
#ifndef __x86_64_accton_minipack_INT_H__
#define __x86_64_accton_minipack_INT_H__
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
#endif /* __x86_64_accton_minipack_INT_H__ */

View File

@@ -0,0 +1,18 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
#include "x86_64_accton_minipack_log.h"
/*
* x86_64_accton_minipack log struct.
*/
AIM_LOG_STRUCT_DEFINE(
X86_64_ACCTON_MINIPACK_CONFIG_LOG_OPTIONS_DEFAULT,
X86_64_ACCTON_MINIPACK_CONFIG_LOG_BITS_DEFAULT,
NULL, /* Custom log map */
X86_64_ACCTON_MINIPACK_CONFIG_LOG_CUSTOM_BITS_DEFAULT
);

View File

@@ -0,0 +1,12 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#ifndef __x86_64_accton_minipack_LOG_H__
#define __x86_64_accton_minipack_LOG_H__
#define AIM_LOG_MODULE_NAME x86_64_accton_minipack
#include <AIM/aim_log.h>
#endif /* __x86_64_accton_minipack_LOG_H__ */

View File

@@ -0,0 +1,24 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
#include "x86_64_accton_minipack_log.h"
static int
datatypes_init__(void)
{
#define x86_64_accton_minipack_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
#include <x86_64_accton_minipack/x86_64_accton_minipack.x>
return 0;
}
void __x86_64_accton_minipack_module_init__(void)
{
AIM_LOG_STRUCT_REGISTER();
datatypes_init__();
}
int __onlp_platform_version__ = 1;

View File

@@ -0,0 +1,50 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_accton_minipack/x86_64_accton_minipack_config.h>
#if x86_64_accton_minipack_CONFIG_INCLUDE_UCLI == 1
#include <uCli/ucli.h>
#include <uCli/ucli_argparse.h>
#include <uCli/ucli_handler_macros.h>
static ucli_status_t
x86_64_accton_minipack_ucli_ucli__config__(ucli_context_t* uc)
{
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_minipack)
}
/* <auto.ucli.handlers.start> */
/* <auto.ucli.handlers.end> */
static ucli_module_t
x86_64_accton_minipack_ucli_module__ =
{
"x86_64_accton_minipack_ucli",
NULL,
x86_64_accton_minipack_ucli_ucli_handlers__,
NULL,
NULL,
};
ucli_node_t*
x86_64_accton_minipack_ucli_node_create(void)
{
ucli_node_t* n;
ucli_module_init(&x86_64_accton_minipack_ucli_module__);
n = ucli_node_create("x86_64_accton_minipack", NULL, &x86_64_accton_minipack_ucli_module__);
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_minipack"));
return n;
}
#else
void*
x86_64_accton_minipack_ucli_node_create(void)
{
return NULL;
}
#endif

View File

@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk

View File

@@ -0,0 +1 @@
include $(ONL)/make/pkg.mk

View File

@@ -0,0 +1 @@
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-minipack REVISION=r0

View File

@@ -0,0 +1,35 @@
---
######################################################################
#
# platform-config for MiniPack
#
######################################################################
x86-64-accton-minipack-r0:
grub:
serial: >-
--unit=0
--speed=9600
--word=8
--parity=0
--stop=1
kernel:
<<: *kernel-4-14
args: >-
nopat
console=ttyS0,9600n8
rd_NO_MD
rd_NO_LUKS
intel_iommu=off
noapic
##network
## interfaces:
## ma1:
## name: ~
## syspath: pci0000:00/0000:00:14.0

View File

@@ -0,0 +1,91 @@
from onl.platform.base import *
from onl.platform.accton import *
class OnlPlatform_x86_64_accton_minipack_r0(OnlPlatformAccton,
OnlPlatformPortConfig_128x100):
MODEL="Minipack"
PLATFORM="x86-64-accton-minipack-r0"
SYS_OBJECT_ID=".100.128.2"
def baseconfig(self):
self.insmod('optoe')
########### initialize I2C bus 1 ###########
self.new_i2c_devices([
# initialize multiplexer (PCA9548)
('pca9548', 0x70, 1),
('pca9548', 0x71, 1),
('pca9548', 0x72, 1),
('pca9548', 0x73, 1),
('pca9548', 0x74, 1),
('24c64', 0x50, 40),
])
# Initialize QSFP devices
self.new_i2c_device('optoe1', 0x50, 2)
self.new_i2c_device('optoe1', 0x50, 3)
self.new_i2c_device('optoe1', 0x50, 4)
self.new_i2c_device('optoe1', 0x50, 5)
self.new_i2c_device('optoe1', 0x50, 6)
self.new_i2c_device('optoe1', 0x50, 7)
self.new_i2c_device('optoe1', 0x50, 8)
self.new_i2c_device('optoe1', 0x50, 9)
self.new_i2c_device('optoe1', 0x50, 10)
self.new_i2c_device('optoe1', 0x50, 11)
self.new_i2c_device('optoe1', 0x50, 12)
self.new_i2c_device('optoe1', 0x50, 13)
self.new_i2c_device('optoe1', 0x50, 14)
self.new_i2c_device('optoe1', 0x50, 15)
self.new_i2c_device('optoe1', 0x50, 16)
self.new_i2c_device('optoe1', 0x50, 17)
self.new_i2c_device('optoe1', 0x50, 18)
self.new_i2c_device('optoe1', 0x50, 19)
self.new_i2c_device('optoe1', 0x50, 20)
self.new_i2c_device('optoe1', 0x50, 21)
self.new_i2c_device('optoe1', 0x50, 22)
self.new_i2c_device('optoe1', 0x50, 23)
self.new_i2c_device('optoe1', 0x50, 24)
self.new_i2c_device('optoe1', 0x50, 25)
self.new_i2c_device('optoe1', 0x50, 26)
self.new_i2c_device('optoe1', 0x50, 27)
self.new_i2c_device('optoe1', 0x50, 28)
self.new_i2c_device('optoe1', 0x50, 29)
self.new_i2c_device('optoe1', 0x50, 30)
self.new_i2c_device('optoe1', 0x50, 31)
self.new_i2c_device('optoe1', 0x50, 32)
self.new_i2c_device('optoe1', 0x50, 33)
subprocess.call('echo port1 > /sys/bus/i2c/devices/3-0050/port_name', shell=True)
subprocess.call('echo port2 > /sys/bus/i2c/devices/2-0050/port_name', shell=True)
subprocess.call('echo port3 > /sys/bus/i2c/devices/5-0050/port_name', shell=True)
subprocess.call('echo port4 > /sys/bus/i2c/devices/4-0050/port_name', shell=True)
subprocess.call('echo port5 > /sys/bus/i2c/devices/7-0050/port_name', shell=True)
subprocess.call('echo port6 > /sys/bus/i2c/devices/6-0050/port_name', shell=True)
subprocess.call('echo port7 > /sys/bus/i2c/devices/9-0050/port_name', shell=True)
subprocess.call('echo port8 > /sys/bus/i2c/devices/8-0050/port_name', shell=True)
subprocess.call('echo port9 > /sys/bus/i2c/devices/11-0050/port_name', shell=True)
subprocess.call('echo port10 > /sys/bus/i2c/devices/10-0050/port_name', shell=True)
subprocess.call('echo port11 > /sys/bus/i2c/devices/13-0050/port_name', shell=True)
subprocess.call('echo port12 > /sys/bus/i2c/devices/12-0050/port_name', shell=True)
subprocess.call('echo port13 > /sys/bus/i2c/devices/15-0050/port_name', shell=True)
subprocess.call('echo port14 > /sys/bus/i2c/devices/14-0050/port_name', shell=True)
subprocess.call('echo port15 > /sys/bus/i2c/devices/17-0050/port_name', shell=True)
subprocess.call('echo port16 > /sys/bus/i2c/devices/16-0050/port_name', shell=True)
subprocess.call('echo port17 > /sys/bus/i2c/devices/19-0050/port_name', shell=True)
subprocess.call('echo port18 > /sys/bus/i2c/devices/18-0050/port_name', shell=True)
subprocess.call('echo port19 > /sys/bus/i2c/devices/21-0050/port_name', shell=True)
subprocess.call('echo port20 > /sys/bus/i2c/devices/20-0050/port_name', shell=True)
subprocess.call('echo port21 > /sys/bus/i2c/devices/23-0050/port_name', shell=True)
subprocess.call('echo port22 > /sys/bus/i2c/devices/22-0050/port_name', shell=True)
subprocess.call('echo port23 > /sys/bus/i2c/devices/25-0050/port_name', shell=True)
subprocess.call('echo port24 > /sys/bus/i2c/devices/24-0050/port_name', shell=True)
subprocess.call('echo port25 > /sys/bus/i2c/devices/27-0050/port_name', shell=True)
subprocess.call('echo port26 > /sys/bus/i2c/devices/26-0050/port_name', shell=True)
subprocess.call('echo port27 > /sys/bus/i2c/devices/29-0050/port_name', shell=True)
subprocess.call('echo port28 > /sys/bus/i2c/devices/28-0050/port_name', shell=True)
subprocess.call('echo port29 > /sys/bus/i2c/devices/31-0050/port_name', shell=True)
subprocess.call('echo port30 > /sys/bus/i2c/devices/30-0050/port_name', shell=True)
subprocess.call('echo port31 > /sys/bus/i2c/devices/33-0050/port_name', shell=True)
subprocess.call('echo port32 > /sys/bus/i2c/devices/32-0050/port_name', shell=True)
return True