From patchwork Mon Mar 16 15:38:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Liu X-Patchwork-Id: 66688 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A9919A0559; Mon, 16 Mar 2020 09:02:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89D341C08D; Mon, 16 Mar 2020 09:02:02 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 3FCBC1C025; Mon, 16 Mar 2020 09:02:01 +0100 (CET) IronPort-SDR: 8usR0H/HjNP5JmrEutrKodj+sQ9RGwUfEj2lsLsMRawzVRI7NefG0sVYgWjcdcFe3EvulJraSi hfF9w5DmxnhA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2020 01:02:00 -0700 IronPort-SDR: 9scwgPXuBMHfxQmIPBPxulYndgIJ5hy3nXm2rLUkuHTzcrCNnEcIvSKBseKv72im7pGFHEwa1v mGMi3NJVkM2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,559,1574150400"; d="scan'208";a="417056899" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.58]) by orsmga005.jf.intel.com with ESMTP; 16 Mar 2020 01:01:56 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com Cc: dev@dpdk.org, stable@dpdk.org, Marvin Liu Date: Mon, 16 Mar 2020 23:38:22 +0800 Message-Id: <20200316153822.113182-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] vhost: fix packed ring zero-copy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Available buffer ID should be stored in the zmbuf in the packed-ring dequeue path. There's no guarantee that local queue avail index is equal to buffer ID. Fixes: d1eafb532268 ("vhost: add packed ring zcopy batch and single dequeue") Cc: stable@dpdk.org Signed-off-by: Marvin Liu Reported-by: Yinan Wang Reviewed-by: Maxime Coquelin Tested-by: Xiao, QimaiX diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 37c47c7dc..210415904 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -2004,7 +2004,7 @@ virtio_dev_tx_batch_packed_zmbuf(struct virtio_net *dev, vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { zmbufs[i]->mbuf = pkts[i]; - zmbufs[i]->desc_idx = avail_idx + i; + zmbufs[i]->desc_idx = ids[i]; zmbufs[i]->desc_count = 1; } @@ -2045,7 +2045,7 @@ virtio_dev_tx_single_packed_zmbuf(struct virtio_net *dev, return -1; } zmbuf->mbuf = *pkts; - zmbuf->desc_idx = vq->last_avail_idx; + zmbuf->desc_idx = buf_id; zmbuf->desc_count = desc_count; rte_mbuf_refcnt_update(*pkts, 1);