netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: "Akeem G. Abodunrin" <akeem.g.abodunrin@intel.com>,
	netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
	"Aurélien Guillaume" <footplus@gmail.com>,
	"Ben Hutchings" <bhutchings@solarflare.com>
Subject: Re: [net-next v2 05/15] igb: Support to read and export SFF-8472/8079 data
Date: Thu, 18 Apr 2013 16:37:48 -0700	[thread overview]
Message-ID: <1366328268.2248.60.camel@jtkirshe-mobl> (raw)
In-Reply-To: <1366327822-10741-6-git-send-email-jeffrey.t.kirsher@intel.com>

[-- Attachment #1: Type: text/plain, Size: 5049 bytes --]

On Thu, 2013-04-18 at 16:30 -0700, Jeff Kirsher wrote:
> From: "Akeem G. Abodunrin" <akeem.g.abodunrin@intel.com>
> 
> This patch adds support to read and export SFF-8472/8079 (SFP data)
> over i2c, through Ethtool.
> 
> v2: Changed implementation to accommodate any offset within SFF module
>     length boundary.
> 
> Reported-by: Aurélien Guillaume <footplus@gmail.com>
> CC: Aurélien Guillaume <footplus@gmail.com>
> CC: Ben Hutchings <bhuntchings@solarflare.com>

Looks like Akeem made a typo in your email Ben.

> Signed-off-by: Akeem G Abodunrin <akeem.g.abodunrin@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  drivers/net/ethernet/intel/igb/igb.h         |  8 +++
>  drivers/net/ethernet/intel/igb/igb_ethtool.c | 81 ++++++++++++++++++++++++++++
>  2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
> index 2515140..7cb0398 100644
> --- a/drivers/net/ethernet/intel/igb/igb.h
> +++ b/drivers/net/ethernet/intel/igb/igb.h
> @@ -178,6 +178,14 @@ enum igb_tx_flags {
>  #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD)
>  #define DESC_NEEDED (MAX_SKB_FRAGS + 4)
>  
> +/* EEPROM byte offsets */
> +#define IGB_SFF_8472_SWAP		0x5C
> +#define IGB_SFF_8472_COMP		0x5E
> +
> +/* Bitmasks */
> +#define IGB_SFF_ADDRESSING_MODE		0x4
> +#define IGB_SFF_8472_UNSUP		0x00
> +
>  /* wrapper around a pointer to a socket buffer,
>   * so a DMA handle can be stored along with the buffer */
>  struct igb_tx_buffer {
> diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> index 8499c48..6afd727 100644
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
> @@ -2622,6 +2622,85 @@ static int igb_set_eee(struct net_device *netdev,
>  	return 0;
>  }
>  
> +static int igb_get_module_info(struct net_device *netdev,
> +			       struct ethtool_modinfo *modinfo)
> +{
> +	struct igb_adapter *adapter = netdev_priv(netdev);
> +	struct e1000_hw *hw = &adapter->hw;
> +	u32 status = E1000_SUCCESS;
> +	u16 sff8472_rev, addr_mode;
> +	bool page_swap = false;
> +
> +	if ((hw->phy.media_type == e1000_media_type_copper) ||
> +	    (hw->phy.media_type == e1000_media_type_unknown))
> +		return -EOPNOTSUPP;
> +
> +	/* Check whether we support SFF-8472 or not */
> +	status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_COMP, &sff8472_rev);
> +	if (status != E1000_SUCCESS)
> +		return -EIO;
> +
> +	/* addressing mode is not supported */
> +	status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_SWAP, &addr_mode);
> +	if (status != E1000_SUCCESS)
> +		return -EIO;
> +
> +	/* addressing mode is not supported */
> +	if ((addr_mode & 0xFF) & IGB_SFF_ADDRESSING_MODE) {
> +		hw_dbg("Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n");
> +		page_swap = true;
> +	}
> +
> +	if ((sff8472_rev & 0xFF) == IGB_SFF_8472_UNSUP || page_swap) {
> +		/* We have an SFP, but it does not support SFF-8472 */
> +		modinfo->type = ETH_MODULE_SFF_8079;
> +		modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
> +	} else {
> +		/* We have an SFP which supports a revision of SFF-8472 */
> +		modinfo->type = ETH_MODULE_SFF_8472;
> +		modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
> +	}
> +
> +	return 0;
> +}
> +
> +static int igb_get_module_eeprom(struct net_device *netdev,
> +				 struct ethtool_eeprom *ee, u8 *data)
> +{
> +	struct igb_adapter *adapter = netdev_priv(netdev);
> +	struct e1000_hw *hw = &adapter->hw;
> +	u32 status = E1000_SUCCESS;
> +	u16 *dataword;
> +	u16 first_word, last_word;
> +	int i = 0;
> +
> +	if (ee->len == 0)
> +		return -EINVAL;
> +
> +	first_word = ee->offset >> 1;
> +	last_word = (ee->offset + ee->len - 1) >> 1;
> +
> +	dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1),
> +			   GFP_KERNEL);
> +	if (!dataword)
> +		return -ENOMEM;
> +
> +	/* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
> +	for (i = 0; i < last_word - first_word + 1; i++) {
> +		status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]);
> +		if (status != E1000_SUCCESS)
> +			/* Error occurred while reading module */
> +			return -EIO;
> +
> +		be16_to_cpus(&dataword[i]);
> +	}
> +
> +	memcpy(data, (u8 *)dataword + (ee->offset & 1), ee->len);
> +	kfree(dataword);
> +
> +	return 0;
> +}
> +
>  static int igb_ethtool_begin(struct net_device *netdev)
>  {
>  	struct igb_adapter *adapter = netdev_priv(netdev);
> @@ -2666,6 +2745,8 @@ static const struct ethtool_ops igb_ethtool_ops = {
>  	.set_rxnfc		= igb_set_rxnfc,
>  	.get_eee		= igb_get_eee,
>  	.set_eee		= igb_set_eee,
> +	.get_module_info	= igb_get_module_info,
> +	.get_module_eeprom	= igb_get_module_eeprom,
>  	.begin			= igb_ethtool_begin,
>  	.complete		= igb_ethtool_complete,
>  };



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-04-18 23:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18 23:30 [net-next 00/15][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2013-04-18 23:30 ` [net-next 01/15] ixgbe: in shutdown, do netif_running() under rtnl_lock Jeff Kirsher
2013-04-18 23:30 ` [net-next 02/15] ixgbe: Add support for WoL on 82599 SFP+ LOM Jeff Kirsher
2013-04-18 23:30 ` [net-next 03/15] ixgbe: Remove unnecessary #ifdef CONFIG_DEBUG_FS tests Jeff Kirsher
2013-04-18 23:30 ` [net-next v2 04/15] igb: Support for 100base-fx SFP Jeff Kirsher
2013-04-18 23:30 ` [net-next v2 05/15] igb: Support to read and export SFF-8472/8079 data Jeff Kirsher
2013-04-18 23:37   ` Jeff Kirsher [this message]
2013-04-18 23:41     ` Jeff Kirsher
2013-04-19 18:20       ` David Miller
2013-04-18 23:30 ` [net-next 06/15] igb: Implement support to power sfp cage and turn on I2C Jeff Kirsher
2013-04-18 23:30 ` [net-next 07/15] igb: random code and comments fix Jeff Kirsher
2013-04-18 23:30 ` [net-next 08/15] igb: Mask off check of frag_off as we only want fragment offset Jeff Kirsher
2013-04-18 23:30 ` [net-next 09/15] igb: Pull adapter out of main path in igb_xmit_frame_ring Jeff Kirsher
2013-04-18 23:30 ` [net-next 10/15] igb: Use rx/tx_itr_setting when setting up initial value of itr Jeff Kirsher
2013-04-18 23:30 ` [net-next 11/15] igb: Fix sparse warnings on function pointers Jeff Kirsher
2013-04-18 23:30 ` [net-next 12/15] igb: Fix code comments and whitespace Jeff Kirsher
2013-04-18 23:30 ` [net-next 13/15] igb: Enable EEE LP advertisement Jeff Kirsher
2013-04-18 23:30 ` [net-next 14/15] igb: add support for spoofchk config Jeff Kirsher
2013-04-18 23:30 ` [net-next 15/15] igb: Add support for i354 devices Jeff Kirsher
2013-04-19 18:19 ` [net-next 00/15][pull request] Intel Wired LAN Driver Updates 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=1366328268.2248.60.camel@jtkirshe-mobl \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=akeem.g.abodunrin@intel.com \
    --cc=bhutchings@solarflare.com \
    --cc=footplus@gmail.com \
    --cc=gospo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).