mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Added onlp_sfp_dev_readb and onlp_sfp_dev_readw support
to msn2100, msn2410 and msn2700 systems V2->v1 Comments pointed out by Vadim: - remove unnecessary braces; Signed-off-by: Oleksandr Shamray <oleksandrs@mellanox.com>
This commit is contained in:
parent
845ac9878d
commit
22e351983a
@@ -68,6 +68,13 @@ msn2100_sfp_get_port_path(int port, char *node_name)
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
static char*
|
||||
msn2100_sfp_convert_i2c_path(int port, int devaddr)
|
||||
{
|
||||
sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port);
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
@@ -150,7 +157,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = msn2100_sfp_convert_i2c_path(port, devaddr);
|
||||
uint8_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 1);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 1) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -162,7 +189,27 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = msn2100_sfp_convert_i2c_path(port, devaddr);
|
||||
uint16_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 2);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 2) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -68,6 +68,13 @@ msn2410_sfp_get_port_path(int port, char *node_name)
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
static char*
|
||||
sn2410_sfp_convert_i2c_path(int port, int devaddr)
|
||||
{
|
||||
sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port);
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
@@ -153,7 +160,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = sn2410_sfp_convert_i2c_path(port, devaddr);
|
||||
uint8_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 1);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 1) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -165,7 +192,29 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = sn2410_sfp_convert_i2c_path(port, devaddr);
|
||||
uint16_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path){
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
}
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 2);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 2) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -68,6 +68,13 @@ sn2700_sfp_get_port_path(int port, char *node_name)
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
static char*
|
||||
sn2700_sfp_convert_i2c_path(int port, int devaddr)
|
||||
{
|
||||
sprintf(sfp_node_path, "/bsp/qsfp/qsfp%d", port);
|
||||
return sfp_node_path;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
@@ -153,7 +160,27 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = sn2700_sfp_convert_i2c_path(port, devaddr);
|
||||
uint8_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 1);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 1) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -165,7 +192,27 @@ onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
char* path = sn2700_sfp_convert_i2c_path(port, devaddr);
|
||||
uint16_t data;
|
||||
int fd;
|
||||
int nrd;
|
||||
|
||||
if (!path)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return ONLP_STATUS_E_MISSING;
|
||||
|
||||
lseek(fd, addr, SEEK_SET);
|
||||
nrd = read(fd, &data, 2);
|
||||
close(fd);
|
||||
|
||||
if (nrd != 2) {
|
||||
AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", path);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user