From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by dpdk.org (Postfix) with ESMTP id EDF751B1B8 for ; Sat, 6 Jan 2018 02:07:09 +0100 (CET) Received: by mail-pl0-f66.google.com with SMTP id o2so4058686plk.12 for ; Fri, 05 Jan 2018 17:07:09 -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=3I0M5YwWxRQQ9evbooznIc4kTdDeTE8HKmYsp5iVPJM=; b=KeqnRF/g1BTNEt3JQwn3tKYd1QQJf8xtA4rAuNOJ30Tg65lfds1ASGBnkXjx7iNCkd h2SfiktrUErnYEiS8t6ygTNgHG7NB480PofvEv08SXwIdG8cSf3493xg1YEPYKtrcVdR CB73e8fU82ZzVw3i8nLfIzIXmN0ZP8SW8mKCd1iMRnFypWR2h/jV691XWobHvpGEQ86H RVItuK6cXu8ol9RYWHFnypJAmql8kKkycFybvfRVb/tUHS44Ja4a5C4qGeawS4AZ0I8m UvepLn7zi1wGWRNxBJbas+EeTyqa6xXMkpJKuhuxlPwsByiWS4rQy5ChmpOSqkNtt1JA 69mQ== 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=3I0M5YwWxRQQ9evbooznIc4kTdDeTE8HKmYsp5iVPJM=; b=h1HHiMj8XlPCP5wgnjOF+zl6GYv/spxIlmoWPf1PQWOPkDlLp1mMSbaaeoGzGyvaYV If7nQvfZZkG7j8m0GBfLavXTJDHSVtRE1AvVWVs7HSbtZ3f3cXRKFpGss7oaXSLmEE9p wqLXEWoOv7GG6qVEZt69+XW2lZ9ehC7tr5HBSV/Vb6P6kP0cT+bb01PdjXnLVeuDCH6S 9j/u+MszG2YgtZ+ARogKZgiK8Kk9lV18P4fMW42fDHJebKpqOTAaJ4shOgsZVjY52A0S WwqY0oWx+DnUiNwwOR6KFXBYDBJIsp9I0WYXWJ9gTiupLZmP/sdiPtwXDXrZKDl5FsWT QXtA== X-Gm-Message-State: AKGB3mKGCTvOMfj6knLvzAHfC0P+O7B4nfjKVAEhO7h1hl0r3bz792tb 43G27RNp81pK6+XPNFQ7fi0y3CBPfLU= X-Google-Smtp-Source: ACJfBougXk5aWw2/lkPrN/TZRSsa8qfYOER3AW2Ek4UyrxdI0C4Wb7bputj6a1qzUz0FBiYGPakYAg== X-Received: by 10.84.138.193 with SMTP id 59mr4797106plp.254.1515200828848; Fri, 05 Jan 2018 17:07:08 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id p14sm12385018pgn.37.2018.01.05.17.07.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 17:07:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 5 Jan 2018 17:06:50 -0800 Message-Id: <20180106010656.9167-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106010656.9167-1-stephen@networkplumber.org> References: <20180106010656.9167-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 09/15] sfc: use new rte_eth_linkstatus functions 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: Sat, 06 Jan 2018 01:07:10 -0000 Use the new API (_rte_eth_linkstatus_set) to handle link status update. Signed-off-by: Stephen Hemminger --- drivers/net/sfc/sfc_ethdev.c | 27 +++++++-------------------- drivers/net/sfc/sfc_ev.c | 23 ++++------------------- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 2f5f86f84877..e0a12b32b1a3 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -238,22 +238,12 @@ static int sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) { struct sfc_adapter *sa = dev->data->dev_private; - struct rte_eth_link *dev_link = &dev->data->dev_link; - struct rte_eth_link old_link; struct rte_eth_link current_link; sfc_log_init(sa, "entry"); -retry: - EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); - *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link); - if (sa->state != SFC_ADAPTER_STARTED) { sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, ¤t_link); - if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link, - *(uint64_t *)&old_link, - *(uint64_t *)¤t_link)) - goto retry; } else if (wait_to_complete) { efx_link_mode_t link_mode; @@ -261,21 +251,18 @@ sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) link_mode = EFX_LINK_UNKNOWN; sfc_port_link_mode_to_info(link_mode, ¤t_link); - if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link, - *(uint64_t *)&old_link, - *(uint64_t *)¤t_link)) - goto retry; } else { sfc_ev_mgmt_qpoll(sa); - *(int64_t *)¤t_link = - rte_atomic64_read((rte_atomic64_t *)dev_link); + _rte_eth_linkstatus_get(dev, ¤t_link); } - if (old_link.link_status != current_link.link_status) - sfc_info(sa, "Link status is %s", - current_link.link_status ? "UP" : "DOWN"); + if (_rte_eth_linkstatus_set(dev, ¤t_link) == 0) + return 0; + + sfc_info(sa, "Link status is %s", + current_link.link_status ? "UP" : "DOWN"); - return old_link.link_status == current_link.link_status ? 0 : -1; + return -1; } static void diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index a16dc27b380e..3e96536a9d60 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -404,29 +404,14 @@ sfc_ev_link_change(void *arg, efx_link_mode_t link_mode) { struct sfc_evq *evq = arg; struct sfc_adapter *sa = evq->sa; - struct rte_eth_link *dev_link = &sa->eth_dev->data->dev_link; struct rte_eth_link new_link; - uint64_t new_link_u64; - uint64_t old_link_u64; - - EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t)); sfc_port_link_mode_to_info(link_mode, &new_link); + if (_rte_eth_linkstatus_set(sa->eth_dev, &new_link) == 0) + return B_FALSE; - new_link_u64 = *(uint64_t *)&new_link; - do { - old_link_u64 = rte_atomic64_read((rte_atomic64_t *)dev_link); - if (old_link_u64 == new_link_u64) - break; - - if (rte_atomic64_cmpset((volatile uint64_t *)dev_link, - old_link_u64, new_link_u64)) { - evq->sa->port.lsc_seq++; - break; - } - } while (B_TRUE); - - return B_FALSE; + evq->sa->port.lsc_seq++; + return B_TRUE; } static const efx_ev_callbacks_t sfc_ev_callbacks = { -- 2.15.1