[v2] net/mlx5: fix link state update

Message ID 20201119142018.25277-1-rasland@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [v2] net/mlx5: fix link state update |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-testing warning Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Raslan Darawsheh Nov. 19, 2020, 2:20 p.m. UTC
  From: Benoît Ganne <bganne@cisco.com>

mlx5 PMD refuses to update link state if link speed is defined but
status is down or if link speed is undefined but status is up, even if
the ioctl() succeeded.
This prevents application to detect link up/down event, especially when
the link speed is not correctly detected.
As link speed is nice to have whereas link status is mandatory for
operations, always update link state regardless of link speed. The
application can then check link speed if needs be.

Signed-off-by: Benoît Ganne <bganne@cisco.com>
Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>
---
 doc/guides/rel_notes/release_20_11.rst  |  1 +
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 10 ----------
 2 files changed, 1 insertion(+), 10 deletions(-)
  

Comments

Raslan Darawsheh Nov. 19, 2020, 4:27 p.m. UTC | #1
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Raslan Darawsheh
> Sent: Thursday, November 19, 2020 4:20 PM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; NBU-Contact-Thomas Monjalon
> <thomas@monjalon.net>; Benoît Ganne <bganne@cisco.com>
> Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix link state update
> 
> From: Benoît Ganne <bganne@cisco.com>
> 
> mlx5 PMD refuses to update link state if link speed is defined but
> status is down or if link speed is undefined but status is up, even if
> the ioctl() succeeded.
> This prevents application to detect link up/down event, especially when
> the link speed is not correctly detected.
> As link speed is nice to have whereas link status is mandatory for
> operations, always update link state regardless of link speed. The
> application can then check link speed if needs be.
> 
> Signed-off-by: Benoît Ganne <bganne@cisco.com>
> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  
Ferruh Yigit Nov. 19, 2020, 5:48 p.m. UTC | #2
On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
> From: Benoît Ganne <bganne@cisco.com>
> 
> mlx5 PMD refuses to update link state if link speed is defined but
> status is down or if link speed is undefined but status is up, even if
> the ioctl() succeeded.
> This prevents application to detect link up/down event, especially when
> the link speed is not correctly detected.
> As link speed is nice to have whereas link status is mandatory for
> operations, always update link state regardless of link speed. The
> application can then check link speed if needs be.
> 

Hi Raslan, Matan,

Can you please provide the Fixes tag? Also should this fix backported?

> Signed-off-by: Benoît Ganne <bganne@cisco.com>
> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com>

<...>
  
Thomas Monjalon Nov. 19, 2020, 6:42 p.m. UTC | #3
19/11/2020 18:48, Ferruh Yigit:
> On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
> > From: Benoît Ganne <bganne@cisco.com>
> > 
> > mlx5 PMD refuses to update link state if link speed is defined but
> > status is down or if link speed is undefined but status is up, even if
> > the ioctl() succeeded.
> > This prevents application to detect link up/down event, especially when
> > the link speed is not correctly detected.
> > As link speed is nice to have whereas link status is mandatory for
> > operations, always update link state regardless of link speed. The
> > application can then check link speed if needs be.
> > 
> 
> Hi Raslan, Matan,
> 
> Can you please provide the Fixes tag? Also should this fix backported?

I think it should not be backported because it is a behaviour change
relying on API doc change.
  
Ferruh Yigit Nov. 20, 2020, 10:51 a.m. UTC | #4
On 11/19/2020 6:42 PM, Thomas Monjalon wrote:
> 19/11/2020 18:48, Ferruh Yigit:
>> On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
>>> From: Benoît Ganne <bganne@cisco.com>
>>>
>>> mlx5 PMD refuses to update link state if link speed is defined but
>>> status is down or if link speed is undefined but status is up, even if
>>> the ioctl() succeeded.
>>> This prevents application to detect link up/down event, especially when
>>> the link speed is not correctly detected.
>>> As link speed is nice to have whereas link status is mandatory for
>>> operations, always update link state regardless of link speed. The
>>> application can then check link speed if needs be.
>>>
>>
>> Hi Raslan, Matan,
>>
>> Can you please provide the Fixes tag? Also should this fix backported?
> 
> I think it should not be backported because it is a behaviour change
> relying on API doc change.
> 

