[v2] net/ixgbe: fix link status

Message ID 20191113163441.90162-1-lunyuanx.cui@intel.com (mailing list archive)
State Superseded, archived
Delegated to: xiaolong ye
Headers
Series [v2] net/ixgbe: fix link status |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

Cui, LunyuanX Nov. 13, 2019, 4:34 p.m. UTC
  After ports reset, tx laser register will be reset. The link
status for 82599eb got from link status register was not correct.
Set tx laser disabled after ports reset.

ixgbe_dev_setup_link_alarm_handler() will set tx laser enabled
when show port information. The purpose of the function has already
implemented in ixgbe_dev_start(). There is no need to reuse it
in ixgbe_dev_link_update_share().

Fixes: 0408f47ba4d6 ("net/ixgbe: fix busy polling while fiber link update")
Cc: stable@dpdk.org

Signed-off-by: Cui LunyuanX <lunyuanx.cui@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
  

Comments

Ilya Maximets Nov. 13, 2019, 3:06 p.m. UTC | #1
On 13.11.2019 17:34, Cui LunyuanX wrote:
> After ports reset, tx laser register will be reset. The link
> status for 82599eb got from link status register was not correct.
> Set tx laser disabled after ports reset.
> 
> ixgbe_dev_setup_link_alarm_handler() will set tx laser enabled
> when show port information. The purpose of the function has already
> implemented in ixgbe_dev_start(). There is no need to reuse it
> in ixgbe_dev_link_update_share().

The reason why the alarm handler stays there is the one described
in following commit:

commit c12d22f65b132c56db7b4fdbfd5ddce27d1e9572
Author: Laurent Hardy <laurent.hardy@6wind.com>
Date:   Thu Apr 27 17:03:42 2017 +0200

    net/ixgbe: ensure link status is updated
    
    In case of fiber and link speed set to 1Gb at peer side (with autoneg
    or with defined speed), link status could be not properly updated at
    time cable is plugged-in.
    Indeed if cable was not plugged when device has been configured and
    started then link status will not be updated properly with new speed
    as no link setup will be triggered.
    
    To avoid this issue, IXGBE_FLAG_NEED_LINK_CONFIG is set to try a link
    setup each time link_update() is triggered and current link status is
    down. When cable is plugged-in, link setup will be performed via
    ixgbe_setup_link().
    
    Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
    Acked-by: Wei Dai <wei.dai@intel.com>

Does it fixed?
If not, you should not touch the alarm handler or implement a different
workaround.

Best regards, Ilya Maximets.
  
Cui, LunyuanX Nov. 14, 2019, 3:45 a.m. UTC | #2
Hi, Ilya Maximets

Before my patch, original treatment is as follows:
	esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
	if ((esdp_reg & IXGBE_ESDP_SDP3))
		link_up = 0;

	if (link_up == 0) {
		if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
			intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
			rte_eal_alarm_set(10,
				ixgbe_dev_setup_link_alarm_handler, dev);
		}
		return rte_eth_linkstatus_set(dev, &link);
	}

ixgbe_dev_setup_link_alarm_handler() can cause link status change from down to up.
When port stops, link status should always be down. When bug which you fixed occur, link status is down.
But this treatment can't confirm whether the reason is. I thank port status should be used as judgment.
If port stops, we don’t need to ensure link status is updated.

If I change patch like this, will it affect your bug?

Looking forward to your reply.
Thanks
Lunyuan.

> -----Original Message-----
> From: Ilya Maximets [mailto:i.maximets@ovn.org]
> Sent: Wednesday, November 13, 2019 11:07 PM
> To: Cui, LunyuanX <lunyuanx.cui@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; stable@dpdk.org; Laurent Hardy
> <laurent.hardy@6wind.com>; Wei Dai <wei.dai@intel.com>; Ye, Xiaolong
> <xiaolong.ye@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: fix link status
> 
> On 13.11.2019 17:34, Cui LunyuanX wrote:
> > After ports reset, tx laser register will be reset. The link status
> > for 82599eb got from link status register was not correct.
> > Set tx laser disabled after ports reset.
> >
> > ixgbe_dev_setup_link_alarm_handler() will set tx laser enabled when
> > show port information. The purpose of the function has already
> > implemented in ixgbe_dev_start(). There is no need to reuse it in
> > ixgbe_dev_link_update_share().
> 
> The reason why the alarm handler stays there is the one described in
> following commit:
> 
> commit c12d22f65b132c56db7b4fdbfd5ddce27d1e9572
> Author: Laurent Hardy <laurent.hardy@6wind.com>
> Date:   Thu Apr 27 17:03:42 2017 +0200
> 
>     net/ixgbe: ensure link status is updated
> 
>     In case of fiber and link speed set to 1Gb at peer side (with autoneg
>     or with defined speed), link status could be not properly updated at
>     time cable is plugged-in.
>     Indeed if cable was not plugged when device has been configured and
>     started then link status will not be updated properly with new speed
>     as no link setup will be triggered.
> 
>     To avoid this issue, IXGBE_FLAG_NEED_LINK_CONFIG is set to try a link
>     setup each time link_update() is triggered and current link status is
>     down. When cable is plugged-in, link setup will be performed via
>     ixgbe_setup_link().
> 
>     Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
>     Acked-by: Wei Dai <wei.dai@intel.com>
> 
> Does it fixed?
> If not, you should not touch the alarm handler or implement a different
> workaround.
> 
> Best regards, Ilya Maximets.
  
