From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52B8AA0A03; Mon, 18 Jan 2021 16:17:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30B8A140F5E; Mon, 18 Jan 2021 16:17:55 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 548E2140F5B for ; Mon, 18 Jan 2021 16:17:53 +0100 (CET) IronPort-SDR: 9DDfdJ6a3QjFdQax4o4+Fa7Pbzc5zv/badMh4Wbhe2Df3eFjwcapJ8v9P6JmVa+ONpOUfyQoPj zbaNg8qBxV3w== X-IronPort-AV: E=McAfee;i="6000,8403,9867"; a="242885585" X-IronPort-AV: E=Sophos;i="5.79,356,1602572400"; d="scan'208";a="242885585" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 07:17:49 -0800 IronPort-SDR: LR3VTo6tyK06eZiDnIpoNMdEsZwp0cSGlXz3rSolqey9jQ80Ku1YNvGlPC3O2pQJm+7bNc1ru8 R1ufXK2rN+hQ== X-IronPort-AV: E=Sophos;i="5.79,356,1602572400"; d="scan'208";a="383603381" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.241.24]) ([10.213.241.24]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2021 07:17:48 -0800 To: asomalap@amd.com, dev@dpdk.org References: <20201222070157.521188-1-asomalap@amd.com> <20210112052833.1799783-1-asomalap@amd.com> From: Ferruh Yigit Message-ID: <307ce5eb-b19d-72b3-b14d-3ffd58a56b2a@intel.com> Date: Mon, 18 Jan 2021 15:17:45 +0000 MIME-Version: 1.0 In-Reply-To: <20210112052833.1799783-1-asomalap@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v5] net/axgbe: support sfp module EEPROM X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 1/12/2021 5:28 AM, asomalap@amd.com wrote: > From: Amaranath Somalapuram > > Adding API for get_module_eeprom and get_module_info. > > Signed-off-by: Amaranath Somalapuram > --- > doc/guides/nics/features/axgbe.ini | 1 + > drivers/net/axgbe/axgbe_ethdev.c | 2 + > drivers/net/axgbe/axgbe_phy.h | 4 + > drivers/net/axgbe/axgbe_phy_impl.c | 114 +++++++++++++++++++++++++++++ > 4 files changed, 121 insertions(+) > > diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini > index 34df0d1ee..3a090183e 100644 > --- a/doc/guides/nics/features/axgbe.ini > +++ b/doc/guides/nics/features/axgbe.ini > @@ -17,6 +17,7 @@ CRC offload = Y > L3 checksum offload = Y > L4 checksum offload = Y > Basic stats = Y > +Module EEPROM dump = Y > Linux UIO = Y > x86-32 = Y > x86-64 = Y > diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c > index cfe6aba73..22e05e8cb 100644 > --- a/drivers/net/axgbe/axgbe_ethdev.c > +++ b/drivers/net/axgbe/axgbe_ethdev.c > @@ -257,6 +257,8 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { > .timesync_adjust_time = axgbe_timesync_adjust_time, > .timesync_read_time = axgbe_timesync_read_time, > .timesync_write_time = axgbe_timesync_write_time, > + .get_module_info = axgbe_get_module_info, > + .get_module_eeprom = axgbe_get_module_eeprom, > }; > > static int axgbe_phy_reset(struct axgbe_port *pdata) > diff --git a/drivers/net/axgbe/axgbe_phy.h b/drivers/net/axgbe/axgbe_phy.h > index 77ee20a31..d9d7fde41 100644 > --- a/drivers/net/axgbe/axgbe_phy.h > +++ b/drivers/net/axgbe/axgbe_phy.h > @@ -188,5 +188,9 @@ > #define DUPLEX_FULL 0x01 > #define DUPLEX_UNKNOWN 0xff > > +int axgbe_get_module_info(struct rte_eth_dev *dev, > + struct rte_eth_dev_module_info *modinfo); > +int axgbe_get_module_eeprom(struct rte_eth_dev *dev, > + struct rte_dev_eeprom_info *info); > #endif > /* PHY */ > diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c > index 02236ec19..e60f51ede 100644 > --- a/drivers/net/axgbe/axgbe_phy_impl.c > +++ b/drivers/net/axgbe/axgbe_phy_impl.c > @@ -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[AXGBE_SFP_EEPROM_PAGE_SIZE]; > +}; > + > #define AXGBE_BEL_FUSE_VENDOR "BEL-FUSE" > #define AXGBE_BEL_FUSE_PARTNO "1GBT-SFP06" > > @@ -734,6 +740,114 @@ 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"); > + goto put; > + } > + > + 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; > + } > + > + 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 { > + ret = -EIO; > + goto put; > + } > + } The issue mentioned is still valid, can you please check comment in the previous version(s). > + > +put: > + axgbe_phy_sfp_put_mux(pdata); > + axgbe_phy_put_comm_ownership(pdata); > + return ret; > +} > + > +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; > + > + if (!info || !info->length || !info->data) { > + axgbe_phy_put_comm_ownership(pdata); > + return -EINVAL; > + } > + > + 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"); > + goto put; > + } > + > + 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 */ > + if (info->length > AXGBE_SFP_EEPROM_PAGE_SIZE) > + 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 */ > + if (info->length > AXGBE_SFP_EEPROM_PAGE_SIZE) > + for (i = 0; i < info->length - AXGBE_SFP_EEPROM_PAGE_SIZE; i++) > + data[i + AXGBE_SFP_EEPROM_PAGE_SIZE] = > + sfp_eeprom.base[i]; The second page can be written partially, isn't this a problem? > + > +put: > + axgbe_phy_sfp_put_mux(pdata); > + axgbe_phy_put_comm_ownership(pdata); > + return ret; > +} > + > + > static void axgbe_phy_sfp_signals(struct axgbe_port *pdata) > { > struct axgbe_phy_data *phy_data = pdata->phy_data; >