X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvhost%2Fmain.c;h=291128e0365adb18ad865f2540f46a62ff4e55f5;hb=a981294b29a39c2781c2fad9356323fa4234a6ad;hp=8517fd3924eef6d7a661b8adc66d3b9b90dba8e7;hpb=b5967c1fe58911ab4f353094c37b0823984570a0;p=dpdk.git diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 8517fd3924..291128e036 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -166,7 +166,7 @@ static uint32_t num_switching_cores = 0; /* number of devices/queues to support*/ static uint32_t num_queues = 0; -uint32_t num_devices = 0; +static uint32_t num_devices; /* * Enable zero copy, pkts buffer will directly dma to hw descriptor, @@ -984,7 +984,7 @@ unlink_vmdq(struct vhost_dev *vdev) * 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. */ -static inline unsigned __attribute__((always_inline)) +static inline int __attribute__((always_inline)) virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) { struct virtio_net_data_ll *dev_ll; @@ -1013,7 +1013,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) LOG_DEBUG(VHOST_DATA, "(%"PRIu64") TX: MAC address is local\n", tdev->device_fh); - if (dev_ll->vdev->remove) { + if (unlikely(dev_ll->vdev->remove)) { /*drop the packet if the device is marked for removal*/ LOG_DEBUG(VHOST_DATA, "(%"PRIu64") Device is marked for removal\n", tdev->device_fh); } else { @@ -1211,7 +1211,7 @@ switch_worker(__attribute__((unused)) void *arg) vdev = dev_ll->vdev; dev = vdev->dev; - if (vdev->remove) { + if (unlikely(vdev->remove)) { dev_ll = dev_ll->next; unlink_vmdq(vdev); vdev->ready = DEVICE_SAFE_REMOVE; @@ -1250,7 +1250,7 @@ switch_worker(__attribute__((unused)) void *arg) } } - if (!vdev->remove) { + if (likely(!vdev->remove)) { /* Handle guest TX*/ tx_count = rte_vhost_dequeue_burst(dev, VIRTIO_TXQ, mbuf_pool, pkts_burst, MAX_PKT_BURST); /* If this is the first received packet we need to learn the MAC and setup VMDQ */ @@ -2702,8 +2702,7 @@ new_device (struct virtio_net *dev) } } /* Add device to lcore ll */ - ll_dev->dev->coreid = core_add; - ll_dev = get_data_ll_free_entry(&lcore_info[ll_dev->dev->coreid].lcore_ll->ll_root_free); + ll_dev = get_data_ll_free_entry(&lcore_info[core_add].lcore_ll->ll_root_free); if (ll_dev == NULL) { RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Failed to add device to data core\n", dev->device_fh); vdev->ready = DEVICE_SAFE_REMOVE; @@ -2716,7 +2715,7 @@ new_device (struct virtio_net *dev) ll_dev->vdev = vdev; vdev->coreid = core_add; - add_data_ll_entry(&lcore_info[ll_dev->dev->coreid].lcore_ll->ll_root_used, ll_dev); + add_data_ll_entry(&lcore_info[vdev->coreid].lcore_ll->ll_root_used, ll_dev); /* Initialize device stats */ memset(&dev_statistics[dev->device_fh], 0, sizeof(struct device_statistics));