From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id B712F5B12 for ; Fri, 16 Mar 2018 10:42:30 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id z12so11052352wrg.4 for ; Fri, 16 Mar 2018 02:42:30 -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=FwlpPnnHbrj3R23nZvguCOi/gJ/NyWivD+xvp5c5hNM=; b=jg9tBQV09UYWPa2BEZJ0mFN/bmFYcaWM26RF4+ij6zRZ3EDz0nu3NaptiCkZWx5vKr 1/3d711y0tyWOr1mB9vwOlhr0rf7texyQQwUJwts23CvY62lIFsJ9fk5+LImkHEg5ZJy 0eZGLdj7UaP0rKU8cobEbwCcfNhMs1dhE1ohuH6WGVaLzixhOhYE5LW9vdiPWbfz9oUc 6wkpsHLA39gg1Ib2PeOWgDWVTGfqSFjoBOV6mfUlc89L8qWTttwG5Cla/+Vo0S8fLfoC dQ0+tPN/duM+paKabcZOyG78NfZcXU7SJG2k5dFub7fuFT8eKMI9a298c1yJH4B7Km+i Q4dw== 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=FwlpPnnHbrj3R23nZvguCOi/gJ/NyWivD+xvp5c5hNM=; b=pfRUFdATRPV7f2RKl+DpXC3nnub2dPVprHBzTDx45DUpT0CYJRHIFa5vsQv17I1ROC Zq2f54AKtkCWbDsoQt+pzrPaGRwp2CM+VSwjOuYnxzjNycFLMCm5NDrsPDloU0gQFYP+ OnPs5SPkL5iQoiDlbA2cz9Qk+JCb7XyghiZ/NeCHrkYP5zSoXif2H+bhnKiOdzadUXl5 AqRPMXLB+aGWaG3UtFr6wbAWHO5IQsAjuzdaLB0ovD1TQRgod2t6D4f9ZX0avnDjEY1M IDxRBHLqi4/dZhjd/j62r2zLyIIj8GJfwWPBP7h+4r0NeLyWI0bkgd4uo5a+Zn+WJIm9 Rj7w== X-Gm-Message-State: AElRT7G6P45KJLLYh1zoBpupaPG3WoTgU9C6JG/cGtwzPU5kgV/DvIqN roYqM+8GxVySD8anTqAp3XBmBGrFTuo= X-Google-Smtp-Source: AG47ELuVrLXqensdK+Orx/z5zsVNXfDemNoOCp/RDLAVmPy3wjBlU1F3yyy7KzWbePcuNd4cDMuejQ== X-Received: by 10.223.139.130 with SMTP id o2mr1072523wra.147.1521193350217; Fri, 16 Mar 2018 02:42:30 -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 p21sm1060783wmc.0.2018.03.16.02.42.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Mar 2018 02:42:29 -0700 (PDT) From: Zijie Pan To: dev@dpdk.org Cc: remy.horton@intel.com, wenzhuo.lu@intel.com, konstantin.ananyev@intel.com Date: Fri, 16 Mar 2018 10:42:11 +0100 Message-Id: <1521193331-25177-1-git-send-email-zijie.pan@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1520828243-25191-4-git-send-email-zijie.pan@6wind.com> References: <1520828243-25191-4-git-send-email-zijie.pan@6wind.com> Subject: [dpdk-dev] [PATCH v2 3/5] net/ixgbe: add module EEPROM callbacks for ixgbe 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: Fri, 16 Mar 2018 09:42:30 -0000 Add new callbacks for eth_dev_ops of ixgbe to get the information and data of plugin module eeprom. Signed-off-by: Zijie Pan --- drivers/net/ixgbe/ixgbe_ethdev.c | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 4483258..28f09d3 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -328,6 +328,11 @@ static int ixgbe_get_eeprom(struct rte_eth_dev *dev, static int ixgbe_set_eeprom(struct rte_eth_dev *dev, struct rte_dev_eeprom_info *eeprom); +static int ixgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_dev_module_info *modinfo); +static int ixgbe_get_module_eeprom(struct rte_eth_dev *dev, + struct rte_dev_eeprom_info *info); + static int ixgbevf_get_reg_length(struct rte_eth_dev *dev); static int ixgbevf_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs); @@ -565,6 +570,8 @@ static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev, .get_eeprom_length = ixgbe_get_eeprom_length, .get_eeprom = ixgbe_get_eeprom, .set_eeprom = ixgbe_set_eeprom, + .get_module_info = ixgbe_get_module_info, + .get_module_eeprom = ixgbe_get_module_eeprom, .get_dcb_info = ixgbe_dev_get_dcb_info, .timesync_adjust_time = ixgbe_timesync_adjust_time, .timesync_read_time = ixgbe_timesync_read_time, @@ -7166,6 +7173,78 @@ static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on) return eeprom->ops.write_buffer(hw, first, length, data); } +static int +ixgbe_get_module_info(struct rte_eth_dev *dev, + struct rte_dev_module_info *modinfo) +{ + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t status; + uint8_t sff8472_rev, addr_mode; + bool page_swap = false; + + /* Check whether we support SFF-8472 or not */ + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_SFF_8472_COMP, + &sff8472_rev); + if (status != 0) + return -EIO; + + /* addressing mode is not supported */ + status = hw->phy.ops.read_i2c_eeprom(hw, + IXGBE_SFF_SFF_8472_SWAP, + &addr_mode); + if (status != 0) + return -EIO; + + if (addr_mode & IXGBE_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."); + page_swap = true; + } + + if (sff8472_rev == IXGBE_SFF_SFF_8472_UNSUP || page_swap) { + /* We have a 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 a 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 +ixgbe_get_module_eeprom(struct rte_eth_dev *dev, + struct rte_dev_eeprom_info *info) +{ + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t status = IXGBE_ERR_PHY_ADDR_INVALID; + uint8_t databyte = 0xFF; + uint8_t *data = info->data; + uint32_t i = 0; + + if (info->length == 0) + return -EINVAL; + + for (i = info->offset; i < info->offset + info->length; i++) { + if (i < ETH_MODULE_SFF_8079_LEN) + status = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte); + else + status = hw->phy.ops.read_i2c_sff8472(hw, i, &databyte); + + if (status != 0) + return -EIO; + + data[i - info->offset] = databyte; + } + + return 0; +} + uint16_t ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) { switch (mac_type) { -- 1.7.10.4