From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by dpdk.org (Postfix) with ESMTP id 280347CAE for ; Fri, 14 Jul 2017 20:30:48 +0200 (CEST) Received: by mail-pf0-f179.google.com with SMTP id q86so49078566pfl.3 for ; Fri, 14 Jul 2017 11:30:47 -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=94tLYdLRy+7C5TiaRp+q6ioKdkXORZuy/2IlPDxbOaE=; b=jSiNmX7SKsUAHkWq3zh9D/obR7kwMlo0NxrDVzqzwqKVnwGqj84q/ZJ/Ru3UusveLm 4QnCGpUru43lHm3vSZ15HzHmdl3XSYaTa72hZDNouXrVvhVJqzjmgCiUkHRjcd1tEUcM nVdcL8aPFxeWCFJrXXB/SPfSI19c/3XoSzGLatIn+qsoza7mujE/etOCJaEIV2OKOKIg mfx14yj2bYFcOf3vskBTtz2/GUhhLPt5zHrSiM4LLWCCTckjY+sjkaBGXG++esbva9+a OKBe2DUsk+MOloeOFw206ll6iTygGG8MqSIjaUIeLSjX4HA29gBddh36qc8ye9U4uaLb kqKw== 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=94tLYdLRy+7C5TiaRp+q6ioKdkXORZuy/2IlPDxbOaE=; b=Evlzb3dDi1polYXFed6RAEC4RpGm5lNcyAVJ1Qn4uO9hzBJZ50cv3EyK9zAXqTIHkg 3EFxebRtIIV4CQRvJhlJQKLXua4ogpP5XKtMvvqJcAuD0N7sNOFnzM6aoBRnMXqBQPMg plQUSufaXG2U5nx6dgrG3EI36YhRwbaLPzBWtnXh8aMjGXlWOHF8LIl2ix8XpxyjXbIP ImyoauS9HJwDNXsUbDgO/1oKChyn9X+mLxf9LBkLk5u38qklfR3LlDvN5Q8KWuljBilR ambBexLtM7yRnWxRHWQCr/Z7JALXllvmgSWT7e4phaJFWzNbx4KF64j7NEaNvepVj9LJ Hb9Q== X-Gm-Message-State: AIVw110ycI4J0FVgyw37ypu/E/64WXFDDr4MdVKDkysaP1ymmARJkOCU jRLkLfCdJWowZgysxdcu3g== X-Received: by 10.84.232.7 with SMTP id h7mr17476618plk.193.1500057046910; Fri, 14 Jul 2017 11:30:46 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 11:30:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 14 Jul 2017 11:30:22 -0700 Message-Id: <20170714183027.16021-10-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 09/14] sfc: use new rte_eth_link helpers 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:48 -0000 Use the new API (_rte_eth_link_update) to handle link status update. ALso fixes a bug where this driver was not returning -1 when link status changed. 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 6b06f08f7c1a..f0a40ad06f23 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -231,22 +231,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; @@ -254,21 +244,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_link_read(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_link_update(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..fc88baef0ef3 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_link_update(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.11.0