From: Zijie Pan <zijie.pan@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 5/5] net/i40e: add module EEPROM callbacks for i40e
Date: Mon, 12 Mar 2018 05:17:23 +0100 [thread overview]
Message-ID: <1520828243-25191-6-git-send-email-zijie.pan@6wind.com> (raw)
In-Reply-To: <1520828243-25191-1-git-send-email-zijie.pan@6wind.com>
Add new callbacks for eth_dev_ops of i40e to get the information
and data of plugin module eeprom.
Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
---
drivers/net/i40e/i40e_ethdev.c | 141 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 141 insertions(+)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 508b417..6f09fc9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -369,6 +369,11 @@ static int i40e_get_regs(struct rte_eth_dev *dev,
static int i40e_get_eeprom(struct rte_eth_dev *dev,
struct rte_dev_eeprom_info *eeprom);
+static int i40e_get_module_info(struct rte_eth_dev *dev,
+ struct rte_dev_module_info *modinfo);
+static int i40e_get_module_eeprom(struct rte_eth_dev *dev,
+ struct rte_dev_eeprom_info *info);
+
static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
struct ether_addr *mac_addr);
@@ -489,6 +494,8 @@ static int i40e_sw_tunnel_filter_insert(struct i40e_pf *pf,
.get_reg = i40e_get_regs,
.get_eeprom_length = i40e_get_eeprom_length,
.get_eeprom = i40e_get_eeprom,
+ .get_module_info = i40e_get_module_info,
+ .get_module_eeprom = i40e_get_module_eeprom,
.mac_addr_set = i40e_set_default_mac_addr,
.mtu_set = i40e_dev_mtu_set,
.tm_ops_get = i40e_tm_ops_get,
@@ -11249,6 +11256,140 @@ static int i40e_get_eeprom(struct rte_eth_dev *dev,
return 0;
}
+static int i40e_get_module_info(struct rte_eth_dev *dev,
+ struct rte_dev_module_info *modinfo)
+{
+ struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ uint32_t sff8472_comp = 0;
+ uint32_t sff8472_swap = 0;
+ uint32_t sff8636_rev = 0;
+ i40e_status status;
+ uint32_t type = 0;
+
+ /* Check if firmware supports reading module EEPROM. */
+ if (!(hw->flags & I40E_HW_FLAG_AQ_PHY_ACCESS_CAPABLE)) {
+ PMD_DRV_LOG(ERR, "Module EEPROM memory read not supported. Please update the NVM image.\n");
+ return -EINVAL;
+ }
+
+ status = i40e_update_link_info(hw);
+ if (status)
+ return -EIO;
+
+ if (hw->phy.link_info.phy_type == I40E_PHY_TYPE_EMPTY) {
+ PMD_DRV_LOG(ERR, "Cannot read module EEPROM memory. No module connected.\n");
+ return -EINVAL;
+ }
+
+ type = hw->phy.link_info.module_type[0];
+
+ switch (type) {
+ case I40E_MODULE_TYPE_SFP:
+ status = i40e_aq_get_phy_register(hw,
+ I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE,
+ I40E_I2C_EEPROM_DEV_ADDR,
+ I40E_MODULE_SFF_8472_COMP,
+ &sff8472_comp, NULL);
+ if (status)
+ return -EIO;
+
+ status = i40e_aq_get_phy_register(hw,
+ I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE,
+ I40E_I2C_EEPROM_DEV_ADDR,
+ I40E_MODULE_SFF_8472_SWAP,
+ &sff8472_swap, NULL);
+ if (status)
+ return -EIO;
+
+ /* Check if the module requires address swap to access
+ * the other EEPROM memory page.
+ */
+ if (sff8472_swap & I40E_MODULE_SFF_ADDR_MODE) {
+ PMD_DRV_LOG(WARNING, "Module address swap to access page 0xA2 is not supported.\n");
+ modinfo->type = ETH_MODULE_SFF_8079;
+ modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
+ } else if (sff8472_comp == 0x00) {
+ /* Module is not SFF-8472 compliant */
+ modinfo->type = ETH_MODULE_SFF_8079;
+ modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
+ } else {
+ modinfo->type = ETH_MODULE_SFF_8472;
+ modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
+ }
+ break;
+ case I40E_MODULE_TYPE_QSFP_PLUS:
+ /* Read from memory page 0. */
+ status = i40e_aq_get_phy_register(hw,
+ I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE,
+ 0,
+ I40E_MODULE_REVISION_ADDR,
+ &sff8636_rev, NULL);
+ if (status)
+ return -EIO;
+ /* Determine revision compliance byte */
+ if (sff8636_rev > 0x02) {
+ /* Module is SFF-8636 compliant */
+ modinfo->type = ETH_MODULE_SFF_8636;
+ modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN;
+ } else {
+ modinfo->type = ETH_MODULE_SFF_8436;
+ modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN;
+ }
+ break;
+ case I40E_MODULE_TYPE_QSFP28:
+ modinfo->type = ETH_MODULE_SFF_8636;
+ modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN;
+ break;
+ default:
+ PMD_DRV_LOG(ERR, "Module type unrecognized\n");
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int i40e_get_module_eeprom(struct rte_eth_dev *dev,
+ struct rte_dev_eeprom_info *info)
+{
+ struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ bool is_sfp = false;
+ i40e_status status;
+ uint8_t *data = info->data;
+ uint32_t value = 0;
+ uint32_t i;
+
+ if (!info || !info->length || !data)
+ return -EINVAL;
+
+ if (hw->phy.link_info.module_type[0] == I40E_MODULE_TYPE_SFP)
+ is_sfp = true;
+
+ for (i = 0; i < info->length; i++) {
+ u32 offset = i + info->offset;
+ u32 addr = is_sfp ? I40E_I2C_EEPROM_DEV_ADDR : 0;
+
+ /* Check if we need to access the other memory page */
+ if (is_sfp) {
+ if (offset >= ETH_MODULE_SFF_8079_LEN) {
+ offset -= ETH_MODULE_SFF_8079_LEN;
+ addr = I40E_I2C_EEPROM_DEV_ADDR2;
+ }
+ } else {
+ while (offset >= ETH_MODULE_SFF_8436_LEN) {
+ /* Compute memory page number and offset. */
+ offset -= ETH_MODULE_SFF_8436_LEN / 2;
+ addr++;
+ }
+ }
+ status = i40e_aq_get_phy_register(hw,
+ I40E_AQ_PHY_REG_ACCESS_EXTERNAL_MODULE,
+ addr, offset, &value, NULL);
+ if (status)
+ return -EIO;
+ data[i] = (uint8_t)value;
+ }
+ return 0;
+}
+
static void i40e_set_default_mac_addr(struct rte_eth_dev *dev,
struct ether_addr *mac_addr)
{
--
1.7.10.4
next prev parent reply other threads:[~2018-03-12 4:18 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 4:17 [dpdk-dev] [PATCH 0/5] Patches to get the information and data of EEPROM Zijie Pan
2018-03-12 4:17 ` [dpdk-dev] [PATCH 1/5] ethdev: add access to eeprom Zijie Pan
2018-03-13 14:51 ` Remy Horton
2018-03-16 9:38 ` [dpdk-dev] [PATCH v2 " Zijie Pan
2018-03-16 9:59 ` Remy Horton
2018-03-12 4:17 ` [dpdk-dev] [PATCH 2/5] examples/ethtool: add a new command module-eeprom Zijie Pan
2018-03-13 14:46 ` Remy Horton
2018-03-16 9:41 ` [dpdk-dev] [PATCH v2 " Zijie Pan
2018-03-16 9:59 ` Remy Horton
2018-03-12 4:17 ` [dpdk-dev] [PATCH 3/5] net/ixgbe: add module EEPROM callbacks for ixgbe Zijie Pan
2018-03-13 14:46 ` Remy Horton
2018-03-16 9:42 ` [dpdk-dev] [PATCH v2 " Zijie Pan
2018-03-16 10:08 ` Remy Horton
2018-03-12 4:17 ` [dpdk-dev] [PATCH 4/5] net/e1000: add module EEPROM callbacks for e1000 Zijie Pan
2018-03-16 9:42 ` [dpdk-dev] [PATCH v2 " Zijie Pan
2018-03-12 4:17 ` Zijie Pan [this message]
2018-03-16 9:42 ` [dpdk-dev] [PATCH v2 5/5] net/i40e: add module EEPROM callbacks for i40e Zijie Pan
2018-03-13 15:19 ` [dpdk-dev] [PATCH 0/5] Patches to get the information and data of EEPROM Remy Horton
2018-03-16 9:36 ` [dpdk-dev] [PATCH v2 0/5] " Zijie Pan
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 " Zijie Pan
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 1/5] ethdev: add access to eeprom Zijie Pan
2018-04-19 13:34 ` Ferruh Yigit
2018-04-22 21:13 ` Thomas Monjalon
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 2/5] examples/ethtool: add a new command module-eeprom Zijie Pan
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 3/5] net/ixgbe: add module EEPROM callbacks for ixgbe Zijie Pan
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 4/5] net/e1000: add module EEPROM callbacks for e1000 Zijie Pan
2018-03-21 11:06 ` [dpdk-dev] [PATCH v3 5/5] net/i40e: add module EEPROM callbacks for i40e Zijie Pan
2018-04-19 13:36 ` [dpdk-dev] [PATCH v3 0/5] get the information and data of EEPROM Ferruh Yigit
2018-04-19 14:17 ` Remy Horton
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 " Zijie Pan
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 1/5] ethdev: add access to eeprom Zijie Pan
2018-04-24 10:25 ` Thomas Monjalon
2018-04-25 8:21 ` Zijie Pan
2018-04-25 8:31 ` Thomas Monjalon
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 2/5] examples/ethtool: add a new command module-eeprom Zijie Pan
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 3/5] net/ixgbe: add module EEPROM callbacks for ixgbe Zijie Pan
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 4/5] net/e1000: add module EEPROM callbacks for e1000 Zijie Pan
2018-04-24 10:17 ` [dpdk-dev] [PATCH v4 5/5] net/i40e: add module EEPROM callbacks for i40e Zijie Pan
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=1520828243-25191-6-git-send-email-zijie.pan@6wind.com \
--to=zijie.pan@6wind.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).