From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by dpdk.org (Postfix) with ESMTP id B05311B00C for ; Tue, 23 Jan 2018 00:55:06 +0100 (CET) Received: by mail-pg0-f66.google.com with SMTP id k68so8353238pga.3 for ; Mon, 22 Jan 2018 15:55:06 -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=72vtAtxAxJhNDF+nTW6d+fdgny/CM3fQJd2sFtELh+k=; b=dVXaJIbM2hjQc+d1mMkFzYO/Op/bCqNBes6/YK1qtypc7PutgXo6u8s0JDxxpijJQ3 Cahm6nnBaaGZOu/h72G0f3YK+c3URJ1yLLbUHpnZ6j/9e1l6vOpU4G/waW9hCeWjUGc+ BExL+dBtE785R0iCYqeRLFKoPUrUROs38Q7o6EmZXjUY+WDpuB1q6ttmRfe0ysST3uLz 0qoFWGma0JlC2fSJEPv/Kk3rJIgNFFH4eHDSy5atdakRQx68wVxUHC5WN+DZroJtoMqU aNlSnCF6QsTusZGK4zb12Bm4gitNfLjjZBXinNF0isuWHiOg8/t50Q3VyrNPY07debYe 9bAQ== 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=72vtAtxAxJhNDF+nTW6d+fdgny/CM3fQJd2sFtELh+k=; b=pMMYerbBvaSDpeNg7S9z/YQNbNGiMXYCUXjWGvw6pDd1vNczkMNXUyka8TFl46NjZe 8Go2K9bA98Lb81PfTFhZQricmBQwiU8vh60TEyF3kmuwue05fBin378DWFjfejtiSjWl EFWKl9q+ERAJHpSn3W0E/C98+cYARRzLH6S3euOMyySB5uUWPW+o7zIPtbfpcGIavH2Z zdrAebx9ZoekcIlIkxQfkpi7qOLbaq7ilvLbLGa0XFHnxSEEq67wmbrIJIBGixExCDPI CD/lVej8ap0BX9Wq2nB70rUP9y8lmZ7slsvMjeDzY03FWXd3EeNSVIf1qA6kDa9Fvtoy Bvew== X-Gm-Message-State: AKwxytf+Y5ncGj/XTSxZdYSHofyORhGabYQzoyOFuby5E8pAkPyXIXmu o4yUt1dtdHTPx3NMHzMN3NwStUQenYs= X-Google-Smtp-Source: AH8x2240VHbAa2LMgqBjV8mXrqv8qJ+Po7X0SxVrlC4VJT9U2wtqk6gizAx5IDypdSQ676S2bPUNKg== X-Received: by 10.101.101.11 with SMTP id x11mr8023786pgv.130.1516665305576; Mon, 22 Jan 2018 15:55:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 15:55:04 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ferruh Yigit Date: Mon, 22 Jan 2018 15:54:46 -0800 Message-Id: <20180122235458.28562-4-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 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: Mon, 22 Jan 2018 23:55:07 -0000 Use the new comon code in ethdev to handle link status update. Signed-off-by: Stephen Hemminger Signed-off-by: Ferruh Yigit --- drivers/net/virtio/virtio_ethdev.c | 65 +++++++------------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 65cb71fa65cc..ff87ee7e9e51 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) { @@ -2023,8 +1982,10 @@ 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_status = ETH_LINK_DOWN, + }; PMD_INIT_LOG(DEBUG, "stop"); @@ -2033,22 +1994,20 @@ 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); 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; - 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; + uint16_t status; + struct rte_eth_link link = { + .link_speed = ETH_SPEED_NUM_10G, + .link_duplex = ETH_LINK_FULL_DUPLEX, + .link_autoneg = ETH_LINK_SPEED_FIXED, + }; if (hw->started == 0) { link.link_status = ETH_LINK_DOWN; @@ -2069,9 +2028,9 @@ 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); + rte_eth_linkstatus_set(dev, &link); - return (old.link_status == link.link_status) ? -1 : 0; + return 0; } static int -- 2.15.1