net/ice: fix link status error when dev start

Message ID 1669207333-8769-1-git-send-email-hanshuang87@gmail.com (mailing list archive)
State Changes Requested, archived
Delegated to: Qi Zhang
Headers
Series net/ice: fix link status error when dev start |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance fail Performance Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Shuang Han Nov. 23, 2022, 12:42 p.m. UTC
  ice_link_update get port link status and wait for one second when dev start.
If the device need almost one second for link up,
ice_link_update will enter the last rte_delay_ms(CHECK_INTERVAL) with link down,
in the meantime link interrupt raised,
the interrupt handler update dev->data->dev_link to up.
After a while the rte_delay_ms(CHECK_INTERVAL) finished
and update dev->data->dev_link to down.

Signed-off-by: Shuang Han <hanshuang87@gmail.com>
---
 drivers/net/ice/ice_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Qi Zhang Dec. 13, 2022, 1:50 a.m. UTC | #1
> -----Original Message-----
> From: Shuang Han <hanshuang87@gmail.com>
> Sent: Wednesday, November 23, 2022 8:42 PM
> To: dev@dpdk.org
> Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Shuang Han <hanshuang87@gmail.com>
> Subject: [PATCH] net/ice: fix link status error when dev start
> 
> ice_link_update get port link status and wait for one second when dev start.
> If the device need almost one second for link up, ice_link_update will enter
> the last rte_delay_ms(CHECK_INTERVAL) with link down, in the meantime
> link interrupt raised, the interrupt handler update dev->data->dev_link to up.
> After a while the rte_delay_ms(CHECK_INTERVAL) finished and update dev-
> >data->dev_link to down.
> 
> Signed-off-by: Shuang Han <hanshuang87@gmail.com>
> ---
>  drivers/net/ice/ice_ethdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 0bc739d..316ba5a 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -4013,9 +4013,9 @@ static int ice_init_rss(struct ice_pf *pf)
>  			      RTE_ETH_LINK_SPEED_FIXED);
> 
>  out:
> -	ice_atomic_write_link_status(dev, &link);
>  	if (link.link_status == old.link_status)
>  		return -1;
> +	ice_atomic_write_link_status(dev, &link);

This looks like a workaround, I think we may need some lock to prevent ice_link_update be re-entered from different thread at same time.

> 
>  	return 0;
>  }
> --
> 1.8.3.1
  
Shuang Han Dec. 13, 2022, 3:12 a.m. UTC | #2
I agree. Maybe this is the better solution

Zhang, Qi Z <qi.z.zhang@intel.com> 于2022年12月13日周二 09:50写道:

>
>
> > -----Original Message-----
> > From: Shuang Han <hanshuang87@gmail.com>
> > Sent: Wednesday, November 23, 2022 8:42 PM
> > To: dev@dpdk.org
> > Cc: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> > <qi.z.zhang@intel.com>; Shuang Han <hanshuang87@gmail.com>
> > Subject: [PATCH] net/ice: fix link status error when dev start
> >
> > ice_link_update get port link status and wait for one second when dev
> start.
> > If the device need almost one second for link up, ice_link_update will
> enter
> > the last rte_delay_ms(CHECK_INTERVAL) with link down, in the meantime
> > link interrupt raised, the interrupt handler update dev->data->dev_link
> to up.
> > After a while the rte_delay_ms(CHECK_INTERVAL) finished and update dev-
> > >data->dev_link to down.
> >
> > Signed-off-by: Shuang Han <hanshuang87@gmail.com>
> > ---
> >  drivers/net/ice/ice_ethdev.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> index
> > 0bc739d..316ba5a 100644
> > --- a/drivers/net/ice/ice_ethdev.c
> > +++ b/drivers/net/ice/ice_ethdev.c
> > @@ -4013,9 +4013,9 @@ static int ice_init_rss(struct ice_pf *pf)
> >                             RTE_ETH_LINK_SPEED_FIXED);
> >
> >  out:
> > -     ice_atomic_write_link_status(dev, &link);
> >       if (link.link_status == old.link_status)
> >               return -1;
> > +     ice_atomic_write_link_status(dev, &link);
>
> This looks like a workaround, I think we may need some lock to prevent
> ice_link_update be re-entered from different thread at same time.
>
> >
> >       return 0;
> >  }
> > --
> > 1.8.3.1
>
>
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 0bc739d..316ba5a 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -4013,9 +4013,9 @@  static int ice_init_rss(struct ice_pf *pf)
 			      RTE_ETH_LINK_SPEED_FIXED);
 
 out:
-	ice_atomic_write_link_status(dev, &link);
 	if (link.link_status == old.link_status)
 		return -1;
+	ice_atomic_write_link_status(dev, &link);
 
 	return 0;
 }