From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 7E2228D28 for ; Wed, 25 Apr 2018 16:02:45 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id j5so7059166wme.5 for ; Wed, 25 Apr 2018 07:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LUIlxceVE5QVnRUbjwBBeO7980fciv92tmAbK5d9bnw=; b=StNGKF931HwYYVfU9VDTp6z4uPV5a36a+mzstMcHvjl5jGZ3/qt6chbaVwir+y2M4C aT6NaSIt8s50120xtLT6Zxm/nbtCtdbpxu5hWGrgsCZxS4NiioqCq5LOXrsgYJAsVfL2 yiJCPJN/PwMK+u7rtX5OxMxk3zncMlSToKfKLcLsPRTONGJLkVWD8n5UHm3HXWgbvInc 1UI6ZdADOCwRzuhNNiyz1hd/yMcenJqyWS7hyQokqbGmGdgWGWknnel7NLhJwfhNnVpr yj2vSErXb5WYiaa8me+6YJTWMjEdSz7LTSKlA9A8Jc2mT+t/CkLzcTukEtIxOD31VRd+ aEQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LUIlxceVE5QVnRUbjwBBeO7980fciv92tmAbK5d9bnw=; b=DSY0D4TH61A0HCk48GHWnD100k0ktFeC9s/UTv6P8ijzFSE2ZRXQmwJEQajSIFQ84J SeD7ZNe5D0ru9GzaebF5BfI5TzXaKBd5C6da6t8kRqQ6VUZeK7z/W2bAF1h0nbA5UNRI ot26G8YA4/jo6E7Xl+MtCc9nW/yxIKOjN5791fEoAYoqU9am0jCEvueWxumK0r9DQqK7 wKatimCAb5//1cStmKMnJF/zU6RVeYf72sCQYAl0J/yA5sI1eGtxP2Ienpk1MJLAjYvC 6TidV0fAv57rby/0+epWvglAyqbJL2vhXD7XZ8QqcYPTC6rSYA7YhlCS+p+jTl3d4bj1 0sgg== X-Gm-Message-State: ALQs6tBeyCLV81TLQTejE2vsTj6dPgM4li/P1iaE2IK6jlcEunGQrp5V Jl3Ns4XslCWEORj/uXNcD7qwJ7bAIw0= X-Google-Smtp-Source: AIpwx4/I45ldgfFswqUpDiazAhKku5XwNqBF/CUiHby0VrafX0wN0UGV15Yt/XmwPvPfjJ8tIH11Bw== X-Received: by 10.28.190.15 with SMTP id o15mr12096917wmf.104.1524664964748; Wed, 25 Apr 2018 07:02:44 -0700 (PDT) Received: from cougar.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x65sm2584552wme.31.2018.04.25.07.02.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Apr 2018 07:02:44 -0700 (PDT) From: Zijie Pan To: dev@dpdk.org Cc: remy.horton@intel.com, ferruh.yigit@intel.com, thomas@monjalon.net, beilei.xing@intel.com, qi.z.zhang@intel.com Date: Wed, 25 Apr 2018 16:02:06 +0200 Message-Id: <1524664926-938-6-git-send-email-zijie.pan@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1524664926-938-1-git-send-email-zijie.pan@6wind.com> References: <1524650515-26659-1-git-send-email-zijie.pan@6wind.com> <1524664926-938-1-git-send-email-zijie.pan@6wind.com> Subject: [dpdk-dev] [PATCH v7 5/5] net/i40e: add module EEPROM callbacks for i40e X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Apr 2018 14:02:46 -0000 Add new callbacks for eth_dev_ops of i40e to get the information and data of plugin module eeprom. Signed-off-by: Zijie Pan Acked-by: Remy Horton --- Cc: beilei.xing@intel.com Cc: qi.z.zhang@intel.com doc/guides/nics/features/i40e.ini | 1 + doc/guides/nics/features/i40e_vec.ini | 1 + drivers/net/i40e/i40e_ethdev.c | 147 +++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) diff --git a/doc/guides/nics/features/i40e.ini b/doc/guides/nics/features/i40e.ini index e862712..c9c4e4e 100644 --- a/doc/guides/nics/features/i40e.ini +++ b/doc/guides/nics/features/i40e.ini @@ -44,6 +44,7 @@ Tx descriptor status = Y Basic stats = Y Extended stats = Y FW version = Y +Module EEPROM dump = Y Multiprocess aware = Y BSD nic_uio = Y Linux UIO = Y diff --git a/doc/guides/nics/features/i40e_vec.ini b/doc/guides/nics/features/i40e_vec.ini index 7d7b3a9..c65e8b0 100644 --- a/doc/guides/nics/features/i40e_vec.ini +++ b/doc/guides/nics/features/i40e_vec.ini @@ -34,6 +34,7 @@ Rx descriptor status = Y Tx descriptor status = Y Basic stats = Y Extended stats = Y +Module EEPROM dump = Y Multiprocess aware = Y BSD nic_uio = Y Linux UIO = Y diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 180ac74..948ee89 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_eth_dev_module_info *modinfo); +static int i40e_get_module_eeprom(struct rte_eth_dev *dev, + struct rte_dev_eeprom_info *info); + static int 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, @@ -11327,6 +11334,146 @@ 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_eth_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 = RTE_ETH_MODULE_SFF_8079; + modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN; + } else if (sff8472_comp == 0x00) { + /* Module is not SFF-8472 compliant */ + 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; + } + 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 = RTE_ETH_MODULE_SFF_8636; + modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; + } else { + modinfo->type = RTE_ETH_MODULE_SFF_8436; + modinfo->eeprom_len = I40E_MODULE_QSFP_MAX_LEN; + } + break; + case I40E_MODULE_TYPE_QSFP28: + modinfo->type = RTE_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 >= RTE_ETH_MODULE_SFF_8079_LEN) { + offset -= RTE_ETH_MODULE_SFF_8079_LEN; + addr = I40E_I2C_EEPROM_DEV_ADDR2; + } + } else { + while (offset >= RTE_ETH_MODULE_SFF_8436_LEN) { + /* Compute memory page number and offset. */ + offset -= RTE_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 int i40e_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *mac_addr) { -- 1.7.10.4