Add new platform: AG9064.

This commit is contained in:
chenglin-tsai
2017-12-19 16:20:49 +08:00
parent b502c9edb4
commit 97b52ca0ad
40 changed files with 2601 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
*x86*64*delta*ag9064*.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/platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag9064 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64"

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-delta-ag9064 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-delta-ag9064
include $(BUILDER)/standardinit.mk
DEPENDMODULES := AIM IOF x86_64_delta_ag9064 onlplib
DEPENDMODULE_HEADERS := sff
include $(BUILDER)/dependmodules.mk
SHAREDLIB := libonlp-x86-64-delta-ag9064.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_delta_ag9064 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_delta_ag9064

View File

@@ -0,0 +1,10 @@
############################################################
#
#
#
############################################################
include $(ONL)/make/config.mk
MODULE := x86_64_delta_ag9064
AUTOMODULE := x86_64_delta_ag9064
include $(BUILDER)/definemodule.mk

View File

@@ -0,0 +1,10 @@
###############################################################################
#
# x86_64_delta_ag9064 Autogeneration
#
###############################################################################
x86_64_delta_ag9064_AUTO_DEFS := module/auto/x86_64_delta_ag9064.yml
x86_64_delta_ag9064_AUTO_DIRS := module/inc/x86_64_delta_ag9064 module/src
include $(BUILDER)/auto.mk

View File

@@ -0,0 +1,55 @@
###############################################################################
#
# x86_64_delta_ag9064 Autogeneration Definitions.
#
###############################################################################
cdefs: &cdefs
- X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING:
doc: "Include or exclude logging."
default: 1
- X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT:
doc: "Default enabled log options."
default: AIM_LOG_OPTIONS_DEFAULT
- X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT:
doc: "Default enabled log bits."
default: AIM_LOG_BITS_DEFAULT
- X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
doc: "Default enabled custom log bits."
default: 0
- X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB:
doc: "Default all porting macros to use the C standard libraries."
default: 1
- X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
doc: "Include standard library headers for stdlib porting macros."
default: X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB
- X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI:
doc: "Include generic uCli support."
default: 0
- X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION:
doc: "Assume chassis fan direction is the same as the PSU fan direction."
default: 0
- X86_64_DELTA_AG9064_CONFIG_SFP_COUNT:
doc: "SFP port numbers."
default: 64
- X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX:
doc: "Max fan speed."
default: 13000
definitions:
cdefs:
X86_64_DELTA_AG9064_CONFIG_HEADER:
defs: *cdefs
basename: x86_64_delta_ag9064_config
portingmacro:
X86_64_DELTA_AG9064:
macros:
- malloc
- free
- memset
- memcpy
- strncpy
- vsnprintf
- snprintf
- strlen

View File

@@ -0,0 +1,16 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_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,155 @@
/**************************************************************************//**
*
* @file
* @brief x86_64_delta_AG9064 Configuration Header
*
* @addtogroup x86_64_delta_AG9064-config
* @{
*
*****************************************************************************/
#ifndef __X86_64_DELTA_AG9064_CONFIG_H__
#define __X86_64_DELTA_AG9064_CONFIG_H__
#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG
#include <global_custom_config.h>
#endif
#ifdef X86_64_DELTA_AG9064_INCLUDE_CUSTOM_CONFIG
#include <x86_64_delta_ag9064_custom_config.h>
#endif
/* <auto.start.cdefs(X86_64_DELTA_AG9064_CONFIG_HEADER).header> */
#include <AIM/aim.h>
/**
* X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING
*
* Include or exclude logging. */
#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING
#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING 1
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT
*
* Default enabled log options. */
#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT
#define X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT
*
* Default enabled log bits. */
#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT
#define X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT
*
* Default enabled custom log bits. */
#ifndef X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT
#define X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB
*
* Default all porting macros to use the C standard libraries. */
#ifndef X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB
#define X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB 1
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
*
* Include standard library headers for stdlib porting macros. */
#ifndef X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
#define X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI
*
* Include generic uCli support. */
#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI
#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI 0
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
*
* Assume chassis fan direction is the same as the PSU fan direction. */
#ifndef X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
#define X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_SFP_COUNT
*
* SFP port numbers. */
#ifndef X86_64_DELTA_AG9064_CONFIG_SFP_COUNT
#define X86_64_DELTA_AG9064_CONFIG_SFP_COUNT 64
#endif
/**
* X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX
*
* Max fan speed. */
#ifndef X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX
#define X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX 13000
#endif
/**
* All compile time options can be queried or displayed
*/
/** Configuration settings structure. */
typedef struct x86_64_delta_ag9064_config_settings_s {
/** name */
const char* name;
/** value */
const char* value;
} x86_64_delta_ag9064_config_settings_t;
/** Configuration settings table. */
/** x86_64_delta_ag9064_config_settings table. */
extern x86_64_delta_ag9064_config_settings_t x86_64_delta_ag9064_config_settings[];
/**
* @brief Lookup a configuration setting.
* @param setting The name of the configuration option to lookup.
*/
const char* x86_64_delta_ag9064_config_lookup(const char* setting);
/**
* @brief Show the compile-time configuration.
* @param pvs The output stream.
*/
int x86_64_delta_ag9064_config_show(struct aim_pvs_s* pvs);
/* <auto.end.cdefs(X86_64_DELTA_AG9064_CONFIG_HEADER).header> */
#include "x86_64_delta_ag9064_porting.h"
#endif /* __X86_64_DELTA_AG9064_CONFIG_H__ */
/* @} */

View File

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

View File

