patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] ethdev: fix link status query
@ 2018-04-10  6:16 Shahaf Shuler
  2018-04-10  8:20 ` Nélio Laranjeiro
  0 siblings, 1 reply; 4+ messages in thread
From: Shahaf Shuler @ 2018-04-10  6:16 UTC (permalink / raw)
  To: ferruh.yigit, thomas; +Cc: dev, stable, stephen, nelio.laranjeiro

When application works with LSC interrupts the ethdev layer skips
the PMD callback and update according to the link status exists on
device data. It is because it assumes the link status on the device data
is the correct one since any link change is processed by the application.

As multiple PMDs install the link status interrupt handler only on port
start and uninstall it on port stop, the link status may be incorrect in
case the query is called after port stop or before port start.

Fixing the query implementation to use the PMD callback for such cases.

Fixes: b77d21cc2364 ("ethdev: add link status get/set helper functions")
Cc: stable@dpdk.org
Cc: stephen@networkplumber.org
Cc: nelio.laranjeiro@6wind.com

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 2c74f7e049..0857670ebe 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1789,7 +1789,8 @@ rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	if (dev->data->dev_conf.intr_conf.lsc)
+	if (dev->data->dev_conf.intr_conf.lsc &&
+	    dev->data->dev_started)
 		rte_eth_linkstatus_get(dev, eth_link);
 	else {
 		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
@@ -1806,7 +1807,8 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
 	RTE_ETH_VALID_PORTID_OR_RET(port_id);
 	dev = &rte_eth_devices[port_id];
 
-	if (dev->data->dev_conf.intr_conf.lsc)
+	if (dev->data->dev_conf.intr_conf.lsc &&
+	    dev->data->dev_started)
 		rte_eth_linkstatus_get(dev, eth_link);
 	else {
 		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
-- 
2.12.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH] ethdev: fix link status query
  2018-04-10  6:16 [dpdk-stable] [PATCH] ethdev: fix link status query Shahaf Shuler
@ 2018-04-10  8:20 ` Nélio Laranjeiro
  2018-04-10  8:29   ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Nélio Laranjeiro @ 2018-04-10  8:20 UTC (permalink / raw)
  To: Shahaf Shuler; +Cc: ferruh.yigit, thomas, dev, stable, stephen

On Tue, Apr 10, 2018 at 09:16:31AM +0300, Shahaf Shuler wrote:
> When application works with LSC interrupts the ethdev layer skips
> the PMD callback and update according to the link status exists on
> device data. It is because it assumes the link status on the device data
> is the correct one since any link change is processed by the application.
> 
> As multiple PMDs install the link status interrupt handler only on port
> start and uninstall it on port stop, the link status may be incorrect in
> case the query is called after port stop or before port start.

It seems also logical to not process interrupts from stopped device,
for them accessing to the link status should always end by calling the
devop function.

This patch is the result of discussion on thread [1].

> Fixing the query implementation to use the PMD callback for such cases.
> 
> Fixes: b77d21cc2364 ("ethdev: add link status get/set helper functions")
> Cc: stable@dpdk.org
> Cc: stephen@networkplumber.org
> Cc: nelio.laranjeiro@6wind.com

Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>

> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> ---
>  lib/librte_ether/rte_ethdev.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 2c74f7e049..0857670ebe 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -1789,7 +1789,8 @@ rte_eth_link_get(uint16_t port_id, struct rte_eth_link *eth_link)
>  	RTE_ETH_VALID_PORTID_OR_RET(port_id);
>  	dev = &rte_eth_devices[port_id];
>  
> -	if (dev->data->dev_conf.intr_conf.lsc)
> +	if (dev->data->dev_conf.intr_conf.lsc &&
> +	    dev->data->dev_started)
>  		rte_eth_linkstatus_get(dev, eth_link);
>  	else {
>  		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
> @@ -1806,7 +1807,8 @@ rte_eth_link_get_nowait(uint16_t port_id, struct rte_eth_link *eth_link)
>  	RTE_ETH_VALID_PORTID_OR_RET(port_id);
>  	dev = &rte_eth_devices[port_id];
>  
> -	if (dev->data->dev_conf.intr_conf.lsc)
> +	if (dev->data->dev_conf.intr_conf.lsc &&
> +	    dev->data->dev_started)
>  		rte_eth_linkstatus_get(dev, eth_link);
>  	else {
>  		RTE_FUNC_PTR_OR_RET(*dev->dev_ops->link_update);
> -- 
> 2.12.0
> 

Thanks,

[1] https://dpdk.org/ml/archives/dev/2018-April/094788.html

-- 
Nélio Laranjeiro
6WIND

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH] ethdev: fix link status query
  2018-04-10  8:20 ` Nélio Laranjeiro
@ 2018-04-10  8:29   ` Thomas Monjalon
  2018-04-10 18:34     ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2018-04-10  8:29 UTC (permalink / raw)
  To: Shahaf Shuler; +Cc: Nélio Laranjeiro, ferruh.yigit, dev, stable, stephen

10/04/2018 10:20, Nélio Laranjeiro:
> On Tue, Apr 10, 2018 at 09:16:31AM +0300, Shahaf Shuler wrote:
> > When application works with LSC interrupts the ethdev layer skips
> > the PMD callback and update according to the link status exists on
> > device data. It is because it assumes the link status on the device data
> > is the correct one since any link change is processed by the application.
> > 
> > As multiple PMDs install the link status interrupt handler only on port
> > start and uninstall it on port stop, the link status may be incorrect in
> > case the query is called after port stop or before port start.
> 
> It seems also logical to not process interrupts from stopped device,
> for them accessing to the link status should always end by calling the
> devop function.
> 
> This patch is the result of discussion on thread [1].
> 
> > Fixing the query implementation to use the PMD callback for such cases.
> > 
> > Fixes: b77d21cc2364 ("ethdev: add link status get/set helper functions")
> > Cc: stable@dpdk.org
> > Cc: stephen@networkplumber.org
> > Cc: nelio.laranjeiro@6wind.com
> 
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
> 
> > Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>

Looks OK

Acked-by: Thomas Monjalon <thomas@monjalon.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-stable] [PATCH] ethdev: fix link status query
  2018-04-10  8:29   ` Thomas Monjalon
@ 2018-04-10 18:34     ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2018-04-10 18:34 UTC (permalink / raw)
  To: Thomas Monjalon, Shahaf Shuler
  Cc: Nélio Laranjeiro, dev, stable, stephen

On 4/10/2018 9:29 AM, Thomas Monjalon wrote:
> 10/04/2018 10:20, Nélio Laranjeiro:
>> On Tue, Apr 10, 2018 at 09:16:31AM +0300, Shahaf Shuler wrote:
>>> When application works with LSC interrupts the ethdev layer skips
>>> the PMD callback and update according to the link status exists on
>>> device data. It is because it assumes the link status on the device data
>>> is the correct one since any link change is processed by the application.
>>>
>>> As multiple PMDs install the link status interrupt handler only on port
>>> start and uninstall it on port stop, the link status may be incorrect in
>>> case the query is called after port stop or before port start.
>>
>> It seems also logical to not process interrupts from stopped device,
>> for them accessing to the link status should always end by calling the
>> devop function.
>>
>> This patch is the result of discussion on thread [1].
>>
>>> Fixing the query implementation to use the PMD callback for such cases.
>>>
>>> Fixes: b77d21cc2364 ("ethdev: add link status get/set helper functions")
>>> Cc: stable@dpdk.org
>>> Cc: stephen@networkplumber.org
>>> Cc: nelio.laranjeiro@6wind.com
>>
>> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
>>
>>> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> 
> Looks OK
> 
> Acked-by: Thomas Monjalon <thomas@monjalon.net>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-10 18:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-10  6:16 [dpdk-stable] [PATCH] ethdev: fix link status query Shahaf Shuler
2018-04-10  8:20 ` Nélio Laranjeiro
2018-04-10  8:29   ` Thomas Monjalon
2018-04-10 18:34     ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).