From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26CF1A04DB; Thu, 15 Oct 2020 07:53:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 926FB1DC5A; Thu, 15 Oct 2020 07:53:07 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0356B1D9C8; Thu, 15 Oct 2020 07:53:04 +0200 (CEST) IronPort-SDR: kpwKHNX/f08adqS+id3nRl+khalMwOtv1BKVnsT0jpki7C75Ea2PJM/WIYWCOZN/L1dl6SuJ0Y YRa0NK/R63Rg== X-IronPort-AV: E=McAfee;i="6000,8403,9774"; a="153202375" X-IronPort-AV: E=Sophos;i="5.77,377,1596524400"; d="scan'208";a="153202375" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Oct 2020 22:53:02 -0700 IronPort-SDR: cAR6s7+eJh9qVQsvzQlBtfoxNednM98A6dvCK+CHwwdqPws8OCHOMURR7FxnRIcm3C4ZAoWOS8 TOaPfWQl3MLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,377,1596524400"; d="scan'208";a="357601284" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.56]) by orsmga007.jf.intel.com with ESMTP; 14 Oct 2020 22:53:01 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com, zhihong.wang@intel.com Cc: dev@dpdk.org, Marvin Liu , stable@dpdk.org Date: Thu, 15 Oct 2020 13:46:07 +0800 Message-Id: <20201015054607.57325-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/virtio: fix invalid indirect desc length 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" When transmitting indirect descriptors, first desc will store net_hdr and following descs will be mapped to mbuf segments. Total desc number will be seg_num plus one. Meaning of variable needed is the number of used descs in packed ring. This value will always be two for indirect desc. Now use mbuf segments number for calculating correct desc length. Fixes: de8b3d238074 ("net/virtio: fix indirect descs in packed datapaths") Cc: stable@dpdk.org Signed-off-by: Marvin Liu diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h index 8c8ab9889..42c4c9882 100644 --- a/drivers/net/virtio/virtqueue.h +++ b/drivers/net/virtio/virtqueue.h @@ -698,6 +698,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, struct virtio_net_hdr *hdr; uint16_t prev; bool prepend_header = false; + uint16_t seg_num = cookie->nb_segs; id = in_order ? vq->vq_avail_idx : vq->vq_desc_head_idx; @@ -732,7 +733,7 @@ virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie, */ start_dp[idx].addr = txvq->virtio_net_hdr_mem + RTE_PTR_DIFF(&txr[idx].tx_packed_indir, txr); - start_dp[idx].len = (needed + 1) * + start_dp[idx].len = (seg_num + 1) * sizeof(struct vring_packed_desc); /* reset flags for indirect desc */ head_flags = VRING_DESC_F_INDIRECT; -- 2.17.1