mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Port to new ONLPv2 APIs.
This commit is contained in:
@@ -218,9 +218,9 @@ onlp_snmp_platform_init(void)
|
||||
int rv;
|
||||
onlp_onie_info_t* oip = NULL;
|
||||
|
||||
if(ONLP_SUCCESS(rv = onlp_attribute_get(ONLP_OID_CHASSIS,
|
||||
ONLP_ATTRIBUTE_ONIE_INFO,
|
||||
(void**)&oip))) {
|
||||
if(ONLP_SUCCESS(rv = onlp_attribute_onie_info_get(ONLP_OID_CHASSIS,
|
||||
&oip))) {
|
||||
|
||||
#define REGISTER_STR(_index, _field) \
|
||||
do { \
|
||||
platform_string_register(_index, #_field, (char*)oip->_field); \
|
||||
@@ -249,12 +249,8 @@ onlp_snmp_platform_init(void)
|
||||
REGISTER_STR(13, diag_version);
|
||||
REGISTER_STR(14, service_tag);
|
||||
REGISTER_STR(15, onie_version);
|
||||
|
||||
onlp_attribute_free(ONLP_OID_CHASSIS,
|
||||
ONLP_ATTRIBUTE_ONIE_INFO,
|
||||
oip);
|
||||
onlp_attribute_onie_info_free(ONLP_OID_CHASSIS, oip);
|
||||
}
|
||||
|
||||
resource_int_register(1, "CpuAllPercentUtilization", utilization_handler);
|
||||
resource_int_register(2, "CpuAllPercentIdle", idle_handler);
|
||||
}
|
||||
|
||||
@@ -21,13 +21,9 @@ packages:
|
||||
- name: oom-shim
|
||||
version: 1.0.0
|
||||
summary: Open Optical Module Wrapper library around ONLP
|
||||
provides: [ oom_shim ]
|
||||
provides: [ oom-shim ]
|
||||
|
||||
files:
|
||||
builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/
|
||||
|
||||
changelog: Initial code for 2016 OCP Demo
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,10 +27,9 @@ include $(ONL)/make/any.mk
|
||||
MODULE := oom_shim
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM onlplib onlp oom_shim cjson cjson_util sff IOF timer_wheel OS
|
||||
DEPENDMODULES := AIM onlplib oom_shim cjson cjson_util IOF timer_wheel OS uCli
|
||||
DEPENDMODULE_HEADERS := onlp sff
|
||||
|
||||
#LIBONLP_PLATFORM_DEFAULTS := ../onlp-platform-defaults/$(BUILD_DIR)/bin/libonlp-platform-defaults.so
|
||||
#LIBONLP_PLATFORM := ../onlp-platform/$(BUILD_DIR)/bin/libonlp-platform.so
|
||||
LIBONLP := $(shell $(ONLPM) --find-file onlp:$(ARCH) libonlp.so)
|
||||
|
||||
include $(BUILDER)/dependmodules.mk
|
||||
@@ -45,6 +44,8 @@ GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_CTOR_DTOR=1
|
||||
GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1
|
||||
GLOBAL_CFLAGS += -DONLP_CONFIG_API_LOCK_GLOBAL_SHARED=1
|
||||
GLOBAL_CFLAGS += -DONLP_CONFIG_INCLUDE_SHLOCK_GLOBAL_INIT=1
|
||||
GLOBAL_CFLAGS += -DUCLI_CONFIG_INCLUDE_ELS_LOOP=1
|
||||
GLOBAL_CFLAGS += -DONLP_CONFIG_INCLUDE_UCLI=1
|
||||
|
||||
GLOBAL_CFLAGS += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread $(LIBONLP)
|
||||
|
||||
@@ -32,24 +32,24 @@
|
||||
|
||||
/*
|
||||
* Initializing the SFP and ONLP modules
|
||||
* compiler calls this function while compiling
|
||||
* compiler calls this function while compiling
|
||||
*/
|
||||
|
||||
void __oom_shim_module_init__(void) {
|
||||
onlp_init();
|
||||
onlp_sw_init(0);
|
||||
}
|
||||
|
||||
/*Gets the portlist of the SFP ports on the switch*/
|
||||
int oom_get_portlist(oom_port_t portlist[], int listsize){
|
||||
|
||||
|
||||
int port,i=0;
|
||||
oom_port_t* pptr;
|
||||
|
||||
|
||||
|
||||
onlp_sfp_bitmap_t bitmap;
|
||||
onlp_sfp_bitmap_t_init(&bitmap);
|
||||
onlp_sfp_bitmap_get(&bitmap);
|
||||
|
||||
|
||||
if ((portlist == NULL) && (listsize == 0)){ /* asking # of ports */
|
||||
if(AIM_BITMAP_COUNT(&bitmap) == 0){
|
||||
return 0;
|
||||
@@ -60,13 +60,13 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){
|
||||
|
||||
AIM_BITMAP_ITER(&bitmap, port){
|
||||
int rv;
|
||||
|
||||
|
||||
pptr = &portlist[i];
|
||||
pptr->handle = (void *)(uintptr_t)port+1;
|
||||
pptr->oom_class = OOM_PORT_CLASS_SFF;
|
||||
pptr->oom_class = OOM_PORT_CLASS_SFF;
|
||||
sprintf(pptr->name, "port%d", port+1);
|
||||
i++;
|
||||
|
||||
|
||||
rv = onlp_sfp_is_present(port);
|
||||
if(rv == 0){
|
||||
/* aim_printf(&aim_pvs_stdout, "module %d is not present\n", port);*/
|
||||
@@ -86,7 +86,7 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){
|
||||
|
||||
int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data){
|
||||
int rv;
|
||||
unsigned int port_num;
|
||||
unsigned int port_num;
|
||||
uint8_t* idprom = NULL;
|
||||
|
||||
port_num = (unsigned int)(uintptr_t)port->handle;
|
||||
@@ -95,15 +95,15 @@ int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int
|
||||
if (offset >= 256)
|
||||
return -1; /* out of range */
|
||||
|
||||
/**
|
||||
* place holder implementation until onlp_sfp_eeprom_read()
|
||||
/**
|
||||
* place holder implementation until onlp_sfp_eeprom_read()
|
||||
* can be improved to handle partial page gets
|
||||
**/
|
||||
|
||||
if (address == 0xa0) {
|
||||
rv = onlp_sfp_eeprom_read(port_num, &idprom);
|
||||
rv = onlp_sfp_dev_read_block(port_num, 0x50, 0, 256, &idprom);
|
||||
} else if (address == 0xa2) {
|
||||
rv = onlp_sfp_dom_read(port_num, &idprom);
|
||||
rv = onlp_sfp_dev_read_block(port_num, 0x51, 0, 256, &idprom);
|
||||
} else {
|
||||
aim_printf(&aim_pvs_stdout, "Error invalid address: 0x%02x\n", address);
|
||||
return -EINVAL;
|
||||
@@ -113,9 +113,9 @@ int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int
|
||||
aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n");
|
||||
return -1;
|
||||
}
|
||||
memcpy(data, &idprom[offset], len);
|
||||
memcpy(data, &idprom[offset], len);
|
||||
aim_free(idprom);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user