Common AS4610 ONLP Module.

This commit is contained in:
Jeffrey Townsend
2016-07-20 23:18:55 +00:00
parent fa2f16cd48
commit f97447ec7e
28 changed files with 4687 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
/arm_accton_as4610.mk
/doc

View File

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

View File

@@ -0,0 +1,28 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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.mk
MODULE := arm_accton_as4610
AUTOMODULE := arm_accton_as4610
include $(BUILDER)/definemodule.mk

View File

@@ -0,0 +1,68 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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>
############################################################
#
# arm_accton_as4610 Autogeneration Definitions.
#
############################################################
cdefs: &cdefs
- ONLPSIM_CONFIG_INCLUDE_LOGGING:
doc: "Include or exclude logging."
default: 1
- ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT:
doc: "Default enabled log options."
default: AIM_LOG_OPTIONS_DEFAULT
- ONLPSIM_CONFIG_LOG_BITS_DEFAULT:
doc: "Default enabled log bits."
default: AIM_LOG_BITS_DEFAULT
- ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
doc: "Default enabled custom log bits."
default: 0
- ONLPSIM_CONFIG_PORTING_STDLIB:
doc: "Default all porting macros to use the C standard libraries."
default: 1
- ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
doc: "Include standard library headers for stdlib porting macros."
default: ONLPSIM_CONFIG_PORTING_STDLIB
- ONLPSIM_CONFIG_INCLUDE_UCLI:
doc: "Include generic uCli support."
default: 0
- ONLPSIM_CONFIG_SFP_COUNT:
doc: "SFP Count."
default: 0
definitions:
cdefs:
ONLPSIM_CONFIG_HEADER:
defs: *cdefs
basename: arm_accton_as4610_config
portingmacro:
ONLPSIM:
macros:
- malloc
- free
- memset
- memcpy
- strncpy
- vsnprintf
- snprintf
- strlen

View File

@@ -0,0 +1,29 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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>
############################################################
#
# arm_accton_as4610 Autogeneration
#
############################################################
arm_accton_as4610_AUTO_DEFS := module/auto/arm_accton_as4610.yml
arm_accton_as4610_AUTO_DIRS := module/inc/arm_accton_as4610 module/src
include $(BUILDER)/auto.mk

View File

@@ -0,0 +1,34 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_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,162 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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>
************************************************************
*
*
*
***********************************************************/
/**************************************************************************//**
*
* @file
* @brief arm_accton_as4610 Configuration Header
*
* @addtogroup arm_accton_as4610-config
* @{
*
*****************************************************************************/
#ifndef __ONLPSIM_CONFIG_H__
#define __ONLPSIM_CONFIG_H__
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
#include <global_custom_config.h>
#endif
#ifdef ONLPSIM_INCLUDE_CUSTOM_CONFIG
#include <arm_accton_as4610_custom_config.h>
#endif
/* <auto.start.cdefs(ONLPSIM_CONFIG_HEADER).header> */
#include <AIM/aim.h>
/**
* ONLPSIM_CONFIG_INCLUDE_LOGGING
*
* Include or exclude logging. */
#ifndef ONLPSIM_CONFIG_INCLUDE_LOGGING
#define ONLPSIM_CONFIG_INCLUDE_LOGGING 1
#endif
/**
* ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
*
* Default enabled log options. */
#ifndef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
#define ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
#endif
/**
* ONLPSIM_CONFIG_LOG_BITS_DEFAULT
*
* Default enabled log bits. */
#ifndef ONLPSIM_CONFIG_LOG_BITS_DEFAULT
#define ONLPSIM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
#endif
/**
* ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
*
* Default enabled custom log bits. */
#ifndef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
#define ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
#endif
/**
* ONLPSIM_CONFIG_PORTING_STDLIB
*
* Default all porting macros to use the C standard libraries. */
#ifndef ONLPSIM_CONFIG_PORTING_STDLIB
#define ONLPSIM_CONFIG_PORTING_STDLIB 1
#endif
/**
* ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
*
* Include standard library headers for stdlib porting macros. */
#ifndef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
#define ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS ONLPSIM_CONFIG_PORTING_STDLIB
#endif
/**
* ONLPSIM_CONFIG_INCLUDE_UCLI
*
* Include generic uCli support. */
#ifndef ONLPSIM_CONFIG_INCLUDE_UCLI
#define ONLPSIM_CONFIG_INCLUDE_UCLI 0
#endif
/**
* ONLPSIM_CONFIG_SFP_COUNT
*
* SFP Count. */
#ifndef ONLPSIM_CONFIG_SFP_COUNT
#define ONLPSIM_CONFIG_SFP_COUNT 0
#endif
/**
* All compile time options can be queried or displayed
*/
/** Configuration settings structure. */
typedef struct arm_accton_as4610_config_settings_s {
/** name */
const char* name;
/** value */
const char* value;
} arm_accton_as4610_config_settings_t;
/** Configuration settings table. */
/** arm_accton_as4610_config_settings table. */
extern arm_accton_as4610_config_settings_t arm_accton_as4610_config_settings[];
/**
* @brief Lookup a configuration setting.
* @param setting The name of the configuration option to lookup.
*/
const char* arm_accton_as4610_config_lookup(const char* setting);
/**
* @brief Show the compile-time configuration.
* @param pvs The output stream.
*/
int arm_accton_as4610_config_show(struct aim_pvs_s* pvs);
/* <auto.end.cdefs(ONLPSIM_CONFIG_HEADER).header> */
#include "arm_accton_as4610_porting.h"
#endif /* __ONLPSIM_CONFIG_H__ */
/* @} */

