mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Merge pull request #177 from zhouzi88/sfp
merge onlp_sfp_dom_read() into onlp_sfp_eeprom_read()
This commit is contained in:
@@ -67,9 +67,10 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst);
|
||||
/**
|
||||
* @brief Read the SFP EEPROM.
|
||||
* @param port The port number.
|
||||
* @param dev_addr EEPROM device address.
|
||||
* @param data Receives the SFP data.
|
||||
*/
|
||||
int onlp_sfpi_eeprom_read(int port, uint8_t data[256]);
|
||||
int onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256]);
|
||||
|
||||
/**
|
||||
* @brief Read a byte from an address on the given SFP port's bus.
|
||||
@@ -98,14 +99,6 @@ int onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr);
|
||||
*/
|
||||
int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read the SFP DOM EEPROM.
|
||||
* @param port The port number.
|
||||
* @param data Receives the SFP data.
|
||||
*/
|
||||
int onlp_sfpi_dom_read(int port, uint8_t data[256]);
|
||||
|
||||
/**
|
||||
* @brief Perform any actions required after an SFP is inserted.
|
||||
* @param port The port number.
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <AIM/aim_pvs.h>
|
||||
#include <sff/sff.h>
|
||||
|
||||
#define SFP_IDPROM_ADDR 0x50
|
||||
#define SFP_DOM_ADDR 0x51
|
||||
|
||||
/* <auto.start.enum(tag:sfp1).define> */
|
||||
/** onlp_sfp_control */
|
||||
typedef enum onlp_sfp_control_e {
|
||||
@@ -108,27 +111,15 @@ int onlp_sfp_is_present(int port);
|
||||
int onlp_sfp_presence_bitmap_get(onlp_sfp_bitmap_t* dst);
|
||||
|
||||
/**
|
||||
* @brief Read IEEE standard EEPROM data from the given port.
|
||||
* @brief Read SFP EEPROM data from the given port.
|
||||
* @param port The SFP Port
|
||||
* @param dev_addr EEPROM device address
|
||||
* @param rv Receives a buffer containing the EEPROM data.
|
||||
* @notes The buffer must be freed after use.
|
||||
* @returns The size of the eeprom data, if successful
|
||||
* @returns -1 on error.
|
||||
*/
|
||||
int onlp_sfp_eeprom_read(int port, uint8_t** rv);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read the DOM data from the given port.
|
||||
* @param port The SFP Port
|
||||
* @param rv Receives a buffer containing the DOM data.
|
||||
* @notes The buffer must be freed after use.
|
||||
* @returns The size of the eeprom data, if successful
|
||||
* @returns -1 on error.
|
||||
* @note This should only be called if the SFP
|
||||
* has advertised DOM support.
|
||||
*/
|
||||
int onlp_sfp_dom_read(int port, uint8_t** rv);
|
||||
int onlp_sfp_eeprom_read(int port, int dev_addr, uint8_t** rv);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the SFP subsystem.
|
||||
|
||||
@@ -75,7 +75,7 @@ show_inventory__(aim_pvs_t* pvs, int database)
|
||||
continue;
|
||||
}
|
||||
|
||||
rv = onlp_sfp_eeprom_read(port, &data);
|
||||
rv = onlp_sfp_eeprom_read(port, SFP_IDPROM_ADDR, &data);
|
||||
|
||||
if(rv < 0) {
|
||||
aim_printf(pvs, "%4d Error %{onlp_status}\n", port, rv);
|
||||
|
||||
@@ -139,38 +139,21 @@ onlp_sfp_port_valid(int port)
|
||||
}
|
||||
|
||||
static int
|
||||
onlp_sfp_eeprom_read_locked__(int port, uint8_t** datap)
|
||||
onlp_sfp_eeprom_read_locked__(int port, int dev_addr, uint8_t** datap)
|
||||
{
|
||||
int rv;
|
||||
uint8_t* data;
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
|
||||
data = aim_zmalloc(256);
|
||||
if((rv = onlp_sfpi_eeprom_read(port, data)) < 0) {
|
||||
if((rv = onlp_sfpi_eeprom_read(port, dev_addr, data)) < 0) {
|
||||
aim_free(data);
|
||||
data = NULL;
|
||||
}
|
||||
*datap = data;
|
||||
return rv;
|
||||
}
|
||||
ONLP_LOCKED_API2(onlp_sfp_eeprom_read, int, port, uint8_t**, rv);
|
||||
|
||||
static int
|
||||
onlp_sfp_dom_read_locked__(int port, uint8_t** datap)
|
||||
{
|
||||
int rv;
|
||||
uint8_t* data;
|
||||
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
|
||||
|
||||
data = aim_zmalloc(256);
|
||||
if((rv = onlp_sfpi_dom_read(port, data)) < 0) {
|
||||
aim_free(data);
|
||||
data = NULL;
|
||||
}
|
||||
*datap = data;
|
||||
return rv;
|
||||
}
|
||||
ONLP_LOCKED_API2(onlp_sfp_dom_read, int, port, uint8_t**, rv);
|
||||
ONLP_LOCKED_API3(onlp_sfp_eeprom_read, int, port, int, dev_addr, uint8_t**, rv);
|
||||
|
||||
void
|
||||
onlp_sfp_dump(aim_pvs_t* pvs)
|
||||
@@ -228,7 +211,7 @@ onlp_sfp_dump(aim_pvs_t* pvs)
|
||||
}
|
||||
if(rv == 1) {
|
||||
uint8_t* idprom = NULL;
|
||||
rv = onlp_sfp_eeprom_read(p, &idprom);
|
||||
rv = onlp_sfp_eeprom_read(p, SFP_IDPROM_ADDR, &idprom);
|
||||
if(rv < 0) {
|
||||
aim_printf(pvs, "Error reading eeprom: %{onlp_status}\n");
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_is_present(int port));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_eeprom_read(int port, uint8_t data[256]));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dom_read(int port, uint8_t data[256]));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256]));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_post_insert(int port, sff_info_t* sff_info));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_port_map(int port, int* rport));
|
||||
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_denit(void));
|
||||
|
||||
@@ -101,7 +101,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
* in the data buffer provided.
|
||||
*/
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
if(port == 17 || port == 19) {
|
||||
/* These ports have SFPs inserted in this example */
|
||||
|
||||
@@ -101,9 +101,9 @@ int oom_get_memory_sff(oom_port_t* port, int address, int page, int offset, int
|
||||
**/
|
||||
|
||||
if (address == 0xa0) {
|
||||
rv = onlp_sfp_eeprom_read(port_num, &idprom);
|
||||
rv = onlp_sfp_eeprom_read(port_num, SFP_IDPROM_ADDR, &idprom);
|
||||
} else if (address == 0xa2) {
|
||||
rv = onlp_sfp_dom_read(port_num, &idprom);
|
||||
rv = onlp_sfp_eeprom_read(port_num, SFP_DOM_ADDR, &idprom);
|
||||
} else {
|
||||
aim_printf(&aim_pvs_stdout, "Error invalid address: 0x%02x\n", address);
|
||||
return -EINVAL;
|
||||
|
||||
@@ -210,9 +210,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -230,20 +237,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\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)
|
||||
{
|
||||
|
||||
@@ -47,9 +47,6 @@
|
||||
#define CPLD_SFP_3_BIT_MASK 0x20
|
||||
#define CPLD_SFP_4_BIT_MASK 0x10
|
||||
|
||||
#define I2C_SLAVE_ADDRESS_SFP_EEPROM_50 0x50
|
||||
#define I2C_SLAVE_ADDRESS_SFP_EEPROM_51 0x51
|
||||
|
||||
#define I2C_SLAVE_ADDR_PCA9548 0x70
|
||||
|
||||
#define PCA9548_PORT_0_BIT_MASK 0x01
|
||||
@@ -206,20 +203,14 @@ onlp_sfpi_read_addr__(int port, int addr, unsigned char *data)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, unsigned char *data)
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, unsigned char *data)
|
||||
{
|
||||
return onlp_sfpi_read_addr__(port, I2C_SLAVE_ADDRESS_SFP_EEPROM_50,
|
||||
data);
|
||||
if ((dev_addr == SFP_IDPROM_ADDR) || (dev_addr == SFP_DOM_ADDR)) {
|
||||
return onlp_sfpi_read_addr__(port, dev_addr, data);
|
||||
}
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, unsigned char* data)
|
||||
{
|
||||
return onlp_sfpi_read_addr__(port, I2C_SLAVE_ADDRESS_SFP_EEPROM_51,
|
||||
data);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Manually enable or disable the given SFP.
|
||||
*
|
||||
|
||||
@@ -693,18 +693,14 @@ sfpi_read_addr__(int port, int addr, uint8_t data[256])
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
return sfpi_read_addr__(port, SFP_IDPROM_ADDR, data);
|
||||
if ((dev_addr == SFP_IDPROM_ADDR) || (dev_addr == SFP_DOM_ADDR)) {
|
||||
return sfpi_read_addr__(port, dev_addr, data);
|
||||
}
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
return sfpi_read_addr__(port, SFP_DOM_ADDR, data);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_sfpi_enable_set(int port, int enable)
|
||||
{
|
||||
|
||||
@@ -280,8 +280,17 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char *eeprom_path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
eeprom_path = SFP_HWMON_NODE(sfp_eeprom);
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
eeprom_path = SFP_HWMON_DOM_NODE(eeprom);
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
*
|
||||
@@ -295,34 +304,7 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (deviceNodeReadBinary(SFP_HWMON_NODE(sfp_eeprom), (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
|
||||
set_active_port(0);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
set_active_port(0);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
/*
|
||||
* Read the SFP DOM page into data[]
|
||||
*
|
||||
* Return MISSING if SFP is missing.
|
||||
* Return OK if eeprom is read
|
||||
*/
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (set_active_port(port+1) != 0) {
|
||||
AIM_LOG_ERROR("Unable to set active port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
if (deviceNodeReadBinary(SFP_HWMON_DOM_NODE(eeprom), (char*)data, 256, 256) != 0) {
|
||||
if (deviceNodeReadBinary(eeprom_path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
|
||||
set_active_port(0);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
|
||||
@@ -160,7 +160,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
|
||||
@@ -220,9 +220,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -240,20 +247,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\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)
|
||||
{
|
||||
|
||||
@@ -313,9 +313,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as5712_54x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = as5712_54x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = as5712_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -333,20 +340,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = as5712_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
|
||||
@@ -192,9 +192,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as5812_54t_sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = as5812_54t_sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = as5812_54t_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -212,20 +219,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = as5812_54t_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\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)
|
||||
{
|
||||
|
||||
@@ -313,9 +313,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as5812_54x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = as5812_54x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = as5812_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -333,20 +340,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = as5812_54x_sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (deviceNodeReadBinary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
|
||||
@@ -161,7 +161,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as6712_32x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as6812_32x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
|
||||
|
||||
@@ -195,9 +195,16 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
char* path;
|
||||
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
path = sfp_get_port_path(port, "sfp_eeprom");
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
@@ -215,20 +222,6 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
char* path = sfp_get_port_path_addr(port, 51, "sfp_eeprom");
|
||||
memset(data, 0, 256);
|
||||
|
||||
if (onlp_file_read_binary(path, (char*)data, 256, 256) != 0) {
|
||||
AIM_LOG_INFO("Unable to read eeprom from port(%d)\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)
|
||||
{
|
||||
|
||||
@@ -161,7 +161,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = as7512_32x_sfp_get_port_path(port, "sfp_eeprom");
|
||||
|
||||
|
||||
@@ -116,9 +116,9 @@ _sfp_rx_los(int port)
|
||||
//return ONLP_STATUS_E_MISSING;
|
||||
|
||||
if (port <= 48) {
|
||||
_read_sfp(port, &byte, ALL_SFP_DIAG_I2C_ADDRESS, SFP_XFP_LOS_ADDR, SFP_XFP_LOS_SIZE);
|
||||
_read_sfp(port, &byte, SFP_DOM_ADDR, SFP_XFP_LOS_ADDR, SFP_XFP_LOS_SIZE);
|
||||
} else if (port <= 54) {
|
||||
_read_sfp(port, &byte, ALL_SFP_DIAG_I2C_ADDRESS, QSFP_LOS_ADDR, SFP_XFP_LOS_SIZE);
|
||||
_read_sfp(port, &byte, SFP_DOM_ADDR, QSFP_LOS_ADDR, SFP_XFP_LOS_SIZE);
|
||||
}
|
||||
|
||||
if (SFP_LOS_MASK == (byte & SFP_LOS_MASK))
|
||||
@@ -143,9 +143,9 @@ _sfp_tx_fault(int port)
|
||||
return -1;
|
||||
|
||||
if (port <= 48) {
|
||||
_read_sfp(port, (uint8_t *)&option, ALL_SFP_DIAG_I2C_ADDRESS, SFP_OPTIONS_ADDR, SFP_OPTIONS_SIZE);
|
||||
_read_sfp(port, (uint8_t *)&option, SFP_DOM_ADDR, SFP_OPTIONS_ADDR, SFP_OPTIONS_SIZE);
|
||||
} else if (port <= 54) {
|
||||
_read_sfp(port, (uint8_t *)&option, ALL_SFP_DIAG_I2C_ADDRESS, QSFP_TX_FAULT_ADDR, SFP_OPTIONS_SIZE);
|
||||
_read_sfp(port, (uint8_t *)&option, SFP_DOM_ADDR, QSFP_TX_FAULT_ADDR, SFP_OPTIONS_SIZE);
|
||||
}
|
||||
|
||||
if (SFP_TX_FAULT_MASK & option)
|
||||
@@ -240,17 +240,21 @@ onlp_sfpi_port_map(int port, int* rport)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
if (port > CEL_REDSTONE_MAX_PORT) {
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
if ((dev_addr != SFP_IDPROM_ADDR) && (dev_addr != SFP_DOM_ADDR)) {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
if (!_get_sfp_state(port))
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
memset(data, 0, 256);
|
||||
if (_read_sfp(port, data, ALL_SFP_I2C_ADDRESS, 0, 256) == -1)
|
||||
if (_read_sfp(port, data, dev_addr, 0, 256) == -1)
|
||||
return ONLP_STATUS_OK;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
|
||||
@@ -328,8 +328,6 @@ extern aim_map_si_t cpld5_reg_desc_map[];
|
||||
/* <auto.end.enum(ALL).header> */
|
||||
|
||||
#define CEL_REDSTONE_MAX_PORT 54
|
||||
#define ALL_SFP_I2C_ADDRESS (0xA0 >> 1)
|
||||
#define ALL_SFP_DIAG_I2C_ADDRESS (0xA2 >> 1)
|
||||
#define SFP_XFP_LOS_ADDR 110
|
||||
#define SFP_XFP_LOS_SIZE 1
|
||||
#define QSFP_LOS_ADDR 3
|
||||
|
||||
@@ -61,7 +61,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
* in the data buffer provided.
|
||||
*/
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = msn2100_sfp_get_port_path(port, "");
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = msn2410_sfp_get_port_path(port, "");
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
char* path = sn2700_sfp_get_port_path(port, "");
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
* in the data buffer provided.
|
||||
*/
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
* in the data buffer provided.
|
||||
*/
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
@@ -137,15 +137,14 @@ onlp_sfpi_is_present(int port)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
}
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
@@ -155,16 +155,14 @@ onlp_sfpi_is_present(int port)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
if (dev_addr == SFP_IDPROM_ADDR){
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
}
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,16 +149,13 @@ onlp_sfpi_is_present(int port)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -184,16 +184,13 @@ onlp_sfpi_is_present(int port)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
if (dev_addr == SFP_IDPROM_ADDR){
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
} else
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -157,31 +157,30 @@ onlp_sfpi_is_present(int port)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_eeprom_read(int port, int dev_addr, uint8_t data[256])
|
||||
{
|
||||
const char * path;
|
||||
|
||||
if(port > 52){
|
||||
qsfpmap_t* qsfp = QSFP_GET(port);
|
||||
|
||||
return onlplib_sfp_eeprom_read_file(qsfp->eeprom, data);
|
||||
}
|
||||
else{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
|
||||
return onlplib_sfp_eeprom_read_file(sfp->eeprom, data);
|
||||
if (dev_addr == SFP_IDPROM_ADDR) {
|
||||
if(port > 52){
|
||||
qsfpmap_t* qsfp = QSFP_GET(port);
|
||||
path = qsfp->eeprom;
|
||||
}
|
||||
else{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
path = sfp->eeprom;
|
||||
}
|
||||
} else if (dev_addr == SFP_DOM_ADDR) {
|
||||
if(port > 52){
|
||||
qsfpmap_t* qsfp = QSFP_GET(port);
|
||||
path = qsfp->dom;
|
||||
}
|
||||
else{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
path = sfp->dom;
|
||||
}
|
||||
} else {
|
||||
return ONLP_STATUS_E_PARAM;
|
||||
}
|
||||
return onlplib_sfp_eeprom_read_file(path, data);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
{
|
||||
if(port > 52){
|
||||
qsfpmap_t* qsfp = QSFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(qsfp->dom, data);
|
||||
}
|
||||
else{
|
||||
sfpmap_t* sfp = SFP_GET(port);
|
||||
return onlplib_sfp_eeprom_read_file(sfp->dom, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user