@@ -0,0 +1,107 @@
/**************************************************************************//**
*
* @file
* @brief x86_64_delta_wb2448 Porting Macros.
*
* @addtogroup x86_64_delta_wb2448-porting
* @{
*
*****************************************************************************/
#ifndef __X86_64_DELTA_AG9064_PORTING_H__
#define __X86_64_DELTA_AG9064_PORTING_H__
/* <auto.start.portingmacro(ALL).define> */
#if X86_64_DELTA_AG9064_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_DELTA_AG9064_MALLOC
#if defined(GLOBAL_MALLOC)
#define X86_64_DELTA_AG9064_MALLOC GLOBAL_MALLOC
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_MALLOC malloc
#else
#error The macro X86_64_DELTA_AG9064_MALLOC is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_FREE
#if defined(GLOBAL_FREE)
#define X86_64_DELTA_AG9064_FREE GLOBAL_FREE
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_FREE free
#else
#error The macro X86_64_DELTA_AG9064_FREE is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_MEMSET
#if defined(GLOBAL_MEMSET)
#define X86_64_DELTA_AG9064_MEMSET GLOBAL_MEMSET
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_MEMSET memset
#else
#error The macro X86_64_DELTA_AG9064_MEMSET is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_MEMCPY
#if defined(GLOBAL_MEMCPY)
#define X86_64_DELTA_AG9064_MEMCPY GLOBAL_MEMCPY
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_MEMCPY memcpy
#else
#error The macro X86_64_DELTA_AG9064_MEMCPY is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_STRNCPY
#if defined(GLOBAL_STRNCPY)
#define X86_64_DELTA_AG9064_STRNCPY GLOBAL_STRNCPY
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_STRNCPY strncpy
#else
#error The macro X86_64_DELTA_AG9064_STRNCPY is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_VSNPRINTF
#if defined(GLOBAL_VSNPRINTF)
#define X86_64_DELTA_AG9064_VSNPRINTF GLOBAL_VSNPRINTF
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_VSNPRINTF vsnprintf
#else
#error The macro X86_64_DELTA_AG9064_VSNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_SNPRINTF
#if defined(GLOBAL_SNPRINTF)
#define X86_64_DELTA_AG9064_SNPRINTF GLOBAL_SNPRINTF
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_SNPRINTF snprintf
#else
#error The macro X86_64_DELTA_AG9064_SNPRINTF is required but cannot be defined.
#endif
#endif
#ifndef X86_64_DELTA_AG9064_STRLEN
#if defined(GLOBAL_STRLEN)
#define X86_64_DELTA_AG9064_STRLEN GLOBAL_STRLEN
#elif X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB == 1
#define X86_64_DELTA_AG9064_STRLEN strlen
#else
#error The macro X86_64_DELTA_AG9064_STRLEN is required but cannot be defined.
#endif
#endif
/* <auto.end.portingmacro(ALL).define> */
#endif /* __X86_64_DELTA_AG9064_PORTING_H__ */
/* @} */

View File

@@ -0,0 +1,10 @@
###############################################################################
#
#
#
###############################################################################
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
x86_64_delta_ag9064_INCLUDES := -I $(THIS_DIR)inc
x86_64_delta_ag9064_INTERNAL_INCLUDES := -I $(THIS_DIR)src
x86_64_delta_ag9064_DEPENDMODULE_ENTRIES := init:x86_64_delta_ag9064 ucli:x86_64_delta_ag9064

View File

@@ -0,0 +1,12 @@
###############################################################################
#
# Local source generation targets.
#
###############################################################################
include ../../../../init.mk
ucli:
$(SUBMODULE_BIGCODE)/tools/uclihandlers.py x86_64_delta_ag9064_ucli.c

View File

