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 2973F1B1B8 for ; Tue, 9 Jan 2018 17:29:10 +0100 (CET) Received: by mail-pf0-f196.google.com with SMTP id n6so8896880pfa.4 for ; Tue, 09 Jan 2018 08:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2phhHQZmegDwt/0JNdFseh7jeQdQAXInNnhMe+yh/yc=; b=iRJalKzE0iPQCEb9Iea0E2vB1gRis8Rj1aLOmaj+VrirzrJGe23EQVewT23VSZBuEd s9Pm8QL7UML9XBUUsqyBeznEplKUx87DRZnNRnj9etLF2J99j1IiUkDO5vzI2d7mpfvI E1uwrWam54H3z+Sa8VpgPyAZoQduRi7bmfjqULf3MDJBK84Aq33uEgL3leNbbtmAWwDa oXTHb1T3obiESeL5B10FKi9m9f+ezxvEzAxJ03EeQfoCmN2LMNsdUr3w7GWKUReuLynv 2OvNeQrWOT41R2zpRNwAD4XXgljOyn0yKt4d0X6LeqVO2lnRSc4qXiZ/WV1pF9+4RpSv mfdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2phhHQZmegDwt/0JNdFseh7jeQdQAXInNnhMe+yh/yc=; b=UVBV5SrJfvSvk7RIu6TrArA1lNbS2qjuzhdWLEjJhNpVuXPBJrpqw1eHXnCoDSX4cL aF8NXtGd9tr6A2BG3MD08r/U94YilSsswxX9WX5lrsGaVejC44YTxu0gnntYWfkCqgDw ECyfKM4K3GSPijDkr2RD90Tx6yUpc0doGKdjYuNwat30G+hvuLysPb3fBB4Ex8JakCZa sn3pLMs5dgPeLdpS6l7V2VyUiQiUjH59e7EmnDlE2/BR5fCOce5H+3GTXswfF99p7ujS sIEXilAxrVm8SZbSkSfhyN+zOKwn8plHoHIqLC/Z0m5jVTEIkYWVbmyxtTyL7EoDHQzi 0DZw== X-Gm-Message-State: AKGB3mL9+C/gOGAX47ajEVZSsxrTV0LUzjpU+e9fxAr8rinxukef5aMJ 46KcM5GKIUjaJ3LtpbJ+oSIG6Q== X-Google-Smtp-Source: ACJfBotHYI1YJNboeOIJOSQS21m67j5/nSVRZllZ2gPy5pqth5cI29OldJBzG40ja1+xnlPlmzwrjw== X-Received: by 10.84.217.217 with SMTP id d25mr7902124plj.312.1515515349195; Tue, 09 Jan 2018 08:29:09 -0800 (PST) Received: from xeon-e3 (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id v126sm2684209pfv.160.2018.01.09.08.29.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 08:29:09 -0800 (PST) Date: Tue, 9 Jan 2018 08:29:02 -0800 From: Stephen Hemminger To: Andrew Rybchenko Cc: Message-ID: <20180109082902.475cb461@xeon-e3> In-Reply-To: References: <20180108174514.14688-1-stephen@networkplumber.org> <20180108174514.14688-3-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 02/15] ethdev: add linkstatus get/set helper 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: Tue, 09 Jan 2018 16:29:10 -0000 On Tue, 9 Jan 2018 13:30:46 +0300 Andrew Rybchenko wrote: > On 01/08/2018 08:45 PM, Stephen Hemminger wrote: > > Many drivers are all doing copy/paste of the same code to atomically > > update the link status. Reduce duplication, and allow for future > > changes by having common function for this. > > > > Signed-off-by: Stephen Hemminger > > --- > > lib/librte_ether/rte_ethdev.c | 36 ++++++++++++++++++++++++++++++++++++ > > lib/librte_ether/rte_ethdev.h | 28 ++++++++++++++++++++++++++++ > > 2 files changed, 64 insertions(+) > > > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > > index a524af740f4a..6674500bbc4a 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -1495,6 +1495,42 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link) > > } > > } > > > > +int > > +_rte_eth_linkstatus_set(struct rte_eth_dev *dev, > > + const struct rte_eth_link *new_link) > > +{ > > + volatile uint64_t *dev_link > > + = (volatile uint64_t *)&(dev->data->dev_link); > > + union { > > + uint64_t val64; > > + struct rte_eth_link link; > > + } orig; > > + > > + RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t)); > > + > > + orig.val64 = rte_atomic64_exchange(dev_link, > > + *(const uint64_t *)new_link); > > + > > + return (orig.link.link_status == new_link->link_status) ? -1 : 0; > > It still contradicts to: -1 if link state has changed, 0 if the same. > BTW, it looks like the return value of the link_update callback is not > specified (described) and not used. It explains why different drivers > behave differently and nobody notices it. It looks like link_status callback could be void. The only places that use return value from set are code that wants to log something if status changed.