From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) by dpdk.org (Postfix) with ESMTP id C8651559A for ; Fri, 14 Jul 2017 20:30:42 +0200 (CEST) Received: by mail-pg0-f43.google.com with SMTP id u62so49286506pgb.3 for ; Fri, 14 Jul 2017 11:30:42 -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=EvZc/hOAuKZE+nufpkyw6S+HhMEL8LYvHsqMqNp6Zrs=; b=XTbERrllzMBo4aS0FxyclkGrmylWVDMkpyuHhkxMhZdpalGPAQOsQmOZoDK0B3nqMe BH3rQMZabVfLnGr0IfarYKOa5xbe7+SF3X1uN3GNLiFDZPcaNwr7OssVuAEjGx8q+Dth CFMyv7tIOdIQICn80Ck0oMd7+y01siEJ+Zoi5M9KVbcsQHp1e09ilBLhD5PggNqMkmgK wEgg1kx6qM2vYDwxHIIikzo/Ncksl6hLUTVmi5iG0OXpnb02ZP4TD4BuOarJXH9nzL4t EB8a3QmeQOoGoL2Il+eiW5oRD+J54nFAnjxNOzU4LvMPQ8/109zkxgVEH57r4omnukg5 W45Q== 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=EvZc/hOAuKZE+nufpkyw6S+HhMEL8LYvHsqMqNp6Zrs=; b=CNO04jWTCm/OaCQSYTlg/BW7o8MdFqFHLH8waQq4sW+ZCjFQQ4l9IqVKwCWxxn9Ali xzcbIef2dsny+mNiCx7G3+9WbEkN3Foz8VMAcJ6qIkBvXzmXgQ2TOZ3wPVPkqFtiCGzl IFq/1wjNxrRZP88WG+nmYL1Pfu/rlmLmX9tzYMmmnYsXqEJX+pHXlKwIBVihJBZEwbHl XllYzrcjmISAToutuxRwI6Pr/CBpACe08oTuevtMhCnyuUR9kAVPvFbcb7WMBIBsBwuS zpXGBNjG0CKkbqOjZ9FkgVcE+GYtdHVIVmw9W8okmMbYJMzopwnTCAyvKa3qsfDlelHx iuqw== X-Gm-Message-State: AIVw113CaGgziNTehd4tJ4ALLARVwlS1rcKbiYk7e8baW5TsQMpNyP+Q G6nvjXqe7ROwNKIV63Jxdg== X-Received: by 10.98.8.132 with SMTP id 4mr6691455pfi.109.1500057041733; Fri, 14 Jul 2017 11:30:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 11:30:40 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Date: Fri, 14 Jul 2017 11:30:18 -0700 Message-Id: <20170714183027.16021-6-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 05/14] dpaa2: use rte_eth_link_update 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:43 -0000 Use new helper function to update the link status. As a good side effect this fixes a but because this driver was not returning correct status (should be -1 in link_status changed). Signed-off-by: Stephen Hemminger --- drivers/net/dpaa2/dpaa2_ethdev.c | 66 +++++----------------------------------- 1 file changed, 8 insertions(+), 58 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 44a5bc2bdb3d..80ce1c5ef8cb 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -59,58 +59,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) { @@ -675,7 +623,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 @@ -707,7 +655,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 @@ -1021,8 +969,8 @@ dpaa2_dev_link_update(struct rte_eth_dev *dev, RTE_LOG(ERR, PMD, "dpni is NULL\n"); return 0; } - memset(&old, 0, sizeof(old)); - dpaa2_dev_atomic_read_link_status(dev, &old); + + _rte_eth_link_read(dev, &old); ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); if (ret < 0) { @@ -1044,13 +992,15 @@ 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); + _rte_eth_link_write(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\n", dev->data->port_id); - return 0; + + + return (old.link_status == link.link_status) ? -1 : 0; } /** -- 2.11.0