From b67df2def1559e3c48b64ad2da2093f21e838f0f Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Thu, 7 Jun 2018 10:42:13 +0800 Subject: [PATCH 01/32] Add new accton platform, AS5916-26XB. --- .../src/python/onl/platform/base.py | 4 + .../configs/x86_64-all/x86_64-all.config | 13 +- .../x86-64-accton-as5916-26xb/.gitignore | 2 + .../x86-64/x86-64-accton-as5916-26xb/Makefile | 1 + .../modules/Makefile | 1 + .../x86-64-accton-as5916-26xb/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as5916-26xb-fan.c | 457 +++++++ .../builds/x86-64-accton-as5916-26xb-led.c | 465 +++++++ .../builds/x86-64-accton-as5916-26xb-psu.c | 547 ++++++++ .../builds/x86-64-accton-as5916-26xb-sfp.c | 1169 +++++++++++++++++ .../builds/x86-64-accton-as5916-26xb-sys.c | 368 ++++++ .../x86-64-accton-as5916-26xb-thermal.c | 358 +++++ .../x86-64-accton-as5916-26xb/onlp/Makefile | 1 + .../x86-64-accton-as5916-26xb/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../module/auto/x86_64_accton_as5916_26xb.yml | 50 + .../x86_64_accton_as5916_26xb.x | 14 + .../x86_64_accton_as5916_26xb_config.h | 137 ++ .../x86_64_accton_as5916_26xb_dox.h | 26 + .../x86_64_accton_as5916_26xb_porting.h | 107 ++ .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 232 ++++ .../onlp/builds/src/module/src/ledi.c | 248 ++++ .../onlp/builds/src/module/src/platform_lib.h | 70 + .../onlp/builds/src/module/src/psui.c | 154 +++ .../onlp/builds/src/module/src/sfpi.c | 287 ++++ .../onlp/builds/src/module/src/sysi.c | 103 ++ .../onlp/builds/src/module/src/thermali.c | 138 ++ .../src/x86_64_accton_as5916_26xb_config.c | 80 ++ .../src/x86_64_accton_as5916_26xb_enums.c | 10 + .../src/x86_64_accton_as5916_26xb_int.h | 12 + .../src/x86_64_accton_as5916_26xb_log.c | 18 + .../src/x86_64_accton_as5916_26xb_log.h | 12 + .../src/x86_64_accton_as5916_26xb_module.c | 24 + .../src/x86_64_accton_as5916_26xb_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as5916-26xb-r0.yml | 33 + .../x86_64_accton_as5916_26xb_r0/__init__.py | 13 + 48 files changed, 5334 insertions(+), 1 deletion(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-fan.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-led.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sfp.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sys.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-thermal.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/lib/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.module create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/README create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/x86_64_accton_as5916_26xb.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb.x create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_config.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_dox.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_porting.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/fani.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/psui.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sfpi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/thermali.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_config.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_enums.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_int.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_module.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/lib/x86-64-accton-as5916-26xb-r0.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/python/x86_64_accton_as5916_26xb_r0/__init__.py diff --git a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py index 4e5ce87a..f2790225 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/platform/base.py @@ -535,3 +535,7 @@ class OnlPlatformPortConfig_48x10_6x100(object): class OnlPlatformPortConfig_12x10_3x100(object): PORT_COUNT=15 PORT_CONFIG="12x10 + 3x100" + +class OnlPlatformPortConfig_24x10_2x100(object): + PORT_COUNT=26 + PORT_CONFIG="24x10 + 2x100" diff --git a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config index d05cf88b..f16bb336 100755 --- a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config @@ -654,6 +654,7 @@ CONFIG_ACPI_PROCESSOR_CSTATE=y CONFIG_ACPI_PROCESSOR_IDLE=y CONFIG_ACPI_CPPC_LIB=y CONFIG_ACPI_PROCESSOR=y +# CONFIG_ACPI_IPMI is not set CONFIG_ACPI_HOTPLUG_CPU=y # CONFIG_ACPI_PROCESSOR_AGGREGATOR is not set CONFIG_ACPI_THERMAL=y @@ -2413,7 +2414,15 @@ CONFIG_SERIAL_CORE_CONSOLE=y # CONFIG_TTY_PRINTK is not set CONFIG_HVC_DRIVER=y CONFIG_VIRTIO_CONSOLE=y -# CONFIG_IPMI_HANDLER is not set +CONFIG_IPMI_HANDLER=y +CONFIG_IPMI_DMI_DECODE=y +# CONFIG_IPMI_PANIC_EVENT is not set +CONFIG_IPMI_DEVICE_INTERFACE=y +CONFIG_IPMI_SI=y +CONFIG_IPMI_SI_PROBE_DEFAULTS=y +# CONFIG_IPMI_SSIF is not set +CONFIG_IPMI_WATCHDOG=y +CONFIG_IPMI_POWEROFF=y CONFIG_HW_RANDOM=y # CONFIG_HW_RANDOM_TIMERIOMEM is not set # CONFIG_HW_RANDOM_INTEL is not set @@ -2715,6 +2724,8 @@ CONFIG_HWMON=y # CONFIG_SENSORS_G762 is not set # CONFIG_SENSORS_GPIO_FAN is not set # CONFIG_SENSORS_HIH6130 is not set +# CONFIG_SENSORS_IBMAEM is not set +# CONFIG_SENSORS_IBMPEX is not set # CONFIG_SENSORS_I5500 is not set CONFIG_SENSORS_CORETEMP=y # CONFIG_SENSORS_IT87 is not set diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/.gitignore new file mode 100644 index 00000000..dbe9025a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/.gitignore @@ -0,0 +1,2 @@ +*x86*64*accton*as5916*26xb*.mk +onlpdump.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/PKG.yml new file mode 100644 index 00000000..32003db8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as5916-26xb ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/Makefile new file mode 100644 index 00000000..61dd5817 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as5916-26xb +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-fan.c new file mode 100644 index 00000000..b54660c1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-fan.c @@ -0,0 +1,457 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_fan" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_FAN_READ_CMD 0x14 +#define IPMI_FAN_WRITE_CMD 0x15 +#define IPMI_TIMEOUT (5 * HZ) + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static ssize_t set_fan(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_fan(struct device *dev, struct device_attribute *attr, char *buf); +static int as5916_26xb_fan_probe(struct platform_device *pdev); +static int as5916_26xb_fan_remove(struct platform_device *pdev); + +enum fan_id { + FAN_1, + FAN_2, + FAN_3, + FAN_4, + FAN_5, + NUM_OF_FAN +}; + +enum fan_data_index { + FAN_PRESENT, + FAN_PWM, + FAN_SPEED0, + FAN_SPEED1, + FAN_DATA_COUNT +}; + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +struct as5916_26xb_fan_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + unsigned char ipmi_resp[20]; + struct ipmi_data ipmi; + unsigned char ipmi_tx_data[3]; /* 0: FAN id, 1: 0x02, 2: PWM */ +}; + +struct as5916_26xb_fan_data *data = NULL; + +static struct platform_driver as5916_26xb_fan_driver = { + .probe = as5916_26xb_fan_probe, + .remove = as5916_26xb_fan_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +#define FAN_PRESENT_ATTR_ID(index) FAN##index##_PRESENT +#define FAN_PWM_ATTR_ID(index) FAN##index##_PWM +#define FAN_RPM_ATTR_ID(index) FAN##index##_INPUT + +#define FAN_ATTR(fan_id) \ + FAN_PRESENT_ATTR_ID(fan_id), \ + FAN_PWM_ATTR_ID(fan_id), \ + FAN_RPM_ATTR_ID(fan_id) + +enum as5916_54x_fan_sysfs_attrs { + FAN_ATTR(1), + FAN_ATTR(2), + FAN_ATTR(3), + FAN_ATTR(4), + FAN_ATTR(5), + NUM_OF_FAN_ATTR, + NUM_OF_PER_FAN_ATTR = (NUM_OF_FAN_ATTR/NUM_OF_FAN) +}; + +/* fan attributes */ +#define DECLARE_FAN_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, show_fan, NULL, FAN##index##_PRESENT); \ + static SENSOR_DEVICE_ATTR(fan##index##_pwm, S_IWUSR | S_IRUGO, show_fan, set_fan, FAN##index##_PWM); \ + static SENSOR_DEVICE_ATTR(fan##index##_input, S_IRUGO, show_fan, NULL, FAN##index##_INPUT) +#define DECLARE_FAN_ATTR(index) \ + &sensor_dev_attr_fan##index##_present.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_pwm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_input.dev_attr.attr + +DECLARE_FAN_SENSOR_DEVICE_ATTR(1); +DECLARE_FAN_SENSOR_DEVICE_ATTR(2); +DECLARE_FAN_SENSOR_DEVICE_ATTR(3); +DECLARE_FAN_SENSOR_DEVICE_ATTR(4); +DECLARE_FAN_SENSOR_DEVICE_ATTR(5); + +static struct attribute *as5916_26xb_fan_attributes[] = { + /* fan attributes */ + DECLARE_FAN_ATTR(1), + DECLARE_FAN_ATTR(2), + DECLARE_FAN_ATTR(3), + DECLARE_FAN_ATTR(4), + DECLARE_FAN_ATTR(5), + NULL +}; + +static const struct attribute_group as5916_26xb_fan_group = { + .attrs = as5916_26xb_fan_attributes, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static struct as5916_26xb_fan_data *as5916_26xb_fan_update_device(void) +{ + int status = 0; + + if (time_before(jiffies, data->last_updated + HZ * 5) && data->valid) { + return data; + } + + mutex_lock(&data->update_lock); + + data->valid = 0; + status = ipmi_send_message(&data->ipmi, IPMI_FAN_READ_CMD, NULL, 0, + data->ipmi_resp, sizeof(data->ipmi_resp)); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->last_updated = jiffies; + data->valid = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_fan(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char fid = attr->index / NUM_OF_PER_FAN_ATTR; + struct as5916_26xb_fan_data *data = NULL; + int value = 0; + int index = 0; + int present = 0; + + data = as5916_26xb_fan_update_device(); + if (!data->valid) { + return -EIO; + } + + index = fid * FAN_DATA_COUNT; /* base index */ + present = !data->ipmi_resp[index + FAN_PRESENT]; + + switch (attr->index) { + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + value = !data->ipmi_resp[index + FAN_PRESENT]; + break; + case FAN1_PWM: + case FAN2_PWM: + case FAN3_PWM: + case FAN4_PWM: + case FAN5_PWM: + value = (data->ipmi_resp[index + FAN_PWM] + 1) * 625 / 100; + break; + case FAN1_INPUT: + case FAN2_INPUT: + case FAN3_INPUT: + case FAN4_INPUT: + case FAN5_INPUT: + value = (int)data->ipmi_resp[index + FAN_SPEED0] | + (int)data->ipmi_resp[index + FAN_SPEED1] << 8; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", present ? value : 0); +} + +static ssize_t set_fan(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long pwm; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char fid = attr->index / NUM_OF_PER_FAN_ATTR; + + status = kstrtol(buf, 10, &pwm); + if (status) { + return status; + } + + pwm = (pwm * 100) / 625 - 1; /* Convert pwm to register value */ + + /* Send IPMI write command */ + data->ipmi_tx_data[0] = fid + 1; /* FAN ID base id for ipmi start from 1 */ + data->ipmi_tx_data[1] = 0x02; + data->ipmi_tx_data[2] = pwm; + status = ipmi_send_message(&data->ipmi, IPMI_FAN_WRITE_CMD, + data->ipmi_tx_data, sizeof(data->ipmi_tx_data), NULL, 0); + if (unlikely(status != 0)) { + return status; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + return -EIO; + } + + /* Update pwm to ipmi_resp buffer to prevent from the impact of lazy update */ + data->ipmi_resp[fid * FAN_DATA_COUNT + FAN_PWM] = pwm; + + return count; +} + +static int as5916_26xb_fan_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_create_group(&pdev->dev.kobj, &as5916_26xb_fan_group); + if (status) { + goto exit; + } + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_fan_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &as5916_26xb_fan_group); + + return 0; +} + +static int __init as5916_26xb_fan_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_fan_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + data->valid = 0; + + ret = platform_driver_register(&as5916_26xb_fan_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_fan_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_fan_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_fan_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB fan driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_fan_init); +module_exit(as5916_26xb_fan_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-led.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-led.c new file mode 100644 index 00000000..c89bed39 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-led.c @@ -0,0 +1,465 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_led" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_LED_READ_CMD 0x1A +#define IPMI_LED_WRITE_CMD 0x1B +#define IPMI_TIMEOUT (5 * HZ) + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static ssize_t set_led(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_led(struct device *dev, struct device_attribute *attr, char *buf); +static int as5916_26xb_led_probe(struct platform_device *pdev); +static int as5916_26xb_led_remove(struct platform_device *pdev); + +enum led_data_index { + LOC_INDEX, + DIAG_RED_INDEX, + DIAG_GREEN_INDEX +}; + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +struct as5916_26xb_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + unsigned char ipmi_resp[3]; /* 0: LOC LED, 1: DIAG Red LED, 2: DIAG Green LED */ + struct ipmi_data ipmi; +}; + +struct as5916_26xb_led_data *data = NULL; + +static struct platform_driver as5916_26xb_led_driver = { + .probe = as5916_26xb_led_probe, + .remove = as5916_26xb_led_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +enum as5916_54x_led_sysfs_attrs { + LED_LOC, + LED_DIAG, + LED_PSU1, + LED_PSU2, + LED_FAN +}; + +static SENSOR_DEVICE_ATTR(led_loc, S_IWUSR | S_IRUGO, show_led, set_led, LED_LOC); +static SENSOR_DEVICE_ATTR(led_diag, S_IWUSR | S_IRUGO, show_led, set_led, LED_DIAG); +static SENSOR_DEVICE_ATTR(led_psu1, S_IWUSR | S_IRUGO, show_led, set_led, LED_PSU1); +static SENSOR_DEVICE_ATTR(led_psu2, S_IWUSR | S_IRUGO, show_led, set_led, LED_PSU2); +static SENSOR_DEVICE_ATTR(led_fan, S_IWUSR | S_IRUGO, show_led, set_led, LED_FAN); + +static struct attribute *as5916_26xb_led_attributes[] = { + &sensor_dev_attr_led_loc.dev_attr.attr, + &sensor_dev_attr_led_diag.dev_attr.attr, + &sensor_dev_attr_led_psu1.dev_attr.attr, + &sensor_dev_attr_led_psu2.dev_attr.attr, + &sensor_dev_attr_led_fan.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5916_26xb_led_group = { + .attrs = as5916_26xb_led_attributes, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static struct as5916_26xb_led_data *as5916_26xb_led_update_device(void) +{ + int status = 0; + + if (time_before(jiffies, data->last_updated + HZ * 5) && data->valid) { + return data; + } + + mutex_lock(&data->update_lock); + + data->valid = 0; + status = ipmi_send_message(&data->ipmi, IPMI_LED_READ_CMD, NULL, 0, + data->ipmi_resp, sizeof(data->ipmi_resp)); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->last_updated = jiffies; + data->valid = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_led(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_26xb_led_data *data = NULL; + int value; + + data = as5916_26xb_led_update_device(); + if (!data->valid) { + return -EIO; + } + + switch (attr->index) { + case LED_LOC: + value = data->ipmi_resp[LOC_INDEX] ? LED_MODE_ORANGE_BLINKING : LED_MODE_OFF; + break; + case LED_DIAG: + { + if (data->ipmi_resp[DIAG_GREEN_INDEX] && data->ipmi_resp[DIAG_RED_INDEX]) + value = LED_MODE_OFF; + else if (!data->ipmi_resp[DIAG_GREEN_INDEX] && !data->ipmi_resp[DIAG_RED_INDEX]) + value = LED_MODE_OFF; + else if (data->ipmi_resp[DIAG_RED_INDEX]) + value = LED_MODE_ORANGE; + else if (data->ipmi_resp[DIAG_GREEN_INDEX] == 1) + value = LED_MODE_GREEN_BLINKING; + else + value = LED_MODE_GREEN; + break; + } + case LED_PSU1: + case LED_PSU2: + case LED_FAN: + value = LED_MODE_AUTO; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t set_led(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long mode; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + status = kstrtol(buf, 10, &mode); + if (status) { + return status; + } + + data = as5916_26xb_led_update_device(); + if (!data->valid) { + return -EIO; + } + + switch (attr->index) { + case LED_LOC: + data->ipmi_resp[LOC_INDEX] = !!mode; + break; + case LED_DIAG: + { + if (mode == LED_MODE_GREEN_BLINKING) { + data->ipmi_resp[DIAG_GREEN_INDEX] = 1; + data->ipmi_resp[DIAG_RED_INDEX] = 0; + } + else if (mode == LED_MODE_GREEN) { + data->ipmi_resp[DIAG_GREEN_INDEX] = 2; + data->ipmi_resp[DIAG_RED_INDEX] = 0; + } + else if (mode == LED_MODE_ORANGE) { + data->ipmi_resp[DIAG_GREEN_INDEX] = 0; + data->ipmi_resp[DIAG_RED_INDEX] = 1; + } + else { /* OFF */ + data->ipmi_resp[DIAG_GREEN_INDEX] = 0; + data->ipmi_resp[DIAG_RED_INDEX] = 0; + } + + break; + } + default: + return -EINVAL; + } + + /* Send IPMI write command */ + status = ipmi_send_message(&data->ipmi, IPMI_LED_WRITE_CMD, + data->ipmi_resp, sizeof(data->ipmi_resp), NULL, 0); + if (unlikely(status != 0)) { + return status; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + return -EIO; + } + + return count; +} + +static int as5916_26xb_led_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_create_group(&pdev->dev.kobj, &as5916_26xb_led_group); + if (status) { + goto exit; + } + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_led_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &as5916_26xb_led_group); + + return 0; +} + +static int __init as5916_26xb_led_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_led_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + data->valid = 0; + + ret = platform_driver_register(&as5916_26xb_led_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_led_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_led_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_led_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB led driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_led_init); +module_exit(as5916_26xb_led_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-psu.c new file mode 100644 index 00000000..ba71289b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-psu.c @@ -0,0 +1,547 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_psu" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_PSU_READ_CMD 0x16 +#define IPMI_PSU_MODEL_NAME_CMD 0x10 +#define IPMI_PSU_SERIAL_NUM_CMD 0x11 +#define IPMI_TIMEOUT (5 * HZ) + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static ssize_t show_psu(struct device *dev, struct device_attribute *attr, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *attr, char *buf); +static int as5916_26xb_psu_probe(struct platform_device *pdev); +static int as5916_26xb_psu_remove(struct platform_device *pdev); + +enum psu_id { + PSU_1, + PSU_2, + NUM_OF_PSU +}; + +enum psu_data_index { + PSU_PRESENT = 0, + PSU_TEMP_FAULT, + PSU_POWER_GOOD_CPLD, + PSU_POWER_GOOD_PMBUS, + PSU_OVER_VOLTAGE, + PSU_OVER_CURRENT, + PSU_POWER_ON, + PSU_VIN0, + PSU_VIN1, + PSU_VOUT0, + PSU_VOUT1, + PSU_IOUT0, + PSU_IOUT1, + PSU_TEMP0, + PSU_TEMP1, + PSU_FAN0, + PSU_FAN1, + PSU_POUT0, + PSU_POUT1, + PSU_STATUS_COUNT, + PSU_MODEL = 0, + PSU_SERIAL = 0 +}; + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +struct ipmi_psu_resp_data { + char status[19]; + char serial[20]; + char model[9]; +}; + +struct as5916_26xb_psu_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid[2]; /* != 0 if registers are valid, 0: PSU1, 1: PSU2 */ + unsigned long last_updated[2]; /* In jiffies, 0: PSU1, 1: PSU2 */ + struct ipmi_data ipmi; + struct ipmi_psu_resp_data ipmi_resp[2]; /* 0: PSU1, 1: PSU2 */ + unsigned char ipmi_tx_data[2]; +}; + +struct as5916_26xb_psu_data *data = NULL; + +static struct platform_driver as5916_26xb_psu_driver = { + .probe = as5916_26xb_psu_probe, + .remove = as5916_26xb_psu_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +#define PSU_PRESENT_ATTR_ID(index) PSU##index##_PRESENT +#define PSU_POWERGOOD_ATTR_ID(index) PSU##index##_POWER_GOOD +#define PSU_VIN_ATTR_ID(index) PSU##index##_VIN +#define PSU_VOUT_ATTR_ID(index) PSU##index##_VOUT +#define PSU_IOUT_ATTR_ID(index) PSU##index##_IOUT +#define PSU_POUT_ATTR_ID(index) PSU##index##_POUT +#define PSU_MODEL_ATTR_ID(index) PSU##index##_MODEL +#define PSU_SERIAL_ATTR_ID(index) PSU##index##_SERIAL +#define PSU_TEMP_INPUT_ATTR_ID(index) PSU##index##_TEMP_INPUT +#define PSU_FAN_INPUT_ATTR_ID(index) PSU##index##_FAN_INPUT + +#define PSU_ATTR(psu_id) \ + PSU_PRESENT_ATTR_ID(psu_id), \ + PSU_POWERGOOD_ATTR_ID(psu_id), \ + PSU_VIN_ATTR_ID(psu_id), \ + PSU_VOUT_ATTR_ID(psu_id), \ + PSU_IOUT_ATTR_ID(psu_id), \ + PSU_POUT_ATTR_ID(psu_id), \ + PSU_MODEL_ATTR_ID(psu_id), \ + PSU_SERIAL_ATTR_ID(psu_id), \ + PSU_TEMP_INPUT_ATTR_ID(psu_id), \ + PSU_FAN_INPUT_ATTR_ID(psu_id) + +enum as5916_54x_psu_sysfs_attrs { + /* psu attributes */ + PSU_ATTR(1), + PSU_ATTR(2), + NUM_OF_PSU_ATTR, + NUM_OF_PER_PSU_ATTR = (NUM_OF_PSU_ATTR/NUM_OF_PSU) +}; + +/* psu attributes */ +#define DECLARE_PSU_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(psu##index##_present, S_IRUGO, show_psu, NULL, PSU##index##_PRESENT); \ + static SENSOR_DEVICE_ATTR(psu##index##_power_good, S_IRUGO, show_psu, NULL, PSU##index##_POWER_GOOD); \ + static SENSOR_DEVICE_ATTR(psu##index##_vin, S_IRUGO, show_psu, NULL, PSU##index##_VIN); \ + static SENSOR_DEVICE_ATTR(psu##index##_vout, S_IRUGO, show_psu, NULL, PSU##index##_VOUT); \ + static SENSOR_DEVICE_ATTR(psu##index##_iout, S_IRUGO, show_psu, NULL, PSU##index##_IOUT); \ + static SENSOR_DEVICE_ATTR(psu##index##_pout, S_IRUGO, show_psu, NULL, PSU##index##_POUT); \ + static SENSOR_DEVICE_ATTR(psu##index##_model, S_IRUGO, show_string, NULL, PSU##index##_MODEL); \ + static SENSOR_DEVICE_ATTR(psu##index##_serial, S_IRUGO, show_string, NULL, PSU##index##_SERIAL);\ + static SENSOR_DEVICE_ATTR(psu##index##_temp1_input, S_IRUGO, show_psu, NULL, PSU##index##_TEMP_INPUT); \ + static SENSOR_DEVICE_ATTR(psu##index##_fan1_input, S_IRUGO, show_psu, NULL, PSU##index##_FAN_INPUT) +#define DECLARE_PSU_ATTR(index) \ + &sensor_dev_attr_psu##index##_present.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_power_good.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_vin.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_vout.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_iout.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_pout.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_model.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_serial.dev_attr.attr,\ + &sensor_dev_attr_psu##index##_temp1_input.dev_attr.attr, \ + &sensor_dev_attr_psu##index##_fan1_input.dev_attr.attr + +DECLARE_PSU_SENSOR_DEVICE_ATTR(1); +DECLARE_PSU_SENSOR_DEVICE_ATTR(2); + +static struct attribute *as5916_26xb_psu_attributes[] = { + /* psu attributes */ + DECLARE_PSU_ATTR(1), + DECLARE_PSU_ATTR(2), + NULL +}; + +static const struct attribute_group as5916_26xb_psu_group = { + .attrs = as5916_26xb_psu_attributes, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static struct as5916_26xb_psu_data *as5916_26xb_psu_update_device(struct device_attribute *da) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_PSU_ATTR; + int status = 0; + + if (time_before(jiffies, data->last_updated[pid] + HZ * 5) && data->valid[pid]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->valid[pid] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = pid + 1; /* PSU ID base id for ipmi start from 1 */ + status = ipmi_send_message(&data->ipmi, IPMI_PSU_READ_CMD, data->ipmi_tx_data, 1, + data->ipmi_resp[pid].status, sizeof(data->ipmi_resp[pid].status)); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + /* Get model name from ipmi */ + data->ipmi_tx_data[1] = 0x10; + status = ipmi_send_message(&data->ipmi, IPMI_PSU_READ_CMD, data->ipmi_tx_data, 2, + data->ipmi_resp[pid].model, sizeof(data->ipmi_resp[pid].model) - 1); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + /* Get serial number from ipmi */ + data->ipmi_tx_data[1] = 0x11; + status = ipmi_send_message(&data->ipmi, IPMI_PSU_READ_CMD, data->ipmi_tx_data, 2, + data->ipmi_resp[pid].serial, sizeof(data->ipmi_resp[pid].serial) - 1); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->last_updated[pid] = jiffies; + data->valid[pid] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +#define VALIDATE_PRESENT_RETURN(id) \ +{ \ + if (data->ipmi_resp[id].status[PSU_PRESENT] != 0) { \ + return -ENXIO; \ + } \ +} + +static ssize_t show_psu(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_PSU_ATTR; + struct as5916_26xb_psu_data *data = NULL; + int value = 0; + + data = as5916_26xb_psu_update_device(da); + if (!data->valid[pid]) { + return -EIO; + } + + switch (attr->index) { + case PSU1_PRESENT: + case PSU2_PRESENT: + value = !(data->ipmi_resp[pid].status[PSU_PRESENT]); + break; + case PSU1_POWER_GOOD: + case PSU2_POWER_GOOD: + VALIDATE_PRESENT_RETURN(pid); + value = data->ipmi_resp[pid].status[PSU_POWER_GOOD_CPLD]; + break; + case PSU1_VIN: + case PSU2_VIN: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_VIN0] | + (int)data->ipmi_resp[pid].status[PSU_VIN1] << 8) * 1000; + break; + case PSU1_VOUT: + case PSU2_VOUT: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_VOUT0] | + (int)data->ipmi_resp[pid].status[PSU_VOUT1] << 8) * 1000; + break; + case PSU1_IOUT: + case PSU2_IOUT: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_IOUT0] | + (int)data->ipmi_resp[pid].status[PSU_IOUT1] << 8) * 1000; + break; + case PSU1_POUT: + case PSU2_POUT: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_POUT0] | + (int)data->ipmi_resp[pid].status[PSU_POUT1] << 8) * 1000; + break; + case PSU1_TEMP_INPUT: + case PSU2_TEMP_INPUT: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_TEMP0] | + (int)data->ipmi_resp[pid].status[PSU_TEMP1] << 8) * 1000; + break; + case PSU1_FAN_INPUT: + case PSU2_FAN_INPUT: + VALIDATE_PRESENT_RETURN(pid); + value = ((int)data->ipmi_resp[pid].status[PSU_FAN0] | + (int)data->ipmi_resp[pid].status[PSU_FAN1] << 8); + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_PSU_ATTR; + struct as5916_26xb_psu_data *data; + char *str = NULL; + + data = as5916_26xb_psu_update_device(da); + if (!data->valid[pid]) { + return -EIO; + } + + switch (attr->index) { + case PSU1_MODEL: + case PSU2_MODEL: + VALIDATE_PRESENT_RETURN(pid); + str = data->ipmi_resp[pid].model; + break; + case PSU1_SERIAL: + case PSU2_SERIAL: + VALIDATE_PRESENT_RETURN(pid); + str = data->ipmi_resp[pid].serial; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%s\n", str); +} + +static int as5916_26xb_psu_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_create_group(&pdev->dev.kobj, &as5916_26xb_psu_group); + if (status) { + goto exit; + } + + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_psu_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &as5916_26xb_psu_group); + return 0; +} + +static int __init as5916_26xb_psu_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_psu_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + + ret = platform_driver_register(&as5916_26xb_psu_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_psu_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_psu_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_psu_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB PSU driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_psu_init); +module_exit(as5916_26xb_psu_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sfp.c new file mode 100644 index 00000000..20e28815 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sfp.c @@ -0,0 +1,1169 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_sfp" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_QSFP_READ_CMD 0x10 +#define IPMI_QSFP_WRITE_CMD 0x11 +#define IPMI_SFP_READ_CMD 0x1C +#define IPMI_SFP_WRITE_CMD 0x1D +#define IPMI_TIMEOUT (5 * HZ) +#define IPMI_READ_MAX_LEN 128 + +#define EEPROM_SIZE 256 /* 256 byte eeprom */ + +#define NUM_OF_SFP 24 +#define NUM_OF_QSFP 2 + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static ssize_t set_sfp(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_sfp(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_sfp_eeprom(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_qsfp_txdisable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t set_qsfp_reset(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_qsfp(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_qsfp_eeprom(struct device *dev, struct device_attribute *da, char *buf); +static int as5916_26xb_sfp_probe(struct platform_device *pdev); +static int as5916_26xb_sfp_remove(struct platform_device *pdev); +static ssize_t show_all(struct device *dev, struct device_attribute *da, char *buf); +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_present(void); +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_txdisable(void); +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_txfault(void); +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_rxlos(void); +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_present(void); +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_txdisable(void); +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_reset(void); +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_eeprom(int port); + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +enum module_status { + SFP_PRESENT = 0, + SFP_TXDISABLE, + SFP_TXFAULT, + SFP_RXLOS, + NUM_OF_SFP_STATUS, + + QSFP_PRESENT = 0, + QSFP_TXDISABLE, + QSFP_RESET, + NUM_OF_QSFP_STATUS, + + PRESENT_ALL = 0, + RXLOS_ALL +}; + +struct ipmi_sfp_resp_data { + unsigned char eeprom[EEPROM_SIZE]; + char eeprom_valid; + + char sfp_valid[NUM_OF_SFP_STATUS]; /* != 0 if registers are valid */ + unsigned long sfp_last_updated[NUM_OF_SFP_STATUS]; /* In jiffies */ + unsigned char sfp_resp[NUM_OF_SFP_STATUS][NUM_OF_SFP]; /* 0: present, 1: tx-disable + 2: tx-fault, 3: rx-los */ + char qsfp_valid[NUM_OF_QSFP_STATUS]; /* != 0 if registers are valid */ + unsigned long qsfp_last_updated[NUM_OF_SFP_STATUS]; /* In jiffies */ + unsigned char qsfp_resp[NUM_OF_QSFP_STATUS][NUM_OF_QSFP]; /* 0: present, 1: tx-disable, 2: reset */ +}; + +struct as5916_26xb_sfp_data { + struct platform_device *pdev; + struct mutex update_lock; + struct ipmi_data ipmi; + struct ipmi_sfp_resp_data ipmi_resp; + unsigned char ipmi_tx_data[3]; +}; + +struct as5916_26xb_sfp_data *data = NULL; + +static struct platform_driver as5916_26xb_sfp_driver = { + .probe = as5916_26xb_sfp_probe, + .remove = as5916_26xb_sfp_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +#define SFP_PRESENT_ATTR_ID(port) SFP##port##_PRESENT +#define SFP_TXDISABLE_ATTR_ID(port) SFP##port##_TXDISABLE +#define SFP_TXFAULT_ATTR_ID(port) SFP##port##_TXFAULT +#define SFP_RXLOS_ATTR_ID(port) SFP##port##_RXLOS +#define SFP_EEPROM_ATTR_ID(port) SFP##port##_EEPROM + +#define SFP_ATTR(port) \ + SFP_PRESENT_ATTR_ID(port), \ + SFP_TXDISABLE_ATTR_ID(port), \ + SFP_TXFAULT_ATTR_ID(port), \ + SFP_RXLOS_ATTR_ID(port), \ + SFP_EEPROM_ATTR_ID(port) + +#define QSFP_PRESENT_ATTR_ID(port) QSFP##port##_PRESENT +#define QSFP_TXDISABLE_ATTR_ID(port) QSFP##port##_TXDISABLE +#define QSFP_RESET_ATTR_ID(port) QSFP##port##_RESET +#define QSFP_EEPROM_ATTR_ID(port) QSFP##port##_EEPROM + +#define QSFP_ATTR(port) \ + QSFP_PRESENT_ATTR_ID(port), \ + QSFP_TXDISABLE_ATTR_ID(port), \ + QSFP_RESET_ATTR_ID(port), \ + QSFP_EEPROM_ATTR_ID(port) + +enum as5916_54x_sfp_sysfs_attrs { + SFP_ATTR(1), + SFP_ATTR(2), + SFP_ATTR(3), + SFP_ATTR(4), + SFP_ATTR(5), + SFP_ATTR(6), + SFP_ATTR(7), + SFP_ATTR(8), + SFP_ATTR(9), + SFP_ATTR(10), + SFP_ATTR(11), + SFP_ATTR(12), + SFP_ATTR(13), + SFP_ATTR(14), + SFP_ATTR(15), + SFP_ATTR(16), + SFP_ATTR(17), + SFP_ATTR(18), + SFP_ATTR(19), + SFP_ATTR(20), + SFP_ATTR(21), + SFP_ATTR(22), + SFP_ATTR(23), + SFP_ATTR(24), + NUM_OF_SFP_ATTR, + NUM_OF_PER_SFP_ATTR = (NUM_OF_SFP_ATTR/NUM_OF_SFP), +}; + +enum as5916_54x_qsfp_sysfs_attrs { + QSFP_ATTR(25), + QSFP_ATTR(26), + NUM_OF_QSFP_ATTR, + NUM_OF_PER_QSFP_ATTR = (NUM_OF_QSFP_ATTR/NUM_OF_QSFP), +}; + +/* sfp attributes */ +#define DECLARE_SFP_SENSOR_DEVICE_ATTR(port) \ + static SENSOR_DEVICE_ATTR(module_present_##port, S_IRUGO, show_sfp, NULL, SFP##port##_PRESENT); \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##port, S_IWUSR | S_IRUGO, show_sfp, set_sfp, SFP##port##_TXDISABLE); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##port, S_IRUGO, show_sfp, NULL, SFP##port##_TXFAULT); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##port, S_IRUGO, show_sfp, NULL, SFP##port##_RXLOS); \ + static SENSOR_DEVICE_ATTR(module_eeprom_##port, S_IRUGO, show_sfp_eeprom, NULL, SFP##port##_EEPROM) +#define DECLARE_SFP_ATTR(port) \ + &sensor_dev_attr_module_present_##port.dev_attr.attr, \ + &sensor_dev_attr_module_tx_disable_##port.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##port.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##port.dev_attr.attr, \ + &sensor_dev_attr_module_eeprom_##port.dev_attr.attr + +/* qsfp attributes */ +#define DECLARE_QSFP_SENSOR_DEVICE_ATTR(port) \ + static SENSOR_DEVICE_ATTR(module_present_##port, S_IRUGO, show_qsfp, NULL, QSFP##port##_PRESENT); \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##port, S_IWUSR | S_IRUGO, show_qsfp, set_qsfp_txdisable, QSFP##port##_TXDISABLE); \ + static SENSOR_DEVICE_ATTR(module_reset_##port, S_IWUSR | S_IRUGO, show_qsfp, set_qsfp_reset, QSFP##port##_RESET); \ + static SENSOR_DEVICE_ATTR(module_eeprom_##port, S_IRUGO, show_qsfp_eeprom, NULL, QSFP##port##_EEPROM) +#define DECLARE_QSFP_ATTR(port) \ + &sensor_dev_attr_module_present_##port.dev_attr.attr, \ + &sensor_dev_attr_module_tx_disable_##port.dev_attr.attr, \ + &sensor_dev_attr_module_reset_##port.dev_attr.attr, \ + &sensor_dev_attr_module_eeprom_##port.dev_attr.attr + +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_all, NULL, PRESENT_ALL); \ +static SENSOR_DEVICE_ATTR(module_rxlos_all, S_IRUGO, show_all, NULL, RXLOS_ALL); \ + +DECLARE_SFP_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_SENSOR_DEVICE_ATTR(24); +DECLARE_QSFP_SENSOR_DEVICE_ATTR(25); +DECLARE_QSFP_SENSOR_DEVICE_ATTR(26); + +static struct attribute *as5916_26xb_sfp_attributes[] = { + /* sfp attributes */ + DECLARE_SFP_ATTR(1), + DECLARE_SFP_ATTR(2), + DECLARE_SFP_ATTR(3), + DECLARE_SFP_ATTR(4), + DECLARE_SFP_ATTR(5), + DECLARE_SFP_ATTR(6), + DECLARE_SFP_ATTR(7), + DECLARE_SFP_ATTR(8), + DECLARE_SFP_ATTR(9), + DECLARE_SFP_ATTR(10), + DECLARE_SFP_ATTR(11), + DECLARE_SFP_ATTR(12), + DECLARE_SFP_ATTR(13), + DECLARE_SFP_ATTR(14), + DECLARE_SFP_ATTR(15), + DECLARE_SFP_ATTR(16), + DECLARE_SFP_ATTR(17), + DECLARE_SFP_ATTR(18), + DECLARE_SFP_ATTR(19), + DECLARE_SFP_ATTR(20), + DECLARE_SFP_ATTR(21), + DECLARE_SFP_ATTR(22), + DECLARE_SFP_ATTR(23), + DECLARE_SFP_ATTR(24), + DECLARE_QSFP_ATTR(25), + DECLARE_QSFP_ATTR(26), + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rxlos_all.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5916_26xb_sfp_group = { + .attrs = as5916_26xb_sfp_attributes, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_present(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.sfp_last_updated[SFP_PRESENT] + HZ) && + data->ipmi_resp.sfp_valid[SFP_PRESENT]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.sfp_valid[SFP_PRESENT] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x10; + status = ipmi_send_message(&data->ipmi, IPMI_SFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.sfp_resp[SFP_PRESENT], + sizeof(data->ipmi_resp.sfp_resp[SFP_PRESENT])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.sfp_last_updated[SFP_PRESENT] = jiffies; + data->ipmi_resp.sfp_valid[SFP_PRESENT] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_txdisable(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.sfp_last_updated[SFP_TXDISABLE] + HZ * 5) && + data->ipmi_resp.sfp_valid[SFP_TXDISABLE]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.sfp_valid[SFP_TXDISABLE] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x01; + status = ipmi_send_message(&data->ipmi, IPMI_SFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.sfp_resp[SFP_TXDISABLE], + sizeof(data->ipmi_resp.sfp_resp[SFP_TXDISABLE])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.sfp_last_updated[SFP_TXDISABLE] = jiffies; + data->ipmi_resp.sfp_valid[SFP_TXDISABLE] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_txfault(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.sfp_last_updated[SFP_TXFAULT] + HZ * 5) && + data->ipmi_resp.sfp_valid[SFP_TXFAULT]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.sfp_valid[SFP_TXFAULT] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x12; + status = ipmi_send_message(&data->ipmi, IPMI_SFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.sfp_resp[SFP_TXFAULT], + sizeof(data->ipmi_resp.sfp_resp[SFP_TXFAULT])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.sfp_last_updated[SFP_TXFAULT] = jiffies; + data->ipmi_resp.sfp_valid[SFP_TXFAULT] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_rxlos(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.sfp_last_updated[SFP_RXLOS] + HZ * 5) && + data->ipmi_resp.sfp_valid[SFP_RXLOS]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.sfp_valid[SFP_RXLOS] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x13; + status = ipmi_send_message(&data->ipmi, IPMI_SFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.sfp_resp[SFP_RXLOS], + sizeof(data->ipmi_resp.sfp_resp[SFP_RXLOS])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.sfp_last_updated[SFP_RXLOS] = jiffies; + data->ipmi_resp.sfp_valid[SFP_RXLOS] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_present(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.qsfp_last_updated[QSFP_PRESENT] + HZ) && + data->ipmi_resp.qsfp_valid[QSFP_PRESENT]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.qsfp_valid[QSFP_PRESENT] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x10; + status = ipmi_send_message(&data->ipmi, IPMI_QSFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.qsfp_resp[QSFP_PRESENT], + sizeof(data->ipmi_resp.qsfp_resp[QSFP_PRESENT])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.qsfp_last_updated[QSFP_PRESENT] = jiffies; + data->ipmi_resp.qsfp_valid[QSFP_PRESENT] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_txdisable(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.qsfp_last_updated[QSFP_TXDISABLE] + HZ * 5) && + data->ipmi_resp.qsfp_valid[QSFP_TXDISABLE]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.qsfp_valid[QSFP_TXDISABLE] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x01; + status = ipmi_send_message(&data->ipmi, IPMI_QSFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.qsfp_resp[QSFP_TXDISABLE], + sizeof(data->ipmi_resp.qsfp_resp[QSFP_TXDISABLE])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.qsfp_last_updated[QSFP_TXDISABLE] = jiffies; + data->ipmi_resp.qsfp_valid[QSFP_TXDISABLE] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_qsfp_update_reset(void) +{ + int status = 0; + + if (time_before(jiffies, data->ipmi_resp.qsfp_last_updated[QSFP_RESET] + HZ * 5) && + data->ipmi_resp.qsfp_valid[QSFP_RESET]) { + return data; + } + + mutex_lock(&data->update_lock); + + data->ipmi_resp.qsfp_valid[QSFP_RESET] = 0; + + /* Get status from ipmi */ + data->ipmi_tx_data[0] = 0x11; + status = ipmi_send_message(&data->ipmi, IPMI_QSFP_READ_CMD, + data->ipmi_tx_data, 1, + data->ipmi_resp.qsfp_resp[QSFP_RESET], + sizeof(data->ipmi_resp.qsfp_resp[QSFP_RESET])); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->ipmi_resp.qsfp_last_updated[QSFP_RESET] = jiffies; + data->ipmi_resp.qsfp_valid[QSFP_RESET] = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static struct as5916_26xb_sfp_data *as5916_26xb_sfp_update_eeprom(int port) +{ + int status = 0, i = 0; + unsigned char cmd = (port <= NUM_OF_SFP) ? IPMI_SFP_READ_CMD : IPMI_QSFP_READ_CMD; + unsigned char ipmi_port_id = (port <= NUM_OF_SFP) ? port : (port - NUM_OF_SFP); + + mutex_lock(&data->update_lock); + + data->ipmi_resp.eeprom_valid = 0; + + for (i = 0; i <= 1; i++) { + data->ipmi_tx_data[0] = ipmi_port_id; + data->ipmi_tx_data[1] = i; /* 0: Get eeprom byte (0~127) from ipmi + 1: Get eeprom byte (128~255) from ipmi */ + status = ipmi_send_message(&data->ipmi, cmd, data->ipmi_tx_data, 2, + data->ipmi_resp.eeprom + i*128, 128); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + } + + data->ipmi_resp.eeprom_valid = 1; + +exit: + mutex_unlock(&data->update_lock); + return data; +} + +static ssize_t show_all(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_26xb_sfp_data *data = NULL; + u32 values = 0; + int i; + + switch (attr->index) { + case PRESENT_ALL: + { + data = as5916_26xb_sfp_update_present(); + if (!data->ipmi_resp.sfp_valid[SFP_PRESENT]) { + return -EIO; + } + + data = as5916_26xb_qsfp_update_present(); + if (!data->ipmi_resp.qsfp_valid[QSFP_PRESENT]) { + return -EIO; + } + + /* Update qsfp present status */ + for (i = (NUM_OF_QSFP-1); i >= 0; i--) { + values <<= 1; + values |= (data->ipmi_resp.qsfp_resp[QSFP_PRESENT][i] & 0x1); + } + + /* Update sfp present status */ + for (i = (NUM_OF_SFP-1); i >= 0; i--) { + values <<= 1; + values |= (data->ipmi_resp.sfp_resp[SFP_PRESENT][i] & 0x1); + } + + /* Return values 1 -> 26 in order */ + return sprintf(buf, "%.2x %.2x %.2x %.2x\n", + 0xFF & values, + 0xFF & (values >> 8), + 0xFF & (values >> 16), + 0x3 & (values >> 24)); + } + case RXLOS_ALL: + { + data = as5916_26xb_sfp_update_rxlos(); + if (!data->ipmi_resp.sfp_valid[SFP_RXLOS]) { + return -EIO; + } + + /* Update sfp rxlos status */ + for (i = (NUM_OF_SFP-1); i >= 0; i--) { + values <<= 1; + values |= !(data->ipmi_resp.sfp_resp[SFP_RXLOS][i] & 0x1); + } + + /* Return values 1 -> 26 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", + 0xFF & values, + 0xFF & (values >> 8), + 0xFF & (values >> 16)); + } + default: + break; + } + + return 0; +} + +static ssize_t show_sfp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_SFP_ATTR; /* port id, 0 based */ + struct as5916_26xb_sfp_data *data = NULL; + int value = 0; + + switch (attr->index) { + case SFP1_PRESENT: + case SFP2_PRESENT: + case SFP3_PRESENT: + case SFP4_PRESENT: + case SFP5_PRESENT: + case SFP6_PRESENT: + case SFP7_PRESENT: + case SFP8_PRESENT: + case SFP9_PRESENT: + case SFP10_PRESENT: + case SFP11_PRESENT: + case SFP12_PRESENT: + case SFP13_PRESENT: + case SFP14_PRESENT: + case SFP15_PRESENT: + case SFP16_PRESENT: + case SFP17_PRESENT: + case SFP18_PRESENT: + case SFP19_PRESENT: + case SFP20_PRESENT: + case SFP21_PRESENT: + case SFP22_PRESENT: + case SFP23_PRESENT: + case SFP24_PRESENT: + { + data = as5916_26xb_sfp_update_present(); + if (!data->ipmi_resp.sfp_valid[SFP_PRESENT]) { + return -EIO; + } + + value = data->ipmi_resp.sfp_resp[SFP_PRESENT][pid]; + break; + } + case SFP1_TXDISABLE: + case SFP2_TXDISABLE: + case SFP3_TXDISABLE: + case SFP4_TXDISABLE: + case SFP5_TXDISABLE: + case SFP6_TXDISABLE: + case SFP7_TXDISABLE: + case SFP8_TXDISABLE: + case SFP9_TXDISABLE: + case SFP10_TXDISABLE: + case SFP11_TXDISABLE: + case SFP12_TXDISABLE: + case SFP13_TXDISABLE: + case SFP14_TXDISABLE: + case SFP15_TXDISABLE: + case SFP16_TXDISABLE: + case SFP17_TXDISABLE: + case SFP18_TXDISABLE: + case SFP19_TXDISABLE: + case SFP20_TXDISABLE: + case SFP21_TXDISABLE: + case SFP22_TXDISABLE: + case SFP23_TXDISABLE: + case SFP24_TXDISABLE: + { + data = as5916_26xb_sfp_update_txdisable(); + if (!data->ipmi_resp.sfp_valid[SFP_TXDISABLE]) { + return -EIO; + } + + value = !data->ipmi_resp.sfp_resp[SFP_TXDISABLE][pid]; + break; + } + case SFP1_TXFAULT: + case SFP2_TXFAULT: + case SFP3_TXFAULT: + case SFP4_TXFAULT: + case SFP5_TXFAULT: + case SFP6_TXFAULT: + case SFP7_TXFAULT: + case SFP8_TXFAULT: + case SFP9_TXFAULT: + case SFP10_TXFAULT: + case SFP11_TXFAULT: + case SFP12_TXFAULT: + case SFP13_TXFAULT: + case SFP14_TXFAULT: + case SFP15_TXFAULT: + case SFP16_TXFAULT: + case SFP17_TXFAULT: + case SFP18_TXFAULT: + case SFP19_TXFAULT: + case SFP20_TXFAULT: + case SFP21_TXFAULT: + case SFP22_TXFAULT: + case SFP23_TXFAULT: + case SFP24_TXFAULT: + { + data = as5916_26xb_sfp_update_txfault(); + if (!data->ipmi_resp.sfp_valid[SFP_TXFAULT]) { + return -EIO; + } + + value = data->ipmi_resp.sfp_resp[SFP_TXFAULT][pid]; + break; + } + case SFP1_RXLOS: + case SFP2_RXLOS: + case SFP3_RXLOS: + case SFP4_RXLOS: + case SFP5_RXLOS: + case SFP6_RXLOS: + case SFP7_RXLOS: + case SFP8_RXLOS: + case SFP9_RXLOS: + case SFP10_RXLOS: + case SFP11_RXLOS: + case SFP12_RXLOS: + case SFP13_RXLOS: + case SFP14_RXLOS: + case SFP15_RXLOS: + case SFP16_RXLOS: + case SFP17_RXLOS: + case SFP18_RXLOS: + case SFP19_RXLOS: + case SFP20_RXLOS: + case SFP21_RXLOS: + case SFP22_RXLOS: + case SFP23_RXLOS: + case SFP24_RXLOS: + { + data = as5916_26xb_sfp_update_rxlos(); + if (!data->ipmi_resp.sfp_valid[SFP_RXLOS]) { + return -EIO; + } + + value = !data->ipmi_resp.sfp_resp[SFP_RXLOS][pid]; + break; + } + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t show_sfp_eeprom(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_SFP_ATTR; /* port id, 0 based */ + struct as5916_26xb_sfp_data *data = NULL; + + data = as5916_26xb_sfp_update_eeprom(pid + 1); + if (!data->ipmi_resp.eeprom_valid) { + return -EIO; + } + + memcpy(buf, data->ipmi_resp.eeprom, sizeof(data->ipmi_resp.eeprom)); + return sizeof(data->ipmi_resp.eeprom); +} + +static ssize_t set_sfp(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_SFP_ATTR; /* port id, 0 based */ + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + disable = !disable; /* the IPMI cmd is 0 for tx-disable and 1 for tx-enable */ + + /* Send IPMI write command */ + data->ipmi_tx_data[0] = pid + 1; /* FAN ID base id for ipmi start from 1 */ + data->ipmi_tx_data[1] = 0x01; + data->ipmi_tx_data[2] = disable; + status = ipmi_send_message(&data->ipmi, IPMI_SFP_WRITE_CMD, + data->ipmi_tx_data, sizeof(data->ipmi_tx_data), NULL, 0); + if (unlikely(status != 0)) { + return status; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + return -EIO; + } + + /* Update to ipmi_resp buffer to prevent from the impact of lazy update */ + data->ipmi_resp.sfp_resp[SFP_TXDISABLE][pid] = disable; + + return count; +} + +static ssize_t show_qsfp(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_QSFP_ATTR; /* port id, 0 based */ + struct as5916_26xb_sfp_data *data = NULL; + int value = 0; + + switch (attr->index) { + case QSFP25_PRESENT: + case QSFP26_PRESENT: + { + data = as5916_26xb_qsfp_update_present(); + if (!data->ipmi_resp.qsfp_valid[QSFP_PRESENT]) { + return -EIO; + } + + value = data->ipmi_resp.qsfp_resp[QSFP_PRESENT][pid]; + break; + } + case QSFP25_TXDISABLE: + case QSFP26_TXDISABLE: + { + data = as5916_26xb_qsfp_update_txdisable(); + if (!data->ipmi_resp.qsfp_valid[QSFP_TXDISABLE]) { + return -EIO; + } + + value = !!data->ipmi_resp.qsfp_resp[QSFP_TXDISABLE][pid]; + break; + } + case QSFP25_RESET: + case QSFP26_RESET: + { + data = as5916_26xb_qsfp_update_reset(); + if (!data->ipmi_resp.qsfp_valid[QSFP_RESET]) { + return -EIO; + } + + value = !data->ipmi_resp.qsfp_resp[QSFP_RESET][pid]; + break; + } + default: + return -EINVAL; + } + + return sprintf(buf, "%d\n", value); +} + +static ssize_t set_qsfp_txdisable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long disable; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_QSFP_ATTR; /* port id, 0 based */ + struct as5916_26xb_sfp_data *data = NULL; + + data = as5916_26xb_qsfp_update_present(); + if (!data->ipmi_resp.qsfp_valid[QSFP_PRESENT]) { + return -EIO; + } + + if (!data->ipmi_resp.qsfp_resp[QSFP_PRESENT][pid]) { + return -ENXIO; + } + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + /* Send IPMI write command */ + data->ipmi_tx_data[0] = pid + 1; /* FAN ID base id for ipmi start from 1 */ + data->ipmi_tx_data[1] = 0x01; + data->ipmi_tx_data[2] = disable ? 0xf : 0; + status = ipmi_send_message(&data->ipmi, IPMI_QSFP_WRITE_CMD, + data->ipmi_tx_data, sizeof(data->ipmi_tx_data), NULL, 0); + if (unlikely(status != 0)) { + return status; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + return -EIO; + } + + /* Update to ipmi_resp buffer to prevent from the impact of lazy update */ + data->ipmi_resp.qsfp_resp[QSFP_TXDISABLE][pid] = disable; + + return count; +} + +static ssize_t set_qsfp_reset(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + long reset; + int status; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_QSFP_ATTR; /* port id, 0 based */ + + status = kstrtol(buf, 10, &reset); + if (status) { + return status; + } + + reset = !reset; /* the IPMI cmd is 0 for reset and 1 for out of reset */ + + /* Send IPMI write command */ + data->ipmi_tx_data[0] = pid + 1; /* FAN ID base id for ipmi start from 1 */ + data->ipmi_tx_data[1] = 0x11; + data->ipmi_tx_data[2] = reset; + status = ipmi_send_message(&data->ipmi, IPMI_QSFP_WRITE_CMD, + data->ipmi_tx_data, sizeof(data->ipmi_tx_data), NULL, 0); + if (unlikely(status != 0)) { + return status; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + return -EIO; + } + + /* Update to ipmi_resp buffer to prevent from the impact of lazy update */ + data->ipmi_resp.qsfp_resp[QSFP_RESET][pid] = reset; + + return count; +} + +static ssize_t show_qsfp_eeprom(struct device *dev, struct device_attribute *da, char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + unsigned char pid = attr->index / NUM_OF_PER_QSFP_ATTR; /* port id, 0 based */ + struct as5916_26xb_sfp_data *data = NULL; + + data = as5916_26xb_sfp_update_eeprom(pid + 1 + NUM_OF_SFP); + if (!data->ipmi_resp.eeprom_valid) { + return -EIO; + } + + memcpy(buf, data->ipmi_resp.eeprom, sizeof(data->ipmi_resp.eeprom)); + return sizeof(data->ipmi_resp.eeprom); +} + +static int as5916_26xb_sfp_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_create_group(&pdev->dev.kobj, &as5916_26xb_sfp_group); + if (status) { + goto exit; + } + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_sfp_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &as5916_26xb_sfp_group); + return 0; +} + +static int __init as5916_26xb_sfp_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_sfp_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + + ret = platform_driver_register(&as5916_26xb_sfp_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_sfp_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_sfp_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_sfp_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB sfp driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_sfp_init); +module_exit(as5916_26xb_sfp_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sys.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sys.c new file mode 100644 index 00000000..e89c962f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-sys.c @@ -0,0 +1,368 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_sys" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_SYSEEPROM_READ_CMD 0x18 +#define IPMI_TIMEOUT (5 * HZ) +#define IPMI_READ_MAX_LEN 128 + +#define EEPROM_NAME "eeprom" +#define EEPROM_SIZE 256 /* 256 byte eeprom */ + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static int as5916_26xb_sys_probe(struct platform_device *pdev); +static int as5916_26xb_sys_remove(struct platform_device *pdev); + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +struct as5916_26xb_sys_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + unsigned char ipmi_resp[256]; + struct ipmi_data ipmi; + unsigned char ipmi_tx_data[2]; + struct bin_attribute eeprom; /* eeprom data */ +}; + +struct as5916_26xb_sys_data *data = NULL; + +static struct platform_driver as5916_26xb_sys_driver = { + .probe = as5916_26xb_sys_probe, + .remove = as5916_26xb_sys_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static ssize_t sys_eeprom_read(loff_t off, char *buf, size_t count) +{ + int status = 0; + + if ((off + count) > EEPROM_SIZE) { + return -EINVAL; + } + + data->ipmi_tx_data[0] = off; + data->ipmi_tx_data[1] = (count >= IPMI_READ_MAX_LEN) ? IPMI_READ_MAX_LEN : count; + data->ipmi.rx_msg_data = data->ipmi_resp + off; + data->ipmi.rx_msg_len = data->ipmi_tx_data[1]; + + status = ipmi_send_message(&data->ipmi, IPMI_SYSEEPROM_READ_CMD, data->ipmi_tx_data, sizeof(data->ipmi_tx_data), + data->ipmi_resp + off, data->ipmi_tx_data[1]); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + status = data->ipmi_tx_data[1]; + memcpy(buf, data->ipmi_resp + off, data->ipmi_tx_data[1]); + +exit: + return status; +} + +static ssize_t sysfs_bin_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *attr, + char *buf, loff_t off, size_t count) +{ + ssize_t retval = 0; + + if (unlikely(!count)) { + return count; + } + + /* + * Read data from chip, protecting against concurrent updates + * from this host + */ + mutex_lock(&data->update_lock); + + while (count) { + ssize_t status; + + status = sys_eeprom_read(off, buf, count); + if (status <= 0) { + if (retval == 0) { + retval = status; + } + break; + } + + buf += status; + off += status; + count -= status; + retval += status; + } + + mutex_unlock(&data->update_lock); + return retval; + +} + +static int sysfs_eeprom_init(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_bin_attr_init(eeprom); + eeprom->attr.name = EEPROM_NAME; + eeprom->attr.mode = S_IRUGO; + eeprom->read = sysfs_bin_read; + eeprom->write = NULL; + eeprom->size = EEPROM_SIZE; + + /* Create eeprom file */ + return sysfs_create_bin_file(kobj, eeprom); +} + +static int sysfs_eeprom_cleanup(struct kobject *kobj, struct bin_attribute *eeprom) +{ + sysfs_remove_bin_file(kobj, eeprom); + return 0; +} + +static int as5916_26xb_sys_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_eeprom_init(&pdev->dev.kobj, &data->eeprom); + if (status) { + goto exit; + } + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_sys_remove(struct platform_device *pdev) +{ + sysfs_eeprom_cleanup(&pdev->dev.kobj, &data->eeprom); + + return 0; +} + +static int __init as5916_26xb_sys_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_sys_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + data->valid = 0; + + ret = platform_driver_register(&as5916_26xb_sys_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_sys_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_sys_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_sys_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB System driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_sys_init); +module_exit(as5916_26xb_sys_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-thermal.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-thermal.c new file mode 100644 index 00000000..5557242f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/modules/builds/x86-64-accton-as5916-26xb-thermal.c @@ -0,0 +1,358 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54x CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_26xb_thermal" +#define ACCTON_IPMI_NETFN 0x34 +#define IPMI_THERMAL_READ_CMD 0x12 +#define IPMI_TIMEOUT (5 * HZ) + +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); +static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf); +static int as5916_26xb_thermal_probe(struct platform_device *pdev); +static int as5916_26xb_thermal_remove(struct platform_device *pdev); + +enum temp_data_index { + TEMP_ADDR, + TEMP_FAULT, + TEMP_INPUT, + TEMP_DATA_COUNT +}; + +struct ipmi_data { + struct completion read_complete; + struct ipmi_addr address; + ipmi_user_t user; + int interface; + + struct kernel_ipmi_msg tx_message; + long tx_msgid; + + void *rx_msg_data; + unsigned short rx_msg_len; + unsigned char rx_result; + int rx_recv_type; + + struct ipmi_user_hndl ipmi_hndlrs; +}; + +struct as5916_26xb_thermal_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + char ipmi_resp[18]; + struct ipmi_data ipmi; +}; + +struct as5916_26xb_thermal_data *data = NULL; + +static struct platform_driver as5916_26xb_thermal_driver = { + .probe = as5916_26xb_thermal_probe, + .remove = as5916_26xb_thermal_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +enum as5916_54x_thermal_sysfs_attrs { + TEMP1_INPUT, + TEMP2_INPUT, + TEMP3_INPUT, + TEMP4_INPUT, + TEMP5_INPUT, + TEMP6_INPUT +}; + +static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, TEMP1_INPUT); +static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, TEMP2_INPUT); +static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, TEMP3_INPUT); +static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, TEMP4_INPUT); +static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, TEMP5_INPUT); +static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, TEMP6_INPUT); + +static struct attribute *as5916_26xb_thermal_attributes[] = { + &sensor_dev_attr_temp1_input.dev_attr.attr, + &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp3_input.dev_attr.attr, + &sensor_dev_attr_temp4_input.dev_attr.attr, + &sensor_dev_attr_temp5_input.dev_attr.attr, + &sensor_dev_attr_temp6_input.dev_attr.attr, + NULL +}; + +static const struct attribute_group as5916_26xb_thermal_group = { + .attrs = as5916_26xb_thermal_attributes, +}; + +/* Functions to talk to the IPMI layer */ + +/* Initialize IPMI address, message buffers and user data */ +static int init_ipmi_data(struct ipmi_data *ipmi, int iface, + struct device *dev) +{ + int err; + + init_completion(&ipmi->read_complete); + + /* Initialize IPMI address */ + ipmi->address.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; + ipmi->address.channel = IPMI_BMC_CHANNEL; + ipmi->address.data[0] = 0; + ipmi->interface = iface; + + /* Initialize message buffers */ + ipmi->tx_msgid = 0; + ipmi->tx_message.netfn = ACCTON_IPMI_NETFN; + + ipmi->ipmi_hndlrs.ipmi_recv_hndl = ipmi_msg_handler; + + /* Create IPMI messaging interface user */ + err = ipmi_create_user(ipmi->interface, &ipmi->ipmi_hndlrs, + ipmi, &ipmi->user); + if (err < 0) { + dev_err(dev, "Unable to register user with IPMI " + "interface %d\n", ipmi->interface); + return -EACCES; + } + + return 0; +} + +/* Send an IPMI command */ +static int ipmi_send_message(struct ipmi_data *ipmi, unsigned char cmd, + unsigned char *tx_data, unsigned short tx_len, + unsigned char *rx_data, unsigned short rx_len) +{ + int err; + + ipmi->tx_message.cmd = cmd; + ipmi->tx_message.data = tx_data; + ipmi->tx_message.data_len = tx_len; + ipmi->rx_msg_data = rx_data; + ipmi->rx_msg_len = rx_len; + + err = ipmi_validate_addr(&ipmi->address, sizeof(ipmi->address)); + if (err) + goto addr_err; + + ipmi->tx_msgid++; + err = ipmi_request_settime(ipmi->user, &ipmi->address, ipmi->tx_msgid, + &ipmi->tx_message, ipmi, 0, 0, 0); + if (err) + goto ipmi_req_err; + + err = wait_for_completion_timeout(&ipmi->read_complete, IPMI_TIMEOUT); + if (!err) + goto ipmi_timeout_err; + + return 0; + +ipmi_timeout_err: + err = -ETIMEDOUT; + dev_err(&data->pdev->dev, "request_timeout=%x\n", err); + return err; +ipmi_req_err: + dev_err(&data->pdev->dev, "request_settime=%x\n", err); + return err; +addr_err: + dev_err(&data->pdev->dev, "validate_addr=%x\n", err); + return err; +} + +/* Dispatch IPMI messages to callers */ +static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) +{ + unsigned short rx_len; + struct ipmi_data *ipmi = user_msg_data; + + if (msg->msgid != ipmi->tx_msgid) { + dev_err(&data->pdev->dev, "Mismatch between received msgid " + "(%02x) and transmitted msgid (%02x)!\n", + (int)msg->msgid, + (int)ipmi->tx_msgid); + ipmi_free_recv_msg(msg); + return; + } + + ipmi->rx_recv_type = msg->recv_type; + if (msg->msg.data_len > 0) + ipmi->rx_result = msg->msg.data[0]; + else + ipmi->rx_result = IPMI_UNKNOWN_ERR_COMPLETION_CODE; + + if (msg->msg.data_len > 1) { + rx_len = msg->msg.data_len - 1; + if (ipmi->rx_msg_len < rx_len) + rx_len = ipmi->rx_msg_len; + ipmi->rx_msg_len = rx_len; + memcpy(ipmi->rx_msg_data, msg->msg.data + 1, ipmi->rx_msg_len); + } else + ipmi->rx_msg_len = 0; + + ipmi_free_recv_msg(msg); + complete(&ipmi->read_complete); +} + +static ssize_t show_temp(struct device *dev, struct device_attribute *da, char *buf) +{ + int status = 0; + int index = 0; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ * 5) || !data->valid) { + data->valid = 0; + + status = ipmi_send_message(&data->ipmi, IPMI_THERMAL_READ_CMD, NULL, 0, + data->ipmi_resp, sizeof(data->ipmi_resp)); + if (unlikely(status != 0)) { + goto exit; + } + + if (unlikely(data->ipmi.rx_result != 0)) { + status = -EIO; + goto exit; + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + /* Get temp fault status */ + index = attr->index * TEMP_DATA_COUNT + TEMP_FAULT; + if (unlikely(data->ipmi_resp[index] == 0)) { + status = -EIO; + goto exit; + } + + /* Get temperature in degree celsius */ + index = attr->index * TEMP_DATA_COUNT + TEMP_INPUT; + status = data->ipmi_resp[index] * 1000; + + return sprintf(buf, "%d\n", status); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static int as5916_26xb_thermal_probe(struct platform_device *pdev) +{ + int status = -1; + + /* Register sysfs hooks */ + status = sysfs_create_group(&pdev->dev.kobj, &as5916_26xb_thermal_group); + if (status) { + goto exit; + } + + dev_info(&pdev->dev, "device created\n"); + + return 0; + +exit: + return status; +} + +static int as5916_26xb_thermal_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &as5916_26xb_thermal_group); + + return 0; +} + +static int __init as5916_26xb_thermal_init(void) +{ + int ret; + + data = kzalloc(sizeof(struct as5916_26xb_thermal_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto alloc_err; + } + + mutex_init(&data->update_lock); + data->valid = 0; + + ret = platform_driver_register(&as5916_26xb_thermal_driver); + if (ret < 0) { + goto dri_reg_err; + } + + data->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(data->pdev)) { + ret = PTR_ERR(data->pdev); + goto dev_reg_err; + } + + /* Set up IPMI interface */ + ret = init_ipmi_data(&data->ipmi, 0, &data->pdev->dev); + if (ret) + goto ipmi_err; + + return 0; + +ipmi_err: + platform_device_unregister(data->pdev); +dev_reg_err: + platform_driver_unregister(&as5916_26xb_thermal_driver); +dri_reg_err: + kfree(data); +alloc_err: + return ret; +} + +static void __exit as5916_26xb_thermal_exit(void) +{ + ipmi_destroy_user(data->ipmi.user); + platform_device_unregister(data->pdev); + platform_driver_unregister(&as5916_26xb_thermal_driver); + kfree(data); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("AS5916 26XB Thermal driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_26xb_thermal_init); +module_exit(as5916_26xb_thermal_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/PKG.yml new file mode 100644 index 00000000..b96bf432 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-accton-as5916-26xb ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/lib/Makefile new file mode 100644 index 00000000..32b55bb7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# 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/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as5916-26xb +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as5916_26xb onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as5916-26xb.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..40aae7b3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# 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/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as5916_26xb onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.module new file mode 100644 index 00000000..588f0566 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as5916_26xb diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/Makefile new file mode 100644 index 00000000..ac46bc42 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_accton_as5916_26xb +AUTOMODULE := x86_64_accton_as5916_26xb +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/README new file mode 100644 index 00000000..0ad083e7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as5916_26xb README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/x86_64_accton_as5916_26xb.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/x86_64_accton_as5916_26xb.yml new file mode 100644 index 00000000..0896dd45 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/x86_64_accton_as5916_26xb.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as5916_26xb Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS5916_26xb_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as5916_26xb_config + + portingmacro: + x86_64_accton_as5916_26xb: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb.x b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb.x new file mode 100644 index 00000000..42078eff --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_config.h new file mode 100644 index 00000000..1dfcfbdb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_26xb Configuration Header + * + * @addtogroup x86_64_accton_as5916_26xb-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_26XB_CONFIG_H__ +#define __X86_64_ACCTON_AS5916_26XB_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as5916_26xb_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as5916_26xb_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as5916_26xb_config_settings table. */ +extern x86_64_accton_as5916_26xb_config_settings_t x86_64_accton_as5916_26xb_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as5916_26xb_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as5916_26xb_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as5916_26xb_porting.h" + +#endif /* __X86_64_ACCTON_AS5916_26XB_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_dox.h new file mode 100644 index 00000000..1c8901e0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_26xb Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_26XB_DOX_H__ +#define __X86_64_ACCTON_AS5916_26XB_DOX_H__ + +/** + * @defgroup x86_64_accton_as5916_26xb x86_64_accton_as5916_26xb - x86_64_accton_as5916_26xb Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as5916_26xb-x86_64_accton_as5916_26xb Public Interface + * @defgroup x86_64_accton_as5916_26xb-config Compile Time Configuration + * @defgroup x86_64_accton_as5916_26xb-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS5916_26XB_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_porting.h new file mode 100644 index 00000000..ba711cd1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/inc/x86_64_accton_as5916_26xb/x86_64_accton_as5916_26xb_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_26xb Porting Macros. + * + * @addtogroup x86_64_accton_as5916_26xb-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_26XB_PORTING_H__ +#define __X86_64_ACCTON_AS5916_26XB_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_AS5916_26XB_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_MALLOC malloc + #else + #error The macro X86_64_ACCTON_AS5916_26XB_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_AS5916_26XB_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_FREE free + #else + #error The macro X86_64_ACCTON_AS5916_26XB_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_AS5916_26XB_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_MEMSET memset + #else + #error The macro X86_64_ACCTON_AS5916_26XB_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_AS5916_26XB_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_AS5916_26XB_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_AS5916_26XB_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_AS5916_26XB_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_AS5916_26XB_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_AS5916_26XB_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_AS5916_26XB_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_AS5916_26XB_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_26XB_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_AS5916_26XB_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_26XB_STRLEN strlen + #else + #error The macro X86_64_ACCTON_AS5916_26XB_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS5916_26XB_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..a7e74bb5 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as5916_26xb_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..bcd6b60e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/fani.c @@ -0,0 +1,232 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + PSU_FAN_INFO(1, 1), + PSU_FAN_INFO(2, 1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; /* fan is not present */ + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + + /* get fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_input", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + info->percentage = (info->rpm * 100)/MAX_FAN_SPEED; + + + /* get fan fault status + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int value, ret; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= ONLP_FAN_STATUS_F2B; + + /* get fan speed + */ + ret = onlp_file_read_int(&value, "%s""psu%d_fan1_input", PSU_SYSFS_PATH, pid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", PSU_SYSFS_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->rpm = value; + info->percentage = (info->rpm * 100)/MAX_PSU_FAN_SPEED; + + /* get fan fault status + */ + if (!info->rpm) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + if (fid < FAN_1_ON_FAN_BOARD || fid > FAN_5_ON_FAN_BOARD) { + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, "%s""fan%d_pwm", FAN_BOARD_PATH, fid) < 0) { + AIM_LOG_ERROR("Unable to write data to file %s""fan%d_pwm", FAN_BOARD_PATH, fid); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/ledi.c new file mode 100644 index 00000000..e3480a6d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,248 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#define LED_FORMAT "/sys/devices/platform/as5916_26xb_led/%s" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_LOC, + LED_DIAG, + LED_PSU1, + LED_PSU2, + LED_FAN, +}; + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_ORANGE_BLINKING, ONLP_LED_MODE_ORANGE_BLINKING}, +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_GREEN_BLINKING, ONLP_LED_MODE_GREEN_BLINKING}, +{LED_DIAG, LED_MODE_ORANGE, ONLP_LED_MODE_ORANGE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char *leds[] = /* must map with onlp_led_id */ +{ + NULL, + "led_loc", + "led_diag", + "led_psu1", + "led_psu2", + "led_fan" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 1 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 2 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 3 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 5 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Turn off the LOCATION and DIAG LEDs at startup + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Get LED mode */ + if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) { + DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid; + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/platform_lib.h new file mode 100644 index 00000000..f6144470 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,70 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_as5916_26xb_log.h" + +#define CHASSIS_FAN_COUNT 5 +#define CHASSIS_THERMAL_COUNT 7 +#define CHASSIS_LED_COUNT 5 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU_SYSFS_PATH "/sys/devices/platform/as5916_26xb_psu/" + +#define FAN_BOARD_PATH "/sys/devices/platform/as5916_26xb_fan/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/devices/platform/as5916_26xb_sys/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_5_ON_MAIN_BROAD, + THERMAL_6_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..156f9bdb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/psui.c @@ -0,0 +1,154 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int val = 0; + int ret = ONLP_STATUS_OK; + int pid = ONLP_OID_ID_GET(id); + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[pid]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + ret = onlp_file_read_int(&val, "%s""psu%d_present", PSU_SYSFS_PATH, pid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s""psu%d_present)\r\n", PSU_SYSFS_PATH, pid); + return ONLP_STATUS_E_INTERNAL; + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + ret = onlp_file_read_int(&val, "%s""psu%d_power_good", PSU_SYSFS_PATH, pid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s""psu%d_power_good)\r\n", PSU_SYSFS_PATH, pid); + return ONLP_STATUS_E_INTERNAL; + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Read voltage, current and power */ + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_vin", PSU_SYSFS_PATH, pid) == 0 && val) { + info->mvin = val; + info->caps |= ONLP_PSU_CAPS_VIN; + } + + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_vout", PSU_SYSFS_PATH, pid) == 0 && val) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_iout", PSU_SYSFS_PATH, pid) == 0 && val) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_pout", PSU_SYSFS_PATH, pid) == 0 && val) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + /* Set the associated oid_table */ + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_fan1_input", PSU_SYSFS_PATH, pid) == 0 && val) { + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(pid + CHASSIS_FAN_COUNT); + } + + val = 0; + if (onlp_file_read_int(&val, "%s""psu%d_temp1_input", PSU_SYSFS_PATH, pid) == 0 && val) { + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(pid + CHASSIS_THERMAL_COUNT); + } + + /* Read model */ + char *string = NULL; + int len = onlp_file_read_str(&string, "%s""psu%d_model", PSU_SYSFS_PATH, pid); + if (string && len) { + strncpy(info->model, string, len); + aim_free(string); + } + + /* Read serial */ + len = onlp_file_read_str(&string, "%s""psu%d_serial", PSU_SYSFS_PATH, pid); + if (string && len) { + strncpy(info->serial, string, len); + aim_free(string); + } + + return ret; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sfpi.c new file mode 100644 index 00000000..29a02a12 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,287 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * 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 "x86_64_accton_as5916_26xb_int.h" +#include "x86_64_accton_as5916_26xb_log.h" + +#define PORT_EEPROM_FORMAT "/sys/devices/platform/as5916_26xb_sfp/module_eeprom_%d" +#define MODULE_PRESENT_FORMAT "/sys/devices/platform/as5916_26xb_sfp/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/devices/platform/as5916_26xb_sfp/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/devices/platform/as5916_26xb_sfp/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/devices/platform/as5916_26xb_sfp/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/devices/platform/as5916_26xb_sfp/module_present_all" +#define MODULE_RXLOS_ALL_ATTR "/sys/devices/platform/as5916_26xb_sfp/module_rxlos_all" + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 54} + */ + int p; + + for(p = 0; p < 26; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[4]; + FILE* fp; + + /* Read present status of port 0~25 */ + int count = 0; + + fp = fopen(MODULE_PRESENT_ALL_ATTR, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file from (%s).", MODULE_PRESENT_ALL_ATTR); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x %x", bytes+0, bytes+1, bytes+2, bytes+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file from(%s).", MODULE_PRESENT_ALL_ATTR); + return ONLP_STATUS_E_INTERNAL; + } + + /* Mask out non-existant QSFP ports */ + bytes[3] &= 0x3; + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[3]; + FILE* fp; + + /* Read present status of port 0~25 */ + int count = 0; + + fp = fopen(MODULE_RXLOS_ALL_ATTR, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rxlos_all device file from (%s).", MODULE_RXLOS_ALL_ATTR); + return ONLP_STATUS_E_INTERNAL; + } + + count = fscanf(fp, "%x %x %x", bytes+0, bytes+1, bytes+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_rxlos_all device file from(%s).", MODULE_RXLOS_ALL_ATTR); + return ONLP_STATUS_E_INTERNAL; + } + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t rx_los_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, (port+1)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + + if (port < 0) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if (port >= 24) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if (port >= 24) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sysi.c new file mode 100644 index 00000000..d8c9f10d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,103 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#include "x86_64_accton_as5916_26xb_int.h" +#include "x86_64_accton_as5916_26xb_log.h" + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as5916-26xb-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ + aim_free(pi->cpld_versions); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..35afa1aa --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,138 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "/sys/devices/platform/as5916_26xb_thermal/temp1_input", + "/sys/devices/platform/as5916_26xb_thermal/temp2_input", + "/sys/devices/platform/as5916_26xb_thermal/temp3_input", + "/sys/devices/platform/as5916_26xb_thermal/temp4_input", + "/sys/devices/platform/as5916_26xb_thermal/temp5_input", + "/sys/devices/platform/as5916_26xb_thermal/temp6_input", + "/sys/devices/platform/as5916_26xb_psu/psu1_temp1_input", + "/sys/devices/platform/as5916_26xb_psu/psu2_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-4", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_5_ON_MAIN_BROAD), "LM75-5", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_6_ON_MAIN_BROAD), "LM75-6", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[tid]); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_config.c new file mode 100644 index 00000000..e5cadc0a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(_x) +x86_64_accton_as5916_26xb_config_settings_t x86_64_accton_as5916_26xb_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS5916_26XB_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_26xb_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as5916_26xb_config_STRINGIFY_VALUE +#undef __x86_64_accton_as5916_26xb_config_STRINGIFY_NAME + +const char* +x86_64_accton_as5916_26xb_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as5916_26xb_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_as5916_26xb_config_settings[i].name, setting)) { + return x86_64_accton_as5916_26xb_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as5916_26xb_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as5916_26xb_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as5916_26xb_config_settings[i].name, x86_64_accton_as5916_26xb_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_enums.c new file mode 100644 index 00000000..9d03c510 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_int.h new file mode 100644 index 00000000..639fe6ea --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_26xb Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_26xb_INT_H__ +#define __x86_64_accton_as5916_26xb_INT_H__ + +#include + + +#endif /* __x86_64_accton_as5916_26xb_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.c new file mode 100644 index 00000000..b2de8434 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_26xb_log.h" +/* + * x86_64_accton_as5916_26xb log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS5916_26XB_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.h new file mode 100644 index 00000000..6ba6a5a3 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_26xb_LOG_H__ +#define __x86_64_accton_as5916_26xb_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as5916_26xb +#include + +#endif /* __x86_64_accton_as5916_26xb_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_module.c new file mode 100644 index 00000000..6c69173d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_26xb_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as5916_26xb_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as5916_26xb_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_ucli.c new file mode 100644 index 00000000..d627a0dc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/x86_64_accton_as5916_26xb_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as5916_26xb_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as5916_26xb_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as5916_26xb) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as5916_26xb_ucli_module__ = + { + "x86_64_accton_as5916_26xb_ucli", + NULL, + x86_64_accton_as5916_26xb_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as5916_26xb_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as5916_26xb_ucli_module__); + n = ucli_node_create("x86_64_accton_as5916_26xb", NULL, &x86_64_accton_as5916_26xb_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as5916_26xb")); + return n; +} + +#else +void* +x86_64_accton_as5916_26xb_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/PKG.yml new file mode 100644 index 00000000..bcd1c338 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as5916-26xb REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/lib/x86-64-accton-as5916-26xb-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/lib/x86-64-accton-as5916-26xb-r0.yml new file mode 100644 index 00000000..bcd34404 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/lib/x86-64-accton-as5916-26xb-r0.yml @@ -0,0 +1,33 @@ +--- + +###################################################################### +# +# platform-config for AS5916 +# +###################################################################### + +x86-64-accton-as5916-26xb-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-4-14 + + args: >- + nopat + console=ttyS0,115200n8 + tg3.short_preamble=1 + tg3.bcm5718s_reset=1 + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/python/x86_64_accton_as5916_26xb_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/python/x86_64_accton_as5916_26xb_r0/__init__.py new file mode 100644 index 00000000..b7f0fec0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/platform-config/r0/src/python/x86_64_accton_as5916_26xb_r0/__init__.py @@ -0,0 +1,13 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as5916_26xb_r0(OnlPlatformAccton, + OnlPlatformPortConfig_24x10_2x100): + PLATFORM='x86-64-accton-as5916-26xb-r0' + MODEL="AS5916-26XB" + SYS_OBJECT_ID=".5916.26" + + def baseconfig(self): + self.insmod_platform() + return True + From 4d76fd299c92279a484778d373e1a737445e2a84 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Thu, 14 Jun 2018 15:58:05 +0800 Subject: [PATCH 02/32] Add support as5916-54xks platform --- .../x86-64-accton-as5916-54xks/.gitignore | 2 + .../x86-64-accton-as5916-54xks/Makefile | 1 + .../modules/Makefile | 1 + .../modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-accton-as5916-54xks-cpld.c | 1098 +++++++++++++++++ .../builds/x86-64-accton-as5916-54xks-fan.c | 485 ++++++++ .../builds/x86-64-accton-as5916-54xks-leds.c | 386 ++++++ .../builds/x86-64-accton-as5916-54xks-psu.c | 288 +++++ .../x86-64-accton-as5916-54xks/onlp/Makefile | 1 + .../x86-64-accton-as5916-54xks/onlp/PKG.yml | 1 + .../onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 + .../onlp/builds/onlpdump/Makefile | 46 + .../onlp/builds/src/.gitignore | 1 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../auto/x86_64_accton_as5916_54xks.yml | 50 + .../x86_64_accton_as5916_54xks.x | 14 + .../x86_64_accton_as5916_54xks_config.h | 137 ++ .../x86_64_accton_as5916_54xks_dox.h | 26 + .../x86_64_accton_as5916_54xks_porting.h | 107 ++ .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/fani.c | 303 +++++ .../onlp/builds/src/module/src/ledi.c | 247 ++++ .../onlp/builds/src/module/src/platform_lib.c | 124 ++ .../onlp/builds/src/module/src/platform_lib.h | 89 ++ .../onlp/builds/src/module/src/psui.c | 177 +++ .../onlp/builds/src/module/src/sfpi.c | 357 ++++++ .../onlp/builds/src/module/src/sysi.c | 339 +++++ .../onlp/builds/src/module/src/thermali.c | 128 ++ .../src/x86_64_accton_as5916_54xks_config.c | 80 ++ .../src/x86_64_accton_as5916_54xks_enums.c | 10 + .../src/x86_64_accton_as5916_54xks_int.h | 12 + .../src/x86_64_accton_as5916_54xks_log.c | 18 + .../src/x86_64_accton_as5916_54xks_log.h | 12 + .../src/x86_64_accton_as5916_54xks_module.c | 24 + .../src/x86_64_accton_as5916_54xks_ucli.c | 50 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../src/lib/x86-64-accton-as5916-54xks-r0.yml | 33 + .../x86_64_accton_as5916_54xks_r0/__init__.py | 74 ++ 45 files changed, 4804 insertions(+) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/.gitignore create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-cpld.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-fan.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-leds.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-psu.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/PKG.yml create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/lib/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.module create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/README create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/auto/x86_64_accton_as5916_54xks.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks.x create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_config.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_dox.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_porting.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.h create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_config.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_enums.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_int.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.h create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_module.c create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_ucli.c create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/Makefile create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/Makefile create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/PKG.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/lib/x86-64-accton-as5916-54xks-r0.yml create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/.gitignore new file mode 100644 index 00000000..5ddbe407 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/.gitignore @@ -0,0 +1,2 @@ +*x86*64*accton*as5916*54xks*.mk +onlpdump.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/PKG.yml new file mode 100755 index 00000000..e1525f63 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-as5916-54xks ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/Makefile new file mode 100755 index 00000000..7d3561ab --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := accton +BASENAME := x86-64-accton-as5916-54xks +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-cpld.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-cpld.c new file mode 100755 index 00000000..fd0c548e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-cpld.c @@ -0,0 +1,1098 @@ +/* + * Copyright (C) Brandon Chuang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as5916_54xks CPLD1/CPLD2 + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ + +static LIST_HEAD(cpld_client_list); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as5916_54xks_cpld1, + as5916_54xks_cpld2 +}; + +struct as5916_54xks_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; +}; + +static const struct i2c_device_id as5916_54xks_cpld_id[] = { + { "as5916_54xks_cpld1", as5916_54xks_cpld1 }, + { "as5916_54xks_cpld2", as5916_54xks_cpld2 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, as5916_54xks_cpld_id); + +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index + +enum as5916_54xks_cpld1_sysfs_attributes { + CPLD_VERSION, + ACCESS, + MODULE_PRESENT_ALL, + MODULE_RXLOS_ALL, + /* transceiver attributes */ + TRANSCEIVER_PRESENT_ATTR_ID(1), + TRANSCEIVER_PRESENT_ATTR_ID(2), + TRANSCEIVER_PRESENT_ATTR_ID(3), + TRANSCEIVER_PRESENT_ATTR_ID(4), + TRANSCEIVER_PRESENT_ATTR_ID(5), + TRANSCEIVER_PRESENT_ATTR_ID(6), + TRANSCEIVER_PRESENT_ATTR_ID(7), + TRANSCEIVER_PRESENT_ATTR_ID(8), + TRANSCEIVER_PRESENT_ATTR_ID(9), + TRANSCEIVER_PRESENT_ATTR_ID(10), + TRANSCEIVER_PRESENT_ATTR_ID(11), + TRANSCEIVER_PRESENT_ATTR_ID(12), + TRANSCEIVER_PRESENT_ATTR_ID(13), + TRANSCEIVER_PRESENT_ATTR_ID(14), + TRANSCEIVER_PRESENT_ATTR_ID(15), + TRANSCEIVER_PRESENT_ATTR_ID(16), + TRANSCEIVER_PRESENT_ATTR_ID(17), + TRANSCEIVER_PRESENT_ATTR_ID(18), + TRANSCEIVER_PRESENT_ATTR_ID(19), + TRANSCEIVER_PRESENT_ATTR_ID(20), + TRANSCEIVER_PRESENT_ATTR_ID(21), + TRANSCEIVER_PRESENT_ATTR_ID(22), + TRANSCEIVER_PRESENT_ATTR_ID(23), + TRANSCEIVER_PRESENT_ATTR_ID(24), + TRANSCEIVER_PRESENT_ATTR_ID(25), + TRANSCEIVER_PRESENT_ATTR_ID(26), + TRANSCEIVER_PRESENT_ATTR_ID(27), + TRANSCEIVER_PRESENT_ATTR_ID(28), + TRANSCEIVER_PRESENT_ATTR_ID(29), + TRANSCEIVER_PRESENT_ATTR_ID(30), + TRANSCEIVER_PRESENT_ATTR_ID(31), + TRANSCEIVER_PRESENT_ATTR_ID(32), + TRANSCEIVER_PRESENT_ATTR_ID(33), + TRANSCEIVER_PRESENT_ATTR_ID(34), + TRANSCEIVER_PRESENT_ATTR_ID(35), + TRANSCEIVER_PRESENT_ATTR_ID(36), + TRANSCEIVER_PRESENT_ATTR_ID(37), + TRANSCEIVER_PRESENT_ATTR_ID(38), + TRANSCEIVER_PRESENT_ATTR_ID(39), + TRANSCEIVER_PRESENT_ATTR_ID(40), + TRANSCEIVER_PRESENT_ATTR_ID(41), + TRANSCEIVER_PRESENT_ATTR_ID(42), + TRANSCEIVER_PRESENT_ATTR_ID(43), + TRANSCEIVER_PRESENT_ATTR_ID(44), + TRANSCEIVER_PRESENT_ATTR_ID(45), + TRANSCEIVER_PRESENT_ATTR_ID(46), + TRANSCEIVER_PRESENT_ATTR_ID(47), + TRANSCEIVER_PRESENT_ATTR_ID(48), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(1), + TRANSCEIVER_TXDISABLE_ATTR_ID(2), + TRANSCEIVER_TXDISABLE_ATTR_ID(3), + TRANSCEIVER_TXDISABLE_ATTR_ID(4), + TRANSCEIVER_TXDISABLE_ATTR_ID(5), + TRANSCEIVER_TXDISABLE_ATTR_ID(6), + TRANSCEIVER_TXDISABLE_ATTR_ID(7), + TRANSCEIVER_TXDISABLE_ATTR_ID(8), + TRANSCEIVER_TXDISABLE_ATTR_ID(9), + TRANSCEIVER_TXDISABLE_ATTR_ID(10), + TRANSCEIVER_TXDISABLE_ATTR_ID(11), + TRANSCEIVER_TXDISABLE_ATTR_ID(12), + TRANSCEIVER_TXDISABLE_ATTR_ID(13), + TRANSCEIVER_TXDISABLE_ATTR_ID(14), + TRANSCEIVER_TXDISABLE_ATTR_ID(15), + TRANSCEIVER_TXDISABLE_ATTR_ID(16), + TRANSCEIVER_TXDISABLE_ATTR_ID(17), + TRANSCEIVER_TXDISABLE_ATTR_ID(18), + TRANSCEIVER_TXDISABLE_ATTR_ID(19), + TRANSCEIVER_TXDISABLE_ATTR_ID(20), + TRANSCEIVER_TXDISABLE_ATTR_ID(21), + TRANSCEIVER_TXDISABLE_ATTR_ID(22), + TRANSCEIVER_TXDISABLE_ATTR_ID(23), + TRANSCEIVER_TXDISABLE_ATTR_ID(24), + TRANSCEIVER_TXDISABLE_ATTR_ID(25), + TRANSCEIVER_TXDISABLE_ATTR_ID(26), + TRANSCEIVER_TXDISABLE_ATTR_ID(27), + TRANSCEIVER_TXDISABLE_ATTR_ID(28), + TRANSCEIVER_TXDISABLE_ATTR_ID(29), + TRANSCEIVER_TXDISABLE_ATTR_ID(30), + TRANSCEIVER_TXDISABLE_ATTR_ID(31), + TRANSCEIVER_TXDISABLE_ATTR_ID(32), + TRANSCEIVER_TXDISABLE_ATTR_ID(33), + TRANSCEIVER_TXDISABLE_ATTR_ID(34), + TRANSCEIVER_TXDISABLE_ATTR_ID(35), + TRANSCEIVER_TXDISABLE_ATTR_ID(36), + TRANSCEIVER_TXDISABLE_ATTR_ID(37), + TRANSCEIVER_TXDISABLE_ATTR_ID(38), + TRANSCEIVER_TXDISABLE_ATTR_ID(39), + TRANSCEIVER_TXDISABLE_ATTR_ID(40), + TRANSCEIVER_TXDISABLE_ATTR_ID(41), + TRANSCEIVER_TXDISABLE_ATTR_ID(42), + TRANSCEIVER_TXDISABLE_ATTR_ID(43), + TRANSCEIVER_TXDISABLE_ATTR_ID(44), + TRANSCEIVER_TXDISABLE_ATTR_ID(45), + TRANSCEIVER_TXDISABLE_ATTR_ID(46), + TRANSCEIVER_TXDISABLE_ATTR_ID(47), + TRANSCEIVER_TXDISABLE_ATTR_ID(48), + TRANSCEIVER_RXLOS_ATTR_ID(1), + TRANSCEIVER_RXLOS_ATTR_ID(2), + TRANSCEIVER_RXLOS_ATTR_ID(3), + TRANSCEIVER_RXLOS_ATTR_ID(4), + TRANSCEIVER_RXLOS_ATTR_ID(5), + TRANSCEIVER_RXLOS_ATTR_ID(6), + TRANSCEIVER_RXLOS_ATTR_ID(7), + TRANSCEIVER_RXLOS_ATTR_ID(8), + TRANSCEIVER_RXLOS_ATTR_ID(9), + TRANSCEIVER_RXLOS_ATTR_ID(10), + TRANSCEIVER_RXLOS_ATTR_ID(11), + TRANSCEIVER_RXLOS_ATTR_ID(12), + TRANSCEIVER_RXLOS_ATTR_ID(13), + TRANSCEIVER_RXLOS_ATTR_ID(14), + TRANSCEIVER_RXLOS_ATTR_ID(15), + TRANSCEIVER_RXLOS_ATTR_ID(16), + TRANSCEIVER_RXLOS_ATTR_ID(17), + TRANSCEIVER_RXLOS_ATTR_ID(18), + TRANSCEIVER_RXLOS_ATTR_ID(19), + TRANSCEIVER_RXLOS_ATTR_ID(20), + TRANSCEIVER_RXLOS_ATTR_ID(21), + TRANSCEIVER_RXLOS_ATTR_ID(22), + TRANSCEIVER_RXLOS_ATTR_ID(23), + TRANSCEIVER_RXLOS_ATTR_ID(24), + TRANSCEIVER_RXLOS_ATTR_ID(25), + TRANSCEIVER_RXLOS_ATTR_ID(26), + TRANSCEIVER_RXLOS_ATTR_ID(27), + TRANSCEIVER_RXLOS_ATTR_ID(28), + TRANSCEIVER_RXLOS_ATTR_ID(29), + TRANSCEIVER_RXLOS_ATTR_ID(30), + TRANSCEIVER_RXLOS_ATTR_ID(31), + TRANSCEIVER_RXLOS_ATTR_ID(32), + TRANSCEIVER_RXLOS_ATTR_ID(33), + TRANSCEIVER_RXLOS_ATTR_ID(34), + TRANSCEIVER_RXLOS_ATTR_ID(35), + TRANSCEIVER_RXLOS_ATTR_ID(36), + TRANSCEIVER_RXLOS_ATTR_ID(37), + TRANSCEIVER_RXLOS_ATTR_ID(38), + TRANSCEIVER_RXLOS_ATTR_ID(39), + TRANSCEIVER_RXLOS_ATTR_ID(40), + TRANSCEIVER_RXLOS_ATTR_ID(41), + TRANSCEIVER_RXLOS_ATTR_ID(42), + TRANSCEIVER_RXLOS_ATTR_ID(43), + TRANSCEIVER_RXLOS_ATTR_ID(44), + TRANSCEIVER_RXLOS_ATTR_ID(45), + TRANSCEIVER_RXLOS_ATTR_ID(46), + TRANSCEIVER_RXLOS_ATTR_ID(47), + TRANSCEIVER_RXLOS_ATTR_ID(48), + TRANSCEIVER_TXFAULT_ATTR_ID(1), + TRANSCEIVER_TXFAULT_ATTR_ID(2), + TRANSCEIVER_TXFAULT_ATTR_ID(3), + TRANSCEIVER_TXFAULT_ATTR_ID(4), + TRANSCEIVER_TXFAULT_ATTR_ID(5), + TRANSCEIVER_TXFAULT_ATTR_ID(6), + TRANSCEIVER_TXFAULT_ATTR_ID(7), + TRANSCEIVER_TXFAULT_ATTR_ID(8), + TRANSCEIVER_TXFAULT_ATTR_ID(9), + TRANSCEIVER_TXFAULT_ATTR_ID(10), + TRANSCEIVER_TXFAULT_ATTR_ID(11), + TRANSCEIVER_TXFAULT_ATTR_ID(12), + TRANSCEIVER_TXFAULT_ATTR_ID(13), + TRANSCEIVER_TXFAULT_ATTR_ID(14), + TRANSCEIVER_TXFAULT_ATTR_ID(15), + TRANSCEIVER_TXFAULT_ATTR_ID(16), + TRANSCEIVER_TXFAULT_ATTR_ID(17), + TRANSCEIVER_TXFAULT_ATTR_ID(18), + TRANSCEIVER_TXFAULT_ATTR_ID(19), + TRANSCEIVER_TXFAULT_ATTR_ID(20), + TRANSCEIVER_TXFAULT_ATTR_ID(21), + TRANSCEIVER_TXFAULT_ATTR_ID(22), + TRANSCEIVER_TXFAULT_ATTR_ID(23), + TRANSCEIVER_TXFAULT_ATTR_ID(24), + TRANSCEIVER_TXFAULT_ATTR_ID(25), + TRANSCEIVER_TXFAULT_ATTR_ID(26), + TRANSCEIVER_TXFAULT_ATTR_ID(27), + TRANSCEIVER_TXFAULT_ATTR_ID(28), + TRANSCEIVER_TXFAULT_ATTR_ID(29), + TRANSCEIVER_TXFAULT_ATTR_ID(30), + TRANSCEIVER_TXFAULT_ATTR_ID(31), + TRANSCEIVER_TXFAULT_ATTR_ID(32), + TRANSCEIVER_TXFAULT_ATTR_ID(33), + TRANSCEIVER_TXFAULT_ATTR_ID(34), + TRANSCEIVER_TXFAULT_ATTR_ID(35), + TRANSCEIVER_TXFAULT_ATTR_ID(36), + TRANSCEIVER_TXFAULT_ATTR_ID(37), + TRANSCEIVER_TXFAULT_ATTR_ID(38), + TRANSCEIVER_TXFAULT_ATTR_ID(39), + TRANSCEIVER_TXFAULT_ATTR_ID(40), + TRANSCEIVER_TXFAULT_ATTR_ID(41), + TRANSCEIVER_TXFAULT_ATTR_ID(42), + TRANSCEIVER_TXFAULT_ATTR_ID(43), + TRANSCEIVER_TXFAULT_ATTR_ID(44), + TRANSCEIVER_TXFAULT_ATTR_ID(45), + TRANSCEIVER_TXFAULT_ATTR_ID(46), + TRANSCEIVER_TXFAULT_ATTR_ID(47), + TRANSCEIVER_TXFAULT_ATTR_ID(48), +}; + +/* sysfs attributes for hwmon + */ +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf); +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); +static ssize_t show_version(struct device *dev, struct device_attribute *da, + char *buf); +static int as5916_54xks_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as5916_54xks_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/* transceiver attributes */ +#define DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index) +#define DECLARE_TRANSCEIVER_PRESENT_ATTR(index) &sensor_dev_attr_module_present_##index.dev_attr.attr + +#define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index) +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); +static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); +/* transceiver attributes */ +static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, NULL, MODULE_PRESENT_ALL); +static SENSOR_DEVICE_ATTR(module_rx_los_all, S_IRUGO, show_rxlos_all, NULL, MODULE_RXLOS_ALL); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(1); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(2); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(3); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(4); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(5); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(6); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(7); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(8); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(9); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(10); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(11); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(12); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(13); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(14); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(15); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(16); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(17); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(18); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(19); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(20); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(21); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(22); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(23); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(24); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(25); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(26); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(27); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(28); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(29); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(30); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(31); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(32); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(33); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(34); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(35); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(36); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(37); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(38); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(39); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(40); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(41); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(42); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(43); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(44); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(45); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(46); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(47); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(48); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(49); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(50); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(51); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(52); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(53); +DECLARE_TRANSCEIVER_PRESENT_SENSOR_DEVICE_ATTR(54); + +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(1); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(2); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(3); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(4); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(5); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(6); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(7); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(8); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(9); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(10); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(11); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(12); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(13); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(14); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(15); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(16); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(17); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(18); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(19); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(20); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(21); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(22); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(23); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(24); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(25); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(26); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(27); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(28); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(29); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(30); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(31); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(32); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(33); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(34); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(35); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(36); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(37); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(38); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(39); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(40); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(41); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(42); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(43); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(44); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(45); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(46); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(47); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(48); + +static struct attribute *as5916_54xks_cpld1_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(1), + DECLARE_TRANSCEIVER_PRESENT_ATTR(2), + DECLARE_TRANSCEIVER_PRESENT_ATTR(3), + DECLARE_TRANSCEIVER_PRESENT_ATTR(4), + DECLARE_TRANSCEIVER_PRESENT_ATTR(5), + DECLARE_TRANSCEIVER_PRESENT_ATTR(6), + DECLARE_TRANSCEIVER_PRESENT_ATTR(7), + DECLARE_TRANSCEIVER_PRESENT_ATTR(8), + DECLARE_TRANSCEIVER_PRESENT_ATTR(9), + DECLARE_TRANSCEIVER_PRESENT_ATTR(10), + DECLARE_TRANSCEIVER_PRESENT_ATTR(11), + DECLARE_TRANSCEIVER_PRESENT_ATTR(12), + DECLARE_TRANSCEIVER_PRESENT_ATTR(13), + DECLARE_TRANSCEIVER_PRESENT_ATTR(14), + DECLARE_TRANSCEIVER_PRESENT_ATTR(15), + DECLARE_TRANSCEIVER_PRESENT_ATTR(16), + DECLARE_TRANSCEIVER_PRESENT_ATTR(17), + DECLARE_TRANSCEIVER_PRESENT_ATTR(18), + DECLARE_TRANSCEIVER_PRESENT_ATTR(19), + DECLARE_TRANSCEIVER_PRESENT_ATTR(20), + DECLARE_TRANSCEIVER_PRESENT_ATTR(21), + DECLARE_TRANSCEIVER_PRESENT_ATTR(22), + DECLARE_TRANSCEIVER_PRESENT_ATTR(23), + DECLARE_TRANSCEIVER_PRESENT_ATTR(24), + DECLARE_SFP_TRANSCEIVER_ATTR(1), + DECLARE_SFP_TRANSCEIVER_ATTR(2), + DECLARE_SFP_TRANSCEIVER_ATTR(3), + DECLARE_SFP_TRANSCEIVER_ATTR(4), + DECLARE_SFP_TRANSCEIVER_ATTR(5), + DECLARE_SFP_TRANSCEIVER_ATTR(6), + DECLARE_SFP_TRANSCEIVER_ATTR(7), + DECLARE_SFP_TRANSCEIVER_ATTR(8), + DECLARE_SFP_TRANSCEIVER_ATTR(9), + DECLARE_SFP_TRANSCEIVER_ATTR(10), + DECLARE_SFP_TRANSCEIVER_ATTR(11), + DECLARE_SFP_TRANSCEIVER_ATTR(12), + DECLARE_SFP_TRANSCEIVER_ATTR(13), + DECLARE_SFP_TRANSCEIVER_ATTR(14), + DECLARE_SFP_TRANSCEIVER_ATTR(15), + DECLARE_SFP_TRANSCEIVER_ATTR(16), + DECLARE_SFP_TRANSCEIVER_ATTR(17), + DECLARE_SFP_TRANSCEIVER_ATTR(18), + DECLARE_SFP_TRANSCEIVER_ATTR(19), + DECLARE_SFP_TRANSCEIVER_ATTR(20), + DECLARE_SFP_TRANSCEIVER_ATTR(21), + DECLARE_SFP_TRANSCEIVER_ATTR(22), + DECLARE_SFP_TRANSCEIVER_ATTR(23), + DECLARE_SFP_TRANSCEIVER_ATTR(24), + NULL +}; + +static const struct attribute_group as5916_54xks_cpld1_group = { + .attrs = as5916_54xks_cpld1_attributes, +}; + +static struct attribute *as5916_54xks_cpld2_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + /* transceiver attributes */ + &sensor_dev_attr_module_present_all.dev_attr.attr, + &sensor_dev_attr_module_rx_los_all.dev_attr.attr, + DECLARE_TRANSCEIVER_PRESENT_ATTR(25), + DECLARE_TRANSCEIVER_PRESENT_ATTR(26), + DECLARE_TRANSCEIVER_PRESENT_ATTR(27), + DECLARE_TRANSCEIVER_PRESENT_ATTR(28), + DECLARE_TRANSCEIVER_PRESENT_ATTR(29), + DECLARE_TRANSCEIVER_PRESENT_ATTR(30), + DECLARE_TRANSCEIVER_PRESENT_ATTR(31), + DECLARE_TRANSCEIVER_PRESENT_ATTR(32), + DECLARE_TRANSCEIVER_PRESENT_ATTR(33), + DECLARE_TRANSCEIVER_PRESENT_ATTR(34), + DECLARE_TRANSCEIVER_PRESENT_ATTR(35), + DECLARE_TRANSCEIVER_PRESENT_ATTR(36), + DECLARE_TRANSCEIVER_PRESENT_ATTR(37), + DECLARE_TRANSCEIVER_PRESENT_ATTR(38), + DECLARE_TRANSCEIVER_PRESENT_ATTR(39), + DECLARE_TRANSCEIVER_PRESENT_ATTR(40), + DECLARE_TRANSCEIVER_PRESENT_ATTR(41), + DECLARE_TRANSCEIVER_PRESENT_ATTR(42), + DECLARE_TRANSCEIVER_PRESENT_ATTR(43), + DECLARE_TRANSCEIVER_PRESENT_ATTR(44), + DECLARE_TRANSCEIVER_PRESENT_ATTR(45), + DECLARE_TRANSCEIVER_PRESENT_ATTR(46), + DECLARE_TRANSCEIVER_PRESENT_ATTR(47), + DECLARE_TRANSCEIVER_PRESENT_ATTR(48), + DECLARE_TRANSCEIVER_PRESENT_ATTR(49), + DECLARE_TRANSCEIVER_PRESENT_ATTR(50), + DECLARE_TRANSCEIVER_PRESENT_ATTR(51), + DECLARE_TRANSCEIVER_PRESENT_ATTR(52), + DECLARE_TRANSCEIVER_PRESENT_ATTR(53), + DECLARE_TRANSCEIVER_PRESENT_ATTR(54), + DECLARE_SFP_TRANSCEIVER_ATTR(25), + DECLARE_SFP_TRANSCEIVER_ATTR(26), + DECLARE_SFP_TRANSCEIVER_ATTR(27), + DECLARE_SFP_TRANSCEIVER_ATTR(28), + DECLARE_SFP_TRANSCEIVER_ATTR(29), + DECLARE_SFP_TRANSCEIVER_ATTR(30), + DECLARE_SFP_TRANSCEIVER_ATTR(31), + DECLARE_SFP_TRANSCEIVER_ATTR(32), + DECLARE_SFP_TRANSCEIVER_ATTR(33), + DECLARE_SFP_TRANSCEIVER_ATTR(34), + DECLARE_SFP_TRANSCEIVER_ATTR(35), + DECLARE_SFP_TRANSCEIVER_ATTR(36), + DECLARE_SFP_TRANSCEIVER_ATTR(37), + DECLARE_SFP_TRANSCEIVER_ATTR(38), + DECLARE_SFP_TRANSCEIVER_ATTR(39), + DECLARE_SFP_TRANSCEIVER_ATTR(40), + DECLARE_SFP_TRANSCEIVER_ATTR(41), + DECLARE_SFP_TRANSCEIVER_ATTR(42), + DECLARE_SFP_TRANSCEIVER_ATTR(43), + DECLARE_SFP_TRANSCEIVER_ATTR(44), + DECLARE_SFP_TRANSCEIVER_ATTR(45), + DECLARE_SFP_TRANSCEIVER_ATTR(46), + DECLARE_SFP_TRANSCEIVER_ATTR(47), + DECLARE_SFP_TRANSCEIVER_ATTR(48), + NULL +}; + +static const struct attribute_group as5916_54xks_cpld2_group = { + .attrs = as5916_54xks_cpld2_attributes, +}; + +static ssize_t show_present_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status, num_regs = 0; + u8 values[4] = {0}; + u8 regs[] = {0x10, 0x11, 0x12, 0x52}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + num_regs = (data->type == as5916_54xks_cpld1) ? 3 : 4; + + for (i = 0; i < num_regs; i++) { + status = as5916_54xks_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = ~(u8)status; + } + + mutex_unlock(&data->update_lock); + + if (data->type == as5916_54xks_cpld1) { + status = sprintf(buf, "%.2x %.2x %.2x\n", + values[0], values[1], values[2]); + } + else { /* as5916_54xks_cpld2 */ + values[3] &= 0x3F; + status = sprintf(buf, "%.2x %.2x %.2x %.2x\n", + values[0], values[1], values[2], values[3]); + } + + return status; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_rxlos_all(struct device *dev, struct device_attribute *da, + char *buf) +{ + int i, status; + u8 values[3] = {0}; + u8 regs[] = {0x30, 0x32, 0x34}; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + for (i = 0; i < ARRAY_SIZE(regs); i++) { + status = as5916_54xks_cpld_read_internal(client, regs[i]); + + if (status < 0) { + goto exit; + } + + values[i] = (u8)status; + } + + mutex_unlock(&data->update_lock); + + /* Return values 1 -> 24 in order */ + return sprintf(buf, "%.2x %.2x %.2x\n", values[0], values[1], values[2]); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) { + case MODULE_PRESENT_1 ... MODULE_PRESENT_8: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_1); + break; + case MODULE_PRESENT_9 ... MODULE_PRESENT_16: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_9); + break; + case MODULE_PRESENT_17 ... MODULE_PRESENT_24: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_17); + break; + case MODULE_PRESENT_25 ... MODULE_PRESENT_32: + reg = 0x10; + mask = 0x1 << (attr->index - MODULE_PRESENT_25); + break; + case MODULE_PRESENT_33 ... MODULE_PRESENT_40: + reg = 0x11; + mask = 0x1 << (attr->index - MODULE_PRESENT_33); + break; + case MODULE_PRESENT_41 ... MODULE_PRESENT_48: + reg = 0x12; + mask = 0x1 << (attr->index - MODULE_PRESENT_41); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_54: + reg = 0x52; + mask = 0x1 << (attr->index - MODULE_PRESENT_49); + break; + case MODULE_TXFAULT_1 ... MODULE_TXFAULT_8: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_1); + break; + case MODULE_TXFAULT_9 ... MODULE_TXFAULT_16: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_9); + break; + case MODULE_TXFAULT_17 ... MODULE_TXFAULT_24: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_17); + break; + case MODULE_TXFAULT_25 ... MODULE_TXFAULT_32: + reg = 0x14; + mask = 0x1 << (attr->index - MODULE_TXFAULT_25); + break; + case MODULE_TXFAULT_33 ... MODULE_TXFAULT_40: + reg = 0x16; + mask = 0x1 << (attr->index - MODULE_TXFAULT_33); + break; + case MODULE_TXFAULT_41 ... MODULE_TXFAULT_48: + reg = 0x18; + mask = 0x1 << (attr->index - MODULE_TXFAULT_41); + break; + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + case MODULE_RXLOS_1 ... MODULE_RXLOS_8: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_1); + break; + case MODULE_RXLOS_9 ... MODULE_RXLOS_16: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_9); + break; + case MODULE_RXLOS_17 ... MODULE_RXLOS_24: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_17); + break; + case MODULE_RXLOS_25 ... MODULE_RXLOS_32: + reg = 0x30; + mask = 0x1 << (attr->index - MODULE_RXLOS_25); + break; + case MODULE_RXLOS_33 ... MODULE_RXLOS_40: + reg = 0x32; + mask = 0x1 << (attr->index - MODULE_RXLOS_33); + break; + case MODULE_RXLOS_41 ... MODULE_RXLOS_48: + reg = 0x34; + mask = 0x1 << (attr->index - MODULE_RXLOS_41); + break; + default: + return 0; + } + + if (attr->index >= MODULE_PRESENT_1 && attr->index <= MODULE_PRESENT_54) { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as5916_54xks_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + + switch (attr->index) { + case MODULE_TXDISABLE_1 ... MODULE_TXDISABLE_8: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_1); + break; + case MODULE_TXDISABLE_9 ... MODULE_TXDISABLE_16: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_9); + break; + case MODULE_TXDISABLE_17 ... MODULE_TXDISABLE_24: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_17); + break; + case MODULE_TXDISABLE_25 ... MODULE_TXDISABLE_32: + reg = 0x20; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_25); + break; + case MODULE_TXDISABLE_33 ... MODULE_TXDISABLE_40: + reg = 0x22; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_33); + break; + case MODULE_TXDISABLE_41 ... MODULE_TXDISABLE_48: + reg = 0x24; + mask = 0x1 << (attr->index - MODULE_TXDISABLE_41); + break; + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as5916_54xks_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + + /* Update tx_disable status */ + if (disable) { + status |= mask; + } + else { + status &= ~mask; + } + + status = as5916_54xks_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static ssize_t access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as5916_54xks_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as5916_54xks_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as5916_54xks_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d", val); +} + +/* + * I2C init/probing/exit functions + */ +static int as5916_54xks_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as5916_54xks_cpld_data *data; + int ret = -ENODEV; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as5916_54xks_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) { + case as5916_54xks_cpld1: + group = &as5916_54xks_cpld1_group; + break; + case as5916_54xks_cpld2: + group = &as5916_54xks_cpld2_group; + break; + default: + break; + } + + if (group) { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as5916_54xks_cpld_add_client(client); + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as5916_54xks_cpld_remove(struct i2c_client *client) +{ + struct as5916_54xks_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as5916_54xks_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) { + case as5916_54xks_cpld1: + group = &as5916_54xks_cpld1_group; + break; + case as5916_54xks_cpld2: + group = &as5916_54xks_cpld2_group; + break; + default: + break; + } + + if (group) { + sysfs_remove_group(&client->dev.kobj, group); + } + + kfree(data); + + return 0; +} + +static int as5916_54xks_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as5916_54xks_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as5916_54xks_cpld_read(unsigned short cpld_addr, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54xks_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54xks_cpld_read); + +int as5916_54xks_cpld_write(unsigned short cpld_addr, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if (cpld_node->client->addr == cpld_addr) { + ret = as5916_54xks_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as5916_54xks_cpld_write); + +static struct i2c_driver as5916_54xks_cpld_driver = { + .driver = { + .name = "as5916_54xks_cpld", + .owner = THIS_MODULE, + }, + .probe = as5916_54xks_cpld_probe, + .remove = as5916_54xks_cpld_remove, + .id_table = as5916_54xks_cpld_id, +}; + +static int __init as5916_54xks_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as5916_54xks_cpld_driver); +} + +static void __exit as5916_54xks_cpld_exit(void) +{ + i2c_del_driver(&as5916_54xks_cpld_driver); +} + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as5916_54xks_cpld_init); +module_exit(as5916_54xks_cpld_exit); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-fan.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-fan.c new file mode 100755 index 00000000..145062db --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-fan.c @@ -0,0 +1,485 @@ +/* + * A hwmon driver for the Accton as5916 54x fan + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "as5916_54xks_fan" +#define MAX_FAN_SPEED_RPM 25500 + +static struct as5916_54xks_fan_data *as5916_54xks_fan_update_device(struct device *dev); +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); + +/* fan related data, the index should match sysfs_fan_attributes + */ +static const u8 fan_reg[] = { + 0x0F, /* fan 1-6 present status */ + 0x10, /* fan 1-6 direction(0:B2F 1:F2B) */ + 0x11, /* fan PWM(for all fan) */ + 0x12, /* front fan 1 speed(rpm) */ + 0x13, /* front fan 2 speed(rpm) */ + 0x14, /* front fan 3 speed(rpm) */ + 0x15, /* front fan 4 speed(rpm) */ + 0x16, /* front fan 5 speed(rpm) */ + 0x17, /* front fan 6 speed(rpm) */ + 0x22, /* rear fan 1 speed(rpm) */ + 0x23, /* rear fan 2 speed(rpm) */ + 0x24, /* rear fan 3 speed(rpm) */ + 0x25, /* rear fan 4 speed(rpm) */ + 0x26, /* rear fan 5 speed(rpm) */ + 0x27, /* rear fan 6 speed(rpm) */ +}; + +/* Each client has this additional data */ +struct as5916_54xks_fan_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ +}; + +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, + FAN4_ID, + FAN5_ID, + FAN6_ID +}; + +enum sysfs_fan_attributes { + FAN_PRESENT_REG, + FAN_DIRECTION_REG, + FAN_DUTY_CYCLE_PERCENTAGE, /* Only one CPLD register to control duty cycle for all fans */ + FAN1_FRONT_SPEED_RPM, + FAN2_FRONT_SPEED_RPM, + FAN3_FRONT_SPEED_RPM, + FAN4_FRONT_SPEED_RPM, + FAN5_FRONT_SPEED_RPM, + FAN6_FRONT_SPEED_RPM, + FAN1_REAR_SPEED_RPM, + FAN2_REAR_SPEED_RPM, + FAN3_REAR_SPEED_RPM, + FAN4_REAR_SPEED_RPM, + FAN5_REAR_SPEED_RPM, + FAN6_REAR_SPEED_RPM, + FAN1_DIRECTION, + FAN2_DIRECTION, + FAN3_DIRECTION, + FAN4_DIRECTION, + FAN5_DIRECTION, + FAN6_DIRECTION, + FAN1_PRESENT, + FAN2_PRESENT, + FAN3_PRESENT, + FAN4_PRESENT, + FAN5_PRESENT, + FAN6_PRESENT, + FAN1_FAULT, + FAN2_FAULT, + FAN3_FAULT, + FAN4_FAULT, + FAN5_FAULT, + FAN6_FAULT, + FAN_MAX_RPM +}; + +/* Define attributes + */ +#define DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_fault, S_IRUGO, fan_show_value, NULL, FAN##index##_FAULT) +#define DECLARE_FAN_FAULT_ATTR(index) &sensor_dev_attr_fan##index##_fault.dev_attr.attr + +#define DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_direction, S_IRUGO, fan_show_value, NULL, FAN##index##_DIRECTION) +#define DECLARE_FAN_DIRECTION_ATTR(index) &sensor_dev_attr_fan##index##_direction.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) +#define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr + +#define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) +#define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr + +#define DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan##index##_front_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_FRONT_SPEED_RPM);\ + static SENSOR_DEVICE_ATTR(fan##index##_rear_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN##index##_REAR_SPEED_RPM) +#define DECLARE_FAN_SPEED_RPM_ATTR(index) &sensor_dev_attr_fan##index##_front_speed_rpm.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_rear_speed_rpm.dev_attr.attr + +static SENSOR_DEVICE_ATTR(fan_max_speed_rpm, S_IRUGO, fan_show_value, NULL, FAN_MAX_RPM); +#define DECLARE_FAN_MAX_RPM_ATTR(index) &sensor_dev_attr_fan_max_speed_rpm.dev_attr.attr + +/* 6 fan fault attributes in this platform */ +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_FAULT_SENSOR_DEV_ATTR(6); +/* 6 fan speed(rpm) attributes in this platform */ +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(3); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(4); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(5); +DECLARE_FAN_SPEED_RPM_SENSOR_DEV_ATTR(6); +/* 6 fan present attributes in this platform */ +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(1); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(2); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(3); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(4); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(5); +DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(6); +/* 6 fan direction attribute in this platform */ +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(1); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(2); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(4); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); +DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); +/* 1 fan duty cycle attribute in this platform */ +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); + +static struct attribute *as5916_54xks_fan_attributes[] = { + /* fan related attributes */ + DECLARE_FAN_FAULT_ATTR(1), + DECLARE_FAN_FAULT_ATTR(2), + DECLARE_FAN_FAULT_ATTR(3), + DECLARE_FAN_FAULT_ATTR(4), + DECLARE_FAN_FAULT_ATTR(5), + DECLARE_FAN_FAULT_ATTR(6), + DECLARE_FAN_SPEED_RPM_ATTR(1), + DECLARE_FAN_SPEED_RPM_ATTR(2), + DECLARE_FAN_SPEED_RPM_ATTR(3), + DECLARE_FAN_SPEED_RPM_ATTR(4), + DECLARE_FAN_SPEED_RPM_ATTR(5), + DECLARE_FAN_SPEED_RPM_ATTR(6), + DECLARE_FAN_PRESENT_ATTR(1), + DECLARE_FAN_PRESENT_ATTR(2), + DECLARE_FAN_PRESENT_ATTR(3), + DECLARE_FAN_PRESENT_ATTR(4), + DECLARE_FAN_PRESENT_ATTR(5), + DECLARE_FAN_PRESENT_ATTR(6), + DECLARE_FAN_DIRECTION_ATTR(1), + DECLARE_FAN_DIRECTION_ATTR(2), + DECLARE_FAN_DIRECTION_ATTR(3), + DECLARE_FAN_DIRECTION_ATTR(4), + DECLARE_FAN_DIRECTION_ATTR(5), + DECLARE_FAN_DIRECTION_ATTR(6), + DECLARE_FAN_DUTY_CYCLE_ATTR(), + DECLARE_FAN_MAX_RPM_ATTR(), + NULL +}; + +#define FAN_DUTY_CYCLE_REG_MASK 0xF +#define FAN_MAX_DUTY_CYCLE 100 +#define FAN_REG_VAL_TO_SPEED_RPM_STEP 100 + +static int as5916_54xks_fan_read_value(struct i2c_client *client, u8 reg) +{ + return i2c_smbus_read_byte_data(client, reg); +} + +static int as5916_54xks_fan_write_value(struct i2c_client *client, u8 reg, u8 value) +{ + return i2c_smbus_write_byte_data(client, reg, value); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val+1) * 625 + 75)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625) - 1; +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + return !!(reg_val & BIT(id)); +} + +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + return !(reg_val & BIT(id)); +} + +static u8 is_fan_fault(struct as5916_54xks_fan_data *data, enum fan_id id) +{ + u8 ret = 1; + int front_fan_index = FAN1_FRONT_SPEED_RPM + id; + int rear_fan_index = FAN1_REAR_SPEED_RPM + id; + + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_val[front_fan_index]) && + reg_val_to_speed_rpm(data->reg_val[rear_fan_index])) { + ret = 0; + } + + return ret; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as5916_54xks_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */ + as5916_54xks_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value)); + return count; +} + +static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_54xks_fan_data *data = as5916_54xks_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) { + case FAN_DUTY_CYCLE_PERCENTAGE: + { + u32 duty_cycle = reg_val_to_duty_cycle(data->reg_val[FAN_DUTY_CYCLE_PERCENTAGE]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + } + case FAN1_FRONT_SPEED_RPM: + case FAN2_FRONT_SPEED_RPM: + case FAN3_FRONT_SPEED_RPM: + case FAN4_FRONT_SPEED_RPM: + case FAN5_FRONT_SPEED_RPM: + case FAN6_FRONT_SPEED_RPM: + case FAN1_REAR_SPEED_RPM: + case FAN2_REAR_SPEED_RPM: + case FAN3_REAR_SPEED_RPM: + case FAN4_REAR_SPEED_RPM: + case FAN5_REAR_SPEED_RPM: + case FAN6_REAR_SPEED_RPM: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_val[attr->index])); + break; + case FAN1_PRESENT: + case FAN2_PRESENT: + case FAN3_PRESENT: + case FAN4_PRESENT: + case FAN5_PRESENT: + case FAN6_PRESENT: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_val[FAN_PRESENT_REG], + attr->index - FAN1_PRESENT)); + break; + case FAN1_FAULT: + case FAN2_FAULT: + case FAN3_FAULT: + case FAN4_FAULT: + case FAN5_FAULT: + case FAN6_FAULT: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN1_FAULT)); + break; + case FAN1_DIRECTION: + case FAN2_DIRECTION: + case FAN3_DIRECTION: + case FAN4_DIRECTION: + case FAN5_DIRECTION: + case FAN6_DIRECTION: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_val[FAN_DIRECTION_REG], + attr->index - FAN1_DIRECTION)); + break; + case FAN_MAX_RPM: + ret = sprintf(buf, "%d\n", MAX_FAN_SPEED_RPM); + default: + break; + } + } + + return ret; +} + +static const struct attribute_group as5916_54xks_fan_group = { + .attrs = as5916_54xks_fan_attributes, +}; + +static struct as5916_54xks_fan_data *as5916_54xks_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_fan_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as5916_54xks_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_val); i++) { + int status = as5916_54xks_fan_read_value(client, fan_reg[i]); + + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg %d, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_val[i] = status; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int as5916_54xks_fan_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as5916_54xks_fan_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5916_54xks_fan_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5916_54xks_fan_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: fan '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5916_54xks_fan_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5916_54xks_fan_remove(struct i2c_client *client) +{ + struct as5916_54xks_fan_data *data = i2c_get_clientdata(client); + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5916_54xks_fan_group); + + return 0; +} + +/* Addresses to scan */ +static const unsigned short normal_i2c[] = { 0x66, I2C_CLIENT_END }; + +static const struct i2c_device_id as5916_54xks_fan_id[] = { + { "as5916_54xks_fan", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as5916_54xks_fan_id); + +static struct i2c_driver as5916_54xks_fan_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = DRVNAME, + }, + .probe = as5916_54xks_fan_probe, + .remove = as5916_54xks_fan_remove, + .id_table = as5916_54xks_fan_id, + .address_list = normal_i2c, +}; + +static int __init as5916_54xks_fan_init(void) +{ + return i2c_add_driver(&as5916_54xks_fan_driver); +} + +static void __exit as5916_54xks_fan_exit(void) +{ + i2c_del_driver(&as5916_54xks_fan_driver); +} + +module_init(as5916_54xks_fan_init); +module_exit(as5916_54xks_fan_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as5916_54xks_fan driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-leds.c new file mode 100755 index 00000000..db530e85 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-leds.c @@ -0,0 +1,386 @@ +/* + * A LED driver for the accton_as5916_54xks_led + * + * Copyright (C) 2016 Accton Technology Corporation. + * Brandon Chuang + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "accton_as5916_54xks_led" + +#define DEBUG_MODE 1 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printk (KERN_INFO "%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +extern int as5916_54xks_cpld_read(unsigned short cpld_addr, u8 reg); +extern int as5916_54xks_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +struct accton_as5916_54xks_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[2]; /* Register value, 0 = RELEASE/DIAG LED, + 1 = FAN/PSU LED, + 2 ~ 4 = SYSTEM LED */ +}; + +static struct accton_as5916_54xks_led_data *ledctl = NULL; + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x0C) +#define LED_MODE_DIAG_GREEN_VALUE (0x04) +#define LED_MODE_DIAG_ORANGE_VALUE (0x08) +#define LED_MODE_DIAG_OFF_VALUE (0x0C) + + +#define LED_TYPE_LOC_REG_MASK (0x10) +#define LED_MODE_LOC_ORANGE_VALUE (0x00) +#define LED_MODE_LOC_OFF_VALUE (0x10) + +static const u8 led_reg[] = { + 0x65, /* LOC/DIAG/FAN LED */ + 0x66, /* PSU LED */ +}; + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_LOC, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +/* FAN/PSU/DIAG/RELEASE led mode */ +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +struct led_type_mode { + enum led_type type; + enum led_light_mode mode; + int type_mask; + int mode_value; +}; + +static struct led_type_mode led_type_mode_data[] = { +{LED_TYPE_LOC, LED_MODE_OFF, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_OFF_VALUE}, +{LED_TYPE_LOC, LED_MODE_ORANGE, LED_TYPE_LOC_REG_MASK, LED_MODE_LOC_ORANGE_VALUE}, +{LED_TYPE_DIAG, LED_MODE_OFF, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_OFF_VALUE}, +{LED_TYPE_DIAG, LED_MODE_GREEN, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_GREEN_VALUE}, +{LED_TYPE_DIAG, LED_MODE_ORANGE, LED_TYPE_DIAG_REG_MASK, LED_MODE_DIAG_ORANGE_VALUE}, +}; + +static int led_reg_val_to_light_mode(enum led_type type, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + if (type != led_type_mode_data[i].type) { + continue; + } + + if ((led_type_mode_data[i].type_mask & reg_val) == + led_type_mode_data[i].mode_value) { + return led_type_mode_data[i].mode; + } + } + + return LED_MODE_UNKNOWN; +} + +static u8 led_light_mode_to_reg_val(enum led_type type, + enum led_light_mode mode, u8 reg_val) { + int i; + + for (i = 0; i < ARRAY_SIZE(led_type_mode_data); i++) { + int type_mask, mode_value; + + if (type != led_type_mode_data[i].type) + continue; + + if (mode != led_type_mode_data[i].mode) + continue; + + type_mask = led_type_mode_data[i].type_mask; + mode_value = led_type_mode_data[i].mode_value; + reg_val = (reg_val & ~type_mask) | mode_value; + } + + return reg_val; +} + +static int accton_as5916_54xks_led_read_value(u8 reg) +{ + return as5916_54xks_cpld_read(LED_CNTRLER_I2C_ADDRESS, reg); +} + +static int accton_as5916_54xks_led_write_value(u8 reg, u8 value) +{ + return as5916_54xks_cpld_write(LED_CNTRLER_I2C_ADDRESS, reg, value); +} + +static void accton_as5916_54xks_led_update(void) +{ + mutex_lock(&ledctl->update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as5916_54xks_led update\n"); + ledctl->valid = 0; + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as5916_54xks_led_read_value(led_reg[i]); + + if (status < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg[i], status); + goto exit; + } + else + ledctl->reg_val[i] = status; + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as5916_54xks_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + u8 reg, enum led_type type) +{ + int reg_val; + + mutex_lock(&ledctl->update_lock); + reg_val = accton_as5916_54xks_led_read_value(reg); + + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + accton_as5916_54xks_led_write_value(reg, reg_val); + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as7312_54x_led_auto_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ +} + +static enum led_brightness accton_as7312_54x_led_auto_get(struct led_classdev *cdev) +{ + return LED_MODE_AUTO; +} + +static void accton_as5916_54xks_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as5916_54xks_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_DIAG); +} + +static enum led_brightness accton_as5916_54xks_led_diag_get(struct led_classdev *cdev) +{ + accton_as5916_54xks_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static enum led_brightness accton_as5916_54xks_led_loc_get(struct led_classdev *cdev) +{ + accton_as5916_54xks_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_LOC, ledctl->reg_val[0]); +} + +static void accton_as5916_54xks_led_loc_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as5916_54xks_led_set(led_cdev, led_light_mode, led_reg[0], LED_TYPE_LOC); +} + +static struct led_classdev accton_as5916_54xks_leds[] = { + [LED_TYPE_LOC] = { + .name = "accton_as5916_54xks_led::loc", + .default_trigger = "unused", + .brightness_set = accton_as5916_54xks_led_loc_set, + .brightness_get = accton_as5916_54xks_led_loc_get, + .max_brightness = LED_MODE_ORANGE, + }, + [LED_TYPE_DIAG] = { + .name = "accton_as5916_54xks_led::diag", + .default_trigger = "unused", + .brightness_set = accton_as5916_54xks_led_diag_set, + .brightness_get = accton_as5916_54xks_led_diag_get, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_PSU1] = { + .name = "accton_as5916_54xks_led::psu1", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "accton_as5916_54xks_led::psu2", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_FAN] = { + .name = "accton_as5916_54xks_led::fan", + .default_trigger = "unused", + .brightness_set = accton_as7312_54x_led_auto_set, + .brightness_get = accton_as7312_54x_led_auto_get, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as5916_54xks_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as5916_54xks_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as5916_54xks_leds[i]); + + if (ret < 0) { + break; + } + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as5916_54xks_leds)){ + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as5916_54xks_leds[i]); + } + } + + return ret; +} + +static int accton_as5916_54xks_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as5916_54xks_leds); i++) { + led_classdev_unregister(&accton_as5916_54xks_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as5916_54xks_led_driver = { + .probe = accton_as5916_54xks_led_probe, + .remove = accton_as5916_54xks_led_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as5916_54xks_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as5916_54xks_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as5916_54xks_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + goto exit_driver; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + goto exit_free; + } + + return 0; + +exit_free: + kfree(ledctl); +exit_driver: + platform_driver_unregister(&accton_as5916_54xks_led_driver); +exit: + return ret; +} + +static void __exit accton_as5916_54xks_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as5916_54xks_led_driver); + kfree(ledctl); +} + +late_initcall(accton_as5916_54xks_led_init); +module_exit(accton_as5916_54xks_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as5916_54xks_led driver"); +MODULE_LICENSE("GPL"); + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-psu.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-psu.c new file mode 100755 index 00000000..fa5f7bd0 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/modules/builds/x86-64-accton-as5916-54xks-psu.c @@ -0,0 +1,288 @@ +/* + * An hwmon driver for accton as5916_54xks Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, char *buf); +static int as5916_54xks_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int as5916_54xks_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as5916_54xks_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[9]; /* Model name, read from eeprom */ +}; + +static struct as5916_54xks_psu_data *as5916_54xks_psu_update_device(struct device *dev); + +enum as5916_54xks_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_model_name,NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); + +static struct attribute *as5916_54xks_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as5916_54xks_psu_data *data = as5916_54xks_psu_update_device(dev); + u8 status = 0; + + if (attr->index == PSU_PRESENT) { + status = !(data->status & BIT(1 - data->index));; + } + else { /* PSU_POWER_GOOD */ + status = !!(data->status & BIT(3 - data->index)); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_model_name(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct as5916_54xks_psu_data *data = as5916_54xks_psu_update_device(dev); + + return sprintf(buf, "%s\n", data->model_name); +} + +static const struct attribute_group as5916_54xks_psu_group = { + .attrs = as5916_54xks_psu_attributes, +}; + +static int as5916_54xks_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as5916_54xks_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as5916_54xks_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as5916_54xks_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as5916_54xks_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as5916_54xks_psu_remove(struct i2c_client *client) +{ + struct as5916_54xks_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as5916_54xks_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as5916_54xks_psu1, + as5916_54xks_psu2 +}; + +static const struct i2c_device_id as5916_54xks_psu_id[] = { + { "as5916_54xks_psu1", as5916_54xks_psu1 }, + { "as5916_54xks_psu2", as5916_54xks_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as5916_54xks_psu_id); + +static struct i2c_driver as5916_54xks_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as5916_54xks_psu", + }, + .probe = as5916_54xks_psu_probe, + .remove = as5916_54xks_psu_remove, + .id_table = as5916_54xks_psu_id, + .address_list = normal_i2c, +}; + +static int as5916_54xks_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as5916_54xks_psu_data *as5916_54xks_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as5916_54xks_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as5916_54xks update\n"); + + /* Read psu status */ + status = as5916_54xks_cpld_read(0x60, 0x2); + + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + power_good = data->status & BIT(3 - data->index); + + if (power_good) { + status = as5916_54xks_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +static int __init as5916_54xks_psu_init(void) +{ + return i2c_add_driver(&as5916_54xks_psu_driver); +} + +static void __exit as5916_54xks_psu_exit(void) +{ + i2c_del_driver(&as5916_54xks_psu_driver); +} + +module_init(as5916_54xks_psu_init); +module_exit(as5916_54xks_psu_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as5916_54xks_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/PKG.yml new file mode 100755 index 00000000..eee3a8ce --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-revision.yml PLATFORM=x86-64-accton-as5916-54xks ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/lib/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/lib/Makefile new file mode 100755 index 00000000..5499ee1b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# 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/config.amd64.mk + +MODULE := libonlp-x86-64-accton-as5916-54xks +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_accton_as5916_54xks onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-accton-as5916-54xks.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/onlpdump/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/onlpdump/Makefile new file mode 100755 index 00000000..aa449fa6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# 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/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_accton_as5916_54xks onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore new file mode 100644 index 00000000..c81d16be --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore @@ -0,0 +1 @@ +*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.module b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.module new file mode 100644 index 00000000..d6a9f94b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_accton_as5916_54xks diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/Makefile new file mode 100755 index 00000000..f4e952d7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include $(ONL)/make/config.mk +MODULE := x86_64_accton_as5916_54xks +AUTOMODULE := x86_64_accton_as5916_54xks +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/README b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/README new file mode 100644 index 00000000..64864843 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_accton_as5916_54x README +# +############################################################################### + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/auto/x86_64_accton_as5916_54xks.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/auto/x86_64_accton_as5916_54xks.yml new file mode 100755 index 00000000..b669e3dd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/auto/x86_64_accton_as5916_54xks.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_accton_as5916_54xks Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB +- X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_ACCTON_AS5916_54XKS_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_accton_as5916_54xks_config + + portingmacro: + x86_64_accton_as5916_54xks: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks.x b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks.x new file mode 100755 index 00000000..d55188cb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_config.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_config.h new file mode 100755 index 00000000..617d632f --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_54xks Configuration Header + * + * @addtogroup x86_64_accton_as5916_54xks-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54XKS_CONFIG_H__ +#define __X86_64_ACCTON_AS5916_54XKS_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_accton_as5916_54xks_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_accton_as5916_54xks_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_accton_as5916_54xks_config_settings table. */ +extern x86_64_accton_as5916_54xks_config_settings_t x86_64_accton_as5916_54xks_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_accton_as5916_54xks_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_accton_as5916_54xks_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_accton_as5916_54xks_porting.h" + +#endif /* __X86_64_ACCTON_AS5916_54XKS_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_dox.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_dox.h new file mode 100755 index 00000000..1e41d2f8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_54xks Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54XKS_DOX_H__ +#define __X86_64_ACCTON_AS5916_54XKS_DOX_H__ + +/** + * @defgroup x86_64_accton_as5916_54xks x86_64_accton_as5916_54xks - x86_64_accton_as5916_54xks Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_accton_as5916_54xks-x86_64_accton_as5916_54xks Public Interface + * @defgroup x86_64_accton_as5916_54xks-config Compile Time Configuration + * @defgroup x86_64_accton_as5916_54xks-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_ACCTON_AS5916_54XKS_DOX_H__ */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_porting.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_porting.h new file mode 100755 index 00000000..f81fb0e6 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/inc/x86_64_accton_as5916_54xks/x86_64_accton_as5916_54xks_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_accton_as5916_54xks Porting Macros. + * + * @addtogroup x86_64_accton_as5916_54xks-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_ACCTON_AS5916_54XKS_PORTING_H__ +#define __X86_64_ACCTON_AS5916_54XKS_PORTING_H__ + + +/* */ +#if X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_MALLOC + #if defined(GLOBAL_MALLOC) + #define X86_64_ACCTON_AS5916_54XKS_MALLOC GLOBAL_MALLOC + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_MALLOC malloc + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_FREE + #if defined(GLOBAL_FREE) + #define X86_64_ACCTON_AS5916_54XKS_FREE GLOBAL_FREE + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_FREE free + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_FREE is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_MEMSET + #if defined(GLOBAL_MEMSET) + #define X86_64_ACCTON_AS5916_54XKS_MEMSET GLOBAL_MEMSET + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_MEMSET memset + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define X86_64_ACCTON_AS5916_54XKS_MEMCPY GLOBAL_MEMCPY + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_MEMCPY memcpy + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define X86_64_ACCTON_AS5916_54XKS_STRNCPY GLOBAL_STRNCPY + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_STRNCPY strncpy + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define X86_64_ACCTON_AS5916_54XKS_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_VSNPRINTF vsnprintf + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define X86_64_ACCTON_AS5916_54XKS_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_SNPRINTF snprintf + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef X86_64_ACCTON_AS5916_54XKS_STRLEN + #if defined(GLOBAL_STRLEN) + #define X86_64_ACCTON_AS5916_54XKS_STRLEN GLOBAL_STRLEN + #elif X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB == 1 + #define X86_64_ACCTON_AS5916_54XKS_STRLEN strlen + #else + #error The macro X86_64_ACCTON_AS5916_54XKS_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_ACCTON_AS5916_54XKS_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/Makefile new file mode 100755 index 00000000..af16f9e8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_accton_as5916_54xks_ucli.c + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/fani.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/fani.c new file mode 100644 index 00000000..6e990cfd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/fani.c @@ -0,0 +1,303 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +enum fan_id { + FAN_1_ON_FAN_BOARD = 1, + FAN_2_ON_FAN_BOARD, + FAN_3_ON_FAN_BOARD, + FAN_4_ON_FAN_BOARD, + FAN_5_ON_FAN_BOARD, + FAN_6_ON_FAN_BOARD, + FAN_1_ON_PSU_1, + FAN_1_ON_PSU_2, +}; + +#define MAX_FAN_SPEED 25500 +#define MAX_PSU_FAN_SPEED 25500 + +#define CHASSIS_FAN_INFO(fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_FAN_BOARD), "Chassis Fan - "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +#define PSU_FAN_INFO(pid, fid) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fid##_ON_PSU_##pid), "PSU "#pid" - Fan "#fid, 0 },\ + 0x0,\ + ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE,\ + 0,\ + 0,\ + ONLP_FAN_MODE_INVALID,\ + } + +/* Static fan information */ +onlp_fan_info_t finfo[] = { + { }, /* Not used */ + CHASSIS_FAN_INFO(1), + CHASSIS_FAN_INFO(2), + CHASSIS_FAN_INFO(3), + CHASSIS_FAN_INFO(4), + CHASSIS_FAN_INFO(5), + CHASSIS_FAN_INFO(6), + PSU_FAN_INFO(1, 1), + PSU_FAN_INFO(2, 1) +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) +{ + int value, ret; + + /* get fan present status + */ + ret = onlp_file_read_int(&value, "%s""fan%d_present", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value == 0) { + return ONLP_STATUS_OK; /* fan is not present */ + } + info->status |= ONLP_FAN_STATUS_PRESENT; + + + /* get fan fault status (turn on when any one fails) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_fault", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + if (value > 0) { + info->status |= ONLP_FAN_STATUS_FAILED; + } + + + /* get fan direction (both : the same) + */ + ret = onlp_file_read_int(&value, "%s""fan%d_direction", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->status |= value ? ONLP_FAN_STATUS_F2B : ONLP_FAN_STATUS_B2F; + + + /* get front fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_front_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + info->rpm = value; + + /* get rear fan speed + */ + ret = onlp_file_read_int(&value, "%s""fan%d_rear_speed_rpm", FAN_BOARD_PATH, fid); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + /* take the min value from front/rear fan speed + */ + if (info->rpm > value) { + info->rpm = value; + } + + /* get speed percentage from rpm + */ + ret = onlp_file_read_int(&value, "%s""fan_max_speed_rpm", FAN_BOARD_PATH); + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from (%s)\r\n", FAN_BOARD_PATH); + return ONLP_STATUS_E_INTERNAL; + } + + info->percentage = (info->rpm * 100)/value; + + return ONLP_STATUS_OK; +} + +static uint32_t +_onlp_get_fan_direction_on_psu(void) +{ + /* Try to read direction from PSU1. + * If PSU1 is not valid, read from PSU2 + */ + int i = 0; + + for (i = PSU1_ID; i <= PSU2_ID; i++) { + psu_type_t psu_type; + psu_type = get_psu_type(i, NULL, 0); + + if (psu_type == PSU_TYPE_UNKNOWN) { + continue; + } + + if (PSU_TYPE_AC_F2B == psu_type) { + return ONLP_FAN_STATUS_F2B; + } + else { + return ONLP_FAN_STATUS_B2F; + } + } + + return 0; +} + +static int +_onlp_fani_info_get_fan_on_psu(int pid, onlp_fan_info_t* info) +{ + int val = 0; + + info->status |= ONLP_FAN_STATUS_PRESENT; + + /* get fan direction + */ + info->status |= _onlp_get_fan_direction_on_psu(); + + /* get fan speed + */ + if (psu_ym2651y_pmbus_info_get(pid, "psu_fan1_speed_rpm", &val) == ONLP_STATUS_OK) { + info->rpm = val; + info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; + info->status |= (val == 0) ? ONLP_FAN_STATUS_FAILED : 0; + } + + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + return ONLP_STATUS_OK; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int fid; + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + *info = finfo[fid]; + + switch (fid) + { + case FAN_1_ON_PSU_1: + rc = _onlp_fani_info_get_fan_on_psu(PSU1_ID, info); + break; + case FAN_1_ON_PSU_2: + rc = _onlp_fani_info_get_fan_on_psu(PSU2_ID, info); + break; + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + rc =_onlp_fani_info_get_fan(fid, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + int fid; + char *path = NULL; + + VALIDATE(id); + + fid = ONLP_OID_ID_GET(id); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + switch (fid) + { + case FAN_1_ON_PSU_1: + return psu_ym2651y_pmbus_info_set(PSU1_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_PSU_2: + return psu_ym2651y_pmbus_info_set(PSU2_ID, "psu_fan1_duty_cycle_percentage", p); + case FAN_1_ON_FAN_BOARD: + case FAN_2_ON_FAN_BOARD: + case FAN_3_ON_FAN_BOARD: + case FAN_4_ON_FAN_BOARD: + case FAN_5_ON_FAN_BOARD: + case FAN_6_ON_FAN_BOARD: + path = FAN_NODE(fan_duty_cycle_percentage); + break; + default: + return ONLP_STATUS_E_INVALID; + } + + if (onlp_file_write_int(p, path) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..ca5c609d --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,247 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#define LED_FORMAT "/sys/class/leds/accton_as5916_54xks_led::%s/brightness" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +/* LED related data + */ +enum onlp_led_id +{ + LED_RESERVED = 0, + LED_LOC, + LED_DIAG, + LED_PSU1, + LED_PSU2, + LED_FAN, +}; + +enum led_light_mode { + LED_MODE_OFF, + LED_MODE_RED = 10, + LED_MODE_RED_BLINKING = 11, + LED_MODE_ORANGE = 12, + LED_MODE_ORANGE_BLINKING = 13, + LED_MODE_YELLOW = 14, + LED_MODE_YELLOW_BLINKING = 15, + LED_MODE_GREEN = 16, + LED_MODE_GREEN_BLINKING = 17, + LED_MODE_BLUE = 18, + LED_MODE_BLUE_BLINKING = 19, + LED_MODE_PURPLE = 20, + LED_MODE_PURPLE_BLINKING = 21, + LED_MODE_AUTO = 22, + LED_MODE_AUTO_BLINKING = 23, + LED_MODE_WHITE = 24, + LED_MODE_WHITE_BLINKING = 25, + LED_MODE_CYAN = 26, + LED_MODE_CYAN_BLINKING = 27, + LED_MODE_UNKNOWN = 99 +}; + +typedef struct led_light_mode_map { + enum onlp_led_id id; + enum led_light_mode driver_led_mode; + enum onlp_led_mode_e onlp_led_mode; +} led_light_mode_map_t; + +led_light_mode_map_t led_map[] = { +{LED_LOC, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_LOC, LED_MODE_ORANGE, ONLP_LED_MODE_ORANGE}, +{LED_DIAG, LED_MODE_OFF, ONLP_LED_MODE_OFF}, +{LED_DIAG, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, +{LED_DIAG, LED_MODE_ORANGE, ONLP_LED_MODE_ORANGE}, +{LED_FAN, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU1, LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, +{LED_PSU2, LED_MODE_AUTO, ONLP_LED_MODE_AUTO} +}; + +static char *leds[] = /* must map with onlp_led_id */ +{ + NULL, + "loc", + "diag", + "psu1", + "psu2", + "fan" +}; + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_LOC), "Chassis LED 1 (LOC LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE, + }, + { + { ONLP_LED_ID_CREATE(LED_DIAG), "Chassis LED 2 (DIAG LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU1), "Chassis LED 3 (PSU1 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_PSU2), "Chassis LED 4 (PSU2 LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED 5 (FAN LED)", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO, + }, +}; + +static int driver_to_onlp_led_mode(enum onlp_led_id id, enum led_light_mode driver_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for (i = 0; i < nsize; i++) + { + if (id == led_map[i].id && driver_led_mode == led_map[i].driver_led_mode) + { + return led_map[i].onlp_led_mode; + } + } + + return 0; +} + +static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led_mode) +{ + int i, nsize = sizeof(led_map)/sizeof(led_map[0]); + + for(i = 0; i < nsize; i++) + { + if (id == led_map[i].id && onlp_led_mode == led_map[i].onlp_led_mode) + { + return led_map[i].driver_led_mode; + } + } + + return 0; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + /* + * Turn off the LOCATION and DIAG LEDs at startup + */ + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOC), ONLP_LED_MODE_OFF); + + return ONLP_STATUS_OK; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int lid, value; + + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[ONLP_OID_ID_GET(id)]; + + /* Get LED mode */ + if (onlp_file_read_int(&value, LED_FORMAT, leds[lid]) < 0) { + DEBUG_PRINT("Unable to read status from file "LED_FORMAT, leds[lid]); + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = driver_to_onlp_led_mode(lid, value); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + VALIDATE(id); + + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int lid; + VALIDATE(id); + + lid = ONLP_OID_ID_GET(id); + if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.c new file mode 100644 index 00000000..1837a772 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,124 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2013 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#define PSU_NODE_MAX_PATH_LEN 64 +#define PSU_MODEL_NAME_LEN 9 +#define PSU_FAN_DIR_LEN 3 + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len) +{ + int ret = 0, value = 0; + char model[PSU_MODEL_NAME_LEN + 1] = {0}; + char fan_dir[PSU_FAN_DIR_LEN + 1] = {0}; + char *path = NULL; + + if (modelname && modelname_len < PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + } + + /* Check AC model name */ + path = (id == PSU1_ID) ? PSU1_AC_EEPROM_NODE(psu_model_name) : PSU2_AC_EEPROM_NODE(psu_model_name); + ret = onlp_file_read((uint8_t*)model, PSU_MODEL_NAME_LEN, &value, path); + if (ret != ONLP_STATUS_OK || value != PSU_MODEL_NAME_LEN) { + return PSU_TYPE_UNKNOWN; + + } + + if (strncmp(model, "YM-2651Y", strlen("YM-2651Y")) != 0) { + return PSU_TYPE_UNKNOWN; + } + + if (modelname) { + strncpy(modelname, model, modelname_len-1); + } + + path = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); + ret = onlp_file_read((uint8_t*)fan_dir, sizeof(fan_dir), &value, path); + if (ret != ONLP_STATUS_OK) { + return PSU_TYPE_UNKNOWN; + } + + if (strncmp(fan_dir, "F2B", strlen("F2B")) == 0) { + return PSU_TYPE_AC_F2B; + } + + if (strncmp(fan_dir, "B2F", strlen("B2F")) == 0) { + return PSU_TYPE_AC_B2F; + } + + return PSU_TYPE_UNKNOWN; +} + +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value) +{ + int ret = 0; + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + *value = 0; + + if (PSU1_ID == id) { + ret = onlp_file_read_int(value, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + } + else { + ret = onlp_file_read_int(value, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + } + + if (ret < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ret; +} + +int psu_ym2651y_pmbus_info_set(int id, char *node, int value) +{ + char path[PSU_NODE_MAX_PATH_LEN] = {0}; + + switch (id) { + case PSU1_ID: + sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); + break; + case PSU2_ID: + sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node); + break; + default: + return ONLP_STATUS_E_UNSUPPORTED; + }; + + if (onlp_file_write_int(value, path) < 0) { + AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..ec908afc --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,89 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_accton_as5916_54xks_log.h" + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 5 +#define CHASSIS_LED_COUNT 5 +#define CHASSIS_PSU_COUNT 2 + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/18-005b/" +#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/17-0058/" + +#define PSU1_AC_PMBUS_NODE(node) PSU1_AC_PMBUS_PREFIX#node +#define PSU2_AC_PMBUS_NODE(node) PSU2_AC_PMBUS_PREFIX#node + +#define PSU1_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/18-0053/" +#define PSU2_AC_EEPROM_PREFIX "/sys/bus/i2c/devices/17-0050/" + +#define PSU1_AC_EEPROM_NODE(node) PSU1_AC_EEPROM_PREFIX#node +#define PSU2_AC_EEPROM_NODE(node) PSU2_AC_EEPROM_PREFIX#node + +#define FAN_BOARD_PATH "/sys/bus/i2c/devices/9-0066/" +#define FAN_NODE(node) FAN_BOARD_PATH#node + +#define IDPROM_PATH "/sys/bus/i2c/devices/0-0056/eeprom" + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_CPU_CORE, + THERMAL_1_ON_MAIN_BROAD, + THERMAL_2_ON_MAIN_BROAD, + THERMAL_3_ON_MAIN_BROAD, + THERMAL_4_ON_MAIN_BROAD, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F +} psu_type_t; + +psu_type_t get_psu_type(int id, char* modelname, int modelname_len); +int psu_ym2651y_pmbus_info_get(int id, char *node, int *value); +int psu_ym2651y_pmbus_info_set(int id, char *node, int value); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(fmt, args...) \ + printf("%s:%s[%d]: " fmt "\r\n", __FILE__, __FUNCTION__, __LINE__, ##args) +#else + #define DEBUG_PRINT(fmt, args...) +#endif + +#endif /* __PLATFORM_LIB_H__ */ + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/psui.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/psui.c new file mode 100644 index 00000000..f7f64f0e --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/psui.c @@ -0,0 +1,177 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 1 +#define PSU_NODE_MAX_PATH_LEN 64 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +psu_status_info_get(int id, char *node, int *value) +{ + char *prefix = NULL; + + *value = 0; + + prefix = (id == PSU1_ID) ? PSU1_AC_EEPROM_PREFIX : PSU2_AC_EEPROM_PREFIX; + if (onlp_file_read_int(value, "%s%s", prefix, node) < 0) { + AIM_LOG_ERROR("Unable to read status from file(%s%s)\r\n", prefix, node); + return ONLP_STATUS_E_INTERNAL; + } + + return 0; +} + +int +onlp_psui_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +psu_ym2651y_info_get(onlp_psu_info_t* info) +{ + int val = 0; + int index = ONLP_OID_ID_GET(info->hdr.id); + + /* Set capability + */ + info->caps = ONLP_PSU_CAPS_AC; + + if (info->status & ONLP_PSU_STATUS_FAILED) { + return ONLP_STATUS_OK; + } + + /* Set the associated oid_table */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(index + CHASSIS_THERMAL_COUNT); + + /* Read voltage, current and power */ + if (psu_ym2651y_pmbus_info_get(index, "psu_v_out", &val) == 0) { + info->mvout = val; + info->caps |= ONLP_PSU_CAPS_VOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_i_out", &val) == 0) { + info->miout = val; + info->caps |= ONLP_PSU_CAPS_IOUT; + } + + if (psu_ym2651y_pmbus_info_get(index, "psu_p_out", &val) == 0) { + info->mpout = val; + info->caps |= ONLP_PSU_CAPS_POUT; + } + + return ONLP_STATUS_OK; +} + +/* + * Get all information about the given PSU oid. + */ +static onlp_psu_info_t pinfo[] = +{ + { }, /* Not used */ + { + { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, + }, + { + { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, + } +}; + +int +onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) +{ + int val = 0; + int ret = ONLP_STATUS_OK; + int index = ONLP_OID_ID_GET(id); + psu_type_t psu_type; + + VALIDATE(id); + + memset(info, 0, sizeof(onlp_psu_info_t)); + *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ + + /* Get the present state */ + if (psu_status_info_get(index, "psu_present", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_present)\r\n", index); + } + + if (val != PSU_STATUS_PRESENT) { + info->status &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + + /* Get power good status */ + if (psu_status_info_get(index, "psu_power_good", &val) != 0) { + printf("Unable to read PSU(%d) node(psu_power_good)\r\n", index); + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + } + + + /* Get PSU type + */ + psu_type = get_psu_type(index, info->model, sizeof(info->model)); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + ret = psu_ym2651y_info_get(info); + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return ret; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..86530460 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,357 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * 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 "x86_64_accton_as5916_54xks_int.h" +#include "x86_64_accton_as5916_54xks_log.h" + +#define PORT_BUS_INDEX(port) (port+33) + +#define PORT_EEPROM_FORMAT "/sys/bus/i2c/devices/%d-0050/eeprom" +#define MODULE_PRESENT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_present_%d" +#define MODULE_RXLOS_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_rx_los_%d" +#define MODULE_TXFAULT_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_fault_%d" +#define MODULE_TXDISABLE_FORMAT "/sys/bus/i2c/devices/%d-00%d/module_tx_disable_%d" +#define MODULE_PRESENT_ALL_ATTR "/sys/bus/i2c/devices/%d-00%d/module_present_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD1 "/sys/bus/i2c/devices/11-0060/module_rx_los_all" +#define MODULE_RXLOS_ALL_ATTR_CPLD2 "/sys/bus/i2c/devices/12-0062/module_rx_los_all" + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + /* + * Ports {0, 54} + */ + int p; + + for(p = 0; p < 54; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present; + int bus, addr; + + addr = (port < 24) ? 60 : 62; + bus = (addr == 60) ? 11 : 12; + + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[7], *ptr = NULL; + FILE* fp; + int addr; + + ptr = bytes; + + for (addr = 60; addr <= 62; addr+=2) { + /* Read present status of port 0~53 */ + int count = 0; + char file[64] = {0}; + int bus = (addr == 60) ? 11 : 12; + + sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + + if (addr == 60) { /* CPLD1 */ + count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + else { /* CPLD2 */ + count = fscanf(fp, "%x %x %x %x", ptr+0, ptr+1, ptr+2, ptr+3); + fclose(fp); + if(count != 4) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD(0x%d).", addr); + return ONLP_STATUS_E_INTERNAL; + } + } + + ptr += count; + } + + /* Mask out non-existant QSFP ports */ + bytes[6] &= 0x3F; + + /* Convert to 64 bit integer in port order */ + int i = 0; + uint64_t presence_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + presence_all <<= 8; + presence_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + uint32_t bytes[6]; + uint32_t *ptr = bytes; + FILE* fp; + + /* Read present status of port 0~23 */ + int addr, i = 0; + + for (addr = 60; addr <= 62; addr+=2) { + if (addr == 60) { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD1, "r"); + } + else { + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD2, "r"); + } + + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + int count = fscanf(fp, "%x %x %x", ptr+0, ptr+1, ptr+2); + fclose(fp); + if(count != 3) { + /* Likely a CPLD read timeout. */ + AIM_LOG_ERROR("Unable to read all fields from the module_rx_los_all device file of CPLD(0x%d)", addr); + return ONLP_STATUS_E_INTERNAL; + } + + ptr += count; + } + + /* Convert to 64 bit integer in port order */ + i = 0; + uint64_t rx_los_all = 0 ; + for(i = AIM_ARRAYSIZE(bytes)-1; i >= 0; i--) { + rx_los_all <<= 8; + rx_los_all |= bytes[i]; + } + + /* Populate bitmap */ + for(i = 0; rx_los_all; i++) { + AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); + rx_los_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + int size = 0; + memset(data, 0, 256); + + if(onlp_file_read(data, 256, &size, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)) != ONLP_STATUS_OK) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (size != 256) { + AIM_LOG_ERROR("Unable to read eeprom from port(%d), size is different!\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + FILE* fp; + char file[64] = {0}; + + sprintf(file, PORT_EEPROM_FORMAT, PORT_BUS_INDEX(port)); + fp = fopen(file, "r"); + if(fp == NULL) { + AIM_LOG_ERROR("Unable to open the eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + if (fseek(fp, 256, SEEK_CUR) != 0) { + fclose(fp); + AIM_LOG_ERROR("Unable to set the file position indicator of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + int ret = fread(data, 1, 256, fp); + fclose(fp); + if (ret != 256) { + AIM_LOG_ERROR("Unable to read the module_eeprom device file of port(%d)", port); + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; + + switch(control) + { + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + return rv; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int rv; + + if (port < 0 || port >= 48) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + int addr = (port < 24) ? 60 : 62; + int bus = (addr == 60) ? 11 : 12; + + switch(control) + { + case ONLP_SFP_CONTROL_RX_LOS: + { + if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_FAULT: + { + if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + case ONLP_SFP_CONTROL_TX_DISABLE: + { + if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); + rv = ONLP_STATUS_E_INTERNAL; + } + else { + rv = ONLP_STATUS_OK; + } + break; + } + + default: + rv = ONLP_STATUS_E_UNSUPPORTED; + } + + return rv; +} + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..d01d1dc9 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,339 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 Accton Technology Corporation. + * + * 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 "platform_lib.h" + +#include "x86_64_accton_as5916_54xks_int.h" +#include "x86_64_accton_as5916_54xks_log.h" + +#define CPLD_VERSION_FORMAT "/sys/bus/i2c/devices/%s/version" +#define NUM_OF_CPLD 2 + +static char* cpld_path[NUM_OF_CPLD] = +{ + "11-0060", + "12-0062" +}; + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-accton-as5916-54xks-r0"; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + uint8_t* rdata = aim_zmalloc(256); + if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { + if(*size == 256) { + *data = rdata; + return ONLP_STATUS_OK; + } + } + + aim_free(rdata); + *size = 0; + return ONLP_STATUS_E_INTERNAL; +} + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 5 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* 5 LEDs on the chassis */ + for (i = 1; i <= CHASSIS_LED_COUNT; i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + /* 6 Fans on the chassis */ + for (i = 1; i <= CHASSIS_FAN_COUNT; i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + return 0; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int i, v[NUM_OF_CPLD] = {0}; + + for (i = 0; i < AIM_ARRAYSIZE(cpld_path); i++) { + v[i] = 0; + + if(onlp_file_read_int(v+i, CPLD_VERSION_FORMAT , cpld_path[i]) < 0) { + return ONLP_STATUS_E_INTERNAL; + } + } + + pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); + return ONLP_STATUS_OK; +} + +void +onlp_sysi_platform_info_free(onlp_platform_info_t* pi) +{ + aim_free(pi->cpld_versions); +} + +#define FAN_DUTY_MAX (100) +#define FAN_DUTY_MID (69) +#define FAN_DUTY_MIN (38) + +#define FANCTRL_DIR_FACTOR (ONLP_FAN_STATUS_B2F) +#define FANCTRL_DIR_FACTOR_DUTY_ADDON (6) + +static int +sysi_fanctrl_fan_fault_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if any fan is not operational */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (!(fi[i].status & ONLP_FAN_STATUS_FAILED)) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_absent_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* Bring fan speed to FAN_DUTY_MAX if fan is not present */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + if (fi[i].status & ONLP_FAN_STATUS_PRESENT) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_fan_unknown_speed_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int fanduty; + int fanduty_min = FAN_DUTY_MIN; + int fanduty_mid = FAN_DUTY_MID; + + *adjusted = 0; + fanduty_min += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + if (onlp_file_read_int(&fanduty, FAN_NODE(fan_duty_cycle_percentage)) < 0) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + /* Bring fan speed to max if current speed is not expected + */ + if (fanduty != fanduty_min && fanduty != fanduty_mid && fanduty != FAN_DUTY_MAX) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_single_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int i; + *adjusted = 0; + + /* When anyone higher than 50 degrees, all fans run with duty 100%. + */ + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + if (ti[i-1].mcelsius < 50000) { + continue; + } + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + + /* When anyone higher than 45 degrees, all fans run with duty 62.5%. + */ + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + if (ti[i-1].mcelsius < 45000) { + continue; + } + + int fanduty_mid = FAN_DUTY_MID; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_mid); + } + + return ONLP_STATUS_OK; +} + +static int +sysi_fanctrl_overall_thermal_sensor_policy(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted) +{ + int fanduty_min = FAN_DUTY_MIN; + int fanduty_mid = FAN_DUTY_MID; + int i, num_of_sensor = 0, temp_avg = 0; + + *adjusted = 0; + fanduty_min += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + fanduty_mid += (fi[0].status & FANCTRL_DIR_FACTOR) ? FANCTRL_DIR_FACTOR_DUTY_ADDON : 0; + + for (i = (THERMAL_1_ON_MAIN_BROAD); i <= (THERMAL_3_ON_MAIN_BROAD); i++) { + num_of_sensor++; + temp_avg += ti[i-1].mcelsius; + } + + temp_avg /= num_of_sensor; + + if (temp_avg >= 45000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + } + else if (temp_avg >= 40000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_mid); + } + else if (temp_avg < 35000) { + *adjusted = 1; + return onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fanduty_min); + } + + return ONLP_STATUS_OK; +} + +typedef int (*fan_control_policy)(onlp_fan_info_t fi[CHASSIS_FAN_COUNT], + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT], + int *adjusted); + +fan_control_policy fan_control_policies[] = { +sysi_fanctrl_fan_fault_policy, +sysi_fanctrl_fan_absent_policy, +sysi_fanctrl_fan_unknown_speed_policy, +sysi_fanctrl_single_thermal_sensor_policy, +sysi_fanctrl_overall_thermal_sensor_policy, +}; + +int +onlp_sysi_platform_manage_fans(void) +{ + int i, rc; + onlp_fan_info_t fi[CHASSIS_FAN_COUNT]; + onlp_thermal_info_t ti[CHASSIS_THERMAL_COUNT]; + + memset(fi, 0, sizeof(fi)); + memset(ti, 0, sizeof(ti)); + + /* Get fan status + */ + for (i = 0; i < CHASSIS_FAN_COUNT; i++) { + rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i+1), &fi[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Get thermal sensor status + */ + for (i = 0; i < CHASSIS_THERMAL_COUNT; i++) { + rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i+1), &ti[i]); + + if (rc != ONLP_STATUS_OK) { + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_MAX); + return ONLP_STATUS_E_INTERNAL; + } + } + + /* Apply thermal policy according the policy list, + * If fan duty is adjusted by one of the policies, skip the others + */ + for (i = 0; i < AIM_ARRAYSIZE(fan_control_policies); i++) { + int adjusted = 0; + + rc = fan_control_policies[i](fi, ti, &adjusted); + if (!adjusted) { + continue; + } + + return rc; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sysi_platform_manage_leds(void) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/thermali.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/thermali.c new file mode 100644 index 00000000..742a4dd1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,128 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2014 Accton Technology Corporation. + * + * 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. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include "platform_lib.h" + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static char* devfiles__[] = /* must map with onlp_thermal_id */ +{ + NULL, + NULL, /* CPU_CORE files */ + "/sys/bus/i2c/devices/10-0048*temp1_input", + "/sys/bus/i2c/devices/10-0049*temp1_input", + "/sys/bus/i2c/devices/10-004a*temp1_input", + "/sys/bus/i2c/devices/10-004b*temp1_input", + "/sys/bus/i2c/devices/18-005b*psu_temp1_input", + "/sys/bus/i2c/devices/17-0058*psu_temp1_input", +}; + +static char* cpu_coretemp_files[] = + { + "/sys/devices/platform/coretemp.0*temp2_input", + "/sys/devices/platform/coretemp.0*temp3_input", + "/sys/devices/platform/coretemp.0*temp4_input", + "/sys/devices/platform/coretemp.0*temp5_input", + NULL, + }; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE), "CPU Core", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "LM75-1-48", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "LM75-2-49", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_MAIN_BROAD), "LM75-3-4A", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_MAIN_BROAD), "LM75-3-4B", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU1_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(PSU2_ID)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int tid; + VALIDATE(id); + + tid = ONLP_OID_ID_GET(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[tid]; + + if(tid == THERMAL_CPU_CORE) { + int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); + return rv; + } + + return onlp_file_read_int(&info->mcelsius, devfiles__[tid]); +} + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_config.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_config.c new file mode 100755 index 00000000..ef3a4dfb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_config.c @@ -0,0 +1,80 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(_x) __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(_x) +x86_64_accton_as5916_54xks_config_settings_t x86_64_accton_as5916_54xks_config_settings[] = +{ +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_LOGGING(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_STDLIB(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_UCLI(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE(X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_ACCTON_AS5916_54XKS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_accton_as5916_54xks_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_accton_as5916_54xks_config_STRINGIFY_VALUE +#undef __x86_64_accton_as5916_54xks_config_STRINGIFY_NAME + +const char* +x86_64_accton_as5916_54xks_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_accton_as5916_54xks_config_settings[i].name; i++) { + if(!strcmp(x86_64_accton_as5916_54xks_config_settings[i].name, setting)) { + return x86_64_accton_as5916_54xks_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_accton_as5916_54xks_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_accton_as5916_54xks_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_accton_as5916_54xks_config_settings[i].name, x86_64_accton_as5916_54xks_config_settings[i].value); + } + return i; +} + +/* */ diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_enums.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_enums.c new file mode 100755 index 00000000..5fc532f1 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_int.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_int.h new file mode 100755 index 00000000..d1ff7124 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_accton_as5916_54xks Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_54xks_INT_H__ +#define __x86_64_accton_as5916_54xks_INT_H__ + +#include + + +#endif /* __x86_64_accton_as5916_54xks_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.c new file mode 100755 index 00000000..4f0f2d27 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_54xks_log.h" +/* + * x86_64_accton_as5916_54xks log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_ACCTON_AS5916_54XKS_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.h b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.h new file mode 100755 index 00000000..7b22ddd8 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_accton_as5916_54xks_LOG_H__ +#define __x86_64_accton_as5916_54xks_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_accton_as5916_54xks +#include + +#endif /* __x86_64_accton_as5916_54xks_LOG_H__ */ \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_module.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_module.c new file mode 100755 index 00000000..9e5fc6b7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_accton_as5916_54xks_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_accton_as5916_54xks_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_accton_as5916_54xks_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_ucli.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_ucli.c new file mode 100755 index 00000000..b5358c60 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/x86_64_accton_as5916_54xks_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if x86_64_accton_as5916_54xks_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_accton_as5916_54xks_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_accton_as5916_54xks) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_accton_as5916_54xks_ucli_module__ = + { + "x86_64_accton_as5916_54xks_ucli", + NULL, + x86_64_accton_as5916_54xks_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_accton_as5916_54xks_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_accton_as5916_54xks_ucli_module__); + n = ucli_node_create("x86_64_accton_as5916_54xks", NULL, &x86_64_accton_as5916_54xks_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_accton_as5916_54xks")); + return n; +} + +#else +void* +x86_64_accton_as5916_54xks_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/Makefile b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/PKG.yml new file mode 100755 index 00000000..0dc57c4c --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=accton BASENAME=x86-64-accton-as5916-54xks REVISION=r0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/lib/x86-64-accton-as5916-54xks-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/lib/x86-64-accton-as5916-54xks-r0.yml new file mode 100755 index 00000000..70bf17fd --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/lib/x86-64-accton-as5916-54xks-r0.yml @@ -0,0 +1,33 @@ +--- + +###################################################################### +# +# platform-config for AS5916 +# +###################################################################### + +x86-64-accton-as5916-54xks-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-4-14 + + args: >- + nopat + console=ttyS0,115200n8 + tg3.short_preamble=1 + tg3.bcm5718s_reset=1 + + ##network: + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0 diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py new file mode 100755 index 00000000..d723aa4a --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py @@ -0,0 +1,74 @@ +from onl.platform.base import * +from onl.platform.accton import * + +class OnlPlatform_x86_64_accton_as5916_54xks_r0(OnlPlatformAccton, + OnlPlatformPortConfig_48x10_6x40): + PLATFORM='x86-64-accton-as5916-54xks-r0' + MODEL="AS5916-54XKS" + SYS_OBJECT_ID=".5916.54" + + def baseconfig(self): + self.insmod('optoe') + self.insmod("ym2651y") + for m in [ "cpld", "psu", "fan", "leds" ]: + self.insmod("x86-64-accton-as5916-54xks-%s" % m) + + ########### initialize I2C bus 0 ########### + self.new_i2c_devices( + [ + # initialize multiplexer (PCA9548) + ('pca9548', 0x77, 0), + ('pca9548', 0x76, 1), + + # initiate chassis fan + ('as5916_54xks_fan', 0x66, 9), + + # inititate LM75 + ('lm75', 0x48, 10), + ('lm75', 0x49, 10), + ('lm75', 0x4a, 10), + ('lm75', 0x4b, 10), + + # initialize CPLDs + ('as5916_54xks_cpld1', 0x60, 11), + ('as5916_54xks_cpld2', 0x62, 12), + + # initialize multiplexer (PCA9548) + ('pca9548', 0x74, 2), + + # initiate PSU-1 AC Power + ('as5916_54xks_psu1', 0x53, 18), + ('ym2651', 0x5b, 18), + + # initiate PSU-2 AC Power + ('as5916_54xks_psu2', 0x50, 17), + ('ym2651', 0x58, 17), + + # initialize multiplexer (PCA9548) + ('pca9548', 0x72, 2), + ('pca9548', 0x75, 25), + ('pca9548', 0x75, 26), + ('pca9548', 0x75, 27), + ('pca9548', 0x75, 28), + ('pca9548', 0x75, 29), + ('pca9548', 0x75, 30), + ('pca9548', 0x75, 31), + + # initiate IDPROM + ('24c02', 0x56, 0), + ] + ) + + # initialize SFP devices + for port in range(1, 49): + self.new_i2c_device('optoe2', 0x50, port+32) + + # initialize QSFP devices + for port in range(49, 55): + self.new_i2c_device('optoe1', 0x50, port+32) + + for port in range(1, 55): + subprocess.call('echo port%d > /sys/bus/i2c/devices/%d-0050/port_name' % (port, port+32), shell=True) + + return True + From 0dad4b745084fa69ad80d4d7cd065c49cb040121 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Tue, 19 Jun 2018 16:11:20 +0800 Subject: [PATCH 03/32] Add make.mk for build as5916-54xks onlp --- .../onlp/builds/src/.gitignore | 1 - .../onlp/builds/src/module/make.mk | 10 ++++++++++ .../onlp/builds/src/module/src/make.mk | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/make.mk create mode 100755 packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/make.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore index c81d16be..e69de29b 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/.gitignore @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/make.mk new file mode 100755 index 00000000..3f0fcdad --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as5916_54xks_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as5916_54xks_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as5916_54xks_DEPENDMODULE_ENTRIES := init:x86_64_accton_as5916_54xks ucli:x86_64_accton_as5916_54xks + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/make.mk new file mode 100755 index 00000000..7f2a9bbb --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as5916_54xks +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk From 108acea4c88f135a7338fc931ed220029d1f3999 Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Tue, 26 Jun 2018 17:31:55 +0800 Subject: [PATCH 04/32] fixing the issue of wrong color of system LEDs --- .../onlp/builds/src/module/src/ledi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c index c04342a2..1442f9a8 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/ledi.c @@ -67,12 +67,12 @@ static led_mode_info_t led_mode_info[] = { {ONLP_LED_MODE_OFF, 0x0}, {ONLP_LED_MODE_OFF, 0x8}, - {ONLP_LED_MODE_RED, 0x1}, - {ONLP_LED_MODE_RED_BLINKING, 0x9}, + {ONLP_LED_MODE_BLUE, 0x1}, + {ONLP_LED_MODE_BLUE_BLINKING, 0x9}, {ONLP_LED_MODE_GREEN, 0x2}, {ONLP_LED_MODE_GREEN_BLINKING, 0xa}, - {ONLP_LED_MODE_BLUE, 0x4}, - {ONLP_LED_MODE_BLUE_BLINKING, 0xc}, + {ONLP_LED_MODE_RED, 0x4}, + {ONLP_LED_MODE_RED_BLINKING, 0xc}, }; /* From d0cbea51a9d2311b33b947c180df81e19fb7ff4b Mon Sep 17 00:00:00 2001 From: phani-karanam Date: Thu, 28 Jun 2018 16:02:18 +0800 Subject: [PATCH 05/32] Fixed onlp_sfp_eeprom_read shifts QSFP EEPROM data --- .../onlp/builds/src/module/src/sfpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c index 0af7c6f3..eceb8881 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-wedge100bf-65x/onlp/builds/src/module/src/sfpi.c @@ -214,8 +214,8 @@ sfpi_eeprom_read(int port, uint8_t devaddr, uint8_t data[256]) return ONLP_STATUS_E_INTERNAL; } - data[i] = val & 0xff; - data[i+1] = (val >> 8) & 0xff; + data[i*2] = val & 0xff; + data[(i*2)+1] = (val >> 8) & 0xff; } return ONLP_STATUS_OK; From 7e83b99d2e5e74be7520bf92127c42fcb2134743 Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Tue, 3 Jul 2018 09:14:14 +0800 Subject: [PATCH 06/32] [as5916-26xb] Add make.mk to fix the build failure --- .../onlp/builds/src/.gitignore | 2 +- .../onlp/builds/src/module/auto/make.mk | 9 +++++++++ .../onlp/builds/src/module/make.mk | 10 ++++++++++ .../onlp/builds/src/module/src/make.mk | 9 +++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/make.mk diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore index c81d16be..8b137891 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/.gitignore @@ -1 +1 @@ -*.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..9db4a259 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_accton_as5916_54x Autogeneration +# +############################################################################### +x86_64_accton_as5916_54x_AUTO_DEFS := module/auto/x86_64_accton_as5916_54x.yml +x86_64_accton_as5916_54x_AUTO_DIRS := module/inc/x86_64_accton_as5916_54x module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..ea9d2db7 --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_accton_as5916_26xb_INCLUDES := -I $(THIS_DIR)inc +x86_64_accton_as5916_26xb_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_accton_as5916_26xb_DEPENDMODULE_ENTRIES := init:x86_64_accton_as5916_26xb ucli:x86_64_accton_as5916_26xb + diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/make.mk b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..b376dc5b --- /dev/null +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-26xb/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_accton_as5916_26xb +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk From 1629e9eee74d172d0ca815c435977dd3ca8dbe2a Mon Sep 17 00:00:00 2001 From: Ed Swarthout Date: Tue, 3 Jul 2018 15:56:12 -0500 Subject: [PATCH 07/32] arm64-nxp-ls1088ardb use correct dtb Signed-off-by: Ed Swarthout --- .../platform-config/r0/src/lib/arm64-nxp-ls1088ardb-r0.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/nxp/arm64/arm64-nxp-ls1088ardb/platform-config/r0/src/lib/arm64-nxp-ls1088ardb-r0.yml b/packages/platforms/nxp/arm64/arm64-nxp-ls1088ardb/platform-config/r0/src/lib/arm64-nxp-ls1088ardb-r0.yml index bb979181..f200e1c8 100644 --- a/packages/platforms/nxp/arm64/arm64-nxp-ls1088ardb/platform-config/r0/src/lib/arm64-nxp-ls1088ardb-r0.yml +++ b/packages/platforms/nxp/arm64/arm64-nxp-ls1088ardb/platform-config/r0/src/lib/arm64-nxp-ls1088ardb-r0.yml @@ -11,7 +11,7 @@ arm64-nxp-ls1088ardb-r0: kernel: <<: *arm64-kernel dtb: - =: fsl-ls1043a-rdb-sdk.dtb + =: fsl-ls1088a-rdb.dtb <<: *arm64-kernel-package itb: <<: *arm64-itb From 68a34873656ba5468f2708ad336d53fc12c784f4 Mon Sep 17 00:00:00 2001 From: Ed Swarthout Date: Sat, 23 Jun 2018 22:08:17 -0500 Subject: [PATCH 08/32] mmc_bootcmds: mmc part does not take a param Signed-off-by: Ed Swarthout --- .../src/lib/platform-config-defaults-uboot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml index e187cbe3..25887edd 100644 --- a/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml +++ b/packages/base/all/vendor-config-onl/src/lib/platform-config-defaults-uboot.yml @@ -132,7 +132,7 @@ default: - "bootm $onl_loadaddr#$onl_platform" mmc_bootcmds: &mmc_bootcmds - - mmc part 0 + - mmc part - ext2load mmc 0:1 $onl_loadaddr $onl_itb - "bootm $onl_loadaddr#$onl_platform" From 0bd13c1ee4b6d7d3df5ac732804c67e9a2d91053 Mon Sep 17 00:00:00 2001 From: "shaohua.xiong" Date: Thu, 5 Jul 2018 09:33:23 +0800 Subject: [PATCH 09/32] support the ag7648c platform --- .../x86-64/x86-64-delta-ag7648c/Makefile | 1 + .../x86-64-delta-ag7648c/modules/Makefile | 1 + .../x86-64-delta-ag7648c/modules/PKG.yml | 1 + .../modules/builds/.gitignore | 1 + .../modules/builds/Makefile | 6 + .../builds/x86-64-delta-ag7648c-cpld-mux.c | 315 ++++++++++ .../x86-64/x86-64-delta-ag7648c/onlp/Makefile | 1 + .../x86-64/x86-64-delta-ag7648c/onlp/PKG.yml | 1 + .../x86-64-delta-ag7648c/onlp/builds/Makefile | 2 + .../onlp/builds/lib/Makefile | 45 ++ .../lib/libonlp-x86-64-delta-ag7648c.mk | 10 + .../onlp/builds/onlpdump/Makefile | 46 ++ .../onlp/builds/onlpdump/onlpdump.mk | 10 + .../onlp/builds/src/.module | 1 + .../onlp/builds/src/Makefile | 9 + .../onlp/builds/src/README | 6 + .../onlp/builds/src/module/auto/make.mk | 9 + .../src/module/auto/x86_64_delta_ag7648c.yml | 50 ++ .../x86_64_delta_ag7648c.x | 14 + .../x86_64_delta_ag7648c_config.h | 137 ++++ .../x86_64_delta_ag7648c_dox.h | 26 + .../x86_64_delta_ag7648c_porting.h | 107 ++++ .../onlp/builds/src/module/make.mk | 10 + .../onlp/builds/src/module/src/Makefile | 9 + .../onlp/builds/src/module/src/debug.c | 44 ++ .../onlp/builds/src/module/src/eeprom_info.c | 118 ++++ .../onlp/builds/src/module/src/eeprom_info.h | 36 ++ .../onlp/builds/src/module/src/fani.c | 590 ++++++++++++++++++ .../onlp/builds/src/module/src/ledi.c | 443 +++++++++++++ .../onlp/builds/src/module/src/make.mk | 9 + .../onlp/builds/src/module/src/platform_lib.c | 58 ++ .../onlp/builds/src/module/src/platform_lib.h | 141 +++++ .../onlp/builds/src/module/src/psui.c | 344 ++++++++++ .../onlp/builds/src/module/src/sfpi.c | 439 +++++++++++++ .../onlp/builds/src/module/src/sysi.c | 300 +++++++++ .../onlp/builds/src/module/src/thermali.c | 229 +++++++ .../module/src/x86_64_delta_ag7648c_config.c | 81 +++ .../module/src/x86_64_delta_ag7648c_enums.c | 10 + .../src/module/src/x86_64_delta_ag7648c_int.h | 12 + .../src/module/src/x86_64_delta_ag7648c_log.c | 18 + .../src/module/src/x86_64_delta_ag7648c_log.h | 12 + .../module/src/x86_64_delta_ag7648c_module.c | 24 + .../module/src/x86_64_delta_ag7648c_ucli.c | 50 ++ .../builds/src/module/src/x86_64_delta_i2c.c | 148 +++++ .../builds/src/module/src/x86_64_delta_i2c.h | 49 ++ .../onlp/builds/src/x86_64_delta_ag7648c.mk | 13 + .../platform-config/Makefile | 1 + .../platform-config/r0/Makefile | 1 + .../platform-config/r0/PKG.yml | 1 + .../r0/src/lib/x86-64-delta-ag7648c-r0.yml | 32 + .../x86_64_delta_ag7648c_r0/__init__.py | 28 + 51 files changed, 4049 insertions(+) create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml create mode 100755 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml create mode 100644 packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml new file mode 100644 index 00000000..ef383e5a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=delta BASENAME=x86-64-delta-ag7648c ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore new file mode 100644 index 00000000..a65b4177 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/.gitignore @@ -0,0 +1 @@ +lib diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile new file mode 100644 index 00000000..151ad4c1 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/Makefile @@ -0,0 +1,6 @@ +KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 +KMODULES := $(wildcard *.c) +VENDOR := delta +BASENAME := x86-64-delta-ag7648c +ARCH := x86_64 +include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c new file mode 100755 index 00000000..00137d80 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/modules/builds/x86-64-delta-ag7648c-cpld-mux.c @@ -0,0 +1,315 @@ +/* + * An I2C multiplexer dirver for delta ag7648c CPLD + * + * Copyright (C) 2018 Delta Technology Corporation. + * Shaohua Xiong + * + * This module supports the delta cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define CTRL_CPLD_BUS 0x2 +#define CTRL_CPLD_I2C_ADDR 0x32 +#define PARENT_CHAN 0x5 +#define NUM_OF_CPLD_CHANS 0x6 + +#define CPLD_CHANNEL_SELECT_REG 0xa +#define CPLD_CHANNEL_SELECT_MASK 0x3f +#define CPLD_CHANNEL_SELECT_OFFSET 0x0 +#define CPLD_QSFP_INTR_STATUS_REG 0xe +#define CPLD_QSFP_INTR_STATUS_OFFSET 0x0 +#define CPLD_QSFP_RESET_CTRL_REG 0xd +#define CPLD_QSFL_RESET_CTRL_OFFSET 0x0 + +#define CPLD_DESELECT_CHANNEL 0xff + +#define CPLD_MUX_MAX_NCHANS 0x6 +enum cpld_mux_type { + delta_cpld_mux +}; + +struct delta_i2c_cpld_mux { + enum cpld_mux_type type; + struct i2c_adapter *virt_adaps[CPLD_MUX_MAX_NCHANS]; + u8 last_chan; /* last register value */ +}; + +struct chip_desc { + u8 nchans; + u8 deselectChan; +}; + +/* Provide specs for the PCA954x types we know about */ +static const struct chip_desc chips[] = { + [delta_cpld_mux] = { + .nchans = NUM_OF_CPLD_CHANS, + .deselectChan = CPLD_DESELECT_CHANNEL, + } +}; + +static struct delta_i2c_cpld_mux *cpld_mux_data; + +static struct device dump_dev; + +/* Write to mux register. Don't use i2c_transfer()/i2c_smbus_xfer() + for this as they will try to lock adapter a second time */ +static int delta_i2c_cpld_mux_reg_write(struct i2c_adapter *adap, + struct i2c_client *client, u8 val) +{ + unsigned long orig_jiffies; + unsigned short flags; + union i2c_smbus_data data; + struct i2c_adapter *ctrl_adap; + int try,change=0; + s32 res = -EIO; + u8 reg_val = 0; + int intr, reset_ctrl; + int i; + + data.byte = val; + flags = 0; + + ctrl_adap = i2c_get_adapter(CTRL_CPLD_BUS); + if (!ctrl_adap) + return res; + + + // try to lock it + if (ctrl_adap->algo->smbus_xfer) { + /* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; + for (res = 0, try = 0; try <= ctrl_adap->retries; try++) { + // workaround + data.byte = 0; + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + //read the interrupt status + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_INTR_STATUS_REG, + I2C_SMBUS_BYTE_DATA, &data); + if ( res == -EAGAIN) + continue; + + intr = data.byte; + + //read the reset control + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if ( res == -EAGAIN) + continue; + + reset_ctrl = data.byte; + + /* there is an interrupt for QSFP port, including failure/plugin/un-plugin + * try to reset it. + * + */ + for (i = 0 ; i < NUM_OF_CPLD_CHANS; i ++) + { + if((reset_ctrl & ( 1 << i )) == 0){ + change=1; + } + if ((intr & ( 1 << i )) == 0 ) + { + + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_READ, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + data.byte &= ~(1 << i); + + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + change=1; + } + } + if(change){ + msleep(10); + data.byte=CPLD_DESELECT_CHANNEL; + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_QSFP_RESET_CTRL_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res == -EAGAIN) + continue; + msleep(200); + } + + + // read first + //res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + // I2C_SMBUS_READ, CPLD_CHANNEL_SELECT_REG, + // I2C_SMBUS_BYTE_DATA, &data); + //if (res && res != -EAGAIN) + // break; + + // modify the field we wanted + //data.byte &= ~(CPLD_CHANNEL_SELECT_MASK << CPLD_CHANNEL_SELECT_OFFSET); + //reg_val |= (((~(1 << val)) & CPLD_CHANNEL_SELECT_MASK) << CPLD_CHANNEL_SELECT_OFFSET); + data.byte = (~(1 << val)) & 0xff; + + // modify the register + res = ctrl_adap->algo->smbus_xfer(ctrl_adap, CTRL_CPLD_I2C_ADDR, flags, + I2C_SMBUS_WRITE, CPLD_CHANNEL_SELECT_REG, + I2C_SMBUS_BYTE_DATA, &data); + if (res != -EAGAIN) + break; + if (time_after(jiffies, + orig_jiffies + ctrl_adap->timeout)) + break; + } + } + + return res; +} + +static int delta_i2c_cpld_mux_select_chan(struct i2c_adapter *adap, + void *client, u32 chan) +{ + u8 regval; + int ret = 0; + regval = chan; + + /* Only select the channel if its different from the last channel */ + if (cpld_mux_data->last_chan != regval) { + ret = delta_i2c_cpld_mux_reg_write(NULL, NULL, regval); + cpld_mux_data->last_chan = regval; + } + + return ret; +} + +static int delta_i2c_cpld_mux_deselect_mux(struct i2c_adapter *adap, + void *client, u32 chan) +{ + /* Deselect active channel */ + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; + + return delta_i2c_cpld_mux_reg_write(NULL, NULL, cpld_mux_data->last_chan); +} + +/* + * I2C init/probing/exit functions + */ +static int __delta_i2c_cpld_mux_init(void) +{ + struct i2c_adapter *adap = i2c_get_adapter(PARENT_CHAN); + int chan=0; + int ret = -ENODEV; + + memset (&dump_dev, 0, sizeof(dump_dev)); + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto err; + + if (!adap) + goto err; + + cpld_mux_data = kzalloc(sizeof(struct delta_i2c_cpld_mux), GFP_KERNEL); + if (!cpld_mux_data) { + ret = -ENOMEM; + goto err; + } + + cpld_mux_data->type = delta_cpld_mux; + cpld_mux_data->last_chan = chips[cpld_mux_data->type].deselectChan; /* force the first selection */ + + /* Now create an adapter for each channel */ + for (chan = 0; chan < NUM_OF_CPLD_CHANS; chan++) { + cpld_mux_data->virt_adaps[chan] = i2c_add_mux_adapter(adap, &dump_dev, NULL, 0, + chan, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) + 0, +#endif + delta_i2c_cpld_mux_select_chan, + delta_i2c_cpld_mux_deselect_mux); + + if (cpld_mux_data->virt_adaps[chan] == NULL) { + ret = -ENODEV; + printk("failed to register multiplexed adapter %d, parent %d\n", chan, PARENT_CHAN); + goto virt_reg_failed; + } + } + + printk("registered %d multiplexed busses for I2C mux bus %d\n", + chan, PARENT_CHAN); + + return 0; + +virt_reg_failed: + for (chan--; chan >= 0; chan--) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + } + + kfree(cpld_mux_data); +err: + return ret; +} + +static int __delta_i2c_cpld_mux_remove(void) +{ + const struct chip_desc *chip = &chips[cpld_mux_data->type]; + int chan; + + for (chan = 0; chan < chip->nchans; ++chan) { + if (cpld_mux_data->virt_adaps[chan]) { + i2c_del_mux_adapter(cpld_mux_data->virt_adaps[chan]); + cpld_mux_data->virt_adaps[chan] = NULL; + } + } + + kfree(cpld_mux_data); + + return 0; +} + +static int __init delta_i2c_cpld_mux_init(void) +{ + return __delta_i2c_cpld_mux_init (); +} + +static void __exit delta_i2c_cpld_mux_exit(void) +{ + __delta_i2c_cpld_mux_remove (); +} + +MODULE_AUTHOR("Shao Hua "); +MODULE_DESCRIPTION("Delta I2C CPLD mux driver"); +MODULE_LICENSE("GPL"); + +module_init(delta_i2c_cpld_mux_init); +module_exit(delta_i2c_cpld_mux_exit); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml new file mode 100644 index 00000000..85b82886 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-delta-ag7648c ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile new file mode 100644 index 00000000..e7437cb2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/Makefile @@ -0,0 +1,2 @@ +FILTER=src +include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile new file mode 100644 index 00000000..1cfcb406 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/Makefile @@ -0,0 +1,45 @@ +############################################################ +# +# +# 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/config.amd64.mk + +MODULE := libonlp-x86-64-delta-ag7648c +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF x86_64_delta_ag7648c onlplib +DEPENDMODULE_HEADERS := sff + +include $(BUILDER)/dependmodules.mk + +SHAREDLIB := libonlp-x86-64-delta-ag7648c.so +$(SHAREDLIB)_TARGETS := $(ALL_TARGETS) +include $(BUILDER)/so.mk +.DEFAULT_GOAL := $(SHAREDLIB) + +GLOBAL_CFLAGS += -I$(onlp_BASEDIR)/module/inc +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -fPIC +GLOBAL_LINK_LIBS += -lpthread + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk new file mode 100755 index 00000000..bfea1e0b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/lib/libonlp-x86-64-delta-ag7648c.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the libonlp-x86-64-delta-ag7648c module. +# +# Autogenerated 2017-03-20 15:05:28.120004 +# +############################################################################### +libonlp-x86-64-delta-ag7648c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile new file mode 100644 index 00000000..bc539466 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/Makefile @@ -0,0 +1,46 @@ +############################################################ +# +# +# 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/config.amd64.mk + +.DEFAULT_GOAL := onlpdump + +MODULE := onlpdump +include $(BUILDER)/standardinit.mk + +DEPENDMODULES := AIM IOF onlp x86_64_delta_ag7648c onlplib onlp_platform_defaults sff cjson cjson_util timer_wheel OS + +include $(BUILDER)/dependmodules.mk + +BINARY := onlpdump +$(BINARY)_LIBRARIES := $(LIBRARY_TARGETS) +include $(BUILDER)/bin.mk + +GLOBAL_CFLAGS += -DAIM_CONFIG_AIM_MAIN_FUNCTION=onlpdump_main +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 +GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 +GLOBAL_LINK_LIBS += -lpthread -lm + +include $(BUILDER)/targets.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk new file mode 100644 index 00000000..1a687b68 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/onlpdump/onlpdump.mk @@ -0,0 +1,10 @@ + +############################################################################### +# +# Inclusive Makefile for the onlpdump module. +# +# Autogenerated 2018-02-27 06:23:08.553582 +# +############################################################################### +onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module new file mode 100644 index 00000000..aee4b16a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/.module @@ -0,0 +1 @@ +name: x86_64_delta_ag7648c diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile new file mode 100644 index 00000000..5722a637 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### +include ../../init.mk +MODULE := x86_64_delta_ag7648c +AUTOMODULE := x86_64_delta_ag7648c +include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README new file mode 100644 index 00000000..b0f9c718 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/README @@ -0,0 +1,6 @@ +############################################################################### +# +# x86_64_delta_ag7648c README +# +############################################################################### + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk new file mode 100644 index 00000000..e903383a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# x86_64_delta_ag7648c Autogeneration +# +############################################################################### +x86_64_delta_ag7648c_AUTO_DEFS := module/auto/x86_64_delta_ag7648c.yml +x86_64_delta_ag7648c_AUTO_DIRS := module/inc/x86_64_delta_ag7648c module/src +include $(BUILDER)/auto.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml new file mode 100755 index 00000000..b2beca64 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/auto/x86_64_delta_ag7648c.yml @@ -0,0 +1,50 @@ +############################################################################### +# +# x86_64_delta_ag7648c Autogeneration Definitions. +# +############################################################################### + +cdefs: &cdefs +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING: + doc: "Include or exclude logging." + default: 1 +- X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT: + doc: "Default enabled log options." + default: AIM_LOG_OPTIONS_DEFAULT +- X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT: + doc: "Default enabled log bits." + default: AIM_LOG_BITS_DEFAULT +- X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT: + doc: "Default enabled custom log bits." + default: 0 +- X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB: + doc: "Default all porting macros to use the C standard libraries." + default: 1 +- X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: + doc: "Include standard library headers for stdlib porting macros." + default: X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI: + doc: "Include generic uCli support." + default: 0 +- X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: + doc: "Assume chassis fan direction is the same as the PSU fan direction." + default: 0 + + +definitions: + cdefs: + X86_64_DELTA_AG7648C_CONFIG_HEADER: + defs: *cdefs + basename: x86_64_delta_ag7648c_config + + portingmacro: + x86_64_delta_ag7648c: + macros: + - malloc + - free + - memset + - memcpy + - strncpy + - vsnprintf + - snprintf + - strlen diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x new file mode 100755 index 00000000..6f87e11b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c.x @@ -0,0 +1,14 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.xmacro(ALL).define> */ +/* */ + +/* <--auto.start.xenum(ALL).define> */ +/* */ + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h new file mode 100755 index 00000000..78b58be0 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_config.h @@ -0,0 +1,137 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag7648c Configuration Header + * + * @addtogroup x86_64_delta_ag7648c-config + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_CONFIG_H__ +#define __X86_64_DELTA_AG7648C_CONFIG_H__ + +#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG +#include +#endif +#ifdef X86_64_DELTA_AG7648C_INCLUDE_CUSTOM_CONFIG +#include +#endif + +/* */ +#include +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING + * + * Include or exclude logging. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING 1 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT + * + * Default enabled log options. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT + * + * Default enabled log bits. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + * + * Default enabled custom log bits. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT +#define X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB + * + * Default all porting macros to use the C standard libraries. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +#define X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB 1 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + * + * Include standard library headers for stdlib porting macros. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS +#define X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI + * + * Include generic uCli support. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI 0 +#endif + +/** + * X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + * + * Assume chassis fan direction is the same as the PSU fan direction. */ + + +#ifndef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION +#define X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 +#endif + + + +/** + * All compile time options can be queried or displayed + */ + +/** Configuration settings structure. */ +typedef struct x86_64_delta_ag7648c_config_settings_s { + /** name */ + const char* name; + /** value */ + const char* value; +} x86_64_delta_ag7648c_config_settings_t; + +/** Configuration settings table. */ +/** x86_64_delta_ag7648c_config_settings table. */ +extern x86_64_delta_ag7648c_config_settings_t x86_64_delta_ag7648c_config_settings[]; + +/** + * @brief Lookup a configuration setting. + * @param setting The name of the configuration option to lookup. + */ +const char* x86_64_delta_ag7648c_config_lookup(const char* setting); + +/** + * @brief Show the compile-time configuration. + * @param pvs The output stream. + */ +int x86_64_delta_ag7648c_config_show(struct aim_pvs_s* pvs); + +/* */ + +#include "x86_64_delta_ag7648c_porting.h" + +#endif /* __X86_64_DELTA_AG7648C_CONFIG_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h new file mode 100755 index 00000000..e2b308bf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_dox.h @@ -0,0 +1,26 @@ +/**************************************************************************//** + * + * x86_64_delta_ag7648c Doxygen Header + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_DOX_H__ +#define __X86_64_DELTA_AG7648C_DOX_H__ + +/** + * @defgroup x86_64_delta_ag7648c x86_64_delta_ag7648c - x86_64_delta_ag7648c Description + * + +The documentation overview for this module should go here. + + * + * @{ + * + * @defgroup x86_64_delta_ag7648c-x86_64_delta_ag7648c Public Interface + * @defgroup x86_64_delta_ag7648c-config Compile Time Configuration + * @defgroup x86_64_delta_ag7648c-porting Porting Macros + * + * @} + * + */ + +#endif /* __X86_64_DELTA_AG7648C_DOX_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h new file mode 100755 index 00000000..c47d5e94 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/inc/x86_64_delta_ag7648c/x86_64_delta_ag7648c_porting.h @@ -0,0 +1,107 @@ +/**************************************************************************//** + * + * @file + * @brief x86_64_delta_ag7648c Porting Macros. + * + * @addtogroup x86_64_delta_ag7648c-porting + * @{ + * + *****************************************************************************/ +#ifndef __X86_64_DELTA_AG7648C_PORTING_H__ +#define __X86_64_DELTA_AG7648C_PORTING_H__ + + +/* */ +#if X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 +#include +#include +#include +#include +#include +#endif + +#ifndef x86_64_delta_ag7648c_MALLOC + #if defined(GLOBAL_MALLOC) + #define x86_64_delta_ag7648c_MALLOC GLOBAL_MALLOC + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MALLOC malloc + #else + #error The macro x86_64_delta_ag7648c_MALLOC is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_FREE + #if defined(GLOBAL_FREE) + #define x86_64_delta_ag7648c_FREE GLOBAL_FREE + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_FREE free + #else + #error The macro x86_64_delta_ag7648c_FREE is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_MEMSET + #if defined(GLOBAL_MEMSET) + #define x86_64_delta_ag7648c_MEMSET GLOBAL_MEMSET + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MEMSET memset + #else + #error The macro x86_64_delta_ag7648c_MEMSET is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_MEMCPY + #if defined(GLOBAL_MEMCPY) + #define x86_64_delta_ag7648c_MEMCPY GLOBAL_MEMCPY + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_MEMCPY memcpy + #else + #error The macro x86_64_delta_ag7648c_MEMCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_STRNCPY + #if defined(GLOBAL_STRNCPY) + #define x86_64_delta_ag7648c_STRNCPY GLOBAL_STRNCPY + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_STRNCPY strncpy + #else + #error The macro x86_64_delta_ag7648c_STRNCPY is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_VSNPRINTF + #if defined(GLOBAL_VSNPRINTF) + #define x86_64_delta_ag7648c_VSNPRINTF GLOBAL_VSNPRINTF + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_VSNPRINTF vsnprintf + #else + #error The macro x86_64_delta_ag7648c_VSNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_SNPRINTF + #if defined(GLOBAL_SNPRINTF) + #define x86_64_delta_ag7648c_SNPRINTF GLOBAL_SNPRINTF + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_SNPRINTF snprintf + #else + #error The macro x86_64_delta_ag7648c_SNPRINTF is required but cannot be defined. + #endif +#endif + +#ifndef x86_64_delta_ag7648c_STRLEN + #if defined(GLOBAL_STRLEN) + #define x86_64_delta_ag7648c_STRLEN GLOBAL_STRLEN + #elif X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB == 1 + #define x86_64_delta_ag7648c_STRLEN strlen + #else + #error The macro x86_64_delta_ag7648c_STRLEN is required but cannot be defined. + #endif +#endif + +/* */ + + +#endif /* __X86_64_DELTA_AG7648C_PORTING_H__ */ +/* @} */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk new file mode 100644 index 00000000..7c39db80 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/make.mk @@ -0,0 +1,10 @@ +############################################################################### +# +# +# +############################################################################### +THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +x86_64_delta_ag7648c_INCLUDES := -I $(THIS_DIR)inc +x86_64_delta_ag7648c_INTERNAL_INCLUDES := -I $(THIS_DIR)src +x86_64_delta_ag7648c_DEPENDMODULE_ENTRIES := init:x86_64_delta_ag7648c ucli:x86_64_delta_ag7648c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile new file mode 100644 index 00000000..845b434b --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/Makefile @@ -0,0 +1,9 @@ +############################################################################### +# +# Local source generation targets. +# +############################################################################### + +ucli: + @../../../../tools/uclihandlers.py x86_64_delta_ag7648c_ucli.c + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c new file mode 100755 index 00000000..8c7d2a94 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/debug.c @@ -0,0 +1,44 @@ + +#if X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEBUG == 1 + +#include + +static char help__[] = + "Usage: debug [options]\n" + " -c CPLD Versions\n" + " -h Help\n" + ; + +int +x86_64_delta_ag7648c_debug_main(int argc, char* argv[]) +{ + int c = 0; + int help = 0; + int rv = 0; + + while( (c = getopt(argc, argv, "ch")) != -1) { + switch(c) + { + case 'c': c = 1; break; + case 'h': help = 1; rv = 0; break; + default: help = 1; rv = 1; break; + } + + } + + if(help || argc == 1) { + printf("%s", help__); + return rv; + } + + if(c) { + printf("Not implemented.\n"); + } + + + return 0; +} + +#endif + + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c new file mode 100755 index 00000000..ffec5ee6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.c @@ -0,0 +1,118 @@ + +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include "eeprom_info.h" +#include + +#define PSU_MODEL_LEN 11 +#define PSU_SERIES_LEN 14 + +/* + function: + search the eeprom with the key + variables: + eeprom: the eeprom data; + key : the searching key string + mode : 1 means model search, 0 means series search + return: + success, return index which points to the finding string + failed, return -1 +*/ + +int eeprom_info_find(char *eeprom, int len, const char *key,int mode) +{ + int index=0; + int found=0; + int key_len=0; + if(!eeprom || !key) + return -1; + + key_len=strlen(key); + + while(index < len-key_len){ + if (!strncmp(&eeprom[index], key, key_len)){ + found=1; + break; + } + index++; + } + if(found){ + /*mode is 1 means the model search and mode is 0 means the series search*/ + if((mode == 1) && (index < len-PSU_MODEL_LEN)) + return index; + else if ((mode == 0) && (index < len-PSU_SERIES_LEN)) + return index; + else + return -1; + } + + return -1; + +} + +int eeprom_info_get(uint8_t *eeprom, int len, char *type, char *v) +{ + const char psu_model_key[]="DPS"; + const char psu_460_series_key[]="DZRD"; + const char psu_550_series_key[]="GVVD"; + int index=0; + char model[PSU_MODEL_LEN+1]={'\0'}; + char * eep=NULL; + if(!eeprom || !type ||!v) + return -1; + eep=(char *)eeprom; + /*fan eeprom is not now*/ + if((strcmp(type, "fan_model")==0) ||(strcmp(type,"fan_series"))==0) + return 0; + /*first get the psu tpye*/ + index = eeprom_info_find(eep,len,psu_model_key,1); + if(index <0) + return -1; + strncpy(model,&eep[index],PSU_MODEL_LEN); + + if((strcmp(type,"psu_model"))==0){ + strncpy(v,model,PSU_MODEL_LEN); + } + else if ((strcmp(type,"psu_series"))==0){ + if(strstr(model,"460")){ + index = eeprom_info_find(eep,len,psu_460_series_key,0); + if(index <0) + return -1; + strncpy(v,&eep[index],PSU_SERIES_LEN); + } + else if(strstr(model,"550")){ + index = eeprom_info_find(eep,len,psu_550_series_key,0); + if(index <0) + return -1; + strncpy(v,&eep[index],PSU_SERIES_LEN); + } + } + else{ + return -1; + } + return 0; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h new file mode 100755 index 00000000..8a370f6f --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/eeprom_info.h @@ -0,0 +1,36 @@ + +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2017 (C) Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ + +#ifndef __EEPROM_INFO__ +#define __EEPROM_INFO__ + +#include "onlp/onlp_config.h" + +extern int eeprom_info_get(uint8_t *eeprom, int len, char *type, char *v); + +#endif // __EEPROM_INFO__ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c new file mode 100755 index 00000000..84c47bb7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/fani.c @@ -0,0 +1,590 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Fan Platform Implementation Defaults. + * + ***********************************************************/ +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" + + +#define MAX_FAN_SPEED 19000 +#define MAX_PSU_FAN_SPEED 18000 + +#define FILE_NAME_LEN 80 + +#define CPLD_FAN_NAME "MASTERCPLD" + +#define CPLD_FAN_TRAY0_PRESENT_REG (0x8) +#define CPLD_FAN_TRAY0_PRESENT_REG_OFFSET (0x6) +#define CPLD_FAN_TRAY1_PRESENT_REG (0x8) +#define CPLD_FAN_TRAY1_PRESENT_REG_OFFSET (0x7) +#define CPLD_FAN_TRAY2_PRESENT_REG (0x9) +#define CPLD_FAN_TRAY2_PRESENT_REG_OFFSET (0x0) + + +/* The MAX6620 registers, valid channel numbers: 0, 1 */ +#define MAX6639_REG_STATUS 0x02 +#define MAX6639_REG_FAN_CONFIG1(ch) (0x10 + 4*(ch-1)) +#define MAX6639_REG_FAN_CNT(ch) (0x20 + (ch-1)) +#define MAX6639_REG_TARGET_CNT(ch) (0x22 + (ch-1)) + +/*define the reg bit mask*/ +#define MAX6639_REG_FAN_STATUS_BIT(ch) (0X02>>(ch-1)) +#define MAX6639_FAN_CONFIG1_RPM_RANGE 0x03 +#define MAX6639_FAN_PRESENT_REG (0x0c) +#define MAX6639_FAN_PRESENT_BIT (0x2) +#define MAX6639_FAN_GOOD_BIT (0x1) +#define FAN_FROM_REG(d1, d2) \ + { \ + int tech = (d1 << 3) | ((d2 >> 5) & 0x07);\ + rpm = (491520 * 4) / (2 * tech);\ + } + +#define FAN_TO_REG(rpm) \ +{ \ + float ftech; \ + uint32_t tech; \ + ftech = (491520.0 * 4)/ (2.0 * rpm); \ + ftech = ftech + 0.3; \ + tech = (uint32_t) ftech; \ + d1 = (uint8_t)(tech >> 3); \ + d2 = (uint8_t)((tech << 5) & 0xe0);\ +} +static int fan_initd=0; + +enum onlp_fan_id +{ + FAN_RESERVED = 0, + FAN_1_ON_MAIN_BOARD, /*fan tray 0*/ + FAN_2_ON_MAIN_BOARD, /*fan tray 0*/ + FAN_3_ON_MAIN_BOARD, /*fan tray 1*/ + FAN_4_ON_MAIN_BOARD, /*fan tray 1*/ + FAN_5_ON_MAIN_BOARD, /*fan tray 2*/ + FAN_6_ON_MAIN_BOARD, /*fan tray 2*/ + FAN_1_ON_PSU1, + FAN_1_ON_PSU2 +}; + +enum onlp_fan_tray_id +{ + FAN_TRAY_0 = 0, + FAN_TRAY_1 = 1, + FAN_TRAY_2 = 2 +}; + +#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0 }, \ + ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_SET_PERCENTAGE |ONLP_FAN_CAPS_SET_RPM| ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id, fan_id) \ + { \ + { ONLP_FAN_ID_CREATE(FAN_##fan_id##_ON_PSU##psu_id), "Chassis PSU-"#psu_id " Fan "#fan_id, 0 }, \ + ONLP_FAN_STATUS_F2B | ONLP_FAN_STATUS_PRESENT, \ + (ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ + 0, \ + 0, \ + ONLP_FAN_MODE_INVALID, \ + } + +/* Static fan information */ +onlp_fan_info_t linfo[] = { + { }, /* Not used */ + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(1), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(2), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(3), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(4), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(5), + MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(6), + MAKE_FAN_INFO_NODE_ON_PSU(1,1), + MAKE_FAN_INFO_NODE_ON_PSU(2,1), +}; + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_FAN(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +static int +_onlp_get_fan_tray(int fanId) +{ + int tray_id; + if((fanId==5) || (fanId==6)) + tray_id=0; + else if((fanId==3) || (fanId==4)) + tray_id=1; + else + tray_id=2; + return tray_id; +} +#if 1 +static int + _onlp_psu_fan_val_to_rpm (int v) +{ + int lf = (v & 0xffff); + int y, n; + + y = lf & 0x7ff; + n = ((lf >> 11) & 0x1f); + + return (y * (1 << n)); +} +#endif + +static int +_onlp_fan_board_init(void) +{ + int i = 0; + int d1,d2; + int rpm = 8000; + i2c_devname_write_byte("FANCTRL1", 0x00,0x10); + i2c_devname_write_byte("FANCTRL2", 0x00,0x10); + + i2c_devname_write_byte("FANCTRL1", 0x01,0x00); + i2c_devname_write_byte("FANCTRL2", 0x01,0x00); + + for (i = FAN_1_ON_MAIN_BOARD; i <= FAN_4_ON_MAIN_BOARD; i ++) + { + int offset = i - FAN_1_ON_MAIN_BOARD; + + i2c_devname_write_byte("FANCTRL2", 0x02 + offset ,0xc0); + + FAN_TO_REG(rpm); + + i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * offset, d1); + i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * offset, d2); + + } + for (i = FAN_5_ON_MAIN_BOARD; i <= FAN_6_ON_MAIN_BOARD; i ++) + { + int offset = i - FAN_5_ON_MAIN_BOARD; + + i2c_devname_write_byte("FANCTRL1", 0x02 + offset ,0xc0); + + FAN_TO_REG(rpm); + + i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * offset, d1); + i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * offset, d2); + } + + fan_initd=1; + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info) +{ + int r_data, fan_present; + int fan_tray = 0; + int reg, offset; + int d1, d2; + int rpm; + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray == 0) + { + reg = CPLD_FAN_TRAY0_PRESENT_REG; + offset = CPLD_FAN_TRAY0_PRESENT_REG_OFFSET; + }else if (fan_tray == 1) + { + reg = CPLD_FAN_TRAY1_PRESENT_REG; + offset = CPLD_FAN_TRAY1_PRESENT_REG_OFFSET; + }else if (fan_tray == 2) + { + reg = CPLD_FAN_TRAY2_PRESENT_REG; + offset = CPLD_FAN_TRAY2_PRESENT_REG_OFFSET; + }else + { + return ONLP_STATUS_E_INVALID; + } + + /* get fan fault status (turn on when any one fails)*/ + r_data = i2c_devname_read_byte(CPLD_FAN_NAME, reg); + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_present = (r_data >> offset ) & 0x1; + + if(!fan_present){ + + info->status |= (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_F2B); + + if (fan_tray == 0) + { + d1 = i2c_devname_read_byte("FANCTRL1", 0x10 + 2 * (local_id - FAN_5_ON_MAIN_BOARD)); + d2 = i2c_devname_read_byte("FANCTRL1", 0x11 + 2 * (local_id - FAN_5_ON_MAIN_BOARD)); + }else + { + d1 = i2c_devname_read_byte("FANCTRL2", 0x10 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) ); + d2 = i2c_devname_read_byte("FANCTRL2", 0x11 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) ); + } + + if (d1 < 0 || d2 < 0) + { + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_E_INVALID; + } + + } + else{ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_E_UNSUPPORTED; + } + DEBUG_PRINT("d1 %d, d2 %d\r\n", d1, d2); + + FAN_FROM_REG(d1,d2); + + info->rpm = rpm; + + DEBUG_PRINT("rpm %d\r\n", rpm); + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_FAN_SPEED; + + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{ } + + return ONLP_STATUS_OK; +} + +static int +_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info) +{ + + int psu_id; + int r_data,fan_rpm; + int psu_present,psu_good; + enum ag7648c_product_id pid; + + /* get fan fault status*/ + psu_id = (local_id - FAN_1_ON_PSU1) + 1; + DEBUG_PRINT("[Debug][%s][%d][psu_id: %d]\n", __FUNCTION__, __LINE__, psu_id); + + //if the psu is not present, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + if(psu_present != 1){ + info->status &= ~ONLP_FAN_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_FAN_STATUS_PRESENT; + /*if the psu power failed , directly to return*/ + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_FAN_STATUS_FAILED; + return ONLP_STATUS_OK; + } + info->status &= ~ONLP_FAN_STATUS_FAILED; + + /* get fan speed*/ + pid=get_product_id(); + if(pid == PID_AG7648C){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x90); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x90); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + + if(r_data<0) + return ONLP_STATUS_E_INVALID; + + fan_rpm=_onlp_psu_fan_val_to_rpm(r_data); + + info->rpm = fan_rpm; + + /* get speed percentage from rpm */ + info->percentage = (info->rpm * 100.0) / MAX_PSU_FAN_SPEED; + + if(info->percentage>100) + strcpy(info->model,"ONLP_FAN_MODE_LAST"); + else if(info->percentage==100) + strcpy(info->model,"ONLP_FAN_MODE_MAX"); + else if(info->percentage>=75&&info->percentage<100) + strcpy(info->model,"ONLP_FAN_MODE_FAST"); + else if(info->percentage>=35&&info->percentage<75) + strcpy(info->model,"ONLP_FAN_MODE_NORMAL"); + else if(info->percentage>0&&info->percentage<35) + strcpy(info->model,"ONLP_FAN_MODE_SLOW"); + else if(info->percentage<=0) + strcpy(info->model,"ONLP_FAN_MODE_OFF"); + else{} + return ONLP_STATUS_OK; +} + +/* + * This function will be called prior to all of onlp_fani_* functions. + */ +int +onlp_fani_init(void) +{ + int rc; + rc=_onlp_fan_board_init(); + return rc; +} + +int +onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) +{ + int rc = 0; + int local_id; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + if (chassis_fan_count() == 0) { + local_id += 1; + } + + *info = linfo[local_id]; + + switch (local_id) + { + case FAN_1_ON_PSU1: + case FAN_1_ON_PSU2: + rc = _onlp_fani_info_get_fan_on_psu(local_id, info); + break; + case FAN_1_ON_MAIN_BOARD: + case FAN_2_ON_MAIN_BOARD: + case FAN_3_ON_MAIN_BOARD: + case FAN_4_ON_MAIN_BOARD: + case FAN_5_ON_MAIN_BOARD: + case FAN_6_ON_MAIN_BOARD: + rc =_onlp_fani_info_get_fan(local_id, info); + break; + default: + rc = ONLP_STATUS_E_INVALID; + break; + } + + return rc; +} + +/* + * This function sets the speed of the given fan in RPM. + * + * This function will only be called if the fan supprots the RPM_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_rpm_set(onlp_oid_t id, int rpm) +{ /* + the rpm is the actual rpm/1000. so 16 represents the 16000(max spd) + */ + int rc1, rc2; + int local_id; + int d1, d2; + int fan_tray; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + DEBUG_PRINT("local id %d, rpm %d\n", local_id, rpm); + + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject rpm=0 (rpm=0, stop fan) */ + if (rpm == 0) + return ONLP_STATUS_E_INVALID; + + + /*get ret value for the speed set*/ + FAN_TO_REG(rpm); + DEBUG_PRINT("local id %d, rpm %d(d1: %d, d2: %d)\n", local_id, rpm, d1, d2); + + /*set the rpm speed */ + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray < 0 || fan_tray > 2) + return ONLP_STATUS_E_INVALID; + + if (fan_tray == 0) + { + rc1 = i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d2); + }else + { + rc1 = i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * (local_id - FAN_1_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * (local_id - FAN_1_ON_MAIN_BOARD), d2); + } + + if (rc1 < 0 || rc2 < 0) + { + return ONLP_STATUS_E_INVALID; + } + + + return ONLP_STATUS_OK; +} +/*set the percentage for the psu fan*/ + + +/* + * This function sets the fan speed of the given OID as a percentage. + * + * This will only be called if the OID has the PERCENTAGE_SET + * capability. + * + * It is optional if you have no fans at all with this feature. + */ +int +onlp_fani_percentage_set(onlp_oid_t id, int p) +{ + /* + p is between 0 and 100 ,p=100 represents 16000(max spd) + */ + int rpm_val; + int local_id; + int d1, d2; + int rc1, rc2; + int fan_tray; + + VALIDATE(id); + + local_id = ONLP_OID_ID_GET(id); + + DEBUG_PRINT("local_id %d, percentage %d", local_id, p); + if((local_id==FAN_1_ON_PSU1)||(local_id==FAN_1_ON_PSU2)) + return ONLP_STATUS_E_UNSUPPORTED; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_INVALID; + } + + /* init the fan on the board*/ + if(fan_initd==0) + _onlp_fan_board_init(); + + /* reject p=0 (p=0, stop fan) */ + if (p == 0){ + return ONLP_STATUS_E_INVALID; + } + + rpm_val=p* MAX_FAN_SPEED/100; + + + /*get ret value for the speed set*/ + FAN_TO_REG(rpm_val); + + DEBUG_PRINT("local_id %d, p %d, rpm_val %d(d1:%d, d2:%d)", local_id, p, rpm_val, d1, d2); + /*set the rpm speed */ + fan_tray = _onlp_get_fan_tray(local_id); + if (fan_tray < 0 || fan_tray > 2) + return ONLP_STATUS_E_INVALID; + + if (fan_tray == 0) + { + rc1 = i2c_devname_write_byte("FANCTRL1", 0x20 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d1); + rc2 = i2c_devname_write_byte("FANCTRL1", 0x21 + 2 * (local_id - FAN_5_ON_MAIN_BOARD), d2); + }else + { + rc1 = i2c_devname_write_byte("FANCTRL2", 0x20 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) , d1); + rc2 = i2c_devname_write_byte("FANCTRL2", 0x21 + 2 * (local_id - FAN_1_ON_MAIN_BOARD) , d2); + } + + if (rc1 < 0 || rc2 < 0) + { + return ONLP_STATUS_E_INVALID; + } + + return ONLP_STATUS_OK; + + +} + + +/* + * This function sets the fan speed of the given OID as per + * the predefined ONLP fan speed modes: off, slow, normal, fast, max. + * + * Interpretation of these modes is up to the platform. + * + */ +int +onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * This function sets the fan direction of the given OID. + * + * This function is only relevant if the fan OID supports both direction + * capabilities. + * + * This function is optional unless the functionality is available. + */ +int +onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +/* + * Generic fan ioctl. Optional. + */ +int +onlp_fani_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c new file mode 100755 index 00000000..888b5ee6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/ledi.c @@ -0,0 +1,443 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include + +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_LED(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + + +#define CPLD_NAME1 "SYSCPLD" +#define CPLD_NAME2 "MASTERCPLD" +#define CPLD_NAME3 "SLAVECPLD" + +#define CPLD_LED_REG_BITS (0X3) //the reg bits + +#define CPLD_LED_FAN_TRAY_REG (0X8) +#define CPLD_LED_FAN_TRAY0_REG_OFFSET (0X0) +#define CPLD_LED_FAN_TRAY1_REG_OFFSET (0X2) +#define CPLD_LED_FAN_TRAY2_REG_OFFSET (0X4) + +#define CPLD_LED_POWER_REG (0X7) +#define CPLD_LED_POWER_REG_OFFSET (0X5) + +#define CPLD_LED_SYS_REG (0X7) +#define CPLD_LED_SYS_REG_OFFSET (0X1) +#define CPLD_LED_LOCATOR_REG_OFFSET (0X3) + +#define CPLD_LED_FAN_REG (0X9) +#define CPLD_LED_FAN_REG_OFFSET (0X3) + + +/* + * Get the information for the given LED OID. + */ +static onlp_led_info_t linfo[] = +{ + { }, /* Not used */ + { + { ONLP_LED_ID_CREATE(LED_SYS), "sys", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_GREEN_BLINKING |ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW_BLINKING | ONLP_LED_CAPS_YELLOW , + }, + + { + { ONLP_LED_ID_CREATE(LED_FAN), "fan", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_YELLOW_BLINKING | + ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_YELLOW, + }, + + { + { ONLP_LED_ID_CREATE(LED_LOCATOR), "locator", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | + ONLP_LED_CAPS_BLUE_BLINKING , + }, + + { + { ONLP_LED_ID_CREATE(LED_POWER), "power", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW_BLINKING | ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY2), "fan_tray1", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY1), "fan_tray2", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, + { + { ONLP_LED_ID_CREATE(LED_FAN_TRAY0), "fan_tray3", 0 }, + ONLP_LED_STATUS_PRESENT, + ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | + ONLP_LED_CAPS_YELLOW, + }, +}; + +static int conver_led_light_mode_to_onl(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case SYS_LED_MODE_GREEN_BLINKING: return ONLP_LED_MODE_GREEN_BLINKING; + case SYS_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case SYS_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + case SYS_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + default: return ONLP_LED_MODE_GREEN_BLINKING; + } + + case LED_FAN: + switch (led_ligth_mode) { + case FAN_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case FAN_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case FAN_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + case FAN_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_LOCATOR: + switch (led_ligth_mode) { + case LOCATOR_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case LOCATOR_LED_MODE_BLUE: return ONLP_LED_MODE_BLUE; + case LOCATOR_LED_MODE_BLUE_BLINKING: return ONLP_LED_MODE_BLUE_BLINKING; + default: return ONLP_LED_MODE_OFF; + } + case LED_POWER: + switch (led_ligth_mode) { + case POWER_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case POWER_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case POWER_LED_MODE_YELLOW_BLINKING: return ONLP_LED_MODE_YELLOW_BLINKING; + case POWER_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + default: return ONLP_LED_MODE_OFF; + } + case LED_FAN_TRAY0: + case LED_FAN_TRAY1: + case LED_FAN_TRAY2: + switch (led_ligth_mode) { + case FAN_TRAY_LED_MODE_OFF: return ONLP_LED_MODE_OFF; + case FAN_TRAY_LED_MODE_GREEN: return ONLP_LED_MODE_GREEN; + case FAN_TRAY_LED_MODE_YELLOW: return ONLP_LED_MODE_YELLOW; + default: return ONLP_LED_MODE_OFF; + } + } + + return ONLP_LED_MODE_OFF; +} + +static int conver_onlp_led_light_mode_to_driver(uint32_t id, int led_ligth_mode) +{ + switch (id) { + case LED_SYS: + switch (led_ligth_mode) { + case ONLP_LED_MODE_GREEN_BLINKING: return SYS_LED_MODE_GREEN_BLINKING; + case ONLP_LED_MODE_GREEN: return SYS_LED_MODE_GREEN; + case ONLP_LED_MODE_YELLOW: return SYS_LED_MODE_YELLOW ; + case ONLP_LED_MODE_YELLOW_BLINKING: return SYS_LED_MODE_YELLOW_BLINKING; + default: return SYS_LED_MODE_UNKNOWN; + } + + case LED_FAN: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return FAN_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return FAN_LED_MODE_GREEN ; + case ONLP_LED_MODE_YELLOW: return FAN_LED_MODE_YELLOW; + case ONLP_LED_MODE_YELLOW_BLINKING: return FAN_LED_MODE_YELLOW_BLINKING; + default: return FAN_LED_MODE_UNKNOWN; + } + case LED_LOCATOR: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return LOCATOR_LED_MODE_OFF; + case ONLP_LED_MODE_BLUE: return LOCATOR_LED_MODE_BLUE; + case ONLP_LED_MODE_BLUE_BLINKING: return LOCATOR_LED_MODE_BLUE_BLINKING; + default: return LOCATOR_LED_MODE_UNKNOWN; + } + case LED_POWER: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return POWER_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return POWER_LED_MODE_GREEN; + case ONLP_LED_MODE_YELLOW_BLINKING: return POWER_LED_MODE_YELLOW_BLINKING; + case ONLP_LED_MODE_YELLOW: return POWER_LED_MODE_YELLOW; + default: return POWER_LED_MODE_UNKNOWN; + } + case LED_FAN_TRAY0: + case LED_FAN_TRAY1: + case LED_FAN_TRAY2: + switch (led_ligth_mode) { + case ONLP_LED_MODE_OFF: return FAN_TRAY_LED_MODE_OFF; + case ONLP_LED_MODE_GREEN: return FAN_TRAY_LED_MODE_GREEN; + case ONLP_LED_MODE_YELLOW: return FAN_TRAY_LED_MODE_YELLOW; + default: return FAN_TRAY_LED_MODE_UNKNOWN; + } + } + + return 0xff; +} + +/* + * This function will be called prior to any other onlp_ledi_* functions. + */ +int +onlp_ledi_init(void) +{ + return ONLP_STATUS_OK; +} + +static int +onlp_ledi_oid_to_internal_id(onlp_oid_t id) +{ + enum ag7648c_product_id pid = get_product_id(); + int lid = ONLP_OID_ID_GET(id); + + if (pid != PID_AG7648C) { + return lid; + } + + switch (lid) { + case 1: return LED_SYS; + case 2: return LED_FAN; + case 3: return LED_LOCATOR; + case 4: return LED_POWER; + case 5: return LED_FAN_TRAY2; + case 6: return LED_FAN_TRAY1; + case 7: return LED_FAN_TRAY0; + } + + return lid; +} + +int +onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) +{ + int r_data,m_data; + + VALIDATE(id); + int lid = onlp_ledi_oid_to_internal_id(id); + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[lid]; + + DEBUG_PRINT("id %u lid %d\n", id, lid); + + switch (lid) + { + case LED_POWER: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_POWER_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_POWER_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_SYS: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_SYS_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_LOCATOR: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_LOCATOR_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + + case LED_FAN: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY0: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY0_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY1: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY1_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + case LED_FAN_TRAY2: + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + m_data = (r_data >> CPLD_LED_FAN_TRAY2_REG_OFFSET) & CPLD_LED_REG_BITS; + break; + default: + return ONLP_STATUS_E_INTERNAL; + } + + info->mode = conver_led_light_mode_to_onl(lid, m_data); + + /* Set the on/off status */ + if (info->mode != ONLP_LED_MODE_OFF) { + info->status |= ONLP_LED_STATUS_ON; + + } + + return ONLP_STATUS_OK; +} + +/* + * This function puts the LED into the given mode. It is a more functional + * interface for multimode LEDs. + * + * Only modes reported in the LED's capabilities will be attempted. + */ +int +onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) +{ + int r_data,driver_mode, rc; + int reg; + + VALIDATE(id); + int lid = onlp_ledi_oid_to_internal_id(id); + + driver_mode = conver_onlp_led_light_mode_to_driver(lid, mode); + + if((driver_mode==SYS_LED_MODE_UNKNOWN)||(driver_mode==FAN_LED_MODE_UNKNOWN)||(driver_mode==FAN_TRAY_LED_MODE_UNKNOWN) ||\ + (driver_mode==POWER_LED_MODE_UNKNOWN)||(driver_mode==LOCATOR_LED_MODE_UNKNOWN)) + return ONLP_STATUS_E_UNSUPPORTED; + + switch (lid) + { + case LED_POWER: + reg = CPLD_LED_POWER_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_POWER_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_POWER_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_POWER_REG_OFFSET; + break; + case LED_SYS: + reg = CPLD_LED_SYS_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_SYS_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_SYS_REG_OFFSET; + break; + case LED_LOCATOR: + reg = CPLD_LED_SYS_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_SYS_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_LOCATOR_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_LOCATOR_REG_OFFSET; + break; + + case LED_FAN: + reg = CPLD_LED_FAN_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_REG_OFFSET; + break; + case LED_FAN_TRAY0: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY0_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY0_REG_OFFSET; + break; + case LED_FAN_TRAY1: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY1_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY1_REG_OFFSET; + break; + case LED_FAN_TRAY2: + reg = CPLD_LED_FAN_TRAY_REG; + r_data = i2c_devname_read_byte(CPLD_NAME2, CPLD_LED_FAN_TRAY_REG); + if (r_data < 0) + return ONLP_STATUS_E_INTERNAL; + r_data &= ~(CPLD_LED_REG_BITS << CPLD_LED_FAN_TRAY2_REG_OFFSET); + r_data |= (driver_mode & CPLD_LED_REG_BITS ) << CPLD_LED_FAN_TRAY2_REG_OFFSET; + break; + default: + return ONLP_STATUS_E_INTERNAL; + } + + rc=i2c_devname_write_byte(CPLD_NAME2, reg, r_data); + + if(rc<0){ + return ONLP_STATUS_E_INTERNAL; + } + + return ONLP_STATUS_OK; +} + +/* + * Turn an LED on or off. + * + * This function will only be called if the LED OID supports the ONOFF + * capability. + * + * What 'on' means in terms of colors or modes for multimode LEDs is + * up to the platform to decide. This is intended as baseline toggle mechanism. + */ +int +onlp_ledi_set(onlp_oid_t id, int on_or_off) +{ + if (!on_or_off) { + return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); + } + + return ONLP_STATUS_E_UNSUPPORTED; +} + + +/* + * Generic LED ioctl interface. + */ +int +onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk new file mode 100644 index 00000000..b68adf14 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/make.mk @@ -0,0 +1,9 @@ +############################################################################### +# +# +# +############################################################################### + +LIBRARY := x86_64_delta_ag7648c +$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) +include $(BUILDER)/lib.mk diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c new file mode 100755 index 00000000..2a0eb3f7 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.c @@ -0,0 +1,58 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2015 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include "platform_lib.h" + +#define I2C_PSU_MODEL_NAME_LEN 13 + +psu_type_t get_psu_type(int id) +{ + if ((id == PSU1_ID)||(id == PSU2_ID)) + return PSU_TYPE_AC_F2B; + return PSU_TYPE_UNKNOWN; +} + +enum ag7648c_product_id get_product_id(void) +{ + return PID_AG7648C; +} + +int chassis_fan_count(void) +{ + return 8 ; +} + +int chassis_led_count(void) +{ + return 7; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h new file mode 100755 index 00000000..cc376207 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/platform_lib.h @@ -0,0 +1,141 @@ +/************************************************************ + * + * + * Copyright 2014 Big Switch Networks, Inc. + * Copyright 2015 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#ifndef __PLATFORM_LIB_H__ +#define __PLATFORM_LIB_H__ + +#include "x86_64_delta_ag7648c_log.h" + +#define PSU1_ID 1 +#define PSU2_ID 2 + +#define CHASSIS_FAN_COUNT 6 +#define CHASSIS_THERMAL_COUNT 6 +#define CHASSIS_PSU_COUNT 2 + + +typedef enum psu_type { + PSU_TYPE_UNKNOWN, + PSU_TYPE_AC_F2B, + PSU_TYPE_AC_B2F, + PSU_TYPE_DC_48V_F2B, + PSU_TYPE_DC_48V_B2F +} psu_type_t; + + +psu_type_t get_psu_type(int id); + +#define DEBUG_MODE 0 + +#if (DEBUG_MODE == 1) + #define DEBUG_PRINT(format, ...) \ + {\ + printf("[%s:%d] ", __FUNCTION__, __LINE__);\ + printf(format, __VA_ARGS__); \ + } +#else + #define DEBUG_PRINT(format, ...) +#endif + +enum onlp_fan_duty_cycle_percentage +{ + FAN_IDLE_RPM = 7500, + FAN_LEVEL1_RPM = 10000, + FAN_LEVEL2_RPM = 13000, + FAN_LEVEL3_RPM = 16000, + FAN_LEVEL4_RPM = 19000, +}; + +enum ag7648c_product_id { + PID_AG7648C= 2, + PID_UNKNOWN +}; +/* LED related data */ +enum sys_led_light_mode { + SYS_LED_MODE_GREEN_BLINKING = 0, + SYS_LED_MODE_GREEN, + SYS_LED_MODE_YELLOW, + SYS_LED_MODE_YELLOW_BLINKING, + SYS_LED_MODE_UNKNOWN +}; + +enum fan_led_light_mode { + FAN_LED_MODE_OFF = 0, + FAN_LED_MODE_YELLOW, + FAN_LED_MODE_GREEN, + FAN_LED_MODE_YELLOW_BLINKING, + FAN_LED_MODE_UNKNOWN +}; + + +enum locator_led_light_mode { + LOCATOR_LED_MODE_OFF = 0, + LOCATOR_LED_MODE_BLUE_BLINKING, + LOCATOR_LED_MODE_BLUE, + LOCATOR_LED_MODE_RESERVERD, + LOCATOR_LED_MODE_UNKNOWN +}; + +enum power_led_light_mode { + POWER_LED_MODE_OFF = 0, + POWER_LED_MODE_YELLOW, + POWER_LED_MODE_YELLOW_BLINKING, + POWER_LED_MODE_GREEN, + POWER_LED_MODE_UNKNOWN +}; + +enum fan_tray_led_light_mode { + FAN_TRAY_LED_MODE_OFF = 0, + FAN_TRAY_LED_MODE_GREEN, + FAN_TRAY_LED_MODE_YELLOW, + FAN_TRAY_LED_MODE_RESERVERD, + FAN_TRAY_LED_MODE_UNKNOWN +}; + +typedef enum onlp_led_id +{ + LED_RESERVED = 0, + LED_SYS, + LED_FAN, + LED_LOCATOR, + LED_POWER, + LED_FAN_TRAY2, + LED_FAN_TRAY1, + LED_FAN_TRAY0, +} onlp_led_id_t; + +enum ag7648c_product_id get_product_id(void); +int chassis_fan_count(void); +int chassis_led_count(void); + +typedef enum platform_id_e { + PLATFORM_ID_UNKNOWN, + PLATFORM_ID_DELTA_AG7648C_R0, +} platform_id_t; + +extern platform_id_t platform_id; +extern int psu_status_info_get(int id, char *node); +#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c new file mode 100755 index 00000000..4dd63133 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/psui.c @@ -0,0 +1,344 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_i2c.h" +#include "eeprom_info.h" +#define CPLD_PSU_NAME "MASTERCPLD" + +#define PSU_STATUS_PRESENT 1 +#define PSU_STATUS_POWER_GOOD 0 +#define PSU_STATUS_REG (0X03) +#define PSU_STATUS_PRESENT_BIT(ch) (0x8<<4*(ch-1)) +#define PSU_STATUS_GOOD_BIT(ch) (0x4<<4*(ch-1)) +#define PSU_STATUS_PRESENT_OFFSET(ch) (4*ch-1) +#define PSU_STATUS_GOOD_OFFSET(ch) (0x2+4*(ch-1)) +#define PSU_PNBUS_VIN_REG (0x88) +#define PSU_PNBUS_IIN_REG (0x89) +#define PSU_PNBUS_PIN_REG (0x97) +#define PSU_PNBUS_VOUT_REG (0x8b) +#define PSU_PNBUS_IOUT_REG (0x8c) +#define PSU_PNBUS_POUT_REG (0x96) +#define PSU_PNBUS_SERIAL_REG (0x39) +#define PSU_PNBUS_MODEL_REG (0xc) + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_PSU(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) +static long psu_data_convert(unsigned int d, int mult) +{ + long X, Y, N, n; + + Y = d & 0x07FF; + N = (d >> 11) & 0x0f; + n = d & 0x8000 ? 1 : 0; + + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = (Y * mult) * (N=(1<<(N&0xf))); + + return X; +} + +static long psu_data_convert_16(unsigned int d, int mult) +{ + long X; + X = (d * mult) / (1 << 9); + return X; + +} + +int +psu_status_info_get(int id, char *node) +{ + int ret; + char r_data; + ret=i2c_devname_read_byte(CPLD_PSU_NAME,PSU_STATUS_REG); + + if(ret<0) + return -1; + + if (PSU1_ID == id) { + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + + } + else if (PSU2_ID == id) { + + if(!strcmp("present",node)) + r_data=!((ret& PSU_STATUS_PRESENT_BIT(id))>> PSU_STATUS_PRESENT_OFFSET(id)); + else if(!strcmp("good",node)) + r_data=((ret& PSU_STATUS_GOOD_BIT(id))>> PSU_STATUS_GOOD_OFFSET(id)); + else + r_data=-1; + } + else{ + r_data=-1; + } + + return r_data; +} +static int +psu_value_info_get(int id, char *type) +{ + int ret; + char *dev_name; + int reg_offset; + + if(PSU1_ID == id) + dev_name="PSU1_PMBUS"; + else + dev_name="PSU2_PMBUS"; + + if(!strcmp(type,"vin")) + reg_offset=PSU_PNBUS_VIN_REG; + else if(!strcmp(type,"iin")) + reg_offset=PSU_PNBUS_IIN_REG; + else if(!strcmp(type,"pin")) + reg_offset=PSU_PNBUS_PIN_REG; + else if(!strcmp(type,"vout")) + reg_offset=PSU_PNBUS_VOUT_REG; + else if(!strcmp(type,"iout")) + reg_offset=PSU_PNBUS_IOUT_REG; + else + reg_offset=PSU_PNBUS_POUT_REG; + + ret=i2c_devname_read_word(dev_name,reg_offset); + + if(ret<0) + return -1; + + return ret; +} + + +static int +psu_serial_model_info_get(int id,char *type,char*data) +{ + int i,r_data,re_cnt; + uint8_t eeprom[256]={0}; + char *dev_name; + + if(PSU1_ID == id) + dev_name="PSU1_EEPROM"; + else + dev_name="PSU2_EEPROM"; + + for(i=0;istatus &= ~ONLP_PSU_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + info->status |= ONLP_PSU_STATUS_PRESENT; + + /* Get power good status */ + val=psu_status_info_get(index,"good"); + + if (val<0) { + AIM_LOG_INFO("Unable to read PSU %d good value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + if (val != PSU_STATUS_POWER_GOOD) { + info->status |= ONLP_PSU_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + /* Get PSU type + */ + psu_type = get_psu_type(index); + + switch (psu_type) { + case PSU_TYPE_AC_F2B: + case PSU_TYPE_AC_B2F: + info->caps = ONLP_PSU_CAPS_AC; + ret = ONLP_STATUS_OK; + break; + case PSU_TYPE_UNKNOWN: /* User insert a unknown PSU or unplugged.*/ + info->status |= ONLP_PSU_STATUS_UNPLUGGED; + info->status &= ~ONLP_PSU_STATUS_FAILED; + ret = ONLP_STATUS_OK; + break; + default: + ret = ONLP_STATUS_E_UNSUPPORTED; + break; + } + + /* Get PSU vin,vout*/ + + r_data=psu_value_info_get(index,"vin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"vout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Vout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mvout=psu_data_convert_16(r_data,1000); + /* Get PSU iin, iout + */ + r_data=psu_value_info_get(index,"iin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"iout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Iout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->miout=psu_data_convert(r_data,1000); + + /* Get PSU pin, pout + */ + r_data=psu_value_info_get(index,"pin"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pin value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpin=psu_data_convert(r_data,1000); + + r_data=psu_value_info_get(index,"pout"); + + if (r_data<0) { + AIM_LOG_INFO("Unable to read PSU %d Pout value)\r\n", index); + return ONLP_STATUS_E_INVALID; + } + + info->mpout=psu_data_convert(r_data,1000); + /* Get PSU serial + */ + + ret=psu_serial_model_info_get(index,"psu_series",info->serial); + if (ret <0) { + strcpy(info->serial,"Unknown"); + } + + /* Get PSU model + */ + ret=psu_serial_model_info_get(index,"psu_model",info->model); + if (ret <0) { + strcpy(info->model,"Unknown"); + } + + return ONLP_STATUS_OK; +} + +int +onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c new file mode 100755 index 00000000..ae77cc62 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sfpi.c @@ -0,0 +1,439 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include "platform_lib.h" + +#include +#include "x86_64_delta_ag7648c_log.h" +#include "x86_64_delta_i2c.h" + +#define QSFP_MIN_PORT 49 +#define QSFP_MAX_PORT 54 + +#define QSFP_49_54_PRESENT_REG (0xC) +#define QSFP_49_54_LP_MODE_REG (0xB) +#define QSFP_49_54_RESET_REG (0xD) +#define INVALID_REG (0xFF) +#define INVALID_REG_BIT (0xFF) + + +struct portCtrl{ + int portId; + char cpldName[32]; + int presentReg; + int presentRegBit; + int lpModeReg; + int lpModeRegBit; + int resetReg; + int resetRegBit; + +}; + +#define CPLD_NAME1 "SYSCPLD" +#define CPLD_NAME2 "MASTERCPLD" +#define CPLD_NAME3 "SLAVECPLD" + +static struct portCtrl gPortCtrl[] = +{ + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG, 0}, + + {49, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 0, QSFP_49_54_LP_MODE_REG, 1, QSFP_49_54_RESET_REG, 0}, + {50, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 1, QSFP_49_54_LP_MODE_REG, 0, QSFP_49_54_RESET_REG, 1}, + {51, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 2, QSFP_49_54_LP_MODE_REG, 3, QSFP_49_54_RESET_REG, 2}, + {52, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 3, QSFP_49_54_LP_MODE_REG, 2, QSFP_49_54_RESET_REG, 3}, + {53, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 4, QSFP_49_54_LP_MODE_REG, 5, QSFP_49_54_RESET_REG, 4}, + {54, CPLD_NAME2, QSFP_49_54_PRESENT_REG, 5, QSFP_49_54_LP_MODE_REG, 4, QSFP_49_54_RESET_REG, 5}, + + {0xFFFF, "", INVALID_REG, 0, INVALID_REG, 0, INVALID_REG_BIT, 0}, + + +}; + +/************************************************************ + * + * SFPI Entry Points + * + ***********************************************************/ +int +onlp_sfpi_init(void) +{ + /* Called at initialization time */ + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) +{ + int p; + int start_port, end_port; + + if(platform_id == PLATFORM_ID_DELTA_AG7648C_R0) + { + start_port = QSFP_MIN_PORT; + end_port = QSFP_MAX_PORT; + } + else /*reserved*/ + { + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + for(p = start_port; p <=end_port; p++) { + AIM_BITMAP_SET(bmap, p); + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_is_present(int port) +{ + /* + * Return 1 if present. + * Return 0 if not present. + * Return < 0 if error. + */ + int present,r_data; + + if((port >= QSFP_MIN_PORT) && (port <= QSFP_MAX_PORT)){ + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].presentReg); + } + else{ + AIM_LOG_ERROR("The port %d is invalid \r\n", port); + return ONLP_STATUS_E_UNSUPPORTED; + } + + if(r_data<0){ + AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + r_data = (~r_data) & 0xFF; + + present = (r_data >> gPortCtrl[port - 1].presentRegBit) & 0x1; + + return present; +} + +int +onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + int status; + int port, i = 0; + uint64_t presence_all=0; + + AIM_BITMAP_CLR_ALL(dst); + + if(platform_id == PLATFORM_ID_DELTA_AG7648C_R0) + { + port = QSFP_MIN_PORT; + + } + else{ + AIM_LOG_ERROR("The platform id %d is invalid \r\n", platform_id); + return ONLP_STATUS_E_UNSUPPORTED; + } + + /*read 8 ports present status once*/ + for (i = port; i <= QSFP_MAX_PORT;) + { + /* + AIM_LOG_ERROR("port %d, cpldname %s, reg %d\r\n", i, gPortCtrl[i - 1].cpldName, \ + gPortCtrl[i - 1].presentReg); + */ + status = i2c_devname_read_byte(gPortCtrl[i - 1].cpldName, gPortCtrl[i - 1].presentReg); + + if(status<0){ + AIM_LOG_ERROR("Unable to read presence from the port %d to %d value(status %d) \r\n", i, i + 8, status); + return ONLP_STATUS_E_INTERNAL; + } + status = ~(status) & 0xFF; + presence_all |= (uint64_t)(status); + + i += 8; + } + + /* Populate bitmap */ + for(i = port; presence_all; i++) { + AIM_BITMAP_MOD(dst, i, (presence_all & 1)); + presence_all >>= 1; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sfpi_eeprom_read(int port, uint8_t data[256]) +{ + /* + * Read the SFP eeprom into data[] + * + * Return MISSING if SFP is missing. + * Return OK if eeprom is read + */ + + int i;//,r_data,re_cnt; + char sfp_name[32]; + + //int i,re_cnt;uint8_t r_data; + memset(data, 0, 256); + memset(sfp_name, 0x0, sizeof(sfp_name)); + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + if (onlp_sfpi_is_present(port) <= 0) + { + AIM_LOG_WARN("port %d is note present or error\r\n", port); + return ONLP_STATUS_E_MISSING; + } + + sprintf(sfp_name, "QSFP%d", port); + for(i=0;i<8;i++){ + if (i2c_devname_read_block(sfp_name, (32*i), (uint8_t*)(data+32*i), 32) < 0) + { + AIM_LOG_ERROR("Unable to read the port %d eeprom\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + } + + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_dom_read(int port, uint8_t data[256]) +{ + + return onlp_sfpi_eeprom_read( port, data); +} + +int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) +{ + *rv = 0; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch (control) { + case ONLP_SFP_CONTROL_LP_MODE: + *rv = 1; + break; + + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_RESET: + *rv = 1; + break; + default: + break; + } + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int r_data,dis_value,rc; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch(control) + { + case ONLP_SFP_CONTROL_LP_MODE: + { + r_data = i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg); + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp lp mode reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + r_data &= ~(0x1 << gPortCtrl[port - 1].lpModeRegBit); + dis_value = value << gPortCtrl[port - 1].lpModeRegBit; + dis_value |= r_data; + rc = i2c_devname_write_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg, dis_value); + + if (rc<0) { + AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + break; + } + + case ONLP_SFP_CONTROL_RESET: + { + r_data = i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg); + if(r_data<0){ + AIM_LOG_INFO("Unable to read sfp reset reg value\r\n"); + return ONLP_STATUS_E_INTERNAL; + } + + r_data &= ~(0x1 << gPortCtrl[port - 1].resetRegBit); + dis_value = (~value) << gPortCtrl[port - 1].resetRegBit; + dis_value |= r_data; + rc = i2c_devname_write_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg, dis_value); + + if (rc<0) { + AIM_LOG_ERROR("Unable to reset port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + break; + } + + default: + return ONLP_STATUS_E_UNSUPPORTED; + } + + return ONLP_STATUS_OK; +} + +int +onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) +{ + int r_data; + + if (port < QSFP_MIN_PORT || port > QSFP_MAX_PORT) + { + AIM_LOG_ERROR("port %d is not invalid\r\n", port); + return ONLP_STATUS_E_INVALID; + } + if (control > ONLP_SFP_CONTROL_LAST) + return ONLP_STATUS_E_UNSUPPORTED; + + switch(control) + { + case ONLP_SFP_CONTROL_LP_MODE: + { + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].lpModeReg); + + if (r_data<0) { + AIM_LOG_ERROR("Unable to read lp_mode status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + r_data &= (0x1 << gPortCtrl[port - 1].lpModeRegBit); + *value = (r_data >> gPortCtrl[port - 1].lpModeRegBit); + break; + } + + case ONLP_SFP_CONTROL_RESET_STATE: + case ONLP_SFP_CONTROL_RESET: + { + r_data=i2c_devname_read_byte(gPortCtrl[port - 1].cpldName, gPortCtrl[port - 1].resetReg); + + if (r_data<0) { + AIM_LOG_ERROR("Unable to read reset status from port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + r_data = (~r_data) & 0xFF; + *value = (r_data >> gPortCtrl[port - 1].presentRegBit) & 0x1; + break; + } + + default: + return ONLP_STATUS_E_UNSUPPORTED; + } + + + return ONLP_STATUS_OK; +} + + +int +onlp_sfpi_denit(void) +{ + return ONLP_STATUS_OK; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c new file mode 100755 index 00000000..49af2088 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/sysi.c @@ -0,0 +1,300 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "x86_64_delta_ag7648c_int.h" +#include "x86_64_delta_ag7648c_log.h" + +#include "platform_lib.h" +#include "x86_64_delta_i2c.h" +platform_id_t platform_id = PLATFORM_ID_UNKNOWN; + +#define ONIE_PLATFORM_NAME "x86-64-delta-ag7648c-r0" +const char* +onlp_sysi_platform_get(void) +{ + enum ag7648c_product_id pid = get_product_id(); + + if (pid == PID_AG7648C) + return "x86-64-delta-ag7648c"; + else + return "unknow"; +} + +int +onlp_sysi_platform_set(const char* platform) +{ + if(strstr(platform,"x86-64-delta-ag7648c-r0")) { + platform_id = PLATFORM_ID_DELTA_AG7648C_R0; + return ONLP_STATUS_OK; + } + AIM_LOG_ERROR("No support for platform '%s'", platform); + return ONLP_STATUS_E_UNSUPPORTED; +} + +int +onlp_sysi_platform_info_get(onlp_platform_info_t* pi) +{ + int v; + + v = i2c_devname_read_byte("SYSCPLD", 0X0); + + pi->cpld_versions = aim_fstrdup("%d", v & 0xf); + + return 0; +} + +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ + int i,re_cnt; + uint8_t* rdata = aim_zmalloc(256); + if(!rdata){ + AIM_LOG_ERROR("Unable to malloc memory \r\n"); + return ONLP_STATUS_E_INTERNAL; + } + for(i=0;i<8;i++){ + re_cnt=3; + while(re_cnt){ + if (i2c_devname_read_block("ID_EEPROM", i * 32, (rdata + i * 32), 32) < 0) + { + re_cnt--; + continue; + } + break; + } + if(re_cnt==0){ + AIM_LOG_ERROR("Unable to read the %d reg \r\n",i); + break; + } + + } + + *data = rdata; + + return ONLP_STATUS_OK; + + +} + +void +onlp_sysi_onie_data_free(uint8_t* data) +{ + aim_free(data); +} + + + +int +onlp_sysi_oids_get(onlp_oid_t* table, int max) +{ + int i; + onlp_oid_t* e = table; + memset(table, 0, max*sizeof(onlp_oid_t)); + + /* 1 Thermal sensors on the chassis */ + for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { + *e++ = ONLP_THERMAL_ID_CREATE(i); + } + + /* LEDs on the chassis */ + for (i = 1; i <= chassis_led_count(); i++) { + *e++ = ONLP_LED_ID_CREATE(i); + } + + /* 1 Fans on the chassis */ + for (i = 1; i <= chassis_fan_count(); i++) { + *e++ = ONLP_FAN_ID_CREATE(i); + } + + /* 2 PSUs on the chassis */ + for (i = 1; i <= CHASSIS_PSU_COUNT; i++) { + *e++ = ONLP_PSU_ID_CREATE(i); + } + + return 0; +} +int +onlp_sysi_onie_info_get(onlp_onie_info_t* onie) +{ + if(onie){ + onie->platform_name = aim_strdup(ONIE_PLATFORM_NAME); + } + return ONLP_STATUS_OK; +} + + + +int +onlp_sysi_platform_manage_fans(void) +{ + + int rc; + onlp_thermal_info_t ti2, ti3, ti4; + int mtemp=0; + int new_rpm=0; + + if (chassis_fan_count() == 0) { + return ONLP_STATUS_E_UNSUPPORTED; + } + + /* Get temperature */ + /*rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(1), &ti1); + + if (rc != ONLP_STATUS_OK) { + return rc; + }*/ + + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(2), &ti2); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(3), &ti3); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + rc = onlp_thermal_info_get(ONLP_THERMAL_ID_CREATE(4), &ti4); + + if (rc != ONLP_STATUS_OK) { + return rc; + } + + mtemp=(ti2.mcelsius+ti3.mcelsius + ti4.mcelsius) / 3; + + DEBUG_PRINT("mtemp %d\n", mtemp); + + /* Bring fan speed according the temp + */ + + if(mtemp<25000) + new_rpm=FAN_IDLE_RPM; + else if((mtemp>=30000)&&(mtemp<40000)) + new_rpm=FAN_LEVEL1_RPM; + else if((mtemp>=45000)&&(mtemp<55000)) + new_rpm=FAN_LEVEL2_RPM; + else if((mtemp>=60000)&&(mtemp<75000)) + new_rpm=FAN_LEVEL3_RPM; + else if(mtemp>=80000) + new_rpm=FAN_LEVEL4_RPM; + else{ + return ONLP_STATUS_OK; + } + + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(1),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(2),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(3),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(4),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(5),new_rpm); + onlp_fan_rpm_set(ONLP_FAN_ID_CREATE(6),new_rpm); + + return ONLP_STATUS_OK; +} + + +int +onlp_sysi_platform_manage_leds(void) +{ + int i,tray_i,rc; + onlp_fan_info_t info; + onlp_led_mode_t fan_new_mode; + onlp_led_mode_t fan_tray_new_mode[3]; + onlp_psu_info_t psu; + onlp_led_mode_t psu_new_mode; + onlp_led_mode_t sys_new_mode; + onlp_led_mode_t locator_new_mode; + /*fan led */ + /*fan led */ + for(tray_i=0;tray_i<3;tray_i++){ + for(i=CHASSIS_FAN_COUNT-2*tray_i;i>=CHASSIS_FAN_COUNT-2*tray_i-1;i--){ + rc=onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &info); + if ((rc != ONLP_STATUS_OK) ||((info.status&0x1)!=1)){ + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_OFF; + goto tray_next; + } + else{ + if((info.status&0x2)==1){ + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_YELLOW; + goto tray_next; + } + } + } + fan_tray_new_mode[tray_i]=ONLP_LED_MODE_GREEN; +tray_next: continue; + } + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY0),fan_tray_new_mode[0]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY1),fan_tray_new_mode[1]); + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN_TRAY2),fan_tray_new_mode[2]); + + if((fan_tray_new_mode[0]==ONLP_LED_MODE_GREEN)&&(fan_tray_new_mode[1]==ONLP_LED_MODE_GREEN)&& + (fan_tray_new_mode[2]==ONLP_LED_MODE_GREEN)) + fan_new_mode=ONLP_LED_MODE_GREEN; + else if((fan_tray_new_mode[0]==ONLP_LED_MODE_OFF)||(fan_tray_new_mode[1]==ONLP_LED_MODE_OFF)|| + (fan_tray_new_mode[2]==ONLP_LED_MODE_OFF)) + fan_new_mode=ONLP_LED_MODE_YELLOW; + else + fan_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN),fan_new_mode); + /*psu1 and psu2 led */ + for(i=1;i<=CHASSIS_PSU_COUNT;i++){ + rc=onlp_psui_info_get(ONLP_PSU_ID_CREATE(i),&psu); + + if (rc != ONLP_STATUS_OK) { + continue; + } + if((psu.status&0x1)&&!(psu.status&0x2)){ + psu_new_mode=ONLP_LED_MODE_GREEN; + goto sys_led; + } + } + psu_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + +sys_led : + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_POWER),psu_new_mode); + //sys led ---------------- + if((fan_new_mode!=ONLP_LED_MODE_GREEN)||(psu_new_mode!=ONLP_LED_MODE_GREEN)) + sys_new_mode=ONLP_LED_MODE_YELLOW_BLINKING; + else + sys_new_mode=ONLP_LED_MODE_GREEN; + + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS),sys_new_mode); + + locator_new_mode=ONLP_LED_MODE_BLUE; + onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_LOCATOR),locator_new_mode); + return ONLP_STATUS_OK; +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c new file mode 100755 index 00000000..8e18624a --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/thermali.c @@ -0,0 +1,229 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * Copyright 2016 Accton Technology Corporation. + * Copyright 2017 Delta Networks, Inc + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * Thermal Sensor Platform Implementation. + * + ***********************************************************/ +#include +#include +#include +#include +#include +#include "platform_lib.h" +#include "x86_64_delta_ag7648c_log.h" +#include +#include "x86_64_delta_i2c.h" +#define prefix_path "/sys/bus/i2c/devices/" +#define LOCAL_DEBUG 0 + +#define VALIDATE(_id) \ + do { \ + if(!ONLP_OID_IS_THERMAL(_id)) { \ + return ONLP_STATUS_E_INVALID; \ + } \ + } while(0) + +enum onlp_thermal_id +{ + THERMAL_RESERVED = 0, + THERMAL_1_CLOSE_TO_CPU, + THERMAL_1_CLOSE_TO_MAC, + THERMAL_2_CLOSE_TO_PHY_SFP_PLUS, + THERMAL_3_CLOSE_TO_PHY_QSFP, + THERMAL_1_ON_PSU1, + THERMAL_1_ON_PSU2, +}; + +static char* last_path[] = /* must map with onlp_thermal_id */ +{ + "reserved", + "2-004d/hwmon/hwmon1/temp1_input", + "3-004c/hwmon/hwmon2/temp1_input", + "3-004d/hwmon/hwmon3/temp1_input", + "3-004e/hwmon/hwmon4/temp1_input", +}; + +/* Static values */ +static onlp_thermal_info_t linfo[] = { + { }, /* Not used */ + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_CPU), "Thermal Sensor 1- close to cpu", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_CLOSE_TO_MAC), "Thermal Sensor 2- close to mac", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_2_CLOSE_TO_PHY_SFP_PLUS), "Thermal Sensor 3- close to sfp+ phy", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_3_CLOSE_TO_PHY_QSFP), "Thermal Sensor 4- close to qsfp phy", 0}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 5", ONLP_PSU_ID_CREATE(1)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + }, + { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 6", ONLP_PSU_ID_CREATE(2)}, + ONLP_THERMAL_STATUS_PRESENT, + ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS + } +}; + +/*thermali val to real tempeture*/ +static int +_onlp_psu_thermali_val_to_temperature (int v,int mult) +{ + long X, Y, N, n; + Y = v & 0x07FF; + N = (v >> 11) & 0x0f; + n = v & 0x8000 ? 1 : 0; + if (n) + X = (Y * mult) / ((1<<(((~N)&0xf)+1))) ; + else + X = Y * mult * (N=(1<<(N&0xf))); + return X; +} + +/* + * This will be called to intiialize the thermali subsystem. + */ +int +onlp_thermali_init(void) +{ + return ONLP_STATUS_OK; +} + +/* + * Retrieve the information structure for the given thermal OID. + * + * If the OID is invalid, return ONLP_E_STATUS_INVALID. + * If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL. + * Otherwise, return ONLP_STATUS_OK with the OID's information. + * + * Note -- it is expected that you fill out the information + * structure even if the sensor described by the OID is not present. + */ +int +_onlp_thermali_info_get(int id, onlp_thermal_info_t* info) +{ + int len, nbytes = 10, temp_base=1, local_id; + uint8_t r_data[10]={0}; + char fullpath[50] = {0}; + + local_id = id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + /* get fullpath */ + sprintf(fullpath, "%s%s", prefix_path, last_path[local_id]); + + //OPEN_READ_FILE(fd, fullpath, r_data, nbytes, len); + onlp_file_read(r_data,nbytes,&len, fullpath); + + info->mcelsius =ONLPLIB_ATOI((char*)r_data) / temp_base; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; +} + +/*psu temperture info get*/ +static int +_onlp_thermali_psu_info_get(int id, onlp_thermal_info_t* info) +{ + int psu_present,psu_good; + int psu_id,local_id; + int r_data,temperature_v; + enum ag7648c_product_id pid; + + local_id=id; + + DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); + + psu_id=(local_id-THERMAL_1_ON_PSU1)+1; + pid=get_product_id(); + //if the psu is not, directly to return + psu_present=psu_status_info_get(psu_id, "present"); + if(psu_present != 1){ + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_OK; + } + psu_good= psu_status_info_get(psu_id,"good"); + if(psu_good != 0){ + info->status |= ONLP_THERMAL_STATUS_FAILED; + return ONLP_STATUS_OK; + } + + //read the pus temperture register value + if(pid == PID_AG7648C){ + if(psu_id==1) + r_data=i2c_devname_read_word("PSU1_PMBUS", 0x8d); + else + r_data=i2c_devname_read_word("PSU2_PMBUS", 0x8d); + } + else{ + DEBUG_PRINT("\n[Debug][%s][%d][unsupported board:%d]", __FUNCTION__, __LINE__, pid); + return ONLP_STATUS_E_UNSUPPORTED; + } + if(r_data<0) + return ONLP_STATUS_E_INVALID; + //get the real temperture value + temperature_v=_onlp_psu_thermali_val_to_temperature(r_data,1000); + + info->mcelsius=temperature_v; + + DEBUG_PRINT("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); + + return ONLP_STATUS_OK; + +} + +int +onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) +{ + int rc; + int local_id; + + VALIDATE(id); + + local_id=ONLP_OID_ID_GET(id); + + if((local_id > THERMAL_1_ON_PSU2) || (local_id < THERMAL_1_CLOSE_TO_CPU)){ + DEBUG_PRINT("\n[Debug][%s][%d][outside addr:%d]", __FUNCTION__, __LINE__, local_id); + info->status &= ~ONLP_THERMAL_STATUS_PRESENT; + return ONLP_STATUS_E_INVALID; + } + + /* Set the onlp_oid_hdr_t and capabilities */ + *info = linfo[local_id]; + + if((local_id==THERMAL_1_ON_PSU1) || (local_id==THERMAL_1_ON_PSU2)) + rc= _onlp_thermali_psu_info_get(local_id,info); + else + rc= _onlp_thermali_info_get(local_id,info); + + return rc; +} diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c new file mode 100755 index 00000000..3cabebd2 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_config.c @@ -0,0 +1,81 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* */ +#define __x86_64_delta_ag7648c_config_STRINGIFY_NAME(_x) #_x +#define __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(_x) __x86_64_delta_ag7648c_config_STRINGIFY_NAME(_x) +x86_64_delta_ag7648c_config_settings_t x86_64_delta_ag7648c_config_settings[] = +{ +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_LOGGING(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_PORTING_STDLIB(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif +#ifdef X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION + { __x86_64_delta_ag7648c_config_STRINGIFY_NAME(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_delta_ag7648c_config_STRINGIFY_VALUE(X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, +#else +{ X86_64_DELTA_AG7648C_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_delta_ag7648c_config_STRINGIFY_NAME), "__undefined__" }, +#endif + { NULL, NULL } +}; +#undef __x86_64_delta_ag7648c_config_STRINGIFY_VALUE +#undef __x86_64_delta_ag7648c_config_STRINGIFY_NAME + +const char* +x86_64_delta_ag7648c_config_lookup(const char* setting) +{ + int i; + for(i = 0; x86_64_delta_ag7648c_config_settings[i].name; i++) { + if(strcmp(x86_64_delta_ag7648c_config_settings[i].name, setting)) { + return x86_64_delta_ag7648c_config_settings[i].value; + } + } + return NULL; +} + +int +x86_64_delta_ag7648c_config_show(struct aim_pvs_s* pvs) +{ + int i; + for(i = 0; x86_64_delta_ag7648c_config_settings[i].name; i++) { + aim_printf(pvs, "%s = %s\n", x86_64_delta_ag7648c_config_settings[i].name, x86_64_delta_ag7648c_config_settings[i].value); + } + return i; +} + +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c new file mode 100755 index 00000000..7eb66a72 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_enums.c @@ -0,0 +1,10 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +/* <--auto.start.enum(ALL).source> */ +/* */ + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h new file mode 100755 index 00000000..0006e5eb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_int.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * x86_64_delta_ag7648c Internal Header + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag7648c_INT_H__ +#define __x86_64_delta_ag7648c_INT_H__ + +#include + + +#endif /* __x86_64_delta_ag7648c_INT_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c new file mode 100755 index 00000000..3f53bd83 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.c @@ -0,0 +1,18 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag7648c_log.h" +/* + * x86_64_delta_ag7648c log struct. + */ +AIM_LOG_STRUCT_DEFINE( + X86_64_DELTA_AG7648C_CONFIG_LOG_OPTIONS_DEFAULT, + X86_64_DELTA_AG7648C_CONFIG_LOG_BITS_DEFAULT, + NULL, /* Custom log map */ + X86_64_DELTA_AG7648C_CONFIG_LOG_CUSTOM_BITS_DEFAULT + ); + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h new file mode 100755 index 00000000..1683bbfb --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_log.h @@ -0,0 +1,12 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#ifndef __x86_64_delta_ag7648c_LOG_H__ +#define __x86_64_delta_ag7648c_LOG_H__ + +#define AIM_LOG_MODULE_NAME x86_64_delta_ag7648c +#include + +#endif /* __x86_64_delta_ag7648c_LOG_H__ */ diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c new file mode 100755 index 00000000..a984cdf5 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_module.c @@ -0,0 +1,24 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#include "x86_64_delta_ag7648c_log.h" + +static int +datatypes_init__(void) +{ +#define x86_64_delta_ag7648c_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); +#include + return 0; +} + +void __x86_64_delta_ag7648c_module_init__(void) +{ + AIM_LOG_STRUCT_REGISTER(); + datatypes_init__(); +} + +int __onlp_platform_version__ = 1; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c new file mode 100755 index 00000000..9dd339b1 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_ag7648c_ucli.c @@ -0,0 +1,50 @@ +/**************************************************************************//** + * + * + * + *****************************************************************************/ +#include + +#if X86_64_DELTA_AG7648C_CONFIG_INCLUDE_UCLI == 1 + +#include +#include +#include + +static ucli_status_t +x86_64_delta_ag7648c_ucli_ucli__config__(ucli_context_t* uc) +{ + UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_delta_ag7648c) +} + +/* */ +/* */ + +static ucli_module_t +x86_64_delta_ag7648c_ucli_module__ = + { + "x86_64_delta_ag7648c_ucli", + NULL, + x86_64_delta_ag7648c_ucli_ucli_handlers__, + NULL, + NULL, + }; + +ucli_node_t* +x86_64_delta_ag7648c_ucli_node_create(void) +{ + ucli_node_t* n; + ucli_module_init(&x86_64_delta_ag7648c_ucli_module__); + n = ucli_node_create("x86_64_delta_ag7648c", NULL, &x86_64_delta_ag7648c_ucli_module__); + ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_delta_ag7648c")); + return n; +} + +#else +void* +x86_64_delta_ag7648c_ucli_node_create(void) +{ + return NULL; +} +#endif + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c new file mode 100755 index 00000000..13d29c48 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.c @@ -0,0 +1,148 @@ +/************************************************************ + * + * + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc + + * 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 +#include +#include "x86_64_delta_ag7648c_log.h" +#include "x86_64_delta_i2c.h" +#include +struct i2c_device_info i2c_device_list[]={ + {"RTC",0X0,0X69}, + {"TMP1_CLOSE_TO_CPU",0X2,0X4d}, + {"TMP1_CLOSE_TO_MAC",0X3,0X4c}, + {"TMP2_CLOSE_TO_SFP_PLUS",0X3,0X4d}, + {"TMP3_CLOSE_TO_QSFP",0X3,0X4E}, + {"SYSCPLD",0X2,0X31}, + {"MASTERCPLD",0X2,0X32}, + {"FAN1EEPROM",0X3,0X51}, + {"FAN2EEPROM",0X3,0X52}, + {"FAN3EEPROM",0X3,0X53}, + {"FANCTRL1",0X3,0X2A}, + {"FANCTRL2",0X3,0X29}, + {"CURT_MONTOR",0X1,0X40}, + {"ID_EEPROM",0X2,0X53}, + {"QSFP49",0XA,0X50}, + {"QSFP50",0XB,0X50}, + {"QSFP51",0XC,0X50}, + {"QSFP52",0XD,0X50}, + {"QSFP53",0XE,0X50}, + {"QSFP54",0XF,0X50}, +// ------------------------- + {"PSU1_PMBUS",0X6,0X58}, + {"PSU2_PMBUS",0X6,0X59}, + {"PSU1_EEPROM",0X6,0X50}, + {"PSU2_EEPROM",0X6,0X51}, + + {NULL, -1,-1}, +}; + +uint32_t i2c_flag=ONLP_I2C_F_FORCE; + +i2c_device_info_t *i2c_dev_find_by_name (char *name) +{ + i2c_device_info_t *i2c_dev = i2c_device_list; + + if (name == NULL) return NULL; + + while (i2c_dev->name) { + if (strcmp (name, i2c_dev->name) == 0) break; + ++ i2c_dev; + } + if (i2c_dev->name == NULL) return NULL; + + return i2c_dev; +} + +int i2c_devname_read_byte (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + + if(i2c_dev==NULL) return -1; + + + ret=onlp_i2c_readb(i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + + return ret; +} + +int i2c_devname_write_byte (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + + ret=onlp_i2c_writeb (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + + return ret; +} + +int i2c_devname_read_word (char *name, int reg) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + ret=onlp_i2c_readw(i2c_dev->i2cbus, i2c_dev->addr, reg, i2c_flag); + + + return ret; +} + +int i2c_devname_write_word (char *name, int reg, int value) +{ + int ret=-1; + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + + ret=onlp_i2c_writew (i2c_dev->i2cbus, i2c_dev->addr, reg, value, i2c_flag); + + + return ret; +} + +int i2c_devname_read_block (char *name, int reg, uint8_t*buff, int buff_size) +{ + int ret = -1; + + i2c_device_info_t *i2c_dev = i2c_dev_find_by_name (name); + + if(i2c_dev==NULL) return -1; + + + ret =onlp_i2c_block_read (i2c_dev->i2cbus, i2c_dev->addr, reg, buff_size, buff, i2c_flag); + + + return ret; + +} + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h new file mode 100755 index 00000000..92a4ee1e --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/module/src/x86_64_delta_i2c.h @@ -0,0 +1,49 @@ +/************************************************************ + * + * + * Copyright 2018 Delta Technology Corporation. + * Copyright 2018 Delta Networks, Inc + * + * 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. + * + * + ************************************************************/ +/* the i2c struct header*/ + +#ifndef __X86_64_DELTA_I2C_H__ +#define __X86_64_DELTA_I2C_H__ + +#include "x86_64_delta_ag7648c_log.h" + +struct i2c_device_info { + /*i2c device name*/ + char *name; + char i2cbus; + char addr; +}; + + +typedef struct i2c_device_info i2c_device_info_t; + +extern struct i2c_device_info i2c_device_list[]; + + +extern int i2c_devname_read_byte(char *name, int reg); + +extern int i2c_devname_write_byte(char *name, int reg, int value); + + +extern int i2c_devname_read_word(char *name, int reg); + +extern int i2c_devname_write_word(char *name, int reg, int value); + + +extern int i2c_devname_read_block (char *name, int reg, uint8_t*buff, int buff_size); +//extern int i2c_devname_write_block(char *name, int reg, char *buff, int buff_size); + +#endif diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk new file mode 100755 index 00000000..1f82839d --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/onlp/builds/src/x86_64_delta_ag7648c.mk @@ -0,0 +1,13 @@ + +############################################################################### +# +# Inclusive Makefile for the x86_64_delta_ag7648c module. +# +# Autogenerated 2017-03-20 15:05:23.627200 +# +############################################################################### +x86_64_delta_ag7648c_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +include $(x86_64_delta_ag7648c_BASEDIR)module/make.mk +include $(x86_64_delta_ag7648c_BASEDIR)module/auto/make.mk +include $(x86_64_delta_ag7648c_BASEDIR)module/src/make.mk + diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile new file mode 100644 index 00000000..003238cf --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/Makefile @@ -0,0 +1 @@ +include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml new file mode 100644 index 00000000..0d86acc6 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/PKG.yml @@ -0,0 +1 @@ +!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=delta BASENAME=x86-64-delta-ag7648c REVISION=r0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml new file mode 100755 index 00000000..2b5a6a3c --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/lib/x86-64-delta-ag7648c-r0.yml @@ -0,0 +1,32 @@ +--- + +###################################################################### +# +# platform-config for AG7648C +# +###################################################################### + +x86-64-delta-ag7648c-r0: + + grub: + + serial: >- + --port=0x3f8 + --speed=115200 + --word=8 + --parity=no + --stop=1 + + kernel: + <<: *kernel-3-16 + + args: >- + nopat + acpi=off + console=ttyS0,115200n8 + + ##network + ## interfaces: + ## ma1: + ## name: ~ + ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py new file mode 100644 index 00000000..e5c25662 --- /dev/null +++ b/packages/platforms/delta/x86-64/x86-64-delta-ag7648c/platform-config/r0/src/python/x86_64_delta_ag7648c_r0/__init__.py @@ -0,0 +1,28 @@ +from onl.platform.base import * +from onl.platform.delta import * + +class OnlPlatform_x86_64_delta_ag7648c_r0(OnlPlatformDelta,OnlPlatformPortConfig_48x10_6x40): + + PLATFORM='x86-64-delta-ag7648c-r0' + MODEL="AG7648C" + SYS_OBJECT_ID=".7648c.1" + + def baseconfig(self): + self.new_i2c_device('pca9547', 0x70, 1); + + self.insmod('x86-64-delta-ag7648c-cpld-mux.ko') + ########### initialize I2C bus 0 ########### + + + self.new_i2c_devices( + [ + ('clock_gen', 0x69, 0), + ('tmp75', 0x4d, 2), + ('tmp75', 0x4c, 3), + ('tmp75', 0x4d, 3), + ('tmp75', 0x4e, 3), + ] + ) + + + return True From 4f803704b1e7ee1e994e713f4c6cab07fb4dbdb7 Mon Sep 17 00:00:00 2001 From: Wataru Ishida Date: Fri, 13 Jul 2018 14:59:47 -0700 Subject: [PATCH 10/32] rfs: fix bug that bash doesn't return on error bash doesn't respect -ex flags when it is not written in the first line Signed-off-by: Wataru Ishida --- tools/onlrfs.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/onlrfs.py b/tools/onlrfs.py index 58f3dc75..46749d3b 100755 --- a/tools/onlrfs.py +++ b/tools/onlrfs.py @@ -389,8 +389,7 @@ class OnlRfsBuilder(object): script = os.path.join(dir_, "tmp/configure.sh") with open(script, "w") as f: os.chmod(script, 0700) - f.write(""" -#!/bin/bash -ex + f.write("""#!/bin/bash -ex /bin/echo -e "#!/bin/sh\\nexit 101" >/usr/sbin/policy-rc.d chmod +x /usr/sbin/policy-rc.d export DEBIAN_FRONTEND=noninteractive From 3e3df10346581b00117298c8369fbe7ec1307c26 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Jul 2018 17:31:29 +0000 Subject: [PATCH 11/32] The SFF code module has been migrated from the ONL repository to the floodlight:bigcode repository. The core SFF functionality has been migrated into the bigcode repository so it can be used by applications outside of ONL proper. This change should be transparent. --- packages/base/any/onlp/APKG.yml | 2 +- packages/base/any/onlp/src/sff/.gitignore | 1 - packages/base/any/onlp/src/sff/.module | 1 - packages/base/any/onlp/src/sff/Makefile | 4 - packages/base/any/onlp/src/sff/README | 6 - .../base/any/onlp/src/sff/module/auto/make.mk | 9 - .../base/any/onlp/src/sff/module/auto/sff.yml | 181 -- .../any/onlp/src/sff/module/inc/sff/8436.h | 525 ----- .../any/onlp/src/sff/module/inc/sff/8472.h | 1021 --------- .../any/onlp/src/sff/module/inc/sff/8636.h | 187 -- .../any/onlp/src/sff/module/inc/sff/sff.h | 388 ---- .../any/onlp/src/sff/module/inc/sff/sff.x | 119 -- .../onlp/src/sff/module/inc/sff/sff_config.h | 157 -- .../any/onlp/src/sff/module/inc/sff/sff_db.h | 60 - .../any/onlp/src/sff/module/inc/sff/sff_dox.h | 26 - .../onlp/src/sff/module/inc/sff/sff_porting.h | 87 - packages/base/any/onlp/src/sff/module/make.mk | 10 - .../sff/module/python/onlp/sff/__init__.py | 34 - .../src/sff/module/python/onlp/sff/enums.py | 76 - .../base/any/onlp/src/sff/module/src/8472.c | 328 --- .../base/any/onlp/src/sff/module/src/Makefile | 9 - .../base/any/onlp/src/sff/module/src/make.mk | 9 - .../any/onlp/src/sff/module/src/nonstandard.c | 37 - .../base/any/onlp/src/sff/module/src/sff.c | 863 -------- .../any/onlp/src/sff/module/src/sff_config.c | 91 - .../base/any/onlp/src/sff/module/src/sff_db.c | 1858 ---------------- .../any/onlp/src/sff/module/src/sff_enums.c | 316 --- .../any/onlp/src/sff/module/src/sff_int.h | 13 - .../any/onlp/src/sff/module/src/sff_log.c | 18 - .../any/onlp/src/sff/module/src/sff_log.h | 12 - .../any/onlp/src/sff/module/src/sff_module.c | 23 - .../any/onlp/src/sff/module/src/sff_tool.c | 143 -- packages/base/any/onlp/src/sff/sff.doxy | 1869 ----------------- .../base/any/onlp/src/sff/utest/.gitignore | 1 - packages/base/any/onlp/src/sff/utest/Makefile | 15 - packages/base/any/onlp/src/sff/utest/_make.mk | 8 - packages/base/any/onlp/src/sff/utest/main.c | 106 - sm/bigcode | 2 +- 38 files changed, 2 insertions(+), 8613 deletions(-) delete mode 100644 packages/base/any/onlp/src/sff/.gitignore delete mode 100644 packages/base/any/onlp/src/sff/.module delete mode 100644 packages/base/any/onlp/src/sff/Makefile delete mode 100644 packages/base/any/onlp/src/sff/README delete mode 100644 packages/base/any/onlp/src/sff/module/auto/make.mk delete mode 100644 packages/base/any/onlp/src/sff/module/auto/sff.yml delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/8436.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/8472.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/8636.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff.x delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff_config.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff_db.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff_dox.h delete mode 100644 packages/base/any/onlp/src/sff/module/inc/sff/sff_porting.h delete mode 100644 packages/base/any/onlp/src/sff/module/make.mk delete mode 100644 packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py delete mode 100644 packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py delete mode 100644 packages/base/any/onlp/src/sff/module/src/8472.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/Makefile delete mode 100644 packages/base/any/onlp/src/sff/module/src/make.mk delete mode 100644 packages/base/any/onlp/src/sff/module/src/nonstandard.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_config.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_db.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_enums.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_int.h delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_log.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_log.h delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_module.c delete mode 100644 packages/base/any/onlp/src/sff/module/src/sff_tool.c delete mode 100644 packages/base/any/onlp/src/sff/sff.doxy delete mode 100644 packages/base/any/onlp/src/sff/utest/.gitignore delete mode 100644 packages/base/any/onlp/src/sff/utest/Makefile delete mode 100644 packages/base/any/onlp/src/sff/utest/_make.mk delete mode 100644 packages/base/any/onlp/src/sff/utest/main.c diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index 1d6832e5..bb66bd7f 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -31,7 +31,7 @@ packages: ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp: ${PY_INSTALL}/onlp/onlp ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test: ${PY_INSTALL}/onlp/test ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib: ${PY_INSTALL}/onlp/onlplib - ${ONL}/packages/base/any/onlp/src/sff/module/python/onlp/sff: ${PY_INSTALL}/onlp/sff + ${ONL}/sm/bigcode/modules/sff/module/python/onlp/sff: ${PY_INSTALL}/onlp/sff init: $ONL/packages/base/any/onlp/src/onlpd.init diff --git a/packages/base/any/onlp/src/sff/.gitignore b/packages/base/any/onlp/src/sff/.gitignore deleted file mode 100644 index c81d16be..00000000 --- a/packages/base/any/onlp/src/sff/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/base/any/onlp/src/sff/.module b/packages/base/any/onlp/src/sff/.module deleted file mode 100644 index 05da7c63..00000000 --- a/packages/base/any/onlp/src/sff/.module +++ /dev/null @@ -1 +0,0 @@ -name: sff diff --git a/packages/base/any/onlp/src/sff/Makefile b/packages/base/any/onlp/src/sff/Makefile deleted file mode 100644 index 50cbaef2..00000000 --- a/packages/base/any/onlp/src/sff/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include $(ONL)/make/config.mk -MODULE := sff -AUTOMODULE := sff -include $(BUILDER)/definemodule.mk diff --git a/packages/base/any/onlp/src/sff/README b/packages/base/any/onlp/src/sff/README deleted file mode 100644 index 12717e2f..00000000 --- a/packages/base/any/onlp/src/sff/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# sff README -# -############################################################################### - diff --git a/packages/base/any/onlp/src/sff/module/auto/make.mk b/packages/base/any/onlp/src/sff/module/auto/make.mk deleted file mode 100644 index 88b2ad6f..00000000 --- a/packages/base/any/onlp/src/sff/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# sff Autogeneration -# -############################################################################### -sff_AUTO_DEFS := module/auto/sff.yml -sff_AUTO_DIRS := module/inc/sff module/src module/python/onlp/sff -include $(BUILDER)/auto.mk - diff --git a/packages/base/any/onlp/src/sff/module/auto/sff.yml b/packages/base/any/onlp/src/sff/module/auto/sff.yml deleted file mode 100644 index ae5a01d6..00000000 --- a/packages/base/any/onlp/src/sff/module/auto/sff.yml +++ /dev/null @@ -1,181 +0,0 @@ -############################################################################### -# -# sff Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- SFF_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- SFF_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- SFF_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- SFF_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: SFF_CONFIG_PORTING_STDLIB -- SFF_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- SFF_CONFIG_INCLUDE_SFF_TOOL: - doc: "Include the SFF tool main entry point." - default: 0 -- SFF_CONFIG_INCLUDE_EXT_CC_CHECK: - doc: "Include extended checksum verification." - default: 0 -- SFF_CONFIG_INCLUDE_DATABASE: - doc: "Include eeprom database." - default: 1 - -sff_media_types: &sff_media_types -- COPPER: - desc: "Copper" -- FIBER: - desc: "Fiber" - -sff_module_types: &sff_module_types -- 100G_AOC: - desc: "100G-AOC" -- 100G_BASE_CR4: - desc: "100GBASE-CR4" -- 100G_BASE_SR4: - desc: "100GBASE-SR4" -- 100G_BASE_LR4: - desc: "100GBASE-LR4" -- 100G_CWDM4: - desc: "100G-CWDM4" -- 100G_PSM4: - desc: "100G-PSM4" -- 100G_SWDM4: - desc: "100G-SWDM4" -- 40G_BASE_CR4: - desc: "40GBASE-CR4" -- 40G_BASE_SR4: - desc: "40GBASE-SR4" -- 40G_BASE_LR4: - desc: "40GBASE-LR4" -- 40G_BASE_LM4: - desc: "40GBASE-LM4" -- 40G_BASE_ACTIVE: - desc: "40GBASE-ACTIVE" -- 40G_BASE_CR: - desc: "40GBASE-CR" -- 40G_BASE_SR2: - desc: "40GBASE-SR2" -- 40G_BASE_SM4: - desc: "40GBASE-SM4" -- 40G_BASE_ER4: - desc: "40GBASE-ER4" -- 25G_BASE_CR: - desc: "25GBASE-CR" -- 25G_BASE_SR: - desc: "25GBASE-SR" -- 25G_BASE_LR: - desc: "25GBASE-LR" -- 25G_BASE_AOC: - desc: "25GBASE-AOC" -- 10G_BASE_SR: - desc: "10GBASE-SR" -- 10G_BASE_LR: - desc: "10GBASE-LR" -- 10G_BASE_LRM: - desc: "10GBASE-LRM" -- 10G_BASE_ER: - desc: "10GBASE-ER" -- 10G_BASE_CR: - desc: "10GBASE-CR" -- 10G_BASE_SX: - desc: "10GBASE-SX" -- 10G_BASE_LX: - desc: "10GBASE-LX" -- 10G_BASE_ZR: - desc: "10GBASE-ZR" -- 10G_BASE_SRL: - desc: "10GBASE-SRL" -- 1G_BASE_SX: - desc: "1GBASE-SX" -- 1G_BASE_LX: - desc: "1GBASE-LX" -- 1G_BASE_ZX: - desc: "1GBASE-ZX" -- 1G_BASE_CX: - desc: "1GBASE-CX" -- 1G_BASE_T: - desc: "1GBASE-T" -- 100_BASE_LX: - desc: "100BASE-LX" -- 100_BASE_FX: - desc: "100BASE-FX" -- 4X_MUX: - desc: "4X-MUX" - -sff_module_caps: &sff_module_caps -- F_100 : 0x1 -- F_1G : 0x2 -- F_10G : 0x4 -- F_25G : 0x8 -- F_40G : 0x10 -- F_100G : 0x20 - -sff_sfp_types: &sff_sfp_types -- SFP: - desc: "SFP" -- QSFP: - desc: "QSFP" -- QSFP_PLUS: - desc: "QSFP+" -- QSFP28: - desc: "QSFP28" -- SFP28: - desc: "SFP28" - -definitions: - cdefs: - SFF_CONFIG_HEADER: - defs: *cdefs - basename: sff_config - - portingmacro: - SFF: - macros: - - memset - - memcpy - - strncpy - - strncmp - - strlen - - snprintf - - enum: &enums - sff_sfp_type: - members: *sff_sfp_types - sff_module_type: - members: *sff_module_types - sff_module_caps: - members: *sff_module_caps - sff_media_type: - members: *sff_media_types - - pyenum: *enums - - xenum: - SFF_ENUMERATION_ENTRY: - members: *enums - - xmacro: - SFF_SFP_TYPE_ENTRY: - members: *sff_sfp_types - SFF_MODULE_TYPE_ENTRY: - members: *sff_module_types - SFF_MODULE_CAP_ENTRY: - members: *sff_module_caps - SFF_MEDIA_TYPE_ENTRY: - members: *sff_module_types diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/8436.h b/packages/base/any/onlp/src/sff/module/inc/sff/8436.h deleted file mode 100644 index ee6640ab..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/8436.h +++ /dev/null @@ -1,525 +0,0 @@ -/********************************************************************** - * - * 8436.h - * - * idprom defintions for QSFP+ modules. - * - **********************************************************************/ - -#ifndef __SFF_8436_H__ -#define __SFF_8436_H__ - -#include -#include "sff/8472.h" - -/* identifier, bytes 128 page 0 (also byte 0) */ - -#define SFF8436_IDENT_UNKNOWN SFF8472_IDENT_UNKNOWN -#define SFF8436_IDENT_GBIC SFF8472_IDENT_GBIC -#define SFF8436_IDENT_BASEBOARD SFF8472_IDENT_BASEBOARD -#define SFF8436_IDENT_SFP SFF8472_IDENT_SFP -#define SFF8436_IDENT_XBI SFF8472_IDENT_XBI -#define SFF8436_IDENT_XENPAK SFF8472_IDENT_XENPAK -#define SFF8436_IDENT_XFP SFF8472_IDENT_XFP -#define SFF8436_IDENT_XFF SFF8472_IDENT_XFF -#define SFF8436_IDENT_XFPE SFF8472_IDENT_XFPE -#define SFF8436_IDENT_XPAK SFF8472_IDENT_XPAK -#define SFF8436_IDENT_X2 SFF8472_IDENT_X2 -#define SFF8436_IDENT_DWDM_SFP SFF8472_IDENT_DWDM_SFP -#define SFF8436_IDENT_QSFP SFF8472_IDENT_QSFP - -/* additional values from this spec */ -#define SFF8436_IDENT_QSFP_PLUS 0x0D - -#define SFF8436_MODULE_QSFP_PLUS(idprom) \ - ((idprom[0] == SFF8436_IDENT_QSFP) \ - || (idprom[0] == SFF8436_IDENT_QSFP_PLUS)) - -#define SFF8436_MODULE_QSFP_PLUS_V2(idprom) \ - ((idprom[128] == SFF8436_IDENT_QSFP) \ - || (idprom[128] == SFF8436_IDENT_QSFP_PLUS)) - -#define SFF8436_RX1_PWR(idprom) \ - (idprom[34] << 8 | idprom[34 + 1]) -#define SFF8436_RX2_PWR(idprom) \ - (idprom[36] << 8 | idprom[36 + 1]) -#define SFF8436_RX3_PWR(idprom) \ - (idprom[38] << 8 | idprom[38 + 1]) -#define SFF8436_RX4_PWR(idprom) \ - (idprom[40] << 8 | idprom[40 + 1]) - -#define SFF8436_TX1_BIAS(idprom) \ - (idprom[42] << 8 | idprom[42 + 1]) -#define SFF8436_TX2_BIAS(idprom) \ - (idprom[44] << 8 | idprom[44 + 1]) -#define SFF8436_TX3_BIAS(idprom) \ - (idprom[46] << 8 | idprom[46 + 1]) -#define SFF8436_TX4_BIAS(idprom) \ - (idprom[48] << 8 | idprom[48 + 1]) - -#define SFF8436_SFP_VOLT(idprom) \ - (idprom[26] << 8 | idprom[26 + 1]) -#define SFF8436_SFP_TEMP(idprom) \ - (idprom[22] << 8 | idprom[22 + 1]) - -/* connector value, byte 130 page 0 */ - -#define SFF8436_CONN_UNKNOWN SFF8472_CONN_UNKNOWN -#define SFF8436_CONN_SC SFF8472_CONN_SC -#define SFF8436_CONN_FC1_CU SFF8472_CONN_FC1_CU -#define SFF8436_CONN_FC2_CU SFF8472_CONN_FC2_CU -#define SFF8436_CONN_BNC SFF8472_CONN_BNC -#define SFF8436_CONN_FC_COAX SFF8472_CONN_FC_COAX -#define SFF8436_CONN_FJ SFF8472_CONN_FJ -#define SFF8436_CONN_LC SFF8472_CONN_LC -#define SFF8436_CONN_MT_RJ SFF8472_CONN_MT_RJ -#define SFF8436_CONN_MU SFF8472_CONN_MU -#define SFF8436_CONN_SG SFF8472_CONN_SG -#define SFF8436_CONN_SI_PIGTAIL SFF8472_CONN_SI_PIGTAIL -#define SFF8436_CONN_MPO SFF8472_CONN_MPO -#define SFF8436_CONN_HSSDC_II SFF8472_CONN_HSSDC_II -#define SFF8436_CONN_CU_PIGTAIL SFF8472_CONN_CU_PIGTAIL -#define SFF8436_CONN_RJ45 SFF8472_CONN_RJ45 - -/* addtional values from this spec */ -#define SFF8436_CONN_NONE 0x23 - -/* Amphenol QSFP, identified as "QSFP" (not "QSFP+") and copper - pigtail */ -#define SFF8436_MEDIA_40GE_CR(idprom) \ - (idprom[130] == SFF8436_CONN_CU_PIGTAIL) - -/* QSFP+ compliance codes, bytes 131-138 */ -#define SFF8436_CC131_XGE_BASE_LRM SFF8472_CC3_XGE_BASE_LRM -#define SFF8436_CC131_XGE_BASE_LR SFF8472_CC3_XGE_BASE_LR -#define SFF8436_CC131_XGE_BASE_SR SFF8472_CC3_XGE_BASE_SR -#define SFF8436_CC131_40GE_BASE_CR4 0x08 -#define SFF8436_CC131_40GE_BASE_SR4 0x04 -#define SFF8436_CC131_40GE_BASE_LR4 0x02 -#define SFF8436_CC131_40GE_ACTIVE 0x01 - -#define SFF8436_MEDIA_XGE_LRM(idprom) \ - ((idprom[131] & SFF8436_CC131_XGE_BASE_LRM) != 0) -#define SFF8436_MEDIA_XGE_LR(idprom) \ - ((idprom[131] & SFF8436_CC131_XGE_BASE_LR) != 0) -#define SFF8436_MEDIA_XGE_SR(idprom) \ - ((idprom[131] & SFF8436_CC131_XGE_BASE_SR) != 0) - -#define SFF8436_MEDIA_40GE_CR4(idprom) \ - ((idprom[131] & SFF8436_CC131_40GE_BASE_CR4) != 0) -#define SFF8436_MEDIA_40GE_SR4(idprom) \ - ((idprom[131] & SFF8436_CC131_40GE_BASE_SR4) != 0) -#define SFF8436_MEDIA_40GE_LR4(idprom) \ - ((idprom[131] & SFF8436_CC131_40GE_BASE_LR4) != 0) -#define SFF8436_MEDIA_40GE_ACTIVE(idprom) \ - ((idprom[131] & SFF8436_CC131_40GE_ACTIVE) != 0) - -#define SFF8436_MEDIA_NONE(idprom) \ - ((idprom[131] & 0x7F) == 0) - -#define SFF8436_CC132_40G_OTN 0x08 -#define SFF8436_CC132_OC48_LONG SFF8472_CC4_OC48_LONG -#define SFF8436_CC132_OC48_INTERMETIATE SFF8472_CC4_OC48_INTERMEDIATE -#define SFF8436_CC132_OC48_SHORT SFF8472_CC4_OC48_SHORT - -#define SFF8436_CC133_SAS_6G 0x20 -#define SFF8436_CC133_SAS_3G 0x10 - -#define SFF8436_CC134_GBE_BASE_T SFF8472_CC6_GBE_BASE_T -#define SFF8436_CC134_GBE_BASE_CX SFF8472_CC6_GBE_BASE_CX -#define SFF8436_CC134_GBE_BASE_LX SFF8472_CC6_GBE_BASE_LX -#define SFF8436_CC134_GBE_BASE_SX SFF8472_CC6_GBE_BASE_SX - -#define SFF8436_MEDIA_GBE_T(idprom) \ - ((idprom[134] & SFF8436_CC134_GBE_BASE_T) != 0) -#define SFF8436_MEDIA_GBE_CX(idprom) \ - ((idprom[134] & SFF8436_CC134_GBE_BASE_CX) != 0) -#define SFF8436_MEDIA_GBE_LX(idprom) \ - ((idprom[134] & SFF8436_CC134_GBE_BASE_LX) != 0) -#define SFF8436_MEDIA_GBE_SX(idprom) \ - ((idprom[134] & SFF8436_CC134_GBE_BASE_SX) != 0) - -#define SFF8436_CC135_FC_VERY_LONG SFF8472_CC7_FC_VERY_LONG -#define SFF8436_CC135_FC_SHORT SFF8472_CC7_FC_SHORT -#define SFF8436_CC135_FC_INTERMEDIATE SFF8472_CC7_FC_INTERMEDIATE -#define SFF8436_CC135_FC_LONG SFF8472_CC7_FC_LONG -#define SFF8436_CC135_FC_MEDIUM SFF8472_CC7_FC_MEDIUM -#define SFF8436_CC135_FC_TECH_LC SFF8472_CC7_FC_TECH_LC -#define SFF8436_CC135_FC_TECH_EL SFF8472_CC7_FC_TECH_EL -#define SFF8436_CC136_FC_TECH_EL SFF8472_CC8_FC_TECH_EL -#define SFF8436_CC136_FC_TECH_SN SFF8472_CC8_FC_TECH_SN -#define SFF8436_CC136_FC_TECH_SL SFF8472_CC8_FC_TECH_SL -#define SFF8436_CC136_FC_TECH_LL SFF8472_CC8_FC_TECH_LL - -#define SFF8436_TECH_FC_FIBER_LONG(idprom) \ - (((idprom[135] & SFF8436_CC135_FC_TECH_LC) != 0) \ - || ((idprom[136] & SFF8436_CC136_FC_TECH_LL) != 0)) - -#define SFF8436_TECH_FC_FIBER_SHORT(idprom) \ - (((idprom[136] & SFF8436_CC136_FC_TECH_SN) != 0) \ - || ((idprom[136] & SFF8436_CC136_FC_TECH_SL) != 0)) - -#define SFF8436_TECH_FC_FIBER(idprom) \ - (SFF8436_TECH_FC_FIBER_SHORT(idprom) \ - || SFF8436_TECH_FC_FIBER_LONG(idprom)) - -#define SFF8436_TECH_FC_COPPER(idprom) \ - (((idprom[135] & SFF8436_CC135_FC_TECH_EL) != 0) \ - || ((idprom[136] & SFF8436_CC136_FC_TECH_EL) != 0)) - -#define SFF8436_CC137_FC_MEDIA_TW SFF8472_CC9_FC_MEDIA_TW -#define SFF8436_CC137_FC_MEDIA_TP SFF8472_CC9_FC_MEDIA_TP -#define SFF8436_CC137_FC_MEDIA_MI SFF8472_CC9_FC_MEDIA_MI -#define SFF8436_CC137_FC_MEDIA_TV SFF8472_CC9_FC_MEDIA_TV -#define SFF8436_CC137_FC_MEDIA_M6 SFF8472_CC9_FC_MEDIA_M6 -#define SFF8436_CC137_FC_MEDIA_M5 SFF8472_CC9_FC_MEDIA_M5 -#define SFF8436_CC137_FC_MEDIA_OM3 0x02 -#define SFF8436_CC137_FC_MEDIA_SM SFF8472_CC9_FC_MEDIA_SM - -#define SFF8436_MEDIA_FC_FIBER_SM(idprom) \ - ((idprom[137] & SFF8436_CC137_FC_MEDIA_SM) != 0) - -#define SFF8436_MEDIA_FC_FIBER_MM(idprom) \ - (((idprom[137] & SFF8436_CC137_FC_MEDIA_OM3) != 0) \ - || ((idprom[137] & SFF8436_CC137_FC_MEDIA_M5) != 0) \ - || ((idprom[137] & SFF8436_CC137_FC_MEDIA_M6) != 0)) - -#define SFF8436_MEDIA_FC_FIBER(idprom) \ - (SFF8436_MEDIA_FC_FIBER_SM(idprom) \ - || SFF8436_MEDIA_FC_FIBER_MM(idprom)) - -#define SFF8436_MEDIA_FC_COPPER_TP(idprom) \ - (((idprom[137] & SFF8436_CC137_FC_MEDIA_TP) != 0) \ - || ((idprom[137] & SFF8436_CC137_FC_MEDIA_TW) != 0)) - -#define SFF8436_MEDIA_FC_COPPER_COAX(idprom) \ - (((idprom[137] & SFF8436_CC137_FC_MEDIA_TV) != 0) \ - || ((idprom[137] & SFF8436_CC137_FC_MEDIA_MI) != 0)) - -#define SFF8436_MEDIA_FC_COPPER(idprom) \ - (SFF8436_MEDIA_FC_COPPER_TP(idprom) \ - || SFF8436_MEDIA_FC_COPPER_COAX(idprom) - -#define SFF8436_CC138_FC_SPEED_100 SFF8472_CC10_FC_SPEED_100 -#define SFF8436_CC138_FC_SPEED_200 SFF8472_CC10_FC_SPEED_200 -#define SFF8436_CC138_FC_SPEED_400 SFF8472_CC10_FC_SPEED_400 -#define SFF8436_CC138_FC_SPEED_1600 SFF8472_CC10_FC_SPEED_1600 -#define SFF8436_CC138_FC_SPEED_800 SFF8472_CC10_FC_SPEED_800 -#define SFF8436_CC138_FC_SPEED_1200 SFF8472_CC10_FC_SPEED_1200 - -#define SFF8436_CC139_8B10B 0x01 -#define SFF8436_CC139_4B5B 0x02 -#define SFF8436_CC139_NRZ 0x03 -#define SFF8436_CC139_SONET 0x04 -#define SFF8436_CC139_64B66B 0x05 -#define SFF8436_CC139_MANCHESTER 0x06 - -#define SFF8436_CC164_INF_SDR 0x01 -#define SFF8436_CC164_INF_DDR 0x02 -#define SFF8436_CC164_INF_QDR 0x04 -#define SFF8436_CC164_INF_FDR 0x08 -#define SFF8436_CC164_INF_EDR 0x10 - -#define SFF8436_RX_PWR_TYPE_MASK 0x08 -#define SFF8436_DOM_GET_RXPWR_TYPE(idprom) \ - (idprom[220] & SFF8436_RX_PWR_TYPE_MASK) - -/* SFF8436 registers */ -#define SFF8436_CONTROL_TX_DISABLE 86 -/* alternate ways to identify pre-standard 40G cables */ -static inline int -_sff8436_qsfp_40g_pre(const uint8_t* idprom) -{ - /* skip if not qsfp+ */ - if (!SFF8436_MODULE_QSFP_PLUS_V2(idprom)) - return 0; - - /* if any of the other standard bits are set, abort */ - if (SFF8436_MEDIA_40GE_CR4(idprom)) - return 0; - if (SFF8436_MEDIA_40GE_SR4(idprom)) - return 0; - if (SFF8436_MEDIA_40GE_LR4(idprom)) - return 0; - if (SFF8436_MEDIA_40GE_ACTIVE(idprom)) - return 0; - - /* since it is QSFP/QSFP+, let us assume 4 lanes */ - - /* QDR infiniband == 8G per lane, 32G total, probably 40G Ethernet - compliant */ - if ((idprom[164] & SFF8436_CC164_INF_QDR) != 0) - return 1; - - /* nominal BR > 100 * 100M (10G), likely 40G Ethernet compliant */ - if (idprom[140] >= 64) - return 1; - - return 0; -} - -static inline int -_sff8436_qsfp_40g_lm4(const uint8_t* idprom) -{ - if(!SFF8436_MODULE_QSFP_PLUS_V2(idprom)) { - return 0; - } - - if (idprom[130] != SFF8436_CONN_LC) return 0; - if (!SFF8436_MEDIA_NONE(idprom)) return 0; - - if ((idprom[142] != 1) && idprom[143] != 70) { - return 0; - } - return 1; -} - -static inline int -_sff8436_qsfp_40g_sm4(const uint8_t* idprom) -{ - if(!SFF8436_MODULE_QSFP_PLUS_V2(idprom)) { - return 0; - } - - if (!SFF8436_MEDIA_NONE(idprom)) return 0; - /* 850nm tx technology */ - if (idprom[147] & 0xF0) return 0; - /* length is 200m(OM3) or 250m(OM4) */ - if ((idprom[143] != 100) && (idprom[146] != 125)) { - return 0; - } - return 1; -} - -static inline int -_sff8436_qsfp_40g_er4(const uint8_t* idprom) -{ - if(!SFF8436_MODULE_QSFP_PLUS_V2(idprom)) { - return 0; - } - - if (idprom[130] != SFF8436_CONN_LC) return 0; - if (!SFF8436_MEDIA_NONE(idprom)) return 0; - - /* 40 kilometer SMF */ - if (idprom[142] != 40) { - return 0; - } - return 1; -} - -static inline int -_sff8436_bitrate(const uint8_t *idprom) -{ - if (idprom[12] == 0) - return 0; - if (idprom[12] == 0xFF) - return 0; - long long br = (long long) idprom[12] * 100*1000000; - if ((br > 1000*1000000LL) && (br < 5*1000*1000000LL)) - return 1; - return 0; -} - -static inline int -_sff8436_length_sm(const uint8_t *idprom) -{ - return idprom[142] * 1000; -} - -static inline int -_sff8436_length_om3(const uint8_t *idprom) -{ - return idprom[143] * 2; -} - -static inline int -_sff8436_length_om2(const uint8_t *idprom) -{ - return idprom[144]; -} - -static inline int -_sff8436_length_om1(const uint8_t *idprom) -{ - return idprom[145]; -} - -static inline int -_sff8436_length_copper_active(const uint8_t *idprom) -{ - return idprom[146]; -} - -static inline int -_sff8436_wavelength(const uint8_t *idprom) -{ - return ((idprom[186] << 8) | idprom[187]) / 20; -} - -/* - * try to detect QSFP modules (outside of the 8436 spec) - */ -static inline int -_sff8436_qsfp_40g_sr2_bidi_pre(const uint8_t *idprom) -{ - /* module should be qsfp */ - if (!SFF8436_MODULE_QSFP_PLUS(idprom) - && !SFF8436_MODULE_QSFP_PLUS_V2(idprom)) - return 0; - - /* module should have LC connector */ - if (idprom[130] != SFF8436_CONN_LC) return 0; - - /* reject any unrelated compliance codes */ - if (SFF8436_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8436_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8436_MEDIA_XGE_SR(idprom)) return 0; - if (SFF8436_MEDIA_40GE_CR4(idprom)) return 0; - - /* do *not* report SR4 compliance */ - if (SFF8436_MEDIA_40GE_SR4(idprom)) return 0; - - if (SFF8436_MEDIA_40GE_LR4(idprom)) return 0; - if (SFF8436_MEDIA_40GE_ACTIVE(idprom)) return 0; - - /* make sure it's MM fiber */ - if (_sff8436_wavelength(idprom) != 850) return 0; - - /* make sure it reports a MM cable length */ - if (_sff8436_length_sm(idprom) > 0) return 0; - if (!_sff8436_length_om1(idprom) - && !_sff8436_length_om2(idprom) - && !_sff8436_length_om3(idprom)) - return 0; - - /* - * report a BR greater than 10G... - * for a two-fiber bidi cable we report 20G, but that is per fiber - */ - long long br = (long long) idprom[140] * 100 * 1000000; - if ((br >= 20LL*1000*1000000) && (br < 40LL*1000*1000000)) return 1; - return 0; - -} - -/* - * non-standard Cisco/Finisar QSFP MM (AOC?) - */ -static inline int -_sff8436_qsfp_40g_sr4_aoc_pre(const uint8_t *idprom) -{ - /* module should be qsfp */ - if (!SFF8436_MODULE_QSFP_PLUS(idprom) - && !SFF8436_MODULE_QSFP_PLUS_V2(idprom)) - return 0; - - /* no separable connector -- likely active */ - if (idprom[130] != SFF8436_CONN_NONE) return 0; - - /* reject any unrelated compliance codes */ - if (SFF8436_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8436_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8436_MEDIA_XGE_SR(idprom)) return 0; - if (SFF8436_MEDIA_40GE_CR4(idprom)) return 0; - - /* do *not* report SR4 compliance */ - if (SFF8436_MEDIA_40GE_SR4(idprom)) return 0; - - if (SFF8436_MEDIA_40GE_LR4(idprom)) return 0; - if (SFF8436_MEDIA_40GE_ACTIVE(idprom)) return 0; - - /* make sure it's MM fiber */ - if (_sff8436_wavelength(idprom) != 850) return 0; - - /* make sure it reports a MM cable length */ - if (_sff8436_length_sm(idprom) > 0) return 0; - if (!_sff8436_length_om1(idprom) - && !_sff8436_length_om2(idprom) - && !_sff8436_length_om3(idprom)) - return 0; - - /* - * report a BR roughly 10G (4 strands) - */ - long long br = (long long) idprom[140] * 100 * 1000000; - if ((br >= 10LL*1000*1000000) && (br < 15LL*1000*1000000)) return 1; - return 0; - -} - -/* - * 40G AOC breakout cable, e.g. Finisar - */ -static inline int -_sff8436_qsfp_40g_aoc_breakout(const uint8_t *idprom) -{ - /* module should be qsfp */ - if (!SFF8436_MODULE_QSFP_PLUS(idprom) - && !SFF8436_MODULE_QSFP_PLUS_V2(idprom)) - return 0; - - /* no separable connector -- likely active */ - if (idprom[130] != SFF8436_CONN_NONE) return 0; - - /* no media compliance, probably active or breakout */ - if (!SFF8436_MEDIA_NONE(idprom)) return 0; - - /* reject any 40G compliance codes */ - if (SFF8436_MEDIA_40GE_CR4(idprom)) return 0; - if (SFF8436_MEDIA_40GE_SR4(idprom)) return 0; - if (SFF8436_MEDIA_40GE_LR4(idprom)) return 0; - - /* also does not report as active! Ugh. */ - if (SFF8436_MEDIA_40GE_ACTIVE(idprom)) return 0; - - /* reject any unrelated compliance codes */ - if (SFF8436_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8436_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8436_MEDIA_XGE_SR(idprom)) return 0; - - /* make sure it's MM fiber */ - if (_sff8436_wavelength(idprom) != 850) return 0; - - /* does not report a fiber length, but does report a cable length */ - if (_sff8436_length_sm(idprom) > 0) return 0; - if (_sff8436_length_om1(idprom) > 0) return 0; - if (_sff8436_length_om2(idprom) > 0) return 0; - if (_sff8436_length_om3(idprom) > 0) return 0; - if (_sff8436_length_copper_active(idprom) == 0) return 0; - - /* maybe, possibly an AOC breakout cable */ - return 1; -} - -/* - * Infer cable length for fixed-length (AOC) optical cables - * - * XXX roth -- may also be able to cook up a rule for SFP+ cables too. - */ -static inline int -_sff8436_qsfp_40g_aoc_length(const uint8_t *idprom) -{ - /* module should be qsfp */ - if (!SFF8436_MODULE_QSFP_PLUS(idprom) - && !SFF8436_MODULE_QSFP_PLUS_V2(idprom)) - return -1; - - /* no separable connector -- likely active */ - if (idprom[130] != SFF8436_CONN_NONE) return -1; - - /* make sure it's MM fiber */ - if (_sff8436_wavelength(idprom) != 850) return 0; - - /* does not report a fiber length, but does report a cable length */ - if (_sff8436_length_sm(idprom) > 0) return -1; - if (_sff8436_length_om1(idprom) > 0) return -1; - if (_sff8436_length_om2(idprom) > 0) return -1; - if (_sff8436_length_om3(idprom) > 0) return -1; - if (_sff8436_length_copper_active(idprom) > 0) - return _sff8436_length_copper_active(idprom); - - return -1; -} - -#endif /* __SFF_8436_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h b/packages/base/any/onlp/src/sff/module/inc/sff/8472.h deleted file mode 100644 index 5a985f3b..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/8472.h +++ /dev/null @@ -1,1021 +0,0 @@ -/************************************************************ - * - * - * 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. - * - * - ************************************************************ - * - * SFF 8472 Definitions. - * - ***********************************************************/ -#ifndef __SFF_8472_H__ -#define __SFF_8472_H__ - -#include -#include - -/****************************** - * - * All (most of) the gory details from table 3.5 of the SFF spec - * - ******************************/ - -/* identifier byte 0x00 */ - -#define SFF8472_IDENT_UNKNOWN 0x00 -#define SFF8472_IDENT_GBIC 0x01 -#define SFF8472_IDENT_BASEBOARD 0x02 -#define SFF8472_IDENT_SFP 0x03 -#define SFF8472_IDENT_XBI 0x04 -#define SFF8472_IDENT_XENPAK 0x05 -#define SFF8472_IDENT_XFP 0x06 -#define SFF8472_IDENT_XFF 0x07 -#define SFF8472_IDENT_XFPE 0x08 -#define SFF8472_IDENT_XPAK 0x09 -#define SFF8472_IDENT_X2 0x0A -#define SFF8472_IDENT_DWDM_SFP 0x0B -#define SFF8472_IDENT_QSFP 0x0C - -#define SFF8472_MODULE_SFP(idprom) \ - ((idprom[0] == SFF8472_IDENT_SFP) \ - || (idprom[0] == SFF8472_IDENT_DWDM_SFP)) - -/* connector byte 0x02 */ - -#define SFF8472_CONN_UNKNOWN 0x00 -#define SFF8472_CONN_SC 0x01 -#define SFF8472_CONN_FC1_CU 0x02 -#define SFF8472_CONN_FC2_CU 0x03 -#define SFF8472_CONN_BNC 0x04 -#define SFF8472_CONN_FC_COAX 0x05 -#define SFF8472_CONN_FJ 0x06 -#define SFF8472_CONN_LC 0x07 -#define SFF8472_CONN_MT_RJ 0x08 -#define SFF8472_CONN_MU 0x09 -#define SFF8472_CONN_SG 0x0A -#define SFF8472_CONN_SI_PIGTAIL 0x0B -#define SFF8472_CONN_MPO 0x0C -#define SFF8472_CONN_HSSDC_II 0x20 -#define SFF8472_CONN_CU_PIGTAIL 0x21 -#define SFF8472_CONN_RJ45 0x22 -#define SFF8472_CONN_NOSEP 0x23 - -/* module compliance codes (SFP type) */ - -#define SFF8472_CC3_INF_1X_CU_PASSIVE 0x01 -#define SFF8472_CC3_INF_1X_CU_ACTIVE 0x02 -#define SFF8472_CC3_INF_1X_LX 0x04 -#define SFF8472_CC3_INF_1X_SX 0x08 -#define SFF8472_CC3_XGE_BASE_SR 0x10 -#define SFF8472_CC3_XGE_BASE_LR 0x20 -#define SFF8472_CC3_XGE_BASE_LRM 0x40 -#define SFF8472_CC3_XGE_BASE_ER 0x80 - -#define SFF8472_CC4_OC48_SHORT 0x01 -#define SFF8472_CC4_OC48_INTERMEDIATE 0x02 -#define SFF8472_CC4_OC48_LONG 0x04 -#define SFF8472_CC4_SONET 0x18 -#define SFF8472_CC4_OC192_SHORT 0x20 -#define SFF8472_CC4_ESCON_SMF 0x40 -#define SFF8472_CC4_ESCON_MMF 0x80 - -#define SFF8472_CC5_OC3_SHORT 0x01 -#define SFF8472_CC5_OC3_SMM_INTERMEDIATE 0x02 -#define SFF8472_CC5_OC3_SMM_LONG 0x04 -#define SFF8472_CC5_UNALLOCATED1 0x08 -#define SFF8472_CC5_OC12_SHORT 0x10 -#define SFF8472_CC5_OC12_SMM_INTERMEDIATE 0x20 -#define SFF8472_CC5_OC12_SMM_LONG 0x40 -#define SFF8472_CC5_UNALLOCATED2 0x80 - -#define SFF8472_CC6_GBE_BASE_SX 0x01 -#define SFF8472_CC6_GBE_BASE_LX 0x02 -#define SFF8472_CC6_GBE_BASE_CX 0x04 -#define SFF8472_CC6_GBE_BASE_T 0x08 -#define SFF8472_CC6_CBE_BASE_LX 0x10 -#define SFF8472_CC6_CBE_BASE_FX 0x20 -#define SFF8472_CC6_BASE_BX10 0x40 -#define SFF8472_CC6_BASE_PX 0x80 - -#define SFF8472_CC7_FC_TECH_EL 0x01 -#define SFF8472_CC7_FC_TECH_LC 0x02 -#define SFF8472_CC7_FC_TECH_SA 0x04 -#define SFF8472_CC7_FC_MEDIUM 0x08 -#define SFF8472_CC7_FC_LONG 0x10 -#define SFF8472_CC7_FC_INTERMEDIATE 0x20 -#define SFF8472_CC7_FC_SHORT 0x40 -#define SFF8472_CC7_FC_VERY_LONG 0x80 - -#define SFF8472_CC8_UNALLOCATED1 0x03 -#define SFF8472_CC8_SFP_PASSIVE 0x04 -#define SFF8472_CC8_SFP_ACTIVE 0x08 -#define SFF8472_CC8_FC_TECH_LL 0x10 -#define SFF8472_CC8_FC_TECH_SL 0x20 -#define SFF8472_CC8_FC_TECH_SN 0x40 -#define SFF8472_CC8_FC_TECH_EL 0x80 - -#define SFF8472_CC9_FC_MEDIA_SM 0x01 -#define SFF8472_CC9_UNALLOCATED1 0x02 -#define SFF8472_CC9_FC_MEDIA_M5 0x04 -#define SFF8472_CC9_FC_MEDIA_M6 0x08 -#define SFF8472_CC9_FC_MEDIA_TV 0x10 -#define SFF8472_CC9_FC_MEDIA_MI 0x20 -#define SFF8472_CC9_FC_MEDIA_TP 0x40 -#define SFF8472_CC9_FC_MEDIA_TW 0x80 - -#define SFF8472_CC10_FC_SPEED_100 0x01 -#define SFF8472_CC10_UNALLOCATED1 0x02 -#define SFF8472_CC10_FC_SPEED_200 0x04 -#define SFF8472_CC10_FC_SPEED_3200 0x08 -#define SFF8472_CC10_FC_SPEED_400 0x10 -#define SFF8472_CC10_FC_SPEED_1600 0x20 -#define SFF8472_CC10_FC_SPEED_800 0x40 -#define SFF8472_CC10_FC_SPEED_1200 0x80 - -#define SFF8472_CC36_XGE_UNALLOCATED 0x01 -#define SFF8472_CC36_UNALLOCATED1 0xF7 -#define SFF8472_CC36_100G_25G_SR 0x02 -#define SFF8472_CC36_100G_25G_LR 0x03 -#define SFF8472_CC36_100G_25G_AOC_1 0x01 -#define SFF8472_CC36_100G_25G_AOC_2 0x18 - -#define SFF8471_CC60_FC_PI_4_LIMITING 0x08 -#define SFF8471_CC60_SFF8431_LIMITING 0x04 -#define SFF8471_CC60_FC_PI_4 0x02 -#define SFF8471_CC60_SFF8431 0x01 - -/* diagnostic monitoring type 0x92 */ -#define SFF8472_DOM_IMPL 0x40 -#define SFF8472_DOM_EXTCAL 0x10 -#define SFF8472_DOM_RXPWRTYPE 0x08 - -#define SFF8472_DOM_SUPPORTED(idprom) \ - ((idprom[92] & SFF8472_DOM_IMPL)? 1:0) -#define SFF8472_DOM_USE_EXTCAL(idprom) \ - ((idprom[92] & SFF8472_DOM_EXTCAL)? 1:0) -#define SFF8472_DOM_GET_RXPWR_TYPE(idprom) \ - ((idprom[92] & SFF8472_DOM_RXPWRTYPE)? 1:0) - -/* SFF8472 A2 registers */ - -/* 32-bit little-endian calibration constants */ -#define SFF8472_CAL_RXPWR4 56 -#define SFF8472_CAL_RXPWR3 60 -#define SFF8472_CAL_RXPWR2 64 -#define SFF8472_CAL_RXPWR1 68 -#define SFF8472_CAL_RXPWR0 72 - -/* 16-bit little endian calibration constants */ -#define SFF8472_CAL_TXI_SLP 76 -#define SFF8472_CAL_TXI_OFF 78 -#define SFF8472_CAL_TXPWR_SLP 80 -#define SFF8472_CAL_TXPWR_OFF 82 -#define SFF8472_CAL_T_SLP 84 -#define SFF8472_CAL_T_OFF 86 -#define SFF8472_CAL_V_SLP 88 -#define SFF8472_CAL_V_OFF 90 - -#define SFF8472_RX_PWR(dom) \ - (dom[104] << 8 | dom[104 + 1]) -#define SFF8472_BIAS_CUR(dom) \ - (dom[100] << 8 | dom[100 + 1]) -#define SFF8472_SFP_VOLT(dom) \ - (dom[98] << 8 | dom[98 + 1]) -#define SFF8472_TX_PWR(dom) \ - (dom[102] << 8 | dom[102 + 1]) -#define SFF8472_SFP_TEMP(dom) \ - (dom[96] << 8 | dom[96 + 1]) - -#define SFF8472_MEDIA_XGE_SR(idprom) \ - ((idprom[3] & SFF8472_CC3_XGE_BASE_SR) != 0) -#define SFF8472_MEDIA_XGE_LR(idprom) \ - ((idprom[3] & SFF8472_CC3_XGE_BASE_LR) != 0) -#define SFF8472_MEDIA_XGE_LRM(idprom) \ - ((idprom[3] & SFF8472_CC3_XGE_BASE_LRM) != 0) -#define SFF8472_MEDIA_XGE_ER(idprom) \ - ((idprom[3] & SFF8472_CC3_XGE_BASE_ER) != 0) - -#define SFF8472_MEDIA_LENGTH_ZX(idprom) \ - (idprom[14] >= 70) - -/* - * some CR cables identify as infiniband copper - * some CR cables identify as FC twinax - * some CR cables identify their electrical compliance - * using bytes 60,61 - * some CR cables identify as FC electrical intra- - * or inter-enclosure (bytes 7, 8) - */ - -static inline int -_sff8472_inf_1x(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 1; - return 0; -} - -static inline int -_sff8472_inf_1x_cu_active(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 0; - - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 1; - - return 0; -} - -static inline int -_sff8472_inf_1x_cu_passive(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 0; - - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 1; - - return 0; -} - -static inline int -_sff8472_fc_media(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 1; - return 0; -} - -static inline int -_sff8472_fc_media_tw(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 0; - - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 1; - - return 0; -} - -static inline int -_sff8472_fc_media_sm(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 0; - - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 1; - return 0; -} - -static inline int -_sff8472_fc_media_mm(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 0; - - if (((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) - && ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) == 0)) return 1; - if (((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) == 0) - && ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0)) return 1; - - return 0; -} - -static inline int -_sff8472_tech_fc(const uint8_t* idprom) -{ - if ((idprom[7] & SFF8472_CC7_FC_TECH_EL) != 0) return 1; - if ((idprom[7] & SFF8472_CC7_FC_TECH_LC) != 0) return 1; - if ((idprom[7] & SFF8472_CC7_FC_TECH_SA) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_EL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_LL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SN) != 0) return 1; - return 0; -} - -static inline int -_sff8472_tech_fc_el(const uint8_t* idprom) -{ - /* non-EL types */ - if ((idprom[7] & SFF8472_CC7_FC_TECH_LC) != 0) return 0; - if ((idprom[7] & SFF8472_CC7_FC_TECH_SA) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_LL) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SL) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SN) != 0) return 0; - - if (((idprom[7] & SFF8472_CC7_FC_TECH_EL) != 0) - || ((idprom[8] & SFF8472_CC8_FC_TECH_EL) != 0)) - return 1; - - return 0; -} - -static inline int -_sff8472_tech_fc_ll(const uint8_t* idprom) -{ - /* non-LL types */ - if ((idprom[7] & SFF8472_CC7_FC_TECH_EL) != 0) return 0; - if ((idprom[7] & SFF8472_CC7_FC_TECH_LC) != 0) return 0; - if ((idprom[7] & SFF8472_CC7_FC_TECH_SA) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SL) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SN) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_EL) != 0) return 0; - - if (((idprom[8] & SFF8472_CC8_FC_TECH_LL) != 0)) - return 1; - - return 0; -} - -/* do not specify an FC speed code unless you are actually FC */ -static inline int -_sff8472_fc_speed_ok(const uint8_t* idprom) -{ - if (_sff8472_tech_fc(idprom) - && (idprom[10] != 0)) - return 1; - if (!_sff8472_tech_fc(idprom) - && (idprom[10] == 0)) - return 1; - return 0; -} - -/* - * for dual ethernet/fc modules, we can infer the ethernet - * speed from the max FC speed - * (like, if the module mi-identifies itself as 10G and 1G - */ -static inline int -_sff8472_fc_speed_1g(const uint8_t *idprom) -{ - /* not FC, cannot infer speed */ - if (!_sff8472_tech_fc(idprom)) - return 0; - - /* 100MByte and 200MByte should be sufficient to identify as 1G */ - if (((idprom[10] & SFF8472_CC10_FC_SPEED_100) != 0) - || ((idprom[10] & SFF8472_CC10_FC_SPEED_200) != 0)) - return 1; - - return 0; -} - -static inline int -_sff8472_fc_speed_10g(const uint8_t *idprom) -{ - /* not FC, cannot infer speed */ - if (!_sff8472_tech_fc(idprom)) - return 0; - - /* check for any speed close to 10G */ - if (((idprom[10] & SFF8472_CC10_FC_SPEED_800) != 0) - || ((idprom[10] & SFF8472_CC10_FC_SPEED_1200) != 0) - || ((idprom[10] & SFF8472_CC10_FC_SPEED_1600) != 0) - || ((idprom[10] & SFF8472_CC10_FC_SPEED_3200) != 0)) - return 1; - - return 0; -} - -/* - * XXX roth - * some CR cables do not list an SFP+ active/passive bit, - * but register as active or passive via infiniband instead - */ - -static inline int -_sff8472_sfp_plus_passive(const uint8_t* idprom) -{ - if ((idprom[8] & SFF8472_CC8_SFP_PASSIVE) != 0) return 1; - - /* also allow pre-standard cables identifying as infiniband */ - if (_sff8472_inf_1x_cu_passive(idprom)) return 1; - - return 0; -} - -static inline int -_sff8472_sfp_plus_active(const uint8_t* idprom) -{ - if ((idprom[8] & SFF8472_CC8_SFP_ACTIVE) != 0) return 1; - - /* also allow pre-standard cables identifying as infiniband */ - if (_sff8472_inf_1x_cu_active(idprom)) return 1; - - return 0; -} - -/* - * XXX roth - * some pre-standard CR cables report a "wavelength" - * in byte 60, 61, pretending to be an optical module - */ - -#define _SFF8472_WAVELENGTH(idprom) \ - ((idprom[60] << 8) | idprom[61]) - -#define _SFF8472_COMPLIANCE_UNSPEC(idprom) \ - ((idprom[60] == 0) \ - && (idprom[61] == 0)) - -static inline int -_sff8472_compliance_passive_fc(const uint8_t* idprom) -{ - if (idprom[61] != 0) return 0; - - int byte = idprom[60]; - - if ((byte & SFF8471_CC60_FC_PI_4) == 0) return 0; - - /* no other wavelength-ish bits */ - byte &= ~SFF8471_CC60_FC_PI_4; - byte &= ~SFF8471_CC60_SFF8431; - if (byte != 0) return 0; - - return 1; -} - -static inline int -_sff8472_compliance_passive_sff(const uint8_t* idprom) -{ - if (idprom[61] != 0) return 0; - - int byte = idprom[60]; - - if ((byte & SFF8471_CC60_SFF8431) == 0) return 0; - - /* no other wavelength-ish bits */ - byte &= ~SFF8471_CC60_FC_PI_4; - byte &= ~SFF8471_CC60_SFF8431; - if (byte != 0) return 0; - - return 1; -} - -static inline int -_sff8472_compliance_active_fc(const uint8_t* idprom) -{ - if (idprom[61] != 0) return 0; - - int byte = idprom[60]; - - if (((byte & SFF8471_CC60_FC_PI_4) == 0) - && ((byte & SFF8471_CC60_FC_PI_4_LIMITING) == 0)) - return 0; - - /* no other wavelength-ish bits */ - byte &= ~SFF8471_CC60_FC_PI_4; - byte &= ~SFF8471_CC60_FC_PI_4_LIMITING; - byte &= ~SFF8471_CC60_SFF8431; - byte &= ~SFF8471_CC60_SFF8431_LIMITING; - if (byte != 0) return 0; - - if (idprom[61] != 0) return 0; - - return 1; -} - -static inline int -_sff8472_compliance_active_sff(const uint8_t* idprom) -{ - int byte = idprom[60]; - - if (((byte & SFF8471_CC60_SFF8431) == 0) - && ((byte & SFF8471_CC60_SFF8431_LIMITING) == 0)) - return 0; - - /* no other wavelength-ish bits */ - byte &= ~SFF8471_CC60_FC_PI_4; - byte &= ~SFF8471_CC60_FC_PI_4_LIMITING; - byte &= ~SFF8471_CC60_SFF8431; - byte &= ~SFF8471_CC60_SFF8431_LIMITING; - if (byte != 0) return 0; - - if (idprom[61] != 0) return 0; - - return 1; -} - -/* - * Cisco pre-standard CR cables - */ -static inline int -_sff8472_hack_cr(const uint8_t* idprom) -{ - /* vendor is 'OEM' */ - if (SFF_STRNCMP((char*)idprom+20, "OEM ", 4) != 0) return 0; - - /* model reads like 'SFP-H10GB-CU...' */ - if (SFF_STRNCMP((char*)idprom+40, "SFP-H10GB-CU", 12) != 0) return 0; - - /* S/N reads like 'CSC...' */ - if (SFF_STRNCMP((char*)idprom+68, "CSC", 3) != 0) return 0; - - /* - * congratulations, you have an expensive Cisco - * pre-standard CR cable. - */ - return 1; -} - -#define SFF8472_MEDIA_GBE_SX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_SX) != 0) -#define SFF8472_MEDIA_GBE_LX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_LX) != 0) -#define SFF8472_MEDIA_GBE_CX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_CX) != 0) -#define SFF8472_MEDIA_GBE_T(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_T) != 0) - -#define SFF8472_MEDIA_CBE_LX(idprom) \ - ((idprom[6] & SFF8472_CC6_CBE_BASE_LX) != 0) -#define SFF8472_MEDIA_CBE_FX(idprom) \ - ((idprom[6] & SFF8472_CC6_CBE_BASE_FX) != 0) - -/* - * XXX roth - * ZR Finisar optics don't list any ethernet - * or FC compliance, but *do* identify as having a high bit rate - */ - -static inline int -_sff8472_bitrate_xge(const uint8_t *idprom) -{ - if (idprom[12] == 0) - return 0; - if (idprom[12] == 0xFF) - return 0; - long long br = (long long) idprom[12] * 100*1000000; - if (br > 10LL*1000*1000000) - return 1; - return 0; -} - -static inline int -_sff8472_bitrate_gbe(const uint8_t *idprom) -{ - if (idprom[12] == 0) - return 0; - if (idprom[12] == 0xFF) - return 0; - long long br = (long long) idprom[12] * 100*1000000; - if (br > 1LL*1000*1000000 && br < 5LL*1000*1000000) - return 1; - return 0; -} - -static inline int -_sff8472_length_sm(const uint8_t *idprom) -{ - if ((idprom[14] == 0) && (idprom[15] == 0)) return 0; - if (idprom[14] != 0) - return idprom[14] * 1000; - return idprom[15] * 100; -} - -static inline int -_sff8472_length_om2(const uint8_t *idprom) -{ - return idprom[16] * 10; -} - -static inline int -_sff8472_length_om1(const uint8_t *idprom) -{ - return idprom[17] * 10; -} - -static inline int -_sff8472_length_om4(const uint8_t *idprom) -{ - return idprom[18] * 10; -} - -static inline int -_sff8472_length_cu(const uint8_t *idprom) -{ - return idprom[18]; -} - -static inline int -_sff8472_length_om3(const uint8_t *idprom) -{ - return idprom[19] * 10; -} - -/* grab-bag to detect pre-standard CR media */ -static inline int -_sff8472_media_cr_passive(const uint8_t* idprom) -{ - int maybe = 0; - - if (_sff8472_inf_1x_cu_passive(idprom)) - maybe = 1; - else if (_sff8472_inf_1x(idprom)) - return 0; - - if (_sff8472_tech_fc_el(idprom)) - maybe = 1; - else if (_sff8472_tech_fc(idprom)) - return 0; - - if (idprom[4] != 0) return 0; - if (idprom[5] != 0) return 0; - /* - * XXX roth -- PAN-934 -- Tyco CR cable advertises 1000BASE-CX, - * presumably because it is a 2-wire cable - */ - if ((idprom[6] != SFF8472_CC6_GBE_BASE_CX) - && (idprom[6] != 0)) - return 0; - - if (_sff8472_sfp_plus_passive(idprom)) - maybe = 1; - - if (_sff8472_fc_media_tw(idprom)) - maybe = 1; - else if (_sff8472_fc_media(idprom)) - return 0; - - if (!_sff8472_fc_speed_ok(idprom)) - return 0; - - /* - * XXX roth -- PAN-934 -- once we relax the checks here - * for 1000BASE-CX, we need to make sure we don't accept any - * 1G cables... make sure the FC speed is specified, - * and is high enough. - */ - if ((idprom[6] == SFF8472_CC6_GBE_BASE_CX) - && !_sff8472_tech_fc(idprom) - && !_sff8472_bitrate_xge(idprom)) - return 0; - if ((idprom[6] == SFF8472_CC6_GBE_BASE_CX) - && _sff8472_tech_fc(idprom) - && !_sff8472_fc_speed_10g(idprom)) - return 0; - - /* - * PAN-1233 -- cable identifies as 1000BASE-CX with a high BR - */ - if ((idprom[6] == SFF8472_CC6_GBE_BASE_CX) - && (_sff8472_length_cu(idprom) > 0) - && (_sff8472_bitrate_xge(idprom))) - maybe = 1; - - if (_sff8472_hack_cr(idprom)) - maybe = 1; - - if (maybe) { - if (!_sff8472_compliance_passive_fc(idprom) - && !_sff8472_compliance_passive_sff(idprom) - && (_SFF8472_WAVELENGTH(idprom) != 850) - && !_SFF8472_COMPLIANCE_UNSPEC(idprom) - && !_sff8472_hack_cr(idprom)) - return 0; - } - - return maybe; -} - -static inline int -_sff8472_media_cr_active(const uint8_t* idprom) -{ - int maybe = 0; - - if (_sff8472_inf_1x_cu_active(idprom)) - maybe = 1; - else if (_sff8472_inf_1x(idprom)) - return 0; - - if (_sff8472_tech_fc_el(idprom)) - maybe = 1; - else if (_sff8472_tech_fc(idprom)) - return 0; - - if (idprom[4] != 0) return 0; - if (idprom[5] != 0) return 0; - /* - * XXX roth -- PAN-1111 -- 3M CR cable advertises 1000BASE-CX, - * presumably because it is a 2-wire cable - */ - if ((idprom[6] != SFF8472_CC6_GBE_BASE_CX) - && (idprom[6] != 0)) - return 0; - - if (_sff8472_sfp_plus_active(idprom)) - maybe = 1; - - if (_sff8472_fc_media_tw(idprom)) - maybe = 1; - else if (_sff8472_fc_media(idprom)) - return 0; - - if (!_sff8472_fc_speed_ok(idprom)) - return 0; - - /* - * XXX roth -- PAN-1111 -- yet another CR cable - * that advertises as 1000BASE-CX. - */ - if ((idprom[6] == SFF8472_CC6_GBE_BASE_CX) - && !_sff8472_tech_fc(idprom)) - return 0; - if ((idprom[6] == SFF8472_CC6_GBE_BASE_CX) - && _sff8472_tech_fc(idprom) - && !_sff8472_fc_speed_10g(idprom)) - return 0; - - if (maybe) { - if (!_sff8472_compliance_active_fc(idprom) - && !_sff8472_compliance_active_sff(idprom) - && !_SFF8472_COMPLIANCE_UNSPEC(idprom)) - return 0; - } - - return maybe; -} - -static inline int -_sff8472_media_zr(const uint8_t *idprom) -{ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - /* should be LC connector */ - if ((idprom[2] & SFF8472_CONN_LC) == 0) return 0; - - /* do not advertise any other infiniband or ethernet features */ - if (_sff8472_inf_1x(idprom)) return 0; - if (SFF8472_MEDIA_XGE_SR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8472_MEDIA_XGE_ER(idprom)) return 0; - - /* JSM-01ZWBA1 from JDSU does not have FC field(idprom[7~9] programmed, - * so check other fields first */ - /* at least 10GbE */ - if (!_sff8472_bitrate_xge(idprom)) return 0; - - /* JSM-01ZWBA1 from JDSU is 80km */ - if (idprom[14] == 80) - return 1; - - /* advertise media and tech as per FC */ - if (_sff8472_tech_fc_ll(idprom) == 0) return 0; - if (_sff8472_fc_media_sm(idprom) == 0) return 0; - /* at least 40km of single-mode */ - if ((idprom[14] > 40) && (idprom[15] == 0xff)) - return 1; - - return 0; - -} - -static inline int -_sff8472_media_srlite(const uint8_t *idprom) -{ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - /* should be LC connector */ - if ((idprom[2] & SFF8472_CONN_LC) == 0) return 0; - - /* do not advertise any other infiniband or ethernet features */ - if (_sff8472_inf_1x(idprom)) return 0; - if (SFF8472_MEDIA_XGE_SR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8472_MEDIA_XGE_ER(idprom)) return 0; - - /* do not advertise FC media */ - if (_sff8472_fc_media(idprom)) return 0; - if (_sff8472_tech_fc(idprom)) return 0; - - /* at least 10GbE */ - if (!_sff8472_bitrate_xge(idprom)) return 0; - - /* no single-mode fiber length */ - if (idprom[14] != 0) return 0; - if (idprom[15] != 0) return 0; - - /* some non-zero multi-mode fiber length */ - if (_sff8472_length_sm(idprom)) return 0; - if (_sff8472_length_om1(idprom)) return 1; - if (_sff8472_length_om2(idprom)) return 1; - if (_sff8472_length_om3(idprom)) return 1; - if (_sff8472_length_om4(idprom)) return 1; - return 0; - -} - -/* - * some modules (e.g. Finisar FTRJ8519P1BNL-B1, 1G Ethernet / - * 2G fiber) mis-identify as supporting 10G *and* 1G; - * in this case we do not want to enable 10G mode; - * we can verify this by looking at the FC speed field - */ - -static inline int -_sff8472_media_gbe_sx_fc_hack(const uint8_t *idprom) -{ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - /* module should report as SX */ - if (!SFF8472_MEDIA_GBE_SX(idprom)) return 0; - - /* module erroneously reports as 10G */ - if (!SFF8472_MEDIA_XGE_SR(idprom) - || !SFF8472_MEDIA_XGE_LR(idprom) - || !SFF8472_MEDIA_XGE_LRM(idprom) - || !SFF8472_MEDIA_XGE_ER(idprom)) return 0; - - /* module reports as 1G FC, but not 10G */ - if (_sff8472_fc_speed_1g(idprom) - && !_sff8472_fc_speed_10g(idprom)) - return 1; - else - return 0; -} - -static inline int -_sff8472_media_gbe_lx_fc_hack(const uint8_t *idprom) -{ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - /* module should report as LX */ - if (!SFF8472_MEDIA_GBE_LX(idprom)) return 0; - - /* module erroneously reports as 10G */ - if (!SFF8472_MEDIA_XGE_SR(idprom) - || !SFF8472_MEDIA_XGE_LR(idprom) - || !SFF8472_MEDIA_XGE_LRM(idprom) - || !SFF8472_MEDIA_XGE_ER(idprom)) return 0; - - /* module reports as 1G FC, but not 10G */ - if (_sff8472_fc_speed_1g(idprom) - && !_sff8472_fc_speed_10g(idprom)) - return 1; - else - return 0; -} - -/* - * Try to identify active SR cables, like breakouts - */ -static inline int -_sff8472_sfp_10g_aoc(const uint8_t *idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - /* should report any normal specs */ - if (_sff8472_fc_media(idprom)) return 0; - if (_sff8472_tech_fc(idprom)) return 0; - - if (SFF8472_MEDIA_XGE_SR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LR(idprom)) return 0; - if (SFF8472_MEDIA_XGE_LRM(idprom)) return 0; - if (SFF8472_MEDIA_XGE_ER(idprom)) return 0; - - if (SFF8472_MEDIA_GBE_SX(idprom)) return 0; - if (SFF8472_MEDIA_GBE_LX(idprom)) return 0; - if (SFF8472_MEDIA_GBE_CX(idprom)) return 0; - if (SFF8472_MEDIA_GBE_T(idprom)) return 0; - if (SFF8472_MEDIA_CBE_LX(idprom)) return 0; - if (SFF8472_MEDIA_CBE_FX(idprom)) return 0; - - /* should be active */ - if (!_sff8472_sfp_plus_active(idprom)) return 0; - - /* should not report passive cable compliance */ - if (_sff8472_compliance_passive_fc(idprom)) return 0; - if (_sff8472_compliance_passive_sff(idprom)) return 0; - - /* should report active FC or SFF */ - if (!_sff8472_compliance_active_fc(idprom) - && !_sff8472_compliance_active_sff(idprom)) - return 0; - - /* nominal BR should be 10g */ - if (!_sff8472_bitrate_xge(idprom)) return 0; - - /* should be a short-ish cable */ - if (_sff8472_length_sm(idprom)) return 0; - if (_sff8472_length_om1(idprom)) return 0; - if (_sff8472_length_om2(idprom)) return 0; - if (_sff8472_length_om3(idprom)) return 0; - - if (!_sff8472_length_cu(idprom)) return 0; - if (_sff8472_length_cu(idprom) > 30) return 0; - - /* congratulations, probably an active optical cable */ - return 1; -} - -/* - * Infer cable length for fixed-length (AOC) optical cables - */ -static inline int -_sff8472_sfp_10g_aoc_length(const uint8_t *idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return -1; - - /* does not report a fiber length, but does report a cable length */ - if (_sff8472_length_sm(idprom) > 0) return -1; - if (_sff8472_length_om1(idprom) > 0) return -1; - if (_sff8472_length_om2(idprom) > 0) return -1; - if (_sff8472_length_om3(idprom) > 0) return -1; - if (_sff8472_length_cu(idprom) > 0) - return _sff8472_length_cu(idprom); - - return -1; -} - -/* - * SFP28 - */ -static inline int -_sff8472_media_sfp28_cr(const uint8_t* idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) == 0) return 0; - if (idprom[12] == 0xFF) return 1; - - return 0; -} - -static inline int -_sff8472_media_sfp28_sr(const uint8_t* idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - if (idprom[12] != 0xFF) return 0; - if (idprom[36] == SFF8472_CC36_100G_25G_SR) return 1; - - return 0; -} - -static inline int -_sff8472_media_sfp28_lr(const uint8_t* idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - if (idprom[12] != 0xFF) return 0; - if (idprom[36] == SFF8472_CC36_100G_25G_LR) return 1; - - return 0; -} - -static inline int -_sff8472_media_sfp28_aoc(const uint8_t* idprom) -{ - /* module should be sfp */ - if (!SFF8472_MODULE_SFP(idprom)) return 0; - - if (idprom[12] != 0xFF) return 0; - if ((idprom[36] == SFF8472_CC36_100G_25G_AOC_1) || - (idprom[36] == SFF8472_CC36_100G_25G_AOC_2)) { - return 1; - } - - return 0; -} -#endif diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/8636.h b/packages/base/any/onlp/src/sff/module/inc/sff/8636.h deleted file mode 100644 index eafc5f69..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/8636.h +++ /dev/null @@ -1,187 +0,0 @@ -/********************************************************************** - * - * 8636.h - * - * idprom defintions for QSFP+ modules. - * - **********************************************************************/ - -#ifndef __SFF_8636_H__ -#define __SFF_8636_H__ - -#include -#include "sff/8472.h" - -/* identifier, bytes 128 page 0 (also byte 0) */ - -#define SFF8636_IDENT_UNKNOWN SFF8472_IDENT_UNKNOWN -#define SFF8636_IDENT_GBIC SFF8472_IDENT_GBIC -#define SFF8636_IDENT_BASEBOARD SFF8472_IDENT_BASEBOARD -#define SFF8636_IDENT_SFP SFF8472_IDENT_SFP -#define SFF8636_IDENT_XBI SFF8472_IDENT_XBI -#define SFF8636_IDENT_XENPAK SFF8472_IDENT_XENPAK -#define SFF8636_IDENT_XFP SFF8472_IDENT_XFP -#define SFF8636_IDENT_XFF SFF8472_IDENT_XFF -#define SFF8636_IDENT_XFPE SFF8472_IDENT_XFPE -#define SFF8636_IDENT_XPAK SFF8472_IDENT_XPAK -#define SFF8636_IDENT_X2 SFF8472_IDENT_X2 -#define SFF8636_IDENT_DWDM_SFP SFF8472_IDENT_DWDM_SFP -#define SFF8636_IDENT_QSFP SFF8472_IDENT_QSFP - -/* additional values from this spec */ -#define SFF8636_IDENT_QSFP_PLUS 0x0D -#define SFF8636_IDENT_QSFP28 0x11 - -#define SFF8636_MODULE_QSFP28(idprom) \ - (idprom[0] == SFF8636_IDENT_QSFP28) - -#define SFF8636_RX1_PWR(idprom) \ - (idprom[34] << 8 | idprom[34 + 1]) -#define SFF8636_RX2_PWR(idprom) \ - (idprom[36] << 8 | idprom[36 + 1]) -#define SFF8636_RX3_PWR(idprom) \ - (idprom[38] << 8 | idprom[38 + 1]) -#define SFF8636_RX4_PWR(idprom) \ - (idprom[40] << 8 | idprom[40 + 1]) - -#define SFF8636_TX1_BIAS(idprom) \ - (idprom[42] << 8 | idprom[42 + 1]) -#define SFF8636_TX2_BIAS(idprom) \ - (idprom[44] << 8 | idprom[44 + 1]) -#define SFF8636_TX3_BIAS(idprom) \ - (idprom[46] << 8 | idprom[46 + 1]) -#define SFF8636_TX4_BIAS(idprom) \ - (idprom[48] << 8 | idprom[48 + 1]) - -#define SFF8636_TX1_PWR(idprom) \ - (idprom[50] << 8 | idprom[50 + 1]) -#define SFF8636_TX2_PWR(idprom) \ - (idprom[52] << 8 | idprom[52 + 1]) -#define SFF8636_TX3_PWR(idprom) \ - (idprom[54] << 8 | idprom[54 + 1]) -#define SFF8636_TX4_PWR(idprom) \ - (idprom[56] << 8 | idprom[56 + 1]) - -#define SFF8636_SFP_VOLT(idprom) \ - (idprom[26] << 8 | idprom[26 + 1]) -#define SFF8636_SFP_TEMP(idprom) \ - (idprom[22] << 8 | idprom[22 + 1]) - -/* connector value, byte 130 page 0 */ - -#define SFF8636_CONN_UNKNOWN SFF8472_CONN_UNKNOWN -#define SFF8636_CONN_SC SFF8472_CONN_SC -#define SFF8636_CONN_FC1_CU SFF8472_CONN_FC1_CU -#define SFF8636_CONN_FC2_CU SFF8472_CONN_FC2_CU -#define SFF8636_CONN_BNC SFF8472_CONN_BNC -#define SFF8636_CONN_FC_COAX SFF8472_CONN_FC_COAX -#define SFF8636_CONN_FJ SFF8472_CONN_FJ -#define SFF8636_CONN_LC SFF8472_CONN_LC -#define SFF8636_CONN_MT_RJ SFF8472_CONN_MT_RJ -#define SFF8636_CONN_MU SFF8472_CONN_MU -#define SFF8636_CONN_SG SFF8472_CONN_SG -#define SFF8636_CONN_SI_PIGTAIL SFF8472_CONN_SI_PIGTAIL -#define SFF8636_CONN_MPO SFF8472_CONN_MPO -#define SFF8636_CONN_HSSDC_II SFF8472_CONN_HSSDC_II -#define SFF8636_CONN_CU_PIGTAIL SFF8472_CONN_CU_PIGTAIL -#define SFF8636_CONN_RJ45 SFF8472_CONN_RJ45 - -/* addtional values from this spec */ -#define SFF8636_CONN_NONE 0x23 - -/* Amphenol QSFP, identified as "QSFP" (not "QSFP+") and copper - pigtail */ -#define SFF8636_MEDIA_40GE_CR(idprom) \ - (idprom[130] == SFF8636_CONN_CU_PIGTAIL) - -/* QSFP+ compliance codes, bytes 131-138 */ -#define SFF8636_CC131_EXTENDED 0x80 -#define SFF8636_CC131_XGE_BASE_LRM SFF8472_CC3_XGE_BASE_LRM -#define SFF8636_CC131_XGE_BASE_LR SFF8472_CC3_XGE_BASE_LR -#define SFF8636_CC131_XGE_BASE_SR SFF8472_CC3_XGE_BASE_SR -#define SFF8636_CC131_40GE_BASE_CR4 0x08 -#define SFF8636_CC131_40GE_BASE_SR4 0x04 -#define SFF8636_CC131_40GE_BASE_LR4 0x02 -#define SFF8636_CC131_40GE_ACTIVE 0x01 - -#define SFF8636_MEDIA_EXTENDED(idprom) \ - ((idprom[131] & SFF8636_CC131_EXTENDED) != 0) - -#define SFF8636_MEDIA_XGE_LRM(idprom) \ - ((idprom[131] & SFF8636_CC131_XGE_BASE_LRM) != 0) -#define SFF8636_MEDIA_XGE_LR(idprom) \ - ((idprom[131] & SFF8636_CC131_XGE_BASE_LR) != 0) -#define SFF8636_MEDIA_XGE_SR(idprom) \ - ((idprom[131] & SFF8636_CC131_XGE_BASE_SR) != 0) - -#define SFF8636_MEDIA_40GE_CR4(idprom) \ - ((idprom[131] & SFF8636_CC131_40GE_BASE_CR4) != 0) -#define SFF8636_MEDIA_40GE_SR4(idprom) \ - ((idprom[131] & SFF8636_CC131_40GE_BASE_SR4) != 0) -#define SFF8636_MEDIA_40GE_LR4(idprom) \ - ((idprom[131] & SFF8636_CC131_40GE_BASE_LR4) != 0) -#define SFF8636_MEDIA_40GE_ACTIVE(idprom) \ - ((idprom[131] & SFF8636_CC131_40GE_ACTIVE) != 0) - -#define SFF8636_MEDIA_NONE(idprom) \ - (idprom[131] == 0) - -#define SFF8636_CC192_100GE_AOC 0x01 -#define SFF8636_CC192_100GE_SR4 0x02 -#define SFF8636_CC192_100GE_LR4 0x03 -#define SFF8636_CC192_100GE_CWDM4 0x06 -#define SFF8636_CC192_100GE_PSM4 0x07 -#define SFF8636_CC192_100GE_ACC 0x08 -#define SFF8636_CC192_100GE_CR4 0x0B -#define SFF8636_CC192_25GE_CR_S 0x0C -#define SFF8636_CC192_25GE_CR_N 0x0D -#define SFF8636_CC192_40GE_SWDM4 0x1F -#define SFF8636_CC192_100GE_SWDM4 0x20 - -#define SFF8636_MEDIA_100GE_AOC(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_AOC) -#define SFF8636_MEDIA_100GE_SR4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_SR4) -#define SFF8636_MEDIA_100GE_LR4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_LR4) -#define SFF8636_MEDIA_100GE_CWDM4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_CWDM4) -#define SFF8636_MEDIA_100GE_PSM4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_PSM4) -#define SFF8636_MEDIA_100GE_CR4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_CR4) -#define SFF8636_MEDIA_100GE_SWDM4(idprom) \ - (idprom[192] == SFF8636_CC192_100GE_SWDM4) -#define SFF8636_MEDIA_40GE_SWDM4(idprom) \ - (idprom[192] == SFF8636_CC192_40GE_SWDM4) -#define SFF8636_MEDIA_25GE_CR_S(idprom) \ - (idprom[192] == SFF8636_CC192_25GE_CR_S) -#define SFF8636_MEDIA_25GE_CR_N(idprom) \ - (idprom[192] == SFF8636_CC192_25GE_CR_N) - -#define SFF8636_RX_PWR_TYPE_MASK 0x08 -#define SFF8636_DOM_GET_RXPWR_TYPE(idprom) \ - (idprom[220] & SFF8636_RX_PWR_TYPE_MASK) -#define SFF8636_TX_PWR_SUPPORT_MASK 0x04 -#define SFF8636_DOM_GET_TXPWR_SUPPORT(idprom) \ - (idprom[220] & SFF8636_TX_PWR_SUPPORT_MASK) - -/* - * Infer cable length for fixed-length (AOC) optical cables - * - * XXX roth -- may also be able to cook up a rule for SFP+ cables too. - */ -static inline int -_sff8636_qsfp28_100g_aoc_length(const uint8_t *idprom) -{ - /* module should be qsfp28 */ - if (!SFF8636_MODULE_QSFP28(idprom)) - return -1; - - /* no separable connector -- likely active */ - if (idprom[130] != SFF8636_CONN_NONE) return -1; - - return idprom[146]; -} - -#endif /* __SFF_8636_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff.h deleted file mode 100644 index 0101cfb3..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff.h +++ /dev/null @@ -1,388 +0,0 @@ -/************************************************************ - * - * - * 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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __SFF_SFF_H__ -#define __SFF_SFF_H__ - -#include -#include - -#include - -/* */ -/** sff_media_type */ -typedef enum sff_media_type_e { - SFF_MEDIA_TYPE_COPPER, - SFF_MEDIA_TYPE_FIBER, - SFF_MEDIA_TYPE_LAST = SFF_MEDIA_TYPE_FIBER, - SFF_MEDIA_TYPE_COUNT, - SFF_MEDIA_TYPE_INVALID = -1, -} sff_media_type_t; - -/** Strings macro. */ -#define SFF_MEDIA_TYPE_STRINGS \ -{\ - "COPPER", \ - "FIBER", \ -} -/** Enum names. */ -const char* sff_media_type_name(sff_media_type_t e); - -/** Enum values. */ -int sff_media_type_value(const char* str, sff_media_type_t* e, int substr); - -/** Enum descriptions. */ -const char* sff_media_type_desc(sff_media_type_t e); - -/** validator */ -#define SFF_MEDIA_TYPE_VALID(_e) \ - ( (0 <= (_e)) && ((_e) <= SFF_MEDIA_TYPE_FIBER)) - -/** sff_media_type_map table. */ -extern aim_map_si_t sff_media_type_map[]; -/** sff_media_type_desc_map table. */ -extern aim_map_si_t sff_media_type_desc_map[]; - -/** sff_module_caps */ -typedef enum sff_module_caps_e { - SFF_MODULE_CAPS_F_100 = 1, - SFF_MODULE_CAPS_F_1G = 2, - SFF_MODULE_CAPS_F_10G = 4, - SFF_MODULE_CAPS_F_25G = 8, - SFF_MODULE_CAPS_F_40G = 16, - SFF_MODULE_CAPS_F_100G = 32, -} sff_module_caps_t; - -/** Enum names. */ -const char* sff_module_caps_name(sff_module_caps_t e); - -/** Enum values. */ -int sff_module_caps_value(const char* str, sff_module_caps_t* e, int substr); - -/** Enum descriptions. */ -const char* sff_module_caps_desc(sff_module_caps_t e); - -/** Enum validator. */ -int sff_module_caps_valid(sff_module_caps_t e); - -/** validator */ -#define SFF_MODULE_CAPS_VALID(_e) \ - (sff_module_caps_valid((_e))) - -/** sff_module_caps_map table. */ -extern aim_map_si_t sff_module_caps_map[]; -/** sff_module_caps_desc_map table. */ -extern aim_map_si_t sff_module_caps_desc_map[]; - -/** sff_module_type */ -typedef enum sff_module_type_e { - SFF_MODULE_TYPE_100G_AOC, - SFF_MODULE_TYPE_100G_BASE_CR4, - SFF_MODULE_TYPE_100G_BASE_SR4, - SFF_MODULE_TYPE_100G_BASE_LR4, - SFF_MODULE_TYPE_100G_CWDM4, - SFF_MODULE_TYPE_100G_PSM4, - SFF_MODULE_TYPE_100G_SWDM4, - SFF_MODULE_TYPE_40G_BASE_CR4, - SFF_MODULE_TYPE_40G_BASE_SR4, - SFF_MODULE_TYPE_40G_BASE_LR4, - SFF_MODULE_TYPE_40G_BASE_LM4, - SFF_MODULE_TYPE_40G_BASE_ACTIVE, - SFF_MODULE_TYPE_40G_BASE_CR, - SFF_MODULE_TYPE_40G_BASE_SR2, - SFF_MODULE_TYPE_40G_BASE_SM4, - SFF_MODULE_TYPE_40G_BASE_ER4, - SFF_MODULE_TYPE_25G_BASE_CR, - SFF_MODULE_TYPE_25G_BASE_SR, - SFF_MODULE_TYPE_25G_BASE_LR, - SFF_MODULE_TYPE_25G_BASE_AOC, - SFF_MODULE_TYPE_10G_BASE_SR, - SFF_MODULE_TYPE_10G_BASE_LR, - SFF_MODULE_TYPE_10G_BASE_LRM, - SFF_MODULE_TYPE_10G_BASE_ER, - SFF_MODULE_TYPE_10G_BASE_CR, - SFF_MODULE_TYPE_10G_BASE_SX, - SFF_MODULE_TYPE_10G_BASE_LX, - SFF_MODULE_TYPE_10G_BASE_ZR, - SFF_MODULE_TYPE_10G_BASE_SRL, - SFF_MODULE_TYPE_1G_BASE_SX, - SFF_MODULE_TYPE_1G_BASE_LX, - SFF_MODULE_TYPE_1G_BASE_ZX, - SFF_MODULE_TYPE_1G_BASE_CX, - SFF_MODULE_TYPE_1G_BASE_T, - SFF_MODULE_TYPE_100_BASE_LX, - SFF_MODULE_TYPE_100_BASE_FX, - SFF_MODULE_TYPE_4X_MUX, - SFF_MODULE_TYPE_LAST = SFF_MODULE_TYPE_4X_MUX, - SFF_MODULE_TYPE_COUNT, - SFF_MODULE_TYPE_INVALID = -1, -} sff_module_type_t; - -/** Strings macro. */ -#define SFF_MODULE_TYPE_STRINGS \ -{\ - "100G_AOC", \ - "100G_BASE_CR4", \ - "100G_BASE_SR4", \ - "100G_BASE_LR4", \ - "100G_CWDM4", \ - "100G_PSM4", \ - "100G_SWDM4", \ - "40G_BASE_CR4", \ - "40G_BASE_SR4", \ - "40G_BASE_LR4", \ - "40G_BASE_LM4", \ - "40G_BASE_ACTIVE", \ - "40G_BASE_CR", \ - "40G_BASE_SR2", \ - "40G_BASE_SM4", \ - "40G_BASE_ER4", \ - "25G_BASE_CR", \ - "25G_BASE_SR", \ - "25G_BASE_LR", \ - "25G_BASE_AOC", \ - "10G_BASE_SR", \ - "10G_BASE_LR", \ - "10G_BASE_LRM", \ - "10G_BASE_ER", \ - "10G_BASE_CR", \ - "10G_BASE_SX", \ - "10G_BASE_LX", \ - "10G_BASE_ZR", \ - "10G_BASE_SRL", \ - "1G_BASE_SX", \ - "1G_BASE_LX", \ - "1G_BASE_ZX", \ - "1G_BASE_CX", \ - "1G_BASE_T", \ - "100_BASE_LX", \ - "100_BASE_FX", \ - "4X_MUX", \ -} -/** Enum names. */ -const char* sff_module_type_name(sff_module_type_t e); - -/** Enum values. */ -int sff_module_type_value(const char* str, sff_module_type_t* e, int substr); - -/** Enum descriptions. */ -const char* sff_module_type_desc(sff_module_type_t e); - -/** validator */ -#define SFF_MODULE_TYPE_VALID(_e) \ - ( (0 <= (_e)) && ((_e) <= SFF_MODULE_TYPE_4X_MUX)) - -/** sff_module_type_map table. */ -extern aim_map_si_t sff_module_type_map[]; -/** sff_module_type_desc_map table. */ -extern aim_map_si_t sff_module_type_desc_map[]; - -/** sff_sfp_type */ -typedef enum sff_sfp_type_e { - SFF_SFP_TYPE_SFP, - SFF_SFP_TYPE_QSFP, - SFF_SFP_TYPE_QSFP_PLUS, - SFF_SFP_TYPE_QSFP28, - SFF_SFP_TYPE_SFP28, - SFF_SFP_TYPE_LAST = SFF_SFP_TYPE_SFP28, - SFF_SFP_TYPE_COUNT, - SFF_SFP_TYPE_INVALID = -1, -} sff_sfp_type_t; - -/** Strings macro. */ -#define SFF_SFP_TYPE_STRINGS \ -{\ - "SFP", \ - "QSFP", \ - "QSFP_PLUS", \ - "QSFP28", \ - "SFP28", \ -} -/** Enum names. */ -const char* sff_sfp_type_name(sff_sfp_type_t e); - -/** Enum values. */ -int sff_sfp_type_value(const char* str, sff_sfp_type_t* e, int substr); - -/** Enum descriptions. */ -const char* sff_sfp_type_desc(sff_sfp_type_t e); - -/** validator */ -#define SFF_SFP_TYPE_VALID(_e) \ - ( (0 <= (_e)) && ((_e) <= SFF_SFP_TYPE_SFP28)) - -/** sff_sfp_type_map table. */ -extern aim_map_si_t sff_sfp_type_map[]; -/** sff_sfp_type_desc_map table. */ -extern aim_map_si_t sff_sfp_type_desc_map[]; -/* */ - -/** - * @brief Determine the SFP type (from the idprom data). - * @param idprom The SFF idprom. - */ -sff_sfp_type_t sff_sfp_type_get(const uint8_t* idprom); - -/** - * @brief Determine the SFF module type (from the idprom data). - * @param idprom The SFF idprom. - */ -sff_module_type_t sff_module_type_get(const uint8_t* idprom); - -/** - * @brief Determine the SFF Media type (from the idprom data)./ - * @param idprom The SFF idprom. - */ -sff_media_type_t sff_media_type_get(sff_module_type_t mt); - -/** - * @brief Determine the SFF module capabilities (from the idprom data). - * @param idprom The SFF idprom. - * @param caps [out] Receives the capabilities. - * @returns 0 on successful parse. - * @returns < 0 on error. - */ -int sff_module_caps_get(sff_module_type_t mt, uint32_t* caps); - - -typedef struct sff_info_s { - - /** Vendor Name */ - char vendor[17]; - - /** Model Number */ - char model[17]; - - /** Serial Number */ - char serial[17]; - - /** SFP Type */ - sff_sfp_type_t sfp_type; - - /** SFP Type Name */ - const char* sfp_type_name; - - /** Module Type */ - sff_module_type_t module_type; - - /** Module Type Name */ - const char* module_type_name; - - /** Media Type */ - sff_media_type_t media_type; - - /** Media Type Name */ - const char* media_type_name; - - /** Capabilities */ - sff_module_caps_t caps; - - /** Cable length, if available */ - int length; - char length_desc[16]; -} sff_info_t; - -/** - * SFF Module Information Structure - */ -typedef struct sff_eeprom_s { - /** Raw eeprom data */ - uint8_t eeprom[256]; - - /** computed checksums for eeprom contents */ - uint8_t cc_base; - uint8_t cc_ext; - - /** Whether this EEPROM was successfully parsed and identified. */ - int identified; - - /** Parsed SFF Information */ - sff_info_t info; - -} sff_eeprom_t; - - -/** - * @brief Initialize an SFF module information structure. - * @param rv [out] Receives the data. - * @param eeprom Raw EEPROM data. - * @note if eeprom is != NULL it will be copied into rv->eeprom first. - * @note if eeprom is NULL it is assumed the rv->eeprom buffer - * has already been initialized. - */ -int sff_eeprom_parse(sff_eeprom_t* rv, uint8_t* eeprom); - -/** - * @brief Initialize an SFF module information structure from a file. - * @param rv [out] Receives thh data. - * @param fname The filename. - */ -int sff_eeprom_parse_file(sff_eeprom_t* rv, const char* fname); - -/** - * @brief Clear an sff_eeprom_t structure. - * @param eeprom The eeprom structure. - */ -void sff_eeprom_invalidate(sff_eeprom_t *info); - -/** - * @brief Determine if this is a valid SFP - * (whether or not we can parse it) - * @param info The info structure. - * @param verbose Whether to report errors on invalid contents. - */ -int sff_eeprom_validate(sff_eeprom_t *info, int verbose); - -/** - * @brief Show an sff info structure. - * @param info The info structure. - * @param pvs The output pvs. - */ -void sff_info_show(sff_info_t* info, aim_pvs_t* pvs); - -/** - * @brief Initialize an info structure based on module type. - */ -int sff_info_init(sff_info_t* pinfo, sff_module_type_t type, - const char* vendor, const char* model, const char* serial, - int length); - - -int sff_info_from_module_type(sff_info_t* info, sff_sfp_type_t st, - sff_module_type_t mt); - -#ifdef DEPENDMODULE_INCLUDE_CJSON_UTIL - -#include - -/** - * @brief Return a JSON representation of the sff_info_t structure. - * @param cj Add keys this object. If NULL a new object is created. - * @param info The info structure. - */ -cJSON* sff_info_json(cJSON* cj, sff_info_t* info); - -#endif /* DEPENDMODULE_CJSON_UTIL */ - -#endif /* __SFF_SFF_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff.x b/packages/base/any/onlp/src/sff/module/inc/sff/sff.x deleted file mode 100644 index 0b211647..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff.x +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#ifdef SFF_MEDIA_TYPE_ENTRY -SFF_MEDIA_TYPE_ENTRY(100G_AOC, 100G-AOC) -SFF_MEDIA_TYPE_ENTRY(100G_BASE_CR4, 100GBASE-CR4) -SFF_MEDIA_TYPE_ENTRY(100G_BASE_SR4, 100GBASE-SR4) -SFF_MEDIA_TYPE_ENTRY(100G_BASE_LR4, 100GBASE-LR4) -SFF_MEDIA_TYPE_ENTRY(100G_CWDM4, 100G-CWDM4) -SFF_MEDIA_TYPE_ENTRY(100G_PSM4, 100G-PSM4) -SFF_MEDIA_TYPE_ENTRY(100G_SWDM4, 100G-SWDM4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_CR4, 40GBASE-CR4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_SR4, 40GBASE-SR4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_LR4, 40GBASE-LR4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_LM4, 40GBASE-LM4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_ACTIVE, 40GBASE-ACTIVE) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_CR, 40GBASE-CR) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_SR2, 40GBASE-SR2) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_SM4, 40GBASE-SM4) -SFF_MEDIA_TYPE_ENTRY(40G_BASE_ER4, 40GBASE-ER4) -SFF_MEDIA_TYPE_ENTRY(25G_BASE_CR, 25GBASE-CR) -SFF_MEDIA_TYPE_ENTRY(25G_BASE_SR, 25GBASE-SR) -SFF_MEDIA_TYPE_ENTRY(25G_BASE_LR, 25GBASE-LR) -SFF_MEDIA_TYPE_ENTRY(25G_BASE_AOC, 25GBASE-AOC) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_SR, 10GBASE-SR) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_LR, 10GBASE-LR) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_LRM, 10GBASE-LRM) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_ER, 10GBASE-ER) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_CR, 10GBASE-CR) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_SX, 10GBASE-SX) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_LX, 10GBASE-LX) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_ZR, 10GBASE-ZR) -SFF_MEDIA_TYPE_ENTRY(10G_BASE_SRL, 10GBASE-SRL) -SFF_MEDIA_TYPE_ENTRY(1G_BASE_SX, 1GBASE-SX) -SFF_MEDIA_TYPE_ENTRY(1G_BASE_LX, 1GBASE-LX) -SFF_MEDIA_TYPE_ENTRY(1G_BASE_ZX, 1GBASE-ZX) -SFF_MEDIA_TYPE_ENTRY(1G_BASE_CX, 1GBASE-CX) -SFF_MEDIA_TYPE_ENTRY(1G_BASE_T, 1GBASE-T) -SFF_MEDIA_TYPE_ENTRY(100_BASE_LX, 100BASE-LX) -SFF_MEDIA_TYPE_ENTRY(100_BASE_FX, 100BASE-FX) -SFF_MEDIA_TYPE_ENTRY(4X_MUX, 4X-MUX) -#undef SFF_MEDIA_TYPE_ENTRY -#endif - -#ifdef SFF_MODULE_CAP_ENTRY -SFF_MODULE_CAP_ENTRY(F_100, 1) -SFF_MODULE_CAP_ENTRY(F_1G, 2) -SFF_MODULE_CAP_ENTRY(F_10G, 4) -SFF_MODULE_CAP_ENTRY(F_25G, 8) -SFF_MODULE_CAP_ENTRY(F_40G, 16) -SFF_MODULE_CAP_ENTRY(F_100G, 32) -#undef SFF_MODULE_CAP_ENTRY -#endif - -#ifdef SFF_MODULE_TYPE_ENTRY -SFF_MODULE_TYPE_ENTRY(100G_AOC, 100G-AOC) -SFF_MODULE_TYPE_ENTRY(100G_BASE_CR4, 100GBASE-CR4) -SFF_MODULE_TYPE_ENTRY(100G_BASE_SR4, 100GBASE-SR4) -SFF_MODULE_TYPE_ENTRY(100G_BASE_LR4, 100GBASE-LR4) -SFF_MODULE_TYPE_ENTRY(100G_CWDM4, 100G-CWDM4) -SFF_MODULE_TYPE_ENTRY(100G_PSM4, 100G-PSM4) -SFF_MODULE_TYPE_ENTRY(100G_SWDM4, 100G-SWDM4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_CR4, 40GBASE-CR4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_SR4, 40GBASE-SR4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_LR4, 40GBASE-LR4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_LM4, 40GBASE-LM4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_ACTIVE, 40GBASE-ACTIVE) -SFF_MODULE_TYPE_ENTRY(40G_BASE_CR, 40GBASE-CR) -SFF_MODULE_TYPE_ENTRY(40G_BASE_SR2, 40GBASE-SR2) -SFF_MODULE_TYPE_ENTRY(40G_BASE_SM4, 40GBASE-SM4) -SFF_MODULE_TYPE_ENTRY(40G_BASE_ER4, 40GBASE-ER4) -SFF_MODULE_TYPE_ENTRY(25G_BASE_CR, 25GBASE-CR) -SFF_MODULE_TYPE_ENTRY(25G_BASE_SR, 25GBASE-SR) -SFF_MODULE_TYPE_ENTRY(25G_BASE_LR, 25GBASE-LR) -SFF_MODULE_TYPE_ENTRY(25G_BASE_AOC, 25GBASE-AOC) -SFF_MODULE_TYPE_ENTRY(10G_BASE_SR, 10GBASE-SR) -SFF_MODULE_TYPE_ENTRY(10G_BASE_LR, 10GBASE-LR) -SFF_MODULE_TYPE_ENTRY(10G_BASE_LRM, 10GBASE-LRM) -SFF_MODULE_TYPE_ENTRY(10G_BASE_ER, 10GBASE-ER) -SFF_MODULE_TYPE_ENTRY(10G_BASE_CR, 10GBASE-CR) -SFF_MODULE_TYPE_ENTRY(10G_BASE_SX, 10GBASE-SX) -SFF_MODULE_TYPE_ENTRY(10G_BASE_LX, 10GBASE-LX) -SFF_MODULE_TYPE_ENTRY(10G_BASE_ZR, 10GBASE-ZR) -SFF_MODULE_TYPE_ENTRY(10G_BASE_SRL, 10GBASE-SRL) -SFF_MODULE_TYPE_ENTRY(1G_BASE_SX, 1GBASE-SX) -SFF_MODULE_TYPE_ENTRY(1G_BASE_LX, 1GBASE-LX) -SFF_MODULE_TYPE_ENTRY(1G_BASE_ZX, 1GBASE-ZX) -SFF_MODULE_TYPE_ENTRY(1G_BASE_CX, 1GBASE-CX) -SFF_MODULE_TYPE_ENTRY(1G_BASE_T, 1GBASE-T) -SFF_MODULE_TYPE_ENTRY(100_BASE_LX, 100BASE-LX) -SFF_MODULE_TYPE_ENTRY(100_BASE_FX, 100BASE-FX) -SFF_MODULE_TYPE_ENTRY(4X_MUX, 4X-MUX) -#undef SFF_MODULE_TYPE_ENTRY -#endif - -#ifdef SFF_SFP_TYPE_ENTRY -SFF_SFP_TYPE_ENTRY(SFP, SFP) -SFF_SFP_TYPE_ENTRY(QSFP, QSFP) -SFF_SFP_TYPE_ENTRY(QSFP_PLUS, QSFP+) -SFF_SFP_TYPE_ENTRY(QSFP28, QSFP28) -SFF_SFP_TYPE_ENTRY(SFP28, SFP28) -#undef SFF_SFP_TYPE_ENTRY -#endif -/* */ - -/* */ -#ifdef SFF_ENUMERATION_ENTRY -SFF_ENUMERATION_ENTRY(sff_media_type, "") -SFF_ENUMERATION_ENTRY(sff_module_caps, "") -SFF_ENUMERATION_ENTRY(sff_module_type, "") -SFF_ENUMERATION_ENTRY(sff_sfp_type, "") -#undef SFF_ENUMERATION_ENTRY -#endif -/* */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff_config.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff_config.h deleted file mode 100644 index c3e5d6de..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff_config.h +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief sff Configuration Header - * - * @addtogroup sff-config - * @{ - * - *****************************************************************************/ -#ifndef __SFF_CONFIG_H__ -#define __SFF_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef SFF_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * SFF_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef SFF_CONFIG_INCLUDE_LOGGING -#define SFF_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * SFF_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef SFF_CONFIG_LOG_OPTIONS_DEFAULT -#define SFF_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * SFF_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef SFF_CONFIG_LOG_BITS_DEFAULT -#define SFF_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * SFF_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef SFF_CONFIG_PORTING_STDLIB -#define SFF_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS SFF_CONFIG_PORTING_STDLIB -#endif - -/** - * SFF_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef SFF_CONFIG_INCLUDE_UCLI -#define SFF_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * SFF_CONFIG_INCLUDE_SFF_TOOL - * - * Include the SFF tool main entry point. */ - - -#ifndef SFF_CONFIG_INCLUDE_SFF_TOOL -#define SFF_CONFIG_INCLUDE_SFF_TOOL 0 -#endif - -/** - * SFF_CONFIG_INCLUDE_EXT_CC_CHECK - * - * Include extended checksum verification. */ - - -#ifndef SFF_CONFIG_INCLUDE_EXT_CC_CHECK -#define SFF_CONFIG_INCLUDE_EXT_CC_CHECK 0 -#endif - -/** - * SFF_CONFIG_INCLUDE_DATABASE - * - * Include eeprom database. */ - - -#ifndef SFF_CONFIG_INCLUDE_DATABASE -#define SFF_CONFIG_INCLUDE_DATABASE 1 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct sff_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} sff_config_settings_t; - -/** Configuration settings table. */ -/** sff_config_settings table. */ -extern sff_config_settings_t sff_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* sff_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int sff_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "sff_porting.h" - -#endif /* __SFF_CONFIG_H__ */ -/* @} */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff_db.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff_db.h deleted file mode 100644 index 2242cd57..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff_db.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************ - * - * - * 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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __SFF_DB_H__ -#define __SFF_DB_H__ - -#include -#include -#include - -typedef struct { - sff_eeprom_t se; -} sff_db_entry_t; - -/** - * @brief Get the database entry table. - * @param entries Receives the table pointer. - * @param count Receives the size of the table. - */ -int sff_db_get(sff_db_entry_t** entries, int* count); - -/** - * @brief Return any entry with the given module type. - * @param se Receives the information struct. - * @param type The type to retreive. - */ -int sff_db_get_type(sff_eeprom_t* se, sff_module_type_t type); - - -/** - * @brief Output the given SFF information to a database entry. - * @param info The source information. - * @param pvs The output pvs.; - * @note This is used mainly for generating new entries for the SFF db from a running system. - */ -int sff_db_entry_struct(sff_eeprom_t* se, aim_pvs_t* pvs); - -#endif /* __SFF_DB_H__ */ - diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff_dox.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff_dox.h deleted file mode 100644 index 1b99e7c9..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * sff Doxygen Header - * - *****************************************************************************/ -#ifndef __SFF_DOX_H__ -#define __SFF_DOX_H__ - -/** - * @defgroup sff sff - sff Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup sff-sff Public Interface - * @defgroup sff-config Compile Time Configuration - * @defgroup sff-porting Porting Macros - * - * @} - * - */ - -#endif /* __SFF_DOX_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/inc/sff/sff_porting.h b/packages/base/any/onlp/src/sff/module/inc/sff/sff_porting.h deleted file mode 100644 index 2425036a..00000000 --- a/packages/base/any/onlp/src/sff/module/inc/sff/sff_porting.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief sff Porting Macros. - * - * @addtogroup sff-porting - * @{ - * - *****************************************************************************/ -#ifndef __SFF_PORTING_H__ -#define __SFF_PORTING_H__ - - -/* */ -#if SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef SFF_MEMSET - #if defined(GLOBAL_MEMSET) - #define SFF_MEMSET GLOBAL_MEMSET - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_MEMSET memset - #else - #error The macro SFF_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef SFF_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define SFF_MEMCPY GLOBAL_MEMCPY - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_MEMCPY memcpy - #else - #error The macro SFF_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef SFF_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define SFF_STRNCPY GLOBAL_STRNCPY - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_STRNCPY strncpy - #else - #error The macro SFF_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef SFF_STRNCMP - #if defined(GLOBAL_STRNCMP) - #define SFF_STRNCMP GLOBAL_STRNCMP - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_STRNCMP strncmp - #else - #error The macro SFF_STRNCMP is required but cannot be defined. - #endif -#endif - -#ifndef SFF_STRLEN - #if defined(GLOBAL_STRLEN) - #define SFF_STRLEN GLOBAL_STRLEN - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_STRLEN strlen - #else - #error The macro SFF_STRLEN is required but cannot be defined. - #endif -#endif - -#ifndef SFF_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define SFF_SNPRINTF GLOBAL_SNPRINTF - #elif SFF_CONFIG_PORTING_STDLIB == 1 - #define SFF_SNPRINTF snprintf - #else - #error The macro SFF_SNPRINTF is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __SFF_PORTING_H__ */ -/* @} */ diff --git a/packages/base/any/onlp/src/sff/module/make.mk b/packages/base/any/onlp/src/sff/module/make.mk deleted file mode 100644 index 9f001b0e..00000000 --- a/packages/base/any/onlp/src/sff/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -sff_INCLUDES := -I $(THIS_DIR)inc -sff_INTERNAL_INCLUDES := -I $(THIS_DIR)src -sff_DEPENDMODULE_ENTRIES := init:sff - diff --git a/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py b/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py deleted file mode 100644 index f6028f01..00000000 --- a/packages/base/any/onlp/src/sff/module/python/onlp/sff/__init__.py +++ /dev/null @@ -1,34 +0,0 @@ -"""__init__.py - -Module init for onlp/sff -""" - -from onlp.sff.enums import * - -import ctypes - -sff_media_type = ctypes.c_int -sff_module_caps = ctypes.c_int -sff_module_type = ctypes.c_int -sff_sfp_type = ctypes.c_int - -class sff_info(ctypes.Structure): - _fields_ = [("vendor", ctypes.c_char * 17), - ("model", ctypes.c_char * 17), - ("serial", ctypes.c_char * 17), - ("sfp_type", sff_sfp_type), - ("sfp_type_name", ctypes.c_char_p), - ("module_type", sff_module_type), - ("module_type_name", ctypes.c_char_p), - ("media_type", sff_media_type), - ("media_type_name", ctypes.c_char_p), - ("caps", sff_module_caps), - ("length", ctypes.c_int), - ("desc", ctypes.c_char * 16),] - -class sff_eeprom(ctypes.Structure): - _fields_ = [("eeprom", ctypes.c_ubyte * 256), - ("cc_base", ctypes.c_ubyte), - ("cc_ext", ctypes.c_ubyte), - ("identified", ctypes.c_int), - ("info", sff_info),] diff --git a/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py b/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py deleted file mode 100644 index bba20c17..00000000 --- a/packages/base/any/onlp/src/sff/module/python/onlp/sff/enums.py +++ /dev/null @@ -1,76 +0,0 @@ -"""enums.py - -Enumerations from the SFF auto.yml. -""" - -class Enumeration(object): - @classmethod - def name(klass, value): - for (k, v) in klass.__dict__.iteritems(): - if v == value: - return k - return None - -# -class SFF_MEDIA_TYPE(Enumeration): - COPPER = 0 - FIBER = 1 - - -class SFF_MODULE_CAPS(Enumeration): - F_100 = 1 - F_1G = 2 - F_10G = 4 - F_25G = 8 - F_40G = 16 - F_100G = 32 - - -class SFF_MODULE_TYPE(Enumeration): - _100G_AOC = 0 - _100G_BASE_CR4 = 1 - _100G_BASE_SR4 = 2 - _100G_BASE_LR4 = 3 - _100G_CWDM4 = 4 - _100G_PSM4 = 5 - _100G_SWDM4 = 6 - _40G_BASE_CR4 = 7 - _40G_BASE_SR4 = 8 - _40G_BASE_LR4 = 9 - _40G_BASE_LM4 = 10 - _40G_BASE_ACTIVE = 11 - _40G_BASE_CR = 12 - _40G_BASE_SR2 = 13 - _40G_BASE_SM4 = 14 - _40G_BASE_ER4 = 15 - _25G_BASE_CR = 16 - _25G_BASE_SR = 17 - _25G_BASE_LR = 18 - _25G_BASE_AOC = 19 - _10G_BASE_SR = 20 - _10G_BASE_LR = 21 - _10G_BASE_LRM = 22 - _10G_BASE_ER = 23 - _10G_BASE_CR = 24 - _10G_BASE_SX = 25 - _10G_BASE_LX = 26 - _10G_BASE_ZR = 27 - _10G_BASE_SRL = 28 - _1G_BASE_SX = 29 - _1G_BASE_LX = 30 - _1G_BASE_ZX = 31 - _1G_BASE_CX = 32 - _1G_BASE_T = 33 - _100_BASE_LX = 34 - _100_BASE_FX = 35 - _4X_MUX = 36 - - -class SFF_SFP_TYPE(Enumeration): - SFP = 0 - QSFP = 1 - QSFP_PLUS = 2 - QSFP28 = 3 - SFP28 = 4 - -# diff --git a/packages/base/any/onlp/src/sff/module/src/8472.c b/packages/base/any/onlp/src/sff/module/src/8472.c deleted file mode 100644 index cb8d13a8..00000000 --- a/packages/base/any/onlp/src/sff/module/src/8472.c +++ /dev/null @@ -1,328 +0,0 @@ -/************************************************************ - * - * - * 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 - -#if 0 - -/* - * some CR cables identify as infiniband copper - * some CR cables identify as FC twinax - * some CR cables identify their electrical compliance - * using bytes 60,61 - * some CR cables identify as FC electrical intra- - * or inter-enclosure (bytes 7, 8) - */ - -int -sff8472_inf_1x(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 1; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 1; - return 0; -} - -int -sff8472_inf_1x_cu_active(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 0; - - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 1; - - return 0; -} - -int -sff8472_inf_1x_cu_passive(const uint8_t* idprom) -{ - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_ACTIVE) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_LX) != 0) return 0; - if ((idprom[3] & SFF8472_CC3_INF_1X_SX) != 0) return 0; - - if ((idprom[3] & SFF8472_CC3_INF_1X_CU_PASSIVE) != 0) return 1; - - return 0; -} - -int -sff8472_fc_media(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 1; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 1; - return 0; -} - -int -sff8472_fc_media_tw(const uint8_t* idprom) -{ - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_SM) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M5) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_M6) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TV) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_MI) != 0) return 0; - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TP) != 0) return 0; - - if ((idprom[9] & SFF8472_CC9_FC_MEDIA_TW) != 0) return 1; - - return 0; -} - -int -sff8472_tech_fc(const uint8_t* idprom) -{ - if ((idprom[7] & SFF8472_CC7_FC_TECH_EL) != 0) return 1; - if ((idprom[7] & SFF8472_CC7_FC_TECH_LC) != 0) return 1; - if ((idprom[7] & SFF8472_CC7_FC_TECH_SA) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_EL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_LL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SL) != 0) return 1; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SN) != 0) return 1; - return 0; -} - -int -sff8472_tech_fc_el(const uint8_t* idprom) -{ - /* non-EL types */ - if ((idprom[7] & SFF8472_CC7_FC_TECH_LC) != 0) return 0; - if ((idprom[7] & SFF8472_CC7_FC_TECH_SA) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_LL) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SL) != 0) return 0; - if ((idprom[8] & SFF8472_CC8_FC_TECH_SN) != 0) return 0; - - if (((idprom[7] & SFF8472_CC7_FC_TECH_EL) != 0) - && ((idprom[8] & SFF8472_CC8_FC_TECH_EL) == 0)) - return 1; - if (((idprom[7] & SFF8472_CC7_FC_TECH_EL) == 0) - && ((idprom[8] & SFF8472_CC8_FC_TECH_EL) != 0)) - return 1; - - return 0; -} - -/* do not specify an FC speed code unless you actually FC */ -int -sff8472_fc_speed_ok(const uint8_t* idprom) -{ - if (_sff8472_tech_fc(idprom) - && (idprom[10] != 0)) - return 1; - if (!_sff8472_tech_fc(idprom) - && (idprom[10] == 0)) - return 1; - return 0; -} - -/* - * XXX roth - * some CR cables do not list an SFP+ active/passive bit, - * but register as active or passive via infiniband instead - */ - -int -sff8472_sfp_plus_passive(const uint8_t* idprom) -{ - if ((idprom[8] & SFF8472_CC8_SFP_PASSIVE) != 0) return 1; - - /* also allow pre-standard cables identifying as infiniband */ - if (_sff8472_inf_1x_cu_passive(idprom)) return 1; - - return 0; -} - -int -sff8472_sfp_plus_active(const uint8_t* idprom) -{ - if ((idprom[8] & SFF8472_CC8_SFP_ACTIVE) != 0) return 1; - - /* also allow pre-standard cables identifying as infiniband */ - if (_sff8472_inf_1x_cu_active(idprom)) return 1; - - return 0; -} - -/* - * XXX roth - * some pre-standard CR cables report a "wavelength" - * in byte 60, 61, pretending to be an optical module - */ - -#define _SFF8472_WAVELENGTH(idprom) \ - ((idprom[60] << 8) | idprom[61]) - -#define _SFF8472_COMPLIANCE_UNSPEC(idprom) \ - ((idprom[60] == 0) \ - && (idprom[61] == 0)) - -#define _SFF8472_COMPLIANCE_PASSIVE_FC(idprom) \ - (((idprom[60] & SFF8471_CC60_FC_PI_4) != 0) \ - && (idprom[61] == 0)) - -#define _SFF8472_COMPLIANCE_PASSIVE_SFF(idprom) \ - (((idprom[60] & SFF8471_CC60_SFF8431) != 0) \ - && (idprom[61] == 0)) - -#define _SFF8472_COMPLIANCE_ACTIVE_FC(idprom) \ - ((((idprom[60] & SFF8471_CC60_FC_PI_4) != 0) \ - || (idprom[60] & SFF8471_CC60_FC_PI_4_LIMITING) != 0) \ - && (idprom[61] == 0)) - -#define _SFF8472_COMPLIANCE_ACTIVE_SFF(idprom) \ - ((((idprom[60] & SFF8471_CC60_SFF8431) != 0) \ - || (idprom[60] & SFF8471_CC60_SFF8431_LIMITING) != 0) \ - && (idprom[61] == 0)) - -/* - * Cisco pre-standard CR cables - */ -int -sff8472_hack_cr(const uint8_t* idprom) -{ - /* vendor is 'OEM' */ - if (SFF_STRNCMP((char*)idprom+20, "OEM ", 4) != 0) return 0; - - /* model reads like 'SFP-H10GB-CU...' */ - if (SFF_STRNCMP((char*)idprom+40, "SFP-H10GB-CU", 12) != 0) return 0; - - /* S/N reads like 'CSC...' */ - if (SFF_STRNCMP((char*)idprom+68, "CSC", 3) != 0) return 0; - - /* - * congratulations, you have an expensive Cisco - * pre-standard CR cable. - */ - return 1; -} - -/* grab-bag to detect pre-standard CR media */ -int -sff8472_media_cr_passive(const uint8_t* idprom) -{ - int maybe = 0; - - if (_sff8472_inf_1x_cu_passive(idprom)) - maybe = 1; - else if (_sff8472_inf_1x(idprom)) - return 0; - - if (_sff8472_tech_fc_el(idprom)) - maybe = 1; - else if (_sff8472_tech_fc(idprom)) - return 0; - - if (idprom[4] != 0) return 0; - if (idprom[5] != 0) return 0; - if (idprom[6] != 0) return 0; - - if (_sff8472_sfp_plus_passive(idprom)) - maybe = 1; - - if (_sff8472_fc_media_tw(idprom)) - maybe = 1; - else if (_sff8472_fc_media(idprom)) - return 0; - - if (!_sff8472_fc_speed_ok(idprom)) - return 0; - - if (_sff8472_hack_cr(idprom)) - maybe = 1; - - if (maybe) { - if (!_SFF8472_COMPLIANCE_PASSIVE_FC(idprom) - && !_SFF8472_COMPLIANCE_PASSIVE_SFF(idprom) - && (_SFF8472_WAVELENGTH(idprom) != 850) - && !_SFF8472_COMPLIANCE_UNSPEC(idprom) - && !_sff8472_hack_cr(idprom)) - return 0; - } - - return maybe; -} - -int -sff8472_media_cr_active(const uint8_t* idprom) -{ - int maybe = 0; - - if (_sff8472_inf_1x_cu_active(idprom)) - maybe = 1; - else if (_sff8472_inf_1x(idprom)) - return 0; - - if (_sff8472_tech_fc_el(idprom)) - maybe = 1; - else if (_sff8472_tech_fc(idprom)) - return 0; - - if (idprom[4] != 0) return 0; - if (idprom[5] != 0) return 0; - if (idprom[6] != 0) return 0; - - if (_sff8472_sfp_plus_active(idprom)) - maybe = 1; - - if (_sff8472_fc_media_tw(idprom)) - maybe = 1; - else if (_sff8472_fc_media(idprom)) - return 0; - - if (!_sff8472_fc_speed_ok(idprom)) - return 0; - - if (maybe) { - if (!_SFF8472_COMPLIANCE_ACTIVE_FC(idprom) - && !_SFF8472_COMPLIANCE_ACTIVE_SFF(idprom) - && !_SFF8472_COMPLIANCE_UNSPEC(idprom)) - return 0; - } - - return maybe; -} - -#define SFF8472_MEDIA_GBE_SX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_SX) != 0) -#define SFF8472_MEDIA_GBE_LX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_LX) != 0) -#define SFF8472_MEDIA_GBE_CX(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_CX) != 0) -#define SFF8472_MEDIA_GBE_T(idprom) \ - ((idprom[6] & SFF8472_CC6_GBE_BASE_T) != 0) - -#define SFF8472_MEDIA_CBE_LX(idprom) \ - ((idprom[6] & SFF8472_CC6_CBE_BASE_LX) != 0) -#define SFF8472_MEDIA_CBE_FX(idprom) \ - ((idprom[6] & SFF8472_CC6_CBE_BASE_FX) != 0) - - -#endif diff --git a/packages/base/any/onlp/src/sff/module/src/Makefile b/packages/base/any/onlp/src/sff/module/src/Makefile deleted file mode 100644 index cf47d083..00000000 --- a/packages/base/any/onlp/src/sff/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py sff_ucli.c - diff --git a/packages/base/any/onlp/src/sff/module/src/make.mk b/packages/base/any/onlp/src/sff/module/src/make.mk deleted file mode 100644 index 40aa534c..00000000 --- a/packages/base/any/onlp/src/sff/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := sff -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/base/any/onlp/src/sff/module/src/nonstandard.c b/packages/base/any/onlp/src/sff/module/src/nonstandard.c deleted file mode 100644 index b512ffe2..00000000 --- a/packages/base/any/onlp/src/sff/module/src/nonstandard.c +++ /dev/null @@ -1,37 +0,0 @@ -/** - * These parts must be special-cased by vendor and model - * due to nonstandard eeprom contents. - */ -#include - -typedef struct sff_ns_entry_s { - const char* vendor; - const char* model; - sff_module_type_t mt; - int len; -} sff_ns_entry_t; - -static sff_ns_entry_t nonstandard_modules__[] = - { - { "CISCO-OEM ", "QSFP-4SFP+-CU2M ", SFF_MODULE_TYPE_40G_BASE_CR4, 2 }, - { "CISCO-OEM ", "QSFP-4SFP+-CU3M ", SFF_MODULE_TYPE_40G_BASE_CR4, 3 }, - { "CISCO-OEM ", "QSFP-4SFP+-CU5M ", SFF_MODULE_TYPE_40G_BASE_CR4, 5 }, - { "Mellanox ", "MC2206130-001 ", SFF_MODULE_TYPE_40G_BASE_CR4, 1 }, - { "OEM ", "F4M-QSSFP-C-2-30", SFF_MODULE_TYPE_40G_BASE_CR4, 2 }, - {}, - }; - - -int -sff_nonstandard_lookup(sff_info_t* info) -{ - sff_ns_entry_t* p; - for(p = nonstandard_modules__; p->vendor; p++) { - if(!strcmp(info->vendor, p->vendor) && !strcmp(info->model, p->model)) { - sff_info_from_module_type(info, info->sfp_type, p->mt); - info->length = p->len; - return 0; - } - } - return -1; -} diff --git a/packages/base/any/onlp/src/sff/module/src/sff.c b/packages/base/any/onlp/src/sff/module/src/sff.c deleted file mode 100644 index ab437441..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff.c +++ /dev/null @@ -1,863 +0,0 @@ -/************************************************************ - * - * - * 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 "sff_log.h" -#include -#include "sff_int.h" - -sff_sfp_type_t -sff_sfp_type_get(const uint8_t* eeprom) -{ - if(eeprom) { - if(SFF8472_MODULE_SFP(eeprom)) { - return SFF_SFP_TYPE_SFP; - } - if(SFF8436_MODULE_QSFP_PLUS_V2(eeprom)) { - return SFF_SFP_TYPE_QSFP_PLUS; - } - if(SFF8636_MODULE_QSFP28(eeprom)) { - return SFF_SFP_TYPE_QSFP28; - } - } - return SFF_SFP_TYPE_INVALID; -} - -sff_module_type_t -sff_module_type_get(const uint8_t* eeprom) -{ - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_AOC(eeprom)) - return SFF_MODULE_TYPE_100G_AOC; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_SR4(eeprom)) - return SFF_MODULE_TYPE_100G_BASE_SR4; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_LR4(eeprom)) - return SFF_MODULE_TYPE_100G_BASE_LR4; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && (SFF8636_MEDIA_100GE_CR4(eeprom) || - SFF8636_MEDIA_25GE_CR_S(eeprom) || - SFF8636_MEDIA_25GE_CR_N(eeprom))) - return SFF_MODULE_TYPE_100G_BASE_CR4; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_CWDM4(eeprom)) - return SFF_MODULE_TYPE_100G_CWDM4; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_PSM4(eeprom)) - return SFF_MODULE_TYPE_100G_PSM4; - - if (SFF8636_MODULE_QSFP28(eeprom) - && SFF8636_MEDIA_EXTENDED(eeprom) - && SFF8636_MEDIA_100GE_SWDM4(eeprom)) - return SFF_MODULE_TYPE_100G_SWDM4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && SFF8436_MEDIA_40GE_CR4(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_CR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && SFF8436_MEDIA_40GE_SR4(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_SR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_sr4_aoc_pre(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_SR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && SFF8436_MEDIA_40GE_LR4(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_LR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && SFF8436_MEDIA_40GE_ACTIVE(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_ACTIVE; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_aoc_breakout(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_SR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && SFF8436_MEDIA_40GE_CR(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_CR; - - /* pre-standard finisar optics */ - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_pre(eeprom) - && (SFF8436_TECH_FC_FIBER_LONG(eeprom) - || SFF8436_MEDIA_FC_FIBER_SM(eeprom))) - return SFF_MODULE_TYPE_40G_BASE_LR4; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_pre(eeprom) - && (SFF8436_TECH_FC_FIBER_SHORT(eeprom) - || SFF8436_MEDIA_FC_FIBER_MM(eeprom))) - return SFF_MODULE_TYPE_40G_BASE_SR4; - - /* pre-standard QSFP-BiDi optics */ - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_sr2_bidi_pre(eeprom)) - return SFF_MODULE_TYPE_40G_BASE_SR2; - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_lm4(eeprom)) { - return SFF_MODULE_TYPE_40G_BASE_LM4; - } - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_sm4(eeprom)) { - return SFF_MODULE_TYPE_40G_BASE_SM4; - } - - if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom) - && _sff8436_qsfp_40g_er4(eeprom)) { - return SFF_MODULE_TYPE_40G_BASE_ER4; - } - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_cr(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_CR; - } - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_sr(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_SR; - } - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_lr(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_LR; - } - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_sfp28_aoc(eeprom)) { - return SFF_MODULE_TYPE_25G_BASE_AOC; - } - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_XGE_SR(eeprom) - && !_sff8472_media_gbe_sx_fc_hack(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_SR; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_XGE_LR(eeprom) - && !_sff8472_media_gbe_lx_fc_hack(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_LR; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_XGE_LRM(eeprom) - && !_sff8472_media_gbe_lx_fc_hack(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_LRM; - - /* - * XXX roth -- PAN-934 -- DAC cable erroneously reports ER, - * so we need to disallow infiniband features when matching here. - * See also _sff8472_media_cr_passive, which encodes some - * additional workarounds for these cables. - */ - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_XGE_ER(eeprom) - && !_sff8472_inf_1x_cu_active(eeprom) - && !_sff8472_inf_1x_cu_passive(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_ER; - - /* XXX roth - not sure on this one */ - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_cr_passive(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_CR; - - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_cr_active(eeprom)) { - if (_sff8472_sfp_10g_aoc(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_SR; - else - return SFF_MODULE_TYPE_10G_BASE_CR; - } - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_GBE_SX(eeprom)) - return SFF_MODULE_TYPE_1G_BASE_SX; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_GBE_LX(eeprom)) { - if (SFF8472_MEDIA_LENGTH_ZX(eeprom)) { - return SFF_MODULE_TYPE_1G_BASE_ZX; - } else { - return SFF_MODULE_TYPE_1G_BASE_LX; - } - } - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_GBE_CX(eeprom)) - return SFF_MODULE_TYPE_1G_BASE_CX; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_GBE_T(eeprom)) - return SFF_MODULE_TYPE_1G_BASE_T; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_CBE_LX(eeprom)) - return SFF_MODULE_TYPE_100_BASE_LX; - - if (SFF8472_MODULE_SFP(eeprom) - && SFF8472_MEDIA_CBE_FX(eeprom)) - return SFF_MODULE_TYPE_100_BASE_FX; - - /* non-standard (e.g. Finisar) ZR media */ - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_zr(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_ZR; - - /* non-standard (e.g. Finisar) SRL media */ - if (SFF8472_MODULE_SFP(eeprom) - && _sff8472_media_srlite(eeprom)) - return SFF_MODULE_TYPE_10G_BASE_SRL; - - return SFF_MODULE_TYPE_INVALID; -} - -sff_media_type_t -sff_media_type_get(sff_module_type_t mt) -{ - switch(mt) - { - case SFF_MODULE_TYPE_100G_BASE_CR4: - case SFF_MODULE_TYPE_40G_BASE_CR4: - case SFF_MODULE_TYPE_40G_BASE_CR: - case SFF_MODULE_TYPE_25G_BASE_CR: - case SFF_MODULE_TYPE_10G_BASE_CR: - case SFF_MODULE_TYPE_1G_BASE_CX: - case SFF_MODULE_TYPE_1G_BASE_T: - return SFF_MEDIA_TYPE_COPPER; - - case SFF_MODULE_TYPE_100G_AOC: - case SFF_MODULE_TYPE_100G_BASE_SR4: - case SFF_MODULE_TYPE_100G_BASE_LR4: - case SFF_MODULE_TYPE_100G_CWDM4: - case SFF_MODULE_TYPE_100G_PSM4: - case SFF_MODULE_TYPE_100G_SWDM4: - case SFF_MODULE_TYPE_40G_BASE_SR4: - case SFF_MODULE_TYPE_40G_BASE_LR4: - case SFF_MODULE_TYPE_40G_BASE_LM4: - case SFF_MODULE_TYPE_40G_BASE_ACTIVE: - case SFF_MODULE_TYPE_40G_BASE_SR2: - case SFF_MODULE_TYPE_40G_BASE_SM4: - case SFF_MODULE_TYPE_40G_BASE_ER4: - case SFF_MODULE_TYPE_25G_BASE_SR: - case SFF_MODULE_TYPE_25G_BASE_LR: - case SFF_MODULE_TYPE_25G_BASE_AOC: - case SFF_MODULE_TYPE_10G_BASE_SR: - case SFF_MODULE_TYPE_10G_BASE_LR: - case SFF_MODULE_TYPE_10G_BASE_LRM: - case SFF_MODULE_TYPE_10G_BASE_ER: - case SFF_MODULE_TYPE_10G_BASE_SX: - case SFF_MODULE_TYPE_10G_BASE_LX: - case SFF_MODULE_TYPE_10G_BASE_ZR: - case SFF_MODULE_TYPE_10G_BASE_SRL: - case SFF_MODULE_TYPE_1G_BASE_SX: - case SFF_MODULE_TYPE_1G_BASE_LX: - case SFF_MODULE_TYPE_1G_BASE_ZX: - case SFF_MODULE_TYPE_100_BASE_LX: - case SFF_MODULE_TYPE_100_BASE_FX: - case SFF_MODULE_TYPE_4X_MUX: - return SFF_MEDIA_TYPE_FIBER; - - case SFF_MODULE_TYPE_COUNT: - case SFF_MODULE_TYPE_INVALID: - return SFF_MEDIA_TYPE_INVALID; - } - - return SFF_MEDIA_TYPE_INVALID; -} - -int -sff_module_caps_get(sff_module_type_t mt, uint32_t *caps) -{ - if (caps == NULL) - return -1; - - *caps = 0; - - switch(mt) - { - case SFF_MODULE_TYPE_100G_AOC: - case SFF_MODULE_TYPE_100G_BASE_SR4: - case SFF_MODULE_TYPE_100G_BASE_LR4: - case SFF_MODULE_TYPE_100G_BASE_CR4: - case SFF_MODULE_TYPE_100G_CWDM4: - case SFF_MODULE_TYPE_100G_PSM4: - case SFF_MODULE_TYPE_100G_SWDM4: - *caps |= SFF_MODULE_CAPS_F_100G; - return 0; - - case SFF_MODULE_TYPE_40G_BASE_CR4: - case SFF_MODULE_TYPE_40G_BASE_SR4: - case SFF_MODULE_TYPE_40G_BASE_LR4: - case SFF_MODULE_TYPE_40G_BASE_LM4: - case SFF_MODULE_TYPE_40G_BASE_ACTIVE: - case SFF_MODULE_TYPE_40G_BASE_CR: - case SFF_MODULE_TYPE_40G_BASE_SR2: - case SFF_MODULE_TYPE_40G_BASE_SM4: - case SFF_MODULE_TYPE_40G_BASE_ER4: - *caps |= SFF_MODULE_CAPS_F_40G; - return 0; - - case SFF_MODULE_TYPE_25G_BASE_CR: - case SFF_MODULE_TYPE_25G_BASE_SR: - case SFF_MODULE_TYPE_25G_BASE_AOC: - *caps |= SFF_MODULE_CAPS_F_25G; - return 0; - - case SFF_MODULE_TYPE_10G_BASE_SR: - case SFF_MODULE_TYPE_10G_BASE_LR: - case SFF_MODULE_TYPE_10G_BASE_LRM: - case SFF_MODULE_TYPE_10G_BASE_ER: - case SFF_MODULE_TYPE_10G_BASE_CR: - case SFF_MODULE_TYPE_10G_BASE_SX: - case SFF_MODULE_TYPE_10G_BASE_LX: - case SFF_MODULE_TYPE_10G_BASE_ZR: - case SFF_MODULE_TYPE_10G_BASE_SRL: - *caps |= SFF_MODULE_CAPS_F_10G; - return 0; - - case SFF_MODULE_TYPE_1G_BASE_SX: - case SFF_MODULE_TYPE_1G_BASE_LX: - case SFF_MODULE_TYPE_1G_BASE_ZX: - case SFF_MODULE_TYPE_1G_BASE_CX: - case SFF_MODULE_TYPE_1G_BASE_T: - *caps |= SFF_MODULE_CAPS_F_1G; - return 0; - - case SFF_MODULE_TYPE_100_BASE_LX: - case SFF_MODULE_TYPE_100_BASE_FX: - *caps |= SFF_MODULE_CAPS_F_100; - return 0; - - default: - return -1; - } -} - -static void -make_printable__(char* string, int size) -{ - char* p; - for(p = string; p && *p && size; p++) { - if(!isprint(*p)) { - *p = '?'; - } - size --; - } -} - -/** - * @brief Initialize an SFF module information structure. - * @param rv [out] Receives the data. - * @param eeprom Raw EEPROM data. - * @note if eeprom is != NULL it will be copied into rv->eeprom first. - * @note if eeprom is NULL it is assumed the rv->eeprom buffer - * has already been initialized. - */ -static int -sff_eeprom_parse_standard__(sff_eeprom_t* se, uint8_t* eeprom) -{ - if(se == NULL) { - return -1; - } - se->identified = 0; - - if(eeprom) { - SFF_MEMCPY(se->eeprom, eeprom, 256); - } - - if (SFF8472_MODULE_SFP(se->eeprom)) { - /* See SFF-8472 pp22, pp28 */ - int i; - for (i = 0, se->cc_base = 0; i < 63; ++i) - se->cc_base = (se->cc_base + se->eeprom[i]) & 0xFF; - for (i = 64, se->cc_ext = 0; i < 95; ++i) - se->cc_ext = (se->cc_ext + se->eeprom[i]) & 0xFF; - } else if (SFF8436_MODULE_QSFP_PLUS_V2(se->eeprom) || - SFF8636_MODULE_QSFP28(se->eeprom)) { - /* See SFF-8436 pp72, pp73 */ - int i; - for (i = 128, se->cc_base = 0; i < 191; ++i) - se->cc_base = (se->cc_base + se->eeprom[i]) & 0xFF; - for (i = 192, se->cc_ext = 0; i < 223; ++i) - se->cc_ext = (se->cc_ext + se->eeprom[i]) & 0xFF; - } - - if (!sff_eeprom_validate(se, 1)) { - return -1; - } - - se->info.sfp_type = sff_sfp_type_get(se->eeprom); - if(se->info.sfp_type == SFF_SFP_TYPE_INVALID) { - AIM_LOG_ERROR("sff_eeprom_parse() failed: invalid sfp type"); - return -1; - } - se->info.sfp_type_name = sff_sfp_type_desc(se->info.sfp_type); - - const uint8_t *vendor, *model, *serial; - - switch(se->info.sfp_type) - { - case SFF_SFP_TYPE_QSFP_PLUS: - case SFF_SFP_TYPE_QSFP28: - vendor=se->eeprom+148; - model=se->eeprom+168; - serial=se->eeprom+196; - break; - - case SFF_SFP_TYPE_SFP: - default: - vendor=se->eeprom+20; - model=se->eeprom+40; - serial=se->eeprom+68; - break; - } - - /* handle NULL fields, they should actually be space-padded */ - const char *empty = " "; - if (*vendor) { - aim_strlcpy(se->info.vendor, (char*)vendor, sizeof(se->info.vendor)); - make_printable__(se->info.vendor, sizeof(se->info.vendor)); - } - else { - aim_strlcpy(se->info.vendor, empty, 17); - } - if (*model) { - aim_strlcpy(se->info.model, (char*)model, sizeof(se->info.model)); - make_printable__(se->info.model, sizeof(se->info.model)); - } - else { - aim_strlcpy(se->info.model, empty, 17); - } - if (*serial) { - aim_strlcpy(se->info.serial, (char*)serial, sizeof(se->info.serial)); - make_printable__(se->info.serial, sizeof(se->info.serial)); - } - else { - aim_strlcpy(se->info.serial, empty, 17); - } - - se->info.module_type = sff_module_type_get(se->eeprom); - if(se->info.module_type == SFF_MODULE_TYPE_INVALID) { - return -1; - } - - if(sff_info_init(&se->info, se->info.module_type, NULL, NULL, NULL, 0) < 0) { - return -1; - } - - int aoc_length; - switch (se->info.media_type) - { - case SFF_MEDIA_TYPE_COPPER: - switch (se->info.sfp_type) - { - case SFF_SFP_TYPE_QSFP_PLUS: - case SFF_SFP_TYPE_QSFP28: - se->info.length = se->eeprom[146]; - break; - case SFF_SFP_TYPE_SFP: - case SFF_SFP_TYPE_SFP28: - se->info.length = se->eeprom[18]; - break; - default: - se->info.length = -1; - break; - } - break; - - case SFF_MEDIA_TYPE_FIBER: - switch (se->info.sfp_type) - { - case SFF_SFP_TYPE_QSFP28: - aoc_length = _sff8636_qsfp28_100g_aoc_length(se->eeprom); - se->info.length = aoc_length; - break; - case SFF_SFP_TYPE_QSFP_PLUS: - case SFF_SFP_TYPE_SFP: - case SFF_SFP_TYPE_SFP28: - aoc_length = _sff8436_qsfp_40g_aoc_length(se->eeprom); - if (aoc_length < 0) - aoc_length = _sff8472_sfp_10g_aoc_length(se->eeprom); - if (aoc_length > 0) - se->info.length = aoc_length; - else - se->info.length = -1; - break; - default: - se->info.length = -1; - break; - } - break; - default: - se->info.length = -1; - } - - if(se->info.length == -1) { - se->info.length_desc[0] = 0; - } - else { - SFF_SNPRINTF(se->info.length_desc, sizeof(se->info.length_desc), "%dm", se->info.length); - } - se->identified = 1; - - return 0; -} - -int -sff_info_from_module_type(sff_info_t* info, sff_sfp_type_t st, sff_module_type_t mt) -{ - info->sfp_type = st; - info->sfp_type_name = sff_sfp_type_desc(st); - - info->module_type = mt; - info->module_type_name = sff_module_type_desc(mt); - - info->media_type = sff_media_type_get(mt); - info->media_type_name = sff_media_type_desc(info->media_type); - - if (sff_module_caps_get(info->module_type, &info->caps) < 0) { - AIM_LOG_ERROR("sff_info_init() failed: invalid module caps"); - return -1; - } - return 0; -} - -void -sff_info_show(sff_info_t* info, aim_pvs_t* pvs) -{ - aim_printf(pvs, "Vendor: %s Model: %s SN: %s Type: %s Module: %s Media: %s Length: %d\n", - info->vendor, info->model, info->serial, info->sfp_type_name, - info->module_type_name, info->media_type_name, info->length); -} - -int -sff_eeprom_parse_file(sff_eeprom_t* se, const char* fname) -{ - int rv; - FILE* fp; - - SFF_MEMSET(se, 0, sizeof(*se)); - - if( (fp = fopen(fname, "r")) == NULL) { - AIM_LOG_ERROR("Failed to open eeprom file %s: %{errno}"); - return -1; - } - - if( (rv = fread(se->eeprom, 1, 256, fp)) > 0) { - if( (rv=sff_eeprom_parse(se, NULL)) < 0) { - AIM_LOG_ERROR("sff_init() failed on data from file %s: %d\n", fname, rv); - rv = -1; - } - rv = 0; - } - else { - rv = -1; - } - fclose(fp); - return rv; -} - -void -sff_eeprom_invalidate(sff_eeprom_t *se) -{ - memset(se->eeprom, 0xFF, 256); - se->cc_base = 0xFF; - se->cc_ext = 0xFF; - se->identified = 0; -} - -int -sff_eeprom_validate(sff_eeprom_t *se, int verbose) -{ - if (SFF8436_MODULE_QSFP_PLUS_V2(se->eeprom) || - SFF8636_MODULE_QSFP28(se->eeprom)) { - - if (se->cc_base != se->eeprom[191]) { - if (verbose) { - AIM_LOG_ERROR("sff_eeprom_validate() failed: invalid base QSFP checksum (0x%x should be 0x%x)", - se->eeprom[191], se->cc_base); - } - return 0; - } - -#if SFF_CONFIG_INCLUDE_EXT_CC_CHECK == 1 - if (se->cc_ext != se->eeprom[223]) { - if (verbose) { - AIM_LOG_ERROR("sff_info_valid() failed: invalid extended QSFP checksum (0x%x should be 0x%x)", - se->eeprom[223], se->cc_ext); - } - return 0; - } -#endif - - } else if (SFF8472_MODULE_SFP(se->eeprom)) { - - if (se->cc_base != se->eeprom[63]) { - if (verbose) { - AIM_LOG_ERROR("sff_info_valid() failed: invalid base SFP checksum (0x%x should be 0x%x)", - se->eeprom[63], se->cc_base); - } - return 0; - } - -#if SFF_CONFIG_INCLUDE_EXT_CC_CHECK == 1 - if (se->cc_ext != se->eeprom[95]) { - if (verbose) { - AIM_LOG_ERROR("sff_info_valid() failed: invalid extended SFP checksum (0x%x should be 0x%x)", - se->eeprom[95], se->cc_ext); - } - return 0; - } -#endif - - } else { - - if (verbose) { - AIM_LOG_ERROR("sff_info_valid() failed: invalid module type"); - } - - return 0; - } - - return 1; -} - -static int -sff_eeprom_parse_nonstandard__(sff_eeprom_t* se, uint8_t* eeprom) -{ - if(se == NULL) { - return -1; - } - se->identified = 0; - - if(eeprom) { - SFF_MEMCPY(se->eeprom, eeprom, 256); - } - - if (strncmp(se->info.vendor, "Amphenol", 8) == 0 && - (strncmp(se->info.model, "625960001", 9) == 0 || strncmp(se->info.model, "659900001", 9) == 0) && - (se->eeprom[240] == 0x0f) && - (se->eeprom[241] == 0x10) && - ((se->eeprom[243] & 0xF0) == 0xE0)) { - - /* 4X_MUX */ - se->identified = 1; - se->info.module_type = SFF_MODULE_TYPE_4X_MUX; - se->info.module_type_name = sff_module_type_desc(se->info.module_type); - se->info.media_type = SFF_MEDIA_TYPE_COPPER; - se->info.media_type_name = sff_media_type_desc(se->info.media_type); - se->info.caps = SFF_MODULE_CAPS_F_1G; - se->info.length = se->eeprom[146]; - SFF_SNPRINTF(se->info.length_desc, sizeof(se->info.length_desc), "%dm", - se->info.length); - return 0; - } - - if (sff_nonstandard_lookup(&se->info) == 0) { - se->identified = 1; - SFF_SNPRINTF(se->info.length_desc, sizeof(se->info.length_desc), "%dm", - se->info.length); - return 0; - } - - return -1; -} - -int -sff_eeprom_parse(sff_eeprom_t* se, uint8_t* eeprom) -{ - int rv = sff_eeprom_parse_standard__(se, eeprom); - if(!se->identified) { - rv = sff_eeprom_parse_nonstandard__(se, eeprom); - } - return rv; -} - -int -sff_info_init(sff_info_t* info, sff_module_type_t mt, - const char* vendor, const char* model, const char* serial, - int length) -{ - info->module_type = mt; - - switch(mt) - { - case SFF_MODULE_TYPE_100G_AOC: - case SFF_MODULE_TYPE_100G_BASE_SR4: - case SFF_MODULE_TYPE_100G_BASE_LR4: - case SFF_MODULE_TYPE_100G_CWDM4: - case SFF_MODULE_TYPE_100G_PSM4: - case SFF_MODULE_TYPE_100G_SWDM4: - info->sfp_type = SFF_SFP_TYPE_QSFP28; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_100G; - break; - - case SFF_MODULE_TYPE_100G_BASE_CR4: - info->sfp_type = SFF_SFP_TYPE_QSFP28; - info->media_type = SFF_MEDIA_TYPE_COPPER; - info->caps = SFF_MODULE_CAPS_F_100G; - break; - - case SFF_MODULE_TYPE_40G_BASE_SR4: - case SFF_MODULE_TYPE_40G_BASE_LR4: - case SFF_MODULE_TYPE_40G_BASE_LM4: - case SFF_MODULE_TYPE_40G_BASE_ACTIVE: - case SFF_MODULE_TYPE_40G_BASE_SR2: - case SFF_MODULE_TYPE_40G_BASE_SM4: - case SFF_MODULE_TYPE_40G_BASE_ER4: - case SFF_MODULE_TYPE_4X_MUX: - info->sfp_type = SFF_SFP_TYPE_QSFP_PLUS; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_40G; - break; - - case SFF_MODULE_TYPE_40G_BASE_CR4: - case SFF_MODULE_TYPE_40G_BASE_CR: - info->sfp_type = SFF_SFP_TYPE_QSFP_PLUS; - info->media_type = SFF_MEDIA_TYPE_COPPER; - info->caps = SFF_MODULE_CAPS_F_40G; - break; - - case SFF_MODULE_TYPE_25G_BASE_CR: - info->sfp_type = SFF_SFP_TYPE_SFP28; - info->media_type = SFF_MEDIA_TYPE_COPPER; - info->caps = SFF_MODULE_CAPS_F_25G; - break; - - case SFF_MODULE_TYPE_25G_BASE_SR: - case SFF_MODULE_TYPE_25G_BASE_LR: - case SFF_MODULE_TYPE_25G_BASE_AOC: - info->sfp_type = SFF_SFP_TYPE_SFP28; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_25G; - break; - - case SFF_MODULE_TYPE_10G_BASE_CR: - info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_COPPER; - info->caps = SFF_MODULE_CAPS_F_10G; - break; - - case SFF_MODULE_TYPE_10G_BASE_SR: - case SFF_MODULE_TYPE_10G_BASE_LR: - case SFF_MODULE_TYPE_10G_BASE_LRM: - case SFF_MODULE_TYPE_10G_BASE_ER: - case SFF_MODULE_TYPE_10G_BASE_SX: - case SFF_MODULE_TYPE_10G_BASE_LX: - case SFF_MODULE_TYPE_10G_BASE_ZR: - case SFF_MODULE_TYPE_10G_BASE_SRL: - info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_10G; - break; - - case SFF_MODULE_TYPE_1G_BASE_SX: - case SFF_MODULE_TYPE_1G_BASE_LX: - case SFF_MODULE_TYPE_1G_BASE_ZX: - info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_1G; - break; - - case SFF_MODULE_TYPE_1G_BASE_CX: - case SFF_MODULE_TYPE_1G_BASE_T: - info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_COPPER; - info->caps = SFF_MODULE_CAPS_F_1G; - break; - - case SFF_MODULE_TYPE_100_BASE_LX: - case SFF_MODULE_TYPE_100_BASE_FX: - info->sfp_type = SFF_SFP_TYPE_SFP; - info->media_type = SFF_MEDIA_TYPE_FIBER; - info->caps = SFF_MODULE_CAPS_F_100; - break; - - case SFF_MODULE_TYPE_COUNT: - case SFF_MODULE_TYPE_INVALID: - return -1; - } - - info->sfp_type_name = sff_sfp_type_desc(info->sfp_type); - info->module_type_name = sff_module_type_desc(info->module_type); - info->media_type_name = sff_media_type_desc(info->media_type); - - if(vendor) { - aim_strlcpy(info->vendor, vendor, sizeof(info->vendor)); - } - if(model) { - aim_strlcpy(info->model, model, sizeof(info->model)); - } - if(serial) { - aim_strlcpy(info->serial, serial, sizeof(info->serial)); - } - - info->length = length; - SFF_SNPRINTF(info->length_desc, sizeof(info->length_desc), "%dm", length); - return 0; -} - -#ifdef DEPENDMODULE_INCLUDE_CJSON_UTIL - -#include - -cJSON* -sff_info_json(cJSON* rv, sff_info_t* info) -{ - if(rv == NULL) { - rv = cJSON_CreateObject(); - } - - cjson_util_add_string_to_object(rv, "vendor", "%-16.16s", info->vendor); - cjson_util_add_string_to_object(rv, "model", "%-16.16s", info->model); - cjson_util_add_string_to_object(rv, "serial", "%-16.16s", info->serial); - cJSON_AddStringToObject(rv, "sfp-type", info->sfp_type_name); - cJSON_AddStringToObject(rv, "module-type", info->module_type_name); - cJSON_AddStringToObject(rv, "media-type", info->media_type_name); - cjson_util_add_string_to_object(rv, "caps", "%{sff_module_caps}", info->caps); - cjson_util_add_string_to_object(rv, "length", info->length_desc); - - return rv; -} - -#endif /* DEPENDMODULE_CJSON_UTIL */ diff --git a/packages/base/any/onlp/src/sff/module/src/sff_config.c b/packages/base/any/onlp/src/sff/module/src/sff_config.c deleted file mode 100644 index cf770933..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_config.c +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __sff_config_STRINGIFY_NAME(_x) #_x -#define __sff_config_STRINGIFY_VALUE(_x) __sff_config_STRINGIFY_NAME(_x) -sff_config_settings_t sff_config_settings[] = -{ -#ifdef SFF_CONFIG_INCLUDE_LOGGING - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_INCLUDE_LOGGING), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_INCLUDE_LOGGING) }, -#else -{ SFF_CONFIG_INCLUDE_LOGGING(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_LOG_OPTIONS_DEFAULT - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_LOG_OPTIONS_DEFAULT), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ SFF_CONFIG_LOG_OPTIONS_DEFAULT(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_LOG_BITS_DEFAULT - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_LOG_BITS_DEFAULT), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ SFF_CONFIG_LOG_BITS_DEFAULT(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_PORTING_STDLIB - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_PORTING_STDLIB), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_PORTING_STDLIB) }, -#else -{ SFF_CONFIG_PORTING_STDLIB(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ SFF_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_INCLUDE_UCLI - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_INCLUDE_UCLI), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_INCLUDE_UCLI) }, -#else -{ SFF_CONFIG_INCLUDE_UCLI(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_INCLUDE_SFF_TOOL - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_INCLUDE_SFF_TOOL), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_INCLUDE_SFF_TOOL) }, -#else -{ SFF_CONFIG_INCLUDE_SFF_TOOL(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_INCLUDE_EXT_CC_CHECK - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_INCLUDE_EXT_CC_CHECK), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_INCLUDE_EXT_CC_CHECK) }, -#else -{ SFF_CONFIG_INCLUDE_EXT_CC_CHECK(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef SFF_CONFIG_INCLUDE_DATABASE - { __sff_config_STRINGIFY_NAME(SFF_CONFIG_INCLUDE_DATABASE), __sff_config_STRINGIFY_VALUE(SFF_CONFIG_INCLUDE_DATABASE) }, -#else -{ SFF_CONFIG_INCLUDE_DATABASE(__sff_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __sff_config_STRINGIFY_VALUE -#undef __sff_config_STRINGIFY_NAME - -const char* -sff_config_lookup(const char* setting) -{ - int i; - for(i = 0; sff_config_settings[i].name; i++) { - if(!strcmp(sff_config_settings[i].name, setting)) { - return sff_config_settings[i].value; - } - } - return NULL; -} - -int -sff_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; sff_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", sff_config_settings[i].name, sff_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/base/any/onlp/src/sff/module/src/sff_db.c b/packages/base/any/onlp/src/sff/module/src/sff_db.c deleted file mode 100644 index 279e8ef4..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_db.c +++ /dev/null @@ -1,1858 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#define SFF_1G_BASE_T_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_1G_BASE_T, "1GBASE-T", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_1G - -#define SFF_1G_BASE_SX_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_1G_BASE_SX, "1GBASE-SX", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_1G - - -#define SFF_1G_BASE_LX_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_1G_BASE_LX, "1GBASE-LR", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_1G - - -#define SFF_10G_BASE_CR_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_10G_BASE_CR, "10GBASE-CR", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_10G - - -#define SFF_10G_BASE_ZR_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_10G_BASE_ZR, "10GBASE-ZR", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_10G - - -#define SFF_10G_BASE_SR_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_10G_BASE_SR, "10GBASE-SR", SFF_MEDIA_TYPE_FIBER, "Fiber",SFF_MODULE_CAPS_F_10G - - -#define SFF_10G_BASE_SRL_PROPERTIES \ - SFF_SFP_TYPE_SFP, "SFP", SFF_MODULE_TYPE_10G_BASE_SRL, "1GBASE-SRL", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_10G - -#define SFF_25G_BASE_SR_PROPERTIES \ - SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_SR, "25GBASE-SR", SFF_MEDIA_TYPE_FIBER, "Fiber",SFF_MODULE_CAPS_F_25G - -#define SFF_25G_BASE_CR_PROPERTIES \ - SFF_SFP_TYPE_SFP28, "SFP28", SFF_MODULE_TYPE_25G_BASE_CR, "25GBASE-CR", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_25G - -#define SFF_40G_BASE_SR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_SR4, "40GBASE-SR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G - -#define SFF_40G_BASE_LR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_LR4, "40GBASE-LR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G - -#define SFF_40G_BASE_LM4_PROPERTIES \ - SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_LM4, "40GBASE-LM4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G - - -#define SFF_40G_BASE_CR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_CR4, "40GBASE-CR4", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_40G - - -#define SFF_40G_BASE_SR2_PROPERTIES \ - SFF_SFP_TYPE_QSFP_PLUS, "QSFP+", SFF_MODULE_TYPE_40G_BASE_SR2, "40GBASE-SR2", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_40G - -#define SFF_100G_AOC_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_AOC, "100G-AOC", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_BASE_LR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_BASE_LR4, "100GBASE-LR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_BASE_SR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_BASE_SR4, "100GBASE-SR4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_BASE_CR4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_BASE_CR4, "100GBASE-CR4", SFF_MEDIA_TYPE_COPPER, "Copper", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_CWDM4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_CWDM4, "100G-CWDM4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_PSM4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_PSM4, "100G-PSM4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -#define SFF_100G_SWDM4_PROPERTIES \ - SFF_SFP_TYPE_QSFP28, "QSFP28", SFF_MODULE_TYPE_100G_SWDM4, "100G-SWDM4", SFF_MEDIA_TYPE_FIBER, "Fiber", SFF_MODULE_CAPS_F_100G - -static sff_db_entry_t sff_database__[] = - { - -#if SFF_CONFIG_INCLUDE_DATABASE == 1 - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x00, 0x00, 0x00, 0x01, 0x20, 0x40, 0x0c, 0x05, 0x01, 0x15, 0x00, 0x00, 0x00, - 0x1e, 0x0f, 0x00, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x52, 0x4a, 0x38, 0x35, 0x31, 0x39, - 0x50, 0x31, 0x42, 0x4e, 0x4c, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x52, 0x00, 0x66, - 0x00, 0x12, 0x00, 0x00, 0x50, 0x38, 0x4a, 0x32, 0x5a, 0x4e, 0x43, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x30, 0x35, 0x31, 0x30, 0x33, 0x31, 0x20, 0x20, 0x58, 0x90, 0x01, 0x74, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "FINISAR CORP. ", - "FTRJ8519P1BNL ", - "P8J2ZNC ", - SFF_1G_BASE_SX_PROPERTIES, - -1, - } - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x41, 0x50, 0x48, 0x35, 0x37, 0x31, 0x35, 0x34, 0x30, 0x30, 0x30, - 0x37, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4b, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xfa, - 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x46, 0x31, 0x30, 0x30, 0x38, 0x30, 0x30, 0x37, 0x30, 0x31, - 0x34, 0x37, 0x20, 0x20, 0x31, 0x30, 0x30, 0x33, 0x30, 0x32, 0x20, 0x20, 0x00, 0x00, 0x00, 0xa9, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "571540007 ", - "APF10080070147 ", - SFF_10G_BASE_CR_PROPERTIES, - 0x1 - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4d, 0x4f, 0x4c, 0x45, 0x58, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x09, 0x3a, 0x37, 0x34, 0x37, 0x35, 0x32, 0x2d, 0x39, 0x35, - 0x31, 0x39, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x20, 0x20, 0x01, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x00, 0x4d, 0x4f, 0x43, 0x31, 0x35, 0x34, 0x37, 0x30, 0x30, 0x30, 0x48, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x31, 0x31, 0x31, 0x32, 0x31, 0x20, 0x20, 0x00, 0x00, 0x00, 0x8f, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xf9, 0x8e, 0x5a, - 0x43, 0x4f, 0x50, 0x51, 0x41, 0x41, 0x34, 0x4a, 0x41, 0x42, 0x33, 0x37, 0x2d, 0x30, 0x39, 0x36, - 0x30, 0x2d, 0x30, 0x33, 0x56, 0x30, 0x33, 0x20, 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0xcc, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x53, 0x46, 0x50, 0x2d, 0x48, 0x31, 0x30, 0x47, 0x42, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "CISCO-MOLEX ", - "74752-9519 ", - "MOC1547000H ", - SFF_10G_BASE_CR_PROPERTIES, - 0x1, - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x43, 0x39, 0x39, 0x39, 0x39, 0x2d, 0x31, 0x4d, - 0x2d, 0x50, 0x2d, 0x4c, 0x43, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xa1, - 0x00, 0x00, 0x00, 0x00, 0x31, 0x33, 0x30, 0x35, 0x33, 0x30, 0x30, 0x30, 0x34, 0x31, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x34, 0x31, 0x33, 0x20, 0x20, 0x00, 0x00, 0x00, 0x1d, - 0x00, 0x00, 0x11, 0xb6, 0x7f, 0x7f, 0x08, 0x96, 0xee, 0x8e, 0x60, 0x37, 0xb4, 0xc8, 0x8b, 0x88, - 0x66, 0x9c, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa3, 0xdd, 0x56, 0xe8, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - " ", - "C9999-1M-P-LC ", - "1305300041 ", - SFF_10G_BASE_CR_PROPERTIES, - 0x0, - } - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4d, 0x4f, 0x4c, 0x45, 0x58, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x09, 0x3a, 0x37, 0x34, 0x37, 0x35, 0x32, 0x2d, 0x39, 0x35, - 0x32, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x20, 0x20, 0x01, 0x00, 0x00, 0x0b, - 0x00, 0x00, 0x00, 0x00, 0x4d, 0x4f, 0x43, 0x31, 0x36, 0x30, 0x33, 0x30, 0x42, 0x48, 0x34, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x30, 0x31, 0x31, 0x39, 0x20, 0x20, 0x00, 0x00, 0x00, 0xa5, - 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x04, 0x3b, 0x5b, - 0x43, 0x4f, 0x50, 0x51, 0x41, 0x41, 0x36, 0x4a, 0x41, 0x42, 0x33, 0x37, 0x2d, 0x30, 0x39, 0x36, - 0x31, 0x2d, 0x30, 0x33, 0x56, 0x30, 0x33, 0x20, 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0xcf, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x53, 0x46, 0x50, 0x2d, 0x48, 0x31, 0x30, 0x47, 0x42, 0x2d, 0x43, 0x55, 0x33, 0x4d, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "CISCO-MOLEX ", - "74752-9520 ", - "MOC16030BH4 ", - SFF_10G_BASE_CR_PROPERTIES, - 0x3 - }, - }, - }, - - { - { - .eeprom = { - 0x00, 0x80, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x0d, 0x33, 0x0c, 0xcb, 0x0c, 0xcb, 0x0d, 0x33, 0x1b, 0xd5, 0x1b, 0x54, 0x18, 0xcd, 0x1c, - 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x03, 0x67, 0x00, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x00, 0x4f, 0x45, 0x4d, 0x20, 0x20, - 0x0d, 0x00, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x67, 0x00, 0x00, 0x00, - 0x0a, 0x03, 0x00, 0x00, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x00, 0x1e, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x30, 0x47, - 0x2d, 0x53, 0x52, 0x34, 0x20, 0x20, 0x20, 0x20, 0x31, 0x41, 0x42, 0x68, 0x07, 0xd0, 0x46, 0x0c, - 0x00, 0x00, 0x00, 0xde, 0x41, 0x43, 0x52, 0x34, 0x30, 0x47, 0x30, 0x30, 0x34, 0x31, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x30, 0x38, 0x32, 0x37, 0x31, 0x39, 0x08, 0x00, 0x00, 0x8a, - 0x00, 0x00, 0x11, 0x9d, 0xf1, 0x68, 0x34, 0xac, 0xb2, 0x3d, 0xc6, 0x19, 0x53, 0x0b, 0xbf, 0xf0, - 0x2e, 0xe1, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf7, 0xfe, 0x58, 0x27, - }, - .info = { - "OEM ", - "QSFP-40G-SR4 ", - "ACR40G0041 ", - SFF_40G_BASE_SR4_PROPERTIES, - -1, - }, - }, - }, - - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xa0, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x36, 0x30, 0x33, 0x30, 0x32, 0x30, 0x30, 0x30, - 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x42, 0x20, 0x07, 0x0b, 0x00, 0x00, 0x46, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x41, 0x50, 0x46, 0x31, 0x33, 0x30, 0x32, 0x30, 0x30, 0x33, 0x35, 0x41, - 0x52, 0x56, 0x20, 0x20, 0x31, 0x33, 0x30, 0x31, 0x31, 0x35, 0x20, 0x20, 0x00, 0x00, 0x00, 0xf9, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "603020003 ", - "APF13020035ARV ", - SFF_40G_BASE_CR4_PROPERTIES, - 0x3 - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x46, 0x69, 0x62, 0x65, 0x72, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x40, 0x20, 0x31, 0x30, 0x47, 0x53, 0x46, 0x50, 0x2d, 0x50, - 0x43, 0x2d, 0x33, 0x30, 0x2d, 0x31, 0x20, 0x20, 0x41, 0x30, 0x20, 0x20, 0x00, 0x00, 0x00, 0xd9, - 0x00, 0x00, 0x00, 0x00, 0x46, 0x53, 0x34, 0x30, 0x32, 0x31, 0x32, 0x44, 0x30, 0x31, 0x37, 0x36, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x34, 0x30, 0x32, 0x31, 0x33, 0x20, 0x20, 0x00, 0x00, 0x00, 0x8f, - 0x00, 0x00, 0x11, 0x4b, 0xd4, 0xe4, 0xc5, 0x99, 0xd1, 0xfb, 0xdb, 0x5e, 0xa2, 0xc4, 0x62, 0x0c, - 0xf2, 0x5b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0xfa, 0x99, - 0x43, 0x4f, 0x50, 0x51, 0x41, 0x41, 0x34, 0x4a, 0x41, 0x41, 0x33, 0x37, 0x2d, 0x30, 0x39, 0x36, - 0x30, 0x2d, 0x30, 0x32, 0x56, 0x30, 0x32, 0x20, 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0xc9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x53, 0x46, 0x50, 0x2d, 0x48, 0x31, 0x30, 0x47, 0x42, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { -"FiberStore ", - "10GSFP-PC-30-1 ", - "FS40212D0176 ", - SFF_10G_BASE_CR_PROPERTIES, - 0x1, - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x06, 0x67, 0x00, 0x50, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x58, 0x31, 0x38, 0x37, 0x31, - 0x4d, 0x33, 0x42, 0x43, 0x4c, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x06, 0x0e, 0x00, 0x33, - 0x06, 0x1a, 0x00, 0x00, 0x55, 0x50, 0x47, 0x30, 0x31, 0x57, 0x4a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x34, 0x32, 0x39, 0x20, 0x20, 0x68, 0xf0, 0x05, 0xfe, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTLX1871M3BCL ", - "UPG01WJ ", - SFF_10G_BASE_ZR_PROPERTIES, - -1, - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, - 0x03, 0x01, 0x00, 0x0a, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x58, 0x38, 0x35, 0x37, 0x30, - 0x44, 0x33, 0x42, 0x43, 0x4c, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x52, 0x00, 0x1c, - 0x00, 0x1a, 0x00, 0x00, 0x50, 0x50, 0x34, 0x34, 0x51, 0x56, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x32, 0x31, 0x37, 0x20, 0x20, 0x68, 0xf0, 0x03, 0xe3, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTLX8570D3BCL ", - "PP44QV1 ", - SFF_10G_BASE_SRL_PROPERTIES, - -1, - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x00, 0x00, 0x00, 0x02, 0x12, 0x10, 0x01, 0x05, 0x01, 0x15, 0x00, 0x0a, 0x64, - 0x00, 0x00, 0x00, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x52, 0x4a, 0x31, 0x33, 0x31, 0x39, - 0x50, 0x31, 0x42, 0x54, 0x4c, 0x2d, 0x4d, 0x44, 0x41, 0x20, 0x20, 0x20, 0x05, 0x1e, 0x00, 0x88, - 0x00, 0x1a, 0x00, 0x00, 0x50, 0x44, 0x42, 0x31, 0x56, 0x51, 0x55, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x30, 0x33, 0x31, 0x37, 0x20, 0x20, 0x68, 0xb0, 0x01, 0xc9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { -"FINISAR CORP. ", - "FTRJ1319P1BTL-MD", - "PDB1VQU ", - SFF_1G_BASE_LX_PROPERTIES, - -1, - }, - }, - }, - - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x81, 0x00, 0x00, 0x04, 0x41, 0x04, 0x80, 0xd5, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x54, 0x79, 0x63, 0x6f, 0x20, 0x45, 0x6c, 0x65, 0x63, 0x74, 0x72, 0x6f, - 0x6e, 0x69, 0x63, 0x73, 0x00, 0x00, 0x40, 0x20, 0x32, 0x31, 0x30, 0x30, 0x38, 0x37, 0x30, 0x2d, - 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x8a, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x39, 0x33, 0x35, 0x45, 0x30, 0x34, 0x38, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x35, 0x30, 0x39, 0x30, 0x30, 0x00, 0x00, 0x00, 0x41, - 0x37, 0x34, 0x30, 0x2d, 0x30, 0x33, 0x30, 0x30, 0x37, 0x36, 0x20, 0x52, 0x45, 0x56, 0x20, 0x30, - 0x31, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Tyco Electronics", - "2100870-1 ", - "0935E048 ", - SFF_10G_BASE_CR_PROPERTIES, - 1, - }, - }, - }, - - { - { - .eeprom = { - /* 0 */ 0x0d, 0x00, 0x02, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 16 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 32 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 64 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 128 */ 0x0d, 0xdc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xce, 0x00, 0x00, 0x32, - /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x41, 0x56, 0x41, 0x47, 0x4f, 0x20, - /* 160 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x17, 0x6a, 0x41, 0x46, 0x42, 0x52, 0x2d, 0x37, 0x39, 0x45, - /* 176 */ 0x42, 0x50, 0x5a, 0x2d, 0x43, 0x53, 0x31, 0x20, 0x30, 0x31, 0x42, 0x68, 0x07, 0xd0, 0x46, 0x47, - /* 192 */ 0x00, 0x00, 0x0f, 0xde, 0x41, 0x56, 0x4d, 0x31, 0x38, 0x30, 0x39, 0x53, 0x30, 0x54, 0x47, 0x20, - /* 208 */ 0x20, 0x20, 0x20, 0x20, 0x31, 0x34, 0x30, 0x32, 0x32, 0x35, 0x20, 0x20, 0x08, 0x00, 0xf5, 0xcc, - /* 224 */ 0xf5, 0x00, 0x06, 0xd2, 0x04, 0x9c, 0x47, 0x09, 0xc5, 0xaf, 0xcf, 0xb7, 0x65, 0xd9, 0x72, 0x03, - /* 240 */ 0xea, 0x59, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x45, 0xbd, 0x94, - }, - .info = { -"CISCO-AVAGO ", - "AFBR-79EBPZ-CS1 ", - "AVM1809S0TG ", - SFF_40G_BASE_SR2_PROPERTIES, - -1, - }, - }, - }, - /* Cisco/Finisar 40G QSFP (QuadWire? AOC? Pigtail?) */ - { - { - .eeprom = { - /* 0x0000 */ 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0010 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xde, 0x00, 0x00, 0x7f, 0x4d, 0x00, 0x00, 0x00, 0x00, - /* 0x0020 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0030 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0040 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0050 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0070 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - /* 0x0080 */ 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x32, - /* 0x0090 */ 0x1e, 0x00, 0x0a, 0x00, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /* 0x00a0 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x34, 0x31, 0x30, 0x51, - /* 0x00b0 */ 0x45, 0x32, 0x43, 0x31, 0x30, 0x2d, 0x43, 0x31, 0x41, 0x20, 0x42, 0x68, 0x07, 0xd0, 0x46, 0xaf, - /* 0x00c0 */ 0x00, 0x01, 0x04, 0xd8, 0x46, 0x49, 0x53, 0x31, 0x37, 0x33, 0x31, 0x30, 0x30, 0x35, 0x33, 0x2d, - /* 0x00d0 */ 0x41, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x37, 0x33, 0x31, 0x20, 0x20, 0x0a, 0x00, 0xf6, 0x90, - /* 0x00e0 */ 0x00, 0x00, 0x02, 0x43, 0x59, 0xd3, 0x68, 0x03, 0x46, 0x83, 0x87, 0x75, 0x1f, 0xee, 0x94, 0x62, - /* 0x00f0 */ 0xb8, 0x98, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x5e, 0x75, 0x43, - }, - .info = { - "CISCO ", - "FCBN410QE2C10-C1", - "FIS17310053-A ", - SFF_40G_BASE_SR4_PROPERTIES, - -1, - }, - }, - }, - /* - * Dell/Amphenol 3M copper - * Identifies as intra-enclosure and inter-enclosure - */ - { - { - .eeprom = { - /* 0000 */ 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x00, 0x41, 0x84, 0x80, 0x55, 0x00, 0x67, 0x00, 0x00, 0x00, - /* 0010 */ 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - /* 0020 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x36, 0x31, 0x36, 0x37, 0x34, 0x30, 0x30, 0x30, - /* 0030 */ 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xe3, - /* 0040 */ 0x00, 0x00, 0x00, 0x00, 0x43, 0x4e, 0x30, 0x35, 0x33, 0x48, 0x56, 0x4e, 0x34, 0x34, 0x4c, 0x38, - /* 0050 */ 0x37, 0x59, 0x59, 0x20, 0x31, 0x34, 0x30, 0x34, 0x32, 0x33, 0x20, 0x20, 0x00, 0x00, 0x00, 0x78, - /* 0060 */ 0x0f, 0x10, 0x00, 0xa3, 0x71, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0070 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0080 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0090 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00a0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00b0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00c0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00d0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00e0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 00f0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "616740003 ", - "CN053HVN44L87YY ", - SFF_10G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - /* - * Dell/Amphenol 3M copper - * Identifies as intra-enclosure and inter-enclosure - */ - { - { - .eeprom = { - /* 0x0000 */ 0x03, 0x04, 0x21, 0x02, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x00, 0x67, 0x00, 0x00, 0x00, - /* 0x0010 */ 0x00, 0x00, 0x03, 0x00, 0x33, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - /* 0x0020 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x31, 0x34, 0x31, 0x30, 0x2d, 0x50, 0x31, 0x37, - /* 0x0030 */ 0x2d, 0x30, 0x30, 0x2d, 0x33, 0x2e, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x1c, - /* 0x0040 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0050 */ 0x00, 0x00, 0x00, 0x00, 0x31, 0x32, 0x30, 0x32, 0x32, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, - /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0070 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0080 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0090 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00a0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00b0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00c0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00d0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00e0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00f0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M ", - "1410-P17-00-3.00", - /* XXX roth -- NULL serial number ??!??111! */ - " ", - SFF_10G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, - 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x14, 0x21, 0x00, 0x00, 0x83, 0x2c, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0a, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, - 0x0c, 0x04, 0x00, 0x00, 0x00, 0x40, 0x40, 0x06, 0x00, 0x05, - 0x64, 0x00, 0x00, 0x32, 0x1e, 0x00, 0x00, 0x00, 0x45, 0x64, - 0x67, 0x65, 0x2d, 0x63, 0x6f, 0x72, 0x45, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x04, 0x70, 0x72, 0xcf, 0x4d, 0x30, - 0x4f, 0x45, 0x43, 0x36, 0x34, 0x30, 0x31, 0x54, 0x30, 0x30, - 0x5a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x42, 0x68, 0x07, 0xd0, - 0x46, 0xb0, 0x00, 0x00, 0x00, 0x12, 0x31, 0x45, 0x37, 0x51, - 0x54, 0x30, 0x30, 0x30, 0x33, 0x30, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x31, 0x34, 0x30, 0x37, 0x32, 0x38, 0x20, 0x20, - 0x08, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "Edge-corE ", - "M0OEC6401T00Z ", - "1E7QT00030 ", - SFF_40G_BASE_SR4_PROPERTIES, - -1, - }, - } - }, - { - { - .eeprom = { - 0x0d, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, - 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0e, 0x30, 0x00, 0x00, 0x82, 0xa2, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, - 0x0c, 0x04, 0x00, 0x00, 0x00, 0x40, 0x40, 0x06, 0x00, 0x05, - 0x64, 0x00, 0x00, 0x32, 0x1e, 0x00, 0x00, 0x00, 0x45, 0x64, - 0x67, 0x65, 0x2d, 0x63, 0x6f, 0x72, 0x45, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x04, 0x70, 0x72, 0xcf, 0x4d, 0x30, - 0x4f, 0x45, 0x43, 0x36, 0x34, 0x30, 0x31, 0x54, 0x30, 0x30, - 0x5a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x42, 0x68, 0x07, 0xd0, - 0x46, 0xb0, 0x00, 0x00, 0x00, 0x12, 0x31, 0x45, 0x37, 0x51, - 0x54, 0x30, 0x30, 0x30, 0x32, 0x38, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x31, 0x34, 0x30, 0x37, 0x32, 0x38, 0x20, 0x20, - 0x08, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - .info = { - "Edge-corE ", - "M0OEC6401T00Z ", - "1E7QT00028 ", - SFF_40G_BASE_SR4_PROPERTIES, - -1, - }, - } - }, - { - { - .eeprom = { - 0x0d, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x17, 0x9f, 0x00, 0x00, 0x80, 0x29, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x44, 0xd5, 0x44, 0x3a, 0x48, 0xb1, - 0x4d, 0x30, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x8c, - 0x23, 0x04, 0x00, 0x00, 0x01, 0x40, 0x40, 0x02, 0x00, 0x05, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x46, 0x4f, - 0x52, 0x4d, 0x45, 0x52, 0x49, 0x43, 0x41, 0x4f, 0x45, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x04, 0x00, 0x00, 0x00, 0x54, 0x51, - 0x53, 0x2d, 0x51, 0x31, 0x4c, 0x48, 0x38, 0x2d, 0x58, 0x43, - 0x41, 0x31, 0x30, 0x20, 0x00, 0x00, 0x42, 0x68, 0x07, 0xd0, - 0x46, 0x4a, 0x00, 0x00, 0x05, 0x31, 0x39, 0x31, 0x33, 0x33, - 0x32, 0x4c, 0x30, 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x31, 0x33, 0x30, 0x38, 0x30, 0x36, 0x20, 0x20, - 0x08, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xef, - 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xef, 0xf7, 0xf7, 0xf7, - 0xf7, 0xf7, 0xf7, 0xf7, 0xfe, 0xfe, - }, - .info = { - "FORMERICAOE ", - "TQS-Q1LH8-XCA10 ", - "91332L0001 ", - SFF_40G_BASE_SR4_PROPERTIES, - 10, - }, - }, - }, - - { - { - .eeprom = { - /* 0x0000 */ 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, - /* - * ^^^^ copper pigtail - * - * ^^^^ no 10G or IB codes - * - * ^^^^ ^^^^ no SONET (fiber) - * - * identifies as 1000BASE-CX ^^^^ - * - * no FC length code ^^^^ - * - * identifies as SFP+ passive ^^^^ - * - * no FC media, copper or otherwise ^^^^ - * - * no FC speed ^^^^ - * - * nominal bitrate 0x67 --> 10.3GB ^^^^ - */ - /* 0x0010 */ 0x00, 0x00, 0x03, 0x00, 0x49, 0x42, 0x4d, 0x2d, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, - /* - * ^^^^ copper cable length (3m) - */ - /* 0x0020 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x17, 0xef, 0x39, 0x30, 0x59, 0x39, 0x34, 0x32, 0x38, 0x2d, - /* 0x0030 */ 0x4e, 0x32, 0x38, 0x35, 0x30, 0x30, 0x41, 0x20, 0x46, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x7a, - /* 0x0040 */ 0x00, 0x00, 0x00, 0x00, 0x59, 0x33, 0x35, 0x30, 0x56, 0x54, 0x32, 0x42, 0x52, 0x31, 0x46, 0x47, - /* 0x0050 */ 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x31, 0x31, 0x32, 0x37, 0x20, 0x20, 0x00, 0x00, 0x00, 0x0d, - /* 0x0060 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0070 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0080 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0090 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00a0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00b0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00c0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00d0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00e0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00f0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { -"IBM-Amphenol ", - "90Y9428-N28500A ", - "Y350VT2BR1FG ", - SFF_10G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - { - /* Verify string normalization for unprintable characters in the vendor, model, or serial number fields. */ - { - { - /* 0x0000 */ 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, - /* 0x0010 */ 0x00, 0x00, 0x03, 0x00, 0x49, 0x42, 0x4d, 0x2d, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, - /* 0x0020 */ 0xF0, 0xF0, 0xF0, 0xF0, 0x00, 0x00, 0x17, 0xef, 0x39, 0x30, 0x59, 0x39, 0x34, 0x32, 0x38, 0xFd, - /* 0x0030 */ 0x4e, 0x32, 0x38, 0x35, 0x30, 0x30, 0x41, 0x20, 0x46, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x8a, - /* 0x0040 */ 0x00, 0x00, 0x00, 0x00, 0x59, 0x33, 0xF5, 0xF0, 0x56, 0x54, 0x32, 0x42, 0x52, 0x31, 0x46, 0x47, - /* 0x0050 */ 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x31, 0x31, 0x32, 0x37, 0x20, 0x20, 0x00, 0x00, 0x00, 0x8d, - /* 0x0060 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0070 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0080 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x0090 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00a0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00b0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00c0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00d0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00e0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - /* 0x00f0 */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "IBM-Amphenol????", - "90Y9428?N28500A ", - "Y3??VT2BR1FG ", - SFF_10G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - { - /* - * Finisar 40G AOC breakout cable - */ - { - { - /* 0x0000 */ 0x0d, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0010 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x9f, 0x00, 0x00, 0x80, 0xc2, 0x00, 0x00, 0x00, 0x00, - /* 0x0020 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0030 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0040 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0050 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0070 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - - /* 0x0080 */ 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - /* - * ^^^^ QSFP+ - * - * ^^^^ no separable connector (active?) - * - * ^^^^^ no media compliance (*NOT* 40G active) - * - * ^^^^ no SONET compliance - * - * ^^^^ no SAS compliance - * - * ^^^^ no GbE compliance - * - * ^^^^ ^^^^ no FC compliance - * - * ^^^^ no FC media - * - * ^^^^ no FC speed - * - * ^^^^ 64b66b - * - * ^^^^ nominal BR >= 10G - * no SM or OM3 length ^^^^ ^^^^ - */ - /* 0x0090 */ 0x00, 0x00, 0x03, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - /* - * ^^^^ ^^^^ no OM1 or OM2 length - * - * ^^^^ 3M cable (copper or active) - */ - /* 0x00a0 */ 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x35, 0x31, 0x30, 0x51, - /* 0x00b0 */ 0x45, 0x32, 0x43, 0x30, 0x33, 0x20, 0x20, 0x20, 0x41, 0x20, 0x42, 0x68, 0x07, 0xd0, 0x46, 0x29, - /* - * ^^^^ ^^^^ 850nm - */ - /* 0x00c0 */ 0x00, 0x01, 0x04, 0xd8, 0x44, 0x53, 0x4b, 0x30, 0x34, 0x56, 0x52, 0x20, 0x20, 0x20, 0x20, 0x20, - /* 0x00d0 */ 0x20, 0x20, 0x20, 0x20, 0x31, 0x34, 0x31, 0x31, 0x30, 0x34, 0x20, 0x20, 0x08, 0x00, 0xf6, 0x54, - /* 0x00e0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00f0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP ", - "FCBN510QE2C03 ", - "DSK04VR ", - SFF_40G_BASE_SR4_PROPERTIES, - 3, - }, - }, - }, - { - /* - * Finisar 40G AOC breakout cable, 10G end - */ - { - { - /* 0x0000 */ 0x03, 0x04, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, - /* - * ^^^^ SFP+ - * - * ^^^^ copper pigtail (ugh) - * - * ^^^^ no 10G or IF compliance - * - * ^^^^ no SONET compliance - * - * ^^^^ no OC length spec - * - * ^^^^ no ethernet compliance - * - * ^^^^ no FC length or tech - * - * ^^^^ active cable, no FC tech - * - * ^^^^ no FC media - * - * ^^^^ no FC speed - * - * ^^^^ 64/66 encoding - * - * nominal BR >= 10G ^^^^ - * - * no SM length ^^^^ ^^^^ - */ - /* 0x0010 */ 0x00, 0x00, 0x01, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - /* - * ^^^^ ^^^^ no MM length - * - * ^^^^ active/copper length 1m - * - * ^^^^ no OM3 length - * - */ - /* 0x0020 */ 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x35, 0x31, 0x30, 0x51, - /* 0x0030 */ 0x45, 0x32, 0x43, 0x30, 0x31, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x0c, 0x00, 0x00, 0xa9, - /* - * compliant with FC or SFF limiting ^^^^ ^^^^ - */ - /* 0x0040 */ 0x00, 0x12, 0x00, 0x00, 0x44, 0x53, 0x4a, 0x30, 0x35, 0x39, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, - /* 0x0050 */ 0x20, 0x20, 0x20, 0x20, 0x31, 0x34, 0x31, 0x30, 0x33, 0x30, 0x20, 0x20, 0x00, 0x00, 0x05, 0x72, - /* 0x0060 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0070 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0080 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x0090 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00a0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00b0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00c0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00d0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00e0 */ 0x00, 0x7f, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 0x00f0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FCBN510QE2C01 ", - "DSJ059S ", - SFF_10G_BASE_SR_PROPERTIES, - 1, - }, - }, - }, - - - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x45, 0x42, 0x30, 0x38, 0x35, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x31, 0x31, 0x30, 0x20, 0x20, 0x00, 0x00, 0x00, 0x44, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10EB085 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x4f, 0x00, 0x00, 0x7f, 0x3d, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1b, 0x19, 0x1c, 0x87, 0x1a, 0x7c, 0x1b, 0xdd, 0x0e, 0xed, 0x0e, 0xd1, 0x0e, 0xcc, - 0x0f, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x23, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x20, 0x20, 0x20, 0x20, 0x1f, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x34, 0x32, 0x35, 0x51, - 0x42, 0x31, 0x43, 0x30, 0x33, 0x20, 0x20, 0x20, 0x41, 0x31, 0x00, 0x00, 0x00, 0x00, 0x46, 0xb1, - 0x01, 0x07, 0xff, 0xde, 0x44, 0x55, 0x48, 0x30, 0x30, 0x32, 0x43, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x30, 0x32, 0x31, 0x20, 0x20, 0x08, 0x00, 0x67, 0x94, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP ", - "FCBN425QB1C03 ", - "DUH002C ", - SFF_100G_AOC_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x4f, 0x00, 0x00, 0x81, 0x10, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x07, 0xd7, 0x06, 0x55, 0x06, 0x41, 0x07, 0xab, 0x4b, 0x1d, 0x45, 0x55, 0x48, 0x45, - 0x44, 0x4a, 0x1f, 0x02, 0x2f, 0x75, 0x32, 0x82, 0x37, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x0d, 0xc0, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x0a, 0x00, - 0x00, 0x00, 0x00, 0x40, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x34, 0x43, 0x31, 0x51, 0x45, - 0x31, 0x43, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x31, 0x65, 0xa4, 0x05, 0x14, 0x46, 0xa1, - 0x00, 0x01, 0x0c, 0xd8, 0x55, 0x51, 0x4b, 0x30, 0x4e, 0x4c, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x31, 0x31, 0x32, 0x30, 0x20, 0x20, 0x08, 0x00, 0x00, 0x61, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTL4C1QE1C ", - "UQK0NL1 ", - SFF_40G_BASE_LR4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xd3, 0x00, 0x00, 0x80, 0x56, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x23, 0x03, 0xbc, 0x03, 0x20, 0x06, 0x49, 0x4d, 0x76, 0x4f, 0x6a, 0x54, 0x33, - 0x44, 0xc5, 0x3c, 0xd8, 0x38, 0xc4, 0x3b, 0xe6, 0x36, 0x89, 0x80, 0x51, 0x81, 0x48, 0x7e, 0xe2, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0xc0, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x0a, 0x00, - 0x00, 0x00, 0x00, 0x40, 0x4a, 0x44, 0x53, 0x55, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x01, 0x9c, 0x4a, 0x51, 0x50, 0x2d, 0x30, 0x34, 0x4c, 0x57, - 0x42, 0x41, 0x32, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x66, 0x6c, 0x05, 0x14, 0x46, 0xe5, - 0x00, 0x00, 0x0c, 0x98, 0x46, 0x45, 0x33, 0x34, 0x31, 0x30, 0x38, 0x38, 0x43, 0x30, 0x32, 0x34, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x34, 0x30, 0x38, 0x32, 0x32, 0x20, 0x20, 0x08, 0x00, 0x00, 0x39, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "JDSU ", - "JQP-04LWBA2 ", - "FE341088C024 ", - SFF_40G_BASE_LR4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x42, 0x39, 0x32, 0x30, 0x32, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x30, 0x39, 0x31, 0x37, 0x20, 0x20, 0x00, 0x00, 0x00, 0x3a, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10B9202 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xa4, 0x00, 0x00, 0x81, 0x43, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x96, 0x1d, 0xe5, 0x28, 0xfc, 0x1e, 0x76, 0x30, 0x05, 0x2e, 0x97, 0x30, 0xaf, - 0x41, 0x07, 0x1f, 0x47, 0x1f, 0x70, 0x20, 0x0c, 0x1d, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x02, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x60, 0x4c, 0x55, 0x4d, 0x45, 0x4e, 0x54, 0x55, 0x4d, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x01, 0x9c, 0x4c, 0x51, 0x32, 0x31, 0x30, 0x43, 0x52, 0x2d, - 0x43, 0x41, 0x41, 0x31, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x66, 0x6c, 0x05, 0x14, 0x00, 0x96, - 0x06, 0x0f, 0xff, 0xfa, 0x46, 0x46, 0x34, 0x32, 0x35, 0x30, 0x35, 0x30, 0x30, 0x30, 0x31, 0x39, - 0x2d, 0x51, 0x20, 0x20, 0x31, 0x35, 0x31, 0x32, 0x30, 0x32, 0x20, 0x20, 0x0c, 0x18, 0x67, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "LUMENTUM ", - "LQ210CR-CAA1 ", - "FF4250500019-Q ", - SFF_100G_CWDM4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x45, 0x42, 0x30, 0x34, 0x39, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x31, 0x31, 0x30, 0x20, 0x20, 0x00, 0x00, 0x00, 0x44, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10EB049 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x17, 0x00, 0x00, 0x7f, 0x46, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1e, 0xa9, 0x1c, 0x81, 0x1c, 0x4a, 0x1d, 0xf0, 0x0f, 0xfb, 0x0f, 0x8e, 0x0f, 0x90, - 0x0f, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x23, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0a, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x20, 0x20, 0x20, 0x20, 0x1f, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x34, 0x32, 0x35, 0x51, - 0x42, 0x31, 0x43, 0x31, 0x30, 0x20, 0x20, 0x20, 0x41, 0x31, 0x00, 0x00, 0x00, 0x00, 0x46, 0xb6, - 0x01, 0x07, 0xff, 0xde, 0x44, 0x55, 0x48, 0x30, 0x30, 0x37, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x30, 0x32, 0x34, 0x20, 0x20, 0x08, 0x00, 0x67, 0x8d, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP ", - "FCBN425QB1C10 ", - "DUH0074 ", - SFF_100G_AOC_PROPERTIES, - 10, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x45, 0x42, 0x30, 0x34, 0x36, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x31, 0x31, 0x30, 0x20, 0x20, 0x00, 0x00, 0x00, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10EB046 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x07, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x2d, 0x00, 0x00, 0x7f, 0x58, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x12, 0xf8, 0x12, 0x17, 0x17, 0x09, 0x0f, 0x2e, 0x8c, 0x56, 0x79, 0x8a, 0x7e, 0x21, - 0x84, 0xb5, 0x1f, 0x8d, 0x21, 0x25, 0x20, 0xa1, 0x23, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, - 0x11, 0xcd, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x64, 0x44, 0x45, 0x4c, 0x4c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x1f, 0x22, 0x33, 0x4d, 0x46, 0x58, 0x47, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x30, 0x66, 0x58, 0x01, 0x90, 0x46, 0x7a, - 0x03, 0x0f, 0xff, 0xda, 0x43, 0x4e, 0x30, 0x33, 0x4d, 0x46, 0x58, 0x47, 0x35, 0x36, 0x49, 0x30, - 0x30, 0x30, 0x31, 0x20, 0x31, 0x35, 0x30, 0x36, 0x31, 0x38, 0x20, 0x20, 0x0c, 0x10, 0x67, 0x9e, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xdf, 0x10, 0x01, 0x21, 0x41, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "DELL ", - "3MFXG ", - "CN03MFXG56I0001 ", - SFF_100G_BASE_LR4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x45, 0x42, 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x31, 0x31, 0x30, 0x20, 0x20, 0x00, 0x00, 0x00, 0x38, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10EB001 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x33, 0x4d, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x08, 0x00, 0x21, 0x39, 0x51, 0x41, 0x30, 0x2d, 0x31, 0x31, 0x31, - 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x2e, 0x30, 0x30, 0x30, 0x31, 0x03, 0x05, 0x06, 0x0c, 0x00, 0x56, - 0x00, 0x00, 0x00, 0x00, 0x56, 0x31, 0x30, 0x42, 0x39, 0x37, 0x36, 0x35, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x30, 0x39, 0x31, 0x37, 0x20, 0x20, 0x00, 0x00, 0x00, 0x48, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "3M Company ", - "9QA0-111-12-1.00", - "V10B9765 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x89, 0x00, 0x00, 0x80, 0xfc, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2c, 0x7a, 0x2c, 0x51, 0x23, 0x1a, 0x25, 0x43, 0x0d, 0xb3, 0x0d, 0x77, 0x0d, 0xc7, - 0x0d, 0x7f, 0x1a, 0xed, 0x1b, 0x3e, 0x1c, 0xa4, 0x1c, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x32, - 0x00, 0x00, 0x00, 0x00, 0x41, 0x56, 0x41, 0x47, 0x4f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x17, 0x6a, 0x41, 0x46, 0x42, 0x52, 0x2d, 0x37, 0x39, 0x45, - 0x51, 0x44, 0x5a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x42, 0x68, 0x07, 0xd0, 0x46, 0xbe, - 0x00, 0x00, 0x0f, 0xde, 0x51, 0x44, 0x34, 0x39, 0x30, 0x37, 0x32, 0x38, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x31, 0x32, 0x30, 0x35, 0x20, 0x20, 0x08, 0x00, 0x00, 0x34, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "AVAGO ", - "AFBR-79EQDZ ", - "QD490728 ", - SFF_40G_BASE_SR4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0x00, 0x23, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xa0, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x1f, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x41, 0x46, 0x46, 0x2d, 0x43, - 0x31, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x07, 0x0b, 0x0d, 0x13, 0x55, 0x15, - 0x0b, 0x00, 0x00, 0x00, 0x41, 0x50, 0x46, 0x31, 0x35, 0x35, 0x30, 0x31, 0x30, 0x33, 0x34, 0x37, - 0x35, 0x46, 0x20, 0x20, 0x31, 0x35, 0x31, 0x32, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0x67, 0x3f, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "NDAAFF-C103 ", - "APF1550103475F ", - SFF_100G_BASE_CR4_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x68, 0x00, 0x00, 0x7f, 0x42, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x34, 0x0f, 0x1c, 0xf3, 0x34, 0x57, 0x33, 0xcf, 0x0d, 0xd3, 0x0d, 0xf9, 0x0e, 0x03, - 0x0d, 0xdf, 0x26, 0xe6, 0x2d, 0xd3, 0x2d, 0xd8, 0x30, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xcc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0x00, 0x00, 0x23, - 0x00, 0x00, 0x32, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x43, 0x39, 0x35, 0x35, 0x31, - 0x52, 0x45, 0x50, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x41, 0x30, 0x42, 0x68, 0x07, 0xd0, 0x00, 0x3c, - 0x02, 0x07, 0xff, 0xde, 0x58, 0x55, 0x39, 0x30, 0x54, 0x52, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x31, 0x30, 0x30, 0x36, 0x20, 0x20, 0x0c, 0x10, 0x67, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP ", - "FTLC9551REPM ", - "XU90TRP ", - SFF_100G_BASE_SR4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x66, 0x00, 0x00, 0x7f, 0x45, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x21, 0x1b, 0x1f, 0x2d, 0x1f, 0xe5, 0x1f, 0xdb, 0x0f, 0x25, 0x0f, 0x19, 0x0f, 0x09, - 0x0e, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x23, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x05, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x20, 0x20, 0x20, 0x20, 0x1f, 0x00, 0x90, 0x65, 0x46, 0x43, 0x42, 0x4e, 0x34, 0x32, 0x35, 0x51, - 0x42, 0x31, 0x43, 0x30, 0x35, 0x20, 0x20, 0x20, 0x41, 0x31, 0x00, 0x00, 0x00, 0x00, 0x46, 0xb5, - 0x01, 0x07, 0xff, 0xde, 0x44, 0x55, 0x38, 0x30, 0x30, 0x33, 0x45, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x30, 0x38, 0x32, 0x31, 0x20, 0x20, 0x08, 0x00, 0x67, 0x8e, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP ", - "FCBN425QB1C05 ", - "DU8003E ", - SFF_100G_AOC_PROPERTIES, - 5, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x10, 0x00, 0x00, 0x00, 0x20, 0x40, 0x0c, 0x80, 0x06, 0x67, 0x00, 0x00, 0x00, - 0x08, 0x03, 0x00, 0x1e, 0x4a, 0x44, 0x53, 0x55, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x01, 0x9c, 0x50, 0x4c, 0x52, 0x58, 0x50, 0x4c, 0x53, 0x43, - 0x53, 0x34, 0x33, 0x32, 0x32, 0x4e, 0x20, 0x20, 0x32, 0x20, 0x20, 0x20, 0x03, 0x52, 0x00, 0xfe, - 0x00, 0x1a, 0x00, 0x00, 0x43, 0x42, 0x34, 0x35, 0x55, 0x46, 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x31, 0x31, 0x30, 0x33, 0x31, 0x20, 0x20, 0x68, 0xf0, 0x03, 0xd6, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "JDSU ", - "PLRXPLSCS4322N ", - "CB45UF001 ", - SFF_10G_BASE_SR_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, - 0x08, 0x03, 0x00, 0x1e, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x58, 0x38, 0x35, 0x37, 0x31, - 0x44, 0x33, 0x42, 0x43, 0x4c, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x52, 0x00, 0x48, - 0x00, 0x1a, 0x00, 0x00, 0x4d, 0x54, 0x38, 0x31, 0x54, 0x45, 0x58, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x30, 0x33, 0x30, 0x34, 0x20, 0x20, 0x68, 0xf0, 0x03, 0xfd, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTLX8571D3BCL ", - "MT81TEX ", - SFF_10G_BASE_SR_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x78, 0x00, 0x00, 0x7f, 0x19, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x89, 0x0d, 0x70, 0xb6, 0x51, 0x1b, 0x7e, 0x8a, 0x51, 0x40, 0x44, 0x62, 0x4f, 0x4f, - 0x4a, 0xe3, 0x46, 0x41, 0x45, 0xc9, 0x49, 0x6e, 0x49, 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x0d, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x01, 0x46, - 0x00, 0x00, 0x00, 0x40, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x34, 0x43, 0x33, 0x51, 0x45, - 0x31, 0x43, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x31, 0x65, 0xa4, 0x05, 0x14, 0x46, 0xde, - 0x00, 0x01, 0x0c, 0xd8, 0x55, 0x54, 0x4e, 0x30, 0x51, 0x38, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x30, 0x33, 0x31, 0x30, 0x20, 0x20, 0x08, 0x00, 0x00, 0x5c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTL4C3QE1C ", - "UTN0Q84 ", - SFF_40G_BASE_LM4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x0a, 0x07, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x02, 0x00, 0x90, 0x65, 0x46, 0x54, 0x4c, 0x46, 0x38, 0x35, 0x33, 0x36, - 0x50, 0x34, 0x42, 0x43, 0x4c, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x52, 0x00, 0xb8, - 0x08, 0x1a, 0x70, 0x00, 0x55, 0x57, 0x42, 0x30, 0x34, 0x56, 0x59, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x32, 0x35, 0x20, 0x20, 0x68, 0xf0, 0x08, 0x84, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "FINISAR CORP. ", - "FTLF8536P4BCL ", - "UWB04VY ", - SFF_25G_BASE_SR_PROPERTIES, - -1, - } - } - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0xed, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, - 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x32, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x07, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x4f, 0x55, 0x30, 0x38, 0x31, 0x30, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe1, 0x8f, - 0xe1, 0x00, 0x11, 0x07, 0xe0, 0x78, 0x3c, 0x38, 0x70, 0xdc, 0x23, 0x54, 0x6f, 0x20, 0xce, 0xa0, - 0x17, 0x22, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x38, 0xfe, 0x76 - }, - .info = { - "CISCO-OEM ", - "QSFP-4SFP+-CU2M ", - "GTOU0810 ", - SFF_40G_BASE_CR4_PROPERTIES, - 2, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x80, 0x45, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x05, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, - 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x35, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x49, 0x59, 0x32, 0x34, 0x35, 0x35, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe2, 0x95, - 0xe2, 0x00, 0x11, 0x18, 0x0f, 0x39, 0xf6, 0x13, 0x6a, 0x40, 0x77, 0x21, 0x63, 0x2a, 0xec, 0xcf, - 0xd7, 0x4d, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe1, 0x50, 0xe8, 0xf4, - }, - .info = { - "CISCO-OEM ", - "QSFP-4SFP+-CU5M ", - "GTIY2455 ", - SFF_40G_BASE_CR4_PROPERTIES, - 5, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xcb, 0x00, 0x00, 0x7e, 0x8c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x10, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0xa0, 0x43, 0x49, 0x53, 0x43, 0x4f, 0x2d, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x34, 0x53, 0x46, - 0x50, 0x2b, 0x2d, 0x43, 0x55, 0x33, 0x4d, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x54, 0x47, 0x52, 0x38, 0x36, 0x38, 0x30, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x37, 0x30, 0x36, 0x32, 0x38, 0x20, 0x20, 0x2e, 0x00, 0xe1, 0x91, - 0xe1, 0x00, 0x11, 0x9f, 0xfa, 0xcd, 0xf5, 0xd3, 0x56, 0xb3, 0x83, 0x78, 0x28, 0xf6, 0x50, 0x52, - 0xd7, 0x72, 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x2f, 0xae, 0x0a, - }, - .info = { - "CISCO-OEM ", - "QSFP-4SFP+-CU3M ", - "GTGR8680 ", - SFF_40G_BASE_CR4_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x4d, 0x65, 0x6c, 0x6c, 0x61, 0x6e, 0x6f, 0x78, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x07, 0x00, 0x02, 0xc9, 0x4d, 0x43, 0x32, 0x32, 0x30, 0x36, 0x31, 0x33, - 0x30, 0x2d, 0x30, 0x30, 0x31, 0x20, 0x20, 0x20, 0x41, 0x20, 0x06, 0x0a, 0x00, 0x00, 0x46, 0xa6, - 0x00, 0x00, 0x00, 0x00, 0x4d, 0x53, 0x2d, 0x31, 0x31, 0x31, 0x37, 0x35, 0x30, 0x33, 0x31, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x33, 0x30, 0x32, 0x32, 0x34, 0x20, 0x20, 0x00, 0x00, 0x00, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "Mellanox ", - "MC2206130-001 ", - "MS-11175031 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x22, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x64, 0x00, 0x46, 0x49, 0x4e, 0x49, 0x53, 0x41, 0x52, 0x20, 0x43, 0x4f, 0x52, 0x50, - 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x90, 0x65, 0x46, 0x43, 0x4c, 0x46, 0x38, 0x35, 0x32, 0x32, - 0x50, 0x32, 0x42, 0x54, 0x4c, 0x2d, 0x44, 0x4c, 0x41, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x33, - 0x00, 0x12, 0x00, 0x00, 0x50, 0x54, 0x4d, 0x33, 0x41, 0x4e, 0x57, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x35, 0x30, 0x35, 0x32, 0x34, 0x20, 0xff, 0x00, 0x00, 0x00, 0x8c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "FINISAR CORP. ", - "FCLF8522P2BTL-DL", - "PTM3ANW ", - SFF_1G_BASE_T_PROPERTIES, - 100, - }, - }, - }, - { - { - .eeprom = { - 0x11, 0x07, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xb8, 0x00, 0x00, 0x85, 0x0b, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x45, 0x26, 0x44, 0xf0, 0x45, 0x63, - 0x45, 0x3a, 0x1d, 0xee, 0x1d, 0x88, 0x23, 0x8a, 0x24, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x11, 0xcc, 0x0c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x00, 0x02, 0x00, - 0x00, 0x00, 0x00, 0x40, 0x49, 0x4e, 0x4e, 0x4f, 0x4c, 0x49, 0x47, 0x48, 0x54, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x44, 0x7c, 0x7f, 0x54, 0x52, 0x2d, 0x56, 0x43, 0x31, 0x33, 0x54, - 0x2d, 0x4e, 0x30, 0x30, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x66, 0x58, 0x07, 0xd0, 0x46, 0x33, - 0x07, 0x07, 0xff, 0xda, 0x49, 0x4e, 0x47, 0x41, 0x54, 0x36, 0x36, 0x35, 0x30, 0x30, 0x37, 0x39, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x30, 0x35, 0x31, 0x32, 0x31, 0x39, 0x0c, 0x00, 0x67, 0x57, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "INNOLIGHT ", - "TR-VC13T-N00 ", - "INGAT6650079 ", - SFF_100G_PSM4_PROPERTIES, - -1, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x43, 0x4d, 0x50, 0x51, 0x41, 0x41, 0x31, 0x43, 0x41, 0x41, 0x33, 0x37, 0x2d, 0x31, - 0x33, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x56, 0x30, 0x32, 0x20, 0x51, 0x53, 0x46, 0x50, 0x2d, 0xe6, - 0x53, 0x46, 0x50, 0x31, 0x30, 0x47, 0x2d, 0x43, 0x55, 0x32, 0x4d, 0x20, 0x20, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0xa0, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x46, 0x34, 0x4d, 0x2d, 0x51, 0x53, 0x53, 0x46, - 0x50, 0x2d, 0x43, 0x2d, 0x32, 0x2d, 0x33, 0x30, 0x41, 0x20, 0x09, 0x0d, 0x00, 0x00, 0x46, 0x8f, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x45, 0x31, 0x36, 0x30, 0x34, 0x30, 0x39, 0x32, 0x33, 0x33, 0x33, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x30, 0x34, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0xe2, 0x60, - 0x00, 0x00, 0x11, 0x92, 0x93, 0x56, 0x08, 0x23, 0xce, 0x3b, 0x71, 0x35, 0xac, 0x37, 0xdc, 0x38, - 0x1d, 0x13, 0xcb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d, 0x36, 0xa4, 0x00, - }, - .info = { - "OEM ", - "F4M-QSSFP-C-2-30", - "GE1604092333 ", - SFF_40G_BASE_CR4_PROPERTIES, - 2, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0d, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x43, - 0x31, 0x30, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x03, 0x00, 0x00, 0x17, - 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x37, 0x31, 0x34, 0x31, 0x30, 0x34, 0x35, 0x55, - 0x47, 0x56, 0x20, 0x20, 0x31, 0x37, 0x30, 0x34, 0x30, 0x38, 0x20, 0x20, 0x00, 0x00, 0x08, 0x83, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "NDCCGF-C104 ", - "APF17141045UGV ", - SFF_25G_BASE_CR_PROPERTIES, - 1, - } , - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x43, 0x43, 0x47, 0x46, 0x2d, 0x48, - 0x33, 0x30, 0x31, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xaf, - 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x34, 0x35, 0x33, 0x30, 0x31, 0x33, 0x33, - 0x50, 0x31, 0x20, 0x20, 0x31, 0x36, 0x31, 0x31, 0x31, 0x36, 0x20, 0x20, 0x00, 0x00, 0x08, 0x41, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "Amphenol ", - "NDCCGF-H301 ", - "APF164530133P1 ", - SFF_25G_BASE_CR_PROPERTIES, - 1, - } , - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x21, 0x01, 0x00, 0x00, 0x04, 0x41, 0x84, 0x80, 0xd5, 0x06, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x0b, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x48, - 0x33, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0xbf, - 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x35, 0x30, 0x33, 0x30, 0x33, 0x31, 0x4c, - 0x50, 0x44, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x31, 0x37, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6b, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - .info = { - "Amphenol ", - "NDAQGF-H303 ", - "APF16503031LPD ", - SFF_25G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x03, 0x04, 0x23, 0x01, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x06, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x03, 0x00, 0x41, 0x6d, 0x70, 0x68, 0x65, 0x6e, 0x6f, 0x6c, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x78, 0xa7, 0x14, 0x4e, 0x44, 0x41, 0x51, 0x47, 0x46, 0x2d, 0x30, - 0x30, 0x30, 0x33, 0x20, 0x20, 0x20, 0x20, 0x20, 0x41, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x67, 0x00, 0x41, 0x50, 0x46, 0x31, 0x36, 0x32, 0x35, 0x30, 0x30, 0x33, 0x31, 0x4b, - 0x43, 0x55, 0x20, 0x20, 0x31, 0x36, 0x30, 0x36, 0x32, 0x35, 0x20, 0x20, 0x00, 0x00, 0x08, 0x6f, - 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - .info = { - "Amphenol ", - "NDAQGF-0003 ", - "APF16250031KCU ", - SFF_25G_BASE_CR_PROPERTIES, - 3, - }, - }, - }, - { - { - .eeprom = { - 0x0d, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x43, 0x4d, 0x50, 0x51, 0x41, 0x41, 0x31, 0x43, 0x41, 0x41, 0x33, 0x37, 0x2d, 0x31, - 0x33, 0x32, 0x31, 0x2d, 0x30, 0x32, 0x56, 0x30, 0x32, 0x20, 0x51, 0x53, 0x46, 0x50, 0x2d, 0xe6, - 0x53, 0x46, 0x50, 0x31, 0x30, 0x47, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x20, 0x20, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, - 0x0d, 0x00, 0x23, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x67, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x01, 0xa0, 0x4f, 0x45, 0x4d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x51, 0x53, 0x46, 0x50, 0x2d, 0x48, 0x34, 0x30, - 0x47, 0x2d, 0x43, 0x55, 0x31, 0x4d, 0x2d, 0x43, 0x41, 0x20, 0x00, 0x00, 0x00, 0x00, 0x46, 0x7a, - 0x00, 0x00, 0x00, 0x00, 0x45, 0x31, 0x36, 0x31, 0x31, 0x31, 0x36, 0x30, 0x30, 0x36, 0x37, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x31, 0x36, 0x31, 0x32, 0x30, 0x32, 0x20, 0x20, 0x00, 0x00, 0xe2, 0x30, - 0x00, 0x00, 0x11, 0xbc, 0xb2, 0x5f, 0x4b, 0xf4, 0x39, 0x79, 0xf6, 0xca, 0xb9, 0x62, 0xf7, 0x4c, - 0x14, 0xd8, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d, 0xc5, 0xef, 0x53, - }, - .info = { - "OEM ", - "QSFP-H40G-CU1M-C", - "E1611160067 ", - SFF_40G_BASE_CR4_PROPERTIES, - 1, - }, - }, - }, -#endif /** SFF_CONFIG_INCLUDE_DATABASE */ - }; - -int -sff_db_get(sff_db_entry_t** entries, int* count) -{ - *entries = sff_database__; - *count = AIM_ARRAYSIZE(sff_database__); - return *count; -} - -int -sff_db_get_type(sff_eeprom_t* se, sff_module_type_t type) -{ - int i; - sff_db_entry_t* entry; - for(i = 0; i < AIM_ARRAYSIZE(sff_database__); i++) { - entry = sff_database__ + i; - if(entry->se.info.module_type == type) { - memcpy(se, &entry->se, sizeof(*se)); - return 1; - } - } - return 0; -} - -int -sff_db_entry_struct(sff_eeprom_t* se, aim_pvs_t* pvs) -{ - int i, j; - aim_printf(pvs, " {\n"); - aim_printf(pvs, " {\n"); - aim_printf(pvs, " .eeprom = {\n"); - for(i = 0; i < 16; i++) { - aim_printf(pvs, " "); - for(j = 0; j < 16; j++) { - aim_printf(pvs, "0x%.2x, ", se->eeprom[i*16+j]); - } - aim_printf(pvs, "\n"); - } - aim_printf(pvs, " },\n"); - aim_printf(pvs, " .info = {\n"); - aim_printf(pvs, " \"%s\",\n", se->info.vendor); - aim_printf(pvs, " \"%s\",\n", se->info.model); - aim_printf(pvs, " \"%s\",\n", se->info.serial); - aim_printf(pvs, " SFF_%s_PROPERTIES,\n", - sff_module_type_name(se->info.module_type)); - aim_printf(pvs, " %d,\n", se->info.length); - aim_printf(pvs, " },\n"); - aim_printf(pvs, " },\n"); - aim_printf(pvs, " },\n"); - return 0;} diff --git a/packages/base/any/onlp/src/sff/module/src/sff_enums.c b/packages/base/any/onlp/src/sff/module/src/sff_enums.c deleted file mode 100644 index deeeb50d..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_enums.c +++ /dev/null @@ -1,316 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include -#include - -/* */ -aim_map_si_t sff_media_type_map[] = -{ - { "COPPER", SFF_MEDIA_TYPE_COPPER }, - { "FIBER", SFF_MEDIA_TYPE_FIBER }, - { NULL, 0 } -}; - -aim_map_si_t sff_media_type_desc_map[] = -{ - { "Copper", SFF_MEDIA_TYPE_COPPER }, - { "Fiber", SFF_MEDIA_TYPE_FIBER }, - { NULL, 0 } -}; - -const char* -sff_media_type_name(sff_media_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_media_type_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_media_type'"; - } -} - -int -sff_media_type_value(const char* str, sff_media_type_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, sff_media_type_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -sff_media_type_desc(sff_media_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_media_type_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_media_type'"; - } -} - - -aim_map_si_t sff_module_caps_map[] = -{ - { "F_100", SFF_MODULE_CAPS_F_100 }, - { "F_1G", SFF_MODULE_CAPS_F_1G }, - { "F_10G", SFF_MODULE_CAPS_F_10G }, - { "F_25G", SFF_MODULE_CAPS_F_25G }, - { "F_40G", SFF_MODULE_CAPS_F_40G }, - { "F_100G", SFF_MODULE_CAPS_F_100G }, - { NULL, 0 } -}; - -aim_map_si_t sff_module_caps_desc_map[] = -{ - { "None", SFF_MODULE_CAPS_F_100 }, - { "None", SFF_MODULE_CAPS_F_1G }, - { "None", SFF_MODULE_CAPS_F_10G }, - { "None", SFF_MODULE_CAPS_F_25G }, - { "None", SFF_MODULE_CAPS_F_40G }, - { "None", SFF_MODULE_CAPS_F_100G }, - { NULL, 0 } -}; - -const char* -sff_module_caps_name(sff_module_caps_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_module_caps_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_module_caps'"; - } -} - -int -sff_module_caps_value(const char* str, sff_module_caps_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, sff_module_caps_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -sff_module_caps_desc(sff_module_caps_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_module_caps_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_module_caps'"; - } -} - -int -sff_module_caps_valid(sff_module_caps_t e) -{ - return aim_map_si_i(NULL, e, sff_module_caps_map, 0) ? 1 : 0; -} - - -aim_map_si_t sff_module_type_map[] = -{ - { "100G_AOC", SFF_MODULE_TYPE_100G_AOC }, - { "100G_BASE_CR4", SFF_MODULE_TYPE_100G_BASE_CR4 }, - { "100G_BASE_SR4", SFF_MODULE_TYPE_100G_BASE_SR4 }, - { "100G_BASE_LR4", SFF_MODULE_TYPE_100G_BASE_LR4 }, - { "100G_CWDM4", SFF_MODULE_TYPE_100G_CWDM4 }, - { "100G_PSM4", SFF_MODULE_TYPE_100G_PSM4 }, - { "100G_SWDM4", SFF_MODULE_TYPE_100G_SWDM4 }, - { "40G_BASE_CR4", SFF_MODULE_TYPE_40G_BASE_CR4 }, - { "40G_BASE_SR4", SFF_MODULE_TYPE_40G_BASE_SR4 }, - { "40G_BASE_LR4", SFF_MODULE_TYPE_40G_BASE_LR4 }, - { "40G_BASE_LM4", SFF_MODULE_TYPE_40G_BASE_LM4 }, - { "40G_BASE_ACTIVE", SFF_MODULE_TYPE_40G_BASE_ACTIVE }, - { "40G_BASE_CR", SFF_MODULE_TYPE_40G_BASE_CR }, - { "40G_BASE_SR2", SFF_MODULE_TYPE_40G_BASE_SR2 }, - { "40G_BASE_SM4", SFF_MODULE_TYPE_40G_BASE_SM4 }, - { "40G_BASE_ER4", SFF_MODULE_TYPE_40G_BASE_ER4 }, - { "25G_BASE_CR", SFF_MODULE_TYPE_25G_BASE_CR }, - { "25G_BASE_SR", SFF_MODULE_TYPE_25G_BASE_SR }, - { "25G_BASE_LR", SFF_MODULE_TYPE_25G_BASE_LR }, - { "25G_BASE_AOC", SFF_MODULE_TYPE_25G_BASE_AOC }, - { "10G_BASE_SR", SFF_MODULE_TYPE_10G_BASE_SR }, - { "10G_BASE_LR", SFF_MODULE_TYPE_10G_BASE_LR }, - { "10G_BASE_LRM", SFF_MODULE_TYPE_10G_BASE_LRM }, - { "10G_BASE_ER", SFF_MODULE_TYPE_10G_BASE_ER }, - { "10G_BASE_CR", SFF_MODULE_TYPE_10G_BASE_CR }, - { "10G_BASE_SX", SFF_MODULE_TYPE_10G_BASE_SX }, - { "10G_BASE_LX", SFF_MODULE_TYPE_10G_BASE_LX }, - { "10G_BASE_ZR", SFF_MODULE_TYPE_10G_BASE_ZR }, - { "10G_BASE_SRL", SFF_MODULE_TYPE_10G_BASE_SRL }, - { "1G_BASE_SX", SFF_MODULE_TYPE_1G_BASE_SX }, - { "1G_BASE_LX", SFF_MODULE_TYPE_1G_BASE_LX }, - { "1G_BASE_ZX", SFF_MODULE_TYPE_1G_BASE_ZX }, - { "1G_BASE_CX", SFF_MODULE_TYPE_1G_BASE_CX }, - { "1G_BASE_T", SFF_MODULE_TYPE_1G_BASE_T }, - { "100_BASE_LX", SFF_MODULE_TYPE_100_BASE_LX }, - { "100_BASE_FX", SFF_MODULE_TYPE_100_BASE_FX }, - { "4X_MUX", SFF_MODULE_TYPE_4X_MUX }, - { NULL, 0 } -}; - -aim_map_si_t sff_module_type_desc_map[] = -{ - { "100G-AOC", SFF_MODULE_TYPE_100G_AOC }, - { "100GBASE-CR4", SFF_MODULE_TYPE_100G_BASE_CR4 }, - { "100GBASE-SR4", SFF_MODULE_TYPE_100G_BASE_SR4 }, - { "100GBASE-LR4", SFF_MODULE_TYPE_100G_BASE_LR4 }, - { "100G-CWDM4", SFF_MODULE_TYPE_100G_CWDM4 }, - { "100G-PSM4", SFF_MODULE_TYPE_100G_PSM4 }, - { "100G-SWDM4", SFF_MODULE_TYPE_100G_SWDM4 }, - { "40GBASE-CR4", SFF_MODULE_TYPE_40G_BASE_CR4 }, - { "40GBASE-SR4", SFF_MODULE_TYPE_40G_BASE_SR4 }, - { "40GBASE-LR4", SFF_MODULE_TYPE_40G_BASE_LR4 }, - { "40GBASE-LM4", SFF_MODULE_TYPE_40G_BASE_LM4 }, - { "40GBASE-ACTIVE", SFF_MODULE_TYPE_40G_BASE_ACTIVE }, - { "40GBASE-CR", SFF_MODULE_TYPE_40G_BASE_CR }, - { "40GBASE-SR2", SFF_MODULE_TYPE_40G_BASE_SR2 }, - { "40GBASE-SM4", SFF_MODULE_TYPE_40G_BASE_SM4 }, - { "40GBASE-ER4", SFF_MODULE_TYPE_40G_BASE_ER4 }, - { "25GBASE-CR", SFF_MODULE_TYPE_25G_BASE_CR }, - { "25GBASE-SR", SFF_MODULE_TYPE_25G_BASE_SR }, - { "25GBASE-LR", SFF_MODULE_TYPE_25G_BASE_LR }, - { "25GBASE-AOC", SFF_MODULE_TYPE_25G_BASE_AOC }, - { "10GBASE-SR", SFF_MODULE_TYPE_10G_BASE_SR }, - { "10GBASE-LR", SFF_MODULE_TYPE_10G_BASE_LR }, - { "10GBASE-LRM", SFF_MODULE_TYPE_10G_BASE_LRM }, - { "10GBASE-ER", SFF_MODULE_TYPE_10G_BASE_ER }, - { "10GBASE-CR", SFF_MODULE_TYPE_10G_BASE_CR }, - { "10GBASE-SX", SFF_MODULE_TYPE_10G_BASE_SX }, - { "10GBASE-LX", SFF_MODULE_TYPE_10G_BASE_LX }, - { "10GBASE-ZR", SFF_MODULE_TYPE_10G_BASE_ZR }, - { "10GBASE-SRL", SFF_MODULE_TYPE_10G_BASE_SRL }, - { "1GBASE-SX", SFF_MODULE_TYPE_1G_BASE_SX }, - { "1GBASE-LX", SFF_MODULE_TYPE_1G_BASE_LX }, - { "1GBASE-ZX", SFF_MODULE_TYPE_1G_BASE_ZX }, - { "1GBASE-CX", SFF_MODULE_TYPE_1G_BASE_CX }, - { "1GBASE-T", SFF_MODULE_TYPE_1G_BASE_T }, - { "100BASE-LX", SFF_MODULE_TYPE_100_BASE_LX }, - { "100BASE-FX", SFF_MODULE_TYPE_100_BASE_FX }, - { "4X-MUX", SFF_MODULE_TYPE_4X_MUX }, - { NULL, 0 } -}; - -const char* -sff_module_type_name(sff_module_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_module_type_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_module_type'"; - } -} - -int -sff_module_type_value(const char* str, sff_module_type_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, sff_module_type_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -sff_module_type_desc(sff_module_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_module_type_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_module_type'"; - } -} - - -aim_map_si_t sff_sfp_type_map[] = -{ - { "SFP", SFF_SFP_TYPE_SFP }, - { "QSFP", SFF_SFP_TYPE_QSFP }, - { "QSFP_PLUS", SFF_SFP_TYPE_QSFP_PLUS }, - { "QSFP28", SFF_SFP_TYPE_QSFP28 }, - { "SFP28", SFF_SFP_TYPE_SFP28 }, - { NULL, 0 } -}; - -aim_map_si_t sff_sfp_type_desc_map[] = -{ - { "SFP", SFF_SFP_TYPE_SFP }, - { "QSFP", SFF_SFP_TYPE_QSFP }, - { "QSFP+", SFF_SFP_TYPE_QSFP_PLUS }, - { "QSFP28", SFF_SFP_TYPE_QSFP28 }, - { "SFP28", SFF_SFP_TYPE_SFP28 }, - { NULL, 0 } -}; - -const char* -sff_sfp_type_name(sff_sfp_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_sfp_type_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_sfp_type'"; - } -} - -int -sff_sfp_type_value(const char* str, sff_sfp_type_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, sff_sfp_type_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -sff_sfp_type_desc(sff_sfp_type_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, sff_sfp_type_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'sff_sfp_type'"; - } -} - -/* */ - diff --git a/packages/base/any/onlp/src/sff/module/src/sff_int.h b/packages/base/any/onlp/src/sff/module/src/sff_int.h deleted file mode 100644 index a67245ac..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_int.h +++ /dev/null @@ -1,13 +0,0 @@ -/**************************************************************************//** - * - * sff Internal Header - * - *****************************************************************************/ -#ifndef __SFF_INT_H__ -#define __SFF_INT_H__ - -#include - -int sff_nonstandard_lookup(sff_info_t* info); - -#endif /* __SFF_INT_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/src/sff_log.c b/packages/base/any/onlp/src/sff/module/src/sff_log.c deleted file mode 100644 index bd348d20..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "sff_log.h" -/* - * sff log struct. - */ -AIM_LOG_STRUCT_DEFINE( - SFF_CONFIG_LOG_OPTIONS_DEFAULT, - SFF_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - SFF_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/base/any/onlp/src/sff/module/src/sff_log.h b/packages/base/any/onlp/src/sff/module/src/sff_log.h deleted file mode 100644 index 5e564436..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __SFF_LOG_H__ -#define __SFF_LOG_H__ - -#define AIM_LOG_MODULE_NAME sff -#include - -#endif /* __SFF_LOG_H__ */ diff --git a/packages/base/any/onlp/src/sff/module/src/sff_module.c b/packages/base/any/onlp/src/sff/module/src/sff_module.c deleted file mode 100644 index 676a04b2..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_module.c +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "sff_log.h" - -static int -datatypes_init__(void) -{ -#define SFF_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __sff_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - diff --git a/packages/base/any/onlp/src/sff/module/src/sff_tool.c b/packages/base/any/onlp/src/sff/module/src/sff_tool.c deleted file mode 100644 index 81427f9b..00000000 --- a/packages/base/any/onlp/src/sff/module/src/sff_tool.c +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************ - * - * - * 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. - * - * - ************************************************************ - * - * SFF Utility for eeprom files. - * - ***********************************************************/ -#include - -#if SFF_CONFIG_INCLUDE_SFF_TOOL == 1 - -#include -#include -#include -#include - -int -sff_tool(int argc, char* argv[]) -{ - int rv = 0; - int i; - int c; - - int s = 0; - int e = 0; - int help = 0; - int n = 0; - int v = 0; - int sin = 0; - - biglist_t* fnames=NULL; - - - while( (c = getopt(argc, argv, "sehnvi")) != -1) { - switch(c) - { - case 's': s = 1; break; - case 'e': e = 1; break; - case 'h': help=1; rv=0; break; - case 'n': n=1; break; - case 'v': v=1; break; - case 'i': sin=1; break; - default: help=1; rv = 1; break; - } - } - - if(help) { - printf("Usage: %s [OPTIONS] [FILES]\n", argv[0]); - printf(" -i Read eeprom data from stdin.\n"); - printf(" -s Read filenames from stdin. \n"); - printf(" -n Print the filename if successful.\n"); - printf(" -v Print the filename always.\n"); - printf(" -e Show the raw eeprom data.\n"); - printf(" -h Help.\n"); - return rv; - } - - if(sin) { - uint8_t data[512]; - if(fread(data, 256, 1, stdin) == 1) { - sff_info_t info; - sff_info_init(&info, data); - if(info.supported) { - sff_info_show(&info, &aim_pvs_stdout); - return 0; - } - else { - aim_printf(&aim_pvs_stderr, "The eeprom data could not be parsed.\n"); - } - } - else { - aim_printf(&aim_pvs_stderr, "Error reading eeprom data from stdin.\n"); - } - return 1; - } - - - - - if(s) { - /* Read filenames from stdin */ - char b[PATH_MAX]; - char* l; - while((l = fgets(b, PATH_MAX, stdin))) { - int len=SFF_STRLEN(l); - if(len) { - if(l[len-1] == '\n') { - l[len-1] = 0; - } - fnames = biglist_append(fnames, aim_strdup(l)); - } - } - } - - /* Read from command line. This can be used together with -s */ - for(i = optind; i < argc; i++) { - fnames = biglist_append(fnames, aim_strdup(argv[i])); - } - - biglist_t* ble; - char* f; - BIGLIST_FOREACH_DATA(ble, fnames, char*, f) { - sff_info_t info; - memset(&info, 0, sizeof(info)); - if( (rv = sff_info_init_file(&info, f)) >= 0) { - if(n || v) { - aim_printf(&aim_pvs_stdout, "%s\n", f); - } - if(e) { - aim_printf(&aim_pvs_stdout, "eeprom:\n%{data}\n", info.eeprom, sizeof(info.eeprom)); - } - sff_info_show(&info, &aim_pvs_stdout); - } - else if(v) { - aim_printf(&aim_pvs_stdout, "%s: failed.\n", f); - } - } - return 0; -} - -#else -int __not_empty__; -#endif - - - diff --git a/packages/base/any/onlp/src/sff/sff.doxy b/packages/base/any/onlp/src/sff/sff.doxy deleted file mode 100644 index 9f96f494..00000000 --- a/packages/base/any/onlp/src/sff/sff.doxy +++ /dev/null @@ -1,1869 +0,0 @@ -# Doxyfile 1.8.3.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = "sff" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = "Small Form Factor Support." - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a percent sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if section-label ... \endif -# and \cond section-label ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. Do not use -# file names with spaces, bibtex cannot handle them. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = module/inc - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and -# SVG. The default value is HTML-CSS, which is slower, but has the best -# compatibility. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. -# There are two flavours of web server based search depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. -# See the manual for details. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain -# the search results. Doxygen ships with an example indexer (doxyindexer) and -# search engine (doxysearch.cgi) which are based on the open source search engine -# library Xapian. See the manual for configuration details. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will returned the search results when EXTERNAL_SEARCH is enabled. -# Doxygen ships with an example search engine (doxysearch) which is based on -# the open source search engine library Xapian. See the manual for configuration -# details. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id -# of to a relative location where the documentation can be found. -# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50 percent before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = YES - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/packages/base/any/onlp/src/sff/utest/.gitignore b/packages/base/any/onlp/src/sff/utest/.gitignore deleted file mode 100644 index 60a3e77b..00000000 --- a/packages/base/any/onlp/src/sff/utest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*_utest.mk diff --git a/packages/base/any/onlp/src/sff/utest/Makefile b/packages/base/any/onlp/src/sff/utest/Makefile deleted file mode 100644 index 1a1cbd07..00000000 --- a/packages/base/any/onlp/src/sff/utest/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.amd64.mk -MODULE := sff_utest -TEST_MODULE := sff -DEPENDMODULES := AIM BigList cjson_util cjson IOF -GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MODULES_INIT=1 -GLOBAL_CFLAGS += -DAIM_CONFIG_INCLUDE_MAIN=1 -GLOBAL_CFLAGS += -DSFF_CONFIG_INCLUDE_EXT_CC_CHECK=1 -GLOBAL_CFLAGS += -DSFF_CONFIG_INCLUDE_DATABASE=1 -GLOBAL_LINK_LIBS += -lrt -lpthread -lm -include $(BUILDER)/build-unit-test.mk diff --git a/packages/base/any/onlp/src/sff/utest/_make.mk b/packages/base/any/onlp/src/sff/utest/_make.mk deleted file mode 100644 index e4492a2a..00000000 --- a/packages/base/any/onlp/src/sff/utest/_make.mk +++ /dev/null @@ -1,8 +0,0 @@ -############################################################################### -# -# sff Unit Test Makefile. -# -############################################################################### -UMODULE := sff -UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/utest.mk diff --git a/packages/base/any/onlp/src/sff/utest/main.c b/packages/base/any/onlp/src/sff/utest/main.c deleted file mode 100644 index acf6593d..00000000 --- a/packages/base/any/onlp/src/sff/utest/main.c +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include -#include -#include -#include -#include -#include - -int -aim_main(int argc, char* argv[]) -{ - int i; - - sff_db_entry_t* entries; - sff_db_entry_t* p; - int count; - - sff_db_get(&entries, &count); - - for(i = 0, p=entries; i < count; i++, p++) { - int rv; - sff_eeprom_t se; - - aim_printf(&aim_pvs_stdout, "Verifying entry %d: %s:%s:%s...\n", - i, - p->se.info.vendor, - p->se.info.model, - p->se.info.serial); - - - if( (rv=sff_eeprom_parse(&se, p->se.eeprom)) < 0) { - AIM_DIE("index=%d sff_eeprom_parse=%d\n", i, rv); - } - if (!se.identified) { - AIM_DIE("index=%d identified=0\n", i); - } - if(strcmp(se.info.vendor, p->se.info.vendor)) { - AIM_DIE("index=%d vendor expected '%s' got '%s'", - i, p->se.info.vendor, se.info.vendor); - } - if(strcmp(se.info.model, p->se.info.model)) { - AIM_DIE("index=%d model expected '%s' got '%s'", - i, p->se.info.model, se.info.model); - } - if(strcmp(se.info.serial, p->se.info.serial)) { - AIM_DIE("index=%d serial expected '%s' got '%s'", - i, p->se.info.serial, se.info.serial); - } - if(se.info.sfp_type != p->se.info.sfp_type) { - AIM_DIE("index=%d sfp_type expected '%{sff_sfp_type}' got '%{sff_sfp_type}'", - i, p->se.info.sfp_type, se.info.sfp_type); - } - if(strcmp(se.info.sfp_type_name, p->se.info.sfp_type_name)) { - AIM_DIE("index=%d type_name expected '%s' got '%s'", - i, p->se.info.sfp_type, se.info.sfp_type); - } - if(se.info.module_type != p->se.info.module_type) { - AIM_DIE("index=%d module_type expected '%{sff_module_type}' got '%{sff_module_type}'", - i, p->se.info.module_type, se.info.module_type); - } - if(se.info.media_type != p->se.info.media_type) { - AIM_DIE("index=%d media_type expected '%{sff_media_type}' got '%{sff_media_type}'\n", - i, p->se.info.media_type, se.info.media_type); - } - if(strcmp(se.info.media_type_name, p->se.info.media_type_name)) { - AIM_DIE("index=%d media_type_name expected '%s' got '%s'", - i, p->se.info.media_type_name, se.info.media_type_name); - } - if (se.info.caps != p->se.info.caps) { - AIM_DIE("index=%d caps expected '%{sff_module_caps}' got '%{sff_module_caps}'", - i, p->se.info.caps, se.info.caps); - } - - if(se.info.length != p->se.info.length) { - AIM_DIE("index=%d length expected %d got %d", - i, p->se.info.length, se.info.length); - } - if(se.info.length == -1 && se.info.length_desc[0]) { - AIM_DIE("index=%d length_desc expected '%s' got '%s'", - i, '\0', se.info.length_desc); - } - else if(se.info.length != -1) { - char tmp[32]; - snprintf(tmp, sizeof(tmp), "%dm", se.info.length); - if(strcmp(tmp, se.info.length_desc)) { - AIM_DIE("index=%d length_desc expected '%s' got '%s'", - i, tmp, se.info.length_desc); - } - } - - aim_printf(&aim_pvs_stdout, "Verifying entry %d: %s:%s:%s...PASSED\n", - i, - p->se.info.vendor, - p->se.info.model, - p->se.info.serial); - - } - return 0; -} - diff --git a/sm/bigcode b/sm/bigcode index 4f6bea63..97e62ffa 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 4f6bea63fdf04a507c6d82ad717ca1f6101ebe5c +Subproject commit 97e62ffa958fe4af6054c5e6f062e42f23594cf8 From be729062804beef9e3e1e924667d085eb1e14026 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Jul 2018 18:01:54 +0000 Subject: [PATCH 12/32] SFF module makefile fixes. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index 97e62ffa..7ddbccfe 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 97e62ffa958fe4af6054c5e6f062e42f23594cf8 +Subproject commit 7ddbccfe17f7d07cb28b8f504f43fa4c515a6ff8 From 90f72e7d81f8c4accb10c6a4c32b16cfa2618b41 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 18 Jul 2018 19:49:41 +0000 Subject: [PATCH 13/32] Updates to the SFF module. --- packages/base/any/onlp/APKG.yml | 2 +- sm/bigcode | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base/any/onlp/APKG.yml b/packages/base/any/onlp/APKG.yml index bb66bd7f..2b585236 100644 --- a/packages/base/any/onlp/APKG.yml +++ b/packages/base/any/onlp/APKG.yml @@ -31,7 +31,7 @@ packages: ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/onlp: ${PY_INSTALL}/onlp/onlp ${ONL}/packages/base/any/onlp/src/onlp/module/python/onlp/test: ${PY_INSTALL}/onlp/test ${ONL}/packages/base/any/onlp/src/onlplib/module/python/onlp/onlplib: ${PY_INSTALL}/onlp/onlplib - ${ONL}/sm/bigcode/modules/sff/module/python/onlp/sff: ${PY_INSTALL}/onlp/sff + ${ONL}/sm/bigcode/modules/sff/module/python/sff: ${PY_INSTALL}/onlp/sff init: $ONL/packages/base/any/onlp/src/onlpd.init diff --git a/sm/bigcode b/sm/bigcode index 7ddbccfe..d20a20a0 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 7ddbccfe17f7d07cb28b8f504f43fa4c515a6ff8 +Subproject commit d20a20a01a61cb68ab7d5d0e2ca02f8ca3a7eb9d From 756d26b75f10bfa2466a5c49b0a2ca9614688a77 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 19 Jul 2018 13:28:08 -0700 Subject: [PATCH 14/32] builder9:1.2 - Stretch Update to fix qemu-aarch64. - Add apt-transport-https --- docker/images/builder9/1.2/Dockerfile | 17 +++++++++++++++++ docker/images/builder9/1.2/Makefile | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 docker/images/builder9/1.2/Dockerfile create mode 100644 docker/images/builder9/1.2/Makefile diff --git a/docker/images/builder9/1.2/Dockerfile b/docker/images/builder9/1.2/Dockerfile new file mode 100644 index 00000000..859b2188 --- /dev/null +++ b/docker/images/builder9/1.2/Dockerfile @@ -0,0 +1,17 @@ +############################################################ +# +# Update Packages for arm64. +# Additional build dependencies. +# +############################################################ +FROM opennetworklinux/builder9:1.1 +MAINTAINER Jeffrey Townsend + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y apt-transport-https + +# Docker shell and other container tools. +# +COPY docker_shell /bin/docker_shell +COPY container-id /bin/container-id diff --git a/docker/images/builder9/1.2/Makefile b/docker/images/builder9/1.2/Makefile new file mode 100644 index 00000000..1d297e9e --- /dev/null +++ b/docker/images/builder9/1.2/Makefile @@ -0,0 +1,19 @@ +VERSION=1.2 +USER=opennetworklinux +REPO=builder9 + +TOOLS=../../../tools/docker_shell ../../../tools/container-id + +build: check_version + cp $(TOOLS) . + docker build -t $(USER)/$(REPO):$(VERSION) . + rm -rf $(notdir $(TOOLS)) + +# +# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites +# when a new image is built but the VERSION variable is not updated. +# +check_version: + +push: + docker push $(USER)/$(REPO):$(VERSION) From 994adf6ebb3f407f4151236847c673732dc4e02f Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 19 Jul 2018 13:30:02 -0700 Subject: [PATCH 15/32] builder8:1.9 - Update to 8.11 - Add apt-transport-https. --- docker/images/builder8/1.9/Dockerfile | 22 ++++++++++++++++++++++ docker/images/builder8/1.9/Makefile | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docker/images/builder8/1.9/Dockerfile create mode 100644 docker/images/builder8/1.9/Makefile diff --git a/docker/images/builder8/1.9/Dockerfile b/docker/images/builder8/1.9/Dockerfile new file mode 100644 index 00000000..6b7ffae2 --- /dev/null +++ b/docker/images/builder8/1.9/Dockerfile @@ -0,0 +1,22 @@ +############################################################ +# +# Minor updates. +# - libelf-dev for kernel 4.14 +# - cryptsetup-bin +# +############################################################ +FROM opennetworklinux/builder8:1.8 +MAINTAINER Jeffrey Townsend + +# LTS architecture fixes + +RUN sudo sed -i s/'http:\/\/security'/'[arch=amd64,armel] http:\/\/security'/g /etc/apt/sources.list && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \ + apt-get install -y apt-transport-https + +# +# Docker shell and other container tools. +# +COPY docker_shell /bin/docker_shell +COPY container-id /bin/container-id diff --git a/docker/images/builder8/1.9/Makefile b/docker/images/builder8/1.9/Makefile new file mode 100644 index 00000000..e895b0c4 --- /dev/null +++ b/docker/images/builder8/1.9/Makefile @@ -0,0 +1,19 @@ +VERSION=1.9 +USER=opennetworklinux +REPO=builder8 + +TOOLS=../../../tools/docker_shell ../../../tools/container-id + +build: check_version + cp $(TOOLS) . + docker build -t $(USER)/$(REPO):$(VERSION) . + rm -rf $(notdir $(TOOLS)) + +# +# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites +# when a new image is built but the VERSION variable is not updated. +# +check_version: + +push: + docker push $(USER)/$(REPO):$(VERSION) From d87c2e9c1d90ae1a91f8339afa630eb68d932c2d Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 19 Jul 2018 13:30:42 -0700 Subject: [PATCH 16/32] Update builder{8,9} to latest. --- docker/tools/onlbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/tools/onlbuilder b/docker/tools/onlbuilder index 73077d22..d9cebc3b 100755 --- a/docker/tools/onlbuilder +++ b/docker/tools/onlbuilder @@ -18,8 +18,8 @@ g_current_uid = os.getuid() g_timestamp = datetime.datetime.now().strftime("%Y-%m-%d.%H%M%S") g_builder7_image_name="opennetworklinux/builder7:1.2" -g_builder8_image_name="opennetworklinux/builder8:1.8" -g_builder9_image_name="opennetworklinux/builder9:1.1" +g_builder8_image_name="opennetworklinux/builder8:1.9" +g_builder9_image_name="opennetworklinux/builder9:1.2" g_default_image_name=g_builder8_image_name g_default_container_name = "%s_%s" % (g_current_user, g_timestamp) From 3bc5f49ab823e0d3b556c156fe0e298d8b577a78 Mon Sep 17 00:00:00 2001 From: Ohad Oz Date: Mon, 23 Jul 2018 21:01:15 +0000 Subject: [PATCH 17/32] Add patches from upstream kernels - backport 4.17 - 4.19 --- .../configs/x86_64-all/x86_64-all.config | 1 + ...ort-patchwork-from-kernels-4.17-4.19.patch | 3063 +++++++++++++++++ .../base/any/kernels/4.9-lts/patches/series | 1 + 3 files changed, 3065 insertions(+) create mode 100644 packages/base/any/kernels/4.9-lts/patches/0013-Mellanox-backport-patchwork-from-kernels-4.17-4.19.patch diff --git a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config index 423e0d63..db1ad67e 100644 --- a/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.9-lts/configs/x86_64-all/x86_64-all.config @@ -2435,6 +2435,7 @@ CONFIG_SENSORS_MAX6620=y # CONFIG_SENSORS_MAX6697 is not set # CONFIG_SENSORS_MAX31790 is not set # CONFIG_SENSORS_MCP3021 is not set +CONFIG_SENSORS_MLXREG_FAN=y # CONFIG_SENSORS_ADCXX is not set # CONFIG_SENSORS_LM63 is not set # CONFIG_SENSORS_LM70 is not set diff --git a/packages/base/any/kernels/4.9-lts/patches/0013-Mellanox-backport-patchwork-from-kernels-4.17-4.19.patch b/packages/base/any/kernels/4.9-lts/patches/0013-Mellanox-backport-patchwork-from-kernels-4.17-4.19.patch new file mode 100644 index 00000000..5c0c5d91 --- /dev/null +++ b/packages/base/any/kernels/4.9-lts/patches/0013-Mellanox-backport-patchwork-from-kernels-4.17-4.19.patch @@ -0,0 +1,3063 @@ +From 54f7d08c9337a82e79142fcdab2b6fa5bcf5843e Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 18 Jul 2018 16:27:08 +0000 +Subject: [patch bacport patchwork 1/1] Mellanox backport patchwork from + kerenls 4.17-4.19 + +Signed-off-by: Vadim Pasternak +--- + drivers/hwmon/Kconfig | 12 + + drivers/hwmon/Makefile | 1 + + drivers/hwmon/mlxreg-fan.c | 489 ++++++++++++ + drivers/platform/mellanox/Kconfig | 9 +- + drivers/platform/mellanox/Makefile | 7 +- + drivers/platform/mellanox/mlxreg-hotplug.c | 306 ++++---- + drivers/platform/mellanox/mlxreg-io.c | 118 +-- + drivers/platform/x86/mlx-platform.c | 1106 +++++++++++++++++++--------- + 8 files changed, 1482 insertions(+), 566 deletions(-) + create mode 100644 drivers/hwmon/mlxreg-fan.c + +diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig +index 45cef3d..9014151 100644 +--- a/drivers/hwmon/Kconfig ++++ b/drivers/hwmon/Kconfig +@@ -907,6 +907,18 @@ config SENSORS_MCP3021 + This driver can also be built as a module. If so, the module + will be called mcp3021. + ++config SENSORS_MLXREG_FAN ++ tristate "Mellanox Mellanox FAN driver" ++ depends on MELLANOX_PLATFORM ++ select THERMAL ++ select REGMAP ++ help ++ This option enables support for the FAN control on the Mellanox ++ Ethernet and InfiniBand switches. The driver can be activated by the ++ platform device add call. Say Y to enable these. To compile this ++ driver as a module, choose 'M' here: the module will be called ++ mlxreg-fan. ++ + config SENSORS_MENF21BMC_HWMON + tristate "MEN 14F021P00 BMC Hardware Monitoring" + depends on MFD_MENF21BMC +diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile +index aecf4ba..4ff1b63 100644 +--- a/drivers/hwmon/Makefile ++++ b/drivers/hwmon/Makefile +@@ -122,6 +122,7 @@ obj-$(CONFIG_SENSORS_MAX6697) += max6697.o + obj-$(CONFIG_SENSORS_MAX31790) += max31790.o + obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o + obj-$(CONFIG_SENSORS_MCP3021) += mcp3021.o ++obj-$(CONFIG_SENSORS_MLXREG_FAN) += mlxreg-fan.o + obj-$(CONFIG_SENSORS_MENF21BMC_HWMON) += menf21bmc_hwmon.o + obj-$(CONFIG_SENSORS_NCT6683) += nct6683.o + obj-$(CONFIG_SENSORS_NCT6775) += nct6775.o +diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c +new file mode 100644 +index 0000000..de46577 +--- /dev/null ++++ b/drivers/hwmon/mlxreg-fan.c +@@ -0,0 +1,489 @@ ++// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) ++// ++// Copyright (c) 2018 Mellanox Technologies. All rights reserved. ++// Copyright (c) 2018 Vadim Pasternak ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MLXREG_FAN_MAX_TACHO 12 ++#define MLXREG_FAN_MAX_STATE 10 ++#define MLXREG_FAN_MIN_DUTY 51 /* 20% */ ++#define MLXREG_FAN_MAX_DUTY 255 /* 100% */ ++/* ++ * Minimum and maximum FAN allowed speed in percent: from 20% to 100%. Values ++ * MLXREG_FAN_MAX_STATE + x, where x is between 2 and 10 are used for ++ * setting FAN speed dynamic minimum. For example, if value is set to 14 (40%) ++ * cooling levels vector will be set to 4, 4, 4, 4, 4, 5, 6, 7, 8, 9, 10 to ++ * introduce PWM speed in percent: 40, 40, 40, 40, 40, 50, 60. 70, 80, 90, 100. ++ */ ++#define MLXREG_FAN_SPEED_MIN (MLXREG_FAN_MAX_STATE + 2) ++#define MLXREG_FAN_SPEED_MAX (MLXREG_FAN_MAX_STATE * 2) ++#define MLXREG_FAN_SPEED_MIN_LEVEL 2 /* 20 percent */ ++#define MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF 44 ++#define MLXREG_FAN_TACHO_DIVIDER_DEF 1132 ++/* ++ * FAN datasheet defines the formula for RPM calculations as RPM = 15/t-high. ++ * The logic in a programmable device measures the time t-high by sampling the ++ * tachometer every t-sample (with the default value 11.32 uS) and increment ++ * a counter (N) as long as the pulse has not change: ++ * RPM = 15 / (t-sample * (K + Regval)), where: ++ * Regval: is the value read from the programmable device register; ++ * - 0xff - represents tachometer fault; ++ * - 0xfe - represents tachometer minimum value , which is 4444 RPM; ++ * - 0x00 - represents tachometer maximum value , which is 300000 RPM; ++ * K: is 44 and it represents the minimum allowed samples per pulse; ++ * N: is equal K + Regval; ++ * In order to calculate RPM from the register value the following formula is ++ * used: RPM = 15 / ((Regval + K) * 11.32) * 10^(-6)), which in the ++ * default case is modified to: ++ * RPM = 15000000 * 100 / ((Regval + 44) * 1132); ++ * - for Regval 0x00, RPM will be 15000000 * 100 / (44 * 1132) = 30115; ++ * - for Regval 0xfe, RPM will be 15000000 * 100 / ((254 + 44) * 1132) = 4446; ++ * In common case the formula is modified to: ++ * RPM = 15000000 * 100 / ((Regval + samples) * divider). ++ */ ++#define MLXREG_FAN_GET_RPM(rval, d, s) (DIV_ROUND_CLOSEST(15000000 * 100, \ ++ ((rval) + (s)) * (d))) ++#define MLXREG_FAN_GET_FAULT(val, mask) (!!((val) ^ (mask))) ++#define MLXREG_FAN_PWM_DUTY2STATE(duty) (DIV_ROUND_CLOSEST((duty) * \ ++ MLXREG_FAN_MAX_STATE, \ ++ MLXREG_FAN_MAX_DUTY)) ++#define MLXREG_FAN_PWM_STATE2DUTY(stat) (DIV_ROUND_CLOSEST((stat) * \ ++ MLXREG_FAN_MAX_DUTY, \ ++ MLXREG_FAN_MAX_STATE)) ++ ++/* ++ * struct mlxreg_fan_tacho - tachometer data (internal use): ++ * ++ * @connected: indicates if tachometer is connected; ++ * @reg: register offset; ++ * @mask: fault mask; ++ */ ++struct mlxreg_fan_tacho { ++ bool connected; ++ u32 reg; ++ u32 mask; ++}; ++ ++/* ++ * struct mlxreg_fan_pwm - PWM data (internal use): ++ * ++ * @connected: indicates if PWM is connected; ++ * @reg: register offset; ++ */ ++struct mlxreg_fan_pwm { ++ bool connected; ++ u32 reg; ++}; ++ ++/* ++ * struct mlxreg_fan - private data (internal use): ++ * ++ * @dev: basic device; ++ * @regmap: register map of parent device; ++ * @tacho: tachometer data; ++ * @pwm: PWM data; ++ * @samples: minimum allowed samples per pulse; ++ * @divider: divider value for tachometer RPM calculation; ++ * @cooling: cooling device levels; ++ * @cdev: cooling device; ++ */ ++struct mlxreg_fan { ++ struct device *dev; ++ void *regmap; ++ struct mlxreg_core_platform_data *pdata; ++ struct mlxreg_fan_tacho tacho[MLXREG_FAN_MAX_TACHO]; ++ struct mlxreg_fan_pwm pwm; ++ int samples; ++ int divider; ++ u8 cooling_levels[MLXREG_FAN_MAX_STATE + 1]; ++ struct thermal_cooling_device *cdev; ++}; ++ ++static int ++mlxreg_fan_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, ++ int channel, long *val) ++{ ++ struct mlxreg_fan *fan = dev_get_drvdata(dev); ++ struct mlxreg_fan_tacho *tacho; ++ u32 regval; ++ int err; ++ ++ switch (type) { ++ case hwmon_fan: ++ tacho = &fan->tacho[channel]; ++ switch (attr) { ++ case hwmon_fan_input: ++ err = regmap_read(fan->regmap, tacho->reg, ®val); ++ if (err) ++ return err; ++ ++ *val = MLXREG_FAN_GET_RPM(regval, fan->divider, ++ fan->samples); ++ break; ++ ++ case hwmon_fan_fault: ++ err = regmap_read(fan->regmap, tacho->reg, ®val); ++ if (err) ++ return err; ++ ++ *val = MLXREG_FAN_GET_FAULT(regval, tacho->mask); ++ break; ++ ++ default: ++ return -EOPNOTSUPP; ++ } ++ break; ++ ++ case hwmon_pwm: ++ switch (attr) { ++ case hwmon_pwm_input: ++ err = regmap_read(fan->regmap, fan->pwm.reg, ®val); ++ if (err) ++ return err; ++ ++ *val = regval; ++ break; ++ ++ default: ++ return -EOPNOTSUPP; ++ } ++ break; ++ ++ default: ++ return -EOPNOTSUPP; ++ } ++ ++ return 0; ++} ++ ++static int ++mlxreg_fan_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, ++ int channel, long val) ++{ ++ struct mlxreg_fan *fan = dev_get_drvdata(dev); ++ ++ switch (type) { ++ case hwmon_pwm: ++ switch (attr) { ++ case hwmon_pwm_input: ++ if (val < MLXREG_FAN_MIN_DUTY || ++ val > MLXREG_FAN_MAX_DUTY) ++ return -EINVAL; ++ return regmap_write(fan->regmap, fan->pwm.reg, val); ++ default: ++ return -EOPNOTSUPP; ++ } ++ break; ++ ++ default: ++ return -EOPNOTSUPP; ++ } ++ ++ return -EOPNOTSUPP; ++} ++ ++static umode_t ++mlxreg_fan_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr, ++ int channel) ++{ ++ switch (type) { ++ case hwmon_fan: ++ if (!(((struct mlxreg_fan *)data)->tacho[channel].connected)) ++ return 0; ++ ++ switch (attr) { ++ case hwmon_fan_input: ++ case hwmon_fan_fault: ++ return 0444; ++ default: ++ break; ++ } ++ break; ++ ++ case hwmon_pwm: ++ if (!(((struct mlxreg_fan *)data)->pwm.connected)) ++ return 0; ++ ++ switch (attr) { ++ case hwmon_pwm_input: ++ return 0644; ++ default: ++ break; ++ } ++ break; ++ ++ default: ++ break; ++ } ++ ++ return 0; ++} ++ ++static const u32 mlxreg_fan_hwmon_fan_config[] = { ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ HWMON_F_INPUT | HWMON_F_FAULT, ++ 0 ++}; ++ ++static const struct hwmon_channel_info mlxreg_fan_hwmon_fan = { ++ .type = hwmon_fan, ++ .config = mlxreg_fan_hwmon_fan_config, ++}; ++ ++static const u32 mlxreg_fan_hwmon_pwm_config[] = { ++ HWMON_PWM_INPUT, ++ 0 ++}; ++ ++static const struct hwmon_channel_info mlxreg_fan_hwmon_pwm = { ++ .type = hwmon_pwm, ++ .config = mlxreg_fan_hwmon_pwm_config, ++}; ++ ++static const struct hwmon_channel_info *mlxreg_fan_hwmon_info[] = { ++ &mlxreg_fan_hwmon_fan, ++ &mlxreg_fan_hwmon_pwm, ++ NULL ++}; ++ ++static const struct hwmon_ops mlxreg_fan_hwmon_hwmon_ops = { ++ .is_visible = mlxreg_fan_is_visible, ++ .read = mlxreg_fan_read, ++ .write = mlxreg_fan_write, ++}; ++ ++static const struct hwmon_chip_info mlxreg_fan_hwmon_chip_info = { ++ .ops = &mlxreg_fan_hwmon_hwmon_ops, ++ .info = mlxreg_fan_hwmon_info, ++}; ++ ++static int mlxreg_fan_get_max_state(struct thermal_cooling_device *cdev, ++ unsigned long *state) ++{ ++ *state = MLXREG_FAN_MAX_STATE; ++ return 0; ++} ++ ++static int mlxreg_fan_get_cur_state(struct thermal_cooling_device *cdev, ++ unsigned long *state) ++ ++{ ++ struct mlxreg_fan *fan = cdev->devdata; ++ u32 regval; ++ int err; ++ ++ err = regmap_read(fan->regmap, fan->pwm.reg, ®val); ++ if (err) { ++ dev_err(fan->dev, "Failed to query PWM duty\n"); ++ return err; ++ } ++ ++ *state = MLXREG_FAN_PWM_DUTY2STATE(regval); ++ ++ return 0; ++} ++ ++static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev, ++ unsigned long state) ++ ++{ ++ struct mlxreg_fan *fan = cdev->devdata; ++ unsigned long cur_state; ++ u32 regval; ++ int i; ++ int err; ++ ++ /* ++ * Verify if this request is for changing allowed FAN dynamical ++ * minimum. If it is - update cooling levels accordingly and update ++ * state, if current state is below the newly requested minimum state. ++ * For example, if current state is 5, and minimal state is to be ++ * changed from 4 to 6, fan->cooling_levels[0 to 5] will be changed all ++ * from 4 to 6. And state 5 (fan->cooling_levels[4]) should be ++ * overwritten. ++ */ ++ if (state >= MLXREG_FAN_SPEED_MIN && state <= MLXREG_FAN_SPEED_MAX) { ++ state -= MLXREG_FAN_MAX_STATE; ++ for (i = 0; i < state; i++) ++ fan->cooling_levels[i] = state; ++ for (i = state; i <= MLXREG_FAN_MAX_STATE; i++) ++ fan->cooling_levels[i] = i; ++ ++ err = regmap_read(fan->regmap, fan->pwm.reg, ®val); ++ if (err) { ++ dev_err(fan->dev, "Failed to query PWM duty\n"); ++ return err; ++ } ++ ++ cur_state = MLXREG_FAN_PWM_DUTY2STATE(regval); ++ if (state < cur_state) ++ return 0; ++ ++ state = cur_state; ++ } ++ ++ if (state > MLXREG_FAN_MAX_STATE) ++ return -EINVAL; ++ ++ /* Normalize the state to the valid speed range. */ ++ state = fan->cooling_levels[state]; ++ err = regmap_write(fan->regmap, fan->pwm.reg, ++ MLXREG_FAN_PWM_STATE2DUTY(state)); ++ if (err) { ++ dev_err(fan->dev, "Failed to write PWM duty\n"); ++ return err; ++ } ++ return 0; ++} ++ ++static const struct thermal_cooling_device_ops mlxreg_fan_cooling_ops = { ++ .get_max_state = mlxreg_fan_get_max_state, ++ .get_cur_state = mlxreg_fan_get_cur_state, ++ .set_cur_state = mlxreg_fan_set_cur_state, ++}; ++ ++static int mlxreg_fan_config(struct mlxreg_fan *fan, ++ struct mlxreg_core_platform_data *pdata) ++{ ++ struct mlxreg_core_data *data = pdata->data; ++ bool configured = false; ++ int tacho_num = 0, i; ++ ++ fan->samples = MLXREG_FAN_TACHO_SAMPLES_PER_PULSE_DEF; ++ fan->divider = MLXREG_FAN_TACHO_DIVIDER_DEF; ++ for (i = 0; i < pdata->counter; i++, data++) { ++ if (strnstr(data->label, "tacho", sizeof(data->label))) { ++ if (tacho_num == MLXREG_FAN_MAX_TACHO) { ++ dev_err(fan->dev, "too many tacho entries: %s\n", ++ data->label); ++ return -EINVAL; ++ } ++ fan->tacho[tacho_num].reg = data->reg; ++ fan->tacho[tacho_num].mask = data->mask; ++ fan->tacho[tacho_num++].connected = true; ++ } else if (strnstr(data->label, "pwm", sizeof(data->label))) { ++ if (fan->pwm.connected) { ++ dev_err(fan->dev, "duplicate pwm entry: %s\n", ++ data->label); ++ return -EINVAL; ++ } ++ fan->pwm.reg = data->reg; ++ fan->pwm.connected = true; ++ } else if (strnstr(data->label, "conf", sizeof(data->label))) { ++ if (configured) { ++ dev_err(fan->dev, "duplicate conf entry: %s\n", ++ data->label); ++ return -EINVAL; ++ } ++ /* Validate that conf parameters are not zeros. */ ++ if (!data->mask || !data->bit) { ++ dev_err(fan->dev, "invalid conf entry params: %s\n", ++ data->label); ++ return -EINVAL; ++ } ++ fan->samples = data->mask; ++ fan->divider = data->bit; ++ configured = true; ++ } else { ++ dev_err(fan->dev, "invalid label: %s\n", data->label); ++ return -EINVAL; ++ } ++ } ++ ++ /* Init cooling levels per PWM state. */ ++ for (i = 0; i < MLXREG_FAN_SPEED_MIN_LEVEL; i++) ++ fan->cooling_levels[i] = MLXREG_FAN_SPEED_MIN_LEVEL; ++ for (i = MLXREG_FAN_SPEED_MIN_LEVEL; i <= MLXREG_FAN_MAX_STATE; i++) ++ fan->cooling_levels[i] = i; ++ ++ return 0; ++} ++ ++static int mlxreg_fan_probe(struct platform_device *pdev) ++{ ++ struct mlxreg_core_platform_data *pdata; ++ struct mlxreg_fan *fan; ++ struct device *hwm; ++ int err; ++ ++ pdata = dev_get_platdata(&pdev->dev); ++ if (!pdata) { ++ dev_err(&pdev->dev, "Failed to get platform data.\n"); ++ return -EINVAL; ++ } ++ ++ fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL); ++ if (!fan) ++ return -ENOMEM; ++ ++ fan->dev = &pdev->dev; ++ fan->regmap = pdata->regmap; ++ platform_set_drvdata(pdev, fan); ++ ++ err = mlxreg_fan_config(fan, pdata); ++ if (err) ++ return err; ++ ++ hwm = devm_hwmon_device_register_with_info(&pdev->dev, "mlxreg_fan", ++ fan, ++ &mlxreg_fan_hwmon_chip_info, ++ NULL); ++ if (IS_ERR(hwm)) { ++ dev_err(&pdev->dev, "Failed to register hwmon device\n"); ++ return PTR_ERR(hwm); ++ } ++ ++ if (IS_REACHABLE(CONFIG_THERMAL)) { ++ fan->cdev = thermal_cooling_device_register("mlxreg_fan", fan, ++ &mlxreg_fan_cooling_ops); ++ if (IS_ERR(fan->cdev)) { ++ dev_err(&pdev->dev, "Failed to register cooling device\n"); ++ return PTR_ERR(fan->cdev); ++ } ++ } ++ ++ return 0; ++} ++ ++static int mlxreg_fan_remove(struct platform_device *pdev) ++{ ++ struct mlxreg_fan *fan = platform_get_drvdata(pdev); ++ ++ if (IS_REACHABLE(CONFIG_THERMAL)) ++ thermal_cooling_device_unregister(fan->cdev); ++ ++ return 0; ++} ++ ++static struct platform_driver mlxreg_fan_driver = { ++ .driver = { ++ .name = "mlxreg-fan", ++ }, ++ .probe = mlxreg_fan_probe, ++ .remove = mlxreg_fan_remove, ++}; ++ ++module_platform_driver(mlxreg_fan_driver); ++ ++MODULE_AUTHOR("Vadim Pasternak "); ++MODULE_DESCRIPTION("Mellanox FAN driver"); ++MODULE_LICENSE("GPL"); ++MODULE_ALIAS("platform:mlxreg-fan"); +diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig +index 5c6dc29..cd8a908 100644 +--- a/drivers/platform/mellanox/Kconfig ++++ b/drivers/platform/mellanox/Kconfig +@@ -1,3 +1,4 @@ ++# SPDX-License-Identifier: GPL-2.0 + # + # Platform support for Mellanox hardware + # +@@ -23,13 +24,13 @@ config MLXREG_HOTPLUG + cables and fans on the wide range Mellanox IB and Ethernet systems. + + config MLXREG_IO +- tristate "Mellanox platform register driver support" ++ tristate "Mellanox platform register access driver support" + depends on REGMAP + depends on HWMON +- ---help--- ++ help + This driver allows access to Mellanox programmable device register +- space trough sysfs interface. The set of registers for sysfs access +- are defined per system type bases and includes the registers related ++ space through sysfs interface. The sets of registers for sysfs access ++ are defined per system type bases and include the registers related + to system resets operation, system reset causes monitoring and some + kinds of mux selection. + +diff --git a/drivers/platform/mellanox/Makefile b/drivers/platform/mellanox/Makefile +index b9a2692..57074d9c 100644 +--- a/drivers/platform/mellanox/Makefile ++++ b/drivers/platform/mellanox/Makefile +@@ -1,2 +1,7 @@ ++# SPDX-License-Identifier: GPL-2.0 ++# ++# Makefile for linux/drivers/platform/mellanox ++# Mellanox Platform-Specific Drivers ++# + obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o +-obj-$(CONFIG_MLXREG_IO) += mlxreg-io.o ++obj-$(CONFIG_MLXREG_IO) += mlxreg-io.o +diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c +index 5c13591..4761211 100644 +--- a/drivers/platform/mellanox/mlxreg-hotplug.c ++++ b/drivers/platform/mellanox/mlxreg-hotplug.c +@@ -1,6 +1,6 @@ + /* +- * Copyright (c) 2017 Mellanox Technologies. All rights reserved. +- * Copyright (c) 2017 Vadim Pasternak ++ * Copyright (c) 2016-2018 Mellanox Technologies. All rights reserved. ++ * Copyright (c) 2016-2018 Vadim Pasternak + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: +@@ -41,6 +41,7 @@ + #include + #include + #include ++#include + #include + #include + +@@ -50,12 +51,9 @@ + #define MLXREG_HOTPLUG_AGGR_MASK_OFF 1 + + /* ASIC health parameters. */ ++#define MLXREG_HOTPLUG_DOWN_MASK 0x00 + #define MLXREG_HOTPLUG_HEALTH_MASK 0x02 +-#define MLXREG_HOTPLUG_RST_CNTR 3 +- +-#define MLXREG_HOTPLUG_PROP_OKAY "okay" +-#define MLXREG_HOTPLUG_PROP_DISABLED "disabled" +-#define MLXREG_HOTPLUG_PROP_STATUS "status" ++#define MLXREG_HOTPLUG_RST_CNTR 2 + + #define MLXREG_HOTPLUG_ATTRS_MAX 24 + #define MLXREG_HOTPLUG_NOT_ASSERT 3 +@@ -63,11 +61,14 @@ + /** + * struct mlxreg_hotplug_priv_data - platform private data: + * @irq: platform device interrupt number; ++ * @dev: basic device; + * @pdev: platform device; + * @plat: platform data; +- * @dwork: delayed work template; ++ * @regmap: register map handle; ++ * @dwork_irq: delayed work template; + * @lock: spin lock; + * @hwmon: hwmon device; ++ * @kobj: hwmon kobject for notification; + * @mlxreg_hotplug_attr: sysfs attributes array; + * @mlxreg_hotplug_dev_attr: sysfs sensor device attribute array; + * @group: sysfs attribute group; +@@ -75,6 +76,7 @@ + * @cell: location of top aggregation interrupt register; + * @mask: top aggregation interrupt common mask; + * @aggr_cache: last value of aggregation register status; ++ * @after_probe: flag indication probing completion; + * @not_asserted: number of entries in workqueue with no signal assertion; + */ + struct mlxreg_hotplug_priv_data { +@@ -84,9 +86,9 @@ struct mlxreg_hotplug_priv_data { + struct mlxreg_hotplug_platform_data *plat; + struct regmap *regmap; + struct delayed_work dwork_irq; +- struct delayed_work dwork; + spinlock_t lock; /* sync with interrupt */ + struct device *hwmon; ++ struct kobject *kobj; + struct attribute *mlxreg_hotplug_attr[MLXREG_HOTPLUG_ATTRS_MAX + 1]; + struct sensor_device_attribute_2 + mlxreg_hotplug_dev_attr[MLXREG_HOTPLUG_ATTRS_MAX]; +@@ -99,70 +101,37 @@ struct mlxreg_hotplug_priv_data { + u8 not_asserted; + }; + +-#if defined(CONFIG_OF_DYNAMIC) +-/** +- * struct mlxreg_hotplug_device_en - Open Firmware property for enabling device +- * +- * @name - property name; +- * @value - property value string; +- * @length - length of proprty value string; +- * +- * The structure is used for the devices, which require some dynamic +- * selection operation allowing access to them. +- */ +-static struct property mlxreg_hotplug_device_en = { +- .name = MLXREG_HOTPLUG_PROP_STATUS, +- .value = MLXREG_HOTPLUG_PROP_OKAY, +- .length = sizeof(MLXREG_HOTPLUG_PROP_OKAY), +-}; +- +-/** +- * struct mlxreg_hotplug_device_dis - Open Firmware property for disabling +- * device +- * +- * @name - property name; +- * @value - property value string; +- * @length - length of proprty value string; +- * +- * The structure is used for the devices, which require some dynamic +- * selection operation disallowing access to them. +- */ +-static struct property mlxreg_hotplug_device_dis = { +- .name = MLXREG_HOTPLUG_PROP_STATUS, +- .value = MLXREG_HOTPLUG_PROP_DISABLED, +- .length = sizeof(MLXREG_HOTPLUG_PROP_DISABLED), +-}; +- +-static int mlxreg_hotplug_of_device_create(struct mlxreg_core_data *data) ++static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv, ++ struct mlxreg_core_data *data) + { +- return of_update_property(data->np, &mlxreg_hotplug_device_en); +-} ++ struct mlxreg_core_hotplug_platform_data *pdata; + +-static void mlxreg_hotplug_of_device_destroy(struct mlxreg_core_data *data) +-{ +- of_update_property(data->np, &mlxreg_hotplug_device_dis); +- of_node_clear_flag(data->np, OF_POPULATED); +-} +-#else +-static int mlxreg_hotplug_of_device_create(struct mlxreg_core_data *data) +-{ +- return 0; +-} ++ /* Notify user by sending hwmon uevent. */ ++ kobject_uevent(priv->kobj, KOBJ_CHANGE); + +-static void mlxreg_hotplug_of_device_destroy(struct mlxreg_core_data *data) +-{ +-} +-#endif ++ /* ++ * Return if adapter number is negative. It could be in case hotplug ++ * event is not associated with hotplug device. ++ */ ++ if (data->hpdev.nr < 0) ++ return 0; + +-static int mlxreg_hotplug_device_create(struct mlxreg_core_data *data) +-{ +- data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr); +- if (!data->hpdev.adapter) ++ pdata = dev_get_platdata(&priv->pdev->dev); ++ data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr + ++ pdata->shift_nr); ++ if (!data->hpdev.adapter) { ++ dev_err(priv->dev, "Failed to get adapter for bus %d\n", ++ data->hpdev.nr + pdata->shift_nr); + return -EFAULT; ++ } + + data->hpdev.client = i2c_new_device(data->hpdev.adapter, + data->hpdev.brdinfo); + if (!data->hpdev.client) { ++ dev_err(priv->dev, "Failed to create client %s at bus %d at addr 0x%02x\n", ++ data->hpdev.brdinfo->type, data->hpdev.nr + ++ pdata->shift_nr, data->hpdev.brdinfo->addr); ++ + i2c_put_adapter(data->hpdev.adapter); + data->hpdev.adapter = NULL; + return -EFAULT; +@@ -171,8 +140,13 @@ static int mlxreg_hotplug_device_create(struct mlxreg_core_data *data) + return 0; + } + +-static void mlxreg_hotplug_device_destroy(struct mlxreg_core_data *data) ++static void ++mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv, ++ struct mlxreg_core_data *data) + { ++ /* Notify user by sending hwmon uevent. */ ++ kobject_uevent(priv->kobj, KOBJ_CHANGE); ++ + if (data->hpdev.client) { + i2c_unregister_device(data->hpdev.client); + data->hpdev.client = NULL; +@@ -184,28 +158,6 @@ static void mlxreg_hotplug_device_destroy(struct mlxreg_core_data *data) + } + } + +-static int mlxreg_hotplug_dev_enable(struct mlxreg_core_data *data) +-{ +- int err; +- +- /* Enable and create device. */ +- if (data->np) +- err = mlxreg_hotplug_of_device_create(data); +- else +- err = mlxreg_hotplug_device_create(data); +- +- return err; +-} +- +-static void mlxreg_hotplug_dev_disable(struct mlxreg_core_data *data) +-{ +- /* Disable and unregister platform device. */ +- if (data->np) +- mlxreg_hotplug_of_device_destroy(data); +- else +- mlxreg_hotplug_device_destroy(data); +-} +- + static ssize_t mlxreg_hotplug_attr_show(struct device *dev, + struct device_attribute *attr, + char *buf) +@@ -281,7 +233,8 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv) + } + } + +- priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs * ++ priv->group.attrs = devm_kcalloc(&priv->pdev->dev, ++ num_attrs, + sizeof(struct attribute *), + GFP_KERNEL); + if (!priv->group.attrs) +@@ -320,12 +273,12 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, + ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, + 0); + if (ret) +- goto access_error; ++ goto out; + + /* Read status. */ + ret = regmap_read(priv->regmap, item->reg, ®val); + if (ret) +- goto access_error; ++ goto out; + + /* Set asserted bits and save last status. */ + regval &= item->mask; +@@ -336,14 +289,14 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, + data = item->data + bit; + if (regval & BIT(bit)) { + if (item->inversed) +- mlxreg_hotplug_dev_disable(data); ++ mlxreg_hotplug_device_destroy(priv, data); + else +- mlxreg_hotplug_dev_enable(data); ++ mlxreg_hotplug_device_create(priv, data); + } else { + if (item->inversed) +- mlxreg_hotplug_dev_enable(data); ++ mlxreg_hotplug_device_create(priv, data); + else +- mlxreg_hotplug_dev_disable(data); ++ mlxreg_hotplug_device_destroy(priv, data); + } + } + +@@ -351,18 +304,15 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv, + ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_EVENT_OFF, + 0); + if (ret) +- goto access_error; ++ goto out; + + /* Unmask event. */ + ret = regmap_write(priv->regmap, item->reg + MLXREG_HOTPLUG_MASK_OFF, + item->mask); +- if (ret) +- goto access_error; + +- return; +- +-access_error: +- dev_err(priv->dev, "Failed to complete workqueue.\n"); ++ out: ++ if (ret) ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); + } + + static void +@@ -371,53 +321,83 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, + { + struct mlxreg_core_data *data = item->data; + u32 regval; +- int i, ret; ++ int i, ret = 0; + + for (i = 0; i < item->count; i++, data++) { + /* Mask event. */ + ret = regmap_write(priv->regmap, data->reg + + MLXREG_HOTPLUG_MASK_OFF, 0); + if (ret) +- goto access_error; ++ goto out; + + /* Read status. */ + ret = regmap_read(priv->regmap, data->reg, ®val); + if (ret) +- goto access_error; ++ goto out; + + regval &= data->mask; +- item->cache = regval; ++ /* ++ * ASIC health indication is provided through two bits. Bits ++ * value 0x2 indicates that ASIC reached the good health, value ++ * 0x0 indicates ASIC the bad health or dormant state and value ++ * 0x2 indicates the booting state. During ASIC reset it should ++ * pass the following states: dormant -> booting -> good. ++ * The transition from dormant to booting state and from ++ * booting to good state are indicated by ASIC twice, so actual ++ * sequence for getting to the steady state after reset is: ++ * dormant -> booting -> booting -> good -> good. It is ++ * possible that due to some hardware noise, the transition ++ * sequence will look like: dormant -> booting -> [ booting -> ++ * good -> dormant -> booting ] -> good -> good. ++ */ + if (regval == MLXREG_HOTPLUG_HEALTH_MASK) { +- if ((data->health_cntr++ == MLXREG_HOTPLUG_RST_CNTR) || ++ if ((++data->health_cntr == MLXREG_HOTPLUG_RST_CNTR) || + !priv->after_probe) { +- mlxreg_hotplug_dev_enable(data); ++ /* ++ * ASIC is in steady state. Connect associated ++ * device, if configured. ++ */ ++ mlxreg_hotplug_device_create(priv, data); + data->attached = true; + } + } else { + if (data->attached) { +- mlxreg_hotplug_dev_disable(data); ++ /* ++ * ASIC health is dropped after ASIC has been ++ * in steady state. Disconnect associated ++ * device, if it has been connected. ++ */ ++ mlxreg_hotplug_device_destroy(priv, data); + data->attached = false; + data->health_cntr = 0; ++ } else if (regval == MLXREG_HOTPLUG_DOWN_MASK && ++ item->cache == MLXREG_HOTPLUG_HEALTH_MASK) { ++ /* ++ * Decrease counter, if health has been dropped ++ * before ASIC reaches the steady state, like: ++ * good -> dormant -> booting. ++ */ ++ data->health_cntr--; + } + } ++ item->cache = regval; + + /* Acknowledge event. */ + ret = regmap_write(priv->regmap, data->reg + + MLXREG_HOTPLUG_EVENT_OFF, 0); + if (ret) +- goto access_error; ++ goto out; + + /* Unmask event. */ + ret = regmap_write(priv->regmap, data->reg + + MLXREG_HOTPLUG_MASK_OFF, data->mask); + if (ret) +- goto access_error; ++ goto out; + } + +- return; +- +-access_error: +- dev_err(priv->dev, "Failed to complete workqueue.\n"); ++ out: ++ if (ret) ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); + } + + /* +@@ -449,32 +429,38 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv, + */ + static void mlxreg_hotplug_work_handler(struct work_struct *work) + { +- struct mlxreg_hotplug_priv_data *priv = container_of(work, +- struct mlxreg_hotplug_priv_data, dwork_irq.work); + struct mlxreg_core_hotplug_platform_data *pdata; ++ struct mlxreg_hotplug_priv_data *priv; + struct mlxreg_core_item *item; +- unsigned long flags; + u32 regval, aggr_asserted; +- int i; +- int ret; ++ unsigned long flags; ++ int i, ret; + ++ priv = container_of(work, struct mlxreg_hotplug_priv_data, ++ dwork_irq.work); + pdata = dev_get_platdata(&priv->pdev->dev); + item = pdata->items; ++ + /* Mask aggregation event. */ + ret = regmap_write(priv->regmap, pdata->cell + + MLXREG_HOTPLUG_AGGR_MASK_OFF, 0); + if (ret < 0) +- goto access_error; ++ goto out; + + /* Read aggregation status. */ + ret = regmap_read(priv->regmap, pdata->cell, ®val); + if (ret) +- goto access_error; ++ goto out; + + regval &= pdata->mask; + aggr_asserted = priv->aggr_cache ^ regval; + priv->aggr_cache = regval; + ++ /* ++ * Handler is invoked, but no assertion is detected at top aggregation ++ * status level. Set aggr_asserted to mask value to allow handler extra ++ * run over all relevant signals to recover any missed signal. ++ */ + if (priv->not_asserted == MLXREG_HOTPLUG_NOT_ASSERT) { + priv->not_asserted = 0; + aggr_asserted = pdata->mask; +@@ -492,47 +478,40 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work) + } + } + +- if (aggr_asserted) { +- spin_lock_irqsave(&priv->lock, flags); ++ spin_lock_irqsave(&priv->lock, flags); + +- /* +- * It is possible, that some signals have been inserted, while +- * interrupt has been masked by mlxreg_hotplug_work_handler. +- * In this case such signals will be missed. In order to handle +- * these signals delayed work is canceled and work task +- * re-scheduled for immediate execution. It allows to handle +- * missed signals, if any. In other case work handler just +- * validates that no new signals have been received during +- * masking. +- */ +- cancel_delayed_work(&priv->dwork_irq); +- schedule_delayed_work(&priv->dwork_irq, 0); ++ /* ++ * It is possible, that some signals have been inserted, while ++ * interrupt has been masked by mlxreg_hotplug_work_handler. In this ++ * case such signals will be missed. In order to handle these signals ++ * delayed work is canceled and work task re-scheduled for immediate ++ * execution. It allows to handle missed signals, if any. In other case ++ * work handler just validates that no new signals have been received ++ * during masking. ++ */ ++ cancel_delayed_work(&priv->dwork_irq); ++ schedule_delayed_work(&priv->dwork_irq, 0); + +- spin_unlock_irqrestore(&priv->lock, flags); ++ spin_unlock_irqrestore(&priv->lock, flags); + +- return; +- } ++ return; + + unmask_event: + priv->not_asserted++; + /* Unmask aggregation event (no need acknowledge). */ + ret = regmap_write(priv->regmap, pdata->cell + + MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); +- if (ret) +- goto access_error; + +- return; +- +-access_error: +- dev_err(priv->dev, "Failed to complete workqueue.\n"); ++ out: ++ if (ret) ++ dev_err(priv->dev, "Failed to complete workqueue.\n"); + } + + static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + { + struct mlxreg_core_hotplug_platform_data *pdata; + struct mlxreg_core_item *item; +- int i; +- int ret; ++ int i, ret; + + pdata = dev_get_platdata(&priv->pdev->dev); + item = pdata->items; +@@ -542,7 +521,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + ret = regmap_write(priv->regmap, item->reg + + MLXREG_HOTPLUG_EVENT_OFF, 0); + if (ret) +- goto access_error; ++ goto out; + + /* Set group initial status as mask and unmask group event. */ + if (item->inversed) { +@@ -551,7 +530,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + MLXREG_HOTPLUG_MASK_OFF, + item->mask); + if (ret) +- goto access_error; ++ goto out; + } + } + +@@ -559,7 +538,7 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + ret = regmap_write(priv->regmap, pdata->cell + + MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask); + if (ret) +- goto access_error; ++ goto out; + + /* Keep low aggregation initial status as zero and unmask events. */ + if (pdata->cell_low) { +@@ -567,21 +546,16 @@ static int mlxreg_hotplug_set_irq(struct mlxreg_hotplug_priv_data *priv) + MLXREG_HOTPLUG_AGGR_MASK_OFF, + pdata->mask_low); + if (ret) +- goto access_error; ++ goto out; + } + + /* Invoke work handler for initializing hot plug devices setting. */ + mlxreg_hotplug_work_handler(&priv->dwork_irq.work); + ++ out: ++ if (ret) ++ dev_err(priv->dev, "Failed to set interrupts.\n"); + enable_irq(priv->irq); +- +- return 0; +- +-access_error: +- dev_err(priv->dev, "Failed to set interrupts.\n"); +- +- enable_irq(priv->irq); +- + return ret; + } + +@@ -619,14 +593,15 @@ static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv) + /* Remove all the attached devices in group. */ + count = item->count; + for (j = 0; j < count; j++, data++) +- mlxreg_hotplug_dev_disable(data); ++ mlxreg_hotplug_device_destroy(priv, data); + } + } + + static irqreturn_t mlxreg_hotplug_irq_handler(int irq, void *dev) + { +- struct mlxreg_hotplug_priv_data *priv = +- (struct mlxreg_hotplug_priv_data *)dev; ++ struct mlxreg_hotplug_priv_data *priv; ++ ++ priv = (struct mlxreg_hotplug_priv_data *)dev; + + /* Schedule work task for immediate execution.*/ + schedule_delayed_work(&priv->dwork_irq, 0); +@@ -683,10 +658,6 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev) + disable_irq(priv->irq); + spin_lock_init(&priv->lock); + INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler); +- /* Perform initial interrupts setup. */ +- mlxreg_hotplug_set_irq(priv); +- +- priv->after_probe = true; + dev_set_drvdata(&pdev->dev, priv); + + err = mlxreg_hotplug_attr_init(priv); +@@ -703,6 +674,11 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev) + PTR_ERR(priv->hwmon)); + return PTR_ERR(priv->hwmon); + } ++ priv->kobj = &priv->hwmon->kobj; ++ ++ /* Perform initial interrupts setup. */ ++ mlxreg_hotplug_set_irq(priv); ++ priv->after_probe = true; + + return 0; + } +diff --git a/drivers/platform/mellanox/mlxreg-io.c b/drivers/platform/mellanox/mlxreg-io.c +index f7434ca..c192dfe 100644 +--- a/drivers/platform/mellanox/mlxreg-io.c ++++ b/drivers/platform/mellanox/mlxreg-io.c +@@ -1,3 +1,11 @@ ++// SPDX-License-Identifier: GPL-2.0+ ++/* ++ * Mellanox register access driver ++ * ++ * Copyright (C) 2018 Mellanox Technologies ++ * Copyright (C) 2018 Vadim Pasternak ++ */ ++ + #include + #include + #include +@@ -33,6 +41,54 @@ struct mlxreg_io_priv_data { + const struct attribute_group *groups[2]; + }; + ++static int ++mlxreg_io_get_reg(void *regmap, struct mlxreg_core_data *data, u32 in_val, ++ bool rw_flag, u32 *regval) ++{ ++ int ret; ++ ++ ret = regmap_read(regmap, data->reg, regval); ++ if (ret) ++ goto access_error; ++ ++ /* ++ * There are three kinds of attributes: single bit, full register's ++ * bits and bit sequence. For the first kind field mask indicates which ++ * bits are not related and field bit is set zero. For the second kind ++ * field mask is set to zero and field bit is set with all bits one. ++ * No special handling for such kind of attributes - pass value as is. ++ * For the third kind, field mask indicates which bits are related and ++ * field bit is set to the first bit number (from 1 to 32) is the bit ++ * sequence. ++ */ ++ if (!data->bit) { ++ /* Single bit. */ ++ if (rw_flag) { ++ /* For show: expose effective bit value as 0 or 1. */ ++ *regval = !!(*regval & ~data->mask); ++ } else { ++ /* For store: set effective bit value. */ ++ *regval &= data->mask; ++ if (in_val) ++ *regval |= ~data->mask; ++ } ++ } else if (data->mask) { ++ /* Bit sequence. */ ++ if (rw_flag) { ++ /* For show: mask and shift right. */ ++ *regval = ror32(*regval & data->mask, (data->bit - 1)); ++ } else { ++ /* For store: shift to the position and mask. */ ++ in_val = rol32(in_val, data->bit - 1) & data->mask; ++ /* Clear relevant bits and set them to new value. */ ++ *regval = (*regval & ~data->mask) | in_val; ++ } ++ } ++ ++access_error: ++ return ret; ++} ++ + static ssize_t + mlxreg_io_attr_show(struct device *dev, struct device_attribute *attr, + char *buf) +@@ -43,13 +99,10 @@ mlxreg_io_attr_show(struct device *dev, struct device_attribute *attr, + u32 regval = 0; + int ret; + +- ret = regmap_read(priv->pdata->regmap, data->reg, ®val); ++ ret = mlxreg_io_get_reg(priv->pdata->regmap, data, 0, true, ®val); + if (ret) + goto access_error; + +- if (!data->bit) +- regval = !!(regval & ~data->mask); +- + return sprintf(buf, "%u\n", regval); + + access_error: +@@ -63,25 +116,22 @@ mlxreg_io_attr_store(struct device *dev, struct device_attribute *attr, + struct mlxreg_io_priv_data *priv = dev_get_drvdata(dev); + int index = to_sensor_dev_attr(attr)->index; + struct mlxreg_core_data *data = priv->pdata->data + index; +- u32 val, regval; ++ u32 input_val, regval; + int ret; + +- ret = kstrtou32(buf, MLXREG_IO_ATT_SIZE, &val); ++ if (len > MLXREG_IO_ATT_SIZE) ++ return -EINVAL; ++ ++ /* Convert buffer to input value. */ ++ ret = kstrtou32(buf, len, &input_val); + if (ret) + return ret; + +- ret = regmap_read(priv->pdata->regmap, data->reg, ®val); ++ ret = mlxreg_io_get_reg(priv->pdata->regmap, data, input_val, false, ++ ®val); + if (ret) + goto access_error; + +- regval &= data->mask; +- +- val = !!val; +- if (val) +- regval |= ~data->mask; +- else +- regval &= data->mask; +- + ret = regmap_write(priv->pdata->regmap, data->reg, regval); + if (ret) + goto access_error; +@@ -93,6 +143,11 @@ mlxreg_io_attr_store(struct device *dev, struct device_attribute *attr, + return ret; + } + ++static struct device_attribute mlxreg_io_devattr_rw = { ++ .show = mlxreg_io_attr_show, ++ .store = mlxreg_io_attr_store, ++}; ++ + static int mlxreg_io_attr_init(struct mlxreg_io_priv_data *priv) + { + int i; +@@ -107,6 +162,8 @@ static int mlxreg_io_attr_init(struct mlxreg_io_priv_data *priv) + for (i = 0; i < priv->pdata->counter; i++) { + priv->mlxreg_io_attr[i] = + &priv->mlxreg_io_dev_attr[i].dev_attr.attr; ++ memcpy(&priv->mlxreg_io_dev_attr[i].dev_attr, ++ &mlxreg_io_devattr_rw, sizeof(struct device_attribute)); + + /* Set attribute name as a label. */ + priv->mlxreg_io_attr[i]->name = +@@ -121,31 +178,6 @@ static int mlxreg_io_attr_init(struct mlxreg_io_priv_data *priv) + + priv->mlxreg_io_dev_attr[i].dev_attr.attr.mode = + priv->pdata->data[i].mode; +- switch (priv->pdata->data[i].mode) { +- case 0200: +- priv->mlxreg_io_dev_attr[i].dev_attr.store = +- mlxreg_io_attr_store; +- break; +- +- case 0444: +- priv->mlxreg_io_dev_attr[i].dev_attr.show = +- mlxreg_io_attr_show; +- break; +- +- case 0644: +- priv->mlxreg_io_dev_attr[i].dev_attr.show = +- mlxreg_io_attr_show; +- priv->mlxreg_io_dev_attr[i].dev_attr.store = +- mlxreg_io_attr_store; +- break; +- +- default: +- dev_err(&priv->pdev->dev, "Bad access mode %u for attribute %s.\n", +- priv->pdata->data[i].mode, +- priv->mlxreg_io_attr[i]->name); +- return -EINVAL; +- } +- + priv->mlxreg_io_dev_attr[i].dev_attr.attr.name = + priv->mlxreg_io_attr[i]->name; + priv->mlxreg_io_dev_attr[i].index = i; +@@ -184,7 +216,9 @@ static int mlxreg_io_probe(struct platform_device *pdev) + } + + priv->hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, +- "mlxreg_io", priv, priv->groups); ++ "mlxreg_io", ++ priv, ++ priv->groups); + if (IS_ERR(priv->hwmon)) { + dev_err(&pdev->dev, "Failed to register hwmon device %ld\n", + PTR_ERR(priv->hwmon)); +@@ -207,5 +241,5 @@ module_platform_driver(mlxreg_io_driver); + + MODULE_AUTHOR("Vadim Pasternak "); + MODULE_DESCRIPTION("Mellanox regmap I/O access driver"); +-MODULE_LICENSE("Dual BSD/GPL"); ++MODULE_LICENSE("GPL"); + MODULE_ALIAS("platform:mlxreg-io"); +diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c +index e03f03f..e1f9fce 100644 +--- a/drivers/platform/x86/mlx-platform.c ++++ b/drivers/platform/x86/mlx-platform.c +@@ -47,34 +47,52 @@ + /* LPC bus IO offsets */ + #define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000 + #define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500 +-#define MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF 0x00 +-#define MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF 0x01 +-#define MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF 0x1d +-#define MLXPLAT_CPLD_LPC_REG_LED1_OFF 0x20 +-#define MLXPLAT_CPLD_LPC_REG_LED2_OFF 0x21 +-#define MLXPLAT_CPLD_LPC_REG_LED3_OFF 0x22 +-#define MLXPLAT_CPLD_LPC_REG_LED4_OFF 0x23 +-#define MLXPLAT_CPLD_LPC_REG_LED5_OFF 0x24 +-#define MLXPLAT_CPLD_LPC_REG_GP1_OFF 0x30 +-#define MLXPLAT_CPLD_LPC_REG_WP1_OFF 0x31 +-#define MLXPLAT_CPLD_LPC_REG_GP2_OFF 0x32 +-#define MLXPLAT_CPLD_LPC_REG_WP2_OFF 0x33 +-#define MLXPLAT_CPLD_LPC_REG_AGGR_OFF 0x3a +-#define MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF 0x3b +-#define MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF 0x40 +-#define MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF 0x41 +-#define MLXPLAT_CPLD_LPC_REG_PSU_OFF 0x58 +-#define MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF 0x59 +-#define MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF 0x5a +-#define MLXPLAT_CPLD_LPC_REG_PWR_OFF 0x64 +-#define MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF 0x65 +-#define MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF 0x66 +-#define MLXPLAT_CPLD_LPC_REG_FAN_OFF 0x88 +-#define MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF 0x89 +-#define MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF 0x8a ++#define MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET 0x00 ++#define MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET 0x01 ++#define MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET 0x1d ++#define MLXPLAT_CPLD_LPC_REG_LED1_OFFSET 0x20 ++#define MLXPLAT_CPLD_LPC_REG_LED2_OFFSET 0x21 ++#define MLXPLAT_CPLD_LPC_REG_LED3_OFFSET 0x22 ++#define MLXPLAT_CPLD_LPC_REG_LED4_OFFSET 0x23 ++#define MLXPLAT_CPLD_LPC_REG_LED5_OFFSET 0x24 ++#define MLXPLAT_CPLD_LPC_REG_GP1_OFFSET 0x30 ++#define MLXPLAT_CPLD_LPC_REG_WP1_OFFSET 0x31 ++#define MLXPLAT_CPLD_LPC_REG_GP2_OFFSET 0x32 ++#define MLXPLAT_CPLD_LPC_REG_WP2_OFFSET 0x33 ++#define MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET 0x37 ++#define MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET 0x3a ++#define MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET 0x3b ++#define MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET 0x40 ++#define MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET 0x41 ++#define MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET 0x50 ++#define MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET 0x51 ++#define MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET 0x52 ++#define MLXPLAT_CPLD_LPC_REG_PSU_OFFSET 0x58 ++#define MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET 0x59 ++#define MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET 0x5a ++#define MLXPLAT_CPLD_LPC_REG_PWR_OFFSET 0x64 ++#define MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET 0x65 ++#define MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET 0x66 ++#define MLXPLAT_CPLD_LPC_REG_FAN_OFFSET 0x88 ++#define MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET 0x89 ++#define MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET 0x8a ++#define MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET 0xe3 ++#define MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET 0xe4 ++#define MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET 0xe5 ++#define MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET 0xe6 ++#define MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET 0xe7 ++#define MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET 0xe8 ++#define MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET 0xe9 ++#define MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET 0xea ++#define MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET 0xeb ++#define MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET 0xec ++#define MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET 0xed ++#define MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET 0xee ++#define MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET 0xef + #define MLXPLAT_CPLD_LPC_IO_RANGE 0x100 + #define MLXPLAT_CPLD_LPC_I2C_CH1_OFF 0xdb + #define MLXPLAT_CPLD_LPC_I2C_CH2_OFF 0xda ++ + #define MLXPLAT_CPLD_LPC_PIO_OFFSET 0x10000UL + #define MLXPLAT_CPLD_LPC_REG1 ((MLXPLAT_CPLD_LPC_REG_BASE_ADRR + \ + MLXPLAT_CPLD_LPC_I2C_CH1_OFF) | \ +@@ -84,17 +102,20 @@ + MLXPLAT_CPLD_LPC_PIO_OFFSET) + + /* Masks for aggregation, psu, pwr and fan event in CPLD related registers. */ ++#define MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF 0x04 + #define MLXPLAT_CPLD_AGGR_PSU_MASK_DEF 0x08 + #define MLXPLAT_CPLD_AGGR_PWR_MASK_DEF 0x08 + #define MLXPLAT_CPLD_AGGR_FAN_MASK_DEF 0x40 +-#define MLXPLAT_CPLD_AGGR_MASK_DEF (MLXPLAT_CPLD_AGGR_PSU_MASK_DEF | \ ++#define MLXPLAT_CPLD_AGGR_MASK_DEF (MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF | \ ++ MLXPLAT_CPLD_AGGR_PSU_MASK_DEF | \ + MLXPLAT_CPLD_AGGR_FAN_MASK_DEF) ++#define MLXPLAT_CPLD_AGGR_ASIC_MASK_NG 0x01 + #define MLXPLAT_CPLD_AGGR_MASK_NG_DEF 0x04 +-#define MLXPLAT_CPLD_LOW_AGGR_MASK_LOW 0xc0 +-#define MLXPLAT_CPLD_AGGR_MASK_MSN21XX 0x04 ++#define MLXPLAT_CPLD_LOW_AGGR_MASK_LOW 0xc1 + #define MLXPLAT_CPLD_PSU_MASK GENMASK(1, 0) + #define MLXPLAT_CPLD_PWR_MASK GENMASK(1, 0) + #define MLXPLAT_CPLD_FAN_MASK GENMASK(3, 0) ++#define MLXPLAT_CPLD_ASIC_MASK GENMASK(1, 0) + #define MLXPLAT_CPLD_FAN_NG_MASK GENMASK(5, 0) + #define MLXPLAT_CPLD_LED_LO_NIBBLE_MASK GENMASK(7, 4) + #define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK GENMASK(3, 0) +@@ -119,6 +140,10 @@ + #define MLXPLAT_CPLD_NR_NONE -1 + #define MLXPLAT_CPLD_PSU_DEFAULT_NR 10 + #define MLXPLAT_CPLD_PSU_MSNXXXX_NR 4 ++#define MLXPLAT_CPLD_FAN1_DEFAULT_NR 11 ++#define MLXPLAT_CPLD_FAN2_DEFAULT_NR 12 ++#define MLXPLAT_CPLD_FAN3_DEFAULT_NR 13 ++#define MLXPLAT_CPLD_FAN4_DEFAULT_NR 14 + + /* mlxplat_priv - platform private data + * @pdev_i2c - i2c controller platform device +@@ -126,6 +151,7 @@ + * @pdev_hotplug - hotplug platform devices + * @pdev_led - led platform devices + * @pdev_io_regs - register access platform devices ++ * @pdev_fan - FAN platform devices + */ + struct mlxplat_priv { + struct platform_device *pdev_i2c; +@@ -133,6 +159,7 @@ struct mlxplat_priv { + struct platform_device *pdev_hotplug; + struct platform_device *pdev_led; + struct platform_device *pdev_io_regs; ++ struct platform_device *pdev_fan; + }; + + /* Regions for LPC I2C controller and LPC base register space */ +@@ -194,6 +221,15 @@ static struct i2c_board_info mlxplat_mlxcpld_psu[] = { + }, + }; + ++static struct i2c_board_info mlxplat_mlxcpld_ng_psu[] = { ++ { ++ I2C_BOARD_INFO("24c32", 0x51), ++ }, ++ { ++ I2C_BOARD_INFO("24c32", 0x50), ++ }, ++}; ++ + static struct i2c_board_info mlxplat_mlxcpld_pwr[] = { + { + I2C_BOARD_INFO("dps460", 0x59), +@@ -222,14 +258,14 @@ static struct i2c_board_info mlxplat_mlxcpld_fan[] = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_psu_items_data[] = { + { + .label = "psu1", +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = BIT(0), + .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], + .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, + }, + { + .label = "psu2", +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = BIT(1), + .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], + .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, +@@ -239,14 +275,14 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_psu_items_data[] = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_items_data[] = { + { + .label = "pwr1", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(0), + .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], + .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, + }, + { + .label = "pwr2", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(1), + .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], + .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, +@@ -256,31 +292,40 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_pwr_items_data[] = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_items_data[] = { + { + .label = "fan1", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(0), + .hpdev.brdinfo = &mlxplat_mlxcpld_fan[0], +- .hpdev.nr = 11, ++ .hpdev.nr = MLXPLAT_CPLD_FAN1_DEFAULT_NR, + }, + { + .label = "fan2", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(1), + .hpdev.brdinfo = &mlxplat_mlxcpld_fan[1], +- .hpdev.nr = 12, ++ .hpdev.nr = MLXPLAT_CPLD_FAN2_DEFAULT_NR, + }, + { + .label = "fan3", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(2), + .hpdev.brdinfo = &mlxplat_mlxcpld_fan[2], +- .hpdev.nr = 13, ++ .hpdev.nr = MLXPLAT_CPLD_FAN3_DEFAULT_NR, + }, + { + .label = "fan4", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(3), + .hpdev.brdinfo = &mlxplat_mlxcpld_fan[3], +- .hpdev.nr = 14, ++ .hpdev.nr = MLXPLAT_CPLD_FAN4_DEFAULT_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_asic_items_data[] = { ++ { ++ .label = "asic1", ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + }; + +@@ -288,7 +333,7 @@ static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = { + { + .data = mlxplat_mlxcpld_default_psu_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_PSU_MASK_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = MLXPLAT_CPLD_PSU_MASK, + .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), + .inversed = 1, +@@ -297,7 +342,7 @@ static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = { + { + .data = mlxplat_mlxcpld_default_pwr_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = MLXPLAT_CPLD_PWR_MASK, + .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), + .inversed = 0, +@@ -306,127 +351,92 @@ static struct mlxreg_core_item mlxplat_mlxcpld_default_items[] = { + { + .data = mlxplat_mlxcpld_default_fan_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_FAN_MASK_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = MLXPLAT_CPLD_FAN_MASK, + .count = ARRAY_SIZE(mlxplat_mlxcpld_fan), + .inversed = 1, + .health = false, + }, ++ { ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), ++ .inversed = 0, ++ .health = true, ++ }, + }; + + static + struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_data = { + .items = mlxplat_mlxcpld_default_items, + .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_items), +- .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, + .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, +-}; +- +-/* Platform hotplug MSN21xx system family data */ +-static struct i2c_board_info mlxplat_mlxcpld_msn21xx_pwr[] = { +- { +- I2C_BOARD_INFO("holder", 0x59), +- }, +- { +- I2C_BOARD_INFO("holder", 0x58), +- }, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, + }; + + static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_pwr_items_data[] = { + { + .label = "pwr1", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(0), +- .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[0], +- .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "pwr2", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(1), +- .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[1], +- .hpdev.nr = MLXPLAT_CPLD_PSU_DEFAULT_NR, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + }; + ++/* Platform hotplug MSN21xx system family data */ + static struct mlxreg_core_item mlxplat_mlxcpld_msn21xx_items[] = { + { + .data = mlxplat_mlxcpld_msn21xx_pwr_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = MLXPLAT_CPLD_PWR_MASK, + .count = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_pwr_items_data), + .inversed = 0, + .health = false, + }, +-}; +- +-static +-struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { +- .items = mlxplat_mlxcpld_msn21xx_items, +- .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_items), +- .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, +- .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, +- .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, +- .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, +-}; +- +-/* Platform hotplug MSN201x system family data */ +-static struct mlxreg_core_data mlxplat_mlxcpld_msn201x_pwr_items_data[] = { +- { +- .label = "pwr1", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, +- .mask = BIT(0), +- .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[0], +- .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, +- }, +- { +- .label = "pwr2", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, +- .mask = BIT(1), +- .hpdev.brdinfo = &mlxplat_mlxcpld_msn21xx_pwr[1], +- .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, +- }, +-}; +- +-static struct mlxreg_core_item mlxplat_mlxcpld_msn201x_items[] = { + { +- .data = mlxplat_mlxcpld_msn201x_pwr_items_data, +- .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, +- .mask = MLXPLAT_CPLD_PWR_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_pwr_items_data), ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), + .inversed = 0, +- .health = false, ++ .health = true, + }, + }; + + static +-struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn201x_data = { ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { + .items = mlxplat_mlxcpld_msn21xx_items, +- .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_items), +- .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, + .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, +- .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, + .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, + }; + +-/* Platform hotplug next generation system family data */ +-static struct i2c_board_info mlxplat_mlxcpld_ng_fan = { +- I2C_BOARD_INFO("holder", 0x50), +-}; +- +-static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = { ++/* Platform hotplug msn274x system family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_psu_items_data[] = { + { + .label = "psu1", +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = BIT(0), + .hpdev.brdinfo = &mlxplat_mlxcpld_psu[0], + .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, + }, + { + .label = "psu2", +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = BIT(1), + .hpdev.brdinfo = &mlxplat_mlxcpld_psu[1], + .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, +@@ -436,173 +446,246 @@ static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_pwr_items_data[] = { + { + .label = "pwr1", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(0), + .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[0], + .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, + }, + { + .label = "pwr2", +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = BIT(1), + .hpdev.brdinfo = &mlxplat_mlxcpld_pwr[1], + .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, + }, + }; + +-static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = { ++static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_fan_items_data[] = { + { + .label = "fan1", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(0), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 11, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan2", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(1), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 12, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan3", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(2), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 13, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan4", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(3), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 14, +- }, +- { +- .label = "fan5", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, +- .mask = BIT(4), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 15, +- }, +- { +- .label = "fan6", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, +- .mask = BIT(5), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 16, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + }; + +-static struct mlxreg_core_item mlxplat_mlxcpld_default_ng_items[] = { ++static struct mlxreg_core_item mlxplat_mlxcpld_msn274x_items[] = { + { +- .data = mlxplat_mlxcpld_default_ng_psu_items_data, ++ .data = mlxplat_mlxcpld_msn274x_psu_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = MLXPLAT_CPLD_PSU_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_psu_items_data), + .inversed = 1, + .health = false, + }, + { + .data = mlxplat_mlxcpld_default_ng_pwr_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = MLXPLAT_CPLD_PWR_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data), + .inversed = 0, + .health = false, + }, + { +- .data = mlxplat_mlxcpld_default_ng_fan_items_data, ++ .data = mlxplat_mlxcpld_msn274x_fan_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = MLXPLAT_CPLD_FAN_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_fan_items_data), + .inversed = 1, + .health = false, + }, ++ { ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), ++ .inversed = 0, ++ .health = true, ++ }, + }; + + static +-struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = { +- .items = mlxplat_mlxcpld_default_ng_items, +- .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items), +- .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = { ++ .items = mlxplat_mlxcpld_msn274x_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, + .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, + .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, + }; + +-static struct mlxreg_core_data mlxplat_mlxcpld_msn274x_fan_items_data[] = { ++/* Platform hotplug MSN201x system family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn201x_pwr_items_data[] = { ++ { ++ .label = "pwr1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = BIT(0), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++ { ++ .label = "pwr2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = BIT(1), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++}; ++ ++static struct mlxreg_core_item mlxplat_mlxcpld_msn201x_items[] = { ++ { ++ .data = mlxplat_mlxcpld_msn201x_pwr_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_PWR_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, ++ .mask = MLXPLAT_CPLD_PWR_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_pwr_items_data), ++ .inversed = 0, ++ .health = false, ++ }, ++ { ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_ASIC_MASK_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), ++ .inversed = 0, ++ .health = true, ++ }, ++}; ++ ++static ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn201x_data = { ++ .items = mlxplat_mlxcpld_msn21xx_items, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn201x_items), ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, ++ .mask = MLXPLAT_CPLD_AGGR_MASK_DEF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, ++ .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, ++}; ++ ++/* Platform hotplug next generation system family data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_psu_items_data[] = { ++ { ++ .label = "psu1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, ++ .mask = BIT(0), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[0], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++ { ++ .label = "psu2", ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, ++ .mask = BIT(1), ++ .hpdev.brdinfo = &mlxplat_mlxcpld_ng_psu[1], ++ .hpdev.nr = MLXPLAT_CPLD_PSU_MSNXXXX_NR, ++ }, ++}; ++ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_fan_items_data[] = { + { + .label = "fan1", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(0), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 11, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan2", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(1), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 12, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan3", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(2), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 13, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + { + .label = "fan4", +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, + .mask = BIT(3), +- .hpdev.brdinfo = &mlxplat_mlxcpld_ng_fan, +- .hpdev.nr = 14, ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++ { ++ .label = "fan5", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, ++ .mask = BIT(4), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, ++ }, ++ { ++ .label = "fan6", ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, ++ .mask = BIT(5), ++ .hpdev.nr = MLXPLAT_CPLD_NR_NONE, + }, + }; + +-static struct mlxreg_core_item mlxplat_mlxcpld_msn274x_items[] = { ++static struct mlxreg_core_item mlxplat_mlxcpld_default_ng_items[] = { + { + .data = mlxplat_mlxcpld_default_ng_psu_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PSU_OFFSET, + .mask = MLXPLAT_CPLD_PSU_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_psu), ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_psu_items_data), + .inversed = 1, + .health = false, + }, + { + .data = mlxplat_mlxcpld_default_ng_pwr_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_PWR_OFFSET, + .mask = MLXPLAT_CPLD_PWR_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_pwr), ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_pwr_items_data), + .inversed = 0, + .health = false, + }, + { +- .data = mlxplat_mlxcpld_msn274x_fan_items_data, ++ .data = mlxplat_mlxcpld_default_ng_fan_items_data, + .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFF, +- .mask = MLXPLAT_CPLD_FAN_MASK, +- .count = ARRAY_SIZE(mlxplat_mlxcpld_msn274x_fan_items_data), ++ .reg = MLXPLAT_CPLD_LPC_REG_FAN_OFFSET, ++ .mask = MLXPLAT_CPLD_FAN_NG_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_fan_items_data), + .inversed = 1, + .health = false, + }, ++ { ++ .data = mlxplat_mlxcpld_default_asic_items_data, ++ .aggr_mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .count = ARRAY_SIZE(mlxplat_mlxcpld_default_asic_items_data), ++ .inversed = 0, ++ .health = true, ++ }, + }; + + static +-struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = { +- .items = mlxplat_mlxcpld_msn274x_items, ++struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = { ++ .items = mlxplat_mlxcpld_default_ng_items, + .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_items), +- .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFF, ++ .cell = MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET, + .mask = MLXPLAT_CPLD_AGGR_MASK_NG_DEF, +- .cell_low = MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF, ++ .cell_low = MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET, + .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW, + }; + +@@ -610,62 +693,62 @@ struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_msn274x_data = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = { + { + .label = "status:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "status:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK + }, + { + .label = "psu:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "psu:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan1:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan1:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan2:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan2:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan3:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan3:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan4:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan4:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + }; +@@ -679,47 +762,47 @@ static struct mlxreg_core_platform_data mlxplat_default_led_data = { + static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = { + { + .label = "status:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "status:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK + }, + { + .label = "fan:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "psu1:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "psu1:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "psu2:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "psu2:red", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "uid:blue", +- .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + }; +@@ -733,82 +816,82 @@ static struct mlxreg_core_platform_data mlxplat_msn21xx_led_data = { + static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = { + { + .label = "status:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "status:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK + }, + { + .label = "psu:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "psu:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan1:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan1:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan2:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan2:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan3:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan3:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan4:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan4:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan5:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan5:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK, + }, + { + .label = "fan6:green", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + { + .label = "fan6:orange", +- .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFF, ++ .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET, + .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK, + }, + }; +@@ -818,26 +901,303 @@ static struct mlxreg_core_platform_data mlxplat_default_ng_led_data = { + .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data), + }; + ++/* Platform register access default */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = { ++ { ++ .label = "cpld1_version", ++ .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET, ++ .bit = GENMASK(7, 0), ++ .mode = 0444, ++ }, ++ { ++ .label = "cpld2_version", ++ .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET, ++ .bit = GENMASK(7, 0), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_long_pb", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_short_pb", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_aux_pwr_or_ref", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(2), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_main_pwr_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(3), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_sw_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(4), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_fw_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(5), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_hotswap_or_wd", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_asic_thermal", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(7), ++ .mode = 0444, ++ }, ++ { ++ .label = "psu1_on", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0200, ++ }, ++ { ++ .label = "psu2_on", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0200, ++ }, ++ { ++ .label = "pwr_cycle", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(2), ++ .mode = 0200, ++ }, ++ { ++ .label = "pwr_down", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(3), ++ .mode = 0200, ++ }, ++ { ++ .label = "select_iio", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP2_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0644, ++ }, ++ { ++ .label = "asic_health", ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .bit = 1, ++ .mode = 0444, ++ }, ++}; ++ ++static struct mlxreg_core_platform_data mlxplat_default_regs_io_data = { ++ .data = mlxplat_mlxcpld_default_regs_io_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_regs_io_data), ++}; ++ ++/* Platform register access MSN21xx, MSN201x, MSN274x systems families data */ ++static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_regs_io_data[] = { ++ { ++ .label = "cpld1_version", ++ .reg = MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET, ++ .bit = GENMASK(7, 0), ++ .mode = 0444, ++ }, ++ { ++ .label = "cpld2_version", ++ .reg = MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET, ++ .bit = GENMASK(7, 0), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_long_pb", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_short_pb", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_aux_pwr_or_ref", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(2), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_sw_reset", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(3), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_main_pwr_fail", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(4), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_asic_thermal", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(5), ++ .mode = 0444, ++ }, ++ { ++ .label = "reset_hotswap_or_halt", ++ .reg = MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(6), ++ .mode = 0444, ++ }, ++ { ++ .label = "psu1_on", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(0), ++ .mode = 0200, ++ }, ++ { ++ .label = "psu2_on", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(1), ++ .mode = 0200, ++ }, ++ { ++ .label = "pwr_cycle", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(2), ++ .mode = 0200, ++ }, ++ { ++ .label = "pwr_down", ++ .reg = MLXPLAT_CPLD_LPC_REG_GP1_OFFSET, ++ .mask = GENMASK(7, 0) & ~BIT(3), ++ .mode = 0200, ++ }, ++ { ++ .label = "asic_health", ++ .reg = MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET, ++ .mask = MLXPLAT_CPLD_ASIC_MASK, ++ .bit = 1, ++ .mode = 0444, ++ }, ++}; ++ ++static struct mlxreg_core_platform_data mlxplat_msn21xx_regs_io_data = { ++ .data = mlxplat_mlxcpld_msn21xx_regs_io_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_regs_io_data), ++}; ++ ++/* Platform FAN default */ ++static struct mlxreg_core_data mlxplat_mlxcpld_default_fan_data[] = { ++ { ++ .label = "pwm1", ++ .reg = MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET, ++ }, ++ { ++ .label = "tacho1", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho2", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho3", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho4", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho5", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho6", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho7", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho8", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho9", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho10", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho11", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++ { ++ .label = "tacho12", ++ .reg = MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET, ++ .mask = GENMASK(7, 0), ++ }, ++}; ++ ++static struct mlxreg_core_platform_data mlxplat_default_fan_data = { ++ .data = mlxplat_mlxcpld_default_fan_data, ++ .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_fan_data), ++}; ++ + static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) + { + switch (reg) { +- case MLXPLAT_CPLD_LPC_REG_LED1_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED2_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED3_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED4_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED5_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP1_OFF: +- case MLXPLAT_CPLD_LPC_REG_WP1_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP2_OFF: +- case MLXPLAT_CPLD_LPC_REG_WP2_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: + return true; + } + return false; +@@ -846,31 +1206,48 @@ static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg) + static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) + { + switch (reg) { +- case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF: +- case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF: +- case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED1_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED2_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED3_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED4_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED5_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP1_OFF: +- case MLXPLAT_CPLD_LPC_REG_WP1_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP2_OFF: +- case MLXPLAT_CPLD_LPC_REG_WP2_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_WP1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_WP2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: + return true; + } + return false; +@@ -879,54 +1256,82 @@ static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg) + static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg) + { + switch (reg) { +- case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF: +- case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF: +- case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED1_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED2_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED3_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED4_OFF: +- case MLXPLAT_CPLD_LPC_REG_LED5_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP1_OFF: +- case MLXPLAT_CPLD_LPC_REG_GP2_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_OFF: +- case MLXPLAT_CPLD_LPC_REG_AGGR_LOW_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFF: +- case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFF: ++ case MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_GP2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_HEALTH_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_ASIC_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PSU_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWR_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_EVENT_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_FAN_MASK_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO1_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO2_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO3_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO4_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO5_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO6_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO7_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO8_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO9_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO10_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO11_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_TACHO12_OFFSET: ++ case MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET: + return true; + } + return false; + } + + static const struct reg_default mlxplat_mlxcpld_regmap_default[] = { +- { MLXPLAT_CPLD_LPC_REG_WP1_OFF, 0x00 }, +- { MLXPLAT_CPLD_LPC_REG_WP2_OFF, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_WP1_OFFSET, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_WP2_OFFSET, 0x00 }, ++ { MLXPLAT_CPLD_LPC_REG_PWM_CONTROL_OFFSET, 0x00 }, ++}; ++ ++struct mlxplat_mlxcpld_regmap_context { ++ void __iomem *base; + }; + ++static struct mlxplat_mlxcpld_regmap_context mlxplat_mlxcpld_regmap_ctx; ++ + static int + mlxplat_mlxcpld_reg_read(void *context, unsigned int reg, unsigned int *val) + { +- *val = ioread8(context + reg); ++ struct mlxplat_mlxcpld_regmap_context *ctx = context; ++ ++ *val = ioread8(ctx->base + reg); + return 0; + } + + static int + mlxplat_mlxcpld_reg_write(void *context, unsigned int reg, unsigned int val) + { +- iowrite8(val, context + reg); ++ struct mlxplat_mlxcpld_regmap_context *ctx = context; ++ ++ iowrite8(val, ctx->base + reg); + return 0; + } + +-const struct regmap_config mlxplat_mlxcpld_regmap_config = { ++static const struct regmap_config mlxplat_mlxcpld_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 255, +@@ -944,46 +1349,11 @@ static struct resource mlxplat_mlxcpld_resources[] = { + [0] = DEFINE_RES_IRQ_NAMED(17, "mlxreg-hotplug"), + }; + +-static struct mlxreg_core_data mlxplat_mlxcpld_default_regs_io_data[] = { +- { "cpld1_version", MLXPLAT_CPLD_LPC_REG_CPLD1_VER_OFF, 0x00, +- GENMASK(7, 0), 0444 }, +- { "cpld2_version", MLXPLAT_CPLD_LPC_REG_CPLD2_VER_OFF, 0x00, +- GENMASK(7, 0), 0444 }, +- { "cause_long_pb", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(0), 0x00, 0444 }, +- { "cause_short_pb", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(1), 0x00, 0444 }, +- { "cause_aux_pwr_or_refresh", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(2), 0x00, 0444 }, +- { "cause_main_pwr_fail", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(3), 0x00, 0444 }, +- { "cause_sw_reset", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(4), 0x00, 0444 }, +- { "cause_fw_reset", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(5), 0x00, 0444 }, +- { "cause_hotswap_or_wd", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(6), 0x00, 0444 }, +- { "cause_asic_thermal", MLXPLAT_CPLD_LPC_REG_RESET_CAUSE_OFF, +- GENMASK(7, 0) & ~BIT(7), 0x00, 0444 }, +- { "psu1_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(0), +- 0x00, 0200 }, +- { "psu2_on", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(1), +- 0x00, 0200 }, +- { "pwr_cycle", MLXPLAT_CPLD_LPC_REG_GP1_OFF, GENMASK(7, 0) & ~BIT(2), +- 0x00, 0200 }, +- { "select_iio", MLXPLAT_CPLD_LPC_REG_GP2_OFF, GENMASK(7, 0) & ~BIT(6), +- 0x00, 0644 }, +-}; +- +-static struct mlxreg_core_platform_data mlxplat_default_regs_io_data = { +- .data = mlxplat_mlxcpld_default_regs_io_data, +- .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_regs_io_data), +-}; +- + static struct platform_device *mlxplat_dev; + static struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug; + static struct mlxreg_core_platform_data *mlxplat_led; + static struct mlxreg_core_platform_data *mlxplat_regs_io; ++static struct mlxreg_core_platform_data *mlxplat_fan; + + static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) + { +@@ -1016,7 +1386,7 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) + mlxplat_hotplug->deferred_nr = + mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_msn21xx_led_data; +- mlxplat_regs_io = &mlxplat_default_regs_io_data; ++ mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; + + return 1; + }; +@@ -1034,12 +1404,12 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) + mlxplat_hotplug->deferred_nr = + mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_default_led_data; +- mlxplat_regs_io = &mlxplat_default_regs_io_data; ++ mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; + + return 1; + }; + +-static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) ++static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) + { + int i; + +@@ -1048,16 +1418,16 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) + mlxplat_mux_data[i].n_values = + ARRAY_SIZE(mlxplat_msn21xx_channels); + } +- mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; ++ mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; + mlxplat_hotplug->deferred_nr = + mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_default_ng_led_data; +- mlxplat_regs_io = &mlxplat_default_regs_io_data; ++ mlxplat_regs_io = &mlxplat_msn21xx_regs_io_data; + + return 1; + }; + +-static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) ++static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) + { + int i; + +@@ -1066,11 +1436,11 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) + mlxplat_mux_data[i].n_values = + ARRAY_SIZE(mlxplat_msn21xx_channels); + } +- mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data; ++ mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data; + mlxplat_hotplug->deferred_nr = + mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1]; + mlxplat_led = &mlxplat_msn21xx_led_data; +- mlxplat_regs_io = &mlxplat_default_regs_io_data; ++ mlxplat_fan = &mlxplat_default_fan_data; + + return 1; + }; +@@ -1222,8 +1592,7 @@ static int mlxplat_mlxcpld_verify_bus_topology(int *nr) + static int __init mlxplat_init(void) + { + struct mlxplat_priv *priv; +- void __iomem *base; +- int i, j, nr, err = 0; ++ int i, j, nr, err; + + if (!dmi_check_system(mlxplat_dmi_table)) + return -ENODEV; +@@ -1267,29 +1636,21 @@ static int __init mlxplat_init(void) + } + } + +- base = devm_ioport_map(&mlxplat_dev->dev, ++ mlxplat_mlxcpld_regmap_ctx.base = devm_ioport_map(&mlxplat_dev->dev, + mlxplat_lpc_resources[1].start, 1); +- if (!base) { ++ if (!mlxplat_mlxcpld_regmap_ctx.base) { + err = -ENOMEM; + goto fail_platform_mux_register; + } + + mlxplat_hotplug->regmap = devm_regmap_init(&mlxplat_dev->dev, NULL, +- base, &mlxplat_mlxcpld_regmap_config); ++ &mlxplat_mlxcpld_regmap_ctx, ++ &mlxplat_mlxcpld_regmap_config); + if (IS_ERR(mlxplat_hotplug->regmap)) { + err = PTR_ERR(mlxplat_hotplug->regmap); + goto fail_platform_mux_register; + } + +- /* Set default registers. */ +- for (j = 0; j < mlxplat_mlxcpld_regmap_config.num_reg_defaults; j++) { +- err = regmap_write(mlxplat_hotplug->regmap, +- mlxplat_mlxcpld_regmap_default[j].reg, +- mlxplat_mlxcpld_regmap_default[j].def); +- if (err) +- goto fail_platform_mux_register; +- } +- + priv->pdev_hotplug = platform_device_register_resndata( + &mlxplat_dev->dev, "mlxreg-hotplug", + PLATFORM_DEVID_NONE, +@@ -1301,6 +1662,16 @@ static int __init mlxplat_init(void) + goto fail_platform_mux_register; + } + ++ /* Set default registers. */ ++ for (j = 0; j < mlxplat_mlxcpld_regmap_config.num_reg_defaults; j++) { ++ err = regmap_write(mlxplat_hotplug->regmap, ++ mlxplat_mlxcpld_regmap_default[j].reg, ++ mlxplat_mlxcpld_regmap_default[j].def); ++ if (err) ++ goto fail_platform_mux_register; ++ } ++ ++ /* Add LED driver. */ + mlxplat_led->regmap = mlxplat_hotplug->regmap; + priv->pdev_led = platform_device_register_resndata( + &mlxplat_dev->dev, "leds-mlxreg", +@@ -1311,24 +1682,48 @@ static int __init mlxplat_init(void) + goto fail_platform_hotplug_register; + } + +- mlxplat_regs_io->regmap = mlxplat_hotplug->regmap; +- priv->pdev_io_regs = platform_device_register_resndata( +- &mlxplat_dev->dev, "mlxreg-io", +- PLATFORM_DEVID_NONE, NULL, 0, +- mlxplat_regs_io, sizeof(*mlxplat_regs_io)); +- if (IS_ERR(priv->pdev_io_regs)) { +- err = PTR_ERR(priv->pdev_io_regs); +- goto fail_platform_led_register; ++ /* Add registers io access driver. */ ++ if (mlxplat_regs_io) { ++ mlxplat_regs_io->regmap = mlxplat_hotplug->regmap; ++ priv->pdev_io_regs = platform_device_register_resndata( ++ &mlxplat_dev->dev, "mlxreg-io", ++ PLATFORM_DEVID_NONE, NULL, 0, ++ mlxplat_regs_io, ++ sizeof(*mlxplat_regs_io)); ++ if (IS_ERR(priv->pdev_io_regs)) { ++ err = PTR_ERR(priv->pdev_io_regs); ++ goto fail_platform_led_register; ++ } ++ } ++ ++ /* Add FAN driver. */ ++ if (mlxplat_fan) { ++ mlxplat_fan->regmap = mlxplat_hotplug->regmap; ++ priv->pdev_fan = platform_device_register_resndata( ++ &mlxplat_dev->dev, "mlxreg-fan", ++ PLATFORM_DEVID_NONE, NULL, 0, ++ mlxplat_fan, ++ sizeof(*mlxplat_fan)); ++ if (IS_ERR(priv->pdev_io_regs)) { ++ err = PTR_ERR(priv->pdev_io_regs); ++ goto fail_platform_io_regs_register; ++ } + } + + /* Sync registers with hardware. */ + regcache_mark_dirty(mlxplat_hotplug->regmap); + err = regcache_sync(mlxplat_hotplug->regmap); + if (err) +- goto fail_platform_led_register; ++ goto fail_platform_fan_register; + + return 0; + ++fail_platform_fan_register: ++ if (mlxplat_fan) ++ platform_device_unregister(priv->pdev_fan); ++fail_platform_io_regs_register: ++ if (mlxplat_regs_io) ++ platform_device_unregister(priv->pdev_io_regs); + fail_platform_led_register: + platform_device_unregister(priv->pdev_led); + fail_platform_hotplug_register: +@@ -1349,7 +1744,10 @@ static void __exit mlxplat_exit(void) + struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev); + int i; + +- platform_device_unregister(priv->pdev_io_regs); ++ if (priv->pdev_fan) ++ platform_device_unregister(priv->pdev_fan); ++ if (priv->pdev_io_regs) ++ platform_device_unregister(priv->pdev_io_regs); + platform_device_unregister(priv->pdev_led); + platform_device_unregister(priv->pdev_hotplug); + +-- +2.1.4 + diff --git a/packages/base/any/kernels/4.9-lts/patches/series b/packages/base/any/kernels/4.9-lts/patches/series index 1d79cd29..bcbed8ca 100644 --- a/packages/base/any/kernels/4.9-lts/patches/series +++ b/packages/base/any/kernels/4.9-lts/patches/series @@ -13,3 +13,4 @@ driver-support-intel-igb-bcm5461-phy.patch 0012-i2c-busses-Add-capabilities-to-i2c-mlxcpld.patch driver-i2c-i2c-core.patch driver-add-the-support-max6620.patch +0013-Mellanox-backport-patchwork-from-kernels-4.17-4.19.patch From a9074bd4923a16a97dc09b6a60d7a9f40f7503ec Mon Sep 17 00:00:00 2001 From: "Carl D. Roth" Date: Wed, 25 Jul 2018 13:32:17 -0700 Subject: [PATCH 18/32] Speed optimizations - don't mount the filesystem if it's already mounted --- .../all/vendor-config-onl/src/python/onl/bootconfig/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py index a9f86293..f64677ea 100755 --- a/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py +++ b/packages/base/all/vendor-config-onl/src/python/onl/bootconfig/__init__.py @@ -22,6 +22,8 @@ class OnlBootConfig(object): def read(self, bc=None): if bc: self._readf(bc) + elif os.path.exists(self.BOOT_CONFIG_DEFAULT): + self._readf(self.BOOT_CONFIG_DEFAULT) else: from onl.mounts import OnlMountContextReadOnly with OnlMountContextReadOnly("ONL-BOOT", logger=None): From cb19a16bba588778907a553fc82e7c41cdd63b8a Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Mon, 30 Jul 2018 20:51:19 +0000 Subject: [PATCH 19/32] Fix bootcmds for the LY2 after the change introduced by 68a34873656ba5468f2708ad336d53fc12c784f4. --- .../r0/src/lib/powerpc-quanta-ly2-r0.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml index 3e2074a5..b60e7b62 100644 --- a/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml +++ b/packages/platforms/quanta/powerpc/powerpc-quanta-ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml @@ -17,17 +17,13 @@ powerpc-quanta-ly2-r0: loader: device: /dev/mmcblk0 - ##partition: /dev/mmcblk0p1 - nos_bootcmds: *mmc_bootcmds + nos_bootcmds: + - mmc part 0 + - ext2load mmc 0:1 $onl_loadaddr $onl_itb + - "bootm $onl_loadaddr#$onl_platform" environment: - device: /dev/mtd2 env_offset: 0x00000000 env_size: 0x00002000 sector_size: 0x00020000 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: soc.0/ffe24000.ethernet From cf5e1b721a5ae6b844644efd47aec528e1e69d33 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Mon, 6 Aug 2018 16:46:12 +0800 Subject: [PATCH 20/32] Implement thermal plan follow HW SPEC --- .../onlp/builds/src/module/src/sysi.c | 512 +++++++----------- 1 file changed, 183 insertions(+), 329 deletions(-) mode change 100644 => 100755 packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c old mode 100644 new mode 100755 index 25b37496..28aef8c2 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7326-56x/onlp/builds/src/module/src/sysi.c @@ -36,6 +36,7 @@ #include "x86_64_accton_as7326_56x_int.h" #include "x86_64_accton_as7326_56x_log.h" +#define NUM_OF_FAN_ON_MAIN_BROAD 6 #define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/" #define NUM_OF_CPLD 3 @@ -47,11 +48,6 @@ #define FAN_ID_FOR_SET_FAN_DUTY (1) #define CELSIUS_RECORD_NUMBER (2) /*Must >= 2*/ -typedef struct fan_ctrl_policy { - int duty_cycle; /* In percetage */ - int step_up_thermal; /* In mini-Celsius */ - int step_dn_thermal; /* In mini-Celsius */ -} fan_ctrl_policy_t; static char arr_cplddev_name[NUM_OF_CPLD][10] = { @@ -136,351 +132,209 @@ onlp_sysi_platform_info_free(onlp_platform_info_t* pi) aim_free(pi->cpld_versions); } -/* Thermal plan: - * $TMP = (CPU_core + LM75_1+ LM75_2 + LM75_3 + LM75_4)/5 - * 1. If any FAN failed, set all the other fans as full speed, 100%. - * 2. If any sensor is high than 45 degrees, set fan speed to duty 62.5%. - * 3. If any sensor is high than 50 degrees, set fan speed to duty 100%. - * 4. When $TMP >= 40 C, set fan speed to duty 62.5%. - * 5. When $TMP >= 45 C, set fan speed to duty 100%. - * 6. When $TMP < 35 C, set fan speed to duty 31.25%. - * 7. Direction factor, when B2F, duty + 12.5%. - * - * Note, all chassis fans share 1 single duty setting. +/* Thermal policy + * Both B2F and F2B direction use the same policy + *1. (Thermal sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 =< 39C , Keep 37.5%(0x05) Fan speed + *2. (Thermal sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 39C , Change Fan speed from 37.5%(0x05) to 75%(0x0B) + *3. (Thermal sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 45C , Change Fan speed from 75%(0x0B) to 100%(0x0F) + *4. (Thermal sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 61C , Send alarm message + *5. (Thermal sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 66C , Shut down system + *6. One Fan fail , Change Fan speed to 100%(0x0F) */ -fan_ctrl_policy_t fan_ctrl_policy_avg[] = { -{FAN_DUTY_CYCLE_MAX , 45000, INT_MIN}, -{63 , 40000, INT_MIN}, -{32 , INT_MAX, 35000}, -}; -fan_ctrl_policy_t fan_ctrl_policy_single[] = { -{FAN_DUTY_CYCLE_MAX , 50000, INT_MIN}, -{63 , 45000, INT_MIN}, -}; -struct fan_control_data_s { - int duty_cycle; - int dir_plus; - int mc_avg_pre[CELSIUS_RECORD_NUMBER]; - int mc_high_pre[CELSIUS_RECORD_NUMBER]; - -} fan_control_data_pre = +typedef struct fan_ctrl_policy { + int duty_cycle; + int pwm; + int temp_down; /* The boundary temperature to down adjust fan speed */ + int temp_up; /* The boundary temperature to up adjust fan speed */ + int state; +} fan_ctrl_policy_t; + +enum { - .duty_cycle = FAN_DUTY_CYCLE_DEFAULT, - .dir_plus = 0, - .mc_avg_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ - .mc_high_pre = {INT_MIN+1, INT_MIN}, /*init as thermal rising to avoid full speed.*/ - + LEVEL_FAN_DEF=0, + LEVEL_FAN_MID, + LEVEL_FAN_MAX, + LEVEL_TEMP_HIGH, + LEVEL_TEMP_CRITICAL }; -static int -sysi_check_fan(uint32_t *fan_dir){ - int i, present; +fan_ctrl_policy_t fan_thermal_policy[] = { +{38, 0x4, 0, 39000, LEVEL_FAN_DEF}, +{75, 0xB, 39000, 45000, LEVEL_FAN_MID}, +{100, 0xE, 45000, 61000, LEVEL_FAN_MAX}, +{100, 0xE, 61000, 66000, LEVEL_TEMP_HIGH}, +{100, 0xE, 66000, 200000, LEVEL_TEMP_CRITICAL} +}; + +#define FAN_SPEED_CTRL_PATH "/sys/bus/i2c/devices/11-0066/fan_duty_cycle_percentage" + +static int fan_state=LEVEL_FAN_DEF; +static int alarm_state = 0; /* 0->default or clear, 1-->alarm detect */ +int +onlp_sysi_platform_manage_fans(void) +{ + int i=0, ori_state=LEVEL_FAN_DEF, current_state=LEVEL_FAN_DEF; + int fd, len; + int cur_duty_cycle, new_duty_cycle, temp=0; + onlp_thermal_info_t thermal_3, thermal_5; + char buf[10] = {0}; + + /* Get current temperature + */ + if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(3), &thermal_3) != ONLP_STATUS_OK ) + { + AIM_LOG_ERROR("Unable to read thermal status, set fans to 75% speed"); + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fan_thermal_policy[LEVEL_FAN_MID].duty_cycle); + return ONLP_STATUS_E_INTERNAL; + } + if(onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(5), &thermal_5) != ONLP_STATUS_OK) + { + AIM_LOG_ERROR("Unable to read thermal status, set fans to 75% speed"); + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), fan_thermal_policy[LEVEL_FAN_MID].duty_cycle); + return ONLP_STATUS_E_INTERNAL; + } - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) + temp = (thermal_3.mcelsius + thermal_5.mcelsius)/2; + + /* Get current fan pwm percent + */ + fd = open(FAN_SPEED_CTRL_PATH, O_RDONLY); + if (fd == -1){ + AIM_LOG_ERROR("Unable to open fan speed control node (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + len = read(fd, buf, sizeof(buf)); + close(fd); + if (len <= 0) { + AIM_LOG_ERROR("Unable to read fan speed from (%s)", FAN_SPEED_CTRL_PATH); + return ONLP_STATUS_E_INTERNAL; + } + cur_duty_cycle = atoi(buf); + ori_state=fan_state; + /* Inpunt temp to get theraml_polyc state and new pwm percent. */ + for(i=0; i < sizeof(fan_thermal_policy)/sizeof(fan_ctrl_policy_t); i++) + { + if (temp > fan_thermal_policy[i].temp_down) + { + if (temp <= fan_thermal_policy[i].temp_up) + { + current_state =i; + } + } + } + + /* Decision 3: Decide new fan pwm percent. + */ + if (cur_duty_cycle!=fan_thermal_policy[current_state].duty_cycle) + { + new_duty_cycle = fan_thermal_policy[current_state].duty_cycle; + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), new_duty_cycle); + } + + /* Get each fan status + */ + for (i = 1; i <= NUM_OF_FAN_ON_MAIN_BROAD; i++) { onlp_fan_info_t fan_info; if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to get fan(%d) status\r\n", i); - return ONLP_STATUS_E_INTERNAL; + AIM_LOG_ERROR("Unable to get fan(%d) status, try to set the other fans as full speed\r\n", i); + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + break; } - - present = fan_info.status & ONLP_FAN_STATUS_PRESENT; - if ((fan_info.status & ONLP_FAN_STATUS_FAILED) || !present) { - AIM_LOG_WARN("Fan(%d) is not working, set the other fans as full speed\r\n", i); - int ret = onlp_fani_percentage_set( - ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY), FAN_DUTY_CYCLE_MAX); - if (ret != ONLP_STATUS_OK) - return ret; - else - return ONLP_STATUS_E_MISSING; - } - - /* Get fan direction (Only get the first one since all fan direction are the same) + /* Decision 1: Set fan as full speed if any fan is failed. */ - if (i == 1) { - *fan_dir = fan_info.status & (ONLP_FAN_STATUS_F2B|ONLP_FAN_STATUS_B2F); - } - } - - return ONLP_STATUS_OK; -} - -static int -sysi_get_fan_duty(int *cur_duty_cycle){ - int fd, len; - char buf[10] = {0}; - char *node = FAN_NODE(fan_duty_cycle_percentage); - - /* Get current fan duty*/ - fd = open(node, O_RDONLY); - if (fd == -1){ - AIM_LOG_ERROR("Unable to open fan speed control node (%s)", node); - return ONLP_STATUS_E_INTERNAL; - } - - len = read(fd, buf, sizeof(buf)); - close(fd); - if (len <= 0) { - AIM_LOG_ERROR("Unable to read fan speed from (%s)", node); - return ONLP_STATUS_E_INTERNAL; - } - *cur_duty_cycle = atoi(buf); - - return ONLP_STATUS_OK; -} - -static int -sysi_get_thermal_sum(int *mcelsius){ - onlp_thermal_info_t thermal_info; - int i; - - *mcelsius = 0; - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) - != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read thermal status"); - return ONLP_STATUS_E_INTERNAL; + if (fan_info.status & ONLP_FAN_STATUS_FAILED || !(fan_info.status & ONLP_FAN_STATUS_PRESENT)) { + AIM_LOG_ERROR("Fan(%d) is not working, set the other fans as full speed\r\n", i); + onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(1), FAN_DUTY_CYCLE_MAX); + break; } - *mcelsius += thermal_info.mcelsius; + } - DEBUG_PRINT("Thermal %d: %d \n ", i, thermal_info.mcelsius); + if(current_state!=ori_state) + { + fan_state=current_state; + + switch (ori_state) + { + case LEVEL_FAN_DEF: + if(current_state==LEVEL_TEMP_HIGH) + { + if(alarm_state==0) + { + AIM_SYSLOG_WARN("Temperature high", "Temperature high","Alarm for temperature high is detected"); + alarm_state=1; + } + } + if(current_state==LEVEL_TEMP_CRITICAL) + { + AIM_SYSLOG_CRIT("Temperature critical", "Temperature critical", "Alarm for temperature critical is detected, reboot DUT"); + system("sync;sync;sync"); + system("reboot"); + } + break; + case LEVEL_FAN_MID: + if(current_state==LEVEL_TEMP_HIGH) + { + if(alarm_state==0) + { + AIM_SYSLOG_WARN("Temperature high", "Temperature high","Alarm for temperature high is detected"); + alarm_state=1; + } + } + if(current_state==LEVEL_TEMP_CRITICAL) + { + AIM_SYSLOG_CRIT("Temperature critical", "Temperature critical", "Alarm for temperature critical is detected, reboot DUT"); + system("sync;sync;sync"); + system("reboot"); + } + break; + case LEVEL_FAN_MAX: + if(current_state==LEVEL_TEMP_HIGH) + { + if(alarm_state==0) + { + AIM_SYSLOG_WARN("Temperature high", "Temperature high","Alarm for temperature high is detected"); + alarm_state=1; + } + } + if(current_state==LEVEL_TEMP_CRITICAL) + { + AIM_SYSLOG_CRIT("Temperature critical", "Temperature critical ", "Alarm for temperature critical is detected, reboot DUT"); + system("sync;sync;sync"); + system("reboot"); + } + break; + case LEVEL_TEMP_HIGH: + if(current_state==LEVEL_TEMP_CRITICAL) + { + AIM_SYSLOG_CRIT("Temperature critical", "Temperature critical ", "Alarm for temperature critical is detected, reboot DUT"); + system("sync;sync;sync"); + system("reboot"); + } + break; + case LEVEL_TEMP_CRITICAL: + break; + default: + AIM_SYSLOG_WARN("onlp_sysi_platform_manage_fans abnormal state", "onlp_sysi_platform_manage_fans abnormal state", "onlp_sysi_platform_manage_fans at abnormal state\n"); + break; + } } - - return ONLP_STATUS_OK; - -} - -static int -sysi_get_highest_thermal(int *mcelsius){ - onlp_thermal_info_t thermal_info; - int i, highest; - - highest = 0; - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) { - if (onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &thermal_info) - != ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read thermal status"); - return ONLP_STATUS_E_INTERNAL; - } - highest = (thermal_info.mcelsius > highest)? - thermal_info.mcelsius : highest; - } - *mcelsius = highest; - return ONLP_STATUS_OK; -} - -/* Anaylze thermal changing history to judge if the change is a stable trend. */ -static int _is_thermal_a_trend(int *mc_history){ - int i, trend, trended; - - if (mc_history == NULL) { - AIM_LOG_ERROR("Unable to get history of thermal\n"); - return 0; - } - - /* Get heat up/down trend. */ - trend = 0; - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - if (( mc_history[i+1] < mc_history[i])){ - trend++; - }else if (( mc_history[i+1] > mc_history[i])){ - trend--; - } - } - - trended = (abs(trend) >= ((CELSIUS_RECORD_NUMBER+1)/2))? 1:0; -#if (DEBUG_MODE == 1) - DEBUG_PRINT("[INFO]%s#%d, trended: %d, UP/DW: %d mcelsius:", - __func__, __LINE__, trended, trend ); - for (i = 0; i <= CELSIUS_RECORD_NUMBER; i++) { - DEBUG_PRINT(" %d =>", mc_history[i]); - } - DEBUG_PRINT("%c\n", ' '); -#endif - - /*For more than half changes are same direction, it's a firm trend.*/ - return trended; -} - - -/* Decide duty by highest value of thermal sensors.*/ -static int -sysi_get_duty_by_highest(int *duty_cycle){ - int i, ret, maxtrix_len; - int new_duty_cycle = 0 ; - int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; - int *mcelsius_pre_p = &mc_history[1]; - int *mcelsius_now_p = &mc_history[0]; - - /* Fill up mcelsius array, - * [0] is current temperature, others are history. - */ - ret = sysi_get_highest_thermal(mcelsius_now_p); - if(ONLP_STATUS_OK != ret){ - return ret; - } - memcpy (mcelsius_pre_p, fan_control_data_pre.mc_high_pre, - sizeof(fan_control_data_pre.mc_high_pre)); - - DEBUG_PRINT("[INFO]%s#%d, highest mcelsius:%d!\n", - __func__, __LINE__, *mcelsius_now_p); - - /* Shift records to the right */ - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - fan_control_data_pre.mc_high_pre[i] = mc_history[i]; - } - - /* Only change duty on consecutive heat rising or falling.*/ - maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_single); - - /* Only change duty when the thermal changing are firm. */ - if (_is_thermal_a_trend(mc_history)) + if(alarm_state==1 && current_state < LEVEL_TEMP_HIGH) { - int matched = 0; - for (i = 0; i < maxtrix_len; i++) { - if ((*mcelsius_now_p > fan_ctrl_policy_single[i].step_up_thermal)) { - new_duty_cycle = fan_ctrl_policy_single[i].duty_cycle; - matched = !matched; - break; - } - } -/* if (!matched) { - DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", - __func__, __LINE__, *mcelsius_now_p); - } */ + if (temp < (fan_thermal_policy[3].temp_down - 5000)) /*below 65 C, clear alarm*/ + { + AIM_SYSLOG_INFO("Temperature high is clean", "Temperature high is clear", "Alarm for temperature high is cleared"); + alarm_state=0; + } } - *duty_cycle = new_duty_cycle; - return ONLP_STATUS_OK; + + return 0; } -/* Decide duty by average value of thermal sensors.*/ -static int -sysi_get_duty_by_average(int *duty_cycle){ - int i, mcelsius_avg, ret, maxtrix_len; - int new_duty_cycle=0; - int mc_history[CELSIUS_RECORD_NUMBER+1] = {0}; - int *mcelsius_pre_p = &mc_history[1]; - int *mcelsius_now_p = &mc_history[0]; - - /* Fill up mcelsius array, - * [0] is current temperature, others are history. - */ - *mcelsius_now_p = 0; - ret = sysi_get_thermal_sum(mcelsius_now_p); - if(ONLP_STATUS_OK != ret){ - return ret; - } - mcelsius_avg = (*mcelsius_now_p)/CHASSIS_THERMAL_COUNT; - - memcpy (mcelsius_pre_p, fan_control_data_pre.mc_avg_pre, - sizeof(fan_control_data_pre.mc_avg_pre)); - - DEBUG_PRINT("[INFO]%s#%d, mcelsius:%d!\n", __func__, __LINE__, mcelsius_avg); - - /* Shift records to the right */ - for (i = 0; i < CELSIUS_RECORD_NUMBER; i++) { - fan_control_data_pre.mc_avg_pre[i] = mc_history[i]; - } - - /* Only change duty on consecutive heat rising or falling.*/ - maxtrix_len = AIM_ARRAYSIZE(fan_ctrl_policy_avg); - - /* Only change duty when the thermal changing are firm. */ - if (_is_thermal_a_trend(mc_history)) - { - int matched = 0; - for (i = 0; i < maxtrix_len; i++) { - if ((mcelsius_avg >= fan_ctrl_policy_avg[i].step_up_thermal)) { - new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; - matched = !matched; - break; - } - } - for (i = maxtrix_len-1; i>=0; i--) { - if ((mcelsius_avg < fan_ctrl_policy_avg[i].step_dn_thermal)) { - new_duty_cycle = fan_ctrl_policy_avg[i].duty_cycle; - matched = !matched; - break; - } - } - /*if (!matched) { - DEBUG_PRINT("%s#%d, celsius(%d) falls into undefined range!!\n", - __func__, __LINE__, mcelsius_avg); - } */ - } - - *duty_cycle = new_duty_cycle; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - uint32_t fan_dir; - int ret; - int cur_duty_cycle, new_duty_cycle, tmp; - int direct_addon = 0; - onlp_oid_t fan_duty_oid = ONLP_FAN_ID_CREATE(FAN_ID_FOR_SET_FAN_DUTY); - - /********************************************************** - * Decision 1: Set fan as full speed if any fan is failed. - **********************************************************/ - ret = sysi_check_fan(&fan_dir); - if(ONLP_STATUS_OK != ret){ - return ret; - } - - if (fan_dir & ONLP_FAN_STATUS_B2F) { - direct_addon = FAN_DUTY_PLUS_FOR_DIR; - } - - /********************************************************** - * Decision 2: If no matched fan speed is found from the policy, - * use FAN_DUTY_CYCLE_MIN as default speed - **********************************************************/ - ret = sysi_get_fan_duty(&cur_duty_cycle); - if(ONLP_STATUS_OK != ret){ - return ret; - } - - /********************************************************** - * Decision 3: Decide new fan speed depend on fan direction and temperature - **********************************************************/ - ret = sysi_get_duty_by_average(&new_duty_cycle); - if (ONLP_STATUS_OK != ret){ - return ret; - } - ret = sysi_get_duty_by_highest(&tmp); - if (ONLP_STATUS_OK != ret){ - return ret; - } - - new_duty_cycle = (tmp > new_duty_cycle)? tmp : new_duty_cycle; - if (new_duty_cycle == 0) - { - new_duty_cycle = fan_control_data_pre.duty_cycle; - } else { - fan_control_data_pre.duty_cycle = new_duty_cycle; - } - fan_control_data_pre.dir_plus = direct_addon; - DEBUG_PRINT("[INFO]%s#%d, new duty: %d = %d + %d (%d)!\n", __func__, __LINE__, - new_duty_cycle + direct_addon, new_duty_cycle, direct_addon, cur_duty_cycle); - - new_duty_cycle += direct_addon; - new_duty_cycle = (new_duty_cycle > FAN_DUTY_CYCLE_MAX)? - FAN_DUTY_CYCLE_MAX : new_duty_cycle; - - if (new_duty_cycle == cur_duty_cycle) { - /* Duty cycle does not change, just return */ - return ONLP_STATUS_OK; - } - - return onlp_fani_percentage_set(fan_duty_oid, new_duty_cycle); -} int onlp_sysi_platform_manage_leds(void) From ef79e64bb87ea0288e65b43490063c6a113481a8 Mon Sep 17 00:00:00 2001 From: Zi Zhou Date: Mon, 6 Aug 2018 16:10:50 -0700 Subject: [PATCH 21/32] fix PSU model display --- .../onlp/builds/src/module/src/platform_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c index 9e2c0143..ea7c7548 100644 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7312-54xs/onlp/builds/src/module/src/platform_lib.c @@ -109,7 +109,7 @@ psu_type_t get_psu_type(int id, char* modelname, int modelname_len) } if (modelname) { - strncpy(modelname, model_name, modelname_len-1); + strncpy(modelname, model_name, I2C_PSU_MODEL_NAME_LEN - 1); } node = (id == PSU1_ID) ? PSU1_AC_PMBUS_NODE(psu_fan_dir) : PSU2_AC_PMBUS_NODE(psu_fan_dir); From 73755f1d2157eb39adc74f777a06d17353774cad Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Tue, 7 Aug 2018 13:30:32 -0700 Subject: [PATCH 22/32] Latest SFF. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index d20a20a0..b53de397 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit d20a20a01a61cb68ab7d5d0e2ca02f8ca3a7eb9d +Subproject commit b53de3978213f9bc153011af3b919197e5bb69b0 From eea5db9aefac9d276f7c7f3b396cff4bb2f7d179 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 8 Aug 2018 01:09:41 +0000 Subject: [PATCH 23/32] Fix symbolic link handling in the 'links' package section. The 'links' section specifies symbolic links which should be added to the package in key : value format. The key is the source of the link. It must be exist in the filesystem already (as part of the 'files' section) and be relative to the root of the filesystem. The value is the name of the link, and can be relative or absolute to the final filesystem. For example, given that a package produces the real binary "/usr/bin/foobar" and you want /usr/bin/foobar-link -> /usr/bin/foobar it will be specified as follows: links: /usr/bin/foobar : /usr/bin/foobar-link --- tools/onlpm.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index 3d89e6d9..4701daed 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -362,9 +362,14 @@ class OnlPackage(object): if os.path.exists(src): OnlPackage.copyf(src, dst, root) - for (link,src) in self.pkg.get('links', {}).iteritems(): + for (link, src) in self.pkg.get('links', {}).iteritems(): logger.info("Linking %s -> %s..." % (link, src)) - link = os.path.join(root, link) + # The source must be relative to the existing root directory. + if link.startswith('/'): + link = "%s%s" % (root, link) + else: + link = "%s/%s" % (root, link) + # The link must be relative or absolute to the final filesystem. os.symlink(src, link) # From a9bf2fedaa73bad6db344017fe027d9e74831982 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 9 Aug 2018 09:13:07 -0700 Subject: [PATCH 24/32] Latest SFF. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index b53de397..bc41ef3d 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit b53de3978213f9bc153011af3b919197e5bb69b0 +Subproject commit bc41ef3d18ab49c4f421b7db91ce7def9d5add0c From dad6acb511dab1078675837da61ea171136cc5f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 9 Aug 2018 17:10:04 -0700 Subject: [PATCH 25/32] Latest --- sm/bigcode | 2 +- sm/infra | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sm/bigcode b/sm/bigcode index bc41ef3d..719414c7 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit bc41ef3d18ab49c4f421b7db91ce7def9d5add0c +Subproject commit 719414c7691780ea454dbd164c40ebc387c56a9b diff --git a/sm/infra b/sm/infra index 16ce9cd7..f78cc911 160000 --- a/sm/infra +++ b/sm/infra @@ -1 +1 @@ -Subproject commit 16ce9cd77f6639aac4813d698f9dd11f3ee47e7a +Subproject commit f78cc91121bf520b48b4888f08e055ed92b9fbf2 From 850c82cc1adb24fc6e1b167eb772a00c3e9b79e6 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Thu, 16 Aug 2018 14:23:20 +0800 Subject: [PATCH 26/32] Modify sysi to read eeprom via word_data due to block_data get error for some eeprom hw. --- .../onlp/builds/src/module/src/sysi.c | 24 +++++++++++++------ .../x86_64_accton_as5916_54xks_r0/__init__.py | 2 -- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c index d01d1dc9..21e6daf1 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/onlp/builds/src/module/src/sysi.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -55,17 +56,26 @@ onlp_sysi_platform_get(void) int onlp_sysi_onie_data_get(uint8_t** data, int* size) { + int ret = ONLP_STATUS_OK; + int i = 0; uint8_t* rdata = aim_zmalloc(256); - if(onlp_file_read(rdata, 256, size, IDPROM_PATH) == ONLP_STATUS_OK) { - if(*size == 256) { - *data = rdata; - return ONLP_STATUS_OK; + + for (i = 0; i < 128; i++) { + ret = onlp_i2c_readw(0, 0x56, i*2, ONLP_I2C_F_FORCE); + if (ret < 0) { + aim_free(rdata); + *size = 0; + return ret; } + + rdata[i*2] = ret & 0xff; + rdata[i*2+1] = (ret >> 8) & 0xff; } - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; + *size = 256; + *data = rdata; + + return ONLP_STATUS_OK; } int diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py index d723aa4a..5dd206e8 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py +++ b/packages/platforms/accton/x86-64/x86-64-accton-as5916-54xks/platform-config/r0/src/python/x86_64_accton_as5916_54xks_r0/__init__.py @@ -54,8 +54,6 @@ class OnlPlatform_x86_64_accton_as5916_54xks_r0(OnlPlatformAccton, ('pca9548', 0x75, 30), ('pca9548', 0x75, 31), - # initiate IDPROM - ('24c02', 0x56, 0), ] ) From 4c2a2b6154452fbefad71d758af4e2ed966e20f6 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 16 Aug 2018 19:27:59 +0000 Subject: [PATCH 27/32] Initial Denverton support. --- .../configs/x86_64-all/x86_64-all.config | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config index e5e3b53a..ad3795fc 100755 --- a/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config +++ b/packages/base/any/kernels/4.14-lts/configs/x86_64-all/x86_64-all.config @@ -440,6 +440,7 @@ CONFIG_ZONE_DMA=y CONFIG_SMP=y CONFIG_X86_FEATURE_NAMES=y CONFIG_X86_FAST_FEATURE_TESTS=y +CONFIG_X86_X2APIC=y CONFIG_X86_MPPARSE=y # CONFIG_GOLDFISH is not set CONFIG_RETPOLINE=y @@ -448,13 +449,14 @@ CONFIG_X86_EXTENDED_PLATFORM=y # CONFIG_X86_VSMP is not set # CONFIG_X86_GOLDFISH is not set # CONFIG_X86_INTEL_MID is not set -# CONFIG_X86_INTEL_LPSS is not set +CONFIG_X86_INTEL_LPSS=y # CONFIG_X86_AMD_PLATFORM_DEVICE is not set CONFIG_IOSF_MBI=y # CONFIG_IOSF_MBI_DEBUG is not set CONFIG_X86_SUPPORTS_MEMORY_FAILURE=y CONFIG_SCHED_OMIT_FRAME_POINTER=y -# CONFIG_HYPERVISOR_GUEST is not set +CONFIG_HYPERVISOR_GUEST=y +# CONFIG_PARAVIRT is not set CONFIG_NO_BOOTMEM=y # CONFIG_MK8 is not set # CONFIG_MPSC is not set @@ -2009,6 +2011,7 @@ CONFIG_MOUSE_PS2_TRACKPOINT=y # CONFIG_MOUSE_PS2_SENTELIC is not set # CONFIG_MOUSE_PS2_TOUCHKIT is not set CONFIG_MOUSE_PS2_FOCALTECH=y +# CONFIG_MOUSE_PS2_VMMOUSE is not set CONFIG_MOUSE_PS2_SMBUS=y # CONFIG_MOUSE_SERIAL is not set # CONFIG_MOUSE_APPLETOUCH is not set @@ -2232,7 +2235,6 @@ CONFIG_IPMI_DMI_DECODE=y # CONFIG_IPMI_PANIC_EVENT is not set CONFIG_IPMI_DEVICE_INTERFACE=y CONFIG_IPMI_SI=y -CONFIG_IPMI_SI_PROBE_DEFAULTS=y CONFIG_IPMI_SSIF=y CONFIG_IPMI_WATCHDOG=y CONFIG_IPMI_POWEROFF=y @@ -2402,6 +2404,27 @@ CONFIG_PTP_1588_CLOCK=y # # Enable PHYLIB and NETWORK_PHY_TIMESTAMPING to see the additional clocks. # +CONFIG_PINCTRL=y + +# +# Pin controllers +# +CONFIG_PINMUX=y +CONFIG_PINCONF=y +CONFIG_GENERIC_PINCONF=y +# CONFIG_DEBUG_PINCTRL is not set +# CONFIG_PINCTRL_AMD is not set +# CONFIG_PINCTRL_MCP23S08 is not set +# CONFIG_PINCTRL_SX150X is not set +# CONFIG_PINCTRL_BAYTRAIL is not set +# CONFIG_PINCTRL_CHERRYVIEW is not set +CONFIG_PINCTRL_INTEL=y +# CONFIG_PINCTRL_BROXTON is not set +# CONFIG_PINCTRL_CANNONLAKE is not set +CONFIG_PINCTRL_DENVERTON=y +# CONFIG_PINCTRL_GEMINILAKE is not set +# CONFIG_PINCTRL_LEWISBURG is not set +# CONFIG_PINCTRL_SUNRISEPOINT is not set CONFIG_GPIOLIB=y CONFIG_GPIO_ACPI=y CONFIG_GPIOLIB_IRQCHIP=y @@ -2438,6 +2461,7 @@ CONFIG_GPIO_SCH=y CONFIG_GPIO_PCA953X=y # CONFIG_GPIO_PCA953X_IRQ is not set CONFIG_GPIO_PCF857X=y +# CONFIG_GPIO_SX150X is not set # CONFIG_GPIO_TPIC2810 is not set # @@ -2781,8 +2805,9 @@ CONFIG_LPC_ICH=y CONFIG_LPC_SCH=y # CONFIG_INTEL_SOC_PMIC is not set # CONFIG_INTEL_SOC_PMIC_CHTWC is not set -# CONFIG_MFD_INTEL_LPSS_ACPI is not set -# CONFIG_MFD_INTEL_LPSS_PCI is not set +CONFIG_MFD_INTEL_LPSS=y +CONFIG_MFD_INTEL_LPSS_ACPI=y +CONFIG_MFD_INTEL_LPSS_PCI=y # CONFIG_MFD_JANZ_CMODIO is not set # CONFIG_MFD_KEMPLD is not set # CONFIG_MFD_88PM800 is not set @@ -3410,6 +3435,7 @@ CONFIG_VIRTIO_PCI_LEGACY=y # # Microsoft Hyper-V guest support # +# CONFIG_HYPERV is not set # CONFIG_HYPERV_TSCPAGE is not set # CONFIG_STAGING is not set CONFIG_X86_PLATFORM_DEVICES=y From 398084e5255f4ad226f574bc58ef7083959eccab Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Thu, 16 Aug 2018 21:46:04 +0000 Subject: [PATCH 28/32] Add python-netaddr dependency. --- packages/base/all/vendor-config-onl/PKG.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/all/vendor-config-onl/PKG.yml b/packages/base/all/vendor-config-onl/PKG.yml index 1429953f..63d83c45 100644 --- a/packages/base/all/vendor-config-onl/PKG.yml +++ b/packages/base/all/vendor-config-onl/PKG.yml @@ -3,7 +3,7 @@ prerequisites: packages: - name: onl-vendor-config-onl - depends: [ python-yaml, onl-bootd, python-dmidecode ] + depends: [ python-yaml, onl-bootd, python-dmidecode, python-netaddr ] version: 1.0.0 arch: all copyright: Copyright 2013, 2014, 2015 Big Switch Networks From f29aa9086b93d2ea51f44129dd6ce409e9fa0564 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Fri, 17 Aug 2018 23:15:16 +0000 Subject: [PATCH 29/32] The SFPI layer should not implement transmitter disable for QSFP modules as part of the TX_DISABLE control. The transmitter disable bytes are standardized by the MSA and managed by the upper layer using the dev_writeb() routines when appropriate based on module type. Writing the transmitter enable bytes are not appropriate for CR cables and will generate write errors so attempting to emulate this behavior without knowing the type of module is also troublesome. --- .../module/src/sfpi.c | 95 ++++++------------- 1 file changed, 27 insertions(+), 68 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c index f9d671b0..45909907 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-as7726-32x/onlp/builds/src/x86_64_accton_as7726_32x/module/src/sfpi.c @@ -52,7 +52,7 @@ int sfp_map_bus[] ={21, 22, 23, 24, 26, 25, 28, 27, * SFPI Entry Points * ***********************************************************/ - + int onlp_sfpi_init(void) { @@ -92,18 +92,18 @@ onlp_sfpi_is_present(int port) */ int present; int bus, addr; - + if(port <0 || port > 34) return ONLP_STATUS_E_INTERNAL; - + addr = 60; bus = 11; - + if (onlp_file_read_int(&present, MODULE_PRESENT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); return ONLP_STATUS_E_INTERNAL; } - + return present; } @@ -116,8 +116,8 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int bus=11; char file[64] = {0}; int count; - - ptr = bytes; + + ptr = bytes; sprintf(file, MODULE_PRESENT_ALL_ATTR, bus, addr); fp = fopen(file, "r"); if(fp == NULL) { @@ -132,7 +132,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) AIM_LOG_ERROR("Unable to read all fields the module_present_all device file of CPLD3."); return ONLP_STATUS_E_INTERNAL; } - + /* Convert to 64 bit integer in port order */ uint64_t presence_all = 0 ; int i = 0; @@ -158,7 +158,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) FILE* fp; int addr=60, i = 0; - + fp = fopen(MODULE_RXLOS_ALL_ATTR_CPLD, "r"); if(fp == NULL) { AIM_LOG_ERROR("Unable to open the module_rx_los_all device file of CPLD(0x%d)", addr); @@ -181,7 +181,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) } /* Populate bitmap */ - for(i = 0; rx_los_all; i++) { + for(i = 0; rx_los_all; i++) { AIM_BITMAP_MOD(dst, i, (rx_los_all & 1)); rx_los_all >>= 1; } @@ -221,7 +221,7 @@ onlp_sfpi_dom_read(int port, uint8_t data[256]) { FILE* fp; char file[64] = {0}; - + sprintf(file, PORT_EEPROM_FORMAT, onlp_sfpi_map_bus_index(port)); fp = fopen(file, "r"); if(fp == NULL) { @@ -279,17 +279,13 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) int rv; int addr = 60; int bus = 11; - - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; switch(control) { case ONLP_SFP_CONTROL_TX_DISABLE: { - if(port==32 || port==33) - { - if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { + if(port==32 || port==33) { + if (onlp_file_write_int(0, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; } @@ -297,21 +293,9 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) rv = ONLP_STATUS_OK; } } - else if(port >=0) - { - if(!onlp_sfpi_is_present(port)) - return ONLP_STATUS_OK; - rv=onlp_sfpi_dev_writeb(port, 0x50, 86, 1); - if(rv < 0) - { - AIM_LOG_ERROR("Fail to read onlp_sfpi_dev_writeb, port=%d\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else - { - rv = ONLP_STATUS_OK; - } - } + else { + rv = ONLP_STATUS_E_UNSUPPORTED; + } break; } @@ -329,16 +313,12 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) int rv; int addr = 60; int bus = 11; - - if(port <0 || port > 34) - return ONLP_STATUS_E_INTERNAL; switch(control) { case ONLP_SFP_CONTROL_RX_LOS: { - if(port==32 || port==33) - { + if(port==32 || port==33) { if (onlp_file_read_int(value, MODULE_RXLOS_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read rx_loss status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; @@ -347,16 +327,15 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) rv = ONLP_STATUS_OK; } } - else - return ONLP_STATUS_E_UNSUPPORTED; - + else { + rv = ONLP_STATUS_E_UNSUPPORTED; + } break; } case ONLP_SFP_CONTROL_TX_FAULT: { - if(port==32 || port==33) - { + if(port==32 || port==33) { if (onlp_file_read_int(value, MODULE_TXFAULT_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_fault status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; @@ -365,15 +344,15 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) rv = ONLP_STATUS_OK; } } - else - return ONLP_STATUS_E_UNSUPPORTED; + else { + rv = ONLP_STATUS_E_UNSUPPORTED; + } break; } case ONLP_SFP_CONTROL_TX_DISABLE: { - if(port==32 || port==33) - { + if(port==32 || port==33) { if (onlp_file_read_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) { AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); rv = ONLP_STATUS_E_INTERNAL; @@ -382,27 +361,8 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) rv = ONLP_STATUS_OK; } } - else - { - if(port >= 0) - { - if(!onlp_sfpi_is_present(port)) - { - *value=0; - return ONLP_STATUS_OK; - } - rv=onlp_sfpi_dev_readb(port, 0x50, 86); - if(rv < 0) - { - AIM_LOG_ERROR("Unable to read tx_disabled status from port(%d)\r\n", port); - rv = ONLP_STATUS_E_INTERNAL; - } - else - { - *value= (rv & 0x1); - rv = ONLP_STATUS_OK; - } - } + else { + rv = ONLP_STATUS_E_UNSUPPORTED; } break; } @@ -419,4 +379,3 @@ onlp_sfpi_denit(void) { return ONLP_STATUS_OK; } - From 62b5e08a062dd62fcbeaffa337b686767f31d2d0 Mon Sep 17 00:00:00 2001 From: Wilson Ng Date: Mon, 27 Aug 2018 16:50:27 -0700 Subject: [PATCH 30/32] Latest bigcode. --- sm/bigcode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sm/bigcode b/sm/bigcode index 719414c7..3a0ca236 160000 --- a/sm/bigcode +++ b/sm/bigcode @@ -1 +1 @@ -Subproject commit 719414c7691780ea454dbd164c40ebc387c56a9b +Subproject commit 3a0ca236ecba75278dffa31c7c4c91a9be2285f4 From cc3223856487d351f12b1959b471bc2310f7c7a4 Mon Sep 17 00:00:00 2001 From: Jostar Yang Date: Tue, 28 Aug 2018 16:31:21 +0800 Subject: [PATCH 31/32] 1. Let csp9250 support kernel-4.14. 2. Remove not need debug log --- .../x86-64/x86-64-accton-csp9250/modules/PKG.yml | 2 +- .../modules/builds/x86-64-accton-csp9250-leds.c | 4 ---- .../modules/builds/x86-64-accton-csp9250-sfp.c | 13 +------------ .../r0/src/lib/x86-64-accton-csp9250-r0.yml | 2 +- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/PKG.yml b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/PKG.yml index 3f59762e..d857a900 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/PKG.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/PKG.yml @@ -1 +1 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-csp9250 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" +!include $ONL_TEMPLATES/platform-modules.yml VENDOR=accton BASENAME=x86-64-accton-csp9250 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-leds.c b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-leds.c index f3a2f878..c6237ccd 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-leds.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-leds.c @@ -33,10 +33,6 @@ extern int csp9250_i2c_cpld_read (unsigned short cpld_addr, u8 reg); extern int csp9250_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); -extern void led_classdev_unregister(struct led_classdev *led_cdev); -extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); -extern void led_classdev_resume(struct led_classdev *led_cdev); -extern void led_classdev_suspend(struct led_classdev *led_cdev); #define DRVNAME "accton_csp9250_led" diff --git a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-sfp.c b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-sfp.c index d13bf7c9..1a3f1775 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-sfp.c +++ b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/modules/builds/x86-64-accton-csp9250-sfp.c @@ -1005,9 +1005,8 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, char *buf, loff_t off, size_t count) { ssize_t retval = 0; - printk("acc trace %s:%d\n", __FUNCTION__, __LINE__); + if (unlikely(!count)) { - printk("acc trace %s:%d\n", __FUNCTION__, __LINE__); DEBUG_PRINT("Count = 0, return"); return count; } @@ -1017,7 +1016,6 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, * from this host, but not from other I2C masters. */ mutex_lock(&data->update_lock); - printk("acc trace %s:%d, off=0x%x,data->client->addr=0x%x\n", __FUNCTION__, __LINE__, off,data->client->addr); while (count) { ssize_t status; @@ -1026,7 +1024,6 @@ static ssize_t sfp_port_read(struct sfp_port_data *data, if (retval == 0) { retval = status; } - printk("acc trace %s:%d\n", __FUNCTION__, __LINE__); break; } @@ -1049,13 +1046,10 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj, struct sfp_port_data *data; DEBUG_PRINT("offset = (%d), count = (%d)", off, count); data = dev_get_drvdata(container_of(kobj, struct device, kobj)); - printk("acc trace %s:%d, data->port=%d\n", __FUNCTION__, __LINE__, data->port); - printk("offset = (%d), count = (%d)", off, count); present = sfp_is_port_present(data->client, data->port); if (IS_ERR_VALUE(present)) { return present; } - printk("Acc trace %s:%d, present=%d\n", __FUNCTION__, __LINE__, present); if (present == 0) { /* port is not present */ return -ENODEV; @@ -1331,11 +1325,6 @@ static struct i2c_driver sfp_driver = { static int __init csp9250_sfp_init(void) { - //extern int platform_accton_csp9250(void); - //if(!platform_accton_csp9250()) { - // return -ENODEV; - //} - printk("Acc trace %s\n", __FUNCTION__); return i2c_add_driver(&sfp_driver); } diff --git a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/platform-config/r0/src/lib/x86-64-accton-csp9250-r0.yml b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/platform-config/r0/src/lib/x86-64-accton-csp9250-r0.yml index 8425af5c..5ff7bf95 100755 --- a/packages/platforms/accton/x86-64/x86-64-accton-csp9250/platform-config/r0/src/lib/x86-64-accton-csp9250-r0.yml +++ b/packages/platforms/accton/x86-64/x86-64-accton-csp9250/platform-config/r0/src/lib/x86-64-accton-csp9250-r0.yml @@ -12,7 +12,7 @@ x86-64-accton-csp9250-r0: serial: >- console=tty0 kernel: - <<: *kernel-3-16 + <<: *kernel-4-14 args: >- console=tty0, From b0553f7e0c561ab0411aef15aaf18838c9c6f138 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 29 Aug 2018 18:27:36 +0000 Subject: [PATCH 32/32] Initialize the SFP bitmap in presence_bitmap_get(). --- packages/base/any/onlp/src/onlp/module/src/sfp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/base/any/onlp/src/onlp/module/src/sfp.c b/packages/base/any/onlp/src/onlp/module/src/sfp.c index de7c64ff..33c176ca 100644 --- a/packages/base/any/onlp/src/onlp/module/src/sfp.c +++ b/packages/base/any/onlp/src/onlp/module/src/sfp.c @@ -110,6 +110,7 @@ ONLP_LOCKED_API1(onlp_sfp_is_present, int, port); static int onlp_sfp_presence_bitmap_get_locked__(onlp_sfp_bitmap_t* dst) { + onlp_sfp_bitmap_t_init(dst); int rv = onlp_sfpi_presence_bitmap_get(dst); if(rv == ONLP_STATUS_E_UNSUPPORTED) {