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 A4C8A2A9 for ; Thu, 30 Oct 2014 09:51:20 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 30 Oct 2014 02:00:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="408377990" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 30 Oct 2014 01:52:00 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9U9067D003577; Thu, 30 Oct 2014 17:00:06 +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 s9U904Cx010378; Thu, 30 Oct 2014 17:00:06 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9U903Yx010374; Thu, 30 Oct 2014 17:00:03 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Thu, 30 Oct 2014 17:00:02 +0800 Message-Id: <1414659602-10115-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 Subject: [dpdk-dev] [PATCH] vhost: Fix packet length 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: Thu, 30 Oct 2014 08:51:21 -0000 As HW vlan strip will reduce the packet length by minus length of vlan tag, so it need restore the packet length by plus it. Signed-off-by: Changchun Ouyang --- examples/vhost/main.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 0566124..dc32fa9 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -1067,6 +1067,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) { struct mbuf_table *tx_q; struct rte_mbuf **m_table; + struct rte_mbuf *last_seg = m; unsigned len, ret, offset = 0; const uint16_t lcore_id = rte_lcore_id(); struct virtio_net_data_ll *dev_ll = ll_root_used; @@ -1097,7 +1098,13 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) rte_pktmbuf_free(m); return; } - offset = 4; + + /* + * HW vlan strip will reduce the packet length + * by minus length of vlan tag, so need restore + * the packet length by plus it. + */ + offset = VLAN_HLEN; vlan_tag = (uint16_t) vlan_tags[(uint16_t)dev_ll->vdev->dev->device_fh]; @@ -1121,8 +1128,12 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) len = tx_q->len; m->ol_flags = PKT_TX_VLAN_PKT; - /*FIXME: offset*/ - m->data_len += offset; + + while (last_seg->next) + last_seg = last_seg->next; + last_seg->data_len += offset; + m->pkt_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m; -- 1.8.4.2