Netdev List
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, idosch@mellanox.com,
	arkadis@mellanox.com, mlxsw@mellanox.com
Subject: Re: [patch net-next 2/2] mlxsw: spectrum: Add support for access cable info via ethtool
Date: Wed, 26 Jul 2017 16:18:33 +0200	[thread overview]
Message-ID: <20170726141833.GB12049@lunn.ch> (raw)
In-Reply-To: <20170614072740.1243-3-jiri@resnulli.us>

> +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

  reply	other threads:[~2017-07-26 14:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14  7:27 [patch net-next 0/2] mlxsw: Add support for cable info access Jiri Pirko
2017-06-14  7:27 ` [patch net-next 1/2] mlxsw: reg: Add MCIA register " Jiri Pirko
2017-06-14  7:27 ` [patch net-next 2/2] mlxsw: spectrum: Add support for access cable info via ethtool Jiri Pirko
2017-07-26 14:18   ` Andrew Lunn [this message]
2017-07-27  8:28     ` Arkadi Sharshevsky
2017-06-14 19:19 ` [patch net-next 0/2] mlxsw: Add support for cable info access David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170726141833.GB12049@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=arkadis@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@resnulli.us \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox