[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 4 Apr 2013 20:07:51 +0100
From: Ben Hutchings <bhutchings@...arflare.com>
To: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
CC: <davem@...emloft.net>,
"Akeem G. Abodunrin" <akeem.g.abodunrin@...el.com>,
<netdev@...r.kernel.org>, <gospo@...hat.com>,
<sassmann@...hat.com>,
Aurélien Guillaume <footplus@...il.com>
Subject: Re: [net-next 05/13] igb: Support to read and export SFF-8472/8079
data
On Thu, 2013-04-04 at 04:37 -0700, Jeff Kirsher wrote:
> From: "Akeem G. Abodunrin" <akeem.g.abodunrin@...el.com>
>
> This patch adds support to read and export SFF-8472/8079 (SFP data)
> over i2c, through Ethtool.
[...]
> --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
> +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
[...]
> +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 = 0xFF;
> + int i = 0;
> +
> + /* Read the first block, SFF-8079, 2 bytes at a time */
> + for (i = 0; i < ETH_MODULE_SFF_8079_LEN; i += 2) {
> + status = igb_read_phy_reg_i2c(hw, i, &dataword);
> + if (status != E1000_SUCCESS)
> + /* Error occurred while reading module */
> + return -EIO;
> +
> + data[i] = (dataword >> 8) & 0xFF;
> + data[i+1] = dataword & 0xFF;
> + }
What if ee->offset != 0 or ee->len < ETH_MODULE_SFF_8079_LEN?
> + /* If the second block is requested, check if SFF-8472 is supported. */
> + if (ee->len == ETH_MODULE_SFF_8472_LEN) {
> + if (data[IGB_SFF_8472_COMP] == IGB_SFF_8472_UNSUP)
> + return -EOPNOTSUPP;
> +
> + /* Read the second block, SFF-8472, 2 bytes at a time */
> + for (i = ETH_MODULE_SFF_8079_LEN;
> + i < ETH_MODULE_SFF_8472_LEN; i += 2) {
> + status = igb_read_phy_reg_i2c(hw, i, &dataword);
> + if (status != E1000_SUCCESS)
> + return -EIO;
> +
> + data[i] = (dataword >> 8) & 0xFF;
> + data[i+1] = dataword & 0xFF;
> + }
> + }
[...]
What if ee->offset != 0 or ETH_MODULE_SFF_8079_LEN < ee->len <
ETH_MODULE_SFF_8472_LEN?
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists