[dpdk-dev] [PATCH 1/2] net/mlx5: fix return value of start operation

Yongseok Koh yskoh at mellanox.com
Fri Jan 19 07:28:53 CET 2018


> On Jan 18, 2018, at 8:13 AM, Olivier Matz <olivier.matz at 6wind.com> wrote:
> 
> On Thu, Jan 18, 2018 at 05:04:27PM +0100, Nélio Laranjeiro wrote:
>> On Thu, Jan 18, 2018 at 02:00:42PM +0100, Olivier Matz wrote:
>>> On error, mlx5_dev_start() does not return a negative value
>>> as it is supposed to do. The consequence is that the application
>>> (ex: testpmd) does not notice that the port is not started
>>> and begins the rxtx on an uninitialized port, which crashes.
>>> 
>>> Fixes: e1016cb73383 ("net/mlx5: fix Rx interrupts management")
>>> Cc: stable at dpdk.org
>>> 
>>> Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
>>> ---
>>> drivers/net/mlx5/mlx5_trigger.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
>>> index 1a20967a2..44f702daa 100644
>>> --- a/drivers/net/mlx5/mlx5_trigger.c
>>> +++ b/drivers/net/mlx5/mlx5_trigger.c
>>> @@ -166,6 +166,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
>>> 		ERROR("%p: an error occurred while configuring control flows:"
>>> 		      " %s",
>>> 		      (void *)priv, strerror(err));
>>> +		err = -err;
>>> 		goto error;
>>> 	}
>>> 	err = priv_flow_start(priv, &priv->flows);
>>> @@ -173,6 +174,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
>>> 		ERROR("%p: an error occurred while configuring flows:"
>>> 		      " %s",
>>> 		      (void *)priv, strerror(err));
>>> +		err = -err;
>>> 		goto error;
>>> 	}
>>> 	err = priv_rx_intr_vec_enable(priv);
>>> @@ -196,7 +198,7 @@ mlx5_dev_start(struct rte_eth_dev *dev)
>>> 	priv_rxq_stop(priv);
>>> 	priv_flow_delete_drop_queue(priv);
>>> 	priv_unlock(priv);
>>> -	return -err;
>>> +	return err;
>>> }
>>> 
>>> /**
>> 
>> err in the function is handled with positives errno's, adding only those
>> two and returning err will make the other positive.
> 
> I tried to check the return value of all functions called by mlx5_dev_start()
> (negative or positive). Do you see something wrong?

Those two func calls have been moved recently. [1]
Please rebase it on top of dpdk-next-net-mlx/for-next-net

Then, the last change is okay to return negative values.

Nelio, we should make all the return values consistent someday, shouldn't we?

[1] http://dpdk.org/browse/next/dpdk-next-net-mlx/commit/?h=for-next-net&id=ed3d6afc9295bc16ab9ed2cad26af0c8cd9bd14e

Thanks,
Yongseok



More information about the dev mailing list