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 2767B37AA for ; Tue, 26 Apr 2016 06:43:44 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 25 Apr 2016 21:43:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,535,1455004800"; d="scan'208";a="940170664" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by orsmga001.jf.intel.com with ESMTP; 25 Apr 2016 21:43:43 -0700 From: Yuanhan Liu To: dev@dpdk.org Cc: huawei.xie@intel.com, Yuanhan Liu , "Xu, Qian Q" Date: Mon, 25 Apr 2016 21:45:49 -0700 Message-Id: <1461645951-14603-6-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1461645951-14603-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1461645951-14603-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-dev] [PATCH 5/7] examples/vhost: handle broadcast packet 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: Tue, 26 Apr 2016 04:43:44 -0000 Every time I do a VM2VM iperf test with vhost example, I have to set the arp table manually, as vhost-switch just ignores the broadcast packet, leaving the ARP request not served. Here we do a transmit a broadcast packet (such as ARP request) to every vhost device, as well as the physical port, to fix above arp table issue. Cc: "Xu, Qian Q" Signed-off-by: Yuanhan Liu --- examples/vhost/main.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 6cc34b7..16ba216 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -833,6 +833,21 @@ unlink_vmdq(struct vhost_dev *vdev) } } +static inline void __attribute__((always_inline)) +virtio_xmit(struct virtio_net *dst_dev, struct virtio_net *src_dev, + struct rte_mbuf *m) +{ + uint16_t ret; + + ret = rte_vhost_enqueue_burst(dst_dev, VIRTIO_RXQ, &m, 1); + if (enable_stats) { + rte_atomic64_inc(&dev_statistics[dst_dev->device_fh].rx_total_atomic); + rte_atomic64_add(&dev_statistics[dst_dev->device_fh].rx_atomic, ret); + dev_statistics[src_dev->device_fh].tx_total++; + dev_statistics[src_dev->device_fh].tx += ret; + } +} + /* * Check if the packet destination MAC address is for a local device. If so then put * the packet on that devices RX queue. If not then return. @@ -841,7 +856,6 @@ static inline int __attribute__((always_inline)) virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) { struct ether_hdr *pkt_hdr; - uint64_t ret = 0; struct virtio_net *dev = vdev->dev; struct virtio_net *tdev; /* destination virito device */ struct vhost_dev *vdev2; @@ -872,15 +886,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) return 0; } - /* send the packet to the local virtio device */ - ret = rte_vhost_enqueue_burst(tdev, VIRTIO_RXQ, &m, 1); - if (enable_stats) { - rte_atomic64_inc(&dev_statistics[fh].rx_total_atomic); - rte_atomic64_add(&dev_statistics[fh].rx_atomic, ret); - dev_statistics[vdev->dev->device_fh].tx_total++; - dev_statistics[vdev->dev->device_fh].tx += ret; - } - + virtio_xmit(tdev, vdev->dev, m); return 0; } @@ -964,6 +970,17 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) struct virtio_net *dev = vdev->dev; struct ether_hdr *nh; + + nh = rte_pktmbuf_mtod(m, struct ether_hdr *); + if (unlikely(is_broadcast_ether_addr(&nh->d_addr))) { + struct vhost_dev *vdev2; + + TAILQ_FOREACH(vdev2, &vhost_dev_list, next) { + virtio_xmit(vdev2->dev, vdev->dev, m); + } + goto queue2nic; + } + /*check if destination is local VM*/ if ((vm2vm_mode == VM2VM_SOFTWARE) && (virtio_tx_local(vdev, m) == 0)) { rte_pktmbuf_free(m); @@ -980,6 +997,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag) RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") TX: " "MAC address is external\n", dev->device_fh); +queue2nic: + /*Add packet to the port tx queue*/ tx_q = &lcore_tx_queue[lcore_id]; len = tx_q->len; -- 1.9.0