From patchwork Tue Apr 24 10:17:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijie Pan X-Patchwork-Id: 38787 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E697C2A62; Tue, 24 Apr 2018 12:18:06 +0200 (CEST) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id E7D64100C for ; Tue, 24 Apr 2018 12:18:02 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id g21-v6so21695092wrb.8 for ; Tue, 24 Apr 2018 03:18:02 -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=xeippUz80SYKUR6Jd6VE1JBA3g6mZNd6waiTOCtLa7M=; b=w5yH7NBZin1uNfzbvXNWfrEM2gXNAfClzxSXq5eQzkrqRKe26RIfJSAwNctJRZXnWc 0a8zDs7MgBATShkN74gU5iSHvSBw8FRQZ98+DO3P3MYJWlnYu22bCph+/f4yKAfKrNTy 4a2ylVrNLDK1O/AW5JoNDmqvCGzrnIihaHdNPN5LHlP98f741gFytLh2erNl4dNscjuN sRcyzR56IrOSsYvJM24e3bYFAu74RzInUZi51x1iIXsXbR6M4BGeLVqULsCQnSO+J4/R KwbaLVK3wn4YHO4cLGfyKubqV9UHihnPegIDCRbaoHYbXcRFBk3xvTxP/gFr8YiFl8bX tIug== 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=xeippUz80SYKUR6Jd6VE1JBA3g6mZNd6waiTOCtLa7M=; b=tO4i6/LPRELaH47LhZ0U3HqyO55Wj02jAKhstASg98UkgU5qU6y7vW3DsXobpLt3HT B64ewcE9wc0GftbW7WDTZsHnjSsmMh+Ai7l3lMk4epQfiRTzbP5fWes4cRRw6KE+tXxK 3ftib1qJPntxp5Z+WEVYFKDz4cphv0+AGf6U1AJAnYRmhOuV2qO0LOPn1pfwy4r9z0i0 d4FWsdhH1GXjPunRy8RWu8JPcXbCsCO8JD4LJYzoJoTYvTPIhx8SfmogbCMu9n4E1kCH JIs38lpnwteu6mkVUVoIb5inmLb7qqt6X6DhGxXVLxzVtl/fyQYuCKGC9r1Z67vuvy+Z /KWQ== X-Gm-Message-State: ALQs6tAt+0pGbs+3xHOLOdWjaKuBmUdNFvwAMU8X8ftkv4SD5fihHkmp Eyjetk09gIrdR37uBMiARhQDHDqebGg= X-Google-Smtp-Source: AIpwx4+/v9EmAMe0/B3q7Iy73ItN6dn4GpLx5wLisDKJTWv2dw+GSmcSxht3ISSfPu5fTVfuMPFwUQ== X-Received: by 2002:adf:9d15:: with SMTP id k21-v6mr17795263wre.213.1524565082060; Tue, 24 Apr 2018 03:18:02 -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 60-v6sm12564155wrj.62.2018.04.24.03.18.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 03:18:01 -0700 (PDT) From: Zijie Pan To: dev@dpdk.org Cc: remy.horton@intel.com, ferruh.yigit@intel.com, thomas@monjalon.net, wenzhuo.lu@intel.com, konstantin.ananyev@intel.com Date: Tue, 24 Apr 2018 12:17:22 +0200 Message-Id: <1524565044-8583-4-git-send-email-zijie.pan@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1524565044-8583-1-git-send-email-zijie.pan@6wind.com> References: <1521630379-9554-1-git-send-email-zijie.pan@6wind.com> <1524565044-8583-1-git-send-email-zijie.pan@6wind.com> Subject: [dpdk-dev] [PATCH v4 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add new callbacks for eth_dev_ops of ixgbe to get the information and data of plugin module eeprom. Signed-off-by: Zijie Pan Acked-by: Remy Horton --- Cc: remy.horton@intel.com Cc: wenzhuo.lu@intel.com Cc: konstantin.ananyev@intel.com 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 a5e2fc0..55850df 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -327,6 +327,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); @@ -564,6 +569,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, @@ -7126,6 +7133,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 = RTE_ETH_MODULE_SFF_8079; + modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN; + } else { + /* We have a SFP which supports a revision of SFF-8472. */ + modinfo->type = RTE_ETH_MODULE_SFF_8472; + modinfo->eeprom_len = RTE_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 < RTE_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) {