From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DF08EA04B5; Wed, 28 Oct 2020 00:39:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C43DDC82C; Wed, 28 Oct 2020 00:25:26 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 564C52C2D for ; Wed, 28 Oct 2020 00:24:02 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 28 Oct 2020 01:23:57 +0200 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 09RNNrs0026642; Wed, 28 Oct 2020 01:23:57 +0200 From: Ophir Munk To: dev@dpdk.org, Raslan Darawsheh Cc: Ophir Munk , Matan Azrad , Tal Shnaiderman , Thomas Monjalon Date: Tue, 27 Oct 2020 23:23:11 +0000 Message-Id: <20201027232335.31427-49-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201027232335.31427-1-ophirmu@nvidia.com> References: <20201027232335.31427-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v1 48/72] net/mlx5/windows: support link update 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" From: Tal Shnaiderman Add support for mlx5_link_update() to get link speed and link state. Other parameters are currently hard-coded. Signed-off-by: Tal Shnaiderman --- drivers/net/mlx5/windows/mlx5_ethdev_os.c | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c index 4925fd8..0c45101 100644 --- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c @@ -171,6 +171,45 @@ mlx5_os_read_dev_counters(struct rte_eth_dev *dev, uint64_t *stats) } /** + * DPDK callback to retrieve physical link information. + * + * @param dev + * Pointer to Ethernet device structure. + * @param wait_to_complete + * Wait for request completion. + * + * @return + * 0 if link status was not updated, positive if it was, a negative errno + * value otherwise and rte_errno is set. + */ +int +mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete) +{ + RTE_SET_USED(wait_to_complete); + struct mlx5_priv *priv; + mlx5_context_st *context_obj; + struct rte_eth_link dev_link; + int ret; + + ret = 0; + if (!dev) { + rte_errno = EINVAL; + return rte_errno; + } + priv = dev->data->dev_private; + context_obj = (mlx5_context_st *)priv->sh->ctx; + dev_link.link_speed = context_obj->mlx5_dev.link_speed / (1024 * 1024); + dev_link.link_status = + (context_obj->mlx5_dev.link_state == 1 && !mlx5_is_removed(dev)) + ? 1 : 0; + dev_link.link_duplex = 1; + ret = !!memcmp(&dev->data->dev_link, &dev_link, + sizeof(struct rte_eth_link)); + dev->data->dev_link = dev_link; + return ret; +} + +/** * DPDK callback to bring the link DOWN. * * @param dev -- 2.8.4