As far as I understand, API change you mention is making 'ETH_SPEED_NUM_UNKNOWN' 
speed value a valid value return value.

Commit log doesn't give the context that it relies on an ethdev behavior change,
it sounds like it is fixing behavior in the driver, it is not possible to figure 
out the relation without digging the mail list discussions.
It would be nice to update the commit log to give more details, I think problem 
is clear but can good to add why the check was there at first place and why it 
can be removed now, etc..

Btw with LTS, with the faulty kernel driver, PMD still won't able to get link 
speed which will prevent returning link status.
Or is the kernel driver fixed and no need to worry about this anymore?
  
Thomas Monjalon Nov. 20, 2020, 1:50 p.m. UTC | #5
20/11/2020 11:51, Ferruh Yigit:
> On 11/19/2020 6:42 PM, Thomas Monjalon wrote:
> > 19/11/2020 18:48, Ferruh Yigit:
> >> On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
> >>> From: Benoît Ganne <bganne@cisco.com>
> >>>
> >>> mlx5 PMD refuses to update link state if link speed is defined but
> >>> status is down or if link speed is undefined but status is up, even if
> >>> the ioctl() succeeded.
> >>> This prevents application to detect link up/down event, especially when
> >>> the link speed is not correctly detected.
> >>> As link speed is nice to have whereas link status is mandatory for
> >>> operations, always update link state regardless of link speed. The
> >>> application can then check link speed if needs be.
> >>>
> >>
> >> Hi Raslan, Matan,
> >>
> >> Can you please provide the Fixes tag? Also should this fix backported?
> > 
> > I think it should not be backported because it is a behaviour change
> > relying on API doc change.
> > 
> 
> As far as I understand, API change you mention is making 'ETH_SPEED_NUM_UNKNOWN' 
> speed value a valid value return value.
> 
> Commit log doesn't give the context that it relies on an ethdev behavior change,
> it sounds like it is fixing behavior in the driver, it is not possible to figure 
> out the relation without digging the mail list discussions.
> It would be nice to update the commit log to give more details, I think problem 
> is clear but can good to add why the check was there at first place and why it 
> can be removed now, etc..

Yes I can help improving the explanations.

> Btw with LTS, with the faulty kernel driver, PMD still won't able to get link 
> speed which will prevent returning link status.

With this PMD change, the link status is returned even if link speed
is not available.

> Or is the kernel driver fixed and no need to worry about this anymore?

Yes the kernel driver is fixed since a long time.
  
Ferruh Yigit Nov. 20, 2020, 2:21 p.m. UTC | #6
On 11/20/2020 1:50 PM, Thomas Monjalon wrote:
> 20/11/2020 11:51, Ferruh Yigit:
>> On 11/19/2020 6:42 PM, Thomas Monjalon wrote:
>>> 19/11/2020 18:48, Ferruh Yigit:
>>>> On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
>>>>> From: Benoît Ganne <bganne@cisco.com>
>>>>>
>>>>> mlx5 PMD refuses to update link state if link speed is defined but
>>>>> status is down or if link speed is undefined but status is up, even if
>>>>> the ioctl() succeeded.
>>>>> This prevents application to detect link up/down event, especially when
>>>>> the link speed is not correctly detected.
>>>>> As link speed is nice to have whereas link status is mandatory for
>>>>> operations, always update link state regardless of link speed. The
>>>>> application can then check link speed if needs be.
>>>>>
>>>>
>>>> Hi Raslan, Matan,
>>>>
>>>> Can you please provide the Fixes tag? Also should this fix backported?
>>>
>>> I think it should not be backported because it is a behaviour change
>>> relying on API doc change.
>>>
>>
>> As far as I understand, API change you mention is making 'ETH_SPEED_NUM_UNKNOWN'
>> speed value a valid value return value.
>>
>> Commit log doesn't give the context that it relies on an ethdev behavior change,
>> it sounds like it is fixing behavior in the driver, it is not possible to figure
>> out the relation without digging the mail list discussions.
>> It would be nice to update the commit log to give more details, I think problem
>> is clear but can good to add why the check was there at first place and why it
>> can be removed now, etc..
> 
> Yes I can help improving the explanations.
> 
>> Btw with LTS, with the faulty kernel driver, PMD still won't able to get link
>> speed which will prevent returning link status.
> 
> With this PMD change, the link status is returned even if link speed
> is not available.
> 