@@ -0,0 +1,278 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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>
************************************************************
*
* Fan Platform Implementation Defaults.
*
***********************************************************/
#include <onlp/platformi/fani.h>
#include "x86_64_delta_ag9064_int.h"
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do \
{ \
if(!ONLP_OID_IS_FAN(_id)) \
{ \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
/* Static values */
static onlp_fan_info_t linfo[] =
{
{ }, /* Not used */
{
{ ONLP_FAN_ID_CREATE(FAN_1_ON_FAN_BOARD), "Chassis Fan 4 front", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_2_ON_FAN_BOARD), "Chassis Fan 3 front", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_3_ON_FAN_BOARD), "Chassis Fan 2 front", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_4_ON_FAN_BOARD), "Chassis Fan 1 front", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_6_ON_FAN_BOARD), "Chassis Fan 4 rear", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_7_ON_FAN_BOARD), "Chassis Fan 3 rear", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_8_ON_FAN_BOARD), "Chassis Fan 2 rear", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_9_ON_FAN_BOARD), "Chassis Fan 1 rear", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_ON_PSU1), "FAN ON PSU1", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
{
{ ONLP_FAN_ID_CREATE(FAN_ON_PSU2), "FAN ON PSU2", 0},
ONLP_FAN_STATUS_PRESENT,
ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, 0, 0, ONLP_FAN_MODE_INVALID,
},
};
int onlp_fani_init(void)
{
return ONLP_STATUS_OK;
}
static int ifnLinearDataToDecimal(uint16_t u16Value, uint16_t u16ManLen, uint16_t u16ExpLen)
{
uint16_t ManMask = 1;
uint16_t ExpMask = 1;
uint16_t Mantissa, Exponent;
uint8_t index;
for(index = 1; index < u16ManLen; index++)
{
ManMask <<= 1;
ManMask |= 0x1;
}
for(index = 1; index < u16ExpLen; index++)
{
ExpMask <<= 1;
ExpMask |= 0x1;
}
/* Didn't check the negative bit */
Mantissa = u16Value & ManMask;
Exponent = u16Value >> u16ManLen;
for(index = 0; index < Exponent; index++)
{
Mantissa *= 2;
}
return Mantissa;
}
static int dni_fani_info_get_on_fanboard(int local_id, onlp_fan_info_t* info)
{
int rv = ONLP_STATUS_OK;
uint32_t FanSpeed = 0;
switch(local_id)
{
case FAN_1_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_1", &FanSpeed);
break;
case FAN_2_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_2", &FanSpeed);
break;
case FAN_3_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_3", &FanSpeed);
break;
case FAN_4_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_4", &FanSpeed);
break;
case FAN_6_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_6", &FanSpeed);
break;
case FAN_7_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_7", &FanSpeed);
break;
case FAN_8_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_8", &FanSpeed);
break;
case FAN_9_ON_FAN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Fan_9", &FanSpeed);
break;
default:
AIM_LOG_ERROR("Invalid Fan ID!!\n");
rv = ONLP_STATUS_E_INVALID;
}
if(rv == ONLP_STATUS_OK)
{
info->rpm = FanSpeed;
info->percentage = (info->rpm * 100) / X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX;
}
return ONLP_STATUS_OK;
}
static int dni_fani_info_get_on_psu(int local_id, onlp_fan_info_t* info)
{
int rv = ONLP_STATUS_OK;
uint32_t FanSpeed = 0;
switch(local_id)
{
case FAN_ON_PSU1:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_1, FAN_ON_PSU1_ADDR, FAN_SPEED_PMBUS, &FanSpeed, 2);
break;
case FAN_ON_PSU2:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_1, FAN_ON_PSU2_ADDR, FAN_SPEED_PMBUS, &FanSpeed, 2);
break;
default:
AIM_LOG_ERROR("Invalid Fan ID!!\n");
return ONLP_STATUS_E_INVALID;
}
if(rv == ONLP_STATUS_OK)
{
FanSpeed = ((FanSpeed >> 8) | (FanSpeed << 8));
FanSpeed = ifnLinearDataToDecimal( FanSpeed, 11, 5 );
info->rpm = FanSpeed;
info->percentage = (info->rpm * 100) / X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX;
}
return rv;
}
int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
{
int rv = ONLP_STATUS_OK;
int local_id = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
*info = linfo[ONLP_OID_ID_GET(id)];
switch(local_id)
{
case FAN_1_ON_FAN_BOARD:
case FAN_2_ON_FAN_BOARD:
case FAN_3_ON_FAN_BOARD:
case FAN_4_ON_FAN_BOARD:
case FAN_6_ON_FAN_BOARD:
case FAN_7_ON_FAN_BOARD:
case FAN_8_ON_FAN_BOARD:
case FAN_9_ON_FAN_BOARD:
rv = dni_fani_info_get_on_fanboard(local_id, info);
break;
case FAN_ON_PSU1:
case FAN_ON_PSU2:
rv = dni_fani_info_get_on_psu(local_id, info);
break;
default:
AIM_LOG_ERROR("Invalid Fan ID!!\n");
rv = ONLP_STATUS_E_INVALID;
}
return rv;
}
int onlp_fani_percentage_set(onlp_oid_t id, int p)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int onlp_fani_rpm_set(onlp_oid_t id, int rpm)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int onlp_fani_ioctl(onlp_oid_t fid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,344 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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 <onlp/platformi/ledi.h>
#include "x86_64_delta_ag9064_int.h"
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do \
{ \
if(!ONLP_OID_IS_LED(_id)) \
{ \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
/*
* Get the information for the given LED OID.
*/
typedef struct led_light_mode_map
{
enum onlp_led_id id;
enum led_light_mode driver_led_mode;
enum onlp_led_mode_e onlp_led_mode;
} led_light_mode_map_t;
led_light_mode_map_t led_map[] =
{
{LED_FAN, LED_MODE_OFF, ONLP_LED_MODE_OFF},
{LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
{LED_FAN, LED_MODE_RED, ONLP_LED_MODE_RED},
{LED_SYS, LED_MODE_OFF, ONLP_LED_MODE_OFF},
{LED_SYS, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
{LED_SYS, LED_MODE_GREEN_BLINK, ONLP_LED_MODE_GREEN_BLINKING},
{LED_SYS, LED_MODE_SYS_RED, ONLP_LED_MODE_RED},
{LED_PSU2, LED_MODE_OFF, ONLP_LED_MODE_OFF},
{LED_PSU2, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
{LED_PSU2, LED_MODE_RED, ONLP_LED_MODE_RED},
{LED_PSU1, LED_MODE_OFF, ONLP_LED_MODE_OFF},
{LED_PSU1, LED_MODE_GREEN, ONLP_LED_MODE_GREEN},
{LED_PSU1, LED_MODE_RED, ONLP_LED_MODE_RED},
{LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE},
{LED_FAN_TRAY_1, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN},
{LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE},
{LED_FAN_TRAY_2, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN},
{LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE},
{LED_FAN_TRAY_3, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN},
{LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_AMBER, ONLP_LED_MODE_ORANGE},
{LED_FAN_TRAY_4, LED_MODE_FAN_TRAY_GREEN, ONLP_LED_MODE_GREEN},
};
static onlp_led_info_t linfo[] =
{
{ },
{
{ ONLP_LED_ID_CREATE(LED_FAN), "FAN LED (FRONT PANEL)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_SYS), "SYSTEM LED (FRONT PANEL)", 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_ID_CREATE(LED_PSU1), "PSU1 LED (FRONT PANEL)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_PSU2), "PSU2 LED (FRONT PANEL)", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), "FAN TRAY 1", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), "FAN TRAY 2", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), "FAN TRAY 3", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE,
},
{
{ ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), "FAN TRAY 4", 0 },
ONLP_LED_STATUS_PRESENT,
ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_ORANGE,
},
};
static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode)
{
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
for (i = 0; i < nsize; i++)
{
if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode)
{
return led_map[i].onlp_led_mode;
}
}
return 0;
}
static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode)
{
int i, nsize = sizeof(led_map)/sizeof(led_map[0]);
for(i = 0; i < nsize; i++)
{
if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode)
{
return led_map[i].driver_led_mode;
}
}
return 0;
}
int onlp_ledi_init(void)
{
return ONLP_STATUS_OK;
}
int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
{
int rv = ONLP_STATUS_OK;
int local_id = 0;
uint32_t LedMode = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
*info = linfo[local_id];
/* Get LED mode */
switch(local_id)
{
case LED_FAN:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_SYS_FRONT_REGISTER, &LedMode, 1);
LedMode = ((LedMode >> LED_FAN_FRONT_BIT) & 0x03);
break;
case LED_SYS:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_SYS_FRONT_REGISTER, &LedMode, 1);
LedMode = ((LedMode >> LED_SYS_FRONT_BIT) & 0x03);
break;
case LED_PSU1:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &LedMode, 1);
if ( ((LedMode >> PSU1_INT_BIT) & 0x01) == PSU_INT_HAPPEN_STATUS )
{
LedMode = LED_MODE_RED;
}
else if( ((LedMode >> PSU1_POWER_GOOD_BIT) & 0x01) == PSU_POWER_GOOD_STATUS )
{
LedMode = LED_MODE_GREEN;
}
else
{
LedMode = LED_MODE_OFF;
}
break;
case LED_PSU2:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &LedMode, 1);
if ( ((LedMode >> PSU2_INT_BIT) & 0x01) == PSU_INT_HAPPEN_STATUS )
{
LedMode = LED_MODE_RED;
}
else if( ((LedMode >> PSU2_POWER_GOOD_BIT) & 0x01) == PSU_POWER_GOOD_STATUS )
{
LedMode = LED_MODE_GREEN;
}
else
{
LedMode = LED_MODE_OFF;
}
break;
case LED_FAN_TRAY_1:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1);
LedMode = (LedMode >> LED_FAN_TRAY_1_BIT ) & 0x01;
break;
case LED_FAN_TRAY_2:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1);
LedMode = (LedMode >> LED_FAN_TRAY_2_BIT) & 0x01;
break;
case LED_FAN_TRAY_3:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1);
LedMode = (LedMode >> LED_FAN_TRAY_3_BIT) & 0x01;
break;
case LED_FAN_TRAY_4:
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LED_FAN_TRAY_REGISTER, &LedMode, 1);
LedMode = (LedMode >> LED_FAN_TRAY_4_BIT) & 0x01;
break;
default:
AIM_LOG_ERROR("Invalid LED ID!!\n");
rv = ONLP_STATUS_E_PARAM;
}
if( rv == ONLP_STATUS_OK)
{
info->mode = driver_to_onlp_led_mode(local_id, LedMode);
/* Set the on/off status */
if (info->mode != ONLP_LED_MODE_OFF)
{
info->status |= ONLP_LED_STATUS_ON;
}
}
return rv;
}
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;
}
int onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}
int onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
int rv = ONLP_STATUS_OK;
int local_id = 0;
uint32_t LEDAddr = 0;
uint32_t NewLedMode = 0;
uint32_t OldLedMode = 0;
onlp_led_mode_t driver_led_mode = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
driver_led_mode = onlp_to_driver_led_mode(local_id, mode);
switch(local_id)
{
case LED_FAN:
LEDAddr = LED_FAN_SYS_FRONT_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0x3F) | ((driver_led_mode << 6) & 0xC0) );
break;
case LED_SYS:
LEDAddr = LED_FAN_SYS_FRONT_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0xCF) | ((driver_led_mode << 4) & 0x30) );
break;
case LED_PSU1:
case LED_PSU2:
AIM_LOG_ERROR("PSU LED (FRONT) is read only!!\n");
rv = ONLP_STATUS_E_UNSUPPORTED;
break;
case LED_FAN_TRAY_1:
LEDAddr = LED_FAN_TRAY_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0x7F) | ((driver_led_mode << 7) & 0x01) );
break;
case LED_FAN_TRAY_2:
LEDAddr = LED_FAN_TRAY_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0xBF) | ((driver_led_mode << 6) & 0x01) );
break;
case LED_FAN_TRAY_3:
LEDAddr = LED_FAN_TRAY_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0xDF) | ((driver_led_mode << 5) & 0x01) );
break;
case LED_FAN_TRAY_4:
LEDAddr = LED_FAN_TRAY_REGISTER;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, &OldLedMode, 1);
NewLedMode = ( (OldLedMode & 0xEF) | ((driver_led_mode << 4) & 0x01) );
break;
default:
rv = ONLP_STATUS_E_PARAM;
AIM_LOG_ERROR("Invalid LED ID!!\n");
}
if(rv == ONLP_STATUS_OK)
{
rv = ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_5, SWPLD_2_ADDR, LEDAddr, NewLedMode, 1);
}
return rv;
}

