mirror of
https://github.com/opnsense/src.git
synced 2026-02-18 18:20:26 -05:00
axgbe: Implement ifdi_i2c_req for diagnostics information
Fixes https://github.com/opnsense/src/issues/178
This commit is contained in:
parent
b9eca9d898
commit
44c9c2da5e
3 changed files with 36 additions and 30 deletions
|
|
@ -108,6 +108,7 @@ static int axgbe_if_promisc_set(if_ctx_t, int);
|
|||
static uint64_t axgbe_if_get_counter(if_ctx_t, ift_counter);
|
||||
static void axgbe_if_vlan_register(if_ctx_t, uint16_t);
|
||||
static void axgbe_if_vlan_unregister(if_ctx_t, uint16_t);
|
||||
static int axgbe_if_i2c_req(if_ctx_t, struct ifi2creq *);
|
||||
#if __FreeBSD_version >= 1300000
|
||||
static bool axgbe_if_needs_restart(if_ctx_t, enum iflib_restart_event);
|
||||
#endif
|
||||
|
|
@ -235,6 +236,7 @@ static device_method_t axgbe_if_methods[] = {
|
|||
DEVMETHOD(ifdi_get_counter, axgbe_if_get_counter),
|
||||
DEVMETHOD(ifdi_vlan_register, axgbe_if_vlan_register),
|
||||
DEVMETHOD(ifdi_vlan_unregister, axgbe_if_vlan_unregister),
|
||||
DEVMETHOD(ifdi_i2c_req, axgbe_if_i2c_req),
|
||||
#if __FreeBSD_version >= 1300000
|
||||
DEVMETHOD(ifdi_needs_restart, axgbe_if_needs_restart),
|
||||
#endif
|
||||
|
|
@ -1904,6 +1906,15 @@ axgbe_if_vlan_unregister(if_ctx_t ctx, uint16_t vtag)
|
|||
xgbe_dump_active_vlans(pdata);
|
||||
}
|
||||
|
||||
static int
|
||||
axgbe_if_i2c_req(if_ctx_t ctx, struct ifi2creq *req)
|
||||
{
|
||||
struct axgbe_if_softc *sc = iflib_get_softc(ctx);
|
||||
struct xgbe_prv_data *pdata = &sc->pdata;
|
||||
|
||||
return pdata->phy_if.phy_impl.module_eeprom(pdata, req->dev_addr, req->offset, req->data, req->len);
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 1300000
|
||||
static bool
|
||||
axgbe_if_needs_restart(if_ctx_t ctx __unused, enum iflib_restart_event event)
|
||||
|
|
|
|||
|
|
@ -1840,63 +1840,57 @@ put:
|
|||
}
|
||||
|
||||
static int
|
||||
xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata)
|
||||
xgbe_phy_module_eeprom(struct xgbe_prv_data *pdata, uint16_t dev_addr,
|
||||
uint16_t offset, uint8_t *data, uint16_t length)
|
||||
{
|
||||
struct xgbe_phy_data *phy_data = pdata->phy_data;
|
||||
uint8_t eeprom_addr, eeprom_data[XGBE_SFP_EEPROM_MAX];
|
||||
struct xgbe_sfp_eeprom *sfp_eeprom;
|
||||
uint8_t eeprom_addr;
|
||||
unsigned int target;
|
||||
int ret;
|
||||
|
||||
if (phy_data->port_mode != XGBE_PORT_MODE_SFP) {
|
||||
ret = -ENXIO;
|
||||
ret = (ENXIO);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (phy_data->sfp_mod_absent) {
|
||||
ret = -EIO;
|
||||
ret = (EIO);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if ((offset + length) > XGBE_SFP_EEPROM_MAX) {
|
||||
ret = (EINVAL);
|
||||
}
|
||||
|
||||
if (!length || length > 16) {
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
target = dev_addr == 0xA0 ? XGBE_SFP_SERIAL_ID_ADDRESS :
|
||||
XGBE_SFP_DIAG_INFO_ADDRESS;
|
||||
|
||||
ret = xgbe_phy_get_comm_ownership(pdata);
|
||||
if (ret) {
|
||||
ret = -EIO;
|
||||
ret = (EIO);
|
||||
goto done;
|
||||
}
|
||||
|
||||
ret = xgbe_phy_sfp_get_mux(pdata);
|
||||
if (ret) {
|
||||
axgbe_error("I2C error setting SFP MUX\n");
|
||||
ret = -EIO;
|
||||
ret = (EIO);
|
||||
goto put_own;
|
||||
}
|
||||
|
||||
/* Read the SFP serial ID eeprom */
|
||||
eeprom_addr = 0;
|
||||
ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_SERIAL_ID_ADDRESS,
|
||||
&eeprom_addr, sizeof(eeprom_addr),
|
||||
eeprom_data, XGBE_SFP_EEPROM_BASE_LEN);
|
||||
eeprom_addr = offset;
|
||||
ret = xgbe_phy_i2c_read(pdata, target, &eeprom_addr, sizeof(eeprom_addr),
|
||||
(void *)data, length);
|
||||
if (ret) {
|
||||
axgbe_error("I2C error reading SFP EEPROM\n");
|
||||
ret = -EIO;
|
||||
ret = (EIO);
|
||||
goto put_mux;
|
||||
}
|
||||
|
||||
sfp_eeprom = (struct xgbe_sfp_eeprom *)eeprom_data;
|
||||
|
||||
if (XGBE_SFP_DIAGS_SUPPORTED(sfp_eeprom)) {
|
||||
/* Read the SFP diagnostic eeprom */
|
||||
eeprom_addr = 0;
|
||||
ret = xgbe_phy_i2c_read(pdata, XGBE_SFP_DIAG_INFO_ADDRESS,
|
||||
&eeprom_addr, sizeof(eeprom_addr),
|
||||
eeprom_data + XGBE_SFP_EEPROM_BASE_LEN,
|
||||
XGBE_SFP_EEPROM_DIAG_LEN);
|
||||
if (ret) {
|
||||
axgbe_error("I2C error reading SFP DIAGS\n");
|
||||
ret = -EIO;
|
||||
goto put_mux;
|
||||
}
|
||||
}
|
||||
|
||||
put_mux:
|
||||
xgbe_phy_sfp_put_mux(pdata);
|
||||
|
||||
|
|
|
|||
|
|
@ -904,7 +904,8 @@ struct xgbe_phy_impl_if {
|
|||
|
||||
/* SFP module related info */
|
||||
int (*module_info)(struct xgbe_prv_data *pdata);
|
||||
int (*module_eeprom)(struct xgbe_prv_data *pdata);
|
||||
int (*module_eeprom)(struct xgbe_prv_data *pdata, uint16_t, uint16_t,
|
||||
uint8_t *, uint16_t);
|
||||
|
||||
/* Drive LED status */
|
||||
void (*toggle_led)(struct xgbe_prv_data *pdata, enum xgbe_led_mode);
|
||||
|
|
|
|||
Loading…
Reference in a new issue