From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f196.google.com (mail-pf0-f196.google.com [209.85.192.196]) by dpdk.org (Postfix) with ESMTP id 16EFE1200A for ; Tue, 23 Jan 2018 00:55:07 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id b25so8334892pfd.9 for ; Mon, 22 Jan 2018 15:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CXNh4I58V9BrpQTvwt4pdizkpdnLRfM4l8RblHN8o4o=; b=rtnZMKOTysrA/sSNdnfQ2LX+O63MRVwOmaQ3upQ38LYONzbBP4sdTfHAIseTDKnRJM xysTUvX4Ap7FpTEXJBoCfjG28iNZ4Kyg1aZvKVie90PHcNortVEQw1/HgIm6D0RNn44M VKHygADubwpfdsCdXaFj0tggpfGNuTkCzjLbx7WaA7FqLhq6dPVqLM8VOHY7pQqscMkI ZtflTtq+ff56NuYk+2NGqjZ2Tyo+KZyXY0+Ho8liDxUrpMkCdPjNgVGMRIqoMsbrkI4h /SgJeCrcvI/+RuVQ9C9QpBZJSzQ/IqSepJcgUfhpCKeIxbHQOvZ6gPxFZiQbgZfyHb4n Ad5Q== 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=CXNh4I58V9BrpQTvwt4pdizkpdnLRfM4l8RblHN8o4o=; b=IObn0e+3VH/+Jc3sA2v544JCoCPvleJ7AsSnSyf1nbq+Umln+uOk7+jmngXuFlttap x+hsj2yGvPFs9GQFJt87Nj4/WY5C+S9G0DXVlWWCsycMHYzaVohMfV7HzxMPUXq7N4xJ +Y5eJPPyiidGr3cGYv9IH3JC/V7s6VHhTQWW1n4s135LUHiLI6fYWVEs082GpRmyRQ9r 9/99qVWooZC9nq7q6E7owVHTR+VDiDwxeeNNE2eVYC9qLlxn4aKRWGcS2cy2uBTQ7piI tilG/IuifAXkVyzNyk1NElUm5dXlEHrOHJXWu7VOV/0+9Z2/CSnQqdliLggBtWsJunrV V3uQ== X-Gm-Message-State: AKwxytddduXwObHb+rBT3MbXOQiu+vB7RXXWDb4TABsMg+45QdiBYNSL mixJ9jeBGqUPQV8fI7oedVK4exYbGL0= X-Google-Smtp-Source: AH8x225QpJkd1vQlQ8dJcDrW0opTA7SYK0cFmaqI1uGl+dqkOWwr+vjD++fSDw1fqwM5P/W3mPmUOQ== X-Received: by 10.101.96.44 with SMTP id p12mr7587334pgu.390.1516665306900; Mon, 22 Jan 2018 15:55:06 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id a24sm1623825pff.160.2018.01.22.15.55.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 15:55:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ferruh Yigit Date: Mon, 22 Jan 2018 15:54:47 -0800 Message-Id: <20180122235458.28562-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180122235458.28562-1-stephen@networkplumber.org> References: <20180122235458.28562-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v7 04/15] net/vmxnet3: use rte_eth_linkstatus_set 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, 22 Jan 2018 23:55:08 -0000 Use new rte_eth_link_update helper. Also remove no longer necessary include of rte_atomic.h Signed-off-by: Stephen Hemminger Signed-off-by: Ferruh Yigit --- drivers/net/vmxnet3/vmxnet3_ethdev.c | 86 +++++++----------------------------- 1 file changed, 16 insertions(+), 70 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index a2fb93cc984c..3a4601a491b1 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -160,59 +159,6 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size, return rte_memzone_reserve_aligned(z_name, size, socket_id, 0, align); } -/** - * Atomically reads the link status information from global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ - -static int -vmxnet3_dev_atomic_read_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = link; - struct rte_eth_link *src = &(dev->data->dev_link); - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - -/** - * Atomically writes the link status information into global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to write to. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static int -vmxnet3_dev_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = &(dev->data->dev_link); - struct rte_eth_link *src = link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - /* * This function is based on vmxnet3_disable_intr() */ @@ -817,9 +763,13 @@ vmxnet3_dev_start(struct rte_eth_dev *dev) static void vmxnet3_dev_stop(struct rte_eth_dev *dev) { - struct rte_eth_link link; struct vmxnet3_hw *hw = dev->data->dev_private; - + struct rte_eth_link link = { + .link_speed = ETH_SPEED_NUM_10G, + .link_duplex = ETH_LINK_FULL_DUPLEX, + .link_autoneg = ETH_LINK_SPEED_FIXED, + .link_status = ETH_LINK_DOWN, + }; PMD_INIT_FUNC_TRACE(); if (hw->adapter_stopped == 1) { @@ -852,8 +802,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev) vmxnet3_dev_clear_queues(dev); /* Clear recorded link status */ - memset(&link, 0, sizeof(link)); - vmxnet3_dev_atomic_write_link_status(dev, &link); + rte_eth_linkstatus_set(dev, &link); } /* @@ -1132,25 +1081,22 @@ __vmxnet3_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { struct vmxnet3_hw *hw = dev->data->dev_private; - struct rte_eth_link old = { 0 }, link; + struct rte_eth_link link = { + .link_speed = ETH_SPEED_NUM_10G, + .link_duplex = ETH_LINK_FULL_DUPLEX, + .link_autoneg = ETH_LINK_SPEED_FIXED, + .link_status = ETH_LINK_DOWN, + }; uint32_t ret; - memset(&link, 0, sizeof(link)); - vmxnet3_dev_atomic_read_link_status(dev, &old); - VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK); ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD); - if (ret & 0x1) { + if (ret & 0x1) link.link_status = ETH_LINK_UP; - link.link_duplex = ETH_LINK_FULL_DUPLEX; - link.link_speed = ETH_SPEED_NUM_10G; - link.link_autoneg = ETH_LINK_AUTONEG; - } - - vmxnet3_dev_atomic_write_link_status(dev, &link); - return (old.link_status == link.link_status) ? -1 : 0; + rte_eth_linkstatus_set(dev, &link); + return 0; } static int -- 2.15.1