Merge pull request #553 from zhouzi88/swl-5235

onlp_sfp_dev_read/write API
This commit is contained in:
Jeffrey Townsend
2019-04-24 13:05:33 -07:00
committed by GitHub
3 changed files with 33 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ int onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr);
int onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value);
/**
* @brief Read a byte from an address on the given SFP port's bus.
* @brief Read a word from an address on the given SFP port's bus.
* @param port The port number.
* @param devaddr The device address.
* @param addr The address.
@@ -94,10 +94,23 @@ int 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);
/**
* @brief Write a byte to an address on the given SFP port's bus.
* @brief Write a word to an address on the given SFP port's bus.
*/
int onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value);
/**
* @brief Read from an address on the given SFP port's bus.
* @param port The port number.
* @param devaddr The device address.
* @param addr The address.
* @returns The data if successful, error otherwise.
*/
int onlp_sfpi_dev_read(int port, uint8_t devaddr, uint8_t addr, uint8_t* rdata, int size);
/**
* @brief Write to an address on the given SFP port's bus.
*/
int onlp_sfpi_dev_write(int port, uint8_t devaddr, uint8_t addr, uint8_t* data, int size);
/**
* @brief Read the SFP DOM EEPROM.

View File

@@ -431,3 +431,19 @@ onlp_sfp_dev_writew_locked__(int port, uint8_t devaddr, uint8_t addr, uint16_t v
return onlp_sfpi_dev_writew(port, devaddr, addr, value);
}
ONLP_LOCKED_API4(onlp_sfp_dev_writew, int, port, uint8_t, devaddr, uint8_t, addr, uint16_t, value);
int
onlp_sfp_dev_read_locked__(int port, uint8_t devaddr, uint8_t addr, uint8_t* rdata, int size)
{
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
return onlp_sfpi_dev_read(port, devaddr, addr, rdata, size);
}
ONLP_LOCKED_API5(onlp_sfp_dev_read, int, port, uint8_t, devaddr, uint8_t, addr, uint8_t*, rdata, int, size);
int
onlp_sfp_dev_write_locked__(int port, uint8_t devaddr, uint8_t addr, uint8_t* data, int size)
{
ONLP_SFP_PORT_VALIDATE_AND_MAP(port);
return onlp_sfpi_dev_write(port, devaddr, addr, data, size);
}
ONLP_LOCKED_API5(onlp_sfp_dev_write, int, port, uint8_t, devaddr, uint8_t, addr, uint8_t*, data, int, size);

View File

@@ -44,3 +44,5 @@ __ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_readb(int port, uint8_t devaddr, ui
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_read(int port, uint8_t devaddr, uint8_t addr, uint8_t *rdata, int size));
__ONLP_DEFAULTI_IMPLEMENTATION(onlp_sfpi_dev_write(int port, uint8_t devaddr, uint8_t addr, uint8_t* data, int size));