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 340DF1B00C for ; Tue, 23 Jan 2018 00:55:09 +0100 (CET) Received: by mail-pf0-f193.google.com with SMTP id t5so8347535pfi.0 for ; Mon, 22 Jan 2018 15:55: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=JO7bFCh8CO1AXQoTkl8sZ9HveDhAKT5busY7SmAbYZo=; b=VyQGZ8XYuDX35ga3YMCtOEjivfaSSiu+eKY8gG/GkOn0MpnX9DP9SxhXHF0aFtVu0o euAPMqmKIePBd5k2sqhNe3dcNVeNjeySGsuScFH9KcRzWaYiPGzGcgbupHJ65V0XErd0 1snj6QwOB8d50v5rwIASi9yu7DaFaRIVeGHQLcD8621Ho4zgf22etWYWY1loZ8wox+Gw JgV6jIwLB8rTknsJvyysvpVKGwT3Q7IhtAbcBL+8sbekefgcHD/tr3UrPsIhaS2THMW6 PgtBvK7T27VBTZucff7CFnBS27ZyEM2rmwCU+MsyL4VM0UbK3Qau4h/VFbP/j8Z/EV0N rAdw== 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=JO7bFCh8CO1AXQoTkl8sZ9HveDhAKT5busY7SmAbYZo=; b=MXJO/yR9Ice9VGL861iifI40Fi6vWg8KAXO+OraHK/oyrDqa2SqnZseW3Dma4EM5Tu E923eJFH/Jvoro3fU4klP9AzZaH1/5PDsmhQV+oe9YItYPveIqATNalzCDQcdkongfE/ tC0Z5Hv23JGv5rVgVVl3hX3OMfjOj7lABbwZbREtVlxr+nl3N49Sr66unbYOd/dkIqcL fII7DSMGExu6e6sWYs99oQkYj5msupnCcOeWMT/yuuwnClbHdfgTe9UCu9qEPpVa1YCW jbyu12g6qsy+lakUJl+ayd6xhMF7hgscEYg09nvsh/yWDK2EUFex2KjuzUnPY5RZitpb +/3A== X-Gm-Message-State: AKwxytd7VvvdH/oeJscNtiGDgrNR6J1pP9V2aOFynN8+vFHRI40sH8iq sC9dO43k8rkZ+AQYI9T3SnHkrXIlWSI= X-Google-Smtp-Source: AH8x226LoCBOWXElI3ORGxuOD0w0VZLblHRJFpTpXd3g69fTjLUH2+22/gsrUSp0rBczYZ2MIvZv2g== X-Received: by 10.99.114.28 with SMTP id n28mr7621142pgc.86.1516665308128; Mon, 22 Jan 2018 15:55: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 a24sm1623825pff.160.2018.01.22.15.55.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 15:55:07 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 22 Jan 2018 15:54:48 -0800 Message-Id: <20180122235458.28562-6-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 05/15] net/dpaa2: 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:09 -0000 Use new helper function to update the link status. Signed-off-by: Stephen Hemminger Acked-by: Shreyansh Jain --- drivers/net/dpaa2/dpaa2_ethdev.c | 75 ++++------------------------------------ 1 file changed, 7 insertions(+), 68 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 09a11d65af93..66d1b1eaad4a 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -57,58 +57,6 @@ static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev); static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev); static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); -/** - * Atomically reads the link status information from global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static inline int -dpaa2_dev_atomic_read_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = link; - struct rte_eth_link *src = &dev->data->dev_link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - -/** - * Atomically writes the link status information into global - * structure rte_eth_dev. - * - * @param dev - * - Pointer to the structure rte_eth_dev to read from. - * - Pointer to the buffer to be saved with the link status. - * - * @return - * - On success, zero. - * - On failure, negative value. - */ -static inline int -dpaa2_dev_atomic_write_link_status(struct rte_eth_dev *dev, - struct rte_eth_link *link) -{ - struct rte_eth_link *dst = &dev->data->dev_link; - struct rte_eth_link *src = link; - - if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, - *(uint64_t *)src) == 0) - return -1; - - return 0; -} - static int dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) { @@ -852,7 +800,7 @@ dpaa2_dev_stop(struct rte_eth_dev *dev) /* clear the recorded link status */ memset(&link, 0, sizeof(link)); - dpaa2_dev_atomic_write_link_status(dev, &link); + _rte_eth_link_write(dev, &link); } static void @@ -884,7 +832,7 @@ dpaa2_dev_close(struct rte_eth_dev *dev) } memset(&link, 0, sizeof(link)); - dpaa2_dev_atomic_write_link_status(dev, &link); + _rte_eth_link_write(dev, &link); } static void @@ -1335,15 +1283,13 @@ dpaa2_dev_link_update(struct rte_eth_dev *dev, int ret; struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; - struct rte_eth_link link, old; + struct rte_eth_link link; struct dpni_link_state state = {0}; if (dpni == NULL) { RTE_LOG(ERR, PMD, "dpni is NULL\n"); return 0; } - memset(&old, 0, sizeof(old)); - dpaa2_dev_atomic_read_link_status(dev, &old); ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); if (ret < 0) { @@ -1351,11 +1297,6 @@ dpaa2_dev_link_update(struct rte_eth_dev *dev, return -1; } - if ((old.link_status == state.up) && (old.link_speed == state.rate)) { - RTE_LOG(DEBUG, PMD, "No change in status\n"); - return -1; - } - memset(&link, 0, sizeof(struct rte_eth_link)); link.link_status = state.up; link.link_speed = state.rate; @@ -1365,12 +1306,10 @@ dpaa2_dev_link_update(struct rte_eth_dev *dev, else link.link_duplex = ETH_LINK_FULL_DUPLEX; - dpaa2_dev_atomic_write_link_status(dev, &link); - - if (link.link_status) - PMD_DRV_LOG(INFO, "Port %d Link is Up\n", dev->data->port_id); - else - PMD_DRV_LOG(INFO, "Port %d Link is Down", dev->data->port_id); + if (rte_eth_linkstatus_set(dev, &link)) { + PMD_DRV_LOG(INFO, "Port %d Link is %s\n", dev->data->port_id, + link.link_status ? "Up" : "Down"); + } return 0; } -- 2.15.1