diff --git a/builds/any/rootfs/jessie/common/common-packages.yml b/builds/any/rootfs/jessie/common/common-packages.yml index b92a757f..74ef19c4 100644 --- a/builds/any/rootfs/jessie/common/common-packages.yml +++ b/builds/any/rootfs/jessie/common/common-packages.yml @@ -69,4 +69,4 @@ - onl-faultd - onl-loader-initscripts - onlp-snmpd - +- oom-shim diff --git a/builds/any/rootfs/wheezy/common/common-packages.yml b/builds/any/rootfs/wheezy/common/common-packages.yml index e5803d7f..5857b0f2 100644 --- a/builds/any/rootfs/wheezy/common/common-packages.yml +++ b/builds/any/rootfs/wheezy/common/common-packages.yml @@ -68,5 +68,6 @@ - onl-faultd - onl-loader-initscripts - onlp-snmpd +- oom-shim diff --git a/docs/GettingStartedWedge.md b/docs/GettingStartedWedge.md index bf608275..fb479df2 100644 --- a/docs/GettingStartedWedge.md +++ b/docs/GettingStartedWedge.md @@ -62,16 +62,19 @@ ONL Manual Install 2) Boot switch and choose "ONIE: Rescue" to go to ONIE''s interactive mode -3) From the ONIE# prompt run "install_url http://opennetlinux.org/binaries/latest-wedge.installer" +3) From the ONIE# prompt run "install_url http://opennetlinux.org/binaries/latest-wedge-2.0.installer" 4) Wait for the install to finish and the system to reboot 5) One the onl login prompt appears login with the username root and the password "onl" -6) You can now change the root password +6) Configure the ma1 interface either via dhcp (dhclient ma1) or manually -7) Configure the ma1 interface either via dhcp (dhclient ma1) or manually +7) Install fboss using the commands + + #> apt-get update + #> apt-get install fboss 8) From the command prompt you can start fboss by using the command "service fboss_wedge_agent start" @@ -126,19 +129,35 @@ Now press RETURN here to jump into ONIE''s manual installer mode. You should se Then simply download the latest ONL wedge installer from the website and run it. - ONIE:/ # install_url http://opennetlinux.org/binaries/latest-wedge.installer + ONIE:/ # install_url http://opennetlinux.org/binaries/latest-wedge-2.0.installer Connecting to opennetlinux.org (107.170.237.53:80) Open Network Installer running under ONIE. - Installer Version: Open Network Linux 019421c (amd64.all,2015.11.17.06.23,019421c116940d87d5a41100d1b8a64cbba50252) - Detected platform: x86-64-accton-wedge-16x-r0 - Installing in standalone mode. - Unpacking Open Network Linux installer files... + Installing Open Network Linux Software Image (ONL-2.0.0_ONL-OS_2016-02-12.2304-b9b7e50_AMD64.swi)... + Installation finished. No error reported. + Install finished. Rebooting to Open Network Linux. ... Connecting tty=ttyS1 with /sbin/pgetty - Open Network Linux 019421c (amd64.all,2015.11.17.06.23,019421c116940d87d5a41100d1b8a64cbba50252) + Debian GNU/Linux 8 localhost ttyS1 - onl-wedge login: + localhost login: root + Password: + Linux localhost 3.2.65-1+deb7u2-OpenNetworkLinux #1 SMP Fri Feb 12 23:10:15 UTC 2016 x86_64 + root@localhost:~# apt-get update + root@localhost:~# apt-get install fboss + WARNING: The following packages cannot be authenticated! + folly wangle fbthrift fboss-py fboss-core fboss + Install these packages without verification? [y/N] y + + root@localhost:~# service fboss_wedge_agent start + [....] Starting Facebook FBOSS agent: fboss_wedge_agent + Error: OpenNSL library not found, attempting to grab from GitHub + Saving to: ‘/usr/local/lib/libopennsl.so.1’ + + OpenNSL library succesfully installed + [ ok --- Loading linux-kernel-bde linux-user-bde linux-bcm-knet ; Creating devices . + root@localhost:~# service fboss_wedge_agent status + [ ok ] fboss_wedge_agent is running. 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.'""" diff --git a/packages/base/amd64/oom-shim/Makefile b/packages/base/amd64/oom-shim/Makefile new file mode 100644 index 00000000..dc1e7b86 --- /dev/null +++ b/packages/base/amd64/oom-shim/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk 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..c119b5fc --- /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-16 14:17:39.946619 +# +############################################################################### +oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/base/any/faultd/builds/Makefile b/packages/base/any/faultd/builds/Makefile index 4f07a942..5f767564 100644 --- a/packages/base/any/faultd/builds/Makefile +++ b/packages/base/any/faultd/builds/Makefile @@ -47,5 +47,5 @@ GLOBAL_CFLAGS += -DFAULTD_CONFIG_INCLUDE_MAIN=1 GLOBAL_CFLAGS += -DFAULTD_CONFIG_INCLUDE_AIM_MAIN=1 GLOBAL_CFLAGS += -g -GLOBAL_LINK_LIBS += -lpthread +GLOBAL_LINK_LIBS += -lpthread -lrt diff --git a/packages/base/any/oom-shim/APKG.yml b/packages/base/any/oom-shim/APKG.yml new file mode 100644 index 00000000..6a54841f --- /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}/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..0ccc185a --- /dev/null +++ b/packages/base/any/oom-shim/builds/Makefile @@ -0,0 +1,56 @@ +# -*- 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 + +#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 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..5833c849 --- /dev/null +++ b/packages/base/any/oom-shim/src/module/inc/oom-shim/oom-shim.h @@ -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 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/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/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/module/src/Makefile b/packages/base/any/oom-shim/src/module/src/Makefile new file mode 100644 index 00000000..1259eda6 --- /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 oom_shim_ucli.c + 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/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 new file mode 100644 index 00000000..c997aadc --- /dev/null +++ b/packages/base/any/oom-shim/src/module/src/oom_shim.c @@ -0,0 +1,143 @@ +/************************************************************ + * + * + * 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 + + +/* +* 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; +} 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..106445d0 --- /dev/null +++ b/packages/base/any/oom-shim/src/oom_shim.mk @@ -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 + 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/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..04cfe7c1 --- /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-16 14:18:46.799062 +# +############################################################################### +oom_shim_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/sm/infra b/sm/infra index 810633d3..19f74c74 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 810633d3fc6b07e6b03428489fc84ef51a160753 +Subproject commit 19f74c743cd8d4c990640d0340fb295da428a0a8