View File

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

View File

@@ -0,0 +1,238 @@
/************************************************************
* <bsn.cl fy=2017 v=onl>
*
* Copyright 2017 Delta 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 <sys/mman.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <AIM/aim.h>
#include <onlp/onlp.h>
#include "platform_lib.h"
int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t *rdata, uint8_t datalen)
{
int rv = ONLP_STATUS_OK;
int dIndex = 1;
char *pch = NULL;
FILE *pFd = NULL;
int tmp_data[OS_MAX_MSG_SIZE] = {0};
char ipmi_cmd[OS_MAX_MSG_SIZE] = {0};
char cmd_rdata[OS_MAX_MSG_SIZE] = {0};
sprintf(ipmi_cmd, "ipmitool raw 0x38 0x2 %d %d %d %d", bus, dev, reg, datalen);
pFd = popen(ipmi_cmd, "r");
if(pFd != NULL)
{
if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL)
{
memset(tmp_data, 0x0, sizeof(tmp_data));
for(dIndex = 1; dIndex <= datalen; dIndex++)
{
if(dIndex == 1)
{
pch = strtok(cmd_rdata," ");
}
else
{
pch = strtok(NULL," ");
}
if(!pch)
{
AIM_LOG_ERROR("Command \"%s\": Extract Data Failed (ret: %d)", ipmi_cmd, ONLP_STATUS_E_INTERNAL);
return ONLP_STATUS_E_INTERNAL;
}
else
{ /* cut newline char */
if( pch[strlen(pch)-1] == '\n')
{
pch[strlen(pch)-1] = 0x0;
}
}
tmp_data[dIndex] = xtoi(pch);
}
switch (datalen)
{
case 1:
*rdata = tmp_data[1];
break;
case 2:
*rdata = (tmp_data[1] << 8) | (tmp_data[2]);
break;
default:
if( (datalen > 2) && (datalen < 64) )
{
for(dIndex = 1; dIndex <= datalen; dIndex++)
{
rdata[dIndex - 1] = tmp_data[dIndex];
}
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Command \"%s\": data length out of range (ret: %d)", ipmi_cmd, rv);
}
}
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv);
}
pclose(pFd);
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv);
}
return rv;
}
int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t reg, uint32_t u4Data, uint8_t datalen)
{
int rv = ONLP_STATUS_OK;
FILE *pFd = NULL;
char ipmi_cmd[OS_MAX_MSG_SIZE] = {0};
switch (datalen)
{
case 1:
sprintf(ipmi_cmd, "ipmitool raw 0x38 0x3 %d %d %d %d", bus, dev, reg, u4Data);
break;
case 2:
sprintf(ipmi_cmd, "ipmitool raw 0x38 0x4 %d %d %d %d %d", bus, dev, reg,
((u4Data & 0xFF00) >> 8), (u4Data & 0xFF));
break;
case 4:
sprintf(ipmi_cmd, "ipmitool raw 0x38 0x5 %d %d %d %d %d %d %d", bus, dev, reg,
((u4Data & 0xFF000000) >> 24), ((u4Data & 0xFF0000) >> 16), ((u4Data & 0xFF00) >> 8), (u4Data & 0xFF));
break;
default:
AIM_LOG_ERROR("ERR: Unsupported data length: %d", datalen);
}
pFd = popen(ipmi_cmd, "r");
if (pFd != NULL)
{
pclose(pFd);
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv);
}
return rv;
}
int ifnOS_LINUX_BmcGetDataByName(char *devname, uint32_t *rdata)
{
int rv = ONLP_STATUS_OK;
char *temp_data = NULL;
FILE *pFd = NULL;
uint32_t devdata = 0;
char ipmi_cmd [OS_MAX_MSG_SIZE] = {0};
char cmd_rdata[OS_MAX_MSG_SIZE] = {0};
sprintf(ipmi_cmd, "ipmitool sdr get %s | grep 'Sensor Reading'", devname);
pFd = popen(ipmi_cmd, "r");
if(pFd != NULL)
{
if (fgets(cmd_rdata, OS_MAX_MSG_SIZE, pFd) != NULL)
{
temp_data = strchr(cmd_rdata, ':');
temp_data = strtok(temp_data, "(");
do
{
devdata += strtol(temp_data, &temp_data, 10);
}while (*temp_data++);
*rdata = devdata;
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Command \"%s\": Get Data Failed (ret: %d)", ipmi_cmd, rv);
}
pclose(pFd);
}
else
{
rv = ONLP_STATUS_E_INTERNAL;
AIM_LOG_ERROR("Execute command \"%s\" failed (ret: %d)", ipmi_cmd, rv);
}
return rv;
}
uint32_t xtoi(const char* str)
{
int digit = 0;
uint32_t x = 0;
if ((*str == '0') && (*(str+1) == 'x')) str += 2;
while (*str)
{
if ((*str >= '0') && (*str <= '9'))
{
digit = *str - '0';
}
else if ((*str >= 'A') && (*str <= 'F'))
{
digit = 10 + *str - 'A';
}
else if ((*str >= 'a') && (*str <= 'f'))
{
digit = 10 + *str - 'a';
}
else
{
break;
}
x *= 16;
x += digit;
str++;
}
return x;
}

View File

