From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by dpdk.org (Postfix) with ESMTP id 95CB01B1A7 for ; Tue, 23 Jan 2018 00:55:18 +0100 (CET) Received: by mail-pg0-f67.google.com with SMTP id w17so8345420pgv.6 for ; Mon, 22 Jan 2018 15:55:18 -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=8Fgs76q4XO8BwuDbiuYp72oZu4vKPY5yhIjpFZeDjUA=; b=P1mYGErdD4uT54tZRwXRp0e4gyFqPDPPsfYzHDpVzUdA4cYoYWrSZnRde84OqSWWUt 6+j+fxhKFYF0u/JG9TDSyRHTzB7odfS7srhIGncsfEaw0l0EyQeTlplDgz9Kru/aSrT4 9bPJatH231pWLiy9d1JYWZZGgjj0UJSHi45QTZ3YlcTkYSuZVayJHz73gb8ARLosx1Q/ F2RFovIomzHkoOkCCF3gh2Kolv11ZJJdavXbhVwXnBXuU8OqTnZ2mPg+TSWSB6qCaY/r LDHhz4LfUKtw4VHHtVLAQjQJrR9JFUImmebpoEkPfKP1AX+K4Hqpcq8rScz6K2RJgQaQ tnQQ== 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=8Fgs76q4XO8BwuDbiuYp72oZu4vKPY5yhIjpFZeDjUA=; b=MFu04tSo85V7FJ4nTM36RsFMlhQP+2q37KEwpvUheFsiCKPLo3zAwL4ET0Ja/drx44 8VVNEBF7v/NLtm8jJjVfqTsOS9BgCnbVw1TaDuDK7sTKUjfN+jzjIHBlILTe/tYjRkPU jjWR0My950gJgKYrBypqcLd1Vvdo7z4lb0q9TKVhpgJHVM82uOzY1xxu5vw4ylCcNniw B3MPKlNXult121xbq+MxqjogScBHWF/4XohZ1mZ6KU6PFGCWP7RIzS53T69rmFnug25Y KYd0H392SJdummaWZ+4HYeRCQ6vgDJ0m2NqKXPpxALLj18zOrDj/MFdBGkkLunLD2Kd1 oOUQ== X-Gm-Message-State: AKwxytf4FKixDGLGzwGmaiJJK6fAHpU7xI1xkYhyIxdVaPIiVRE0GDmB 3msYk0pfmDzADkB65cX7Ndx24WHfkfk= X-Google-Smtp-Source: AH8x224KiHkqVw5MZEwwtLHU9rcUcRCIwg/ztX1f+f3gvY0lVW8s43kDJZ61pC8mdApd3FjQJq4YkA== X-Received: by 2002:a17:902:6b83:: with SMTP id p3-v6mr4225757plk.18.1516665317484; Mon, 22 Jan 2018 15:55:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 15:55:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 22 Jan 2018 15:54:55 -0800 Message-Id: <20180122235458.28562-13-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 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: Mon, 22 Jan 2018 23:55:18 -0000 Use new helper function. Signed-off-by: Stephen Hemminger --- drivers/net/thunderx/nicvf_ethdev.c | 48 ++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index d34938c64b1d..f23170c5a4a9 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,31 +68,20 @@ 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; + memset(link, 0, sizeof(*link)); - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} + link->link_autoneg = ETH_LINK_AUTONEG; + 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) link->link_duplex = ETH_LINK_FULL_DUPLEX; link->link_speed = nic->speed; - link->link_autoneg = ETH_LINK_AUTONEG; } static void @@ -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,17 @@ 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); + + rte_eth_linkstatus_set(dev, &link); + return 0; } static int -- 2.15.1