From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f44.google.com (mail-pg0-f44.google.com [74.125.83.44]) by dpdk.org (Postfix) with ESMTP id 1DE9D7CB5 for ; Fri, 14 Jul 2017 20:30:50 +0200 (CEST) Received: by mail-pg0-f44.google.com with SMTP id j186so49275990pge.2 for ; Fri, 14 Jul 2017 11:30:50 -0700 (PDT) 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=L44MXlwnTvoyAtKEpVKWD00MMcifZyrTZ70O0WO2m68=; b=EGnqquQ63GrCrK4kvJ8FiOcdHfA+9rij2SJTLmT0aGZArmfWHa4Pi6XGarTmiC46tn WTYnvodrOeFdW/+koj5B+/Lo03rkOHy+o5J5RkpNBzyHw4DIyRiZ63Vjsz8VRw7TzQ40 5CuN9kUbOcZhjv1Xy7k3J8XkdHmAL9SVNQ6XUXw404frRI3yHavIzhBD7wNIHQu0y706 TDf/6SV5fCOOeMlBAW4ozGmf63ZOlAewh1lyrheInt8jSaOOpaUPlGRa6x3NL4Xs7dvx 5Xfmv07a8F7SDUhXIN6Qn4typsyAOUOYdXOMhnq8UlWX7+IbZ2l7tOUcOBQUH/nGAHq4 htKA== 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=L44MXlwnTvoyAtKEpVKWD00MMcifZyrTZ70O0WO2m68=; b=c4ia1SaGx2e+35zs35u1Hy9gv50vMhpPpPcfoNuarTvEVVtBxtT2cM/8Q1wEHekKF3 Q3vBRL3f0y/YFXM6cU0JFmnnogREdiCOtrWT6z8O4meK025wdt4QI+nhPM408C9n2iNE /9YckhK/hNdlDUTemyPcFHWT6OnIGBtXgqp3R/kQZ/li2NS7D4+whWra5Fi43MmMh/zn ISHy4HTL2+MqxYFV3UZYwHngjPC9oxoo0o6yT6ZKWdqD/mpFb+d3VzEKWoweESo6kn3G g6AU5EoA739k4UTSMDG0i4NYdTKrltLt7Wno13q9QHrlWaze88xw8XzWL6/tzZ5SNojg q7hA== X-Gm-Message-State: AIVw112YXo8hyn/o1Er1hxpl8IDLxyWk1tyNsPhuEuT2WCHQht6kvvE3 VpP+55OYp+oAWizQcDiuVA== X-Received: by 10.98.79.130 with SMTP id f2mr6610959pfj.133.1500057049752; Fri, 14 Jul 2017 11:30:49 -0700 (PDT) Received: from xeon-e3.wavecable.com (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id r9sm22711163pfi.114.2017.07.14.11.30.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 11:30:49 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Fri, 14 Jul 2017 11:30:24 -0700 Message-Id: <20170714183027.16021-12-stephen@networkplumber.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170714183027.16021-1-stephen@networkplumber.org> References: <20170714183027.16021-1-stephen@networkplumber.org> Subject: [dpdk-dev] [RFC 11/14] liquidio: use _rte_eth_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: , X-List-Received-Date: Fri, 14 Jul 2017 18:30:51 -0000 Use the new link update API, and cleanup the logic in the the link update routine. Signed-off-by: Stephen Hemminger --- drivers/net/liquidio/lio_ethdev.c | 76 ++++++++++----------------------------- 1 file changed, 19 insertions(+), 57 deletions(-) diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 479936a52ff9..95dc7232601e 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -888,32 +888,6 @@ lio_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id, int on) return 0; } -/** - * Atomically writes the link status information into global - * structure rte_eth_dev. - * - * @param eth_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 -lio_dev_atomic_write_link_status(struct rte_eth_dev *eth_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 uint64_t lio_hweight64(uint64_t w) { @@ -933,45 +907,33 @@ lio_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete __rte_unused) { struct lio_device *lio_dev = LIO_DEV(eth_dev); - struct rte_eth_link link, old; + struct rte_eth_link link; /* Initialize */ - link.link_status = ETH_LINK_DOWN; - link.link_speed = ETH_SPEED_NUM_NONE; - link.link_duplex = ETH_LINK_HALF_DUPLEX; - memset(&old, 0, sizeof(old)); - + memset(&link, 0, sizeof(link)); /* Return what we found */ if (lio_dev->linfo.link.s.link_up == 0) { - /* Interface is down */ - if (lio_dev_atomic_write_link_status(eth_dev, &link)) - return -1; - if (link.link_status == old.link_status) - return -1; - return 0; - } - - link.link_status = ETH_LINK_UP; /* Interface is up */ - link.link_duplex = ETH_LINK_FULL_DUPLEX; - switch (lio_dev->linfo.link.s.speed) { - case LIO_LINK_SPEED_10000: - link.link_speed = ETH_SPEED_NUM_10G; - break; - case LIO_LINK_SPEED_25000: - link.link_speed = ETH_SPEED_NUM_25G; - break; - default: + link.link_status = ETH_LINK_DOWN; link.link_speed = ETH_SPEED_NUM_NONE; link.link_duplex = ETH_LINK_HALF_DUPLEX; - } - - if (lio_dev_atomic_write_link_status(eth_dev, &link)) - return -1; + } else { + link.link_status = ETH_LINK_UP; /* Interface is up */ + link.link_duplex = ETH_LINK_FULL_DUPLEX; + switch (lio_dev->linfo.link.s.speed) { + case LIO_LINK_SPEED_10000: + link.link_speed = ETH_SPEED_NUM_10G; + break; + case LIO_LINK_SPEED_25000: + link.link_speed = ETH_SPEED_NUM_25G; + break; + default: + link.link_speed = ETH_SPEED_NUM_NONE; + link.link_duplex = ETH_LINK_HALF_DUPLEX; + } - if (link.link_status == old.link_status) - return -1; + } - return 0; + return _rte_eth_link_update(eth_dev, &link); } /** -- 2.11.0