DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: asomalap@amd.com, dev@dpdk.org
Cc: Ravi1.Kumar@amd.com
Subject: Re: [dpdk-dev] [PATCH v1] net/axgbe: support sfp module EEPROM
Date: Thu, 9 Apr 2020 14:16:07 +0100	[thread overview]
Message-ID: <67d7272a-29fc-885f-ad8e-e865687e1267@intel.com> (raw)
In-Reply-To: <20200408070803.32051-1-asomalap@amd.com>

On 4/8/2020 8:08 AM, asomalap@amd.com wrote:
> From: Amaranath Somalapuram <Amaranath.Somalapuram@amd.com>
> 
> Adding API for get_module_eeprom and get_module_info.
> 
> Signed-off-by: Amaranath Somalapuram <Amaranath.Somalapuram@amd.com>
> ---
>  drivers/net/axgbe/axgbe_ethdev.c   |   2 +
>  drivers/net/axgbe/axgbe_phy.h      |   4 ++
>  drivers/net/axgbe/axgbe_phy_impl.c | 107 +++++++++++++++++++++++++++++
>  3 files changed, 113 insertions(+)
> 
> diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
> index 867058845..ea2f9bba1 100644
> --- a/drivers/net/axgbe/axgbe_ethdev.c
> +++ b/drivers/net/axgbe/axgbe_ethdev.c
> @@ -214,6 +214,8 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = {
>  	.dev_supported_ptypes_get     = axgbe_dev_supported_ptypes_get,
>  	.rx_descriptor_status         = axgbe_dev_rx_descriptor_status,
>  	.tx_descriptor_status         = axgbe_dev_tx_descriptor_status,
> +	.get_module_info              = axgbe_get_module_info,
> +	.get_module_eeprom            = axgbe_get_module_eeprom,

Can you please update the 'axgbe.ini', to document the "Module EEPROM dump" feature?

<...>

> @@ -141,12 +141,18 @@ enum axgbe_sfp_speed {
>  
>  #define AXGBE_SFP_EXTD_CC			31
>  
> +#define AXGBE_SFP_EEPROM_PAGE_SIZE		256
> +
>  struct axgbe_sfp_eeprom {
>  	u8 base[64];
>  	u8 extd[32];
>  	u8 vendor[32];
>  };
>  
> +struct axgbe_sfp_eeprom_module {
> +	u8 base[256];

Is there any relation between this '256' and 'AXGBE_SFP_EEPROM_PAGE_SIZE' ?

<...>

> @@ -734,6 +740,106 @@ static int axgbe_phy_sfp_read_eeprom(struct axgbe_port *pdata)
>  	return ret;
>  }
>  
> +int axgbe_get_module_info(struct rte_eth_dev *dev,
> +				struct rte_eth_dev_module_info *modinfo)
> +{
> +	struct axgbe_port *pdata = dev->data->dev_private;
> +	struct axgbe_sfp_eeprom sfp_eeprom;
> +	uint8_t eeprom_addr;
> +	int ret;
> +
> +	ret = axgbe_phy_get_comm_ownership(pdata);
> +
> +	if (ret)
> +		return -EIO;
> +
> +	ret = axgbe_phy_sfp_get_mux(pdata);
> +
> +	if (ret) {
> +		PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n");
> +		return ret;

Should here put the ownsership back, 'axgbe_phy_put_comm_ownership()', ?

> +	}
> +
> +	eeprom_addr = 0;
> +	ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_SERIAL_ID_ADDRESS,
> +			&eeprom_addr, sizeof(eeprom_addr),
> +			 &sfp_eeprom, sizeof(sfp_eeprom));
> +
> +	if (ret) {
> +		PMD_DRV_LOG(ERR, "I2C error reading SFP EEPROM\n");
> +		goto put;

In this case still returning success, shouldn't it return fail?

> +	}
> +
> +	if (sfp_eeprom.extd[AXGBE_SFP_EXTD_SFF_8472] != 0xff) {
> +		if (sfp_eeprom.extd[AXGBE_SFP_EXTD_SFF_8472] == 0) {
> +			modinfo->type = RTE_ETH_MODULE_SFF_8079;
> +			modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN;
> +		} else {
> +			modinfo->type = RTE_ETH_MODULE_SFF_8472;
> +			modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN;
> +		}
> +	}
> +
> +

Can you please remove extra empty line?

> +put:
> +	axgbe_phy_sfp_put_mux(pdata);
> +	axgbe_phy_put_comm_ownership(pdata);
> +	return 0;
> +}
> +
> +int axgbe_get_module_eeprom(struct rte_eth_dev *dev,
> +				struct rte_dev_eeprom_info *info)
> +{
> +	struct axgbe_port *pdata = dev->data->dev_private;
> +	struct axgbe_sfp_eeprom_module sfp_eeprom;
> +	uint8_t eeprom_addr;
> +	uint8_t *data;
> +	uint32_t i;
> +	int ret;
> +
> +	ret = axgbe_phy_get_comm_ownership(pdata);
> +
> +	if (ret)
> +		return -EIO;
> +
> +	if (!info || !info->length || !info->data)
> +		return -EINVAL;

What do you think doing input validation before getting ownership?

> +
> +	ret = axgbe_phy_sfp_get_mux(pdata);
> +	if (ret) {
> +		PMD_DRV_LOG(ERR, "I2C error setting SFP MUX\n");
> +		return ret;
> +	}
> +
> +	eeprom_addr = 0;
> +	ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_SERIAL_ID_ADDRESS,
> +			&eeprom_addr, sizeof(eeprom_addr),
> +			&sfp_eeprom, sizeof(sfp_eeprom));
> +	if (ret) {
> +		PMD_DRV_LOG(ERR, "I2C error reading SFP EEPROM\n");
> +		goto put;
> +	}
> +	data = info->data;
> +
> +	/* for AXGBE_SFP_SERIAL_ID_ADDRESS */
> +	for (i = 0; i < AXGBE_SFP_EEPROM_PAGE_SIZE; i++)
> +		data[i] = sfp_eeprom.base[i];
> +
> +	eeprom_addr = 0;
> +	ret = axgbe_phy_i2c_read(pdata, AXGBE_SFP_DIAG_INFO_ADDRESS,
> +			&eeprom_addr, sizeof(eeprom_addr),
> +			&sfp_eeprom, sizeof(sfp_eeprom));
> +
> +	/* for AXGBE_SFP_DIAG_INFO_ADDRESS */
> +	for (i = 0; i < info->length - AXGBE_SFP_EEPROM_PAGE_SIZE; i++)
> +		data[i + AXGBE_SFP_EEPROM_PAGE_SIZE] = sfp_eeprom.base[i];

the provided offset information (info->offset) is not used at all, is this a
limitation or forgotten?

> +
> +put:
> +	axgbe_phy_sfp_put_mux(pdata);
> +	axgbe_phy_put_comm_ownership(pdata);
> +	return 0;
> +}
> +
>  static void axgbe_phy_sfp_signals(struct axgbe_port *pdata)
>  {
>  	struct axgbe_phy_data *phy_data = pdata->phy_data;
> @@ -741,6 +847,7 @@ static void axgbe_phy_sfp_signals(struct axgbe_port *pdata)
>  	u8 gpio_reg, gpio_ports[2];
>  	int ret;
>  
> +

This looks unrelated, can you please drop from the patch.

>  	/* Read the input port registers */
>  	gpio_reg = 0;
>  	ret = axgbe_phy_i2c_read(pdata, phy_data->sfp_gpio_address,
> 


  parent reply	other threads:[~2020-04-09 13:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08  7:08 asomalap
2020-04-08  8:30 ` Somalapuram, Amaranath
2020-04-09  9:42 ` Kumar, Ravi1
2020-04-09 13:16 ` Ferruh Yigit [this message]
2020-05-14 13:43 asomalap
2020-05-14 16:35 ` Ferruh Yigit

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=67d7272a-29fc-885f-ad8e-e865687e1267@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=Ravi1.Kumar@amd.com \
    --cc=asomalap@amd.com \
    --cc=dev@dpdk.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;
as well as URLs for NNTP newsgroup(s).