@@ -0,0 +1,173 @@
/************************************************************
* <bsn.cl fy=2017 v=onl>
*
* Copyright 2017 Delta 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 __PLATFORM_LIB_H__
#define __PLATFORM_LIB_H__
#include "x86_64_delta_ag9064_log.h"
#define IDPROM_PATH "/sys/class/i2c-adapter/i2c-0/0-0056/eeprom"
#define I2C_BMC_BUS_1 0x00
#define I2C_BMC_BUS_3 0x02
#define I2C_BMC_BUS_5 0x04
#define I2C_BUS_1 0x00
#define I2C_BUS_2 0x01
#define I2C_BUS_3 0x02
#define SWPLD_1_ADDR 0x35
#define SWPLD_2_ADDR 0x34
#define SWPLD_3_ADDR 0x33
#define SWPLD_4_ADDR 0x32
#define NUM_OF_THERMAL_ON_MAIN_BROAD 6
#define NUM_OF_LED_ON_MAIN_BROAD 8
#define NUM_OF_PSU_ON_MAIN_BROAD 2
#define NUM_OF_FAN_ON_MAIN_BROAD 8
#define NUM_OF_FAN_ON_PSU_BROAD 2
#define NUM_OF_FAN NUM_OF_FAN_ON_MAIN_BROAD + NUM_OF_FAN_ON_PSU_BROAD
#define CPLD_VERSION_REGISTER 0x00
#define CPLD_VERSION_OFFSET 4
#define LED_FAN_SYS_FRONT_REGISTER 0x02
#define LED_FAN_TRAY_REGISTER 0x1B
#define LED_FAN_FRONT_BIT 0x06
#define LED_SYS_FRONT_BIT 0x04
#define LED_FAN_TRAY_1_BIT 0x07
#define LED_FAN_TRAY_2_BIT 0x06
#define LED_FAN_TRAY_3_BIT 0x05
#define LED_FAN_TRAY_4_BIT 0x04
#define PSU_STATUS_REGISTER 0x02
#define PSU1_PRESENT_BIT 0x07
#define PSU1_POWER_GOOD_BIT 0x06
#define PSU1_INT_BIT 0x05
#define PSU2_PRESENT_BIT 0x03
#define PSU2_POWER_GOOD_BIT 0x02
#define PSU2_INT_BIT 0x01
#define PSU_INT_HAPPEN_STATUS 0x01
#define PSU_POWER_GOOD_STATUS 0x00
#define PSU_PRESENT_STATUS 0x00
#define FAN_SPEED_PMBUS 0x90
#define FAN_ON_PSU1_ADDR 0x58
#define FAN_ON_PSU2_ADDR 0x59
#define THERMAL_CPU_ADDR 0x4D
#define THERMAL_FAN_ADDR 0x4F
#define THERMAL_1_ADDR 0x4C
#define THERMAL_2_ADDR 0x4E
#define THERMAL_3_ADDR 0x4B
#define THERMAL_4_ADDR 0x4A
#define THERMAL_REGISTER 0x00
#define QSFP_MIN_PORT 1
#define QSFP_MAX_PORT 64
#define PCA9548_I2C_MUX_ADDR 0x70
#define QSFP_CHAN_ON_PCA9548 0x04
#define QSFP_PORT_MUX_REG 0x13
#define QSFP_EEPROM_ADDR 0x50
#define QSFP_1_TO_8_PRESENT_REG 0x03
#define QSFP_9_TO_16_PRESENT_REG 0x03
#define QSFP_17_TO_24_PRESENT_REG 0x24
#define QSFP_25_TO_32_PRESENT_REG 0x24
#define QSFP_33_TO_40_PRESENT_REG 0x04
#define QSFP_41_TO_48_PRESENT_REG 0x04
#define QSFP_49_TO_56_PRESENT_REG 0x25
#define QSFP_57_TO_64_PRESENT_REG 0x25
#define OS_MAX_MSG_SIZE 100
#define INVALID_ADDR 0xFF
#define INVALID_REG 0xFF
#define INVALID_REG_BIT 0xFF
enum onlp_led_id
{
LED_RESERVED = 0,
LED_FAN,
LED_SYS,
LED_PSU1,
LED_PSU2,
LED_FAN_TRAY_1,
LED_FAN_TRAY_2,
LED_FAN_TRAY_3,
LED_FAN_TRAY_4
};
enum onlp_fan_id
{
FAN_RESERVED = 0,
FAN_1_ON_FAN_BOARD,
FAN_2_ON_FAN_BOARD,
FAN_3_ON_FAN_BOARD,
FAN_4_ON_FAN_BOARD,
FAN_6_ON_FAN_BOARD,
FAN_7_ON_FAN_BOARD,
FAN_8_ON_FAN_BOARD,
FAN_9_ON_FAN_BOARD,
FAN_ON_PSU1,
FAN_ON_PSU2
};
enum onlp_psu_id
{
PSU_RESERVED = 0,
PSU_1,
PSU_2,
};
enum onlp_thermal_id
{
THERMAL_RESERVED = 0,
THERMAL_CPU_CORE,
THERMAL_ON_FAN_BROAD,
THERMAL_1_ON_MAIN_BOARD,
THERMAL_2_ON_MAIN_BOARD,
THERMAL_3_ON_MAIN_BOARD,
THERMAL_4_ON_MAIN_BOARD,
};
enum led_light_mode
{
LED_MODE_OFF = 0,
LED_MODE_GREEN = 1,
LED_MODE_RED = 2,
LED_MODE_FAN_TRAY_GREEN = 1,
LED_MODE_SYS_RED = 3,
LED_MODE_FAN_TRAY_AMBER = 0,
LED_MODE_GREEN_BLINK = 2,
LED_MODE_UNKNOWN
};
int ifnOS_LINUX_BmcI2CGet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t *data, uint8_t datalen);
int ifnOS_LINUX_BmcI2CSet(uint8_t bus, uint8_t dev, uint32_t addr, uint32_t data, uint8_t datalen);
int ifnOS_LINUX_BmcGetDataByName(char *FanName, uint32_t *data);
uint32_t xtoi(const char* str);
#endif /* __PLATFORM_LIB_H__ */

View File

