[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <682f2f10-3f5b-eab0-a252-8cf94841c432@mellanox.com>
Date: Thu, 27 Jul 2017 11:28:26 +0300
From: Arkadi Sharshevsky <arkadis@...lanox.com>
To: Andrew Lunn <andrew@...n.ch>, Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, davem@...emloft.net, idosch@...lanox.com,
mlxsw@...lanox.com
Subject: Re: [patch net-next 2/2] mlxsw: spectrum: Add support for access
cable info via ethtool
On 07/26/2017 05:18 PM, Andrew Lunn wrote:
>> +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
>
Yeah, it seems generic for all modules, it can be moved into ethtool
I think.
Thanks,
Arkadi
Powered by blists - more mailing lists