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 4FF3BA49F for ; Tue, 23 Jan 2018 16:05:47 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id r71so2498200wmd.1 for ; Tue, 23 Jan 2018 07:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RTpKFRhiB4V7us8YCmYx9Ehcgh8h7DcprfqHaZZRTNw=; b=PIKv4zGHK6yLZZ/cOXHBW4O2FFSScV2ho/g9a7Twd28ppYpb6qxnzQ6DtoYjg6Svx1 I7nekQd7sRNWi8LeBbBrmGngG45+ce1S/Cavxh1KDC5gtQKoAN09fy94eMGrqs9OL1Jl Vgd31sHyLfhza0y4u3bVlL5+zYi9Uw8Qcz39FhlpPWBqvd1EEyqiVCSc89K3PKBcI9yN FBaATiC0D3LHezb0mBl2grktIkllRDmI/icO5G99Z3DR0TABWVjZ6CDPsswU3QP7a9ve Mos4rpPfw2jrIjDEOvjoljzINwafwdFt+ke5b/g9pkMv/EcugjzKR3JSy/jsRYBkch+u oJJw== 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=RTpKFRhiB4V7us8YCmYx9Ehcgh8h7DcprfqHaZZRTNw=; b=p81tGFd8R4ktMpj21Ij7RQFfzeFFRHvD83ViakqV8i/TXnyY9ipePBSMRHbP5TPRE0 Ts+7xN3s3XLQ3gJv5zEOqLNh+LPi/Ka9t8m0SSKgXpPZXIEJitQZBgg7BPQSFim5P98H EafCh+Mm/Em9fNPDsvIwUbAWLnmVEyRLYICnrKE5XSbyw19oPlh640u7+gm5GhrkP/gr 3VGGQiE18Dtq1uTe+fMyLqtGlt53suNbmHiD5yws4lviqMvDGeI+VpTRHVw/9fr5eDAq +9MFCcij0z4M7EXylRYzhreBH4DpL3qB8wcUeRRTi0YHKgWVvDkOQPfCteEaq4fJV9P0 DHYA== X-Gm-Message-State: AKwxytclnFBpeK53osZetyImhjJqSNymNILTWfg4XLAR94r5L98WEk4U fF0vclB7ufxBZtJhZaYrLIyy1A== X-Google-Smtp-Source: AH8x225bRqbZO7k67cS8UI/8UhG5Wquiq1y9FQtPL1NR6/84eKcty+FQwJqsK7B/dCQOeX0024ZNyw== X-Received: by 10.28.111.219 with SMTP id c88mr2391212wmi.41.1516719946817; Tue, 23 Jan 2018 07:05:46 -0800 (PST) Received: from schoudah-dev.vyatta.net ([137.221.143.78]) by smtp.gmail.com with ESMTPSA id a62sm7556228wmh.3.2018.01.23.07.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 07:05:46 -0800 (PST) From: Shweta Choudaha To: dev@dpdk.org Cc: Shweta Choudaha Date: Tue, 23 Jan 2018 15:05:31 +0000 Message-Id: <20180123150532.33912-1-shweta.choudaha@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <1509978323-9879-1-git-send-email-shweta.choudaha@gmail.com> References: <1509978323-9879-1-git-send-email-shweta.choudaha@gmail.com> Subject: [dpdk-dev] [PATCH v3 1/2] net/ixgbe: add and export MDIO APIs 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: Tue, 23 Jan 2018 15:05:47 -0000 From: Shweta Choudaha Add ixgbe MDIO access APIs to read and write PHY registers when being used as a backplane port. Export these APIs via the map file Signed-off-by: Shweta Choudaha Reviewed-by: Chas Williams Reviewed-by: Luca Boccassi --- drivers/net/ixgbe/rte_pmd_ixgbe.c | 53 +++++++++++++++++++++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe.h | 39 +++++++++++++++++++++ drivers/net/ixgbe/rte_pmd_ixgbe_version.map | 2 ++ 3 files changed, 94 insertions(+) diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.c b/drivers/net/ixgbe/rte_pmd_ixgbe.c index 001a8647e..a3f376e11 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.c +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c @@ -1012,3 +1012,56 @@ rte_pmd_ixgbe_bypass_wd_reset(uint16_t port_id) return ixgbe_bypass_wd_reset(dev); } #endif + +static void rte_pmd_ixgbe_get_hw_phy(uint16_t port, struct ixgbe_hw **hw, + struct ixgbe_phy_info **phy) +{ + struct rte_eth_dev *dev; + + *hw = NULL; + *phy = NULL; + + dev = &rte_eth_devices[port]; + if (!is_ixgbe_supported(dev)) + return; + + *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + if (!*hw) + return; + + *phy = &(*hw)->phy; +} + +int +rte_pmd_ixgbe_mdio_read(uint16_t port, uint32_t reg_addr, + uint32_t dev_type, uint16_t *phy_data) +{ + struct ixgbe_hw *hw; + struct ixgbe_phy_info *phy; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + + rte_pmd_ixgbe_get_hw_phy(port, &hw, &phy); + + if (!hw || !phy) + return -ENOTSUP; + + return phy->ops.read_reg(hw, reg_addr, dev_type, phy_data); +} + +int +rte_pmd_ixgbe_mdio_write(uint16_t port, uint32_t reg_addr, + uint32_t dev_type, uint16_t phy_data) +{ + struct ixgbe_hw *hw; + struct ixgbe_phy_info *phy; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + + rte_pmd_ixgbe_get_hw_phy(port, &hw, &phy); + + if (!hw || !phy) + return -ENOTSUP; + + return phy->ops.write_reg(hw, reg_addr, dev_type, phy_data); +} diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h index 463a78e50..1fd6280e5 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.h +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h @@ -573,6 +573,45 @@ int rte_pmd_ixgbe_bypass_wd_timeout_show(uint16_t port, uint32_t *wd_timeout); */ int rte_pmd_ixgbe_bypass_wd_reset(uint16_t port); +/** + * Read PHY register using MDIO with swfw semaphore lock + * + * @param port + * The port identifier of the Ethernet device. + * @param reg_addr + * 32 bit PHY Register + * @param dev_type + * Always Unused + * @param phy_data + * Pointer for reading PHY register data + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port* invalid. + */ +int +rte_pmd_ixgbe_mdio_read(uint16_t port, uint32_t reg_addr, + uint32_t dev_type, uint16_t *phy_data); + +/** + * Write data to PHY register using MDIO with swfw semaphore lock + * + * @param port + * The port identifier of the Ethernet device. + * @param reg_addr + * 32 bit PHY Register + * @param dev_type + * Always unused + * @param phy_data + * Data to write to PHY register + * @return + * - (0) if successful. + * - (-ENOTSUP) if hardware doesn't support. + * - (-ENODEV) if *port* invalid. + */ +int +rte_pmd_ixgbe_mdio_write(uint16_t port, uint32_t reg_addr, + uint32_t dev_type, uint16_t phy_data); /** * Response sent back to ixgbe driver from user app after callback diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map index bf776742c..9cad217e9 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map +++ b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map @@ -51,4 +51,6 @@ DPDK_17.08 { rte_pmd_ixgbe_bypass_wd_reset; rte_pmd_ixgbe_bypass_wd_timeout_show; rte_pmd_ixgbe_bypass_wd_timeout_store; + rte_pmd_ixgbe_mdio_read; + rte_pmd_ixgbe_mdio_write; } DPDK_17.05; -- 2.11.0