[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170726141833.GB12049@lunn.ch>
Date: Wed, 26 Jul 2017 16:18:33 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, davem@...emloft.net, idosch@...lanox.com,
arkadis@...lanox.com, mlxsw@...lanox.com
Subject: Re: [patch net-next 2/2] mlxsw: spectrum: Add support for access
cable info via ethtool
> +static int mlxsw_sp_get_module_info(struct net_device *netdev,
> + struct ethtool_modinfo *modinfo)
> +{
> + struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(netdev);
> + u8 module_info[MLXSW_SP_EEPROM_MODULE_INFO_SIZE];
> + u8 module_rev_id, module_id;
> + unsigned int read_size;
> + int err;
> +
> + err = mlxsw_sp_query_module_eeprom(mlxsw_sp_port, 0,
> + MLXSW_SP_EEPROM_MODULE_INFO_SIZE,
> + module_info, &read_size);
> + if (err)
> + return err;
> +
> + if (read_size < MLXSW_SP_EEPROM_MODULE_INFO_SIZE)
> + return -EIO;
> +
> + module_rev_id = module_info[MLXSW_SP_EEPROM_MODULE_INFO_REV_ID];
> + module_id = module_info[MLXSW_SP_EEPROM_MODULE_INFO_ID];
> +
> + switch (module_id) {
> + case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP:
> + modinfo->type = ETH_MODULE_SFF_8436;
> + modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
> + break;
> + case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP_PLUS:
> + case MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP28:
> + if (module_id == MLXSW_SP_EEPROM_MODULE_INFO_ID_QSFP28 ||
> + module_rev_id >= MLXSW_SP_EEPROM_MODULE_INFO_REV_ID_8636) {
> + modinfo->type = ETH_MODULE_SFF_8636;
> + modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
> + } else {
> + modinfo->type = ETH_MODULE_SFF_8436;
> + modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
> + }
> + break;
> + case MLXSW_SP_EEPROM_MODULE_INFO_ID_SFP:
> + modinfo->type = ETH_MODULE_SFF_8472;
> + modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
> + break;
> + default:
> + return -EINVAL;
Hi Jiri
I remember seeing a few different implementations of this function in
various drivers. Could you pull it out into a helper, passing in the
array of bytes and mod info? bnxt, mlx4, mlx5, igb, ixgbe and sfc
could then use the helper.
Andrew
Powered by blists - more mailing lists