Import from ONLP Repository.

This commit is contained in:
Jeffrey Townsend
2016-05-17 12:46:58 -07:00
committed by Carl D. Roth
parent c568351d91
commit 711fbacd65
23 changed files with 2050 additions and 1282 deletions

View File

@@ -111,6 +111,7 @@ sfp_control: &sfp_control
- RX_LOS
- TX_FAULT
- TX_DISABLE
- TX_DISABLE_CHANNEL
- LP_MODE
- POWER_OVERRIDE
@@ -253,6 +254,7 @@ definitions:
- RX_LOS
- TX_FAULT
- TX_DISABLE
- TX_DISABLE_CHANNEL
- LP_MODE
- POWER_OVERRIDE
onlp_sfp_control_flag:

View File

@@ -130,6 +130,11 @@ int onlp_sysi_oids_get(onlp_oid_t* table, int max);
int onlp_sysi_ioctl(int code, va_list vargs);
/**
* @brief Platform management initialization.
*/
int onlp_sysi_platform_manage_init(void);
/**
* @brief Perform necessary platform fan management.
* @note This function should automatically adjust the FAN speeds

View File

@@ -39,6 +39,7 @@ typedef enum onlp_sfp_control_e {
ONLP_SFP_CONTROL_RX_LOS,
ONLP_SFP_CONTROL_TX_FAULT,
ONLP_SFP_CONTROL_TX_DISABLE,
ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL,
ONLP_SFP_CONTROL_LP_MODE,
ONLP_SFP_CONTROL_POWER_OVERRIDE,
ONLP_SFP_CONTROL_LAST = ONLP_SFP_CONTROL_POWER_OVERRIDE,
@@ -238,6 +239,7 @@ int onlp_sfp_control_flags_get(int port, uint32_t* flags);
"RX_LOS", \
"TX_FAULT", \
"TX_DISABLE", \
"TX_DISABLE_CHANNEL", \
"LP_MODE", \
"POWER_OVERRIDE", \
}

View File

@@ -728,6 +728,7 @@ aim_map_si_t onlp_sfp_control_map[] =
{ "RX_LOS", ONLP_SFP_CONTROL_RX_LOS },
{ "TX_FAULT", ONLP_SFP_CONTROL_TX_FAULT },
{ "TX_DISABLE", ONLP_SFP_CONTROL_TX_DISABLE },
{ "TX_DISABLE_CHANNEL", ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL },
{ "LP_MODE", ONLP_SFP_CONTROL_LP_MODE },
{ "POWER_OVERRIDE", ONLP_SFP_CONTROL_POWER_OVERRIDE },
{ NULL, 0 }
@@ -740,6 +741,7 @@ aim_map_si_t onlp_sfp_control_desc_map[] =
{ "None", ONLP_SFP_CONTROL_RX_LOS },
{ "None", ONLP_SFP_CONTROL_TX_FAULT },
{ "None", ONLP_SFP_CONTROL_TX_DISABLE },
{ "None", ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL },
{ "None", ONLP_SFP_CONTROL_LP_MODE },
{ "None", ONLP_SFP_CONTROL_POWER_OVERRIDE },
{ NULL, 0 }

View File

@@ -28,6 +28,7 @@
#include <onlp/sys.h>
#include <onlp/sfp.h>
#include <sff/sff.h>
#include <sff/sff_db.h>
#include <AIM/aim_log_handler.h>
#include <syslog.h>
@@ -38,7 +39,7 @@ static void platform_manager_daemon__(const char* pidfile, char** argv);
* This should be moved to common.
*/
static void
show_inventory__(aim_pvs_t* pvs)
show_inventory__(aim_pvs_t* pvs, int database)
{
int port;
onlp_sfp_bitmap_t bitmap;
@@ -50,8 +51,10 @@ show_inventory__(aim_pvs_t* pvs)
aim_printf(pvs, "No SFPs on this platform.\n");
}
else {
if(!database) {
aim_printf(pvs, "Port Type Media Status Len Vendor Model S/N \n");
aim_printf(pvs, "---- -------------- ------ ------ ----- ---------------- ---------------- ----------------\n");
}
AIM_BITMAP_ITER(&bitmap, port) {
int rv;
@@ -60,7 +63,9 @@ show_inventory__(aim_pvs_t* pvs)
rv = onlp_sfp_is_present(port);
if(rv == 0) {
if(!database) {
aim_printf(pvs, "%4d NONE\n", port);
}
continue;
}
@@ -76,17 +81,21 @@ show_inventory__(aim_pvs_t* pvs)
continue;
}
sff_info_t sff;
sff_eeprom_t sff;
char status_str[32] = {0};
sff_info_init(&sff, data);
sff_eeprom_parse(&sff, data);
if(!sff.supported) {
if(!sff.identified) {
/* Present but unidentified. */
aim_printf(pvs, "%13d UNK\n", port);
continue;
}
if(database) {
sff_db_entry_struct(&sff, &aim_pvs_stdout);
continue;
}
uint32_t status = 0;
char* cp = status_str;
@@ -105,13 +114,13 @@ show_inventory__(aim_pvs_t* pvs)
}
aim_printf(pvs, "%4d %-14s %-6s %-6.6s %-5.5s %-16.16s %-16.16s %16.16s\n",
port,
sff.module_type_name,
sff.media_type_name,
sff.info.module_type_name,
sff.info.media_type_name,
status_str,
sff.length_desc,
sff.vendor,
sff.model,
sff.serial);
sff.info.length_desc,
sff.info.vendor,
sff.info.model,
sff.info.serial);
}
}
}
@@ -170,6 +179,7 @@ onlpdump_main(int argc, char* argv[])
int S = 0;
int l = 0;
int M = 0;
int b = 0;
char* pidfile = NULL;
const char* O = NULL;
const char* t = NULL;
@@ -182,7 +192,7 @@ onlpdump_main(int argc, char* argv[])
return onlp_sys_debug(&aim_pvs_stdout, argc-2, argv+2);
}
while( (c = getopt(argc, argv, "srehdojmyM:ipxlSt:O:")) != -1) {
while( (c = getopt(argc, argv, "srehdojmyM:ipxlSt:O:b")) != -1) {
switch(c)
{
case 's': show=1; break;
@@ -201,6 +211,7 @@ onlpdump_main(int argc, char* argv[])
case 'O': O = optarg; break;
case 'S': S=1; break;
case 'l': l=1; break;
case 'b': b=1; break;
case 'y': show=1; showflags |= ONLP_OID_SHOW_F_YAML; break;
default: help=1; rv = 1; break;
}
@@ -223,6 +234,7 @@ onlpdump_main(int argc, char* argv[])
printf(" -t <file> Decode TlvInfo data.\n");
printf(" -O <oid> Dump OID.\n");
printf(" -S Decode SFP Inventory\n");
printf(" -b Decode SFP Inventory into SFF database entries.\n");
printf(" -l API Lock test.\n");
return rv;
}
@@ -262,7 +274,7 @@ onlpdump_main(int argc, char* argv[])
}
if(S) {
show_inventory__(&aim_pvs_stdout);
show_inventory__(&aim_pvs_stdout, b);
return 0;
}

