From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id C16EB1B2A6 for ; Fri, 26 Jan 2018 03:02:03 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id t12so7203913pfg.2 for ; Thu, 25 Jan 2018 18:02:03 -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=WpB4bodauw/F9NsBvGKnFV5LgObcnqOyrFhjQ4l571M=; b=a6wRxryRXYG8Q8gJj5jTZo8nYt6Iy7J8pILkMclSYOnOvxLsSrE5LFj95fBPcb+Zxo wAna8bhp+HOgrWgeqURMiSAu7UBc9jm+EMKxESy53fy1UIp5ETq0Vu/ILSH4AyP/oDQO FVWjQqqgESFEtPBD5qBZunaaGufHsb36PGAf6cJhvl7FkJoJUnyZorn3T1kYCUge0b6C YV+zmGAnAP7dwl6hC/HUS5a1Nhx+L9tc3IEjNXkB6zU1XtFDDB3Rlc88/Q5ZltwkdY8+ X2izX55kksFEi1QkjuZQUEk0SHcmJUCe6SVb+uCYcsroKq0e49yHq3znbVT4UHZsb/lD 30LQ== 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=WpB4bodauw/F9NsBvGKnFV5LgObcnqOyrFhjQ4l571M=; b=LDIiaYI7rtYytYcf/g4fc0kzTnz/l5HyBsiyyRZfl+ABmzQfqM3joezGyaZX1/fhmB cI4IRFIu6/SN6P2H5fDxDrHXMPONGOKVY+SKyAOzhlI0bSdXAqnPCdsqWpBoVayxM0CT XaKO1jp7k7ZuiKJ12kPbToyWj4+3FyBa70aSv7AifHlqof9ON1NjX6SZUZEAn5asSMwJ XLUqKM0w2SOnIGb3mMtE6/nwWDnrSV/sKlEmIqqfV8cGfR27xEoISrLHGzYR8INpVk9l tyE00OTurU0ol1JPcI5+9z3hScwBgSrR/I7L2XLkLeHiOg6bog9zlS3ErNoMeBGjo9yb Mpdg== X-Gm-Message-State: AKwxytdoSHGS+a3FQ3Bom11obLZmg9fmSbnbF1M9WH/VIJbyfRmGvErf b2Mv59Vfk+POLsEEY2haxwcgZFOuaJg= X-Google-Smtp-Source: AH8x2274caZH2Ml9i4uZd02tyQEH5Plkfnqm/j7c1He54aRrk6eUSIA+YfxB/NKuEQ6YCuL8dVgYSQ== X-Received: by 2002:a17:902:229:: with SMTP id 38-v6mr11283272plc.429.1516932122650; Thu, 25 Jan 2018 18:02:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 18:02:01 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 25 Jan 2018 18:01:45 -0800 Message-Id: <20180126020151.979-10-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 09/15] net/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: Fri, 26 Jan 2018 02:02:04 -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 | 24 +++++------------------- drivers/net/sfc/sfc_ev.c | 20 ++------------------ 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 89a452907621..7d51db979a03 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -236,22 +236,13 @@ 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; + int ret; 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; @@ -259,21 +250,16 @@ 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) + ret = rte_eth_linkstatus_set(dev, ¤t_link); + if (ret == 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 ret; } static void diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c index 7abe61ae5ff1..273a92ccb222 100644 --- a/drivers/net/sfc/sfc_ev.c +++ b/drivers/net/sfc/sfc_ev.c @@ -382,27 +382,11 @@ 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); - - 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); + if (rte_eth_linkstatus_set(sa->eth_dev, &new_link)) + evq->sa->port.lsc_seq++; return B_FALSE; } -- 2.15.1