From: Zijie Pan <zijie.pan@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/5] net/e1000: add module EEPROM callbacks for e1000
Date: Mon, 12 Mar 2018 05:17:22 +0100 [thread overview]
Message-ID: <1520828243-25191-5-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 e1000 to get the information and
data of plugin module EEPROM.
Signed-off-by: Zijie Pan <zijie.pan@6wind.com>
---
drivers/net/e1000/base/e1000_phy.h | 8 ++++
drivers/net/e1000/igb_ethdev.c | 83 ++++++++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/drivers/net/e1000/base/e1000_phy.h b/drivers/net/e1000/base/e1000_phy.h
index 3e45a9e..2cd0e14 100644
--- a/drivers/net/e1000/base/e1000_phy.h
+++ b/drivers/net/e1000/base/e1000_phy.h
@@ -330,4 +330,12 @@ struct sfp_e1000_flags {
#define E1000_SFF_VENDOR_OUI_AVAGO 0x00176A00
#define E1000_SFF_VENDOR_OUI_INTEL 0x001B2100
+/* EEPROM byte offsets */
+#define IGB_SFF_8472_SWAP 0x5C
+#define IGB_SFF_8472_COMP 0x5E
+
+/* Bitmasks */
+#define IGB_SFF_ADDRESSING_MODE 0x4
+#define IGB_SFF_8472_UNSUP 0x00
+
#endif
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 3c5138d..048caaf 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -224,6 +224,10 @@ static int eth_igb_get_eeprom(struct rte_eth_dev *dev,
struct rte_dev_eeprom_info *eeprom);
static int eth_igb_set_eeprom(struct rte_eth_dev *dev,
struct rte_dev_eeprom_info *eeprom);
+static int eth_igb_get_module_info(struct rte_eth_dev *dev,
+ struct rte_dev_module_info *modinfo);
+static int eth_igb_get_module_eeprom(struct rte_eth_dev *dev,
+ struct rte_dev_eeprom_info *info);
static int eth_igb_set_mc_addr_list(struct rte_eth_dev *dev,
struct ether_addr *mc_addr_set,
uint32_t nb_mc_addr);
@@ -403,6 +407,8 @@ static void eth_igb_write_ivar(struct e1000_hw *hw, uint8_t msix_vector,
.get_eeprom_length = eth_igb_get_eeprom_length,
.get_eeprom = eth_igb_get_eeprom,
.set_eeprom = eth_igb_set_eeprom,
+ .get_module_info = eth_igb_get_module_info,
+ .get_module_eeprom = eth_igb_get_module_eeprom,
.timesync_adjust_time = igb_timesync_adjust_time,
.timesync_read_time = igb_timesync_read_time,
.timesync_write_time = igb_timesync_write_time,
@@ -5384,6 +5390,83 @@ static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on)
}
static int
+eth_igb_get_module_info(struct rte_eth_dev *dev,
+ struct rte_dev_module_info *modinfo)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ uint32_t status = 0;
+ uint16_t sff8472_rev, addr_mode;
+ bool page_swap = false;
+
+ if (hw->phy.media_type == e1000_media_type_copper ||
+ hw->phy.media_type == e1000_media_type_unknown)
+ return -EOPNOTSUPP;
+
+ /* Check whether we support SFF-8472 or not */
+ status = e1000_read_phy_reg_i2c(hw, IGB_SFF_8472_COMP, &sff8472_rev);
+ if (status)
+ return -EIO;
+
+ /* addressing mode is not supported */
+ status = e1000_read_phy_reg_i2c(hw, IGB_SFF_8472_SWAP, &addr_mode);
+ if (status)
+ return -EIO;
+
+ /* addressing mode is not supported */
+ if ((addr_mode & 0xFF) & IGB_SFF_ADDRESSING_MODE) {
+ PMD_DRV_LOG(ERR, "Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n");
+ page_swap = true;
+ }
+
+ if ((sff8472_rev & 0xFF) == IGB_SFF_8472_UNSUP || page_swap) {
+ /* We have an SFP, but it does not support SFF-8472 */
+ modinfo->type = ETH_MODULE_SFF_8079;
+ modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
+ } else {
+ /* We have an SFP which supports a revision of SFF-8472 */
+ modinfo->type = ETH_MODULE_SFF_8472;
+ modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
+ }
+
+ return 0;
+}
+
+static int
+eth_igb_get_module_eeprom(struct rte_eth_dev *dev,
+ struct rte_dev_eeprom_info *info)
+{
+ struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+ uint32_t status = 0;
+ uint16_t dataword[ETH_MODULE_SFF_8472_LEN / 2 + 1];
+ u16 first_word, last_word;
+ int i = 0;
+
+ if (info->length == 0)
+ return -EINVAL;
+
+ first_word = info->offset >> 1;
+ last_word = (info->offset + info->length - 1) >> 1;
+
+ /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
+ for (i = 0; i < last_word - first_word + 1; i++) {
+ status = e1000_read_phy_reg_i2c(hw, (first_word + i) * 2,
+ &dataword[i]);
+ if (status) {
+ /* Error occurred while reading module */
+ return -EIO;
+ }
+
+ dataword[i] = rte_be_to_cpu_16(dataword[i]);
+ }
+
+ memcpy(info->data, (u8 *)dataword + (info->offset & 1), info->length);
+
+ return 0;
+}
+
+static int
eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
{
struct e1000_hw *hw =
--
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 ` Zijie Pan [this message]
2018-03-16 9:42 ` [dpdk-dev] [PATCH v2 4/5] net/e1000: add module EEPROM callbacks for e1000 Zijie Pan
2018-03-12 4:17 ` [dpdk-dev] [PATCH 5/5] net/i40e: add module EEPROM callbacks for i40e Zijie Pan
2018-03-16 9:42 ` [dpdk-dev] [PATCH v2 " 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-5-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).