From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D96B6282 for ; Wed, 10 Dec 2014 13:12:02 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 10 Dec 2014 04:11:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,552,1413270000"; d="scan'208";a="645407249" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2014 04:11:57 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sBACBpHh006081; Wed, 10 Dec 2014 20:11:51 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sBACBnAx001944; Wed, 10 Dec 2014 20:11:51 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sBACBnfU001940; Wed, 10 Dec 2014 20:11:49 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Wed, 10 Dec 2014 20:11:47 +0800 Message-Id: <1418213507-1911-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 Subject: [dpdk-dev] [PATCH] examples/vhost: Fix data len issue 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: Wed, 10 Dec 2014 12:12:03 -0000 Search the right segment to increase its data length, rather than wrongly early return and exit the tx function, which leads to drop all jumbo frame packets when vm2vm is in hard forward mode. Signed-off-by: Changchun Ouyang --- examples/vhost/main.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 1f1edbe..12fa4ce 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1127,9 +1127,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) return; } - if (vm2vm_mode == VM2VM_HARDWARE) { - if (find_local_dest(dev, m, &offset, &vlan_tag) != 0 || - offset > rte_pktmbuf_tailroom(m)) { + if (unlikely(vm2vm_mode == VM2VM_HARDWARE)) { + if (unlikely(find_local_dest(dev, m, &offset, &vlan_tag) != 0)) { rte_pktmbuf_free(m); return; } @@ -1143,8 +1142,24 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) m->ol_flags = PKT_TX_VLAN_PKT; - m->data_len += offset; - m->pkt_len += offset; + /* + * Find the right seg to adjust the data len when offset is + * bigger than tail room size. + */ + if (unlikely(vm2vm_mode == VM2VM_HARDWARE)) { + if (likely(offset <= rte_pktmbuf_tailroom(m))) + m->data_len += offset; + else { + struct rte_mbuf *seg = m; + + while ((seg->next != NULL) && + (offset > rte_pktmbuf_tailroom(seg))) + seg = seg->next; + + seg->data_len += offset; + } + m->pkt_len += offset; + } m->vlan_tci = vlan_tag; -- 1.8.4.2