From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <nelio.laranjeiro@6wind.com>
Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com
 [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 8F1791B33A
 for <dev@dpdk.org>; Fri, 19 Jan 2018 15:18:27 +0100 (CET)
Received: by mail-wr0-f193.google.com with SMTP id x1so1716811wrb.5
 for <dev@dpdk.org>; Fri, 19 Jan 2018 06:18:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=date:from:to:cc:subject:message-id:references:mime-version
 :content-disposition:content-transfer-encoding:in-reply-to
 :user-agent; bh=skXi9vhDDcp/tZlJKa6qarDPEPW+K6UpY6QF0NJx2eU=;
 b=ZdpzVHYpuvbpG+oTM4h2RFtU4GNC63pnUGv+/2zmMhg+JM8TNoLSeMapVcXvqahXXV
 KWx4c+mOqcRnFhxIyms5HNJYCYUt6Mj5FGk0VCUAENHCiUfUsGJEmUVPVyKj/KOOEl3u
 leFfCb+AeYbdDAnggkCmfUPCPRFExiDgjob37g/QFT8lbWMemdUrVMxy6tBXMALwNzky
 kb9I+cGP8Jdr9ruHOoqkhCdDQKzW4inEMc06rJUecl0YvfI98kgJ66yst9sGDIg//hX1
 SX6lXFEnfTzFHgrk+9orLmPF68H4Q4H9Yhn1qymd4//tkYyn07qRWAfXEj3CxNGBn5xz
 phFg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:content-transfer-encoding
 :in-reply-to:user-agent;
 bh=skXi9vhDDcp/tZlJKa6qarDPEPW+K6UpY6QF0NJx2eU=;
 b=adJaYxV6hR0z7tr/wSJThzkWvEG6UFmLp/6dyD0RFiWxiJ6oNOdBaNi0c9qQZ9dreS
 sWZPSBzU1A+RlpmUOfSSCJ0PZHp021GABLUBP0er21b4rL052js5sS2dIyS2Dr5H9CJf
 N0w2helwSyhTINJoZZjsB5UUiWcb3a0HPBv/4eCcHx5Ea9H/WmvOW+DoocdH8r2NLyvA
 9LnUseXvsIgfB2eqshaYxqYa7YsXatnTxY5b4tjEyg7dbAe1hpLUR4vR1+LqQdBtvIWa
 /AjjL/6lPi6X+kRfigtoQOumESRRbzUlF2y1BU4paVjen540f41+n7FDoCly5SvCRE7t
 UEnA==
X-Gm-Message-State: AKwxytdjUpFUa6wvA72NYiCet1/DmqA3K5jtdkmXGWX4vKzryWnv5Lwh
 04TmT4AeLYmCyLzozyBdaWYfgwPLBQ==
X-Google-Smtp-Source: ACJfBovVspHGuWvuIhjkr0XOSaQI1SU9w/dX8Vz7X+1vgusXJ1Z8OCwVcK3Jk2jSsGlIVjVFHzwA0A==
X-Received: by 10.223.198.198 with SMTP id c6mr7816609wrh.159.1516371506118;
 Fri, 19 Jan 2018 06:18:26 -0800 (PST)
Received: from laranjeiro-vm.dev.6wind.com
 (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78])
 by smtp.gmail.com with ESMTPSA id i47sm9485031wrf.26.2018.01.19.06.18.25
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 19 Jan 2018 06:18:25 -0800 (PST)
Date: Fri, 19 Jan 2018 15:18:14 +0100
From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro <nelio.laranjeiro@6wind.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, Adrien Mazarguil <adrien.mazarguil@6wind.com>,
 Yongseok Koh <yskoh@mellanox.com>, stable@dpdk.org
Message-ID: <20180119141814.x26mnya6icdv7f3d@laranjeiro-vm.dev.6wind.com>
References: <20180118130043.31773-1-olivier.matz@6wind.com>
 <20180118160427.4fokyhq7koux6ga6@laranjeiro-vm.dev.6wind.com>
 <20180118161308.26ssahokrsu4e2rn@platinum>
 <20180119083501.osf4rnd4y4lwujwn@laranjeiro-vm.dev.6wind.com>
 <20180119084314.uvjbhtveuq7wfpj3@platinum>
 <20180119133045.2skvdjis6yxk3bet@platinum>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20180119133045.2skvdjis6yxk3bet@platinum>
User-Agent: NeoMutt/20170113 (1.7.2)
Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx5: fix return value of start
	operation
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 19 Jan 2018 14:18:27 -0000

On Fri, Jan 19, 2018 at 02:30:45PM +0100, Olivier Matz wrote:
> On Fri, Jan 19, 2018 at 09:43:14AM +0100, Olivier Matz wrote:
> > On Fri, Jan 19, 2018 at 09:35:01AM +0100, Nélio Laranjeiro wrote:
> > > On Thu, Jan 18, 2018 at 05:13:08PM +0100, Olivier Matz 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@dpdk.org
> > > > > > 
> > > > > > Signed-off-by: Olivier Matz <olivier.matz@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?
> > > 
> > > What I mean is priv_flow_start() is returning a positive errno as all
> > > other functions priv_*() that's the main reason for the final rteurn -err;
> 
> priv_txq_start(priv);
>   -> negative on error
> priv_rxq_start(priv);
>   -> negative on error
> priv_dev_traffic_enable(priv, dev);
>   -> positive (+errno) on error
> priv_flow_start(priv, &priv->flows);
>   -> positive (+errno) on error
> priv_rx_intr_vec_enable(priv);
>   -> negative (-1 or -errno) on error

Indeed,

All this needs to be re-worked to only return negatives values, in the
mean time,

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

> > > Internally MLX5 driver only works with positives errnos as lot of them
> > > are retuning the values from ioctl directly.  Only the public ones are
> > > returning negatives.
> > 
> > So, what should I modify in this patch for v2?
> > Do you agree that there is a bug regarding the return value of mlx5_dev_start()?
> > 
> > It can be reproduced easily by starting testpmd on a dual-socket machine,
> > use the core and memory from socket 0, and have the mlx device on socket 1.
> > Then start traffic forwarding, it will crash.

-- 
Nélio Laranjeiro
6WIND