From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id 4052D1B1CA for ; Fri, 26 Jan 2018 03:01:58 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id t12so7203732pfg.2 for ; Thu, 25 Jan 2018 18:01:58 -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=8mns/7AYATrSoSz44TH+qRNiCfL5A1Mq95XlhrIQrjY=; b=iyVeuidEWXWmdXdRqw4tmkREY8B2r3pFH4jx9wJhN6z326sKL6p8J76x2Zm5wXsgKz booGZZ8M96q+QOgivv9NrGTNIQBbEDCvkVZv/0hznChbpGUlk16sPLo/sMZBTw38oeiu XYf4Lurw3irZREVNyVppyMxe5PA8FK1GjdL6Y2ZUtpNw/TrsFzfgnnnkz0ykll7vDMZe 4OQRdKc0lOWgXfWHyy/2ELi+Nj/toLWwvHwlWpjlDhhUNTysMu6sEU6BfQab14Yj5S/C xR7VEPOKk3T1xld4t/VXaZOLGB2j5wIEy1r+A1g+PQmM2C9YwUnviGDddSeivvysSwrV 4tVg== 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=8mns/7AYATrSoSz44TH+qRNiCfL5A1Mq95XlhrIQrjY=; b=iqdYfLh43YtJnt0wBnaJhRshS3+FKqT8z+j1ACTYKdtewqYAtJ6notIrcYApSZHUcL kE0hz1y8MMPtFdxEcMJ2vWjEHRl5QyBVUis9e9XZNF8Q6+jBsirEfmAOcAAO8hQOyVQJ PEXfJW5HPYhtqh3stOhpAkGwtln6VoK8xKmLp4dAfof96au4GUsJC7jOk0Ddqub3Lhu6 Mz5zoV3oGl9i7/H5VNZpH4G4KBoNdN7IOF3eXaCiodViX3EmXEVWkxWs07rSRgUZnGL9 Bg40WhrofqFJwYiNrpNoL0c4XuMBF9Ne1qROyyhN0YfOv/q4ZnGotFDfEZJ1uuFGlWui PHqA== X-Gm-Message-State: AKwxytfA+sF7n0wxw9A912I7+92paIPqxdQYJ5NBWPcZx6S+GKX2/5eE Ivtjzxue8cZKctC7WAmhO0oE7QgMzG8= X-Google-Smtp-Source: AH8x225bR2QlQmFW3iKasdC4Rr81WCt673ZUjbO3FTia7kHV5jGJFkggxxOpUw1v0wZttKfD86CMpg== X-Received: by 2002:a17:902:bc85:: with SMTP id bb5-v6mr13298612plb.425.1516932116916; Thu, 25 Jan 2018 18:01:56 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id d5sm22141492pfk.2.2018.01.25.18.01.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 18:01:56 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 25 Jan 2018 18:01:39 -0800 Message-Id: <20180126020151.979-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180126020151.979-1-stephen@networkplumber.org> References: <20180126020151.979-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v8 03/15] net/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: Fri, 26 Jan 2018 02:01:58 -0000 Use the new comon code in ethdev to handle link status update. Signed-off-by: Stephen Hemminger --- drivers/net/virtio/virtio_ethdev.c | 52 ++++---------------------------------- 1 file changed, 5 insertions(+), 47 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 65cb71fa65cc..fbba2db594fe 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 @@ -785,46 +784,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) { @@ -2034,21 +1993,21 @@ virtio_dev_stop(struct rte_eth_dev *dev) hw->started = 0; memset(&link, 0, sizeof(link)); - virtio_dev_atomic_write_link_status(dev, &link); + rte_eth_linkstatus_set(dev, &link); rte_spinlock_unlock(&hw->state_lock); } static int virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { - struct rte_eth_link link, old; + struct rte_eth_link link; 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 = ETH_SPEED_NUM_10G; + link.link_autoneg = ETH_LINK_SPEED_FIXED; if (hw->started == 0) { link.link_status = ETH_LINK_DOWN; @@ -2069,9 +2028,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