From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by dpdk.org (Postfix) with ESMTP id 55F8C1B16A for ; Sat, 6 Jan 2018 02:07:02 +0100 (CET) Received: by mail-pl0-f67.google.com with SMTP id bd8so4073838plb.9 for ; Fri, 05 Jan 2018 17:07:02 -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=eBL8ZT3nJS9NuDQK2JAxdW6G9wqEGdE/Z7z4w8FUmDw=; b=rWyk08iIp74I6YfmC48vZQjsH/5E3qakbydttE69Bbm3pZkda6RDgrxu0Ii4giEUUJ yB0kwf9L2AOAjsPwVotX4axEUs3mG4llwef6Lc8GMQqt6bvJb0zVA5UnGlb5BFpwBOQ1 ga0q38jveAQhgWRUhNNuwFYXHvcSeCu2tqkywLc3YK082tGZSrYrxfOn1gKBAnAA2/b+ S0q0GPN+Z8MBOesGOl85/N24dMkTc/LoHi1UxDUqAGSM5ho5IbnC2iytlQYxZkp3kpTk ZEzt0TkVG0MRd4sH5shkDL9YP0qNiKki2fRFV+fCicbvGIHEEqFvcgZvk1t3kIA3YbeE gUmQ== 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=eBL8ZT3nJS9NuDQK2JAxdW6G9wqEGdE/Z7z4w8FUmDw=; b=uXkAixgU3xnHFE9LoTMToubWHqzk161hWn2jSveHylxaNYB3UVefxzyMckJNMGlrUW 5c4HirnDLPQwDEYrAjGl9M4jN8/vqXvbzlno/y/qiDSsLycNcyCawnXyXF8oMwtlBkC4 24Kf4IllQrZSA18LTh/iOqT9O6o8PdrHQEdWS1zY9+RIJ3FbPv3kAcHakQbihLAGoFWD LiD7Y8wnm0A8uVSSe1rxrR+2FrUBdi/tfh8sk+Np2QqHIHmgmnNPaUftq2+1G4SqRnQ9 TJKAv0tXyal0nw5OJNBRaDJzwsOg9bw2z6ZT+r8MktiwfAvp3JdTGnR6E0PVoGZcO4LE HlPQ== X-Gm-Message-State: AKGB3mL4+eIzhn+0henCc/LwKBnMcwl0tVQakztvJJhydk8wu4IUx4Tt bafkXoIg+MBp8lm9IRJntYcng5hADgc= X-Google-Smtp-Source: ACJfBosebCnjsp0T+VJ4ioxFcmhYaw3Z3PiCt5mbmO7Wzib2jycLmQGYPI7BACHR7dhfy3TXrZ9c3w== X-Received: by 10.84.129.98 with SMTP id 89mr4952777plb.77.1515200821214; Fri, 05 Jan 2018 17:07:01 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id p14sm12385018pgn.37.2018.01.05.17.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 17:07:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 5 Jan 2018 17:06:44 -0800 Message-Id: <20180106010656.9167-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106010656.9167-1-stephen@networkplumber.org> References: <20180106010656.9167-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 03/15] virtio: use 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: Sat, 06 Jan 2018 01:07:02 -0000 Use the new comon code in ethdev to handle link status update. Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_ethdev.c | 67 ++++++++------------------------------ 1 file changed, 14 insertions(+), 53 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 21f2131a9efd..748d40188e5d 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -771,46 +770,6 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { .mac_addr_set = virtio_mac_addr_set, }; -static inline int -virtio_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 read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static inline int -virtio_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; -} - static void virtio_update_stats(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -1913,8 +1872,13 @@ static void virtio_dev_stop(struct rte_eth_dev *dev) { struct virtio_hw *hw = dev->data->dev_private; - struct rte_eth_link link; struct rte_intr_conf *intr_conf = &dev->data->dev_conf.intr_conf; + struct rte_eth_link link = { + .link_speed = SPEED_10G, + .link_duplex = ETH_LINK_FULL_DUPLEX, + .link_autoneg = ETH_LINK_SPEED_FIXED, + .link_status = ETH_LINK_DOWN, + }; PMD_INIT_LOG(DEBUG, "stop"); @@ -1922,21 +1886,19 @@ virtio_dev_stop(struct rte_eth_dev *dev) virtio_intr_disable(dev); hw->started = 0; - memset(&link, 0, sizeof(link)); - virtio_dev_atomic_write_link_status(dev, &link); + _rte_eth_linkstatus_set(dev, &link); } static int virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct rte_eth_link link, old; - uint16_t status; struct virtio_hw *hw = dev->data->dev_private; - memset(&link, 0, sizeof(link)); - virtio_dev_atomic_read_link_status(dev, &link); - old = link; - link.link_duplex = ETH_LINK_FULL_DUPLEX; - link.link_speed = SPEED_10G; + uint16_t status; + struct rte_eth_link link = { + .link_speed = SPEED_10G, + .link_duplex = ETH_LINK_FULL_DUPLEX, + .link_autoneg = ETH_LINK_SPEED_FIXED, + }; if (hw->started == 0) { link.link_status = ETH_LINK_DOWN; @@ -1957,9 +1919,8 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet } else { link.link_status = ETH_LINK_UP; } - virtio_dev_atomic_write_link_status(dev, &link); - return (old.link_status == link.link_status) ? -1 : 0; + return _rte_eth_linkstatus_set(dev, &link); } static int -- 2.15.1