Esempio n. 1
0
uint16_t
rte_vhost_enqueue_burst(struct virtio_net *dev, uint16_t queue_id,
	struct rte_mbuf **pkts, uint16_t count)
{
	if (unlikely(dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)))
		return virtio_dev_merge_rx(dev, queue_id, pkts, count);
	else
		return virtio_dev_rx(dev, queue_id, pkts, count);
}
Esempio n. 2
0
virtio_tx_local(struct virtio_net *dev, struct rte_mbuf *m)
{
	struct virtio_net_data_ll *dev_ll;
	struct ether_hdr *pkt_hdr;
	uint64_t ret = 0;

	pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);

	/*get the used devices list*/
	dev_ll = ll_root_used;

	while (dev_ll != NULL) {
		if (likely(dev_ll->dev->ready == DEVICE_READY) && ether_addr_cmp(&(pkt_hdr->d_addr),
				          &dev_ll->dev->mac_address)) {

			/* Drop the packet if the TX packet is destined for the TX device. */
			if (dev_ll->dev->device_fh == dev->device_fh) {
				RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") TX: "
					"Source and destination MAC addresses are the same. "
					"Dropping packet.\n",
					dev_ll->dev->device_fh);
				return 0;
			}


			RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") TX: "
				"MAC address is local\n", dev_ll->dev->device_fh);

			if (dev_ll->dev->remove) {
				/*drop the packet if the device is marked for removal*/
				RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") "
					"Device is marked for removal\n",
					dev_ll->dev->device_fh);
			} else {
				/*send the packet to the local virtio device*/
				ret = virtio_dev_rx(dev_ll->dev, &m, 1);
				if (enable_stats) {
					rte_atomic64_add(&dev_statistics[dev_ll->dev->device_fh].rx_total, 1);
					rte_atomic64_add(&dev_statistics[dev_ll->dev->device_fh].rx, ret);
					dev_statistics[dev->device_fh].tx_total++;
					dev_statistics[dev->device_fh].tx += ret;
				}
			}

			return 0;
		}
		dev_ll = dev_ll->next;
	}

	return -1;
}