From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <yuanhan.liu@linux.intel.com>
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by dpdk.org (Postfix) with ESMTP id 0087B2BA1
 for <dev@dpdk.org>; Mon,  4 Jul 2016 14:25:24 +0200 (CEST)
Received: from fmsmga002.fm.intel.com ([10.253.24.26])
 by orsmga103.jf.intel.com with ESMTP; 04 Jul 2016 05:25:23 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.26,574,1459839600"; d="scan'208";a="1015299355"
Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162])
 by fmsmga002.fm.intel.com with ESMTP; 04 Jul 2016 05:25:15 -0700
Date: Mon, 4 Jul 2016 20:26:30 +0800
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Cc: dev@dpdk.org, thomas.monjalon@6wind.com, bruce.richardson@intel.com,
 jianbo.liu@linaro.org, huawei.xie@intel.com
Message-ID: <20160704122630.GB26521@yliu-dev.sh.intel.com>
References: <1467028448-8914-1-git-send-email-jerin.jacob@caviumnetworks.com>
 <1467371814-26754-1-git-send-email-jerin.jacob@caviumnetworks.com>
 <1467371814-26754-2-git-send-email-jerin.jacob@caviumnetworks.com>
 <20160704073648.GV2831@yliu-dev.sh.intel.com>
 <20160704083626.GA12596@localhost.localdomain>
 <20160704084232.GY2831@yliu-dev.sh.intel.com>
 <20160704090754.GD12596@localhost.localdomain>
 <20160704110225.GA2831@yliu-dev.sh.intel.com>
 <20160704121556.GA5050@localhost.localdomain>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20160704121556.GA5050@localhost.localdomain>
User-Agent: Mutt/1.5.23 (2014-03-12)
Subject: Re: [dpdk-dev] [PATCH v2 1/3] virtio: conditional compilation
	cleanup
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://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: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Jul 2016 12:25:25 -0000

On Mon, Jul 04, 2016 at 05:45:57PM +0530, Jerin Jacob wrote:
> On Mon, Jul 04, 2016 at 07:02:25PM +0800, Yuanhan Liu wrote:
> > On Mon, Jul 04, 2016 at 02:37:55PM +0530, Jerin Jacob wrote:
> > > On Mon, Jul 04, 2016 at 04:42:32PM +0800, Yuanhan Liu wrote:
> > > > On Mon, Jul 04, 2016 at 02:06:27PM +0530, Jerin Jacob wrote:
> > > > > On Mon, Jul 04, 2016 at 03:36:48PM +0800, Yuanhan Liu wrote:
> > > > > > On Fri, Jul 01, 2016 at 04:46:36PM +0530, Jerin Jacob wrote:
> > > > > > > @@ -494,9 +486,6 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
> > > > > > >  {
> > > > > > >  	uint8_t vtpci_queue_idx = 2 * queue_idx + VTNET_SQ_TQ_QUEUE_IDX;
> > > > > > >  
> > > > > > > -#ifdef RTE_MACHINE_CPUFLAG_SSSE3
> > > > > > > -	struct virtio_hw *hw = dev->data->dev_private;
> > > > > > > -#endif
> > > > > > >  	struct virtnet_tx *txvq;
> > > > > > >  	struct virtqueue *vq;
> > > > > > >  	uint16_t tx_free_thresh;
> > > > > > > @@ -511,13 +500,14 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
> > > > > > >  	}
> > > > > > >  
> > > > > > >  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> > > > > > > +	struct virtio_hw *hw = dev->data->dev_private;
> > > > > > 
> > > > > > I'd suggest to move above declaration to ...
> > > > > > 
> > > > > > >  	/* Use simple rx/tx func if single segment and no offloads */
> > > > > > >  	if ((tx_conf->txq_flags & VIRTIO_SIMPLE_FLAGS) == VIRTIO_SIMPLE_FLAGS &&
> > > > > > >  	     !vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
> > > > > > 
> > > > > > here: we should try to avoid declaring vars in the middle of a code block.
> > > > > 
> > > > > Next patch in this series, moving all rxtx handler selection code to
> > > > > separate function(virtio_update_rxtx_handler()) where declaration comes
> > > > > as first line in the function.i.e the comment is taken care of in the
> > > > > series.
> > > > 
> > > > Yes, I saw that. But in principle, each patch is atomic: it's not a
> > > > good idea/practice to introduce issues in path A and then fix it in
> > > > path B.
> > > 
> > > In my view it was not an issue as I was removing all possible
> > > conditional compilation flag. If I were to move the declaration to top
> > > then another conditional compilation RTE_MACHINE_CPUFLAG_SSSE3
> > > flag I need to add around declaring the variable.
> > 
> > Nope, I was suggesting to move it inside the "if" block. So, this
> > is actually consistent with what you are trying to do. Besides, it
> > removes an declaration in the middle.
> 
> Just to get the clarity on "moving inside the 'if' block"
> 
> Are you suggesting to have like below?
> 
>  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> +       struct virtio_hw *hw;
>         /* Use simple rx/tx func if single segment and no offloads */
>         if ((tx_conf->txq_flags & VIRTIO_SIMPLE_FLAGS) ==
> VIRTIO_SIMPLE_FLAGS &&
>              !vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
>                 PMD_INIT_LOG(INFO, "Using simple rx/tx path");
>                 dev->tx_pkt_burst = virtio_xmit_pkts_simple;
>                 dev->rx_pkt_burst = virtio_recv_pkts_vec;
> -               use_simple_rxtx = 1;
> +		hw = dev->data->dev_private;
> +               hw->use_simple_rxtx = 1;
>         }
>  #endif
> 
> 
> Instead of following scheme in existing patch,
> 
>  #ifdef RTE_MACHINE_CPUFLAG_SSSE3
> +       struct virtio_hw *hw = dev->data->dev_private;
>         /* Use simple rx/tx func if single segment and no offloads */
>         if ((tx_conf->txq_flags & VIRTIO_SIMPLE_FLAGS) ==
> VIRTIO_SIMPLE_FLAGS &&
>              !vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
>                 PMD_INIT_LOG(INFO, "Using simple rx/tx path");
>                 dev->tx_pkt_burst = virtio_xmit_pkts_simple;
>                 dev->rx_pkt_burst = virtio_recv_pkts_vec;
> -               use_simple_rxtx = 1;
> +               hw->use_simple_rxtx = 1;
>         }
>  #endif
> 
> 
> The former case will have issue as "hw" been used in "if" with vtpci_with_feature.

Oh, my bad. I overlooked it. Sorry for that!

> OR
> 
> if you meant just floating "struct virtio_hw *hw" without RTE_MACHINE_CPUFLAG_SSSE3
> then it comes error on non x86 as unused "hw" variable.
> 
> If you meant something else then let me know?

I then prefer to keep the "#ifdef .. #endif" on top then. It will stop
us from offending a minor rule, while you can remove the ugly "#ifdef"
block in the next patch.

Works to you?

	--yliu