From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id EDB242B97 for ; Thu, 15 Sep 2016 18:35:39 +0200 (CEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32B725455E; Thu, 15 Sep 2016 16:35:39 +0000 (UTC) Received: from [10.36.7.92] (vpn1-7-92.ams2.redhat.com [10.36.7.92]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8FGZZFs009024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Sep 2016 12:35:37 -0400 To: "Wang, Zhihong" , "dev@dpdk.org" References: <1471319402-112998-1-git-send-email-zhihong.wang@intel.com> <1473392368-84903-1-git-send-email-zhihong.wang@intel.com> <1473392368-84903-3-git-send-email-zhihong.wang@intel.com> <2cc970ca-ea2c-8e3b-069a-9f1ec1182b03@redhat.com> <8F6C2BD409508844A0EFC19955BE09414E70FB1C@SHSMSX103.ccr.corp.intel.com> Cc: "yuanhan.liu@linux.intel.com" , "thomas.monjalon@6wind.com" From: Maxime Coquelin Message-ID: <272ec2b8-70f5-e32b-62f4-45c53c121630@redhat.com> Date: Thu, 15 Sep 2016 18:35:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <8F6C2BD409508844A0EFC19955BE09414E70FB1C@SHSMSX103.ccr.corp.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 15 Sep 2016 16:35:39 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v5 2/6] vhost: rewrite enqueue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2016 16:35:40 -0000 Hi, On 09/14/2016 10:20 AM, Wang, Zhihong wrote: >>> + desc_current = >>> + vq->avail->ring[(vq->last_used_idx) >> & >>> + (vq->size - 1)]; >>> + desc_chain_head = desc_current; >>> + desc = &vq->desc[desc_current]; >>> + desc_addr = gpa_to_vva(dev, desc->addr); >>> + if (unlikely(!desc_addr)) >>> + goto error; >>> >>> - desc = &vq->desc[desc->next]; >>> - desc_addr = gpa_to_vva(dev, desc->addr); >>> - if (unlikely(!desc_addr)) >>> - return -1; >>> - >>> - desc_offset = 0; >>> - desc_avail = desc->len; >>> + desc_chain_len = 0; >>> + desc_offset = 0; >> As I commented on v3, there is code duplication between next flag, and >> mrg buf cases: >> desc_offset = 0; >> >> and: >> >> desc = &vq->desc[desc_current]; >> desc_addr = gpa_to_vva(dev, desc->addr); >> if (unlikely(!desc_addr)) >> goto error; >> > > Do you mean to add something like: > > static inline int __attribute__((always_inline)) > get_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, > uint32_t desc_idx, struct vring_desc **desc, > uint64_t *desc_addr) > { > *desc = &vq->desc[desc_idx]; > *desc_addr = gpa_to_vva(dev, (*desc)->addr); > if (unlikely(!(*desc_addr))) > return -1; > > return 0; > } I meant, move this code after the if/else. You can do it in a function if it is done elsewhere in the file.