From 0864c30d4db4083676eaf79f1e58109a0ceff596 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Fri, 5 Feb 2016 10:02:01 -0800 Subject: [PATCH 01/13] Skeleton OOM_shim package for OCP Demo --- packages/base/amd64/oom_shim/Makefile | 1 + packages/base/amd64/oom_shim/PKG.yml | 2 ++ packages/base/amd64/oom_shim/builds/Makefile | 3 ++ packages/base/any/oom_shim/APKG.yml | 32 ++++++++++++++++++++ packages/base/any/oom_shim/builds/Makefile | 9 ++++++ packages/base/any/oom_shim/src/oom_shim.c | 7 +++++ 6 files changed, 54 insertions(+) create mode 100644 packages/base/amd64/oom_shim/Makefile create mode 100644 packages/base/amd64/oom_shim/PKG.yml create mode 100644 packages/base/amd64/oom_shim/builds/Makefile create mode 100644 packages/base/any/oom_shim/APKG.yml create mode 100644 packages/base/any/oom_shim/builds/Makefile create mode 100644 packages/base/any/oom_shim/src/oom_shim.c diff --git a/packages/base/amd64/oom_shim/Makefile b/packages/base/amd64/oom_shim/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/base/amd64/oom_shim/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/base/amd64/oom_shim/PKG.yml b/packages/base/amd64/oom_shim/PKG.yml new file mode 100644 index 00000000..d8f9b23f --- /dev/null +++ b/packages/base/amd64/oom_shim/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu + diff --git a/packages/base/amd64/oom_shim/builds/Makefile b/packages/base/amd64/oom_shim/builds/Makefile new file mode 100644 index 00000000..a6c9d258 --- /dev/null +++ b/packages/base/amd64/oom_shim/builds/Makefile @@ -0,0 +1,3 @@ +include $(ONL)/make/config.amd64.mk +include $(ONL)/packages/base/any/oom_shim/builds/Makefile + diff --git a/packages/base/any/oom_shim/APKG.yml b/packages/base/any/oom_shim/APKG.yml new file mode 100644 index 00000000..e8490b9b --- /dev/null +++ b/packages/base/any/oom_shim/APKG.yml @@ -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}/liboom_shim.so : $libdir/ + + changelog: Initial code for 2016 OCP Demo + + + + diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile new file mode 100644 index 00000000..8bc9a7f5 --- /dev/null +++ b/packages/base/any/oom_shim/builds/Makefile @@ -0,0 +1,9 @@ +include $(ONL)/make/any.mk + + +liboom_shim.so: + @$(CC) -o liboom_shim.so -shared -PIC liboom_shim.c + +.PHONY: deb +deb: + $(MAKE) -C deb diff --git a/packages/base/any/oom_shim/src/oom_shim.c b/packages/base/any/oom_shim/src/oom_shim.c new file mode 100644 index 00000000..5e866c30 --- /dev/null +++ b/packages/base/any/oom_shim/src/oom_shim.c @@ -0,0 +1,7 @@ +#include + +int test_func(int argc) +{ + + printf("Looks like it works...\n"); +} From fa29d183b7b20fecaac979b26f153f16a0690a95 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Fri, 5 Feb 2016 10:24:14 -0800 Subject: [PATCH 02/13] Skeleton guide for development in our Make system --- docs/dev.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/dev.md diff --git a/docs/dev.md b/docs/dev.md new file mode 100644 index 00000000..77130458 --- /dev/null +++ b/docs/dev.md @@ -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.'""" From acea7ab90c447bbd30520b931461cf892d05cfd0 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Fri, 5 Feb 2016 18:53:19 -0800 Subject: [PATCH 03/13] Made the OOM-shim package makefile work --- packages/base/any/oom_shim/builds/Makefile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile index 8bc9a7f5..8f2d99a4 100644 --- a/packages/base/any/oom_shim/builds/Makefile +++ b/packages/base/any/oom_shim/builds/Makefile @@ -1,9 +1,27 @@ include $(ONL)/make/any.mk +ifndef TOOLCHAIN +$(error Must define $$TOOLCHAIN to use this Makefile) +endif -liboom_shim.so: - @$(CC) -o liboom_shim.so -shared -PIC liboom_shim.c +ifndef RELEASE +$(warn Assuming RELEASE is wheezy -- FIXME) +RELEASE=wheezy +endif + +PACKAGE=oom_shim + +OUTDIR=$(ONL)/packages/base/$(ARCH)/$(PACKAGE)/builds/BUILD/$(RELEASE)/$(TOOLCHAIN) + +VPATH=$(ONL)/packages/base/any/$(PACKAGE)/src + +$(OUTDIR)/liboom_shim.so: oom_shim.c + @mkdir -p $(OUTDIR) || true + @$(CC) -o $(OUTDIR)/liboom_shim.so -shared -fPIC $+ .PHONY: deb deb: $(MAKE) -C deb + +clean: + rm -rf $(OUTDIR) From 43e1405c40dd93b33928714f9d8294b99849316c Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Mon, 8 Feb 2016 11:44:44 -0800 Subject: [PATCH 04/13] Adding powerpc version of oom_shim --- packages/base/powerpc/oom_shim/Makefile | 1 + packages/base/powerpc/oom_shim/PKG.yml | 2 ++ packages/base/powerpc/oom_shim/builds/Makefile | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 packages/base/powerpc/oom_shim/Makefile create mode 100644 packages/base/powerpc/oom_shim/PKG.yml create mode 100644 packages/base/powerpc/oom_shim/builds/Makefile diff --git a/packages/base/powerpc/oom_shim/Makefile b/packages/base/powerpc/oom_shim/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/base/powerpc/oom_shim/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/base/powerpc/oom_shim/PKG.yml b/packages/base/powerpc/oom_shim/PKG.yml new file mode 100644 index 00000000..74562b35 --- /dev/null +++ b/packages/base/powerpc/oom_shim/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu + diff --git a/packages/base/powerpc/oom_shim/builds/Makefile b/packages/base/powerpc/oom_shim/builds/Makefile new file mode 100644 index 00000000..dbb8572e --- /dev/null +++ b/packages/base/powerpc/oom_shim/builds/Makefile @@ -0,0 +1,3 @@ +include $(ONL)/make/config.powerpc.mk +include $(ONL)/packages/base/any/oom_shim/builds/Makefile + From 10271c420ef53b3e8b4ae25936f1c5fe83a5fe75 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Mon, 8 Feb 2016 12:12:38 -0800 Subject: [PATCH 05/13] Change the library name to liboom_south --- packages/base/amd64/oom_shim/Makefile | 2 +- packages/base/any/oom_shim/APKG.yml | 2 +- packages/base/any/oom_shim/builds/Makefile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/base/amd64/oom_shim/Makefile b/packages/base/amd64/oom_shim/Makefile index 003238cf..dc1e7b86 100644 --- a/packages/base/amd64/oom_shim/Makefile +++ b/packages/base/amd64/oom_shim/Makefile @@ -1 +1 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file +include $(ONL)/make/pkg.mk diff --git a/packages/base/any/oom_shim/APKG.yml b/packages/base/any/oom_shim/APKG.yml index e8490b9b..04023976 100644 --- a/packages/base/any/oom_shim/APKG.yml +++ b/packages/base/any/oom_shim/APKG.yml @@ -23,7 +23,7 @@ packages: provides: [ oom_shim ] files: - builds/$BUILD_DIR/${TOOLCHAIN}/liboom_shim.so : $libdir/ + builds/$BUILD_DIR/${TOOLCHAIN}/liboom_south.so : $libdir/ changelog: Initial code for 2016 OCP Demo diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile index 8f2d99a4..2cfc08d9 100644 --- a/packages/base/any/oom_shim/builds/Makefile +++ b/packages/base/any/oom_shim/builds/Makefile @@ -15,9 +15,9 @@ OUTDIR=$(ONL)/packages/base/$(ARCH)/$(PACKAGE)/builds/BUILD/$(RELEASE)/$(TOOLCHA VPATH=$(ONL)/packages/base/any/$(PACKAGE)/src -$(OUTDIR)/liboom_shim.so: oom_shim.c +$(OUTDIR)/liboom_south.so: oom_shim.c @mkdir -p $(OUTDIR) || true - @$(CC) -o $(OUTDIR)/liboom_shim.so -shared -fPIC $+ + @$(CC) -o $(OUTDIR)/liboom_south.so -shared -fPIC $+ .PHONY: deb deb: From 33bb8c0690eb1fdc693283ffa35f06bcf2f00303 Mon Sep 17 00:00:00 2001 From: Rob Sherwood Date: Fri, 12 Feb 2016 09:19:29 -0800 Subject: [PATCH 06/13] Changed OOM_SHIM package to module formatted code --- .../amd64/{oom_shim => oom-shim}/Makefile | 0 packages/base/amd64/oom-shim/PKG.yml | 2 + packages/base/amd64/oom-shim/builds/Makefile | 3 + .../base/amd64/oom-shim/builds/oom_shim.mk | 10 ++ packages/base/amd64/oom_shim/PKG.yml | 2 - packages/base/amd64/oom_shim/builds/Makefile | 3 - .../base/any/{oom_shim => oom-shim}/APKG.yml | 4 +- packages/base/any/oom-shim/builds/Makefile | 53 +++++++ packages/base/any/oom-shim/src/Makefile | 4 + .../base/any/oom-shim/src/module/auto/make.mk | 28 ++++ .../any/oom-shim/src/module/auto/oom_shim.yml | 86 ++++++++++++ .../src/module/inc/oom-shim/oom-shim.h | 0 .../src/module/inc/oom_shim/oom-shim.h | 0 packages/base/any/oom-shim/src/module/make.mk | 30 ++++ .../src/module}/src/oom_shim.c | 0 packages/base/any/oom-shim/src/oom_shim.mk | 12 ++ packages/base/any/oom-shim/src/utest/_make.mk | 28 ++++ packages/base/any/oom-shim/src/utest/main.c | 131 ++++++++++++++++++ packages/base/any/oom_shim/builds/Makefile | 27 ---- 19 files changed, 389 insertions(+), 34 deletions(-) rename packages/base/amd64/{oom_shim => oom-shim}/Makefile (100%) create mode 100644 packages/base/amd64/oom-shim/PKG.yml create mode 100644 packages/base/amd64/oom-shim/builds/Makefile create mode 100644 packages/base/amd64/oom-shim/builds/oom_shim.mk delete mode 100644 packages/base/amd64/oom_shim/PKG.yml delete mode 100644 packages/base/amd64/oom_shim/builds/Makefile rename packages/base/any/{oom_shim => oom-shim}/APKG.yml (85%) create mode 100644 packages/base/any/oom-shim/builds/Makefile create mode 100644 packages/base/any/oom-shim/src/Makefile create mode 100644 packages/base/any/oom-shim/src/module/auto/make.mk create mode 100644 packages/base/any/oom-shim/src/module/auto/oom_shim.yml create mode 100644 packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h create mode 100644 packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h create mode 100644 packages/base/any/oom-shim/src/module/make.mk rename packages/base/any/{oom_shim => oom-shim/src/module}/src/oom_shim.c (100%) create mode 100644 packages/base/any/oom-shim/src/oom_shim.mk create mode 100644 packages/base/any/oom-shim/src/utest/_make.mk create mode 100644 packages/base/any/oom-shim/src/utest/main.c delete mode 100644 packages/base/any/oom_shim/builds/Makefile diff --git a/packages/base/amd64/oom_shim/Makefile b/packages/base/amd64/oom-shim/Makefile similarity index 100% rename from packages/base/amd64/oom_shim/Makefile rename to packages/base/amd64/oom-shim/Makefile diff --git a/packages/base/amd64/oom-shim/PKG.yml b/packages/base/amd64/oom-shim/PKG.yml new file mode 100644 index 00000000..7f4f460d --- /dev/null +++ b/packages/base/amd64/oom-shim/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu + diff --git a/packages/base/amd64/oom-shim/builds/Makefile b/packages/base/amd64/oom-shim/builds/Makefile new file mode 100644 index 00000000..66500cec --- /dev/null +++ b/packages/base/amd64/oom-shim/builds/Makefile @@ -0,0 +1,3 @@ +include $(ONL)/make/config.amd64.mk +include $(ONL)/packages/base/any/oom-shim/builds/Makefile + diff --git a/packages/base/amd64/oom-shim/builds/oom_shim.mk b/packages/base/amd64/oom-shim/builds/oom_shim.mk new file mode 100644 index 00000000..88c00283 --- /dev/null +++ b/packages/base/amd64/oom-shim/builds/oom_shim.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the oom_shim module. +# +# Autogenerated 2016-02-12 17:14:48.789289 +# +############################################################################### +oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/base/amd64/oom_shim/PKG.yml b/packages/base/amd64/oom_shim/PKG.yml deleted file mode 100644 index d8f9b23f..00000000 --- a/packages/base/amd64/oom_shim/PKG.yml +++ /dev/null @@ -1,2 +0,0 @@ -!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu - diff --git a/packages/base/amd64/oom_shim/builds/Makefile b/packages/base/amd64/oom_shim/builds/Makefile deleted file mode 100644 index a6c9d258..00000000 --- a/packages/base/amd64/oom_shim/builds/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -include $(ONL)/make/config.amd64.mk -include $(ONL)/packages/base/any/oom_shim/builds/Makefile - diff --git a/packages/base/any/oom_shim/APKG.yml b/packages/base/any/oom-shim/APKG.yml similarity index 85% rename from packages/base/any/oom_shim/APKG.yml rename to packages/base/any/oom-shim/APKG.yml index e8490b9b..6a54841f 100644 --- a/packages/base/any/oom_shim/APKG.yml +++ b/packages/base/any/oom-shim/APKG.yml @@ -17,13 +17,13 @@ common: packages: - - name: oom_shim + - name: oom-shim version: 1.0.0 summary: Open Optical Module Wrapper library around ONLP provides: [ oom_shim ] files: - builds/$BUILD_DIR/${TOOLCHAIN}/liboom_shim.so : $libdir/ + builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/ changelog: Initial code for 2016 OCP Demo diff --git a/packages/base/any/oom-shim/builds/Makefile b/packages/base/any/oom-shim/builds/Makefile new file mode 100644 index 00000000..484d66aa --- /dev/null +++ b/packages/base/any/oom-shim/builds/Makefile @@ -0,0 +1,53 @@ +# -*- Makefile -*- +############################################################ +# +# +# 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. +# +# +############################################################ +# +# +############################################################ +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 + + +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_PLATFORM) $(LIBONLP_PLATFORM_DEFAULTS) + +include $(BUILDER)/targets.mk + +.PHONY: deb +deb: + $(MAKE) -C deb diff --git a/packages/base/any/oom-shim/src/Makefile b/packages/base/any/oom-shim/src/Makefile new file mode 100644 index 00000000..ee296946 --- /dev/null +++ b/packages/base/any/oom-shim/src/Makefile @@ -0,0 +1,4 @@ +include $(ONL)/make/config.mk +MODULE := oom_shim +AUTOMODULE := oom_shim +include $(BUILDER)/definemodule.mk diff --git a/packages/base/any/oom-shim/src/module/auto/make.mk b/packages/base/any/oom-shim/src/module/auto/make.mk new file mode 100644 index 00000000..9dac4629 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/auto/make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# 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 + diff --git a/packages/base/any/oom-shim/src/module/auto/oom_shim.yml b/packages/base/any/oom-shim/src/module/auto/oom_shim.yml new file mode 100644 index 00000000..32557d9e --- /dev/null +++ b/packages/base/any/oom-shim/src/module/auto/oom_shim.yml @@ -0,0 +1,86 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# 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 diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h new file mode 100644 index 00000000..e69de29b diff --git a/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h new file mode 100644 index 00000000..e69de29b diff --git a/packages/base/any/oom-shim/src/module/make.mk b/packages/base/any/oom-shim/src/module/make.mk new file mode 100644 index 00000000..b6ec73a3 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/make.mk @@ -0,0 +1,30 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# +# +############################################################ + +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 + diff --git a/packages/base/any/oom_shim/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c similarity index 100% rename from packages/base/any/oom_shim/src/oom_shim.c rename to packages/base/any/oom-shim/src/module/src/oom_shim.c diff --git a/packages/base/any/oom-shim/src/oom_shim.mk b/packages/base/any/oom-shim/src/oom_shim.mk new file mode 100644 index 00000000..dde86cf9 --- /dev/null +++ b/packages/base/any/oom-shim/src/oom_shim.mk @@ -0,0 +1,12 @@ + +############################################################################### +# +# Inclusive Makefile for the oom-shim module. +# +# Autogenerated 2016-02-12 16:50:50.721882 +# +############################################################################### +oom-shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(oom-shim_BASEDIR)/module/make.mk +include $(oom-shim_BASEDIR)/utest/_make.mk + diff --git a/packages/base/any/oom-shim/src/utest/_make.mk b/packages/base/any/oom-shim/src/utest/_make.mk new file mode 100644 index 00000000..43139d4c --- /dev/null +++ b/packages/base/any/oom-shim/src/utest/_make.mk @@ -0,0 +1,28 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# +# +############################################################ + +UMODULE := oom_shim +UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/utest.mk diff --git a/packages/base/any/oom-shim/src/utest/main.c b/packages/base/any/oom-shim/src/utest/main.c new file mode 100644 index 00000000..e7e9e030 --- /dev/null +++ b/packages/base/any/oom-shim/src/utest/main.c @@ -0,0 +1,131 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +/** + * 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 +#include +#include +#include + +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; +} diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile deleted file mode 100644 index 8f2d99a4..00000000 --- a/packages/base/any/oom_shim/builds/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include $(ONL)/make/any.mk - -ifndef TOOLCHAIN -$(error Must define $$TOOLCHAIN to use this Makefile) -endif - -ifndef RELEASE -$(warn Assuming RELEASE is wheezy -- FIXME) -RELEASE=wheezy -endif - -PACKAGE=oom_shim - -OUTDIR=$(ONL)/packages/base/$(ARCH)/$(PACKAGE)/builds/BUILD/$(RELEASE)/$(TOOLCHAIN) - -VPATH=$(ONL)/packages/base/any/$(PACKAGE)/src - -$(OUTDIR)/liboom_shim.so: oom_shim.c - @mkdir -p $(OUTDIR) || true - @$(CC) -o $(OUTDIR)/liboom_shim.so -shared -fPIC $+ - -.PHONY: deb -deb: - $(MAKE) -C deb - -clean: - rm -rf $(OUTDIR) From 9ed539ab94c90c61816a0aa530e73a90d785bfb5 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Sun, 14 Feb 2016 14:59:05 -0800 Subject: [PATCH 07/13] Remove unwanted directory --- packages/base/any/oom_shim/builds/Makefile | 27 ------------------- packages/base/powerpc/oom_shim/Makefile | 1 - packages/base/powerpc/oom_shim/PKG.yml | 2 -- .../base/powerpc/oom_shim/builds/Makefile | 3 --- 4 files changed, 33 deletions(-) delete mode 100644 packages/base/any/oom_shim/builds/Makefile delete mode 100644 packages/base/powerpc/oom_shim/Makefile delete mode 100644 packages/base/powerpc/oom_shim/PKG.yml delete mode 100644 packages/base/powerpc/oom_shim/builds/Makefile diff --git a/packages/base/any/oom_shim/builds/Makefile b/packages/base/any/oom_shim/builds/Makefile deleted file mode 100644 index 2cfc08d9..00000000 --- a/packages/base/any/oom_shim/builds/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -include $(ONL)/make/any.mk - -ifndef TOOLCHAIN -$(error Must define $$TOOLCHAIN to use this Makefile) -endif - -ifndef RELEASE -$(warn Assuming RELEASE is wheezy -- FIXME) -RELEASE=wheezy -endif - -PACKAGE=oom_shim - -OUTDIR=$(ONL)/packages/base/$(ARCH)/$(PACKAGE)/builds/BUILD/$(RELEASE)/$(TOOLCHAIN) - -VPATH=$(ONL)/packages/base/any/$(PACKAGE)/src - -$(OUTDIR)/liboom_south.so: oom_shim.c - @mkdir -p $(OUTDIR) || true - @$(CC) -o $(OUTDIR)/liboom_south.so -shared -fPIC $+ - -.PHONY: deb -deb: - $(MAKE) -C deb - -clean: - rm -rf $(OUTDIR) diff --git a/packages/base/powerpc/oom_shim/Makefile b/packages/base/powerpc/oom_shim/Makefile deleted file mode 100644 index dc1e7b86..00000000 --- a/packages/base/powerpc/oom_shim/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/base/powerpc/oom_shim/PKG.yml b/packages/base/powerpc/oom_shim/PKG.yml deleted file mode 100644 index 74562b35..00000000 --- a/packages/base/powerpc/oom_shim/PKG.yml +++ /dev/null @@ -1,2 +0,0 @@ -!include $ONL/packages/base/any/oom_shim/APKG.yml ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu - diff --git a/packages/base/powerpc/oom_shim/builds/Makefile b/packages/base/powerpc/oom_shim/builds/Makefile deleted file mode 100644 index dbb8572e..00000000 --- a/packages/base/powerpc/oom_shim/builds/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -include $(ONL)/make/config.powerpc.mk -include $(ONL)/packages/base/any/oom_shim/builds/Makefile - From a3f983f652c8049c0f6314d2209084fa7befec44 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Tue, 16 Feb 2016 06:11:23 -0800 Subject: [PATCH 08/13] Adding powerpc changes --- packages/base/any/oom-shim/APKG.yml | 4 --- packages/base/any/oom-shim/builds/Makefile | 5 +++- .../src/module/inc/oom_shim/oom-shim.h | 0 .../base/any/oom-shim/src/module/src/Makefile | 30 +++++++++++++++++++ packages/base/any/oom-shim/src/oom_shim.mk | 12 ++++---- packages/base/powerpc/oom-shim/Makefile | 1 + packages/base/powerpc/oom-shim/PKG.yml | 2 ++ .../base/powerpc/oom-shim/builds/Makefile | 3 ++ .../base/powerpc/oom-shim/builds/oom-shim.mk | 10 +++++++ 9 files changed, 57 insertions(+), 10 deletions(-) delete mode 100644 packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h create mode 100644 packages/base/any/oom-shim/src/module/src/Makefile create mode 100644 packages/base/powerpc/oom-shim/Makefile create mode 100644 packages/base/powerpc/oom-shim/PKG.yml create mode 100644 packages/base/powerpc/oom-shim/builds/Makefile create mode 100644 packages/base/powerpc/oom-shim/builds/oom-shim.mk diff --git a/packages/base/any/oom-shim/APKG.yml b/packages/base/any/oom-shim/APKG.yml index 21caf002..6a54841f 100644 --- a/packages/base/any/oom-shim/APKG.yml +++ b/packages/base/any/oom-shim/APKG.yml @@ -23,11 +23,7 @@ packages: provides: [ oom_shim ] files: -<<<<<<< HEAD:packages/base/any/oom_shim/APKG.yml - builds/$BUILD_DIR/${TOOLCHAIN}/liboom_south.so : $libdir/ -======= builds/$BUILD_DIR/${TOOLCHAIN}/bin/liboom-south.so : $libdir/ ->>>>>>> 33bb8c0690eb1fdc693283ffa35f06bcf2f00303:packages/base/any/oom-shim/APKG.yml changelog: Initial code for 2016 OCP Demo diff --git a/packages/base/any/oom-shim/builds/Makefile b/packages/base/any/oom-shim/builds/Makefile index 484d66aa..0ccc185a 100644 --- a/packages/base/any/oom-shim/builds/Makefile +++ b/packages/base/any/oom-shim/builds/Makefile @@ -29,6 +29,9 @@ 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 @@ -44,7 +47,7 @@ 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_PLATFORM) $(LIBONLP_PLATFORM_DEFAULTS) +GLOBAL_LINK_LIBS += -lpthread $(LIBONLP) include $(BUILDER)/targets.mk diff --git a/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom_shim/oom-shim.h deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/base/any/oom-shim/src/module/src/Makefile b/packages/base/any/oom-shim/src/module/src/Makefile new file mode 100644 index 00000000..87a73132 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/src/Makefile @@ -0,0 +1,30 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# Local source generation targets. +# +############################################################ + +include ../../../../init.mk + +ucli: + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py onlpie_ucli.c + diff --git a/packages/base/any/oom-shim/src/oom_shim.mk b/packages/base/any/oom-shim/src/oom_shim.mk index dde86cf9..106445d0 100644 --- a/packages/base/any/oom-shim/src/oom_shim.mk +++ b/packages/base/any/oom-shim/src/oom_shim.mk @@ -1,12 +1,14 @@ ############################################################################### # -# Inclusive Makefile for the oom-shim module. +# Inclusive Makefile for the oom_shim module. # -# Autogenerated 2016-02-12 16:50:50.721882 +# 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)/utest/_make.mk +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 diff --git a/packages/base/powerpc/oom-shim/Makefile b/packages/base/powerpc/oom-shim/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/base/powerpc/oom-shim/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk diff --git a/packages/base/powerpc/oom-shim/PKG.yml b/packages/base/powerpc/oom-shim/PKG.yml new file mode 100644 index 00000000..9fe09577 --- /dev/null +++ b/packages/base/powerpc/oom-shim/PKG.yml @@ -0,0 +1,2 @@ +!include $ONL/packages/base/any/oom-shim/APKG.yml ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu + diff --git a/packages/base/powerpc/oom-shim/builds/Makefile b/packages/base/powerpc/oom-shim/builds/Makefile new file mode 100644 index 00000000..ee3b6e85 --- /dev/null +++ b/packages/base/powerpc/oom-shim/builds/Makefile @@ -0,0 +1,3 @@ +include $(ONL)/make/config.powerpc.mk +include $(ONL)/packages/base/any/oom-shim/builds/Makefile + diff --git a/packages/base/powerpc/oom-shim/builds/oom-shim.mk b/packages/base/powerpc/oom-shim/builds/oom-shim.mk new file mode 100644 index 00000000..4815edcf --- /dev/null +++ b/packages/base/powerpc/oom-shim/builds/oom-shim.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the oom-shim module. +# +# Autogenerated 2016-02-15 20:59:29.632190 +# +############################################################################### +oom-shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + From 8748ee2f4f8915fd2b6c2668da0b1147b77893a3 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Tue, 16 Feb 2016 06:23:06 -0800 Subject: [PATCH 09/13] Adding Powerpc minor changes --- .../base/amd64/oom-shim/builds/oom_shim.mk | 2 +- .../base/any/oom-shim/src/module/src/make.mk | 29 +++++++++++++++++++ .../builds/{oom-shim.mk => oom_shim.mk} | 6 ++-- 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 packages/base/any/oom-shim/src/module/src/make.mk rename packages/base/powerpc/oom-shim/builds/{oom-shim.mk => oom_shim.mk} (52%) diff --git a/packages/base/amd64/oom-shim/builds/oom_shim.mk b/packages/base/amd64/oom-shim/builds/oom_shim.mk index 88c00283..c119b5fc 100644 --- a/packages/base/amd64/oom-shim/builds/oom_shim.mk +++ b/packages/base/amd64/oom-shim/builds/oom_shim.mk @@ -3,7 +3,7 @@ # # Inclusive Makefile for the oom_shim module. # -# Autogenerated 2016-02-12 17:14:48.789289 +# Autogenerated 2016-02-16 14:17:39.946619 # ############################################################################### oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) diff --git a/packages/base/any/oom-shim/src/module/src/make.mk b/packages/base/any/oom-shim/src/module/src/make.mk new file mode 100644 index 00000000..973f1ce3 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/src/make.mk @@ -0,0 +1,29 @@ +############################################################ +# +# +# 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. +# +# +############################################################ +# +# +# +############################################################ + +LIBRARY := oom_shim +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +#$(LIBRARY)_LAST := 1 +include $(BUILDER)/lib.mk diff --git a/packages/base/powerpc/oom-shim/builds/oom-shim.mk b/packages/base/powerpc/oom-shim/builds/oom_shim.mk similarity index 52% rename from packages/base/powerpc/oom-shim/builds/oom-shim.mk rename to packages/base/powerpc/oom-shim/builds/oom_shim.mk index 4815edcf..04cfe7c1 100644 --- a/packages/base/powerpc/oom-shim/builds/oom-shim.mk +++ b/packages/base/powerpc/oom-shim/builds/oom_shim.mk @@ -1,10 +1,10 @@ ############################################################################### # -# Inclusive Makefile for the oom-shim module. +# Inclusive Makefile for the oom_shim module. # -# Autogenerated 2016-02-15 20:59:29.632190 +# Autogenerated 2016-02-16 14:18:46.799062 # ############################################################################### -oom-shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) From 073eb6c7fd0737f8205549ee626aa4a81e3b6f60 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Sat, 20 Feb 2016 07:10:12 -0800 Subject: [PATCH 10/13] oom-shim get portlist --- .../src/module/inc/oom-shim/oom-shim.h | 1 + .../src/module/inc/oom-shim/oom_south.h | 230 ++++++++++++++++++ .../base/any/oom-shim/src/module/src/Makefile | 2 +- .../any/oom-shim/src/module/src/oom_shim.c | 101 +++++++- 4 files changed, 330 insertions(+), 4 deletions(-) create mode 100644 packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h index e69de29b..0925b787 100644 --- a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h @@ -0,0 +1 @@ +#define MAXPORTS 6 diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h new file mode 100644 index 00000000..fef10e0c --- /dev/null +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_south.h @@ -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 + +/* 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); diff --git a/packages/base/any/oom-shim/src/module/src/Makefile b/packages/base/any/oom-shim/src/module/src/Makefile index 87a73132..1259eda6 100644 --- a/packages/base/any/oom-shim/src/module/src/Makefile +++ b/packages/base/any/oom-shim/src/module/src/Makefile @@ -26,5 +26,5 @@ include ../../../../init.mk ucli: - $(SUBMODULE_BIGCODE)/tools/uclihandlers.py onlpie_ucli.c + $(SUBMODULE_BIGCODE)/tools/uclihandlers.py oom_shim_ucli.c diff --git a/packages/base/any/oom-shim/src/module/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c index 5e866c30..535a8a85 100644 --- a/packages/base/any/oom-shim/src/module/src/oom_shim.c +++ b/packages/base/any/oom-shim/src/module/src/oom_shim.c @@ -1,7 +1,102 @@ +/************************************************************ + * + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ #include +#include +#include +#include +#include +#include +#include +#include -int test_func(int argc) -{ +int Initialized = 0; - printf("Looks like it works...\n"); +/*Initializing the SFP and ONLP modules*/ +void __oom_shim_module_init__(void) { + onlp_init(); + Initialized = 1; +} + +/*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; + + if(Initialized == 0){ + __oom_shim_module_init__(); + } + + 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){ + printf("No SFPs on this platform.\n"); + return 0; + } + else + return AIM_BITMAP_COUNT(&bitmap); + } + + AIM_BITMAP_ITER(&bitmap, port){ + int rv; + uint8_t* data; + + pptr = &portlist[i]; + pptr->handle = (void *)(uintptr_t)port; + pptr->oom_class = OOM_PORT_CLASS_SFF; + sprintf(pptr->name, "port%d", port); + i++; + + rv = onlp_sfp_is_present(port); + if(rv == 0){ + printf("module %d is not present\n", port); + continue; + } + + if(rv < 0){ + printf("%4d Error\n", port); + continue; + } + + rv = onlp_sfp_eeprom_read(port, &data); + + if(rv < 0){ + printf("%4d Error}\n", port); + continue; + } + + sff_info_t sff; + sff_info_init(&sff, data); + if(!sff.supported) { + printf("%13d UNK\n", port); + continue; + } + printf("The sfp_type is : %-14s",sff.sfp_type_name); + } + return 0; } From b2564128f899e82239649fba3bf25a5840a25287 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Tue, 23 Feb 2016 14:50:28 -0800 Subject: [PATCH 11/13] cleaning code --- .../src/module/inc/oom-shim/oom-shim.h | 2 +- .../src/module/inc/oom-shim/oom_internal.h | 6 +++ .../oom-shim/src/module/src/oom_internal.c | 28 ++++++++++++++ .../any/oom-shim/src/module/src/oom_shim.c | 38 +++++++++++++++---- 4 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 packages/base/any/oom-shim/src/module/inc/oom-shim/oom_internal.h create mode 100644 packages/base/any/oom-shim/src/module/src/oom_internal.c diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h index 0925b787..f83e8035 100644 --- a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h @@ -1 +1 @@ -#define MAXPORTS 6 +#define MAXPORTS 512 diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_internal.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_internal.h new file mode 100644 index 00000000..67bb0618 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom_internal.h @@ -0,0 +1,6 @@ +#ifndef OOM_INTERNAL_H_ +#define OOM_INTERNAL_H_ + +extern void print_block_hex(uint8_t* buf); + +#endif diff --git a/packages/base/any/oom-shim/src/module/src/oom_internal.c b/packages/base/any/oom-shim/src/module/src/oom_internal.c new file mode 100644 index 00000000..0059479d --- /dev/null +++ b/packages/base/any/oom-shim/src/module/src/oom_internal.c @@ -0,0 +1,28 @@ +/* + * Internal OOM functions + */ + +#include +#include + +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"); + } +} diff --git a/packages/base/any/oom-shim/src/module/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c index 535a8a85..14c1275b 100644 --- a/packages/base/any/oom-shim/src/module/src/oom_shim.c +++ b/packages/base/any/oom-shim/src/module/src/oom_shim.c @@ -30,6 +30,7 @@ #include #include #include +#include int Initialized = 0; @@ -68,7 +69,7 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ pptr = &portlist[i]; pptr->handle = (void *)(uintptr_t)port; - pptr->oom_class = OOM_PORT_CLASS_SFF; + pptr->oom_class = OOM_PORT_CLASS_UNKNOWN; sprintf(pptr->name, "port%d", port); i++; @@ -79,24 +80,47 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ } if(rv < 0){ - printf("%4d Error\n", port); + aim_printf(&aim_pvs_stdout, "%4d Error %{onlp_status}\n", port, rv); continue; } rv = onlp_sfp_eeprom_read(port, &data); if(rv < 0){ - printf("%4d Error}\n", port); + aim_printf(&aim_pvs_stdout, "%4d Error %{onlp_status}\n", port, rv); continue; } sff_info_t sff; sff_info_init(&sff, data); - if(!sff.supported) { - printf("%13d UNK\n", port); - continue; + + if(sff.supported) { + pptr->oom_class = OOM_PORT_CLASS_SFF; } - printf("The sfp_type is : %-14s",sff.sfp_type_name); } return 0; } + +int oom_get_function(oom_port_t* port, oom_functions_t function, int* rv){ + return -1; +} + +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; + uint8_t* idprom = NULL; + + port_num = (unsigned int)(uintptr_t)port->handle; + rv = onlp_sfp_eeprom_read(port_num, &idprom); + if(rv < 0) { + aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n"); + } + else { + aim_printf(&aim_pvs_stdout, "eeprom:\n%{data}\n", idprom, 128); + aim_free(idprom); + } + return 0; +} +int oom_get_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data){ + return -1; +} From b568a271d78cafe21121c2a204e3c2c0a636c277 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Wed, 24 Feb 2016 07:07:40 -0800 Subject: [PATCH 12/13] implemented oom_get_memory_sff --- .../src/module/inc/oom-shim/oom-shim.h | 12 ++++ .../any/oom-shim/src/module/src/oom_shim.c | 66 ++++++++++++++----- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h index f83e8035..5833c849 100644 --- a/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h @@ -1 +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 diff --git a/packages/base/any/oom-shim/src/module/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c index 14c1275b..8c3c37aa 100644 --- a/packages/base/any/oom-shim/src/module/src/oom_shim.c +++ b/packages/base/any/oom-shim/src/module/src/oom_shim.c @@ -22,22 +22,21 @@ * * ***********************************************************/ -#include -#include #include #include #include #include #include #include -#include -int Initialized = 0; -/*Initializing the SFP and ONLP modules*/ +/* +* Initializing the SFP and ONLP modules +* compiler calls this function while compiling +*/ + void __oom_shim_module_init__(void) { onlp_init(); - Initialized = 1; } /*Gets the portlist of the SFP ports on the switch*/ @@ -46,9 +45,6 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ int port,i=0; oom_port_t* pptr; - if(Initialized == 0){ - __oom_shim_module_init__(); - } onlp_sfp_bitmap_t bitmap; onlp_sfp_bitmap_t_init(&bitmap); @@ -75,7 +71,7 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ rv = onlp_sfp_is_present(port); if(rv == 0){ - printf("module %d is not present\n", port); + aim_printf(&aim_pvs_stdout, "module %d is not present\n", port); continue; } @@ -101,12 +97,9 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ return 0; } -int oom_get_function(oom_port_t* port, oom_functions_t function, int* rv){ - return -1; -} int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int len, uint8_t* data){ - int rv; + int rv,cur_offset; unsigned int port_num; uint8_t* idprom = NULL; @@ -114,13 +107,50 @@ int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int rv = onlp_sfp_eeprom_read(port_num, &idprom); if(rv < 0) { aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n"); + return -1; } - else { - aim_printf(&aim_pvs_stdout, "eeprom:\n%{data}\n", idprom, 128); - aim_free(idprom); + +#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_memory_cfp(oom_port_t* port, int address, int len, uint16_t* data){ + +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; } From 4d7b8f9e17da4a776e9f76f12281cb1a50f39197 Mon Sep 17 00:00:00 2001 From: Rohit Malaga Date: Wed, 24 Feb 2016 11:06:41 -0800 Subject: [PATCH 13/13] including suggestions by Rob --- .../any/oom-shim/src/module/src/oom_shim.c | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/base/any/oom-shim/src/module/src/oom_shim.c b/packages/base/any/oom-shim/src/module/src/oom_shim.c index 8c3c37aa..c997aadc 100644 --- a/packages/base/any/oom-shim/src/module/src/oom_shim.c +++ b/packages/base/any/oom-shim/src/module/src/oom_shim.c @@ -52,7 +52,6 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ if ((portlist == NULL) && (listsize == 0)){ /* asking # of ports */ if(AIM_BITMAP_COUNT(&bitmap) == 0){ - printf("No SFPs on this platform.\n"); return 0; } else @@ -61,38 +60,25 @@ int oom_get_portlist(oom_port_t portlist[], int listsize){ AIM_BITMAP_ITER(&bitmap, port){ int rv; - uint8_t* data; pptr = &portlist[i]; - pptr->handle = (void *)(uintptr_t)port; - pptr->oom_class = OOM_PORT_CLASS_UNKNOWN; - sprintf(pptr->name, "port%d", port); + 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; } - - rv = onlp_sfp_eeprom_read(port, &data); - - if(rv < 0){ - aim_printf(&aim_pvs_stdout, "%4d Error %{onlp_status}\n", port, rv); - continue; - } - - sff_info_t sff; - sff_info_init(&sff, data); - - if(sff.supported) { - pptr->oom_class = OOM_PORT_CLASS_SFF; - } } return 0; } @@ -104,7 +90,8 @@ int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int uint8_t* idprom = NULL; port_num = (unsigned int)(uintptr_t)port->handle; - rv = onlp_sfp_eeprom_read(port_num, &idprom); + 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;