From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id E4D5B2BF4 for ; Sun, 21 Jan 2018 20:00:18 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2018 11:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,392,1511856000"; d="scan'208";a="28253677" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by orsmga002.jf.intel.com with ESMTP; 21 Jan 2018 11:00:16 -0800 From: Ferruh Yigit To: Bruce Richardson , Konstantin Ananyev , Beilei Xing , Qi Zhang Cc: dev@dpdk.org, Ferruh Yigit , Stephen Hemminger Date: Sun, 21 Jan 2018 18:59:51 +0000 Message-Id: <20180121185956.32970-9-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180121185956.32970-1-ferruh.yigit@intel.com> References: <20180116183755.24542-1-stephen@networkplumber.org> <20180121185956.32970-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v6 09/14] net/i40e: use ethdev linkstatus helper 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: Sun, 21 Jan 2018 19:00:19 -0000 From: Stephen Hemminger Use new rte_linkstatus update API Signed-off-by: Stephen Hemminger Signed-off-by: Ferruh Yigit --- v6: * Keep logic exact same, only use new APIs to get/set link --- drivers/net/i40e/i40e_ethdev.c | 39 +++++---------------------------------- drivers/net/i40e/i40e_ethdev_vf.c | 19 +++---------------- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 5ea9f9917..0b102c0de 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"); @@ -2353,11 +2325,11 @@ i40e_dev_link_update(struct rte_eth_dev *dev, 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); + rte_eth_linkstatus_get(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,7 +2382,7 @@ i40e_dev_link_update(struct rte_eth_dev *dev, ETH_LINK_SPEED_FIXED); out: - rte_i40e_dev_atomic_write_link_status(dev, &link); + rte_eth_linkstatus_set(dev, &link); if (link.link_status == old.link_status) return -1; @@ -10034,9 +10006,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 0cca0d324..8e61fa84f 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: @@ -2106,9 +2093,9 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, new_link.link_status = vf->link_up ? ETH_LINK_UP : ETH_LINK_DOWN; new_link.link_autoneg = - dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED; + dev->data->dev_conf.link_speeds & ETH_LINK_FIXED; - i40evf_dev_atomic_write_link_status(dev, &new_link); + rte_eth_linkstatus_set(dev, &new_link); return 0; } -- 2.14.3