From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 8E52B1200A for ; Thu, 11 Jan 2018 18:07:46 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jan 2018 09:07:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,345,1511856000"; d="scan'208";a="19346246" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by orsmga003.jf.intel.com with ESMTP; 11 Jan 2018 09:07:40 -0800 From: Ferruh Yigit To: Bruce Richardson , Konstantin Ananyev , Beilei Xing , Qi Zhang Cc: dev@dpdk.org, Ferruh Yigit , Stephen Hemminger Date: Thu, 11 Jan 2018 17:06:53 +0000 Message-Id: <20180111170658.2809-10-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180111170658.2809-1-ferruh.yigit@intel.com> References: <20180108174514.14688-1-stephen@networkplumber.org> <20180111170658.2809-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v4 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: Thu, 11 Jan 2018 17:07:47 -0000 From: Stephen Hemminger 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 fb2b4d8c4..9f32edbac 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"); @@ -2345,17 +2317,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); @@ -2408,13 +2379,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 */ @@ -10032,7 +10000,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 86f94e926..dfda62272 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) @@ -2075,6 +2061,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: @@ -2106,9 +2093,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.14.3