From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 919405F72 for ; Wed, 21 Mar 2018 12:07:50 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id z12so4753730wrg.4 for ; Wed, 21 Mar 2018 04:07:50 -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=uxCfJwT82nIJhsA5bzElgAIRlpGZgqtZXN9Lbt37EUY=; b=SgXRdgAvknCFAy+tglkbdtO8CzJsavve6+7KNckwdPQGwZlXQsGoalYvzsriASpU3K Ca7EoOUJcN67CjxR0n2ZCyVncFVtNnqLX18cxBvSgzsXSz4rthsjEOC/fIz5W1iswv6+ nEeMpZ6Hyt6MU7HYz8Nlrq79ODTiT74Z+D574D/5p57pTHZwJFkGIBqXUad9B3LvS9oP ALczT6B8svFB2LYWlTIqMUpJ+/DBC41jgPR4wBMzDYI8HWqT/KM9L9FVabdltBoupVoi p9nFvhrYIrlUnWBhl0P4a3/2D+BO8BrhJ+aGYcynb4D22eDYeEMlyWiRlGWOkEG/wJkf 4mEw== 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=uxCfJwT82nIJhsA5bzElgAIRlpGZgqtZXN9Lbt37EUY=; b=TcWfF9Uzp5IHKqjODjhWgReeLc6MTKypbpj7AlwX0/9cDa7iqjDAV9CkjGps6IzqYj Pg2Snj6L9MB8wQEBG8g9IqnusKyYLc3fzXTiQUPgHtwcPnKdizQVKABuN11tup11XtMh W3szbJ/Ch8p1H0dJg5tPm3njvIP/8rFJBZ39NtvsJKaGi6J8/9l5vsPRWTrzbfIAc31M JHxrzrgJRIzulsKtpwJzH05C3fbYyMUeSMLqhq2diiqfa6c2sGJhgYJARLqpBSRtbNxA pJvTz3LiTCggLTbLRybjUH75hIE3B4EErPgWPtLcOh+zIJ/zjKjx3riQOpbeSBPBX3eJ TAlA== X-Gm-Message-State: AElRT7GPQYWqjElpHkfu/sjVgK8HkHiAUqJ8rwgZL9Yf0tLSv2HsMr93 +mJVreSmywyGglW/r8aQi66EbeoDEE8= X-Google-Smtp-Source: AG47ELuoLtlP1J7qXyJhBl/vFy9wj85tawLkVqawDnNdAUo2BHzzV/bTKFEg3jAaRb2W3jh++sorrA== X-Received: by 10.223.158.196 with SMTP id b4mr15578473wrf.112.1521630470037; Wed, 21 Mar 2018 04:07:50 -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 n23sm3708482wra.14.2018.03.21.04.07.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 04:07:49 -0700 (PDT) From: Zijie Pan To: dev@dpdk.org Cc: remy.horton@intel.com, wenzhuo.lu@intel.com Date: Wed, 21 Mar 2018 12:06:18 +0100 Message-Id: <1521630379-9554-5-git-send-email-zijie.pan@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1521630379-9554-1-git-send-email-zijie.pan@6wind.com> References: <1521193010-25050-1-git-send-email-zijie.pan@6wind.com> <1521630379-9554-1-git-send-email-zijie.pan@6wind.com> Subject: [dpdk-dev] [PATCH v3 4/5] net/e1000: add module EEPROM callbacks for e1000 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, 21 Mar 2018 11:07:50 -0000 Add new callbacks for eth_dev_ops of e1000 to get the information and data of plugin module EEPROM. Signed-off-by: Zijie Pan --- Cc: wenzhuo.lu@intel.com drivers/net/e1000/base/e1000_phy.h | 8 ++++ drivers/net/e1000/igb_ethdev.c | 86 ++++++++++++++++++++++++++++++++++++ 2 files changed, 94 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..77ec4f9 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,86 @@ 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