MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_vhost_clear_queue

Function rte_vhost_clear_queue

dpdk/lib/vhost/virtio_net.c:2463–2522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2461}
2462
2463uint16_t
2464rte_vhost_clear_queue(int vid, uint16_t queue_id, struct rte_mbuf **pkts,
2465 uint16_t count, int16_t dma_id, uint16_t vchan_id)
2466{
2467 struct virtio_net *dev = get_device(vid);
2468 struct vhost_virtqueue *vq;
2469 uint16_t n_pkts_cpl = 0;
2470
2471 if (!dev)
2472 return 0;
2473
2474 VHOST_LOG_DATA(dev->ifname, DEBUG, "%s\n", __func__);
2475 if (unlikely(queue_id >= dev->nr_vring)) {
2476 VHOST_LOG_DATA(dev->ifname, ERR, "%s: invalid virtqueue idx %u.\n",
2477 __func__, queue_id);
2478 return 0;
2479 }
2480
2481 if (unlikely(dma_id < 0 || dma_id >= RTE_DMADEV_DEFAULT_MAX)) {
2482 VHOST_LOG_DATA(dev->ifname, ERR, "%s: invalid dma id %d.\n",
2483 __func__, dma_id);
2484 return 0;
2485 }
2486
2487 vq = dev->virtqueue[queue_id];
2488
2489 if (rte_rwlock_read_trylock(&vq->access_lock)) {
2490 VHOST_LOG_DATA(dev->ifname, DEBUG, "%s: virtqueue %u is busy.\n",
2491 __func__, queue_id);
2492 return 0;
2493 }
2494
2495 if (unlikely(!vq->async)) {
2496 VHOST_LOG_DATA(dev->ifname, ERR, "%s: async not registered for queue id %u.\n",
2497 __func__, queue_id);
2498 goto out_access_unlock;
2499 }
2500
2501 if (unlikely(!dma_copy_track[dma_id].vchans ||
2502 !dma_copy_track[dma_id].vchans[vchan_id].pkts_cmpl_flag_addr)) {
2503 VHOST_LOG_DATA(dev->ifname, ERR, "%s: invalid channel %d:%u.\n",
2504 __func__, dma_id, vchan_id);
2505 goto out_access_unlock;
2506 }
2507
2508 if ((queue_id & 1) == 0)
2509 n_pkts_cpl = vhost_poll_enqueue_completed(dev, vq, pkts, count,
2510 dma_id, vchan_id);
2511 else
2512 n_pkts_cpl = async_poll_dequeue_completed(dev, vq, pkts, count,
2513 dma_id, vchan_id, dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS);
2514
2515 vhost_queue_stats_update(dev, vq, pkts, n_pkts_cpl);
2516 vq->stats.inflight_completed += n_pkts_cpl;
2517
2518out_access_unlock:
2519 rte_rwlock_read_unlock(&vq->access_lock);
2520

Callers 1

vhost_clear_queueFunction · 0.85

Calls 4

get_deviceFunction · 0.85
vhost_queue_stats_updateFunction · 0.85

Tested by

no test coverage detected