View File

@@ -27,12 +27,36 @@
#include "onlp_log.h"
#include <onlplib/shlocks.h>
#include <onlp/oids.h>
static int
onlp_aim_ts__onlp_oid(aim_datatype_context_t* dtc, aim_va_list_t* vargs,
const char** rv)
{
onlp_oid_t oid = va_arg(vargs->val, onlp_oid_t);
int id = ONLP_OID_ID_GET(oid);
switch(ONLP_OID_TYPE_GET(oid))
{
#define ONLP_OID_TYPE_ENTRY(_name, _value) \
case ONLP_OID_TYPE_##_name: \
*rv = aim_fstrdup("%s:%d", #_name, id); \
break;
#include <onlp/onlp.x>
}
return AIM_DATATYPE_OK;
}
static int
datatypes_init__(void)
{
#define ONLP_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL);
#include <onlp/onlp.x>
aim_datatype_register(0, "onlp_oid",
"ONLP OID",
NULL,
onlp_aim_ts__onlp_oid, NULL);
/*

View File

@@ -134,6 +134,7 @@ onlp_sys_platform_manage_init(void)
int i;
uint64_t now = os_time_monotonic();
onlp_sysi_platform_manage_init();
control__.tw = timer_wheel_create(4, 512, now);
for(i = 0; i < AIM_ARRAYSIZE(management_entries); i++) {

View File

@@ -65,6 +65,7 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_oids_get(onlp_oid_t* table, int max));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_platform_info_get(onlp_platform_info_t* pi));
__ONLP_DEFAULTI_VIMPLEMENTATION(onlp_sysi_platform_info_free(onlp_platform_info_t* pi));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_ioctl(int id, va_list vargs));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_platform_manage_init(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_platform_manage_fans(void));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sysi_platform_manage_leds(void));

View File

@@ -3,12 +3,12 @@
#
# Inclusive Makefile for the onlp_platform_defaults module.
#
# Autogenerated 2016-03-23 18:28:25.688419
# Autogenerated 2016-05-17 17:43:05.660985
#
###############################################################################
onlp_platform_defaults_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(onlp_platform_defaults_BASEDIR)/module/make.mk
include $(onlp_platform_defaults_BASEDIR)/module/auto/make.mk
include $(onlp_platform_defaults_BASEDIR)/module/src/make.mk
include $(onlp_platform_defaults_BASEDIR)/utest/_make.mk
include $(onlp_platform_defaults_BASEDIR)module/make.mk
include $(onlp_platform_defaults_BASEDIR)module/auto/make.mk
include $(onlp_platform_defaults_BASEDIR)module/src/make.mk
include $(onlp_platform_defaults_BASEDIR)utest/_make.mk

View File

@@ -0,0 +1,36 @@
/**************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
**************************************************************
*
* Common thermal support routines.
*
************************************************************/
#ifndef __ONLPLIB_THERMAL_H__
#define __ONLPLIB_THERMAL_H__
#include <onlplib/onlplib_config.h>
#include <onlp/thermal.h>
/**
* @brief Read the mcelsius value from the given file.
* @param fname Filename
* @param info Thermal info structure.
*/
int onlplib_thermal_read_file(const char* fname, onlp_thermal_info_t* info);
#endif /* __ONLPLIB_THERMAL_H__ */

View File

@@ -0,0 +1,51 @@
/**************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
**************************************************************
*
* Common thermal support routines.
*
************************************************************/
#include <onlplib/thermal.h>
#include <onlplib/file.h>
#include <onlp/thermal.h>
int
onlplib_thermal_read_file(const char* fname, onlp_thermal_info_t* info)
{
int ret;
int rv = onlp_file_read_int(&info->mcelsius, fname);
if(rv == ONLP_STATUS_E_MISSING) {
/* Absent */
info->status = 0;
ret = 0;
}
else if(rv >= 0) {
/* Present */
info->status |= 1;
ret = 0;
}
else {
/** Other error. */
ret = ONLP_STATUS_E_INTERNAL;
}
return ret;
}

View File

@@ -3,12 +3,12 @@
#
# Inclusive Makefile for the onlplib module.
#
# Autogenerated 2016-03-23 18:28:25.806397
# Autogenerated 2016-05-17 17:43:05.779760
#
###############################################################################
onlplib_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(onlplib_BASEDIR)/module/make.mk
include $(onlplib_BASEDIR)/module/auto/make.mk
include $(onlplib_BASEDIR)/module/src/make.mk
include $(onlplib_BASEDIR)/utest/_make.mk
include $(onlplib_BASEDIR)module/make.mk
include $(onlplib_BASEDIR)module/auto/make.mk
include $(onlplib_BASEDIR)module/src/make.mk
include $(onlplib_BASEDIR)utest/_make.mk

View File

@@ -32,6 +32,9 @@ cdefs: &cdefs
- 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:
@@ -56,6 +59,8 @@ sff_module_types: &sff_module_types
desc: "40GBASE-SR4"
- 40G_BASE_LR4:
desc: "40GBASE-LR4"
- 40G_BASE_LM4:
desc: "40GBASE-LM4"
- 40G_BASE_ACTIVE:
desc: "40GBASE-ACTIVE"
- 40G_BASE_CR:

View File

@@ -224,6 +224,8 @@
#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)
@@ -255,6 +257,18 @@ _sff8436_qsfp_40g_pre(const uint8_t* idprom)
return 0;
}
static inline int
_sff8436_qsfp_40g_lm4(const uint8_t* idprom)
{
if(!SFF8436_MODULE_QSFP_PLUS_V2(idprom)) {
return 0;
}
/* Restrict to Finisar FTL4C3QE1C at this point. */
if(strncmp("FTL4C3QE1C ", (char*)idprom+168, 16)) {
return 0;
}
return SFF8436_MEDIA_NONE(idprom);
}
static inline int
_sff8436_bitrate(const uint8_t *idprom)

View File

@@ -1,21 +1,21 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
*
* </bsn.cl>
************************************************************
*
@@ -103,6 +103,7 @@ typedef enum sff_module_type_e {
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,
@@ -137,6 +138,7 @@ typedef enum sff_module_type_e {
"40G_BASE_CR4", \
"40G_BASE_SR4", \
"40G_BASE_LR4", \
"40G_BASE_LM4", \
"40G_BASE_ACTIVE", \
"40G_BASE_CR", \
"40G_BASE_SR2", \
@@ -228,7 +230,7 @@ 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(const uint8_t* idprom);
sff_media_type_t sff_media_type_get(sff_module_type_t mt);
/**
@@ -238,45 +240,35 @@ sff_media_type_t sff_media_type_get(const uint8_t* idprom);
* @returns 0 on successful parse.
* @returns < 0 on error.
*/
int sff_module_caps_get(const uint8_t* idprom, uint32_t* caps);
int sff_module_caps_get(sff_module_type_t mt, uint32_t* caps);
/**
* Display a summary of the given SFF module.
* @param idprom The idprom data
* @param pvs The output pvs.
*/
void sff_module_show(const uint8_t* idprom, aim_pvs_t* pvs);
/**
* SFF Module Information Structure
*/
typedef struct sff_info_s {
/** Raw eeprom data */
uint8_t eeprom[256];
/** 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;
@@ -286,15 +278,26 @@ typedef struct sff_info_s {
/** Cable length, if available */
int length;
char length_desc[16];
} sff_info_t;
/** computed checksums for idprom contents */
/**
* 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 SFP is supported */
int supported;
/** Whether this EEPROM was successfully parsed and identified. */
int identified;
} sff_info_t;
/** Parsed SFF Information */
sff_info_t info;
} sff_eeprom_t;
/**
@@ -305,14 +308,28 @@ typedef struct sff_info_s {
* @note if eeprom is NULL it is assumed the rv->eeprom buffer
* has already been initialized.
*/
int sff_info_init(sff_info_t* rv, uint8_t* eeprom);
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_info_init_file(sff_info_t* rv, const char* fname);
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.
@@ -322,18 +339,12 @@ int sff_info_init_file(sff_info_t* rv, const char* fname);
void sff_info_show(sff_info_t* info, aim_pvs_t* pvs);
/**
* @brief Invalidate an idprom data structure,
* such that any resulting sff_info_init will fail.
* @param eeprom The idprom buffer (256 bytes).
* @brief Populate an SFF info structure from a module type.
*/
void sff_info_invalidate(sff_info_t *info);
int sff_info_from_module_type(sff_info_t* info,
sff_sfp_type_t st,
sff_module_type_t mt);
/**
* @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_info_valid(sff_info_t *info, int verbose);
#endif /* __SFF_SFF_H__ */

View File

@@ -109,6 +109,16 @@
#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
/**

View File

@@ -0,0 +1,60 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
* </bsn.cl>
************************************************************
*
*
*
***********************************************************/
#ifndef __SFF_DB_H__
#define __SFF_DB_H__
#include <sff/sff_config.h>
#include <sff/sff.h>
#include <AIM/aim_pvs.h>
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__ */

View File

@@ -1,21 +1,21 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
*
* Copyright 2014, 2015 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.eclipse.org/legal/epl-v10.html
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*
*
* </bsn.cl>
************************************************************
*
@@ -30,16 +30,16 @@
#include <ctype.h>
sff_sfp_type_t
sff_sfp_type_get(const uint8_t* idprom)
sff_sfp_type_get(const uint8_t* eeprom)
{
if(idprom) {
if(SFF8472_MODULE_SFP(idprom)) {
if(eeprom) {
if(SFF8472_MODULE_SFP(eeprom)) {
return SFF_SFP_TYPE_SFP;
}
if(SFF8436_MODULE_QSFP_PLUS_V2(idprom)) {
if(SFF8436_MODULE_QSFP_PLUS_V2(eeprom)) {
return SFF_SFP_TYPE_QSFP_PLUS;
}
if(SFF8636_MODULE_QSFP28(idprom)) {
if(SFF8636_MODULE_QSFP28(eeprom)) {
return SFF_SFP_TYPE_QSFP28;
}
}
@@ -47,92 +47,97 @@ sff_sfp_type_get(const uint8_t* idprom)
}
sff_module_type_t
sff_module_type_get(const uint8_t* idprom)
sff_module_type_get(const uint8_t* eeprom)
{
if (SFF8636_MODULE_QSFP28(idprom)
&& SFF8636_MEDIA_EXTENDED(idprom)
&& SFF8636_MEDIA_100GE_AOC(idprom))
if (SFF8636_MODULE_QSFP28(eeprom)
&& SFF8636_MEDIA_EXTENDED(eeprom)
&& SFF8636_MEDIA_100GE_AOC(eeprom))
return SFF_MODULE_TYPE_100G_AOC;
if (SFF8636_MODULE_QSFP28(idprom)
&& SFF8636_MEDIA_EXTENDED(idprom)
&& SFF8636_MEDIA_100GE_SR4(idprom))
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(idprom)
&& SFF8636_MEDIA_EXTENDED(idprom)
&& SFF8636_MEDIA_100GE_LR4(idprom))
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(idprom)
&& SFF8636_MEDIA_EXTENDED(idprom)
&& SFF8636_MEDIA_100GE_CR4(idprom))
if (SFF8636_MODULE_QSFP28(eeprom)
&& SFF8636_MEDIA_EXTENDED(eeprom)
&& SFF8636_MEDIA_100GE_CR4(eeprom))
return SFF_MODULE_TYPE_100G_BASE_CR4;
if (SFF8636_MODULE_QSFP28(idprom)
&& SFF8636_MEDIA_EXTENDED(idprom)
&& SFF8636_MEDIA_100GE_CWDM4(idprom))
if (SFF8636_MODULE_QSFP28(eeprom)
&& SFF8636_MEDIA_EXTENDED(eeprom)
&& SFF8636_MEDIA_100GE_CWDM4(eeprom))
return SFF_MODULE_TYPE_100G_CWDM4;
if (SFF8436_MODULE_QSFP_PLUS_V2(idprom)
&& SFF8436_MEDIA_40GE_CR4(idprom))
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(idprom)
&& SFF8436_MEDIA_40GE_SR4(idprom))
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(idprom)
&& _sff8436_qsfp_40g_sr4_aoc_pre(idprom))
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(idprom)
&& SFF8436_MEDIA_40GE_LR4(idprom))
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(idprom)
&& SFF8436_MEDIA_40GE_ACTIVE(idprom))
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(idprom)
&& _sff8436_qsfp_40g_aoc_breakout(idprom))
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(idprom)
&& SFF8436_MEDIA_40GE_CR(idprom))
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(idprom)
&& _sff8436_qsfp_40g_pre(idprom)
&& (SFF8436_TECH_FC_FIBER_LONG(idprom)
|| SFF8436_MEDIA_FC_FIBER_SM(idprom)))
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(idprom)
&& _sff8436_qsfp_40g_pre(idprom)
&& (SFF8436_TECH_FC_FIBER_SHORT(idprom)
|| SFF8436_MEDIA_FC_FIBER_MM(idprom)))
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(idprom)
&& _sff8436_qsfp_40g_sr2_bidi_pre(idprom))
if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom)
&& _sff8436_qsfp_40g_sr2_bidi_pre(eeprom))
return SFF_MODULE_TYPE_40G_BASE_SR2;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_XGE_SR(idprom)
&& !_sff8472_media_gbe_sx_fc_hack(idprom))
if (SFF8436_MODULE_QSFP_PLUS_V2(eeprom)
&& _sff8436_qsfp_40g_lm4(eeprom)) {
return SFF_MODULE_TYPE_40G_BASE_LM4;
}
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(idprom)
&& SFF8472_MEDIA_XGE_LR(idprom)
&& !_sff8472_media_gbe_lx_fc_hack(idprom))
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(idprom)
&& SFF8472_MEDIA_XGE_LRM(idprom)
&& !_sff8472_media_gbe_lx_fc_hack(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_XGE_LRM(eeprom)
&& !_sff8472_media_gbe_lx_fc_hack(eeprom))
return SFF_MODULE_TYPE_10G_BASE_LRM;
/*
@@ -141,71 +146,69 @@ sff_module_type_get(const uint8_t* idprom)
* See also _sff8472_media_cr_passive, which encodes some
* additional workarounds for these cables.
*/
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_XGE_ER(idprom)
&& !_sff8472_inf_1x_cu_active(idprom)
&& !_sff8472_inf_1x_cu_passive(idprom))
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(idprom)
&& _sff8472_media_cr_passive(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& _sff8472_media_cr_passive(eeprom))
return SFF_MODULE_TYPE_10G_BASE_CR;
if (SFF8472_MODULE_SFP(idprom)
&& _sff8472_media_cr_active(idprom)) {
if (_sff8472_sfp_10g_aoc(idprom))
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(idprom)
&& SFF8472_MEDIA_GBE_SX(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_GBE_SX(eeprom))
return SFF_MODULE_TYPE_1G_BASE_SX;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_GBE_LX(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_GBE_LX(eeprom))
return SFF_MODULE_TYPE_1G_BASE_LX;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_GBE_CX(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_GBE_CX(eeprom))
return SFF_MODULE_TYPE_1G_BASE_CX;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_GBE_T(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_GBE_T(eeprom))
return SFF_MODULE_TYPE_1G_BASE_T;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_GBE_LX(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_GBE_LX(eeprom))
return SFF_MODULE_TYPE_1G_BASE_LX;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_CBE_LX(idprom))
if (SFF8472_MODULE_SFP(eeprom)
&& SFF8472_MEDIA_CBE_LX(eeprom))
return SFF_MODULE_TYPE_100_BASE_LX;
if (SFF8472_MODULE_SFP(idprom)
&& SFF8472_MEDIA_CBE_FX(idprom))
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(idprom)
&& _sff8472_media_zr(idprom))
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(idprom)
&& _sff8472_media_srlite(idprom))
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(const uint8_t* idprom)
sff_media_type_get(sff_module_type_t mt)
{
sff_module_type_t mt = sff_module_type_get(idprom);
switch(mt)
{
case SFF_MODULE_TYPE_100G_BASE_CR4:
@@ -222,6 +225,7 @@ sff_media_type_get(const uint8_t* idprom)
case SFF_MODULE_TYPE_100G_CWDM4:
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_10G_BASE_SR:
@@ -247,14 +251,11 @@ sff_media_type_get(const uint8_t* idprom)
}
int
sff_module_caps_get(const uint8_t* idprom, uint32_t *caps)
sff_module_caps_get(sff_module_type_t mt, uint32_t *caps)
{
if (idprom == NULL)
return -1;
if (caps == NULL)
return -1;
sff_module_type_t mt = sff_module_type_get(idprom);
*caps = 0;
switch(mt)
@@ -270,6 +271,7 @@ sff_module_caps_get(const uint8_t* idprom, uint32_t *caps)
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:
@@ -305,24 +307,6 @@ sff_module_caps_get(const uint8_t* idprom, uint32_t *caps)
}
}
void
sff_module_show(const uint8_t* idprom, aim_pvs_t* pvs)
{
if (SFF8436_MODULE_QSFP_PLUS_V2(idprom) ||
SFF8636_MODULE_QSFP28(idprom)) {
aim_printf(pvs,
"%-12.12s %-16.16s %-16.16s %-16.16s\n",
sff_module_type_desc(sff_module_type_get(idprom)),
idprom+148, idprom+168, idprom+196);
} else {
aim_printf(pvs,
"%-12.12s %-16.16s %-16.16s %-16.16s\n",
sff_module_type_desc(sff_module_type_get(idprom)),
idprom+20, idprom+40, idprom+68);
}
}
static void
make_printable__(char* string)
{
@@ -342,154 +326,176 @@ make_printable__(char* string)
* @note if eeprom is NULL it is assumed the rv->eeprom buffer
* has already been initialized.
*/
int
sff_info_init(sff_info_t* rv, uint8_t* eeprom)
sff_eeprom_parse(sff_eeprom_t* se, uint8_t* eeprom)
{
if(rv == NULL) {
if(se == NULL) {
return -1;
}
rv->supported = 0;
se->identified = 0;
if(eeprom) {
SFF_MEMCPY(rv->eeprom, eeprom, 256);
SFF_MEMCPY(se->eeprom, eeprom, 256);
}
if (SFF8472_MODULE_SFP(rv->eeprom)) {
if (SFF8472_MODULE_SFP(se->eeprom)) {
/* See SFF-8472 pp22, pp28 */
int i;
for (i = 0, rv->cc_base = 0; i < 63; ++i)
rv->cc_base = (rv->cc_base + rv->eeprom[i]) & 0xFF;
for (i = 64, rv->cc_ext = 0; i < 95; ++i)
rv->cc_ext = (rv->cc_ext + rv->eeprom[i]) & 0xFF;
} else if (SFF8436_MODULE_QSFP_PLUS_V2(rv->eeprom) ||
SFF8636_MODULE_QSFP28(rv->eeprom)) {
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, rv->cc_base = 0; i < 191; ++i)
rv->cc_base = (rv->cc_base + rv->eeprom[i]) & 0xFF;
for (i = 192, rv->cc_ext = 0; i < 223; ++i)
rv->cc_ext = (rv->cc_ext + rv->eeprom[i]) & 0xFF;
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_info_valid(rv, 1)) return -1;
rv->sfp_type = sff_sfp_type_get(rv->eeprom);
if(rv->sfp_type == SFF_SFP_TYPE_INVALID) {
AIM_LOG_ERROR("sff_info_init() failed: invalid sfp type");
if (!sff_eeprom_validate(se, 1)) {
return -1;
}
rv->sfp_type_name = sff_sfp_type_desc(rv->sfp_type);
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(rv->sfp_type)
switch(se->info.sfp_type)
{
case SFF_SFP_TYPE_QSFP_PLUS:
case SFF_SFP_TYPE_QSFP28:
vendor=rv->eeprom+148;
model=rv->eeprom+168;
serial=rv->eeprom+196;
vendor=se->eeprom+148;
model=se->eeprom+168;
serial=se->eeprom+196;
break;
case SFF_SFP_TYPE_SFP:
default:
vendor=rv->eeprom+20;
model=rv->eeprom+40;
serial=rv->eeprom+68;
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(rv->vendor, (char*)vendor, sizeof(rv->vendor));
make_printable__(rv->vendor);
aim_strlcpy(se->info.vendor, (char*)vendor, sizeof(se->info.vendor));
make_printable__(se->info.vendor);
}
else {
aim_strlcpy(rv->vendor, empty, 17);
aim_strlcpy(se->info.vendor, empty, 17);
}
if (*model) {
aim_strlcpy(rv->model, (char*)model, sizeof(rv->model));
make_printable__(rv->model);
aim_strlcpy(se->info.model, (char*)model, sizeof(se->info.model));
make_printable__(se->info.model);
}
else {
aim_strlcpy(rv->model, empty, 17);
aim_strlcpy(se->info.model, empty, 17);
}
if (*serial) {
aim_strlcpy(rv->serial, (char*)serial, sizeof(rv->serial));
make_printable__(rv->serial);
aim_strlcpy(se->info.serial, (char*)serial, sizeof(se->info.serial));
make_printable__(se->info.serial);
}
else {
aim_strlcpy(rv->serial, empty, 17);
aim_strlcpy(se->info.serial, empty, 17);
}
rv->module_type = sff_module_type_get(rv->eeprom);
if(rv->module_type == SFF_MODULE_TYPE_INVALID) {
se->info.module_type = sff_module_type_get(se->eeprom);
if(se->info.module_type == SFF_MODULE_TYPE_INVALID) {
AIM_LOG_ERROR("sff_info_init() failed: invalid module type");
return -1;
}
rv->module_type_name = sff_module_type_desc(rv->module_type);
rv->media_type = sff_media_type_get(rv->eeprom);
rv->media_type_name = sff_media_type_desc(rv->media_type);
if (sff_module_caps_get(rv->eeprom, &rv->caps) < 0) {
AIM_LOG_ERROR("sff_info_init() failed: invalid module caps");
if(sff_info_from_module_type(&se->info, se->info.sfp_type,
se->info.module_type) < 0) {
return -1;
}
int aoc_length;
switch (rv->media_type) {
case SFF_MEDIA_TYPE_COPPER:
switch (rv->sfp_type) {
case SFF_SFP_TYPE_QSFP_PLUS:
case SFF_SFP_TYPE_QSFP28:
rv->length = rv->eeprom[146];
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:
se->info.length = se->eeprom[18];
break;
default:
se->info.length = -1;
break;
}
break;
case SFF_SFP_TYPE_SFP:
rv->length = rv->eeprom[18];
break;
default:
rv->length = -1;
break;
}
break;
case SFF_MEDIA_TYPE_FIBER:
switch (rv->sfp_type) {
case SFF_SFP_TYPE_QSFP28:
aoc_length = _sff8636_qsfp28_100g_aoc_length(rv->eeprom);
rv->length = aoc_length;
break;
case SFF_SFP_TYPE_QSFP_PLUS:
case SFF_SFP_TYPE_SFP:
aoc_length = _sff8436_qsfp_40g_aoc_length(rv->eeprom);
if (aoc_length < 0)
aoc_length = _sff8472_sfp_10g_aoc_length(rv->eeprom);
if (aoc_length > 0)
rv->length = aoc_length;
else
rv->length = -1;
break;
default:
rv->length = -1;
break;
}
break;
default:
rv->length = -1;
}
if(rv->length == -1) {
rv->length_desc[0] = 0;
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:
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(rv->length_desc, sizeof(rv->length_desc), "%dm", rv->length);
SFF_SNPRINTF(se->info.length_desc, sizeof(se->info.length_desc), "%dm", se->info.length);
}
rv->supported = 1;
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)
{
@@ -499,20 +505,20 @@ sff_info_show(sff_info_t* info, aim_pvs_t* pvs)
}
int
sff_info_init_file(sff_info_t* info, const char* fname)
sff_eeprom_parse_file(sff_eeprom_t* se, const char* fname)
{
int rv;
FILE* fp;
SFF_MEMSET(info, 0, sizeof(*info));
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(info->eeprom, 1, 256, fp)) > 0) {
if( (rv=sff_info_init(info, NULL)) < 0) {
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;
}
@@ -526,53 +532,53 @@ sff_info_init_file(sff_info_t* info, const char* fname)
}
void
sff_info_invalidate(sff_info_t *info)
sff_eeprom_invalidate(sff_eeprom_t *se)
{
memset(info->eeprom, 0xFF, 256);
info->cc_base = 0xFF;
info->cc_ext = 0xFF;
info->supported = 0;
memset(se->eeprom, 0xFF, 256);
se->cc_base = 0xFF;
se->cc_ext = 0xFF;
se->identified = 0;
}
int
sff_info_valid(sff_info_t *info, int verbose)
sff_eeprom_validate(sff_eeprom_t *se, int verbose)
{
if (SFF8436_MODULE_QSFP_PLUS_V2(info->eeprom) ||
SFF8636_MODULE_QSFP28(info->eeprom)) {
if (SFF8436_MODULE_QSFP_PLUS_V2(se->eeprom) ||
SFF8636_MODULE_QSFP28(se->eeprom)) {
if (info->cc_base != info->eeprom[191]) {
if (se->cc_base != se->eeprom[191]) {
if (verbose) {
AIM_LOG_ERROR("sff_info_valid() failed: invalid base QSFP checksum (0x%x should be 0x%x)",
info->eeprom[191], info->cc_base);
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 (info->cc_ext != info->eeprom[223]) {
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)",
info->eeprom[223], info->cc_ext);
se->eeprom[223], se->cc_ext);
}
return 0;
}
#endif
} else if (SFF8472_MODULE_SFP(info->eeprom)) {
} else if (SFF8472_MODULE_SFP(se->eeprom)) {
if (info->cc_base != info->eeprom[63]) {
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)",
info->eeprom[63], info->cc_base);
se->eeprom[63], se->cc_base);
}
return 0;
}
#if SFF_CONFIG_INCLUDE_EXT_CC_CHECK == 1
if (info->cc_ext != info->eeprom[95]) {
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)",
info->eeprom[95], info->cc_ext);
se->eeprom[95], se->cc_ext);
}
return 0;
}

View File

@@ -54,6 +54,11 @@ sff_config_settings_t sff_config_settings[] =
{ __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 }
};

File diff suppressed because it is too large Load Diff

View File

@@ -137,6 +137,7 @@ aim_map_si_t sff_module_type_map[] =
{ "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 },
@@ -168,6 +169,7 @@ aim_map_si_t sff_module_type_desc_map[] =
{ "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 },

View File

@@ -3,12 +3,12 @@
#
# Inclusive Makefile for the sff module.
#
# Autogenerated 2016-03-23 18:28:25.869697
# Autogenerated 2016-05-17 17:43:05.843123
#
###############################################################################
sff_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
include $(sff_BASEDIR)/module/make.mk
include $(sff_BASEDIR)/module/auto/make.mk
include $(sff_BASEDIR)/module/src/make.mk
include $(sff_BASEDIR)/utest/_make.mk
include $(sff_BASEDIR)module/make.mk
include $(sff_BASEDIR)module/auto/make.mk
include $(sff_BASEDIR)module/src/make.mk
include $(sff_BASEDIR)utest/_make.mk

File diff suppressed because it is too large Load Diff