From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by dpdk.org (Postfix) with ESMTP id 48CCD1B1BD for ; Sat, 6 Jan 2018 02:07:11 +0100 (CET) Received: by mail-pl0-f67.google.com with SMTP id i6so4069858plt.13 for ; Fri, 05 Jan 2018 17:07:11 -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=N1zcln55tl4hCPwsPsMk6yY2Azk+Sj3KQ4kBjh0xtw/rdOajFGjgLjyjcgnW4QPdGT xt6qF8OS5JMAF/opy1gxdqKcIzGgRTWeyHHYW2uDp18sgoKTe0/iWmy41DZ5Ume+OJwb Z4zrVM5/4skvp8yNCNjHz558AMDUY1q6FbP87fl4JHWKRMiuu7PtipjJaSEV08Ezs26x jEKDLoKqcu6NAM+8DybWwCJV2Kyz+Hr8nP4iIzD3EZJq9sGYo7xmkp3JaLiS5rRw2xTX bG0W99CwLvVyfnkzKjU0g3atW+T1TQkZ6KpR9ggZOqbDQtSBXbIlMQseoF2fSOBnyrap /iiA== 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=e4Agxh5imxsJmfuCtVT04mbfH0ONRKF5O5P7DbyGRMcxOXEgQgcEIwAyBsMDe/Bkja 4fnrh3sK6Pv3T3C8NrC2Ni0yXtrqSxyj4fGgxXgW+kECx/QwLMw1sdnzun5g3Cy/yjuq s41uSeF/qV+RWywOXCI0hhQ9gj7zrgv5Aq4AFhmR8t2/7tJMyNOXh/7QDo3JNLwsM1Ro Hc/UMT5eysa6uhlBTmaZ+8ejzusYuOQ8XQgoh/yNG+1McMEFDckv0CbcMlWWi9sfL/kl Xu6GXTo5n2QZMlJW9iji+35P29mWihsLWvNDXmF9xhsXiVnWPotw+5OOOQjXfXx1/zHl +9Vg== X-Gm-Message-State: AKGB3mIWjc7z+ncHfyqGVAHAgQonGTt33oX7f2jcJUZrAetkQW1dd+yX t5Hsvg8MRZO+PLd7Baa6iFrrXjcAfvU= X-Google-Smtp-Source: ACJfBotYo9JwvpeZfYLSpWelbFnEvAetJ8UPNmbiuC627wDc9LahjtkjH5Wg5Qf3s9ffUiJA7Ks8Og== X-Received: by 10.84.214.137 with SMTP id j9mr4820044pli.440.1515200830166; Fri, 05 Jan 2018 17:07:10 -0800 (PST) Received: from xeon-e3.lan (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id p14sm12385018pgn.37.2018.01.05.17.07.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 17:07:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 5 Jan 2018 17:06:51 -0800 Message-Id: <20180106010656.9167-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180106010656.9167-1-stephen@networkplumber.org> References: <20180106010656.9167-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 10/15] 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: Sat, 06 Jan 2018 01:07:11 -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