From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id 25B931B1B7 for ; Mon, 8 Jan 2018 18:45:37 +0100 (CET) Received: by mail-pg0-f68.google.com with SMTP id f14so3433644pga.10 for ; Mon, 08 Jan 2018 09:45:37 -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=WN+d3pT/9tfPG5gQNs+9cYsLTepnmWlqubdSvwola/M=; b=H8jgnze0zBsAXMITPIH4EbEMA5t4JZMghAuGHqOCJ8jtBxDz7VLz28NL0dr5lPXqeu wDoevnN2asVhHzxlZWxc0GHI1FOxgxtuu7q2yUuY1hVvNLE3qcAt9AitJXo6JQmfoYKb 88V+TIPC5yPMLvEuZLeywjUOgujma2ve7h6XLI2jASwW7q1+JW4ItRSgLipUc7YQeGJp 1tlC6V47F5n//fm7e+KlPp+EbrC3yH9YUxbTb2GsF/ilTKx8HGf+VJA2pG5hN3cRhoR/ MJ28OYEDSQ/YQeS5tA1hMFM49nzD36cSDW64phbqifArBrxYEOi2g/YLquHe2E8KGD6h Glpg== 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=WN+d3pT/9tfPG5gQNs+9cYsLTepnmWlqubdSvwola/M=; b=RaR9XxVioNp439ZrlNkeFD3IYua+9LzYg4Xc3fDsLfov7S+o1lM93XpyuVpoG35CzV VykJLyQaRIlP9gzlx1FJ7DtGIfSWAAmfqwnCcp+rysiCRwsnrQpzZDxH0Eqksx+3nWKu env0WUXw/lySsn1XaQoB2VAVKpZDOVnSozT1EtdvSbN9OAXBtCzu/B2mhowM3Pu8FEUv hOMzdobFhkIxmZ0PswpOsaglfxC9Pjyw0JDwWJAlh5FMlr59AxYQGLbw3vMN7ggO1ooX pPIx4DnQfTQ9pjLi0F+53tL3n8KKPPiFGsxLcoHtWT8MIoTPeZdx5/5RVKOOHi7P1dNX 2R1A== X-Gm-Message-State: AKGB3mJTY5fURlsgogVNX5bCpgOaONoyblUbJMWFtLh7y2NfZamSD9Wm R0xZj+PhSq2ZCsO0ntUsVXye1oMYWa0= X-Google-Smtp-Source: ACJfBov2WQDG2Hj7GQ9cVz+W3WouNPllloN6R+qcABx2PtYdzy/FKQ0DrPqlStdwH6SRZY0GsSBmPw== X-Received: by 10.84.248.68 with SMTP id e4mr12865095pln.296.1515433535963; Mon, 08 Jan 2018 09:45:35 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 09:45:34 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 8 Jan 2018 09:45:09 -0800 Message-Id: <20180108174514.14688-11-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 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: Mon, 08 Jan 2018 17:45:37 -0000 Use new rte_linkstatus update API Signed-off-by: Stephen Hemminger --- drivers/net/i40e/i40e_ethdev.c | 44 ++++++--------------------------------- drivers/net/i40e/i40e_ethdev_vf.c | 19 ++--------------- 2 files changed, 8 insertions(+), 55 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 285d92b3e7df..75affed2936f 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -627,34 +627,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"); @@ -2327,17 +2299,16 @@ 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; 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); @@ -2390,13 +2361,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; - + status = _rte_eth_linkstatus_set(dev, &link); i40e_notify_all_vfs_link_status(dev); - return 0; + return status; } /* Get all the statistics of a VSI */ @@ -9854,7 +9822,7 @@ i40e_start_timecounters(struct rte_eth_dev *dev) /* 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 b96d77a0caed..44c6c5b62a90 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1034,20 +1034,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) @@ -2069,6 +2055,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: @@ -2100,9 +2087,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