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 5D7F91B2BB for ; Fri, 26 Jan 2018 03:02:07 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id t5so7211822pfi.0 for ; Thu, 25 Jan 2018 18:02: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=KXfY8Y8RZ2Ygmylqrnmcuqmqq3LZVllMvINMKHWEa4I=; b=KAg67cqnknjESZWGWbr/xPRkqP5ugRGoCS1aNyCBs3alASmnDAJMlmF73+ziS7au6H JmfCsW4NYv0Xtesx7HnCf6TqgT/ybU+68d7AJHry3Ad9CaWaGMTDRfEvN8vy/Rv2R+q3 yb8+w5fAUosEr1R8WB1N88LHa2CSlcBIpfc9pQEPiVKZKiaKU+Zced6pa8u4glP1oc40 ERQ1Z3d97qKBjjriTj5Rv00G88pye3IbgUiANM4xYTVVVm3i16eCVyZVLlI8qFAMBCXG 2VfTqPyI7r8GlVQjBWRHt8g1Wr384W2HcyOZlXMy4HYcQEIkdiVYavqOg5VfW6cMNqG9 usXA== 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=KXfY8Y8RZ2Ygmylqrnmcuqmqq3LZVllMvINMKHWEa4I=; b=uAnR3AyJ6ZT310KBo5M2yENimGBUBg/bqS8oZ1ZHrUcTtyMvD373+cc+KainR+bRGP 149ZsxOtCW1AcHBfQJZZj1ZlVDLairR3PPCJr1Ax5+uL4aOIZyyYkXfhB6AiBOGgbIXG LwH9g2vPYFUzU0cd55gOPXbakiX/W9rT4WdLU28CemH77Tl8tnsBHs8yR2CPJgKC37dn 9yD60llNHgxU+5mYaxaJ0OMDf4T+DYCUyC+qZKY03M3CbtOn3KO4z5K9mccCo1ajeTnV vzX3C7Xz2tLBK1wvmvkLJt6dmT9yrTRjw6v7vjy2U0+B/siRUW8/rQdfjxvrTMqo/54x 12pg== X-Gm-Message-State: AKwxyteJgKhu4sHSGaRes1AZosPWUd71Orvs+JaWslMcqgymI1tVVk63 PGUC96UAbE/+kJGe79VoYR1wQv0e95Q= X-Google-Smtp-Source: AH8x224i3NzXhGckOxHfMedZYVAkQwwb8A1W/XVlV9AVTxdXpO9J9kaFMIy6uq8USOnI0byxYBvQMg== X-Received: by 10.101.78.207 with SMTP id w15mr14902920pgq.349.1516932126274; Thu, 25 Jan 2018 18:02: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 d5sm22141492pfk.2.2018.01.25.18.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 18:02:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 25 Jan 2018 18:01:48 -0800 Message-Id: <20180126020151.979-13-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 12/15] net/thunderx: 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: Fri, 26 Jan 2018 02:02:07 -0000 Use new helper function. Signed-off-by: Stephen Hemminger --- drivers/net/thunderx/nicvf_ethdev.c | 45 +++++++++++++++---------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index d34938c64b1d..fc5c9a486937 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -15,7 +15,6 @@ #include #include -#include #include #include #include @@ -69,25 +68,14 @@ nicvf_init_log(void) rte_log_set_level(nicvf_logtype_driver, RTE_LOG_NOTICE); } -static inline int -nicvf_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) +static void +nicvf_link_status_update(struct nicvf *nic, + 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; + memset(link, 0, sizeof(*link)); - return 0; -} + link->link_status = nic->link_up ? ETH_LINK_UP : ETH_LINK_DOWN; -static inline void -nicvf_set_eth_link_status(struct nicvf *nic, struct rte_eth_link *link) -{ - link->link_status = nic->link_up; - link->link_duplex = ETH_LINK_AUTONEG; if (nic->duplex == NICVF_HALF_DUPLEX) link->link_duplex = ETH_LINK_HALF_DUPLEX; else if (nic->duplex == NICVF_FULL_DUPLEX) @@ -101,12 +89,16 @@ nicvf_interrupt(void *arg) { struct rte_eth_dev *dev = arg; struct nicvf *nic = nicvf_pmd_priv(dev); + struct rte_eth_link link; if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) { - if (dev->data->dev_conf.intr_conf.lsc) - nicvf_set_eth_link_status(nic, &dev->data->dev_link); - _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, - NULL); + if (dev->data->dev_conf.intr_conf.lsc) { + nicvf_link_status_update(nic, &link); + rte_eth_linkstatus_set(dev, &link); + + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, + NULL); + } } rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, @@ -153,17 +145,16 @@ nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) if (wait_to_complete) { /* rte_eth_link_get() might need to wait up to 9 seconds */ for (i = 0; i < MAX_CHECK_TIME; i++) { - memset(&link, 0, sizeof(link)); - nicvf_set_eth_link_status(nic, &link); - if (link.link_status) + nicvf_link_status_update(nic, &link); + if (link.link_status == ETH_LINK_UP) break; rte_delay_ms(CHECK_INTERVAL); } } else { - memset(&link, 0, sizeof(link)); - nicvf_set_eth_link_status(nic, &link); + nicvf_link_status_update(nic, &link); } - return nicvf_atomic_write_link_status(dev, &link); + + return rte_eth_linkstatus_set(dev, &link); } static int -- 2.15.1