@@ -0,0 +1,128 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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 <onlp/platformi/psui.h>
#include "x86_64_delta_ag9064_int.h"
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do \
{ \
if(!ONLP_OID_IS_PSU(_id)) \
{ \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
/*
* Get all information about the given PSU oid.
*/
static onlp_psu_info_t pinfo[] =
{
{ }, /* Not used */
{
{ ONLP_PSU_ID_CREATE(PSU_1), "PSU 1", 0 },
{"DPS-1300AB-6 D"},
},
{
{ ONLP_PSU_ID_CREATE(PSU_2), "PSU 2", 0 },
{"DPS-1300AB-6 D"},
}
};
int onlp_psui_init(void)
{
return ONLP_STATUS_OK;
}
int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
{
int rv = ONLP_STATUS_OK;
int local_id = 0;
uint32_t PSUStatus = 0;
uint32_t PSUIsPresent = 0;
uint32_t PSUIsGood = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
*info = pinfo[local_id];
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, PSU_STATUS_REGISTER, &PSUStatus, 1);
if(rv == ONLP_STATUS_OK)
{
switch(local_id)
{
case PSU_1:
PSUIsPresent = PSUStatus >> PSU1_PRESENT_BIT;
PSUIsGood = (PSUStatus >> PSU1_POWER_GOOD_BIT) & 0x01;
break;
case PSU_2:
PSUIsPresent = (PSUStatus >> PSU2_PRESENT_BIT) & 0x01;
PSUIsGood = (PSUStatus >> PSU2_POWER_GOOD_BIT) & 0x01;
break;
default:
AIM_LOG_ERROR("Invalid PSU ID!!\n");
return ONLP_STATUS_E_PARAM;
}
if (PSUIsPresent != PSU_PRESENT_STATUS)
{
info->status &= ~ONLP_PSU_STATUS_PRESENT;
return ONLP_STATUS_OK;
}
else
{
info->status |= ONLP_PSU_STATUS_PRESENT;
}
if (PSUIsGood != PSU_POWER_GOOD_STATUS)
{
info->status |= ONLP_PSU_STATUS_FAILED;
}
}
else
{
AIM_LOG_ERROR("Unable to read PSU present status: %d\r\n", rv);
return ONLP_STATUS_E_INVALID;
}
return rv;
}
int onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,276 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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 <onlp/platformi/sfpi.h>
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
#include "x86_64_delta_ag9064_log.h"
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include <onlplib/i2c.h>
#include "platform_lib.h"
struct portCtrl
{
int portId;
int swpldAddr;
int presentReg;
int presentRegBit;
int rxLosReg;
int rxLosRegBit;
int txDisableReg;
int txDisableRegBit;
};
static struct portCtrl gPortCtrl[] =
{
{},
{1, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{2, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{3, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{4, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{5, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{6, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{7, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{8, SWPLD_1_ADDR, QSFP_1_TO_8_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{9, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{10, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{11, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{12, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{13, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{14, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{15, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{16, SWPLD_2_ADDR, QSFP_9_TO_16_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{17, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{18, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{19, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{20, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{21, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{22, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{23, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{24, SWPLD_4_ADDR, QSFP_17_TO_24_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{25, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{26, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{27, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{28, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{29, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{30, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{31, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{32, SWPLD_3_ADDR, QSFP_25_TO_32_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{33, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{34, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{35, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{36, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{37, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{38, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{39, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{40, SWPLD_1_ADDR, QSFP_33_TO_40_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{41, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{42, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{43, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{44, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{45, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{46, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{47, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{48, SWPLD_2_ADDR, QSFP_41_TO_48_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{49, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{50, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{51, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{52, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{53, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{54, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{55, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{56, SWPLD_4_ADDR, QSFP_49_TO_56_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{57, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
{58, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 1, INVALID_REG, 0, INVALID_REG, 0},
{59, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 2, INVALID_REG, 0, INVALID_REG, 0},
{60, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 3, INVALID_REG, 0, INVALID_REG, 0},
{61, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 4, INVALID_REG, 0, INVALID_REG, 0},
{62, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 5, INVALID_REG, 0, INVALID_REG, 0},
{63, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 6, INVALID_REG, 0, INVALID_REG, 0},
{64, SWPLD_3_ADDR, QSFP_57_TO_64_PRESENT_REG, 7, INVALID_REG, 0, INVALID_REG, 0},
{0xFFFF, INVALID_ADDR , INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0},
};
static int port_to_presence_all_bitmap(int portstart, int portend, uint64_t* presence_all)
{
int i = 0;
int rv = ONLP_STATUS_OK;
uint32_t present_bit = 0;
for (i = portstart; i <= portend; i += 8)
{
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, gPortCtrl[i].swpldAddr, gPortCtrl[i].presentReg, &present_bit, 1);
if (rv != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", i, rv);
return ONLP_STATUS_E_INTERNAL;
}
present_bit = ~(present_bit) & 0xFF;
*presence_all |= ((uint64_t)(present_bit)) << (((i - 1)/ 8) * 8);
}
return 0;
}
int onlp_sfpi_init(void)
{
return ONLP_STATUS_OK;
}
int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
{
int p;
AIM_BITMAP_CLR_ALL(bmap);
for(p = QSFP_MIN_PORT; p <= QSFP_MAX_PORT; p++)
{
AIM_BITMAP_SET(bmap, p);
}
return ONLP_STATUS_OK;
}
int onlp_sfpi_is_present(int port)
{
int rv = ONLP_STATUS_OK;
uint32_t present_bit = 0, IsPresent = 0;
if( (port >= QSFP_MIN_PORT) && (port <= QSFP_MAX_PORT) )
{
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, gPortCtrl[port].swpldAddr, gPortCtrl[port].presentReg, &present_bit, 1);
if (rv == ONLP_STATUS_OK)
{
present_bit = (present_bit >> gPortCtrl[port].presentRegBit ) & 0x01;
/* From sfp_is_present value,
* return 0 = The module is preset
* return 1 = The module is NOT present
*/
if(present_bit == 0)
{
IsPresent = 1;
}
else if (present_bit == 1)
{
IsPresent = 0;
}
else
{
AIM_LOG_ERROR("Error to present status from port(%d)\r\n", port);
IsPresent = -1;
}
return IsPresent;
}
else
{
AIM_LOG_ERROR("Unable to read present status from port(%d). error code: %d\r\n", port, rv);
return ONLP_STATUS_E_INTERNAL;
}
}
else
{
AIM_LOG_ERROR("The port %d is invalid \r\n", port);
return ONLP_STATUS_E_UNSUPPORTED;
}
}
int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
{
int i = 0;
uint64_t presence_all = 0;
AIM_BITMAP_CLR_ALL(dst);
port_to_presence_all_bitmap(1, 64, &presence_all);
/* Populate bitmap */
for(i = QSFP_MIN_PORT; 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_E_UNSUPPORTED;
}
int onlp_sfpi_eeprom_read(int port, uint8_t data[256])
{
if(onlp_i2c_writeb(I2C_BUS_3, PCA9548_I2C_MUX_ADDR, 0x00, QSFP_CHAN_ON_PCA9548, 0) != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("ERROR: unable to set QSFP channel on PCA9548\n");
return ONLP_STATUS_E_INTERNAL;
}
if(ifnOS_LINUX_BmcI2CSet(I2C_BMC_BUS_5, SWPLD_2_ADDR, QSFP_PORT_MUX_REG, port, 1) != ONLP_STATUS_OK)
{
AIM_LOG_ERROR("ERROR: unable to set QSFP port mux\n");
return ONLP_STATUS_E_INTERNAL;
}
memset(data, 0 ,256);
/* Read eeprom information into data[] */
if (onlp_i2c_read(I2C_BUS_3, QSFP_EEPROM_ADDR, 0x00, 256, data, 0) != 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])
{
return onlp_sfpi_eeprom_read( port, data);
}
int onlp_sfpi_ioctl(int port, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,214 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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>
************************************************************
*
* HardwareVersion: 02
*
***********************************************************/
#include <onlp/platformi/sysi.h>
#include <onlplib/crc32.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 "x86_64_delta_ag9064_log.h"
#include "platform_lib.h"
const char* onlp_sysi_platform_get(void)
{
return "x86-64-delta-ag9064-r0";
}
int onlp_sysi_init(void)
{
return ONLP_STATUS_OK;
}
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_platform_info_get(onlp_platform_info_t* pi)
{
int rv = ONLP_STATUS_OK;
uint32_t u4Data = 0;
rv = ifnOS_LINUX_BmcI2CGet(I2C_BMC_BUS_5, SWPLD_1_ADDR, CPLD_VERSION_REGISTER, &u4Data, 1);
if(rv == ONLP_STATUS_OK)
{
u4Data = u4Data >> CPLD_VERSION_OFFSET;
pi->cpld_versions = aim_fstrdup("%d", u4Data);
}
return rv;
}
void onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
{
aim_free(pi->cpld_versions);
}
int onlp_sysi_oids_get(onlp_oid_t* table, int max)
{
int i = 0;
onlp_oid_t* e = table;
memset(table, 0, max*sizeof(onlp_oid_t));
for (i = 1; i <= NUM_OF_THERMAL_ON_MAIN_BROAD; i++)
{
*e++ = ONLP_THERMAL_ID_CREATE(i);
}
for (i = 1; i <= NUM_OF_LED_ON_MAIN_BROAD; i++)
{
*e++ = ONLP_LED_ID_CREATE(i);
}
for (i = 1; i <= NUM_OF_PSU_ON_MAIN_BROAD; i++)
{
*e++ = ONLP_PSU_ID_CREATE(i);
}
for (i = 1; i <= NUM_OF_FAN; i++)
{
*e++ = ONLP_FAN_ID_CREATE(i);
}
return 0;
}
int onlp_sysi_platform_manage_leds(void)
{
int i = 0, rc = ONLP_STATUS_OK;
onlp_fan_info_t fan_info;
onlp_led_mode_t fan_new_mode;
onlp_led_mode_t fan_tray_new_mode[NUM_OF_FAN_ON_MAIN_BROAD];
onlp_psu_info_t psu_info[NUM_OF_PSU_ON_MAIN_BROAD];
onlp_led_mode_t psu_new_mode[NUM_OF_PSU_ON_MAIN_BROAD];
onlp_led_mode_t sys_new_mode;
/* FAN LED */
for(i = 0; i < NUM_OF_FAN_ON_MAIN_BROAD; i++)
{
rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fan_info);
if ( (rc != ONLP_STATUS_OK) || !(fan_info.status & ONLP_FAN_STATUS_PRESENT) )
{
fan_tray_new_mode[i] = ONLP_LED_MODE_ORANGE;
continue;
}
else
{
if(fan_info.status & ONLP_FAN_STATUS_FAILED)
{
fan_tray_new_mode[i] = ONLP_LED_MODE_ORANGE;
continue;
}
}
fan_tray_new_mode[i] = ONLP_LED_MODE_GREEN;
}
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_1), fan_tray_new_mode[0]);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_2), fan_tray_new_mode[1]);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_3), fan_tray_new_mode[2]);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY_4), fan_tray_new_mode[3]);
if((fan_tray_new_mode[0] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[1] == ONLP_LED_MODE_GREEN) &&
(fan_tray_new_mode[2] == ONLP_LED_MODE_GREEN) && (fan_tray_new_mode[3] == ONLP_LED_MODE_GREEN))
{
fan_new_mode = ONLP_LED_MODE_GREEN;
}
else
{
fan_new_mode = ONLP_LED_MODE_ORANGE;
}
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), fan_new_mode);
/* PSU1 and PSU2 LED */
for( i = 0; i < NUM_OF_PSU_ON_MAIN_BROAD; i++)
{
rc = onlp_psui_info_get(ONLP_PSU_ID_CREATE(i+1), &psu_info[i]);
if (rc != ONLP_STATUS_OK)
{
psu_new_mode[i] = ONLP_LED_MODE_OFF;
continue;
}
if(psu_info[i].status & ONLP_PSU_STATUS_PRESENT)
{
if(psu_info[i].status & ONLP_PSU_STATUS_FAILED)
{
psu_new_mode[i] = ONLP_LED_MODE_RED;
}
else
{
psu_new_mode[i] = ONLP_LED_MODE_GREEN;
}
}
else
{
psu_new_mode[i] = ONLP_LED_MODE_OFF;
}
}
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU1), psu_new_mode[0]);
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PSU2), psu_new_mode[1]);
/* SYS LED */
if( ((psu_new_mode[0] == ONLP_LED_MODE_GREEN) || (psu_new_mode[1] == ONLP_LED_MODE_GREEN)) &&
(fan_new_mode == ONLP_LED_MODE_GREEN))
{
sys_new_mode = ONLP_LED_MODE_GREEN;
}
else
{
sys_new_mode = ONLP_LED_MODE_RED;
}
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), sys_new_mode);
return ONLP_STATUS_OK;
}

View File

@@ -0,0 +1,141 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
* Copyright 2017 Delta 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>
************************************************************
*
* Thermal Sensor Platform Implementation.
*
***********************************************************/
#include <onlp/platformi/thermali.h>
#include "x86_64_delta_ag9064_log.h"
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <onlplib/mmap.h>
#include <onlplib/i2c.h>
#include "platform_lib.h"
#define VALIDATE(_id) \
do \
{ \
if(!ONLP_OID_IS_THERMAL(_id)) \
{ \
return ONLP_STATUS_E_INVALID; \
} \
} while(0)
/* 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_ON_FAN_BROAD), "FAN Board", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{
{ ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BOARD), "Close to right case", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{
{ ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BOARD), "Placed between QSFP cage and MAC", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{
{ ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BOARD), "Close to left case", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
{
{ ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BOARD), "Board sensor near MAC", 0},
ONLP_THERMAL_STATUS_PRESENT,
ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
},
};
int onlp_thermali_init(void)
{
return ONLP_STATUS_OK;
}
int onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
{
int rv = ONLP_STATUS_OK;
int local_id = 0;
int temp_base = 1000;
uint32_t temp_data = 0;
VALIDATE(id);
local_id = ONLP_OID_ID_GET(id);
*info = linfo[local_id];
switch(local_id)
{
case THERMAL_CPU_CORE:
rv = onlp_i2c_read(I2C_BUS_2, THERMAL_CPU_ADDR, THERMAL_REGISTER, 1, (uint8_t*)&temp_data, 0);
break;
case THERMAL_1_ON_MAIN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Temp_1", &temp_data);
break;
case THERMAL_2_ON_MAIN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Temp_2", &temp_data);
break;
case THERMAL_3_ON_MAIN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Temp_3", &temp_data);
break;
case THERMAL_4_ON_MAIN_BOARD:
rv = ifnOS_LINUX_BmcGetDataByName("Temp_4", &temp_data);
break;
case THERMAL_ON_FAN_BROAD:
rv = ifnOS_LINUX_BmcGetDataByName("Temp_5", &temp_data);
break;
default:
AIM_LOG_ERROR("Invalid Thermal ID!!\n");
return ONLP_STATUS_E_PARAM;
}
if(rv == ONLP_STATUS_OK)
{
info->mcelsius = temp_data * temp_base;
}
return rv;
}
int onlp_thermali_ioctl(int id, va_list vargs)
{
return ONLP_STATUS_E_UNSUPPORTED;
}

View File

@@ -0,0 +1,93 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
/* <auto.start.cdefs(x86_64_delta_ag9064_CONFIG_HEADER).source> */
#define __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x) #_x
#define __x86_64_delta_ag9064_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag9064_config_STRINGIFY_NAME(_x)
x86_64_delta_ag9064_config_settings_t x86_64_delta_ag9064_config_settings[] =
{
#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING) },
#else
{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_LOGGING(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT) },
#else
{ X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT) },
#else
{ X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT) },
#else
{ X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB) },
#else
{ X86_64_DELTA_AG9064_CONFIG_PORTING_STDLIB(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) },
#else
{ X86_64_DELTA_AG9064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI) },
#else
{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_UCLI(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) },
#else
{ X86_64_DELTA_AG9064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_SFP_COUNT
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_SFP_COUNT), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_SFP_COUNT) },
#else
{ X86_64_DELTA_AG9064_CONFIG_SFP_COUNT(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
#ifdef X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX
{ __x86_64_delta_ag9064_config_STRINGIFY_NAME(X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX), __x86_64_delta_ag9064_config_STRINGIFY_VALUE(X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX) },
#else
{ X86_64_DELTA_AG9064_CONFIG_FAN_RPM_MAX(__x86_64_delta_ag9064_config_STRINGIFY_NAME), "__undefined__" },
#endif
{ NULL, NULL }
};
#undef __x86_64_delta_ag9064_config_STRINGIFY_VALUE
#undef __x86_64_delta_ag9064_config_STRINGIFY_NAME
const char*
x86_64_delta_ag9064_config_lookup(const char* setting)
{
int i;
for(i = 0; x86_64_delta_ag9064_config_settings[i].name; i++) {
if(strcmp(x86_64_delta_ag9064_config_settings[i].name, setting)) {
return x86_64_delta_ag9064_config_settings[i].value;
}
}
return NULL;
}
int
x86_64_delta_ag9064_config_show(struct aim_pvs_s* pvs)
{
int i;
for(i = 0; x86_64_delta_ag9064_config_settings[i].name; i++) {
aim_printf(pvs, "%s = %s\n", x86_64_delta_ag9064_config_settings[i].name, x86_64_delta_ag9064_config_settings[i].value);
}
return i;
}
/* <auto.end.cdefs(x86_64_delta_ag9064_CONFIG_HEADER).source> */

View File

@@ -0,0 +1,12 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
/* <--auto.start.enum(ALL).source> */
/* <auto.end.enum(ALL).source> */

View File

@@ -0,0 +1,13 @@
/**************************************************************************//**
*
* x86_64_delta_ag9064 Internal Header
*
*****************************************************************************/
#ifndef __X86_64_DELTA_AG9064_INT_H__
#define __X86_64_DELTA_AG9064_INT_H__
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
#endif /* __X86_64_DELTA_AG9064_INT_H__ */

View File

@@ -0,0 +1,21 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
#include "x86_64_delta_ag9064_log.h"
/*
* x86_64_delta_ag9064 log struct.
*/
AIM_LOG_STRUCT_DEFINE
(
X86_64_DELTA_AG9064_CONFIG_LOG_OPTIONS_DEFAULT,
X86_64_DELTA_AG9064_CONFIG_LOG_BITS_DEFAULT,
NULL, /* Custom log map */
X86_64_DELTA_AG9064_CONFIG_LOG_CUSTOM_BITS_DEFAULT
);

View File

@@ -0,0 +1,14 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#ifndef __X86_64_DELTA_AG9064_LOG_H__
#define __X86_64_DELTA_AG9064_LOG_H__
#define AIM_LOG_MODULE_NAME x86_64_delta_ag9064
#include <AIM/aim_log.h>
#endif /* __X86_64_DELTA_AG9064_LOG_H__ */

View File

@@ -0,0 +1,26 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
#include "x86_64_delta_ag9064_log.h"
static int
datatypes_init__(void)
{
#define x86_64_DELTA_AG9064_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
#include <x86_64_delta_ag9064/x86_64_delta_ag9064.x>
return 0;
}
void __x86_64_delta_ag9064_module_init__(void)
{
AIM_LOG_STRUCT_REGISTER();
datatypes_init__();
}
int __onlp_platform_version__ = 1;

View File

@@ -0,0 +1,64 @@
/**************************************************************************//**
*
*
*
*****************************************************************************/
#include <x86_64_delta_ag9064/x86_64_delta_ag9064_config.h>
#if X86_64_DELTA_AG9064_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_delta_ag9064_ucli_ucli__config__(ucli_context_t* uc)
{
UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_ag9064)
}
/* <auto.ucli.handlers.start> */
/******************************************************************************
*
* These handler table(s) were autogenerated from the symbols in this
* source file.
*
*****************************************************************************/
static ucli_command_handler_f x86_64_delta_ag9064_ucli_ucli_handlers__[] =
{
x86_64_delta_ag9064_ucli_ucli__config__,
NULL
};
/******************************************************************************/
/* <auto.ucli.handlers.end> */
static ucli_module_t
x86_64_delta_ag9064_ucli_module__ =
{
"x86_64_delta_ag9064_ucli",
NULL,
x86_64_delta_ag9064_ucli_ucli_handlers__,
NULL,
NULL,
};
ucli_node_t*
x86_64_delta_ag9064_ucli_node_create(void)
{
ucli_node_t* n;
ucli_module_init(&x86_64_delta_ag9064_ucli_module__);
n = ucli_node_create("x86_64_delta_ag9064", NULL, &x86_64_delta_ag9064_ucli_module__);
ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_ag9064"));
return n;
}
#else
void*
x86_64_delta_ag9064_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,2 @@
!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag9064 REVISION=r0

View File

@@ -0,0 +1,30 @@
---
######################################################################
#
# platform-config for DELTA ag9064
######################################################################
x86-64-delta-ag9064-r0:
grub:
serial: >-
--port=0x3f8
--speed=115200
--word=8
--parity=no
--stop=1
kernel:
<<: *kernel-3-16
args: >-
nopat
console=ttyS0,115200n8
##network
## interfaces:
## ma1:
## name: ~
## syspath: pci0000:00/0000:00:03.0

View File

@@ -0,0 +1,18 @@
from onl.platform.base import *
from onl.platform.delta import *
class OnlPlatform_x86_64_delta_ag9064_r0(OnlPlatformDelta,
OnlPlatformPortConfig_64x100):
PLATFORM='x86-64-delta-ag9064-r0'
MODEL="ag9064"
SYS_OBJECT_ID=".9064.1"
def baseconfig(self):
# initiate eeprom
self.new_i2c_device('24c02', 0x56, 0)
self.insmod('i2c-mei')
return True