From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 3260A1B2CF for ; Mon, 6 Nov 2017 15:25:38 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id z3so14576961wme.5 for ; Mon, 06 Nov 2017 06:25:38 -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=elWXS5KpUydJb7TaI8Z5KUBkNax8wfiahJoXZLVq/xs=; b=ce20a3z+yTFx+XxfJXpJH68mObdWU+ZyozElFmE/dYsLNMabxs7fG/wFwfpe/S73Kd XuBPFeiA3H4M0m7fTbDDfIKxkHJUxnj4higxzmCWqxnToaz5bJMSf0xwZ7VE5MZZn+Eo VV9EgWujR2fopWX+vzK1Qh7o1vkjYCksHKULxZHcNhyzPTbHOX+d/gGjVOLf8GohodJF 7uOCgQIPGfFlTKChGkz7n3Riu9IYVA1QOwGE42uJzIQbD6EymKlqMqGB/qv6VoixZtgx oRTvq8duqda/dFtXqYBs5gnI+FUKwT/r5LLMbMRvf8NQtBSq+bkizBRX6k8mYxcXztVa oJ3Q== 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=elWXS5KpUydJb7TaI8Z5KUBkNax8wfiahJoXZLVq/xs=; b=AU8u51ae74j7Ex/DoHZehLxHtrBhc6yvwQDRB89v8psCQD9BoJ8PWp3SeQsl60lNze SA1kz6kbUm79uHyjcSmxziHTVQb/WY9S4293w7AFlHHZ5idb5+GXv7375793kskrSrYI DrVn/lS5fLnmrVQxiZeIspmHwH+lBhrmsFXU8pvZuMHUJp4z0f62hfPlzFVEWrXjKclO SKYflMii0GWc+6fR+W8wj+JIyHQ7XDKZ3iEyIh3stSkjD5RLXX8LzYkvL9ZwSoOUDcQC e1hRJvYGgqTxxJY6529+BhK+3rSjz2em88EwpoNWbVSJoGkVufpYqPUzg8/naJU7WsHr M2WA== X-Gm-Message-State: AMCzsaVDzApdnxIUolWjfBQsZmeDjYCLhFjangsSDCkd7RcM3ykbPLwh NxAFqFIbtQGHXd2FkXwy1RRzr43jK4o= X-Google-Smtp-Source: ABhQp+Tz14q1wy14AVCkweCeubNFHi28V4aBywO5iBQHZ0PXQ1qjo5ZavjmtU28DzhlqStwCkghciA== X-Received: by 10.80.193.130 with SMTP id m2mr20251305edf.209.1509978337639; Mon, 06 Nov 2017 06:25:37 -0800 (PST) Received: from BRA-LCJN4P12.brocade.com ([144.49.71.22]) by smtp.gmail.com with ESMTPSA id h16sm10369601edj.33.2017.11.06.06.25.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 06:25:36 -0800 (PST) From: Shweta Choudaha To: dev@dpdk.org Cc: Shweta Choudaha Date: Mon, 6 Nov 2017 14:25:22 +0000 Message-Id: <1509978323-9879-1-git-send-email-shweta.choudaha@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 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: Mon, 06 Nov 2017 14:25:38 -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 | 7 ++++ 3 files changed, 99 insertions(+) diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.c b/drivers/net/ixgbe/rte_pmd_ixgbe.c index f127378..34d8cb4 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.c +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c @@ -1041,3 +1041,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_mdi(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_mdi(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 81b18f8..5d36f8a 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.h +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h @@ -601,6 +601,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 + * + * @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 + * + * @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 bf77674..ce72c73 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map +++ b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map @@ -52,3 +52,10 @@ DPDK_17.08 { rte_pmd_ixgbe_bypass_wd_timeout_show; rte_pmd_ixgbe_bypass_wd_timeout_store; } DPDK_17.05; + +EXPERIMENTAL { + global: + + rte_pmd_ixgbe_mdio_read; + rte_pmd_ixgbe_mdio_write; +} DPDK_17.08; -- 2.1.4