From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id 47AA71B1D8 for ; Mon, 8 Jan 2018 18:45:32 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id n6so6457295pfa.4 for ; Mon, 08 Jan 2018 09:45:32 -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=TvMlPxxn/FC/MG9T049F4r35LqXuuk2Ag9awXe4b518=; b=2F2sOfMsAPnFgff4RDG3QjsQqUsvMiCs0AOthMiAshVBTBki94Y0EUbgc3FxiL4yAD vEjVhcKFzUwGueiy4XmDavCsmcd5lvVFBw4Pd81h3sn9u1EhDEwgtXyCdh15pqk6YKQV wTfaFR6t6aJyn69xRuqAe6IY6xiJ92UD3K/NnBy5KwwBM2diRNhQ7oGjXYhlZpx/yheX PN/rDrC/N8PUGqSkgxRjSJ8kfOVDt2fSY8gWTOm1OEElATlDuDv3DtGg7dkl8bDFfAON zdnV2niYP5rJLr4cR+NbrmserusWf1wV7rVH481NhBihP4hLdzjPHVUltnjfK9IXE53w pZMw== 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=TvMlPxxn/FC/MG9T049F4r35LqXuuk2Ag9awXe4b518=; b=r4pHHkiB8YJDENc/QQayZrw1EmtTP9AH15v94+hY+YiCmqBIpPII7l7XiX+Q/+a3Fx hmmfnqYXsEHOGLNft6ej2wImBfCXyA7Nn8je+pq0SuK6JQ7k8yZkqOSKzUcIPG4ip7wM E6kq6QIE/JKHp/9BMWtIPcFLF4v7CRhw1V8uRqryVHDe0B18LivXV/JPtMqGyDzK9/nU reCrj2H6uS3vYRXQ2OGVtJ97+dXPJQSvInkyK9no27pzmvY7ralEqZui2PFXvsu5RXeq f5yoYtP6IHOEgaTaGH49rVxjooHML+nU1zVwVQ3K8oVPTZ5FLlVoLPmQbnaB71qaRLB1 kA2Q== X-Gm-Message-State: AKGB3mK00NlKYVqMAvQNMVbk5mysIAI0cV9yQeY24kEDVNH240yHLkc7 29iyad1P+pjmffsDHC5xBqaRy5kp2mI= X-Google-Smtp-Source: ACJfBos4i39Z50iju00oKVgG1l5gPLTRfZIyKIKbx85SYLSolR533IahbLWmz8f+1MTc8TCMIWQjbw== X-Received: by 10.159.235.135 with SMTP id f7mr12792448plr.41.1515433531188; Mon, 08 Jan 2018 09:45:31 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id j14sm10933142pfh.94.2018.01.08.09.45.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 09:45:30 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 8 Jan 2018 09:45:05 -0800 Message-Id: <20180108174514.14688-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108174514.14688-1-stephen@networkplumber.org> References: <20180108174514.14688-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3 06/15] net/nfp: use 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: Mon, 08 Jan 2018 17:45:32 -0000 Use new _rte_eth_linkstatus_get/set helper function. Signed-off-by: Stephen Hemminger --- drivers/net/nfp/nfp_net.c | 75 +++++------------------------------------------ 1 file changed, 8 insertions(+), 67 deletions(-) diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 0501156bacb7..79c031ed2745 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -204,57 +204,6 @@ nn_cfg_writeq(struct nfp_net_hw *hw, int off, uint64_t val) nn_writeq(rte_cpu_to_le_64(val), hw->ctrl_bar + off); } -/* - * Atomically reads 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 -nfp_net_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 -nfp_net_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 void nfp_net_rx_queue_release_mbufs(struct nfp_net_rxq *rxq) { @@ -977,7 +926,7 @@ static int nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) { struct nfp_net_hw *hw; - struct rte_eth_link link, old; + struct rte_eth_link link; uint32_t nn_link_status; static const uint32_t ls_to_ethtool[] = { @@ -995,9 +944,6 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private); - memset(&old, 0, sizeof(old)); - nfp_net_dev_atomic_read_link_status(dev, &old); - nn_link_status = nn_cfg_readl(hw, NFP_NET_CFG_STS); memset(&link, 0, sizeof(struct rte_eth_link)); @@ -1015,15 +961,13 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) else link.link_speed = ls_to_ethtool[nn_link_status]; - if (old.link_status != link.link_status) { - nfp_net_dev_atomic_write_link_status(dev, &link); - if (link.link_status) - PMD_DRV_LOG(INFO, "NIC Link is Up\n"); - else - PMD_DRV_LOG(INFO, "NIC Link is Down\n"); + if (_rte_eth_linkstatus_set(dev, &link) == 0) return 0; - } + if (link.link_status) + PMD_DRV_LOG(INFO, "NIC Link is Up\n"); + else + PMD_DRV_LOG(INFO, "NIC Link is Down\n"); return -1; } @@ -1354,8 +1298,7 @@ nfp_net_dev_link_status_print(struct rte_eth_dev *dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); struct rte_eth_link link; - memset(&link, 0, sizeof(link)); - nfp_net_dev_atomic_read_link_status(dev, &link); + _rte_eth_linkstatus_get(dev, &link); if (link.link_status) RTE_LOG(INFO, PMD, "Port %d: Link Up - speed %u Mbps - %s\n", dev->data->port_id, link.link_speed, @@ -1408,9 +1351,7 @@ nfp_net_dev_interrupt_handler(void *param) PMD_DRV_LOG(DEBUG, "We got a LSC interrupt!!!\n"); - /* get the link status */ - memset(&link, 0, sizeof(link)); - nfp_net_dev_atomic_read_link_status(dev, &link); + _rte_eth_linkstatus_get(dev, &link); nfp_net_link_update(dev, 0); -- 2.15.1