View File

@@ -0,0 +1,51 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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>
************************************************************
*
*
*
***********************************************************/
/********************************************************//**
*
* arm_accton_as4610 Doxygen Header
*
***********************************************************/
#ifndef __ONLPSIM_DOX_H__
#define __ONLPSIM_DOX_H__
/**
* @defgroup arm_accton_as4610 arm_accton_as4610 - onlpsim Description
*
The documentation overview for this module should go here.
*
* @{
*
* @defgroup arm_accton_as4610-arm_accton_as4610 Public Interface
* @defgroup arm_accton_as4610-config Compile Time Configuration
* @defgroup arm_accton_as4610-porting Porting Macros
*
* @}
*
*/
#endif /* __ONLPSIM_DOX_H__ */

View File

@@ -0,0 +1,132 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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>
************************************************************
*
*
*
***********************************************************/
/********************************************************//**
*
* @file
* @brief arm_accton_as4610 Porting Macros.
*
* @addtogroup arm_accton_as4610-porting
* @{
*
***********************************************************/
#ifndef __ONLPSIM_PORTING_H__
#define __ONLPSIM_PORTING_H__
/* <auto.start.portingmacro(ALL).define> */
#if ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <memory.h>
#endif
#ifndef ONLPSIM_MALLOC
#if defined(GLOBAL_MALLOC)
#define ONLPSIM_MALLOC GLOBAL_MALLOC
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MALLOC malloc
#else
#error The macro ONLPSIM_MALLOC is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_FREE
#if defined(GLOBAL_FREE)
#define ONLPSIM_FREE GLOBAL_FREE
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_FREE free
#else
#error The macro ONLPSIM_FREE is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_MEMSET
#if defined(GLOBAL_MEMSET)
#define ONLPSIM_MEMSET GLOBAL_MEMSET
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MEMSET memset
#else
#error The macro ONLPSIM_MEMSET is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_MEMCPY
#if defined(GLOBAL_MEMCPY)
#define ONLPSIM_MEMCPY GLOBAL_MEMCPY
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_MEMCPY memcpy
#else
#error The macro ONLPSIM_MEMCPY is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_STRNCPY
#if defined(GLOBAL_STRNCPY)
#define ONLPSIM_STRNCPY GLOBAL_STRNCPY
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_STRNCPY strncpy
#else
#error The macro ONLPSIM_STRNCPY is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_VSNPRINTF
#if defined(GLOBAL_VSNPRINTF)
#define ONLPSIM_VSNPRINTF GLOBAL_VSNPRINTF
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_VSNPRINTF vsnprintf
#else
#error The macro ONLPSIM_VSNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_SNPRINTF
#if defined(GLOBAL_SNPRINTF)
#define ONLPSIM_SNPRINTF GLOBAL_SNPRINTF
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_SNPRINTF snprintf
#else
#error The macro ONLPSIM_SNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef ONLPSIM_STRLEN
#if defined(GLOBAL_STRLEN)
#define ONLPSIM_STRLEN GLOBAL_STRLEN
#elif ONLPSIM_CONFIG_PORTING_STDLIB == 1
#define ONLPSIM_STRLEN strlen
#else
#error The macro ONLPSIM_STRLEN is required but cannot be defined.
#endif
#endif
/* <auto.end.portingmacro(ALL).define> */
#endif /* __ONLPSIM_PORTING_H__ */
/* @} */

View File

@@ -0,0 +1,29 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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>
############################################################
#
#
#
############################################################
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
arm_accton_as4610_INCLUDES := -I $(THIS_DIR)inc
arm_accton_as4610_INTERNAL_INCLUDES := -I $(THIS_DIR)src
arm_accton_as4610_DEPENDMODULE_ENTRIES := init:arm_accton_as4610 ucli:arm_accton_as4610

View File

@@ -0,0 +1,30 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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>
############################################################
#
# Local source generation targets.
#
############################################################
include ../../../../init.mk
ucli:
$(SUBMODULE_BIGCODE)/tools/uclihandlers.py arm_accton_as4610_ucli.c

View File