Ilya Maximets Nov. 14, 2019, 11:03 a.m. UTC | #3
On 14.11.2019 4:45, Cui, LunyuanX wrote:
> Hi, Ilya Maximets
> 
> Before my patch, original treatment is as follows:
> 	esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
> 	if ((esdp_reg & IXGBE_ESDP_SDP3))
> 		link_up = 0;
> 
> 	if (link_up == 0) {
> 		if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
> 			intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
> 			rte_eal_alarm_set(10,
> 				ixgbe_dev_setup_link_alarm_handler, dev);
> 		}
> 		return rte_eth_linkstatus_set(dev, &link);
> 	}
> 
> ixgbe_dev_setup_link_alarm_handler() can cause link status change from down to up.
> When port stops, link status should always be down. When bug which you fixed occur, link status is down.
> But this treatment can't confirm whether the reason is. I thank port status should be used as judgment.
> If port stops, we don’t need to ensure link status is updated.
> 
> If I change patch like this, will it affect your bug?

At first, your 'Fixes' tag is not correct because patch 0408f47ba4d6
only changed direct ixgbe_setup_link() call to delayed alarm handler.

You may add some more conditions in order to not schedule the handler
if adapter is stopped, but don't remove the workaround completely.

Best regards, Ilya Maximets.

> 
> Looking forward to your reply.
> Thanks
> Lunyuan.
> 
>> -----Original Message-----
>> From: Ilya Maximets [mailto:i.maximets@ovn.org]
>> Sent: Wednesday, November 13, 2019 11:07 PM
>> To: Cui, LunyuanX <lunyuanx.cui@intel.com>; dev@dpdk.org
>> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; Yang, Qiming
>> <qiming.yang@intel.com>; stable@dpdk.org; Laurent Hardy
>> <laurent.hardy@6wind.com>; Wei Dai <wei.dai@intel.com>; Ye, Xiaolong
>> <xiaolong.ye@intel.com>
>> Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: fix link status
>>
>> On 13.11.2019 17:34, Cui LunyuanX wrote:
>>> After ports reset, tx laser register will be reset. The link status
>>> for 82599eb got from link status register was not correct.
>>> Set tx laser disabled after ports reset.
>>>
>>> ixgbe_dev_setup_link_alarm_handler() will set tx laser enabled when
>>> show port information. The purpose of the function has already
>>> implemented in ixgbe_dev_start(). There is no need to reuse it in
>>> ixgbe_dev_link_update_share().
>>
>> The reason why the alarm handler stays there is the one described in
>> following commit:
>>
>> commit c12d22f65b132c56db7b4fdbfd5ddce27d1e9572
>> Author: Laurent Hardy <laurent.hardy@6wind.com>
>> Date:   Thu Apr 27 17:03:42 2017 +0200
>>
>>     net/ixgbe: ensure link status is updated
>>
>>     In case of fiber and link speed set to 1Gb at peer side (with autoneg
>>     or with defined speed), link status could be not properly updated at
>>     time cable is plugged-in.
>>     Indeed if cable was not plugged when device has been configured and
>>     started then link status will not be updated properly with new speed
>>     as no link setup will be triggered.
>>
>>     To avoid this issue, IXGBE_FLAG_NEED_LINK_CONFIG is set to try a link
>>     setup each time link_update() is triggered and current link status is
>>     down. When cable is plugged-in, link setup will be performed via
>>     ixgbe_setup_link().
>>
>>     Signed-off-by: Laurent Hardy <laurent.hardy@6wind.com>
>>     Acked-by: Wei Dai <wei.dai@intel.com>
>>
>> Does it fixed?
>> If not, you should not touch the alarm handler or implement a different
>> workaround.
>>
>> Best regards, Ilya Maximets.
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 8c1caac18..5e516599c 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1298,6 +1298,8 @@  eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
 	/* enable support intr */
 	ixgbe_enable_intr(eth_dev);
 
+	ixgbe_dev_set_link_down(eth_dev);
+
 	/* initialize filter info */
 	memset(filter_info, 0,
 	       sizeof(struct ixgbe_filter_info));
@@ -4154,11 +4156,6 @@  ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 		link_up = 0;
 
 	if (link_up == 0) {
-		if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
-			intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
-			rte_eal_alarm_set(10,
-				ixgbe_dev_setup_link_alarm_handler, dev);
-		}
 		return rte_eth_linkstatus_set(dev, &link);
 	}