On 01/26/2018 05:01 AM, Stephen Hemminger wrote:
Use the new API rte_eth_linkstatus_set to handle link status update.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
  drivers/net/sfc/sfc_ethdev.c | 24 +++++-------------------
  drivers/net/sfc/sfc_ev.c     | 20 ++------------------
  2 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 89a452907621..7d51db979a03 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -236,22 +236,13 @@ static int
  sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
  {
        struct sfc_adapter *sa = dev->data->dev_private;
-       struct rte_eth_link *dev_link = &dev->data->dev_link;
-       struct rte_eth_link old_link;
        struct rte_eth_link current_link;
+       int ret;
sfc_log_init(sa, "entry"); -retry:
-       EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
-       *(int64_t *)&old_link = rte_atomic64_read((rte_atomic64_t *)dev_link);
-
        if (sa->state != SFC_ADAPTER_STARTED) {
                sfc_port_link_mode_to_info(EFX_LINK_UNKNOWN, &current_link);
-               if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
-                                        *(uint64_t *)&old_link,
-                                        *(uint64_t *)&current_link))
-                       goto retry;
        } else if (wait_to_complete) {
                efx_link_mode_t link_mode;
@@ -259,21 +250,16 @@ sfc_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
                        link_mode = EFX_LINK_UNKNOWN;
                sfc_port_link_mode_to_info(link_mode, &current_link);
- if (!rte_atomic64_cmpset((volatile uint64_t *)dev_link,
-                                        *(uint64_t *)&old_link,
-                                        *(uint64_t *)&current_link))
-                       goto retry;
        } else {
                sfc_ev_mgmt_qpoll(sa);
-               *(int64_t *)&current_link =
-                       rte_atomic64_read((rte_atomic64_t *)dev_link);
+               rte_eth_linkstatus_get(dev, &current_link);
        }
- if (old_link.link_status != current_link.link_status)
+       ret = rte_eth_linkstatus_set(dev, &current_link);
+       if (ret == 0)
                sfc_info(sa, "Link status is %s",
                         current_link.link_status ? "UP" : "DOWN");
-
-       return old_link.link_status == current_link.link_status ? 0 : -1;
+       return ret;
  }
static void

These changes are OK.

diff --git a/drivers/net/sfc/sfc_ev.c b/drivers/net/sfc/sfc_ev.c
index 7abe61ae5ff1..273a92ccb222 100644
--- a/drivers/net/sfc/sfc_ev.c
+++ b/drivers/net/sfc/sfc_ev.c
@@ -382,27 +382,11 @@ sfc_ev_link_change(void *arg, efx_link_mode_t link_mode)
  {
        struct sfc_evq *evq = arg;
        struct sfc_adapter *sa = evq->sa;
-       struct rte_eth_link *dev_link = &sa->eth_dev->data->dev_link;
        struct rte_eth_link new_link;
-       uint64_t new_link_u64;
-       uint64_t old_link_u64;
-
-       EFX_STATIC_ASSERT(sizeof(*dev_link) == sizeof(rte_atomic64_t));
sfc_port_link_mode_to_info(link_mode, &new_link);
-
-       new_link_u64 = *(uint64_t *)&new_link;
-       do {
-               old_link_u64 = rte_atomic64_read((rte_atomic64_t *)dev_link);
-               if (old_link_u64 == new_link_u64)
-                       break;
-
-               if (rte_atomic64_cmpset((volatile uint64_t *)dev_link,
-                                       old_link_u64, new_link_u64)) {
-                       evq->sa->port.lsc_seq++;
-                       break;
-               }
-       } while (B_TRUE);
+       if (rte_eth_linkstatus_set(sa->eth_dev, &new_link))
+               evq->sa->port.lsc_seq++;
return B_FALSE;
  }

Let me repeat part of my review notes for v4:
>>
lsc_seq should be incremented in the case of any changes in link,
not up/down changes only and it should be preserved.
<<
and I'd like to keep it here. Thanks to rte_atomic64_exchange()
the function can be simplified to:
 - convert link mode to link info (as now)
 - do exchange
 - compare old and new value as uint64_t and increment lsc_seq
   if different

Thanks.

Reply via email to