From: Stephen Hemminger <step...@networkplumber.org>

Use new rte_linkstatus update API

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
Signed-off-by: Ferruh Yigit <ferruh.yi...@intel.com>
---
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

Reply via email to