mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-11-01 10:48:18 +00:00
Merge pull request #35 from rohitmalaga/oom
Oom_shim to support OCP demo
This commit is contained in:
16
docs/dev.md
Normal file
16
docs/dev.md
Normal file
@@ -0,0 +1,16 @@
|
||||
==== FIXME ===
|
||||
Finish this doc
|
||||
|
||||
== Adding a new package
|
||||
|
||||
* Create most of the files in the 'any' architecture for cross compiling
|
||||
* Copy the directory structure from an existing package
|
||||
* APKG.yml goes into the $(ONL)/packages/base/any/foo/ directory
|
||||
* PKG.yml goes into the $(ONL)/packages/base/$ARCH/foo directory
|
||||
* Create for each $ARCH you intend to support
|
||||
* Put code in $(ONL)/packages/base/any/foo/src
|
||||
* Put package specific Makefiles in $(ONL)/packages/base/any/builds
|
||||
|
||||
* Run `make rebuild` in $(ONL)/packages/base/$ARCH/foo to rebuild the package cache
|
||||
* particularly if you see an error like:
|
||||
"""ERROR:onlpm:'Package all does not exist.'"""
|
||||
1
packages/base/amd64/oom-shim/Makefile
Normal file
1
packages/base/amd64/oom-shim/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
2
packages/base/amd64/oom-shim/PKG.yml
Normal file
2
packages/base/amd64/oom-shim/PKG.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu
|
||||
|
||||
3
packages/base/amd64/oom-shim/builds/Makefile
Normal file
3
packages/base/amd64/oom-shim/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
include $(ONL)/make/config.amd64.mk
|
||||
include $(ONL)/packages/base/any/oom-shim/builds/Makefile
|
||||
|
||||
10
packages/base/amd64/oom-shim/builds/oom_shim.mk
Normal file
10
packages/base/amd64/oom-shim/builds/oom_shim.mk
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the oom_shim module.
|
||||
#
|
||||
# Autogenerated 2016-02-16 14:17:39.946619
|
||||
#
|
||||
###############################################################################
|
||||
oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
32
packages/base/any/oom-shim/APKG.yml
Normal file
32
packages/base/any/oom-shim/APKG.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
############################################################
|
||||
#
|
||||
# OOM SHIM
|
||||
#
|
||||
# Requires: ARCH, TOOLCHAIN
|
||||
#
|
||||
############################################################
|
||||
variables:
|
||||
libdir: /lib/${TOOLCHAIN}
|
||||
|
||||
common:
|
||||
arch: $ARCH
|
||||
version: 1.0.0
|
||||
copyright: Copyright 2016 Big Switch Networks
|
||||
maintainer: support@bigswitch.com
|
||||
|
||||
|
||||
|
||||
packages:
|
||||
- name: oom-shim
|
||||
version: 1.0.0
|
||||
summary: Open Optical Module Wrapper library around ONLP
|
||||
provides: [ oom_shim ]
|
||||
|
||||
files:
|
||||
builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/
|
||||
|
||||
changelog: Initial code for 2016 OCP Demo
|
||||
|
||||
|
||||
|
||||
|
||||
56
packages/base/any/oom-shim/builds/Makefile
Normal file
56
packages/base/any/oom-shim/builds/Makefile
Normal file
@@ -0,0 +1,56 @@
|
||||
# -*- Makefile -*-
|
||||
############################################################
|
||||
# <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/any.mk
|
||||
|
||||
MODULE := oom_shim
|
||||
include $(BUILDER)/standardinit.mk
|
||||
|
||||
DEPENDMODULES := AIM onlplib onlp oom_shim cjson cjson_util sff IOF timer_wheel OS
|
||||
|
||||
#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
|
||||
|
||||
SHAREDLIB := liboom-south.so
|
||||
$(SHAREDLIB)_TARGETS := $(ALL_TARGETS)
|
||||
include $(BUILDER)/so.mk
|
||||
|
||||
.DEFAULT_GOAL := sharedlibs
|
||||
|
||||
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 += -fPIC
|
||||
GLOBAL_LINK_LIBS += -lpthread $(LIBONLP)
|
||||
|
||||
include $(BUILDER)/targets.mk
|
||||
|
||||
.PHONY: deb
|
||||
deb:
|
||||
$(MAKE) -C deb
|
||||
4
packages/base/any/oom-shim/src/Makefile
Normal file
4
packages/base/any/oom-shim/src/Makefile
Normal file
@@ -0,0 +1,4 @@
|
||||
include $(ONL)/make/config.mk
|
||||
MODULE := oom_shim
|
||||
AUTOMODULE := oom_shim
|
||||
include $(BUILDER)/definemodule.mk
|
||||
28
packages/base/any/oom-shim/src/module/auto/make.mk
Normal file
28
packages/base/any/oom-shim/src/module/auto/make.mk
Normal file
@@ -0,0 +1,28 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=onl>
|
||||
#
|
||||
# Copyright 2013, 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>
|
||||
############################################################
|
||||
#
|
||||
# faultd Autogeneration
|
||||
#
|
||||
############################################################
|
||||
oom_shim_AUTO_DEFS := module/auto/oom_shim.yml
|
||||
oom_shim_AUTO_DIRS := module/inc/oom_shim module/src
|
||||
include $(BUILDER)/auto.mk
|
||||
|
||||
86
packages/base/any/oom-shim/src/module/auto/oom_shim.yml
Normal file
86
packages/base/any/oom-shim/src/module/auto/oom_shim.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
############################################################
|
||||
# <bsn.cl fy=2013 v=onl>
|
||||
#
|
||||
# Copyright 2013, 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>
|
||||
############################################################
|
||||
#
|
||||
# faultd Autogeneration Definitions.
|
||||
#
|
||||
############################################################
|
||||
|
||||
cdefs: &cdefs
|
||||
- OOM_SHIM_CONFIG_INCLUDE_LOGGING:
|
||||
doc: "Include or exclude logging."
|
||||
default: 1
|
||||
- OOM_SHIM_CONFIG_LOG_OPTIONS_DEFAULT:
|
||||
doc: "Default enabled log options."
|
||||
default: AIM_LOG_OPTIONS_DEFAULT
|
||||
- OOM_SHIM_CONFIG_LOG_BITS_DEFAULT:
|
||||
doc: "Default enabled log bits."
|
||||
default: AIM_LOG_BITS_DEFAULT
|
||||
- OOM_SHIM_CONFIG_LOG_CUSTOM_BITS_DEFAULT:
|
||||
doc: "Default enabled custom log bits."
|
||||
default: 0
|
||||
- OOM_SHIM_CONFIG_PORTING_STDLIB:
|
||||
doc: "Default all porting macros to use the C standard libraries."
|
||||
default: 1
|
||||
- OOM_SHIM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS:
|
||||
doc: "Include standard library headers for stdlib porting macros."
|
||||
default: OOM_SHIM_CONFIG_PORTING_STDLIB
|
||||
- OOM_SHIM_CONFIG_INCLUDE_UCLI:
|
||||
doc: "Include generic uCli support."
|
||||
default: 0
|
||||
- OOM_SHIM_CONFIG_PIPE_NAME_DEFAULT:
|
||||
doc: "Default named pipe."
|
||||
default: "\"/var/run/faultd.pipe\""
|
||||
- OOM_SHIM_CONFIG_BINARY_SIZE:
|
||||
doc: "Maximum binary name size."
|
||||
default: 255
|
||||
- OOM_SHIM_CONFIG_BACKTRACE_SIZE_MAX:
|
||||
doc: "Maximum backtrace size."
|
||||
default: 32
|
||||
- OOM_SHIM_CONFIG_SERVICE_PIPES_MAX:
|
||||
doc: "Maximum number of simulatanous service pipes."
|
||||
default: 8
|
||||
- OOM_SHIM_CONFIG_BACKTRACE_SYMBOLS_SIZE:
|
||||
doc: "Maximum backtrace symbols size"
|
||||
default: 4096
|
||||
- OOM_SHIM_CONFIG_INCLUDE_MAIN:
|
||||
doc: "Include faultd_main() for standard faultd daemon build."
|
||||
default: 0
|
||||
- OOM_SHIM_CONFIG_INCLUDE_AIM_MAIN:
|
||||
doc: "Include aim_main() as faultd_main()."
|
||||
default: OOM_SHIM_CONFIG_INCLUDE_MAIN
|
||||
- OOM_SHIM_CONFIG_MAIN_PIPENAME:
|
||||
doc: "Default pipename used by faultd_main() if included."
|
||||
default: "\"/var/run/faultd.fifo\""
|
||||
|
||||
|
||||
definitions:
|
||||
cdefs:
|
||||
OOM_SHIM_CONFIG_HEADER:
|
||||
defs: *cdefs
|
||||
basename: faultd_config
|
||||
|
||||
portingmacro:
|
||||
OOM_SHIM:
|
||||
macros:
|
||||
- memset
|
||||
- memcpy
|
||||
- strncpy
|
||||
- strlen
|
||||
@@ -0,0 +1,13 @@
|
||||
#define MAXPORTS 512
|
||||
#define SFF_A0_BASE 0x0
|
||||
#define SFF_A2_BASE 0x100
|
||||
|
||||
/**
|
||||
* SFF_EEPROM_DATA_DEBUG
|
||||
* For printing the eeprom hex data for debugging.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SFF_EEPROM_DATA_DEBUG
|
||||
#define SFF_EEPROM_DATA_DEBUG 0
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef OOM_INTERNAL_H_
|
||||
#define OOM_INTERNAL_H_
|
||||
|
||||
extern void print_block_hex(uint8_t* buf);
|
||||
|
||||
#endif
|
||||
230
packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h
Normal file
230
packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h
Normal file
@@ -0,0 +1,230 @@
|
||||
/******************************
|
||||
*
|
||||
* Southbound API definition for
|
||||
* Open Optical Monitoring (OOM) initiative under the
|
||||
* umbrella of OCP.
|
||||
*
|
||||
* Copyright 2015 Finisar Inc.
|
||||
*
|
||||
* LIKELY TO CHANGE, no promises of compatibility with future
|
||||
* versions is made or implied
|
||||
*
|
||||
* Version: 0.4, January 28, 2016 (added oom_get_port(n))
|
||||
* Author: Don Bollinger
|
||||
*
|
||||
*******************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Discovery definitions */
|
||||
|
||||
/*
|
||||
* list of valid port types
|
||||
* Values are from SFF-8436 spec (rev 4.8, page 74)
|
||||
* note OOM_PORT_TYPE_NOT_PRESENT to indicate no
|
||||
* module is present in this port
|
||||
*/
|
||||
|
||||
typedef enum oom_port_class_e {
|
||||
OOM_PORT_CLASS_UNKNOWN = 0x00,
|
||||
OOM_PORT_CLASS_SFF = 0x01,
|
||||
OOM_PORT_CLASS_CFP = 0x02,
|
||||
} oom_port_class_t;
|
||||
|
||||
|
||||
/* Define the elements of a port
|
||||
* Note: seq_num is an implementation defined magic
|
||||
* number to detect that the module
|
||||
* on this port has been removed/inserted since this
|
||||
* port was last accessed
|
||||
* port_flags is implementation dependent, for use
|
||||
* by the underlying NOS and switch
|
||||
* port_flags should NOT be used or modified by the
|
||||
* decode layer or above
|
||||
*/
|
||||
typedef struct oom_port_s {
|
||||
void *handle; /* opaque handle for this port */
|
||||
oom_port_class_t oom_class; /* class is SFF or CFP */
|
||||
char name[32]; /* 32 bytes for a human readable name */
|
||||
} oom_port_t;
|
||||
|
||||
|
||||
/*
|
||||
* get the list of available ports, as an array
|
||||
* of oom_port_t structs. 'listsize' indicates the
|
||||
* number of ports that will fit in the portlist[] array.
|
||||
*
|
||||
* If there are listsize or fewer ports, and the portlist[]
|
||||
* array is new or out of date, then the shim populates
|
||||
* the portlist structure, and returns 0 (success).
|
||||
*
|
||||
* If the portlist structure is already current, then the
|
||||
* shim does not modify portlist[], and returns 1 (no change).
|
||||
* This is intended as a way to poll for changes to the ports
|
||||
* (eg modules added, deleted, replaced, etc)
|
||||
*
|
||||
* If there are more than listize ports, the shim
|
||||
* returns -ENOMEM, to indicate that a larger portlist[]
|
||||
* array is required.
|
||||
*
|
||||
* If called as oom_get_portlist(NULL, 0), then the shim will
|
||||
* return the number of ports, ie the minimum value of listsize. Note
|
||||
* that some implementations can dynamically add ports, so the return
|
||||
* value is a very good hint, but not a guarantee as to the required
|
||||
* size of the portlist[] structure.
|
||||
*/
|
||||
int oom_get_portlist(oom_port_t portlist[], int listsize);
|
||||
|
||||
|
||||
/* Read/write control "PINS" function definitions */
|
||||
|
||||
/* note that these 'control pins' functions are in limbo right
|
||||
* now, and may not be implemented until later, if at all.
|
||||
* Developers of "southbound shims" may choose to delay
|
||||
* implementation of oom_{get, set}_function()
|
||||
*/
|
||||
|
||||
/* list of functions that can be controlled */
|
||||
typedef enum oom_functions_e {
|
||||
OOM_FUNCTIONS_TX_FAULT,
|
||||
OOM_FUNCTIONS_TX_DISABLE,
|
||||
OOM_FUNCTIONS_MODULE_ABSENT,
|
||||
OOM_FUNCTIONS_RS0,
|
||||
OOM_FUNCTIONS_RS1,
|
||||
/* more control functions to be defined here */
|
||||
OOM_FUNCTIONS_RXLOSS_OF_SIG,
|
||||
OOM_FUNCTIONS_LAST = OOM_FUNCTIONS_RXLOSS_OF_SIG,
|
||||
OOM_FUNCTIONS_COUNT,
|
||||
OOM_FUNCTIONS_INVALID = -1,
|
||||
} oom_functions_t;
|
||||
|
||||
/*
|
||||
* read a function
|
||||
* rv will be 1 for asserted or enabled, 0 if not
|
||||
* returns 0 on success, or negative error code
|
||||
*/
|
||||
int oom_get_function(oom_port_t* port, oom_functions_t function, int* rv);
|
||||
|
||||
/*
|
||||
* write a function
|
||||
* value should be 1 for asserted or enabled, 0 if not
|
||||
* returns 0 on success, or negative error code
|
||||
*/
|
||||
int oom_set_function(oom_port_t* port, oom_functions_t function, int value);
|
||||
|
||||
|
||||
/* Read/write EEPROM definitions */
|
||||
|
||||
/*
|
||||
* read EEPROM
|
||||
* address: the 2-wire (i2c) address, per the SFF specs,
|
||||
* eg A0h, A2h, A8h, etc. (160, 162, 168 respectively.)
|
||||
* Note that this address points to 256 bytes of data.
|
||||
* Bytes 0-127 are intrinsic to this address space.
|
||||
* Bytes 128-255 are the contents of the "page" selected
|
||||
* in byte 127. (The page select byte will be written by
|
||||
* the driver as part of this call. DO NOT explicitly
|
||||
* set byte 127 to select a page.)
|
||||
* Thus there are 256 pages (based on one
|
||||
* byte of page select in byte 127). ONE of these pages
|
||||
* can be accessed in an EEPROM read, and the content
|
||||
* of that page will be at offset 128-255 of the address
|
||||
* space. Page contents starts at offset=128. It is NOT
|
||||
* necessary to read the first 128 bytes of the address
|
||||
* space to access the page contents in the second 128
|
||||
* bytes. See the specs for a further description of
|
||||
* this access architecture, and the content of each page.
|
||||
* Note: Bytes 0-127 do not depend on the value of page.
|
||||
* Reading 256 bytes, starting at offset 0, will read both
|
||||
* the lower half of the address space, AND the page selected.
|
||||
* page: page of EEPROM to read from
|
||||
* offset: byte location within the address space to begin
|
||||
* transferring data from. Remember, offset 0-127 reference
|
||||
* the first 128 bytes of "address" range. Their contents
|
||||
* do not depend on the value of page. Page content begins
|
||||
* at offset=128.
|
||||
* len: the number of bytes to be read
|
||||
* note that (offset + len) must be no more than 256, as
|
||||
* there are only 256 bytes of data available at A0, A2, etc
|
||||
* data: receives the memory contents
|
||||
* returns: the number of bytes read, or a
|
||||
* negative error code
|
||||
*/
|
||||
int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data);
|
||||
|
||||
|
||||
/*
|
||||
* write EEPROM
|
||||
* address: the 2-wire (i2c) address, per the SFF specs,
|
||||
* eg A0h, A2h, A8h, etc. (160, 162, 168 respectively.)
|
||||
* Note that this address points to 256 bytes of data.
|
||||
* Bytes 0-127 are intrinsic to this address space.
|
||||
* Bytes 128-255 are the contents of the "page" selected
|
||||
* in byte 127. (The page select byte will be written by
|
||||
* the driver as part of this call. DO NOT explicitly
|
||||
* set byte 127 to select a page.)
|
||||
* Thus there are 256 pages (based on one
|
||||
* byte of page select in byte 127). ONE of these pages
|
||||
* can be accessed in an EEPROM write, and data written
|
||||
* to that page must be written to offset 128-255 of the
|
||||
* address space.
|
||||
* Page contents starts at offset=128. It is NOT
|
||||
* necessary to write the first 128 bytes of the address
|
||||
* space to access the page contents in the second 128
|
||||
* bytes. See the specs for a further description of
|
||||
* this access architecture, and the content of each page.
|
||||
* Note: Writes to bytes 0-127 will go to the lower half
|
||||
* of the address space, and do not depend on the
|
||||
* value of page. Writing 256 bytes, starting at offset 0,
|
||||
* will write both the lower half of the address space AND
|
||||
* the page selected.
|
||||
* page: page of EEPROM to write to
|
||||
* offset: byte location within the address space to begin
|
||||
* transferring data from. Remember, offset 0-127 reference
|
||||
* the first 128 bytes of "address" range. Their contents
|
||||
* do not depend on the value of page. Page content begins
|
||||
* at offset=128.
|
||||
* len: the number of bytes to be written
|
||||
* note that (offset + len) must be no more than 256, as
|
||||
* there are only 256 bytes of address space at A0, A2, etc
|
||||
* data: data to be written to memory
|
||||
* returns: the number of bytes written, or a
|
||||
* negative error code
|
||||
*/
|
||||
int oom_set_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data);
|
||||
|
||||
/*
|
||||
* read 16 bit oriented EEPROM
|
||||
* CFP modules (for example) do not use 2-wire (i2c) addresses
|
||||
* nor do they use the page table scheme of SFP, XFP, QSFP, etc
|
||||
* their EEPROM is addressed in 16 bit words, in a 32K word
|
||||
* linear address space from 8000hex to FFFFhex
|
||||
* (0000-7FFF are reserved for IEEE 802.3 use)
|
||||
* the interface below is for these types of modules
|
||||
* port: an OOM port structure
|
||||
* address: address between 0x8000 and 0xFFFF to begin read
|
||||
* Each consecutive address is a 16 bit "register"
|
||||
* (not an 8 bit byte)
|
||||
* len: number of 16 bit "registers" to read
|
||||
* data: receives the memory contents
|
||||
* returns the number of words read, or a negative error code
|
||||
*/
|
||||
int oom_get_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data);
|
||||
|
||||
/*
|
||||
* write 16 bit oriented EEPROM
|
||||
* CFP modules (for example) do not use 2-wire (i2c) addresses
|
||||
* nor do they use the page table scheme of SFP, XFP, QSFP, etc
|
||||
* their EEPROM is addressed in 16 bit words, in a 32K word
|
||||
* linear address space from 8000hex to FFFFhex
|
||||
* (0000-7FFF are reserved for IEEE 802.3 use)
|
||||
* the interface below is for these types of modules
|
||||
* port: an OOM port structure
|
||||
* address: address between 0x8000 and 0xFFFF to begin write
|
||||
* Each consecutive address is a 16 bit "register"
|
||||
* (not an 8 bit byte)
|
||||
* len: number of 16 bit "registers" to write
|
||||
* data: data to be written to memory
|
||||
* returns the number of words written, or a negative error code
|
||||
*/
|
||||
int oom_set_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data);
|
||||
30
packages/base/any/oom-shim/src/module/make.mk
Normal file
30
packages/base/any/oom-shim/src/module/make.mk
Normal 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>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
oom_shim_INCLUDES := -I $(THIS_DIR)inc
|
||||
oom_shim_INTERNAL_INCLUDES := -I $(THIS_DIR)src
|
||||
oom_shim_DEPENDMODULE_ENTRIES := init:oom_shim ucli:oom_shim
|
||||
|
||||
30
packages/base/any/oom-shim/src/module/src/Makefile
Normal file
30
packages/base/any/oom-shim/src/module/src/Makefile
Normal 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 oom_shim_ucli.c
|
||||
|
||||
29
packages/base/any/oom-shim/src/module/src/make.mk
Normal file
29
packages/base/any/oom-shim/src/module/src/make.mk
Normal 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 := oom_shim
|
||||
$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
#$(LIBRARY)_LAST := 1
|
||||
include $(BUILDER)/lib.mk
|
||||
28
packages/base/any/oom-shim/src/module/src/oom_internal.c
Normal file
28
packages/base/any/oom-shim/src/module/src/oom_internal.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Internal OOM functions
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void print_block_hex(uint8_t* buf)
|
||||
{
|
||||
int j, k;
|
||||
uint8_t* bufptr8;
|
||||
uint32_t tempintchar;
|
||||
|
||||
bufptr8 = buf;
|
||||
for (j = 0; j < 8; j++) {
|
||||
printf(" " );
|
||||
for (k = 0; k < 19; k++) {
|
||||
if ((k % 5) == 4) {
|
||||
printf(" ");
|
||||
} else {
|
||||
tempintchar = *bufptr8;
|
||||
printf("%.2X", tempintchar);
|
||||
bufptr8++;
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
143
packages/base/any/oom-shim/src/module/src/oom_shim.c
Normal file
143
packages/base/any/oom-shim/src/module/src/oom_shim.c
Normal file
@@ -0,0 +1,143 @@
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2016 v=onl>
|
||||
*
|
||||
* Copyright 2016 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 <errno.h>
|
||||
#include <onlp/onlp.h>
|
||||
#include <onlp/sfp.h>
|
||||
#include <sff/sff.h>
|
||||
#include <oom-shim/oom-shim.h>
|
||||
#include <oom-shim/oom_south.h>
|
||||
|
||||
|
||||
/*
|
||||
* Initializing the SFP and ONLP modules
|
||||
* compiler calls this function while compiling
|
||||
*/
|
||||
|
||||
void __oom_shim_module_init__(void) {
|
||||
onlp_init();
|
||||
}
|
||||
|
||||
/*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;
|
||||
}
|
||||
else
|
||||
return AIM_BITMAP_COUNT(&bitmap);
|
||||
}
|
||||
|
||||
AIM_BITMAP_ITER(&bitmap, port){
|
||||
int rv;
|
||||
|
||||
pptr = &portlist[i];
|
||||
pptr->handle = (void *)(uintptr_t)port+1;
|
||||
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);
|
||||
pptr->oom_class = OOM_PORT_CLASS_UNKNOWN;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(rv < 0){
|
||||
aim_printf(&aim_pvs_stdout, "%4d Error %{onlp_status}\n", port, rv);
|
||||
pptr->oom_class = OOM_PORT_CLASS_UNKNOWN;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data){
|
||||
int rv,cur_offset;
|
||||
unsigned int port_num;
|
||||
uint8_t* idprom = NULL;
|
||||
|
||||
port_num = (unsigned int)(uintptr_t)port->handle;
|
||||
port_num -= 1;
|
||||
rv = onlp_sfp_eeprom_read(port_num, &idprom);/*place holder implementation until onlp_sfp_eeprom_read() can be improved to handle subpages*/
|
||||
if(rv < 0) {
|
||||
aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if SFF_EEPROM_DATA_DEBUG == 1
|
||||
aim_printf(&aim_pvs_stdout, "eeprom:\n%{data}\n", idprom, 256);/*print the hex data for debugging purpose*/
|
||||
#endif
|
||||
|
||||
if (address == 0xa0) {
|
||||
cur_offset = SFF_A0_BASE;
|
||||
} else if (address == 0xa2) {
|
||||
cur_offset = SFF_A2_BASE;
|
||||
} else {
|
||||
aim_printf(&aim_pvs_stdout, "Error invalid address: 0x%02x\n", address);
|
||||
return -EINVAL;
|
||||
}
|
||||
cur_offset += page * 128;
|
||||
cur_offset += offset;
|
||||
|
||||
memcpy(data, &idprom[cur_offset], len);
|
||||
aim_free(idprom);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int oom_get_function(oom_port_t* port, oom_functions_t function, int* rv){
|
||||
//not implemented
|
||||
return -1;
|
||||
}
|
||||
|
||||
int oom_get_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data){
|
||||
//not implemented
|
||||
return -1;
|
||||
}
|
||||
|
||||
int oom_set_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data){
|
||||
//not implemented
|
||||
return -1;
|
||||
}
|
||||
|
||||
int oom_set_function(oom_port_t* port, oom_functions_t function, int value){
|
||||
//not implemented
|
||||
return -1;
|
||||
}
|
||||
int oom_set_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data){
|
||||
//not implemented
|
||||
return -1;
|
||||
}
|
||||
14
packages/base/any/oom-shim/src/oom_shim.mk
Normal file
14
packages/base/any/oom-shim/src/oom_shim.mk
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the oom_shim module.
|
||||
#
|
||||
# Autogenerated 2016-02-16 12:05:28.510482
|
||||
#
|
||||
###############################################################################
|
||||
oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
include $(oom_shim_BASEDIR)/module/make.mk
|
||||
include $(oom_shim_BASEDIR)/module/auto/make.mk
|
||||
include $(oom_shim_BASEDIR)/module/src/make.mk
|
||||
include $(oom_shim_BASEDIR)/utest/_make.mk
|
||||
|
||||
28
packages/base/any/oom-shim/src/utest/_make.mk
Normal file
28
packages/base/any/oom-shim/src/utest/_make.mk
Normal 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>
|
||||
############################################################
|
||||
#
|
||||
#
|
||||
#
|
||||
############################################################
|
||||
|
||||
UMODULE := oom_shim
|
||||
UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
include $(BUILDER)/utest.mk
|
||||
131
packages/base/any/oom-shim/src/utest/main.c
Normal file
131
packages/base/any/oom-shim/src/utest/main.c
Normal file
@@ -0,0 +1,131 @@
|
||||
/************************************************************
|
||||
* <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 <onlp/onlp_config.h>
|
||||
#include <onlp/oids.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <AIM/aim.h>
|
||||
#include <onlp/onlp.h>
|
||||
#include <onlplib/shlocks.h>
|
||||
|
||||
/**
|
||||
* Base functionality unit tests.
|
||||
*/
|
||||
#define __TRY(_prefix, _expr, _suffix) \
|
||||
do { \
|
||||
int _rv; \
|
||||
fprintf(stderr, "%s%s...%s", _prefix, #_expr, _suffix); \
|
||||
fflush(stderr); \
|
||||
_rv = _expr ; \
|
||||
fprintf(stderr, "%s%s...%d\n", _prefix, #_expr, _rv); \
|
||||
fflush(stderr); \
|
||||
if(_rv < 0) { \
|
||||
AIM_DIE("%s%s: failed: %d", #_expr, _rv); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define __TRYNR(_prefix, _expr, _suffix) \
|
||||
do { \
|
||||
fprintf(stderr, "%s%s...%s", _prefix, #_expr, _suffix); \
|
||||
fflush(stderr); \
|
||||
_expr ; \
|
||||
fprintf(stderr, "%s%s...Done\n", _prefix, #_expr); \
|
||||
fflush(stderr); \
|
||||
} while(0)
|
||||
|
||||
#define TRY(_expr) __TRY(" ", _expr, "\r")
|
||||
#define TRYNR(_expr) ___TRYNR(" ", _expr, "\r")
|
||||
#define TEST(_expr) __TRYNR("", _expr, "\n");
|
||||
|
||||
/**
|
||||
* Test Shared Locks
|
||||
*/
|
||||
void
|
||||
shlock_test(void)
|
||||
{
|
||||
onlp_shlock_t* lock = NULL;
|
||||
|
||||
TRY(onlp_shlock_create(0xEEEF, &lock, "utest-lock:%d", 1));
|
||||
TRY(onlp_shlock_take(lock));
|
||||
TRY(onlp_shlock_give(lock));
|
||||
TRY(onlp_shlock_take(lock));
|
||||
TRY(onlp_shlock_give(lock));
|
||||
TRY(onlp_shlock_global_take());
|
||||
TRY(onlp_shlock_global_give());
|
||||
TRY(onlp_shlock_global_take());
|
||||
TRY(onlp_shlock_global_give());
|
||||
if(strcmp("utest-lock:1", onlp_shlock_name(lock))) {
|
||||
AIM_DIE("lock name does not match (%s)", onlp_shlock_name(lock));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test ONIE parsing
|
||||
*/
|
||||
void
|
||||
onie_test(void)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
int
|
||||
iter__(onlp_oid_t oid, void* cookie)
|
||||
{
|
||||
onlp_oid_hdr_t hdr;
|
||||
onlp_oid_hdr_get(oid, &hdr);
|
||||
printf("OID: 0x%x, D='%s'\n", oid, hdr.description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <onlp/fan.h>
|
||||
#include <onlp/thermal.h>
|
||||
#include <onlp/oids.h>
|
||||
#include <onlp/sys.h>
|
||||
|
||||
int
|
||||
aim_main(int argc, char* argv[])
|
||||
{
|
||||
// TEST(shlock_test());
|
||||
|
||||
/* Example Platform Dump */
|
||||
onlp_init();
|
||||
onlp_platform_dump(&aim_pvs_stdout, ONLP_OID_DUMP_F_RECURSE);
|
||||
onlp_oid_iterate(0, 0, iter__, NULL);
|
||||
onlp_platform_show(&aim_pvs_stdout, ONLP_OID_SHOW_F_RECURSE|ONLP_OID_SHOW_F_EXTENDED);
|
||||
|
||||
if(argv[1] && !strcmp("manage", argv[1])) {
|
||||
onlp_sys_platform_manage_start();
|
||||
printf("Sleeping...\n");
|
||||
sleep(10);
|
||||
printf("Stopping...\n");
|
||||
onlp_sys_platform_manage_stop();
|
||||
printf("Stopped.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
1
packages/base/powerpc/oom-shim/Makefile
Normal file
1
packages/base/powerpc/oom-shim/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include $(ONL)/make/pkg.mk
|
||||
2
packages/base/powerpc/oom-shim/PKG.yml
Normal file
2
packages/base/powerpc/oom-shim/PKG.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu
|
||||
|
||||
3
packages/base/powerpc/oom-shim/builds/Makefile
Normal file
3
packages/base/powerpc/oom-shim/builds/Makefile
Normal file
@@ -0,0 +1,3 @@
|
||||
include $(ONL)/make/config.powerpc.mk
|
||||
include $(ONL)/packages/base/any/oom-shim/builds/Makefile
|
||||
|
||||
10
packages/base/powerpc/oom-shim/builds/oom_shim.mk
Normal file
10
packages/base/powerpc/oom-shim/builds/oom_shim.mk
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Inclusive Makefile for the oom_shim module.
|
||||
#
|
||||
# Autogenerated 2016-02-16 14:18:46.799062
|
||||
#
|
||||
###############################################################################
|
||||
oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
Reference in New Issue
Block a user