From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by dpdk.org (Postfix) with ESMTP id 5FCE01B2BB for ; Fri, 26 Jan 2018 03:02:05 +0100 (CET) Received: by mail-pg0-f67.google.com with SMTP id y27so6286182pgc.5 for ; Thu, 25 Jan 2018 18:02:05 -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=u1W0BYDftsCE9kHq+yYrNJOJ5dJ8t6MimpHgwouzbFI=; b=C9KXVSCn0nw/0h5fvrHHPpHQMyper/xQlwb6TW+hpIQwoA2V9vg6XAbSeATRbIMPBF I/vtLX8i9kdhwnPu6DHqnb/CYlLiXEQCr4fbZgdRiOk5CBZ8KTJ2aUivc0I4xtum8Wn2 gmkoERxW61+PFAm8PaoCvn9ZU37lQkN6QXn+AhVWerXSzm9vJm8HgFhbY4OSa0qlsyTz f/K35GAxpaS+Ngx9KoWLPhKJMqzMECaFN+vnb56eEzancHbUYG7QOQUafzhyw8RvbQJT Rwh9W1g2nWf9E5MSdAofPUCAQJcAEGkjKP8HMl4YTpefdCkZMwZhJuOaCqdM3eIPWUkB A1WQ== 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=u1W0BYDftsCE9kHq+yYrNJOJ5dJ8t6MimpHgwouzbFI=; b=g/L7jOewGt7ofMfhCEkFddeBwaKVCSnaj06jxwzQ6RzHJAlKGNyi2QHJSWBQSLLCKv 9Gg5WhsOzhKukypoW19zEfkGKwOCcEeknwBsikon3O4qRFr1HQWClGeC3/jDNSKGQhwn qiIvsHwDDuKyqvVYqH41557HX2fl2ffUinosLAmFxCeephtuWmUvslnFt/YdfwA3pdjm M2MSm+dIuardwOlBdQQwkNymsQvVycM7/2sfKviW3cvzmU3trNeg+t4Y1kt6yMa65lFG rkK8q7clQa1M5DQlOB+M5MhX29ziNB4cgEwqymnudQcU5SdW0f3r8gb13+stdO4FwTdW UwLQ== X-Gm-Message-State: AKwxytcrTvVAq2RMXCAyrVq0edUmmS8ksfiwuJTnDcjF5kSLlXK1aIfE 7ra3dPTH119JR3Qh1i5OYYpgQUt8PBw= X-Google-Smtp-Source: AH8x224APnB+QPbg9L1kVsyDiqZxNaN6nZYlWe5I/KksMQLba/D/+wrGXc1XZ+JA8Fc9vAMZWLbs6w== X-Received: by 2002:a17:902:bcc2:: with SMTP id o2-v6mr8862128pls.89.1516932124176; Thu, 25 Jan 2018 18:02:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 18:02:02 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 25 Jan 2018 18:01:46 -0800 Message-Id: <20180126020151.979-11-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 10/15] net/i40e: 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: Fri, 26 Jan 2018 02:02:05 -0000 Use new rte_linkstatus update API Signed-off-by: Stephen Hemminger --- drivers/net/i40e/i40e_ethdev.c | 46 ++++++--------------------------------- drivers/net/i40e/i40e_ethdev_vf.c | 19 ++-------------- 2 files changed, 9 insertions(+), 56 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index c4df65df0cf6..85c02e82d7db 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -628,34 +628,6 @@ static struct rte_pci_driver rte_i40e_pmd = { .remove = eth_i40e_pci_remove, }; -static inline int -rte_i40e_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; -} - -static inline int -rte_i40e_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; -} - RTE_PMD_REGISTER_PCI(net_i40e, rte_i40e_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_i40e, pci_id_i40e_map); RTE_PMD_REGISTER_KMOD_DEP(net_i40e, "* igb_uio | uio_pci_generic | vfio-pci"); @@ -2347,17 +2319,17 @@ i40e_dev_link_update(struct rte_eth_dev *dev, #define MAX_REPEAT_TIME 10 /* 1s (10 * 100ms) in total */ struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_link_status link_status; - struct rte_eth_link link, old; + struct rte_eth_link link; int status; unsigned rep_cnt = MAX_REPEAT_TIME; bool enable_lse = dev->data->dev_conf.intr_conf.lsc ? true : false; + int ret; memset(&link, 0, sizeof(link)); - memset(&old, 0, sizeof(old)); - memset(&link_status, 0, sizeof(link_status)); - rte_i40e_dev_atomic_read_link_status(dev, &old); do { + memset(&link_status, 0, sizeof(link_status)); + /* Get link status information from hardware */ status = i40e_aq_get_link_info(hw, enable_lse, &link_status, NULL); @@ -2410,13 +2382,10 @@ i40e_dev_link_update(struct rte_eth_dev *dev, ETH_LINK_SPEED_FIXED); out: - rte_i40e_dev_atomic_write_link_status(dev, &link); - if (link.link_status == old.link_status) - return -1; - + ret = rte_eth_linkstatus_set(dev, &link); i40e_notify_all_vfs_link_status(dev); - return 0; + return ret; } /* Get all the statistics of a VSI */ @@ -10034,9 +10003,8 @@ i40e_start_timecounters(struct rte_eth_dev *dev) uint32_t tsync_inc_h; /* Get current link speed. */ - memset(&link, 0, sizeof(link)); i40e_dev_link_update(dev, 1); - rte_i40e_dev_atomic_read_link_status(dev, &link); + rte_eth_linkstatus_get(dev, &link); switch (link.link_speed) { case ETH_SPEED_NUM_40G: diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 6ac3f8c04a50..800915386501 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1036,20 +1036,6 @@ static const struct rte_pci_id pci_id_i40evf_map[] = { { .vendor_id = 0, /* sentinel */ }, }; -static inline int -i40evf_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; -} - /* Disable IRQ0 */ static inline void i40evf_disable_irq0(struct i40e_hw *hw) @@ -2077,6 +2063,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, * while Linux driver does not */ + memset(&new_link, 0, sizeof(new_link)); /* Linux driver PF host */ switch (vf->link_speed) { case I40E_LINK_SPEED_100MB: @@ -2108,9 +2095,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_autoneg = dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED; - i40evf_dev_atomic_write_link_status(dev, &new_link); - - return 0; + return rte_eth_linkstatus_set(dev, &new_link); } static void -- 2.15.1