@@ -0,0 +1,101 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_config.h>
/* <auto.start.cdefs(ONLPSIM_CONFIG_HEADER).source> */
#define __arm_accton_as4610_config_STRINGIFY_NAME(_x) #_x
#define __arm_accton_as4610_config_STRINGIFY_VALUE(_x) __arm_accton_as4610_config_STRINGIFY_NAME(_x)
arm_accton_as4610_config_settings_t arm_accton_as4610_config_settings[] =
{
#ifdef ONLPSIM_CONFIG_INCLUDE_LOGGING
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_LOGGING), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_LOGGING) },
#else
{ ONLPSIM_CONFIG_INCLUDE_LOGGING(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_BITS_DEFAULT
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_BITS_DEFAULT), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_BITS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_BITS_DEFAULT(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
#else
{ ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_PORTING_STDLIB
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_STDLIB), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_STDLIB) },
#else
{ ONLPSIM_CONFIG_PORTING_STDLIB(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
#else
{ ONLPSIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_INCLUDE_UCLI
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_INCLUDE_UCLI), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_INCLUDE_UCLI) },
#else
{ ONLPSIM_CONFIG_INCLUDE_UCLI(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef ONLPSIM_CONFIG_SFP_COUNT
{ __arm_accton_as4610_config_STRINGIFY_NAME(ONLPSIM_CONFIG_SFP_COUNT), __arm_accton_as4610_config_STRINGIFY_VALUE(ONLPSIM_CONFIG_SFP_COUNT) },
#else
{ ONLPSIM_CONFIG_SFP_COUNT(__arm_accton_as4610_config_STRINGIFY_NAME), "__undefined__" },
#endif
{ NULL, NULL }
};
#undef __arm_accton_as4610_config_STRINGIFY_VALUE
#undef __arm_accton_as4610_config_STRINGIFY_NAME
const char*
arm_accton_as4610_config_lookup(const char* setting)
{
int i;
for(i = 0; arm_accton_as4610_config_settings[i].name; i++) {
if(strcmp(arm_accton_as4610_config_settings[i].name, setting)) {
return arm_accton_as4610_config_settings[i].value;
}
}
return NULL;
}
int
arm_accton_as4610_config_show(struct aim_pvs_s* pvs)
{
int i;
for(i = 0; arm_accton_as4610_config_settings[i].name; i++) {
aim_printf(pvs, "%s = %s\n", arm_accton_as4610_config_settings[i].name, arm_accton_as4610_config_settings[i].value);
}
return i;
}
/* <auto.end.cdefs(ONLPSIM_CONFIG_HEADER).source> */

View File

@@ -0,0 +1,30 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_config.h>
/* <--auto.start.enum(ALL).source> */
/* <auto.end.enum(ALL).source> */

View File

@@ -0,0 +1,32 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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>
************************************************************
*
*
*
***********************************************************/
#ifndef __ONLPSIM_INT_H__
#define __ONLPSIM_INT_H__
#include <arm_accton_as4610/arm_accton_as4610_config.h>
#endif /* __ONLPSIM_INT_H__ */

View File

@@ -0,0 +1,38 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_config.h>
#include "arm_accton_as4610_log.h"
/*
* arm_accton_as4610 log struct.
*/
AIM_LOG_STRUCT_DEFINE(
ONLPSIM_CONFIG_LOG_OPTIONS_DEFAULT,
ONLPSIM_CONFIG_LOG_BITS_DEFAULT,
NULL, /* Custom log map */
ONLPSIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT
);

View File

@@ -0,0 +1,32 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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>
************************************************************
*
*
*
***********************************************************/
#ifndef __ONLPSIM_LOG_H__
#define __ONLPSIM_LOG_H__
#define AIM_LOG_MODULE_NAME arm_accton_as4610
#include <AIM/aim_log.h>
#endif /* __ONLPSIM_LOG_H__ */

View File

@@ -0,0 +1,44 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_config.h>
#include "arm_accton_as4610_log.h"
static int
datatypes_init__(void)
{
#define ONLPSIM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
#include <arm_accton_as4610/arm_accton_as4610.x>
return 0;
}
void __arm_accton_as4610_module_init__(void)
{
AIM_LOG_STRUCT_REGISTER();
datatypes_init__();
}
int __onlp_platform_version__ = 1;

View File

@@ -0,0 +1,82 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch 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 <arm_accton_as4610/arm_accton_as4610_config.h>
#if ONLPSIM_CONFIG_INCLUDE_UCLI == 1
#include <uCli/ucli.h>
#include <uCli/ucli_argparse.h>
#include <uCli/ucli_handler_macros.h>
static ucli_status_t
arm_accton_as4610_ucli_ucli__config__(ucli_context_t* uc)
{
UCLI_HANDLER_MACRO_MODULE_CONFIG(arm_accton_as4610)
}
/* <auto.ucli.handlers.start> */
/******************************************************************************
*
* These handler table(s) were autogenerated from the symbols in this
* source file.
*
*****************************************************************************/
static ucli_command_handler_f arm_accton_as4610_ucli_ucli_handlers__[] =
{
arm_accton_as4610_ucli_ucli__config__,
NULL
};
/******************************************************************************/
/* <auto.ucli.handlers.end> */
static ucli_module_t
arm_accton_as4610_ucli_module__ =
{
"arm_accton_as4610_ucli",
NULL,
arm_accton_as4610_ucli_ucli_handlers__,
NULL,
NULL,
};
ucli_node_t*
arm_accton_as4610_ucli_node_create(void)
{
ucli_node_t* n;
ucli_module_init(&arm_accton_as4610_ucli_module__);
n = ucli_node_create("arm_accton_as4610", NULL, &arm_accton_as4610_ucli_module__);
ucli_node_subnode_add(n, ucli_module_log_node_create("arm_accton_as4610"));
return n;
}
#else
void*
arm_accton_as4610_ucli_node_create(void)
{
return NULL;
}
#endif

View File

@@ -0,0 +1,345 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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>
************************************************************
*
* Fan Platform Implementation Defaults.
*
***********************************************************/
#include <onlp/platformi/fani.h>
#include <unistd.h>
#include <fcntl.h>
#include "platform_lib.h"
#include "arm_accton_as4610_int.h"
#define PREFIX_PATH_ON_MAIN_BOARD "/sys/devices/platform/as4610_fan/"
#define PREFIX_PATH_ON_PSU "/sys/bus/i2c/devices/"
#define MAX_FAN_SPEED 13000
#define MAX_PSU_FAN_SPEED 25500
#define FILE_NAME_LEN 80
enum onlp_fan_id
{
FAN_RESERVED = 0,
FAN_1_ON_MAIN_BOARD,
FAN_1_ON_PSU1,
FAN_1_ON_PSU2
};
typedef struct fan_path_S
{
char status[FILE_NAME_LEN];
char speed[FILE_NAME_LEN];
char ctrl_speed[FILE_NAME_LEN];
}fan_path_T;
#define _MAKE_FAN_PATH_ON_MAIN_BOARD(id) \
{ "fan"#id"_fault", "fan"#id"_speed_rpm", "fan_duty_cycle_percentage"}
#define MAKE_FAN_PATH_ON_MAIN_BOARD(id) _MAKE_FAN_PATH_ON_MAIN_BOARD(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 */
{
{ }, /* Not used */
MAKE_FAN_PATH_ON_MAIN_BOARD(2),
MAKE_FAN_PATH_ON_PSU(8-0058),
MAKE_FAN_PATH_ON_PSU(8-0059)
};
#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \
{ \
{ ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \
ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \
(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 }, \
ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \
(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_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
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);
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 speed
*/
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);
/* 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 psu_id;
int fd, len, nbytes = 10;
char r_data[10] = {0};
char fullpath[80] = {0};
psu_type_t psu_type;
/* get fan fault status
*/
psu_id = (local_id - FAN_1_ON_PSU1) + 1;
DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id);
psu_type = get_psu_type(psu_id, NULL, 0); /* psu_id = 1 , present PSU1. pus_id =2 , present PSU2 */
DEBUG_PRINT("[Debug][%s][%d][psu_type: %d]\n", __FUNCTION__, __LINE__, psu_type);
switch (psu_type) {
case PSU_TYPE_AC_F2B:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B);
break;
case PSU_TYPE_AC_B2F:
info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_B2F);
break;
default:
return ONLP_STATUS_E_UNSUPPORTED;
}
/* 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);
if (atoi(r_data) > 0) {
info->status |= ONLP_FAN_STATUS_FAILED;
return ONLP_STATUS_OK;
}
/* 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;
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);
if (chassis_fan_count() == 0) {
local_id += 1;
}
*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:
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);
if (chassis_fan_count() == 0) {
return ONLP_STATUS_E_INVALID;
}
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:
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;
}

View File

@@ -0,0 +1,422 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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 <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"
#include "arm_accton_as4610_int.h"
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_LED(_id)) { \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
/* LED related data
*/
enum led_light_mode {
LED_MODE_OFF = 0,
LED_MODE_GREEN,
LED_MODE_GREEN_BLINKING,
LED_MODE_AMBER,
LED_MODE_AMBER_BLINKING,
LED_MODE_RED,
LED_MODE_RED_BLINKING,
LED_MODE_BLUE,
LED_MODE_BLUE_BLINKING,
LED_MODE_AUTO,
LED_MODE_AUTO_BLINKING,
LED_MODE_UNKNOWN,
LED_MODE_SEVEN_SEGMENT_MAX = 9,
};
#define led_prefix_path "/sys/class/leds/as4610::"
#define led_filename "brightness"
typedef enum onlp_led_id
{
LED_RESERVED = 0,
LED_7SEG_DIG1,
LED_7SEG_DP1,
LED_7SEG_DIG2,
LED_7SEG_DP2,
LED_SYS,
LED_PRI,
LED_PSU1,
LED_PSU2,
LED_STK1,
LED_STK2,
LED_FAN,
LED_POE
} onlp_led_id_t;
static char onlp_led_node_subname[][20] = /* must map with onlp_led_id */
{
"reserved",
"7seg_tens",
"7seg_tens_point",
"7seg_digits",
"7seg_digits_point",
"sys",
"pri",
"psu1",
"psu2",
"stk1",
"stk2",
"fan",
"poe"
};
/*
* Get the information for the given LED OID.
*/
static onlp_led_info_t linfo[] =
{
{ }, /* Not used */
{
{ ONLP_LED_ID_CREATE(LED_7SEG_DIG1), "7-segment digit 1", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_CHAR, ONLP_LED_MODE_ON,
},
{
{ ONLP_LED_ID_CREATE(LED_7SEG_DP1), "7-segment dot 1", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN,
},
{
{ ONLP_LED_ID_CREATE(LED_7SEG_DIG2), "7-segment digit 2", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_CHAR, ONLP_LED_MODE_ON,
},
{
{ ONLP_LED_ID_CREATE(LED_7SEG_DP2), "7-segment dot 2", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN,
},
{
{ ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_PRI), "pri", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_PSU1), "psu1", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_AUTO | ONLP_LED_CAPS_AUTO_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_PSU2), "psu2", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_AUTO | ONLP_LED_CAPS_AUTO_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_STK1), "stk1", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_STK2), "stk2", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 },
ONLP_LED_STATUS_PRESENT, ONLP_LED_CAPS_AUTO | ONLP_LED_CAPS_AUTO_BLINKING,
},
{
{ ONLP_LED_ID_CREATE(LED_POE), "poe", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN_BLINKING |
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_ORANGE_BLINKING,
},
};
static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode)
{
switch (id) {
case LED_SYS:
case LED_PRI:
case LED_STK1:
case LED_STK2:
case LED_POE:
case LED_7SEG_DP1:
case LED_7SEG_DP2:
switch (led_ligth_mode) {
case LED_MODE_OFF: return ONLP_LED_MODE_OFF;
case LED_MODE_GREEN: return ONLP_LED_MODE_GREEN;
case LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING;
case LED_MODE_AMBER: return ONLP_LED_MODE_ORANGE;
case LED_MODE_AMBER_BLINKING: return ONLP_LED_MODE_ORANGE_BLINKING;
default: return ONLP_LED_MODE_OFF;
}
case LED_PSU1:
case LED_PSU2:
case LED_FAN:
switch (led_ligth_mode) {
case LED_MODE_AUTO: return ONLP_LED_MODE_AUTO;
case LED_MODE_AUTO_BLINKING: return ONLP_LED_MODE_AUTO_BLINKING;
default: return ONLP_LED_MODE_OFF;
}
}
return ONLP_LED_MODE_OFF;
}
static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode)
{
switch (id) {
case LED_SYS:
case LED_PRI:
case LED_STK1:
case LED_STK2:
case LED_POE:
case LED_7SEG_DP1:
case LED_7SEG_DP2:
switch (led_ligth_mode) {
case ONLP_LED_MODE_OFF: return LED_MODE_OFF;
case ONLP_LED_MODE_GREEN: return LED_MODE_GREEN;
case ONLP_LED_MODE_GREEN_BLINKING: return LED_MODE_GREEN_BLINKING;
case ONLP_LED_MODE_ORANGE: return LED_MODE_AMBER;
case ONLP_LED_MODE_ORANGE_BLINKING: return LED_MODE_AMBER_BLINKING;
default: return LED_MODE_OFF;
}
case LED_PSU1:
case LED_PSU2:
case LED_FAN:
switch (led_ligth_mode) {
case ONLP_LED_MODE_AUTO: return LED_MODE_AUTO;
case ONLP_LED_MODE_AUTO_BLINKING: return LED_MODE_AUTO_BLINKING;
default: return ONLP_LED_MODE_OFF;
}
}
return ONLP_LED_MODE_OFF;
}
/*
* This function will be called prior to any other onlp_ledi_* functions.
*/
int
onlp_ledi_init(void)
{
return ONLP_STATUS_OK;
}
/** Set the character */
int onlp_ledi_char_set(onlp_oid_t id, char c)
{
int fd, len, nbytes=1;
char data[2] = {0};
char fullpath[50] = {0};
int lid = ONLP_OID_ID_GET(id);
VALIDATE(id);
if (!(linfo[lid].caps & ONLP_LED_CAPS_CHAR)) {
return ONLP_STATUS_E_UNSUPPORTED;
}
sprintf(fullpath, "%s%s/%s", led_prefix_path, onlp_led_node_subname[lid], led_filename);
data[0] = c;
/* Create output file descriptor */
fd = open(fullpath, O_WRONLY | O_CREAT, 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;
}
/** Get the current character */
int onlp_ledi_char_get(onlp_oid_t id, char* c)
{
int fd, len;
char data = 0;
char fullpath[50] = {0};
int lid = ONLP_OID_ID_GET(id);
VALIDATE(id);
if (!(linfo[lid].caps & ONLP_LED_CAPS_CHAR)) {
return ONLP_STATUS_E_UNSUPPORTED;
}
sprintf(fullpath, "%s%s/%s", led_prefix_path, onlp_led_node_subname[lid], led_filename);
/* Set current char */
if ((fd = open(fullpath, O_RDONLY)) == -1) {
return ONLP_STATUS_E_INTERNAL;
}
if ((len = read(fd, &data, sizeof(data))) < 0) {
close(fd);
return ONLP_STATUS_E_INTERNAL;
}
/* If the read byte count is less, the format is different and calc will be wrong*/
if ((close(fd) == -1) || (len != sizeof(data))) {
return ONLP_STATUS_E_INTERNAL;
}
*c = data;
return ONLP_STATUS_OK;
}
int
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
int fd, len, nbytes=1;
char data[2] = {0};
char fullpath[50] = {0};
int lid = ONLP_OID_ID_GET(id);
VALIDATE(id);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[ONLP_OID_ID_GET(id)];
if (linfo[lid].caps & ONLP_LED_CAPS_CHAR) {
return onlp_ledi_char_get(id, &info->character);
}
else {
sprintf(fullpath, "%s%s/%s", led_prefix_path, onlp_led_node_subname[ONLP_OID_ID_GET(id)], led_filename);
/* Set current mode */
if ((fd = open(fullpath, O_RDONLY)) == -1) {
return ONLP_STATUS_E_INTERNAL;
}
if ((len = read(fd, data, nbytes)) < 0) {
close(fd);
return ONLP_STATUS_E_INTERNAL;
}
/* If the read byte count is less, the format is different and calc will be wrong*/
if ((close(fd) == -1) || (len != nbytes)) {
return ONLP_STATUS_E_INTERNAL;
}
info->mode = conver_led_light_mode_to_onl(ONLP_OID_ID_GET(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 fd, len, driver_mode, nbytes=1;
char data[2] = {0};
char fullpath[50] = {0};
int lid = ONLP_OID_ID_GET(id);
VALIDATE(id);
if (linfo[lid].caps & ONLP_LED_CAPS_CHAR) {
return ONLP_STATUS_E_UNSUPPORTED;
}
sprintf(fullpath, "%s%s/%s", led_prefix_path, onlp_led_node_subname[ONLP_OID_ID_GET(id)], led_filename);
driver_mode = conver_onlp_led_light_mode_to_driver(ONLP_OID_ID_GET(id),mode);
sprintf(data, "%d", driver_mode);
/* Create output file descriptor */
fd = open(fullpath, O_WRONLY | O_CREAT, 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;
}
/*
* 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,29 @@
############################################################
# <bsn.cl fy=2014 v=onl>
#
# Copyright 2014, 2015 Big Switch 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>
############################################################
#
#
#
############################################################
LIBRARY := arm_accton_as4610
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
#$(LIBRARY)_LAST := 1
include $(BUILDER)/lib.mk

View File

@@ -0,0 +1,170 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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 <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 8
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};
/* Check AC model name */
node = (id == PSU1_ID) ? PSU1_AC_EEPROM_NODE(psu_model_name) : PSU2_AC_EEPROM_NODE(psu_model_name);
if (deviceNodeReadString(node, model_name, sizeof(model_name), 0) == 0) {
if (strncmp(model_name, "YM-1921A", strlen("YM-1921A")) == 0 ||
strncmp(model_name, "YM-1151D", strlen("YM-1151D")) == 0 ||
strncmp(model_name, "YM-1601A", strlen("YM-1601A")) == 0) {
if (modelname) {
strncpy(modelname, model_name, modelname_len-1);
}
return PSU_TYPE_AC_F2B;
}
}
return PSU_TYPE_UNKNOWN;
}
enum as4610_product_id get_product_id(void)
{
char *node = "/sys/bus/i2c/devices/0-0030/product_id";
char buf[3] = {0};
int pid = PID_UNKNOWN;
if (deviceNodeReadString(node, buf, sizeof(buf), 0) != 0) {
return PID_UNKNOWN;
}
pid = atoi(buf);
if (pid >= PID_UNKNOWN || pid < PID_AS4610_30T) {
return PID_UNKNOWN;
}
return pid;
}
int chassis_fan_count(void)
{
enum as4610_product_id pid = get_product_id();
return (pid == PID_AS4610_30P || pid == PID_AS4610P) ? 1 : 0;
}
int chassis_led_count(void)
{
enum as4610_product_id pid = get_product_id();
return (pid == PID_AS4610_30P || pid == PID_AS4610P) ? 12 : 10;
}

View File

@@ -0,0 +1,98 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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>
************************************************************
*
*
*
***********************************************************/
#ifndef __PLATFORM_LIB_H__
#define __PLATFORM_LIB_H__
#include "arm_accton_as4610_log.h"
#define CHASSIS_THERMAL_COUNT 1
#define CHASSIS_PSU_COUNT 2
#define PSU1_ID 1
#define PSU2_ID 2
#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/8-0058/"
#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/8-0059/"
#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_EEPROM_PREFIX "/sys/bus/i2c/devices/8-0050/"
#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/8-0051/"
#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node
#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node
#define IDPROM_PATH "/sys/devices/1803b000.i2c/i2c-1/i2c-9/9-0050/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
enum onlp_fan_duty_cycle_percentage
{
FAN_PERCENTAGE_LOW = 13,
FAN_PERCENTAGE_HIGH = 75
};
enum as4610_product_id {
PID_AS4610_30T = 0,
PID_AS4610_30P,
PID_AS4610T,
PID_AS4610P,
PID_UNKNOWN
};
enum as4610_product_id get_product_id(void);
int chassis_fan_count(void);
int chassis_led_count(void);
typedef enum platform_id_e {
PLATFORM_ID_UNKNOWN,
PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0,
PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0,
} platform_id_t;
extern platform_id_t platform_id;
#endif /* __PLATFORM_LIB_H__ */

View File

@@ -0,0 +1,153 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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 <onlp/platformi/psui.h>
#include <onlplib/mmap.h>
#include <stdio.h>
#include <string.h>
#include "platform_lib.h"
#include "arm_accton_as4610_int.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_EEPROM_PREFIX, node);
}
else if (PSU2_ID == id) {
sprintf(node_path, "%s%s", PSU2_AC_EEPROM_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;
}
/*
* 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:
info->caps = ONLP_PSU_CAPS_AC;
ret = ONLP_STATUS_OK;
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;
}
return ret;
}
int
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,338 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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 <onlp/platformi/sfpi.h>
#include "platform_lib.h"
#include <arm_accton_as4610/arm_accton_as4610_config.h>
#include "arm_accton_as4610_log.h"
#define MAX_SFP_PATH 64
static char sfp_node_path[MAX_SFP_PATH] = {0};
#define FRONT_PORT_MUX_INDEX(port) (port-46)
static int
sfp_node_read_int(char *node_path, int *value, int data_len)
{
int ret = 0;
char buf[8];
*value = 0;
ret = deviceNodeReadString(node_path, buf, sizeof(buf), data_len);
if (ret == 0) {
*value = atoi(buf);
}
return ret;
}
static char*
sfp_get_port_path_addr(int port, int addr, char *node_name)
{
int front_port_mux_id;
if(platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0)
front_port_mux_id = port - 22;
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
front_port_mux_id = port - 46;
sprintf(sfp_node_path, "/sys/bus/i2c/devices/%d-00%d/%s",
front_port_mux_id, addr, node_name);
return sfp_node_path;
}
static char*
sfp_get_port_path(int port, char *node_name)
{
return sfp_get_port_path_addr(port, 50, node_name);
}
/************************************************************
*
* 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)
{
int p;
int start_port, end_port;
if(platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0)
{
start_port = 24;
end_port = 30;
}
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
{
start_port = 48;
end_port = 54;
}
for(p = start_port; p < end_port; p++) {
AIM_BITMAP_SET(bmap, p);
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_is_present(int port)
{
/*
* Return 1 if present.
* Return 0 if not present.
* Return < 0 if error.
*/
int present;
char* path = sfp_get_port_path(port, "sfp_is_present");
if (sfp_node_read_int(path, &present, 0) != 0) {
AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
return present;
}
int
onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{
uint32_t byte;
char* path;
FILE* fp;
int port;
AIM_BITMAP_CLR_ALL(dst);
if(platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0)
port = 24;
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
port = 48;
path = sfp_get_port_path(port, "sfp_is_present_all");
fp = fopen(path, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the sfp_is_present_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
int count = fscanf(fp, "%x", &byte);
fclose(fp);
if(count != 1) {
/* Likely a CPLD read timeout. */
AIM_LOG_ERROR("Unable to read all fields from the sfp_is_present_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
/* Convert to 64 bit integer in port order */
int i = 0;
uint64_t presence_all = byte;
presence_all <<= port;
/* 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)
{
uint32_t byte;
char* path;
FILE* fp;
int port;
if(platform_id == PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0)
port = 24;
else /*PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0*/
port = 48;
path = sfp_get_port_path(port, "sfp_rx_los_all");
fp = fopen(path, "r");
if(fp == NULL) {
AIM_LOG_ERROR("Unable to open the sfp_rx_los_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
int count = fscanf(fp, "%x", &byte);
fclose(fp);
if(count != 1) {
AIM_LOG_ERROR("Unable to read all fields from the sfp_rx_los_all device file.");
return ONLP_STATUS_E_INTERNAL;
}
/* Convert to 64 bit integer in port order */
int i = 0;
uint64_t rx_los_all = byte;
rx_los_all <<= port;
/* Populate bitmap */
for(i = 0; rx_los_all; i++) {
AIM_BITMAP_MOD(dst, i, (rx_los_all & 1));
rx_los_all >>= 1;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
{
char* path = sfp_get_port_path(port, "sfp_eeprom");
/*
* Read the SFP eeprom into data[]
*
* Return MISSING if SFP is missing.
* Return OK if eeprom is read
*/
memset(data, 0, 256);
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_dom_read(int port, uint8_t data[256])
{
char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
memset(data, 0, 256);
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port);
return ONLP_STATUS_E_INTERNAL;
}
return ONLP_STATUS_OK;
}
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
int rv;
switch(control)
{
case ONLP_SFP_CONTROL_TX_DISABLE:
{
char* path = sfp_get_port_path(port, "sfp_tx_disable");
if (deviceNodeWriteInt(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
break;
}
return rv;
}
int
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
{
int rv;
char* path = NULL;
switch(control)
{
case ONLP_SFP_CONTROL_RX_LOS:
{
path = sfp_get_port_path(port, "sfp_rx_los");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read rx_los status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
case ONLP_SFP_CONTROL_TX_FAULT:
{
path = sfp_get_port_path(port, "sfp_tx_fault");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
case ONLP_SFP_CONTROL_TX_DISABLE:
{
path = sfp_get_port_path(port, "sfp_tx_disable");
if (sfp_node_read_int(path, value, 0) != 0) {
AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port);
rv = ONLP_STATUS_E_INTERNAL;
}
else {
rv = ONLP_STATUS_OK;
}
break;
}
default:
rv = ONLP_STATUS_E_UNSUPPORTED;
}
return rv;
}
int
onlp_sfpi_denit(void)
{
return ONLP_STATUS_OK;
}

View File

@@ -0,0 +1,208 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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 <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 "arm_accton_as4610_int.h"
#include "arm_accton_as4610_log.h"
#include "platform_lib.h"
#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
platform_id_t platform_id = PLATFORM_ID_UNKNOWN;
const char*
onlp_sysi_platform_get(void)
{
return "arm-accton-as4610";
}
int
onlp_sysi_platform_set(const char* platform)
{
if(strstr(platform, "arm-accton-as4610-30-r0")) {
platform_id = PLATFORM_ID_POWERPC_ACCTON_AS4610_30_R0;
return ONLP_STATUS_OK;
}
if(strstr(platform, "arm-accton-as4610-54-r0")) {
platform_id = PLATFORM_ID_POWERPC_ACCTON_AS4610_54_R0;
return ONLP_STATUS_OK;
}
AIM_LOG_ERROR("No support for platform '%s'", platform);
return ONLP_STATUS_E_UNSUPPORTED;
}
int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
int v;
int fd, len, nbytes = 10;
char r_data[10] = {0};
char fullpath[65] = {0};
sprintf(fullpath, "/sys/bus/i2c/devices/0-0030/version");
OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len);
v = atoi(r_data);
pi->cpld_versions = aim_fstrdup("%d", v);
return 0;
}
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;
}
void
onlp_sysi_onie_data_free(uint8_t* data)
{
aim_free(data);
}
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));
/* 1 Thermal sensors on the chassis */
for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) {
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
/* LEDs on the chassis */
for (i = 1; i <= chassis_led_count(); i++) {
*e++ = ONLP_LED_ID_CREATE(i);
}
/* 1 Fans on the chassis */
for (i = 1; i <= chassis_fan_count(); i++) {
*e++ = ONLP_FAN_ID_CREATE(i);
}
/* 2 PSUs on the chassis */
for (i = 1; i <= CHASSIS_PSU_COUNT; i++) {
*e++ = ONLP_PSU_ID_CREATE(i);
}
return 0;
}
int
onlp_sysi_platform_manage_fans(void)
{
int rc, oldP, newP = 0;
onlp_thermal_info_t ti;
int fd, len;
char buf[10] = {0};
char path[70] = "/sys/devices/platform/as4610_fan/fan_duty_cycle_percentage";
if (chassis_fan_count() == 0) {
return ONLP_STATUS_E_UNSUPPORTED;
}
/* Get fan duty cycle */
fd = open(path, O_RDWR, 0644);
if (fd == -1){
return ONLP_STATUS_E_INTERNAL;
}
len = read(fd, buf, sizeof(buf));
if (len <= 0){
close(fd);
return ONLP_STATUS_E_INTERNAL;
}
if (close(fd) == -1) {
return ONLP_STATUS_E_INTERNAL;
}
DEBUG_PRINT("[Debug][%s][%d][read data: %s]\n", __FUNCTION__, __LINE__, buf);
oldP = atoi(buf);
/* Get temperature */
rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &ti);
if (rc != ONLP_STATUS_OK) {
return rc;
}
/* Bring fan speed to high if current speed is unexpected
*/
if (oldP != FAN_PERCENTAGE_LOW && oldP != FAN_PERCENTAGE_HIGH) {
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_PERCENTAGE_HIGH);
return ONLP_STATUS_OK;
}
if (oldP == FAN_PERCENTAGE_LOW && ti.mcelsius >= 61000) {
newP = FAN_PERCENTAGE_HIGH;
}
else if (oldP == FAN_PERCENTAGE_HIGH && ti.mcelsius <= 49000) {
newP = FAN_PERCENTAGE_LOW;
}
if (newP) {
onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), newP);
}
return ONLP_STATUS_OK;
}
int
onlp_sysi_platform_manage_leds(void)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,130 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 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>
************************************************************
*
* Thermal Sensor Platform Implementation.
*
***********************************************************/
#include <unistd.h>
#include <onlplib/mmap.h>
#include <onlplib/file.h>
#include <onlp/platformi/thermali.h>
#include <fcntl.h>
#include "platform_lib.h"
#include "arm_accton_as4610_log.h"
#define prefix_path "/sys/bus/i2c/devices/"
#define LOCAL_DEBUG 0
#define VALIDATE(_id) \
do { \
if(!ONLP_OID_IS_THERMAL(_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
enum onlp_thermal_id
{
THERMAL_RESERVED = 0,
THERMAL_1_ON_MAIN_BROAD,
THERMAL_1_ON_PSU1,
THERMAL_1_ON_PSU2,
};
static char* last_path[] = /* must map with onlp_thermal_id */
{
"reserved",
"9-0048/temp1_input",
"8-0058/psu_temp1_input",
"8-0059/psu_temp1_input",
};
/* 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_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(1)},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{ { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(2)},
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 fd, len, nbytes = 10, temp_base=1, local_id;
char r_data[10] = {0};
char fullpath[50] = {0};
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
/* Set the onlp_oid_hdr_t and capabilities */
*info = linfo[local_id];
/* 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);
return ONLP_STATUS_OK;
}