That is why I am asking if this patch should be backported :)

>> Or is the kernel driver fixed and no need to worry about this anymore?
> 
> Yes the kernel driver is fixed since a long time.
> 
> 
>
  
Raslan Darawsheh Nov. 22, 2020, 10:03 a.m. UTC | #7
Hi,
> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Friday, November 20, 2020 4:21 PM
> To: NBU-Contact-Thomas Monjalon <thomas@monjalon.net>
> Cc: Raslan Darawsheh <rasland@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>; Benoît
> Ganne <bganne@cisco.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2] net/mlx5: fix link state update
> 
> On 11/20/2020 1:50 PM, Thomas Monjalon wrote:
> > 20/11/2020 11:51, Ferruh Yigit:
> >> On 11/19/2020 6:42 PM, Thomas Monjalon wrote:
> >>> 19/11/2020 18:48, Ferruh Yigit:
> >>>> On 11/19/2020 2:20 PM, Raslan Darawsheh wrote:
> >>>>> From: Benoît Ganne <bganne@cisco.com>
> >>>>>
> >>>>> mlx5 PMD refuses to update link state if link speed is defined but
> >>>>> status is down or if link speed is undefined but status is up, even if
> >>>>> the ioctl() succeeded.
> >>>>> This prevents application to detect link up/down event, especially
> when
> >>>>> the link speed is not correctly detected.
> >>>>> As link speed is nice to have whereas link status is mandatory for
> >>>>> operations, always update link state regardless of link speed. The
> >>>>> application can then check link speed if needs be.
> >>>>>
> >>>>
> >>>> Hi Raslan, Matan,
> >>>>
> >>>> Can you please provide the Fixes tag? Also should this fix backported?
> >>>
> >>> I think it should not be backported because it is a behaviour change
> >>> relying on API doc change.
> >>>
> >>
> >> As far as I understand, API change you mention is making
> 'ETH_SPEED_NUM_UNKNOWN'
> >> speed value a valid value return value.
> >>
> >> Commit log doesn't give the context that it relies on an ethdev behavior
> change,
> >> it sounds like it is fixing behavior in the driver, it is not possible to figure
> >> out the relation without digging the mail list discussions.
> >> It would be nice to update the commit log to give more details, I think
> problem
> >> is clear but can good to add why the check was there at first place and
> why it
> >> can be removed now, etc..
> >
> > Yes I can help improving the explanations.
> >
> >> Btw with LTS, with the faulty kernel driver, PMD still won't able to get link
> >> speed which will prevent returning link status.
> >
> > With this PMD change, the link status is returned even if link speed
> > is not available.
> >
> 
> That is why I am asking if this patch should be backported :)
> 
> >> Or is the kernel driver fixed and no need to worry about this anymore?
> >
> > Yes the kernel driver is fixed since a long time.
> >
> >
> >
Thanks for your comments and reviews, 
I'll send a v3 changing the commit log accordingly.

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst
index 1c262d39a5..75b4ebc84b 100644
--- a/doc/guides/rel_notes/release_20_11.rst
+++ b/doc/guides/rel_notes/release_20_11.rst
@@ -207,6 +207,7 @@  New Features
     by rte_flow API.
   * Added support of Age action query.
   * Added support of multi-ports hairpin.
+  * Allow unknown link speed.
 
   Updated Mellanox mlx5 vDPA driver:
 
diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 19b281925f..f7ef1492b1 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -425,11 +425,6 @@  mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev,
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
 	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 			ETH_LINK_SPEED_FIXED);
-	if (((dev_link.link_speed && !dev_link.link_status) ||
-	     (!dev_link.link_speed && dev_link.link_status))) {
-		rte_errno = EAGAIN;
-		return -rte_errno;
-	}
 	*link = dev_link;
 	return 0;
 }
@@ -571,11 +566,6 @@  mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev,
 				ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
 	dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
 				  ETH_LINK_SPEED_FIXED);
-	if (((dev_link.link_speed && !dev_link.link_status) ||
-	     (!dev_link.link_speed && dev_link.link_status))) {
-		rte_errno = EAGAIN;
-		return -rte_errno;
-	}
 	*link = dev_link;
 	return 0;
 }